'0.4.2' ) { return require AMPFORWP_PLUGIN_DIR .'templates/customizer/customizer-new.php' ; } else { return require AMPFORWP_PLUGIN_DIR .'templates/customizer/customizer.php' ; } } else { return require AMPFORWP_PLUGIN_DIR .'templates/customizer/customizer.php' ; } } ampforwp_include_customizer_files(); //0. define('AMPFORWP_COMMENTS_PER_PAGE', ampforwp_define_comments_number() ); // Define number of comments function ampforwp_define_comments_number(){ global $redux_builder_amp; $number_of_comments = ''; if(isset($redux_builder_amp['ampforwp-number-of-comments'])){ $number_of_comments = $redux_builder_amp['ampforwp-number-of-comments']; } return $number_of_comments; } // 1. Add Home REL canonical // Add AMP rel-canonical for home and archive pages add_action('amp_init','ampforwp_allow_homepage'); function ampforwp_allow_homepage() { add_action( 'wp', 'ampforwp_add_endpoint_actions' ); } function ampforwp_add_endpoint_actions() { $ampforwp_is_amp_endpoint = ampforwp_is_amp_endpoint(); if ( $ampforwp_is_amp_endpoint ) { amp_prepare_render(); } else { add_action( 'wp_head', 'ampforwp_home_archive_rel_canonical' ); } $cpage_var = get_query_var('cpage'); if ( $cpage_var >= 1) : remove_action( 'wp_head', 'ampforwp_home_archive_rel_canonical' ); endif; } function ampforwp_home_archive_rel_canonical() { global $redux_builder_amp; global $wp, $post; if( is_attachment() ) { return; } if( is_home() && !$redux_builder_amp['ampforwp-homepage-on-off-support'] ) { return; } if( is_front_page() && ! $redux_builder_amp['ampforwp-homepage-on-off-support'] ) { return; } if ( is_archive() && !$redux_builder_amp['ampforwp-archive-support'] ) { return; } // #1192 Password Protected posts exclusion if(post_password_required( $post )){ return; } // #872 no-amphtml if selected as hide from settings if(is_archive() && $redux_builder_amp['ampforwp-archive-support']){ $selected_cats = array(); $categories = get_the_category(); $category_id = $categories[0]->cat_ID; $get_categories_from_checkbox = $redux_builder_amp['hide-amp-categories']; // Check if $get_categories_from_checkbox has some cats then only show if ( $get_categories_from_checkbox ) { $get_selected_cats = array_filter($get_categories_from_checkbox); foreach ($get_selected_cats as $key => $value) { $selected_cats[] = $key; } if($selected_cats && $category_id){ if(in_array($category_id, $selected_cats)){ return; } } } } if( is_page() && !$redux_builder_amp['amp-on-off-for-all-pages'] ) { return; } $query_arg_array = $wp->query_vars; if( in_array( "cpage" , $query_arg_array ) ) { if( is_front_page() && $wp->query_vars['cpage'] >= '2' ) { return; } if( is_singular() && $wp->query_vars['cpage'] >= '2' ) { return; } } if ( is_home() || is_front_page() || is_archive() ){ global $wp; $current_archive_url = home_url( $wp->request ); $amp_url = trailingslashit($current_archive_url); } else { $amp_url = amp_get_permalink( get_queried_object_id() ); } global $post; $ampforwp_amp_post_on_off_meta = get_post_meta( get_the_ID(),'ampforwp-amp-on-off',true); if( is_singular() && $ampforwp_amp_post_on_off_meta === 'hide-amp' ) { //dont Echo anything } else { $supported_types = array('post','page'); $supported_types = apply_filters('get_amp_supported_post_types',$supported_types); $type = get_post_type(); $supported_amp_post_types = in_array( $type , $supported_types ); $query_arg_array = $wp->query_vars; if( array_key_exists( 'paged' , $query_arg_array ) ) { if ( (is_home() || is_archive()) && $wp->query_vars['paged'] >= '2' ) { $new_url = home_url('/'); $category_path = $wp->request; $explode_path = explode("/",$category_path); $inserted = array(AMPFORWP_AMP_QUERY_VAR); array_splice( $explode_path, -2, 0, $inserted ); $impode_url = implode('/', $explode_path); $amp_url = $new_url . $impode_url ; } if( is_search() && $wp->query_vars['paged'] >= '2' ) { $current_search_url =trailingslashit(get_home_url()) . $wp->request .'/'."?amp=1&s=".get_search_query(); } } $amp_url = user_trailingslashit($amp_url); if( is_search() ) { $current_search_url =trailingslashit(get_home_url())."?amp=1&s=".get_search_query(); $amp_url = untrailingslashit($current_search_url); } // WPML AMPHTML #1285 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if(is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' )){ Global $sitepress_settings; if($sitepress_settings[ 'language_negotiation_type' ] == 3){ $wpml_url =get_permalink( get_queried_object_id() ); $explode_url = explode('/', $wpml_url); $append_amp = 'amp'; array_splice( $explode_url, 5, 0, $append_amp ); $impode_url = implode('/', $explode_url); $amp_url = untrailingslashit($impode_url); } } $amp_url = ampforwp_url_purifier($amp_url); $amp_url = apply_filters('ampforwp_modify_rel_canonical',$amp_url); if( $supported_amp_post_types) { printf('', esc_url($amp_url)); } } } //end of ampforwp_home_archive_rel_canonical() // Remove default wordpress rel canonical add_filter('amp_frontend_show_canonical','ampforwp_remove_default_canonical'); if (! function_exists('ampforwp_remove_default_canonical') ) { function ampforwp_remove_default_canonical() { return false; } } // 2. Custom Design // Add Homepage AMP file code add_filter( 'amp_post_template_file', 'ampforwp_custom_template', 10, 3 ); function ampforwp_custom_template( $file, $type, $post ) { // Custom Homepage and Archive file global $redux_builder_amp; $slug = array(); $current_url_in_pieces = array(); $ampforwp_custom_post_page = ampforwp_custom_post_page(); // Homepage and FrontPage if ( is_home() ) { if ( 'single' === $type ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/index.php'; if ($redux_builder_amp['amp-frontpage-select-option'] == 1) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/frontpage.php'; } if ( $ampforwp_custom_post_page == "page" && ampforwp_name_blog_page() ) { $current_url = home_url( $GLOBALS['wp']->request ); $current_url_in_pieces = explode( '/', $current_url ); if( in_array( ampforwp_name_blog_page() , $current_url_in_pieces ) ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/index.php'; } } } } // Archive Pages if ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/archive.php'; } // Search pages if ( is_search() && ( $redux_builder_amp['amp-design-1-search-feature'] || $redux_builder_amp['amp-design-2-search-feature'] || $redux_builder_amp['amp-design-3-search-feature'] ) ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/search.php'; } // Custom Single file if ( is_single() || is_page() ) { if('single' === $type && !('product' === $post->post_type )) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/single.php'; } } return $file; } // 3. Custom Style files add_filter( 'amp_post_template_file', 'ampforwp_set_custom_style', 10, 3 ); function ampforwp_set_custom_style( $file, $type, $post ) { if ( 'style' === $type ) { $file = ''; } return $file; } //3.5 add_filter( 'amp_post_template_file', 'ampforwp_empty_filter', 10, 3 ); function ampforwp_empty_filter( $file, $type, $post ) { if ( 'empty-filter' === $type ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php'; } return $file; } // 4. Custom Header files add_filter( 'amp_post_template_file', 'ampforwp_custom_header', 10, 3 ); function ampforwp_custom_header( $file, $type, $post ) { if ( 'header-bar' === $type ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/header-bar.php'; } return $file; } // 4.1 Custom Meta-Author files add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_author', 10, 3 ); function ampforwp_set_custom_meta_author( $file, $type, $post ) { if ( 'meta-author' === $type ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php'; } return $file; } // 4.2 Custom Meta-Taxonomy files add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_taxonomy', 10, 3 ); function ampforwp_set_custom_meta_taxonomy( $file, $type, $post ) { if ( 'meta-taxonomy' === $type ) { $file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/empty-filter.php'; } return $file; } // 4.5 Added hook to add more layout. do_action('ampforwp_after_features_include'); // 5. Customize with Width of the site add_filter( 'amp_content_max_width', 'ampforwp_change_content_width' ); function ampforwp_change_content_width( $content_max_width ) { return 1000; } // 6. Add required Javascripts for extra AMP features // Code updated and added the JS proper way #336 add_filter('amp_post_template_data','ampforwp_add_amp_social_share_script', 20); function ampforwp_add_amp_social_share_script( $data ){ global $redux_builder_amp; if( $redux_builder_amp['enable-single-social-icons'] == true || defined('AMPFORWP_DM_SOCIAL_CHECK') && AMPFORWP_DM_SOCIAL_CHECK === 'true' ) { if( is_single() && is_socialshare_or_socialsticky_enabled_in_ampforwp() ) { if ( empty( $data['amp_component_scripts']['amp-social-share'] ) ) { $data['amp_component_scripts']['amp-social-share'] = 'https://cdn.ampproject.org/v0/amp-social-share-0.1.js'; } } } return $data; } // 6.1 Adding Analytics Scripts add_filter('amp_post_template_data','ampforwp_register_analytics_script', 20); function ampforwp_register_analytics_script( $data ){ global $redux_builder_amp; if( $redux_builder_amp['amp-analytics-select-option'] && $redux_builder_amp['amp-analytics-select-option'] != '3' && $redux_builder_amp['amp-analytics-select-option'] != '6' && $redux_builder_amp['amp-analytics-select-option'] != '7' && $redux_builder_amp['amp-analytics-select-option'] != '8'){ if ( empty( $data['amp_component_scripts']['amp-analytics'] ) ) { $data['amp_component_scripts']['amp-analytics'] = 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js'; } } return $data; } add_filter( 'amp_post_template_data', 'ampforwp_add_amp_related_scripts', 20 ); function ampforwp_add_amp_related_scripts( $data ) { global $redux_builder_amp; // Adding Sidebar Script if(isset($redux_builder_amp['ampforwp-amp-menu']) && $redux_builder_amp['ampforwp-amp-menu']){ if ( empty( $data['amp_component_scripts']['amp-sidebar'] ) ) { $data['amp_component_scripts']['amp-sidebar'] = 'https://cdn.ampproject.org/v0/amp-sidebar-0.1.js'; } } return $data; } // 7. Footer for AMP Pages add_filter( 'amp_post_template_file', 'ampforwp_custom_footer', 10, 3 ); function ampforwp_custom_footer( $file, $type, $post ) { if ( 'footer' === $type ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/footer.php'; } return $file; } add_action('ampforwp_global_after_footer','ampforwp_footer'); function ampforwp_footer() { global $redux_builder_amp; ?>

