base ) { $opt = get_option("ampforwp_option_panel_view_type"); wp_localize_script( 'ampforwp_admin_js', 'amp_option_panel_view', $opt); }else{ $opt = get_option("ampforwp_option_panel_view_type"); if($opt==1 || $opt==2){ $opt="3".intval($opt); }else{ $opt = "31"; } wp_localize_script( 'ampforwp_admin_js', 'amp_option_panel_view', "$opt"); } wp_localize_script( 'ampforwp_admin_js', 'amp_fields', $amp_fields ); $redux_data = apply_filters("ampforwp_custom_localize_data", $redux_data); wp_localize_script( 'ampforwp_admin_js', 'redux_data', $redux_data ); wp_localize_script( 'ampforwp_admin_js', 'ampforwp_nonce', wp_create_nonce('ampforwp-verify-request') ); wp_enqueue_script( 'wp-color-picker' ); wp_enqueue_script( 'ampforwp_admin_js' ); } // 96. ampforwp_is_front_page() ampforwp_is_home() and ampforwp_is_blog is created function ampforwp_is_front_page(){ global $redux_builder_amp; // Reading settings me frontpage set $get_front_page_reading_settings = get_option('page_on_front'); // Homepage support on $get_amp_homepage_settings = ampforwp_get_setting('ampforwp-homepage-on-off-support'); // AMP Custom front page from AMP panel $get_custom_frontpage_settings = ampforwp_get_setting('amp-frontpage-select-option'); // Frontpage id should be assigned if ( ampforwp_get_setting('amp-frontpage-select-option-pages') ) { $get_amp_custom_frontpage_id = $redux_builder_amp['amp-frontpage-select-option-pages']; } // Passing Frontpage id true for polylang static pages if ( (class_exists('polylang') || class_exists('Polylang_Pro')) && function_exists('poly_archive_url') ) { if( !ampforwp_get_setting('amp-frontpage-select-option-pages') && $get_custom_frontpage_settings && 'page' === get_option( 'show_on_front' )){ $get_amp_custom_frontpage_id = true; } } // TRUE: When we have "Your latest posts" in reading settings and custom frontpage in amp if ( 'posts' == get_option( 'show_on_front') && is_home() && $get_amp_homepage_settings && $get_custom_frontpage_settings) return true; // TRUE: When we have " A static page" in reading settings and custom frontpage in amp if ( 'page' == get_option( 'show_on_front') && (is_home() || is_front_page()) && $get_front_page_reading_settings && $get_amp_homepage_settings && $get_custom_frontpage_settings && !empty($get_amp_custom_frontpage_id)) { $current_page = get_queried_object(); if ( $current_page ) { $current_page = $current_page->ID; } if ( get_option( 'page_for_posts') == $current_page ) { return false ; } return true; } return false ; } function ampforwp_is_home(){ global $redux_builder_amp; $output = false; if ( ampforwp_is_front_page() == false && ampforwp_is_blog () == false && is_home() ) { $output = true; } return $output; } function ampforwp_is_blog(){ $get_blog_details = ""; $get_blog_details = ampforwp_get_blog_details(); return $get_blog_details ; } // Polylang frontpage function ampforwp_polylang_front_page() { include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if( is_plugin_active( 'polylang/polylang.php' ) || is_plugin_active( 'polylang-pro/polylang.php' ) ){ global $polylang; $page_id = $polylang->curlang->page_on_front; $frontpage_id = get_option('page_on_front'); // is_front_page is not working here so had to do this way // Check current page id with translated page id if ( function_exists('pll_get_post') && $page_id == pll_get_post($frontpage_id) && ! is_page() && ! is_single() && ! is_archive() && ! is_search() && ! ampforwp_is_blog() ){ return true; } } return false; } // Get The ID for AMP #2867 function ampforwp_get_the_ID($post_id=''){ $post_id = get_the_ID(); if(ampforwp_is_front_page()){ $post_id = ampforwp_get_frontpage_id(); } if(ampforwp_is_blog()){ $post_id = ampforwp_get_blog_details('id'); } return $post_id; } // Backward Compatibility function ampforwp_correct_frontpage() { return ampforwp_get_frontpage_id(); } //Common function to get frontpageID function ampforwp_get_frontpage_id() { $post_id = ''; if ( ampforwp_is_front_page() ) { $post_id = ampforwp_get_setting('amp-frontpage-select-option-pages'); } $post_id = apply_filters('ampforwp_modify_frontpage_id', $post_id); return $post_id; } // 27. Clean the Defer issue // TODO : Get back to this issue. #407 function ampforwp_the_content_filter_full( $content_buffer ) { if ((!is_plugin_active('amp/amp.php') && function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() ) || (function_exists('amp_activate') && function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() )) { $content_buffer = preg_replace("/' defer='defer/", "", $content_buffer); $content_buffer = preg_replace("/' defer onload='/", "", $content_buffer); $content_buffer = preg_replace("/' defer /", "", $content_buffer); $content_buffer = preg_replace("/onclick=[^>]*/", "", $content_buffer); $content_buffer = preg_replace("/<\\/?thrive_headline(.|\\s)*?>/",'',$content_buffer); // Remove Extra styling added by other Themes/ Plugins preg_match('/((.*?)<\/style>)/', $content_buffer, $m1); if($m1){ $content_buffer = preg_replace('/((.*?)<\/style>)/','',$content_buffer); } preg_match('/((.*?)<\/style>)(\/\*)/', $content_buffer, $m2); if($m2){ $content_buffer = preg_replace('/((.*?)<\/style>)(\/\*)/','$4',$content_buffer); } $content_buffer = preg_replace("/<\\/?g(.|\\s)*?>/",'',$content_buffer); $content_buffer = preg_replace('/(<[^>]+) spellcheck="false"/', '$1', $content_buffer); $content_buffer = preg_replace('/(<[^>]+) spellcheck="true"/', '$1', $content_buffer); $content_buffer = preg_replace("/about:blank/", "#", $content_buffer); $content_buffer = preg_replace("/
$1 ".$nonampCss.$galleryCss.""; $returnData = preg_replace($re, $subst, $returnData); $returnData = preg_replace( '/<\/amp-youtube>/', '', $returnData); $returnData = preg_replace_callback( '/<\/amp-iframe>/', function($matches){ return ''; }, $returnData); $returnData = preg_replace_callback('/(.*?)<\/amp-carousel>/s', 'ampforwp_non_amp_gallery', $returnData ); $returnData = preg_replace('/on="tap(.*?).goToSlide(.*?)"/', 'onclick="currentDiv$2"', $returnData); $returnData = preg_replace('/', $returnData); $returnData = str_replace('', ''.$galleryJs, $returnData); break; } return $returnData; } } // wp_update_nav_menu #3052 add_action('wp_update_nav_menu', 'ampforwp_wp_update_nav_menu', 10 , 1 ); if ( ! function_exists('ampforwp_wp_update_nav_menu') ) { function ampforwp_wp_update_nav_menu( $menu_id ) { if ( false != get_transient('ampforwp_header_menu') ) { delete_transient('ampforwp_header_menu'); } if ( false != get_transient('ampforwp_footer_menu') ) { delete_transient('ampforwp_footer_menu'); } } } // Delete Menu Transients on Saving AMP Settings #3052 if ( ! function_exists('ampforwp_menu_transient_on_save') ){ function ampforwp_menu_transient_on_save($redux_builder_amp, $this_transients_changed_values) { if ( isset($this_transients_changed_values['amp-design-selector']) ) { if ( false != get_transient('ampforwp_header_menu') ) { delete_transient('ampforwp_header_menu'); } if ( false != get_transient('ampforwp_footer_menu') ) { delete_transient('ampforwp_footer_menu'); } } } } add_action("redux/options/redux_builder_amp/saved",'ampforwp_menu_transient_on_save', 10, 2); // Protocol Remover if ( ! function_exists('ampforwp_remove_protocol') ) { function ampforwp_remove_protocol($url){ $url = preg_replace('#^https?://#', '//', $url); return $url; } } // #3009 if ( ! function_exists('ampforwp_sanitize_i_amphtml') ) { function ampforwp_sanitize_i_amphtml($data){ if(empty($data)){ return $data; } $data = preg_replace_callback('/.i-amphtml-(.*?){(.*?)}/s',function($matches){ if(!empty($matched)){ return ''; } }, $data); return $data; } } function checkAMPforPageBuilderStatus($postId){ global $post; $postId = (is_object($post)? $post->ID: ''); $response =false; if( ampforwp_is_front_page() ){ $postId = ampforwp_get_frontpage_id(); } if ( empty( $postId ) ) { $response = false; }else{ $amp_builder = get_post_field('amp-page-builder',$postId); $amp_pd_data = json_decode($amp_builder); $ampforwp_pagebuilder_enable = get_post_meta($postId,'ampforwp_page_builder_enable', true); if( $ampforwp_pagebuilder_enable=='yes' && true == ampforwp_get_setting('ampforwp-pagebuilder') && ( function_exists('amppb_post_content') && !empty($amp_pd_data->rows))){ $response = true; }else{ $response = false; } } $response = apply_filters( 'ampforwp_pagebuilder_status_modify', $response, $postId ); return $response; } // Gallery Code #3296 function ampforwp_new_gallery_images($images_markup, $image, $markup_arr){ add_action('amp_post_template_css', 'ampforwp_additional_gallery_style'); add_filter('amp_post_template_data','ampforwp_carousel_bind_script'); add_action('amp_post_template_css', 'ampforwp_additional_style_carousel_caption'); return $images_markup; } if( ! function_exists( 'ampforwp_additional_gallery_style' ) ){ function ampforwp_additional_gallery_style(){ global $redux_builder_amp,$carousel_markup_all; $design_type = ''; $design_type = $redux_builder_amp['ampforwp-gallery-design-type']; if(isset($design_type) && $design_type!==''){ echo $carousel_markup_all[$design_type]['gallery_css']; } } } // amp-bind for carousel with captions function ampforwp_carousel_bind_script($data){ if( 1 == ampforwp_get_setting('ampforwp-gallery-design-type') || 2 == ampforwp_get_setting('ampforwp-gallery-design-type') ){ if ( empty( $data['amp_component_scripts']['amp-bind'] ) ) { $data['amp_component_scripts']['amp-bind'] = 'https://cdn.ampproject.org/v0/amp-bind-0.1.js'; } } if( 3 == ampforwp_get_setting('ampforwp-gallery-design-type') || true == ampforwp_get_setting('ampforwp-gallery-lightbox') ){ if ( empty( $data['amp_component_scripts']['amp-image-lightbox'] ) ) { $data['amp_component_scripts']['amp-image-lightbox'] = 'https://cdn.ampproject.org/v0/amp-image-lightbox-0.1.js'; } } return $data; } function ampforwp_new_thumbnail_images($amp_images, $uniqueid, $markup_arr){ if(!isset($markup_arr['carousel_with_thumbnail_html'])){return '';} $amp_thumb_image_buttons = array(); foreach ($amp_images as $key => $value) { $returnHtml = $markup_arr['carousel_with_thumbnail_html']; $returnHtml = str_replace('{{thumbnail}}', $value , $returnHtml); $returnHtml = str_replace('{{unique_id}}', $uniqueid , $returnHtml); $returnHtml = str_replace('{{unique_index}}', $key , $returnHtml); $amp_thumb_image_buttons[$key] = $returnHtml; } return $amp_thumb_image_buttons; } // Gallery Styling if( ! function_exists( 'ampforwp_additional_style_carousel_caption' ) ){ function ampforwp_additional_style_carousel_caption(){ ?> .collapsible-captions {--caption-height: 32px; --image-height: 100%; --caption-padding:1rem; --button-size: 28px; --caption-color: #f5f5f5;; --caption-bg-color: #111;} .collapsible-captions * { -webkit-tap-highlight-color: rgba(255, 255, 255, 0); box-sizing: border-box; } .collapsible-captions .amp-carousel-container {position: relative; width: 100%;} .collapsible-captions amp-img img {object-fit: contain; } .collapsible-captions figure { margin: 0; padding: 0; } .collapsible-captions figcaption { position: absolute; bottom: 0;width: 100%; max-height: var(--caption-height);margin-bottom:0; line-height: var(--caption-height); padding: 0 var(--button-size) 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: max-height 200ms cubic-bezier(0.4, 0, 0.2, 1); z-index: 1000; color: var(--caption-color); background: rgba(0, 0, 0, 0.6); } .collapsible-captions figcaption.expanded { line-height: inherit; white-space: normal; text-overflow: auto; max-height: 100px; overflow: auto; } .collapsible-captions figcaption:focus { outline: none; border: none; } .collapsible-captions figcaption span { display: block; position: absolute; top: calc((var(--caption-height) - var(--button-size)) / 2); right: 2px; width: var(--button-size); height: var(--button-size); line-height: var(--button-size); text-align: center; font-size: 12px; color: inherit; cursor: pointer; } figcaption{ margin-bottom: 20px; } roles; $hasrole = array_intersect( $currentuserrole, $amp_roles ); if( empty($hasrole)){ $user_role = false; } $user_role = apply_filters('ampforwp_modify_user_access_role', $user_role, $currentUser, $amp_roles, $hasrole ); return $user_role; } if(!function_exists('ampforwp_sassy_share_icons')){ function ampforwp_sassy_share_icons($ampforwp_the_content) { if(function_exists('heateor_sss_run')){ global $heateor_sss;global $post; $share_counts = false; $sassy_options = $heateor_sss->options; $post_url = get_the_permalink($post); if(isset($sassy_options['horizontal_counts'])){ $post_id = ampforwp_get_the_ID(); if ( $post_id == 'custom' ) { $share_counts = get_option( 'heateor_sss_custom_url_shares' ) ; } elseif ( $post_url == home_url() ) { $share_counts = get_option( 'heateor_sss_homepage_shares' ); } elseif ( $post_id > 0 ) { $share_counts = get_post_meta( $post_id, '_heateor_sss_shares_meta', true ); } $total_share = 0; if(isset($sassy_options['horizontal_re_providers'])){ $share_icons = $sassy_options['horizontal_re_providers']; foreach($share_icons as $i){ if(isset($share_counts[$i])){ $total_share += round($share_counts[$i]); } } } $_append = ''; preg_match_all('/
<\/div>
(.*)
<\/div><\/div>
<\/div>/', $ampforwp_the_content, $matches); $_actual = $matches[0]; if(isset($matches[1][0])){ $_replace = '
'.$_append.'
'; $ampforwp_the_content = str_replace($_actual, $_replace, $ampforwp_the_content); } } } return $ampforwp_the_content; } } // Notice for Dev Mode function ampforwp_dev_mode_notice(){ global $redux_builder_amp; $message = ''; if(isset($redux_builder_amp['ampforwp-development-mode']) && $redux_builder_amp['ampforwp-development-mode']) { $message = ' Please turn off Development mode, when you are done.';?>
'. esc_html__('AMP Dev mode is Enabled!', 'accelerated-mobile-pages').''. esc_html__($message, 'accelerated-mobile-pages'); ?>

