= 1) : remove_action( 'wp_head', 'ampforwp_home_archive_rel_canonical', 1 ); endif; } function ampforwp_amphtml_generator(){ global $redux_builder_amp; global $wp, $post; $post_id = ''; $endpoint_check = false; $endpoint_check = ampforwp_get_setting('amp-core-end-point'); if( is_attachment() ) { return; } if(get_query_var('paged') && true == ampforwp_get_setting('amp-paginated-pages-indexing')) { return; } if( is_home() && is_front_page() && !ampforwp_get_setting('ampforwp-homepage-on-off-support') ) { return; } if( is_front_page() && ! ampforwp_get_setting('ampforwp-homepage-on-off-support') ) { return; } // HIDE/SHOW TAG AND CATEGORY #4326 if(is_tag() || is_category() || is_tax()){ $term_id = get_queried_object()->term_id; $tax_status = ampforwp_get_taxonomy_meta($term_id,'status'); if($tax_status==false){ return; } }else if(is_single()){ $tax_status = ampforwp_get_taxonomy_meta('','post_status'); if($tax_status==false){ return; } } // Skip this condition for woocommerce product archive and shop pages. if( function_exists('amp_woocommerce_pro_add_woocommerce_support') && (function_exists('is_product_category') && !is_product_category()) && (function_exists('is_product_tag') && !is_product_tag()) && (function_exists('is_shop') && !is_shop() ) ){ if( is_archive() && ( !ampforwp_get_setting('ampforwp-archive-support') || ( is_category() && !ampforwp_get_setting('ampforwp-archive-support-cat') ) || ( is_tag() && !ampforwp_get_setting('ampforwp-archive-support-tag') ))){ return; } } // When amp woocommerce pro plugin is not active. if ( is_archive() && !function_exists('amp_woocommerce_pro_add_woocommerce_support') ) { if(!ampforwp_get_setting('ampforwp-archive-support')){ return; } if( is_category() && !ampforwp_get_setting('ampforwp-archive-support-cat') ){ return; } if( is_tag() && !ampforwp_get_setting('ampforwp-archive-support-tag') ){ return; } } // #1192 Password Protected posts exclusion if(post_password_required( $post )){ return; } // #2018 404 exclusion if(is_404()){ return; } // #1443 AMP should be skip on the check out page if(class_exists( 'WooCommerce' )){ if(function_exists('is_checkout') && is_checkout()){ return; } if(function_exists('is_account_page') && is_account_page()){ return; } } // Search results on/off option #3786 if(is_search() && 0 == ampforwp_get_setting('amp-redirection-search')){ return; } if(function_exists('yith_wishlist_constructor')){ $class = get_body_class(); if(in_array("woocommerce-wishlist", $class)){ return; } } // #872 no-amphtml if selected as hide from settings if ( is_category_amp_disabled() ) { return; } if ( is_page() && ! ampforwp_get_setting('amp-on-off-for-all-pages') && ! is_home() && ! is_front_page() ) { return; } if ( is_home() && ! ampforwp_is_blog() && !ampforwp_get_setting('ampforwp-homepage-on-off-support') ) { return; } if (!ampforwp_is_home() && !ampforwp_is_front_page() && !ampforwp_is_blog() && !is_category() && !is_tag() && !is_singular( array('page', 'attachment', 'post')) && !function_exists('amp_woocommerce_pro_add_woocommerce_support')){ global $post_type; if (empty(ampforwp_get_setting('ampforwp-custom-type'))) { return; } if(is_array(ampforwp_get_setting('ampforwp-custom-type')) && $post_type != ampforwp_get_setting('ampforwp-custom-type')[0]){ return; } } $page_for_posts = intval(get_option( 'page_for_posts' )); $post_id = ampforwp_get_the_ID(); if ( ampforwp_is_blog() && ! ampforwp_get_setting('amp-on-off-for-all-pages') && ($page_for_posts != $post_id ) ) { return; } $query_arg_array = $wp->query_vars; if( in_array( "cpage" , $query_arg_array ) ) { if( is_front_page() && $wp->query_vars['cpage'] >= '2' ) { return; } if( is_singular() && $wp->query_vars['cpage'] >= '2' ) { return; } } if ( is_home() || is_front_page() || is_archive() ){ global $wp; $current_archive_url = home_url( $wp->request ); // If its custom permalink with /index.php/ #3279 if ( is_archive() && false !== strpos($wp->matched_rule, 'index.php') && false === strpos($current_archive_url, 'index.php') ) { $current_archive_url = home_url( 'index.php/' . $wp->request ); } $amp_url = trailingslashit($current_archive_url); } else { $amp_url = AMPforWP\AMPVendor\amp_get_permalink( get_queried_object_id() ); } global $post; if ( is_singular() ) { $post_id = get_the_ID(); } if ( ampforwp_is_blog() ) { $post_id = ampforwp_get_blog_details('id'); } $ampforwp_amp_post_on_off_meta = get_post_meta( $post_id,'ampforwp-amp-on-off',true); if ( ( is_singular() || ampforwp_is_blog() ) && $ampforwp_amp_post_on_off_meta === 'hide-amp' ) { //dont Echo anything } else { $supported_types = ampforwp_get_all_post_types(); if(isset($supported_types['web-story'])){ $supported_types['web-story'] = ''; } $supported_types = apply_filters('get_amp_supported_post_types',$supported_types); $type = get_post_type(); if(is_home() || is_front_page()){ if( ampforwp_get_setting('ampforwp-homepage-on-off-support') == 1 && ampforwp_get_setting('amp-on-off-for-all-posts') == 0 && ampforwp_get_setting('amp-on-off-for-all-pages') == 0 ){ $supported_types['post'] = 'post'; } } $supported_amp_post_types = in_array( $type , $supported_types ); $query_arg_array = $wp->query_vars; if( array_key_exists( 'paged' , $query_arg_array ) ) { if ( (is_home() || is_archive()) && $wp->query_vars['paged'] >= '2' ) { $new_url = home_url('/'); // If its custom permalink with /index.php/ #3537 if ( (is_home() || is_archive()) && false !== strpos($wp->matched_rule, 'index.php') && false === strpos( home_url( $wp->request ), 'index.php') ) { $new_url = home_url( 'index.php' ); $o_url = home_url(); $new_url = str_replace($o_url, $new_url, $amp_url); $new_url = user_trailingslashit($new_url); $amp_url = $new_url; } $category_path = $wp->request; if ( null != $category_path && true != $endpoint_check) { $explode_path = explode("/",$category_path); $inserted = array(AMPFORWP_AMP_QUERY_VAR); array_splice( $explode_path, -2, 0, $inserted ); $impode_url = implode('/', $explode_path); $amp_url = $new_url . $impode_url ; } } if( is_search() && $wp->query_vars['paged'] >= '2' ) { $current_search_url =trailingslashit(get_home_url()) . $wp->request .'/'."?amp=1&s=".get_search_query(); } } $amp_url = user_trailingslashit($amp_url); if( is_search() ) { $current_search_url =trailingslashit(get_home_url())."?amp=1&s=".get_search_query(); $amp_url = untrailingslashit($current_search_url); } // URL Purifier if(!ampforwp_get_setting('amp-core-end-point') && !ampforwp_get_setting('ampforwp-amp-takeover')){ $amp_url = ampforwp_url_purifier($amp_url); } if(true == ampforwp_get_setting('amp-core-end-point') && (!is_home() && !is_front_page() && !is_archive())){ $amp_url = add_query_arg( 'amp', '', get_the_permalink() ); } $amp_url = apply_filters('ampforwp_modify_rel_canonical',$amp_url); if( $supported_amp_post_types || ampforwp_is_front_page() ) { if(true == ampforwp_get_setting('amp-core-end-point')){ if( class_exists('SitePress') ){ if( get_option('permalink_structure') ){ global $sitepress_settings, $wp; $wpml_lang_checker = false; if($sitepress_settings[ 'language_negotiation_type' ] == 3){ $amp_url = esc_url($amp_url); $active_langs = $sitepress_settings['active_languages']; foreach ($active_langs as $active_lang) { if (preg_match('/\?lang='.$active_lang.'/', $amp_url)){ $amp_url = preg_replace('/&amp=1/', '', $amp_url); $amp_url = preg_replace('/#038;amp/', '', $amp_url); $amp_url = str_replace('?lang='.$active_lang, '?amp=1', $amp_url); $amp_url = add_query_arg( 'lang',$active_lang, $amp_url); } } } } } } if (is_category() && class_exists('WPSEO_Options') && method_exists('WPSEO_Options', 'get') && WPSEO_Options::get( 'stripcategorybase' ) == true && false == ampforwp_get_setting('ampforwp-category-base-removel-link')) { return; } if (is_category() && class_exists('RankMath') && RankMath\Helper::get_settings( 'general.strip_category_base' ) == true && false == ampforwp_get_setting('ampforwp-category-base-removel-link')) { return; } if (is_preview()) { $amp_url = preg_replace('/(.*?)&(.*?)/', '$1&&$2', $amp_url); } if(ampforwp_get_setting('amp-core-end-point') && ampforwp_get_setting('ampforwp-amp-takeover') && is_singular()){ $amp_url = get_the_permalink(); }else if(ampforwp_get_setting('amp-core-end-point') && (ampforwp_is_home() || ampforwp_is_front_page() || ampforwp_is_blog() || is_category() || is_tag() || is_front_page())){ $amp_url = ampforwp_url_controller($amp_url); } return esc_url_raw($amp_url); } } return; } // AMPHTML when using custom page and then creating a blog page add_action('amp_init','ampforwp_allow_homepage_as_blog'); function ampforwp_allow_homepage_as_blog() { if(function_exists('mfn_opts_setup')){ remove_action( 'pre_get_posts', 'mfn_search' ); } add_action( 'wp', 'ampforwp_static_blog' , 11 ); } function ampforwp_static_blog(){ global $page; $modify_canonical = ampforwp_is_front_page(); $get_front_page_reading_settings = get_option('page_on_front'); // Homepage support on $get_amp_homepage_support = ampforwp_get_setting('ampforwp-homepage-on-off-support'); if ( 'page' == get_option( 'show_on_front') && is_front_page() && $get_front_page_reading_settings && $get_amp_homepage_support ){ $modify_canonical = true; } if ( true == $modify_canonical && $page >= 2 && is_page() && false == ampforwp_get_setting('amp-core-end-point') ) { add_filter('ampforwp_modify_rel_canonical','ampforwp_modify_amphtml_static_blog'); } } function ampforwp_modify_amphtml_static_blog($amp_url) { $explode_url = $amp_endpoint = $offset = ""; $explode_url = explode('/', $amp_url); $explode_url = array_flip($explode_url); unset($explode_url[AMPFORWP_AMP_QUERY_VAR]); $explode_url = array_flip($explode_url); $amp_endpoint = array(AMPFORWP_AMP_QUERY_VAR); $offset = count($explode_url) - 2; array_splice( $explode_url, $offset, 0, $amp_endpoint ); $amp_url = implode('/', $explode_url); return $amp_url; } function ampforwp_home_archive_rel_canonical() { $amp_url = ""; $amp_url = ampforwp_amphtml_generator(); if ( $amp_url ) { printf('', esc_url($amp_url)); if(false==ampforwp_get_setting('hide-amp-version-from-source')){ printf('', esc_html__('AMP for WP'), esc_attr(AMPFORWP_VERSION) ); } } } //end of ampforwp_home_archive_rel_canonical() // Remove default wordpress rel canonical add_filter('amp_frontend_show_canonical','ampforwp_remove_default_canonical'); if (! function_exists('ampforwp_remove_default_canonical') ) { function ampforwp_remove_default_canonical() { return false; } } // 2. Custom Design // Add Homepage AMP file code add_filter( 'amp_post_template_file', 'ampforwp_custom_template', 10, 3 ); function ampforwp_custom_template( $file, $type, $post ) { global $redux_builder_amp; // Custom Homepage and Archive file $slug = array(); $current_url_in_pieces = array(); $ampforwp_custom_post_page = ampforwp_custom_post_page(); if ( 'single' === $type ) { // Homepage and FrontPage if ( is_home() || ( true == $redux_builder_amp['ampforwp-amp-takeover'] && is_front_page() ) ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/index.php'; } if ( ampforwp_is_blog() ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/index.php'; } if ( ampforwp_is_front_page() || ( true == $redux_builder_amp['ampforwp-amp-takeover'] && is_front_page() && $redux_builder_amp['amp-frontpage-select-option']) ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/frontpage.php'; } // Archive Pages if ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] && 'single' === $type ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/archive.php'; } // Search pages if ( is_search() ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/search.php'; } // 404 Pages #2042 if ( is_404() && 'single' === $type ) { add_filter('ampforwp_modify_rel_url','ampforwp_404_canonical'); $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/404.php'; } } // Polylang compatibility // For Frontpage if ( 'single' === $type && ampforwp_polylang_front_page() && true == $redux_builder_amp['amp-frontpage-select-option'] ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/frontpage.php'; } return $file; } add_filter('amp_post_template_dir','ampforwp_new_dir'); function ampforwp_new_dir( $dir ) { global $redux_builder_amp; if ( 1 == $redux_builder_amp['amp-design-selector'] || 2 == $redux_builder_amp['amp-design-selector'] || 3 == $redux_builder_amp['amp-design-selector'] ) { $dir = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector(); } else { $dir = AMPFORWP_CUSTOM_THEME; } return $dir; } //3.5 add_filter( 'amp_post_template_file', 'ampforwp_empty_filter', 10, 3 ); function ampforwp_empty_filter( $file, $type, $post ) { if ( 'empty-filter' === $type ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php'; } return $file; } // 4. Custom Header files add_filter( 'amp_post_template_file', 'ampforwp_custom_header', 10, 3 ); function ampforwp_custom_header( $file, $type, $post ) { if ( 'header-bar' === $type ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/header-bar.php'; } return $file; } // 4.1 Custom Meta-Author files add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_author', 10, 3 ); function ampforwp_set_custom_meta_author( $file, $type, $post ) { if ( 'meta-author' === $type ) { $file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php'; } return $file; } // 4.2 Custom Meta-Taxonomy files add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_taxonomy', 10, 3 ); function ampforwp_set_custom_meta_taxonomy( $file, $type, $post ) { if ( 'meta-taxonomy' === $type ) { $file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/empty-filter.php'; } return $file; } // 5. Customize with Width of the site add_filter( 'amp_content_max_width', 'ampforwp_change_content_width' ); function ampforwp_change_content_width( $content_max_width ) { return 1000; } // 6. Add required Javascripts for extra AMP features // Code updated and added the JS proper way #336 add_filter('amp_post_template_data','ampforwp_add_amp_social_share_script', 20); function ampforwp_add_amp_social_share_script( $data ){ global $redux_builder_amp; $social_check = $social_check_page = false; if ( is_page() && isset($redux_builder_amp['ampforwp-page-social']) && $redux_builder_amp['ampforwp-page-social'] ) { $social_check_page = true; } if ( 4 == ampforwp_get_setting('amp-design-selector') ) { $social_check = true; } if ( '4' !== ampforwp_get_setting('amp-design-selector') && defined('AMPFORWP_DM_SOCIAL_CHECK') && 'true' === AMPFORWP_DM_SOCIAL_CHECK ) { $social_check = true; } if( ampforwp_get_setting('enable-single-social-icons') == true || defined('AMPFORWP_DM_SOCIAL_CHECK') && AMPFORWP_DM_SOCIAL_CHECK === 'true' ) { if( (is_singular() || $social_check_page ) && is_socialshare_or_socialsticky_enabled_in_ampforwp() ) { if ( empty( $data['amp_component_scripts']['amp-social-share'] ) ) { $data['amp_component_scripts']['amp-social-share'] = 'https://cdn.ampproject.org/v0/amp-social-share-0.1.js'; } } } // Facebook Like Script $fb_like = false; $isBBPress = (function_exists('is_bbpress') ? is_bbpress() : false ); if ( true == ampforwp_get_setting('ampforwp-facebook-like-button') ){ if ( is_single() && ( true == ampforwp_get_setting('enable-single-social-icons') || (true == ampforwp_get_setting('ampforwp-social-share') && $social_check) ) && !checkAMPforPageBuilderStatus(ampforwp_get_the_ID()) && !$isBBPress) { $fb_like = true; } if ( is_page() && ( true == ampforwp_get_setting('ampforwp-page-sticky-social') || ( $social_check_page && !checkAMPforPageBuilderStatus(ampforwp_get_the_ID()) ) ) ) { $fb_like = true; } if ( true == ampforwp_get_setting('enable-single-social-icons') && checkAMPforPageBuilderStatus(ampforwp_get_the_ID()) && is_singular()) { $fb_like = true; } } if ( true == $fb_like ) { if(empty($data['amp_component_scripts']['amp-facebook-like'])){ $data['amp_component_scripts']['amp-facebook-like'] = 'https://cdn.ampproject.org/v0/amp-facebook-like-0.1.js'; } } return $data; } add_filter( 'amp_post_template_data', 'ampforwp_add_amp_related_scripts', 20 ); function ampforwp_add_amp_related_scripts( $data ) { global $redux_builder_amp; // Adding Sidebar Script if ( isset($redux_builder_amp['ampforwp-amp-menu']) && $redux_builder_amp['ampforwp-amp-menu'] && 4 != $redux_builder_amp['amp-design-selector'] ) { if ( empty( $data['amp_component_scripts']['amp-sidebar'] ) ) { $data['amp_component_scripts']['amp-sidebar'] = 'https://cdn.ampproject.org/v0/amp-sidebar-0.1.js'; } } return $data; } // 8. Add Main tag as a Wrapper // Removed this code after moving to design manager // 9. Advertisement code // Moved to ads-functions.php // 10. Analytics Area // Moved to analytics-functions.php // 11. Strip unwanted codes and tags from the_content add_action( 'pre_amp_render_post','ampforwp_strip_invalid_content'); function ampforwp_strip_invalid_content() { add_filter( 'the_content', 'ampforwp_the_content_filter', 2 ); } function ampforwp_the_content_filter( $content ) { $content = preg_replace('/property=[^>]*/', '', $content); $content = preg_replace('/vocab=[^>]*/', '', $content); $content = preg_replace('/noshade=[^>]*/', '', $content); $content = preg_replace('/contenteditable=[^>]*/', '', $content); $content = preg_replace('/non-refundable=[^>]*/', '', $content); $content = preg_replace('/security=[^>]*/', '', $content); $content = preg_replace('/deposit=[^>]*/', '', $content); $content = preg_replace('/nowrap="nowrap"/', '', $content); $content = preg_replace('#(.*?)#i', '', $content); $content = preg_replace('#(.*?)#i', '', $content); $content = preg_replace('#(.*?)#i', '', $content); $content = preg_replace('##i', '', $content); //Removed because class is being removed from table #2699 $content = preg_replace('/href="javascript:void*/', ' ', $content); // Convert the Wistia embed into URL to build amp-wistia-player and remove unnecesarry wistia code $content = preg_replace('/ '; } return $output; } } //AMP to WP Theme Analytics add_action('wp_footer','ampforwp_nonamp_analytics'); if ( ! function_exists('ampforwp_nonamp_analytics') ) { function ampforwp_nonamp_analytics() { global $redux_builder_amp; $ga_account = $redux_builder_amp['ga-feild']; if ( ampforwp_is_non_amp("non_amp_check_convert") ) { echo " "; } } } // Coauthors Compatibility #1895 add_filter('coauthors_posts_link', 'ampforwp_coauthors_links'); function ampforwp_coauthors_links($args){ global $redux_builder_amp; if ( function_exists('ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() && true == $redux_builder_amp['ampforwp-archive-support']) { $args['href'] = ampforwp_url_controller($args['href']); } return $args; } //remove anchor from the image when lightbox option is enabled #2695 add_action('pre_amp_render_post','ampforwp_remove_ahref_lightbox'); function ampforwp_remove_ahref_lightbox(){ if(true == ampforwp_get_setting('ampforwp-amp-img-lightbox') ){ add_filter( 'the_content', 'ampforwp_remove_ahref_lightbox_in_amp' ); add_filter('tablepress_table_render_data','amforwp_remove_tp_image_href'); } } function ampforwp_remove_ahref_lightbox_in_amp( $content ) { preg_match_all('/((.*?)]*>)/', $content, $matches); if( count($matches[3])){ for( $i=0;$i(]*>)<\/a>/i', '$3', $content); } } } return $content; } function amforwp_remove_tp_image_href( $orig_table){ $tablepressData = array(); $j = 0; foreach ($orig_table['data'] as $cols) { for($i=0;$i< count($cols);$i++){ $tablepressData[$j][$i] = preg_replace("/]+\>(]+\>)<\/a>/i",'$1', $cols[$i]); } $j++; } $orig_table['data'] = $tablepressData; return $orig_table; } // amp-image-lightbox #1892 if ( ! function_exists('ampforwp_amp_img_lightbox') ) { function ampforwp_amp_img_lightbox(){ echo ''; } } // New Image attributes for amp-image-lightbox #1892 add_filter('amp_img_attributes', 'ampforwp_img_new_attrs'); function ampforwp_img_new_attrs($attributes) { global $redux_builder_amp; if ( ampforwp_get_setting('ampforwp-amp-img-lightbox') ) { $attributes['on'] = 'tap:amp-img-lightbox'; $attributes['role'] = 'button'; $attributes['tabindex'] = '0'; } return $attributes; } // Facebook Comments script for AMP2WP add_action('ampforwp_body_beginning', 'ampforwp_amp2wp_fb'); if ( ! function_exists('ampforwp_amp2wp_fb') ) { function ampforwp_amp2wp_fb(){ global $redux_builder_amp; if( ampforwp_is_non_amp() && isset($redux_builder_amp['ampforwp-amp-convert-to-wp']) && $redux_builder_amp['ampforwp-amp-convert-to-wp'] && ($redux_builder_amp['ampforwp-facebook-comments-support'] || $redux_builder_amp['ampforwp-facebook-like-button']) ) { echo '
'; } } } // Removing AMPHTML Added by Facebook's Instant Article's Plugin #2043 add_action( 'wp', 'ampforwp_remove_instant_articles_amp_markup' ); function ampforwp_remove_instant_articles_amp_markup(){ if(class_exists('Instant_Articles_AMP_Markup')){ remove_action( 'wp_head', array('Instant_Articles_AMP_Markup', 'inject_link_rel') ); } // #1696 if(function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint()){ if(class_exists('SQ_Classes_ObjController')){ $SQ_Classes_ObjController = new SQ_Classes_ObjController(); $sq_analytics_class_obj = $SQ_Classes_ObjController::getClass('SQ_Models_Services_Analytics'); } } } // #2042 function ampforwp_404_canonical(){ global $wp; return home_url( $wp->request ); } // #2001 removing unused JS from the Paginated Posts add_filter('ampforwp_post_content_filter', 'ampforwp_paginated_post_content'); function ampforwp_paginated_post_content($content){ global $numpages; if(is_singular()){ if ( get_query_var( 'paged' ) ) { $paged = get_query_var('paged'); } elseif ( get_query_var( 'page' ) ) { $paged = get_query_var('page'); } else { $paged = 1; } if( $numpages >= 2 && true == ampforwp_get_setting('amp-pagination') ){ return get_the_content(); } } return $content; } // GDPR Compliancy #2040 // Moved to notice-bar-functions.php // Thrive Leads Compatibility #2067 add_filter('thrive_leads_skip_request', 'ampforwp_skip_thrive_leads'); if ( ! function_exists('ampforwp_skip_thrive_leads') ) { function ampforwp_skip_thrive_leads($skip) { // Skip thrive leads on AMP if ( function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() ) { return true; } return $skip; } } // Re-save permalink once the post value changed in Redading Settings #2190 add_action( 'update_option', 'ampforwp_resave_permalink', 10, 3 ); function ampforwp_resave_permalink( $option, $old_value, $value ){ if('posts_per_page' === $option){ if($old_value != $value){ delete_transient( 'ampforwp_current_version_check' ); } } } // Canonical From Yoast #2118 and All in One SEO #1720 and Rank Math #2701 function ampforwp_generate_canonical(){ global $redux_builder_amp; $canonical = ''; $canonical = $WPSEO_Frontend = $All_in_One_SEO_Pack = $opts = ''; if ( 'yoast' == ampforwp_get_setting('ampforwp-seo-selection') && true == ampforwp_get_setting('ampforwp-seo-yoast-canonical') && class_exists('WPSEO_Frontend') && !class_exists('Yoast\\WP\\SEO\\Integrations\\Front_End_Integration')) { $WPSEO_Frontend = WPSEO_Frontend::get_instance(); $canonical = $WPSEO_Frontend->canonical(false); } elseif ( 'aioseo' == ampforwp_get_setting('ampforwp-seo-selection') && true == ampforwp_get_setting('ampforwp-seo-aioseo-canonical') && class_exists('All_in_One_SEO_Pack') ) { $All_in_One_SEO_Pack = new All_in_One_SEO_Pack(); $opts = $All_in_One_SEO_Pack->get_current_options( array(), 'aiosp' ); $canonical = $opts['aiosp_custom_link']; } elseif ( defined( 'RANK_MATH_FILE' ) && 'rank_math' == ampforwp_get_setting('ampforwp-seo-selection') && ampforwp_get_setting( 'ampforwp-seo-rank_math-canonical' ) ) { $canonical = \RankMath\Paper\Paper::get()->get_canonical(); } return $canonical; } add_filter('amp_post_template_data', 'ampforwp_modified_canonical', 85); function ampforwp_modified_canonical( $data ) { $canonical = ''; $canonical = ampforwp_generate_canonical(); if ( !empty($canonical) ) { $data['canonical_url'] = $canonical; } return $data; } if(class_exists('WPSEO_Frontend') && 'yoast' == ampforwp_get_setting('ampforwp-seo-selection') && true == ampforwp_get_setting('ampforwp-seo-yoast-canonical') && !class_exists('Yoast\\WP\\SEO\\Integrations\\Front_End_Integration') ){ add_filter('ampforwp_modify_rel_url','ampforwp_yoast_canonical'); } function ampforwp_yoast_canonical($canonical){ if(ampforwp_is_front_page()){ $canonical = ampforwp_generate_canonical(); } return $canonical; } // #2220 Remove Space Shortcode by Pro Theme from THEMCO add_action('pre_amp_render_post','ampforwp_remove_space_shortcodes'); function ampforwp_remove_space_shortcodes(){ add_filter('the_content','ampforwp_remove_pro_theme_space_shortcodes'); } function ampforwp_remove_pro_theme_space_shortcodes($content){ if(has_shortcode( $content, 'gap' )){ remove_shortcode( 'gap' ); // to remove the useless shortcode from the AMP Content add_shortcode( 'gap', 'ampforwp_return_no_gap' ); } return $content; } function ampforwp_return_no_gap(){ return; } /* #2229 Function to check the option for comments to display on post, page or both. */ function ampforwp_get_comments_status(){ global $redux_builder_amp; $display_comments_on = ""; if ( false == ampforwp_get_setting('ampforwp-display-on-pages') && true == ampforwp_get_setting('ampforwp-display-on-posts') ) { $display_comments_on = is_single(); } if ( true == ampforwp_get_setting('ampforwp-display-on-pages') && false == ampforwp_get_setting('ampforwp-display-on-posts') ) { $display_comments_on = is_page(); } if ( true == ampforwp_get_setting('ampforwp-display-on-pages') && true == ampforwp_get_setting('ampforwp-display-on-posts')) { $display_comments_on = is_singular(); if ( ampforwp_is_front_page() ) { $display_comments_on = ampforwp_is_front_page(); } } $display_comments_on = apply_filters('ampforwp_comments_visibility', $display_comments_on); return $display_comments_on; } // Vuukle Comments Support #2075 add_action('ampforwp_post_after_design_elements','ampforwp_vuukle_comments_support'); function ampforwp_vuukle_comments_support() { global $redux_builder_amp; if ( true == ampforwp_get_setting('ampforwp-vuukle-comments-support') && comments_open()) { echo ampforwp_vuukle_comments_markup(); } } function ampforwp_vuukle_comments_markup() { global $redux_builder_amp,$post; $apiKey = $locale = ''; $tag_name =''; $img = get_the_post_thumbnail_url(); $tags = get_the_tags($post->ID); if( isset($redux_builder_amp['ampforwp-vuukle-comments-apiKey']) && $redux_builder_amp['ampforwp-vuukle-comments-apiKey'] !== ""){ $apiKey = $redux_builder_amp['ampforwp-vuukle-comments-apiKey']; } $display_comments_on = false; $display_comments_on = ampforwp_get_comments_status(); $siteUrl = trim(site_url(), '/'); if (!preg_match('#^http(s)?://#', $siteUrl)) { $siteUrl = 'http://' . $siteUrl; } if($img == false){ $img = plugins_url('accelerated-mobile-pages/images/150x150.png'); } if($tags){ foreach($tags as $individual_tag) { $tag_name = $individual_tag->name; } } $urlParts = parse_url($siteUrl); $siteUrl = preg_replace('/^www\./', '', $urlParts['host']);// remove www $srcUrl = 'https://cdn.vuukle.com/amp.html?'; $srcUrl = add_query_arg('url' ,get_permalink(), $srcUrl); $srcUrl = add_query_arg('host' ,$siteUrl, $srcUrl); $srcUrl = add_query_arg('id' , $post->ID, $srcUrl); if(!empty($apiKey)){ $srcUrl = add_query_arg('apiKey' , $apiKey, $srcUrl); } $srcUrl = add_query_arg('title' , urlencode($post->post_title), $srcUrl); $srcUrl = add_query_arg('img' , esc_url($img), $srcUrl); $srcUrl = add_query_arg('tags' , urlencode($tag_name), $srcUrl); if(ampforwp_get_setting('ampforwp-vuukle-comments-emoji')==false){ $srcUrl = add_query_arg('emotes' , 'false', $srcUrl); } $consent = ''; if(ampforwp_get_data_consent()){ $consent = 'data-block-on-consent '; } $vuukle_html =''; if ( $display_comments_on ) { $vuukle_html .= '
Show comments
'; } return $vuukle_html; } add_filter( 'amp_post_template_data', 'ampforwp_add_vuukle_scripts' ); function ampforwp_add_vuukle_scripts( $data ) { global $redux_builder_amp; $display_comments_on = ""; $display_comments_on = ampforwp_get_comments_status(); if ( ampforwp_get_setting('ampforwp-vuukle-comments-support') && $display_comments_on) { if ( empty( $data['amp_component_scripts']['amp-iframe'] ) ) { $data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js'; } if (ampforwp_get_setting('ampforwp-vuukle-Ads-before-comments') && empty( $data['amp_component_scripts']['amp-ad'] ) ) { $data['amp_component_scripts']['amp-ad'] = 'https://cdn.ampproject.org/v0/amp-ad-0.1.js'; } } return $data; } //spotim #2076 add_action('ampforwp_post_after_design_elements','ampforwp_spotim_comments_support'); function ampforwp_spotim_comments_support() { global $redux_builder_amp; if ( 4 != $redux_builder_amp['amp-design-selector'] && isset($redux_builder_amp['ampforwp-spotim-comments-support']) && $redux_builder_amp['ampforwp-spotim-comments-support']==1 ) { echo ampforwp_spotim_comments_markup(); } } function ampforwp_spotim_comments_markup() { global $post; $display_comments_on = false; $display_comments_on = ampforwp_get_comments_status(); if (! $display_comments_on ) { return ''; } $spotId =''; if( true == ampforwp_get_setting('ampforwp-spotim-comments-apiKey') && ampforwp_get_setting('ampforwp-spotim-comments-apiKey') !== ""){ $spotId = ampforwp_get_setting('ampforwp-spotim-comments-apiKey'); } $srcUrl = 'https://amp.spot.im/production.html?spot_im_highlight_immediate=true'; $srcUrl = add_query_arg('spotId' ,$spotId, $srcUrl); $srcUrl = add_query_arg('postId' , $post->ID, $srcUrl); $spotim_html = '
Load more...
'; return $spotim_html; } //spotim script add_filter( 'amp_post_template_data', 'ampforwp_add_spotim_scripts' ); function ampforwp_add_spotim_scripts( $data ) { global $redux_builder_amp; $display_comments_on = ""; $display_comments_on = ampforwp_get_comments_status(); if ( 4 != $redux_builder_amp['amp-design-selector'] && isset($redux_builder_amp['ampforwp-spotim-comments-support']) && $redux_builder_amp['ampforwp-spotim-comments-support'] && $display_comments_on && comments_open() ) { if ( empty( $data['amp_component_scripts']['amp-iframe'] ) ) { $data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js'; } } return $data; } //spotim css add_action('amp_post_template_css','ampforwp_spotim_vuukle_styling',60); function ampforwp_spotim_vuukle_styling(){ global $redux_builder_amp; $display_comments_on = ""; $display_comments_on = ampforwp_get_comments_status(); if ( isset($redux_builder_amp['ampforwp-spotim-comments-support']) && $redux_builder_amp['ampforwp-spotim-comments-support'] && $display_comments_on && comments_open() ) { ?>.spot-im-amp-overflow { background: white; font-size: 15px; padding: 15px 0; text-align: center; font-family: Helvetica, Arial, sans-serif; color: #307fe2; } .afwp-vuukle-support{ display: block;text-align: center;background: #1f87e5;color: #fff;border-radius: 4px; }
'; } } // rel="next" & rel="prev" pagination meta tags #2343 add_action( 'amp_post_template_head', 'ampforwp_rel_next_prev' ); function ampforwp_rel_next_prev(){ global $paged; if(ampforwp_is_front_page()){ return ; } if ( get_previous_posts_link() ) { ?> = 3000 ) { $content = '
' . $content . '
'; $content = $content . '
'; $content = $content . '
'; } return $content; } // Content Sneak Peek Scripts css function ampforwp_sneak_peek_css(){ global $redux_builder_amp; $height = $txt_color = $btn_color = ''; $height = ampforwp_get_setting('content-sneak-peek-height'); $btn_color = $redux_builder_amp['content-sneak-peek-btn-color']['color']; $txt_color = $redux_builder_amp['content-sneak-peek-txt-color']['color'];?> .fd-h{height: ;overflow: hidden;position: relative;} .fd-b-c{text-align: center;margin: 0px 0px 30px 0px;} .fd-b-c .fd-b:hover{cursor:pointer;} .fd-b-c .fd-b {border:none;border-radius: 5px;color: ;font-size: 16px;font-weight: 700;padding: 12px 32px 12px 32px;background-color: ; } .fd-h:after { content: ""; display: inline-block; position: absolute; background: linear-gradient(to bottom,rgba(255,255,255,0) 0,rgba(255,255,255,1) 100%); width:100%; bottom: 0; top:auto; height:230px; } array(), 'AMP_Blacklist_Sanitizer' => array(), 'AMP_Style_Sanitizer' => array(), 'AMP_Video_Sanitizer' => array(), 'AMP_Audio_Sanitizer' => array(), 'AMP_Iframe_Sanitizer' => array( 'add_placeholder' => true, ), ) ) ); $content = $sanitizer_obj->get_amp_content(); return $content; } // Instant Articles Meta Box add_action( 'add_meta_boxes', 'ampforwp_ia_meta_box' ); if ( ! function_exists('ampforwp_ia_meta_box') ) { function ampforwp_ia_meta_box() { global $redux_builder_amp, $post; if ( ampforwp_role_based_access_options() == true ) { if( true == $redux_builder_amp['fb-instant-article-switch'] && $post->post_type == 'post' ) { add_meta_box( 'ampforwp_ia_meta', esc_html__( 'Show Instant Article for Current Post?','accelerated-mobile-pages' ), 'ampforwp_ia_meta_callback', 'post','side' ); } } } } // Callback function for Instant Articles Meta Box. function ampforwp_ia_meta_callback( $post ) { global $redux_builder_amp; wp_nonce_field( basename( __FILE__ ), 'ampforwp_ia_nonce' ); $ampforwp_stored_meta = get_post_meta( $post->ID ); if ( ! isset($ampforwp_stored_meta['ampforwp-ia-on-off']) && ! isset($ampforwp_stored_meta['ampforwp-ia-on-off'][0]) && $ampforwp_stored_meta['ampforwp-ia-on-off'][0] == 'hide-ia') { $exclude_post_value = get_option('ampforwp_ia_exclude_post'); if ( $exclude_post_value == null ) { $exclude_post_value[] = 0; } if ( $exclude_post_value ) { if ( ! in_array( $post->ID, $exclude_post_value ) ) { $exclude_post_value[] = $post->ID; update_option('ampforwp_ia_exclude_post', $exclude_post_value); } } } else { $exclude_post_value = get_option('ampforwp_ia_exclude_post'); if ( $exclude_post_value == null ) { $exclude_post_value[] = 0; } if ( $exclude_post_value ) { if ( in_array( $post->ID, $exclude_post_value ) ) { $exclude_ids = array_diff($exclude_post_value, array($post->ID) ); update_option('ampforwp_ia_exclude_post', $exclude_ids); } } } ?>

