: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if (class_exists('YoastSEO_AMP_Frontend') ) { ?>
a {text-decoration:none;}
if ( isset($redux_builder_amp['ampforwp-underline-content-links']) && $redux_builder_amp['ampforwp-underline-content-links'] ) { ?>
.the_content a {text-decoration:underline;}
// Filter for Frontpage id
add_filter('ampforwp_modify_frontpage_id', 'ampforwp_modified_frontpage_id');
if( ! function_exists('ampforwp_modified_frontpage_id') ) {
function ampforwp_modified_frontpage_id($page_id){
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
// WPML Compatibility #1111
if( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' )){
$page_id = get_option('page_on_front');
// Polylang Compatibility #1779
elseif( ampforwp_polylang_front_page() ){
$frontpage_id = get_option('page_on_front');
$page_id = pll_get_post($frontpage_id);
add_filter('ampforwp_modify_ads', 'ampforwp_nonamp_ads',10, 5);
if ( ! function_exists('ampforwp_nonamp_ads') ) {
function ampforwp_nonamp_ads($output, $width, $height, $client_id, $data_slot) {
if ( ampforwp_is_non_amp('non_amp_check_convert') ) {
$output = ' <div class="add-wrapper" style="text-align:center;">
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
<ins class="adsbygoogle" style="display:inline-block;width:'.esc_attr($width).';height:'.esc_attr($height).'" data-ad-client="'.esc_attr($client_id).'" data-ad-slot="'.esc_attr($data_slot).'">
(adsbygoogle = window.adsbygoogle || []).push({});
//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") ) {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '$ga_account', 'auto');
// 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']);
//remove anchor from the image when lightbox option is enabled #2695
add_action('pre_amp_render_post','ampforwp_remove_ahref_lightbox');
function ampforwp_remove_ahref_lightbox(){
if(true == ampforwp_get_setting('ampforwp-amp-img-lightbox') ){
add_filter( 'the_content', 'ampforwp_remove_ahref_lightbox_in_amp' );
add_filter('tablepress_table_render_data','amforwp_remove_tp_image_href');
function ampforwp_remove_ahref_lightbox_in_amp( $content ) {
preg_match_all('/(<a(.*?)href=\"(.*?)\"(.*?)>(.*?)<img(.*?)src=\"(.*?)\"(.*?)(.*?)[^>]*>)/', $content, $matches);
for( $i=0;$i<count($matches[3]);$i++){
$href_url = $matches[3][$i];
$href_url = explode('/', $href_url);
$href_url = end($href_url);
$href_url = pathinfo($href_url, PATHINFO_FILENAME);
if($matches[3][$i] == $matches[7][$i] || (!empty($href_url) && strpos($matches[7][$i], $href_url) !== false)){
$href_src = str_replace( '/', '\/', esc_url($href));
$image_src = str_replace( '/', '\/', esc_url($src));
$content = preg_replace('/<a(.*?)href=\"'.$href_src.'\"(.*?)>(<img(.*?)src=\"'.$image_src.'\"(.*?)[^>]*>)<\/a>/i', '$3', $content);
function amforwp_remove_tp_image_href( $orig_table){
$tablepressData = array();
foreach ($orig_table['data'] as $cols) {
for($i=0;$i< count($cols);$i++){
$tablepressData[$j][$i] = preg_replace("/<a[^>]+\>(<img[^>]+\>)<\/a>/i",'$1', $cols[$i]);
$orig_table['data'] = $tablepressData;
// amp-image-lightbox #1892
if ( ! function_exists('ampforwp_amp_img_lightbox') ) {
function ampforwp_amp_img_lightbox(){
echo '<amp-image-lightbox id="amp-img-lightbox" layout="nodisplay"></amp-image-lightbox>';
// 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 ( ampforwp_get_setting('ampforwp-amp-img-lightbox') ) {
$attributes['on'] = 'tap:amp-img-lightbox';
$attributes['role'] = 'button';
$attributes['tabindex'] = '0';
// 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 '<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.12";
fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));</script>';
// 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') );
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');
function ampforwp_404_canonical(){
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){
if ( get_query_var( 'paged' ) ) {
$paged = get_query_var('paged');
} elseif ( get_query_var( 'page' ) ) {
$paged = get_query_var('page');
if( $numpages >= 2 && true == ampforwp_get_setting('amp-pagination') ){
return get_the_content();
// Moved to notice-bar-functions.php
// 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() ) {
// 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 and Rank Math #2701
function ampforwp_generate_canonical(){
global $redux_builder_amp;
$canonical = $WPSEO_Frontend = $All_in_One_SEO_Pack = $opts = '';
if ( 'yoast' == ampforwp_get_setting('ampforwp-seo-selection') && true == ampforwp_get_setting('ampforwp-seo-yoast-canonical') && class_exists('WPSEO_Frontend') && !class_exists('Yoast\\WP\\SEO\\Integrations\\Front_End_Integration')) {
$WPSEO_Frontend = WPSEO_Frontend::get_instance();
$canonical = $WPSEO_Frontend->canonical(false);
elseif ( 'aioseo' == ampforwp_get_setting('ampforwp-seo-selection') && true == ampforwp_get_setting('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'];
elseif ( defined( 'RANK_MATH_FILE' ) && 'rank_math' == ampforwp_get_setting('ampforwp-seo-selection') && ampforwp_get_setting( 'ampforwp-seo-rank_math-canonical' ) ) {
$canonical = \RankMath\Paper\Paper::get()->get_canonical();
add_filter('amp_post_template_data', 'ampforwp_modified_canonical', 85);
function ampforwp_modified_canonical( $data ) {
$canonical = ampforwp_generate_canonical();
if ( !empty($canonical) ) {
$data['canonical_url'] = $canonical;
if(class_exists('WPSEO_Frontend') && 'yoast' == ampforwp_get_setting('ampforwp-seo-selection') && true == ampforwp_get_setting('ampforwp-seo-yoast-canonical') && !class_exists('Yoast\\WP\\SEO\\Integrations\\Front_End_Integration') ){
add_filter('ampforwp_modify_rel_url','ampforwp_yoast_canonical');
function ampforwp_yoast_canonical($canonical){
if(ampforwp_is_front_page()){
$canonical = ampforwp_generate_canonical();
// #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' );
function ampforwp_return_no_gap(){
#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 ( false == ampforwp_get_setting('ampforwp-display-on-pages') && true == ampforwp_get_setting('ampforwp-display-on-posts') ) {
$display_comments_on = is_single();
if ( true == ampforwp_get_setting('ampforwp-display-on-pages') && false == ampforwp_get_setting('ampforwp-display-on-posts') ) {
$display_comments_on = is_page();
if ( true == ampforwp_get_setting('ampforwp-display-on-pages') && true == ampforwp_get_setting('ampforwp-display-on-posts')) {
$display_comments_on = is_singular();
if ( ampforwp_is_front_page() ) {
$display_comments_on = ampforwp_is_front_page();
$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 ( true == ampforwp_get_setting('ampforwp-vuukle-comments-support') && comments_open() && ampforwp_get_setting('amp-design-selector') != 4) {
echo ampforwp_vuukle_comments_markup();
function ampforwp_vuukle_comments_markup() {
global $redux_builder_amp,$post;
$img = get_the_post_thumbnail_url();
$tags = get_the_tags($post->ID);
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;
$img = plugins_url('accelerated-mobile-pages/images/150x150.png');
foreach($tags as $individual_tag) {
$tag_name = $individual_tag->name;
$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);
$srcUrl = add_query_arg('img' , esc_url($img), $srcUrl);
$srcUrl = add_query_arg('tags' , urlencode($tag_name), $srcUrl);
if(ampforwp_get_setting('ampforwp-vuukle-comments-emoji')==false){
$srcUrl = add_query_arg('emotes' , 'false', $srcUrl);
if(ampforwp_get_data_consent()){
$consent = 'data-block-on-consent ';
if ( $display_comments_on ) {
$vuukle_html .= '<amp-iframe width="600" height="350" '.esc_attr($consent).'layout="responsive" sandbox="allow-scripts allow-same-origin allow-modals allow-popups allow-forms" resizable frameborder="0" src="'.esc_url($srcUrl).'">
<div overflow tabindex="0" role="button" aria-label="Show comments" class="afwp-vuukle-support">Show comments</div></amp-iframe>';
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 (ampforwp_get_setting('ampforwp-vuukle-Ads-before-comments') && empty( $data['amp_component_scripts']['amp-ad'] ) ) {
$data['amp_component_scripts']['amp-ad'] = 'https://cdn.ampproject.org/v0/amp-ad-0.1.js';
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() {
$display_comments_on = false;
$display_comments_on = ampforwp_get_comments_status();
if (! $display_comments_on ) {
if( true == ampforwp_get_setting('ampforwp-spotim-comments-apiKey') && ampforwp_get_setting('ampforwp-spotim-comments-apiKey') !== ""){
$spotId = ampforwp_get_setting('ampforwp-spotim-comments-apiKey');
$srcUrl = 'https://amp.spot.im/production.html?spot_im_highlight_immediate=true';
$srcUrl = add_query_arg('spotId' ,$spotId, $srcUrl);
$srcUrl = add_query_arg('postId' , $post->ID, $srcUrl);
$spotim_html = '<amp-iframe width="375" height="815" resizable sandbox="allow-scripts allow-same-origin allow-popups allow-top-navigation" layout="responsive"
frameborder="0" src="'.esc_url($srcUrl).'">
<amp-img placeholder height="815" layout="fill" src="//amp.spot.im/loader.png"></amp-img>
<div overflow class="spot-im-amp-overflow" tabindex="0" role="button" aria-label="Read more">Load more...</div>
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';
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 {
font-family: Helvetica, Arial, sans-serif;
if ( isset($redux_builder_amp['ampforwp-vuukle-comments-support'])
&& $redux_builder_amp['ampforwp-vuukle-comments-support']
&& $display_comments_on && comments_open() ) { ?>
display: block;text-align: center;background: #1f87e5;color: #fff;border-radius: 4px;
function ampforwp_check_excerpt(){
global $redux_builder_amp;
$value = ( isset( $redux_builder_amp['excerpt-option'] ) && $redux_builder_amp['excerpt-option'] ) ;
add_action( 'ampforwp_body_beginning' ,'ampforwp_back_to_top_markup');
function ampforwp_back_to_top_markup(){
if(true == ampforwp_get_setting('ampforwp-footer-top')){
echo '<div id="backtotop"></div>';
// rel="next" & rel="prev" pagination meta tags #2343
add_action( 'amp_post_template_head', 'ampforwp_rel_next_prev' );
function ampforwp_rel_next_prev(){
if(ampforwp_is_front_page()){
if ( get_previous_posts_link() ) { ?>
<link rel="prev" href="<?php echo esc_url(get_pagenum_link( $paged - 1 )); ?>" /><?php
if ( get_next_posts_link() ) { ?>
<link rel="next" href="<?php echo esc_url(get_pagenum_link( $paged + 1 )); ?>" /><?php
// Content Sneak Peek #2246
add_action('pre_amp_render_post', 'ampforwp_content_sneak_peek');
if ( ! function_exists('ampforwp_content_sneak_peek') ) {
function ampforwp_content_sneak_peek() {
global $redux_builder_amp;
if ( ampforwp_get_setting('content-sneak-peek') && is_single() && 'post' == get_post_type() ) {
add_filter('ampforwp_modify_the_content', 'ampforwp_sneak_peek_content_modifier');
add_action('amp_post_template_css','ampforwp_sneak_peek_css');
add_filter('ampforwp_post_template_data','ampforwp_sneak_peek_scripts');