: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
if ( is_customize_preview() ) {
// Load all the elements in the customizer as we want all the elements in design-manager
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_the_title' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_meta_info' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_featured_image' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_the_content' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_meta_taxonomy' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_social_icons' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_comments' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_related_posts' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_bread_crumbs' );
add_action('pre_amp_render_post','ampforwp_design_selector', 11 );
function ampforwp_design_selector() {
$url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH),'/' );
if( function_exists('ampforwp_is_amp_inURL') && ampforwp_is_amp_inURL($url_path)) {
$design = ampforwp_get_setting('amp-design-selector');
$data = get_option( 'ampforwp_design',array());
$data['elements'] = "bread_crumbs:1,meta_info:1,title:1,featured_image:1,content:1,meta_taxonomy:1,social_icons:1,comments:1,related_posts:1";
if( isset( $data['elements'] ) || ! empty( $data['elements'] ) ){
$options = explode( ',', $data['elements'] );
if ($options): foreach ($options as $key=>$value) {
if ( ! is_customize_preview() ) {
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_bread_crumbs' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_the_title' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_meta_info' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_featured_image' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_the_content' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_meta_taxonomy' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_social_icons' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_comments' );
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_related_posts' );
$design = ampforwp_get_setting('amp-design-selector');
if ( file_exists(AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. $design . '/style.php') ) {
return ampforwp_get_setting('amp-design-selector');
elseif ( 4 == $design && file_exists(AMPFORWP_PLUGIN_DIR . 'templates/design-manager/swift/style.php') ) {
return ampforwp_get_setting('amp-design-selector');
if ( file_exists( WP_PLUGIN_DIR.'/'.$design.'/functions.php' ) ){
add_action('pre_amp_render_post','ampforwp_stylesheet_file_insertion', 12 );
function ampforwp_stylesheet_file_insertion() {
if ( ! ampforwp_design_selector() ) {
$ampforwp_design_selector = 4;
$ampforwp_design_selector = ampforwp_design_selector();
if ( file_exists(AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. $ampforwp_design_selector . '/style.php') && 4 != $ampforwp_design_selector ) {
//require AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. $ampforwp_design_selector . '/style.php';
require AMPFORWP_PLUGIN_DIR."/components/theme-loader.php";
if(4 != ampforwp_design_selector()){
add_filter( 'amp_post_template_file', 'ampforwp_design_element_the_title', 10, 3 );
add_filter( 'amp_post_template_file', 'ampforwp_design_element_meta_info', 10, 3 );
add_filter( 'amp_post_template_file', 'ampforwp_design_element_featured_image', 10, 3 );
add_filter( 'amp_post_template_file', 'ampforwp_design_element_bread_crumbs', 10, 3 );
add_filter( 'amp_post_template_file', 'ampforwp_design_element_the_content', 10, 3 );
add_filter( 'amp_post_template_file', 'ampforwp_design_element_social_icons', 10, 3 );
add_filter( 'amp_post_template_file', 'ampforwp_design_element_meta_taxonomy', 10, 3 );
add_filter( 'amp_post_template_file', 'ampforwp_design_element_comments', 10, 3 );
add_filter( 'amp_post_template_file', 'ampforwp_design_element_related_posts', 10, 3 );
add_filter('ampforwp_design_elements', 'ampforwp_empty_design_elements', 12);
function ampforwp_add_element_the_title( $meta_parts ) {
$meta_parts[] = 'ampforwp-the-title';
function ampforwp_design_element_the_title( $file, $type, $post ) {
if ( 'ampforwp-the-title' === $type ) {
$file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. ampforwp_design_selector() .'/elements/title.php' ;
function ampforwp_add_element_meta_info( $meta_parts ) {
$meta_parts[] = 'ampforwp-meta-info';
function ampforwp_design_element_meta_info( $file, $type, $post ) {
if ( 'ampforwp-meta-info' === $type ) {
$file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. ampforwp_design_selector() .'/elements/meta-info.php' ;
function ampforwp_add_element_featured_image( $meta_parts ) {
$meta_parts[] = 'ampforwp-featured-image';
function ampforwp_design_element_featured_image( $file, $type, $post ) {
if ( 'ampforwp-featured-image' === $type ) {
$file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. ampforwp_design_selector() .'/elements/featured-image.php';
function ampforwp_add_element_bread_crumbs( $meta_parts ) {
$meta_parts[] = 'ampforwp-bread-crumbs';
function ampforwp_design_element_bread_crumbs( $file, $type, $post ) {
if ( 'ampforwp-bread-crumbs' === $type ) {
$file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. ampforwp_design_selector() .'/elements/bread-crumbs.php' ;
function ampforwp_add_element_the_content( $meta_parts ) {
$meta_parts[] = 'ampforwp-the-content';
function ampforwp_design_element_the_content( $file, $type, $post ) {
if ( 'ampforwp-the-content' === $type ) {
$file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. ampforwp_design_selector() .'/elements/content.php';
function ampforwp_add_element_meta_taxonomy( $meta_parts ) {
$meta_parts[] = 'ampforwp-meta-taxonomy';
function ampforwp_design_element_meta_taxonomy( $file, $type, $post ) {
if ( 'ampforwp-meta-taxonomy' === $type ) {
$file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. ampforwp_design_selector() .'/elements/meta-taxonomy.php';
function ampforwp_add_element_social_icons( $meta_parts ) {
$meta_parts[] = 'ampforwp-social-icons';
function ampforwp_design_element_social_icons( $file, $type, $post ) {
if ( 'ampforwp-social-icons' === $type ) {
$file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. ampforwp_design_selector() .'/elements/social-icons.php';
function ampforwp_add_element_comments( $meta_parts ) {
$meta_parts[] = 'ampforwp-comments';
function ampforwp_design_element_comments( $file, $type, $post ) {
if ( 'ampforwp-comments' === $type ) {
$file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. ampforwp_design_selector() .'/elements/comments.php';
function ampforwp_add_element_related_posts( $meta_parts ) {
$meta_parts[] = 'ampforwp-related-posts';
function ampforwp_design_element_related_posts( $file, $type, $post ) {
if ( 'ampforwp-related-posts' === $type ) {
$file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/design-'. ampforwp_design_selector() .'/elements/related-posts.php';
// Empty meta parts when Pagebuilder is enabled
function ampforwp_empty_design_elements($meta_parts) {
if( checkAMPforPageBuilderStatus(get_the_ID()) ){
$meta_parts[] = 'ampforwp-the-content';