Complex classes like WordAds often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use WordAds, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 14 | class WordAds { |
||
| 15 | |||
| 16 | public $params = null; |
||
| 17 | |||
| 18 | public $ads = array(); |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Array of supported ad types. |
||
| 22 | * |
||
| 23 | * @var array |
||
| 24 | */ |
||
| 25 | public static $ad_tag_ids = array( |
||
| 26 | 'mrec' => array( |
||
| 27 | 'tag' => '300x250_mediumrectangle', |
||
| 28 | 'height' => '250', |
||
| 29 | 'width' => '300', |
||
| 30 | ), |
||
| 31 | 'leaderboard' => array( |
||
| 32 | 'tag' => '728x90_leaderboard', |
||
| 33 | 'height' => '90', |
||
| 34 | 'width' => '728', |
||
| 35 | ), |
||
| 36 | 'mobile_leaderboard' => array( |
||
| 37 | 'tag' => '320x50_mobileleaderboard', |
||
| 38 | 'height' => '50', |
||
| 39 | 'width' => '320', |
||
| 40 | ), |
||
| 41 | 'wideskyscraper' => array( |
||
| 42 | 'tag' => '160x600_wideskyscraper', |
||
| 43 | 'height' => '600', |
||
| 44 | 'width' => '160', |
||
| 45 | ), |
||
| 46 | ); |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Mapping array of location slugs to placement ids |
||
| 50 | * |
||
| 51 | * @var array |
||
| 52 | */ |
||
| 53 | public static $ad_location_ids = array( |
||
| 54 | 'top' => 110, |
||
| 55 | 'belowpost' => 120, |
||
| 56 | 'belowpost2' => 130, |
||
| 57 | 'sidebar' => 140, |
||
| 58 | 'widget' => 150, |
||
| 59 | 'gutenberg' => 200, |
||
| 60 | 'inline' => 310, |
||
| 61 | 'inline-plugin' => 320, |
||
| 62 | ); |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Counter to enable unique, sequential section IDs for all amp-ad units |
||
| 66 | * |
||
| 67 | * @var int |
||
| 68 | */ |
||
| 69 | public static $amp_section_id = 1; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Checks for AMP support and returns true iff active & AMP request |
||
| 73 | * |
||
| 74 | * @return boolean True if supported AMP request |
||
| 75 | * |
||
| 76 | * @since 7.5.0 |
||
| 77 | */ |
||
| 78 | public static function is_amp() { |
||
| 79 | return class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request(); |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Increment the AMP section ID and return the value |
||
| 84 | * |
||
| 85 | * @return int |
||
| 86 | */ |
||
| 87 | public static function get_amp_section_id() { |
||
| 88 | return self::$amp_section_id++; |
||
| 89 | } |
||
| 90 | |||
| 91 | public static $SOLO_UNIT_CSS = 'float:left;margin-right:5px;margin-top:0px;'; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Convenience function for grabbing options from params->options |
||
| 95 | * |
||
| 96 | * @param string $option the option to grab |
||
| 97 | * @param mixed $default (optional) |
||
| 98 | * @return option or $default if not set |
||
| 99 | * |
||
| 100 | * @since 4.5.0 |
||
| 101 | */ |
||
| 102 | function option( $option, $default = false ) { |
||
| 103 | if ( ! isset( $this->params->options[ $option ] ) ) { |
||
| 104 | return $default; |
||
| 105 | } |
||
| 106 | |||
| 107 | return $this->params->options[ $option ]; |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Returns the ad tag property array for supported ad types. |
||
| 112 | * |
||
| 113 | * @return array array with ad tags |
||
| 114 | * |
||
| 115 | * @since 7.1.0 |
||
| 116 | */ |
||
| 117 | function get_ad_tags() { |
||
| 118 | return self::$ad_tag_ids; |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * Returns the solo css for unit |
||
| 123 | * |
||
| 124 | * @return string the special css for solo units |
||
| 125 | * |
||
| 126 | * @since 7.1.0 |
||
| 127 | */ |
||
| 128 | function get_solo_unit_css() { |
||
| 129 | return self::$SOLO_UNIT_CSS; |
||
| 130 | } |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Instantiate the plugin |
||
| 134 | * |
||
| 135 | * @since 4.5.0 |
||
| 136 | */ |
||
| 137 | function __construct() { |
||
| 138 | add_action( 'wp', array( $this, 'init' ) ); |
||
| 139 | add_action( 'rest_api_init', array( $this, 'init' ) ); |
||
| 140 | } |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Code to run on WordPress 'init' hook |
||
| 144 | * |
||
| 145 | * @since 4.5.0 |
||
| 146 | */ |
||
| 147 | function init() { |
||
| 148 | require_once WORDADS_ROOT . '/php/params.php'; |
||
| 149 | $this->params = new WordAds_Params(); |
||
| 150 | |||
| 151 | if ( $this->should_bail() || self::is_infinite_scroll() ) { |
||
| 152 | return; |
||
| 153 | } |
||
| 154 | |||
| 155 | if ( is_admin() ) { |
||
| 156 | require_once WORDADS_ROOT . '/php/admin.php'; |
||
| 157 | return; |
||
| 158 | } |
||
| 159 | |||
| 160 | $this->insert_adcode(); |
||
| 161 | |||
| 162 | if ( '/ads.txt' === $_SERVER['REQUEST_URI'] ) { |
||
| 163 | |||
| 164 | if ( false === ( $ads_txt_transient = get_transient( 'jetpack_ads_txt' ) ) ) { |
||
| 165 | $ads_txt_transient = ! is_wp_error( WordAds_API::get_wordads_ads_txt() ) ? WordAds_API::get_wordads_ads_txt() : ''; |
||
| 166 | set_transient( 'jetpack_ads_txt', $ads_txt_transient, DAY_IN_SECONDS ); |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Provide plugins a way of modifying the contents of the automatically-generated ads.txt file. |
||
| 171 | * |
||
| 172 | * @module wordads |
||
| 173 | * |
||
| 174 | * @since 6.1.0 |
||
| 175 | * |
||
| 176 | * @param string WordAds_API::get_wordads_ads_txt() The contents of the ads.txt file. |
||
| 177 | */ |
||
| 178 | $ads_txt_content = apply_filters( 'wordads_ads_txt', $ads_txt_transient ); |
||
| 179 | |||
| 180 | http_response_code( 200 ); |
||
| 181 | header( 'Content-Type: text/plain; charset=utf-8' ); |
||
| 182 | echo esc_html( $ads_txt_content ); |
||
| 183 | die(); |
||
| 184 | } |
||
| 185 | } |
||
| 186 | |||
| 187 | /** |
||
| 188 | * Check for Jetpack's The_Neverending_Home_Page and use got_infinity |
||
| 189 | * |
||
| 190 | * @return boolean true if load came from infinite scroll |
||
| 191 | * |
||
| 192 | * @since 4.5.0 |
||
| 193 | */ |
||
| 194 | public static function is_infinite_scroll() { |
||
| 195 | return class_exists( 'The_Neverending_Home_Page' ) && The_Neverending_Home_Page::got_infinity(); |
||
| 196 | } |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Add the actions/filters to insert the ads. Checks for mobile or desktop. |
||
| 200 | * |
||
| 201 | * @since 4.5.0 |
||
| 202 | */ |
||
| 203 | private function insert_adcode() { |
||
| 204 | add_filter( 'wp_resource_hints', array( $this, 'resource_hints' ), 10, 2 ); |
||
| 205 | add_action( 'wp_head', array( $this, 'insert_head_meta' ), 20 ); |
||
| 206 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
||
| 207 | add_filter( 'wordads_ads_txt', array( $this, 'insert_custom_adstxt' ) ); |
||
| 208 | |||
| 209 | /** |
||
| 210 | * Filters enabling ads in `the_content` filter |
||
| 211 | * |
||
| 212 | * @see https://jetpack.com/support/ads/ |
||
| 213 | * |
||
| 214 | * @module wordads |
||
| 215 | * |
||
| 216 | * @since 5.8.0 |
||
| 217 | * |
||
| 218 | * @param bool True to disable ads in `the_content` |
||
| 219 | */ |
||
| 220 | if ( ! apply_filters( 'wordads_content_disable', false ) ) { |
||
| 221 | add_filter( 'the_content', array( $this, 'insert_ad' ) ); |
||
| 222 | } |
||
| 223 | |||
| 224 | /** |
||
| 225 | * Filters enabling ads in `the_excerpt` filter |
||
| 226 | * |
||
| 227 | * @see https://jetpack.com/support/ads/ |
||
| 228 | * |
||
| 229 | * @module wordads |
||
| 230 | * |
||
| 231 | * @since 5.8.0 |
||
| 232 | * |
||
| 233 | * @param bool True to disable ads in `the_excerpt` |
||
| 234 | */ |
||
| 235 | if ( ! apply_filters( 'wordads_excerpt_disable', false ) ) { |
||
| 236 | add_filter( 'the_excerpt', array( $this, 'insert_ad' ) ); |
||
| 237 | } |
||
| 238 | |||
| 239 | if ( $this->option( 'enable_header_ad', true ) ) { |
||
| 240 | if ( self::is_amp() ) { |
||
| 241 | add_filter( 'the_content', array( $this, 'insert_header_ad_amp' ) ); |
||
| 242 | } else { |
||
| 243 | switch ( get_stylesheet() ) { |
||
| 244 | case 'twentyseventeen': |
||
| 245 | case 'twentyfifteen': |
||
| 246 | case 'twentyfourteen': |
||
| 247 | add_action( 'wp_footer', array( $this, 'insert_header_ad_special' ) ); |
||
| 248 | break; |
||
| 249 | default: |
||
| 250 | add_action( 'wp_head', array( $this, 'insert_header_ad' ), 100 ); |
||
| 251 | break; |
||
| 252 | } |
||
| 253 | } |
||
| 254 | } |
||
| 255 | } |
||
| 256 | |||
| 257 | /** |
||
| 258 | * Register desktop scripts and styles |
||
| 259 | * |
||
| 260 | * @since 4.5.0 |
||
| 261 | */ |
||
| 262 | function enqueue_scripts() { |
||
| 263 | wp_enqueue_style( |
||
| 264 | 'wordads', |
||
| 265 | WORDADS_URL . 'css/style.css', |
||
| 266 | array(), |
||
| 267 | '2015-12-18' |
||
| 268 | ); |
||
| 269 | } |
||
| 270 | |||
| 271 | /** |
||
| 272 | * Add the IPW resource hints |
||
| 273 | * |
||
| 274 | * @since 7.9 |
||
| 275 | */ |
||
| 276 | public function resource_hints( $hints, $relation_type ) { |
||
| 277 | if ( 'dns-prefetch' === $relation_type ) { |
||
| 278 | $hints[] = '//s.pubmine.com'; |
||
| 279 | $hints[] = '//x.bidswitch.net'; |
||
| 280 | $hints[] = '//static.criteo.net'; |
||
| 281 | $hints[] = '//ib.adnxs.com'; |
||
| 282 | $hints[] = '//aax.amazon-adsystem.com'; |
||
| 283 | $hints[] = '//bidder.criteo.com'; |
||
| 284 | $hints[] = '//cas.criteo.com'; |
||
| 285 | $hints[] = '//gum.criteo.com'; |
||
| 286 | $hints[] = '//ads.pubmatic.com'; |
||
| 287 | $hints[] = '//gads.pubmatic.com'; |
||
| 288 | $hints[] = '//tpc.googlesyndication.com'; |
||
| 289 | $hints[] = '//ad.doubleclick.net'; |
||
| 290 | $hints[] = '//googleads.g.doubleclick.net'; |
||
| 291 | $hints[] = '//www.googletagservices.com'; |
||
| 292 | $hints[] = '//cdn.switchadhub.com'; |
||
| 293 | $hints[] = '//delivery.g.switchadhub.com'; |
||
| 294 | $hints[] = '//delivery.swid.switchadhub.com'; |
||
| 295 | } |
||
| 296 | |||
| 297 | return $hints; |
||
| 298 | } |
||
| 299 | |||
| 300 | /** |
||
| 301 | * IPONWEB metadata used by the various scripts |
||
| 302 | * |
||
| 303 | * @return [type] [description] |
||
|
|
|||
| 304 | */ |
||
| 305 | function insert_head_meta() { |
||
| 306 | if ( self::is_amp() ) { |
||
| 307 | return; |
||
| 308 | } |
||
| 309 | $themename = esc_js( get_stylesheet() ); |
||
| 310 | $pagetype = intval( $this->params->get_page_type_ipw() ); |
||
| 311 | $data_tags = ( $this->params->cloudflare ) ? ' data-cfasync="false"' : ''; |
||
| 312 | $site_id = $this->params->blog_id; |
||
| 313 | $consent = intval( isset( $_COOKIE['personalized-ads-consent'] ) ); |
||
| 314 | echo <<<HTML |
||
| 315 | <script$data_tags type="text/javascript"> |
||
| 316 | var __ATA = __ATA || {}; |
||
| 317 | __ATA.cmd = __ATA.cmd || { |
||
| 318 | push: function( callback ) { |
||
| 319 | __ATA_PP = { pt: $pagetype, ht: 2, tn: '$themename', amp: false, siteid: $site_id, consent: $consent }; |
||
| 320 | __ATA.cmd = [ callback ]; |
||
| 321 | __ATA.criteo = __ATA.criteo || {}; |
||
| 322 | __ATA.criteo.cmd = __ATA.criteo.cmd || []; |
||
| 323 | |||
| 324 | (function(){function g(a,c){a:{for(var b=a.length,d="string"==typeof a?a.split(""):a,e=0;e<b;e++)if(e in d&&c.call(void 0,d[e],e,a)){c=e;break a}c=-1}return 0>c?null:"string"==typeof a?a.charAt(c):a[c]};function h(a,c,b){b=null!=b?"="+encodeURIComponent(String(b)):"";if(c+=b){b=a.indexOf("#");0>b&&(b=a.length);var d=a.indexOf("?");if(0>d||d>b){d=b;var e=""}else e=a.substring(d+1,b);a=[a.substr(0,d),e,a.substr(b)];b=a[1];a[1]=c?b?b+"&"+c:c:b;a=a[0]+(a[1]?"?"+a[1]:"")+a[2]}return a};var k=0;function l(a,c){var b=document.createElement("script");b.src=a;b.onload=function(){c&&c(void 0)};b.onerror=function(){c("error")};a=document.getElementsByTagName("head");var d;a&&0!==a.length?d=a[0]:d=document.documentElement;d.appendChild(b)}function m(a){return"string"==typeof a&&0<a.length} |
||
| 325 | function p(a,c,b){c=void 0===c?"":c;b=void 0===b?".":b;var d=[];Object.keys(a).forEach(function(e){var f=a[e],n=typeof f;"object"==n&&null!=f||"function"==n?d.push(p(f,c+e+b)):null!==f&&void 0!==f&&(e=encodeURIComponent(c+e),d.push(e+"="+encodeURIComponent(f)))});return d.filter(m).join("&")}function q(){return window.__ATA||{}}function r(a,c){a||(q().config=c.c,l(c.url))}var t=Math.floor(1E13*Math.random());q().rid=t; |
||
| 326 | var u=q().pageParams,v="//"+(q().serverDomain||"s.pubmine.com")+"/conf",w=window.top===window,x;try{var y=JSON.parse(document.getElementById("oil-configuration").innerText);if("boolean"!==typeof y.gdpr_applies)throw Error("Config doesn't contain gdpr_applies");x=y.gdpr_applies?1:0}catch(a){x=null} |
||
| 327 | var z=x,A=window.__ATA_PP||u||null,B=w?document.referrer?document.referrer:null:null,C=w?null:document.referrer?document.referrer:null,D=function(){var a=void 0===a?document.cookie:a;return(a=g(a.split("; "),function(c){return-1!=c.indexOf("__ATA_tuuid=")}))?a.split("=")[1]:""}(),E=p({gdpr:z,pp:A,rid:t,src:B,ref:C,tuuid:D?D:null,vp:window.innerWidth+"x"+window.innerHeight},"","."); |
||
| 328 | (function(a){var c;k++;var b="callback__"+Date.now().toString(36)+"_"+k.toString(36);a=h(a,void 0===c?"cb":c,b);window[b]=function(d){r(void 0,d)};l(a,function(d){d&&r(d)})})(v+"?"+E);}).call(this); |
||
| 329 | } |
||
| 330 | } |
||
| 331 | </script> |
||
| 332 | HTML; |
||
| 333 | } |
||
| 334 | |||
| 335 | /** |
||
| 336 | * Insert the ad onto the page |
||
| 337 | * |
||
| 338 | * @since 4.5.0 |
||
| 339 | */ |
||
| 340 | function insert_ad( $content ) { |
||
| 341 | // Don't insert ads in feeds, or for anything but the main display. (This is required for compatibility with the Publicize module). |
||
| 342 | if ( is_feed() || ! is_main_query() || ! in_the_loop() ) { |
||
| 343 | return $content; |
||
| 344 | } |
||
| 345 | /** |
||
| 346 | * Allow third-party tools to disable the display of in post ads. |
||
| 347 | * |
||
| 348 | * @module wordads |
||
| 349 | * |
||
| 350 | * @since 4.5.0 |
||
| 351 | * |
||
| 352 | * @param bool true Should the in post unit be disabled. Default to false. |
||
| 353 | */ |
||
| 354 | $disable = apply_filters( 'wordads_inpost_disable', false ); |
||
| 355 | if ( ! $this->params->should_show() || $disable ) { |
||
| 356 | return $content; |
||
| 357 | } |
||
| 358 | |||
| 359 | $ad_type = $this->option( 'wordads_house' ) ? 'house' : 'iponweb'; |
||
| 360 | return $content . $this->get_ad( 'belowpost', $ad_type ); |
||
| 361 | } |
||
| 362 | |||
| 363 | /** |
||
| 364 | * Insert an inline ad into a post content |
||
| 365 | * Used for rendering the `wordads` shortcode. |
||
| 366 | * |
||
| 367 | * @since 6.1.0 |
||
| 368 | */ |
||
| 369 | function insert_inline_ad( $content ) { |
||
| 370 | // Ad JS won't work in XML feeds. |
||
| 371 | if ( is_feed() ) { |
||
| 372 | return $content; |
||
| 373 | } |
||
| 374 | /** |
||
| 375 | * Allow third-party tools to disable the display of in post ads. |
||
| 376 | * |
||
| 377 | * @module wordads |
||
| 378 | * |
||
| 379 | * @since 4.5.0 |
||
| 380 | * |
||
| 381 | * @param bool true Should the in post unit be disabled. Default to false. |
||
| 382 | */ |
||
| 383 | $disable = apply_filters( 'wordads_inpost_disable', false ); |
||
| 384 | if ( $disable ) { |
||
| 385 | return $content; |
||
| 386 | } |
||
| 387 | |||
| 388 | $ad_type = $this->option( 'wordads_house' ) ? 'house' : 'iponweb'; |
||
| 389 | $content .= $this->get_ad( 'inline', $ad_type ); |
||
| 390 | return $content; |
||
| 391 | } |
||
| 392 | |||
| 393 | /** |
||
| 394 | * Inserts ad into header |
||
| 395 | * |
||
| 396 | * @since 4.5.0 |
||
| 397 | */ |
||
| 398 | function insert_header_ad() { |
||
| 399 | /** |
||
| 400 | * Allow third-party tools to disable the display of header ads. |
||
| 401 | * |
||
| 402 | * @module wordads |
||
| 403 | * |
||
| 404 | * @since 4.5.0 |
||
| 405 | * |
||
| 406 | * @param bool true Should the header unit be disabled. Default to false. |
||
| 407 | */ |
||
| 408 | if ( apply_filters( 'wordads_header_disable', false ) ) { |
||
| 409 | return; |
||
| 410 | } |
||
| 411 | |||
| 412 | $ad_type = $this->option( 'wordads_house' ) ? 'house' : 'iponweb'; |
||
| 413 | echo $this->get_ad( 'top', $ad_type ); |
||
| 414 | } |
||
| 415 | |||
| 416 | /** |
||
| 417 | * Special cases for inserting header unit via JS |
||
| 418 | * |
||
| 419 | * @since 4.5.0 |
||
| 420 | */ |
||
| 421 | function insert_header_ad_special() { |
||
| 422 | /** |
||
| 423 | * Allow third-party tools to disable the display of header ads. |
||
| 424 | * |
||
| 425 | * @module wordads |
||
| 426 | * |
||
| 427 | * @since 4.5.0 |
||
| 428 | * |
||
| 429 | * @param bool true Should the header unit be disabled. Default to false. |
||
| 430 | */ |
||
| 431 | if ( apply_filters( 'wordads_header_disable', false ) ) { |
||
| 432 | return; |
||
| 433 | } |
||
| 434 | |||
| 435 | $selector = '#content'; |
||
| 436 | switch ( get_stylesheet() ) { |
||
| 437 | case 'twentyseventeen': |
||
| 438 | $selector = '#content'; |
||
| 439 | break; |
||
| 440 | case 'twentyfifteen': |
||
| 441 | $selector = '#main'; |
||
| 442 | break; |
||
| 443 | case 'twentyfourteen': |
||
| 444 | $selector = 'article'; |
||
| 445 | break; |
||
| 446 | } |
||
| 447 | |||
| 448 | $ad_type = $this->option( 'wordads_house' ) ? 'house' : 'iponweb'; |
||
| 449 | echo $this->get_ad( 'top', $ad_type ); |
||
| 450 | if ( ! self::is_amp() ) { |
||
| 451 | echo <<<HTML |
||
| 452 | <script type="text/javascript"> |
||
| 453 | (function ( selector ) { |
||
| 454 | var main = document.querySelector( selector ); |
||
| 455 | var headerAd = document.querySelector('.wpcnt-header'); |
||
| 456 | |||
| 457 | if ( main ) { |
||
| 458 | main.parentNode.insertBefore( headerAd, main ); |
||
| 459 | } |
||
| 460 | })( '$selector' ); |
||
| 461 | |||
| 462 | </script> |
||
| 463 | HTML; |
||
| 464 | } |
||
| 465 | } |
||
| 466 | |||
| 467 | /** |
||
| 468 | * Header unit for AMP |
||
| 469 | * |
||
| 470 | * @param string $content Content of the page. |
||
| 471 | * |
||
| 472 | * @since 7.5.0 |
||
| 473 | */ |
||
| 474 | public function insert_header_ad_amp( $content ) { |
||
| 483 | |||
| 484 | /** |
||
| 485 | * Filter the latest ads.txt to include custom user entries. Strips any tags or whitespace. |
||
| 486 | * |
||
| 487 | * @param string $adstxt The ads.txt being filtered |
||
| 488 | * @return string Filtered ads.txt with custom entries, if applicable |
||
| 489 | * |
||
| 490 | * @since 6.5.0 |
||
| 491 | */ |
||
| 492 | function insert_custom_adstxt( $adstxt ) { |
||
| 501 | |||
| 502 | /** |
||
| 503 | * Get the ad for the spot and type. |
||
| 504 | * |
||
| 505 | * @param string $spot top, side, inline, or belowpost |
||
| 506 | * @param string $type iponweb or adsense |
||
| 507 | */ |
||
| 508 | function get_ad( $spot, $type = 'iponweb' ) { |
||
| 553 | |||
| 554 | |||
| 555 | /** |
||
| 556 | * Returns the snippet to be inserted into the ad unit |
||
| 557 | * |
||
| 558 | * @param int $section_id |
||
| 559 | * @param int $height |
||
| 560 | * @param int $width |
||
| 561 | * @param int $location |
||
| 562 | * @param string $css |
||
| 563 | * @return string |
||
| 564 | * |
||
| 565 | * @since 5.7 |
||
| 566 | */ |
||
| 567 | public function get_ad_snippet( $section_id, $height, $width, $location = '', $css = '' ) { |
||
| 615 | |||
| 616 | /** |
||
| 617 | * Returns the complete ad div with snippet to be inserted into the page |
||
| 618 | * |
||
| 619 | * @param string $spot top, side, inline, or belowpost. |
||
| 620 | * @param string $snippet The snippet to insert into the div. |
||
| 621 | * @param array $css_classes CSS classes. |
||
| 622 | * @return string The supporting ad unit div. |
||
| 623 | * |
||
| 624 | * @since 7.1 |
||
| 625 | */ |
||
| 626 | function get_ad_div( $spot, $snippet, array $css_classes = array() ) { |
||
| 650 | |||
| 651 | /** |
||
| 652 | * Check the reasons to bail before we attempt to insert ads. |
||
| 653 | * |
||
| 654 | * @return true if we should bail (don't insert ads) |
||
| 655 | * |
||
| 656 | * @since 4.5.0 |
||
| 657 | */ |
||
| 658 | public function should_bail() { |
||
| 661 | |||
| 662 | /** |
||
| 663 | * Returns markup for HTML5 house ad base on unit |
||
| 664 | * |
||
| 665 | * @param string $unit mrec, widesky, or leaderboard |
||
| 666 | * @return string markup for HTML5 house ad |
||
| 667 | * |
||
| 668 | * @since 4.7.0 |
||
| 669 | */ |
||
| 670 | public function get_house_ad( $unit = 'mrec' ) { |
||
| 700 | |||
| 701 | /** |
||
| 702 | * Activation hook actions |
||
| 703 | * |
||
| 704 | * @since 4.5.0 |
||
| 705 | */ |
||
| 706 | public static function activate() { |
||
| 709 | } |
||
| 710 | |||
| 711 | add_action( 'jetpack_activate_module_wordads', array( 'WordAds', 'activate' ) ); |
||
| 712 | add_action( 'jetpack_activate_module_wordads', array( 'WordAds_Cron', 'activate' ) ); |
||
| 713 | add_action( 'jetpack_deactivate_module_wordads', array( 'WordAds_Cron', 'deactivate' ) ); |
||
| 714 | |||
| 715 | global $wordads; |
||
| 716 | $wordads = new WordAds(); |
||
| 717 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.