: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
function ampforwp_remove_default_canonical() {
// Add Homepage AMP file code
add_filter( 'amp_post_template_file', 'ampforwp_custom_template', 10, 3 );
function ampforwp_custom_template( $file, $type, $post ) {
global $redux_builder_amp;
// Custom Homepage and Archive file
$current_url_in_pieces = array();
$ampforwp_custom_post_page = ampforwp_custom_post_page();
if ( 'single' === $type ) {
// Homepage and FrontPage
if ( is_home() || ( true == $redux_builder_amp['ampforwp-amp-takeover'] && is_front_page() ) ) {
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/index.php';
if ( ampforwp_is_blog() ) {
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/index.php';
if(function_exists('ampforwp_mobile_redirect_preseve_link')){
$mob_pres_link = ampforwp_mobile_redirect_preseve_link();
if ( ampforwp_is_front_page() || ( (true == ampforwp_get_setting('ampforwp-amp-takeover') || $mob_pres_link == true) && is_front_page() && ampforwp_get_setting('amp-frontpage-select-option')) ) {
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/frontpage.php';
if ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] && 'single' === $type ) {
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/archive.php';
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/search.php';
if ( is_404() && 'single' === $type ) {
add_filter('ampforwp_modify_rel_url','ampforwp_404_canonical');
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/404.php';
// Polylang compatibility
if ( 'single' === $type && ampforwp_polylang_front_page() && true == $redux_builder_amp['amp-frontpage-select-option'] ) {
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/frontpage.php';
add_filter('amp_post_template_dir','ampforwp_new_dir');
function ampforwp_new_dir( $dir ) {
global $redux_builder_amp;
if ( 1 == $redux_builder_amp['amp-design-selector'] || 2 == $redux_builder_amp['amp-design-selector'] || 3 == $redux_builder_amp['amp-design-selector'] ) {
$dir = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector();
$dir = AMPFORWP_CUSTOM_THEME;
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';
// 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';
// 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';
// 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';
// 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 ) {
// 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;
$social_check = $social_check_page = false;
if ( is_page() && isset($redux_builder_amp['ampforwp-page-social']) && $redux_builder_amp['ampforwp-page-social'] ) {
$social_check_page = true;
if ( 4 == ampforwp_get_setting('amp-design-selector') ) {
if ( '4' !== ampforwp_get_setting('amp-design-selector') && defined('AMPFORWP_DM_SOCIAL_CHECK') && 'true' === AMPFORWP_DM_SOCIAL_CHECK ) {
if( ampforwp_get_setting('enable-single-social-icons') == true || defined('AMPFORWP_DM_SOCIAL_CHECK') && AMPFORWP_DM_SOCIAL_CHECK === 'true' ) {
if( (is_singular() || $social_check_page ) && 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';
$isBBPress = (function_exists('is_bbpress') ? is_bbpress() : false );
if ( true == ampforwp_get_setting('ampforwp-facebook-like-button') ){
if ( is_single() && ( true == ampforwp_get_setting('enable-single-social-icons') || (true == ampforwp_get_setting('ampforwp-social-share') && $social_check) ) && !checkAMPforPageBuilderStatus(ampforwp_get_the_ID()) && !$isBBPress) {
if ( is_page() && ( true == ampforwp_get_setting('ampforwp-page-sticky-social') || ( $social_check_page && !checkAMPforPageBuilderStatus(ampforwp_get_the_ID()) ) ) ) {
if ( true == ampforwp_get_setting('enable-single-social-icons') && checkAMPforPageBuilderStatus(ampforwp_get_the_ID()) && is_singular()) {
if ( true == $fb_like ) {
if(empty($data['amp_component_scripts']['amp-facebook-like'])){
$data['amp_component_scripts']['amp-facebook-like'] = 'https://cdn.ampproject.org/v0/amp-facebook-like-0.1.js';
add_filter( 'amp_post_template_data', 'ampforwp_add_amp_related_scripts', 20 );
function ampforwp_add_amp_related_scripts( $data ) {
global $redux_builder_amp;
if ( isset($redux_builder_amp['ampforwp-amp-menu']) && $redux_builder_amp['ampforwp-amp-menu'] && 4 != $redux_builder_amp['amp-design-selector'] ) {
if ( empty( $data['amp_component_scripts']['amp-sidebar'] ) ) {
$data['amp_component_scripts']['amp-sidebar'] = 'https://cdn.ampproject.org/v0/amp-sidebar-0.1.js';
// 8. Add Main tag as a Wrapper
// Removed this code after moving to design manager
// Moved to ads-functions.php
// Moved to analytics-functions.php
// 11. Strip unwanted codes and tags from the_content
add_action( 'pre_amp_render_post','ampforwp_strip_invalid_content');
function ampforwp_strip_invalid_content() {
add_filter( 'the_content', 'ampforwp_the_content_filter', 2 );
function ampforwp_the_content_filter( $content ) {
$content = preg_replace('/property=[^>]*/', '', $content);
$content = preg_replace('/vocab=[^>]*/', '', $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('/nowrap="nowrap"/', '', $content);
$content = preg_replace('#<comments-count.*?>(.*?)</comments-count>#i', '', $content);
$content = preg_replace('#<badge.*?>(.*?)</badge>#i', '', $content);
$content = preg_replace('#<plusone.*?>(.*?)</plusone>#i', '', $content);
$content = preg_replace('#<col.*?>#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('/<script src="(https?).*(\/\/fast|support)(\.wistia\.com\/)(embed\/medias\/)([0-9|\w]+)(.*?)<\/script>/', "$1:$2$3$4$5\n", $content);
$content = preg_replace('/<div class="wistia_responsive_padding" (.*?)>/', "", $content);
$content = preg_replace('/<div class="wistia_responsive_wrapper" (.*?)>/', "", $content);
$content = preg_replace('/<div class="wistia_embed (.*?)>/', "", $content);
$content = preg_replace('/<div class="wistia_swatch" (.*?)>/', "", $content);
$content = preg_replace('/<img(.*?)src="https:\/\/fast.wistia.com\/embed\/(.*?)"(.*?)\/>/', "", $content);
$content = preg_replace('/<script[^>]*>.*?<\/script>/i', '', $content);
//for removing attributes within html tags
$content = preg_replace('/(<[^>]+) onclick=".*?"/', '$1', $content);
// Remove alt attribute from the div tag #2093
$content = preg_replace('/<div(.*?) alt=".*?"(.*?)/', '<div $1', $content);
$content = preg_replace('/(<[^>]+) ref=".*?"/', '$1', $content);
$content = preg_replace('/(<[^>]+) imap=".*?"/', '$1', $content);
$content = preg_replace('/(<[^>]+) spellcheck/', '$1', $content);
$content = preg_replace('/<font(.*?)>(.*?)<\/font>/', '$2', $content);
$content = preg_replace('/<script[^>]*>.*?<\/script>/i', '', $content);
/// simpy add more elements to simply strip tag but not the content as so
$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
$content = preg_replace('/<like\s(.*?)>(.*)<\/like>/i', '', $content);
$content = preg_replace('/<g:plusone\s(.*?)>(.*)<\/g:plusone>/i', '', $content);
$content = preg_replace('/imageanchor="1"/i', '', $content);
$content = preg_replace('/<plusone\s(.*?)>(.*?)<\/plusone>/', '', $content);
$content = preg_replace('/xml:lang=[^>]*/', '', $content);
// Removing the type attribute from the <ul> (Improved after 0.9.63)
$content = preg_replace('/<ul(.*?)\btype=".*?"(.*?)/','<ul $1',$content);
//Convert the Twitter embed into url for better sanitization #1010
$content = preg_replace("/<blockquote(\s)class=\"twitter-(.*?)\"[^>](.*?)<a href=\"(https:\/\/twitter.com\/([a-zA-Z0-9_]{1,20})\/status\/)(.*?)\">(.*?)<\/blockquote>/si", "\n$4$6", $content);
// Convert the Soundcloud embed into URL to build amp-soundcloud
$content = preg_replace('/<iframe .*(https?).*(\/\/api\.soundcloud\.com\/tracks\/)([0-9]+)(.*)<\/iframe>/', "$1:$2$3", $content);
// for readability attibute in div tag
$content = preg_replace('/readability=[^>]*/', '', $content);
// removing sl-processed attribute
$content = preg_replace('/(<[^>]+) sl-processed=".*?"/', '$1', $content);
$content = preg_replace('/(<[^>]+) ga-on=".*?"/', '$1', $content);
$content = preg_replace('/(<[^>]+) ga-event-category=".*?"/', '$1', $content);
$content = preg_replace('/(<[^>]+) aria-current=".*?"/', '$1', $content);
$content = preg_replace('/[^\[]\[gallery(.*?)ids=(.*?)\]/', '</p>[gallery$1ids=$2]</p>', $content);
// value attribute from anchor tag #2262
$content = preg_replace('/<a(.*?)(value=".*?")(.*?)>/', '<a$1$3>', $content);
//Compatibility with Cloudflare stream. #3230
$content = preg_replace('/<stream[^>]* src="(.*?)"><\/stream>/', '<amp-iframe width="175" height="100" sandbox="allow-scripts allow-same-origin" layout="responsive" allowfullscreen src="https://iframe.cloudflarestream.com/$1"></amp-iframe>', $content);
//Compatibility with amp-connatix-player #3524
$content = preg_replace('/<script id="(.*?)">(.*?)playerId:\s\'(.*?)\'(.*?)mediaId:\s\'(.*?)\'(.*?)<\/script>/s', '<amp-connatix-player data-player-id="$3" data-media-id = "$5" layout="responsive" width="16" height="9"></amp-connatix-player>', $content);
// Fixed CSS syntax error when redgifs iframe is embedded # 4422
if(preg_match("/<div\s+style='(.*?)\)'><iframe(.*?)redgifs\.com(.*?)<\/iframe>/", $content)){
$content = preg_replace("/<div\s+style='(.*?)\)'><iframe(.*?)redgifs\.com(.*?)<\/iframe>/", "<div style='$1'><iframe$2redgifs.com$3</iframe>", $content);
// TODO: Remove this function if it's not in use
// 11.1 Strip unwanted codes and tags from wp_footer for better compatibility with Plugins
if ( ! is_customize_preview() && ! ampforwp_is_non_amp("non_amp_check_convert") ) {
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');
// 12. Add Logo URL in the structured metadata
// Moved to structured-data-functions.php
// 13. Add Custom Placeholder Image for Structured Data.
// if there is no image in the post, then use this image to validate Structured Data.
// Moved to structured-data-functions.php
// 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_title_custom_meta() {
global $redux_builder_amp;
$post_types = ampforwp_get_all_post_types();
if ( $post_types && (ampforwp_role_based_access_options() == true && ( current_user_can('edit_posts') || current_user_can('edit_pages') ) ) ) { // If there are any custom public post types.
foreach ( $post_types as $post_type ) {
if( $post_type == 'amp-cta' || $post_type == 'amp-optin' ) {
if( ampforwp_get_setting('amp-on-off-for-all-posts') && $post_type == 'post' ) {
add_meta_box( 'ampforwp_title_meta', esc_html__( 'Show AMP for Current Post?','accelerated-mobile-pages' ), 'ampforwp_title_callback', 'post','side' );
$frontpage_id = ampforwp_get_the_ID();
$page_for_posts = intval(get_option( 'page_for_posts' ));
if( ampforwp_get_setting('amp-on-off-for-all-pages') && $post_type == 'page' || ( true == ampforwp_get_setting('amp-frontpage-select-option') && $post_id == $frontpage_id ) || ($post_id == $page_for_posts)) {
add_meta_box( 'ampforwp_title_meta', esc_html__( 'Show AMP for Current Page?' ,'accelerated-mobile-pages'), 'ampforwp_title_callback','page','side' );
if( $post_type !== 'page' && $post_type !== 'post' ) {
add_meta_box( 'ampforwp_title_meta', esc_html__( '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 ) {
global $redux_builder_amp;
wp_nonce_field( basename( __FILE__ ), 'ampforwp_title_nonce' );
$ampforwp_stored_meta = get_post_meta( $post->ID );
if(isset($ampforwp_stored_meta['ampforwp-amp-on-off'])){
$hide_show = $ampforwp_stored_meta['ampforwp-amp-on-off'];
$hide_show = ampforwp_get_setting('amp-pages-meta-default');
if(!isset($ampforwp_stored_meta['ampforwp-amp-on-off'])){
$ampforwp_stored_meta['ampforwp-amp-on-off'][0] = 'default';
$preview_query_args = array();
$preview_link = $list_of_posts = $skip_this_post = '';
$preview_query_args = array(AMPFORWP_AMP_QUERY_VAR => 1);
$preview_link = get_preview_post_link($post, $preview_query_args );
$exclude_post_value = array();
if ( ampforwp_posts_to_remove() && $post->post_type == 'post' ) {
$ampforwp_stored_meta['ampforwp-amp-on-off'][0] = 'hide-amp';
$exclude_post_value = ampforwp_exclude_posts();
// if hide-amp is selected, add it in the $exclude_post_value
if ( 'hide-amp' == ( isset($ampforwp_stored_meta['ampforwp-amp-on-off'][0]) && $ampforwp_stored_meta['ampforwp-amp-on-off'][0] ) && 'page' != $post->post_type ) {
if ( ! in_array($post->ID, $exclude_post_value) ) {
$exclude_post_value[] = $post->ID;
set_transient('ampforwp_exclude_post_transient', $exclude_post_value);
if ( ( 'default' == ( isset($ampforwp_stored_meta['ampforwp-amp-on-off'][0]) && $ampforwp_stored_meta['ampforwp-amp-on-off'][0] ) || !isset($ampforwp_stored_meta['ampforwp-amp-on-off'][0]) ) && 'page' != $post->post_type ) {
if ( in_array($post->ID, $exclude_post_value) ) {
$exclude_post_value = array_flip($exclude_post_value);
unset($exclude_post_value[$post->ID] );
$exclude_post_value = array_flip($exclude_post_value);
set_transient('ampforwp_exclude_post_transient', $exclude_post_value);
if ($post->post_type == 'page' && ampforwp_get_setting('amp-pages-meta-default') == 'hide' && ($hide_show=='hide' || $hide_show=='hide-amp')) {
$ampforwp_stored_meta['ampforwp-amp-on-off'][0] = 'hide-amp';
<div class="prfx-row-content">
<label class="meta-radio-two" for="ampforwp-on-off-meta-radio-one">
<input type="radio" name="ampforwp-amp-on-off" id="ampforwp-on-off-meta-radio-one" value="default" checked="checked" <?php if ( isset ( $ampforwp_stored_meta['ampforwp-amp-on-off'] ) ) checked( $ampforwp_stored_meta['ampforwp-amp-on-off'][0], 'default' ); ?>>
<?php esc_html_e( 'Show', 'accelerated-mobile-pages' )?>
<label class="meta-radio-two" for="ampforwp-on-off-meta-radio-two">
<input type="radio" name="ampforwp-amp-on-off" id="ampforwp-on-off-meta-radio-two" value="hide-amp" <?php if ( isset ( $ampforwp_stored_meta['ampforwp-amp-on-off'] ) ) checked( $ampforwp_stored_meta['ampforwp-amp-on-off'][0], 'hide-amp' ); ?>>
<?php esc_html_e( 'Hide', 'accelerated-mobile-pages' )?>
if($post->post_status == 'publish') {
<div class="ampforwp-preview-button-container">
<input alt="#TB_inline?height=1135&width=718&inlineId=ampforwp_preview" title="AMP Mobile Preview" class="thickbox ampforwp-preview-button preview button amp-preview-button" type="button" value="Preview AMP" />
<div id="ampforwp_preview" style="display:none">
<div id="ampforwp-preview-format">
<div class="col-sm-12 margin-top-bottom text-center">
<div class="ampforwp-preview-phone-frame-wrapper">
<div class="ampforwp-preview-phone-frame">
<div class="ampforwp-preview-container" id="amp-preview-iframe" data-src="<?php echo $preview_link; ?>">
if ( get_option('page_on_front') == $post->ID && false == $redux_builder_amp['amp-frontpage-select-option'] ) {
echo sprintf(('<p class="afp"><b> %s </b> <a class="" target= "_blank" href="%s">%s</a></p>'), esc_html__('We have detected that you have not setup the FrontPage for AMP,','accelerated-mobile-pages'),admin_url("admin.php?page=amp_options&tabid=opt-text-subsection#redux_builder_amp-ampforwp-homepage-on-off-support"),esc_html__('Click here to setup','accelerated-mobile-pages'));
if ( true == $redux_builder_amp['amp-frontpage-select-option'] && $post->ID == $redux_builder_amp['amp-frontpage-select-option-pages'] ) {
echo sprintf('<p>%s</p>', esc_html__('AMP FrontPage'));
* Adds a meta box to the post editing screen for Mobile Redirection on-off on specific pages
function ampforwp_mobile_redirection() {
global $redux_builder_amp;
$post_types = ampforwp_get_all_post_types();
if ( $post_types && ampforwp_role_based_access_options() == true ) { // If there are any custom public post types.
foreach ( $post_types as $post_type ) {
if( $post_type == 'amp-cta' || $post_type == 'amp-optin' ) {
if( ampforwp_get_setting('amp-on-off-for-all-posts') && $post_type == 'post' ) {
if ( ampforwp_get_setting('amp-mobile-redirection') ) {
add_meta_box( 'ampforwp_title_meta_redir', esc_html__( 'Mobile Redirection for Current Page?','accelerated-mobile-pages' ), 'ampforwp_title_callback_redirection', 'post','side' );
if( ampforwp_get_setting('amp-on-off-for-all-pages') && $post_type == 'page' ) {
if ( ampforwp_get_setting('amp-mobile-redirection') ) {
add_meta_box( 'ampforwp_title_meta_redir', esc_html__( 'Mobile Redirection for Current Page?' ,'accelerated-mobile-pages'), 'ampforwp_title_callback_redirection','page','side' );
if( $post_type !== 'page' && $post_type !== 'post' ) {
if (ampforwp_get_setting('amp-mobile-redirection') ) {
add_meta_box( 'ampforwp_title_meta_redir', esc_html__( 'Mobile Redirection for Current Page?','accelerated-mobile-pages' ), 'ampforwp_title_callback_redirection', $post_type,'side' );
add_action( 'add_meta_boxes', 'ampforwp_mobile_redirection' );
* Outputs the content of the meta box for Mobile Redirection on-off on specific pages
function ampforwp_title_callback_redirection( $post ) {
wp_nonce_field( basename( __FILE__ ), 'ampforwp_title_nonce' );
$ampforwp_redirection_stored_meta = get_post_meta( $post->ID );?>
<div class="prfx-row-content">
<label for="meta-redirection-radio-one">
<input type="radio" name="ampforwp-redirection-on-off" id="meta-redirection-radio-one" value="enable" checked="checked" <?php if ( isset ( $ampforwp_redirection_stored_meta['ampforwp-redirection-on-off'] ) ) checked( $ampforwp_redirection_stored_meta['ampforwp-redirection-on-off'][0], 'enable' ); ?>>
<?php esc_html_e( 'Enable', 'accelerated-mobile-pages' )?>
<label for="meta-redirection-radio-two">
<input type="radio" name="ampforwp-redirection-on-off" id="meta-redirection-radio-two" value="disable" <?php if ( isset ( $ampforwp_redirection_stored_meta['ampforwp-redirection-on-off'] ) ) checked( $ampforwp_redirection_stored_meta['ampforwp-redirection-on-off'][0], 'disable' ); ?>>
<?php esc_html_e( 'Disable', 'accelerated-mobile-pages' )?>
function ampforwp_meta_redirection_status(){
$ampforwp_redirection_post_on_off_meta = '';
if ( (! is_404() && ampforwp_is_search_has_results() ) && (is_singular() || ampforwp_is_front_page()) ) {
$ampforwp_redirection_post_on_off_meta = get_post_meta( $post->ID,'ampforwp-redirection-on-off',true);
if ( empty( $ampforwp_redirection_post_on_off_meta ) ) {
$ampforwp_redirection_post_on_off_meta = 'enable';
$ampforwp_redirection_post_on_off_meta = apply_filters('ampforwp_disable_mobile_redirection', $ampforwp_redirection_post_on_off_meta);
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 ) {
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
$ampforwp_amp_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';
$is_valid_nonce_ia = ( isset( $_POST[ 'ampforwp_ia_nonce' ] ) && wp_verify_nonce( $_POST[ 'ampforwp_ia_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';