: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Disable wptextturize #1458
add_action('init','ampforwp_wptexturize_disabler');
if ( ! function_exists('ampforwp_wptexturize_disabler') ) {
function ampforwp_wptexturize_disabler(){
global $redux_builder_amp;
if ( isset($redux_builder_amp['ampforwp-wptexturize']) && true == $redux_builder_amp['ampforwp-wptexturize'] ) {
remove_filter('the_content', 'wptexturize');
remove_filter('the_title', 'wptexturize');
// amp-vimeo proper video id for 3 parameter url
add_filter('amp_vimeo_parse_url','amp_vimeo_parse_url_video_id');
function amp_vimeo_parse_url_video_id($tok){
if (in_array("ondemand", $tok) && sizeof($tok)==3){
if( ! function_exists( 'ampforwp_wc_cart_page_url' ) ){
function ampforwp_wc_cart_page_url(){
if(function_exists('amp_woocommerce_pro_add_woocommerce_support') && (function_exists('wc_get_cart_url') || function_exists('get_cart_url'))){
$cart_url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : $woocommerce->cart->get_cart_url();
$cart_url = ampforwp_url_controller($cart_url);
// Add Google Font support
add_action('amp_post_template_css', 'ampforwp_google_fonts_generator');
if ( ! function_exists( 'ampforwp_google_fonts_generator' ) ) {
function ampforwp_google_fonts_generator() {
global $redux_builder_amp;
if( 1!=ampforwp_get_setting('ampforwp-google-font-switch') || true == ampforwp_get_setting('amp_google_font_restrict')){
if(isset($redux_builder_amp['google_current_font_data'])){
$font_data = json_decode(stripslashes($redux_builder_amp['google_current_font_data']));
if(isset( $redux_builder_amp['amp_font_type'])){
$font_type = $redux_builder_amp['amp_font_type'];
if ( $font_type && ampforwp_get_setting('amp_font_selector') != 'Segoe UI') {
foreach ($font_type as $key => $value) {
$font_weight = (int) $value;
$font_weight = ( $font_weight != 0 ? $font_weight : 400 );
$font_style = preg_replace('/\d+/u', '', $value);
$font_style = ( $font_style == 'italic' ? 'italic' : 'normal' );
if ( $font_weight === 100 ) {
$font_local_weight = 'Thin';
if ( $font_weight === 200 ) {
$font_local_weight = 'Ultra Light';
if ( $font_weight === 300 ) {
$font_local_weight = 'Light';
if ( $font_weight === 400 ) {
$font_local_weight = 'Regular';
if ( $font_weight === 500 ) {
$font_local_weight = 'Medium';
if ( $font_weight === 600 ) {
$font_local_weight = 'SemiBold';
if ( $font_weight === 700 ) {
$font_local_weight = 'Bold';
if ( $font_weight === 800 ) {
$font_local_weight = 'ExtraBold';
if ( $font_weight === 900 ) {
$font_local_weight = 'Black';
if ('italic' === $font_style) {
$font_local_type = 'Italic';
$font_output .= "@font-face { ";
$font_output .= "font-family: " . $redux_builder_amp['amp_font_selector']. ';' ;
$font_output .= "font-display: optional;";
$font_output .= "font-style: " . $font_style . ';';
$font_output .= "font-weight: " . $font_weight . ';' ;
$font_output .= "src: local('". $redux_builder_amp['amp_font_selector']." ".$font_local_weight." ".$font_local_type."'), local('". $redux_builder_amp['amp_font_selector']."-".$font_local_weight.$font_local_type."'), url(" .str_replace("http://", "https://", $font_data->files->$value) . ');' ;
//for Single content Font Family
if(ampforwp_get_setting('content-font-family-enable') && (is_singular() || (ampforwp_get_setting('amp-design-selector')!=4) ) ){
if(ampforwp_get_setting('google_current_font_data_content_single')){
$font_data = json_decode(stripslashes(ampforwp_get_setting('google_current_font_data_content_single')));
if( ampforwp_get_setting('amp_font_type_content_single') ){
$font_type = ampforwp_get_setting('amp_font_type_content_single');
if ( $font_type && ampforwp_get_setting('amp_font_selector_content_single') != 'Segoe UI') {
foreach ($font_type as $key => $value) {
$font_weight = (int) $value;
$font_weight = ( $font_weight != 0 ? $font_weight : 400 );
$font_style = preg_replace('/\d+/u', '', $value);
$font_style = ( $font_style == 'italic' ? 'italic' : 'normal' );
if ( $font_weight === 100 ) {
$font_local_weight = 'Thin';
if ( $font_weight === 200 ) {
$font_local_weight = 'Ultra Light';
if ( $font_weight === 300 ) {
$font_local_weight = 'Light';
if ( $font_weight === 400 ) {
$font_local_weight = 'Regular';
if ( $font_weight === 500 ) {
$font_local_weight = 'Medium';
if ( $font_weight === 600 ) {
$font_local_weight = 'SemiBold';
if ( $font_weight === 700 ) {
$font_local_weight = 'Bold';
if ( $font_weight === 800 ) {
$font_local_weight = 'ExtraBold';
if ( $font_weight === 900 ) {
$font_local_weight = 'Black';
if ('italic' === $font_style) {
$font_local_type = 'Italic';
$font_output .= "@font-face { ";
$font_output .= "font-family: " . esc_attr(ampforwp_get_setting('amp_font_selector_content_single')). ';' ;
if (ampforwp_get_setting('ampforwp_font_display') == 'optional') {
$font_output .= "font-display: optional".';';
$font_output .= "font-display: swap".';';
$font_output .= "font-style: " . esc_attr($font_style) . ';';
$font_output .= "font-weight: " . esc_attr($font_weight) . ';' ;
$font_output .= "src: local('". esc_attr(ampforwp_get_setting('amp_font_selector_content_single'))." ".esc_attr($font_local_weight)." ".esc_attr($font_local_type)."'), local('". esc_attr(ampforwp_get_setting('amp_font_selector_content_single'))."-".esc_attr($font_local_weight).$font_local_type."'), url(" .esc_url(str_replace("http://", "https://", $font_data->files->$value)) . ');' ;
echo $font_output; // escaped above
function swifttheme_footer_widgets_init() {
'name' => esc_html__( 'AMP Widget Below Header', 'accelerated-mobile-pages' ),
'id' => 'ampforwp-below-header',
'description' => esc_html__( 'This Widget will be display on Below Header area', 'accelerated-mobile-pages' ),
'before_widget' => '<div class="w-bl">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
'name' => esc_html__( 'AMP Widget Above Loop', 'accelerated-mobile-pages' ),
'id' => 'ampforwp-above-loop',
'description' => esc_html__( 'This Widget will be display on Above Loop area', 'accelerated-mobile-pages' ),
'before_widget' => '<div class="w-bl">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
'name' => esc_html__( 'AMP Widget Below loop', 'accelerated-mobile-pages' ),
'id' => 'ampforwp-below-loop',
'description' => esc_html__( 'This Widget will be display on Below loop area', 'accelerated-mobile-pages' ),
'before_widget' => '<div class="w-bl">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
'name' => esc_html__( 'AMP Widget Above Footer', 'accelerated-mobile-pages' ),
'id' => 'ampforwp-above-footer',
'description' => esc_html__( 'This Widget will be display on Above Footer area', 'accelerated-mobile-pages' ),
'before_widget' => '<div class="w-bl">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
if(ampforwp_design_selector()==4 || ampforwp_design_selector()==3 || ampforwp_design_selector()==2 || ampforwp_design_selector()==1){
'name' => esc_html__( 'AMP Footer', 'accelerated-mobile-pages' ),
'id' => 'swift-footer-widget-area',
'description' => esc_html__( 'The Footer widget area', 'accelerated-mobile-pages' ),
'before_widget' => '<div class="w-bl">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
if(true == ampforwp_get_setting('gnrl-sidebar')){
'name' => esc_html__( 'AMP Sidebar', 'accelerated-mobile-pages' ),
'description' => esc_html__( 'The Swift Sidebar', 'accelerated-mobile-pages' ),
'before_widget' => '<div class="amp-sidebar">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
add_action( 'init', 'swifttheme_footer_widgets_init' );
function ampforwp_is_non_amp( $type="" ) {
global $redux_builder_amp;
$ampforwp_amp_post_on_off_meta = $post_id = '';
if ( ampforwp_is_front_page() ) {
$post_id = ampforwp_get_frontpage_id();
if ( false !== get_query_var( 'amp', false ) ) {
$mob_pres_link = ampforwp_mobile_redirect_preseve_link();
if (""===$type && (ampforwp_get_setting('ampforwp-amp-takeover') || $mob_pres_link == true) ) {
if ( is_single() && false == ampforwp_get_setting('amp-on-off-for-all-posts') ) {
if ( is_archive() && false == ampforwp_get_setting('ampforwp-archive-support') ) {
if ( is_page() && false == ampforwp_get_setting('amp-on-off-for-all-pages') ) {
$page_for_posts = intval(get_option( 'page_for_posts' ));
if ( $page_for_posts == ampforwp_get_the_ID() ) {
if ( is_home() && false == ampforwp_get_setting('ampforwp-homepage-on-off-support') ) {
if ( is_search() && ( (4 == ampforwp_get_setting('amp-design-selector') && false == ampforwp_get_setting('amp-swift-search-feature') ) ) ){
//Removed AMP Takeover when custom 404 Page is selected in enfold theme #4723
if ( function_exists('avia_preload_screen') && !empty(avia_get_option('error404_page')) && is_404() ) {
// Enabling AMP Takeover only when selected in Custom Post Type
$supported_types_for_takeover = array();
$supported_types_for_takeover = ampforwp_get_all_post_types();
if( $supported_types_for_takeover ){
$current_type = get_post_type(get_the_ID());
if( $current_type==false){
if(!in_array($current_type, $supported_types_for_takeover) && !is_404() && !is_search()){
if ( is_front_page() && false == ampforwp_get_setting('ampforwp-homepage-on-off-support') ) {
if(get_query_var( 'robots' )){
if ( function_exists('is_embed') && is_embed() ){
if(is_search() && 0 == ampforwp_get_setting('amp-redirection-search')){
ampforwp_get_setting('amp-design-selector') == 4)
true == ampforwp_get_setting('ampforwp-amp-convert-to-wp')
'non_amp_check_convert' === $type
&& true == ampforwp_get_setting('ampforwp-amp-convert-to-wp')
// Convert AMP to WP issues fixed #2493
if ( is_home() && ampforwp_get_setting('ampforwp-homepage-on-off-support') == false ) {
if ( is_page() && false == ampforwp_get_setting('amp-on-off-for-all-pages') ) {
if ( is_singular() || ampforwp_is_front_page() || ampforwp_is_blog() ) {
$ampforwp_amp_post_on_off_meta = get_post_meta( $post_id,'ampforwp-amp-on-off',true);
if($ampforwp_amp_post_on_off_meta == 'hide-amp'){
// Removing the AMP on login register etc of Theme My Login plugin
if (function_exists('tml_register_default_actions')){
$tml_pages = tml_get_actions();
if ( isset($tml_pages) && $tml_pages ) {
foreach ($tml_pages as $page) {
$pages[] = $page->get_slug();
if(in_array(get_query_var('action'), $pages) ){
function ampforwp_mobile_redirect_preseve_link(){
if(ampforwp_get_setting('amp-mobile-redirection') == true && ampforwp_get_setting('amp-mob-redirection-pres-link') == true){
require_once AMPFORWP_PLUGIN_DIR.'/includes/vendor/Mobile_Detect.php';
$mobile_detect = new AMPforWP_Mobile_Detect;
$isMobile = $mobile_detect->isMobile();
$isTablet = $mobile_detect->isTablet();
$isTabletUserAction = ampforwp_get_setting('amp-tablet-redirection');
if( $isMobile && $isTabletUserAction && $isTablet ){ //Only For tablet
}else if($isMobile && !$isTablet){ // Only for mobile
// Remove wpautop from specific posts which contain amp-components
add_action('pre_amp_render_post','ampforwp_custom_wpautop');
function ampforwp_custom_wpautop(){
if ( get_post_meta(get_the_ID(), 'ampforwp-wpautop', true) == 'false') {
remove_filter('the_content', 'wpautop');
if(function_exists('ubermenu_get_nav_menu_args')){
add_filter( 'ubermenu_nav_menu_args' ,'ampforwp_modify_ubermenu_nav_menu_args' , 10,2);
function ampforwp_modify_ubermenu_nav_menu_args($args , $config_id){
$args['menu_class'] = 'amp-menu '.$args['menu_class'];
// Backward Compatibility for AMP Preview #1529
if ( ! function_exists('get_preview_post_link') ) {
function get_preview_post_link( $post = null, $query_args = array(), $preview_link = '' ) {
$post = get_post( $post );
$post_type_object = get_post_type_object( $post->post_type );
if ( is_post_type_viewable( $post_type_object ) ) {
$preview_link = set_url_scheme( get_permalink( $post ) );
$query_args['preview'] = 'true';
$preview_link = add_query_arg( $query_args, $preview_link );
return apply_filters( 'preview_post_link', $preview_link, $post );
// Homepage Loop Modifier #1701
add_filter('ampforwp_query_args','ampforwp_homepage_loop');
function ampforwp_homepage_loop( $args ) {
global $redux_builder_amp;
// Check if Custom Post Type is selected
if ('' != ampforwp_get_setting('ampforwp-homepage-loop-type') ) {
$post_type = ampforwp_get_setting('ampforwp-homepage-loop-type');
$args['post_type'] = $post_type;
// Exclude Categories if any selected
if ('' != ampforwp_get_setting('ampforwp-homepage-loop-cats') ) {
$args['category__not_in'] = ampforwp_get_setting('ampforwp-homepage-loop-cats');
if(function_exists('ampforwp_is_home') && ampforwp_is_home() && isset($redux_builder_amp['amp-no-of-posts-home-page'])){
$args['posts_per_page'] = $redux_builder_amp['amp-no-of-posts-home-page'];
if(function_exists('is_category') && is_category() && isset($redux_builder_amp['amp-no-of-posts-cat-page'])){
$args['posts_per_archive_page'] = $redux_builder_amp['amp-no-of-posts-cat-page'];
//To modify number of posts #5503
add_filter( 'pre_get_posts', 'ampforwp_modify_no_of_posts' );
function ampforwp_modify_no_of_posts( $query ) {
global $redux_builder_amp;
$amp_q_ck = is_object($query) ? $query->query : '';
if(isset($amp_q_ck['amp']) && $amp_q_ck['amp'] == 1){
if(function_exists('ampforwp_is_home') && ampforwp_is_home() && isset($redux_builder_amp['amp-no-of-posts-home-page'])){
$query->set( 'posts_per_page', $redux_builder_amp['amp-no-of-posts-home-page']);
if(function_exists('is_category') && is_category() && isset($redux_builder_amp['amp-no-of-posts-cat-page'])){
$query->set( 'posts_per_page', $redux_builder_amp['amp-no-of-posts-cat-page']);
// To get correct comments count #1662
add_filter('get_comments_number', 'ampforwp_comment_count', 0);
function ampforwp_comment_count( $count ) {
/* TODO: Allowed memory size exhausted #1865
get_comments() was trying to access by Id and because the ID is not present on amp frontpages. It is getting exhausted. Need to recreate issue and validate the hypothesis
if ( ! is_admin() && function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() && is_single() ) {
$get_comments = get_comments('status=approve&post_id=' . $id);
$comments_by_type = separate_comments($get_comments);
return count($comments_by_type['comment']);
// Glue underline css compatibility #1743 #1932
add_action('amp_post_template_css', 'ampforwp_glue_css_comp', PHP_INT_MAX );
if ( ! function_exists('ampforwp_glue_css_comp') ) {
function ampforwp_glue_css_comp() {
global $redux_builder_amp;