base ) { remove_action('admin_enqueue_scripts', 'total_plus_admin_scripts', 100); // Save option is not showing with a basix theme #3366 if(function_exists('addPanelCSS')){ remove_action( 'admin_enqueue_scripts', 'addPanelCSS'); } } } // uploading the images with SVG format #2431 function ampforwp_upload_svg($file_types){ $new_filetypes = array(); $new_filetypes['svg'] = 'image/svg+xml'; $file_types = array_merge($file_types, $new_filetypes ); return $file_types; } add_action('upload_mimes', 'ampforwp_upload_svg'); // Ajax functions add_action( 'wp_ajax_ampforwp_categories', 'ampforwp_ajax_cats' ); function ampforwp_ajax_cats(){ if(!wp_verify_nonce($_GET['security'],'ampforwp-verify-request') ){ echo json_encode(array('status'=>403,'message'=>'user request is not allowed')) ; die; } $return = array(); $categories = get_categories(array('search'=> esc_html($_GET['q']),'number'=>500,'hide_empty' => 0)); $categories_array = array(); if ( $categories ) : foreach ($categories as $cat ) { $return[] = array($cat->cat_ID,$cat->name);// array( Cat ID, Cat Name ) } endif; wp_send_json( $return ); } add_action( 'wp_ajax_ampforwp_tags', 'ampforwp_ajax_tags' ); function ampforwp_ajax_tags(){ if(!wp_verify_nonce($_GET['security'],'ampforwp-verify-request') ){ echo json_encode(array('status'=>403,'message'=>'user request is not allowed')) ; die; } $return = array(); $tags = get_tags(array('search'=> esc_html($_GET['q']),'number'=>500)); if ( $tags ) : foreach ($tags as $tag ) { $return[] = array($tag->term_id,$tag->name);// array( Tag ID, tag Name ) } endif; wp_send_json( $return ); } add_filter( 'amp_post_template_data', 'ampforwp_backtotop' ); function ampforwp_backtotop( $data ) { global $redux_builder_amp; if(true == ampforwp_get_setting('ampforwp-footer-top')){ if ( empty( $data['amp_component_scripts']['amp-position-observer'] ) ) { $data['amp_component_scripts']['amp-position-observer'] = 'https://cdn.ampproject.org/v0/amp-position-observer-0.1.js'; } if ( empty( $data['amp_component_scripts']['amp-animation'] ) ) { $data['amp_component_scripts']['amp-animation'] = 'https://cdn.ampproject.org/v0/amp-animation-0.1.js'; } } return $data; } // Jannah Theme Subtitle Support #2732 add_action('ampforwp_below_the_title','ampforwp_jannah_subtitle'); function ampforwp_jannah_subtitle(){ if (function_exists('jannah_theme_name') && function_exists('tie_get_postdata')){?>

.wp-block-button { color: #fff} .wp-block-button a {background-color: ;border-radius: 28px;color: inherit;display: inline-block;padding: 12px 24px;} .wp-block-cover{position:relative;background-color: #000;background-size: cover;background-position: center center;min-height: 430px;width: 100%;margin: 1.5em 0 1.5em 0;display: flex;justify-content: center;align-items: center;overflow: hidden;} .wp-block-cover-text{color: #fff;font-size: 2em;line-height: 1.25;z-index: 1;} .wp-block-cover-image.has-background-dim::before, .wp-block-cover.has-background-dim::before {content: "";position: absolute;top: 0;left: 0;bottom: 0;right: 0;background-color: inherit;opacity: .5;z-index: 1;} .has--color { color: ;} .has--background-color { background-color: }

$postID, 'order' => esc_attr($comment_order), 'status' => 'approve' //Change this to the type of comments to be displayed ) ); foreach ($comments as $comment) { $comment_data = get_comment( $comment->comment_ID ); $comment_text = $comment_data->comment_content; $comment_text = wpautop( $comment_text ); $sanitizer = new AMPforWP_Content( $comment_text, apply_filters( 'amp_content_embed_handlers', array( 'AMP_Reddit_Embed_Handler' => array(), 'AMP_Twitter_Embed_Handler' => array(), 'AMP_YouTube_Embed_Handler' => array(), 'AMP_DailyMotion_Embed_Handler' => array(), 'AMP_Vimeo_Embed_Handler' => array(), 'AMP_SoundCloud_Embed_Handler' => array(), 'AMP_Instagram_Embed_Handler' => array(), 'AMP_Vine_Embed_Handler' => array(), 'AMP_Facebook_Embed_Handler' => array(), 'AMP_Pinterest_Embed_Handler' => array(), 'AMP_Gallery_Embed_Handler' => array(), ) ), apply_filters( 'amp_sidebar_sanitizers', array( 'AMP_Style_Sanitizer' => array(), 'AMP_Blacklist_Sanitizer' => array(), 'AMP_Img_Sanitizer' => array(), 'AMP_Video_Sanitizer' => array(), 'AMP_Audio_Sanitizer' => array(), 'AMP_Playbuzz_Sanitizer' => array(), 'AMP_Iframe_Sanitizer' => array( 'add_placeholder' => true, ), ) ) ); if ( $sanitizer ) { $sanitizer_scripts = $sanitizer->get_amp_scripts(); if ( $sanitizer_scripts ){ $comments_scripts = array_merge($comments_scripts, $sanitizer_scripts); } } } if ( $comments_scripts ) { $ampforwp_data['comments']['scripts'] = $comments_scripts; } } } // AMPforWP Global Scripts add_filter('amp_post_template_data','ampforwp_add_global_scripts'); function ampforwp_add_global_scripts($data){ global $ampforwp_data; $comments_scripts = array(); // Add Comments Scripts #2827 if ( $comments_scripts ) { $comments_scripts = $ampforwp_data['comments']['scripts']; } if ( !empty($comments_scripts) ) { foreach ($comments_scripts as $key => $value ) { if( empty( $data['amp_component_scripts'][$key] ) ){ $data['amp_component_scripts'][$key] = $value; } } } // AddThis Support #3068 if ( ampforwp_get_setting('enable-add-this-option') && ( is_single() || (is_page() && ampforwp_get_setting('ampforwp-page-social') ) ) && !ampforwp_woocommerce_conditional_check() && !checkAMPforPageBuilderStatus(ampforwp_get_the_ID()) && ( ampforwp_get_setting('addthis-floating-share') == true || ampforwp_get_setting('addthis-inline-share') == true)) { if ( empty( $data['amp_component_scripts']['amp-addthis'] ) ) { $data['amp_component_scripts']['amp-addthis'] = 'https://cdn.ampproject.org/v0/amp-addthis-0.1.js'; } } // Featured video SmartMag theme Compatibility #2559: if( function_exists('get_the_post_video') || class_exists('Bunyad') ) { if ( empty( $data['amp_component_scripts']['amp-iframe'] ) ) { $data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js'; } } //Appearance option for Related Posts #1545 if ( true == ampforwp_get_setting('ampforwp-single-related-posts-switch') && ampforwp_get_setting('rp_design_type') == '3') { if ( empty( $data['amp_component_scripts']['amp-carousel'] ) ) { $data['amp_component_scripts']['amp-carousel'] = 'https://cdn.ampproject.org/v0/amp-carousel-0.2.js'; } } return $data; } if ( ! function_exists('ampforwp_get_weglot_url') ) { function ampforwp_get_weglot_url(){ $url = weglot_get_full_url_no_language(); $current_lang = weglot_get_current_and_original_language(); $original_lang = $current_lang['original']; $current_lang = $current_lang['current']; if($current_lang == $original_lang ){ return $url; }else{ $url = trailingslashit($url) . $current_lang; return esc_url(user_trailingslashit($url)); } } } // Rank Math SEO Compatibility #2701 // og tags and Schema add_action('amp_post_template_head','ampforwp_rank_math'); if ( ! function_exists('ampforwp_rank_math') ) { function ampforwp_rank_math(){ // Early Bail if Rank Math is not selected in SEO Plugin Integration. if ( 'rank_math' !== ampforwp_get_setting('ampforwp-seo-selection') ) { return; } // Remove Canonical & Title Tag added by the Rank Math plugin. remove_all_actions( 'rank_math/head', 20 ); remove_all_actions( 'rank_math/head', 1 ); // Remove meta tags added by the Rank Math plugin. if ( ! ampforwp_get_setting( 'ampforwp-seo-rank_math-meta' ) ) { $json_ld_data = isset( $wp_filter['rank_math/json_ld'] ) ? $wp_filter['rank_math/json_ld'] : ''; remove_all_actions( 'rank_math/opengraph/facebook' ); remove_all_actions( 'rank_math/opengraph/twitter' ); add_filter( 'rank_math/frontend/robots', function() { return []; }); }else if(ampforwp_is_front_page()){ add_filter( 'rank_math/frontend/robots', function() { return []; }); } // Remove ld+json data added by the Rank math plugin. if ( ! ampforwp_get_setting( 'ampforwp-seo-rank_math-schema' ) ) { remove_all_actions( 'rank_math/json_ld' ); } if(class_exists('RankMath') && true == ampforwp_get_setting('ampforwp-amp-takeover') && ( ampforwp_is_home() || ampforwp_is_front_page())){ $google = RankMath\Helper::get_settings( 'general.google_verify' ); $bing = RankMath\Helper::get_settings( 'general.bing_verify' ); $baidu = RankMath\Helper::get_settings( 'general.baidu_verify' ); $alexa = RankMath\Helper::get_settings( 'general.alexa_verify' ); $yandex = RankMath\Helper::get_settings( 'general.yandex_verify' ); $pinterest = RankMath\Helper::get_settings( 'general.pinterest_verify' ); $norton = RankMath\Helper::get_settings( 'general.norton_verify' ); if(!empty($google)){?> preview->is_preview_mode() ){ return false; }else{ return $data; } } return $data; } // Multiple Images #2259 // Moved to structured-data-functions.php // schema.org/SiteNavigationElement missing from menus #1229 & #2952 // Moved to structured-data-functions.php // WP Subtitle Support #2831 add_action('ampforwp_below_the_title','ampforwp_wpsubtitle_support'); if (! function_exists('ampforwp_wpsubtitle_support') ) { function ampforwp_wpsubtitle_support(){ if(class_exists('WPSubtitle')){?>

loadHTML($menu); libxml_use_internal_errors(false); // get all the forms $nodes = $dom->getElementsByTagName( 'form' ); $num_nodes = $nodes->length; for ( $i = $num_nodes - 1; $i >= 0; $i-- ) { $node = $nodes->item( $i ); // Set The Width and Height if there in none if ( '' === $node->getAttribute( 'target' ) ) { $node->setAttribute('target', '_top'); } if ( $node->getAttribute('action')){ $action_url = ''; $action_url = $node->getAttribute('action'); $action_url = preg_replace('#^http?:#', '', $action_url); $node->setAttribute('action', $action_url); } } $menu = $dom->saveHTML(); } return $menu; } } add_action('amp_post_template_css','ampforwp_ivory_search_css'); function ampforwp_ivory_search_css(){ if(class_exists('Ivory_Search')){?> svg.icon.icon-search { display: none; } input.search-field { display: inline-block; } svg.search-icon { display: none; } og_image(); echo $og_tsf->og_locale(); echo $og_tsf->og_type(); echo $og_tsf->og_title(); echo $og_tsf->og_image(); echo $og_tsf->og_description(); echo $og_tsf->og_sitename(); } } $prefetch = ampforwp_get_setting('amp-prefetch-options'); $data_arr = array(); if(is_array($prefetch)){ foreach ( $prefetch as $k => $value ) { if(is_array($value)){ foreach ($value as $tk => $tval) { $temp_arr = array(); $temp_arr['name'][] = $k; $temp_arr['type'][] = $tk; foreach ($tval as $ck => $cval) { $temp_arr['value'][] = $cval; } $data_arr[] = $temp_arr; } } } if(isset($data_arr[0]) && !empty($data_arr)){ $val_count = count($data_arr[0]['value']); for($i=0;$i<$val_count;$i++){ for($j=0;$j (.*?)<\/a>/', $breadcrumb)){ $breadcrumb = preg_replace('/(.*?)<\/a>/', '$2', $breadcrumb); } return $breadcrumb; } } } // Slide Anything compatibility #2891 add_filter('amp_content_embed_handlers','ampforwp_slide_anything_embed'); function ampforwp_slide_anything_embed($data) { if ( function_exists('cpt_slider_plugin_activation') ) { require_once( AMPFORWP_PLUGIN_DIR. 'classes/class-ampforwp-slide-anything-embed.php' ); $data['AMPFORWP_Slide_Anything_Embed_Handler'] = array(); } return $data; } // Revolution Slider compatibility #1464 add_action('pre_amp_render_post', 'ampforwp_initialise_rev_slider'); if ( ! function_exists('ampforwp_initialise_rev_slider') ) { function ampforwp_initialise_rev_slider(){ if ( class_exists('RevSliderOutput') ){ require AMPFORWP_PLUGIN_DIR .'/classes/class-ampforwp-rev-slider.php'; } } } add_filter('amp_content_embed_handlers','ampforwp_rev_slider_embed'); function ampforwp_rev_slider_embed($data) { if ( class_exists('RevSliderOutput') ){ $data['AMP_Rev_Slider_Embed_Handler'] = array(); } return $data; } // Photo Gallery by 10Web Compatibility #1811 add_action('pre_amp_render_post', 'ampforwp_initialise_photo_gallery'); if ( ! function_exists('ampforwp_initialise_photo_gallery') ) { function ampforwp_initialise_photo_gallery(){ if ( class_exists('BWG') ) { require AMPFORWP_PLUGIN_DIR .'/classes/class-ampforwp-photo-gallery-embed.php'; } } } add_filter('amp_content_embed_handlers','ampforwp_photo_gallery_embed'); function ampforwp_photo_gallery_embed($data) { if ( class_exists('BWG') ) { $data['AMPforWP_Photo_Gallery_Embed_Handler'] = array(); } return $data; } function ampforwp_rel_attributes_social_links(){ $rel_attributes = array(); if (true == ampforwp_get_setting('ampforwp-social-no-follow')) { $rel_attributes[] = 'nofollow'; } if (true == ampforwp_get_setting('ampforwp-social-no-referrer')) { $rel_attributes[] = 'noreferrer'; } if (true == ampforwp_get_setting('ampforwp-social-no-opener')) { $rel_attributes[] = 'noopener'; } $rel_attributes = apply_filters('ampforwp_rel_attributes_social_links', $rel_attributes); $rel_attributes = array_map('esc_attr', $rel_attributes); if ( $rel_attributes ) { echo 'rel="' . implode(" ",$rel_attributes).'"'; } return; } // Fallback added function ampforwp_nofollow_social_links(){ ampforwp_rel_attributes_social_links(); return ; } function ampforwp_nofollow_notification(){ if(true == ampforwp_get_setting('ampforwp-notifications-nofollow')){ echo 'rel=nofollow'; return; } return false; } // Featured Video SmartMag theme Compatibility CSS #2559 add_action('amp_post_template_css', 'ampforwp_featured_video_plus_css'); function ampforwp_featured_video_plus_css(){ if( function_exists('get_the_post_video') ) {?> .fvp-onload{display:none} .amp-featured-image amp-iframe, .amp-wp-article-featured-image amp-iframe { margin:auto; height:100%; } .f_vid { background: #000; } ";?>
'; } return $form; } } //Saving all taxonomies in Transient add_action('init','ampforwp_generate_taxonomies_transient'); function ampforwp_generate_taxonomies_transient(){ $taxonomies = get_transient('ampforwp_get_taxonomies'); $tax_arr = array(); $args = array( 'public' => true, '_builtin' => false, ); $output = 'objects'; // or objects $operator = 'and'; // 'and' or 'or' $alltaxonomies = get_taxonomies( $args, $output, $operator ); if ($alltaxonomies) { foreach ($alltaxonomies as $taxKey => $taxVal) { $tax_arr[$taxVal->name] = $taxVal->labels->singular_name; } } if ( false == $taxonomies ) { set_transient('ampforwp_get_taxonomies',$tax_arr); }else{ if(count($tax_arr) > count($taxonomies)){ $result = array_diff_assoc($tax_arr,$taxonomies); }elseif( count($taxonomies) > count($tax_arr)){ $result = array_diff_assoc($taxonomies,$tax_arr); } if( !empty($result)){ delete_transient('ampforwp_get_taxonomies'); } } return $taxonomies; } // Include Opengraph.php #3261 add_action('pre_amp_render_post', 'ampforwp_include_opengraph'); if ( ! function_exists('ampforwp_include_opengraph') ) { function ampforwp_include_opengraph(){ if ( true == ampforwp_get_setting('ampforwp-seo-og-meta-tags') && '' == ampforwp_get_setting('ampforwp-seo-selection') ) { require_once AMPFORWP_PLUGIN_DIR."includes/features/opengraph.php"; } } } add_action('wp_ajax_ampforwp_import_file_from_file','ampforwp_import_settings_from_file'); function ampforwp_import_settings_from_file(){ $security = $_POST['security']; if ( wp_verify_nonce( $security, 'ampforwp_import_file' ) && current_user_can( 'manage_options' ) ) { if(isset($_FILES["file"]["tmp_name"])){ $content = file_get_contents($_FILES["file"]["tmp_name"]); if ( ! empty ( $content ) ) { $imported_options = json_decode( $content, true ); } $plugin_options = get_option('redux_builder_amp'); if ( ! empty ( $imported_options ) && is_array( $imported_options ) && isset ( $imported_options['redux-backup'] ) && $imported_options['redux-backup'] == '1' ) { echo $content; } } } } add_filter('ampforwp_loop_image_update','ampforwp_recentpost_link_to_nonamp'); function ampforwp_recentpost_link_to_nonamp($image_link_data){ if( true == ampforwp_get_setting('ampforwp-recentpost-posts-link') ){ $image_link_data['image_link'] = get_permalink(); }else{ $image_link_data['image_link'] = ampforwp_url_controller( get_permalink() ) ; } return $image_link_data; } #3596 link to nonamp option on title for recent posts add_filter('ampforwp_loop_permalink_update','ampforwp_recentpost_title_link_to_nonamp'); function ampforwp_recentpost_title_link_to_nonamp($title_link){ if( true == ampforwp_get_setting('ampforwp-recentpost-posts-link') ){ $title_link = get_permalink(); }else{ $title_link = ampforwp_url_controller( get_permalink() ) ; } return $title_link; } // Post Meta Revisions #3548 -- start here -- add_filter( '_wp_post_revision_field_amp_page_builder', 'ampforwp_meta_revi_pb_field', 22, 2 ); add_action( 'save_post', 'ampforwp_meta_revi_save_post', 10, 2 ); add_action( 'wp_restore_post_revision', 'ampforwp_meta_restore_revision', 10, 2 ); add_filter( '_wp_post_revision_fields', 'ampforwp_meta_revi_fields' ); // Displaying the meta field on the revisions screen function ampforwp_meta_revi_fields( $fields ) { $fields['post_title'] = 'Title'; $fields['post_content'] = 'Content'; $fields['post_excerpt'] = 'Excerpt'; $fields['amp-page-builder'] = 'AMP Page Builder'; return $fields; } // Displaying the meta field on the revisions screen function ampforwp_meta_revi_pb_field( $value, $field ) { global $revision; return get_metadata( 'post', $revision->ID, $field, true ); } // Reverting to the correct revision of the meta field when a post is reverted function ampforwp_meta_restore_revision( $post_id, $revision_id ) { if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) { return; } $post = get_post( $post_id ); $revision = get_post( $revision_id ); $meta = get_metadata( 'post', $revision->ID, 'amp-page-builder', true ); if ( false === $meta ) { delete_post_meta( $post_id, 'amp-page-builder' ); } else{ update_post_meta( $post_id, 'amp-page-builder', $meta ); } } // Storing a revision of the meta field when a post is saved function ampforwp_meta_revi_save_post( $post_id, $post ) { if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) { return; } if ( $parent_id = wp_is_post_revision( $post_id ) ) { $parent = get_post( $parent_id ); $pb_meta = get_post_meta( $parent->ID, 'amp-page-builder', true ); if ( false !== $pb_meta ){ add_metadata( 'post', $post_id, 'amp-page-builder', $pb_meta ); } } } // Post Meta Revisions #3548 -- end here -- // FOR ADMIN MENU BAR add_action( 'pre_amp_render_post', 'ampforwp_front_admin_menu_bar' ); function ampforwp_front_admin_menu_bar(){ if( is_user_logged_in() ){ $pref = get_user_option( "show_admin_bar_front", get_current_user_id() ); if($pref==="true"){ if(class_exists('QM_Plugin') && class_exists('QM_Dispatchers') && ampforwp_get_setting('ampforwp-query-monitor')){ $dis = QM_Dispatchers::get( 'html' ); if($dis->did_footer==false){ $dis->did_footer = true; add_action( 'amp_post_template_head', 'ampforwp_query_monitor_script' ); add_action( 'amp_post_template_head', 'ampforwp_manual_qm_script', 11 ); } } add_action("ampforwp_admin_menu_bar_front", function(){ add_action('wp_before_admin_bar_render','ampforwp_add_admin_menu_front'); wp_admin_bar_render(); }); add_action( 'admin_bar_init', 'ampforwp_init_admin_bar'); add_action( 'wp_before_admin_bar_render','ampforwp_remove_before_admin_bar_redner',9); add_action( 'admin_bar_menu', 'ampforwp_remove_admin_menu_front',999); add_action('amp_post_template_css', 'ampforwp_head_css'); } } } function ampforwp_remove_before_admin_bar_redner(){ remove_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' ); } function ampforwp_init_admin_bar(){ remove_action( 'wp_head', '_admin_bar_bump_cb' ); remove_action( 'wp_head', 'wp_admin_bar_header' ); } global $wp_filesystem; function ampforwp_head_css(){ global $ampforwpTemplate, $redux_builder_amp, $wp_filesystem; $css = ""; if( is_user_logged_in() ){ $pref = get_user_option( "show_admin_bar_front", get_current_user_id() ); if($pref==="true"){ 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() ); if(ampforwp_get_setting('ampforwp_css_tree_shaking')==1){ if(ampforwp_is_home()){ $tscss = "home"; }elseif(ampforwp_is_blog()){ $tscss = "blog"; }elseif(ampforwp_is_front_page()){ $tscss = "post-".ampforwp_get_frontpage_id(); }elseif(is_singular()){ $tscss = "post-".ampforwp_get_the_ID(); }elseif(is_archive()){ $page_id = get_queried_object_id(); $tscss = "archive-".intval($page_id); } $tscss = $tscss.'-admin'; $upload_dir = wp_upload_dir(); $ts_file = esc_attr($upload_dir['basedir']) . '/' . 'ampforwp-tree-shaking/_transient_'.esc_attr($tscss).".css"; if(file_exists($ts_file)){ $css = $wp_filesystem->get_contents($ts_file); if(preg_match("/#wpadminbar/", $css)==0){ $user_dirname = $upload_dir['basedir'] . '/' . 'ampforwp-tree-shaking'; if(file_exists($user_dirname)){ $files = glob($user_dirname . '/*'); foreach($files as $file){ if(is_file($file) && strpos($file, '_transient')!==false ){ unlink($file); } } } } } } $css = $wp_filesystem->get_contents(AMPFORWP_PLUGIN_DIR."/templates/template-mode/admin-bar.css"); $incurl = includes_url(); $incurl = trailingslashit($incurl) .'fonts/dashicons.ttf?50db0456fde2a241f005968eede3f987'; $css.='@font-face{font-family:dashicons;src:url('.$incurl.'/fonts/dashicons.ttf?50db0456fde2a241f005968eede3f987) format("truetype"); font-weight:400;font-style:normal} #wp-admin-bar-my-account .avatar{float:right;margin-top:7px;margin-left:5px;height:18px;width:18px;border:1px solid #82878c}#wp-admin-bar-wpseo-notifications .yoast-issue-counter{float:right}@media(max-width:782px){#wpadminbar~header #headerwrap{top:46px}}'; if(ampforwp_get_setting('amp-design-selector')!=3){ $css.='#wpadminbar~header{margin-top:32px}@media(max-width:782px){#wpadminbar~header{margin-top:46px}}'; }else{ $css.='#wpadminbar~header #headerwrap{top:32px}@media(max-width:782px){#wpadminbar~header #headerwrap{margin-top:46px}}'; } echo ampforwp_css_sanitizer($css); } } } function ampforwp_css_sanitizer($css){ $css = preg_replace( '/\s*!important/', '', $css, -1, $important_count ); $css = preg_replace( '/overflow(-[xy])?\s*:\s*(auto|scroll)\s*;?\s*/', '', $css, -1, $overlow_count ); $css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css); $css = str_replace(array (chr(10), ' {', '{ ', ' }', '} ', '( ', ' )', ' :', ': ', ' ;', '; ', ' ,', ', ', ';}', '::-' ), array('', '{', '{', '}', '}', '(', ')', ':', ':', ';', ';', ',', ', ', '}', ' ::-'), $css); return $css; } function ampforwp_get_remote_content($src){ if($src){ $arg = array( "sslverify" => false, "timeout" => 60 ) ; $response = wp_remote_get( $src, $arg ); if ( wp_remote_retrieve_response_code($response) == 200 && is_array( $response ) ) { $header = wp_remote_retrieve_headers($response); // array of http header lines $contentData = wp_remote_retrieve_body($response); // use the content return $contentData; } }else{ return $contentData = file_get_contents( $src ); } return ''; } function ampforwp_add_admin_menu_front(){ global $wp_admin_bar; $dom = new DOMDocument(); $my_account = $wp_admin_bar->get_node('my-account'); $title = ''; if(is_object($my_account)){ $title = ampforwp_content_sanitizer($my_account->title); } $wp_admin_bar->add_menu( array( 'id' => 'my-account', 'title' => $title ) ); $user_info = $wp_admin_bar->get_node('user-info'); if(is_object($user_info)){ $title = $user_info->title; } if($title){ // To Suppress Warnings libxml_use_internal_errors(true); $dom->loadHTML($title); libxml_use_internal_errors(false); $anchors = $dom -> getElementsByTagName('img'); $src=""; foreach($anchors as $im){ $src = $im->getAttribute('src'); } $authname = get_the_author_meta('nickname'); $title = ''.esc_html__($authname,'accelerated-mobile-pages').''; $wp_admin_bar->add_menu( array( 'id' => 'user-info', 'title' => $title ) ); if(class_exists('WPSEO_Options')){ $wp_admin_bar->add_menu( array( 'id' => 'wpseo-menu', 'title' => "SEO" ) ); } $wp_admin_bar->remove_menu( 'ampforwp-view-amp' ); if(function_exists('autoptimize_autoload')){ $wp_admin_bar->remove_menu( 'autoptimize' ); } if (is_preview()) { $url = get_preview_post_link(); $wp_admin_bar->add_node(array( 'id' => 'ampforwp-view-non-amp', 'title' => 'View Non-AMP', 'href' => esc_url($url) )); } else{ $url = ampforwp_get_non_amp_url(); $wp_admin_bar->add_node(array( 'id' => 'ampforwp-view-non-amp', 'title' => 'View Non-AMP' , 'href' => esc_url($url) )); } } } function ampforwp_remove_admin_menu_front($wp){ $node_arr = ['search','admin-bar-likes-widget']; for($i=0;$iremove_node($node_arr[$i]); } } function ampforwp_manual_qm_script() { wp_print_scripts( array( 'query-monitor', ) ); wp_print_styles( array( 'query-monitor', ) ); } function ampforwp_query_monitor_script() { global $wp_locale; $qm = plugins_url(); $deps = array( 'jquery', ); if ( defined( 'QM_NO_JQUERY' ) && QM_NO_JQUERY ) { $deps = array(); } $css = 'query-monitor'; if ( method_exists( 'Dark_Mode', 'is_using_dark_mode' ) && is_user_logged_in() ) { if ( Dark_Mode::is_using_dark_mode() ) { $css .= '-dark'; } } elseif ( defined( 'QM_DARK_MODE' ) && QM_DARK_MODE ) { $css .= '-dark'; } wp_enqueue_style( 'query-monitor', esc_attr($qm)."/query-monitor/assets/{$css}.css", array( 'dashicons' ) ); wp_enqueue_script( 'query-monitor', esc_attr($qm).'/query-monitor/assets/query-monitor.js', $deps, false ); wp_localize_script( 'query-monitor', 'qm_number_format', $wp_locale->number_format ); wp_localize_script( 'query-monitor', 'qm_l10n', array( 'ajax_error' => __( 'PHP Errors in Ajax Response', 'query-monitor' ), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'auth_nonce' => array( 'on' => wp_create_nonce( 'qm-auth-on' ), 'off' => wp_create_nonce( 'qm-auth-off' ), 'editor-set' => wp_create_nonce( 'qm-editor-set' ), ), ) ); } function ampforwp_get_non_amp_url(){ global $post, $wp; $nofollow = $page = $amp_url = $non_amp_url = ''; if( true == ampforwp_get_setting('ampforwp-nofollow-view-nonamp') ){ $nofollow = 'rel=nofollow'; } $amp_url = untrailingslashit( home_url( $wp->request ) ); $amp_url = explode('/', $amp_url); $amp_url = array_flip($amp_url); unset($amp_url[AMPFORWP_AMP_QUERY_VAR]); $non_amp_url = array_flip($amp_url); $non_amp_url = implode('/', $non_amp_url); $query_arg_array = $wp->query_vars; if( array_key_exists( "page" , $query_arg_array ) ) { $page = $wp->query_vars['page']; } if ( $page >= '2') { $non_amp_url = trailingslashit( $non_amp_url . '?page=' . $page); } if ( ampforwp_get_setting('amp-mobile-redirection') ) { $non_amp_url = add_query_arg('nonamp','1',$non_amp_url); } else $non_amp_url = user_trailingslashit($non_amp_url); if ( true == ampforwp_get_setting('ampforwp-amp-takeover') ) { $non_amp_url = ''; } if ( $non_amp_url ) { return apply_filters('ampforwp_view_nonamp_url', $non_amp_url); } } add_action( 'wp_ajax_ampforwp_set_option_panel_view', 'ampforwp_set_option_panel_view' ); function ampforwp_set_option_panel_view(){ if(!is_admin() && !current_user_can('manage_options')){ return ; } if(!wp_verify_nonce($_POST['verify_nonce'],'ampforwp-verify-request') ){ echo json_encode(array('status'=>403,'message'=>'user request is not allowed')) ; die; } $opt_type = intval($_POST['option_type']); if($opt_type==1 || $opt_type==2){ $opt = get_option("ampforwp_option_panel_view_type"); if($opt){ update_option("ampforwp_option_panel_view_type", $opt_type); }else{ add_option("ampforwp_option_panel_view_type", $opt_type); } } } add_action('admin_head', 'ampforwp_remove_admin_help'); if(!function_exists('ampforwp_remove_admin_help')){ function ampforwp_remove_admin_help(){ if(!is_admin() && !current_user_can('manage_options')){ return ; } $screen = get_current_screen(); if ( 'toplevel_page_amp_options' == $screen->base ) { $screen->remove_help_tabs(); } } } if(!function_exists('ampforwp_sassy_icon_style')){ function ampforwp_sassy_icon_style(){ global $wp_filesystem; $css = get_transient('ampforwp_sassy_css'); if($css == false){ 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() ); } $css = $wp_filesystem->get_contents(AMPFORWP_PLUGIN_DIR."/includes/sassy-style.css"); set_transient('ampforwp_sassy_css', $css); } echo ampforwp_css_sanitizer($css); } } if(function_exists('heateor_sss_run')){ add_action('amp_post_template_css', 'ampforwp_sassy_icon_style'); } function ampforwp_nofollow_cta_header_link(){ if(true == ampforwp_get_setting('ampforwp-header-cta-link-nofollow')){ echo 'rel=nofollow'; return; } return false; } // Generating canonical url when FlexMLS plugin is active. if(class_exists('flexmlsConnectPageSearchResults')){ add_action('pre_amp_render_post','ampforwp_flexmls_canonical'); } function ampforwp_flexmls_canonical(){ add_filter('wpseo_canonical','ampforwp_flexmls_generate_canonical_url',99,2); } function ampforwp_flexmls_generate_canonical_url($canonical,$object){ $canonical = $object->model->permalink; return esc_url($canonical); } // Font Selector if( ! function_exists('ampforwp_font_selector') ) { function ampforwp_font_selector( $container ) { global $redux_builder_amp; $fontFamily = ''; if(1==ampforwp_get_setting('ampforwp-google-font-switch')){ return sanitize_text_field($fontFamily); } if(empty($container)) { $container = 'body'; } if ( 'content' == $container && ampforwp_get_setting('amp_font_selector_content_single') && 1 != ampforwp_get_setting('amp_font_selector_content_single') ) { $fontFamily = "font-family: '".ampforwp_get_setting('amp_font_selector_content_single')."';"; } if ( 'body' == $container && ampforwp_get_setting('amp_font_selector') && 1 != ampforwp_get_setting('amp_font_selector') ) { $fontFamily = "font-family: '".ampforwp_get_setting('amp_font_selector')."'"; } return sanitize_text_field($fontFamily); } } if(class_exists('WPSEO_Options')){ add_filter('ampforwp_the_content_last_filter','ampforwp_remove_duplicate_canonical',25); } function ampforwp_remove_duplicate_canonical($content){ $comp_dom = new DOMDocument(); @$comp_dom->loadHTML($content); $xpath = new DOMXPath( $comp_dom ); $count = 0; $nodes = $xpath->query('//link[@rel="canonical"]'); $con = ''; foreach ($nodes as $node) { $count++; } if($count>1){ if(preg_match("/]*?\brel=[\'\"]canonical[\'\"][^>]*>/", $content, $matches, PREG_OFFSET_CAPTURE)){ $content = preg_replace("/]*?\brel=[\'\"]canonical[\'\"][^>]*>/", "", $content); $content = substr_replace($content, $matches[0][0], $matches[0][1], 0); } } return $content; } // Font URL controller if ( ! function_exists('ampforwp_font_url') ) { function ampforwp_font_url($font_url){ return apply_filters('ampforwp_font_url', $font_url); } } //Need to add full short pixel plugin compatibility #3782 if(class_exists('ShortPixelAPI')){ add_filter( 'ampforwp_the_content_last_filter','ampforwp_short_pixel_cdn'); } function ampforwp_short_pixel_cdn($content){ $api_url = get_option('spai_settings_api_url'); $compress_level = get_option('spai_settings_compress_level'); if('0'== $compress_level){ $compress_level = '+q_lossless'; } if('1'== $compress_level){ $compress_level = '+q_lossy'; } if('2'== $compress_level){ $compress_level = '+q_glossy'; } $compress_level .= '+ret_img+to_webp/'; if(!empty($api_url)){ $content = preg_replace('/]*)>/','',$content); } return $content; } if(ampforwp_get_setting('ampforwp_css_tree_shaking') == true && ampforwp_is_gutenberg_active()){ add_action('amp_post_template_css','ampforwp_gutenberg_block_styles'); } if(!function_exists('ampforwp_gutenberg_block_styles')){ function ampforwp_gutenberg_block_styles(){ $gutenberg_styles = $block_css = ''; ob_start(); wp_print_styles('wp-block-library'); $block_css .= ob_get_contents(); ob_end_clean(); preg_match("/href='(.*?)'/", $block_css, $matches); $style_path = explode('?', $matches[1]); $gutenberg_styles = get_transient('ampforwp_gutenberg_styles'); if($gutenberg_styles == false){ $response = wp_remote_get( $style_path[0] ); if( is_array( $response ) && ! is_wp_error( $response ) ){ set_transient('ampforwp_gutenberg_styles', $response['body'], 24 * HOUR_IN_SECONDS ); } } echo ampforwp_css_sanitizer($gutenberg_styles); } } function ampforwp_is_gutenberg_active() { $gutenberg = false; $block_editor = false; $use_block_editor = ''; if ( has_filter( 'replace_editor', 'gutenberg_init' ) ) { $gutenberg = true; } if ( version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' ) ) { $block_editor = true; } if ( ! $gutenberg && ! $block_editor ) { return false; } if ( !class_exists('Classic_Editor') ) { return true; } $use_block_editor = ( get_option( 'classic-editor-replace' ) === 'no-replace' ); return $use_block_editor; } add_filter( 'amp_post_template_data', 'ampforwp_pblayout_head_scripts'); $pb_remove_script = array(); function ampforwp_pblayout_head_scripts($data){ $postId = ampforwp_get_the_ID(); $ampforwp_pagebuilder_enable = get_post_meta($postId,'ampforwp_page_builder_enable', true); if(isset($ampforwp_pagebuilder_enable) && $ampforwp_pagebuilder_enable=="yes"){ $previousData = get_post_meta($postId,'amp-page-builder'); $previousData = isset($previousData[0])? $previousData[0]: null; $previousData = (str_replace("'", "'", $previousData)); $totalRows = 1; $totalmodules = 1; if(!empty($previousData)){ $jsonData = json_decode($previousData,true); if(count($jsonData['rows'])>0){ $totalRows = $jsonData['totalrows']; $totalmodules = $jsonData['totalmodules']; $previousData = json_encode($jsonData); }else{ $jsonData['rows'] = array(); $jsonData['totalrows']=1; $jsonData['totalmodules'] = 1; $previousData = json_encode($jsonData); } } $jarr = json_decode($previousData); if(isset($jarr->settingdata->scripts_data)){ $script_data = $jarr->settingdata->scripts_data; $content = $data['post_amp_content']; $script_slug = ''; $allscripts = $script_data; preg_match_all('/<\/script>/', $allscripts, $matches); if($matches){ if(isset($matches[2])){ $script_slug = $matches[2]; foreach ($script_slug as $key => $slug) { if(!preg_match('/'.$slug.'/', $content)){ global $pb_remove_script; $pb_remove_script[]= esc_attr($slug); } } } add_filter( 'ampforwp_the_content_last_filter','ampforwp_remove_unused_pb_amp_script',12); } } } return $data; } function ampforwp_remove_unused_pb_amp_script($data){ global $pb_remove_script; for($i=0;$i<\/script>/', '', $data); } return $data; } if(class_exists('RankMath')){ add_filter('ampforwp_modify_the_content','ampforwp_rank_math_nofollow_to_external_link'); } function ampforwp_rank_math_nofollow_to_external_link($content){ $rank_math_external_link = RankMath\Helper::get_settings( 'general.nofollow_external_links' ); if($rank_math_external_link){ preg_match_all('/(.*?)<\/a>/', $content, $matches); for($i=0;$i .tg:checked + .hamb-mnu > .m-ctr { margin-right: 0%; } .m-ctr{ margin-right: -100%; float: left; } .tg:checked + .hamb-mnu > .m-ctr { margin-right: calc(100% - ); } .m-ctr{ margin-right: 100%; float: right; } (.*?)<\/amp-consent>/s', $content)){ $content = preg_replace('/(.*?)<\/amp-consent>/s', '', $content); } if(preg_match('/
(.*?)<\/form>/s', $content)){ $content = preg_replace('/(.*?)<\/form>/s', '', $content); } // close #4206 // Ticket #4539 if(function_exists('orbital_setup')){ if(preg_match('/'; $content = str_replace('', $script_tag, $content); } } } } } $comp_dom = new DOMDocument(); @$comp_dom->loadHTML($content); $xpath = new DOMXPath( $comp_dom ); $elements = $xpath->query("*/script[@custom-element]"); $component_arr = array(); $elements_arr = array(); if (!is_null($elements)) { foreach ($elements as $element) { $component_arr[]= $element->getAttribute('custom-element'); $elements_arr[] = $comp_dom->saveHTML($element); } } if (!is_null($elements)) { if(!empty($component_arr)){ $excl_arr = array('amp-bind','amp-access','amp-analytics','amp-access-laterpay','amp-access-poool','amp-dynamic-css-classes','amp-fx-collection','amp-inputmask','amp-lightbox-gallery','amp-inputmask','amp-mustache','amp-subscriptions-google','amp-subscriptions','amp-video-docking','amp-story'); $inc_elem_arr = array(); for($r=0;$r/", $content) && !$is_script){ $remove_comp = $elements_arr[$i]; $content = str_replace($remove_comp, '', $content); }else if(in_array($component, $inc_elem_arr )){ for($rc=0;$rc(.*?)<\/script>/s', $content,$rmc)){ if(isset($rmc[0])){ $remove_comp = $rmc[0]; $content = str_replace($remove_comp, '', $content); } } } } } // REMOVING DUPLICATE SCRIPT. $count_elem = array_count_values($component_arr)[$component]; if($count_elem>1){ $content = preg_replace('/(.*?)<\/script>/s','',$content,1,$component_arr[$i]); } } } } } //OTHER COMPONENT CHECK $other_comp_arr = array('amp-mustache'=>'amp-mustache','amp-embed'=>'amp-ad','form'=>'amp-form','amp-access'=>'amp-access','amp-fx'=>'amp-fx-collection'); foreach ($other_comp_arr as $key => $value) { $ocomp = $value; $celem = 'element'; if($ocomp=='amp-mustache'){ $celem = 'template'; } if(preg_match('/(type|template|id)="('.$ocomp.')"/', $content) || preg_match("/<\/$key>/", $content) || preg_match("/amp-fx/", $content)){ if(!preg_match('/(.*?)<\/script>/s', $content)){ $o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js'; $script_tag = ''; $content = str_replace('', $script_tag, $content); } } } $amp_video = $xpath->query("//amp-video"); foreach($amp_video as $node) { if($node->hasAttribute('dock')){ if(ampforwp_get_setting('ampforwp-amp-video-docking')){ $celem = 'element'; $ocomp = 'amp-video-docking'; if(!preg_match('/(.*?)<\/script>/s', $content)){ $o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js'; $script_tag = ''; $content = str_replace('', $script_tag, $content); } }else{ if(preg_match('//','', $content); } } } } $amp_youtube = $xpath->query("//amp-youtube"); foreach($amp_youtube as $node) { if($node->hasAttribute('dock')){ if(ampforwp_get_setting('ampforwp-amp-video-docking')){ $celem = 'element'; $ocomp = 'amp-video-docking'; if(!preg_match('/(.*?)<\/script>/s', $content)){ $o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js'; $script_tag = ''; $content = str_replace('', $script_tag, $content); } }else{ if(preg_match('//','', $content); } } } } $amp_brid_player = $xpath->query("//amp-brid-player"); foreach($amp_brid_player as $node) { if($node->hasAttribute('dock')){ if(ampforwp_get_setting('ampforwp-amp-video-docking')){ $celem = 'element'; $ocomp = 'amp-video-docking'; if(!preg_match('/(.*?)<\/script>/s', $content)){ $o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js'; $script_tag = ''; $content = str_replace('', $script_tag, $content); } }else{ if(preg_match('//','', $content); } } } } $amp_brightcove = $xpath->query("//amp-brightcove"); foreach($amp_brightcove as $node) { if($node->hasAttribute('dock')){ if(ampforwp_get_setting('ampforwp-amp-video-docking')){ $celem = 'element'; $ocomp = 'amp-video-docking'; if(!preg_match('/(.*?)<\/script>/s', $content)){ $o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js'; $script_tag = ''; $content = str_replace('', $script_tag, $content); } }else{ if(preg_match('//','', $content); } } } } $allscripts = apply_filters( 'ampforwp_modify_scripts', $allscripts); // Scripts added from Options panel should have higher priority #4064 if( $allscripts || (ampforwp_get_setting('amp-header-text-area-for-html') && ampforwp_get_setting('amp-header-text-area-for-html')!="")) { $allscripts .= ampforwp_get_setting('amp-header-text-area-for-html'); preg_match_all('/(.*?)<\/script>/s', $allscripts, $rep); if($rep){ if(isset($rep[2]) && isset($rep[4])){ $script_slug = $rep[2]; $script_url = $rep[4]; for($s=0;$s(.*?)<\/script>/', $content, $conmatch)){ if(isset($conmatch[3]) && $conmatch[3]!=""){ $rep_url = $conmatch[3]; if(preg_match('/https/', $rep_url)){ $content = str_replace($rep_url, $surl, $content); } } } } } } } } return $content; } if(!function_exists('ampforwp_get_retina_image_settings')){ function ampforwp_get_retina_image_settings($width,$height){ $data['width'] = intval($width); $data['height'] = intval($height); if ( 1 == ampforwp_get_setting('ampforwp-retina-images') ) { $resolution = 2; if (ampforwp_get_setting('ampforwp-retina-images-res')) { $resolution = ampforwp_get_setting('ampforwp-retina-images-res'); } $width = $width * $resolution; $height = $height * $resolution; $data['width'] = intval($width); $data['height'] = intval($height); } return $data; } } if(!function_exists('ampforwp_add_fallback_element')){ function ampforwp_add_fallback_element($content='',$tag=''){ preg_match_all('/<'.$tag.' (.*?)<\/'.$tag.'>/', $content, $matches); if(!empty($matches) && false == ampforwp_get_setting('ampforwp-amp-convert-to-wp')){ if(isset($matches[0])){ $con = ""; for($i=0;$i";//$m_content, $m1_content escaped above. $content = str_replace("$match", $fallback_img, $content); } } } } return $content; } } if(!function_exists('ampforwp_imagify_webp_compatibility')){ function ampforwp_imagify_webp_compatibility($content){ if(function_exists('_imagify_init')){ preg_match_all('/src="(.*?)"/', $content,$src); $imageify_opt = get_option( 'imagify_settings' ); $convert_to_webp = false; if(isset($imageify_opt['convert_to_webp'])){ $convert_to_webp = $imageify_opt['convert_to_webp']; } $display_webp = false; if(isset($imageify_opt['display_webp'])){ $display_webp = $imageify_opt['display_webp']; } if($convert_to_webp && $display_webp){ $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); return $content; } } if(!function_exists('ampforwp_set_default_fallback_image')){ function ampforwp_set_default_fallback_image($content){ if(!function_exists('_imagify_init') && !function_exists('ewww_image_optimizer_webp_initialize')){ preg_match_all('/src="(.*?)"/', $content,$cc); // need to check extenstion for fallback. if(isset($cc[1][0])){ $img = $cc[1][0]; $defaul_fallback_img = ampforwp_get_setting('ampforwp_default_fallback_image'); if(isset($defaul_fallback_img['url']) && $defaul_fallback_img['url']!=''){ $defaul_fallback_img = esc_url($defaul_fallback_img['url']); $content = str_replace($img, $defaul_fallback_img, $content); // need to change fallback extenstion. } } } return $content; } } if(!function_exists('ampforwp_ewww_webp_compatibility')){ function ampforwp_ewww_webp_compatibility($content){ if(defined( 'EWWW_IO_CLOUD_PLUGIN' )){ preg_match_all('/src="(.*?)"/', $content,$src); if(isset($src[1][0])){ $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); return $content; } } if(!function_exists('ampforwp_check_image_existance')){ function ampforwp_check_image_existance($image){ if(preg_match('/wp-content\/uploads/', $image)){ $img_arr = explode('wp-content', $image); if(!empty($img_arr) && isset($img_arr[1])){ $img = WP_CONTENT_DIR.$img_arr[1]; if(!file_exists($img)){ if(preg_match('/\d+x\d+/', $image,$ma)){ $t_sizes = explode('x', $ma[0]); $width = $t_sizes[0]; $height = $t_sizes[1]; $image = preg_replace('/-\d+x\d+/','', $image); $resize = ampforwp_aq_resize( $image, $width , $height , true, false, true ); if(isset($resize[0])){ $image = $resize[0]; } } } } } return $image; } } if (function_exists('themify_builder_activate')) { add_filter('ampforwp_modify_the_content','ampforwp_themify_compatibility'); } function ampforwp_themify_compatibility($content){ $get_data = get_post_meta(ampforwp_get_the_ID(),'_themify_builder_settings_json',true); if($get_data){ $decode = json_decode($get_data,true); $cols = ''; for($i=0;$i $value) { foreach ($value['mod_settings'] as $key => $val) { $content.=$val; } } } } } } } return $content; } if(class_exists('RankMath')){ add_filter('ampforwp_modify_the_content','ampforwp_rank_math_external_link_newtab'); } function ampforwp_rank_math_external_link_newtab($content){ $rank_math_external_link = RankMath\Helper::get_settings( 'general.new_window_external_links' ); if($rank_math_external_link){ preg_match_all('//' , $content)){ $content = preg_replace('//', '', $content); } } } } return $content; } /* add_action( 'wp_ajax_ampforwp_referesh_related_post', 'ampforwp_referesh_related_post' ); function ampforwp_referesh_related_post(){ if(!wp_verify_nonce($_POST['verify_nonce'],'ampforwp_refresh_related_poost') ){ echo json_encode(array('status'=>403,'message'=>'user request is not allowed')) ; die; } $orderby = 'ID'; if( true == ampforwp_get_setting('ampforwp-single-order-of-related-posts')){ $orderby = 'rand'; } $args=array( 'fields' => 'ids', 'post_type' => 'post', 'posts_per_page'=> '50', 'orderby' => $orderby, 'ignore_sticky_posts'=>1, 'has_password' => false , 'post_status'=> 'publish', 'no_found_rows' => true, 'meta_query' => array( array( 'key' => 'ampforwp-amp-on-off', 'compare' => 'NOT EXISTS', ) ) ); $my_query = new wp_query( $args ); while( $my_query->have_posts() ) { $my_query->the_post(); update_post_meta(get_the_ID(),'ampforwp-amp-on-off','default'); } $args=array( 'fields' => 'ids', 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'posts_per_page' => 50, 'no_found_rows' => true, 'meta_query' => array( array( 'key' => 'ampforwp-ia-on-off', 'compare' => 'NOT EXISTS', ) ) ); $my_query = new wp_query( $args ); while( $my_query->have_posts() ) { $my_query->the_post(); update_post_meta(get_the_ID(),'ampforwp-ia-on-off','default'); } delete_transient('ampforwp_get_not_meta_post_count'); $data['response'] = ampforwp_get_post_percent(); echo json_encode($data); } add_action( 'save_post', 'ampforwp_delete_refresh_related_post_trans'); function ampforwp_delete_refresh_related_post_trans(){ delete_transient('ampforwp_get_not_meta_post_count'); delete_transient('ampforwp_get_total_post_count'); } */ // HIDE/SHOW TAG AND CATEGORY #4326 function ampforwp_save_taxonomy_meta($term_id){ if(isset($_POST['amp_taxonomy'])){ $cat_status = sanitize_text_field($_POST['amp_taxonomy']); $hide_tax = sanitize_text_field($_POST['hide_tax']); add_term_meta($term_id, 'amp_taxonomy', $cat_status ); add_term_meta( $term_id,'amp_hide_tax', $hide_tax); } } function ampforwp_update_taxonomy_meta($term_id, $term_id1){ if(isset($_POST['amp_taxonomy'])){ $cat_status = sanitize_text_field($_POST['amp_taxonomy']); $hide_tax = sanitize_text_field($_POST['hide_tax']); update_term_meta( $term_id,'amp_taxonomy', $cat_status); update_term_meta( $term_id,'amp_hide_tax', $hide_tax); } } if ( isset( $_REQUEST['taxonomy'] )) { $taxonomy = $_REQUEST['taxonomy']; add_action('edited_'.esc_attr($taxonomy), 'ampforwp_update_taxonomy_meta',10,2); add_action('create_'.esc_attr($taxonomy), 'ampforwp_save_taxonomy_meta', 10); add_action('edited_'.esc_attr($taxonomy), 'ampforwp_update_taxonomy_meta',10,2); add_action('create_'.esc_attr($taxonomy), 'ampforwp_save_taxonomy_meta', 10); add_action (esc_attr($taxonomy).'_edit_form_fields', 'ampforwp_extra_category_fields'); add_action (esc_attr($taxonomy).'_add_form_fields', 'ampforwp_extra_category_fields'); } function ampforwp_extra_category_fields( $tag ) { $label = 'Category'; if(is_object($tag)){ if($tag->taxonomy=="post_tag"){ $label = 'Tag'; }else if($tag->taxonomy!='category'){ $label = $tag->taxonomy; } }else{ if($tag=='post_tag'){ $label = 'Tag'; } } ?> term_id)){?>
term_id); $visible = ''; $visible_status = ''; if(isset($term_data['visible'])){ $visible = $term_data['visible'][0]; $visible_status = $term_data['visible_status'][0]; } ?>
You can enable or disable AMP on this category. Learn More.
style="display: none;" class="edit_hide_tax mrtop-10">
checked > : Hide from Archive Page.
checked > & Posts: Hide from Archive Page and all it's posts
$element) { if(isset($cdn_url['cdn_cnames'][$key]) && $cdn_url['cdn_cnames'][$key]!=''){ $cnds_arr[$element] = $cdn_url['cdn_cnames'][$key]; } } } if(isset($cnds_arr['images'])){ $img_cdn_url = $cnds_arr['images']; }else if(isset($cnds_arr['all'])){ $img_cdn_url = $cnds_arr['all']; } if($img_cdn_url!=''){ $parse_url = parse_url($img_cdn_url); if(!isset($parse_url['scheme'])){ if(!preg_match('/\/\//', $img_cdn_url)){ $img_cdn_url = '//'.$img_cdn_url; } } $comp_dom = new DOMDocument(); @$comp_dom->loadHTML($content); $xpath = new DOMXPath( $comp_dom ); $nodes = $xpath->query('//amp-img[@src]'); $home_url = home_url(); foreach ($nodes as $node) { $url = $node->getAttribute('src'); $srcset = $node->getAttribute('srcset'); $is_external = ampforwp_isexternal($url); if(!$is_external && !$node->hasAttribute('fallback')){ $img_src = str_replace($home_url, $img_cdn_url, $url); $content = str_replace($url, $img_src, $content); $srcset_arr = explode(",", $srcset); for($i=0;$i /i", $content,$matches)){ $content = preg_replace( "//i", ' $url, 1 => $width, 2 => $height); } } add_filter('ampforwp_post_template_data','ampforwp_amp_bind_script'); function ampforwp_amp_bind_script($data) { if ( empty( $data['amp_component_scripts']['amp-bind'] ) ) { $data['amp_component_scripts']['amp-bind'] = 'https://cdn.ampproject.org/v0/amp-bind-latest.js'; } return $data; } add_filter('ampforwp_post_template_data','ampforwp_amp_story_player_script'); function ampforwp_amp_story_player_script($data) { if ( empty( $data['amp_component_scripts']['amp-story-player'] ) ) { $data['amp_component_scripts']['amp-story-player'] = 'https://cdn.ampproject.org/v0/amp-story-player-latest.js'; } return $data; } if(!function_exists('ampforwp_video_lightbox')){ function ampforwp_video_lightbox($content){ $video_tags_arr = array('amp-youtube'); add_action('amp_post_template_css','ampforwp_video_lightbox_css',30); for($i=0;$i/', $content, $matches); if(!empty($matches)){ if(isset($matches[0])){ $con = ""; for($i=0;$igetElementsByTagName( 'amp-youtube' ); $video_id =''; $width = 800; $height = 450; foreach ($nodes as $key => $node) { $video_id = $node->getAttribute('data-videoid'); $width =$node->getAttribute('width'); $height =$node->getAttribute('height'); } $amp_light_box = '
'.$match.'
'; $content = str_replace("$match", $amp_light_box, $content); } } } } return $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-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}'; } function ampforwp_admin_discount_btn() { if(! current_user_can( 'manage_options' )) { return ; } $screen = get_current_screen(); $result = get_option( "ampforwp_dismiss_discount_btn"); $date_now = new DateTime(); $date_exp = new DateTime("02/12/2020"); if ($result != 'removed' && ($date_now > $date_exp) && ('toplevel_page_amp_options' == $screen->base || 'dashboard' == $screen->base || 'plugins' == $screen->base)) { $date = date('d-m-y'); if ($date == '01-12-20') { $msg = 'Only 24 Hours Remaining'; $img = AMPFORWP_IMAGE_DIR . '/last-chance.png'; $class_img = 'offer-img-24'; $class_text = 'offer-text-bm-24'; }else{ $msg = 'Black Friday & Cyber Monday'; $img = AMPFORWP_IMAGE_DIR . '/bf-offer.png'; $class_img = 'offer-img'; $class_text = 'offer-text-bm'; } $href = admin_url('admin.php?page=amp_options&tab=31'); if (ampforwp_check_extensions()) { $href = 'https://ampforwp.com/festive-season/'; } ?>
't')); }else{ echo json_encode(array('status'=>'f')); } wp_die(); } add_action('wp_ajax_ampforwp_dismiss_discount_btn', 'ampforwp_dismiss_discount_btn');