'; $output .= ''; $output .= ''; $output .= ' '; echo $output; } } // Above Footer Global add_action('amp_post_template_above_footer','ampforwp_footer_advert',10); function ampforwp_footer_advert() { global $redux_builder_amp; if($redux_builder_amp['enable-amp-ads-2'] == true) { if($redux_builder_amp['enable-amp-ads-select-2'] == 1) { $advert_width = '300'; $advert_height = '250'; } elseif ($redux_builder_amp['enable-amp-ads-select-2'] == 2) { $advert_width = '336'; $advert_height = '280'; } elseif ($redux_builder_amp['enable-amp-ads-select-2'] == 3) { $advert_width = '728'; $advert_height = '90'; } elseif ($redux_builder_amp['enable-amp-ads-select-2'] == 4) { $advert_width = '300'; $advert_height = '600'; } elseif ($redux_builder_amp['enable-amp-ads-select-2'] == 5) { $advert_width = '320'; $advert_height = '100'; } elseif ($redux_builder_amp['enable-amp-ads-select-2'] == 6) { $advert_width = '200'; $advert_height = '50'; } elseif ($redux_builder_amp['enable-amp-ads-select-2'] == 7) { $advert_width = '320'; $advert_height = '50'; } $output = '
'; $output .= ''; $output .= ''; $output .= '
'; echo $output; } } // Below Title Single add_action('ampforwp_before_post_content','ampforwp_before_post_content_advert'); add_action('ampforwp_inside_post_content_before','ampforwp_before_post_content_advert'); function ampforwp_before_post_content_advert() { global $redux_builder_amp; if($redux_builder_amp['enable-amp-ads-3'] == true) { if($redux_builder_amp['enable-amp-ads-select-3'] == 1) { $advert_width = '300'; $advert_height = '250'; } elseif ($redux_builder_amp['enable-amp-ads-select-3'] == 2) { $advert_width = '336'; $advert_height = '280'; } elseif ($redux_builder_amp['enable-amp-ads-select-3'] == 3) { $advert_width = '728'; $advert_height = '90'; } elseif ($redux_builder_amp['enable-amp-ads-select-3'] == 4) { $advert_width = '300'; $advert_height = '600'; } elseif ($redux_builder_amp['enable-amp-ads-select-3'] == 5) { $advert_width = '320'; $advert_height = '100'; } elseif ($redux_builder_amp['enable-amp-ads-select-3'] == 6) { $advert_width = '200'; $advert_height = '50'; } elseif ($redux_builder_amp['enable-amp-ads-select-3'] == 7) { $advert_width = '320'; $advert_height = '50'; } $output = '
'; $output .= ''; $output .= ''; $output .= '
'; echo $output; } } // Below Content Single add_action('ampforwp_after_post_content','ampforwp_after_post_content_advert'); // Hook updated // add_action('ampforwp_inside_post_content_after','ampforwp_after_post_content_advert'); function ampforwp_after_post_content_advert() { global $redux_builder_amp; if($redux_builder_amp['enable-amp-ads-4'] == true) { if($redux_builder_amp['enable-amp-ads-select-4'] == 1) { $advert_width = '300'; $advert_height = '250'; } elseif ($redux_builder_amp['enable-amp-ads-select-4'] == 2) { $advert_width = '336'; $advert_height = '280'; } elseif ($redux_builder_amp['enable-amp-ads-select-4'] == 3) { $advert_width = '728'; $advert_height = '90'; } elseif ($redux_builder_amp['enable-amp-ads-select-4'] == 4) { $advert_width = '300'; $advert_height = '600'; } elseif ($redux_builder_amp['enable-amp-ads-select-4'] == 5) { $advert_width = '320'; $advert_height = '100'; } elseif ($redux_builder_amp['enable-amp-ads-select-4'] == 6) { $advert_width = '200'; $advert_height = '50'; } elseif ($redux_builder_amp['enable-amp-ads-select-4'] == 7) { $advert_width = '320'; $advert_height = '50'; } $output = '
'; $output .= ''; $output .= ''; $output .= '
'; echo $output; } } // Below The Title add_action('ampforwp_below_the_title','ampforwp_below_the_title_advert'); function ampforwp_below_the_title_advert() { global $redux_builder_amp; if($redux_builder_amp['enable-amp-ads-5'] == true) { if($redux_builder_amp['enable-amp-ads-select-5'] == 1) { $advert_width = '300'; $advert_height = '250'; } elseif ($redux_builder_amp['enable-amp-ads-select-5'] == 2) { $advert_width = '336'; $advert_height = '280'; } elseif ($redux_builder_amp['enable-amp-ads-select-5'] == 3) { $advert_width = '728'; $advert_height = '90'; } elseif ($redux_builder_amp['enable-amp-ads-select-5'] == 4) { $advert_width = '300'; $advert_height = '600'; } elseif ($redux_builder_amp['enable-amp-ads-select-5'] == 5) { $advert_width = '320'; $advert_height = '100'; } elseif ($redux_builder_amp['enable-amp-ads-select-5'] == 6) { $advert_width = '200'; $advert_height = '50'; } elseif ($redux_builder_amp['enable-amp-ads-select-5'] == 7) { $advert_width = '320'; $advert_height = '50'; } $output = '
'; $output .= ''; $output .= ''; $output .= '
'; echo $output; } } // Above Related post add_action('ampforwp_above_related_post','ampforwp_above_related_post_advert'); function ampforwp_above_related_post_advert() { global $redux_builder_amp; if($redux_builder_amp['enable-amp-ads-6'] == true) { if($redux_builder_amp['enable-amp-ads-select-6'] == 1) { $advert_width = '300'; $advert_height = '250'; } elseif ($redux_builder_amp['enable-amp-ads-select-6'] == 2) { $advert_width = '336'; $advert_height = '280'; } elseif ($redux_builder_amp['enable-amp-ads-select-6'] == 3) { $advert_width = '728'; $advert_height = '90'; } elseif ($redux_builder_amp['enable-amp-ads-select-6'] == 4) { $advert_width = '300'; $advert_height = '600'; } elseif ($redux_builder_amp['enable-amp-ads-select-6'] == 5) { $advert_width = '320'; $advert_height = '100'; } elseif ($redux_builder_amp['enable-amp-ads-select-6'] == 6) { $advert_width = '200'; $advert_height = '50'; } elseif ($redux_builder_amp['enable-amp-ads-select-6'] == 7) { $advert_width = '320'; $advert_height = '50'; } $output = '
'; $output .= ''; $output .= ''; $output .= '
'; echo $output; } } // 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 ( $redux_builder_amp['amp-analytics-select-option']=='1' ){ $ga_fields = array(); $ampforwp_ga_fields = array(); $ga_account = ''; $ga_account = $redux_builder_amp['ga-feild']; $ga_fields = array( 'vars'=>array( 'account'=>$ga_account ), 'triggers'=> array( 'trackPageview'=> array( 'on'=>'visible', 'request'=>'pageview' ) ) ); $ampforwp_ga_fields = json_encode( $ga_fields); $ampforwp_ga_fields = apply_filters('ampforwp_advance_google_analytics', $ampforwp_ga_fields ); ?>
]*/', '', $content); $content = preg_replace('/vocab=[^>]*/', '', $content); // $content = preg_replace('/type=[^>]*/', '', $content); $content = preg_replace('/value=[^>]*/', '', $content); // $content = preg_replace('/date=[^>]*/', '', $content); $content = preg_replace('/noshade=[^>]*/', '', $content); $content = preg_replace('/contenteditable=[^>]*/', '', $content); // $content = preg_replace('/time=[^>]*/', '', $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); $content = preg_replace('##i', '', $content); $content = preg_replace('##i', '', $content); /* Removed So Inline style can work $content = preg_replace('##i', '', $content); */ $content = preg_replace('/href="javascript:void*/', ' ', $content); $content = preg_replace('/]*>.*?<\/script>/i', '', $content); //for removing attributes within html tags $content = preg_replace('/(<[^>]+) onclick=".*?"/', '$1', $content); /* Removed So Inline style can work $content = preg_replace('/(<[^>]+) style=".*?"/', '$1', $content); */ $content = preg_replace('/(<[^>]+) rel="(.*?) noopener(.*?)"/', '$1 rel="$2$3"', $content); $content = preg_replace('/]+) ref=".*?"/', '$1', $content); /*$content = preg_replace('/(<[^>]+) date=".*?"/', '$1', $content); $content = preg_replace('/(<[^>]+) time=".*?"/', '$1', $content); $content = preg_replace('/(<[^>]+) date/', '$1', $content);*/ $content = preg_replace('/(<[^>]+) imap=".*?"/', '$1', $content); $content = preg_replace('/(<[^>]+) spellcheck/', '$1', $content); $content = preg_replace('/(.*?)<\/font>/', '$2', $content); //removing scripts and rel="nofollow" from Body and from divs //issue #268 //$content = str_replace(' rel="nofollow"',"",$content); $content = preg_replace('/]*>.*?<\/script>/i', '', $content); /// simpy add more elements to simply strip tag but not the content as so /// Array ("p","font"); $tags_to_strip = Array("thrive_headline","type","place","state","city" ); $tags_to_strip = apply_filters('ampforwp_strip_bad_tags', $tags_to_strip); foreach ($tags_to_strip as $tag) { $content = preg_replace("/<\\/?" . $tag . "(.|\\s)*?>/",'',$content); } // regex on steroids from here on // issue #420 $content = preg_replace("/(.*)<\/div>/i", '
$11
', $content); $content = preg_replace('/(.*)<\/like>/i', '', $content); $content = preg_replace('/(.*)<\/g:plusone>/i', '', $content); $content = preg_replace('/imageanchor="1"/i', '', $content); $content = preg_replace('/(.*?)<\/plusone>/', '', $content); $content = preg_replace('/xml:lang=[^>]*/', '', $content); // $content = preg_replace('/ (Improved after 0.9.63) $content = preg_replace('/ tag for itemtype and itemscope #1210 $content = preg_replace('/)<\/blockquote>/s', "$1", $content); // for readability attibute in div tag $content = preg_replace('/readability=[^>]*/', '', $content); // removing color from span tag $content = preg_replace('//', '', $content); // removing sl-processed form anchor tag $content = preg_replace('//', '', $content); // removing text-align:center from p tag $content = preg_replace('//', '', $content); // removing paraid, paraeid from p tag $content = preg_replace('//', '', $content); return $content; } // 11.1 Strip unwanted codes and tags from wp_footer for better compatibility with Plugins if ( ! is_customize_preview() ) { add_action( 'pre_amp_render_post','ampforwp_strip_invalid_content_footer'); } function ampforwp_strip_invalid_content_footer() { add_filter( 'wp_footer', 'ampforwp_the_content_filter_footer', 1 ); } function ampforwp_the_content_filter_footer( $content ) { remove_all_actions('wp_footer'); return $content; } // 11.5 Strip unwanted codes the_content of Frontpage add_action( 'pre_amp_render_post','ampforwp_strip_invalid_content_frontpage'); function ampforwp_strip_invalid_content_frontpage(){ if ( is_front_page() || is_home() ) { add_filter( 'the_content', 'ampforwp_the_content_filter_frontpage', 20 ); } } function ampforwp_the_content_filter_frontpage( $content ) { $content = preg_replace('/ 'ImageObject', 'url' => $structured_data_logo , 'height' => $ampforwp_sd_height, 'width' => $ampforwp_sd_width, ); //code for adding 'description' meta from Yoast SEO if($redux_builder_amp['ampforwp-seo-yoast-description']){ if ( class_exists('WPSEO_Frontend') ) { $front = WPSEO_Frontend::get_instance(); $desc = $front->metadesc( false ); if ( $desc ) { $metadata['description'] = $desc; } // Code for Custom Frontpage Yoast SEO Description $post_id = $redux_builder_amp['amp-frontpage-select-option-pages']; if ( class_exists('WPSEO_Meta') ) { $custom_fp_desc = WPSEO_Meta::get_value('metadesc', $post_id ); if ( is_home() && $redux_builder_amp['amp-frontpage-select-option'] ) { if ( $custom_fp_desc ) { $metadata['description'] = $custom_fp_desc; } else { unset( $metadata['description'] ); } } } } } //End of code for adding 'description' meta from Yoast SEO return $metadata; } // 13. Add Custom Placeholder Image for Structured Data. // if there is no image in the post, then use this image to validate Structured Data. add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata_featured_image', 10, 2 ); function ampforwp_update_metadata_featured_image( $metadata, $post ) { global $redux_builder_amp; global $post; $post_id = get_the_ID() ; $post_image_id = get_post_thumbnail_id( $post_id ); $structured_data_image = wp_get_attachment_image_src( $post_image_id, 'full' ); $post_image_check = $structured_data_image; $structured_data_image_url = ''; if ( $post_image_check == false) { if (! empty( $redux_builder_amp['amp-structured-data-placeholder-image']['url'] ) ) { $structured_data_image_url = $redux_builder_amp['amp-structured-data-placeholder-image']['url']; } $structured_data_image = $structured_data_image_url; $structured_data_height = intval($redux_builder_amp['amp-structured-data-placeholder-image-height']); $structured_data_width = intval($redux_builder_amp['amp-structured-data-placeholder-image-width']); $metadata['image'] = array( '@type' => 'ImageObject', 'url' => $structured_data_image , 'height' => $structured_data_height, 'width' => $structured_data_width, ); } // Custom Structured Data information for Archive, Categories and tag pages. if ( is_archive() ) { $structured_data_image = $redux_builder_amp['amp-structured-data-placeholder-image']['url']; $structured_data_height = intval($redux_builder_amp['amp-structured-data-placeholder-image-height']); $structured_data_width = intval($redux_builder_amp['amp-structured-data-placeholder-image-width']); $structured_data_archive_title = "Archived Posts"; $structured_data_author = get_userdata( 1 ); if ( $structured_data_author ) { $structured_data_author = $structured_data_author->display_name ; } else { $structured_data_author = "admin"; } $metadata['image'] = array( '@type' => 'ImageObject', 'url' => $structured_data_image , 'height' => $structured_data_height, 'width' => $structured_data_width, ); $metadata['author'] = array( '@type' => 'Person', 'name' => $structured_data_author , ); $metadata['headline'] = $structured_data_archive_title; } if( in_array( "image" , $metadata ) ) { if ( $metadata['image']['width'] < 696 ) { $metadata['image']['width'] = 700 ; } } return $metadata; } // 14. Adds a meta box to the post editing screen for AMP on-off on specific pages. /** * Adds a meta box to the post editing screen for AMP on-off on specific pages */ function ampforwp_get_all_post_types(){ global $redux_builder_amp; $post_types = array(); $selected_post_types = array(); $post_types = array('post' => 'post', 'page' => 'page'); if ( isset($redux_builder_amp['ampforwp-custom-type']) && $redux_builder_amp['ampforwp-custom-type'] ) { foreach ($redux_builder_amp['ampforwp-custom-type'] as $key) { $selected_post_types[$key] = $key; } $post_types = array_merge($post_types, $selected_post_types); } return $post_types; } function ampforwp_title_custom_meta() { global $redux_builder_amp; $post_types = ampforwp_get_all_post_types(); if ( $post_types ) { // If there are any custom public post types. foreach ( $post_types as $post_type ) { if( $post_type == 'amp-cta' || $post_type == 'amp-optin' ) { continue; } // Posts if( $redux_builder_amp['amp-on-off-for-all-posts'] && $post_type == 'post' ) { add_meta_box( 'ampforwp_title_meta', __( 'Show AMP for Current Page?','accelerated-mobile-pages' ), 'ampforwp_title_callback', 'post','side' ); } // Pages if( $redux_builder_amp['amp-on-off-for-all-pages'] && $post_type == 'page' ) { add_meta_box( 'ampforwp_title_meta', __( 'Show AMP for Current Page?' ,'accelerated-mobile-pages'), 'ampforwp_title_callback','page','side' ); } // Custom Post Types if( $post_type !== 'page' && $post_type !== 'post' ) { add_meta_box( 'ampforwp_title_meta', __( 'Show AMP for Current Page?','accelerated-mobile-pages' ), 'ampforwp_title_callback', $post_type,'side' ); } } } } add_action( 'add_meta_boxes', 'ampforwp_title_custom_meta' ); /** * Outputs the content of the meta box for AMP on-off on specific pages */ function ampforwp_title_callback( $post ) { wp_nonce_field( basename( __FILE__ ), 'ampforwp_title_nonce' ); $ampforwp_stored_meta = get_post_meta( $post->ID ); $preview_query_args = array(); $preview_link = ''; $preview_query_args = array(AMPFORWP_AMP_QUERY_VAR => 1); $preview_link = get_preview_post_link($post, $preview_query_args ); // TODO: Move the data storage code, to Save meta Box area as it is not a good idea to update an option everytime, try adding this code inside ampforwp_title_meta_save() // This code needs a rewrite. if ( ! isset($ampforwp_stored_meta['ampforwp-amp-on-off'][0]) || $ampforwp_stored_meta['ampforwp-amp-on-off'][0] == 'hide-amp') { $exclude_post_value = get_option('ampforwp_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_exclude_post', $exclude_post_value); } } } else { $exclude_post_value = get_option('ampforwp_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_exclude_post', $exclude_ids); } } } ?>

