Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/advanced.../public
File: class-advanced-ads.php
<?php
[0] Fix | Delete
// phpcs:ignoreFile
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* Advanced Ads.
[4] Fix | Delete
*
[5] Fix | Delete
* @package Advanced_Ads_Admin
[6] Fix | Delete
* @author Thomas Maier <support@wpadvancedads.com>
[7] Fix | Delete
* @license GPL-2.0+
[8] Fix | Delete
* @link https://wpadvancedads.com
[9] Fix | Delete
* @copyright 2013-2018 Thomas Maier, Advanced Ads GmbH
[10] Fix | Delete
*/
[11] Fix | Delete
[12] Fix | Delete
use AdvancedAds\Entities;
[13] Fix | Delete
use AdvancedAds\Utilities\WordPress;
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* Plugin class. This class should ideally be used to work with the
[17] Fix | Delete
* public-facing side of the WordPress site.
[18] Fix | Delete
*
[19] Fix | Delete
* @package Advanced_Ads
[20] Fix | Delete
* @author Thomas Maier <support@wpadvancedads.com>
[21] Fix | Delete
*/
[22] Fix | Delete
class Advanced_Ads {
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Post type slug
[26] Fix | Delete
*
[27] Fix | Delete
* @deprecated 1.47.0 Use \AdvancedAds\Entities::POST_TYPE_AD
[28] Fix | Delete
*
[29] Fix | Delete
* @var string
[30] Fix | Delete
*/
[31] Fix | Delete
const POST_TYPE_SLUG = 'advanced_ads';
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Ad group slug
[35] Fix | Delete
*
[36] Fix | Delete
* @deprecated 1.47.0 Use \AdvancedAds\Entities::TAXONOMY_AD_GROUP
[37] Fix | Delete
*
[38] Fix | Delete
* @var string
[39] Fix | Delete
*/
[40] Fix | Delete
const AD_GROUP_TAXONOMY = 'advanced_ads_groups';
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Instance of this class.
[44] Fix | Delete
*
[45] Fix | Delete
* @var object
[46] Fix | Delete
*/
[47] Fix | Delete
private static $instance = null;
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Array with ads currently delivered in the frontend
[51] Fix | Delete
*
[52] Fix | Delete
* @var array Ads already loaded in the frontend
[53] Fix | Delete
*/
[54] Fix | Delete
public $current_ads = [];
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Ad types
[58] Fix | Delete
*
[59] Fix | Delete
* @var array Ad types
[60] Fix | Delete
*/
[61] Fix | Delete
public $ad_types = [];
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Plugin options
[65] Fix | Delete
*
[66] Fix | Delete
* @var array (if loaded)
[67] Fix | Delete
*/
[68] Fix | Delete
protected $options = false;
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Adsense options
[72] Fix | Delete
*
[73] Fix | Delete
* @var array (if loaded)
[74] Fix | Delete
*/
[75] Fix | Delete
protected $adsense_options = null;
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* Interal plugin options – set by the plugin
[79] Fix | Delete
*
[80] Fix | Delete
* @var array (if loaded)
[81] Fix | Delete
*/
[82] Fix | Delete
protected $internal_options = false;
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Whether the loop started in an inner `the_content`.
[86] Fix | Delete
*
[87] Fix | Delete
* @var bool
[88] Fix | Delete
*/
[89] Fix | Delete
protected $was_in_the_loop = false;
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* Signifies Whether the loop has started and the caller is in the loop.
[93] Fix | Delete
*
[94] Fix | Delete
* We need it because Some the "Divi" theme calls the `loop_start/loop_end` hooks
[95] Fix | Delete
* instead of calling `the_post()` to signify that the caller is in the loop.
[96] Fix | Delete
*
[97] Fix | Delete
* @var bool
[98] Fix | Delete
*/
[99] Fix | Delete
protected $in_the_loop = false;
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* List of bots and crawlers to exclude from ad impressions
[103] Fix | Delete
*
[104] Fix | Delete
* @var array list of bots
[105] Fix | Delete
*/
[106] Fix | Delete
protected $bots = [ 'bot', 'spider', 'crawler', 'scraper', 'parser', '008', 'Accoona-AI-Agent', 'ADmantX', 'alexa', 'appie', 'Apple-PubSub', 'Arachmo', 'Ask Jeeves', 'avira\.com', 'B-l-i-t-z-B-O-T', 'boitho\.com-dc', 'BUbiNG', 'Cerberian Drtrs', 'Charlotte', 'cosmos', 'Covario IDS', 'curl', 'Datanyze', 'DataparkSearch', 'Dataprovider\.com', 'DDG-Android', 'Ecosia', 'expo9', 'facebookexternalhit', 'Feedfetcher-Google', 'FindLinks', 'Firefly', 'froogle', 'Genieo', 'heritrix', 'Holmes', 'htdig', 'https://developers\.google\.com', 'ia_archiver', 'ichiro', 'igdeSpyder', 'InfoSeek', 'inktomi', 'Kraken', 'L\.webis', 'Larbin', 'Linguee', 'LinkWalker', 'looksmart', 'lwp-trivial', 'mabontland', 'Mnogosearch', 'mogimogi', 'Morning Paper', 'MVAClient', 'NationalDirectory', 'NetResearchServer', 'NewsGator', 'NG-Search', 'Nusearch', 'NutchCVS', 'Nymesis', 'oegp', 'Orbiter', 'Peew', 'Pompos', 'PostPost', 'proximic', 'PycURL', 'Qseero', 'rabaz', 'Radian6', 'Reeder', 'savetheworldheritage', 'SBIder', 'Scooter', 'ScoutJet', 'Scrubby', 'SearchSight', 'semanticdiscovery', 'Sensis', 'ShopWiki', 'silk', 'Snappy', 'Spade', 'Sqworm', 'StackRambler', 'TechnoratiSnoop', 'TECNOSEEK', 'Teoma', 'Thumbnail\.CZ', 'TinEye', 'truwoGPS', 'updated', 'Vagabondo', 'voltron', 'Vortex', 'voyager', 'VYU2', 'WebBug', 'webcollage', 'WebIndex', 'Websquash\.com', 'WeSEE:Ads', 'wf84', 'Wget', 'WomlpeFactory', 'WordPress', 'yacy', 'Yahoo! Slurp', 'Yahoo! Slurp China', 'YahooSeeker', 'YahooSeeker-Testing', 'YandexBot', 'YandexMedia', 'YandexBlogs', 'YandexNews', 'YandexCalendar', 'YandexImages', 'Yeti', 'yoogliFetchAgent', 'Zao', 'ZyBorg', 'okhttp', 'ips-agent', 'ltx71', 'Optimizer', 'Daum', 'Qwantify' ];
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Loaded instance of Advanced_Ads_Model
[110] Fix | Delete
*
[111] Fix | Delete
* @var Advanced_Ads_Model
[112] Fix | Delete
*/
[113] Fix | Delete
protected $model;
[114] Fix | Delete
[115] Fix | Delete
/**
[116] Fix | Delete
* Loaded instance of Advanced_Ads_Plugin
[117] Fix | Delete
*
[118] Fix | Delete
* @var Advanced_Ads_Plugin
[119] Fix | Delete
*/
[120] Fix | Delete
protected $plugin;
[121] Fix | Delete
[122] Fix | Delete
/**
[123] Fix | Delete
* Loaded instance of Advanced_Ads_Select
[124] Fix | Delete
*
[125] Fix | Delete
* @var Advanced_Ads_Select
[126] Fix | Delete
*/
[127] Fix | Delete
protected $ad_selector;
[128] Fix | Delete
[129] Fix | Delete
/**
[130] Fix | Delete
* Is the query the main query?, when WP_Query is used
[131] Fix | Delete
*
[132] Fix | Delete
* @var bool
[133] Fix | Delete
*/
[134] Fix | Delete
private $is_main_query;
[135] Fix | Delete
[136] Fix | Delete
/**
[137] Fix | Delete
* Save number of ads
[138] Fix | Delete
*
[139] Fix | Delete
* @var array
[140] Fix | Delete
*/
[141] Fix | Delete
private $number_of_ads = [];
[142] Fix | Delete
[143] Fix | Delete
/**
[144] Fix | Delete
* Reason why are disabled.
[145] Fix | Delete
*
[146] Fix | Delete
* @var string
[147] Fix | Delete
*/
[148] Fix | Delete
public $disabled_reason = null;
[149] Fix | Delete
[150] Fix | Delete
/**
[151] Fix | Delete
* Identifier that supplement the disabled reason.
[152] Fix | Delete
*
[153] Fix | Delete
* @var int|string
[154] Fix | Delete
*/
[155] Fix | Delete
public $disabled_id = null;
[156] Fix | Delete
[157] Fix | Delete
/**
[158] Fix | Delete
* Initialize frontend features
[159] Fix | Delete
*/
[160] Fix | Delete
private function __construct() {
[161] Fix | Delete
$this->plugin = Advanced_Ads_Plugin::get_instance();
[162] Fix | Delete
$this->plugin->set_model( $this->get_model() );
[163] Fix | Delete
$this->ad_selector = Advanced_Ads_Select::get_instance();
[164] Fix | Delete
[165] Fix | Delete
// initialize plugin specific functions.
[166] Fix | Delete
add_action( 'init', [ $this, 'wp_init' ] );
[167] Fix | Delete
[168] Fix | Delete
// only when not doing ajax.
[169] Fix | Delete
if ( wp_doing_ajax() ) {
[170] Fix | Delete
Advanced_Ads_Ajax::get_instance();
[171] Fix | Delete
}
[172] Fix | Delete
add_action( 'plugins_loaded', [ $this, 'wp_plugins_loaded' ] );
[173] Fix | Delete
[174] Fix | Delete
// allow add-ons to interact.
[175] Fix | Delete
add_action( 'init', [ $this, 'advanced_ads_loaded' ], 9 );
[176] Fix | Delete
[177] Fix | Delete
add_filter( 'the_content', [ $this, 'set_was_in_the_loop' ], ~PHP_INT_MAX );
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
/**
[181] Fix | Delete
* Return an instance of this class.
[182] Fix | Delete
*
[183] Fix | Delete
* @return Advanced_Ads A single instance of this class.
[184] Fix | Delete
*/
[185] Fix | Delete
public static function get_instance() {
[186] Fix | Delete
[187] Fix | Delete
// if the single instance hasn't been set, set it now.
[188] Fix | Delete
if ( null === self::$instance ) {
[189] Fix | Delete
self::$instance = new self();
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
return self::$instance;
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
/**
[196] Fix | Delete
* Return the Advanced_Ads_Model responsible for loading ads, groups and placements into the frontend
[197] Fix | Delete
*
[198] Fix | Delete
* @return Advanced_Ads_Model
[199] Fix | Delete
*/
[200] Fix | Delete
public function get_model() {
[201] Fix | Delete
[202] Fix | Delete
global $wpdb;
[203] Fix | Delete
[204] Fix | Delete
if ( ! isset( $this->model ) ) {
[205] Fix | Delete
$this->model = new Advanced_Ads_Model( $wpdb );
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
return $this->model;
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
/**
[212] Fix | Delete
* Initialize the plugin by setting localization and loading public scripts
[213] Fix | Delete
* and styles.
[214] Fix | Delete
*/
[215] Fix | Delete
public function wp_plugins_loaded() {
[216] Fix | Delete
// register hook for global constants.
[217] Fix | Delete
// Wait until BuddyPress assigns `WP_Query->is_404` back to `false`.
[218] Fix | Delete
add_action( 'template_redirect', [ $this, 'set_disabled_constant' ], 11 );
[219] Fix | Delete
add_action( 'rest_api_init', [ $this, 'set_disabled_constant' ] );
[220] Fix | Delete
[221] Fix | Delete
// setup default ad types.
[222] Fix | Delete
add_filter( 'advanced-ads-ad-types', [ $this, 'setup_default_ad_types' ], 5 );
[223] Fix | Delete
[224] Fix | Delete
// register hooks and filters for auto ad injection.
[225] Fix | Delete
$this->init_injection();
[226] Fix | Delete
[227] Fix | Delete
// add meta robots noindex, nofollow to images, which are part of 'Image ad' ad type.
[228] Fix | Delete
add_action( 'wp_head', [ $this, 'noindex_attachment_images' ] );
[229] Fix | Delete
[230] Fix | Delete
// use custom CSS or other custom header code.
[231] Fix | Delete
add_action( 'wp_head', [ $this, 'custom_header_code' ] );
[232] Fix | Delete
[233] Fix | Delete
// check if ads are disabled in secondary queries.
[234] Fix | Delete
add_action( 'the_post', [ $this, 'set_query_type' ], 10, 2 );
[235] Fix | Delete
add_action( 'loop_start', [ $this, 'set_loop_start' ], 10, 0 );
[236] Fix | Delete
add_action( 'loop_end', [ $this, 'set_loop_end' ], 10, 0 );
[237] Fix | Delete
[238] Fix | Delete
// register debug parameter
[239] Fix | Delete
$this->debug_parameter();
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
/**
[243] Fix | Delete
* Allow add-ons to hook
[244] Fix | Delete
*/
[245] Fix | Delete
public function advanced_ads_loaded() {
[246] Fix | Delete
do_action( 'advanced-ads-plugin-loaded' );
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
/**
[250] Fix | Delete
* Init / load plugin specific functions and settings
[251] Fix | Delete
*/
[252] Fix | Delete
public function wp_init() {
[253] Fix | Delete
$this->set_ad_types();
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
/**
[257] Fix | Delete
* Define ad types with their options
[258] Fix | Delete
* name => publically readable name
[259] Fix | Delete
* description => publically readable description
[260] Fix | Delete
* editor => kind of editor: text (normal text field), content (WP content field), none (no content field)
[261] Fix | Delete
* will display text field, if left empty
[262] Fix | Delete
*/
[263] Fix | Delete
public function set_ad_types() {
[264] Fix | Delete
[265] Fix | Delete
/**
[266] Fix | Delete
* Load default ad type files
[267] Fix | Delete
* custom ad types can also be loaded in your own plugin or functions.php
[268] Fix | Delete
*/
[269] Fix | Delete
$types = [];
[270] Fix | Delete
[271] Fix | Delete
/**
[272] Fix | Delete
* Developers can add new ad types using this filter
[273] Fix | Delete
* see classes/ad-type-content.php for an example for an ad type and usage of this filter
[274] Fix | Delete
*/
[275] Fix | Delete
$this->ad_types = apply_filters( 'advanced-ads-ad-types', $types );
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
/**
[279] Fix | Delete
* Load filters to inject ads into various sections of our site
[280] Fix | Delete
*/
[281] Fix | Delete
public function init_injection() {
[282] Fix | Delete
// -TODO abstract
[283] Fix | Delete
add_action( 'wp_head', [ $this, 'inject_header' ], 20 );
[284] Fix | Delete
add_action( 'wp_footer', [ $this, 'inject_footer' ], 20 );
[285] Fix | Delete
add_filter( 'the_content', [ $this, 'inject_content' ], $this->plugin->get_content_injection_priority() );
[286] Fix | Delete
}
[287] Fix | Delete
[288] Fix | Delete
/**
[289] Fix | Delete
* Set global constant that prevents ads from being displayed on the current page view
[290] Fix | Delete
*/
[291] Fix | Delete
public function set_disabled_constant() {
[292] Fix | Delete
[293] Fix | Delete
global $post, $wp_the_query;
[294] Fix | Delete
[295] Fix | Delete
// don't set the constant if already defined.
[296] Fix | Delete
if ( defined( 'ADVADS_ADS_DISABLED' ) ) {
[297] Fix | Delete
return; }
[298] Fix | Delete
[299] Fix | Delete
$options = $this->plugin->options();
[300] Fix | Delete
[301] Fix | Delete
// check if ads are disabled completely.
[302] Fix | Delete
if ( ! empty( $options['disabled-ads']['all'] ) ) {
[303] Fix | Delete
$this->disable_ads( 'all' );
[304] Fix | Delete
return;
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
// Check if ads are disabled in REST API.
[308] Fix | Delete
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
[309] Fix | Delete
if ( ! empty( $options['disabled-ads']['rest-api'] ) ) {
[310] Fix | Delete
$this->disable_ads();
[311] Fix | Delete
}
[312] Fix | Delete
return;
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
// check if ads are disabled from 404 pages.
[316] Fix | Delete
if ( $wp_the_query->is_404() && ! empty( $options['disabled-ads']['404'] ) ) {
[317] Fix | Delete
$this->disable_ads( '404' );
[318] Fix | Delete
return;
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
// check if ads are disabled from non singular pages (often = archives).
[322] Fix | Delete
if ( ! $wp_the_query->is_singular() && ! empty( $options['disabled-ads']['archives'] ) ) {
[323] Fix | Delete
$this->disable_ads( 'archive' );
[324] Fix | Delete
return;
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
// check if ads are disabled in Feed.
[328] Fix | Delete
if ( $wp_the_query->is_feed() && ( ! isset( $options['disabled-ads']['feed'] ) || $options['disabled-ads']['feed'] ) ) {
[329] Fix | Delete
$this->disable_ads();
[330] Fix | Delete
return;
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
// check if ads are disabled on the current page.
[334] Fix | Delete
if ( $wp_the_query->is_singular() && isset( $post->ID ) ) {
[335] Fix | Delete
$post_ad_options = get_post_meta( $post->ID, '_advads_ad_settings', true );
[336] Fix | Delete
[337] Fix | Delete
if ( ! empty( $post_ad_options['disable_ads'] ) ) {
[338] Fix | Delete
$this->disable_ads( 'page', $post->ID );
[339] Fix | Delete
return;
[340] Fix | Delete
}
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
// "Posts page" set on the WordPress Reading settings page.
[344] Fix | Delete
if ( $wp_the_query->is_posts_page ) {
[345] Fix | Delete
$post_ad_options = get_post_meta( $wp_the_query->queried_object_id, '_advads_ad_settings', true );
[346] Fix | Delete
[347] Fix | Delete
if ( ! empty( $post_ad_options['disable_ads'] ) ) {
[348] Fix | Delete
$this->disable_ads( 'page', $wp_the_query->queried_object_id );
[349] Fix | Delete
return;
[350] Fix | Delete
}
[351] Fix | Delete
}
[352] Fix | Delete
[353] Fix | Delete
/**
[354] Fix | Delete
* Check if ads are disabled on WooCommerce shop page (and currently on shop page).
[355] Fix | Delete
* since WooCommerce changes the post ID of the static page selected to be the product overview page, we need to get the original page id from the WC options.
[356] Fix | Delete
*/
[357] Fix | Delete
if ( function_exists( 'is_shop' ) && is_shop() ) {
[358] Fix | Delete
$shop_id = get_option( 'woocommerce_shop_page_id' );
[359] Fix | Delete
$shop_ad_options = get_post_meta( absint( $shop_id ), '_advads_ad_settings', true );
[360] Fix | Delete
if ( ! empty( $shop_ad_options['disable_ads'] ) ) {
[361] Fix | Delete
$this->disable_ads( 'page', $shop_id );
[362] Fix | Delete
return;
[363] Fix | Delete
}
[364] Fix | Delete
}
[365] Fix | Delete
[366] Fix | Delete
if ( isset( $options['hide-for-user-role'] ) ) {
[367] Fix | Delete
$hide_for_roles = Advanced_Ads_Utils::maybe_translate_cap_to_role( $options['hide-for-user-role'] );
[368] Fix | Delete
} else {
[369] Fix | Delete
$hide_for_roles = [];
[370] Fix | Delete
}
[371] Fix | Delete
$user = wp_get_current_user();
[372] Fix | Delete
[373] Fix | Delete
if ( $hide_for_roles && is_user_logged_in() && is_array( $user->roles ) && array_intersect( $hide_for_roles, $user->roles ) ) {
[374] Fix | Delete
$this->disable_ads();
[375] Fix | Delete
return;
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
// check bots if option is enabled.
[379] Fix | Delete
if ( isset( $options['block-bots'] ) && $options['block-bots']
[380] Fix | Delete
&& ! $this->is_cache_bot() && $this->is_bot() ) {
[381] Fix | Delete
$this->disable_ads();
[382] Fix | Delete
return;
[383] Fix | Delete
}
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
/**
[387] Fix | Delete
* Disable ads.
[388] Fix | Delete
*
[389] Fix | Delete
* @param string $reason Reason why are disabled.
[390] Fix | Delete
* @param int|string $id Identifier that supplement the disabled reason.
[391] Fix | Delete
*/
[392] Fix | Delete
private function disable_ads( $reason = null, $id = null ) {
[393] Fix | Delete
define( 'ADVADS_ADS_DISABLED', true );
[394] Fix | Delete
$this->disabled_reason = $reason;
[395] Fix | Delete
$this->disabled_id = $id;
[396] Fix | Delete
}
[397] Fix | Delete
[398] Fix | Delete
/**
[399] Fix | Delete
* Return the plugin slug.
[400] Fix | Delete
*
[401] Fix | Delete
* @return string Plugin slug variable.
[402] Fix | Delete
*/
[403] Fix | Delete
public function get_plugin_slug() {
[404] Fix | Delete
return $this->plugin->get_plugin_slug();
[405] Fix | Delete
}
[406] Fix | Delete
[407] Fix | Delete
/**
[408] Fix | Delete
* Add plain and content ad types to the default ads of the plugin using a filter
[409] Fix | Delete
*
[410] Fix | Delete
* @param array $types array with ad types.
[411] Fix | Delete
* @return array
[412] Fix | Delete
*/
[413] Fix | Delete
public function setup_default_ad_types( $types ) {
[414] Fix | Delete
$types['plain'] = new Advanced_Ads_Ad_Type_Plain(); /* plain text and php code */
[415] Fix | Delete
$types['dummy'] = new Advanced_Ads_Ad_Type_Dummy(); /* dummy ad */
[416] Fix | Delete
$types['content'] = new Advanced_Ads_Ad_Type_Content(); /* rich content editor */
[417] Fix | Delete
$types['image'] = new Advanced_Ads_Ad_Type_Image(); /* image ads */
[418] Fix | Delete
$types['group'] = new Advanced_Ads_Ad_Type_Group(); /* group ad */
[419] Fix | Delete
return $types;
[420] Fix | Delete
}
[421] Fix | Delete
[422] Fix | Delete
/**
[423] Fix | Delete
* Log error messages when debug is enabled
[424] Fix | Delete
*
[425] Fix | Delete
* @param string $message error message.
[426] Fix | Delete
* @link http://www.smashingmagazine.com/2011/03/08/ten-things-every-wordpress-plugin-developer-should-know/
[427] Fix | Delete
*/
[428] Fix | Delete
public static function log( $message ) {
[429] Fix | Delete
if ( true === WP_DEBUG ) {
[430] Fix | Delete
if ( is_array( $message ) || is_object( $message ) ) {
[431] Fix | Delete
error_log( __( 'Advanced Ads Error following:', 'advanced-ads' ) );
[432] Fix | Delete
error_log( print_r( $message, true ) );
[433] Fix | Delete
} else {
[434] Fix | Delete
// translators: %s is an error message generated by the plugin.
[435] Fix | Delete
$message = sprintf( __( 'Advanced Ads Error: %s', 'advanced-ads' ), $message );
[436] Fix | Delete
error_log( $message );
[437] Fix | Delete
}
[438] Fix | Delete
}
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
/**
[442] Fix | Delete
* Compat method
[443] Fix | Delete
*
[444] Fix | Delete
* @return array with plugin options
[445] Fix | Delete
*/
[446] Fix | Delete
public function options() {
[447] Fix | Delete
return $this->plugin->options();
[448] Fix | Delete
}
[449] Fix | Delete
[450] Fix | Delete
/**
[451] Fix | Delete
* Compat method
[452] Fix | Delete
*
[453] Fix | Delete
* @return array with adsense options
[454] Fix | Delete
*/
[455] Fix | Delete
public function get_adsense_options() {
[456] Fix | Delete
// we can’t store options if WPML String Translations is enabled, or it would not translate the "Ad Label" option.
[457] Fix | Delete
if ( ! isset( $this->adsense_options ) || class_exists( 'WPML_ST_String' ) ) {
[458] Fix | Delete
$this->adsense_options = get_option( 'advanced-ads-adsense', [] );
[459] Fix | Delete
}
[460] Fix | Delete
return $this->adsense_options;
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
/**
[464] Fix | Delete
* Compat method
[465] Fix | Delete
*
[466] Fix | Delete
* @return array with internal plugin options
[467] Fix | Delete
*/
[468] Fix | Delete
public function internal_options() {
[469] Fix | Delete
return $this->plugin->internal_options();
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
/**
[473] Fix | Delete
* Injected ad into header
[474] Fix | Delete
*/
[475] Fix | Delete
public function inject_header() {
[476] Fix | Delete
$placements = get_option( 'advads-ads-placements', [] );
[477] Fix | Delete
if ( is_array( $placements ) ) {
[478] Fix | Delete
foreach ( $placements as $_placement_id => $_placement ) {
[479] Fix | Delete
if ( isset( $_placement['type'] ) && 'header' === $_placement['type'] ) {
[480] Fix | Delete
$_options = isset( $_placement['options'] ) ? $_placement['options'] : [];
[481] Fix | Delete
// injecting ad code so we don’t run escaping here.
[482] Fix | Delete
// phpcs:ignore
[483] Fix | Delete
echo Advanced_Ads_Select::get_instance()->get_ad_by_method( $_placement_id, Advanced_Ads_Select::PLACEMENT, $_options );
[484] Fix | Delete
}
[485] Fix | Delete
}
[486] Fix | Delete
}
[487] Fix | Delete
}
[488] Fix | Delete
[489] Fix | Delete
/**
[490] Fix | Delete
* Injected ads into footer
[491] Fix | Delete
*
[492] Fix | Delete
* @since 1.1.0
[493] Fix | Delete
*/
[494] Fix | Delete
public function inject_footer() {
[495] Fix | Delete
$placements = get_option( 'advads-ads-placements', [] );
[496] Fix | Delete
if ( is_array( $placements ) ) {
[497] Fix | Delete
foreach ( $placements as $_placement_id => $_placement ) {
[498] Fix | Delete
if ( isset( $_placement['type'] ) && 'footer' === $_placement['type'] ) {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function