| '; echo strip_tags($redux_builder_amp['amp-notification-text'],$allowed_tags); ?>
';
$output .= '';
$output .= '';
$output .= '';
$output .= '';
$output .= '';
$output .= ''.esc_attr($redux_builder_amp['ampforwp-ads-sponsorship-label']).'';
}
}
// Ads Optimize For Viewability
if( !function_exists('ampforwp_ad_optimize')){
function ampforwp_ad_optimize(){
global $redux_builder_amp;
$optimized_code = '';
if( isset( $redux_builder_amp['ampforwp-ads-data-loading-strategy'] ) && true == $redux_builder_amp['ampforwp-ads-data-loading-strategy']){
$optimized_code = 'data-loading-strategy="prefer-viewability-over-views"';
}
return $optimized_code;
}
}
// 10. Analytics Area
add_action('amp_post_template_footer','ampforwp_analytics',11);
function ampforwp_analytics() {
// 10.1 Analytics Support added for Google Analytics
global $redux_builder_amp;
if( false == $redux_builder_amp['amp-use-gtm-option'] ) {
if ( true == $redux_builder_amp['ampforwp-ga-switch'] ){
$ga_fields = array();
$ampforwp_ga_fields = array();
$ga_account = '';
$ga_account = $redux_builder_amp['ga-feild'];
$ga_account = str_replace(' ', '', $ga_account);
$ga_fields = array(
'vars'=>array(
'account'=>$ga_account,
),
'triggers'=> array(
'trackPageview'=> array(
'on'=>'visible',
'request'=>'pageview'
)
)
);
if ( isset($redux_builder_amp['ampforwp-ga-field-anonymizeIP']) && true == $redux_builder_amp['ampforwp-ga-field-anonymizeIP'] ) {
$ga_fields['vars']['anonymizeIP'] = 'set';
}
$ampforwp_ga_fields = json_encode( $ga_fields);
$ampforwp_ga_fields = apply_filters('ampforwp_advance_google_analytics', $ampforwp_ga_fields ); ?>
data-block-on-consent type="googleanalytics" id="analytics1">
data-block-on-consent type="segment">
data-block-on-consent src="">
data-block-on-consent type="quantcast">
data-block-on-consent type="comscore">
data-block-on-consent src="" />
data-block-on-consent src="" >
data-block-on-consent src="//sstatic1.histats.com/0.gif?&101" >
data-block-on-consent type="metrika">
data-block-on-consent type="chartbeat">
data-block-on-consent type="alexametrics">
99999)
$afs_server = 'www1';
if ($afs_account > 199999)
$afs_server = 'www2';
if ($afs_account > 299999)
$afs_server = 'www3';
if ($afs_account > 399999)
$afs_server = 'www4';
if ($afs_account > 499999)
$afs_server = 'www5';
if ($afs_account > 599999)
$afs_server = 'www6';
if ($afs_account > 699999)
$afs_server = 'www7';
if ($afs_account > 799999)
$afs_server = 'www8';
if ($afs_account > 899999)
$afs_server = 'www9';
if ($afs_account > 999999)
$afs_server = 'www10'; ?>
data-block-on-consent type="afsanalytics">
]*/', '', $content);
$content = preg_replace('/vocab=[^>]*/', '', $content);
$content = preg_replace('/(<[^>]+) value=[^>]*/', '$1', $content);
$content = preg_replace('/noshade=[^>]*/', '', $content);
$content = preg_replace('/contenteditable=[^>]*/', '', $content);
$content = preg_replace('/non-refundable=[^>]*/', '', $content);
$content = preg_replace('/security=[^>]*/', '', $content);
$content = preg_replace('/deposit=[^>]*/', '', $content);
$content = preg_replace('/for=[^>]*/', '', $content);
$content = preg_replace('/nowrap="nowrap"/', '', $content);
$content = preg_replace('#(.*?)#i', '', $content);
$content = preg_replace('#(.*?)#i', '', $content);
$content = preg_replace('#(.*?)#i', '', $content);
$content = preg_replace('##i', '', $content);
//Removed because class is being removed from table #2699
$content = preg_replace('/href="javascript:void*/', ' ', $content);
// Convert the Wistia embed into URL to build amp-wistia-player and remove unnecesarry wistia code
$content = preg_replace('/
';
}
return $output;
}
}
//AMP to WP Theme Analytics
add_action('wp_footer','ampforwp_nonamp_analytics');
if ( ! function_exists('ampforwp_nonamp_analytics') ) {
function ampforwp_nonamp_analytics() {
global $redux_builder_amp;
$ga_account = $redux_builder_amp['ga-feild'];
if ( ampforwp_is_non_amp("non_amp_check_convert") ) {
echo "
";
}
}
}
// Coauthors Compatibility #1895
add_filter('coauthors_posts_link', 'ampforwp_coauthors_links');
function ampforwp_coauthors_links($args){
global $redux_builder_amp;
if ( function_exists('ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() && true == $redux_builder_amp['ampforwp-archive-support']) {
$args['href'] = ampforwp_url_controller($args['href']);
}
return $args;
}
// amp-image-lightbox #1892
if ( ! function_exists('ampforwp_amp_img_lightbox') ) {
function ampforwp_amp_img_lightbox(){
echo '';
}
}
// New Image attributes for amp-image-lightbox #1892
add_filter('amp_img_attributes', 'ampforwp_img_new_attrs');
function ampforwp_img_new_attrs($attributes) {
global $redux_builder_amp;
if ( isset($redux_builder_amp['ampforwp-amp-img-lightbox']) && $redux_builder_amp['ampforwp-amp-img-lightbox'] ) {
$attributes['on'] = 'tap:amp-img-lightbox';
$attributes['role'] = 'button';
$attributes['tabindex'] = '0';
}
return $attributes;
}
// Facebook Comments script for AMP2WP
add_action('ampforwp_body_beginning', 'ampforwp_amp2wp_fb');
if ( ! function_exists('ampforwp_amp2wp_fb') ) {
function ampforwp_amp2wp_fb(){
global $redux_builder_amp;
if( ampforwp_is_non_amp() && isset($redux_builder_amp['ampforwp-amp-convert-to-wp']) && $redux_builder_amp['ampforwp-amp-convert-to-wp'] && ($redux_builder_amp['ampforwp-facebook-comments-support'] || $redux_builder_amp['ampforwp-facebook-like-button']) ) {
echo '
';
}
}
}
// Backward Compatibility
function ampforwp_correct_frontpage() {
return ampforwp_get_frontpage_id();
}
//Common function to get frontpageID
function ampforwp_get_frontpage_id() {
global $redux_builder_amp;
$post_id = '';
//$post_id = get_the_ID();
if ( ampforwp_is_front_page() && $redux_builder_amp['amp-frontpage-select-option']==1
&& isset( $redux_builder_amp['amp-frontpage-select-option-pages'] )
) {
$post_id = $redux_builder_amp['amp-frontpage-select-option-pages'];
}
$post_id = apply_filters('ampforwp_modify_frontpage_id', $post_id);
return $post_id;
}
// Removing AMPHTML Added by Facebook's Instant Article's Plugin #2043
add_action( 'wp', 'ampforwp_remove_instant_articles_amp_markup' );
function ampforwp_remove_instant_articles_amp_markup(){
if(class_exists('Instant_Articles_AMP_Markup')){
remove_action( 'wp_head', array('Instant_Articles_AMP_Markup', 'inject_link_rel') );
}
}
// #2042
function ampforwp_404_canonical(){
global $wp;
return home_url( $wp->request );
}
// #2001 removing unused JS from the Paginated Posts
add_filter('ampforwp_post_content_filter', 'ampforwp_paginated_post_content');
function ampforwp_paginated_post_content($content){
global $numpages;
if(is_singular()){
if ( get_query_var( 'paged' ) ) {
$paged = get_query_var('paged');
} elseif ( get_query_var( 'page' ) ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
if( $numpages >= 2 ){
return get_the_content();
}
}
return $content;
}
// GDPR Compliancy #2040
add_action('amp_init', 'ampforwp_gdpr_init');
if ( ! function_exists('ampforwp_gdpr_init') ) {
function ampforwp_gdpr_init() {
if ( ampforwp_get_setting('amp-gdpr-compliance-switch') ) {
// gdpr component
add_action('amp_footer_link' , 'amp_gdpr' );
}
}
}
// #1696
add_action('wp','ampforwp_remove_squirly_js');
function ampforwp_remove_squirly_js(){
if(function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint()){
if(class_exists('SQ_Classes_ObjController')){
$SQ_Classes_ObjController = new SQ_Classes_ObjController();
$sq_analytics_class_obj = $SQ_Classes_ObjController::getClass('SQ_Models_Services_Analytics');
}
}
}
// Thrive Leads Compatibility #2067
add_filter('thrive_leads_skip_request', 'ampforwp_skip_thrive_leads');
if ( ! function_exists('ampforwp_skip_thrive_leads') ) {
function ampforwp_skip_thrive_leads($skip) {
// Skip thrive leads on AMP
if ( function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() ) {
return true;
}
return $skip;
}
}
// Re-save permalink once the post value changed in Redading Settings #2190
add_action( 'update_option', 'ampforwp_resave_permalink', 10, 3 );
function ampforwp_resave_permalink( $option, $old_value, $value ){
if('posts_per_page' === $option){
if($old_value != $value){
delete_transient( 'ampforwp_current_version_check' );
}
}
}
// Canonical From Yoast #2118 and All in One SEO #1720
function ampforwp_generate_canonical(){
global $redux_builder_amp;
$canonical = '';
$canonical = $WPSEO_Frontend = $All_in_One_SEO_Pack = $opts = '';
if ( isset($redux_builder_amp['ampforwp-seo-yoast-canonical']) && true == $redux_builder_amp['ampforwp-seo-yoast-canonical'] && class_exists('WPSEO_Frontend') ) {
$WPSEO_Frontend = WPSEO_Frontend::get_instance();
$canonical = $WPSEO_Frontend->canonical(false);
}
elseif ( isset($redux_builder_amp['ampforwp-seo-aioseo-canonical']) && true == $redux_builder_amp['ampforwp-seo-aioseo-canonical'] && class_exists('All_in_One_SEO_Pack') ) {
$All_in_One_SEO_Pack = new All_in_One_SEO_Pack();
$opts = $All_in_One_SEO_Pack->get_current_options( array(), 'aiosp' );
$canonical = $opts['aiosp_custom_link'];
}
return $canonical;
}
add_filter('amp_post_template_data', 'ampforwp_modified_canonical', 85);
function ampforwp_modified_canonical( $data ) {
$canonical = '';
$canonical = ampforwp_generate_canonical();
if ( !empty($canonical) ) {
$data['canonical_url'] = $canonical;
}
return $data;
}
function ampforwp_get_data_consent(){
global $redux_builder_amp;
$dboc = false;
$is_dboc = '';
if(isset($redux_builder_amp['amp-gdpr-compliance-switch']) && $redux_builder_amp['amp-gdpr-compliance-switch'] ){
$dboc = true;
}
return $dboc;
}
function ampforwp_amp_consent_check($attrs){
if( ampforwp_get_data_consent() ){
$attrs['data-block-on-consent'] = '';
}
$attrs = apply_filters( 'ampforwp_embedd_attrs_handler', $attrs );
return $attrs;
}
// #2220 Remove Space Shortcode by Pro Theme from THEMCO
add_action('pre_amp_render_post','ampforwp_remove_space_shortcodes');
function ampforwp_remove_space_shortcodes(){
add_filter('the_content','ampforwp_remove_pro_theme_space_shortcodes');
}
function ampforwp_remove_pro_theme_space_shortcodes($content){
if(has_shortcode( $content, 'gap' )){
remove_shortcode( 'gap' );
// to remove the useless shortcode from the AMP Content
add_shortcode( 'gap', 'ampforwp_return_no_gap' );
}
return $content;
}
function ampforwp_return_no_gap(){
return;
}
/*
#2229 Function to check the option for comments to display on post, page or both.
*/
function ampforwp_get_comments_status(){
global $redux_builder_amp;
$display_comments_on = "";
if ( (isset($redux_builder_amp['ampforwp-display-on-pages']) && $redux_builder_amp['ampforwp-display-on-pages']==false ) && (isset($redux_builder_amp['ampforwp-display-on-posts']) && $redux_builder_amp['ampforwp-display-on-posts']==true ) ) {
$display_comments_on = is_single();
}
if ( (isset($redux_builder_amp['ampforwp-display-on-pages']) && $redux_builder_amp['ampforwp-display-on-pages']==true ) && (isset($redux_builder_amp['ampforwp-display-on-posts']) && $redux_builder_amp['ampforwp-display-on-posts']==false ) ) {
$display_comments_on = is_page();
}
if ( (isset($redux_builder_amp['ampforwp-display-on-pages']) && $redux_builder_amp['ampforwp-display-on-pages']==true ) && (isset($redux_builder_amp['ampforwp-display-on-posts']) && $redux_builder_amp['ampforwp-display-on-posts']==true ) ) {
$display_comments_on = is_singular();
}
$display_comments_on = apply_filters('ampforwp_comments_visibility', $display_comments_on);
return $display_comments_on;
}
// Vuukle Comments Support #2075
add_action('ampforwp_post_after_design_elements','ampforwp_vuukle_comments_support');
function ampforwp_vuukle_comments_support() {
global $redux_builder_amp;
if ( 4 != $redux_builder_amp['amp-design-selector']
&& isset($redux_builder_amp['ampforwp-vuukle-comments-support'])
&& $redux_builder_amp['ampforwp-vuukle-comments-support']==1
&& comments_open()
) {
echo ampforwp_vuukle_comments_markup();
}
}
function ampforwp_vuukle_comments_markup() {
global $redux_builder_amp;
$apiKey = $locale = '';
if( isset($redux_builder_amp['ampforwp-vuukle-comments-apiKey']) && $redux_builder_amp['ampforwp-vuukle-comments-apiKey'] !== ""){
$apiKey = $redux_builder_amp['ampforwp-vuukle-comments-apiKey'];
}
$display_comments_on = false;
$display_comments_on = ampforwp_get_comments_status();
$siteUrl = trim(site_url(), '/');
if (!preg_match('#^http(s)?://#', $siteUrl)) {
$siteUrl = 'http://' . $siteUrl;
}
$urlParts = parse_url($siteUrl);
$siteUrl = preg_replace('/^www\./', '', $urlParts['host']);// remove www
$srcUrl = 'https://cdn.vuukle.com/amp.html?';
$srcUrl = add_query_arg('url' ,get_permalink(), $srcUrl);
$srcUrl = add_query_arg('host' ,$siteUrl, $srcUrl);
$srcUrl = add_query_arg('id' , $post->ID, $srcUrl);
$srcUrl = add_query_arg('apiKey' , $apiKey, $srcUrl);
$srcUrl = add_query_arg('title' , urlencode($post->post_title), $srcUrl);
$vuukle_html ='';
if ( $display_comments_on ) {
$vuukle_html .= '
Show comments ';
}
return $vuukle_html;
}
add_filter( 'amp_post_template_data', 'ampforwp_add_vuukle_scripts' );
function ampforwp_add_vuukle_scripts( $data ) {
global $redux_builder_amp;
$display_comments_on = "";
$display_comments_on = ampforwp_get_comments_status();
if ( ampforwp_get_setting('ampforwp-vuukle-comments-support') && $display_comments_on) {
if ( empty( $data['amp_component_scripts']['amp-iframe'] ) ) {
$data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js';
}
if ($redux_builder_amp['ampforwp-vuukle-Ads-before-comments']==1
&& empty( $data['amp_component_scripts']['amp-ad'] ) ) {
$data['amp_component_scripts']['amp-ad'] = 'https://cdn.ampproject.org/v0/amp-ad-0.1.js';
}
}
return $data;
}
//spotim #2076
add_action('ampforwp_post_after_design_elements','ampforwp_spotim_comments_support');
function ampforwp_spotim_comments_support() {
global $redux_builder_amp;
if ( 4 != $redux_builder_amp['amp-design-selector']
&& isset($redux_builder_amp['ampforwp-spotim-comments-support'])
&& $redux_builder_amp['ampforwp-spotim-comments-support']==1
) {
echo ampforwp_spotim_comments_markup();
}
}
function ampforwp_spotim_comments_markup() {
global $post, $redux_builder_amp;
$display_comments_on = false;
$display_comments_on = ampforwp_get_comments_status();
if (! $display_comments_on ) {
return '';
}
$spotId ='';
if( isset($redux_builder_amp['ampforwp-spotim-comments-apiKey']) && $redux_builder_amp['ampforwp-spotim-comments-apiKey'] !== ""){
$spotId = $redux_builder_amp['ampforwp-spotim-comments-apiKey'];
}
$srcUrl = 'https://amp.spot.im/production.html?';
$srcUrl = add_query_arg('spotId' ,get_permalink(), $srcUrl);
$srcUrl = add_query_arg('postId' , $post->ID, $srcUrl);
$spotim_html = '
Load more...
';
return $spotim_html;
}
//spotim script
add_filter( 'amp_post_template_data', 'ampforwp_add_spotim_scripts' );
function ampforwp_add_spotim_scripts( $data ) {
global $redux_builder_amp;
$display_comments_on = "";
$display_comments_on = ampforwp_get_comments_status();
if ( 4 != $redux_builder_amp['amp-design-selector']
&& isset($redux_builder_amp['ampforwp-spotim-comments-support'])
&& $redux_builder_amp['ampforwp-spotim-comments-support']
&& $display_comments_on && comments_open()
) {
if ( empty( $data['amp_component_scripts']['amp-iframe'] ) ) {
$data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js';
}
}
return $data;
}
//spotim css
add_action('amp_post_template_css','ampforwp_spotim_vuukle_styling',60);
function ampforwp_spotim_vuukle_styling(){
global $redux_builder_amp;
$display_comments_on = "";
$display_comments_on = ampforwp_get_comments_status();
if ( isset($redux_builder_amp['ampforwp-spotim-comments-support'])
&& $redux_builder_amp['ampforwp-spotim-comments-support']
&& $display_comments_on && comments_open() ) {
?>.spot-im-amp-overflow {
background: white;
font-size: 15px;
padding: 15px 0;
text-align: center;
font-family: Helvetica, Arial, sans-serif;
color: #307fe2;
}
.afwp-vuukle-support{
display: block;text-align: center;background: #1f87e5;color: #fff;border-radius: 4px;
} ';
}
// Function to check if the query and the post name are same #2361
function ampforwp_is_query_post_same($haystack = '' , $needle = ''){
$result = '';
if(!empty($haystack) && !empty($needle)){
$result = strpos($haystack ,$needle);
}
if( ($result != false || is_int($result)) && !empty($result) ){
return true;
}
return false;
}
// rel="next" & rel="prev" pagination meta tags #2343
add_action( 'amp_post_template_head', 'ampforwp_rel_next_prev' );
function ampforwp_rel_next_prev(){
global $paged;
if ( get_previous_posts_link() ) { ?>
' . $content . '';
$content = $content . '';
$content = $content . '';
return $content;
}
// Content Sneak Peek Scripts css
function ampforwp_sneak_peek_css(){
global $redux_builder_amp;
$height = $txt_color = $btn_color = '';
$height = $redux_builder_amp['content-sneak-peek-height'];
$btn_color = $redux_builder_amp['content-sneak-peek-btn-color']['color'];
$txt_color = $redux_builder_amp['content-sneak-peek-txt-color']['color'];?>
.fd-h{height: ;overflow: hidden;}
.fd-b-c{text-align: center;}
.fd-b-c .fd-b {border: 1px solid #93abbc;border-radius: 5px;color: ;font-size: 16px;font-weight: 700;line-height: 24px;padding: 8px 5px;width: 250px;background-color: ; }
array(),
'AMP_Blacklist_Sanitizer' => array(),
'AMP_Style_Sanitizer' => array(),
'AMP_Video_Sanitizer' => array(),
'AMP_Audio_Sanitizer' => array(),
'AMP_Iframe_Sanitizer' => array(
'add_placeholder' => true,
),
)
)
);
$content = $sanitizer_obj->get_amp_content();
return $content;
}
// Instant Articles Meta Box
add_action( 'add_meta_boxes', 'ampforwp_ia_meta_box' );
if ( ! function_exists('ampforwp_ia_meta_box') ) {
function ampforwp_ia_meta_box() {
global $redux_builder_amp, $post;
$user_level = '';
$user_level = current_user_can( 'manage_options' );
if ( isset( $redux_builder_amp['amp-meta-permissions'] ) && $redux_builder_amp['amp-meta-permissions'] == 'all' ) {
$user_level = true;
}
if ( $user_level ) {
if( true == $redux_builder_amp['fb-instant-article-switch'] && $post->post_type == 'post' ) {
add_meta_box( 'ampforwp_ia_meta', esc_html__( 'Show Instant Article for Current Post?','accelerated-mobile-pages' ), 'ampforwp_ia_meta_callback', 'post','side' );
}
}
}
}
// Callback function for Instant Articles Meta Box.
function ampforwp_ia_meta_callback( $post ) {
global $redux_builder_amp;
wp_nonce_field( basename( __FILE__ ), 'ampforwp_ia_nonce' );
$ampforwp_stored_meta = get_post_meta( $post->ID );
if ( ! isset($ampforwp_stored_meta['ampforwp-ia-on-off'][0]) || $ampforwp_stored_meta['ampforwp-ia-on-off'][0] == 'hide-ia') {
$exclude_post_value = get_option('ampforwp_ia_exclude_post');
if ( $exclude_post_value == null ) {
$exclude_post_value[] = 0;
}
if ( $exclude_post_value ) {
if ( ! in_array( $post->ID, $exclude_post_value ) ) {
$exclude_post_value[] = $post->ID;
update_option('ampforwp_ia_exclude_post', $exclude_post_value);
}
}
} else {
$exclude_post_value = get_option('ampforwp_ia_exclude_post');
if ( $exclude_post_value == null ) {
$exclude_post_value[] = 0;
}
if ( $exclude_post_value ) {
if ( in_array( $post->ID, $exclude_post_value ) ) {
$exclude_ids = array_diff($exclude_post_value, array($post->ID) );
update_option('ampforwp_ia_exclude_post', $exclude_ids);
}
}
} ?>
$value) {
$allowed_atts[$att] = true;
}
foreach ($allowed_amp_tags as $amp_tag => $values ) {
$allowed_amp_tags[$amp_tag] = $allowed_atts;
}
}
$allowed_html = array_merge_recursive($allowed_normal_html, $allowed_amp_tags);
if( $allowed_html ) {
foreach ( $allowed_html as $tag => $atts ) {
if ( is_array($atts) ){
unset($allowed_html[$tag]['style']);
}
if ( 'a' == $tag ) {
$allowed_html[$tag]['data-toggle'] = true;
}
if ( 'label' == $tag ) {
$allowed_html[$tag]['aria-label'] = true;
}
if ( 'amp-img' == $tag ) {
$allowed_html[$tag] = array('width'=>true,'height'=>true,'src'=>true,'layout'=>true,'alt'=>true,'on'=>true,'role'=>true,'tabindex'=>true);
}
}
$allowed_html['input'] = array('class'=>true,'type'=>true,'id'=>true,'placeholder'=>true,'value'=>true,'name'=>true);
}
return $allowed_html;
}
function ampforwp_wp_kses($data){
$allowed_html = ampforwp_wp_kses_allowed_html();
$data = wp_kses( stripslashes( $data ), $allowed_html );
return $data;
}
// Removing Marfeel plugin which was blocking internal pages of AMP #2423
add_action('wp','ampforwp_remove_marfeel',9);
function ampforwp_remove_marfeel(){
remove_action('wp', 'render_marfeel_amp_content' );
}
// Total Plus compatibility #2511
add_action('current_screen', 'ampforwp_totalplus_comp_admin');
function ampforwp_totalplus_comp_admin() {
$screen = get_current_screen();
if ( 'toplevel_page_amp_options' == $screen->base ) {
remove_action('admin_enqueue_scripts', 'total_plus_admin_scripts', 100);
}
}
// uploading the images with SVG format #2431
function ampforwp_upload_svg($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_action('upload_mimes', 'ampforwp_upload_svg'); |
|---|