%s %s

'), esc_html__('The configuration of AMPforWP and '.esc_html($seo).' plugin is seems incorrect. Please go to AMPforWP plugin settings and select '.esc_html($seo).' from SEO Plugin Integration or ','accelerated-mobile-pages'),esc_url(admin_url('admin.php?page=amp_options&tab=5')),esc_html__('Click Here','accelerated-mobile-pages')); } } add_action('wp_ajax_ampforwp_subscribe_newsletter','ampforwp_subscribe_for_newsletter'); add_action('wp_ajax_nopriv_ampforwp_subscribe_newsletter','ampforwp_subscribe_for_newsletter'); function ampforwp_subscribe_for_newsletter(){ $api_url = 'http://magazine3.company/wp-json/api/central/email/subscribe'; $api_params = array( 'name' => sanitize_text_field($_POST['name']), 'email'=> sanitize_text_field($_POST['email']), 'website'=> sanitize_text_field($_POST['website']), 'type'=> 'amp' ); $response = wp_remote_post( $api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); $response = wp_remote_retrieve_body( $response ); echo $response; die; } function ampforwp_mobile_redirection_notice(){ if(false == ampforwp_get_setting('amp-mobile-redirection')){ return; } $plugin = $option = ''; if(function_exists('rocket_load_textdomain') && 0 == get_rocket_option( 'do_caching_mobile_files' )){ $plugin = 'WP Rocket'; $option = 'Separate cache files for mobile devices'; } if(function_exists('wp_super_cache_init_action')) { global $wp_cache_mobile_enabled; if(0 == $wp_cache_mobile_enabled){ $plugin = 'WP Super Cache'; $option = 'Mobile device support'; }else{ return; } } if(function_exists('litespeed_purge_single_post') && !LiteSpeed_Cache_Admin_Rules::get_instance()->get_rewrite_rule_mobile_agents()) { $plugin = 'LiteSpeed Cache'; $option = 'Cache Mobile'; } if(function_exists('wpfastestcache_activate') && 'on' != $GLOBALS["wp_fastest_cache_options"]->wpFastestCacheMobile) { $plugin = 'WP Fastest Cache'; $option = 'Mobile'; } if(!empty($plugin) && !empty($option)){ echo sprintf(('

