Skip to content

Commit

Permalink
Ads: Updated House Ads & "Advertisements" Notice (#6471)
Browse files Browse the repository at this point in the history
* Removed link from "Advertisements" notice

It was generating too much spam and we have better happiness options
now.

* Updated house ads to new HTML5 unit
  • Loading branch information
dbspringer authored and samhotchkiss committed Feb 23, 2017
1 parent 569d719 commit 6166678
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 33 deletions.
5 changes: 0 additions & 5 deletions modules/wordads/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
box-shadow: none !important;
}

.wpa-about:hover, .wa_infobox a:hover {
text-decoration: underline !important; /* !important necessary, since themes override this routinely */
color: #444;
}

/* ad unit wrapper */
.wpa .u>div { /* @todo: deprecate wpdvert */
display: block;
Expand Down
16 changes: 5 additions & 11 deletions modules/wordads/php/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,14 @@ public function widget( $args, $instance ) {

$snippet = '';
if ( $wordads->option( 'wordads_house', true ) ) {
$ad_url = 'https://s0.wp.com/wp-content/blog-plugins/wordads/house/';
$unit = 'mrec';
if ( 'leaderboard' == $instance['unit'] && ! $this->params->mobile_device ) {
$ad_url .= 'leaderboard.png';
$unit = 'leaderboard';
} else if ( 'wideskyscraper' == $instance['unit'] ) {
$ad_url .= 'widesky.png';
} else {
$ad_url .= 'mrec.png';
$unit = 'widesky';
}

$snippet = <<<HTML
<a href="https://wordpress.com/create/" target="_blank">
<img src="$ad_url" alt="WordPress.com: Grow Your Business" width="$width" height="$height" />
</a>
HTML;
$snippet = $wordads->get_house_ad( $unit );
} else {
$section_id = 0 === $wordads->params->blog_id ? WORDADS_API_TEST_ID : $wordads->params->blog_id . '3';
$data_tags = ( $wordads->params->cloudflare ) ? ' data-cfasync="false"' : '';
Expand All @@ -64,7 +58,7 @@ public function widget( $args, $instance ) {
echo <<< HTML
<div class="wpcnt">
<div class="wpa">
<a class="wpa-about" href="https://en.wordpress.com/about-these-ads/" rel="nofollow">$about</a>
<span class="wpa-about">$about</span>
<div class="u {$instance['unit']}">
$snippet
</div>
Expand Down
55 changes: 38 additions & 17 deletions modules/wordads/wordads.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,30 +302,16 @@ function get_ad( $spot, $type = 'iponweb' ) {
</script>
HTML;
} else if ( 'house' == $type ) {
$width = 300;
$height = 250;
$ad_url = 'https://s0.wp.com/wp-content/blog-plugins/wordads/house/';
if ( 'top' == $spot && ! $this->params->mobile_device ) {
$width = 728;
$height = 90;
$ad_url .= 'leaderboard.png';
} else {
$ad_url .= 'mrec.png';
}

$snippet = <<<HTML
<a href="https://wordpress.com/create/" target="_blank">
<img src="$ad_url" alt="WordPress.com: Grow Your Business" width="$width" height="$height" />
</a>
HTML;
$leaderboard = 'top' == $spot && ! $this->params->mobile_device;
$snippet = $this->get_house_ad( $leaderboard ? 'leaderboard' : 'mrec' );
}

$header = 'top' == $spot ? 'wpcnt-header' : '';
$about = __( 'Advertisements', 'jetpack' );
return <<<HTML
<div class="wpcnt $header">
<div class="wpa">
<a class="wpa-about" href="https://en.wordpress.com/about-these-ads/" rel="nofollow">$about</a>
<span class="wpa-about">$about</span>
<div class="u $spot">
$snippet
</div>
Expand All @@ -344,6 +330,41 @@ public function should_bail() {
return ! $this->option( 'wordads_approved' );
}

/**
* Returns markup for HTML5 house ad base on unit
* @param string $unit mrec, widesky, or leaderboard
* @return string markup for HTML5 house ad
*
* @since 4.7.0
*/
public function get_house_ad( $unit = 'mrec' ) {
if ( ! in_array( $unit, array( 'mrec', 'widesky', 'leaderboard' ) ) ) {
$unit = 'mrec';
}

$width = 300;
$height = 250;
if ( 'widesky' == $unit ) {
$width = 160;
$height = 600;
} else if ( 'leaderboard' == $unit ) {
$width = 728;
$height = 90;
}

return <<<HTML
<iframe
src="https://s0.wp.com/wp-content/blog-plugins/wordads/house/html5/$unit/index.html"
width="$width"
height="$height"
frameborder="0"
scrolling="no"
marginheight="0"
marginwidth="0">
</iframe>
HTML;
}

/**
* Activation hook actions
*
Expand Down

0 comments on commit 6166678

Please sign in to comment.