Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ads: Updated House Ads & "Advertisements" Notice #6471

Merged
merged 2 commits into from
Feb 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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