Skip to content

Commit

Permalink
Issue #10 & #12
Browse files Browse the repository at this point in the history
10: Ads after content should only display in Posts [Fixed]

12: Custom Dimensions for Link Ads [Added]
  • Loading branch information
Sejiro-Hiko committed Mar 23, 2018
1 parent 7cb9b55 commit 21d690d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 4 deletions.
30 changes: 26 additions & 4 deletions ads-for-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,19 +307,27 @@ function ampforwp_display_amp_ads(){
case '7':
// "After Content";
if('1' === $ad_vendor){
if(is_single()){
add_action('ampforwp_after_post_content','ampforwp_adsense_ads');
}
}
// DFP Ad
else if('2' === $ad_vendor){
add_action('ampforwp_after_post_content','ampforwp_dfp_ads');
if(is_single()){
add_action('ampforwp_after_post_content','ampforwp_dfp_ads');
}
}
// Custom Ad
else if('3' === $ad_vendor){
add_action('ampforwp_after_post_content','ampforwp_custom_ads');
if(is_single()){
add_action('ampforwp_after_post_content','ampforwp_custom_ads');
}
}
else if('4' === $ad_vendor){
add_action('ampforwp_after_post_content',function() use ( $args ) {
adsforwp_media_net_ads( $args ); });
if(is_single()){
add_action('ampforwp_after_post_content',function() use ( $args ) {
adsforwp_media_net_ads( $args ); });
}
}
break;
case '8':
Expand Down Expand Up @@ -634,6 +642,13 @@ function get_adsense_dimensions($id){
);
return $dimension;
break;

case '7':
$dimension = array();
$dimension['width'] = get_post_meta($id,'link_custom_width',true);
$dimension['height'] = get_post_meta($id,'link_custom_height',true);
return $dimension;
break;
default:
$dimension = array('width' => '120',
'height' => '90'
Expand Down Expand Up @@ -753,6 +768,13 @@ function get_adsense_dimensions($id){
);
return $dimension;
break;

case '7':
$dimension = array();
$dimension['width'] = get_post_meta($id,'_amp_link_custom_width',true);
$dimension['height'] = get_post_meta($id,'_amp_link_custom_height',true);
return $dimension;
break;
default:
$dimension = array('width' => '120',
'height' => '90'
Expand Down
26 changes: 26 additions & 0 deletions assets/ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ $("#select_ads_for").change(function(){
});
}).change();

$("#link_ads_dimensions").change(function(){
$(this).find("option:selected").each(function(){
var optionValue = $(this).attr("value");
if(optionValue){
$(".link-custom-dimensions").hide();
if('7' === optionValue){
$(".link-custom-dimensions.link-custom-data-1").show();
}

}
});
}).change();

$("#adsense_dimensions").change(function(){
$(this).find("option:selected").each(function(){
var optionValue = $(this).attr("value");
Expand Down Expand Up @@ -174,6 +187,19 @@ $("#_amp_ad_type_format").change(function(){
});
}).change();

$("#_amp_link_ads_dimensions").change(function(){
$(this).find("option:selected").each(function(){
var optionValue = $(this).attr("value");
if(optionValue){
$(".amp-link-custom-dimensions").hide();
if('7' === optionValue){
$(".amp-link-custom-dimensions.amp-link-custom-data-1").show();
}

}
});
}).change();

$("#_amp_adsense_dimensions").change(function(){
$(this).find("option:selected").each(function(){
var optionValue = $(this).attr("value");
Expand Down
30 changes: 30 additions & 0 deletions includes/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,24 @@ function advanced_amp_ampforwp_ads_options() {
'4' => esc_html__( '200×90', 'ampforwp_adsforwp' ),
'5' => esc_html__( '468×15', 'ampforwp_adsforwp' ),
'6' => esc_html__( '728×15', 'ampforwp_adsforwp' ),
'7' => esc_html__( 'Custom', 'ampforwp_adsforwp' ),
),
'classes' => 'link-ads-dimensions'
) );
$ampforwp_ads_option->add_field( array(
'name' => esc_html__( 'Width', 'ampforwp_adsforwp' ),
'desc' => 'Enter the width',
'id' => 'link_custom_width',
'type' => 'text_small',
'classes' => 'link-custom-dimensions link-custom-data-1'
) );
$ampforwp_ads_option->add_field( array(
'name' => esc_html__( 'Height', 'ampforwp_adsforwp' ),
'desc' => 'Enter the height',
'id' => 'link_custom_height',
'type' => 'text_small',
'classes' => 'link-custom-dimensions link-custom-data-1'
) );
$ampforwp_ads_option->add_field( array(
'name' => esc_html__( 'Dimensions', 'ampforwp_adsforwp' ),
'desc' => 'Select the preferred dimensions for your ad',
Expand Down Expand Up @@ -541,9 +556,24 @@ function amp_by_automattic_options(){
'4' => esc_html__( '200×90', 'ampforwp_adsforwp' ),
'5' => esc_html__( '468×15', 'ampforwp_adsforwp' ),
'6' => esc_html__( '728×15', 'ampforwp_adsforwp' ),
'7' => esc_html__( 'Custom', 'ampforwp_adsforwp' ),
),
'classes' => 'amp-link-ads-dimensions'
) );
$amp_ads_option->add_field( array(
'name' => esc_html__( 'Width', 'ampforwp_adsforwp' ),
'desc' => 'Enter the width',
'id' => '_amp_link_custom_width',
'type' => 'text_small',
'classes' => 'amp-link-custom-dimensions amp-link-custom-data-1'
) );
$amp_ads_option->add_field( array(
'name' => esc_html__( 'Height', 'ampforwp_adsforwp' ),
'desc' => 'Enter the height',
'id' => '_amp_link_custom_height',
'type' => 'text_small',
'classes' => 'amp-link-custom-dimensions amp-link-custom-data-1'
) );
$amp_ads_option->add_field( array(
'name' => esc_html__( 'Dimensions', 'ampforwp_adsforwp' ),
'desc' => 'Select the preferred dimensions for your ad',
Expand Down

0 comments on commit 21d690d

Please sign in to comment.