: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
foreach ($nodes as $key => $node) {
$video_id = $node->getAttribute('data-videoid');
$width =$node->getAttribute('width');
$height =$node->getAttribute('height');
$amp_light_box = '<amp-lightbox id="open-video'.esc_attr($video_id).'" layout="nodisplay">
<div class="amp-lightbox-video" on="tap:open-video'.esc_attr($video_id).'.close,btn-play'.esc_attr($video_id).'.show" role="button" tabindex="'.$i.'" aria-label="Close Video">
<div class="amp-video-box">'.$match.'</div>
<div class="amp-video-img" id="btn-play'.esc_attr($video_id).'" on="tap:video.show, video.play, btn-play'.esc_attr($video_id).'.hide,open-video'.esc_attr($video_id).'" role="button" tabindex="'.$i.'" aria-label="Play Video">
<amp-img alt="Video" src="http://i3.ytimg.com/vi/'.esc_attr($video_id).'/hqdefault.jpg" width="'.esc_attr($width).'" height="'.esc_attr($height).'" layout="responsive"></amp-img>
<div class="amp-video-play-on-image"></div>
$content = str_replace("$match", $amp_light_box, $content);
function ampforwp_video_lightbox_css(){
echo '.amp-video-box,.amp-video-img{width:100%;margin:0 auto;text-align:center}
.amp-lightbox-video{background:rgba(0,0,0,.8);width:100%;height:100%;position:absolute;display:flex;align-items:center;justify-content:center}
.amp-video-box{max-width:800px}
.amp-video-img{max-width:600px;position:relative}
.amp-lightbox-video .lb-x { top: 100px; right: 5%; }
.amp-video-play-on-image{cursor:pointer;margin:auto;width:56px;height:56px;-webkit-border-radius:50%;border-radius:50%;background-color:rgba(0,0,0,.2);background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAAY1BMVEVHcEz///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////80LMUcAAAAIHRSTlMA1d4MSXeg9glf6yEq4hfnnr7Z8qm5U/3Jm1pwFJcmBYTgJ9QAAAIjSURBVGje7VnJdoMwDFSMHVMSQljCklX//5U99NQHGEm22gtz9tPAWNYKsGPHDiou1h3rpvDD4Iumvjp7SWg86yeDM5ipz5KYt53HFfjORn+8KzEI88iizLe4icLlUvtfFZJQ3kXmTzWScTsJPr9FBtovpvn8iExMrJu4jMjGyHh67xIFMOSLOFcoQnUmfr/QPmL1JulfohiGcA/5iBEYt33piFG4br4vjMTGizu1sQRt2FlrjMZNVSBExEBszaoUBOW6JzlMArf6A0XIOzyZoMgkPwDnA5nhsWz/E4wRnBxhVuoTDBMAkGVarma6TQKyTN3iFfttAqJMg1/y1B4JBFSZ+gWCiUZAk+m1QGCIBCSZmoVEhlQCkkxPppP+JiDIZNlxiFmYOXaqnEX2sEwTO9XMq6egTPXsfMMlCMt0mB0v2ARBmYrZYS8gCMjkZ2cHCcG6TMPfE6hLpH7J6m6a+KHN67urdqhQD3bq4Vo94ainTP2kn7RssbqFF7a5buk4dP9T/Ib9KEH5Dg/lBkS/hVJvAiEvU9gPtLFwT0HQh1r9m/IoQX8YEj+t2JwCX+PsT7ojtWH8EIaCJmIo+FQeaxJHs9LBbPkGIt4ilQxjxi8ajj+BgZztra8P8MBcUAi2LCdGXJKsWADgTozeppeuoXJXEPKXfM0FANnDaC7qtlaNbfyq8Uep/rXQYDUvm0M6XKyb6sPPuvdwm5x9wo4dO6j4BoilN6H4pmTiAAAAAElFTkSuQmCC);background-position:center;-webkit-background-size:48px 48px;background-size:48px 48px;position:absolute;top:0;bottom:0;left:0;right:0}';
if (class_exists('WPSEO_Options')) {
add_filter('yoast_seo_development_mode','ampforwp_yoast_seo_development');
add_filter('wpseo_debug_json_data','ampforwp_remove_homepage_breadcrumb');
function ampforwp_yoast_seo_development($dev){
$url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH),'/' );
if (ampforwp_get_setting('ampforwp-seo-selection') == 'yoast' && ampforwp_get_setting('ampforwp-seo-yoast-schema') && ampforwp_is_home() && function_exists('ampforwp_is_amp_inURL') && ampforwp_is_amp_inURL($url_path)) {
function ampforwp_remove_homepage_breadcrumb($data){
$url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH),'/' );
if (ampforwp_get_setting('ampforwp-seo-selection') == 'yoast' && ampforwp_get_setting('ampforwp-seo-yoast-schema') && ampforwp_is_home() && function_exists('ampforwp_is_amp_inURL') && ampforwp_is_amp_inURL($url_path)) {
if (isset($data["@graph"][2]["breadcrumb"])) {
unset($data["@graph"][2]["breadcrumb"]);
if(array_key_exists(3, $data["@graph"])) {
if (!empty($data["@graph"][3]["@type"]) && $data["@graph"][3]["@type"] == 'BreadcrumbList') {
unset($data["@graph"][3]);
function ampforwp_sanitize_twitter_title($post_title){
$post_title = html_entity_decode( $post_title, ENT_QUOTES, 'UTF-8' );
$post_title = rawurlencode( $post_title );
$post_title = esc_html( $post_title );
if (function_exists('i2_pros_cons_setup')) {
add_action('amp_post_template_css','ampforwp_i2prosandcons');
function ampforwp_i2prosandcons(){
$options = get_option( 'i2_pros_and_cons');
$prosHeadingBackground = $options['pros_heading_background'];
$consHeadingBackground = $options['cons_heading_background'];
$prosBackground = $options['pros_background'];
$consBackground = $options['cons_background'];
$headingFontSize = $options['heading_font_size'];
$sectionFontSize = $options['body_font_size'];
$headingColor = $options['heading_color'];
$sectionColor = $options['body_color'];?>
.i2-pros-cons-main-wrapper .i2-pros-cons-wrapper {
.i2-pros-cons-main-wrapper .i2-pros-cons-wrapper .i2-pros, .i2-pros-cons-main-wrapper .i2-pros-cons-wrapper .i2-cons {
.i2-pros-cons-main-wrapper .i2-pros-cons-wrapper .i2-pros .i2-pros-title, .i2-pros-cons-main-wrapper .i2-pros-cons-wrapper .i2-pros .i2-cons-title, .i2-pros-cons-main-wrapper .i2-pros-cons-wrapper .i2-cons .i2-pros-title, .i2-pros-cons-main-wrapper .i2-pros-cons-wrapper .i2-cons .i2-cons-title {
.i2-pros-cons-wrapper .i2-pros-title {
background-color:<?php echo ampforwp_sanitize_color($prosHeadingBackground); ?>;
font-size:<?php echo esc_html($headingFontSize); ?>px;
.i2-pros-cons-wrapper .i2-cons-title, .i2-pros-cons-wrapper .i2-pros-title {
color: #ffffff!important;
font-size:<?php echo esc_html($headingFontSize); ?>px;
background-color: <?php echo ampforwp_sanitize_color($prosBackground); ?>;
background-color: <?php echo ampforwp_sanitize_color($consBackground); ?>;
.i2-pros-cons-wrapper ul li{
font-size:<?php echo esc_html($sectionFontSize); ?>px;
.i2-pros-cons-wrapper .i2-cons-title {
background-color: <?php echo ampforwp_sanitize_color($consHeadingBackground); ?>;
.i2-pros-cons-wrapper .i2-pros, .i2-pros-cons-wrapper .i2-cons{
color: <?php echo ampforwp_sanitize_color($sectionColor); ?>;
.i2-pros-cons-wrapper .i2-cons-title, .i2-pros-cons-wrapper .i2-pros-title {
color: <?php echo ampforwp_sanitize_color($headingColor); ?>;
function ampforwp_modify_url_utm_params($url){
if(true == ampforwp_get_setting('ampforwp-related-post-utm-tracking-switch') && !empty(ampforwp_get_setting('ampforwp-related-posts-utm-tracking'))){
$modify_url = ampforwp_get_setting('ampforwp-related-posts-utm-tracking');
$modify_url = apply_filters('ampforwp_modify_related_post_url', $modify_url);
$url = add_query_arg($modify_url, '' , $url);
return esc_url_raw($url);
return esc_url_raw($url);
if(true == ampforwp_get_setting('ampforwp-recent-post-utm-tracking-switch') && !empty(ampforwp_get_setting('ampforwp-recent-posts-utm-tracking'))){
add_filter('ampforwp_loop_permalink_update','ampforwp_recent_posts_utm_tracking');
function ampforwp_recent_posts_utm_tracking($recent_post_permalink){
$modify_url = ampforwp_get_setting('ampforwp-recent-posts-utm-tracking');
$modify_url = apply_filters('ampforwp_modify_recent_post_url', $modify_url);
$recent_post_permalink = add_query_arg($modify_url, '' , $recent_post_permalink);
return esc_url_raw($recent_post_permalink);
return esc_url_raw($recent_post_permalink);
if(ampforwp_get_setting('ampforwp-facebook-comments-support')){
add_action('amp_post_template_head','ampforwp_facebook_moderation_tool');
function ampforwp_facebook_moderation_tool(){
$facebook_app_id = ampforwp_get_setting('ampforwp-fb-moderation-app-id');
if($facebook_app_id!=''){
<meta property="fb:app_id" content="<?php echo esc_attr($facebook_app_id);?>" />
$facebook_admin_id = ampforwp_get_setting('ampforwp-fb-moderation-admin-id');
if($facebook_admin_id!=''){
$ids = explode(",", $facebook_admin_id);
for($i=0;$i<count($ids);$i++){
<meta property="fb:admins" content="<?php echo esc_attr($id);?>"/>
//Schema Pro FAQ block compatibility #4956
add_filter('ampforwp_modify_the_content','ampforwp_schema_pro_faq_block');
function ampforwp_schema_pro_faq_block($content_buffer){
if (!function_exists('on_bsf_aiosrs_pro_activate')) {
preg_match_all('/<div class="wp-block-wpsp-faq(.*?)class="wpsp-question">(.*?)<\/(.*?)>(.*?)class="wpsp-faq-content"><span><p>(.*?)<\/p>/', $content_buffer, $matches);
$schema['@context'] = 'https://schema.org';
$schema['type'] = 'FAQPage';
for($i=0;$i<count($matches[2]);$i++){
$questions = $matches[2];
foreach ( $questions as $key => $question ) {
$schema['mainEntity'][ $key ]['@type'] = 'Question';
$schema['mainEntity'][ $key ]['name'] = $question;
foreach ( $answers as $key => $answer ) {
$schema['mainEntity'][ $key ]['acceptedAnswer']['@type'] = 'Answer';
$schema['mainEntity'][ $key ]['acceptedAnswer']['text'] = $answer;
$schema = '<script type="application/ld+json">'.wp_json_encode( $schema, JSON_UNESCAPED_UNICODE ).'</script>';
$content_buffer = preg_replace('/(<div class="wp-block-wpsp-faq\s(.*?)<\/div>)/s', ''.$schema.'$1', $content_buffer);
function ampforwp_get_gitty_image_embed( $html, $url, $attr, $post_ID ) {
global $getty_img_content;
$getty_img_content[] = $html;
function ampforwp_getty_image_compatibility($content){
global $getty_img_content;
if(is_array($getty_img_content)){
if(preg_match_all('/<a id="(.*?)"\sclass="gie-single(.*?)">Embed from Getty Images<\/a>/', $content, $matches)){
for($i=0;$i<count($matches[0]);$i++){
$full_content = $matches[0][$i];
$img_id = $matches[1][$i];
if(isset($getty_img_content[$i])){
if(preg_match('/gie\.widgets\.load\({id:\'(.*?)\',sig:\'(.*?)\',w:\'(.*?)\',h:\'(.*?)\',items:\'(.*?)\'/',$getty_img_content[$i],$match)){
if(isset($match[1]) && isset($match[2]) && isset($match[3]) && isset($match[4]) && isset($match[5])){
$iframe = '<iframe src="//embed.gettyimages.com/embed/'.esc_attr($img_emb_id).'?et='.esc_attr($image_id).'&tld=com&sig='.esc_attr($image_key).'&caption=false&ver=2" scrolling="no" frameborder="0" width="'.esc_attr($width).'" height="'.esc_attr($height).'"></iframe>';
$description = get_the_archive_description();
$sanitizer = new AMPFORWP_Content( $iframe, array(),
apply_filters( 'ampforwp_content_sanitizers',
'AMP_Style_Sanitizer' => array(),
'AMP_Blacklist_Sanitizer' => array(),
'AMP_Img_Sanitizer' => array(),
'AMP_Video_Sanitizer' => array(),
'AMP_Audio_Sanitizer' => array(),
'AMP_Iframe_Sanitizer' => array(
'add_placeholder' => true,
$iframe_content = $sanitizer->get_amp_content();
$content = str_replace($full_content, $iframe_content, $content );
if(function_exists('vp_pfui_admin_init') && function_exists('penci_setup')){
add_action('ampforwp_before_post_content','ampforwp_pennews_audio_embed');
function ampforwp_pennews_audio_embed(){
$audio = get_post_meta(ampforwp_get_the_ID(), '_format_audio_embed', true);
$audio = preg_replace('/<iframe(.*?)width="(.*?)%"(.*?)<\/iframe>/', '<iframe$1width="1000"$3</iframe>', $audio);
$audio_str = substr( $audio, -4 );
$html ='<div class="audio-iframe">';
if ( wp_oembed_get( $audio ) ) {
$html .= wp_oembed_get( $audio );
}elseif( $audio_str == '.mp3' ) {
$html .= do_shortcode('[audio src="'. esc_url( $audio ) .'"]');
$html .= do_shortcode( $audio );
$sanitizer = new AMPFORWP_Content( $html, array(),
apply_filters( 'ampforwp_content_sanitizers',
'AMP_Audio_Sanitizer' => array(),
'AMP_Iframe_Sanitizer' => array(
'add_placeholder' => true,
$sanitized_html = $sanitizer->get_amp_content();
if(function_exists('penci_soledad_theme_setup')){
add_action('ampforwp_before_post_content','ampforwp_penci_format_video_embed');
add_filter('ampforwp_modify_featured_image','ampforwp_penci_remove_featured_image');
function ampforwp_penci_format_video_embed($content){
$penci_video = get_post_meta( get_the_ID(), '_format_video_embed', true );
if(!empty($penci_video) && $penci_video != ''){
$penci_video = 'https://www.youtube.com/watch?v=pMFEDv9Chlw';
$video_html = '<div class="amp fluid-width-video-wrapper">';
if(strpos($penci_video, 'youtu') !== false){
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $penci_video, $match)){
$video_html .= '<amp-youtube width="480" height="270" layout="responsive" data-videoid="'.$video_id.'" loop autoplay></amp-youtube>';
}elseif(strpos($penci_video, 'vimeo')){
if (preg_match('%^https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)(?:[?]?.*)$%im', $penci_video, $regs)){
$video_html .= '<amp-vimeo data-videoid="'.$video_id.'" layout="responsive" width="16" height="9" loop autoplay></amp-vimeo>';
$video_html .= '<amp-video width="480" height="270" src="'.$penci_video.'" layout="responsive" loop autoplay>
<p>Your browser doesn\'t support HTML5 video.</p>
<source type="video/mp4" src="'.$penci_video.'>
//Remove Image if video is present.
function ampforwp_penci_remove_featured_image($amp_html){
$penci_video = get_post_meta( get_the_ID(), '_format_video_embed', true );
if(!empty($penci_video) && $penci_video != ''){
//Alignment issue with Gutenberg image block #4997
add_filter('ampforwp_modify_the_content','ampforwp_wp_block_cover_image');
function ampforwp_wp_block_cover_image($content_buffer){
if(ampforwp_get_setting('ampforwp_css_tree_shaking') && ampforwp_is_gutenberg_active()){
preg_match_all('/<amp-img(.*?)class="wp-block-cover__image-background(.*?)"(.*?)src="(.*?)"(.*?)<\/amp-img>/', $content_buffer, $matches);
if(is_array($matches) && isset($matches[4][0])){
$img_url = $matches[4][0];
$content_buffer = preg_replace('/<div(.*?)class="wp-block-cover(.*?)"><amp-img(.*?)<\/amp-img>/', '<div$1style="background-image:url('.$img_url.');" class="wp-block-cover$2"><amp-img$3</amp-img>', $content_buffer);
$content_buffer = preg_replace('/<amp-img(.*?)class="wp-block-cover__image-background(.*?)"(.*?)src="(.*?)"(.*?)<\/amp-img>/', '', $content_buffer);
function ampforwp_mobile_redirection_js() {
$url_to_redirect = ampforwp_amphtml_generator();?>
window.location = "<?php echo esc_url($url_to_redirect); ?>";
function ampforwp_webp_express_compatibility($content){
if(function_exists('webp_express_process_post')){
preg_match_all('/src="(.*?)"/', $content,$src);
$img_url = esc_url($src[1][0]);
if(preg_match('/m\.media-amazon/', $img_url)){
if(!preg_match('/\.webp/', $img_url)){
$config = \WebPExpress\Config::loadConfigAndFix();
if($config['destination-folder'] == 'mingled'){
$img_url_webp = $img_url;
$img_url_webp = preg_replace('/http(.*?)\/wp-content(.*?)/', 'http$1/wp-content/webp-express/webp-images$2', $img_url);
if($config['destination-structure'] == 'doc-root'){
$img_url_webp = preg_replace('/http(.*?)\/wp-content(.*?)/', 'http$1/wp-content/webp-express/webp-images/doc-root/wp-content$2', $img_url);
if(!preg_match('/\.webp/', $img_url)){
$img_url_webp = esc_url($img_url_webp).".webp";
$content = str_replace($img_url, $img_url_webp, $content);
add_action('amp_post_template_css','ampforwp_set_local_font',33);
if(!function_exists('ampforwp_set_local_font')){
function ampforwp_set_local_font(){
if(ampforwp_get_setting('ampforwp-local-font-switch') && ampforwp_get_setting('ampforwp-local-font-upload','url')!=""){
$upload_dir = wp_upload_dir();
$user_dirname = $upload_dir['basedir'] . '/' . 'ampforwp-local-fonts';
if ( file_exists( $user_dirname ) ) {
$files = glob( $user_dirname . '/*' );
$font_css = '@font-face {';
foreach ( $files as $file ) {
$fonts = explode("/", $file);
$font_name = end($fonts);
$ext = end(explode(".", $font_name));
$font_arr = explode('-', $font_name);
$font_family = $font_arr[0];
$font_css .= "font-family: '".esc_attr(ucfirst($font_family))."'; font-style: normal; font-weight: 400;";
$font_path = $upload_dir['baseurl'].'/'.'ampforwp-local-fonts/'.$font_name;
$font_css .= "src: url('".esc_url($font_path)."'); src: url('".esc_url($font_path)."?#iefix') format('embedded-opentype'),";
$font_css .= "src: url('".esc_url($font_path)."?#".esc_attr(ucfirst($font_family))."') format('svg'),";
$font_css .= "src: url('".esc_url($font_path)."') format('truetype'),";
$font_css .= "src: url('".esc_url($font_path)."') format('".esc_attr($ext)."'),";
if(!empty($font_family) && $font_family != ''){
$font_css .= "body, .cntn-wrp {font-family: '".esc_attr(ucfirst($font_family))."'}";
function ampforwp_year_shortcode() {
add_shortcode('ampforwp_current_year', 'ampforwp_year_shortcode');
function ampforwp_litespeed_webp_compatibility($content){
if(class_exists( 'WP_Offload_Media_Autoloader')){
if(function_exists( 'run_litespeed_cache' )){
preg_match_all('/src="(.*?)"/', $content,$src);
$img_url = esc_url($src[1][0]);
if(!preg_match('/\.webp/', $img_url)){
$rep_url = esc_url($src[1][0]).".webp";
if(preg_match('/http(.*)\/wp-content\/uploads/', $rep_url)){
$upload_dir = wp_upload_dir()['basedir'];
$img_file = preg_replace('/http(.*)\/wp-content\/uploads/', $upload_dir, $rep_url);
if(file_exists($img_file)){
$content = str_replace($img_url, $rep_url, $content);
$content = str_replace('.webp.webp','.webp',$content);
if (ampforwp_get_setting('amp-core-end-point') && function_exists('get_rocket_cache_query_string') ) {
add_filter('rocket_cache_query_strings', 'ampforwp_rocket_cache_query_string');
function ampforwp_rocket_cache_query_string($query_strings){
array_push($query_strings,"amp");
function ampforwp_publisher_desk_ads_insert( $ads, $content ) {
if ( ! is_array( $ads ) ) {
$paragraphs = explode( $closing_p, $content );
foreach ($paragraphs as $index => $paragraph) {
if ( trim( $paragraph ) ) {
$paragraphs[$index] .= $closing_p;
if ( isset( $ads[ $n ] ) ) {
$paragraphs[$index] .= $ads[ $n ];
return implode( '', $paragraphs );
add_filter( 'ampforwp_modify_the_content', 'ampforwp_publisher_desk_ads' );
function ampforwp_publisher_desk_ads( $content ) {
if (!ampforwp_get_setting('ampforwp-ads-publisherdesk')) {
$pub_id = ampforwp_get_setting('ampforwp-publisherdesk-id');
$url = 'https://cdn.tpdads.com/json/amp-tags/'.esc_html($pub_id).'.json';
$data_api = wp_remote_get($url);