Skip to content

Commit

Permalink
#3668 - Improved code and merged in 1.0.52
Browse files Browse the repository at this point in the history
  • Loading branch information
WasimM3 committed Jun 17, 2020
1 parent cb02562 commit 69c0fbd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/featured-image/featured-image.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
function ampforwp_framework_get_featured_image(){
do_action('ampforwp_before_featured_image_hook');
ampforwp_featured_markup();
ampforwp_featured_markup(true);
do_action('ampforwp_after_featured_image_hook');
}
?>
23 changes: 18 additions & 5 deletions includes/features/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1409,11 +1409,19 @@ function ampforwp_get_taxonomy_meta($term_id,$type=''){
}

if(!function_exists('ampforwp_featured_markup')){
function ampforwp_featured_markup(){
function ampforwp_featured_markup($echo=false){
if(ampforwp_featured_video_markup('check')){
echo ampforwp_featured_video_markup();
if($echo == true){
echo ampforwp_featured_video_markup();
}else{
return ampforwp_featured_video_markup();
}
}else{
echo ampforwp_get_featured_image_markup();
if($echo == true){
echo ampforwp_get_featured_image_markup();
}else{
return ampforwp_get_featured_image_markup();
}
}
}
}
Expand Down Expand Up @@ -1517,7 +1525,9 @@ function ampforwp_featured_video_markup($check=''){
if(function_exists('rh_admin_notice_warning') && !empty($video_post)){
$video_url = $video_post[0]['video_post_embed_url'];
$video_url = explode("=",$video_url);
$amp_f_video = '<amp-youtube data-videoid="'.esc_html($video_url[1]).'" layout="responsive" width="480"height="270"></amp-youtube>';
if(isset($video_url[1])){
$amp_f_video = '<amp-youtube data-videoid="'.esc_html($video_url[1]).'" layout="responsive" width="480"height="270"></amp-youtube>';
}
}
$class = "amp-wp-article-featured-image wp-caption";
if(ampforwp_get_setting('amp-design-selector')==4){
Expand Down Expand Up @@ -1554,12 +1564,15 @@ function ampforwp_get_featured_image_markup($post_id=0, $data=''){
}
$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 );
Expand Down Expand Up @@ -1633,7 +1646,7 @@ function ampforwp_get_featured_image_markup($post_id=0, $data=''){
$class = "amp-featured-image";
}
$fimgdata = '';
if($src!=""){
if($amp_html!=""){
$fimgdata = '<figure class="'.esc_attr($class).'">'.$amp_html; // xss escaping done before.
if ( $caption ) {
$fimgdata .='<p class="wp-caption-text">'.wp_kses_data($caption).'
Expand Down
2 changes: 1 addition & 1 deletion templates/design-manager/featured-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<?php if( ampforwp_get_setting('amp-design-selector')==3){?>
<div class="post-featured-img">
<?php }
ampforwp_featured_markup();
ampforwp_featured_markup(true);
if( ampforwp_get_setting('amp-design-selector')==3){?>
</div>
<?php }?>
Expand Down

0 comments on commit 69c0fbd

Please sign in to comment.