%s %s

'), esc_html__('You need to enable the option of "'.esc_html($option).'" in '.esc_html($plugin).' plugin for mobile redirection to work properly in AMP','accelerated-mobile-pages'),esc_url('https://ampforwp.com/tutorials/article/how-to-redirect-all-mobile-visitors-to-amp/'),esc_html__('Click here for more info','accelerated-mobile-pages')); } } function ampforwp_category_base_remove_notice(){ if(true == ampforwp_get_setting('ampforwp-category-base-removel-link')){ return; } if(class_exists('WPSEO_Options') && method_exists('WPSEO_Options', 'get') && WPSEO_Options::get( 'stripcategorybase' ) == true ){ echo sprintf(('

%s %s%s%s

'), esc_html__('We have detected that you removed Category Base from Yoast SEO plugin but not from AMPforWP settings. Please','accelerated-mobile-pages'), esc_url('admin.php?page=amp_options&tab=17'), esc_html__('Click here','accelerated-mobile-pages'), esc_html__(' to set up to make sure AMP pages work properly on category pages or ','accelerated-mobile-pages'), esc_url('https://ampforwp.com/tutorials/article/how-to-remove-the-category-base-in-the-amp/'),esc_html__('Click here for the tutorial','accelerated-mobile-pages'),esc_html__('Click here for the tutorial','accelerated-mobile-pages')); } } // HIDE/SHOW TAG AND CATEGORY #4326 function ampforwp_get_taxonomy_meta($term_id,$type=''){ if($type=='' || $type=='data'){ $amp_taxonomy = get_term_meta( $term_id,'amp_taxonomy'); $amp_hide_tax = get_term_meta( $term_id,'amp_hide_tax'); $data = array('visible'=>$amp_taxonomy,'visible_status'=>$amp_hide_tax); return $data; }else if($type=='status'){ $amp_taxonomy = get_term_meta( $term_id,'amp_taxonomy'); if(isset($amp_taxonomy[0]) && $amp_taxonomy[0]=='hide'){ return false; }else{ return true; } }else if($type=='post_status'){ $term = wp_get_post_terms(ampforwp_get_the_ID(),array('category','post_tag')); foreach ($term as $key => $value) { $amp_taxonomy = get_term_meta( $value->term_id,'amp_taxonomy'); $amp_hide_tax = get_term_meta( $value->term_id,'amp_hide_tax'); if(isset($amp_taxonomy[0]) && $amp_taxonomy[0]=='hide' && $amp_hide_tax[0]=='hide-tax-post'){ return false; } } return true; } } if(!function_exists('ampforwp_featured_markup')){ function ampforwp_featured_markup($echo=false, $_this = ''){ if(ampforwp_featured_video_markup('check')){ if($echo == true){ echo ampforwp_featured_video_markup(); }else{ return ampforwp_featured_video_markup(); } }else{ if($echo == true){ echo ampforwp_get_featured_image_markup(0,'',$_this); }else{ return ampforwp_get_featured_image_markup(0,'',$_this); } } } } function ampforwp_jnews_featured_video($video_url){ if(function_exists('jnews_plugin_active')){ $metaKey = ampforwp_get_setting('ampforwp-featured-video-metakey'); $metaKey = get_post_meta(ampforwp_get_the_ID(),$metaKey,true); $video_url = $metaKey['video']; } return $video_url ; } add_filter('amp_post_template_data','ampforwp_feature_video_amp_js', 20); function ampforwp_feature_video_amp_js($data){ $vmeta = ampforwp_get_setting('ampforwp-featured-video-metakey'); if (ampforwp_get_setting('ampforwp-featured-video')==true && !empty($vmeta)) { $post_id = ampforwp_get_the_ID(); $data['amp_component_scripts']['amp-video'] = 'https://cdn.ampproject.org/v0/amp-video-0.1.js'; $vmeta = ampforwp_get_setting('ampforwp-featured-video-metakey'); if(ampforwp_get_setting('ampforwp-featured-video')==true && !empty($vmeta)){ $metaKey = ampforwp_get_setting('ampforwp-featured-video-metakey'); $video_url = get_post_meta($post_id, $metaKey,true); $video_url = ampforwp_jnews_featured_video($video_url); if(preg_match('/youtube/', $video_url)){ $data['amp_component_scripts']['amp-youtube'] = 'https://cdn.ampproject.org/v0/amp-youtube-0.1.js'; }else if(preg_match('/vimeo/', $video_url)){ $data['amp_component_scripts']['amp-vimeo'] = 'https://cdn.ampproject.org/v0/amp-vimeo-0.1.js'; }else if(preg_match('/dailymotion/', $video_url)){ $data['amp_component_scripts']['amp-dailymotion'] = 'https://cdn.ampproject.org/v0/amp-dailymotion-0.1.js'; } } } return $data; } if(function_exists('jnews_plugin_active')){ add_filter('ampforwp_modify_the_content', 'ampforwp_featured_video_markup'); } if(!function_exists('ampforwp_featured_video_markup')){ function ampforwp_featured_video_markup($check=''){ if(ampforwp_get_setting('ampforwp-featured-video')){ $post_id = ampforwp_get_the_ID(); $amp_f_video = ''; // Featured Video SmartMag theme Compatibility #2559 if(class_exists('Bunyad') && Bunyad::posts()->meta('featured_video') ){ global $wp_embed; $videoContent = Bunyad::posts()->meta('featured_video'); $featured_video = $wp_embed->autoembed($videoContent); $amp_f_video = ampforwp_content_sanitizer($featured_video); } // Featured Video Plus Compatibility #2394 #2583 elseif(function_exists('has_post_video') && has_post_video($post_id)){ $videoContent = get_the_post_video(); $amp_f_video = ampforwp_content_sanitizer($videoContent); } $vmeta = ampforwp_get_setting('ampforwp-featured-video-metakey'); if(ampforwp_get_setting('ampforwp-featured-video')==true && !empty($vmeta)){ $metaKey = ampforwp_get_setting('ampforwp-featured-video-metakey'); $video_url = get_post_meta($post_id, $metaKey,true); $video_url = ampforwp_jnews_featured_video($video_url); $parts = parse_url($video_url); parse_str($parts['query'], $query); $ext = pathinfo($parts['path'], PATHINFO_EXTENSION); $type = ''; $video_id = ''; if(!strpos($video_url,"iframe") && $ext!=""){ $amp_f_video = '
'; }else if(preg_match('/youtube/', $video_url)){ preg_match_all('/(youtu.be\/|\/watch\?v=|\/embed\/)([a-z0-9\-_]+)/i',$video_url,$matches); if(isset($matches[2][0])){ $video_id = $matches[2][0]; $amp_f_video = '
'; } }else if(preg_match('/vimeo/', $video_url)){ preg_match_all('/vimeo.com\/(.*)/i',$video_url,$matches); if(isset($matches[1][0])){ $video_id = $matches[1][0]; $amp_f_video = '
'; } }else if(preg_match('/dailymotion/', $video_url)){ preg_match_all('/^.+dailymotion.com\/(?:video|swf\/video|embed\/video|hub|swf)\/([^&?]+)/',$video_url,$matches); if(isset($matches[1][0])){ $video_id = $matches[1][0]; $amp_f_video = '
'; } } } $video_post = get_post_meta(ampforwp_get_the_ID(), 'video_post', true ); if(function_exists('rh_admin_notice_warning') && !empty($video_post)){ $video_url = $video_post[0]['video_post_embed_url']; $video_url = explode("=",$video_url); if(isset($video_url[1])){ $amp_f_video = ''; } } $class = "amp-wp-article-featured-image wp-caption"; if(ampforwp_get_setting('amp-design-selector')==4){ $class = "amp-featured-image f_vid"; } switch ($check) { case 'check': if($amp_f_video!=''){ return true; }else{ return false; } break; default : $fvideo = ''; if($amp_f_video!=''){ $fvideo = '
'.$amp_f_video.'
';// xss escaping done before. } if(function_exists('jnews_plugin_active')){ return $fvideo . $check; } return $fvideo; break; } } } } if(!function_exists('ampforwp_get_featured_image_markup')){ function ampforwp_get_featured_image_markup($post_id=0, $data='',$_this=''){ global $post; if($post_id==0){ $post_id = ampforwp_get_the_ID(); } $featured_image = ''; if(ampforwp_get_setting('amp-design-selector')!=4){ if($_this!=''){ $featured_image = $_this->get( 'featured_image' ); } } $amp_html='';$height ='';$width='';$src='';$srcet='';$alt='';$caption=''; if( true == ampforwp_has_post_thumbnail() ) { if (has_post_thumbnail( $post_id ) ){ $thumb_id = get_post_thumbnail_id($post_id); $post_content = get_post_field('post_content', $post_id); if (true !== apply_filters('ampforwp_allow_featured_image', false) && ( false !== strpos( $post_content, 'wp-image-' . $thumb_id ) || false !== strpos( $post_content, 'attachment_' . $thumb_id ) ) ) { return; } if(ampforwp_get_setting('amp-design-selector')==4){ $image_size = ampforwp_get_setting('swift-featued-image-size'); $image_size = apply_filters( 'ampforwp_featured_image_size', $image_size ); }else{ $image_size = apply_filters( 'ampforwp_featured_image', 'full' ); } $image = wp_get_attachment_image_src( $thumb_id, $image_size ); $caption = get_the_post_thumbnail_caption( $post_id ); $thumb_alt = get_post_meta( $thumb_id, '_wp_attachment_image_alt', true); $thumbnail_srcset = wp_get_attachment_image_srcset( $thumb_id, $image_size); if(ampforwp_get_setting('amp-design-selector')==4){ if ( $thumbnail_srcset && 'full' == ampforwp_get_setting('swift-featued-image-size') ) { $srcet = $thumbnail_srcset; } } if($thumb_alt){ $alt = $thumb_alt; } else{ $alt = get_the_title( $post_id ); } $alt = convert_chars( stripslashes( $alt ) ); if( $image ){ if(empty($image[1])){ $image[1] = 1000; } if(empty($image[2])){ $image[2] = 600; } if ( empty($srcet) ) { $srcet = $image[0]; } $height = $image[2]; $width = $image[1]; $src = $image[0]; } }elseif ( ampforwp_is_custom_field_featured_image() ) { $src = ampforwp_cf_featured_image_src(); $width = ampforwp_cf_featured_image_src('width'); $height = ampforwp_cf_featured_image_src('height'); } switch ($data) { case 'url': return $src; break; case 'width': return $width; break; case 'height': return $height; break; case 'caption': return $caption; break; case 'srcset': return $srcet; break; default : if ( $featured_image!='' ) { $amp_html = $featured_image['amp_html']; $caption = $featured_image['caption']; }else{ $amp_html = ''; } if( true == ampforwp_get_setting('ampforwp-featured-image-from-content') && ampforwp_get_featured_image_from_content() ){ $amp_html = ampforwp_get_featured_image_from_content(); $amp_html = preg_replace('#sizes="(.*)"#', "layout='responsive'", $amp_html); } if(function_exists('ampforwp_add_fallback_element')){ $amp_html = ampforwp_add_fallback_element($amp_html,'amp-img'); } $class = "amp-wp-article-featured-image wp-caption"; if(ampforwp_get_setting('amp-design-selector')==4){ $class = "amp-featured-image"; } $fimgdata = ''; if($amp_html!=""){ $fimgdata = '
'.$amp_html; // xss escaping done before. if ( $caption ) { $fimgdata .='

'.wp_kses_data($caption).'

'; } $fimgdata .='
'; } return $fimgdata; break; } } } }