: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
use AMPforWP\AMPVendor\AMP_Post_Template;
use AMPforWP\AMPVendor\AMP_HTML_Utils;
if ( ! defined( 'ABSPATH' ) ) {
global $redux_builder_amp;
$loadComponent = array();
$scriptComponent = array();
$supportComponent = array('AMP-search','AMP-menu','AMP-alter-menu','AMP-logo','AMP-social-icons','AMP-sidebar','AMP-featured-image','AMP-author-box','AMP-loop','AMP-categories-tags','AMP-comments','AMP-post-navigation','AMP-related-posts','AMP-post-pagination','AMP-call-now', 'AMP-breadcrumb','AMP-gdpr', 'AMP-google-font', 'AMP-google-font');
add_filter( 'amp_post_template_data', 'ampforwp_framework_add_and_form_scripts',20);
function ampforwp_framework_add_and_form_scripts($data) {
global $scriptComponent, $loadComponent;
if(count($scriptComponent)>0){
foreach ($scriptComponent as $key => $value) {
if ( empty( $data['amp_component_scripts'][$key] ) ) {
$data['amp_component_scripts'][$key] = $value;
function add_amp_theme_support($componentName){
global $loadComponent,$supportComponent;
if(in_array($componentName, $supportComponent)){
$loadComponent[$componentName] = true;
ampforwp_loadComponents($componentName);
//Include the Component file
function ampforwp_loadComponents($componentName){
if(empty($componentName)) return '';
$componentName = str_replace("AMP-", "", $componentName);
$file = AMP_FRAMEWORK_COMOPNENT_DIR_PATH.'/'.esc_attr($componentName).'/'.esc_attr($componentName).".php";
include_once( esc_attr($file));
$amp_icons_css = array();
function add_amp_icon($args=array()){
global $amp_icons_css, $redux_builder_amp;
$amp_icons_css_array = include AMPFORWP_PLUGIN_DIR .'includes/icons/amp-icons.php';
foreach ($args as $key ) {
if(isset($amp_icons_css_array[$key]))
$amp_icons_css[$key] = $amp_icons_css_array[$key];
if ( 1 == $redux_builder_amp['amp-design-selector'] || 2 == $redux_builder_amp['amp-design-selector'] || 3 == $redux_builder_amp['amp-design-selector'] ) {
add_action('amp_post_template_css', 'amp_icon_css',999);
add_action('amp_css', 'amp_icon_css');
global $amp_icons_css, $redux_builder_amp;
foreach ($amp_icons_css as $key => $value) {
// TODO: https://github.com/ahmedkaludi/accelerated-mobile-pages/issues/2651
$icon_url = plugin_dir_url(__FILE__);
$icon_url = ampforwp_font_url($icon_url);
// Add @font-face for Design-1,2,3
if ( 1 == $redux_builder_amp['amp-design-selector'] || 2 == $redux_builder_amp['amp-design-selector'] || 3 == $redux_builder_amp['amp-design-selector'] ) { ?>
@font-face {font-family: 'icomoon';font-style: normal;font-weight: normal;font-display: swap;src: local('icomoon'), local('icomoon'), url('<?php echo esc_url($icon_url) ?>icomoon/icomoon.ttf');}
[class^="icon-"], [class*=" icon-"] {font-family: 'icomoon';speak: none;font-style: normal;font-weight: normal;font-variant: normal;text-transform: none;line-height: 1;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}
//Search Component Utilities
if(isset($loadComponent['AMP-search']) && $loadComponent['AMP-search']==true){
ampforwp_framework_get_search_form();
// Logo Component Utilitis
if(isset($loadComponent['AMP-logo']) && $loadComponent['AMP-logo']==true){
ampforwp_framework_get_logo();
$ID = ampforwp_get_the_ID();
if ( ampforwp_polylang_front_page() ) {
$ID = pll_get_post(get_option('page_on_front'));
elseif( ampforwp_is_front_page() && ampforwp_get_setting('ampforwp-title-on-front-page') == false) {
do_action('ampforwp_above_the_title');
$ampforwp_title = get_the_title($ID);
$ampforwp_title = apply_filters('ampforwp_filter_single_title', $ampforwp_title);
if(!empty($ampforwp_title)){
$title_tag = '<h1 class="amp-post-title">' . wp_kses_data( $ampforwp_title ) . '</h1>';
$title_tag = apply_filters('ampforwp_modify_title_tag',$title_tag,$ampforwp_title);
echo $title_tag; // Escaped above
do_action('ampforwp_below_the_title');
function amp_excerpt( $no_of_words=260 ) {
$post_id = $content = '';
$no_of_words = (int) $no_of_words;
$post_id = ampforwp_get_the_ID();
if ( $post_id != null && true == ampforwp_get_setting('enable-excerpt-single') ) { ?>
$content = get_the_excerpt();
Encoding $content as HTML entities, then trimming it to a certain number of words, decoding it back from HTML entities, and finally ensuring that all HTML tags are properly balanced.
We are doing this since the excerpt may contain HTML tags and wp_trim_words strips all HTML tags.
echo force_balance_tags( html_entity_decode( wp_trim_words( htmlentities( $content ), $no_of_words) ) );
function amp_menu($echo=true, $menu_args=array(), $type='header'){
if ( ($type == 'header' && ! has_nav_menu( 'amp-menu' )) || ( 'footer' == $type && ! has_nav_menu( 'amp-footer-menu' ) ) ) {
if(isset($loadComponent['AMP-menu']) && $loadComponent['AMP-menu']==true){
$header_menu = get_transient('ampforwp_header_menu');
$footer_menu = get_transient('ampforwp_footer_menu');
if ( 'header' == $type && false != $header_menu ){
$amp_menu = $header_menu;
elseif ('footer' == $type && false != $footer_menu) {
$amp_menu = $footer_menu;
$amp_menu = amp_menu_html($echo, $menu_args, $type);
echo $amp_menu; // escaped above
function amp_alter_menu($echo=true){
if ( ! has_nav_menu('amp-alternative-menu') ) {
if(isset($loadComponent['AMP-alter-menu']) && $loadComponent['AMP-alter-menu']==true){
return amp_menu_html($echo, array(),'amp-alternative-menu');
echo amp_menu_html($echo, array(), 'amp-alternative-menu');
// Social Icons component
function amp_social( $social_icons="" ) {
$amp_social = array( 'twitter', 'facebook', 'pinterest', 'google-plus', 'linkedin', 'youtube', 'instagram', 'reddit', 'VKontakte', 'Odnoklassniki', 'snapchat', 'tumblr' );
if ( isset($loadComponent['AMP-social-icons']) && true == $loadComponent['AMP-social-icons'] ) {
if ( null != $social_icons ) {
ampforwp_framework_get_social_icons($social_icons);
ampforwp_framework_get_social_icons($amp_social);
function amp_sidebar($tag='start',$data=array()){
if(isset($loadComponent['AMP-sidebar']) && $loadComponent['AMP-sidebar']==true){
ampforwp_framework_get_sideabr($tag,$data);
function amp_featured_image( ){
if(isset($loadComponent['AMP-featured-image']) && $loadComponent['AMP-featured-image']==true){
ampforwp_framework_get_featured_image( );
function amp_author_box($args=array() ){
if(isset($loadComponent['AMP-author-box']) && $loadComponent['AMP-author-box']==true){
ampforwp_framework_get_author_box($args);
function amp_categories_list( $separator = '' ){
if(isset($loadComponent['AMP-categories-tags']) && $loadComponent['AMP-categories-tags']==true){
ampforwp_framework_get_categories_list( $separator );
function amp_tags_list( $separator = '' ){
if(isset($loadComponent['AMP-categories-tags']) && $loadComponent['AMP-categories-tags']==true){
ampforwp_framework_get_tags_list( $separator );
function amp_comments( ){
if(isset($loadComponent['AMP-comments']) && $loadComponent['AMP-comments']==true){
ampforwp_framework_get_comments( );
function amp_post_navigation( ){
if(isset($loadComponent['AMP-post-navigation']) && $loadComponent['AMP-post-navigation']==true){
echo ampforwp_framework_get_post_navigation();
function amp_related_posts($argsdata = array()){
if(isset($loadComponent['AMP-related-posts']) && $loadComponent['AMP-related-posts']==true){
echo ampforwp_framework_get_related_posts( $argsdata);
function amp_post_pagination($args='' ){
if(isset($loadComponent['AMP-post-pagination']) && $loadComponent['AMP-post-pagination']==true){
ampforwp_framework_get_post_pagination($args);
function amp_breadcrumb(){
if ( isset($loadComponent['AMP-breadcrumb']) && true == $loadComponent['AMP-breadcrumb'] ) {
echo amp_breadcrumb_output();
$gdpr = apply_filters('ampforwp_on_off_gdpr', true);
if ( isset($loadComponent['AMP-gdpr']) && true == $loadComponent['AMP-gdpr'] && $gdpr) {
function amp_header_core(){
global $ampforwpTemplate;
$post_id = ampforwp_get_the_ID();
if ( ampforwp_polylang_front_page() ) {
$post_id = pll_get_post(get_option('page_on_front'));
$thisTemplate = $ampforwpTemplate;
$html_tag_attributes = AMP_HTML_Utils::build_attributes_string( $thisTemplate->get( 'html_tag_attributes' ) );
if ( is_single() || is_page() ) {
$bodyClass = 'single-post';
$bodyClass .= ( is_page()? ' amp-single-page ' : ' amp-single ');
$bodyClass = 'amp-archive';
$ampforwp_custom_post_page = ampforwp_custom_post_page();
add_action('amp_post_template_head','ampforwp_sanitize_archive_desc');
if ( !function_exists('ampforwp_sanitize_archive_desc') ) {
function ampforwp_sanitize_archive_desc(){
$description = get_the_archive_description();
$sanitizer = new AMPFORWP_Content( $description, 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,
$amp_component_scripts = $sanitizer->amp_scripts;
if ( $sanitizer && $amp_component_scripts) {
foreach ($amp_component_scripts as $ampforwp_service => $ampforwp_js_file) { ?>
<script custom-element="<?php echo esc_attr($ampforwp_service); ?>" src="<?php echo esc_url($ampforwp_js_file); ?>" async></script> <?php
$bodyClass = 'amp-index amp-home'.esc_attr( $thisTemplate->get( 'body_class' ) );
if (ampforwp_get_setting('amp-frontpage-select-option') == 1) {
$bodyClass = 'single-post design_3_wrapper';
if ( $ampforwp_custom_post_page == "page" && ampforwp_name_blog_page() ) {
$current_url = home_url( $GLOBALS['wp']->request );
$current_url_in_pieces = explode( '/', $current_url );
if( in_array( ampforwp_name_blog_page() , $current_url_in_pieces ) ) {
$bodyClass = 'amp-index' .esc_attr( $thisTemplate->get( 'body_class' ) );
$bodyClass = 'amp_home_body archives_body design_3_wrapper';
if( true == ampforwp_get_setting('amp-rtl-select-option') ){
if( false == ampforwp_get_setting('ampforwp-amp-img-lightbox') ){
$lightbox = 'data-amp-auto-lightbox-disable';
<html <?php echo esc_attr(ampforwp_amp_nonamp_convert('amp ')); ?><?php echo AMP_HTML_Utils::build_attributes_string( $thisTemplate->get( 'html_tag_attributes' ) ); ?>>
<?php do_action('amp_experiment_meta', $thisTemplate); ?>
<link rel="preconnect" href="//cdn.ampproject.org">
<?php do_action( 'amp_meta', $thisTemplate ); ?>
if(ampforwp_amp_nonamp_convert("", "check")){
echo '<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=2,user-scalable=yes">';
if(is_search() && false == ampforwp_get_setting('amp-inspection-tool') && false == ampforwp_get_setting('ampforwp-robots-search-pages')){?>
<meta name="robots" content="noindex,nofollow"/>
do_action( 'amp_post_template_head', $thisTemplate );
<?php $thisTemplate->load_parts( array( 'style' ) ); ?>
<?php do_action( 'amp_post_template_css', $thisTemplate ); ?>
<?php do_action( 'amp_css', $thisTemplate ); ?>
<?php $custom_css = ampforwp_get_setting('css_editor');
if (function_exists('heateor_sss_run') && ampforwp_get_setting('ampforwp_css_tree_shaking') ) {
if(!is_object($wp_filesystem)){
require_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
require_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
$wp_filesystem = new WP_Filesystem_Direct( array() );
$custom_css .= $wp_filesystem->get_contents(AMPFORWP_PLUGIN_DIR."/includes/sassy-style-optimized.css");
$custom_css = apply_filters('ampforwp_custom_css_output', $custom_css);
$custom_css = str_replace(array('.accordion-mod'), array('.apac'), $custom_css);
$sanitized_css = ampforwp_sanitize_i_amphtml($custom_css);
echo $sanitized_css; // sanitized above ?>
<?php do_action('ampforwp_before_head', $thisTemplate); ?>
<body <?php echo esc_attr($lightbox); ?> <?php ampforwp_body_class($bodyClass); ?>>
<?php do_action('amp_start', $thisTemplate); ?>
<?php do_action('ampforwp_admin_menu_bar_front'); ?>
<?php do_action('ampforwp_body_beginning', $thisTemplate);
global $ampforwpTemplate;
$post_id = ampforwp_get_the_ID();
if ( ampforwp_polylang_front_page() ) {
$post_id = pll_get_post(get_option('page_on_front'));
$thisTemplate = $ampforwpTemplate;
$thisTemplate->load_parts( array( 'header' ) );
do_action( 'amp_after_header', $thisTemplate );
do_action( 'ampforwp_after_header', $thisTemplate );
do_action('ampforwp_post_before_design_elements') ?>
global $ampforwpTemplate;
$post_id = ampforwp_get_the_ID();
if ( ampforwp_polylang_front_page() ) {
$post_id = pll_get_post(get_option('page_on_front'));
$thisTemplate = $ampforwpTemplate;
do_action( 'amp_before_footer', $thisTemplate );
do_action( 'amp_post_template_above_footer', $thisTemplate );
$thisTemplate->load_parts( array( 'footer' ) );
function amp_footer_core(){
global $ampforwpTemplate;
$post_id = ampforwp_get_the_ID();
if ( ampforwp_polylang_front_page() ) {
$post_id = pll_get_post(get_option('page_on_front'));
$thisTemplate = $ampforwpTemplate;
if(ampforwp_amp_nonamp_convert("", "check")){
do_action( 'amp_post_template_footer', $thisTemplate );
do_action('ampforwp_global_after_footer');
do_action('amp_end',$thisTemplate);
// Close the body and Html tags ?>
function amp_non_amp_link(){
$allowed_tags = '<p><a><b><strong><i><u><ul><ol><li><h1><h2><h3><h4><h5><h6><table><tr><th><td><em><span>';
if (function_exists('pll__')) {
echo '<span>' . strip_tags(pll__(ampforwp_get_setting('amp-translator-footer-text'),'All Rights Reserved'),$allowed_tags) . '</span>';
echo '<span>' . strip_tags(ampforwp_translation(do_shortcode(ampforwp_get_setting('amp-translator-footer-text')),'All Rights Reserved'),$allowed_tags) . '</span>';
if(ampforwp_get_setting('amp-footer-link-non-amp-page')=='1') { ampforwp_view_nonamp(); }
function amp_back_to_top_link(){
if(true == ampforwp_get_setting('ampforwp-footer-top')){?>
<a id="scrollToTopButton" title="back to top" on="tap:backtotop.scrollTo(duration=500)" class="btt" href="#" ></a>
if(ampforwp_get_setting('ampforwp-amp-convert-to-wp') == true){?>
var elem = document.getElementById('scrollToTopButton');
elem.addEventListener("click", function(){
function amp_loop_template(){
global $ampforwpTemplate;
$post_id = get_queried_object_id();
$thisTemplate = $ampforwpTemplate;
do_action('amp_before_loop',$thisTemplate);
$thisTemplate->load_parts( array( 'loop' ) );