post_status == 'publish') { add_thickbox(); ?>

ID ); // TODO: Move the data storage code, to Save meta Box area as it is not a good idea to update an option everytime, try adding this code inside ampforwp_title_meta_save() // This code needs a rewrite. if ( !isset($ampforwp_redirection_stored_meta['ampforwp-redirection-on-off'][0]) || $ampforwp_redirection_stored_meta['ampforwp-redirection-on-off'][0] == 'disable') { $exclude_post_value = get_option('ampforwp_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_exclude_post', $exclude_post_value); } } } else { $exclude_post_value = get_option('ampforwp_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_exclude_post', $exclude_ids); } } } ?>

ID,'ampforwp-redirection-on-off',true); } if ( empty( $ampforwp_redirection_post_on_off_meta ) ) { $ampforwp_redirection_post_on_off_meta = 'enable'; } return $ampforwp_redirection_post_on_off_meta; } // Added the check to see if any search results exists function ampforwp_is_search_has_results() { return 0 != $GLOBALS['wp_query']->found_posts; } /** * Saves the custom meta input for AMP on-off on specific pages */ function ampforwp_title_meta_save( $post_id ) { $ampforwp_amp_status = ''; // Checks save status $is_autosave = wp_is_post_autosave( $post_id ); $is_revision = wp_is_post_revision( $post_id ); $is_valid_nonce = ( isset( $_POST[ 'ampforwp_title_nonce' ] ) && wp_verify_nonce( $_POST[ 'ampforwp_title_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false'; // Exits script depending on save status if ( $is_autosave || $is_revision || !$is_valid_nonce ) { return; } // Checks for radio buttons and saves if needed if( isset( $_POST[ 'ampforwp-amp-on-off' ] ) ) { $ampforwp_amp_status = sanitize_text_field( $_POST[ 'ampforwp-amp-on-off' ] ); update_post_meta( $post_id, 'ampforwp-amp-on-off', $ampforwp_amp_status ); } if( isset( $_POST[ 'ampforwp-redirection-on-off' ] ) ) { $ampforwp_redirection_status = sanitize_text_field( $_POST[ 'ampforwp-redirection-on-off' ] ); update_post_meta( $post_id, 'ampforwp-redirection-on-off', $ampforwp_redirection_status ); } } add_action( 'save_post', 'ampforwp_title_meta_save' ); add_filter('amp_frontend_show_canonical','ampforwp_hide_amp_for_specific_pages'); function ampforwp_hide_amp_for_specific_pages($input){ global $post; $ampforwp_amp_status = get_post_meta($post->ID, 'ampforwp-amp-on-off', true); if ( $ampforwp_amp_status == 'hide-amp' ) { $input = false; } return $input; } // 15. Disable New Relic's extra script that its adds in AMP pages. add_action( 'amp_post_template_data', 'ampforwp_disable_new_relic_scripts' ); if ( ! function_exists('ampforwp_disable_new_relic_scripts') ) { function ampforwp_disable_new_relic_scripts( $data ) { if ( ! function_exists( 'newrelic_disable_autorum' ) ) { return $data; } if ( function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() ) { newrelic_disable_autorum(); } return $data; } } // 16. Remove Unwanted Scripts if ( function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() ) { add_action( 'wp_enqueue_scripts', 'ampforwp_remove_unwanted_scripts',20 ); } function ampforwp_remove_unwanted_scripts() { wp_dequeue_script('jquery'); } // Remove Print Scripts and styles function ampforwp_remove_print_scripts() { if ( ampforwp_is_amp_endpoint() ) { function ampforwp_remove_all_scripts() { global $wp_scripts; $wp_scripts->queue = array(); } add_action('wp_print_scripts', 'ampforwp_remove_all_scripts', 100); function ampforwp_remove_all_styles() { global $wp_styles; $wp_styles->queue = array(); } add_action('wp_print_styles', 'ampforwp_remove_all_styles', 100); // Remove Print Emoji for Nextgen Gallery support remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); } } add_action( 'template_redirect', 'ampforwp_remove_print_scripts' ); // 17. Archives Canonical in AMP version // function ampforwp_rel_canonical_archive() { // // // $archivelink = esc_url( get_permalink( $id ) . AMPFORWP_AMP_QUERY_VAR . '/' ); // echo "\n"; // } // add_action( 'amp_post_template_head', 'ampforwp_rel_canonical_archive' ); // 18. Custom Canonical for Homepage // function ampforwp_rel_canonical() { // if ( !is_home() ) // return; // // $link = esc_url( get_permalink( $id ) . AMPFORWP_AMP_QUERY_VAR . '/' ); // $homelink = get_home_url(); // echo "\n"; // } // add_action( 'amp_post_template_head', 'ampforwp_rel_canonical' ); // 18.5. Custom Canonical for Frontpage // function ampforwp_rel_canonical_frontpage() { // if ( is_home() || is_front_page() ) // return; // // $link = esc_url( get_permalink( $id ) . AMPFORWP_AMP_QUERY_VAR . '/' ); // $homelink = get_home_url(); // echo "\n"; // } // add_action( 'amp_post_template_head', 'ampforwp_rel_canonical_frontpage' ); // 19. Remove Canonical tags function ampforwp_amp_remove_actions() { if ( is_home() || is_front_page() || is_archive() || is_search() ) { remove_action( 'amp_post_template_head', 'amp_post_template_add_canonical' ); } } add_action( 'amp_post_template_head', 'ampforwp_amp_remove_actions', 9 ); // 20. Remove the default Google font for performance // add_action( 'amp_post_template_head', function() { // remove_action( 'amp_post_template_head', 'amp_post_template_add_fonts' ); // }, 9 ); // 21. Remove Schema data from All In One Schema.org Rich Snippets Plugin add_action( 'pre_amp_render_post', 'ampforwp_remove_schema_data' ); function ampforwp_remove_schema_data() { remove_filter('the_content','display_rich_snippet'); // Ultimate Social Media PLUS Compatiblity Added remove_filter('the_content','sfsi_plus_beforaftereposts'); remove_filter('the_content','sfsi_plus_beforeafterblogposts'); // Thrive Content Builder $amp_custom_content_enable = get_post_meta( get_the_ID() , 'ampforwp_custom_content_editor_checkbox', true); if ($amp_custom_content_enable == 'yes') { remove_filter( 'the_content', 'tve_editor_content', 10 ); } // Removed GTranslate Flags from AMP pages #819 remove_filter('wp_nav_menu_items', 'gtranslate_menu_item', 10, 2); // Remove elements of WP Like Button plugin #841 remove_filter('the_content', 'fb_like_button'); remove_filter('the_excerpt', 'fb_like_button'); // Compatibility issue with the rocket lazy load #907 remove_filter( 'the_content' , 'rocket_lazyload_images', PHP_INT_MAX ); remove_filter( 'the_content', 'rocket_lazyload_iframes', PHP_INT_MAX ); add_filter( 'do_rocket_lazyload', '__return_false' ); // Remove Popups and other elements added by Slider-in Plugin define('WDSI_BOX_RENDERED', true, true); // Remove Filters added by third party plugin through class if ( function_exists('ampforwp_remove_filters_for_class')) { //Remove Disallowed 'like' tag from facebook Like button by Ultimate Facebook ampforwp_remove_filters_for_class( 'the_content', 'Wdfb_UniversalWorker', 'inject_facebook_button', 10 ); //Compatibility with Sassy Social Share Plugin ampforwp_remove_filters_for_class( 'the_content', 'Sassy_Social_Share_Public', 'render_sharing', 10 ); ampforwp_remove_filters_for_class( 'amp_post_template_head', 'Sassy_Social_Share_Public', 'frontend_scripts', 10 ); ampforwp_remove_filters_for_class( 'amp_post_template_css', 'Sassy_Social_Share_Public', 'frontend_inline_style', 10 ); ampforwp_remove_filters_for_class( 'amp_post_template_css', 'Sassy_Social_Share_Public', 'frontend_amp_css', 10 ); //Removing the Monarch social share icons from AMP ampforwp_remove_filters_for_class( 'the_content', 'ET_Monarch', 'display_inline', 10 ); ampforwp_remove_filters_for_class( 'the_content', 'ET_Monarch', 'display_media', 9999 ); //Compatibility with wordpress twitter bootstrap #525 ampforwp_remove_filters_for_class( 'the_content', 'ICWP_WPTB_CssProcessor_V1', 'run', 10 ); //Perfect SEO url + Yoast SEO Compatibility #982 ampforwp_remove_filters_for_class( 'wpseo_canonical', 'PSU', 'canonical', 10 ); //SiteOrigin Page builder compatibilty //Neglect SOPB If Custom AMP Editor is checked if ( $amp_custom_content_enable === 'yes') { ampforwp_remove_filters_for_class( 'the_content', 'SiteOrigin_Panels', 'generate_post_content', 10 ); } } //Removing the WPTouch Pro social share links from AMP remove_filter( 'the_content', 'foundation_handle_share_links_bottom', 100 ); //Removing the space added by the Google adsense #967 remove_filter( 'the_content', 'ga_strikable_add_optimized_adsense_code'); //Removing Social Media Share Buttons & Social Sharing Icons #1135 remove_filter('the_content', 'sfsi_social_buttons_below'); // Removing WordPress Social Share Buttons #1272 remove_filter ('the_content', 'FTGSB'); } // 22. Removing author links from comments Issue #180 if( ! function_exists( 'ampforwp_disable_comment_author_links' ) ) { function ampforwp_disable_comment_author_links( $author_link ){ $ampforwp_is_amp_endpoint = ampforwp_is_amp_endpoint(); if ( $ampforwp_is_amp_endpoint ) { return strip_tags( $author_link ); } else { return $author_link; } } add_filter( 'get_comment_author_link', 'ampforwp_disable_comment_author_links' ); } // 23. The analytics tag appears more than once in the document. This will soon be an error remove_action( 'amp_post_template_head', 'quads_amp_add_amp_ad_js'); // 24. Seperate Sticky Single Social Icons // TO DO: we can directly call social-icons.php instead of below code add_action('amp_post_template_footer','ampforwp_sticky_social_icons'); function ampforwp_sticky_social_icons(){ global $redux_builder_amp; /* include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if( !is_plugin_active( 'amp-cta/amp-cta.php' ) ) {*/ if($redux_builder_amp['enable-single-social-icons'] == true && is_single() ) { $permalink = ''; if(isset($redux_builder_amp['enable-single-twitter-share-link']) && $redux_builder_amp['enable-single-twitter-share-link']){ $permalink = get_the_permalink(); } else $permalink = wp_get_shortlink(); ?>
' ); } } else { if(isset($redux_builder_amp['ampforwp-seo-custom-additional-meta']) && $redux_builder_amp['ampforwp-seo-custom-additional-meta']){ echo strip_tags($redux_builder_amp['ampforwp-seo-custom-additional-meta'], '' ); } } } function ampforwp_custom_yoast_meta_homepage(){ global $redux_builder_amp; if ($redux_builder_amp['ampforwp-seo-yoast-meta']) { if(! class_exists('YoastSEO_AMP') ) { if ( class_exists('WPSEO_Options')) { if( method_exists('WPSEO_Options', 'get_option')){ $options = WPSEO_Options::get_option( 'wpseo_social' ); if ( $options['twitter'] === true ) { WPSEO_Twitter::get_instance(); } if ( $options['opengraph'] === true ) { $GLOBALS['wpseo_og'] = new WPSEO_OpenGraph; } } } do_action( 'wpseo_opengraph' ); }//execute only if Glue is deactive if(isset($redux_builder_amp['ampforwp-seo-custom-additional-meta']) && $redux_builder_amp['ampforwp-seo-custom-additional-meta']){ echo strip_tags($redux_builder_amp['ampforwp-seo-custom-additional-meta'], '' ); } } } function ampforwp_add_proper_post_meta(){ $check_custom_front_page = get_option('show_on_front'); if ( $check_custom_front_page == 'page' ) { add_action( 'amp_post_template_head', 'ampforwp_custom_yoast_meta_homepage' ); if(is_home()){ add_filter('wpseo_opengraph_title', 'custom_twitter_title_homepage'); add_filter('wpseo_twitter_title', 'custom_twitter_title_homepage'); add_filter('wpseo_opengraph_desc', 'custom_twitter_description_homepage'); add_filter('wpseo_twitter_description', 'custom_twitter_description_homepage'); add_filter('wpseo_opengraph_url', 'custom_og_url_homepage'); // This is causing the 2nd debug issue reported in #740 // add_filter('wpseo_twitter_image', 'custom_og_image_homepage'); add_filter('wpseo_opengraph_image', 'custom_og_image_homepage'); } } else { add_action( 'amp_post_template_head', 'ampforwp_custom_yoast_meta' ); } } add_action('pre_amp_render_post','ampforwp_add_proper_post_meta'); function custom_twitter_title_homepage() { return esc_attr( get_bloginfo( 'name' ) ); } function custom_twitter_description_homepage() { return esc_attr( get_bloginfo( 'description' ) ); } function custom_og_url_homepage() { return esc_url( get_bloginfo( 'url' ) ); } function custom_og_image_homepage() { if ( class_exists('WPSEO_Options') ) { $options = WPSEO_Options::get_option( 'wpseo_social' ); return $options['og_default_image'] ; } } /** * PR by Sybre Waaijer: * @link https://github.com/ahmedkaludi/accelerated-mobile-pages/pull/761 * * @since version 0.9.48 : * 1. Removes unused code. * 2. Cleaned up code. * 3. Keeps legacy action in place. * 4. No longer replaces the title tag. * 5. Instead, filters the title tag. * 6. Therefore, it works with all SEO plugins. * 7. Removed direct Yoast SEO compat -- It's no longer needed. * 8. Removed unwanted spaces. * 9. Improved performance. * 10. Improved security. * 11. Added support for CPT and attachment pages. */ //26. Extending Title Tagand De-Hooking the Standard one from AMP add_action( 'pre_amp_render_post', 'ampforwp_remove_title_tags'); function ampforwp_remove_title_tags() { return ampforwp_replace_title_tags(); } function ampforwp_replace_title_tags() { add_filter( 'pre_get_document_title', 'ampforwp_add_custom_title_tag', 10 ); add_filter( 'wp_title', 'ampforwp_add_custom_title_tag', 10, 3 ); function ampforwp_add_custom_title_tag( $title = '', $sep = '', $seplocation = '' ) { global $redux_builder_amp; $site_title = ''; $genesis_title = ''; //* We can filter this later if needed: $sep = ' | '; if ( is_singular() ) { global $post; $title = ! empty( $post->post_title ) ? $post->post_title : $title; $site_title = $title . $sep . get_option( 'blogname' ); } elseif ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] ) { $site_title = strip_tags( get_the_archive_title( '' ) . $sep . get_the_archive_description( '' ) ); } if ( is_home() ) { // Custom frontpage $site_title = get_bloginfo( 'name' ) . $sep . get_option( 'blogdescription' ); if( get_option( 'page_on_front' ) && $redux_builder_amp['amp-frontpage-select-option'] ){ //WPML Static Front Page Support for title and description with Yoast #1143 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && is_plugin_active('wordpress-seo/wp-seo.php')){ $ID = get_option( 'page_on_front' ); $fixed_title = WPSEO_Meta::get_value( 'title', $ID ); $site_title = apply_filters( 'wpseo_title', wpseo_replace_vars( $fixed_title, get_post( $ID, ARRAY_A ) ) ); } else{ $ID = $redux_builder_amp['amp-frontpage-select-option-pages']; $site_title = get_the_title( $ID ) . $sep . get_option( 'blogname' ); } } // Blog page if ( get_option( 'page_for_posts' ) && get_queried_object_id() ) { $ID = get_option( 'page_for_posts' ); $site_title = get_the_title( $ID ) . $sep . get_option( 'blogname' ); } // Custom Front Page Title From Yoast SEO #1163 if (class_exists('WPSEO_Meta_Columns')) { Global $redux_builder_amp; $ID = $redux_builder_amp['amp-frontpage-select-option-pages']; $fixed_title = WPSEO_Meta::get_value( 'title', $ID ); if($fixed_title){ $site_title = apply_filters( 'wpseo_title', wpseo_replace_vars( $fixed_title, get_post( $ID, ARRAY_A ) ) ); } } } if ( is_search() ) { $site_title = $redux_builder_amp['amp-translator-search-text'] . ' ' . get_search_query(); } //Genesis #1013 if(function_exists('genesis_title')){ if(is_home() && is_front_page() && !$redux_builder_amp['amp-frontpage-select-option']){ // Determine the doctitle. $genesis_title = genesis_get_seo_option( 'home_doctitle' ) ? genesis_get_seo_option( 'home_doctitle' ) : get_bloginfo( 'name' ); // Append site description, if necessary. $genesis_title = genesis_get_seo_option( 'append_description_home' ) ? $genesis_title . " $sep " . get_bloginfo( 'description' ) : $genesis_title; } elseif ( is_home() && get_option( 'page_for_posts' ) && get_queried_object_id() ) { $post_id = get_option( 'page_for_posts' ); if ( null !== $post_id || is_singular() ) { if ( genesis_get_custom_field( '_genesis_title', $post_id ) ) { $genesis_title = genesis_get_custom_field( '_genesis_title', $post_id ); } } } elseif( is_home() && get_option( 'page_on_front' ) && $redux_builder_amp['amp-frontpage-select-option'] ){ $post_id = get_option('page_on_front'); if ( null !== $post_id || is_singular() ) { if ( genesis_get_custom_field( '_genesis_title', $post_id ) ) { $genesis_title = genesis_get_custom_field( '_genesis_title', $post_id ); } } } else { $genesis_title = genesis_default_title( $title ); } if( $genesis_title ){ $site_title = $genesis_title; } } return esc_html( convert_chars( wptexturize( trim( $site_title ) ) ) ); } } add_action('amp_post_template_include_single','ampforwp_update_title_for_frontpage'); function ampforwp_update_title_for_frontpage() { $check_custom_front_page = get_option('show_on_front'); if ( $check_custom_front_page == 'page' && is_home() ) { remove_action( 'amp_post_template_head', 'amp_post_template_add_title' ); add_action('amp_post_template_head','ampforwp_frontpage_title_markup'); add_filter('aioseop_title','ampforwp_aioseop_front_page_title'); } } // Custom Frontpage title for ALL in one SEO. function ampforwp_aioseop_front_page_title() { $sep = ' | '; return $site_title = get_bloginfo( 'name' ) . $sep . get_option( 'blogdescription' ); } function ampforwp_frontpage_title_markup () { $front_page_title = ampforwp_add_custom_title_tag(); $front_page_title = apply_filters('ampforwp_frontpage_title_filter', $front_page_title); ?><?php echo esc_html( $front_page_title ); ?>]*/", "", $content_buffer); $content_buffer = preg_replace("/<\\/?thrive_headline(.|\\s)*?>/",'',$content_buffer); // Remove Extra styling added by other Themes/ Plugins $content_buffer = preg_replace('/((.*?)<\/style>)/','',$content_buffer); $content_buffer = preg_replace('/((.*?)<\/style>)(\/\*)/','$4',$content_buffer); $content_buffer = preg_replace("/<\\/?g(.|\\s)*?>/",'',$content_buffer); $content_buffer = preg_replace('/(<[^>]+) spellcheck="false"/', '$1', $content_buffer); $content_buffer = preg_replace('/(<[^>]+) spellcheck="true"/', '$1', $content_buffer); $content_buffer = preg_replace("/about:blank/", "#", $content_buffer); $content_buffer = preg_replace("/