: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
//Remove ResponsifyWP #1131
add_action('plugins_loaded', 'ampforwp_filter_remove_function_responsifywp');
function ampforwp_filter_remove_function_responsifywp(){
if(is_plugin_active('responsify-wp/responsify-wp.php')){
add_filter('rwp_add_filters','removeFilterOfResponsify');
function removeFilterOfResponsify($filter){
add_action('pre_amp_render_post','ampforwp_thirdparty_compatibility');
function ampforwp_thirdparty_compatibility(){
// Remove Schema theme Lazy Load #1170
remove_filter( 'wp_get_attachment_image_attributes', 'mts_image_lazy_load_attr', 10, 3 );
remove_filter('the_content', 'mts_content_image_lazy_load_attr');
//Remove CSS header from the GoodLife Theme #2673
remove_filter('amp_post_template_file', 'thb_custom_amp_templates');
remove_action( 'amp_post_template_css', 'thb_amp_additional_css_styles' );
// Viewport appear more than once in Zox news theme. #2971
if ( function_exists( 'mvp_setup' ) && ampforwp_get_setting('amp-design-selector') != 4 ) {
remove_action( 'amp_post_template_head','ampforwp_add_meta_viewport');
//Menu css is not loading when directory plus theme is active. #2963
remove_filter('wp_nav_menu_args',array('AitMenu','modify_arguments'),100);
// #3124 enfold theme shortcodes removed
add_filter('the_content','ampforwp_remove_enfold_theme_shortcodes_tags');
if ( in_array( 'wordproof-timestamp/wordproof-timestamp.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
add_filter('amp_post_template_data','ampforwp_compatibility_filter_tags_for_wordproof_plugin');
if ( in_array( 'opensea/opensea.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
add_filter('amp_post_template_data','ampforwp_compatibility_for_opensea_plugin');
add_filter('amp_post_template_data','ampforwp_add_target_attribute_in_form_tags');
// AMP is not working due to JCH Optimize Pro plugin #3185
remove_action('shutdown', 'jch_buffer_end', -1);
//ShortPixel Plugin Compatibility to remove picture tag in amp #3439
remove_filter( 'the_content', 'shortPixelConvertImgToPictureAddWebp', 10000 );
remove_filter( 'the_excerpt', 'shortPixelConvertImgToPictureAddWebp', 10000 );
remove_filter( 'post_thumbnail_html', 'shortPixelConvertImgToPictureAddWebp');
//Validation error with Authentic theme #3535
remove_filter( 'amp_post_template_data', 'csco_amp_post_template_data', 10, 2 );
//Breaking the layout with diginex theme #4068
if(function_exists('airkit_widgetFileAutoloader')){
remove_filter( 'amp_post_template_file', 'airkit_amp_set_custom_style_path', 10, 3 );
//Validation errors in amp category page due to HotWP PRO #3455
if(function_exists('hotwp_get_option') && is_category()){
remove_all_filters('get_the_archive_title');
if(function_exists('thb_remove_youtube_controls')){
remove_filter( 'embed_handler_html', 'thb_remove_youtube_controls', 10, 2 );
if (function_exists('gpress_switch_theme')) {
remove_filter('the_content', 'add_data_atts');
if(class_exists( 'Jetpack_RelatedPosts' ) && false == ampforwp_get_setting('ampforwp-jetpack-related-posts')){
$jprp = Jetpack_RelatedPosts::init();
remove_filter( 'the_content', array( $jprp, 'filter_add_target_to_dom' ), 40 );
if(function_exists('heateor_sss_save_default_options') && false == ampforwp_get_setting('ampforwp-sassy_social-switch') ){
add_filter('heateor_sss_disable_sharing','ampforwp_removing_sassy_social_share');
if(function_exists('defer_parsing_of_js')){
remove_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
if(class_exists('gdlr_core_page_builder')){
add_filter('the_content','ampforwp_gdlr_core_page_builder_content',12);
if(function_exists('vicomi_feelbacks_template')){
remove_action('the_content', 'vicomi_feelbacks_template');
if(class_exists('FinalTiles_Gallery')){
add_filter('wp_is_mobile','ampforwp_final_tiles_grid_gallery');
if(class_exists('Getty_Images')){
add_filter( 'embed_oembed_html', 'ampforwp_get_gitty_image_embed',10,4);
add_filter( 'ampforwp_the_content_last_filter','ampforwp_getty_image_compatibility',10);
if(function_exists('megashop_setup')){
remove_filter( 'wp_nav_menu_args', 'TT_nav_menu_args' );
if (function_exists('vinkmag_action_setup')) {
remove_action( 'amp_post_template_head', 'vinkmag_amp_fonts', 1 );
if(function_exists('zeen_lazyload_images')){
add_filter('zeen_lazy_embedded_images','ampforwp_zeen_lazyload');
$yoast_canonical = $yoast_canonical_post = $yoast_canonical_page = '';
$yoast_canonical = get_option( 'wpseo_titles' );
if(isset($yoast_canonical['noindex-post'])){
$yoast_canonical_post = $yoast_canonical['noindex-post'];
if(isset($yoast_canonical['noindex-page'])){
$yoast_canonical_page = $yoast_canonical['noindex-page'];
if (class_exists('WPSEO_Options') && 'yoast' == ampforwp_get_setting('ampforwp-seo-selection') && $yoast_canonical_post && $yoast_canonical_page && WPSEO_Meta::get_value( 'meta-robots-noindex', ampforwp_get_the_ID()) != 2) {
add_action( 'amp_post_template_head', 'AMPforWP\\AMPVendor\\amp_post_template_add_canonical' );
}elseif(class_exists('WPSEO_Options') && 'yoast' == ampforwp_get_setting('ampforwp-seo-selection') && is_page() && $yoast_canonical_page ){
add_action( 'amp_post_template_head', 'AMPforWP\\AMPVendor\\amp_post_template_add_canonical' );
}elseif(class_exists('WPSEO_Options') && 'yoast' == ampforwp_get_setting('ampforwp-seo-selection') && is_single() && $yoast_canonical_post ){
add_action( 'amp_post_template_head', 'AMPforWP\\AMPVendor\\amp_post_template_add_canonical' );
}elseif (class_exists('WPSEO_Options') && 'yoast' == ampforwp_get_setting('ampforwp-seo-selection') && WPSEO_Meta::get_value( 'meta-robots-noindex', ampforwp_get_the_ID()) == 1) {
add_action( 'amp_post_template_head', 'AMPforWP\\AMPVendor\\amp_post_template_add_canonical' );
if(class_exists('\\EmbedPress\\Ends\\Front\\Handler')){
remove_filter('the_content', ['\\EmbedPress\\Ends\\Front\\Handler', 'autoEmbedUrls']);
add_filter('the_content', [$wp_embed, 'autoembed'], 8);
add_filter('the_content', [$wp_embed, 'run_shortcode'], 8);
function ampforwp_removing_sassy_social_share(){
//Updater to check license
require_once AMPFORWP_PLUGIN_DIR . '/includes/updater/update.php';
//Facility to create child theme For AMP
add_filter( 'amp_post_template_file', 'ampforwp_child_custom_header_file', 20, 3 );
add_filter( 'amp_post_template_file', 'ampforwp_child_designing_custom_template', 20, 3 );
add_filter( 'amp_post_template_file', 'ampforwp_child_custom_footer_file', 20, 3 );
function ampforwp_theme_template_directry(){
$folder_name = 'ampforwp';
$folder_name = apply_filters('ampforwp_template_locate', $folder_name);
return get_stylesheet_directory() . '/' . $folder_name;
function ampforwp_child_custom_header_file( $file, $type, $post ) {
if ( 'header' === $type ) {
$file = ampforwp_theme_template_directry() . '/header.php';
if ( 'header-bar' === $type ) {
$file = ampforwp_theme_template_directry() . '/header-bar.php';
function ampforwp_child_designing_custom_template( $file, $type, $post ) {
if(is_page() && !is_page_template()){
global $redux_builder_amp;
$filePath = ampforwp_theme_template_directry();
if( 'single' === $type && ! ('product' === $post->post_type) ) {
$file = $filePath . '/single.php';
if( 'single' === $type && ! ('product' === $post->post_type) ) {
$file = $filePath . '/page.php';
if ( 'loop' === $type ) {
$file = $filePath . '/loop.php';
if ( 'single' === $type ) {
$file = $filePath . '/archive.php';
if ( is_404() && 'single' === $type) {
$file = $filePath . '/404.php';
$ampforwp_custom_post_page = ampforwp_custom_post_page();
if ( 'single' === $type ) {
$file = $filePath . '/index.php';
if ( $redux_builder_amp['amp-frontpage-select-option'] == 1 ) {
$file = $filePath . '/page.php';
if ( ampforwp_is_blog() ) {
$file = $filePath . '/index.php';
if ( 'single' === $type ) {
$file = $filePath . '/search.php';
if ( 4 != ampforwp_get_setting('amp-design-selector') ) {
if ( 'ampforwp-the-title' === $type ) {
$file = $filePath .'/elements/title.php' ;
if ( 'ampforwp-meta-info' === $type ) {
$file = $filePath .'/elements/meta-info.php' ;
if ( 'ampforwp-featured-image' === $type ) {
$file = $filePath .'/elements/featured-image.php' ;
if ( 'ampforwp-bread-crumbs' === $type ) {
$file = $filePath .'/elements/bread-crumbs.php' ;
if ( 'ampforwp-the-content' === $type ) {
$file = $filePath .'/elements/content.php' ;
if ( 'ampforwp-meta-taxonomy' === $type ) {
$file = $filePath .'/elements/meta-taxonomy.php' ;
if ( 'ampforwp-social-icons' === $type ) {
$file = $filePath .'/elements/social-icons.php' ;
if ( 'ampforwp-comments' === $type ) {
$file = $filePath .'/elements/comments.php' ;
if ( 'ampforwp-simple-comment-button' === $type ) {
$file = $filePath .'/elements/simple-comment-button.php' ;
if ( 'ampforwp-related-posts' === $type ) {
$file = $filePath .'/elements/related-posts.php' ;
case ampforwp_is_front_page():
$templates[] = $filePath . "/front-page.php";
foreach ( $templates as $key => $value ) {
if ( 'single' == $type && file_exists($value) ) {
$templates[] = $filePath . "/home.php";
$templates[] = $filePath . "/index.php";
foreach ( $templates as $key => $value ) {
if ( 'single' == $type && file_exists($value) ) {
$term = get_queried_object();
if ( ! empty( $term->slug ) ) {
$taxonomy = $term->taxonomy;
$slug_decoded = urldecode( $term->slug );
if ( $slug_decoded !== $term->slug ) {
$templates[] = $filePath . "/taxonomy-$taxonomy-{$slug_decoded}.php";
$templates[] = $filePath . "/taxonomy-$taxonomy-{$term->slug}.php";
$templates[] = $filePath . "/taxonomy-$taxonomy.php";
$templates[] = $filePath . "/taxonomy.php";
foreach ( $templates as $key => $value ) {
if ( 'single' === $type && file_exists($value) ) {
$category = get_queried_object();
if ( ! empty( $category->slug ) ) {
$slug_decoded = urldecode( $category->slug );
if ( $slug_decoded !== $category->slug ) {
$templates[] = $filePath . "/category-{$slug_decoded}.php";
$templates[] = $filePath . "/category-{$category->slug}.php";
$templates[] = $filePath . "/category-{$category->term_id}.php";
$templates[] = $filePath . '/category.php';
foreach ( $templates as $key => $value ) {
if ( 'single' === $type && file_exists($value) ) {
$tag = get_queried_object();
if ( ! empty( $tag->slug ) ) {
$slug_decoded = urldecode( $tag->slug );
if ( $slug_decoded !== $tag->slug ) {
$templates[] = $filePath . "/tag-{$slug_decoded}.php";
$templates[] = $filePath . "/tag-{$tag->slug}.php";
$templates[] = $filePath . "/tag-{$tag->term_id}.php";
$templates[] = $filePath . '/tag.php';
foreach ( $templates as $key => $value ) {
if ( 'single' === $type && file_exists($value) ) {
$author = get_queried_object();
if ( $author instanceof WP_User ) {
$templates[] = $filePath . "/author-{$author->user_nicename}.php";
$templates[] = $filePath . "/author-{$author->ID}.php";
$templates[] = $filePath . "/author.php";
foreach ( $templates as $key => $value ) {
if ( 'single' === $type && file_exists($value) ) {
$ptype = esc_attr(get_query_var( 'post_type' ));
$post_types = array_filter( (array) $ptype );
if ( count( $post_types ) == 1 ) {
$post_type = reset( $post_types );
$templates[] = $filePath . "/archive-{$post_type}.php";
$templates[] = $filePath . '/archive.php';
foreach ( $templates as $key => $value ) {
if ( 'single' === $type && file_exists($value) ) {
case (is_post_type_archive()):
$post_type = get_query_var( 'post_type' );
if ( is_array( $post_type ) )
$post_type = reset( $post_type );
$obj = get_post_type_object( $post_type );
if ( ! ($obj instanceof WP_Post_Type) || ! $obj->has_archive ) {
$ptype = esc_attr(get_query_var( 'post_type' ));
$post_types = array_filter( (array) $ptype );
if ( count( $post_types ) == 1 ) {
$post_type = reset( $post_types );
$templates[] = $filePath . "/archive-{$post_type}.php";
$templates[] = $filePath . '/archive.php';
foreach ( $templates as $key => $value ) {
if ( 'single' === $type && file_exists($value) ) {
$object = get_queried_object();
if ( ! empty( $object->post_type ) ) {
$template = get_page_template_slug( $object );
if ( $template && 0 === validate_file( $template ) ) {
$templates[] = $filePath.'/'.$template;
$name_decoded = urldecode( $object->post_name );
if ( $name_decoded !== $object->post_name ) {
$templates[] = $filePath . "/single-{$object->post_type}-{$name_decoded}.php";
$templates[] = $filePath . "/single-{$object->post_type}-{$object->post_name}.php";
$templates[] = $filePath . "/single-{$object->post_type}.php";
$templates[] = $filePath . "/single.php";
foreach ( $templates as $key => $value ) {
if ( 'single' === $type && file_exists($value) ) {
$id = get_queried_object_id();
$template = get_page_template_slug();
$pagename = get_query_var('pagename');
if ( ! $pagename && $id ) {
// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
$post = get_queried_object();
$pagename = $post->post_name;
if ( $template && 0 === validate_file( $template ) )
$templates[] = $filePath.'/'.$template;
$pagename_decoded = urldecode( $pagename );
if ( $pagename_decoded !== $pagename ) {
$templates[] = $filePath . "/page-{$pagename_decoded}.php";
$templates[] = $filePath . "/page-{$pagename}.php";
$templates[] = $filePath . "/page-{$id}.php";
$templates[] = $filePath . "/page.php";
foreach ( $templates as $key => $value ) {
if ( 'single' == $type && file_exists($value) ) {
function ampforwp_child_custom_footer_file( $file, $type, $post ) {
if ( 'footer' === $type ) {
$file = ampforwp_theme_template_directry() . '/footer.php';
add_action("ampforwp_pagebuilder_layout_filter","ampforwp_add_upcomminglayouts");
function ampforwp_add_upcomminglayouts($layoutTemplate){
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if(function_exists('ampforwp_upcomming_layouts_demo') && !is_plugin_active('amp-layouts/amp-layouts.php') ){
$layouts_demo = ampforwp_upcomming_layouts_demo();
if(is_array($layouts_demo)){
foreach($layouts_demo as $k=>$val){
$layoutTemplate[$val['name'].'-upcomming'] = array(
'preview_demo'=>$val['link'],
'preview_img'=>$val['image'],
'layout_json'=>'{"rows":[],"totalrows":"23","totalmodules":"94",}',
add_action( 'redux/options/redux_builder_amp/saved', 'ampforwp_extension_individual_amp_page',10,2);
function ampforwp_extension_individual_amp_page($options, $changed_values){
if(isset($changed_values['amp-pages-meta-default']) && $options['amp-pages-meta-default']=='hide'){
delete_transient('ampforwp_current_version_check');
add_filter("redux/options/redux_builder_amp/data/category_list_hierarchy", 'ampforwp_redux_category_list_hierarchy',10,1);
function ampforwp_redux_category_list_hierarchy($data){
if(!is_array($data)){ $data = array(); }// To avoid PHP Fatal error: Cannot use string offset as an array
$cats = get_categories();
if ( ! empty ( $cats ) ) {
foreach ( $cats as $cat ) {
if($cat->category_parent!=0){
$data[ $cat->category_parent ]['child'][$cat->term_id] = $cat->name;
$data[ $cat->term_id ]['name'] = $cat->name;