: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$nofollow = $page = $amp_url = $non_amp_url = '';
if( true == ampforwp_get_setting('ampforwp-nofollow-view-nonamp') ){
$nofollow = 'rel=nofollow';
$amp_url = ampforwp_amphtml_generator();
$amp_url = explode('/', $amp_url);
$amp_url = array_flip($amp_url);
$endpoint = AMPFORWP_AMP_QUERY_VAR;
if (ampforwp_get_setting('amp-core-end-point')) {
$endpoint = '?'. $endpoint;
unset($amp_url[$endpoint]);
$non_amp_url = array_flip($amp_url);
$non_amp_url = implode('/', $non_amp_url);
$query_arg_array = $wp->query_vars;
if( array_key_exists( "page" , $query_arg_array ) ) {
$page = $wp->query_vars['page'];
$non_amp_url = trailingslashit( $non_amp_url . '?page=' . $page);
if ( ampforwp_get_setting('amp-mobile-redirection')==true && ampforwp_get_setting('amp-mob-redirection-pres-link')==false) {
$non_amp_url = user_trailingslashit($non_amp_url);
$non_amp_url = add_query_arg('nonamp','1',$non_amp_url);
if(function_exists('ampforwp_mobile_redirect_preseve_link')){
$mob_pres_link = ampforwp_mobile_redirect_preseve_link();
$non_amp_url = user_trailingslashit($non_amp_url);
if ( true == ampforwp_get_setting('ampforwp-amp-takeover') || $mob_pres_link == true) {
$permalink = get_option('permalink_structure');
if(strpos($permalink, '/%year%/%monthnum%/%day%/%postname%/') !== false){
$non_amp_url = get_permalink(ampforwp_get_the_ID());
if ( $non_amp_url ) { ?><a class="view-non-amp" href="<?php echo esc_url(apply_filters('ampforwp_view_nonamp_url', $non_amp_url) ) ?>" <?php echo esc_attr($nofollow); ?> title="<?php echo ampforwp_get_setting('amp-translator-non-amp-page-text') ?>"><?php if(function_exists('pll__')){echo pll__(esc_html__( ampforwp_get_setting('amp-translator-non-amp-page-text'), 'accelerated-mobile-pages'));}else{echo esc_html__( ampforwp_get_setting('amp-translator-non-amp-page-text'), 'accelerated-mobile-pages');}?></a> <?php }
//68. Facebook Instant Articles
add_action('init', 'ampforwp_fb_instant_article_feed_generator');
function ampforwp_fb_instant_article_feed_generator() {
if( ampforwp_get_setting('fb-instant-article-switch') ) {
add_feed('instant_articles', 'ampforwp_fb_instant_article_feed_function');
add_action( 'ampforwp_fbia_head', 'ampforwp_fbia_meta_tags' );
require AMPFORWP_PLUGIN_DIR . '/templates/instant-articles/instant-article-sanitizer.php';
function ampforwp_fb_instant_article_feed_function() {
add_filter('pre_option_rss_use_excerpt', '__return_zero');
load_template( AMPFORWP_PLUGIN_DIR . '/feeds/instant-article-feed.php' );
if ( ! function_exists('ampforwp_fbia_meta_tags') ) {
function ampforwp_fbia_meta_tags(){
global $redux_builder_amp;
// undefined index fb-instant-page-id #2610
$fb_page_id = ampforwp_get_setting('fb-instant-page-id');
<meta property="fb:pages" content="<?php echo esc_attr( $fb_page_id ); ?>" />
// undefined index fb-instant-page-id ends here #2610
// If there's no current post, return
$url = add_query_arg( 'ia_markup', '1', $url );
if( ampforwp_get_setting('fb-instant-crawler-ingestion') ) { ?>
<meta property="ia:markup_url" content="<?php echo esc_url( $url ); ?>" />
// 69. Post Pagination #834 #857
function ampforwp_post_pagination( $args = '' ) {
global $page, $numpages, $multipage, $more, $redux_builder_amp;
if ( ampforwp_is_front_page() ) {
$id = ampforwp_get_frontpage_id();
$content_post = get_post($id);
$content = $content_post->post_content;
$checker = preg_match('/<!--nextpage-->/', $content);
$ampforwp_new_content = explode('<!--nextpage-->', $content);
$queried_var = get_query_var('paged');
if ( $queried_var > 1 ) {
$numpages = count($ampforwp_new_content);
$amp_current_post_id =ampforwp_get_the_ID();
$amp_custom_content_enable = get_post_meta( $amp_current_post_id , 'ampforwp_custom_content_editor_checkbox', true);
if($amp_custom_content_enable=='yes'){
$content = get_post_meta ( $amp_current_post_id, 'ampforwp_custom_content_editor', true );
$content = html_entity_decode($content);
$checker = preg_match('/<!--nextpage-->/', $content);
$ampforwp_new_content = explode('<!--nextpage-->', $content);
$queried_var = get_query_var('paged');
if ( $queried_var > 1 ) {
$numpages = count($ampforwp_new_content);
}else if(ampforwp_get_setting('ampforwp-pagination-link-type')==true && is_singular() && !checkAMPforPageBuilderStatus(ampforwp_get_the_ID())){
$id = ampforwp_get_the_ID();
$content = get_post_field( 'post_content', $id);
$sanitizer_obj = new AMPFORWP_Content( $content,
apply_filters( 'amp_content_embed_handlers', array(
'AMP_Reddit_Embed_Handler' => array(),
'AMP_Twitter_Embed_Handler' => array(),
'AMP_YouTube_Embed_Handler' => array(),
'AMP_DailyMotion_Embed_Handler' => array(),
'AMP_Vimeo_Embed_Handler' => array(),
'AMP_SoundCloud_Embed_Handler' => array(),
'AMP_Instagram_Embed_Handler' => array(),
'AMP_Vine_Embed_Handler' => array(),
'AMP_Facebook_Embed_Handler' => array(),
'AMP_Pinterest_Embed_Handler' => array(),
'AMP_Gallery_Embed_Handler' => array(),
'AMP_Playlist_Embed_Handler' => array(),
'AMP_Tiktok_Embed_Handler'=>array(),
apply_filters( 'amp_content_sanitizers', array(
'AMP_Style_Sanitizer' => array(),
'AMP_Blacklist_Sanitizer' => array(),
'AMP_Img_Sanitizer' => array(),
'AMP_Video_Sanitizer' => array(),
'AMP_Audio_Sanitizer' => array(),
'AMP_Playbuzz_Sanitizer' => array(),
'AMP_Iframe_Sanitizer' => array(
'add_placeholder' => true,
$content = $sanitizer_obj->get_amp_content();
$checker = preg_match('/<!--nextpage-->/', $content);
$ampforwp_new_content = explode('<!--nextpage-->', $content);
$queried_var = get_query_var('paged');
if ( $queried_var > 1 ) {
$numpages = count($ampforwp_new_content);
'before' => '<div class="ampforwp_post_pagination" ><p>' . '<span>' . ampforwp_translation($redux_builder_amp['amp-translator-page-text'], 'Page') . ':</span>',
'next_or_number' => 'number',
'nextpagelink' => ampforwp_translation($redux_builder_amp['amp-translator-next-text'], 'Next'),
'previouspagelink' => ampforwp_translation($redux_builder_amp['amp-translator-previous-text'], 'Previous'),
$params = wp_parse_args( $args, $defaults );
* Filters the arguments used in retrieving page links for paginated posts.
* @param array $params An array of arguments for page links for paginated posts.
$r = apply_filters( 'ampforwp_post_pagination_args', $params );
if ( isset($redux_builder_amp['ampforwp-pagination-select']) && 2 == $redux_builder_amp['ampforwp-pagination-select'] ) {
$r['next_or_number'] = 'next';
$r['before'] = '<div class="ampforwp_post_pagination" ><p>';
$r['after'] = '</p></div>';
if ( 'number' == $r['next_or_number'] ) {
for ( $i = 1; $i <= $numpages; $i++ ) {
$link = $r['link_before'] . str_replace( '%', '<span>'.$i.'</span>', $r['pagelink'] ) . $r['link_after'];
if ( $i != $page || ! $more && 1 == $page ) {
$link = ampforwp_post_paginated_link_generator( $i ) . $link . '</a>';
* Filters the HTML output of individual page number links.
* @param string $link The page number HTML output.
* @param int $i Page number for paginated posts' page links.
$link = apply_filters( 'ampforwp_post_pagination_link', $link, $i );
// Use the custom links separator beginning with the second link.
$output .= ( 1 === $i ) ? ' ' : $r['separator'];
$link = ampforwp_post_paginated_link_generator( $prev ) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
$output .= apply_filters( 'ampforwp_post_pagination_link', $link, $prev );
$output .= $r['separator'];
$text = $page . ' of ' . $numpages;
$output .= apply_filters( 'ampforwp_post_pagination_page', $text, $page, $numpages);
if ( $next <= $numpages ) {
$output .= $r['separator'];
$link = ampforwp_post_paginated_link_generator( $next ) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>';
$output .= apply_filters( 'ampforwp_post_pagination_link', $link, $next );
* Filters the HTML output of page links for paginated posts.
* @param string $output HTML output of paginated posts' page links.
* @param array $args An array of arguments.
$html = apply_filters( 'ampforwp_post_pagination', $output, $args );
if($redux_builder_amp['amp-pagination']) {
* Helper function for ampforwp_post_pagination().
* @global WP_Rewrite $wp_rewrite
* @param int $i Page number.
function ampforwp_post_paginated_link_generator( $i ) {
if ( ampforwp_is_front_page() ) {
$id = ampforwp_get_frontpage_id();
if(ampforwp_is_front_page()){
if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) {
$url = add_query_arg( 'page', $i, get_permalink() );
if(ampforwp_is_front_page()){
$url = add_query_arg( 'page', $i, get_home_url() );
elseif ( ampforwp_is_front_page() )
$url = trailingslashit(get_home_url()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
$url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
$query_args['preview_id'] = wp_unslash( $_GET['preview_id'] );
$query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] );
$url = get_preview_post_link( $post, $query_args, $url );
if(function_exists('ampforwp_mobile_redirect_preseve_link')){
$mob_pres_link = ampforwp_mobile_redirect_preseve_link();
if ( false == ampforwp_get_setting('ampforwp-amp-takeover') && $mob_pres_link == false) {
if(ampforwp_get_setting('ampforwp-pagination-link-type')==true && is_singular() && !checkAMPforPageBuilderStatus(ampforwp_get_the_ID())){
$url = ampforwp_url_controller($url);
$url = add_query_arg(AMPFORWP_AMP_QUERY_VAR,'1',$url);
return '<a href="' . esc_url( $url ) . '">';
// Modify the content to make Pagination work on Pages and FrontPage #2253
add_filter('ampforwp_modify_the_content','ampforwp_post_paginated_content');
function ampforwp_post_paginated_content($content){
//Embed pinterest images to the amp #4361
if(preg_match('/<a(.*?)data-pin-do="embedPin"(.*?)href="(.*?)"><\/a>/', $content)){
$content = preg_replace('/<a(.*?)data-pin-do="embedPin"(.*?)href="(.*?)"><\/a>/', '<amp-pinterest width="250" height="500" data-do="embedPin" data-url="$3"></amp-pinterest>', $content);
if ( is_singular() || ampforwp_is_front_page() ){
global $redux_builder_amp, $page, $multipage;
$ampforwp_new_content = $ampforwp_the_content = $checker = '';
if(ampforwp_get_setting('ampforwp-pagination-link-type')==true && is_singular() && !checkAMPforPageBuilderStatus(ampforwp_get_the_ID())){
if (get_query_var('paged') > 1) {
$id = ampforwp_get_the_ID();
$content = get_post_field( 'post_content', $id);
$sanitizer_obj = new AMPFORWP_Content( $content,
apply_filters( 'amp_content_embed_handlers', array(
'AMP_Reddit_Embed_Handler' => array(),
'AMP_Twitter_Embed_Handler' => array(),
'AMP_YouTube_Embed_Handler' => array(),
'AMP_DailyMotion_Embed_Handler' => array(),
'AMP_Vimeo_Embed_Handler' => array(),
'AMP_SoundCloud_Embed_Handler' => array(),
'AMP_Instagram_Embed_Handler' => array(),
'AMP_Vine_Embed_Handler' => array(),
'AMP_Facebook_Embed_Handler' => array(),
'AMP_Pinterest_Embed_Handler' => array(),
'AMP_Gallery_Embed_Handler' => array(),
'AMP_Playlist_Embed_Handler' => array(),
'AMP_Tiktok_Embed_Handler'=>array(),
apply_filters( 'amp_content_sanitizers', array(
'AMP_Style_Sanitizer' => array(),
'AMP_Blacklist_Sanitizer' => array(),
'AMP_Img_Sanitizer' => array(),
'AMP_Video_Sanitizer' => array(),
'AMP_Audio_Sanitizer' => array(),
'AMP_Playbuzz_Sanitizer' => array(),
'AMP_Iframe_Sanitizer' => array(
'add_placeholder' => true,
$content = $sanitizer_obj->get_amp_content();
$queried_var = get_query_var('paged');
$con = explode("<!--nextpage-->", $content);
if(isset($con[$queried_var-1])){
$content = $con[$queried_var-1];
$ampforwp_the_content = $content;
$checker = preg_match('/<!--nextpage-->/', $ampforwp_the_content);
if ( 1 === $checker && true == ampforwp_get_setting('amp-pagination') ) {
$ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
$queried_var = get_query_var('page');
if ( ampforwp_is_front_page() ) {
$queried_var = get_query_var('paged');
if ( $queried_var > 1 ) {
$queried_var = $queried_var -1 ;
return $ampforwp_new_content[$queried_var];
return $ampforwp_the_content;
add_filter('ampforwp_modify_rel_canonical','ampforwp_modify_rel_amphtml_paginated_post');
function ampforwp_modify_rel_amphtml_paginated_post($url) {
$post_paginated_page = get_query_var('page');
$permalink_structure = '';
$permalink_structure = get_option('permalink_structure');
if($post_paginated_page){
if('' == $permalink_structure){
$new_url = add_query_arg('page',$post_paginated_page,$url);
$new_url = trailingslashit($url) . user_trailingslashit($post_paginated_page);
if(ampforwp_get_setting('ampforwp-pagination-link-type')==true ){
$new_url = ampforwp_url_controller($new_url);
$new_url = add_query_arg(AMPFORWP_AMP_QUERY_VAR,'1',$new_url);
add_action('amp_post_template_head','ampforwp_modify_rel_canonical_paginated_post',9);
function ampforwp_modify_rel_canonical_paginated_post(){
$post_paginated_page = get_query_var('page');
if($post_paginated_page && !class_exists('Yoast\\WP\\SEO\\Integrations\\Front_End_Integration')){
remove_action( 'amp_post_template_head', 'AMPforWP\\AMPVendor\\amp_post_template_add_canonical' );
add_action('amp_post_template_head','ampforwp_rel_canonical_paginated_post');
function ampforwp_rel_canonical_paginated_post(){
$permalink_structure = '';
$permalink_structure = get_option('permalink_structure');
$current_post_id = $post->ID;
$new_canonical_url = get_permalink($current_post_id);
$new_canonical_url = trailingslashit($new_canonical_url);
$post_paginated_page = get_query_var('page');
if($post_paginated_page){
if('' == $permalink_structure){
$new_canonical_url = add_query_arg('page',$post_paginated_page,$new_canonical_url);
$new_canonical_url = $new_canonical_url.$post_paginated_page;
<link rel="canonical" href="<?php echo esc_url($new_canonical_url) ?>/" /><?php }
add_action('ampforwp_after_post_content','ampforwp_post_pagination');
// Generating Canonical Url for Yoast no index pages.
add_filter( 'wpseo_robots_array', 'ampforwp_yoast_no_index_condition_check',20,2);
function ampforwp_yoast_no_index_condition_check($robots,$object){
if($robots['index'] == 'noindex'){
$yoast_data['canonical'] = $object->model->permalink;
add_action( 'amp_post_template_head', 'ampforwp_generate_yoast_no_index_canonical_url' );
function ampforwp_generate_yoast_no_index_canonical_url(){
if(isset($yoast_data['canonical'])){
$canonical_url = $yoast_data['canonical'];
if(ampforwp_is_home() || ampforwp_is_front_page()){
$canonical_url = user_trailingslashit(get_home_url());
<link rel="canonical" href="<?php echo esc_url($canonical_url) ?>"/>
// Modified Homepage wrong canonical url generated by yoast
add_action('pre_amp_render_post','ampforwp_modify_yoast_amp_homepage_canonical');
function ampforwp_modify_yoast_amp_homepage_canonical(){
add_filter('wpseo_canonical','ampforwp_modify_yoast_homepage_canonical_url',20);
function ampforwp_modify_yoast_homepage_canonical_url($canonical_url){
if(ampforwp_is_home() || ampforwp_is_front_page()){
$canonical_url = user_trailingslashit(get_home_url());
return esc_url($canonical_url);
// 70. Hide AMP by specific Categories & Tags #872
function ampforwp_posts_to_remove () {
if(ampforwp_get_setting('ampforwp-archive-support-cat')==false){
if(ampforwp_get_setting('ampforwp-archive-support-tag')==false){
if(ampforwp_get_setting('hide-amp-categories2')){
if ( has_category(array_filter(ampforwp_get_setting('hide-amp-categories2'))) ) {
if( ampforwp_get_setting('hide-amp-tags-bulk-option2') ) {
if ( has_tag(array_filter(ampforwp_get_setting('hide-amp-tags-bulk-option2') )) ) {