���� JFIF    �� �        "" $(4,$&1'-=-157:::#+?D?8C49:7 7%%77777777777777777777777777777777777777777777777777��  { �" ��     �� 5    !1AQa"q�2��BR��#b�������  ��  ��   ? ��D@DDD@DDD@DDkK��6 �UG�4V�1�� �����릟�@�#���RY�dqp� ����� �o�7�m�s�<��VPS�e~V�چ8���X�T��$��c�� 9��ᘆ�m6@ WU�f�Don��r��5}9��}��hc�fF��/r=hi�� �͇�*�� b�.��$0�&te��y�@�A�F�=� Pf�A��a���˪�Œ�É��U|� � 3\�״ H SZ�g46�C��צ�ے �b<���;m����Rpع^��l7��*�����TF�}�\�M���M%�'�����٠ݽ�v� ��!-�����?�N!La��A+[`#���M����'�~oR�?��v^)��=��h����A��X�.���˃����^Ə��ܯsO"B�c>; �e�4��5�k��/CB��.  �J?��;�҈�������������������~�<�VZ�ꭼ2/)Í”jC���ע�V�G�!���!�F������\�� Kj�R�oc�h���:Þ I��1"2�q×°8��Р@ז���_C0�ր��A��lQ��@纼�!7��F�� �]�sZ B�62r�v�z~�K�7�c��5�.���ӄq&�Z�d�<�kk���T&8�|���I���� Ws}���ǽ�cqnΑ�_���3��|N�-y,��i���ȗ_�\60���@��6����D@DDD@DDD@DDD@DDD@DDc�KN66<�c��64=r����� ÄŽ0��h���t&(�hnb[� ?��^��\��â|�,�/h�\��R��5�? �0�!צ܉-����G����٬��Q�zA���1�����V��� �:R���`�$��ik��H����D4�����#dk����� h�}����7���w%�������*o8wG�LycuT�.���ܯ7��I��u^���)��/c�,s�Nq�ۺ�;�ך�YH2���.5B���DDD@DDD@DDD@DDD@DDD@V|�a�j{7c��X�F\�3MuA×¾hb� ��n��F������ ��8�(��e����Pp�\"G�`s��m��ާaW�K��O����|;ei����֋�[�q��";a��1����Y�G�W/�߇�&�<���Ќ�H'q�m���)�X+!���=�m�ۚ丷~6a^X�)���,�>#&6G���Y��{����"" """ """ """ """ ""��at\/�a�8 �yp%�lhl�n����)���i�t��B�������������?��modskinlienminh.com - WSOX ENC readme.txt000064400000111010146731142050006537 0ustar00=== Ad Inserter - Ad Manager & AdSense Ads === Contributors: adinserter, spacetime Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4 Tags: ads, adsense, ad rotation, ad manager, amp, amazon, ad blocking detection, header code, banners, in-feed ads, sticky fixed widgets, hooks Requires at least: 4.9 Tested up to: 6.2 Requires PHP: 5.6 Stable tag: 2.7.29 License: GPLv3 Manage Google AdSense, Media.net, Amazon banners, ads.txt, ad rotation, sticky widgets, AMP ads, DFP, tracking, AdSense header and footer code == Description == Ad management plugin with many advanced advertising features to insert ad codes at optimal positions. Supports all kinds of ads including **Google AdSense**, **Google Ad Manager** (DFP - DoubleClick for publishers), contextual **Amazon Native Shopping Ads**, **Media.net** , **Infolinks** and **rotating banners.** This plugin is more than AdSense plugin or plugin for ads. It provides many advanced options to insert opt-in forms, header scripts, Javascript, CSS, HTML, PHP, analytics, tracking or advert code anywhere on the page. **Insert ads where other plugins fail**. It's all about the [settings](https://adinserter.pro/documentation). [Plugin reviews](https://wordpress.org/support/topic/wow-684/): > I've been using another ad placement manager for a couple years and just recently started using Ad Inserter. > > I'm blown AWAY with the power and flexibility of it. > > I can HIGHLY recommend this plugin to anyone looking for an easy way to manage ads within WordPress. > > Difficult to choose, but certainly top 3 plugins I've ever used in WordPress, ever. **Features** - check [documentation](https://adinserter.pro/documentation/features) for the complete list * [AdSense integration](https://adinserter.pro/documentation/adsense-ads) * Support for [Google Ad Manager](https://adinserter.pro/documentation/ad-manager-ads) (DoubleClick for publishers) * Syntax highlighting [editor](https://adinserter.pro/documentation/code-editing) * Plain JavaScript code on front-end - no library dependencies * Code preview with visual CSS editor * Automatically inserts ads on posts and pages * Insert before or after post * Insert before or after content * Insert before or after paragraph * Insert before or after random paragraph * Insert before or after multiple paragraphs * Insert before or after image * Insert before or after comments * Insert before or after excerpt * Insert near any element on the page (using CSS selectors) * Insert above the header (after `` tag) * Insert in the footer (before `` tag) * Insert at relative positions in posts * Insert between posts on blog pages (in-feed AdSense) * Insert between excerpts on blog pages * Insert between comments * Insert at custom hook positions (`do_action ()` WP function) * Insert before or after any HTML element using CSS selectors * Visual HTML element selector (DOM explorer) * Avoid inserting ads near images or headers (AdSense TOS) * Disable ads on individual posts or pages * Insert header (`` section) and footer code * Insert raw HTTP response header lines * Insert Google Analytics, Matomo (Piwik) or any other tracking code * Insert images, HTML, CSS, Javascript or PHP code * Code generator for banners and placeholders * AdSense code generator * Support to detect, hide or replace blank AdSense blocks * Visual advert editor - create adverts from scratch * Manual insertion: widgets, shortcodes, PHP function call * Sticky (fixed) widgets (sticky sidebar - the sidebar does not move when the page is scrolled) * Custom alignments and styles * Insert different ad codes on AMP pages * Custom CSS class name for wrapping divs to avoid ad blockers * Use shortcodes from other plugins * Use custom fields as defined in posts * Use post title, tags or category names to create contextual adverts * PHP code processing * Ad labels - show customized label above adverts * ads.txt editor * Support for [GDPR consent checks](https://adinserter.pro/faq/gdpr-compliance-cookies-consent) * Support for IAB TCF 2.0 GDPR consent API (used by Quantcast Choice) * Ad rotation (server-side and client-side - works with caching) * Timed ad rotation - define times to rotate adverts in a single ad block * Create rich media ads with standard WordPress TinyMCE editor * Ad blocking detection - popup message, page redirection * Desktop/mobile device detection (server-side and client-side - works with caching) * [Blacklist/Whitelist](https://adinserter.pro/documentation/black-and-white-lists) categories, tags, taxonomies, post IDs, urls, url query parameters, cookies, referrers, browsers, operating systems * Easy copying and pasting ads or settings using internal clipboard * Use it with Google Site Kit or replace it to have more control over ad placement * Simple troubleshooting with many debugging functions * Function to visualize inserted blocks * Function to visualize AdSense ads with ad names and IDs * Function to visualize available insertion positions * Function to visualize HTML tags * You name it :) 👉 TEST the plugin on a [demo website](https://tastewp.com/template/AdInserterDemo?redirect=options-general.php%3Fpage%3Dad-inserter.php%26ai-demo%3D1&ni=true) [Review on WP Mayor](https://wpmayor.com/ad-inserter-review-the-best-wordpress-ad-management-plugin/) > The Best WordPress Ad Management Plugin? [Review on ShoutMeLoud](https://www.shoutmeloud.com/ad-inserter-review.html) > Both Google and Amazon recommend this plugin for inserting ads, which is a testament to its quality **Endorsed by Google** - [How to insert ad code in your WordPress site](https://support.google.com/adsense/answer/7527509) > If you're new to AdSense, one of your first tasks is to connect your site to AdSense. This requires you to copy the code on your AdSense homepage and paste it into the HTML of your page, between the `` and `` tags. **Endorsed by Amazon** - Wordpress Integration Guide for Native Shopping Ads. > Native Shopping Ads provide highly relevant and dynamic product recommendations in a stylishly designed and responsive ad unit that can be placed at the end or within your content to create a more compelling visitor experience and shopping opportunity. **Pro version** supports additional [advanced features](https://adinserter.pro/documentation/features): * Geolocation using internal or [MaxMind](http://www.maxmind.com/) databases (works also with caching) * Country, state, region and city level geotargeting * Blacklist/Whitelist IP addresses or countries/cities (works also with caching) * Ad impression and click statistics (works also with `' . "\n"; } else { if (is_array ($this->check_codes) && isset ($this->check_codes [$this->check_codes_index])) { $this->check_codes_index ++; $code = $this->check_codes [$this->check_codes_index]; } else { unset ($ai_wp_data [AI_SHORTCODES]['check']); unset ($ai_wp_data [AI_SHORTCODES]['count']); unset ($ai_wp_data [AI_SHORTCODES]['rotate']); unset ($ai_wp_data [AI_SHORTCODES]['head']); unset ($ai_wp_data [AI_SHORTCODES]['viewport']); $ai_wp_data [AI_CURRENT_BLOCK_NUMBER] = $this->number; $ai_wp_data [AI_CURRENT_BLOCK_NAME] = $this->get_ad_name (); $ai_code = $this->ai_getCode (); $replace_embed = false; if (stripos ($ai_code, 'embed]') !== false) { $replace_embed = true; $ai_code = str_ireplace (array ('[embed]', '[/embed]'), array ('[#embed#]', '[#/embed#]'), $ai_code); } $code = do_shortcode (replace_ai_tags ($ai_code, $this->get_ad_general_tag())); if ($replace_embed) { $code = str_ireplace (array ('[#embed#]', '[#/embed#]'), array ('[embed]', '[/embed]'), $code); $code = $GLOBALS[ 'wp_embed']->run_shortcode ($code); } unset ($ai_wp_data [AI_CURRENT_BLOCK_NUMBER]); unset ($ai_wp_data [AI_CURRENT_BLOCK_NAME]); if (isset ($ai_wp_data [AI_SHORTCODES])) { $this->shortcodes = $ai_wp_data [AI_SHORTCODES]; } } } $processed_code .= $code; // $this->needs_class = true; // ??? $this->wrapping_div_classes = array (); $dynamic_blocks = get_dynamic_blocks (); if ($ai_wp_data [AI_FORCE_SERVERSIDE_CODE] || ($dynamic_blocks == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && defined ('AI_NO_W3TC'))) $dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE; if ($not_iframe_or_inside) { // [ADINSERTER CHECK] if (function_exists ('ai_check_separators')) { $processed_code = ai_check_separators ($this, $processed_code); if ($this->check_code_empty && $processed_code == '') { return ''; } } // [ADINSERTER COUNT] preg_match_all ('/\|count([0-9]+?)\|/', $processed_code, $matches); if (count ($matches [1]) != 0) { $count_parameters = array (); foreach ($matches [1] as $match) { // $count_parameters []= $ai_wp_data [AI_SHORTCODES]['count'][$match]; $count_parameters []= $this->shortcodes ['count'][$match]; } $processed_code = preg_replace ('/\|count([0-9]+?)\|/', AD_COUNT_SEPARATOR, $processed_code); // } else if (isset ($ai_wp_data [AI_SHORTCODES]['count'])) $count_parameters = $ai_wp_data [AI_SHORTCODES]['count']; } else if (isset ($this->shortcodes ['count'])) $count_parameters = $this->shortcodes ['count']; if (strpos ($processed_code, AD_COUNT_SEPARATOR) !== false) { $ads = explode (AD_COUNT_SEPARATOR, $processed_code); $allow_empty = false; if (isset ($count_parameters [0]['count'])) { if (strpos (strtolower ($count_parameters [0]['count']), 'empty') !== false) { $allow_empty = true; } } if (trim ($ads [0]) == '' && !$allow_empty) { unset ($ads [0]); $ads = array_values ($ads); // $count_parameters are shifted (the first $count_parameters is for the deleted empty option) } $this->count_names = null; if ($ai_wp_data [AI_FORCE_SERVERSIDE_CODE]) { // Code for preview $processed_code = $ads [$this->count_index]; foreach ($ads as $index => $ad) $this->count_names []= $index + 1; } else { if (isset ($ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number])) { $block_counter = $ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number]; $option_index = $block_counter - 1; if (isset ($count_parameters [$block_counter - 1]['count'])) { if (strpos (strtolower ($count_parameters [$block_counter - 1]['count']), 'shuffle') !== false) { $ai_wp_data [AI_COUNT_SHUFFLE][$this->number] = $ads; shuffle ($ai_wp_data [AI_COUNT_SHUFFLE][$this->number]); } if (strpos (strtolower ($count_parameters [$block_counter - 1]['count']), 'repeat') !== false) { $ai_wp_data [AI_COUNT_REPEAT][$this->number] = true; } } if (isset ($ai_wp_data [AI_COUNT_SHUFFLE][$this->number])) { $ads = $ai_wp_data [AI_COUNT_SHUFFLE][$this->number]; } if (isset ($ai_wp_data [AI_COUNT_REPEAT][$this->number])) { $option_index = $option_index % count ($ads); } if ($option_index >= 0 && $option_index < count ($ads)) { $processed_code = $ads [$option_index]; } else { $processed_code = ''; $additional_code = ''; } } else $processed_code = $ads [rand (0, count ($ads) - 1)]; } } // [ADINSERTER ROTATE] // (Re)set option index and name $check_options_for_statistics = $this->check_statistics; $check_option_always = isset ($this->check_codes_data [0]) && empty ($this->check_codes_data [0]); if ($check_options_for_statistics) { $option_index = isset ($this->check_codes_data [$this->check_codes_index]['name']) ? $this->check_codes_data [$this->check_codes_index]['name'] : $this->check_codes_index; if ($check_option_always) { // first option with index 0 is always inserted // first check option has index 1 $this->code_version = isset ($this->check_codes_data [$this->check_codes_index]['index']) && trim ($this->check_codes_data [$this->check_codes_index]['index']) != '' ? (int) $this->check_codes_data [$this->check_codes_index]['index'] : $this->check_codes_index; $this->tracking_index = $this->code_version; $this->version_name = isset ($this->check_codes_data [$this->check_codes_index]['name']) ? $this->check_codes_data [$this->check_codes_index]['name'] : ''; } else { // first check option has index 0 => 1 $this->code_version = isset ($this->check_codes_data [$this->check_codes_index]['index']) && trim ($this->check_codes_data [$this->check_codes_index]['index']) != '' ? (int) $this->check_codes_data [$this->check_codes_index]['index'] : $this->check_codes_index + 1; $this->tracking_index = $this->code_version; $this->version_name = isset ($this->check_codes_data [$this->check_codes_index]['name']) ? $this->check_codes_data [$this->check_codes_index]['name'] : ''; } } else { // Clear for ROTATE in case of multiple block insertions (CHECK separator) $this->code_version = 0; $this->tracking_index = 0; $this->version_name = ''; } preg_match_all ('/\|rotate([0-9]+?)\|/', $processed_code, $matches); if (count ($matches [1]) != 0) { $rotate_parameters = array (); foreach ($matches [1] as $match) { // $rotate_parameters []= $ai_wp_data [AI_SHORTCODES]['rotate'][$match]; $rotate_parameters []= $this->shortcodes ['rotate'][$match]; } $processed_code = preg_replace ('/\|rotate([0-9]+?)\|/', AD_ROTATE_SEPARATOR, $processed_code); // } else if (isset ($ai_wp_data [AI_SHORTCODES]['rotate'])) $rotate_parameters = $ai_wp_data [AI_SHORTCODES]['rotate']; } else if (isset ($this->shortcodes ['rotate'])) $rotate_parameters = $this->shortcodes ['rotate']; if (strpos ($processed_code, AD_ROTATE_SEPARATOR) !== false) { $ads = explode (AD_ROTATE_SEPARATOR, $processed_code); if (!isset ($rotate_parameters)) { // using old separator |rotate| $rotate_parameters = array (); foreach ($ads as $index => $ad) { // Skip parameters for first option (it will be added with array_unshift below) if ($index == 0) continue; $rotate_parameters []= array (); } } if (trim ($ads [0]) == '') { unset ($ads [0]); $ads = array_values ($ads); } else array_unshift ($rotate_parameters, array ('name' => '')); $prepend_code = ''; $append_code = ''; $shares = false; $ctr_shares = false; $ctr_min_impressions = 1000; $ctr_days = 30; $ctr_top_share = 75; $times = false; $scheduling = false; $groups = false; $unique = false; $version_names = array (); $tracking_indexes = array (); $version_shares = array (); $version_times = array (); $version_scheduling = array (); $version_groups = array (); foreach ($rotate_parameters as $index => $rotate_parameter) { if ((isset ($rotate_parameter ['code']) && trim ($rotate_parameter ['code']) != '')) { switch (strtolower ($rotate_parameter ['code'])) { case 'prepend': $prepend_code .= $ads [$index]; unset ($ads [$index]); unset ($rotate_parameters [$index]); break; case 'append': $append_code .= $ads [$index]; unset ($ads [$index]); unset ($rotate_parameters [$index]); break; } } } $ads = array_values ($ads); $rotate_parameters = array_values ($rotate_parameters); if ($prepend_code != '') { foreach ($ads as $index => $ad) { $ads [$index] = $prepend_code . $ads [$index]; } } if ($append_code != '') { foreach ($ads as $index => $ad) { $ads [$index] .= $append_code; } } foreach ($rotate_parameters as $index => $option) { $tracking_indexes []= isset ($option ['index']) && trim ($option ['index']) != '' ? (int) $option ['index'] : $index + 1; if ((isset ($option ['group']) && trim ($option ['group']) != '') || $groups) { $groups = true; $shares = false; $times = false; $version_groups []= mb_strtolower (trim ($option ['group'])); $version_names []= isset ($option ['group']) && trim ($option ['group']) != '' ? $option ['group'] : chr (ord ('A') + $index); $version_shares []= - 1; $version_times []= - 1; $version_scheduling []= - 1; } else { $version_names []= isset ($option ['name']) && trim ($option ['name']) != '' ? $option ['name'] : chr (ord ('A') + $index); // Just in case there will be a ROTATE group option $version_groups []= ''; if (isset ($option ['share']) && strpos ($share_option = strtolower ($option ['share']), 'ctr') === 0 && function_exists ('ai_get_impressions_and_clicks')) { $ctr_options = explode (':', $share_option); if (isset ($ctr_options [1]) && $ctr_options [1] > 0 && $ctr_options [1] < 366) { $ctr_days = (int) $ctr_options [1]; } if (isset ($ctr_options [2]) && $ctr_options [2] > 1 && $ctr_options [2] < 10000000) { $ctr_min_impressions = (int) $ctr_options [2]; } if (isset ($ctr_options [3]) && $ctr_options [3] > 1 && $ctr_options [3] < 100) { $ctr_top_share = (int) $ctr_options [3]; } $shares = true; $ctr_shares = true; $version_shares []= - 1; } else { $option_share = isset ($option ['share']) && is_numeric ($option ['share']); if ($option_share) $shares = true; $version_shares []= $option_share ? intval ($option ['share']) : - 1; } $option_time = isset ($option ['time']) && is_numeric ($option ['time']); if ($option_time) $times = true; $version_times []= $option_time ? intval ($option ['time']) : - 1; $option_scheduling = isset ($option ['scheduling']) && strpos ($option ['scheduling'], '=') !== false; if ($option_scheduling) $scheduling = true; $version_scheduling []= $option_scheduling ? trim ($option ['scheduling']) : - 1; } if (isset ($option ['rotate']) && strtolower ($option ['rotate']) == 'unique') $unique = true; } if ($unique && !isset ($ai_wp_data [AI_ROTATION_SEED])) { $ai_wp_data [AI_ROTATION_SEED] = mt_rand (1, time ()) % count ($ads); } $this->rotate_names = $version_names; if ($groups) { // Clear in case there were mixed rotate options foreach ($rotate_parameters as $index => $option) { $version_shares [$index] - 1; $version_times [$index] - 1; $version_scheduling [$index] - 1; } } if ($shares) { $total_share = 0; $no_share = 0; if ($ctr_shares) { $disabled_shares = 0; foreach ($version_shares as $index => $share) { if ($share == 0) { $disabled_shares ++; } } if ($disabled_shares < count ($rotate_parameters) - 1) { // Default state (no CTR data yet) is equal shares foreach ($version_shares as $index => $share) { if ($share != 0) { $version_shares [$index] = number_format (100 / (count ($rotate_parameters) - $disabled_shares), 2); } } if (count ($rotate_parameters) > 1 && $this->get_tracking () && get_internal_tracking ()) { $tracking_data = ai_get_impressions_and_clicks ($this->number, $ctr_days, false, true); if ($tracking_data [2] >= $ctr_min_impressions) { $max_ctr = 0; $max_ctr_option = 0; foreach ($tracking_data [4] as $option => $ctr) { if ($option == 0) continue; if ($ctr > $max_ctr) { $max_ctr = $ctr; $max_ctr_option = $option; } } // We have a winner if ($max_ctr_option != 0) { foreach ($version_shares as $index => $share) { if ($version_shares [$index] != 0) { if ($index + 1 == $max_ctr_option) $version_shares [$index] = $ctr_top_share; else $version_shares [$index] = number_format ((100 - $ctr_top_share) / (count ($rotate_parameters) - $disabled_shares - 1), 2); } } } } } else $ctr_shares = false; } } foreach ($version_shares as $index => $share) { if ($share < 0) $no_share ++; else $total_share += $share; } if ($total_share > 100 || $no_share == 0) { $scale = $total_share / 100; } else $scale = 1; foreach ($version_shares as $index => $share) { // Disable options with share 0 if ($share == 0) $version_shares [$index] = - 1; else if ($share < 0) $version_shares [$index] = (100 - $total_share / $scale) / $no_share; else $version_shares [$index] = $share / $scale; } $thresholds = array (); $total_share = 0; foreach ($version_shares as $index => $share) { if ($share >= 0) { $total_share += $share; $thresholds [] = round ($total_share); } else $thresholds [] = - 1; } } if ($times) { if ($dynamic_blocks != AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW && $dynamic_blocks != AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT) $dynamic_blocks = AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW; $ai_wp_data [AI_CLIENT_SIDE_ROTATION] = true; } $rotation_dynamic_blocks = $dynamic_blocks; if ($ai_wp_data [AI_FORCE_SERVERSIDE_CODE] || ($rotation_dynamic_blocks == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW || $rotation_dynamic_blocks == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT) && $ai_wp_data [AI_WP_AMP_PAGE]) $rotation_dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE; $groups_marker = "##"; switch ($rotation_dynamic_blocks) { case AI_DYNAMIC_BLOCKS_SERVER_SIDE: if ($ai_wp_data [AI_FORCE_SERVERSIDE_CODE]) { // Code for preview if ($this->rotate_index >= count ($ads)) { $this->rotate_index = 0; } $this->code_version = $this->rotate_index + 1; } elseif ($shares) { $random_threshold = mt_rand (0, 100); foreach ($thresholds as $index => $threshold) { $this->code_version = $index + 1; if ($threshold < 0) continue; if ($random_threshold <= $threshold) break; } } elseif ($groups) { $this->code_version = 0; $processed_code = ''; $this->version_name = ''; if (count ($ai_wp_data [AI_ACTIVE_GROUP_NAMES]) != 0) { $this->check_code_empty = true; foreach ($ai_wp_data [AI_ACTIVE_GROUP_NAMES] as $group_name) { foreach ($version_groups as $index => $version_group) { if ($version_group == trim ($group_name)) { $this->code_version = $index + 1; if ($debug_processing) ai_log ('GROUP NAME FOUND: "' . trim ($group_name) . '"'); break 2; } } } if ($this->code_version == 0) { if ($debug_processing) { $this->no_insertion_text = 'GROUP NAMES NOT FOUND IN "' . $ai_wp_data [AI_ACTIVE_GROUP_NAMES] . '"'; ai_log ($this->no_insertion_text); } return ''; } $this->check_code_empty = false; } } elseif ($scheduling) { $this->code_version = 0; foreach ($version_scheduling as $index => $scheduling_data) { if (check_scheduled_rotation ($scheduling_data)) { $this->code_version = $index + 1; break; } } } else { if ($unique) { $block_counter = isset ($ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number]) ? $ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number] : 0; $this->code_version = $ai_wp_data [AI_ROTATION_SEED] + $block_counter; if ($this->code_version > count ($ads)) $this->code_version -= count ($ads); } else $this->code_version = mt_rand (1, count ($ads)); } if ($this->code_version != 0) { $processed_code = trim ($ads [$this->code_version - 1]); $this->tracking_index = $tracking_indexes [$this->code_version - 1]; $this->version_name = $version_names [$this->code_version - 1]; } if (preg_match ($groups_marker, $processed_code, $matches)) { $ai_wp_data [AI_ACTIVE_GROUP_NAMES] = array_merge ($ai_wp_data [AI_ACTIVE_GROUP_NAMES], json_decode (base64_decode ($matches [1]))); $processed_code = preg_replace ($groups_marker, '', $processed_code); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ('GROUP NAMES SET: "' . implode (', ', $ai_wp_data [AI_ACTIVE_GROUP_NAMES]) . '"'); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { $debug_list = new ai_block_labels ('ai-debug-iframe'); $processed_code = $debug_list->bar (__('ACTIVE GROUPS', 'ad-inserter') . ': ' . implode (', ', json_decode (base64_decode ($matches [1]))), '', '') . $processed_code; } } if ($processed_code == '') { $additional_code = ''; } break; case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW: case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT: $this->code_version = '""'; $this->tracking_index = '""'; $rotation_data = ''; if ($shares) { $rotation_data = " data-shares='".base64_encode (json_encode ($thresholds))."'"; } // Additional class to identify rotation code block in case of timed rotation $rotation_class = ''; if ($groups) { $rotation_class = ' ai-rotation-groups ai-'.$this->number; } if ($times) { // Add block insertion counter fo rrotation id - block might be inserted more than once and each insertion has different starting option and time $block_counter = 0; if (isset ($ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number])) { $block_counter = $ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number]; } $rotation_class .= ' ai-timed-rotation'; $rotation_class .= ' ai-'.$this->number.'-'.$block_counter; $rotation_data .= " data-info='".base64_encode ('["'.$this->number.'-'.$block_counter.'",'.count ($ads).']')."'"; } if ($scheduling) { $rotation_class .= ' ai-rotation-scheduling'; $gmt = get_option ('gmt_offset') * 3600 * 1000; $rotation_data .= " data-gmt='$gmt'"; } $processed_code = ''; if (($times || $scheduling) && !isset ($ai_wp_data [AI_CLIENT_SIDE_CSS])) { $processed_code = "\n"; } if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_AJAX) { $block_id = 'ai-rotate-' . $this->number . '-' . rand (1000, 9999) . rand (1000, 9999); $rotation_class = ' ' . $block_id . $rotation_class; } if ($unique) { $rotation_class .= ' ai-unique'; $block_counter = isset ($ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number]) ? $ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number] : 0; $rotation_data .= " data-counter='".$block_counter."'"; } if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !get_inline_styles ()) { $processed_code .= "\n
\n"; } else $processed_code .= "\n
\n"; foreach ($ads as $index => $ad) { // If AMP separator is present use only code for normal pages if (strpos ($ad, AD_AMP_SEPARATOR) !== false) { $codes = explode (AD_AMP_SEPARATOR, $ad); $ad = trim ($codes [0]); } if (strpos ($ad, AD_HEAD_SEPARATOR) !== false) { $head_body_code = explode (AD_HEAD_SEPARATOR, $ad ); $ad = trim ($head_body_code [1]); // Insert all HEAD codes for all options into section // if ($ai_wp_data [AI_SHORTCODES]['head'][0]['group'] != '') { if ($this->shortcodes ['head'][0]['group'] != '') { // $ai_wp_data [AI_HEAD_GROUPS][strtolower ($ai_wp_data [AI_SHORTCODES]['head'][0]['group'])] []= trim ($head_body_code [0]); $ai_wp_data [AI_HEAD_GROUPS][strtolower ($this->shortcodes ['head'][0]['group'])] []= trim ($head_body_code [0]); } else $ai_wp_data [AI_HEAD_CODES] []= trim ($head_body_code [0]); } $ad = $this->ai_processViewportSeparators ($ad); $ad = $this->ai_processFallbackSeparator ($ad); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { $debug_list = new ai_block_labels ('ai-debug-iframe'); if (preg_match ($groups_marker, $ad, $matches)) { $current_group_name = implode (', ', json_decode (base64_decode ($matches [1]))); } else $current_group_name = ''; $ad = preg_replace ("#()#", '$1' . $debug_list->bar (__('ACTIVE GROUPS', 'ad-inserter') . ': ' . $current_group_name, '', ''), $ad); } $tracking_index_data = ' data-index="'.$tracking_indexes [$index].'"'; $version_name_data = ' data-name="' .base64_encode ($version_names [$index]).'"'; $version_time_data = $version_times [$index] >= 0 ? ' data-time="'.base64_encode ($version_times [$index]).'"' : ''; $version_scheduling_data = $version_scheduling [$index] != - 1 ? ' data-scheduling="'.base64_encode ($version_scheduling [$index]).'"' : ''; $version_group_data = $groups ? ' data-group="'.base64_encode ($version_groups [$index]).'"' : ''; switch ($rotation_dynamic_blocks) { case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW: switch ($index) { case 0: if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !get_inline_styles ()) { $processed_code .= "
\n".trim ($ad, "\n\r")."
\n"; } else $processed_code .= "\n"; break; default: if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !get_inline_styles ()) { $processed_code .= "
\n".trim ($ad, "\n\r")."
\n"; } else $processed_code .= "\n"; break; } break; case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT: $version_code_data = ' data-code="'.base64_encode (ai_strip_js_markers ($ad)).'"'; $processed_code .= '
\n
\n"; break; } } $processed_code .= "
\n"; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME] && !get_disable_js_code ()) { // $processed_code .= "\n"; $processed_code .= "\n"; } break; case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC: if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS ROTATE'; } if ($groups) { $ad_index_code = ' global $ai_groups; $ai_index = 0; if (isset ($ai_groups) && count ($ai_groups) != 0) {foreach ($ai_groups as $group_name) {foreach (unserialize (base64_decode (\''. base64_encode (serialize ($version_groups)).'\')) as $index => $version_group) {if ($version_group == trim ($group_name)) {$ai_index = $index + 1; break 2;}}}}'; } elseif ($shares) { $ad_index_code = ' $ai_random_threshold = mt_rand (0, 100); $ai_thresholds = unserialize (\''. serialize ($thresholds).'\'); foreach ($ai_thresholds as $ai_option_index => $ai_threshold) {$ai_index = $ai_option_index + 1; if ($ai_random_threshold <= $ai_threshold) break;}'; } elseif ($scheduling) { $ad_index_code = ' $ai_index = 0; $ai_scheduling_data = unserialize (\''. serialize ($version_scheduling).'\'); foreach ($ai_scheduling_data as $ai_option_index => $ai_scheduling_data_item) {if (check_scheduled_rotation ($ai_scheduling_data_item)) {$ai_index = $ai_option_index + 1; break;}}'; } elseif ($unique) { $ad_index_code = ' if (!defined (\'AI_W3TC_ROTATION_SEED\')) define (\'AI_W3TC_ROTATION_SEED\', mt_rand (1, time ()) % '.count ($ads).');'; $ad_index_code .= ' $ai_block_counter = '.(isset ($ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number]) ? $ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $this->number] : 0).';'; $ad_index_code .= ' $ai_index = AI_W3TC_ROTATION_SEED + $ai_block_counter; if ($ai_index > '.count ($ads).') $ai_index -= '.count ($ads).';'; if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $ad_index_code .= 'ai_w3tc_log_run (\'PROCESS UNIQUE, SEED: \' . AI_W3TC_ROTATION_SEED . \', \' . $ai_block_counter);'; } } else $ad_index_code = ' $ai_index = mt_rand (1, '.count ($ads).');'; $this->w3tc_code .= '$ai_code = unserialize (base64_decode (\''.base64_encode (serialize ($ads)).'\'));'.$ad_index_code; if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= 'ai_w3tc_log_run (\'PROCESS ROTATE: \' . $ai_index);'; } $this->w3tc_code .= ' if ($ai_index != 0) {$ai_dummy1 = $ai_dummy2 = null; $ai_code = ai_w3tc_execute_php ($ai_code [$ai_index - 1], $ai_dummy1, $ai_dummy2); $ai_enabled = true;} else {$ai_code = \'\'; $ai_enabled = false;}'; // Set $ai_version_name according to $ai_index and and $ai_index to the index for tracking $this->w3tc_code .= ' if ($ai_index != 0) {$version_names = unserialize (base64_decode (\''.base64_encode (serialize ($this->rotate_names)).'\')); $ai_version_name = $version_names [$ai_index - 1]; $tracking_indexes = unserialize (base64_decode (\''.base64_encode (serialize ($tracking_indexes)).'\')); $ai_index = $tracking_indexes [$ai_index - 1];'; if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' ai_w3tc_log_run (\'TRACKING INDEX: \' . $ai_index . (isset ($ai_version_name) ? \' [\'.$ai_version_name.\']\' : \'\'));'; } $this->w3tc_code .= '}'; $this->w3tc_code .= ' if ($ai_enabled) {$groups_marker = base64_decode (\'' . base64_encode ($groups_marker) . '\'); global $ai_groups; if (preg_match ($groups_marker, $ai_code, $matches)) {if (!isset ($ai_groups)) $ai_groups = array (); $ai_groups = array_merge ($ai_groups, json_decode (base64_decode ($matches [1]))); $ai_code = preg_replace ($groups_marker, \'\', $ai_code);}}'; $processed_code = $this->generate_html_from_w3tc_code (); break; } } // [ADINSERTER AMP] // [ADINSERTER HEAD] $this->labels->class = 'ai-debug-default'; // If previously inserted block with AMP separator (multiple CHECK insertions) $amp_head_dynamic_blocks = $dynamic_blocks; if ($ai_wp_data [AI_FORCE_SERVERSIDE_CODE]) $amp_head_dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE; elseif ($amp_head_dynamic_blocks == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && $this->w3tc_code == '') $amp_head_dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE; elseif ($amp_head_dynamic_blocks == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW) $amp_head_dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE; elseif ($amp_head_dynamic_blocks == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT) $amp_head_dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE; switch ($amp_head_dynamic_blocks) { case AI_DYNAMIC_BLOCKS_SERVER_SIDE: if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) { $codes = explode (AD_AMP_SEPARATOR, $processed_code); $code_index = $ai_wp_data [AI_WP_AMP_PAGE] ? 1 : 0; $this->labels->class = $code_index ? 'ai-debug-amp' : 'ai-debug-default'; if ($code_index == 1) { ai_log ('BLOCK ' . $this->number . ' AMP CODE USED'); } $processed_code = trim ($codes [$code_index]); if ($this->empty_code ($processed_code)) { ai_log ('AMP SEPARATOR ' . ($ai_wp_data [AI_WP_AMP_PAGE] ? '[AMP]' : '[NORMAL]') . ': EMPTY CODE FOR BLOCK ' . $this->number); $this->code_empty = true; } } else { // AMP page but No AMP separator - don't insert the code unless enabled if ($ai_wp_data [AI_WP_AMP_PAGE]) { if (!$this->get_enable_amp ()) { $processed_code = ''; $additional_code = ''; $this->hide_debug_labels = true; ai_log ('BLOCK ' . $this->number . ' NOT ENABLED FOR AMP PAGES - EMPTY CODE'); $this->code_empty = true; } } } if (strpos ($processed_code, AD_HEAD_SEPARATOR) !== false) { ai_log ('BLOCK ' . $this->number . ' HEAD CODE'); $head_body_code = explode (AD_HEAD_SEPARATOR, $processed_code); $processed_code = trim ($head_body_code [1]); // $once = isset ($ai_wp_data [AI_SHORTCODES]['head'][0]['head']) && strtolower ($ai_wp_data [AI_SHORTCODES]['head'][0]['head']) == 'once'; $once = isset ($this->shortcodes ['head'][0]['head']) && strtolower ($this->shortcodes ['head'][0]['head']) == 'once'; if (!$once || !$this->head_code_written) { // if ($ai_wp_data [AI_SHORTCODES]['head'][0]['group'] != '') { if ($this->shortcodes ['head'][0]['group'] != '') { // $ai_wp_data [AI_HEAD_GROUPS][strtolower ($ai_wp_data [AI_SHORTCODES]['head'][0]['group'])] []= trim ($head_body_code [0], "\n\r"); $ai_wp_data [AI_HEAD_GROUPS][strtolower ($this->shortcodes ['head'][0]['group'])] []= trim ($head_body_code [0], "\n\r"); } else $ai_wp_data [AI_HEAD_CODES] []= trim ($head_body_code [0]); $this->head_code_written = true; } } // $processed_code = $additional_code . $processed_code; break; case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC: if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS AMP, HEAD'; } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { $this->labels->class = $ai_wp_data [AI_WP_AMP_PAGE] ? 'ai-debug-amp' : 'ai-debug-default'; } $this->w3tc_code .= '$ai_amp_separator = base64_decode (\'' . base64_encode (AD_AMP_SEPARATOR) . '\'); $ai_amp_page = ' . ($ai_wp_data [AI_WP_AMP_PAGE] ? 'true' : 'false') . '; $ai_amp_enabled = ' . $this->get_enable_amp () . ';'; $this->w3tc_code .= '$ai_dummy1 = $ai_dummy2 = null; $ai_code = ai_w3tc_execute_php ($ai_code, $ai_dummy1, $ai_dummy2);'; // Fix to prevent converting && into && on AMP pages // $this->w3tc_code .= 'if (strpos ($ai_code, $ai_amp_separator) !== false) {$codes = explode ($ai_amp_separator, $ai_code); $ai_code = trim ($codes [$ai_amp_page ? 1 : 0]); } else {if ($ai_amp_page && !$ai_amp_enabled) $ai_code = \'\';} $ai_enabled = true;'; $this->w3tc_code .= 'if (strpos ($ai_code, $ai_amp_separator) !== false) {$codes = explode ($ai_amp_separator, $ai_code); $ai_code = trim ($codes [$ai_amp_page ? 1 : 0]); } else {if ($ai_amp_page + !$ai_amp_enabled == 2) $ai_code = \'\';} $ai_enabled = true;'; if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' ai_w3tc_log_run (\'PROCESS AMP: \' . ($ai_amp_page ? \'AMP PAGE\' : \'NORMAL PAGE\'));'; } // Process HEAD separator $this->w3tc_code .= '$ai_head_separator = base64_decode (\'' . base64_encode (AD_HEAD_SEPARATOR) . '\');'; if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' ai_w3tc_log_run (\'PROCESS HEAD: \' . (strpos ($ai_code, $ai_head_separator) !== false ? \'CODE\' : \'-\'));'; } $this->w3tc_code .= 'if (strpos ($ai_code, $ai_head_separator) !== false) {$codes = explode ($ai_head_separator, $ai_code); $ai_code = trim ($codes [1]);} $ai_enabled = true;'; $processed_code = $this->generate_html_from_w3tc_code (); break; } // [ADINSERTER VIEWPORT] if ($this->w3tc_code != '') { // if (isset ($ai_wp_data [AI_SHORTCODES]['viewport'])) { if (isset ($this->shortcodes ['viewport'])) { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS VIEWPORT SEPARATORS'; } // $this->w3tc_code .= 'if ($ai_enabled) $ai_code = ai_process_viewport_separators ($ai_code, unserialize (base64_decode (\''.base64_encode (serialize ($ai_wp_data [AI_SHORTCODES]['viewport'])).'\')));'; $this->w3tc_code .= 'if ($ai_enabled) $ai_code = ai_process_viewport_separators ($ai_code, unserialize (base64_decode (\''.base64_encode (serialize ($this->shortcodes)).'\')));'; $processed_code = $this->generate_html_from_w3tc_code (); } } else $processed_code = $this->ai_processViewportSeparators ($processed_code); // [ADINSERTER FALLBACK] if ($this->w3tc_code != '') { if (isset ($this->shortcodes ['fallback'])) { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS FALLBACK SEPARATOR'; } $this->w3tc_code .= 'if ($ai_enabled) $ai_code = ai_process_fallback_separator ($ai_code, unserialize (base64_decode (\''.base64_encode (serialize ($this->shortcodes)).'\')));'; $processed_code = $this->generate_html_from_w3tc_code (); } } else $processed_code = $this->ai_processFallbackSeparator ($processed_code); } if ($this->check_block) { $this->check_block_additional_code = $additional_code; $additional_code = ''; } // Additional code (Ad label, close button, parallax backgrounds) if ($dynamic_blocks == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && $this->w3tc_code != '' && !defined ('AI_NO_W3TC') && $additional_code != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS ADDITIONAL CODE'; } $this->w3tc_code .= 'if ($ai_code != \'\') $ai_code = base64_decode (\''.base64_encode ($additional_code).'\') . $ai_code;'; $processed_code = $this->generate_html_from_w3tc_code (); } else $processed_code = $additional_code . $processed_code; if (!$ai_wp_data [AI_CODE_FOR_IFRAME] && !$ai_wp_data [AI_FORCE_SERVERSIDE_CODE]) { // PROTECTED if (function_exists ('ai_process_protected_code')) $processed_code = ai_process_protected_code ($this, $processed_code); // LAZY LOADING if ($this->get_lazy_loading () && !$ai_wp_data [AI_WP_AMP_PAGE]) { if ($this->w3tc_code != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS LAZY LOADING'; } } $lazy_code = $this->base64_encode_w3tc ($processed_code); $wrapper_class = base64_encode (get_block_class_name (true)); $processed_code = '
'."\n"; // Recreate W3TC code if ($this->w3tc_code != '') { $processed_code = $this->regenerate_w3tc_code ($processed_code); } } // MANUAL LOADING ENABLED if ($this->get_manual_loading () == AI_MANUAL_LOADING_ENABLED && !$ai_wp_data [AI_WP_AMP_PAGE]) { if ($this->w3tc_code != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS MANUAL LOADING ALWAYS'; } } $manual_code = $this->base64_encode_w3tc ($processed_code); $wrapper_class = base64_encode (get_block_class_name (true)); $processed_code = '
'."\n"; // Recreate W3TC code if ($this->w3tc_code != '') { $processed_code = $this->regenerate_w3tc_code ($processed_code); } } } if ($not_iframe_or_inside) { if (function_exists ('ai_adb_check') && !$ai_wp_data [AI_FORCE_SERVERSIDE_CODE] && $not_iframe_or_inside) $processed_code = ai_adb_check ($this, $processed_code); // Reset if multiple block insertions $this->client_side_list_detection = false; $lists_dynamic_blocks = $dynamic_blocks; // replace with $this->server_side_check if ($ai_wp_data [AI_FORCE_SERVERSIDE_CODE] || ($lists_dynamic_blocks == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW || $lists_dynamic_blocks == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT) && $ai_wp_data [AI_WP_AMP_PAGE]) $lists_dynamic_blocks = AI_DYNAMIC_BLOCKS_SERVER_SIDE; // LISTS, COOKIE, SCHEDULING if ($lists_dynamic_blocks != AI_DYNAMIC_BLOCKS_SERVER_SIDE) { // Url parameters, cookies, referrers, clients do { $scheduling_start_time = ''; $scheduling_end_time = ''; $scheduling_days_in_week = ''; $scheduling_type = null; $scheduling_fallback_block = 0; $check_again = false; if (isset ($this->check_url_parameters) || isset ($this->check_cookies) || isset ($this->check_referers) || isset ($this->check_clients) || isset ($this->check_scheduling_start_time)) { $url_parameters_raw = ''; $url_parameter_list_type = ''; $cookies_raw = ''; $cookie_list_type = ''; $referers_raw = ''; $referer_list_type = ''; $clients_raw = ''; $client_list_type = ''; if (isset ($this->check_url_parameters)) { $url_parameters_raw = trim ($this->check_url_parameters); $url_parameter_list_type = $this->check_url_parameter_list_type; } if (isset ($this->check_cookies)) { $cookies_raw = trim ($this->check_cookies); $cookie_list_type = $this->check_cookie_list_type; } if (isset ($this->check_referers)) { $referers_raw = trim (str_replace (' ', '', strtolower ($this->check_referers))); $referer_list_type = $this->check_referers_list_type; } if (isset ($this->check_clients)) { // $clients_raw = trim (str_replace (' ', '', strtolower ($this->check_clients))); $clients_raw = trim ($this->check_clients); $client_list_type = $this->check_clients_list_type; } if (isset ($this->check_scheduling_start_time)) { $scheduling_start_time_raw = trim ($this->check_scheduling_start_time); $scheduling_start_time = base64_encode ($scheduling_start_time_raw); $scheduling_end_time_raw = trim ($this->check_scheduling_end_time); $scheduling_end_time = base64_encode ($scheduling_end_time_raw); $scheduling_days_in_week_raw = $this->check_scheduling_days_in_week; $scheduling_days_in_week = base64_encode ($scheduling_days_in_week_raw); $scheduling_type = $this->check_scheduling_type; $scheduling_fallback_block = $this->check_scheduling_fallback_block; } unset ($this->check_url_parameters); unset ($this->check_url_parameter_list_type); unset ($this->check_cookies); unset ($this->check_cookie_list_type); unset ($this->check_referers); unset ($this->check_referers_list_type); unset ($this->check_clients); unset ($this->check_clients_list_type); unset ($this->check_scheduling_start_time); unset ($this->check_scheduling_end_time); unset ($this->check_scheduling_days_in_week); unset ($this->check_scheduling_type); unset ($this->check_scheduling_fallback_block); $check_again = true; } else { $url_parameters_raw = trim ($this->get_url_parameter_list ()); $url_parameter_list_type = $this->get_url_parameter_list_type (); $cookies_raw = trim ($this->get_cookie_list ()); $cookie_list_type = $this->get_cookie_list_type (); $referers_raw = trim (str_replace (' ', '', strtolower ($this->get_ad_domain_list ()))); $referer_list_type = $this->get_ad_domain_list_type (); // $clients_raw = trim (str_replace (' ', '', strtolower ($this->get_client_list ()))); $clients_raw = trim ($this->get_client_list ()); $client_list_type = $this->get_client_list_type (); switch ($this->get_scheduling ()) { case AI_SCHEDULING_BETWEEN_DATES: case AI_SCHEDULING_OUTSIDE_DATES: $scheduling_start_time_raw = trim ($this->get_schedule_start_date () . ' ' . $this->get_schedule_start_time ()); $scheduling_start_time = base64_encode ($scheduling_start_time_raw); $scheduling_end_time_raw = trim ($this->get_schedule_end_date () . ' ' . $this->get_schedule_end_time ()); $scheduling_end_time = base64_encode ($scheduling_end_time_raw); $scheduling_days_in_week_raw = $this->get_schedule_weekdays (); $scheduling_days_in_week = base64_encode ($scheduling_days_in_week_raw); $scheduling_type = $this->get_scheduling(); $scheduling_fallback_block = intval ($this->get_scheduling_fallback()); break; } } $url_parameters = base64_encode (html_entity_decode ($url_parameters_raw)); $cookies = base64_encode (html_entity_decode ($cookies_raw)); $referers = base64_encode ($referers_raw); $clients = base64_encode (html_entity_decode ($clients_raw)); if (($this->client_side_cookie_check_url && $url_parameters != '') || ($this->client_side_cookie_check && $cookies != '') || $referers != '' || $clients != '' || $scheduling_type !== null) { switch ($dynamic_blocks) { case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW: case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT: if ($url_parameter_list_type == AI_BLACK_LIST) $url_parameter_list_type = 'B'; else $url_parameter_list_type = 'W'; if ($cookie_list_type == AI_BLACK_LIST) $cookie_list_type = 'B'; else $cookie_list_type = 'W'; if ($referer_list_type == AI_BLACK_LIST) $referer_list_type = 'B'; else $referer_list_type = 'W'; if ($client_list_type == AI_BLACK_LIST) $client_list_type = 'B'; else $client_list_type = 'W'; if ($scheduling_type == AI_SCHEDULING_OUTSIDE_DATES) { $scheduling_type_code = 'B'; $scheduling_type_text = 'OUT'; } else { $scheduling_type_code = 'W'; $scheduling_type_text = 'IN'; } $gmt = get_option ('gmt_offset') * 3600 * 1000; $fallback_code = ''; $fallback_code_data = ''; $fallback_block_data = 0; $fallback_level = ''; $fallback_tracking_data = ''; if ($scheduling_type !== null) { $fallback_block = $scheduling_fallback_block; if ($fallback_block != $this->number && $fallback_block >= 1 && $fallback_block <= 96) { $globals_name = AI_FALLBACK_DEPTH_NAME; if (!isset ($ad_inserter_globals [$globals_name])) { $ad_inserter_globals [$globals_name] = 0; } if ($ad_inserter_globals [$globals_name] < 3) { $ad_inserter_globals [$globals_name] ++; $fallback_level = $ad_inserter_globals [$globals_name]; $fallback_block_data = $fallback_block; $fallback_obj = $block_object [$fallback_block]; $fallback_code = $fallback_obj->ai_getProcessedCode (); $fallback_code_data = " data-fallback-code='" . base64_encode ($fallback_code) . "'"; $fallback_tracking_block = $fallback_obj->get_tracking () ? $fallback_obj->number : 0; // $fallback_tracking_data = base64_encode ("[{$fallback_tracking_block},{$fallback_obj->code_version},\"{$fallback_obj->get_ad_name ()}\",\"{$fallback_obj->version_name}\"]"); $fallback_tracking_data = base64_encode ("[{$fallback_tracking_block},{$fallback_obj->tracking_index},\"{$fallback_obj->get_ad_name ()}\",\"{$fallback_obj->version_name}\"]"); $ad_inserter_globals [$globals_name] --; } } } if ($this->client_side_cookie_check_url && $url_parameters != '') $url_parameter_attributes = " parameter-list='$url_parameters' parameter-list-type='$url_parameter_list_type'"; else $url_parameter_attributes = ''; if ($this->client_side_cookie_check && $cookies != '') $cookie_attributes = " cookie-list='$cookies' cookie-list-type='$cookie_list_type'"; else $cookie_attributes = ''; if ( $referers != '') $referer_attributes = " referer-list='$referers' referer-list-type='$referer_list_type'"; else $referer_attributes = ''; if ( $clients != '') $client_attributes = " client-list='$clients' client-list-type='$client_list_type'"; else $client_attributes = ''; if ($scheduling_type !== null ) $scheduling_attributes = " scheduling-start='$scheduling_start_time' scheduling-end='$scheduling_end_time' scheduling-days='$scheduling_days_in_week' scheduling-type='$scheduling_type_code' gmt='$gmt' scheduling-fallback='$fallback_block_data' fallback_level='$fallback_level' fallback-tracking='$fallback_tracking_data'"; else $scheduling_attributes = ''; // Deprecated $this->client_side_list_detection = true; // ??? If $ai_wp_data [AI_WP_AMP_PAGE] is set it will not get here if ($ai_wp_data [AI_WP_AMP_PAGE]) $this->needs_class = true; // Hide block only when no block height is defined - for check options don't hide the first one if (trim ($this->get_block_height ()) == '' || isset ($this->check_codes) && $this->check_codes_index != 0) { $this->wrapping_div_classes []= 'ai-list-block'; } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { $debug_id = 'ai-debug-info-' . $this->number . '-' . rand (1000, 9999) . rand (1000, 9999); $debug_id_data = " data-debug-info='$debug_id'"; } else $debug_id_data = ''; switch ($dynamic_blocks) { case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW: if (($url_parameter_attributes != '' || $cookie_attributes != '') && $this->get_manual_loading () == AI_MANUAL_LOADING_AUTO) { $list_class = ' ai-list-manual'; } else $list_class = ''; $processed_code = "\n
{$processed_code}
\n"; if ($scheduling_type !== null) { $processed_code .= "
{$fallback_code}
\n"; } break; case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT: $code_data = " data-code='".base64_encode ($processed_code)."'"; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { $block_id = 'ai-list-' . $this->number . '-' . rand (1000, 9999) . rand (1000, 9999); $list_class = ' ' . $block_id ; } else $list_class = ''; if (($url_parameter_attributes != '' || $cookie_attributes != '') && $this->get_manual_loading () == AI_MANUAL_LOADING_AUTO) { $list_class .= ' ai-list-manual'; } $processed_code = "\n
\n"; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME] && !get_disable_js_code ()) { // $processed_code .= "\n"; $processed_code .= "\n"; } break; } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { if ($scheduling_type !== null) { $scheduling_attributes_dbg = sprintf (__ ("start='%s' end='%s' days='%s' type='%s'", 'ad-inserter'), $scheduling_start_time_raw, $scheduling_end_time_raw, $scheduling_days_in_week_raw, $scheduling_type_text); $debug_scheduling = new ai_block_labels ('ai-debug-scheduling'); $debug_processed_code = $debug_scheduling->bar ($scheduling_attributes_dbg, 'OUT = ' . AI_TEXT_INSERT_OUTSIDE_DATES .', IN = ' . AI_TEXT_INSERT_BETWEEN_DATES, '', ''); $processed_code = $debug_processed_code . $processed_code; } if ($this->client_side_cookie_check_url && ($url_parameters != '')) $url_parameter_attributes_dbg = sprintf (__ ("parameters='%s' type='%s'", 'ad-inserter'), $url_parameters_raw, $url_parameter_list_type); else $url_parameter_attributes_dbg = ''; if ($this->client_side_cookie_check && ($cookies != '')) $cookie_attributes_dbg = sprintf (__ ("cookies='%s' type='%s'", 'ad-inserter'), $cookies_raw, $cookie_list_type); else $cookie_attributes_dbg = ''; // translators: %s: list parameters and type if ( $referers != '') $referer_attributes_dbg = sprintf (__ ("referers='%s' type='%s'", 'ad-inserter'), $referers_raw, $referer_list_type); else $referer_attributes_dbg = ''; // translators: %s: list parameters and type if ( $clients != '') $client_attributes_dbg = sprintf (__ ("clients='%s' type='%s'", 'ad-inserter'), $clients_raw, $client_list_type); else $client_attributes_dbg = ''; if ($url_parameter_attributes_dbg != '' || $cookie_attributes_dbg != '' || $referer_attributes_dbg != '' || $client_attributes_dbg) { $debug_list = new ai_block_labels ('ai-debug-lists'); $debug_processed_code = $debug_list->bar ($url_parameter_attributes_dbg . ' ' . $cookie_attributes_dbg . ' ' . $referer_attributes_dbg . ' ' . $client_attributes_dbg, 'B = ' . AI_TEXT_BLACK_LIST .', W = ' . AI_TEXT_WHITE_LIST, '', ''); $processed_code = $debug_processed_code . $processed_code; } if ($url_parameter_attributes_dbg != '' && ($this->get_manual_loading () == AI_MANUAL_LOADING_AUTO || strpos ($url_parameters_raw, 'tcf-') !== false || strpos ($url_parameters_raw, 'euconsent-v2') !== false) || $cookie_attributes_dbg != '' && ($this->get_manual_loading () == AI_MANUAL_LOADING_AUTO || strpos ($cookies_raw, 'tcf-') !== false || strpos ($cookies_raw, 'euconsent-v2') !== false)) { $debug_manual_loading = new ai_block_labels ('ai-debug-lists'); $version_name = $this->version_name == '' ? '' : ' - ' . $this->version_name; $block_name = $this->number . '   ' . $this->get_ad_name () . '' . $version_name . ''; $status = $this->get_manual_loading () == AI_MANUAL_LOADING_AUTO ? 'MANUAL LOADING' : 'NOT ENABLED'; // Debugging label before the hidden block in case manual loading is set to Auto and the block has not been enabled yet $this->additional_code_before_block = $debug_manual_loading->bar ($block_name, '', 'NOT LOADED', $status, '', $debug_id); } } break; case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC: if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS LISTS'; } $this->generate_w3tc_code_from_html ($processed_code); if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' ai_w3tc_log_run (\'PROCESS LISTS\' . ($ai_enabled ? \'\' : \', NOT ENABLED\'));'; } if ($referers != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' if ($ai_enabled) ai_w3tc_log_run (\' REFERRERS: \\\'\' . base64_decode (\'' . $referers . '\').\'\\\' ' . ($referer_list_type == AI_WHITE_LIST ? 'W':'B'). '\');'; $w3tc_status = ' if (!$ai_enabled) ai_w3tc_log_run (\' FAILED\', \'color: red;\');'; } else $w3tc_status = ''; $this->w3tc_code .= ' if ($ai_enabled) {$ai_enabled = check_referer_list (base64_decode (\''.$referers.'\'), '.($referer_list_type == AI_WHITE_LIST ? 'true':'false').');'.$w3tc_status.'};'; } if ($clients != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' if ($ai_enabled) ai_w3tc_log_run (\' CLIENTS: \\\'\' . base64_decode (\'' . $clients . '\').\'\\\' ' . ($client_list_type == AI_WHITE_LIST ? 'W':'B'). '\');'; $w3tc_status = ' if (!$ai_enabled) ai_w3tc_log_run (\' FAILED\', \'color: red;\');'; } else $w3tc_status = ''; $this->w3tc_code .= ' if ($ai_enabled) {$ai_enabled = check_client_list (base64_decode (\''.$clients.'\'), '.($client_list_type == AI_WHITE_LIST ? 'true':'false').');'.$w3tc_status.'};'; } if ($this->client_side_cookie_check_url) { if ($url_parameters != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' if ($ai_enabled) ai_w3tc_log_run (\' URL PARAMETERS: \\\'\' . base64_decode (\'' . $url_parameters . '\').\'\\\' ' . ($url_parameter_list_type == AI_WHITE_LIST ? 'W':'B'). '\');'; $w3tc_status = ' if (!$ai_enabled) ai_w3tc_log_run (" FAILED", "color: red;");'; } else $w3tc_status = ''; $this->w3tc_code .= ' if ($ai_enabled) {$ai_enabled = check_cookie_list (base64_decode (\''.$url_parameters.'\'), '.($url_parameter_list_type == AI_WHITE_LIST ? 'true':'false').');'.$w3tc_status.'};'; } } if ($this->client_side_cookie_check) { if ($cookies != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' if ($ai_enabled) ai_w3tc_log_run (\' COOKIES: \\\'\' . base64_decode (\'' . $cookies . '\').\'\\\' ' . ($cookie_list_type == AI_WHITE_LIST ? 'W':'B'). '\');'; $w3tc_status = ' if (!$ai_enabled) ai_w3tc_log_run (" FAILED", "color: red;");'; } else $w3tc_status = ''; $this->w3tc_code .= ' if ($ai_enabled) {$ai_enabled = check_cookie_list (base64_decode (\''.$cookies.'\'), '.($cookie_list_type == AI_WHITE_LIST ? 'true':'false').');'.$w3tc_status.'};'; } } if ($scheduling_type !== null) { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' if ($ai_enabled) ai_w3tc_log_run (\' SCHEDULING: \' . base64_decode (\'' . $scheduling_start_time . '\') . \', \' . base64_decode (\'' . $scheduling_end_time . '\'). \' [\' . base64_decode (\'' . $scheduling_days_in_week . '\') . \'] ' . ($scheduling_type == AI_SCHEDULING_BETWEEN_DATES ? 'IN':'OUT'). '\');'; $w3tc_status = ' if (!$ai_enabled) ai_w3tc_log_run (\' FAILED\', \'color: red;\');'; } else $w3tc_status = ''; $fallback_block = intval ($this->get_scheduling_fallback()); if ($fallback_block != $this->number && $fallback_block >= 1 && $fallback_block <= 96) { $fallback_obj = $block_object [$fallback_block]; $fallback_obj->hide_debug_labels = true; $fallback_block_code = base64_encode ($fallback_obj->ai_getProcessedCode ()); // Encode HTML + W3TC PHP $fallback_obj->hide_debug_labels = false; if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $w3tc_fallback_status = ' ai_w3tc_log_run (\' FALLBACK BLOCK: ' . $fallback_block . '\');'; array_unshift ($fallback_obj->w3tc_debug, 'FALLBACK BLOCK ' . $fallback_block); $fallback_obj->w3tc_debug []= 'FALLBACK BLOCK END'; $this->w3tc_debug = array_merge ($this->w3tc_debug, $fallback_obj->w3tc_debug); } else $w3tc_fallback_status = ''; if ($fallback_obj->get_tracking ()) { $fallback_tracking_block = $fallback_block; } else $fallback_tracking_block = '0'; $fallback_code = ' if (!$ai_enabled) {'.$w3tc_fallback_status.' $ai_enabled = true; if (!isset ($ai_index)) $ai_index = 0; $ai_fallback = '.$fallback_tracking_block.'; $ai_code = ai_w3tc_execute_php (base64_decode (\''. $fallback_block_code . '\'), $ai_index, $ai_fallback);}'; } else $fallback_code = ''; $this->w3tc_code .= ' if ($ai_enabled) {$ai_enabled = check_scheduling_time (base64_decode (\''. $scheduling_start_time.'\'), base64_decode (\''.$scheduling_end_time.'\'), base64_decode (\''.$scheduling_days_in_week.'\'), '.($scheduling_type == AI_SCHEDULING_BETWEEN_DATES ? 'true':'false').');' . $w3tc_status . $fallback_code . '};'; } $processed_code = $this->generate_html_from_w3tc_code (); break; } } } while ($check_again); // Countries, IP addresses do { $check_again = false; if (isset ($this->check_countries) || isset ($this->check_ip_addresses)) { $countries = ''; $country_list_type = ''; $ip_addresses = ''; $ip_address_list_type = ''; if (isset ($this->check_countries)) { $countries = trim (strtoupper ($this->check_countries)); $country_list_type = $this->check_countries_list_type; } if (isset ($this->check_ip_addresses)) { $ip_addresses = trim (str_replace (' ', '', strtolower ($this->check_ip_addresses))); $ip_address_list_type = $this->check_ip_addresses_list_type; } unset ($this->check_countries); unset ($this->check_countries_list_type); unset ($this->check_ip_addresses); unset ($this->check_ip_addresses_list_type); $check_again = true; } else { $countries = trim (strtoupper ($this->get_ad_country_list (true))); $country_list_type = $this->get_ad_country_list_type (); $ip_addresses = trim (str_replace (' ', '', strtolower ($this->get_ad_ip_address_list ()))); $ip_address_list_type = $this->get_ad_ip_address_list_type (); } // $countries = trim (strtoupper (isset ($this->check_countries) ? $this->check_countries : $this->get_ad_country_list (true))); // $country_list_type = isset ($this->check_countries_list_type) ? $this->check_countries_list_type : $this->get_ad_country_list_type (); // $ip_addresses = trim (str_replace (' ', '', strtolower (isset ($this->check_ip_addresses) ? $this->check_ip_addresses : $this->get_ad_ip_address_list ()))); // $ip_address_list_type = isset ($this->check_ip_addresses_list_type) ? $this->check_ip_addresses_list_type : $this->get_ad_ip_address_list_type (); if ($countries != '' || $ip_addresses != '') { switch ($dynamic_blocks) { case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW: case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT: if ($country_list_type == AI_BLACK_LIST) $country_list_type = 'B'; else $country_list_type = 'W'; if ($ip_address_list_type == AI_BLACK_LIST) $ip_address_list_type = 'B'; else $ip_address_list_type = 'W'; if ($countries != '') $country_attributes = "countries='$countries' country-list='$country_list_type'"; else $country_attributes = ''; if ($ip_addresses != '') $ip_address_attributes = "ip-addresses='$ip_addresses' ip-address-list='$ip_address_list_type'"; else $ip_address_attributes = ''; // Deprecated $this->client_side_list_detection = true; // ??? If $ai_wp_data [AI_WP_AMP_PAGE] is set it will not get here if ($ai_wp_data [AI_WP_AMP_PAGE]) $this->needs_class = true; // Hide block only when no block height is defined - for check options don't hide the first one if (trim ($this->get_block_height ()) == '' || isset ($this->check_codes) && $this->check_codes_index != 0) { $this->wrapping_div_classes []= 'ai-list-block-ip'; } switch ($dynamic_blocks) { case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW: $processed_code = "\n
$processed_code
\n"; break; case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT: $code_data = "data-code='".base64_encode ($processed_code)."'"; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { $block_id = 'ai-ip-' . $this->number . '-' . rand (1000, 9999) . rand (1000, 9999); $ip_class = ' ' . $block_id ; } else $ip_class = ''; $processed_code = "\n
\n"; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME] && function_exists ('add_footer_inline_scripts_2') && !get_disable_js_code ()) { // $processed_code .= "\n"; $processed_code .= "\n"; } break; } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { // translators: %s: list parameters and type if ($countries != '' ) $country_attributes_dbg = sprintf (__("countries='%s' type='%s'", 'ad-inserter'), $countries, $country_list_type); else $country_attributes_dbg = ''; // translators: %s: list parameters and type if ($ip_addresses != '' ) $ip_address_attributes_dbg = sprintf (__("ip addresses='%s' type='%s'", 'ad-inserter'), $ip_addresses, $ip_address_list_type); else $ip_address_attributes_dbg = ''; $debug_ip = new ai_block_labels ('ai-debug-lists'); $processed_code = $debug_ip->bar ($country_attributes_dbg . ' ' . $ip_address_attributes_dbg, 'B = ' . AI_TEXT_BLACK_LIST .', W = ' . AI_TEXT_WHITE_LIST, '', '') . $processed_code; } break; case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC: if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS IP ADDRESSES'; } $this->generate_w3tc_code_from_html ($processed_code); $this->w3tc_code .= ' require_once \''.AD_INSERTER_PLUGIN_DIR.'includes/geo/Ip2Country.php\';'; if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' if ($ai_enabled) ai_w3tc_log_run (\'PROCESS IP ADDRESSES\' . ($ai_enabled ? \'\' : \', NOT ENABLED\'));'; } if ($ip_addresses != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' if ($ai_enabled) ai_w3tc_log_run (\' IP ADDRESSES: \\\'\' . base64_decode (\'' . base64_encode ($ip_addresses) . '\').\'\\\' ' . ($ip_address_list_type == AI_WHITE_LIST ? 'W':'B'). '\');'; $w3tc_status = ' if (!$ai_enabled) ai_w3tc_log_run (\' FAILED\', \'color: red;\');'; } else $w3tc_status = ''; $this->w3tc_code .= ' if ($ai_enabled) {$ai_enabled = check_ip_address_list (base64_decode (\''.base64_encode ($ip_addresses).'\'), '.($ip_address_list_type == AI_WHITE_LIST ? 'true':'false').');'.$w3tc_status.'};'; } if ($countries != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' if ($ai_enabled) ai_w3tc_log_run (\' COUNTRIES: \\\'\' . base64_decode (\'' . base64_encode ($countries) . '\').\'\\\' ' . ($country_list_type == AI_WHITE_LIST ? 'W':'B'). '\');'; $w3tc_status = ' if (!$ai_enabled) ai_w3tc_log_run (\' FAILED\', \'color: red;\');'; } else $w3tc_status = ''; $this->w3tc_code .= ' if ($ai_enabled) {$ai_enabled = check_country_list (base64_decode (\''.base64_encode ($countries).'\'), '.($country_list_type == AI_WHITE_LIST ? 'true':'false').');'.$w3tc_status.'};'; } $processed_code = $this->generate_html_from_w3tc_code (); break; } } } while ($check_again); } // Viewports if (!$ai_wp_data [AI_FORCE_SERVERSIDE_CODE] && !$ai_wp_data [AI_WP_AMP_PAGE]) { $viewports_code = false; do { $check_again = false; if (isset ($this->check_viewports)) { $viewports = $this->check_viewports; $viewport_list_type = $this->check_viewports_list_type; unset ($this->check_viewports); unset ($this->check_viewports_list_type); // Not needed as only check possible is from the CHECK separator // $check_again = true; } else { $viewports = ''; $viewport_list_type = ''; } if ($viewports != '') { $separator_viewports = explode (',', strtolower ($viewports)); foreach ($separator_viewports as $index => $separator_viewport) { $separator_viewports [$index] = trim ($separator_viewport); } $viewport_classes = ''; $invisible_viewport_classes = ''; for ($viewport = 1; $viewport <= 6; $viewport ++) { $viewport_name = strtolower (get_viewport_name ($viewport)); $viewport_width = get_viewport_width ($viewport); if ($viewport_name != '') { $viewport_found = in_array ($viewport_name, $separator_viewports); if ($viewport_list_type == AI_BLACK_LIST) { $viewport_found = !$viewport_found; } if ($viewport_found) { $viewport_classes .= " ai-viewport-" . $viewport; } else { $invisible_viewport_classes .= " ai-viewport-" . $viewport; } } } if ($ai_wp_data [AI_CODE_FOR_IFRAME]) { $viewport_classes = ''; $invisible_viewport_classes = 'ai-viewport-0'; } elseif ($viewport_classes == '') { $viewport_classes = 'ai-viewport-0'; $invisible_viewport_classes = ''; } elseif ($invisible_viewport_classes == '') { $viewport_classes = ''; $invisible_viewport_classes = 'ai-viewport-0'; } $viewport_classes = trim ($viewport_classes); $invisible_viewport_classes = trim ($invisible_viewport_classes); if ($viewport_classes != '') { $viewport_class = " class='" . $viewport_classes . "'"; } else $viewport_class = ''; $invisible_label = ''; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { if ($viewport_list_type == AI_BLACK_LIST) $list_type = 'B'; else $list_type = 'W'; $invisible_label_classes = $dynamic_blocks == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT ? '' : $invisible_viewport_classes; $invisible_debug_viewport = new ai_block_labels ('ai-debug-viewport-invisible '. $invisible_label_classes); $invisible_label = $invisible_debug_viewport->bar (sprintf (__("viewport='%s' type='%s'", 'ad-inserter'), $viewports, $list_type), '', _x('HIDDEN', 'Block', 'ad-inserter'), ' '); $debug_viewport = new ai_block_labels ('ai-debug-lists'); $processed_code = $debug_viewport->bar (sprintf (__("viewport='%s' type='%s'", 'ad-inserter'), $viewports, $list_type), '', _x('VISIBLE', 'Block', 'ad-inserter'), ' ') . $processed_code; } $viewports_code = true; // All viewports selected if ($viewport_classes == '' && $invisible_viewport_classes == 'ai-viewport-0') { // $processed_code already contains code for isnertion } else // No viewport selected if ($viewport_classes == 'ai-viewport-0' && $invisible_viewport_classes == '') { $processed_code = $invisible_label; } else if ($dynamic_blocks == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT) { $class_id = 'ai-insert-' . $this->number . '-' . rand (1000, 9999) . rand (1000, 9999); if ($viewport_classes != '') { $viewport_classes = 'ai-viewports ' . $viewport_classes; } $ai_code = $this->base64_encode_w3tc (ai_strip_w3tc_markers ($processed_code), false); // Use W3TC code in case W3TC was used before and insert was specified for CHECK $processed_code = "
\n"; if (!get_disable_js_code ()) { $js_code = "ai_insert_list_code ('{$class_id}');"; $processed_code .= $this->ai_js_dom_ready ($js_code); if ($invisible_label != '') { if ($invisible_viewport_classes != '') { $invisible_viewport_classes = 'ai-viewports ' . $invisible_viewport_classes . ' '; } $ai_dbg_code = base64_encode ($invisible_label); $processed_code .= "
\n"; $js_code = "ai_insert_code_by_class ('{$class_id}-dbg');"; $processed_code .= $this->ai_js_dom_ready ($js_code); } } } else { if ($this->get_alignment_type () == AI_ALIGNMENT_NO_WRAPPING || $invisible_label != '') { if ($viewport_class != '') { $processed_code = $invisible_label . "\n" . $processed_code . "\n
\n"; } else $processed_code = $invisible_label . $processed_code; } else $this->wrapping_div_classes = array_merge ($this->wrapping_div_classes, explode (' ', $viewport_classes)); } } } while ($check_again); // Recreate W3TC code if ($viewports_code && $this->w3tc_code != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS VIEWPORT CHECKS'; } $processed_code = $this->regenerate_w3tc_code ($processed_code); } } // LIMITS + COOKIE if ($check_block_code && !$ai_wp_data [AI_FORCE_SERVERSIDE_CODE] && !$ai_wp_data [AI_WP_AMP_PAGE]) { // Check for cookie if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && !defined ('AI_NO_W3TC')) { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS LIMITS AND COOKIE'; $this->generate_w3tc_code_from_html ($processed_code); $this->w3tc_code .= 'if ($ai_enabled) ai_w3tc_log_run (\'PROCESS LIMITS AND COOKIE\');'; $w3tc_status = ' if (!$ai_enabled) ai_w3tc_log_run (\' FAILED\', \'color: red;\');'; } else $w3tc_status = ''; $fallback_block = intval ($this->get_limits_fallback ()); if ($fallback_block != $this->number && $fallback_block >= 1 && $fallback_block <= 96) { $fallback_obj = $block_object [$fallback_block]; $fallback_obj->hide_debug_labels = true; $fallback_block_code = base64_encode ($fallback_obj->ai_getProcessedCode ()); // Encode HTML + W3TC PHP $fallback_obj->hide_debug_labels = false; if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $w3tc_fallback_status = ' ai_w3tc_log_run (\' FALLBACK BLOCK: ' . $fallback_block . '\');'; array_unshift ($fallback_obj->w3tc_debug, 'FALLBACK BLOCK ' . $fallback_block); $fallback_obj->w3tc_debug []= 'FALLBACK BLOCK END'; $this->w3tc_debug = array_merge ($this->w3tc_debug, $fallback_obj->w3tc_debug); } else $w3tc_fallback_status = ''; if ($fallback_obj->get_tracking ()) { $fallback_tracking_block = $fallback_block; } else $fallback_tracking_block = '0'; $fallback_code = ' if (!$ai_enabled) {'.$w3tc_fallback_status.' $ai_enabled = true; if (!isset ($ai_index)) $ai_index = 0; $ai_fallback = '.$fallback_tracking_block.'; $ai_code = ai_w3tc_execute_php (base64_decode (\''. $fallback_block_code . '\'), $ai_index, $ai_fallback);}'; } else $fallback_code = ''; $this->generate_w3tc_code_from_html ($processed_code); $this->w3tc_code .= $ai_check_block_w3tc_code; $this->w3tc_code .= 'if ($ai_enabled) {$ai_enabled = ai_check_impression_and_click_limits (' . $this->number . ', false); if ($ai_enabled) {$ai_enabled = ai_check_block (' . $this->number . ');}; '. $w3tc_status . $fallback_code . '};'; $processed_code = $this->generate_html_from_w3tc_code (); } else { $debug_html_code = ''; $block_id = $this->number . '-' . rand (1000, 9999) . rand (1000, 9999); $fallback_data = ''; $fallback_block = $this->get_limits_fallback (); if ($fallback_block != $this->number && $fallback_block >= 1 && $fallback_block <= 96) { $globals_name = AI_FALLBACK_DEPTH_NAME; if (!isset ($ad_inserter_globals [$globals_name])) { $ad_inserter_globals [$globals_name] = 0; } if ($ad_inserter_globals [$globals_name] < 3) { $ad_inserter_globals [$globals_name] ++; $fallback_level = $ad_inserter_globals [$globals_name]; $fallback_obj = $block_object [$fallback_block]; $fallback_code = $fallback_obj->ai_getProcessedCode (); $fallback_tracking_block = $fallback_obj->get_tracking () ? $fallback_obj->number : 0; // $fallback_tracking_data = base64_encode ("[{$fallback_tracking_block},{$fallback_obj->code_version},\"{$fallback_obj->get_ad_name ()}\",\"{$fallback_obj->version_name}\"]"); $fallback_tracking_data = base64_encode ("[{$fallback_tracking_block},{$fallback_obj->tracking_index},\"{$fallback_obj->get_ad_name ()}\",\"{$fallback_obj->version_name}\"]"); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { $debug_fallback = new ai_block_labels ('ai-debug-fallback'); $debug_fallback_code = $debug_fallback->bar ('', '', _x ('FALLBACK', 'alternative block', 'ad-inserter') . " = {$fallback_block}", ''); } else $debug_fallback_code = ''; $fallback_data = " data-fallback-code='" . base64_encode ($debug_fallback_code . $fallback_code) . "' limits-fallback='$fallback_block' fallback_level='$fallback_level' fallback-tracking='$fallback_tracking_data'"; $ad_inserter_globals [$globals_name] --; } } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { $debug_label = new ai_block_labels ('ai-debug-cookie'); $debug_html_code = $debug_label->block_start () . $debug_label->bar ('COOKIE CHECK', '', '', '', '', 'ai-check-' . $block_id . '-dbg') . $debug_label->block_end (); } $processed_code = $debug_html_code . "
{$ai_check_block_html_code}
\n"; if (!get_disable_js_code ()) { $js_code = "{$ai_check_block_js_code}ai_check_and_insert_block ({$this->number}, 'ai-check-{$block_id}');"; $processed_code .= $this->ai_js_dom_ready ($js_code); } } } // FILTER HOOK if ($this->client_side_filter_hook_check && !$ai_wp_data [AI_FORCE_SERVERSIDE_CODE] && !$ai_wp_data [AI_WP_AMP_PAGE]) { // Check filter hook if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { $debug_label = new ai_block_labels ('ai-debug-filter'); $debug_html_code = $debug_label->bar ('FILTER HOOK CHECK', '', '', 'ai_block_insertion_check'); } else $debug_html_code = ''; $dynamic_blocks_filetr_check = $dynamic_blocks; if ($dynamic_blocks_filetr_check == AI_DYNAMIC_BLOCKS_SERVER_SIDE && $this->client_side_filter_hook_check) { // if filter ai_block_insertion_check returns null on server-side check, it means it needs client-side check $dynamic_blocks_filetr_check = AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT; } switch ($dynamic_blocks_filetr_check) { case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW: // Hide block only when no block height is defined - for check options don't hide the first one if (trim ($this->get_block_height ()) == '' || isset ($this->check_codes) && $this->check_codes_index != 0) { $this->wrapping_div_classes []= 'ai-list-block-filter'; } $processed_code = $debug_html_code . "\n
$processed_code
\n"; break; case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT: // Hide block only when no block height is defined - for check options don't hide the first one if (trim ($this->get_block_height ()) == '' || isset ($this->check_codes) && $this->check_codes_index != 0) { $this->wrapping_div_classes []= 'ai-list-block-filter'; } $code_data = "data-code='".base64_encode ($processed_code)."'"; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { $block_id = 'ai-filter-' . $this->number . '-' . rand (1000, 9999) . rand (1000, 9999); $filter_class = ' ' . $block_id ; } else $filter_class = ''; $processed_code = $debug_html_code . "\n
\n"; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME] && !get_disable_js_code ()) { // $processed_code .= "\n"; $processed_code .= "\n"; } break; case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC: if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS FILTER HOOK'; $this->generate_w3tc_code_from_html ($processed_code); $this->w3tc_code .= 'if ($ai_enabled) ai_w3tc_log_run (\'PROCESS FILTER HOOK: \' . (ai_check_filter_hook (' . $this->number . ') ? \'ENABLED\' : \'NOT ENABLED\'));'; $w3tc_status = ' if (!$ai_enabled) ai_w3tc_log_run (\' FAILED\', \'color: red;\');'; } else $w3tc_status = ''; $this->generate_w3tc_code_from_html ($processed_code); $this->w3tc_code .= $ai_check_block_w3tc_code; $this->w3tc_code .= 'if ($ai_enabled) {$ai_enabled = ai_check_filter_hook (' . $this->number . ');'.$w3tc_status.'};'; $processed_code = $this->generate_html_from_w3tc_code (); break; } } } if (!$ai_wp_data [AI_CODE_FOR_IFRAME] && !$ai_wp_data [AI_FORCE_SERVERSIDE_CODE]) { // DELAY if ((int) $this->get_delay_time () != 0 && !$ai_wp_data [AI_WP_AMP_PAGE]) { if ($this->w3tc_code != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS DELAY'; } } $manual_code = $this->base64_encode_w3tc ($processed_code); $wrapper_class = base64_encode (get_block_class_name (true)); $processed_code = '
'."\n"; // Recreate W3TC code if ($this->w3tc_code != '') { $processed_code = $this->regenerate_w3tc_code ($processed_code); } } // WAIT FOR INTERACTION if ($this->get_wait_for_interaction () && !$ai_wp_data [AI_WP_AMP_PAGE]) { if ($this->w3tc_code != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS WAIT FOR INTERACTION'; } } $manual_code = $this->base64_encode_w3tc ($processed_code); $wrapper_class = base64_encode (get_block_class_name (true)); $processed_code = '
'."\n"; // Recreate W3TC code if ($this->w3tc_code != '') { $processed_code = $this->regenerate_w3tc_code ($processed_code); } } // CHECK RECAPTCHA SCORE if (function_exists ('get_recaptcha_site_key')) { if ($this->get_check_recaptcha_score () && !$ai_wp_data [AI_WP_AMP_PAGE] && trim (get_recaptcha_site_key ()) != '' && trim (get_recaptcha_secret_key ()) != '' && is_numeric (get_recaptcha_threshold ())) { if ($this->w3tc_code != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_debug []= 'PROCESS CHECK FOR RECAPTCHA SCORE'; } } $manual_code = $this->base64_encode_w3tc ($processed_code); $wrapper_class = base64_encode (get_block_class_name (true)); $processed_code = '
'."\n"; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { $debug_label = new ai_block_labels ('ai-debug-script'); $processed_code = $debug_label->bar ('reCAPTCHA score threshold = '.get_recaptcha_threshold (), '', '', 'reCAPTCHA score: ') . $processed_code; } // Recreate W3TC code if ($this->w3tc_code != '') { $processed_code = $this->regenerate_w3tc_code ($processed_code); } } } } // TODO single CHECK block // } while (is_array ($this->check_codes) && isset ($this->check_codes [$this->check_codes_index + 1])); if (defined ('AI_DEBUGGING_DEMO') && !$this->demo_debugging) { $this->hide_debug_labels = true; } if ($close_button && ($width = trim ($this->get_block_width ())) != '' && $this->get_alignment_type() != AI_ALIGNMENT_NO_WRAPPING) { if (is_numeric ($width)) { $width .= 'px'; } $style = 'width: ' . $width . ';'; $processed_code = "
\n" . $processed_code ."\n
\n"; } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { $processed_code = "
\n" . $processed_code ."\n
\n"; } // Process W3TC filter hook if ($this->w3tc_code != '') { $processed_code = $this->regenerate_w3tc_code ($processed_code); $this->w3tc_code .= ' $ai_code_org = $ai_code; if (!isset ($ai_enabled) || $ai_enabled) {$ai_code = apply_filters ("ai_block_w3tc_code_after_processing", $ai_code_org, ' . $this->number . ');}'; if ($ai_wp_data [AI_W3TC_DEBUGGING]) { $this->w3tc_code .= ' if ($ai_code != $ai_code_org) {ai_w3tc_log_run ("PROCESS HOOK FILTER ai_block_w3tc_code_after_processing");}'; } $processed_code = $this->generate_html_from_w3tc_code (); } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$this->hide_debug_labels) { $this->ai_generateDebugLabel (); } $code = $this->additional_code_before . $processed_code . $this->additional_code_after; // $this->additional_code_after may contain W3TC code because of ai_adb_block_actions () if ($this->w3tc_code != '' || strpos ($this->additional_code_after, ''; } else { $serverside_insertion_code = str_replace ('[#AI_CODE#]', $block_code, $serverside_insertion_code); } $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; $serverside_insertion_code_org = $serverside_insertion_code; $hook_start_time = microtime (true); $serverside_insertion_code = apply_filters ("ai_block_code_serverside_html_js", $serverside_insertion_code_org, $this->number); if ($debug_processing && $serverside_insertion_code != $serverside_insertion_code_org) { $filter_hooks []= array ("ai_block_code_serverside_html_js", $this->number); } $ai_total_hook_php_time += microtime (true) - $hook_start_time; return $serverside_insertion_code; } public function get_code_for_serverside_insertion ($include_viewport_classes = true, $hidden_widgets = false, $code_only = false) { global $ai_wp_data, $ai_total_hook_php_time, $filter_hooks; if (!isset ($ai_wp_data [AI_NESTING_LEVEL])) $ai_wp_data [AI_NESTING_LEVEL] = 0; else $ai_wp_data [AI_NESTING_LEVEL] ++; $code = $this->get_html_js_code_for_serverside_insertion ($include_viewport_classes, $hidden_widgets, $code_only); if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_AJAX || $ai_wp_data [AI_NESTING_LEVEL] != 0) { // For Ajax pages and nested blocks do not extract JS code $code = ai_strip_js_markers ($code); } else { $code = ai_extract_js_code ($code); } $ai_wp_data [AI_NESTING_LEVEL] --; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; $code_org = $code; $hook_start_time = microtime (true); $code = apply_filters ("ai_block_code_serverside_insertion", $code_org, $this->number); if ($debug_processing && $code != $code_org) { $filter_hooks []= array ("ai_block_code_serverside_insertion", $this->number); } $ai_total_hook_php_time += microtime (true) - $hook_start_time; return $code; } public function get_iframe_page () { global $ai_wp_data, $wp_version, $wp_scripts; $adb_code = defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION] && !isset ($ai_wp_data [AI_ADB_SHORTCODE_DISABLED]); if (isset ($wp_scripts->registered ['jquery']->ver)) { $jquery_version = $wp_jquery_ver = $wp_scripts->registered ['jquery']->ver; } else $jquery_version = $wp_version; if (isset ($wp_scripts->registered ['jquery-migrate']->ver)) { $jquery_migrate_version = $wp_jquery_ver = $wp_scripts->registered ['jquery-migrate']->ver; } else $jquery_migrate_version = $wp_version; $ai_wp_data [AI_CODE_FOR_IFRAME] = true; ob_start (); echo ' '; if (!defined ('AI_NO_JQUERY')) { echo "\n"; echo "\n"; } ai_wp_head_hook (); echo ' Ad Inserter Pro - Advanced WordPress Ads Management Plugin '; $ai_wp_data [AI_NESTING_LEVEL] = 0; // $include_viewport_classes = true, $hidden_widgets = false, $code_only = false echo ai_extract_js_code ($this->get_code_for_insertion (false, false, false)); echo "\n"; ai_set_footer_inline_scripts (); ai_wp_footer_hook_end_buffering (); ai_wp_footer_hook (); echo ' '; $page = ob_get_clean (); $ai_wp_data [AI_CODE_FOR_IFRAME] = false; $page = ai_process_head_codes ($page); return $page; } public function get_close_button (){ $option = isset ($this->wp_options [AI_OPTION_CLOSE_BUTTON]) ? $this->wp_options [AI_OPTION_CLOSE_BUTTON] : DEFAULT_CLOSE_BUTTON; return $option; } public function get_auto_close_time () { $option = isset ($this->wp_options [AI_OPTION_AUTO_CLOSE_TIME]) ? $this->wp_options [AI_OPTION_AUTO_CLOSE_TIME] : DEFAULT_AUTO_CLOSE_TIME; if ($option == '0') $option = ''; return $option; } public function get_stay_closed_time () { $option = isset ($this->wp_options [AI_OPTION_STAY_CLOSED_TIME]) ? $this->wp_options [AI_OPTION_STAY_CLOSED_TIME] : DEFAULT_STAY_CLOSED_TIME; if ($option == '0') $option = ''; return $option; } public function get_delay_time () { $option = isset ($this->wp_options [AI_OPTION_DELAY_TIME]) ? $this->wp_options [AI_OPTION_DELAY_TIME] : DEFAULT_DELAY_TIME; if ($option == '0') $option = ''; return $option; } public function get_delay_showing () { $option = isset ($this->wp_options [AI_OPTION_DELAY_SHOWING]) ? $this->wp_options [AI_OPTION_DELAY_SHOWING] : DEFAULT_DELAY_SHOWING; if ($option == '0') $option = ''; return $option; } public function get_show_every () { $option = isset ($this->wp_options [AI_OPTION_SHOW_EVERY]) ? $this->wp_options [AI_OPTION_SHOW_EVERY] : DEFAULT_SHOW_EVERY; if ($option == '0') $option = ''; return $option; } public function get_background (){ $option = isset ($this->wp_options [AI_OPTION_BACKGROUND]) ? $this->wp_options [AI_OPTION_BACKGROUND] : DEFAULT_BACKGROUND; return $option; } public function get_background_image (){ $option = isset ($this->wp_options [AI_OPTION_BACKGROUND_IMAGE]) ? $this->wp_options [AI_OPTION_BACKGROUND_IMAGE] : AD_EMPTY_DATA; return $option; } public function get_background_color (){ $option = isset ($this->wp_options [AI_OPTION_BACKGROUND_COLOR]) ? $this->wp_options [AI_OPTION_BACKGROUND_COLOR] : AD_EMPTY_DATA; return $option; } public function get_background_repeat (){ $option = isset ($this->wp_options [AI_OPTION_BACKGROUND_REPEAT]) ? $this->wp_options [AI_OPTION_BACKGROUND_REPEAT] : DEFAULT_BACKGROUND_REPEAT; return $option; } public function get_background_size (){ $option = isset ($this->wp_options [AI_OPTION_BACKGROUND_SIZE]) ? $this->wp_options [AI_OPTION_BACKGROUND_SIZE] : DEFAULT_BACKGROUND_SIZE; return $option; } public function get_set_body_background (){ if (!get_output_buffering ()) { return false; } $option = isset ($this->wp_options [AI_OPTION_SET_BODY_BACKGROUND]) ? $this->wp_options [AI_OPTION_SET_BODY_BACKGROUND] : DEFAULT_SET_BODY_BACKGROUND; return $option; } public function get_parallax ($index) { $option_name = AI_OPTION_PARALLAX . '_' . $index; $option = isset ($this->wp_options [$option_name]) ? $this->wp_options [$option_name] : AI_DISABLED; return $option; } public function get_parallax_image ($index) { $option_name = AI_OPTION_PARALLAX_IMAGE . '_' . $index; $option = isset ($this->wp_options [$option_name]) ? $this->wp_options [$option_name] : AD_EMPTY_DATA; return $option; } public function get_parallax_shift ($index) { $option_name = AI_OPTION_PARALLAX_SHIFT . '_' . $index; $option = isset ($this->wp_options [$option_name]) ? $this->wp_options [$option_name] : AD_EMPTY_DATA; if ($option == '0') $option = ''; return $option; } public function get_parallax_link () { $option = isset ($this->wp_options [AI_OPTION_PARALLAX_LINK]) ? $this->wp_options [AI_OPTION_PARALLAX_LINK] : AD_EMPTY_DATA; return $option; } public function get_parallax_link_new_tab () { $option = isset ($this->wp_options [AI_OPTION_PARALLAX_LINK_NEW_TAB]) ? $this->wp_options [AI_OPTION_PARALLAX_LINK_NEW_TAB] : AD_EMPTY_DATA; return $option; } public function get_visitor_max_impressions () { $option = isset ($this->wp_options [AI_OPTION_VISITOR_MAX_IMPRESSIONS]) ? $this->wp_options [AI_OPTION_VISITOR_MAX_IMPRESSIONS] : DEFAULT_VISITOR_MAX_IMPRESSIONS; if ($option == '0') $option = ''; return $option; } public function get_visitor_limit_impressions_per_time_period () { $option = isset ($this->wp_options [AI_OPTION_VISITOR_LIMIT_IMPRESSIONS_PER_TIME_PERIOD]) ? $this->wp_options [AI_OPTION_VISITOR_LIMIT_IMPRESSIONS_PER_TIME_PERIOD] : DEFAULT_VISITOR_LIMIT_IMPRESSIONS_PER_TIME_PERIOD; if ($option == '0') $option = ''; return $option; } public function get_visitor_limit_impressions_time_period () { $option = isset ($this->wp_options [AI_OPTION_VISITOR_LIMIT_IMPRESSIONS_TIME_PERIOD]) ? $this->wp_options [AI_OPTION_VISITOR_LIMIT_IMPRESSIONS_TIME_PERIOD] : DEFAULT_VISITOR_LIMIT_IMPRESSIONS_TIME_PERIOD; if ($option == '0') $option = ''; return $option; } public function get_max_impressions () { $option = isset ($this->wp_options [AI_OPTION_MAX_IMPRESSIONS]) ? $this->wp_options [AI_OPTION_MAX_IMPRESSIONS] : DEFAULT_MAX_IMPRESSIONS; if ($option == '0') $option = ''; return $option; } public function get_limit_impressions_per_time_period () { $option = isset ($this->wp_options [AI_OPTION_LIMIT_IMPRESSIONS_PER_TIME_PERIOD]) ? $this->wp_options [AI_OPTION_LIMIT_IMPRESSIONS_PER_TIME_PERIOD] : DEFAULT_LIMIT_IMPRESSIONS_PER_TIME_PERIOD; if ($option == '0') $option = ''; return $option; } public function get_limit_impressions_time_period () { $option = isset ($this->wp_options [AI_OPTION_LIMIT_IMPRESSIONS_TIME_PERIOD]) ? $this->wp_options [AI_OPTION_LIMIT_IMPRESSIONS_TIME_PERIOD] : DEFAULT_LIMIT_IMPRESSIONS_TIME_PERIOD; if ($option == '0') $option = ''; return $option; } public function get_visitor_max_clicks () { $option = isset ($this->wp_options [AI_OPTION_VISITOR_MAX_CLICKS]) ? $this->wp_options [AI_OPTION_VISITOR_MAX_CLICKS] : DEFAULT_VISITOR_MAX_CLICKS; if ($option == '0') $option = ''; return $option; } public function get_visitor_limit_clicks_per_time_period () { $option = isset ($this->wp_options [AI_OPTION_VISITOR_LIMIT_CLICKS_PER_TIME_PERIOD]) ? $this->wp_options [AI_OPTION_VISITOR_LIMIT_CLICKS_PER_TIME_PERIOD] : DEFAULT_VISITOR_LIMIT_CLICKS_PER_TIME_PERIOD; if ($option == '0') $option = ''; return $option; } public function get_visitor_limit_clicks_time_period () { $option = isset ($this->wp_options [AI_OPTION_VISITOR_LIMIT_CLICKS_TIME_PERIOD]) ? $this->wp_options [AI_OPTION_VISITOR_LIMIT_CLICKS_TIME_PERIOD] : DEFAULT_VISITOR_LIMIT_CLICKS_TIME_PERIOD; if ($option == '0') $option = ''; return $option; } public function get_max_clicks () { $option = isset ($this->wp_options [AI_OPTION_MAX_CLICKS]) ? $this->wp_options [AI_OPTION_MAX_CLICKS] : DEFAULT_MAX_CLICKS; if ($option == '0') $option = ''; return $option; } public function get_limit_clicks_per_time_period () { $option = isset ($this->wp_options [AI_OPTION_LIMIT_CLICKS_PER_TIME_PERIOD]) ? $this->wp_options [AI_OPTION_LIMIT_CLICKS_PER_TIME_PERIOD] : DEFAULT_LIMIT_CLICKS_PER_TIME_PERIOD; if ($option == '0') $option = ''; return $option; } public function get_limit_clicks_time_period () { $option = isset ($this->wp_options [AI_OPTION_LIMIT_CLICKS_TIME_PERIOD]) ? $this->wp_options [AI_OPTION_LIMIT_CLICKS_TIME_PERIOD] : DEFAULT_LIMIT_CLICKS_TIME_PERIOD; if ($option == '0') $option = ''; return $option; } public function get_trigger_click_fraud_protection () { $option = isset ($this->wp_options [AI_OPTION_TRIGGER_CLICK_FRAUD_PROTECTION]) ? $this->wp_options [AI_OPTION_TRIGGER_CLICK_FRAUD_PROTECTION] : DEFAULT_TRIGGER_CLICK_FRAUD_PROTECTION; if ($option == '0') $option = ''; return $option; } public function get_limits_fallback () { $option = isset ($this->wp_options [AI_OPTION_LIMITS_FALLBACK]) ? $this->wp_options [AI_OPTION_LIMITS_FALLBACK] : ""; return $option; } public function get_horizontal_margin (){ $option = isset ($this->wp_options [AI_OPTION_HORIZONTAL_MARGIN]) ? $this->wp_options [AI_OPTION_HORIZONTAL_MARGIN] : DEFAULT_HORIZONTAL_MARGIN; return $option; } public function get_vertical_margin () { $option = isset ($this->wp_options [AI_OPTION_VERTICAL_MARGIN]) ? $this->wp_options [AI_OPTION_VERTICAL_MARGIN] : DEFAULT_VERTICAL_MARGIN; return $option; } public function get_animation () { $option = isset ($this->wp_options [AI_OPTION_ANIMATION]) ? $this->wp_options [AI_OPTION_ANIMATION] : DEFAULT_ANIMATION; return $option; } public function get_animation_trigger () { $option = isset ($this->wp_options [AI_OPTION_ANIMATION_TRIGGER]) ? $this->wp_options [AI_OPTION_ANIMATION_TRIGGER] : DEFAULT_ANIMATION_TRIGGER; return $option; } public function get_animation_trigger_value () { $option = isset ($this->wp_options [AI_OPTION_ANIMATION_TRIGGER_VALUE]) ? $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_VALUE] : DEFAULT_ANIMATION_TRIGGER_VALUE; return $option; } public function get_animation_trigger_offset () { $option = isset ($this->wp_options [AI_OPTION_ANIMATION_TRIGGER_OFFSET]) ? $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_OFFSET] : DEFAULT_ANIMATION_TRIGGER_OFFSET; return $option; } public function get_animation_trigger_delay () { $option = isset ($this->wp_options [AI_OPTION_ANIMATION_TRIGGER_DELAY]) ? $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_DELAY] : DEFAULT_ANIMATION_TRIGGER_DELAY; return $option; } // Deprecated public function get_animation_trigger_once () { $option = isset ($this->wp_options [AI_OPTION_ANIMATION_TRIGGER_ONCE]) ? $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_ONCE] : DEFAULT_ANIMATION_TRIGGER_ONCE; return $option; } public function get_animation_out_trigger () { if ($this->get_animation_trigger_once ()) { return AI_TRIGGER_DISABLED; } $option = isset ($this->wp_options [AI_OPTION_ANIMATION_OUT_TRIGGER]) ? $this->wp_options [AI_OPTION_ANIMATION_OUT_TRIGGER] : AI_TRIGGER_ENABLED; return $option; } public function get_animation_out_trigger_value () { $option = isset ($this->wp_options [AI_OPTION_ANIMATION_OUT_TRIGGER_VALUE]) ? $this->wp_options [AI_OPTION_ANIMATION_OUT_TRIGGER_VALUE] : DEFAULT_ANIMATION_TRIGGER_VALUE; return $option; } public function get_animation_out_trigger_offset () { $option = isset ($this->wp_options [AI_OPTION_ANIMATION_OUT_TRIGGER_OFFSET]) ? $this->wp_options [AI_OPTION_ANIMATION_OUT_TRIGGER_OFFSET] : DEFAULT_ANIMATION_TRIGGER_OFFSET; return $option; } public function get_ad_general_tag(){ $option = isset ($this->wp_options [AI_OPTION_GENERAL_TAG]) ? $this->wp_options [AI_OPTION_GENERAL_TAG] : DEFAULT_GENERAL_TAG; // if ($option == '') $option = DEFAULT_GENERAL_TAG; return $option; } public function get_adb_block_action (){ $option = isset ($this->wp_options [AI_OPTION_ADB_BLOCK_ACTION]) ? $this->wp_options [AI_OPTION_ADB_BLOCK_ACTION] : DEFAULT_ADB_BLOCK_ACTION; return $option; } public function get_adb_block_replacement (){ $option = isset ($this->wp_options [AI_OPTION_ADB_BLOCK_REPLACEMENT]) ? $this->wp_options [AI_OPTION_ADB_BLOCK_REPLACEMENT] : AD_EMPTY_DATA; return $option; } public function get_scheduling(){ $option = isset ($this->wp_options [AI_OPTION_SCHEDULING]) ? $this->wp_options [AI_OPTION_SCHEDULING] : ""; // Convert old option if ($option == '' && intval ($this->get_ad_after_day()) != 0) $option = AI_SCHEDULING_DELAY_FOR; if ($option == '') $option = AI_SCHEDULING_OFF; return $option; } public function get_ad_after_day(){ $option = isset ($this->wp_options [AI_OPTION_AFTER_DAYS]) ? $this->wp_options [AI_OPTION_AFTER_DAYS] : ""; // if ($option == '') $option = AD_ZERO; if ($option == '0') $option = ''; return $option; } public function get_schedule_start_date(){ $option = isset ($this->wp_options [AI_OPTION_START_DATE]) ? $this->wp_options [AI_OPTION_START_DATE] : ""; return $option; } public function get_schedule_end_date(){ $option = isset ($this->wp_options [AI_OPTION_END_DATE]) ? $this->wp_options [AI_OPTION_END_DATE] : ""; return $option; } public function get_schedule_start_time(){ $option = isset ($this->wp_options [AI_OPTION_START_TIME]) ? $this->wp_options [AI_OPTION_START_TIME] : ""; return $option; } public function get_schedule_end_time(){ $option = isset ($this->wp_options [AI_OPTION_END_TIME]) ? $this->wp_options [AI_OPTION_END_TIME] : ""; return $option; } public function get_schedule_weekdays (){ $option = isset ($this->wp_options [AI_OPTION_WEEKDAYS]) ? $this->wp_options [AI_OPTION_WEEKDAYS] : DEFAULT_WEEKDAYS; return $option; } public function get_scheduling_fallback(){ $option = isset ($this->wp_options [AI_OPTION_SCHEDULING_FALLBACK]) ? $this->wp_options [AI_OPTION_SCHEDULING_FALLBACK] : ""; return $option; } public function get_maximum_insertions (){ $option = isset ($this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS]) ? $this->wp_options [AI_OPTION_MAXIMUM_INSERTIONS] : ""; if ($option == '0') $option = ''; return $option; } public function get_id_list(){ $option = isset ($this->wp_options [AI_OPTION_ID_LIST]) ? $this->wp_options [AI_OPTION_ID_LIST] : ""; return $option; } public function get_id_list_type (){ $option = isset ($this->wp_options [AI_OPTION_ID_LIST_TYPE]) ? $this->wp_options [AI_OPTION_ID_LIST_TYPE] : AI_BLACK_LIST; if ($option == '') $option = AI_BLACK_LIST; elseif ($option == AD_BLACK_LIST) $option = AI_BLACK_LIST; elseif ($option == AD_WHITE_LIST) $option = AI_WHITE_LIST; return $option; } public function get_ad_url_list(){ $option = isset ($this->wp_options [AI_OPTION_URL_LIST]) ? $this->wp_options [AI_OPTION_URL_LIST] : ""; return $option; } public function get_ad_url_list_type (){ $option = isset ($this->wp_options [AI_OPTION_URL_LIST_TYPE]) ? $this->wp_options [AI_OPTION_URL_LIST_TYPE] : AI_BLACK_LIST; if ($option == '') $option = AI_BLACK_LIST; elseif ($option == AD_BLACK_LIST) $option = AI_BLACK_LIST; elseif ($option == AD_WHITE_LIST) $option = AI_WHITE_LIST; return $option; } public function get_url_parameter_list(){ $option = isset ($this->wp_options [AI_OPTION_URL_PARAMETER_LIST]) ? $this->wp_options [AI_OPTION_URL_PARAMETER_LIST] : ""; return $option; } public function get_url_parameter_list_type (){ $option = isset ($this->wp_options [AI_OPTION_URL_PARAMETER_LIST_TYPE]) ? $this->wp_options [AI_OPTION_URL_PARAMETER_LIST_TYPE] : AI_BLACK_LIST; if ($option == '') $option = AI_BLACK_LIST; elseif ($option == AD_BLACK_LIST) $option = AI_BLACK_LIST; elseif ($option == AD_WHITE_LIST) $option = AI_WHITE_LIST; return $option; } public function get_cookie_list(){ $option = isset ($this->wp_options [AI_OPTION_COOKIE_LIST]) ? $this->wp_options [AI_OPTION_COOKIE_LIST] : ""; return $option; } public function get_cookie_list_type (){ $option = isset ($this->wp_options [AI_OPTION_COOKIE_LIST_TYPE]) ? $this->wp_options [AI_OPTION_COOKIE_LIST_TYPE] : AI_BLACK_LIST; if ($option == '') $option = AI_BLACK_LIST; return $option; } public function get_ad_domain_list(){ $option = isset ($this->wp_options [AI_OPTION_DOMAIN_LIST]) ? $this->wp_options [AI_OPTION_DOMAIN_LIST] : ""; return $option; } public function get_ad_domain_list_type (){ $option = isset ($this->wp_options [AI_OPTION_DOMAIN_LIST_TYPE]) ? $this->wp_options [AI_OPTION_DOMAIN_LIST_TYPE] : AI_BLACK_LIST; if ($option == '') $option = AI_BLACK_LIST; elseif ($option == AD_BLACK_LIST) $option = AI_BLACK_LIST; elseif ($option == AD_WHITE_LIST) $option = AI_WHITE_LIST; return $option; } public function get_client_list(){ $option = isset ($this->wp_options [AI_OPTION_CLIENT_LIST]) ? $this->wp_options [AI_OPTION_CLIENT_LIST] : ""; return $option; } public function get_client_list_type (){ $option = isset ($this->wp_options [AI_OPTION_CLIENT_LIST_TYPE]) ? $this->wp_options [AI_OPTION_CLIENT_LIST_TYPE] : AI_BLACK_LIST; if ($option == '') $option = AI_BLACK_LIST; return $option; } public function get_ad_ip_address_list (){ $option = isset ($this->wp_options [AI_OPTION_IP_ADDRESS_LIST]) ? $this->wp_options [AI_OPTION_IP_ADDRESS_LIST] : ""; return $option; } public function get_ad_ip_address_list_type (){ $option = isset ($this->wp_options [AI_OPTION_IP_ADDRESS_LIST_TYPE]) ? $this->wp_options [AI_OPTION_IP_ADDRESS_LIST_TYPE] : AI_BLACK_LIST; if ($option == '') $option = AI_BLACK_LIST; elseif ($option == AD_BLACK_LIST) $option = AI_BLACK_LIST; elseif ($option == AD_WHITE_LIST) $option = AI_WHITE_LIST; return $option; } public function get_ad_country_list ($expand = false){ $option = isset ($this->wp_options [AI_OPTION_COUNTRY_LIST]) ? $this->wp_options [AI_OPTION_COUNTRY_LIST] : ""; if ($expand && function_exists ('expanded_country_list')) return expanded_country_list ($option); return $option; } public function get_ad_country_list_type (){ $option = isset ($this->wp_options [AI_OPTION_COUNTRY_LIST_TYPE]) ? $this->wp_options [AI_OPTION_COUNTRY_LIST_TYPE] : AI_BLACK_LIST; if ($option == '') $option = AI_BLACK_LIST; elseif ($option == AD_BLACK_LIST) $option = AI_BLACK_LIST; elseif ($option == AD_WHITE_LIST) $option = AI_WHITE_LIST; return $option; } public function get_ad_name(){ $option = isset ($this->wp_options [AI_OPTION_BLOCK_NAME]) ? $this->wp_options [AI_OPTION_BLOCK_NAME] : ""; if ($option == '') $option = DEFAULT_AD_NAME. " " . $this->number; return $option; } public function get_ad_block_cat(){ $option = isset ($this->wp_options [AI_OPTION_CATEGORY_LIST]) ? $this->wp_options [AI_OPTION_CATEGORY_LIST] : ""; return $option; } public function get_ad_block_cat_type(){ $option = isset ($this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE]) ? $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] : AI_BLACK_LIST; // Update old data if ($option == ''){ $option = AI_BLACK_LIST; $this->wp_options [AI_OPTION_CATEGORY_LIST_TYPE] = AI_BLACK_LIST; } if ($option == '') $option = AI_BLACK_LIST; elseif ($option == AD_BLACK_LIST) $option = AI_BLACK_LIST; elseif ($option == AD_WHITE_LIST) $option = AI_WHITE_LIST; return $option; } public function get_ad_block_tag(){ $option = isset ($this->wp_options [AI_OPTION_TAG_LIST]) ? $this->wp_options [AI_OPTION_TAG_LIST] : ""; return $option; } public function get_ad_block_tag_type(){ $option = isset ($this->wp_options [AI_OPTION_TAG_LIST_TYPE]) ? $this->wp_options [AI_OPTION_TAG_LIST_TYPE] : AI_BLACK_LIST; if ($option == '') $option = AI_BLACK_LIST; elseif ($option == AD_BLACK_LIST) $option = AI_BLACK_LIST; elseif ($option == AD_WHITE_LIST) $option = AI_WHITE_LIST; return $option; } public function get_ad_block_taxonomy(){ $option = isset ($this->wp_options [AI_OPTION_TAXONOMY_LIST]) ? $this->wp_options [AI_OPTION_TAXONOMY_LIST] : ""; return $option; } public function get_ad_block_taxonomy_type(){ $option = isset ($this->wp_options [AI_OPTION_TAXONOMY_LIST_TYPE]) ? $this->wp_options [AI_OPTION_TAXONOMY_LIST_TYPE] : AI_BLACK_LIST; if ($option == '') $option = AI_BLACK_LIST; elseif ($option == AD_BLACK_LIST) $option = AI_BLACK_LIST; elseif ($option == AD_WHITE_LIST) $option = AI_WHITE_LIST; return $option; } public function get_ad_enabled_on_which_pages (){ // Old option if (isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES])) { $option = isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES]) ? $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES] : AI_IGNORE_EXCEPTIONS; if ($option == '') $option = AI_IGNORE_EXCEPTIONS; elseif ($option == AD_ENABLED_ON_ALL) $option = AI_IGNORE_EXCEPTIONS; elseif ($option == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) $option = AI_DEFAULT_INSERTION_ENABLED; elseif ($option == AD_ENABLED_ONLY_ON_SELECTED) $option = AI_DEFAULT_INSERTION_DISABLED; return $option; } if (!$this->get_exceptions_enabled ()) { return AI_IGNORE_EXCEPTIONS; } return $this->get_exceptions_function (); } public function get_ad_enabled_on_which_pages_text ($translated = true){ switch ($this->get_ad_enabled_on_which_pages ()) { case AI_IGNORE_EXCEPTIONS: if (!$translated) return AI_TEXT_ENG_NO_INDIVIDUAL_EXCEPTIONS; return AI_TEXT_PAGES_NO_INDIVIDUAL_EXCEPTIONS; break; case AI_DEFAULT_INSERTION_ENABLED: if (!$translated) return AI_TEXT_ENG_INDIVIDUALLY_DISABLED; return AI_TEXT_PAGES_INDIVIDUALLY_DISABLED; break; case AI_DEFAULT_INSERTION_DISABLED: if (!$translated) return AI_TEXT_ENG_INDIVIDUALLY_ENABLED; return AI_TEXT_PAGES_INDIVIDUALLY_ENABLED; break; default: return ''; break; } } public function get_ad_enabled_on_which_posts (){ // Old option if (isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS])) { $option = $this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS]; if ($option == '') $option = AI_IGNORE_EXCEPTIONS; elseif ($option == AD_ENABLED_ON_ALL) $option = AI_IGNORE_EXCEPTIONS; elseif ($option == AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED) $option = AI_DEFAULT_INSERTION_ENABLED; elseif ($option == AD_ENABLED_ONLY_ON_SELECTED) $option = AI_DEFAULT_INSERTION_DISABLED; return $option; } if (!$this->get_exceptions_enabled ()) { return AI_IGNORE_EXCEPTIONS; } return $this->get_exceptions_function (); } public function get_ad_enabled_on_which_posts_text ($translated = true){ switch ($this->get_ad_enabled_on_which_posts ()) { case AI_IGNORE_EXCEPTIONS: if (!$translated) return AI_TEXT_ENG_NO_INDIVIDUAL_EXCEPTIONS; return AI_TEXT_POSTS_NO_INDIVIDUAL_EXCEPTIONS; break; case AI_DEFAULT_INSERTION_ENABLED: if (!$translated) return AI_TEXT_ENG_INDIVIDUALLY_DISABLED; return AI_TEXT_POSTS_INDIVIDUALLY_DISABLED; break; case AI_DEFAULT_INSERTION_DISABLED: if (!$translated) return AI_TEXT_ENG_INDIVIDUALLY_ENABLED; return AI_TEXT_POSTS_INDIVIDUALLY_ENABLED; break; default: return ''; break; } } public function import_old_exception_settings (&$needs_check){ $needs_check = false; if (isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS]) || isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES])) { // Import old settings $posts = isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS]) ? $this->get_ad_enabled_on_which_posts () : AI_IGNORE_EXCEPTIONS; $pages = isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES]) ? $this->get_ad_enabled_on_which_pages () : AI_IGNORE_EXCEPTIONS; if ($posts == $pages) { return $posts; } if (!$this->get_display_settings_page ()) { return $posts; } if (!$this->get_display_settings_post ()) { return $pages; } $needs_check = true; // POSTS = AI_DEFAULT_INSERTION_DISABLED NO INSERTION ON PAGES // POSTS = AI_DEFAULT_INSERTION_ENABLED OK if ($pages == AI_IGNORE_EXCEPTIONS) { return $posts; } // PAGES = AI_DEFAULT_INSERTION_DISABLED NO INSERTION ON POSTS // PAGES = AI_DEFAULT_INSERTION_ENABLED OK if ($posts == AI_IGNORE_EXCEPTIONS) { return $pages; } // POSTS = AI_DEFAULT_INSERTION_DISABLED NO INSERTION ON PAGES // PAGES = AI_DEFAULT_INSERTION_ENABLED // POSTS = AI_DEFAULT_INSERTION_ENABLED INVERTED INSERTION ON PAGES // PAGES = AI_DEFAULT_INSERTION_DISABLED return $posts; } return - 1; } public function get_exceptions_enabled (){ $needs_check = false; $option = $this->import_old_exception_settings ($needs_check); if ($option >= 0) { return $option != AI_IGNORE_EXCEPTIONS; } $option = isset ($this->wp_options [AI_OPTION_EXCEPTIONS_ENABLED]) ? $this->wp_options [AI_OPTION_EXCEPTIONS_ENABLED] : AI_DISABLED; return $option; } public function get_exceptions_function (){ $needs_check = false; $option = $this->import_old_exception_settings ($needs_check); if ($option >= 0) { if ($option == AI_IGNORE_EXCEPTIONS) $option == AI_DEFAULT_INSERTION_ENABLED; return $option; } $option = isset ($this->wp_options [AI_OPTION_EXCEPTIONS_FUNCTION]) ? $this->wp_options [AI_OPTION_EXCEPTIONS_FUNCTION] : AI_DEFAULT_INSERTION_ENABLED; return $option; } public function get_exceptions_function_text ($translated = true){ switch ($this->get_exceptions_function ()) { case AI_DEFAULT_INSERTION_ENABLED: if (!$translated) return AI_TEXT_ENG_ENABLED; return AI_TEXT_ENABLED; break; case AI_DEFAULT_INSERTION_DISABLED: if (!$translated) return AI_TEXT_ENG_DISABLED; return AI_TEXT_DISABLED; break; default: return ''; break; } } public function get_name_class () { $name = $this->get_ad_name (); if ($name == '') return ''; return strtolower (str_replace ('--', '-', preg_replace ('/[^\-_a-zA-Z0-9]/', '', str_replace (' ', '-', html_entity_decode ($name))))); } public function get_viewport_classes () { global $ai_wp_data; // if ($ai_wp_data [AI_WP_AMP_PAGE]) return ''; $viewport_classes = ""; if ($this->get_detection_client_side ()) { $all_viewports = true; for ($viewport = 1; $viewport <= 6; $viewport ++) { $viewport_name = get_viewport_name ($viewport); if ($viewport_name != '') { if ($this->get_detection_viewport ($viewport)) $viewport_classes .= " ai-viewport-" . $viewport; else $all_viewports = false; } } if ($viewport_classes == "") $viewport_classes = " ai-viewport-0"; elseif ($all_viewports) $viewport_classes = ""; } return ($viewport_classes); } public function get_viewport_names () { global $ai_wp_data; if ($ai_wp_data [AI_WP_AMP_PAGE]) return ''; $viewport_names = array (); if ($this->get_detection_client_side ()) { for ($viewport = 1; $viewport <= 6; $viewport ++) { $viewport_name = get_viewport_name ($viewport); if ($viewport_name != '') { if ($this->get_detection_viewport ($viewport)) $viewport_names []= $viewport_name; } } } return (implode (', ', $viewport_names)); } public function get_alignment_class ($block_class_name = null){ global $ai_wp_data; if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES && $ai_wp_data [AI_WP_AMP_PAGE] || defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !$ai_wp_data [AI_WP_AMP_PAGE] && !get_inline_styles ()) { return $this->generate_alignment_class ($block_class_name); } return ''; } public function generate_alignment_class ($block_class_name = null){ if ($block_class_name == null) $block_class_name = get_block_class_name (true); $block_class_name .= '-'; switch ($this->get_alignment_type ()) { case AI_ALIGNMENT_DEFAULT: case AI_ALIGNMENT_LEFT: case AI_ALIGNMENT_RIGHT: case AI_ALIGNMENT_CENTER: case AI_ALIGNMENT_FLOAT_LEFT: case AI_ALIGNMENT_FLOAT_RIGHT: case AI_ALIGNMENT_STICKY_LEFT: case AI_ALIGNMENT_STICKY_RIGHT: case AI_ALIGNMENT_STICKY_TOP: case AI_ALIGNMENT_STICKY_BOTTOM: return $block_class_name . str_replace (' ', '-', strtolower ($this->get_alignment_type_text (false))); break; case AI_ALIGNMENT_STICKY: // return $block_class_name . str_replace (' ', '-', strtolower (md5 ($this->alignment_style ($this->get_alignment_type ())))); return $block_class_name . strtolower (md5 ($this->alignment_style ($this->get_alignment_type ()))); break; case AI_ALIGNMENT_CUSTOM_CSS: // return $block_class_name . str_replace (' ', '-', strtolower (md5 ($this->get_custom_css ()))); return $block_class_name . strtolower (md5 ($this->get_custom_css ())); break; } return ''; } public function get_size_class ($block_class_name = null){ global $ai_wp_data; if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES && $ai_wp_data [AI_WP_AMP_PAGE] || defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !$ai_wp_data [AI_WP_AMP_PAGE] && !get_inline_styles ()) { return $this->generate_size_class ($block_class_name); } return ''; } public function generate_size_class ($block_class_name = null) { $size_background_style = $this->size_background_style (); if ($this->get_alignment_type () != AI_ALIGNMENT_CUSTOM_CSS && $size_background_style != '') { if ($block_class_name == null) $block_class_name = get_block_class_name (true); $block_class_name .= '-'; return $block_class_name . ai_css_to_name ($size_background_style); } return ''; } public function before_image ($content, $position_preview = false) { return $this->before_paragraph ($content, $position_preview, true); } public function before_paragraph ($content, $position_preview = false, $before_image = false) { global $ai_wp_data, $ai_last_check, $special_element_tags, $ad_inserter_globals; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; $multibyte = $ai_wp_data [AI_MBSTRING_LOADED] && get_paragraph_counting_functions() == AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS; $paragraph_positions = array (); $active_paragraph_positions = array (); $dummy = array (); if ($before_image) { $paragraph_tags = 'figure,img,amp-img'; } else $paragraph_tags = trim ($this->get_paragraph_tags()); if ($paragraph_tags == '') return $content; $paragraph_start_strings = explode (",", $paragraph_tags); $ai_last_check = AI_CHECK_PARAGRAPH_TAGS; if (count ($paragraph_start_strings) == 0) return $content; get_paragraph_start_positions ($content, $multibyte, $dummy, $paragraph_start_strings, $paragraph_positions, $active_paragraph_positions); // Nothing to do $ai_last_check = AI_CHECK_PARAGRAPHS_WITH_TAGS; if (array_sum ($active_paragraph_positions) == 0) return $content; sort ($paragraph_positions); ksort ($active_paragraph_positions); $new_active_paragraph_positions = array (); foreach ($active_paragraph_positions as $active_paragraph_position) { $new_active_paragraph_positions [] = $active_paragraph_position; } $active_paragraph_positions = $new_active_paragraph_positions; if (!$this->get_count_inside_blockquote () || $before_image) { $special_element_offsets = array (); if ($before_image) { $special_element_tags_array = array_unique (array_merge ($special_element_tags, array ('figure', 'amp-img'))); } else $special_element_tags_array = $special_element_tags; foreach ($special_element_tags_array as $special_element_tag) { preg_match_all ("/<\/?$special_element_tag/i", $content, $special_elements, PREG_OFFSET_CAPTURE); $nesting = array (); $special_elements = $special_elements [0]; foreach ($special_elements as $index => $special_element) { if (isset ($special_elements [$index + 1][0])) { $tag1 = strtolower ($special_element [0]); $tag2 = strtolower ($special_elements [$index + 1][0]); $start_offset = $special_element [1]; $nesting_ended = false; $tag1_start = $tag1 == "<$special_element_tag"; $tag2_start = $tag2 == "<$special_element_tag"; $tag1_end = $tag1 == "= $special_element_offset [0] && $paragraph_position <= $special_element_offset [1]) $inside_special_element [] = $paragraph_position; } } foreach ($paragraph_positions as $index => $paragraph_position) { if (in_array ($paragraph_position, $inside_special_element)) $active_paragraph_positions [$index] = 0; } } $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE; if (array_sum ($active_paragraph_positions) == 0) return $content; } $element_tags = $this->get_count_inside_elements (); if ($element_tags != '') { $special_element_tags_array = explode (',', str_replace (' ', '', $element_tags)); $count_inside = $this->get_count_inside (); $element_text_type = $this->get_count_inside_elements_contain (); $check_only_tag_attributes = $this->get_check_only_tag_attributes (); $element_text = str_replace (' ', '', html_entity_decode ($this->get_count_inside_elements_text ())); if (strpos ($element_text, ",") !== false) { $element_texts = explode (',', $element_text); } elseif (trim ($element_text) != '') $element_texts = array (trim ($element_text)); else $element_texts = array (); $special_element_offsets = array (); foreach ($special_element_tags_array as $special_element_tag) { preg_match_all ("/<\/?$special_element_tag/i", $content, $special_elements, PREG_OFFSET_CAPTURE); $special_elements = $special_elements [0]; if (count ($special_elements) % 2 != 0) { if ($debug_processing) ai_log ('INVALID TAGS: ODD NUMBER OF ' . $special_element_tag . ' TAGS'); } $elements = array (); $nesting = array (); foreach ($special_elements as $index => $special_element) { $tag = strtolower ($special_element [0]); $tag_start = $tag == "<$special_element_tag"; $tag_end = $tag == "]+?)>#', $search_content, $search_content_tag); if (isset ($search_content_tag [1])) { $search_content = $search_content_tag [1]; } } if (stripos ($search_content, $element_text)) { $check = true; break; } } switch ($element_text_type) { case AI_CONTAIN: if ($check) { $special_element_offsets []= $element_offsets; } break; default: if (!$check) { $special_element_offsets []= $element_offsets; } break; } } else { $special_element_offsets []= $element_offsets; } } } $inside_special_element = array (); if (count ($special_element_offsets) != 0) { foreach ($special_element_offsets as $special_element_offset) { foreach ($paragraph_positions as $paragraph_position) { if ($paragraph_position >= $special_element_offset [0] + 1 && $paragraph_position <= $special_element_offset [1]) $inside_special_element [] = $paragraph_position; } } } foreach ($paragraph_positions as $index => $paragraph_position) { $paragraph_inside = in_array ($paragraph_position, $inside_special_element); switch ($count_inside) { case AI_COUNT_ONLY: if (!$paragraph_inside) $active_paragraph_positions [$index] = 0; break; default: if ($paragraph_inside) $active_paragraph_positions [$index] = 0; break; } } $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE_ELEMENTS; if (array_sum ($active_paragraph_positions) == 0) return $content; } if (!$before_image) { $paragraph_min_words = intval ($this->get_minimum_paragraph_words()); $paragraph_max_words = intval ($this->get_maximum_paragraph_words()); if ($paragraph_min_words != 0 || $paragraph_max_words != 0) { if (!isset ($paragraph_end_positions)) { $paragraph_end_positions = array (); get_paragraph_end_positions ($content, $multibyte, $paragraph_positions, $paragraph_start_strings, $paragraph_end_positions, $dummy); } foreach ($paragraph_positions as $index => $paragraph_position) { if ($active_paragraph_positions [$index] == 0) continue; if ($multibyte) { $paragraph_code = mb_substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1); } else { $paragraph_code = substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1); } if (!$this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $active_paragraph_positions [$index] = 0; } } // Nothing to do $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS; if (array_sum ($active_paragraph_positions) == 0) return $content; $paragraph_texts = explode (",", html_entity_decode ($this->get_paragraph_text())); if ($this->get_paragraph_text() != "" && count ($paragraph_texts) != 0) { if (!isset ($paragraph_end_positions)) { $paragraph_end_positions = array (); get_paragraph_end_positions ($content, $multibyte, $paragraph_positions, $paragraph_start_strings, $paragraph_end_positions, $dummy); } $paragraph_text_type = $this->get_paragraph_text_type (); foreach ($paragraph_positions as $index => $paragraph_position) { if ($active_paragraph_positions [$index] == 0) continue; if ($multibyte) { $paragraph_code = mb_substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1); } else { $paragraph_code = substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1); } if ($paragraph_text_type == AI_CONTAIN) { $found = true; foreach ($paragraph_texts as $paragraph_text) { if (trim ($paragraph_text) == '') continue; $paragraph_text = trim ($paragraph_text); $invert = false; if ($paragraph_text [0] == '^') { $paragraph_text = substr ($paragraph_text, 1); $invert = true; } if ($multibyte) { $paragraph_text_found = mb_stripos ($paragraph_code, $paragraph_text) !== false; if ($invert) { $paragraph_text_found = !$paragraph_text_found; } if (!$paragraph_text_found) { $found = false; break; } } else { $paragraph_text_found = stripos ($paragraph_code, $paragraph_text) !== false; if ($invert) { $paragraph_text_found = !$paragraph_text_found; } if (!$paragraph_text_found) { $found = false; break; } } } if (!$found) $active_paragraph_positions [$index] = 0; } elseif ($paragraph_text_type == AI_DO_NOT_CONTAIN) { $found = false; foreach ($paragraph_texts as $paragraph_text) { if (trim ($paragraph_text) == '') continue; $paragraph_text = trim ($paragraph_text); $invert = false; if ($paragraph_text [0] == '^') { $paragraph_text = substr ($paragraph_text, 1); $invert = true; } if ($multibyte) { $paragraph_text_found = mb_stripos ($paragraph_code, $paragraph_text) !== false; if ($invert) { $paragraph_text_found = !$paragraph_text_found; } if ($paragraph_text_found) { $found = true; break; } } else { $paragraph_text_found = stripos ($paragraph_code, $paragraph_text) !== false; if ($invert) { $paragraph_text_found = !$paragraph_text_found; } if ($paragraph_text_found) { $found = true; break; } } } if ($found) $active_paragraph_positions [$index] = 0; } } } // Nothing to do $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_TEXT; if (array_sum ($active_paragraph_positions) == 0) return $content; } // !$before_image $position_text = trim ($this->get_paragraph_number()); if ($before_image) { $direction_type = AI_DIRECTION_FROM_TOP; } else $direction_type = $this->get_direction_type(); // Prepare $paragraph_end_positions // if ($position_preview || $position_text == '') { // Prepare always if (!isset ($paragraph_end_positions)) { $paragraph_end_positions = array (); get_paragraph_end_positions ($content, $multibyte, $paragraph_positions, $paragraph_start_strings, $paragraph_end_positions, $dummy); } $filtered_paragraph_end_positions = array (); // Use $paragraph_positions for counting as it is checked for consistency foreach ($paragraph_positions as $index => $paragraph_position) { if ($active_paragraph_positions [$index]) $filtered_paragraph_end_positions [] = $paragraph_end_positions [$index]; } $paragraph_end_positions = $filtered_paragraph_end_positions; if ($direction_type == AI_DIRECTION_FROM_BOTTOM) { $paragraph_end_positions = array_reverse ($paragraph_end_positions); } // } $filtered_paragraph_positions = array (); foreach ($paragraph_positions as $index => $paragraph_position) { if ($active_paragraph_positions [$index]) $filtered_paragraph_positions [] = $paragraph_position; } $paragraph_positions = $filtered_paragraph_positions; if ($direction_type == AI_DIRECTION_FROM_BOTTOM) { $paragraph_positions = array_reverse ($paragraph_positions); } // $positions contains indexes in $paragraph_positions $positions = array (); if (!$position_preview) { if (strpos ($position_text, '[') !== false) { $random_range = false; for ($i = 0; $i < strlen ($position_text); $i ++) { switch ($position_text [$i]) { case '[': $random_range = true; break; case ']': $random_range = false; break; case ',': if ($random_range) { $position_text [$i] = '|'; } break; } } } $position = $position_text; if (is_numeric ($position)) { if ($position > 0 && $position < 1) { $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5); } elseif ($position > - 1 && $position < 0) { $position = intval (count ($paragraph_positions) + $position * (count ($paragraph_positions) - 1) - 0.5); } elseif ($position <= - 1) { $position = count ($paragraph_positions) + $position; } elseif ($position == 0) { $position = mt_rand (0, count ($paragraph_positions) - 1); } else $position --; $positions = array ($position); } elseif (strpos ($position_text, '[') === 0 && strpos ($position_text, ']') === strlen ($position_text) - 1) { $wanted_paragraphs_text = trim (substr ($position_text, 1, strlen ($position_text) - 2)); $wanted_paragraph_ranges = array (); $wanted_paragraphs = array (); if (strpos ($position_text, '|') !== false) { $items = explode ('|', str_replace (' ', '', $wanted_paragraphs_text)); foreach ($items as $item) { $wanted_paragraph_ranges []= $item; } } else $wanted_paragraph_ranges []= $wanted_paragraphs_text; foreach ($wanted_paragraph_ranges as $wanted_paragraph_range) { if (strpos ($wanted_paragraph_range, '-') !== false) { $limits = explode ('-', $wanted_paragraph_range); $limit_min = (int) $limits [0]; $limit_max = (int) $limits [1]; } else { $limit_min = (int) $wanted_paragraph_range; $limit_max = (int) $wanted_paragraph_range; } if ($limit_min < 0) $limit_min = 0; else if ($limit_min > 9999) $limit_min = 9999; if ($limit_max < 0) $limit_max = 0; else if ($limit_max > 9999) $limit_max = 9999; if ($limit_min > $limit_max) $limit_max = $limit_min; while ($limit_max >= $limit_min) { $wanted_paragraphs [] = $limit_max; $limit_max --; } } $wanted_paragraphs = array_unique ($wanted_paragraphs); sort ($wanted_paragraphs); if (count ($wanted_paragraphs) == 0) $wanted_paragraphs = array (0); $random_paragraph = mt_rand (0, count ($wanted_paragraphs) - 1); $paragraph = $wanted_paragraphs [$random_paragraph]; if ($paragraph == 0) { $paragraph = mt_rand (0, count ($paragraph_positions) - 1); } else $paragraph --; $positions = array ($paragraph); if ($debug_processing) { ai_log ('BLOCK ' . $this->number . ' RANDOM PARAGRAPHS ' . str_replace ('|', ', ', $position_text) . ' => [' . implode (', ', $wanted_paragraphs) . '] of ' . count ($paragraph_positions) . ' => ' . ($paragraph + 1)); } } elseif (strpos ($position_text, ',') !== false) { if ($debug_processing) { ai_log ('BLOCK ' . $this->number . ' BEFORE PARAGRAPHS ' . str_replace ('|', ', ', $position_text) . ' of ' . count ($paragraph_positions) . ' available'); } $new_positions = array (); $positions = explode (',', str_replace (' ', '', $position_text)); foreach ($positions as $index => $position) { if (isset ($position [0]) && strpos ($position, '[') === 0 && strpos ($position, ']') === strlen ($position) - 1) { $wanted_paragraphs_text = trim (substr ($position, 1, strlen ($position) - 2)); $wanted_paragraph_ranges = array (); $wanted_paragraphs = array (); if (strpos ($position, '|') !== false) { $items = explode ('|', str_replace (' ', '', $wanted_paragraphs_text)); foreach ($items as $item) { $wanted_paragraph_ranges []= $item; } } else $wanted_paragraph_ranges []= $wanted_paragraphs_text; foreach ($wanted_paragraph_ranges as $wanted_paragraph_range) { if (strpos ($wanted_paragraph_range, '-') !== false) { $limits = explode ('-', $wanted_paragraph_range); $limit_min = (int) $limits [0]; $limit_max = (int) $limits [1]; } else { $limit_min = (int) $wanted_paragraph_range; $limit_max = (int) $wanted_paragraph_range; } if ($limit_min < 0) $limit_min = 0; else if ($limit_min > 9999) $limit_min = 9999; if ($limit_max < 0) $limit_max = 0; else if ($limit_max > 9999) $limit_max = 9999; if ($limit_min > $limit_max) $limit_max = $limit_min; while ($limit_max >= $limit_min) { $wanted_paragraphs [] = $limit_max; $limit_max --; } } $wanted_paragraphs = array_unique ($wanted_paragraphs); sort ($wanted_paragraphs); if (count ($wanted_paragraphs) == 0) $wanted_paragraphs = array (0); $random_paragraph = mt_rand (0, count ($wanted_paragraphs) - 1); $paragraph = $wanted_paragraphs [$random_paragraph]; if ($paragraph == 0) { $paragraph = mt_rand (0, count ($paragraph_positions) - 1); } else $paragraph --; $positions [$index] = $paragraph; if ($debug_processing) { ai_log ('BLOCK ' . $this->number . ' RANDOM PARAGRAPHS ' . str_replace ('|', ', ', $position) . ' => [' . implode (', ', $wanted_paragraphs) . '] of ' . count ($paragraph_positions) . ' => ' . ($paragraph + 1)); } } elseif (isset ($position [0]) && $position [0] == '%') { unset ($positions [$index]); $position = substr ($position, 1); $mod_value = $position; $offset_value = 0; if (strpos ($mod_value, '@') !== false) { $mod_value_array = explode ('@', $mod_value); $mod_value = $mod_value_array [0]; $offset_value = $mod_value_array [1]; } if (is_numeric ($mod_value) && $mod_value > 0 && is_numeric ($offset_value)) { foreach ($paragraph_positions as $index => $paragraph_position) { if ($index + 1 < $offset_value) continue; if (($index + 1 - $offset_value) % $mod_value == 0) $new_positions []= $index; } } } elseif (is_numeric ($position) && $position > 0 && $position < 1) { $positions [$index] = intval ($position * (count ($paragraph_positions) - 1) + 0.5); } elseif (is_numeric ($position) && $position > - 1 && $position < 0) { $positions [$index] = intval (count ($paragraph_positions) + $position * (count ($paragraph_positions) - 1) - 0.5); } elseif (is_numeric ($position) && $position <= - 1) { $positions [$index] = count ($paragraph_positions) + $position; } elseif ($position == 0) { $positions [$index] = mt_rand (0, count ($paragraph_positions) - 1); } else $positions [$index] = (int) $position - 1; } $positions = array_unique (array_merge ($positions, $new_positions)); sort ($positions); } elseif (isset ($position_text [0]) && $position_text [0] == '%') { $position_text = substr ($position_text, 1); $mod_value = $position_text; $offset_value = 0; if (strpos ($mod_value, '@') !== false) { $mod_value_array = explode ('@', $mod_value); $mod_value = $mod_value_array [0]; $offset_value = $mod_value_array [1]; } if (is_numeric ($mod_value) && $mod_value > 0 && is_numeric ($offset_value)) { foreach ($paragraph_positions as $index => $paragraph_position) { if ($index + 1 < $offset_value) continue; if (($index + 1 - $offset_value) % $mod_value == 0) $positions []= $index; } } } elseif ($position_text == '') { $positions = array (); $min_words_above = $this->get_minimum_words_above (); if (!empty ($min_words_above) && !$before_image) { $words_above = 0; foreach ($paragraph_positions as $index => $paragraph_position) { if ($direction_type != AI_DIRECTION_FROM_BOTTOM) { if ($words_above >= $min_words_above) { $positions []= $index; $words_above = 0; } } if ($multibyte) { $paragraph_code = mb_substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1); } else { $paragraph_code = substr ($content, $paragraph_position, $paragraph_end_positions [$index] - $paragraph_position + 1); } $words_above += number_of_words ($paragraph_code); if ($direction_type == AI_DIRECTION_FROM_BOTTOM) { if ($words_above >= $min_words_above) { $positions []= $index; $words_above = 0; } } } } else foreach ($paragraph_positions as $index => $paragraph_position) { $positions []= $index; } $filter_settings = trim (str_replace (' ', '', $this->get_call_filter())); if (!empty ($filter_settings)) { $filter_counter = $before_image ? AI_FILTER_IMAGES : AI_FILTER_PARAGRAPHS; if ($this->get_filter_type() == $filter_counter) { $filter_values = array (); if (strpos ($filter_settings, ",") !== false) { $filter_values = explode (",", $filter_settings); } else $filter_values []= $filter_settings; $inverted_filter = $this->get_inverted_filter(); $filtered_positions = array (); foreach ($positions as $index => $position) { $insert = false; if (in_array ($index + 1, $filter_values)) { $insert = true; } else { foreach ($filter_values as $filter_value) { $filter_value = trim ($filter_value); if (isset ($filter_value [0]) && $filter_value [0] == '%') { $mod_value = substr ($filter_value, 1); $offset_value = 0; if (strpos ($mod_value, '@') !== false) { $mod_value_array = explode ('@', $mod_value); $mod_value = $mod_value_array [0]; $offset_value = $mod_value_array [1]; } if (is_numeric ($mod_value) && $mod_value > 0 && is_numeric ($offset_value)) { // if (($index + 1) % $mod_value == 0) { if ($index + 1 >= $offset_value && ($index + 1 - $offset_value) % $mod_value == 0) { $insert = true; break; } } } } } if ($insert xor $inverted_filter) $filtered_positions []= $position; } $positions = $filtered_positions; } } } } $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; if (!empty ($positions) && !$before_image) { // if (!isset ($paragraph_end_positions)) { // $paragraph_end_positions = array (); // get_paragraph_end_positions ($content, $multibyte, $paragraph_positions, $paragraph_start_strings, $paragraph_end_positions, $dummy); // } $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above()); $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below()); $avoid_text_above = $this->get_avoid_text_above(); $avoid_text_below = $this->get_avoid_text_below(); $avoid_paragraph_texts_above = explode (",", html_entity_decode (trim ($avoid_text_above))); $avoid_paragraph_texts_below = explode (",", html_entity_decode (trim ($avoid_text_below))); $check_direction = $this->get_avoid_direction(); $max_checks = $this->get_avoid_try_limit(); $check_strictly_inside_paragraphs = false; $failed_clearance_positions = array (); foreach ($positions as $position_index => $position) { $direction = $check_direction; if (($avoid_paragraphs_above != 0 || $avoid_paragraphs_below != 0) && count ($paragraph_positions) > $position) { if ($debug_processing && $this->number != 0) { ai_log ('---------------------------------'); ai_log ('BLOCK ' . $this->number . ' CLEARANCE CHECK POSITION ' . ($position + 1)); } $checks = $max_checks; $saved_position = $position; do { $found_above = false; $paragraph_text_found_above = ''; if ($position != 0 && $avoid_paragraphs_above != 0 && $avoid_text_above != "" && is_array ($avoid_paragraph_texts_above) && count ($avoid_paragraph_texts_above) != 0) { for ($avoid_paragraph_above = $avoid_paragraphs_above; $avoid_paragraph_above > 0; $avoid_paragraph_above --) { $paragraph_position_above = $position - $avoid_paragraph_above; if (!$check_strictly_inside_paragraphs) { if ($paragraph_position_above < 0) { // If paragraph position is not the first one start with the first paragraph if ($position != 0) $paragraph_position_above = 0; // Othewise do not check anything } } if ($paragraph_position_above >= 0) { if ($check_strictly_inside_paragraphs) { $start_position_above = $paragraph_positions [$paragraph_position_above]; $end_position_above = $paragraph_end_positions [$paragraph_position_above]; } else { $start_position_above = $paragraph_positions [$paragraph_position_above]; $end_position_above = $paragraph_positions [$position]; } if ($multibyte) { $paragraph_code = mb_substr ($content, $start_position_above, $end_position_above - $start_position_above); } else { $paragraph_code = substr ($content, $start_position_above, $end_position_above - $start_position_above); } foreach ($avoid_paragraph_texts_above as $paragraph_text_above) { if (trim ($paragraph_text_above) == '') continue; if ($multibyte) { if (mb_stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) { $found_above = true; $paragraph_text_found_above = $paragraph_text_above; break; } } else { if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) { $found_above = true; $paragraph_text_found_above = $paragraph_text_above; break; } } } } if ($found_above || !$check_strictly_inside_paragraphs) break; } } $found_below = false; $paragraph_text_found_below = ''; if ($avoid_paragraphs_below != 0 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) { for ($avoid_paragraph_below = $avoid_paragraphs_below; $avoid_paragraph_below > 0; $avoid_paragraph_below --) { $paragraph_position_below = $position + $avoid_paragraph_below - 1; if (!$check_strictly_inside_paragraphs) { if ($paragraph_position_below >= count ($paragraph_positions)) $paragraph_position_below = count ($paragraph_positions) - 1; } if ($paragraph_position_below < count ($paragraph_positions)) { if ($check_strictly_inside_paragraphs) { $start_position_below = $paragraph_positions [$paragraph_position_below]; $end_position_below = $paragraph_end_positions [$paragraph_position_below]; } else { $start_position_below = $paragraph_positions [$position]; $end_position_below = $paragraph_end_positions [$paragraph_position_below]; } if ($multibyte) { $paragraph_code = mb_substr ($content, $start_position_below, $end_position_below - $start_position_below); } else { $paragraph_code = substr ($content, $start_position_below, $end_position_below - $start_position_below); } foreach ($avoid_paragraph_texts_below as $paragraph_text_below) { if (trim ($paragraph_text_below) == '') continue; if ($multibyte) { if (mb_stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) { $found_below = true; $paragraph_text_found_below = $paragraph_text_below; break; } } else { if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) { $found_below = true; $paragraph_text_found_below = $paragraph_text_below; break; } } } } if ($found_below || !$check_strictly_inside_paragraphs) break; } } // echo "position: $position = before #", $position + 1, "
\n"; // echo "checks: $checks
\n"; // echo "direction: $direction
\n"; // if ($found_above) // echo "found_above
\n"; // if ($found_below) // echo "found_below
\n"; // echo "=================
\n"; if ($found_above || $found_below) { if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' CLEARANCE CHECK POSITION ' . ($position + 1) . ' FAILED (' . ($found_above ? 'ABOVE: ' . $paragraph_text_found_above .($found_below ? ', ' : '') : '') . ($found_below ? 'BELOW: ' . $paragraph_text_found_below : '') . ')'); $ai_last_check = AI_CHECK_DO_NOT_INSERT; if ($this->get_avoid_action() == AI_DO_NOT_INSERT) { $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break; } switch ($direction) { case AI_ABOVE: // Try above $ai_last_check = AI_CHECK_AD_ABOVE; // Already at the top - do not insert if ($position == 0) { $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break 2; } $position --; break; case AI_BELOW: // Try below $ai_last_check = AI_CHECK_AD_BELOW; // Already at the bottom - do not insert if ($position >= count ($paragraph_positions) - 1) { $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break 2; } $position ++; break; case AI_ABOVE_AND_THEN_BELOW: // Try first above and then below if ($position == 0 || $checks == 0) { // Try below $direction = AI_BELOW; $checks = $max_checks; $position = $saved_position; $ai_last_check = AI_CHECK_AD_BELOW; // Already at the bottom - do not insert if ($position >= count ($paragraph_positions) - 1) { $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break 2; } $position ++; } else $position --; break; case AI_BELOW_AND_THEN_ABOVE: // Try first below and then above if ($position >= count ($paragraph_positions) - 1 || $checks == 0) { // Try above $direction = AI_ABOVE; $checks = $max_checks; $position = $saved_position; $ai_last_check = AI_CHECK_AD_ABOVE; // Already at the top - do not insert if ($position == 0) { $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break 2; } $position --; } else $position ++; break; } } else { if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' CLEARANCE CHECK POSITION ' . ($position + 1) . ' OK'); // Text not found - insert $positions [$position_index] = $position; break; } // Try next position if ($checks <= 0) { // Suitable position not found - do not insert $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break; } $checks --; } while (true); } // Nothing to do $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE; if (count ($paragraph_positions) == 0) return $content; } if ($debug_processing && $this->number != 0) ai_log ('---------------------------------'); } if (!$before_image) { $no_insertion_first_paragraphs = intval ($this->get_skip_first_paragraphs ()); $no_insertion_last_paragraphs = intval ($this->get_skip_last_paragraphs ()); if ($no_insertion_first_paragraphs != 0 /*&& $no_insertion_first_paragraphs <= count ($paragraph_positions)*/) { foreach ($positions as $index => $position) { if ($position < $no_insertion_first_paragraphs) unset ($positions [$index]); } $positions = array_values ($positions); } if ($no_insertion_last_paragraphs != 0 /*&& $no_insertion_last_paragraphs <= count ($paragraph_positions)*/) { foreach ($positions as $index => $position) { if ($position >= count ($paragraph_positions) - $no_insertion_last_paragraphs) unset ($positions [$index]); } $positions = array_values ($positions); } } if ($position_preview || !empty ($positions)) { $offset = 0; if (!empty ($positions)) $ai_last_check = AI_CHECK_PARAGRAPH_NUMBER; $real_positions = array (); foreach ($positions as $position_index) $real_positions []= $position_index >= 0 ? $position_index + 1 : '*'; if ($debug_processing && $this->number != 0 && count ($real_positions) != 0) ai_log ('BLOCK ' . $this->number . ' INSERTION POSITIONS: ' . implode (', ', $real_positions)); $min_paragraphs = intval ($this->get_paragraph_number_minimum()); $max_paragraphs = intval ($this->get_paragraph_number_maximum()); $max_page_blocks_enabled = $this->get_max_page_blocks_enabled (); foreach ($paragraph_positions as $counter => $paragraph_position) { if ($position_preview) { if ($multibyte) { $paragraph_code = mb_substr ($content, $paragraph_position + $offset, $paragraph_end_positions [$counter] - $paragraph_position + 1); } else { $paragraph_code = substr ($content, $paragraph_position + $offset, $paragraph_end_positions [$counter] - $paragraph_position + 1); } $paragraph_words = number_of_words ($paragraph_code); $debug_label = $before_image ? 'BI' : 'BP'; $inserted_code = "[[AI_".$debug_label.($counter + 1)."=".$paragraph_words."]]"; } elseif (!empty ($positions) && in_array ($counter, $positions)) { $inserted = false; $ai_last_check = AI_CHECK_PARAGRAPHS_MIN_NUMBER; if (count ($paragraph_positions) >= $min_paragraphs) { $ai_last_check = AI_CHECK_PARAGRAPHS_MAX_NUMBER; if ($max_paragraphs <= 0 || count ($paragraph_positions) <= $max_paragraphs) { $ai_last_check = AI_CHECK_MAX_PAGE_BLOCKS; if (!$max_page_blocks_enabled || $ai_wp_data [AI_PAGE_BLOCKS] < get_max_page_blocks ()) { // Last check before insertion if ($this->check_and_increment_block_counter ()) { // Increment page block counter if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++; $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION; if (!$this->get_debug_disable_insertion ()) { $inserted_code = $this->get_code_for_serverside_insertion (); $ai_last_check = AI_CHECK_INSERTED; $this->clear_code_cache (); $inserted = true; } } } } } if ($debug_processing) ai_log (ai_log_block_status ($this->number, $ai_last_check)); if (!$inserted) continue; } else { if ($debug_processing && isset ($failed_clearance_positions [$counter])) ai_log (ai_log_block_status ($this->number, $failed_clearance_positions [$counter])); continue; } if ($multibyte) { if ($direction_type == AI_DIRECTION_FROM_BOTTOM) { $content = mb_substr ($content, 0, $paragraph_position) . $inserted_code . mb_substr ($content, $paragraph_position); } else { $content = mb_substr ($content, 0, $paragraph_position + $offset) . $inserted_code . mb_substr ($content, $paragraph_position + $offset); $offset += mb_strlen ($inserted_code); } } else { if ($direction_type == AI_DIRECTION_FROM_BOTTOM) { $content = substr_replace ($content, $inserted_code, $paragraph_position, 0); } else { $content = substr_replace ($content, $inserted_code, $paragraph_position + $offset, 0); $offset += strlen ($inserted_code); } } } $ai_last_check = AI_CHECK_NONE; // Already logged on each insertion return $content; } // empty $positions $ai_last_check = AI_CHECK_NO_PARAGRAPHS; return $content; } public function after_image ($content, $position_preview = false) { return $this->after_paragraph ($content, $position_preview, true); } public function after_paragraph ($content, $position_preview = false, $after_image = false) { global $ai_wp_data, $ai_last_check, $special_element_tags; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; $multibyte = $ai_wp_data [AI_MBSTRING_LOADED] && get_paragraph_counting_functions() == AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS; $paragraph_positions = array (); $active_paragraph_positions = array (); $dummy = array (); if ($multibyte) { $last_content_position = mb_strlen ($content) - 1; } else { $last_content_position = strlen ($content) - 1; } if ($after_image) { $paragraph_tags = 'figure,img,amp-img'; } else $paragraph_tags = trim ($this->get_paragraph_tags()); if ($paragraph_tags == '') return $content; $paragraph_end_strings = explode (",", $paragraph_tags); $ai_last_check = AI_CHECK_PARAGRAPH_TAGS; if (count ($paragraph_end_strings) == 0) return $content; get_paragraph_end_positions ($content, $multibyte, $dummy, $paragraph_end_strings, $paragraph_positions, $active_paragraph_positions); // Nothing to do $ai_last_check = AI_CHECK_PARAGRAPHS_WITH_TAGS; if (array_sum ($active_paragraph_positions) == 0) return $content; sort ($paragraph_positions); ksort ($active_paragraph_positions); $new_active_paragraph_positions = array (); foreach ($active_paragraph_positions as $active_paragraph_position) { $new_active_paragraph_positions [] = $active_paragraph_position; } $active_paragraph_positions = $new_active_paragraph_positions; if (!$this->get_count_inside_blockquote () || $after_image) { $special_element_offsets = array (); if ($after_image) { $special_element_tags_array = array_unique (array_merge ($special_element_tags, array ('figure', 'amp-img'))); } else $special_element_tags_array = $special_element_tags; foreach ($special_element_tags_array as $special_element_tag) { preg_match_all ("/<\/?$special_element_tag/i", $content, $special_elements, PREG_OFFSET_CAPTURE); $nesting = array (); $special_elements = $special_elements [0]; foreach ($special_elements as $index => $special_element) { if (isset ($special_elements [$index + 1][0])) { $tag1 = strtolower ($special_element [0]); $tag2 = strtolower ($special_elements [$index + 1][0]); $start_offset = $special_element [1]; $nesting_ended = false; $tag1_start = $tag1 == "<$special_element_tag"; $tag2_start = $tag2 == "<$special_element_tag"; $tag1_end = $tag1 == "= $special_element_offset [0] && $paragraph_position <= $special_element_offset [1]) $inside_special_element [] = $paragraph_position; } } foreach ($paragraph_positions as $index => $paragraph_position) { if (in_array ($paragraph_position, $inside_special_element)) $active_paragraph_positions [$index] = 0; } } $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE; if (array_sum ($active_paragraph_positions) == 0) return $content; } $element_tags = $this->get_count_inside_elements (); if ($element_tags != '') { $special_element_tags_array = explode (',', str_replace (' ', '', $element_tags)); $count_inside = $this->get_count_inside (); $element_text_type = $this->get_count_inside_elements_contain (); $check_only_tag_attributes = $this->get_check_only_tag_attributes (); $element_text = str_replace (' ', '', html_entity_decode ($this->get_count_inside_elements_text ())); if (strpos ($element_text, ",") !== false) { $element_texts = explode (',', $element_text); } elseif (trim ($element_text) != '') $element_texts = array (trim ($element_text)); else $element_texts = array (); $special_element_offsets = array (); foreach ($special_element_tags_array as $special_element_tag) { preg_match_all ("/<\/?$special_element_tag/i", $content, $special_elements, PREG_OFFSET_CAPTURE); $special_elements = $special_elements [0]; if (count ($special_elements) % 2 != 0) { if ($debug_processing) ai_log ('INVALID TAGS: ODD NUMBER OF ' . $special_element_tag . ' TAGS'); } $elements = array (); $nesting = array (); foreach ($special_elements as $index => $special_element) { $tag = strtolower ($special_element [0]); $tag_start = $tag == "<$special_element_tag"; $tag_end = $tag == "]+?)>#', $search_content, $search_content_tag); if (isset ($search_content_tag [1])) { $search_content = $search_content_tag [1]; } } if (stripos ($search_content, $element_text)) { $check = true; break; } } switch ($element_text_type) { case AI_CONTAIN: if ($check) { $special_element_offsets []= $element_offsets; } break; default: if (!$check) { $special_element_offsets []= $element_offsets; } break; } } else { $special_element_offsets []= $element_offsets; } } } $inside_special_element = array (); if (count ($special_element_offsets) != 0) { foreach ($special_element_offsets as $special_element_offset) { foreach ($paragraph_positions as $paragraph_position) { if ($paragraph_position >= $special_element_offset [0] && $paragraph_position <= $special_element_offset [1]) $inside_special_element [] = $paragraph_position; } } } foreach ($paragraph_positions as $index => $paragraph_position) { $paragraph_inside = in_array ($paragraph_position, $inside_special_element); switch ($count_inside) { case AI_COUNT_ONLY: if (!$paragraph_inside) $active_paragraph_positions [$index] = 0; break; default: if ($paragraph_inside) $active_paragraph_positions [$index] = 0; break; } } $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE_ELEMENTS; if (array_sum ($active_paragraph_positions) == 0) return $content; } if (!$after_image) { $paragraph_min_words = intval ($this->get_minimum_paragraph_words()); $paragraph_max_words = intval ($this->get_maximum_paragraph_words()); if ($paragraph_min_words != 0 || $paragraph_max_words != 0) { if (!isset ($paragraph_start_positions)) { $paragraph_start_positions = array (); get_paragraph_start_positions ($content, $multibyte, $paragraph_positions, $paragraph_end_strings, $paragraph_start_positions, $dummy); } foreach ($paragraph_positions as $index => $paragraph_position) { if ($active_paragraph_positions [$index] == 0) continue; if ($multibyte) { $paragraph_code = mb_substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1); } else { $paragraph_code = substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1); } if (!$this->check_number_of_words_in_paragraph ($paragraph_code, $paragraph_min_words, $paragraph_max_words)) $active_paragraph_positions [$index] = 0; } } // Nothing to do $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS; if (array_sum ($active_paragraph_positions) == 0) return $content; $paragraph_texts = explode (",", html_entity_decode ($this->get_paragraph_text())); if ($this->get_paragraph_text() != "" && count ($paragraph_texts) != 0) { if (!isset ($paragraph_start_positions)) { $paragraph_start_positions = array (); get_paragraph_start_positions ($content, $multibyte, $paragraph_positions, $paragraph_end_strings, $paragraph_start_positions, $dummy); } $paragraph_text_type = $this->get_paragraph_text_type (); foreach ($paragraph_positions as $index => $paragraph_position) { if ($active_paragraph_positions [$index] == 0) continue; if ($multibyte) { $paragraph_code = mb_substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1); } else { $paragraph_code = substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1); } if ($paragraph_text_type == AI_CONTAIN) { $found = true; foreach ($paragraph_texts as $paragraph_text) { if (trim ($paragraph_text) == '') continue; $paragraph_text = trim ($paragraph_text); $invert = false; if ($paragraph_text [0] == '^') { $paragraph_text = substr ($paragraph_text, 1); $invert = true; } if ($multibyte) { $paragraph_text_found = mb_stripos ($paragraph_code, $paragraph_text) !== false; if ($invert) { $paragraph_text_found = !$paragraph_text_found; } if (!$paragraph_text_found) { $found = false; break; } } else { $paragraph_text_found = stripos ($paragraph_code, $paragraph_text) !== false; if ($invert) { $paragraph_text_found = !$paragraph_text_found; } if (!$paragraph_text_found) { $found = false; break; } } } if (!$found) $active_paragraph_positions [$index] = 0; } elseif ($paragraph_text_type == AI_DO_NOT_CONTAIN) { $found = false; foreach ($paragraph_texts as $paragraph_text) { if (trim ($paragraph_text) == '') continue; $paragraph_text = trim ($paragraph_text); $invert = false; if ($paragraph_text [0] == '^') { $paragraph_text = substr ($paragraph_text, 1); $invert = true; } if ($multibyte) { $paragraph_text_found = mb_stripos ($paragraph_code, $paragraph_text) !== false; if ($invert) { $paragraph_text_found = !$paragraph_text_found; } if ($paragraph_text_found) { $found = true; break; } } else { $paragraph_text_found = stripos ($paragraph_code, $paragraph_text) !== false; if ($invert) { $paragraph_text_found = !$paragraph_text_found; } if ($paragraph_text_found) { $found = true; break; } } } if ($found) $active_paragraph_positions [$index] = 0; } } } // Nothing to do $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_TEXT; if (array_sum ($active_paragraph_positions) == 0) return $content; } // !$after_image $position_text = trim ($this->get_paragraph_number()); if ($after_image) { $direction_type = AI_DIRECTION_FROM_TOP; } else $direction_type = $this->get_direction_type(); // Prepare $paragraph_start_positions // if ($position_preview || $position_text == '') { // Prepare always if (!isset ($paragraph_start_positions)) { $paragraph_start_positions = array (); get_paragraph_start_positions ($content, $multibyte, $paragraph_positions, $paragraph_end_strings, $paragraph_start_positions, $dummy); } $filtered_paragraph_positions = array (); // Use $paragraph_positions for counting as it is checked for consistency foreach ($paragraph_positions as $index => $paragraph_position) { if ($active_paragraph_positions [$index]) $filtered_paragraph_positions [] = $paragraph_start_positions [$index]; } $paragraph_start_positions = $filtered_paragraph_positions; if ($direction_type == AI_DIRECTION_FROM_BOTTOM) { $paragraph_start_positions = array_reverse ($paragraph_start_positions); } // } $filtered_paragraph_positions = array (); foreach ($paragraph_positions as $index => $paragraph_position) { if ($active_paragraph_positions [$index]) $filtered_paragraph_positions [] = $paragraph_position; } $paragraph_positions = $filtered_paragraph_positions; if ($direction_type == AI_DIRECTION_FROM_BOTTOM) { $paragraph_positions = array_reverse ($paragraph_positions); } // $positions contains indexes in $paragraph_positions $positions = array (); if (!$position_preview) { if (strpos ($position_text, '[') !== false) { $random_range = false; for ($i = 0; $i < strlen ($position_text); $i ++) { switch ($position_text [$i]) { case '[': $random_range = true; break; case ']': $random_range = false; break; case ',': if ($random_range) { $position_text [$i] = '|'; } break; } } } $position = $position_text; if (is_numeric ($position)) { if ($position > 0 && $position < 1) { $position = intval ($position * (count ($paragraph_positions) - 1) + 0.5); } elseif ($position > - 1 && $position < 0) { $position = intval (count ($paragraph_positions) + $position * (count ($paragraph_positions) - 1) - 0.5); } elseif ($position <= - 1) { $position = count ($paragraph_positions) + $position; } elseif ($position == 0) { $position = mt_rand (0, count ($paragraph_positions) - 1); } else $position --; $positions = array ($position); } elseif (strpos ($position_text, '[') === 0 && strpos ($position_text, ']') === strlen ($position_text) - 1) { $wanted_paragraphs_text = trim (substr ($position_text, 1, strlen ($position_text) - 2)); $wanted_paragraph_ranges = array (); $wanted_paragraphs = array (); if (strpos ($position_text, '|') !== false) { $items = explode ('|', str_replace (' ', '', $wanted_paragraphs_text)); foreach ($items as $item) { $wanted_paragraph_ranges []= $item; } } else $wanted_paragraph_ranges []= $wanted_paragraphs_text; foreach ($wanted_paragraph_ranges as $wanted_paragraph_range) { if (strpos ($wanted_paragraph_range, '-') !== false) { $limits = explode ('-', $wanted_paragraph_range); $limit_min = (int) $limits [0]; $limit_max = (int) $limits [1]; } else { $limit_min = (int) $wanted_paragraph_range; $limit_max = (int) $wanted_paragraph_range; } if ($limit_min < 0) $limit_min = 0; else if ($limit_min > 9999) $limit_min = 9999; if ($limit_max < 0) $limit_max = 0; else if ($limit_max > 9999) $limit_max = 9999; if ($limit_min > $limit_max) $limit_max = $limit_min; while ($limit_max >= $limit_min) { $wanted_paragraphs [] = $limit_max; $limit_max --; } } $wanted_paragraphs = array_unique ($wanted_paragraphs); sort ($wanted_paragraphs); if (count ($wanted_paragraphs) == 0) $wanted_paragraphs = array (0); $random_paragraph = mt_rand (0, count ($wanted_paragraphs) - 1); $paragraph = $wanted_paragraphs [$random_paragraph]; if ($paragraph == 0) { $paragraph = mt_rand (0, count ($paragraph_positions) - 1); } else $paragraph --; $positions = array ($paragraph); if ($debug_processing) { ai_log ('BLOCK ' . $this->number . ' RANDOM PARAGRAPHS ' . str_replace ('|', ', ', $position_text) . ' => [' . implode (',', $wanted_paragraphs) . '] of ' . count ($paragraph_positions) . ' => ' . ($paragraph + 1)); } } elseif (strpos ($position_text, ',') !== false) { if ($debug_processing) { ai_log ('BLOCK ' . $this->number . ' AFTER PARAGRAPHS ' . str_replace ('|', ', ', $position_text) . ' of ' . count ($paragraph_positions) . ' available'); } $new_positions = array (); $positions = explode (',', str_replace (' ', '', $position_text)); foreach ($positions as $index => $position) { if (isset ($position [0]) && strpos ($position, '[') === 0 && strpos ($position, ']') === strlen ($position) - 1) { $wanted_paragraphs_text = trim (substr ($position, 1, strlen ($position) - 2)); $wanted_paragraph_ranges = array (); $wanted_paragraphs = array (); if (strpos ($position, '|') !== false) { $items = explode ('|', str_replace (' ', '', $wanted_paragraphs_text)); foreach ($items as $item) { $wanted_paragraph_ranges []= $item; } } else $wanted_paragraph_ranges []= $wanted_paragraphs_text; foreach ($wanted_paragraph_ranges as $wanted_paragraph_range) { if (strpos ($wanted_paragraph_range, '-') !== false) { $limits = explode ('-', $wanted_paragraph_range); $limit_min = (int) $limits [0]; $limit_max = (int) $limits [1]; } else { $limit_min = (int) $wanted_paragraph_range; $limit_max = (int) $wanted_paragraph_range; } if ($limit_min < 0) $limit_min = 0; else if ($limit_min > 9999) $limit_min = 9999; if ($limit_max < 0) $limit_max = 0; else if ($limit_max > 9999) $limit_max = 9999; if ($limit_min > $limit_max) $limit_max = $limit_min; while ($limit_max >= $limit_min) { $wanted_paragraphs [] = $limit_max; $limit_max --; } } $wanted_paragraphs = array_unique ($wanted_paragraphs); sort ($wanted_paragraphs); if (count ($wanted_paragraphs) == 0) $wanted_paragraphs = array (0); $random_paragraph = mt_rand (0, count ($wanted_paragraphs) - 1); $paragraph = $wanted_paragraphs [$random_paragraph]; if ($paragraph == 0) { $paragraph = mt_rand (0, count ($paragraph_positions) - 1); } else $paragraph --; $positions [$index] = $paragraph; if ($debug_processing) { ai_log ('BLOCK ' . $this->number . ' RANDOM PARAGRAPHS ' . str_replace ('|', ', ', $position) . ' => [' . implode (', ', $wanted_paragraphs) . '] of ' . count ($paragraph_positions) . ' => ' . ($paragraph + 1)); } } elseif (isset ($position [0]) && $position [0] == '%') { unset ($positions [$index]); $position = substr ($position, 1); $mod_value = $position; $offset_value = 0; if (strpos ($mod_value, '@') !== false) { $mod_value_array = explode ('@', $mod_value); $mod_value = $mod_value_array [0]; $offset_value = $mod_value_array [1]; } if (is_numeric ($mod_value) && $mod_value > 0 && is_numeric ($offset_value)) { foreach ($paragraph_positions as $index => $paragraph_position) { if ($index + 1 < $offset_value) continue; if (($index + 1 - $offset_value) % $mod_value == 0) $new_positions []= $index; } } } elseif (is_numeric ($position) && $position > 0 && $position < 1) { $positions [$index] = intval ($position * (count ($paragraph_positions) - 1) + 0.5); } elseif (is_numeric ($position) && $position > - 1 && $position < 0) { $positions [$index] = intval (count ($paragraph_positions) + $position * (count ($paragraph_positions) - 1) - 0.5); } elseif (is_numeric ($position) && $position <= - 1) { $positions [$index] = count ($paragraph_positions) + $position; } elseif ($position == 0) { $positions [$index] = mt_rand (0, count ($paragraph_positions) - 1); } else $positions [$index] = (int) $position - 1; } $positions = array_unique (array_merge ($positions, $new_positions)); sort ($positions); } elseif (isset ($position_text [0]) && $position_text [0] == '%') { $position_text = substr ($position_text, 1); $mod_value = $position_text; $offset_value = 0; if (strpos ($mod_value, '@') !== false) { $mod_value_array = explode ('@', $mod_value); $mod_value = $mod_value_array [0]; $offset_value = $mod_value_array [1]; } if (is_numeric ($mod_value) && $mod_value > 0 && is_numeric ($offset_value)) { foreach ($paragraph_positions as $index => $paragraph_position) { if ($index + 1 < $offset_value) continue; if (($index + 1 - $offset_value) % $mod_value == 0) $positions []= $index; } } } elseif ($position_text == '') { $positions = array (); $min_words_above = $this->get_minimum_words_above (); if (!empty ($min_words_above) && !$after_image) { $words_above = 0; foreach ($paragraph_positions as $index => $paragraph_position) { if ($direction_type == AI_DIRECTION_FROM_BOTTOM) { if ($words_above >= $min_words_above) { $positions []= $index; $words_above = 0; } } if ($multibyte) { $paragraph_code = mb_substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1); } else { $paragraph_code = substr ($content, $paragraph_start_positions [$index], $paragraph_position - $paragraph_start_positions [$index] + 1); } $words_above += number_of_words ($paragraph_code); if ($direction_type != AI_DIRECTION_FROM_BOTTOM) { if ($words_above >= $min_words_above) { $positions []= $index; $words_above = 0; } } } } else foreach ($paragraph_positions as $index => $paragraph_position) { $positions []= $index; } $filter_settings = trim (str_replace (' ', '', $this->get_call_filter())); if (!empty ($filter_settings)) { $filter_counter = $after_image ? AI_FILTER_IMAGES : AI_FILTER_PARAGRAPHS; if ($this->get_filter_type() == $filter_counter) { $filter_values = array (); if (strpos ($filter_settings, ",") !== false) { $filter_values = explode (",", $filter_settings); } else $filter_values []= $filter_settings; $inverted_filter = $this->get_inverted_filter(); $filtered_positions = array (); foreach ($positions as $index => $position) { $insert = false; if (in_array ($index + 1, $filter_values)) { $insert = true; } else { foreach ($filter_values as $filter_value) { $filter_value = trim ($filter_value); if (isset ($filter_value [0]) && $filter_value [0] == '%') { $mod_value = substr ($filter_value, 1); $offset_value = 0; if (strpos ($mod_value, '@') !== false) { $mod_value_array = explode ('@', $mod_value); $mod_value = $mod_value_array [0]; $offset_value = $mod_value_array [1]; } // if (is_numeric ($mod_value) && $mod_value > 0) { if (is_numeric ($mod_value) && $mod_value > 0 && is_numeric ($offset_value)) { // if (($index + 1) % $mod_value == 0) { if ($index + 1 >= $offset_value && ($index + 1 - $offset_value) % $mod_value == 0) { $insert = true; break; } } } } } if ($insert xor $inverted_filter) $filtered_positions []= $position; } $positions = $filtered_positions; } } } } $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; if (!empty ($positions) && !$after_image) { // Not needed anymore // if (!isset ($paragraph_start_positions)) { // $paragraph_start_positions = array (); // get_paragraph_start_positions ($content, $multibyte, $paragraph_positions, $paragraph_end_strings, $paragraph_start_positions, $dummy); // } $avoid_paragraphs_above = intval ($this->get_avoid_paragraphs_above()); $avoid_paragraphs_below = intval ($this->get_avoid_paragraphs_below()); $avoid_text_above = $this->get_avoid_text_above(); $avoid_text_below = $this->get_avoid_text_below(); $avoid_paragraph_texts_above = explode (",", html_entity_decode (trim ($avoid_text_above))); $avoid_paragraph_texts_below = explode (",", html_entity_decode (trim ($avoid_text_below))); $check_direction = $this->get_avoid_direction(); $max_checks = $this->get_avoid_try_limit(); $check_strictly_inside_paragraphs = false; $failed_clearance_positions = array (); foreach ($positions as $position_index => $position) { $direction = $check_direction; if (($avoid_paragraphs_above != 0 || $avoid_paragraphs_below != 0) && count ($paragraph_positions) > $position) { if ($debug_processing && $this->number != 0) { ai_log ('---------------------------------'); ai_log ('BLOCK ' . $this->number . ' CLEARANCE CHECK POSITION ' . ($position + 1)); } $checks = $max_checks; $saved_position = $position; do { $found_above = false; $paragraph_text_found_above = ''; if ($avoid_paragraphs_above != 0 && $avoid_text_above != "" && is_array ($avoid_paragraph_texts_above) && count ($avoid_paragraph_texts_above) != 0) { for ($avoid_paragraph_above = $avoid_paragraphs_above; $avoid_paragraph_above > 0; $avoid_paragraph_above --) { $paragraph_position_above = $position - $avoid_paragraph_above + 1; if (!$check_strictly_inside_paragraphs) { if ($paragraph_position_above < 0) $paragraph_position_above = 0; } if ($paragraph_position_above >= 0) { if ($check_strictly_inside_paragraphs) { $start_position_above = $paragraph_start_positions [$paragraph_position_above]; $end_position_above = $paragraph_positions [$paragraph_position_above]; } else { $start_position_above = $paragraph_start_positions [$paragraph_position_above]; $end_position_above = $paragraph_positions [$position]; } if ($multibyte) { $paragraph_code = mb_substr ($content, $start_position_above, $end_position_above - $start_position_above); } else { $paragraph_code = substr ($content, $start_position_above, $end_position_above - $start_position_above); } foreach ($avoid_paragraph_texts_above as $paragraph_text_above) { if (trim ($paragraph_text_above) == '') continue; if ($multibyte) { if (mb_stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) { $found_above = true; $paragraph_text_found_above = $paragraph_text_above; break; } } else { if (stripos ($paragraph_code, trim ($paragraph_text_above)) !== false) { $found_above = true; $paragraph_text_found_above = $paragraph_text_above; break; } } } } if ($found_above || !$check_strictly_inside_paragraphs) break; } } $found_below = false; $paragraph_text_found_below = ''; if ($avoid_paragraphs_below != 0 && $position != count ($paragraph_positions) - 1 && $avoid_text_below != "" && is_array ($avoid_paragraph_texts_below) && count ($avoid_paragraph_texts_below) != 0) { for ($avoid_paragraph_below = $avoid_paragraphs_below; $avoid_paragraph_below > 0; $avoid_paragraph_below --) { $paragraph_position_below = $position + $avoid_paragraph_below; if (!$check_strictly_inside_paragraphs) { if ($paragraph_position_below >= count ($paragraph_positions)) { // If paragraph position is not the last one end with the last paragraph if ($position != count ($paragraph_positions) - 1) $paragraph_position_below = count ($paragraph_positions) - 1; // Othewise do not check anything } } if ($paragraph_position_below < count ($paragraph_positions)) { if ($check_strictly_inside_paragraphs) { $start_position_below = $paragraph_start_positions [$paragraph_position_below]; $end_position_below = $paragraph_positions [$paragraph_position_below]; } else { $start_position_below = $paragraph_positions [$position]; $end_position_below = $paragraph_positions [$paragraph_position_below]; } if ($multibyte) { $paragraph_code = mb_substr ($content, $start_position_below, $end_position_below - $start_position_below); } else { $paragraph_code = substr ($content, $start_position_below, $end_position_below - $start_position_below); } foreach ($avoid_paragraph_texts_below as $paragraph_text_below) { if (trim ($paragraph_text_below) == '') continue; if ($multibyte) { if (mb_stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) { $found_below = true; $paragraph_text_found_below = $paragraph_text_below; break; } } else { if (stripos ($paragraph_code, trim ($paragraph_text_below)) !== false) { $found_below = true; $paragraph_text_found_below = $paragraph_text_below; break; } } } } if ($found_below || !$check_strictly_inside_paragraphs) break; } } // echo "position: $position = after #", $position + 1, "
\n"; // echo "checks: $checks
\n"; // echo "direction: $direction
\n"; // if ($found_above) // echo "found_above
\n"; // if ($found_below) // echo "found_below
\n"; // echo "=================
\n"; if ($found_above || $found_below) { if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' CLEARANCE CHECK POSITION ' . ($position + 1) . ' FAILED (' . ($found_above ? 'ABOVE: ' . $paragraph_text_found_above .($found_below ? ', ' : '') : '') . ($found_below ? 'BELOW: ' . $paragraph_text_found_below : '') . ')'); $ai_last_check = AI_CHECK_DO_NOT_INSERT; if ($this->get_avoid_action() == AI_DO_NOT_INSERT) { $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break; } switch ($direction) { case AI_ABOVE: // Try above $ai_last_check = AI_CHECK_AD_ABOVE; // Already at the top - do not insert if ($position == 0) { $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break 2; } $position --; break; case AI_BELOW: // Try below $ai_last_check = AI_CHECK_AD_BELOW; // Already at the bottom - do not insert if ($position >= count ($paragraph_positions) - 1) { $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break 2; } $position ++; break; case AI_ABOVE_AND_THEN_BELOW: // Try first above and then below if ($position == 0 || $checks == 0) { // Try below $direction = AI_BELOW; $checks = $max_checks; $position = $saved_position; $ai_last_check = AI_CHECK_AD_BELOW; // Already at the bottom - do not insert if ($position >= count ($paragraph_positions) - 1) { $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break 2; } $position ++; } else $position --; break; case AI_BELOW_AND_THEN_ABOVE: // Try first below and then above if ($position >= count ($paragraph_positions) - 1 || $checks == 0) { // Try above $direction = AI_ABOVE; $checks = $max_checks; $position = $saved_position; $ai_last_check = AI_CHECK_AD_ABOVE; // Already at the top - do not insert if ($position == 0) { $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break 2; } $position --; } else $position ++; break; } } else { if ($debug_processing && $this->number != 0) ai_log ('BLOCK ' . $this->number . ' CLEARANCE CHECK POSITION ' . ($position + 1) . ' OK'); // Text not found - insert $positions [$position_index] = $position; break; } // Try next position if ($checks <= 0) { // Suitable position not found - do not insert $failed_clearance_positions [$positions [$position_index]] = $ai_last_check; $positions [$position_index] = - 1; break; } $checks --; } while (true); } // Nothing to do $ai_last_check = AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE; if (count ($paragraph_positions) == 0) return $content; } if ($debug_processing && $this->number != 0) ai_log ('---------------------------------'); } if (!$after_image) { $no_insertion_first_paragraphs = intval ($this->get_skip_first_paragraphs ()); $no_insertion_last_paragraphs = intval ($this->get_skip_last_paragraphs ()); if ($no_insertion_first_paragraphs != 0 /*&& $no_insertion_first_paragraphs <= count ($paragraph_positions)*/) { foreach ($positions as $index => $position) { if ($position < $no_insertion_first_paragraphs) unset ($positions [$index]); } $positions = array_values ($positions); } if ($no_insertion_last_paragraphs != 0 /*&& $no_insertion_last_paragraphs <= count ($paragraph_positions)*/) { foreach ($positions as $index => $position) { if ($position >= count ($paragraph_positions) - $no_insertion_last_paragraphs) unset ($positions [$index]); } $positions = array_values ($positions); } } if ($position_preview || !empty ($positions)) { $offset = 0; if (!empty ($positions)) $ai_last_check = AI_CHECK_PARAGRAPH_NUMBER; $real_positions = array (); foreach ($positions as $position_index) $real_positions []= $position_index >= 0 ? $position_index + 1 : '*'; if ($debug_processing && $this->number != 0 && count ($real_positions) != 0) ai_log ('BLOCK ' . $this->number . ' INSERTION POSITIONS: ' . implode (', ', $real_positions) . ' of ' . count ($paragraph_positions)); $min_paragraphs = intval ($this->get_paragraph_number_minimum()); $max_paragraphs = intval ($this->get_paragraph_number_maximum()); $max_page_blocks_enabled = $this->get_max_page_blocks_enabled (); foreach ($paragraph_positions as $counter => $paragraph_position) { $debug_label = $after_image ? 'AI' : 'AP'; if ($position_preview) $inserted_code = "[[AI_".$debug_label.($counter + 1)."]]"; elseif (!empty ($positions) && in_array ($counter, $positions)) { $inserted = false; $ai_last_check = AI_CHECK_PARAGRAPHS_MIN_NUMBER; if (count ($paragraph_positions) >= $min_paragraphs) { $ai_last_check = AI_CHECK_PARAGRAPHS_MAX_NUMBER; if ($max_paragraphs <= 0 || count ($paragraph_positions) <= $max_paragraphs) { $ai_last_check = AI_CHECK_MAX_PAGE_BLOCKS; if (!$max_page_blocks_enabled || $ai_wp_data [AI_PAGE_BLOCKS] < get_max_page_blocks ()) { // Last check before insertion if ($this->check_and_increment_block_counter ()) { // Increment page block counter if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++; $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION; if (!$this->get_debug_disable_insertion ()) { $inserted_code = $this->get_code_for_serverside_insertion (); $ai_last_check = AI_CHECK_INSERTED; $this->clear_code_cache (); $inserted = true; } } } } } if ($debug_processing) ai_log (ai_log_block_status ($this->number, $ai_last_check)); if (!$inserted) continue; } else { if ($debug_processing && isset ($failed_clearance_positions [$counter])) ai_log (ai_log_block_status ($this->number, $failed_clearance_positions [$counter])); continue; } if ($multibyte) { if ($direction_type == AI_DIRECTION_FROM_BOTTOM) { $content = mb_substr ($content, 0, $paragraph_position + 1) . $inserted_code . mb_substr ($content, $paragraph_position + 1); } else { $content = mb_substr ($content, 0, $paragraph_position + $offset + 1) . $inserted_code . mb_substr ($content, $paragraph_position + $offset + 1); $offset += mb_strlen ($inserted_code); } } else { if ($direction_type == AI_DIRECTION_FROM_BOTTOM) { $content = substr_replace ($content, $inserted_code, $paragraph_position + 1, 0); } else { $content = substr_replace ($content, $inserted_code, $paragraph_position + $offset + 1, 0); $offset += strlen ($inserted_code); } } } $ai_last_check = AI_CHECK_NONE; // Already logged on each insertion return $content; } // empty $positions $ai_last_check = AI_CHECK_NO_PARAGRAPHS; return $content; } // Deprecated function manual ($content){ if (preg_match_all("/{adinserter (.+?)}/", $content, $tags)){ $block_class_name = get_block_class_name (); $viewport_classes = $this->get_viewport_classes (); if ($block_class_name != '' || $viewport_classes != '') { if ($block_class_name =='') $viewport_classes = trim ($viewport_classes); $class = " class='" . ($block_class_name != '' ? $block_class_name . " " . $block_class_name . "-" . $this->number : '') . $viewport_classes ."'"; } else $class = ''; // $display_for_devices = $this->get_display_for_devices (); foreach ($tags [1] as $tag) { $ad_tag = strtolower (trim ($tag)); $ad_name = strtolower (trim ($this->get_ad_name())); if ($ad_tag == $ad_name || $ad_tag == $this->number) { if ($this->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) $ad_code = $this->ai_getProcessedCode (); else $ad_code = "" . $this->ai_getProcessedCode () . ""; $content = preg_replace ("/{adinserter " . $tag . "}/", $ad_code, $content); } } } return $content; } // Deprecated function display_disabled ($content){ $ad_name = $this->get_ad_name(); if (preg_match ("//i", $content)) return true; if (preg_match ("//i", $content)) return true; if (preg_match ("//i", $content)) return true; if (strpos ($content, "") != false) return true; return false; } function check_disabled () { global $ai_wp_data; if (isset ($ai_wp_data [AI_DISABLED_BLOCKS])) { if (in_array ($this->number, $ai_wp_data [AI_DISABLED_BLOCKS])) { return false; } if (in_array ('#', $ai_wp_data [AI_DISABLED_BLOCKS])) { return false; } } return true; } function check_category ($categories = null, $cat_type = AI_WHITE_LIST) { global $ai_wp_data; if ($categories === null) { $categories = trim (strtolower ($this->get_ad_block_cat())); $cat_type = $this->get_ad_block_cat_type(); } if ($categories == AD_EMPTY_DATA) return true; switch ($ai_wp_data [AI_WP_PAGE_TYPE]) { case AI_PT_STATIC: case AI_PT_POST: $wp_categories = get_the_category (); break; default: $wp_categories = get_queried_object(); if ($wp_categories instanceof WP_Term) { $wp_categories = array ($wp_categories); } else $wp_categories = array (); break; } if ($cat_type == AI_BLACK_LIST) { // if ($categories == AD_EMPTY_DATA) return true; $cats_listed = explode (",", $categories); foreach ($wp_categories as $wp_category) { if (isset ($wp_category->cat_name) && isset ($wp_category->slug)) foreach ($cats_listed as $cat_disabled) { $check_parent = true; $check_childern = false; $cat_disabled = trim ($cat_disabled); if (substr ($cat_disabled, - 1) == '*') { $check_childern = true; $cat_disabled = rtrim ($cat_disabled, '*'); } elseif (substr ($cat_disabled, - 1) == '+') { $check_parent = false; $check_childern = true; $cat_disabled = rtrim ($cat_disabled, '+'); } $wp_category_name = strtolower ($wp_category->cat_name); $wp_category_slug = strtolower ($wp_category->slug); if ($check_parent) { if ($wp_category_name == $cat_disabled || $wp_category_slug == $cat_disabled) { return false; } } if ($check_childern) { if (ai_post_is_in_child_categories ($cat_disabled)) { return false; } } } } return true; } else { // if ($categories == AD_EMPTY_DATA) return false; $cats_listed = explode (",", $categories); foreach ($wp_categories as $wp_category) { if (isset ($wp_category->cat_name) && isset ($wp_category->slug)) foreach ($cats_listed as $cat_enabled) { $check_parent = true; $check_childern = false; $cat_enabled = trim ($cat_enabled); if (substr ($cat_enabled, - 1) == '*') { $check_childern = true; $cat_enabled = rtrim ($cat_enabled, '*'); } elseif (substr ($cat_enabled, - 1) == '+') { $check_parent = false; $check_childern = true; $cat_enabled = rtrim ($cat_enabled, '+'); } $wp_category_name = strtolower ($wp_category->cat_name); $wp_category_slug = strtolower ($wp_category->slug); if ($check_parent) { if ($wp_category_name == $cat_enabled || $wp_category_slug == $cat_enabled) { return true; } } if ($check_childern) { if (ai_post_is_in_child_categories ($cat_enabled)) { return true; } } } } return false; } } function check_tag ($tags = null, $tag_type = AI_WHITE_LIST) { if ($tags === null) { $tags = $this->get_ad_block_tag(); $tag_type = $this->get_ad_block_tag_type(); } $tags = trim ($tags); if ($tags == AD_EMPTY_DATA) return true; $tags_listed = explode (",", $tags); foreach ($tags_listed as $index => $tag_listed) { $tags_listed [$index] = trim ($tag_listed); } // $has_any_of_the_given_tags = has_tag ($tags_listed); $has_any_of_the_given_tags = has_tag ($tags_listed, ai_get_post_id ()); if ($tag_type == AI_BLACK_LIST) { // if ($tags == AD_EMPTY_DATA) return true; if (is_tag()) { foreach ($tags_listed as $tag_listed) { if (is_tag ($tag_listed)) return false; } return true; } return !$has_any_of_the_given_tags; } else { // if ($tags == AD_EMPTY_DATA) return false; if (is_tag()) { foreach ($tags_listed as $tag_listed) { if (is_tag ($tag_listed)) return true; } return false; } return $has_any_of_the_given_tags; } } function check_taxonomy ($taxonomies = null, $taxonomy_type = AI_WHITE_LIST) { global $ai_wp_data; if ($taxonomies === null) { $taxonomies = trim ($this->get_ad_block_taxonomy ()); $taxonomy_type = $this->get_ad_block_taxonomy_type(); } if ($taxonomies == AD_EMPTY_DATA) return true; if ($taxonomy_type == AI_BLACK_LIST) { $taxonomies_listed = explode (",", $taxonomies); foreach ($taxonomies_listed as $taxonomy_disabled) { $taxonomy_disabled_org = trim ($taxonomy_disabled); $taxonomy_disabled = strtolower ($taxonomy_disabled_org); if (strpos ($taxonomy_disabled, 'user:') === 0) { $current_user = wp_get_current_user(); $terms = explode (':', $taxonomy_disabled); if ($terms [1] == 'logged-in') { return !is_user_logged_in (); } elseif ($terms [1] == 'not-logged-in') { return is_user_logged_in (); } if ($terms [1] == $current_user->user_login) return false; } elseif (strpos ($taxonomy_disabled, 'author:') === 0) { if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) $current_author = strtolower (get_the_author_meta ('user_login')); else $current_author = ''; $terms = explode (':', $taxonomy_disabled); if ($terms [1] == $current_author) return false; } elseif (strpos ($taxonomy_disabled, 'user-role:') === 0) { $current_user = wp_get_current_user(); $terms = explode (':', $taxonomy_disabled); foreach (wp_get_current_user()->roles as $role) { if ($terms [1] == $role) return false; } } elseif (strpos ($taxonomy_disabled, 'post-type:') === 0) { $post_type = get_post_type (); $terms = explode (':', $taxonomy_disabled); if ($terms [1] == $post_type) return false; } elseif (strpos ($taxonomy_disabled, 'primary-category:') === 0) { $primary_category = explode (':', $taxonomy_disabled); if ($primary_category [1] == ai_primary_category ()) return false; } elseif (strpos ($taxonomy_disabled, 'yoast-primary-category:') === 0) { $primary_category = explode (':', $taxonomy_disabled); if ($primary_category [1] == ai_yoast_primary_category ()) return false; } elseif (strpos ($taxonomy_disabled, 'multisite:') === 0) { if (is_multisite () && function_exists ('ai_plugin_settings')) { $site_id = explode (':', $taxonomy_disabled); if ($site_id [1] == '#' && is_main_site ()) return false; if (get_current_blog_id () == $site_id [1]) return false; } else return true; } elseif (strpos ($taxonomy_disabled_org, 'meta:') === 0) { $meta_data = explode (':', str_replace ('meta:', '', $taxonomy_disabled_org)); if (count ($meta_data) == 2) { if (get_post_meta (get_the_id (), $meta_data [0], true) == $meta_data [1]) return false; } else { if (get_post_meta (get_the_id (), $meta_data [0], true) != '') return false; } } $taxonomy_names = get_post_taxonomies (); foreach ($taxonomy_names as $taxonomy_name) { $terms = get_the_terms (0, $taxonomy_name); if (is_array ($terms)) { foreach ($terms as $term) { $post_term_name = strtolower ($term->name); $post_term_slug = strtolower ($term->slug); $post_taxonomy = strtolower ($term->taxonomy); if ($post_term_name == $taxonomy_disabled || $post_term_slug == $taxonomy_disabled) return false; $post_taxonomy = strtolower ($term->taxonomy); if ($post_taxonomy == $taxonomy_disabled) return false; $check_parent = true; $check_childern = false; if (substr ($taxonomy_disabled, - 1) == '*') { $check_childern = true; $taxonomy_disabled = rtrim ($taxonomy_disabled, '*'); } elseif (substr ($taxonomy_disabled, - 1) == '+') { $check_parent = false; $check_childern = true; $taxonomy_disabled = rtrim ($taxonomy_disabled, '+'); } if ($check_parent) { if ($taxonomy_disabled == $post_taxonomy . ':' . $post_term_slug) { return false; } } if ($check_childern) { if (strpos ($taxonomy_disabled, ':') !== false) { $taxonomy_data = explode (':', $taxonomy_disabled); if (count ($taxonomy_data) == 2 && ai_post_is_in_child_taxonomies ($taxonomy_data [0], $taxonomy_data [1])) { return false; } } } } } } } return true; } else { $taxonomies_listed = explode (",", $taxonomies); foreach ($taxonomies_listed as $taxonomy_enabled) { $taxonomy_enabled_org = trim ($taxonomy_enabled); $taxonomy_enabled = strtolower ($taxonomy_enabled_org); if (strpos ($taxonomy_enabled, 'user:') === 0) { $current_user = wp_get_current_user(); $terms = explode (':', $taxonomy_enabled); if ($terms [1] == 'logged-in') { return is_user_logged_in (); } elseif ($terms [1] == 'not-logged-in') { return !is_user_logged_in (); } if ($terms [1] == $current_user->user_login) return true; } elseif (strpos ($taxonomy_enabled, 'author:') === 0) { if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) $current_author = strtolower (get_the_author_meta ('user_login')); else $current_author = ''; $terms = explode (':', $taxonomy_enabled); if ($terms [1] == $current_author) return true; } elseif (strpos ($taxonomy_enabled, 'user-role:') === 0) { $current_user = wp_get_current_user(); $terms = explode (':', $taxonomy_enabled); foreach (wp_get_current_user()->roles as $role) { if ($terms [1] == $role) return true; } } elseif (strpos ($taxonomy_enabled, 'post-type:') === 0) { $post_type = get_post_type (); $terms = explode (':', $taxonomy_enabled); if ($terms [1] == $post_type) return true; } elseif (strpos ($taxonomy_enabled, 'primary-category:') === 0) { $primary_category = explode (':', $taxonomy_enabled); if ($primary_category [1] == ai_primary_category ()) return true; } elseif (strpos ($taxonomy_enabled, 'yoast-primary-category:') === 0) { $primary_category = explode (':', $taxonomy_enabled); if ($primary_category [1] == ai_yoast_primary_category ()) return true; } elseif (strpos ($taxonomy_enabled, 'multisite:') === 0) { if (is_multisite () && function_exists ('ai_plugin_settings')) { $site_id = explode (':', $taxonomy_enabled); if ($site_id [1] == '#' && is_main_site ()) return true; if (get_current_blog_id () == $site_id [1]) return true; } else return false; } elseif (strpos ($taxonomy_enabled_org, 'meta:') === 0) { $meta_data = explode (':', str_replace ('meta:', '', $taxonomy_enabled_org)); if (count ($meta_data) == 2) { if (get_post_meta (get_the_id (), $meta_data [0], true) == $meta_data [1]) return true; } else { if (get_post_meta (get_the_id (), $meta_data [0], true) != '') return true; } } $taxonomy_names = get_post_taxonomies (); foreach ($taxonomy_names as $taxonomy_name) { $terms = get_the_terms (0, $taxonomy_name); if (is_array ($terms)) { foreach ($terms as $term) { $post_term_name = strtolower ($term->name); $post_term_slug = strtolower ($term->slug); $post_taxonomy = strtolower ($term->taxonomy); if ($post_term_name == $taxonomy_enabled || $post_term_slug == $taxonomy_enabled) return true; $post_taxonomy = strtolower ($term->taxonomy); if ($post_taxonomy == $taxonomy_enabled) return true; $check_parent = true; $check_childern = false; if (substr ($taxonomy_enabled, - 1) == '*') { $check_childern = true; $taxonomy_enabled = rtrim ($taxonomy_enabled, '*'); } elseif (substr ($taxonomy_enabled, - 1) == '+') { $check_parent = false; $check_childern = true; $taxonomy_enabled = rtrim ($taxonomy_enabled, '+'); } if ($check_parent) { if ($taxonomy_enabled == $post_taxonomy . ':' . $post_term_slug) { return true; } } if ($check_childern) { if (strpos ($taxonomy_enabled, ':') !== false) { $taxonomy_data = explode (':', $taxonomy_enabled); if (count ($taxonomy_data) == 2 && ai_post_is_in_child_taxonomies ($taxonomy_data [0], $taxonomy_data [1])) { return true; } } } } } } } return false; } } function check_id ($ids = null, $id_type = AI_WHITE_LIST) { global $ai_wp_data; // Check post IDs only on posts and static pages if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_POST && $ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_STATIC) return true; if ($ids === null) { $ids = trim ($this->get_id_list()); $id_type = $this->get_id_list_type(); } if ($ids == AD_EMPTY_DATA) return true; $page_id = get_the_ID(); if ($id_type == AI_BLACK_LIST) $return = false; else $return = true; if (/*$ids == AD_EMPTY_DATA ||*/ $page_id === false) { return !$return; } $ids_listed = explode (",", $ids); foreach ($ids_listed as $index => $id_listed) { if (trim ($id_listed) == "") unset ($ids_listed [$index]); else $ids_listed [$index] = trim ($id_listed); } foreach ($ids_listed as $index => $id_listed) { switch ($ai_wp_data [AI_WP_PAGE_TYPE]) { case AI_PT_POST: if ($ids_listed [$index] == 'posts') return $return; break; case AI_PT_STATIC: if ($ids_listed [$index] == 'pages') return $return; break; } if (strpos ($ids_listed [$index], '-') !== false) { $id_limits = explode ('-', str_replace (' ', '', $ids_listed [$index])); if ($page_id >= $id_limits [0] && $page_id <= $id_limits [1]) return $return; } } if (in_array ($page_id, $ids_listed)) return $return; return !$return; } function check_url ($urls = null, $url_type = AI_WHITE_LIST) { global $ai_wp_data; if ($urls === null) { $urls = trim ($this->get_ad_url_list()); $url_type = $this->get_ad_url_list_type(); } $page_url = $ai_wp_data [AI_WP_URL]; if ($url_type == AI_BLACK_LIST) $return = false; else $return = true; if ($urls == AD_EMPTY_DATA) return true; $list_separator = ','; if (strpos ($urls, ' ') !== false && strpos ($urls, ',') === false) $list_separator = ' '; $urls_listed = explode ($list_separator, $urls); foreach ($urls_listed as $index => $url_listed) { if (trim ($url_listed) == "") unset ($urls_listed [$index]); else $urls_listed [$index] = trim ($url_listed); } // print_r ($urls_listed); // echo "
\n"; // echo ' page url: ' . $page_url, "
\n"; // echo ' listed urls: ' . $urls, "\n"; // echo "
\n"; foreach ($urls_listed as $url_listed) { if ($url_listed == '*') return $return; if ($url_listed [0] == '*') { if ($url_listed [strlen ($url_listed) - 1] == '*') { $url_listed = substr ($url_listed, 1, strlen ($url_listed) - 2); if (strpos ($page_url, $url_listed) !== false) return $return; } else { $url_listed = substr ($url_listed, 1); if (substr ($page_url, - strlen ($url_listed)) == $url_listed) return $return; } } elseif ($url_listed [strlen ($url_listed) - 1] == '*') { $url_listed = substr ($url_listed, 0, strlen ($url_listed) - 1); if (strpos ($page_url, $url_listed) === 0) return $return; } elseif ($url_listed == $page_url) return $return; } return !$return; } function check_scheduling ($server_side_check) { global $block_object, $ai_wp_data; switch ($this->get_scheduling()) { case AI_SCHEDULING_OFF: return true; break; case AI_SCHEDULING_DELAY_FOR: $after_days = trim ($this->get_ad_after_day()); if ($after_days == '') return true; $after_days = $after_days; $post_date = get_the_date ('U'); if ($post_date === false) return true; return (date ('U', current_time ('timestamp')) >= $post_date + $after_days * 86400); break; case AI_SCHEDULING_INSERT_ONLY_FOR: $after_days = trim ($this->get_ad_after_day()); if ($after_days == '') return false; $after_days = $after_days; $post_date = get_the_date ('U'); if ($post_date === false) return false; return (date ('U', current_time ('timestamp')) < $post_date + $after_days * 86400); break; case AI_SCHEDULING_BETWEEN_DATES: if (!function_exists ('ai_scheduling_options')) return true; if (!$server_side_check) return true; $start_time = $this->get_schedule_start_date () . ' ' . $this->get_schedule_start_time (); $end_time = $this->get_schedule_end_date () . ' ' . $this->get_schedule_end_time (); $days_in_week = $this->get_schedule_weekdays (); $insertion_enabled = check_scheduling_time ($start_time, $end_time, $days_in_week, true); if (!$insertion_enabled) { if (!isset ($ai_wp_data [AI_FALLBACK_LEVEL])) $ai_wp_data [AI_FALLBACK_LEVEL] = 1; else $ai_wp_data [AI_FALLBACK_LEVEL] ++; $fallback = intval ($this->get_scheduling_fallback()); if ($fallback != $this->number && $fallback != 0 && $fallback <= 96 && $ai_wp_data [AI_FALLBACK_LEVEL] <= 2) { $fallback_obj = $block_object [$fallback]; if ($fallback_obj->check_scheduling ($server_side_check) && ai_check_impression_and_click_limits ($fallback, true)) { $this->fallback = $fallback_obj->fallback != 0 ? $fallback_obj->fallback : $fallback; $insertion_enabled = true; } } $ai_wp_data [AI_FALLBACK_LEVEL] --; } return ($insertion_enabled); break; case AI_SCHEDULING_OUTSIDE_DATES: if (!function_exists ('ai_scheduling_options')) return true; if (!$server_side_check) return true; $start_time = $this->get_schedule_start_date () . ' ' . $this->get_schedule_start_time (); $end_time = $this->get_schedule_end_date () . ' ' . $this->get_schedule_end_time (); $days_in_week = $this->get_schedule_weekdays (); $insertion_enabled = check_scheduling_time ($start_time, $end_time, $days_in_week, false); if (!$insertion_enabled) { if (!isset ($ai_wp_data [AI_FALLBACK_LEVEL])) $ai_wp_data [AI_FALLBACK_LEVEL] = 1; else $ai_wp_data [AI_FALLBACK_LEVEL] ++; $fallback = intval ($this->get_scheduling_fallback()); if ($fallback != $this->number && $fallback != 0 && $fallback <= 96 && $ai_wp_data [AI_FALLBACK_LEVEL] <= 2) { $fallback_obj = $block_object [$fallback]; if ($fallback_obj->check_scheduling ($server_side_check) && ai_check_impression_and_click_limits ($fallback, true)) { $this->fallback = $fallback_obj->fallback != 0 ? $fallback_obj->fallback : $fallback; $insertion_enabled = true; } } $ai_wp_data [AI_FALLBACK_LEVEL] --; } return ($insertion_enabled); break; case AI_SCHEDULING_PUBLISHED_BETWEEN_DATES: if (!function_exists ('ai_scheduling_options')) return true; $post_date = get_the_date ('U'); if ($post_date === false) return false; $post_weekday = date ('w', $post_date); if ($post_weekday == 0) $post_weekday = 6; else $post_weekday --; $current_time = current_time ('timestamp'); $current_weekday = date ('w', $current_time); if ($current_weekday == 0) $current_weekday = 6; else $current_weekday --; $start_date = strtotime ($this->get_schedule_start_date () . ' ' . $this->get_schedule_start_time (), $current_time); $end_date = strtotime ($this->get_schedule_end_date () . ' ' . $this->get_schedule_end_time (), $current_time); $weekdays = explode (',', $this->get_schedule_weekdays ()); if (isset ($weekdays [0]) and $weekdays [0] === '') $weekdays = array (); $insertion_enabled = $post_date >= $start_date && $post_date < $end_date && in_array ($post_weekday, $weekdays); if (!$insertion_enabled) { if (!isset ($ai_wp_data [AI_FALLBACK_LEVEL])) $ai_wp_data [AI_FALLBACK_LEVEL] = 1; else $ai_wp_data [AI_FALLBACK_LEVEL] ++; $fallback = intval ($this->get_scheduling_fallback()); if ($fallback != $this->number && $fallback != 0 && $fallback <= 96 && $ai_wp_data [AI_FALLBACK_LEVEL] <= 2) { $this->fallback = $fallback; return true; } $ai_wp_data [AI_FALLBACK_LEVEL] --; } return ($insertion_enabled); break; case AI_SCHEDULING_PUBLISHED_OUTSIDE_DATES: if (!function_exists ('ai_scheduling_options')) return true; $post_date = get_the_date ('U'); if ($post_date === false) return true; $post_weekday = date ('w', $post_date); if ($post_weekday == 0) $post_weekday = 6; else $post_weekday --; $current_time = current_time ('timestamp'); $current_weekday = date ('w', $current_time); if ($current_weekday == 0) $current_weekday = 6; else $current_weekday --; $start_date = strtotime ($this->get_schedule_start_date () . ' ' . $this->get_schedule_start_time (), $current_time); $end_date = strtotime ($this->get_schedule_end_date () . ' ' . $this->get_schedule_end_time (), $current_time); $weekdays = explode (',', $this->get_schedule_weekdays ()); if (isset ($weekdays [0]) and $weekdays [0] === '') $weekdays = array (); // echo "
";
//        echo "current_time ", $current_time, " ", date ("Y-m-d H:i:s", $current_time), "
"; // echo "start_date ", $start_date, " ", date ("Y-m-d H:i:s", $start_date), "
"; // echo "end_date ", $end_date, " ", date ("Y-m-d H:i:s", $end_date), "
"; // echo "post_date ", $post_date, " ", date ("Y-m-d H:i:s", $post_date), "
"; // echo "
"; $insertion_enabled = $post_date < $start_date || $post_date >= $end_date || !in_array ($post_weekday, $weekdays); if (!$insertion_enabled) { if (!isset ($ai_wp_data [AI_FALLBACK_LEVEL])) $ai_wp_data [AI_FALLBACK_LEVEL] = 1; else $ai_wp_data [AI_FALLBACK_LEVEL] ++; $fallback = intval ($this->get_scheduling_fallback()); if ($fallback != $this->number && $fallback != 0 && $fallback <= 96 && $ai_wp_data [AI_FALLBACK_LEVEL] <= 2) { $this->fallback = $fallback; return true; } $ai_wp_data [AI_FALLBACK_LEVEL] --; } return ($insertion_enabled); break; default: return true; break; } } function check_referer () { return check_referer_list ($this->get_ad_domain_list(), $this->get_ad_domain_list_type() == AI_WHITE_LIST); } function check_client () { return check_client_list ($this->get_client_list(), $this->get_client_list_type() == AI_WHITE_LIST); } function check_number_of_words (&$content = null, $number_of_words = 0) { global $ai_last_check, $ai_wp_data; $minimum_words = intval ($this->get_minimum_words()); $maximum_words = intval ($this->get_maximum_words()); if ($minimum_words == 0 && $maximum_words == 0) return true; // if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) { if ($number_of_words == 0) { if (!isset ($ai_wp_data [AI_WORD_COUNT])) { if ($content === null) { $content = ''; $content_post = get_post (); if (isset ($content_post->post_content)) $content = $content_post->post_content; } $number_of_words = number_of_words ($content); } else $number_of_words = $ai_wp_data [AI_WORD_COUNT]; } // } else $number_of_words = 0; // Cache word count only on single pages if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) $ai_wp_data [AI_WORD_COUNT] = $number_of_words; $ai_last_check = AI_CHECK_MIN_NUMBER_OF_WORDS; if ($number_of_words < $minimum_words) return false; if ($maximum_words <= 0) $maximum_words = 1000000; $ai_last_check = AI_CHECK_MAX_NUMBER_OF_WORDS; if ($number_of_words > $maximum_words) return false; return true; } function check_number_of_words_in_paragraph ($content, $min, $max) { $number_of_words = number_of_words ($content); if ($max <= 0) $max = 1000000; if ($number_of_words < $min || $number_of_words > $max) return false; return true; } function server_side_check () { global $ai_wp_data; return get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_SERVER_SIDE || ((get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW || get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT) && $ai_wp_data [AI_WP_AMP_PAGE]); } function check_page_types_lists_users ($ignore_page_types = false) { global $ai_last_check, $ai_wp_data; if (!$ignore_page_types) { if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_HOMEPAGE){ $ai_last_check = AI_CHECK_PAGE_TYPE_FRONT_PAGE; if (!$this->get_display_settings_home()) return false; } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC){ $ai_last_check = AI_CHECK_PAGE_TYPE_STATIC_PAGE; if (!$this->get_display_settings_page()) return false; } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST){ $ai_last_check = AI_CHECK_PAGE_TYPE_POST; if (!$this->get_display_settings_post()) return false; } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_CATEGORY){ $ai_last_check = AI_CHECK_PAGE_TYPE_CATEGORY; if (!$this->get_display_settings_category()) return false; } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_SEARCH){ $ai_last_check = AI_CHECK_PAGE_TYPE_SEARCH; if (!$this->get_display_settings_search()) return false; } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ARCHIVE){ $ai_last_check = AI_CHECK_PAGE_TYPE_ARCHIVE; if (!$this->get_display_settings_archive()) return false; } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_FEED){ $ai_last_check = AI_CHECK_PAGE_TYPE_FEED; if (!$this->get_enable_feed()) return false; } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404){ $ai_last_check = AI_CHECK_PAGE_TYPE_404; if (!$this->get_enable_404()) return false; } } $ai_last_check = AI_CHECK_CATEGORY; if (!$this->check_category ()) return false; $ai_last_check = AI_CHECK_TAG; if (!$this->check_tag ()) return false; $ai_last_check = AI_CHECK_TAXONOMY; if (!$this->check_taxonomy ()) return false; $ai_last_check = AI_CHECK_ID; if (!$this->check_id ()) return false; $ai_last_check = AI_CHECK_URL; if (!$this->check_url ()) return false; $server_side_check = $this->server_side_check (); $ai_last_check = AI_CHECK_URL_PARAMETER; switch ($server_side_check) { case true: if (!check_url_parameter_and_cookie_list ($this->get_url_parameter_list(), $this->get_url_parameter_list_type() == AI_WHITE_LIST)) return false; break; default: $url_parameter_found = false; $url_parameter_list_pass = check_url_parameter_list ($this->get_url_parameter_list(), $this->get_url_parameter_list_type() == AI_WHITE_LIST, $url_parameter_found); if ($url_parameter_found && !$url_parameter_list_pass) return false; if (!$url_parameter_found) $this->client_side_cookie_check_url = true; break; } $ai_last_check = AI_CHECK_COOKIE; switch ($server_side_check) { case true: if (!check_cookie_list ($this->get_cookie_list(), $this->get_cookie_list_type() == AI_WHITE_LIST)) return false; break; default: $this->client_side_cookie_check = true; break; } if ($server_side_check) { $ai_last_check = AI_CHECK_REFERER; if (!$this->check_referer ()) return false; } if ($server_side_check) { $ai_last_check = AI_CHECK_CLIENT; if (!$this->check_client ()) return false; } if (function_exists ('ai_check_lists')) { if (!ai_check_lists ($this, $server_side_check)) return false; } $ai_last_check = AI_CHECK_SCHEDULING; if (!$this->check_scheduling ($server_side_check)) return false; $display_for_users = $this->get_display_for_users (); $ai_last_check = AI_CHECK_LOGGED_IN_USER; if ($display_for_users == AI_DISPLAY_LOGGED_IN_USERS && ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != AI_USER_LOGGED_IN) return false; $ai_last_check = AI_CHECK_NOT_LOGGED_IN_USER; if ($display_for_users == AI_DISPLAY_NOT_LOGGED_IN_USERS && ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) == AI_USER_LOGGED_IN) return false; $ai_last_check = AI_CHECK_ADMINISTRATOR; if ($display_for_users == AI_DISPLAY_ADMINISTRATORS && ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != AI_USER_ADMINISTRATOR) return false; if (function_exists ('ai_check_impression_and_click_limits')) { if ($server_side_check && !ai_check_impression_and_click_limits ($this->number)) return false; } return true; } function check_post_page_exceptions ($selected_blocks) { global $ai_last_check, $ai_wp_data; if (isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_POSTS]) || isset ($this->wp_options [AI_OPTION_ENABLED_ON_WHICH_PAGES])) { // Use old settings if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) { $enabled_on = $this->get_ad_enabled_on_which_posts (); if ($enabled_on == AI_DEFAULT_INSERTION_ENABLED) { $ai_last_check = AI_CHECK_INDIVIDUALLY_DISABLED; if (in_array ($this->number, $selected_blocks)) return false; } elseif ($enabled_on == AI_DEFAULT_INSERTION_DISABLED) { $ai_last_check = AI_CHECK_INDIVIDUALLY_ENABLED; if (!in_array ($this->number, $selected_blocks)) return false; } } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) { $enabled_on = $this->get_ad_enabled_on_which_pages (); if ($enabled_on == AI_DEFAULT_INSERTION_ENABLED) { $ai_last_check = AI_CHECK_INDIVIDUALLY_DISABLED; if (in_array ($this->number, $selected_blocks)) return false; } elseif ($enabled_on == AI_DEFAULT_INSERTION_DISABLED) { $ai_last_check = AI_CHECK_INDIVIDUALLY_ENABLED; if (!in_array ($this->number, $selected_blocks)) return false; } } return true; } if (!$this->get_exceptions_enabled ()) return true; switch ($this->get_exceptions_function ()) { case AI_DEFAULT_INSERTION_ENABLED: $ai_last_check = AI_CHECK_INDIVIDUALLY_DISABLED; if (in_array ($this->number, $selected_blocks)) return false; break; case AI_DEFAULT_INSERTION_DISABLED: $ai_last_check = AI_CHECK_INDIVIDUALLY_ENABLED; if (!in_array ($this->number, $selected_blocks)) return false; break; } return true; } function check_filter ($counter_for_filter) { global $ai_last_check, $ad_inserter_globals, $page; $filter_ok = $this->get_inverted_filter() ? false : true; $ai_last_check = AI_CHECK_FILTER; $filter_settings = trim (str_replace (' ', '', $this->get_call_filter())); if (empty ($filter_settings)) return $filter_ok; switch ($this->get_filter_type ()) { case AI_FILTER_PHP_FUNCTION_CALLS: if (isset ($ad_inserter_globals [AI_PHP_FUNCTION_CALL_COUNTER_NAME . $this->number])) $counter_for_filter = $ad_inserter_globals [AI_PHP_FUNCTION_CALL_COUNTER_NAME . $this->number]; else return !$filter_ok; break; case AI_FILTER_CONTENT_PROCESSING: if (isset ($ad_inserter_globals [AI_CONTENT_COUNTER_NAME])) $counter_for_filter = $ad_inserter_globals [AI_CONTENT_COUNTER_NAME]; else return !$filter_ok; break; case AI_FILTER_EXCERPT_PROCESSING: if (isset ($ad_inserter_globals [AI_EXCERPT_COUNTER_NAME])) $counter_for_filter = $ad_inserter_globals [AI_EXCERPT_COUNTER_NAME]; else return !$filter_ok; break; case AI_FILTER_BEFORE_POST_PROCESSING: if (isset ($ad_inserter_globals [AI_LOOP_BEFORE_COUNTER_NAME])) $counter_for_filter = $ad_inserter_globals [AI_LOOP_BEFORE_COUNTER_NAME]; else return !$filter_ok; break; case AI_FILTER_AFTER_POST_PROCESSING: if (isset ($ad_inserter_globals [AI_LOOP_AFTER_COUNTER_NAME])) $counter_for_filter = $ad_inserter_globals [AI_LOOP_AFTER_COUNTER_NAME]; else return !$filter_ok; break; case AI_FILTER_WIDGET_DRAWING: if (isset ($ad_inserter_globals [AI_WIDGET_COUNTER_NAME . $this->number])) $counter_for_filter = $ad_inserter_globals [AI_WIDGET_COUNTER_NAME . $this->number]; else return !$filter_ok; break; case AI_FILTER_SUBPAGES: if (isset ($page)) $counter_for_filter = $page; else return !$filter_ok; break; case AI_FILTER_POSTS: if (isset ($ad_inserter_globals [AI_POST_COUNTER_NAME])) $counter_for_filter = $ad_inserter_globals [AI_POST_COUNTER_NAME]; else return !$filter_ok; break; case AI_FILTER_PARAGRAPHS: case AI_FILTER_IMAGES: return true; break; case AI_FILTER_COMMENTS: if (isset ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME])) $counter_for_filter = $ad_inserter_globals [AI_COMMENT_COUNTER_NAME]; else return !$filter_ok; break; } $filter_values = array (); if (strpos ($filter_settings, ",") !== false) { $filter_values = explode (",", $filter_settings); } else $filter_values []= $filter_settings; foreach ($filter_values as $filter_value) { $filter_value = trim ($filter_value); if (isset ($filter_value [0]) && $filter_value [0] == '%') { $mod_value = substr ($filter_value, 1); $offset_value = 0; if (strpos ($mod_value, '@') !== false) { $mod_value_array = explode ('@', $mod_value); $mod_value = $mod_value_array [0]; $offset_value = $mod_value_array [1]; } // if (is_numeric ($mod_value) && $mod_value > 0) { if (is_numeric ($mod_value) && $mod_value > 0 && is_numeric ($offset_value)) { // if ($counter_for_filter % $mod_value == 0) return $filter_ok; if ($counter_for_filter >= $offset_value && ($counter_for_filter - $offset_value) % $mod_value == 0) return $filter_ok; } } } return in_array ($counter_for_filter, $filter_values) xor !$filter_ok; } function check_and_increment_block_counter () { global $ad_inserter_globals, $ai_last_check; $global_name = AI_BLOCK_COUNTER_NAME . $this->number; $max_insertions = intval ($this->get_maximum_insertions ()); if (!isset ($ad_inserter_globals [$global_name])) { $ad_inserter_globals [$global_name] = 0; } $ai_last_check = AI_CHECK_MAX_INSERTIONS; if ($max_insertions != 0 && $ad_inserter_globals [$global_name] >= $max_insertions) return false; $ad_inserter_globals [$global_name] ++; return true; } function check_block_counter () { global $ad_inserter_globals, $ai_last_check; $global_name = AI_BLOCK_COUNTER_NAME . $this->number; $max_insertions = intval ($this->get_maximum_insertions ()); if (!isset ($ad_inserter_globals [$global_name])) { $ad_inserter_globals [$global_name] = 0; } $ai_last_check = AI_CHECK_MAX_INSERTIONS; if ($max_insertions != 0 && $ad_inserter_globals [$global_name] >= $max_insertions) return false; return true; } function increment_block_counter () { global $ad_inserter_globals; if ($this->number == 0) return; $global_name = AI_BLOCK_COUNTER_NAME . $this->number; if (!isset ($ad_inserter_globals [$global_name])) { $ad_inserter_globals [$global_name] = 0; } $ad_inserter_globals [$global_name] ++; return; } function extract_features (){ global $ai_wp_data; // AI_SERVER_SIDE_DETECTION // AI_CLIENT_SIDE_DETECTION // AI_CLIENT_SIDE_INSERTION // AI_STICK_TO_THE_CONTENT // AI_TRACKING // AI_CLOSE_BUTTONS // AI_IFRAMES // AI_ANIMATION // AI_LAZY_LOADING // AI_GEOLOCATION // if ($this->get_detection_server_side()) echo "#", $this->number; // echo "#", $this->number; // return; if ($this->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true; if (trim ($this->get_client_list ()) != '') $ai_wp_data [AI_MOBILE_DETECT_JS] = true; if ($this->get_detection_client_side ()) { $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = true; if ($this->get_client_side_action () == AI_CLIENT_SIDE_ACTION_INSERT) { $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = true; } } else { $code = $this->get_ad_data(); if (stripos ($code, '[adinserter') !== false) { if (stripos ($code, 'viewport=') !== false) { $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = true; $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = true; } if (stripos ($code, 'fallback=') !== false) { $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = true; } } } if (function_exists ('ai_extract_features_2')) ai_extract_features_2 ($this); if ($this->stick_to_the_content_class () != '' || $this->get_background ()) $ai_wp_data [AI_STICK_TO_THE_CONTENT] = true; switch ($this->get_automatic_insertion()) { case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT: case AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT: case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT: if ($this->get_html_element_insertion () != AI_HTML_INSERTION_SEREVR_SIDE) $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = true; break; } } } class ai_Block extends ai_CodeBlock { public function __construct ($number) { parent::__construct(); $this->number = $number; } } class ai_AdH extends ai_BaseCodeBlock { public function __construct () { parent::__construct(); $this->number = 'H'; $this->wp_options [AI_OPTION_BLOCK_NAME] = 'HEADER'; } } class ai_AdF extends ai_BaseCodeBlock { public function __construct () { parent::__construct(); $this->number = 'F'; $this->wp_options [AI_OPTION_BLOCK_NAME] = 'FOOTER'; } } class ai_AdA extends ai_BaseCodeBlock { public function __construct () { parent::__construct(); $this->number = 'A'; $this->wp_options [AI_OPTION_BLOCK_NAME] = 'AD BLOCKING MESSAGE'; } public function get_ad_data (){ $option = isset ($this->wp_options [AI_OPTION_CODE]) ? $this->wp_options [AI_OPTION_CODE] : AI_DEFAULT_ADB_MESSAGE; if ($option == AD_EMPTY_DATA) $option = AI_DEFAULT_ADB_MESSAGE; return $option; } } class ai_Walker_Comment extends Walker_Comment { public function comment_callback ($comment, $args, $depth) { if (($comment->comment_type == 'pingback' || $comment->comment_type == 'trackback') && $args ['short_ping']) { $this->ping ($comment, $depth, $args); } elseif ($args['format'] === 'html5') { $this->html5_comment ($comment, $depth, $args); } else { $this->comment ($comment, $depth, $args); } } } class ai_code_generator { public function __construct () { } public function generate ($data){ $code = ''; switch ($data ['generate-code']) { case AI_CODE_BANNER: $code = ''; if (isset ($data ['image']) && $data ['image'] != '') { $attributes = ''; if (isset ($data ['loading']) && $data ['loading'] != '') { $attributes .= ' loading="'.esc_html ($data ['loading']).'"'; } if (isset ($data ['alt']) && $data ['alt'] != '') { $attributes .= ' alt="'.esc_html ($data ['alt']).'"'; } $code = ''; } if (isset ($data ['link']) && $data ['link'] != '') { $code = '' . $code . ''; } break; case AI_CODE_ADSENSE: $adsense_size = ($data ['adsense-width'] != '' ? ' width: '. esc_html ($data ['adsense-width']). 'px;' : '') . ($data ['adsense-height'] != '' ? ' height: '.esc_html ($data ['adsense-height']).'px;' : ''); switch ($data ['adsense-type']) { case AI_ADSENSE_AMP_ONLY: $code = ''; break; default: $code = ''; if ($data ['adsense-comment']) $code .= "\n"; $adsense_full_width_responsive = $data ['adsense-full-width-responsive'] != '' ? "\n".' data-full-width-responsive="' . esc_html ($data ['adsense-full-width-responsive']) . '"' : ''; break; } switch ($data ['adsense-type']) { case AI_ADSENSE_STANDARD: switch ($data ['adsense-size']) { case AI_ADSENSE_SIZE_FIXED: // Normal $code .= ' '; break; case AI_ADSENSE_SIZE_FIXED_BY_VIEWPORT: $code = $this->adsense_size_styles ($data) . $code; // Normal $code .= ' '; break; case AI_ADSENSE_SIZE_RESPONSIVE: // Responsive $code .= ' '; break; } break; case AI_ADSENSE_LINK: switch ($data ['adsense-size']) { case AI_ADSENSE_SIZE_FIXED: // Normal $code .= ' '; break; case AI_ADSENSE_SIZE_FIXED_BY_VIEWPORT: $code = $this->adsense_size_styles ($data) . $code; // Normal $code .= ' '; break; case AI_ADSENSE_SIZE_RESPONSIVE: // Responsive $code .= ' '; break; } break; case AI_ADSENSE_IN_ARTICLE: $code .= ' '; break; case AI_ADSENSE_IN_FEED: $code .= ' '; break; case AI_ADSENSE_MATCHED_CONTENT: $code .= ' '; break; case AI_ADSENSE_AUTO: $code .= ' '; break; } if ($data ['adsense-amp'] != AI_ADSENSE_AMP_DISABLED) { if ($code != '') { $code .= ' '; } switch ($data ['adsense-amp']) { case AI_ADSENSE_AMP_AUTO: $code .= '[ADINSERTER AMP] '; break; case AI_ADSENSE_AMP_ABOVE_THE_FOLD: $code .= '[ADINSERTER AMP] '; break; case AI_ADSENSE_AMP_FIXED: $code .= '[ADINSERTER AMP] '; break; case AI_ADSENSE_AMP_BELOW_THE_FOLD: $code .= '[ADINSERTER AMP]
'; break; case AI_ADSENSE_AMP_STICKY: if ($data ['adsense-width'] == '') { $data ['adsense-width'] = 320; } if ($data ['adsense-height'] == '') { $data ['adsense-height'] = 50; } $code .= '[ADINSERTER AMP] '; break; } } break; case AI_CODE_AMAZON: $code_lines = explode ("\n", stripslashes ($data ['amazon-data'])); $clean_code = ''; $regionurl = ''; $amp_lines = array (); foreach ($code_lines as $index => $code_line) { if (strpos ($code_line, 'regionurl') !== false) { unset ($code_lines [$index]); $regionurl = trim (str_replace ('regionurl', '', $code_line)); $regionurl = trim (ltrim ($regionurl, '=')); } else { $amp_lines [] = ' data-' . $code_lines [$index]; $code_lines [$index] = ' ' . $code_lines [$index] . ';'; } } $amazon_data = implode ("\n", $code_lines); $code .= ' '; if ($data ['amazon-amp']) { $code .= ' [ADINSERTER AMP] '; } break; } return $code; } public function adsense_size_styles ($data){ $code = ' '; return $code; } public function import ($code){ if (trim ($code) == '') { return array ('type' => AI_CODE_UNKNOWN); } $code_expanded_shortodes = do_shortcode ($code); $amp = false; $adsense_amp = AI_ADSENSE_AMP_DISABLED; if (strpos ($code_expanded_shortodes, AD_AMP_SEPARATOR) !== false) { $amp = true; $adsense_amp = AI_ADSENSE_AMP_ABOVE_THE_FOLD; } if (!class_exists ('DOMDocument')) { echo __('ERROR: class DOMDocument not found. Your webhost needs to install the DOM extension for PHP.', 'ad-inserter'); wp_die (); } try { $dom = new DOMDocument (); libxml_use_internal_errors (true); $dom->loadHTML ($code); libxml_clear_errors (); } catch (Exception $e) { echo 'ERROR: ', $e->getMessage(); wp_die (); } // AdSense if (strpos ($code, 'data-ad-client') !== false) { $adsense_code = $dom->getElementsByTagName ('ins'); $adsense_code_amp = $dom->getElementsByTagName ('amp-ad'); $adsense_code_amp_sticky = $dom->getElementsByTagName ('amp-sticky-ad'); $adsense_code_amp_auto = $dom->getElementsByTagName ('amp-auto-ads'); if ($adsense_code_amp_sticky->length != 0) { $adsense_amp = AI_ADSENSE_AMP_STICKY; } elseif ($adsense_code_amp_auto->length != 0) { $adsense_amp = AI_ADSENSE_AMP_AUTO; } if ($adsense_code_amp->length == 0) { if ($adsense_code_amp_auto->length != 0) { $adsense_code_amp = $adsense_code_amp_auto; } } if ($adsense_code_amp->length != 0) { // $layout = $adsense_code_amp [0]->getAttribute ('layout'); // PHP 5.6.3 $layout = $adsense_code_amp->item (0)->getAttribute ('layout'); if ($adsense_amp != AI_ADSENSE_AMP_DISABLED) { switch ($layout) { case 'fixed-height': $adsense_amp = AI_ADSENSE_AMP_ABOVE_THE_FOLD; break; case 'fixed': $adsense_amp = AI_ADSENSE_AMP_FIXED; break; case 'nodisplay': $adsense_amp = AI_ADSENSE_AMP_STICKY; break; default: $auto_format = $adsense_code_amp->item (0)->getAttribute ('data-auto-format'); if ($auto_format == "rspv") { $adsense_amp = AI_ADSENSE_AMP_BELOW_THE_FOLD; } break; } } if ($adsense_code->length == 0) $adsense_code = $adsense_code_amp; } if ($adsense_code->length != 0) { $data = array ( 'type' => AI_CODE_ADSENSE, 'adsense-publisher-id' => '', 'adsense-ad-slot-id' => '', 'adsense-type' => AI_ADSENSE_STANDARD, 'adsense-size' => AI_ADSENSE_SIZE_FIXED, 'adsense-width' => '', 'adsense-height' => '', 'adsense-layout' => '', 'adsense-layout-key' => '', 'adsense-full-width-responsive' => '', 'adsense-comment' => '', 'adsense-amp' => $adsense_amp, 'adsense-amp-block-on-consent' => '#', ); // $data ['adsense-publisher-id'] = str_replace ('ca-', '', $adsense_code [0]->getAttribute ('data-ad-client')); $data ['adsense-publisher-id'] = str_replace ('ca-', '', $adsense_code->item (0)->getAttribute ('data-ad-client')); // $data ['adsense-ad-slot-id'] = $adsense_code [0]->getAttribute ('data-ad-slot'); $data ['adsense-ad-slot-id'] = $adsense_code->item (0)->getAttribute ('data-ad-slot'); if ($data ['adsense-ad-slot-id'] == '') { $data ['adsense-ad-slot-id'] = $adsense_code->item (0)->getAttribute ('data-slot'); } // $adsense_style = $adsense_code [0]->getAttribute ('style'); $adsense_style = $adsense_code->item (0)->getAttribute ('style'); $style_width = preg_match ("/width\s*:\s*(\d+)px/", $adsense_style, $width_match); if ($style_width) $data ['adsense-width'] = $width_match [1]; if ($data ['adsense-width'] == '') { $data ['adsense-width'] = $adsense_code->item (0)->getAttribute ('width'); } $style_height = preg_match ("/height\s*:\s*(\d+)px/", $adsense_style, $height_match); if ($style_height) $data ['adsense-height'] = $height_match [1]; if ($data ['adsense-height'] == '') { $data ['adsense-height'] = $adsense_code->item (0)->getAttribute ('height'); } $display = ''; $style_display = preg_match ("/display\s*:\s*([a-z\-]+)/", $adsense_style, $display_match); if ($style_display) $display = $display_match [1]; $adsense_class = trim ($adsense_code->item (0)->getAttribute ('class')); $adsense_classes = explode (' ', $adsense_class); $adsense_size = !$style_width && !$style_height && $display == 'block' ? AI_ADSENSE_SIZE_RESPONSIVE : AI_ADSENSE_SIZE_FIXED; if (count ($adsense_classes) == 2 && !$style_width && !$style_height) { $adsense_size = AI_ADSENSE_SIZE_FIXED_BY_VIEWPORT; $viewport_class = $adsense_classes [1]; $style = preg_match ("##s", $code, $style_match); $style_lines = explode ("\n", trim ($style_match [1])); $viewport_data = array (); for ($viewport = 1; $viewport <= 6; $viewport ++) { $viewport_name = get_viewport_name ($viewport); $viewport_width = get_viewport_width ($viewport); if ($viewport_name != '') { $viewport_data []= array ('index' => $viewport, 'name' => $viewport_name, 'width' => $viewport_width); } } usort ($viewport_data, 'ai_compare_viewport'); $viewport_data = array_reverse ($viewport_data); $sizes = array (); $viewport_widths = array (); $viewport_indexes = array (); foreach ($viewport_data as $index => $viewport) { $viewport_name = $viewport ['name']; $viewport_width = $viewport ['width']; $viewport_index = $viewport ['index']; if ($viewport_name != '') { $viewport_widths [] = $viewport_width; $viewport_indexes [] = $viewport_index; $sizes []= array (0 => '', 1 => ''); } } if (count ($style_lines) == count ($sizes)) { foreach ($style_lines as $index => $style_line) { $viewport_index = $viewport_indexes [$index] - 1; if (strpos ($style_line, $viewport_class) !== false) { $min_width = preg_match ("/min-width\s*:\s*(\d+)px/", $style_line, $min_width_match); $viewport_width = $min_width ? $min_width_match [1] : 0; if ($viewport_width == $viewport_widths [$index]) { $styles = explode ($viewport_class, $style_line); $style_line = $styles [1]; $style_width = preg_match ("/width\s*:\s*(\d+)px/", $style_line, $width_match); $adsense_width = $style_width ? $width_match [1] : ''; $style_height = preg_match ("/height\s*:\s*(\d+)px/", $style_line, $height_match); $adsense_height = $style_height ? $height_match [1] : ''; $sizes [$viewport_index] = array (0 => $adsense_width, 1 => $adsense_height); } } else $sizes [$viewport_index] = array ('', ''); } } $data ['adsense-sizes'] = $sizes; } $data ['adsense-size'] = $adsense_size; $comment = preg_match ("##", $code, $comment_match); if ($comment) $data ['adsense-comment'] = trim ($comment_match [1]); // $adsense_ad_format = $adsense_code [0]->getAttribute ('data-ad-format'); $adsense_ad_format = $adsense_code->item (0)->getAttribute ('data-ad-format'); if ($adsense_amp == AI_ADSENSE_AMP_STICKY) { $data ['adsense-type'] = AI_ADSENSE_AMP_ONLY; } elseif ($adsense_amp == AI_ADSENSE_AMP_AUTO) { $data ['adsense-type'] = AI_ADSENSE_AMP_ONLY; } else switch ($adsense_ad_format) { case '': break; case 'auto': break; case 'autorelaxed': $data ['adsense-type'] = AI_ADSENSE_MATCHED_CONTENT; break; // case 'link': // $data ['adsense-type'] = AI_ADSENSE_LINK; // break; case 'fluid': // $adsense_ad_layout = $adsense_code [0]->getAttribute ('data-ad-layout'); $adsense_ad_layout = $adsense_code->item (0)->getAttribute ('data-ad-layout'); switch ($adsense_ad_layout) { case 'in-article': $data ['adsense-type'] = AI_ADSENSE_IN_ARTICLE; break 2; } $data ['adsense-type'] = AI_ADSENSE_IN_FEED; $data ['adsense-layout'] = $adsense_ad_layout; // $data ['adsense-layout-key'] = urlencode ($adsense_code [0]->getAttribute ('data-ad-layout-key')); $data ['adsense-layout-key'] = urlencode ($adsense_code->item (0)->getAttribute ('data-ad-layout-key')); break; } $data ['adsense-full-width-responsive'] = $adsense_code->item (0)->getAttribute ('data-full-width-responsive'); if ($adsense_code_amp->item (0) != null) { if ($adsense_code_amp->item (0)->hasAttribute ('data-block-on-consent')) { $data ['adsense-amp-block-on-consent'] = $adsense_code->item (0)->getAttribute ('data-block-on-consent'); } } return $data; } } // Old AdSense / AdSense Auto ads if (strpos ($code, 'google_ad_client') !== false) { $data = array ( 'type' => AI_CODE_ADSENSE, 'adsense-publisher-id' => '', 'adsense-ad-slot-id' => '', 'adsense-type' => AI_ADSENSE_STANDARD, 'adsense-size' => AI_ADSENSE_SIZE_FIXED, 'adsense-width' => '', 'adsense-height' => '', 'adsense-layout' => '', 'adsense-layout-key' => '', 'adsense-amp' => $adsense_amp, 'adsense-amp-block-on-consent' => '#', ); $comment = preg_match ("##", $code, $comment_match); if ($comment) $data ['adsense-comment'] = trim ($comment_match [1]); if (preg_match ("/google_ad_client.+[\"\'](.+?)[\"\']/", $code, $match)) { $data ['adsense-publisher-id'] = str_replace ('ca-', '', $match [1]); } if (preg_match ("/google_ad_slot.+[\"\'](.+?)[\"\']/", $code, $match)) { $data ['adsense-ad-slot-id'] = $match [1]; } if (preg_match ("/google_ad_width[^\d]+(\d+)/", $code, $match)) { $data ['adsense-width'] = $match [1]; } if (preg_match ("/google_ad_height[^\d]+(\d+)/", $code, $match)) { $data ['adsense-height'] = $match [1]; } if (preg_match ("/enable_page_level_ads[^\d]+true/", $code, $match)) { $data ['adsense-type'] = AI_ADSENSE_AUTO; } return $data; } // Amazon if (strpos ($code, 'amzn_assoc_') !== false) { $data = array ( 'type' => AI_CODE_AMAZON, 'amazon-amp' => AI_AMAZON_AMP_DISABLED, 'amazon-width' => '', 'amazon-height' => '200', 'amazon-amp-block-on-consent' => '#', ); if (strpos ($code, 'data-amzn_assoc_') !== false) { $data ['amazon-amp'] = AI_AMAZON_AMP_ENABLED; $amazon_amp_ad = $dom->getElementsByTagName ('amp-ad'); if ($amazon_amp_ad->item (0)->getAttribute ('width') != '') { $data ['amazon-width'] = $amazon_amp_ad->item (0)->getAttribute ('width'); } if ($amazon_amp_ad->item (0)->getAttribute ('height') != '') { $data ['amazon-height'] = $amazon_amp_ad->item (0)->getAttribute ('height'); } if ($amazon_amp_ad->item (0)->hasAttribute ('data-block-on-consent')) { $data ['amazon-amp-block-on-consent'] = $amazon_amp_ad->item (0)->getAttribute ('data-block-on-consent'); } } if (preg_match_all ("/(amzn_assoc_[^\s=]+?)\s*=\s*[\"](.+?)[\"]/", $code, $matches)) { $unique_matches = array (); $unique_matches_values = array (); foreach ($matches [1] as $index => $match) { $found = false; foreach ($unique_matches as $unique_match) { if ($match == $unique_match) { $found = true; break; } } if (!$found) { $unique_matches [] = $match; $unique_matches_values [] = $matches [2][$index]; } } $amazon_data = ''; foreach ($unique_matches as $index => $unique_match) { if ($amazon_data != '') $amazon_data .= "\n"; $amazon_data .= $unique_match . ' = "' . $unique_matches_values [$index] . '"'; } $amazon_script = $dom->getElementsByTagName ('script'); if ($amazon_script-> length >= 2) { $amazon_data .= "\n".'regionurl' . ' = "' . $amazon_script->item (1)->getAttribute ('src') . '"'; } $data ['amazon-data'] = $amazon_data; } return $data; } // Banner $links = $dom->getElementsByTagName ('a'); $images = $dom->getElementsByTagName ('img'); if ($links->length != 0 || $images->length != 0) { $data = array ('type' => AI_CODE_BANNER, 'image' => '', 'link' => '', 'target' => ''); if ($images->length != 0) { // $data ['image'] = $images [0]->getAttribute ('src'); $data ['image'] = $images->item (0)->getAttribute ('src'); $data ['alt'] = $images->item (0)->getAttribute ('alt'); $data ['loading'] = $images->item (0)->getAttribute ('loading'); } if ($links->length != 0) { // $data ['link'] = $links [0]->getAttribute ('href'); $data ['link'] = $links->item (0)->getAttribute ('href'); // $data ['target'] = $links [0]->getAttribute ('target'); $data ['target'] = $links->item (0)->getAttribute ('target'); } return $data; } return array ('type' => AI_CODE_UNKNOWN); } public function import_rotation ($code, $extract_check_names = false){ global $ai_expand_only_rotate_count_check, $ai_wp_data; $data = array ( 'options' => array ( array ( 'code' => $code, 'name' => '', 'share' => '', 'time' => '', ), ), ); $ai_expand_only_rotate_count_check = true; unset ($ai_wp_data [AI_SHORTCODES]['rotate']); $code = do_shortcode ($code); $ai_expand_only_rotate_count_check = false; if (strpos ($code, AD_CHECK_SEPARATOR) !== false) { if (!$extract_check_names) { return $data; } if (function_exists ('ai_check_separators') && isset ($ai_wp_data [AI_SHORTCODES]['check'][0]['check']) && $ai_wp_data [AI_SHORTCODES]['check'][0]['check'] == 'statistics') { $check_parameters = $ai_wp_data [AI_SHORTCODES]['check']; $options = explode (AD_CHECK_SEPARATOR, $code); $data ['options'] = array (); foreach ($options as $index => $option) { $option_code = trim ($option, "\n"); $option_name = isset ($check_parameters [$index - 1]['name']) ? $check_parameters [$index - 1]['name'] : ''; $option_index = isset ($check_parameters [$index - 1]['index']) && $check_parameters [$index - 1]['index'] != '' ? (int) $check_parameters [$index - 1]['index'] : $index; // Skip option before first CHECK shortcode (always inserted) if ($option_index == 0) continue; $data ['options'][$option_index - 1] = array ('name' => $option_name); } } return $data; } preg_match_all ('/\|count([0-9]+?)\|/', $code, $matches); if (count ($matches [1]) != 0) { return $data; } preg_match_all ('/\|rotate([0-9]+?)\|/', $code, $matches); if (count ($matches [1]) != 0) { $rotate_parameters = array (); foreach ($matches [1] as $match) { $rotate_parameters []= $ai_wp_data [AI_SHORTCODES]['rotate'][$match]; } $code = preg_replace ('/\|rotate([0-9]+?)\|/', AD_ROTATE_SEPARATOR, $code); } else if (isset ($ai_wp_data [AI_SHORTCODES]['rotate'])) $rotate_parameters = $ai_wp_data [AI_SHORTCODES]['rotate']; if (strpos ($code, AD_ROTATE_SEPARATOR) !== false) { $options = explode (AD_ROTATE_SEPARATOR, $code); $data ['options'] = array (); foreach ($options as $index => $option) { $option_code = trim ($option, "\n"); $rotation_groups = 0; if (isset ($rotate_parameters [$index - 1]['group']) && $rotate_parameters [$index - 1]['group'] != '') { $rotation_groups = 1; $option_name = $rotate_parameters [$index - 1]['group']; $option_share = ''; $option_time = ''; $option_scheduling = ''; } else { $option_name = isset ($rotate_parameters [$index - 1]['name']) ? $rotate_parameters [$index - 1]['name'] : ''; if (isset ($rotate_parameters [$index - 1]['share'])) { if (is_numeric ($rotate_parameters [$index - 1]['share'])) { $option_share = intval ($rotate_parameters [$index - 1]['share']); } elseif (strpos (strtolower ($rotate_parameters [$index - 1]['share']), 'ctr') === 0) { $option_share = $rotate_parameters [$index - 1]['share']; } else $option_share = ''; } // $option_share = isset ($rotate_parameters [$index - 1]['share']) && is_numeric ($rotate_parameters [$index - 1]['share']) ? intval ($rotate_parameters [$index - 1]['share']) : ''; $option_time = isset ($rotate_parameters [$index - 1]['time']) && is_numeric ($rotate_parameters [$index - 1]['time']) ? intval ($rotate_parameters [$index - 1]['time']) : ''; $option_scheduling = isset ($rotate_parameters [$index - 1]['scheduling']) && strpos ($rotate_parameters [$index - 1]['scheduling'], '%') !== false && strpos ($rotate_parameters [$index - 1]['scheduling'], '=') !== false ? $rotate_parameters [$index - 1]['scheduling'] : ''; } if ($index == 0 && $option_code == '') continue; $data ['options'] []= array ('code' => $option_code, 'name' => $option_name, 'share' => $option_share, 'time' => $option_time, 'scheduling' => $option_scheduling, 'groups' => $rotation_groups); } } return $data; } public function generate_rotation ($rotation_data){ if (count ($rotation_data) == 1) { $rotation_code = trim ($rotation_data [0]['code']); } else { $rotation_code = ''; $rotation_groups = $rotation_data [0]['groups']; foreach ($rotation_data as $index => $rotation_data_row) { $name = trim ($rotation_data_row ['name']); $share = trim ($rotation_data_row ['share']); $scheduling = trim ($rotation_data_row ['scheduling']); $time = trim ($rotation_data_row ['time']); $code = trim ($rotation_data_row ['code'], "\n"); if ($index != 0 || $name != '' || $share != '' || $scheduling != ''|| $time != '') { $shortcode = "" ; if ($index != 0) $shortcode .= "\n\n"; $shortcode .= '[ADINSERTER ROTATE'; if ($rotation_groups) { if ($name != '') $shortcode .= ' group="'.str_replace ('"', '\'', $name).'"'; } else { if ($name != '') $shortcode .= ' name="'.str_replace ('"', '\'', $name).'"'; if ($share != '') $shortcode .= ' share="'.str_replace ('"', '\'', $share).'"'; if ($scheduling != '') $shortcode .= ' scheduling="'.str_replace ('"', '\'', $scheduling).'"'; if ($time != '') $shortcode .= ' time="'.str_replace ('"', '\'', $time).'"'; } $shortcode .= "]\n\n"; } else $shortcode = ''; $rotation_code .= $shortcode . $code; } } return $rotation_code; } } class ai_block_labels { var $class; var $text_color; var $left_text; var $right_text; public function __construct ($class = '') { $this->class = $class == '' ? 'ai-debug-default' : $class; $this->text_color = ''; $this->left_text = ''; $this->right_text = ''; } public function block_start () { return "
\n"; } public function block_end () { return "
\n"; } public function bar ($left_text, $left_title = '', $center_text = '', $right_text = '', $right_title = '', $additional_class = '') { return "
" . $this->invisible_start () . $this->bar_text_left ($left_text, $left_title) . $this->bar_text_center ($center_text) . $this->bar_text_right ($right_text, $right_title) . $this->invisible_end () . "
\n"; } public function bar_hidden_viewport ($left_text, $left_title = '', $center_text = '', $right_text = '', $right_title = '') { return "
" . $this->invisible_start () . $this->bar_text_left ($left_text, $left_title) . $this->bar_text_center ($center_text) . $this->bar_text_right ($right_text, $right_title) . $this->invisible_end () . "
\n"; } public function center_bar ($center_text) { return "
" . $this->left_text . $this->invisible_start () . // "".$this->left_text."" . $this->bar_text_center ($center_text) . // "".$this->right_text."" . $this->invisible_end () . "
\n"; } public function bar_text_left ($text, $title) { // $this->left_text = $text; return "$text"; } public function bar_text_center ($text) { return " $text "; } public function bar_text_right ($text, $title) { // $this->right_text = $text; return "$text"; } public function invisible_start () { return '[AI]'; } public function invisible_end () { return '[/AI]'; } public function message ($text, $attr = '') { return "
" . $this->invisible_start () . $text . $this->invisible_end () . "
\n"; } public function adb_hidden_section_start () { return "
"; } public function adb_hidden_section_end () { return "
\n"; } public function adb_visible_section_start () { return "
"; } public function adb_visible_section_end () { return "
\n"; } } settings.php000064400001425321146731142050007130 0ustar00 $article) { $title = ''; if (preg_match ('##', $article, $match)) { $title = trim ($match [1]); } if ($title != '' && strlen ($article) > 100) { $postarr = array ( 'ID' => 0, 'post_content' => $article, 'post_title' => $title, 'post_status' => 'publish', ); $post_id = wp_insert_post ($postarr); } } } } @unlink ($ai_articles); update_option ('ai-notice-review', 'no'); } $save_url = $_SERVER ['REQUEST_URI']; if (isset ($_GET ['tab'])) { $save_url = preg_replace ("/&tab=\d+/", "", $save_url); } $generate_all = false; if (isset ($_GET ['generate-all']) && $_GET ['generate-all'] == 1) { $generate_all = true; } $subpage = 'main'; $start = 1; $end = 16; if (isset ($_GET ['start']) && is_numeric ($start) && $start >= 1 && $start <= 96) $start = (int) $_GET ['start']; else $start = 1; $end = min ($start + 15, 96); if (isset ($_POST ['ai-active-tab'])) { $active_tabs = json_decode ($_POST ['ai-active-tab']); if ($active_tabs == null) $active_tabs = array ($start, 0); } if (isset ($_GET ['settings']) && is_numeric ($_GET ['settings'])) { $active_tab = (int) $_GET ['settings']; if ($active_tab < 1 || $active_tab > 96) $active_tab = 1; if (isset ($_GET ['single'])) { $start = $active_tab; $end = $active_tab; } else { $start = intval (($active_tab - 1) / 16) * 16 + 1; $end = $start + 15; } } elseif (isset ($_GET ['tab']) && is_numeric ($_GET ['tab'])) { $active_tab = (int) $_GET ['tab']; $start = intval (($active_tab - 1) / 16) * 16 + 1; $end = $start + 15; } else $active_tab = isset ($active_tabs [0]) ? (int) $active_tabs [0] : $start; if (!is_numeric ($active_tab)) $active_tab = 1; if ($active_tab != 0) { if ($active_tab < $start || $active_tab > $end) $active_tab = $start; } $active_tab_0 = isset ($active_tabs [1]) ? (int) $active_tabs [1] : 0; $disable_block_insertions = get_disable_block_insertions (); $disable_php_processing = get_disable_php_processing (); $disable_html_code = get_disable_html_code (); $disable_css_code = get_disable_css_code (); $disable_js_code = get_disable_js_code (); $disable_footer_code = get_disable_footer_code (); $disable_header_code = get_disable_header_code (); $insertion_disabled = $disable_block_insertions || $disable_php_processing || $disable_html_code || $disable_css_code || $disable_js_code || $disable_footer_code || $disable_header_code; if ($insertion_disabled) { $insertion_statuses = 'H   '; $insertion_statuses .= 'F   '; $insertion_statuses .= 'JS   '; $insertion_statuses .= 'CSS   '; $insertion_statuses .= 'HTML   '; $insertion_statuses .= 'PHP   '; $insertion_statuses .= 'BLOCKS'; } else $insertion_statuses = ''; $adH = $block_object [AI_HEADER_OPTION_NAME]; $adF = $block_object [AI_FOOTER_OPTION_NAME]; if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { $adA = $block_object [AI_ADB_MESSAGE_OPTION_NAME]; } $syntax_highlighter_theme = defined ('AI_SAFE_MODE') ? 'disabled' : get_syntax_highlighter_theme (); $block_class_name = get_block_class_name (); $block_class = get_block_class (); $block_number_class = get_block_number_class (); $block_name_class = get_block_name_class (); $inline_styles = get_inline_styles (); $default = $block_object [0]; $exceptions_array = ai_get_exceptions (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())); $exceptions = $exceptions_array [0]; $block_exceptions = $exceptions_array [1]; if (get_wait_for_jquery ()) { echo '

', __('Information', 'ad-inserter'), ': ', __('Legacy JavaScript code used', 'ad-inserter'), ', ', __('disable ', 'ad-inserter'), '', __ ('Wait for jQuery', 'ad-inserter'), '

'; } if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) { if (isset ($_POST [AI_FORM_CLEAR_EXCEPTIONS])) { if ($_POST [AI_FORM_CLEAR_EXCEPTIONS] == "\xe2\x9d\x8c" && !empty ($exceptions)) { echo '

' . sprintf (__('Warning: only exceptions for %d posts cleared, %d posts still have exceptions', 'ad-inserter'), AI_LIST_EXCEPTIONS_LIMIT, count ($exceptions)) . '

'; } elseif (is_numeric ($_POST [AI_FORM_CLEAR_EXCEPTIONS]) && !empty ($block_exceptions [$_POST [AI_FORM_CLEAR_EXCEPTIONS]])) { echo '

' . sprintf (__('Warning: only exceptions for %d posts cleared, %d posts still have exceptions', 'ad-inserter'), AI_LIST_EXCEPTIONS_LIMIT, count ($block_exceptions [$_POST [AI_FORM_CLEAR_EXCEPTIONS]])) . '

'; } } } if (!$ai_wp_data [AI_UNFILTERED_HTML]) { // translators: %s: HTML link code echo '

' . sprintf (__('Warning: %s Unfiltered HTML %s is disabled for this website - most ad codes can\'t be used', 'ad-inserter'), '', '') . '

'; } $rating_string = ''; if ($rating_string = get_transient (AI_TRANSIENT_RATING)) { if ($rating_string < 1 && $rating_string > 5) $rating_string = ''; } $rating_css = $rating_string == '' ? 'width: 100%;' : 'width: '.number_format ($rating_string * 20, 4).'%;'; $rating_value = $rating_string == '' ? '' : number_format ($rating_string, 1); if (isset ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]) && is_string ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]) && strlen ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]) != 0) { $used_blocks = unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]); } else $used_blocks = array (); if (!isset ($_GET ['settings'])): // start of code only for normal settings $default_sidebar = isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL]) && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 19 && count ($used_blocks) >= 4 && function_exists ('ai_settings_side') && function_exists ('ai_admin_settings_notices') ? '1' : '0'; // Not needed anymore // if (is_multisite () && multisite_main_for_all_blogs () && defined ('BLOG_ID_CURRENT_SITE')) { // $saved_options = get_blog_option (BLOG_ID_CURRENT_SITE, AI_OPTION_NAME); // if (is_string ($saved_options) && substr ($saved_options, 0, 4) === ':AI:') { // $saved_options = unserialize (base64_decode (substr ($saved_options, 4), true)); // } // } else $saved_options = ai_get_option (AI_OPTION_NAME); // $warning = false; // if (!empty ($saved_options)) // foreach ($saved_options as $block => $block_settings) { // if ($block >= $start && $block <= $end) { // if (isset ($saved_options [$block]) && strpos (serialize ($saved_options [$block]), '_on_which_') !== false) { // $warning = true; // break; // } // } // } // if ($warning) { // echo '

' . __('Settings for individual exceptions have been updated. Please check all blocks that have exceptions and and then save settings.', 'ad-inserter') . '

'; // } if (function_exists ('ai_admin_settings_notices')) ai_admin_settings_notices (); $hide_settings_enabled = defined ('AI_HIDE_SETTINGS_ENABLED') && AI_HIDE_SETTINGS_ENABLED; $settings_hidden = function_exists ('ai_block_list_buttons') && $hide_settings_enabled ? get_settings_hidden () : false; $settings_page = get_menu_position () == AI_SETTINGS_SUBMENU ? 'options-general.php?page=ad-inserter.php' : 'admin.php?page=ad-inserter.php'; ?>
">

', ''); ?>

', ''); ?>

', $insertion_statuses, ''; ?>
number = $block; $default->wp_options [AI_OPTION_BLOCK_NAME] = DEFAULT_AD_NAME." ".$block; $tab_visible = $block == $active_tab || $generate_all; $obj = $block_object [$block]; } else { $block = 999; $sidebars [$block] = ""; $manual_widget [$block] = $obj->get_enable_widget() == AI_ENABLED; $manual_shortcode [$block] = $obj->get_enable_manual() == AI_ENABLED; $manual_php_function [$block] = $obj->get_enable_php_call() == AI_ENABLED; $manual [$block] = ($manual_widget [$block] && !empty ($sidebars_with_widget [$block])) || $manual_shortcode [$block] || $manual_php_function [$block]; $default->number = 0; $default->wp_options [AI_OPTION_BLOCK_NAME] = DEFAULT_AD_NAME." 0"; $tab_visible = false; $obj = $default; } $client_side_devices = $obj->get_detection_client_side () == AI_ENABLED; $server_side_devices = $obj->get_detection_server_side () == AI_ENABLED; if ($client_side_devices) $client_side_style = "font-weight: bold; color: #66f;"; else $client_side_style = ""; if ($server_side_devices) $server_side_style = "font-weight: bold; color: #66f;"; else $server_side_style = ""; $show_devices = $client_side_devices || $server_side_devices == AI_ENABLED; if ($show_devices) $devices_style = "font-weight: bold; color: #66f;"; else $devices_style = ""; $cat_list = $obj->get_ad_block_cat(); $tag_list = $obj->get_ad_block_tag(); $taxonomy_list = $obj->get_ad_block_taxonomy(); $id_list = $obj->get_id_list(); $url_list = $obj->get_ad_url_list(); $url_parameter_list = $obj->get_url_parameter_list(); $cookie_list = $obj->get_cookie_list(); $domain_list = $obj->get_ad_domain_list(); $client_list = $obj->get_client_list(); if (function_exists ('ai_lists')) $lists = ai_lists ($obj); else $lists = false; $show_cat_list = $cat_list != ''; $show_tag_list = $tag_list != ''; $show_taxonomy_list = $taxonomy_list != ''; $show_id_list = $id_list != ''; $show_url_list = $url_list != ''; $show_url_parameter_list = $url_parameter_list != ''; $show_cookie_list = $cookie_list != ''; $show_domain_list = $domain_list != ''; $show_client_list = $client_list != ''; $show_lists = $show_cat_list || $show_tag_list || $show_taxonomy_list || $show_id_list || $show_url_list || $show_url_parameter_list || $show_cookie_list || $show_domain_list || $show_client_list || $lists; if ($show_lists) $lists_style = "font-weight: bold; color: #66f;"; else $lists_style = ""; $show_manual = $manual [$block] ||!empty ($sidebars_with_widget [$block]); if ($show_manual) $manual_style = "font-weight: bold; color: " . ($manual_widget [$block] || empty ($sidebars_with_widget [$block]) ? "#66f;" : "#e44;"); else $manual_style = ""; $insertion_options = $obj->get_maximum_insertions () || $obj->get_display_for_users() != AI_DISPLAY_ALL_USERS || $obj->get_enable_amp () == AI_ENABLED || $obj->get_enable_ajax () != AI_ENABLED || $obj->get_enable_404 () == AI_ENABLED || $obj->get_enable_feed () == AI_ENABLED || $obj->get_max_page_blocks_enabled () || $obj->get_only_in_the_loop () || $obj->get_embed_js_code () || $obj->get_disable_caching (); $word_count_options = intval ($obj->get_minimum_words()) != 0 || intval ($obj->get_maximum_words()) != 0; $automatic_insertion = $obj->get_automatic_insertion(); $paragraph_settings = $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH; $image_settings = $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_IMAGE || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_IMAGE; $filter_insertions_settings = $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_EXCERPT || $automatic_insertion == AI_AUTOMATIC_INSERTION_BETWEEN_POSTS || $automatic_insertion == AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS; if ($filter_insertions_settings) { $filter_active = $obj->get_filter_type() != AI_FILTER_AUTO || $obj->get_inverted_filter() != 0; } else $filter_active = $obj->get_call_filter() || $obj->get_inverted_filter() != 0; $adb_block_action_active = $obj->get_adb_block_action () != AI_ADB_BLOCK_ACTION_DO_NOTHING; $parallax_options = false; for ($index = 1; $index <= 3; $index ++) { $parallax_options |= $obj->get_parallax ($index) && $obj->get_parallax_image ($index) != ''; if ($parallax_options) break; } $display_options = $obj->get_block_width () != '' || $obj->get_block_height () != '' || $obj->get_block_background_color () != '' || $obj->get_show_label () || $obj->get_lazy_loading () || $obj->get_wait_for_interaction () || $obj->get_protected () || $obj->get_sticky () || $obj->get_check_recaptcha_score () ||$obj->get_manual_loading () != AI_MANUAL_LOADING_DISABLED || $obj->get_close_button () || $obj->get_auto_close_time () || $obj->get_stay_closed_time () || $obj->get_delay_time () || $obj->get_delay_showing () || $obj->get_show_every () || $obj->get_iframe () || $parallax_options; $limits_options = $obj->get_max_impressions () || ($obj->get_limit_impressions_per_time_period () && $obj->get_limit_impressions_time_period ()) || $obj->get_max_clicks () || ($obj->get_limit_clicks_per_time_period () && $obj->get_limit_clicks_time_period ()) || $obj->get_visitor_max_impressions () || ($obj->get_visitor_limit_impressions_per_time_period () && $obj->get_visitor_limit_impressions_time_period ()) || $obj->get_visitor_max_clicks () || ($obj->get_visitor_limit_clicks_per_time_period () && $obj->get_visitor_limit_clicks_time_period ()) || $obj->get_trigger_click_fraud_protection (); $scheduling_active = $obj->get_scheduling () != AI_SCHEDULING_OFF; $show_misc = $insertion_options || $word_count_options || $scheduling_active || $filter_active || $adb_block_action_active || $display_options || $limits_options; if ($show_misc) $misc_style = "font-weight: bold; color: #66f;"; else $misc_style = ""; if ($insertion_options) $insertion_style = "font-weight: bold; color: #66f;"; else $insertion_style = ""; if ($word_count_options) $word_count_style = "font-weight: bold; color: #66f;"; else $word_count_style = ""; if ($scheduling_active) $scheduling_style = ($scheduling_period_inactive [$block] ? 'font-weight: bold; color: #e44;' : "font-weight: bold; color: #66f;"); else $scheduling_style = ""; if ($filter_active) $filter_style = "font-weight: bold; color: #66f;"; else $filter_style = ""; if ($adb_block_action_active) $adb_style = "font-weight: bold; color: #66f;"; else $adb_style = ""; if ($display_options) $display_style = "font-weight: bold; color: #66f;"; else $display_style = ""; if ($limits_options) $limits_style = "font-weight: bold; color: #66f;"; else $limits_style = ""; $general_style = ''; $paragraph_counting = $paragraph_settings && ( $obj->get_direction_type() != $default->get_direction_type() || $obj->get_paragraph_tags() != $default->get_paragraph_tags() || $obj->get_minimum_paragraph_words() != $default->get_minimum_paragraph_words() || $obj->get_maximum_paragraph_words() != $default->get_maximum_paragraph_words() || $obj->get_paragraph_text_type() != $default->get_paragraph_text_type() || $obj->get_paragraph_text() != $default->get_paragraph_text() || $obj->get_count_inside_blockquote() != $default->get_count_inside_blockquote() || $obj->get_count_inside() != $default->get_count_inside() || $obj->get_count_inside_elements() != $default->get_count_inside_elements() || $obj->get_count_inside_elements_contain() != $default->get_count_inside_elements_contain() || $obj->get_count_inside_elements_text() != $default->get_count_inside_elements_text() || $obj->get_paragraph_number_minimum() != $default->get_paragraph_number_minimum() || $obj->get_paragraph_number_maximum() != $default->get_paragraph_number_maximum() || $obj->get_skip_first_paragraphs() != $default->get_skip_first_paragraphs() || $obj->get_skip_last_paragraphs() != $default->get_skip_last_paragraphs() || $obj->get_minimum_words_above() != $default->get_minimum_words_above() ); $paragraph_clearance = $paragraph_settings && ( ($obj->get_avoid_text_above() != $default->get_avoid_text_above() && intval ($obj->get_avoid_paragraphs_above()) != 0) || ($obj->get_avoid_text_below() != $default->get_avoid_text_below() && intval ($obj->get_avoid_paragraphs_below()) != 0) ); $html_settings = $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT || $automatic_insertion == AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT; $html_element_insertion = $obj->get_html_element_insertion (); $server_side_insertion = $obj->get_server_side_insertion (); $inside_element = $obj->get_inside_element (); $filter_type = $obj->get_filter_type(); $page_exceptions = array (); $post_exceptions = array (); if (!empty ($block_exceptions [$block])) { $page_index = 0; $post_index = 0; foreach ($block_exceptions [$block] as $id => $exception) { if ($exception ['type'] == 'page') { $row_class = $page_index % 2 == 0 ? 'even' : 'odd'; } else { $row_class = $post_index % 2 == 0 ? 'even' : 'odd'; } $exception_line = ' ' . $id .' ' . $exception ['name'] . ' ' . $exception ['title'] . ' ' . "\n"; if (defined ('AI_CONNECTED_WEBSITE')) { $connected_website = get_transient (AI_CONNECTED_WEBSITE); if ($connected_website !== false) { // No links to the local site $exception_line = preg_replace ('#(.*?)#i', '\1', $exception_line); $exception_line = preg_replace ('#title="(.*?)"#i', '', $exception_line); } } if ($exception ['type'] == 'page') { $page_exceptions []= $exception_line; $page_index ++; } else { $post_exceptions []= $exception_line; $post_index ++; } } } $exceptions_needs_check = false; $option = $obj->import_old_exception_settings ($exceptions_needs_check); $exceptions_error = $obj->get_exceptions_enabled () && $obj->get_exceptions_function () == AI_DEFAULT_INSERTION_DISABLED && empty ($block_exceptions [$block]); $exceptions_shown = $exceptions_needs_check || $exceptions_error; $exception_button_on = $obj->get_exceptions_enabled () && !empty ($block_exceptions [$block]) || $exceptions_shown; ?>
">
get_ad_name() ?> get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" /> get_disable_insertion () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
' class="ai-rotation-warning" style='float: left; font-size: 18px; font-weight: bold; margin: 5px 5px 0 0; display: none;'>⚠
get_display_settings_post()==AI_ENABLED) echo 'checked '; ?> /> get_display_settings_home()==AI_ENABLED) echo 'checked '; ?> /> get_display_settings_category()==AI_ENABLED) echo 'checked '; ?> />
get_display_settings_page()==AI_ENABLED) echo 'checked '; ?> /> get_display_settings_search()==AI_ENABLED) echo 'checked '; ?> /> get_display_settings_archive()==AI_ENABLED) echo 'checked '; ?> />
get_exceptions_enabled () == AI_ENABLED) echo 'checked '; ?> />  
' style='display: table-cell; font-size: 20px; vertical-align: middle; padding: 0;'>⚠ ' style='display: table-cell; font-size: 20px; vertical-align: middle; padding: 0;'>⚠
ID
"> ">
">
    
ms
">
    " type="text" name="" default="get_paragraph_tags(); ?>" value="get_paragraph_tags(); ?>" size="12" maxlength="500"/>  

" type="text" name="" default="get_count_inside_elements (); ?>" value="get_count_inside_elements (); ?>" size="4" maxlength="500"/>
get_check_only_tag_attributes ()==AI_ENABLED) echo 'checked '; ?> /> get_count_inside_blockquote()==AI_ENABLED) echo 'checked '; ?> />

get_skip_first_paragraphs(),'ad-inserter'); ?> get_skip_last_paragraphs(),'ad-inserter'); ?> get_skip_last_paragraphs(), 'ad-inserter'); ?>

get_paragraph_number_maximum(), 'ad-inserter'); ?>

">
 
 
get_ad_block_cat_type() == AI_WHITE_LIST) echo 'checked '; ?> style="display: none;" />
get_ad_block_tag_type() == AI_WHITE_LIST) echo 'checked '; ?> style="display: none;" />
get_ad_block_taxonomy_type() == AI_WHITE_LIST) echo 'checked '; ?> style="display: none;" />
get_id_list_type() == AI_WHITE_LIST) echo 'checked '; ?> style="display: none;" />
get_ad_url_list_type() == AI_WHITE_LIST) echo 'checked '; ?> style="display: none;" />
  " type="text" name="" default="get_url_parameter_list(); ?>" value="" size="54" maxlength="1500"/> get_url_parameter_list_type() == AI_WHITE_LIST) echo 'checked '; ?> style="display: none;" />
get_ad_domain_list_type() == AI_WHITE_LIST) echo 'checked '; ?> style="display: none;" />
get_client_list_type() == AI_WHITE_LIST) echo 'checked '; ?> style="display: none;" />
get_enable_widget () == AI_ENABLED) echo 'checked '; ?> />
get_enable_manual () == AI_ENABLED) echo 'checked '; ?> />
[adinserter block=""]
or
[adinserter name="get_ad_name(); ?>"]
/>
<?php if (function_exists ('adinserter')) echo adinserter (); ?>
get_detection_client_side ()==AI_ENABLED) echo 'checked '; ?> />
$viewport_name) { if ($column % $columns == 0) { ?>
" value="1" default="get_detection_viewport ($viewport); ?>" get_detection_viewport ($viewport)==AI_ENABLED) echo 'checked '; ?> />
get_detection_server_side ()==AI_ENABLED) echo 'checked '; ?> />
get_enable_amp (true) == AI_ENABLED) echo 'checked '; ?> /> get_enable_ajax () == AI_ENABLED) echo 'checked '; ?> /> get_enable_feed () == AI_ENABLED) echo 'checked '; ?> /> get_enable_404 () == AI_ENABLED) echo 'checked '; ?> />
get_max_page_blocks_enabled () == AI_ENABLED) echo 'checked '; ?> />
get_only_in_the_loop () == AI_ENABLED) echo 'checked '; ?> /> get_embed_js_code () == AI_ENABLED) echo 'checked '; ?> /> get_disable_caching () == AI_ENABLED) echo 'checked '; ?> />
get_inverted_filter () == AI_ENABLED) echo 'checked '; ?> />
get_maximum_words(), 'ad-inserter'); ?>
get_show_label () == AI_ENABLED) echo 'checked '; ?> />
  " />
get_call_filter() != '' || $obj->get_maximum_insertions () != ''); ?>
', '', '', '', '', '' ); ?>
">

' class="ai-rotation-warning" style='float: left; font-size: 18px; font-weight: bold; margin: 5px 5px 0 0; display: none;'>⚠
get_plugin_tracking () !== null) { $plugin_tracking = $ai_dst->get_tracking (); ?>
px
/> /> /> />

  
</div>
    : [[
[adinserter data=""]
]]'/>   
[adinserter data=""]
    " size="15" maxlength="40" /> ' ?>    " size="4" maxlength="4" /> px ' ?>
/>
get_enable_manual () == AI_ENABLED) echo 'checked '; ?> style="display: none;" /> get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />

<head></head>'); ?> ', _x ('NOT ENABLED', 'code in the header', 'ad-inserter'), ''; ?>
get_detection_server_side ()==AI_ENABLED) echo 'checked '; ?> />
get_enable_404 () == AI_ENABLED) echo 'checked '; ?> />
get_enable_manual () == AI_ENABLED): ?> ' style='display: inline-block; font-size: 20px; vertical-align: bottom; padding: 0;'> get_enable_manual () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />

  ', _x ('NOT ENABLED', 'ad blocking detection', 'ad-inserter'), ''; ?>
/>
0, 'child_of' => 0, 'selected' => get_redirection_page (true), 'echo' => 0, 'name' => AI_OPTION_ADB_REDIRECTION_PAGE, 'id' => 'redirection-page', 'class' => null, 'show_option_none' => __('Custom Url', 'ad-inserter'), 'show_option_no_change' => null, 'option_none_value' => '0', ); $dropdown_pages = wp_dropdown_pages ($args); $dropdown_title = __ ('Static page for redirection when ad blocking is detected. For other pages select Custom url and set it below.', 'ad-inserter'); $dropdown_pages = str_replace ('
get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
/>
get_tracking (); } if (function_exists ('ai_remote_plugin_data')) { $install_timestamp = ai_remote_plugin_data ('install', $install_timestamp); $install_time = ai_remote_plugin_data ('install-time', $install_time); $since_install = ai_remote_plugin_data ('since-install', $since_install); $review = ai_remote_plugin_data ('review', $review); if (defined ('AI_PLUGIN_TRACKING') && AI_PLUGIN_TRACKING) { $tracking = ai_remote_plugin_data ('tracking', $tracking); } } $d1 = __ ("Force showing admin toolbar for administrators when viewing site. Enable this option when you are logged in as admin and you don't see admin toolbar.", 'ad-inserter'); // Preview of client-side dynamic blocks ?>
style="display: none;" /> style="display: none;" /> style="display: none;" /> style="display: none;" /> style="display: none;" /> style="display: none;" /> style="display: none;" />

<html>
<head>
  ...
  ><style>
    

  </style>
  >
</head>
<body>
  ...
  >

    ><?php  ?>
    

  </div>
  ...
  ><span></span>
  ><script>
    

  </script>
  >
</body>
</html>
/>
/>
/>
/>
/>
2) $sidebar = 1; if ($number_of_used_blocks >= 4 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 5 || $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 10) $sidebar = 2; if ($number_of_used_blocks >= 12 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 7 || $number_of_used_blocks >= 8 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 10 || $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 15) $sidebar = 3; if ($ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20) $sidebar = 4; } else { if ($number_of_used_blocks >= 1) $sidebar = 4; } // $sidebar = 0; if (!function_exists ('ai_settings_side')) { switch ($sidebar) { case 0: break; case 1: break; case 2: sidebar_addense_alternative (); break; case 3: sidebar_support_review (); sidebar_addense_alternative (); break; case 4: sidebar_addense_alternative (); break; } } ?>
$sidebar_widget) { if (is_array ($sidebar_widget) && isset ($GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'])) { $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name']; if ($sidebar_name != "") { foreach ($sidebar_widget as $widget) { if (preg_match ("/ai_widget-([\d]+)/", $widget, $widget_id)) { if (isset ($widget_id [1]) && is_numeric ($widget_id [1])) { $widget_option = $widget_options [$widget_id [1]]; $widget_block = $widget_option ['block']; // if ($widget_block >= $start && $widget_block <= $end && !in_array ($sidebar_name, $sidebars_with_widget [$widget_block])) { if ($widget_block >= 1 && $widget_block <= 96 && !in_array ($sidebar_name, $sidebars_with_widget [$widget_block])) { $sidebars_with_widget [$widget_block] []= $sidebar_name; } } } } } } } return $sidebars_with_widget; } function page_checker_container () { global $ai_custom_hooks; if (function_exists ('ai_settings_theme')) { $current_theme = ai_settings_theme (); } else $current_theme = wp_get_theme (); ?>
>
get_ad_data (); // data-ad-client="ca-pub-3118622027477755" if (preg_match_all ('#data-ad-client\s*=\s*"(.+?)"#', $block_code, $adsense_matches)) { foreach ($adsense_matches [1] as $adsense_match) { if (preg_match ('#(pub-[0-9]+)#', $adsense_match, $adsense_pub_id)) { $found = false; foreach ($block_ads as $block_ad) { if ($block_ad ['ads_data'][1] == $adsense_pub_id [1]) { $found = true; break; } } if (!$found) { $block_ads [] = array ('ads_data' => array ('google.com', $adsense_pub_id [1], 'DIRECT', 'f08c47fec0942fa0'), 'found' => false); } } } } // google_ad_client = "ca-pub-3118622027477755"; if (preg_match_all ('#google_ad_client\s*=\s*"(.+?)"#', $block_code, $adsense_matches)) { foreach ($adsense_matches [1] as $adsense_match) { if (preg_match ('#(pub-[0-9]+)#', $adsense_match, $adsense_pub_id)) { $found = false; foreach ($block_ads as $block_ad) { if ($block_ad ['ads_data'][1] == $adsense_pub_id [1]) { $found = true; break; } } if (!$found) { $block_ads [] = array ('ads_data' => array ('google.com', $adsense_pub_id [1], 'DIRECT', 'f08c47fec0942fa0'), 'found' => false); } } } } } $site_url = site_url (); $home_url = home_url (); $url_parts = explode (DIRECTORY_SEPARATOR, str_replace (array ('https', 'http', '://'), '', $site_url)); $ads_txt_home = 'http' . (is_ssl() ? 's' : '') . '://'. $url_parts [0]; $ads_txt_url = $ads_txt_home . DIRECTORY_SEPARATOR . 'ads.txt'; $wp_content_dir_array = explode ('/', WP_CONTENT_DIR); $wp_content_dir = $wp_content_dir_array [count ($wp_content_dir_array) - 1]; $root_path = str_replace ($wp_content_dir, '', WP_CONTENT_DIR); $ads_txt_file = $root_path . 'ads.txt'; $wp_folder = ''; if (count ($url_parts) > 1) { $wp_folder = str_replace ($ads_txt_home, '', $site_url); $wp_folder = str_replace ('/', DIRECTORY_SEPARATOR, $wp_folder); } echo ''; $virtual = isset ($_GET ["virtual"]) && $_GET ["virtual"]; $virtual_file_missing = false; if ($virtual) { $ads = get_option (AI_ADS_TXT_NAME); if ($ads === false) { $virtual_file_missing = true; $ads = ''; if ($action == 'table') { $action = 'text'; } } } else { if (file_exists ($ads_txt_file)) { $ads = file_get_contents ($ads_txt_file); } else { $ads = ''; if ($action == 'table') { $action = 'text'; } } } $ads_lines = explode ("\n", $ads); $rows = array (); foreach ($ads_lines as $ads_line) { if (trim ($ads_line) == '') continue; $ads_data = explode ('#', str_replace (array ("\r", ' '), '', $ads_line)); $ads_elements = explode (',', $ads_data [0]); if (count ($ads_elements) == 0) continue; $found = false; foreach ($block_ads as $index => $block_ad) { if (!isset ($ads_elements [1])) continue; if ($block_ad ['ads_data'][1] == $ads_elements [1]) { $found = true; $block_ads [$index]['found'] = true; break; } } $rows []= array ('ads_elements' => $ads_elements, 'status' => $found ? 'F' : ''); } $missing_lines = array (); foreach ($block_ads as $block_ad) { if (!$block_ad ['found']) { array_unshift ($rows, array ('ads_elements' => $block_ad ['ads_data'], 'status' => 'M')); $missing_lines []= implode (', ', $block_ad ['ads_data']); } } $search_text = isset ($_GET ["search"]) ? trim (esc_html ($_GET ["search"])) : ''; if ($search_text != '') $search_array = explode (' ', $search_text); else $search_array = array (); foreach ($rows as $index => $row) { $ads_line = implode (' ', $row ['ads_elements']); foreach ($search_array as $search_item) { if (stripos ($ads_line, trim ($search_item)) === false) { unset ($rows [$index]); continue 2; } } } switch ($virtual) { case true: echo '
'; // translators: %s: Ad Inserter echo '
', sprintf (__('ads.txt file: %s virtual ads.txt file', 'ad-inserter'), AD_INSERTER_NAME), '
'; echo '
'; if ($virtual_file_missing) { echo '
'; echo '
', __('Warning', 'ad-inserter'), ': ', /* translators: %s: Ad Inserter */ sprintf (__('%s virtual file ads.txt not found', 'ad-inserter'), AD_INSERTER_NAME), '
'; echo '
'; } break; default: echo '
'; if ($wp_folder != '') { echo '
', __('IMPORTANT', 'ad-inserter'), ': ', __('ads.txt file must be placed on the root domain', 'ad-inserter'), ' ', $ads_txt_url, '
'; echo '
'; } echo ''; echo ''; echo ''; echo '
WordPress', ABSPATH, '
', __('ads.txt file', 'ad-inserter'), '', $ads_txt_file, is_writable ($ads_txt_file) ? '' : ''.__('NOT WRITABLE', 'ad-inserter').'', '
'; echo '
'; if (!file_exists ($ads_txt_file)) { echo '
'; echo '
', __('Warning', 'ad-inserter'), ': ', sprintf (__('file %s not found', 'ad-inserter'), $ads_txt_file), '
'; echo '
'; } break; } // $missing_lines = array (); switch ($action) { case 'text': if (count ($missing_lines)) { echo '
', __('Account IDs found in blocks but not present in the ads.txt file', 'ad-inserter'), '
'; echo ''; if ($virtual) { // translators: %s: Ad Inserter echo '
', sprintf (__('%s virtual ads.txt file', 'ad-inserter'), AD_INSERTER_NAME), '
'; } else { echo '
', $ads_txt_file, '
'; } } echo ''; if (!$virtual) { delete_option (AI_ADS_TXT_NAME); } ai_add_rewrite_rules (); flush_rewrite_rules(); break; case 'table': ?> '.$ads_elements [3] .''; } else $element3 = $ads_elements [3]; } else $element3 = ''; ?>
>
96 || $command === null) { return; } $ai_options = false; if (function_exists ('ai_raw_remote_options')) { $ai_options = ai_raw_remote_options (); } if ($ai_options === false) $ai_options = ai_get_option (AI_OPTION_NAME, array ()); $update_settings = false; switch ($command) { case 'pause': $value = $block_object [$block]->get_disable_insertion () == AI_DISABLED ? AI_ENABLED : AI_DISABLED; $ai_options [$block][AI_OPTION_DISABLE_INSERTION] = $value; $update_settings = true; break; } if ($update_settings) { ai_save_options ($ai_options); } } } function ai_update_block_numbers ($blocks_org, $blocks_new) { global $wpdb; $ai_widgets = get_option ('widget_ai_widget'); if (is_array ($ai_widgets)) foreach ($ai_widgets as $widget_index => $ai_widget) { if (isset ($ai_widget ['block'])) { $widget_block = $ai_widget ['block']; if ($widget_block >= 1 && $widget_block <= 96) { foreach ($blocks_new as $index => $org_block) { if ($widget_block == $org_block) { $ai_widgets [$widget_index]['block'] = $blocks_org [$index]; break; } } } } } update_option ('widget_ai_widget', $ai_widgets); if (defined ('AI_STATISTICS') && AI_STATISTICS) { // Update statistics - two passes to avoid duplicate entries $offset = 1000; // Lock table to prevent updates of old blocks $query = 'LOCK TABLES ' . AI_STATISTICS_DB_TABLE . ' WRITE;'; $update = $wpdb->query ($query); // Pass 1 - new blocks with offset $query = 'UPDATE ' . AI_STATISTICS_DB_TABLE . ' SET block= CASE '; foreach ($blocks_new as $index => $org_block) { $new_block = $blocks_org [$index] + $offset; $query .= "WHEN block= $org_block THEN $new_block "; } $query .= 'ELSE block END;'; $update = $wpdb->query ($query); // Pass 2 - remove offset $query = 'UPDATE ' . AI_STATISTICS_DB_TABLE . " SET block = block - $offset WHERE block >= $offset;"; $update = $wpdb->query ($query); // Unlock table $query = 'UNLOCK TABLES;'; $update = $wpdb->query ($query); } } function code_block_list ($start, $end, $search_text, $show_all_blocks, $active_block) { global $block_object, $ai_db_options_extract; if (defined ('AI_SAFE_MODE') || isset ($_GET ['safe-mode'])) { $url_safe_mode = '&ai-safe-mode'; } else $url_safe_mode = ''; if (isset ($_GET ["cmd"])) { ai_change_settings (); } if (isset ($_GET ["blocks-org"]) && isset ($_GET ["blocks-new"])) { $blocks_org = json_decode ($_GET ["blocks-org"]); $blocks_new = json_decode ($_GET ["blocks-new"]); if (!empty ($blocks_org) && count ($blocks_org) == count ($blocks_new)) { // Update widgets $current_options = false; if (function_exists ('ai_raw_remote_options')) { $current_options = ai_raw_remote_options (); } if ($current_options === false) $current_options = ai_get_option (AI_OPTION_NAME, array ()); $new_options = $current_options; $error = false; foreach ($blocks_org as $index => $block) { $new_block = $blocks_new [$index]; if ($block >= 1 && $block <= 96 && $new_block >= 1 && $new_block <= 96) { if (isset ($current_options [$new_block])) { $new_options [$block] = $current_options [$new_block]; } else { unset ($new_options [$block]); } } else $error = true; } if (!$error) { // Update AI_OPTION_SCHEDULING_FALLBACK, AI_OPTION_LIMITS_FALLBACK and AI_OPTION_ADB_BLOCK_REPLACEMENT for ($block = 1; $block <= 96; $block ++) { if (isset ($new_options [$block][AI_OPTION_SCHEDULING_FALLBACK])) { $ai_option_fallback = $new_options [$block][AI_OPTION_SCHEDULING_FALLBACK]; if ($ai_option_fallback != '') foreach ($blocks_new as $index => $org_block) { if ($ai_option_fallback == $org_block) { $new_options [$block][AI_OPTION_SCHEDULING_FALLBACK] = $blocks_org [$index]; } } } if (isset ($new_options [$block][AI_OPTION_LIMITS_FALLBACK])) { $ai_option_fallback = $new_options [$block][AI_OPTION_LIMITS_FALLBACK]; if ($ai_option_fallback != '') foreach ($blocks_new as $index => $org_block) { if ($ai_option_fallback == $org_block) { $new_options [$block][AI_OPTION_LIMITS_FALLBACK] = $blocks_org [$index]; } } } if (isset ($new_options [$block][AI_OPTION_ADB_BLOCK_REPLACEMENT])) { $ai_option_adb_block_replacement = $new_options [$block][AI_OPTION_ADB_BLOCK_REPLACEMENT]; if ($ai_option_adb_block_replacement != '') foreach ($blocks_new as $index => $org_block) { if ($ai_option_adb_block_replacement == $org_block) { $new_options [$block][AI_OPTION_ADB_BLOCK_REPLACEMENT] = $blocks_org [$index]; } } } } ai_save_options ($new_options, null, $blocks_org, $blocks_new); } } } $sidebars_with_widget = get_sidebar_widgets (); ob_start (); if ($search_text != '') $search_array = explode (' ', $search_text); else $search_array = array (); $blocks = array (); $row_counter = 0; for ($block = 1; $block <= 96; $block ++) { $obj = $block_object [$block]; $automatic_insertion = $obj->get_automatic_insertion () != AI_AUTOMATIC_INSERTION_DISABLED; $manual_widget = $obj->get_enable_widget() == AI_ENABLED; $manual_shortcode = $obj->get_enable_manual() == AI_ENABLED; $manual_php_function = $obj->get_enable_php_call() == AI_ENABLED; $disabled = $obj->get_disable_insertion (); $block_used = /*!$disabled &&*/ ($automatic_insertion || $manual_php_function || $manual_shortcode || $manual_widget && !empty ($sidebars_with_widget [$block])); if (!$show_all_blocks && !$block_used) continue; $process_php = $obj->get_process_php (); $exceptions = $obj->get_exceptions_enabled (); $devices = $obj->get_detection_server_side () || $obj->get_detection_client_side (); $scheduling = $obj->get_scheduling() != AI_SCHEDULING_OFF; $scheduling_period = ''; switch ($obj->get_scheduling ()) { case AI_SCHEDULING_BETWEEN_DATES: case AI_SCHEDULING_OUTSIDE_DATES: $scheduling_period_inactive = !check_scheduling_time ( $obj->get_schedule_start_date () . ' ' . $obj->get_schedule_start_time (), $obj->get_schedule_end_date () . ' ' . $obj->get_schedule_end_time (), $obj->get_schedule_weekdays (), $obj->get_scheduling () == AI_SCHEDULING_BETWEEN_DATES ); $scheduling_period = $obj->get_schedule_start_date () . ($obj->get_schedule_start_time () != '' ? ' ' . $obj->get_schedule_start_time () : ''). '[BR]' . $obj->get_schedule_end_date () . ($obj->get_schedule_end_time () != '' ? ' ' . $obj->get_schedule_end_time () : ''); break; default: $scheduling_period_inactive = false; break; } $tracking = $obj->get_tracking (true); if (ai_pro ()) { $limits = $tracking && ( $obj->get_max_impressions () || ($obj->get_limit_impressions_per_time_period () && $obj->get_limit_impressions_time_period ()) || $obj->get_max_clicks () || ($obj->get_limit_clicks_per_time_period () && $obj->get_limit_clicks_time_period ()) || $obj->get_visitor_max_impressions () || ($obj->get_visitor_limit_impressions_per_time_period () && $obj->get_visitor_limit_impressions_time_period ()) || $obj->get_visitor_max_clicks () || ($obj->get_visitor_limit_clicks_per_time_period () && $obj->get_visitor_limit_clicks_time_period ()) || $obj->get_trigger_click_fraud_protection () && get_click_fraud_protection () ); } $block_text = $block . ' '. $obj->get_ad_name () . ' ' . $obj->get_automatic_insertion_text() . ' ' . implode (', ', $sidebars_with_widget [$block]); if ($process_php) $block_text .= ' php'; if ($exceptions) $block_text .= ' exceptions'; if ($devices) $block_text .= ' device'; if ($scheduling) $block_text .= ' scheduling'; if (ai_pro ()) { if ($limits) $block_text .= ' limits'; } if ($tracking) $block_text .= ' tracking'; if (!empty ($sidebars_with_widget [$block])) $block_text .= ' widget'; if ($manual_shortcode) $block_text .= ' shortcode'; if ($manual_php_function) $block_text .= ' function'; foreach ($search_array as $search_item) { if (stripos ($block_text, trim ($search_item)) === false) continue 2; } $blocks []= $block; $row_counter ++; $row_class = $row_counter % 2 == 0 ? 'even' : 'odd'; if ($block == $active_block) { $row_class .= ' ai-block-active'; } $settings_page = get_menu_position () == AI_SETTINGS_SUBMENU ? 'options-general.php?page=ad-inserter.php' : 'admin.php?page=ad-inserter.php'; $edit_url = admin_url ($settings_page) . '&start=' . (intval (($block - 1) / 16) * 16 + 1) . '&tab=' . $block . $url_safe_mode; $visible_tab = $block >= $start && $block <= $end; $insertion_parameter = ''; $insertion_title = ''; switch ($obj->get_automatic_insertion()) { case AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH: case AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH: case AI_AUTOMATIC_INSERTION_BEFORE_IMAGE: case AI_AUTOMATIC_INSERTION_AFTER_IMAGE: $insertion_parameter = ' ' . $obj->get_paragraph_number (); $insertion_title = $obj->get_paragraph_number (); break; case AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT: case AI_AUTOMATIC_INSERTION_AFTER_EXCERPT: case AI_AUTOMATIC_INSERTION_BETWEEN_POSTS: case AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS: $insertion_parameter = ' ' . $obj->get_call_filter (); $insertion_title = $obj->get_call_filter (); break; case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT: case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT: case AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT: $insertion_title = $obj->get_html_selector (); break; } ?> get_ad_name(); ?> get_ad_name(); ?> get_automatic_insertion_text(), $insertion_parameter; ?> fn [s] w
fn [s] W
", __ ('No active block', 'ad-inserter'), ""; else echo "
", __ ('No block matches search keywords', 'ad-inserter'), "
"; } } if (defined ('AI_ADSENSE_API')) { function ai_adsense_data (&$error) { require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php'; $error = 'AdSense not authorized'; $ad_data = false; if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) { $error = ''; $update_ad_units = isset ($_GET ["update_ad_units"]) ? $_GET ["update_ad_units"] == 1 : false; $adsense = new adsense_api (); $ad_data = get_transient (AI_TRANSIENT_ADSENSE_ADS); if ($ad_data === false || $update_ad_units) { $ad_units = $adsense->getAdUnits(); $error = $adsense->getError (); if ($error == '' && is_array ($ad_units)) { $ad_data = array ($adsense->getAdSensePublisherID (), $ad_units); set_transient (AI_TRANSIENT_ADSENSE_ADS, $ad_data, AI_TRANSIENT_ADSENSE_ADS_EXPIRATION); } } } return $ad_data; } function adsense_list () { require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php'; if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) { if (get_transient (AI_TRANSIENT_ADSENSE_TOKEN_1) !== false) { // Old token for API version 1 $error = 'unauthorized_client_2'; } else { $publisher_id = ''; $ad_units = array (); $error = ''; $ad_data = ai_adsense_data ($error); } if ($error == '') { $publisher_id = $ad_data [0]; $ad_units = $ad_data [1]; $show_all_ad_units = isset ($_GET ["all"]) && $_GET ["all"]; ?>
$error"; if (strpos ($error, 'unauthorized_client') !== false) { echo '
', // translators: %s: HTML tags sprintf (__('Please %s clear authorization %s with the button %s above and once again authorize access to your AdSense account.', 'ad-inserter'), '', '', '' ), '
'; } } } elseif (defined ('AI_ADSENSE_CLIENT_ID')) { $adsense = new adsense_api(); $adsense_ids = defined ('AI_CI_STRING') && get_option (AI_ADSENSE_OWN_IDS) === false; ?>

', '', '', '' ); ?>

'.AD_INSERTER_NAME.'', AD_INSERTER_NAME ); ?>

  1. ', ''); ?>
  2. Ad Inserter', '', ''); ?>
  3. ', ''); ?>
  4. Ad Inserter', '', ''); ?>
  5. Ad Inserter'); ?>
  6. ', ''); ?>
  7. AdSense Management API'); ?>
  8. ', ''); ?>
  9. ', '', '', ''); ?>
  10. ', '', '', ''); ?>
  11. ', '', '', ''); ?>
  12. ', ''); ?>
  13. ', '', '', ''); ?>
  14. ', '', '', '', '', ''); ?>
  15. ', '', 'Ad Inserter', '', ''); ?>
  16. ', '', '', ''); ?>
  17. ', '', '', ''); ?>
  18. ', '', '', ''); ?>
  19. ', '', '', '', '', ''); ?>
  20. ', '', '', ''); ?>
  21. ', '', '', '', '', ''); ?>
   
getAdCode ($ad_slot_id); echo json_encode (array ('code' => $code, 'error-message' => $adsense->getError ())); } } } function adsense_ad_name () { if (defined ('AI_ADSENSE_API')) { $publisher_id = ''; $ad_units = array (); $error = ''; $ad_data = ai_adsense_data ($error); if ($error == '') { $publisher_id = $ad_data [0]; $ad_units = $ad_data [1]; $ad_slot_names = array ('publisher_id' => $publisher_id); foreach ($ad_units as $ad_unit) { if ($ad_unit ['active']) $ad_slot_names [$ad_unit ['code']] = $ad_unit ['name']; } echo json_encode ($ad_slot_names); } } } function generate_list_options ($options) { switch ($options) { case 'category': $category_data = ai_get_category_list (); foreach ($category_data as $category) { echo " \n"; $category_to_check = get_term_by ('slug', $category->slug, 'category'); if ($category_to_check) { $descendants = get_term_children ($category_to_check->term_id, 'category'); if ($descendants) { // Translators: %s: category name echo " \n"; // Translators: %s: category name echo " \n"; } } } break; case 'tag': $tag_data = ai_get_tag_list (); foreach ($tag_data as $tag) { echo " \n"; } break; case 'taxonomy': $taxonomies = ai_get_taxonomy_list (); foreach ($taxonomies as $taxonomy => $taxonomy_name) { if ($taxonomy_name != '') echo " \n"; else echo " \n"; } break; case 'id': $posts_pages = ai_get_post_id_list (); $counter = 0; foreach ($posts_pages as $post_page) { if ($post_page->post_title == '') continue; echo " \n"; $counter ++; if ($counter >= AI_MAX_LIST_ITEMS) break; } echo " \n"; echo " \n"; break; case 'client': $languages = array ( 'af' => 'Afrikaans', 'sq' => 'Albanian', 'an' => 'Aragonese', 'ar*' => 'Arabic (Standard)', 'ar-dz' => 'Arabic (Algeria)', 'ar-bh' => 'Arabic (Bahrain)', 'ar-eg' => 'Arabic (Egypt)', 'ar-iq' => 'Arabic (Iraq)', 'ar-jo' => 'Arabic (Jordan)', 'ar-kw' => 'Arabic (Kuwait)', 'ar-lb' => 'Arabic (Lebanon)', 'ar-ly' => 'Arabic (Libya)', 'ar-ma' => 'Arabic (Morocco)', 'ar-om' => 'Arabic (Oman)', 'ar-qa' => 'Arabic (Qatar)', 'ar-sa' => 'Arabic (Saudi Arabia)', 'ar-sy' => 'Arabic (Syria)', 'ar-tn' => 'Arabic (Tunisia)', 'ar-ae' => 'Arabic (U.A.E.)', 'ar-ye' => 'Arabic (Yemen)', 'hy' => 'Armenian', 'as' => 'Assamese', 'ast' => 'Asturian', 'az' => 'Azerbaijani', 'eu' => 'Basque', 'bg' => 'Bulgarian', 'be' => 'Belarusian', 'bn' => 'Bengali', 'bs' => 'Bosnian', 'br' => 'Breton', 'my' => 'Burmese', 'ca' => 'Catalan', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh*' => 'Chinese', 'zh-hk' => 'Chinese (Hong Kong)', 'zh-cn' => 'Chinese (PRC)', 'zh-sg' => 'Chinese (Singapore)', 'zh-tw' => 'Chinese (Taiwan)', 'cv' => 'Chuvash', 'co' => 'Corsican', 'cr' => 'Cree', 'hr' => 'Croatian', 'cs' => 'Czech', 'da' => 'Danish', 'nl*' => 'Dutch (Standard)', 'nl-be' => 'Dutch (Belgian)', 'en*' => 'English', 'en-au' => 'English (Australia)', 'en-bz' => 'English (Belize)', 'en-ca' => 'English (Canada)', 'en-ie' => 'English (Ireland)', 'en-jm' => 'English (Jamaica)', 'en-nz' => 'English (New Zealand)', 'en-ph' => 'English (Philippines)', 'en-za' => 'English (South Africa)', 'en-tt' => 'English (Trinidad & Tobago)', 'en-gb' => 'English (United Kingdom)', 'en-us' => 'English (United States)', 'en-zw' => 'English (Zimbabwe)', 'eo' => 'Esperanto', 'et' => 'Estonian', 'fo' => 'Faeroese', 'fa' => 'Persian', 'fj' => 'Fijian', 'fi' => 'Finnish', 'fr*' => 'French (Standard)', 'fr-be' => 'French (Belgium)', 'fr-ca' => 'French (Canada)', 'fr-fr' => 'French (France)', 'fr-lu' => 'French (Luxembourg)', 'fr-mc' => 'French (Monaco)', 'fr-ch' => 'French (Switzerland)', 'fy' => 'Frisian', 'fur' => 'Friulian', 'gd*' => 'Scots Gaelic', 'gd-ie' => 'Gaelic (Irish)', 'gl' => 'Galacian', 'ka' => 'Georgian', 'de*' => 'German (Standard)', 'de-at' => 'German (Austria)', 'de-de' => 'German (Germany)', 'de-li' => 'German (Liechtenstein)', 'de-lu' => 'German (Luxembourg)', 'de-ch' => 'German (Switzerland)', 'el' => 'Greek', 'gu' => 'Gujurati', 'ht' => 'Haitian', 'he' => 'Hebrew', 'hi' => 'Hindi', 'hu' => 'Hungarian', 'is' => 'Icelandic', 'id' => 'Indonesian', 'iu' => 'Inuktitut', 'ga' => 'Irish', 'it*' => 'Italian (Standard)', 'it-ch' => 'Italian (Switzerland)', 'ja' => 'Japanese', 'kn' => 'Kannada', 'ks' => 'Kashmiri', 'kk' => 'Kazakh', 'km' => 'Khmer', 'ky' => 'Kirghiz', 'tlh' => 'Klingon', 'ko*' => 'Korean', 'ko-kp' => 'Korean (North Korea)', 'ko-kr' => 'Korean (South Korea)', 'la' => 'Latin', 'lv' => 'Latvian', 'lt' => 'Lithuanian', 'lb' => 'Luxembourgish', 'mk' => 'FYRO Macedonian', 'ms' => 'Malay', 'ml' => 'Malayalam', 'mt' => 'Maltese', 'mi' => 'Maori', 'mr' => 'Marathi', 'mo' => 'Moldavian', 'nv' => 'Navajo', 'ng' => 'Ndonga', 'ne' => 'Nepali', 'no' => 'Norwegian', 'nb' => 'Norwegian (Bokmal)', 'nn' => 'Norwegian (Nynorsk)', 'oc' => 'Occitan', 'or' => 'Oriya', 'om' => 'Oromo', 'fa-ir' => 'Persian/Iran', 'pl' => 'Polish', 'pt*' => 'Portuguese', 'pt-br' => 'Portuguese (Brazil)', 'pa*' => 'Punjabi', 'pa-in' => 'Punjabi (India)', 'pa-pk' => 'Punjabi (Pakistan)', 'qu' => 'Quechua', 'rm' => 'Rhaeto-Romanic', 'ro*' => 'Romanian', 'ro-mo' => 'Romanian (Moldavia)', 'ru*' => 'Russian', 'ru-mo' => 'Russian (Moldavia)', 'sz' => 'Sami (Lappish)', 'sg' => 'Sango', 'sa' => 'Sanskrit', 'sc' => 'Sardinian', 'sd' => 'Sindhi', 'si' => 'Singhalese', 'sr' => 'Serbian', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'so' => 'Somani', 'sb' => 'Sorbian', 'es*' => 'Spanish', 'es-ar' => 'Spanish (Argentina)', 'es-bo' => 'Spanish (Bolivia)', 'es-cl' => 'Spanish (Chile)', 'es-co' => 'Spanish (Colombia)', 'es-cr' => 'Spanish (Costa Rica)', 'es-do' => 'Spanish (Dominican Republic)', 'es-ec' => 'Spanish (Ecuador)', 'es-sv' => 'Spanish (El Salvador)', 'es-gt' => 'Spanish (Guatemala)', 'es-hn' => 'Spanish (Honduras)', 'es-mx' => 'Spanish (Mexico)', 'es-ni' => 'Spanish (Nicaragua)', 'es-pa' => 'Spanish (Panama)', 'es-py' => 'Spanish (Paraguay)', 'es-pe' => 'Spanish (Peru)', 'es-pr' => 'Spanish (Puerto Rico)', 'es-es' => 'Spanish (Spain)', 'es-uy' => 'Spanish (Uruguay)', 'es-ve' => 'Spanish (Venezuela)', 'sx' => 'Sutu', 'sw' => 'Swahili', 'sv*' => 'Swedish', 'sv-fi' => 'Swedish (Finland)', 'sv-sv' => 'Swedish (Sweden)', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Teluga', 'th' => 'Thai', 'tig' => 'Tigre', 'ts' => 'Tsonga', 'tn' => 'Tswana', 'tr' => 'Turkish', 'tk' => 'Turkmen', 'uk' => 'Ukrainian', 'hsb' => 'Upper Sorbian', 'ur' => 'Urdu', 've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapuk', 'wa' => 'Walloon', 'cy' => 'Welsh', 'xh' => 'Xhosa', 'ji' => 'Yiddish', 'zu' => 'Zulu', ); $clients = array (); if (version_compare (phpversion (), "5.6", ">=")) { require_once AD_INSERTER_PLUGIN_DIR.'includes/agent/Agent.php'; $agent = new Agent(); $clients = array_merge ( array_keys ($agent->getOperatingSystems ()), array_keys ($agent->getBrowsers ()), array_keys ($agent->getPhoneDevices ()), array_keys ($agent->getTabletDevices ()), array_keys ($agent->getUtilities ()) ); foreach ($clients as $client) { echo " \n"; } } else { } foreach ($languages as $language_id => $language) { echo " \n"; } $clients = array_merge ( $clients, $languages ); break; default: if (function_exists ('ai_generate_list_options')) ai_generate_list_options ($options); break; } } function ai_get_posts_pages_with_exceptions () { $args = array ( 'public' => true, '_builtin' => false ); $custom_post_types = get_post_types ($args, 'names', 'and'); $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types)); $args = array ( 'posts_per_page' => AI_LIST_EXCEPTIONS_LIMIT, 'offset' => 0, 'category' => '', 'category_name' => '', 'orderby' => 'type', 'order' => 'ASC', 'include' => '', 'exclude' => '', 'meta_query' => array ( array ( 'key' => '_adinserter_block_exceptions', 'value' => '', 'compare' => '!=' ) ), 'post_type' => $screens, 'post_mime_type' => '', 'post_parent' => '', 'author' => '', 'author_name' => '', 'post_status' => '', 'suppress_filters' => true ); return (get_posts ($args)); } function ai_get_exceptions ($conditions) { if (function_exists ('ai_get_exceptions_2')) { $exceptions = ai_get_exceptions_2 (); if (is_array ($exceptions)) return $exceptions; } $exceptions = false; $block_exceptions = array (); if ($conditions) { $posts_pages = ai_get_posts_pages_with_exceptions (); $exceptions = array (); foreach ($posts_pages as $page) { $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true); if ($post_meta == '') continue; $post_type_object = get_post_type_object ($page->post_type); $exceptions [$page->ID] = array ('type' => $page->post_type, 'name' => $post_type_object->labels->singular_name, 'title' => $page->post_title, 'blocks' => $post_meta); $selected_blocks = explode (",", $post_meta); foreach ($selected_blocks as $selected_block) { $block_exceptions [$selected_block][$page->ID] = array ('type' => $page->post_type, 'name' => $post_type_object->labels->singular_name, 'title' => $page->post_title); } } } return array ($exceptions, $block_exceptions); } function ai_clear_exceptions () { $clear = $_POST [AI_FORM_CLEAR_EXCEPTIONS]; $posts_pages = ai_get_posts_pages_with_exceptions (); // All exceptions if ($clear == "\xe2\x9d\x8c") { foreach ($posts_pages as $page) { delete_post_meta ($page->ID, '_adinserter_block_exceptions'); } } // Exceptions for post id elseif (strpos ($clear, 'id=') === 0) { $id = str_replace ('id=', '', $clear); if (is_numeric ($id)) { delete_post_meta ($id, '_adinserter_block_exceptions'); } } // Block exceptions elseif (is_numeric ($clear)) { foreach ($posts_pages as $page) { $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true); $selected_blocks = explode (",", $post_meta); if (($key = array_search ($clear, $selected_blocks)) !== false) { unset ($selected_blocks [$key]); update_post_meta ($page->ID, '_adinserter_block_exceptions', implode (",", $selected_blocks)); } } } } function ai_clear_settings () { global $ai_db_options, $block_object, $wpdb, $ai_db_options_extract; if (defined ('AI_CONNECTED_MANAGER')) { $connected_manager = get_transient (AI_CONNECTED_MANAGER); } else $connected_manager = false; for ($block = 1; $block <= 96; $block ++) { delete_option (str_replace ("#", $block, AD_ADx_OPTIONS)); } $saved_management_key = isset ($ai_db_options [AI_OPTION_GLOBAL]['MANAGEMENT_KEY']) ? $ai_db_options [AI_OPTION_GLOBAL]['MANAGEMENT_KEY'] : ''; delete_option (str_replace ("#", "Header", AD_ADx_OPTIONS)); delete_option (str_replace ("#", "Footer", AD_ADx_OPTIONS)); delete_option (AD_OPTIONS); delete_option (AI_OPTION_NAME); delete_option (AI_EXTRACT_NAME); delete_option (AI_FLAGS_NAME); if (is_multisite () && is_main_site ()) { delete_site_option (AI_OPTION_NAME); } delete_option (AI_ADSENSE_CLIENT_IDS); delete_option (AI_ADSENSE_AUTH_CODE); delete_option (AI_ADSENSE_OWN_IDS); delete_option (AI_ADS_TXT_NAME); delete_transient (AI_TRANSIENT_ADSENSE_TOKEN_1); delete_transient (AI_TRANSIENT_ADSENSE_TOKEN); delete_transient (AI_TRANSIENT_ADSENSE_ADS); delete_transient ('ai-close'); if (function_exists ('ai_load_globals')) { delete_option (WP_AD_INSERTER_PRO_LICENSE); if ($connected_manager === false) { delete_option (WP_AD_INSERTER_PRO_KEY); } delete_option (WP_AD_INSERTER_PRO_CLIENT); $wpdb->query ("DROP TABLE IF EXISTS " . AI_STATISTICS_DB_TABLE); if (defined ('AI_CONNECTED_WEBSITE')) { delete_transient (AI_CONNECTED_WEBSITE); delete_option (AI_WEBSITES); } delete_transient (AI_TRANSIENT_ADB_CLASS_1); delete_transient (AI_TRANSIENT_ADB_CLASS_2); delete_transient (AI_TRANSIENT_ADB_CLASS_3); delete_transient (AI_TRANSIENT_ADB_CLASS_4); delete_transient (AI_TRANSIENT_ADB_CLASS_5); delete_transient (AI_TRANSIENT_ADB_CLASS_6); delete_transient (AI_TRANSIENT_ADB_FILES_VERSION); } // if (/*ai_current_user_role_ok () && */(!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) { $posts_pages = ai_get_posts_pages_with_exceptions (); foreach ($posts_pages as $page) { delete_post_meta ($page->ID, '_adinserter_block_exceptions'); } // } ai_load_settings (); $options = $ai_db_options; $options [AI_OPTION_EXTRACT] = ai_generate_extract ($options); $ai_db_options_extract = $options [AI_OPTION_EXTRACT]; $options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'] = generate_viewport_css (); $options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'] = generate_alignment_css (); $options [AI_OPTION_GLOBAL]['TIMESTAMP'] = time (); if ($connected_manager !== false) { $options [AI_OPTION_GLOBAL]['REMOTE_DEBUGGING'] = AI_ENABLED; $options [AI_OPTION_GLOBAL]['REMOTE_MANAGEMENT'] = AI_ENABLED; $options [AI_OPTION_GLOBAL]['MANAGEMENT_KEY'] = $saved_management_key; } ai_update_option (AI_OPTION_NAME, $options); update_option (AI_EXTRACT_NAME, $ai_db_options_extract); ai_load_settings (); if (function_exists ('ai_load_globals')) ai_load_globals (); } function ai_clear_statistics () { global $wpdb; if (isset ($_POST [AI_FORM_CLEAR_STATISTICS]) &&is_numeric ($_POST [AI_FORM_CLEAR_STATISTICS])) { if ($_POST [AI_FORM_CLEAR_STATISTICS] != 0) { $wpdb->query ("DELETE FROM " . AI_STATISTICS_DB_TABLE . " WHERE block = " . ((int) $_POST [AI_FORM_CLEAR_STATISTICS])); } else $wpdb->query ("DROP TABLE IF EXISTS " . AI_STATISTICS_DB_TABLE); } } function ai_check_page () { $download_urls = array (); // echo '["1","2","3","4"]'; // return; switch ($_GET ["check-page"]) { case 'po': case 'pa': $args = array ( 'public' => true, '_builtin' => false ); $custom_post_types = get_post_types ($args, 'names', 'and'); $screens = array_values (array_merge (array ($_GET ["check-page"] == 'po' ? 'post' : 'page'), $custom_post_types)); $args = array ( 'posts_per_page' => 1, 'offset' => 0, 'category' => '', 'category_name' => '', 'orderby' => 'ID', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => $screens, 'post_mime_type' => '', 'post_parent' => '', 'author' => '', 'author_name' => '', 'post_status' => '', 'suppress_filters' => true, ); $posts_pages = get_posts ($args); if (isset ($posts_pages [0])) { $download_urls []= get_permalink ($posts_pages [0]->ID); } // Check also post/page with comments $args = array ('post_type' => $_GET ["check-page"] == 'po' ? 'post' : 'page', 'number' => 1); $comment_data = get_comments ($args); if (isset ($comment_data [0])) { $download_urls []= get_permalink ($comment_data [0]->comment_post_ID); } break; case 'hp': $download_urls []= home_url () . '/'; break; case 'cp': $args = array ('hide_empty' => 0, 'orderby' => 'count', 'order' => 'DESC', 'number' => 1); $category_data = get_categories ($args); if (isset ($category_data [0])) { $download_urls []= get_category_link ($category_data [0]->cat_ID) . '/'; } break; case 'ap': $args = array ('hide_empty' => 0, 'orderby' => 'count', 'order' => 'DESC', 'number' => 1); $tag_data = get_tags ($args); if (isset ($tag_data [0])) { $download_urls []= get_tag_link ($tag_data [0]->term_taxonomy_id) . '/'; } break; case 'sp': $download_urls []= home_url () . '/?s=a'; break; } if (!empty ($download_urls)) { $positions = array (); $secret_key = ai_secret_key (); foreach ($download_urls as $download_url) { $tmp_file = download_url (add_query_arg (array (AI_URL_DEBUG_POSITIONS => '0', 'ai-secret' => $secret_key), $download_url)); if (!is_wp_error ($tmp_file) && file_exists ($tmp_file)) { $page = file_get_contents ($tmp_file); preg_match_all ('#data-ai-position=[\'\"](.+?)[\'\"]#', $page, $matches); foreach (array_unique ($matches [1]) as $position) { $positions [] = (int) $position; } } else { // @unlink ($tmp_file); $error_string = $tmp_file->get_error_message(); echo $error_string; return; } @unlink ($tmp_file); } switch ($_GET ["check-page"]) { case 'po': case 'pa': if (in_array (AI_AUTOMATIC_INSERTION_BEFORE_CONTENT, $positions) && in_array (AI_AUTOMATIC_INSERTION_AFTER_CONTENT, $positions)) { $positions [] = AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH; $positions [] = AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH; $positions [] = AI_AUTOMATIC_INSERTION_BEFORE_IMAGE; $positions [] = AI_AUTOMATIC_INSERTION_AFTER_IMAGE; } if (in_array (AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS, $positions) && in_array (AI_AUTOMATIC_INSERTION_AFTER_COMMENTS, $positions)) { $positions [] = AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS; } break; } $positions = array_unique ($positions); sort ($positions); foreach ($download_urls as $index => $download_url) { $download_urls [$index] = add_query_arg (array (AI_URL_DEBUG_POSITIONS => '0', 'no-cookie' => '1'), $download_url); } echo json_encode (array ('positions' => $positions, 'urls' => $download_urls)); } } function sidebar_addense_alternative () { ?>


Ad Inserter', '', '', ' ' ); ?>

<?php _e ('Ad Inserter on Twitter', 'ad-inserter'); ?> <?php _e ('Ad Inserter on Facebook', 'ad-inserter'); ?>

', '', '', '', '', '', '', '' ); ?>
', '', '', '', '', '', '', '', '', '', '', '' ); ?>

', '' ); ?> happy

', '' ); ?>
', '' ); ?>

20 EUR'); ?>

  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', '', '', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', '', '<body>', '</body>'); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>

one year of free updates and support via email. If you find Ad Inserter useful and need ad statistics for impressions and clicks, A/B testing, sticky ads, slider ads, pop-up ads, geotargeting or geolocation to serve country-specific ads, to protect content or to serve different ads for users using ad blockers, multisite options to limit settings for ads, to block some IP addresses, to schedule ads, then you can simply upgrade to %s Ad Inserter Pro %s (existing settings will be preserved).', 'ad-inserter'), '', ''); ?>

', ''); ?>


  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
  • ', ''); ?>
generate_alignment_class ($block_class_name); if ($block_class_name != '' && $block_number_class) $classes []= $block_class_name . '-n'; if ($block_class_name != '' && $block_name_class) $classes []= $block_class_name . '-name'; $class = count ($classes) ? ' class="' . implode (' ', $classes) . '"' : ''; $style = $inline_styles || !defined ('AI_NORMAL_HEADER_STYLES') ? ' style="' . AI_ALIGNMENT_CSS_DEFAULT . '"' : ''; echo "<div$class$style>"; } changelog.txt000064400000070521146731142050007244 0ustar00= Changelog archive = This is an archive of older changelog entries. Most recent entries are maintained in readme.txt = 2.6.27 = - Added support for scheduled rotation - Few minor bug fixes, cosmetic changes and code improvements = 2.6.26 = - Few bug fixes (Pro only) = 2.6.25 = - Added support for block names in adinserter shortcode block attributes - Added support for default custom field values - Added support to list post ID range - Improved ad blocking detection - Reduced layout shift when using CHECK shortcodes - Fix for expanded shortcodes in the rotate code generator - Few minor bug fixes, cosmetic changes and code improvements = 2.6.24 = - Added support for consent attribute for code generator for AdSense and Amazon AMP ads - Added support for random number shortcode - Added support for && and !! operators in client-side client list checks - Added scheduling time on blocks list (Pro only) - Improved undismissible message when ad blocking is detected - Few minor bug fixes, cosmetic changes and code improvements = 2.6.23 = - Reduced layout shift when using lists and client-side dynamic blocks - Few minor bug fixes, cosmetic changes and code improvements = 2.6.22 = - Various security fixes - Updated AdSense API authorization process - Reduced layout shift when using client-side device detection - Added option to block IP addresses for click fraud protection (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.6.21 = - Improved compatibility with PHP 8 - Few minor bug fixes, cosmetic changes and code improvements = 2.6.20 = - Added support for alt text and lazy loading for banner code generator - Few minor bug fixes, cosmetic changes and code improvements = 2.6.19 = - Improved code to reduce layout shift when using client-side device detection - Added translation for es_ES - Added translation for fr_FR - Added translation for it_IT - Improved compatibility with PHP 8 - Few minor bug fixes, cosmetic changes and code improvements = 2.6.18 = - Added support to change Dynamic blocks setting for adinserter PHP function call - Few minor bug fixes, cosmetic changes and code improvements = 2.6.17 = - Fix for double client-side insertions when using geolocation (Pro only) = 2.6.16 = - Added support for ad blocking detection action every n pageviews - Added support to individually disable pageview or click tracking (Pro only) - Changed IAB TCF v2 cookie check name from euconsent-v2 to tcf-v2 (euconsent-v2 will still work) - Fix for category check on category pages - Fix for issues with Safari browser - Few minor bug fixes, cosmetic changes and code improvements = 2.6.15 = - No ad blocking detection actions for crawlers and bots - Fix for processing Ad Inserter shortcodes inside HTML tags - Few minor bug fixes, cosmetic changes and code improvements = 2.6.14 = - Added support to insert [embed] shortcodes - Few minor bug fixes, cosmetic changes and code improvements = 2.6.13 = - Few minor bug fixes = 2.6.12 = - Improved ad blocking detection - Added options to delay client-side insertions at HTML element - Added support to check for multiple cookie values (needed for IAB TCF 2.0) - Added filter hooks for block processing - Few minor bug fixes, cosmetic changes and code improvements = 2.6.11 = - Added support for IAB Transparency & Consent Framework 2.0 - Added support for taxonomy for primary category - Added support for taxonomy for post meta data - Added support to invert contain/do not contain text condition for paragraph counting - Few minor bug fixes, cosmetic changes and code improvements = 2.6.10 = - Added user taxonomy items for logged-in and not logged-in users - Added option to define tab setup delay (for the plugin settings page) - Added option to insert unique ad rotation options when block is inserted more than once - Added support for client-side device detection for AMP pages (for method Show) - Added support for code generator for Amazon AMP ads - Added support for custom tracking events (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.6.9 = - Added option for paragraph counting to search only tag attributes for text - Added option to embed block Javascript code (to be loaded with Ajax calls) - Added support to prevent duplicate insertions when the_content filter is called more than once (experimental) - Added support for the client list to check for partial user agent strings - Added support for check of cookie object properties - Improved ad blocking detection - Viewports no longer need to be in descending width order - Added option to protect inserted block content (Pro only) - Added support for adb scripts path filter hook (Pro only) - Added support to export statistics data to CSV file (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.6.8 = - Added support to disable PHP processing by PHP constant - Added support to repeat COUNT options - Added support for offset for %n paragraph number (%n@o) - Added support for options to skip insertion for first and last paragraphs - Added support for hook filter 'ai_block_insertion_check' - Added support for background ads (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.6.7 = - Added support for various shortcodes for post categories - Added support for various shortcodes for post tags - Added support for user action on click (Pro only) - Added support for manual loading (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.6.6 = - Fix for exceptions list not showing all exceptions - Improved ad blocking detection - Fix for close button in preview window (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.6.5 = - Added support for url data shortcode - Added warning if not all exceptions were cleared - Added support for MaxMind country only database (Pro only) - Added support for ip to country lookup filter hook (Pro only) - Fix for country groups in CHECK separators (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.6.4 = - Fix for use of undefined constant warning (Pro only) = 2.6.3 = - Added support for shortcodes to disable block insertion - Added support for child taxonomy list items - Added random parameter to Ajax requests for geolocation (Pro only) - Added options to define external tracking event category, action and label (Pro only) - Number of custom hooks increased to 20 - Fix to prevent insertion into head section when using Rank Math plugin - Few minor bug fixes, cosmetic changes and code improvements = 2.6.2 = - Added support to disable caching of block PHP code - Added support to pause blocks on the blocks list - Added support for no url parameters list item - Added support for client-side scheduling (Pro only) - Added support for server-side scheduling using W3TC (Pro only) - Added support for multisite:site-id taxonomy list item (Pro only) - Updated MaxMind GeoLite2 database download using license key (Pro only) - Changed settings format in the database to prevent export/import issues with MySQL/PhpMyAdmin - Fix for [ADINSERTER counter] shortcode not expanding inside HTML tags - Few minor bug fixes, cosmetic changes and code improvements = 2.6.1 = - Fix for errors on the settings page - Fix for non English characters in ads - Fix for sticky widgets - Few minor bug fixes = 2.6.0 = - Added support for VIEWPORT separator - Added support for viewport check in CHECK separators (Pro only) - Added support to show processing log on front-end - Added support to show link to the Ad Inserter Pro settings page on multisite Sites page (Pro only) - Added support to detect and prevent document.write after DOM is ready - Added support for scheduling hours (Pro only) - Added support for scheduling days in week (Pro only) - Added support for W3TC insertion debugging info - Improved Javascript code for client-side functions - Improved ad blocking detection - Default value for Wait for jQuery set to Enabled - Few minor bug fixes, cosmetic changes and code improvements = 2.5.10 = - Optimized Javascript code to allow advanced optimizations - Added support to wait for jQuery so it can be deferred - Added support for children categories in lists - Added support to load settings page in safe mode - Added warning notice if PHP version is below 5.6 - Improved user interface for lists - Modified Javascript code that was wrongly replaced by CDN url - Fix for updates server access warning message (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.5.9 = - Added support for block name class - Added support for code generator for AdSense sticky AMP ads - Fix for paragraph clearance issues - Few minor bug fixes, cosmetic changes and code improvements = 2.5.8 = - Added support to call function adinserter () with block name - Added support to insert header code with HEAD separator only once - Additional info for errors when saving settings - Improved support for insertion between posts on AMP pages - Implemented compatibility with other plugins using phpQuery library - Added support for shortcode to disable tracking on specific pages (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.5.7 = - Fix for error when saving settings = 2.5.6 = - Added support for PenCi Soledad AMP plugin - Fix for php processing on multisite installations - Fix for client-side referrer check - Fix for header and footer code on AMP pages using AMP plugin - Few minor bug fixes, cosmetic changes and code improvements = 2.5.5 = - Added support for client list (black/whitelist operating systems, browsers, device names) - Fix for replaced tags with default value {name:default-value} - Few minor bug fixes, cosmetic changes and code improvements = 2.5.4 = - Minor bug fix regarding update checks (Pro only) = 2.5.3 = - Added support for warning when Ad Inserter is disabled by AMPforWP Plugin Manager - Added support for block shortcode attributes - Added support for post ID list to include all posts or static pages - Added option for maximum number of paragraphs - Added support to check for update server accessibility (Pro only) - Added ids to ad blocking popup message and overlay elements - Few minor bug fixes, cosmetic changes and code improvements = 2.5.2 = - Added options to define paragraph counting inside container elements - Added support to pin block list (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.5.1 = - Few minor bug fixes (Pro only) = 2.5.0 = - Improved user interface - Simplified user interface for individual post/page exceptions - Added support for virtual ads.txt file - Added support for frequency capping (Pro only) - Added support for click fraud detection (Pro only) - Changed url prefix for public reports to avoid possible url collisions (Pro only) - Fix for shortcode processing when blocks were used before init hook - Many minor bug fixes, cosmetic changes and code improvements = 2.4.23 = - Added support to define custom fields with shortocdes - Added support to delay showing ads for specified number of pageviews (Pro only) - Added support to remember closed ad for specified time period (Pro only) - Added support to automatically close ad after specified time period (Pro only) - Fix for false positive ad blocking detection (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.4.22 = - Fix for remote code execution vulnerability - credit to Wordfence = 2.4.21 = - Fix for possible error Class not found (Pro only) = 2.4.20 = - Fix for path traversal vulnerability - credit to Wilfried Becard of Synacktiv (https://synacktiv.com) - Fix for block rearrangement issues - Few minor bug fixes, cosmetic changes and code improvements = 2.4.19 = - Added support for taxonomy for Yoast primary category - Layout changes to accomodate longer translated texts - Fix for escape character not saved in header, footer and ad blocking message code - Few minor bug fixes, cosmetic changes and code improvements = 2.4.18 = - Added support for full width responsive AdSense code option - Few minor bug fixes, cosmetic changes and code improvements = 2.4.17 = - Few minor bug fixes, cosmetic changes and code improvements = 2.4.16 = - Fix for compatibility with AMP for WP - Accelerated Mobile Pages for WordPress - Few minor bug fixes = 2.4.15 = - Fix for improved compatibility with other plugins - Few minor bug fixes and cosmetic changes = 2.4.14 = - Fix for ROTATE shortcodes with option name identical to block name - Fix for possible conflict with output buffering in other plugins - Few minor bug fixes, cosmetic changes and code improvements = 2.4.13 = - Added shortcode to disable ad blocking detection code - Added options to disable ad blocking actions for administrators or logged in users - Added option to change PDF report footer (Pro only) - Added support for public ad impression and click reports (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.4.12 = - Added ads.txt editor - Added option to prevent disabling caching for logged in administrators - Improved compatibility with PHP 7.2 - Few minor bug fixes, cosmetic changes and code improvements = 2.4.11 = - Fix for saving code with slashes - Fix for rotation editor code import - Few minor bug fixes, cosmetic changes and code improvements = 2.4.10 = - Added support for counter shortcodes - Added support for code separator selection for code preview - Added support for group rotations - Added support for CHECK separator (Pro only) - Added links to test pages for check for available positions - Few minor bug fixes, cosmetic changes and code improvements = 2.4.9 = - Added support for HEAD separator - Added support for DoubleClick for Publishers (DFP) ads - Added support to generate statistics reports in PDF format (Pro only) - Fix for ad label when using AMP separator - Fix for AdSense code fixed by viewport - Fix for error when checking for available positions - Few minor bug fixes, cosmetic changes and code improvements = 2.4.8 = - Added support for automatic insertion before/after image - Added support for theme checker for available positions for automatic insertion = 2.4.7 = - Fix for lazy loading in Ajax calls (Pro only) - Fix for country list editor (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.4.6 = - Improved ad blocking detection (detects Firefox content blocking) - Added support for wildcards for referrers (domains) - Added debugging notice when JavaScript errors are detected - Added support to load blocks in iframes (Pro only) - Added geolocation support for country subdivisions and cities (Pro only) - Added option to hide license key on client websites (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.4.5 = - Added support for AMP WP - Google AMP For WordPress - Added support to individually disable insertions for debugging purposes - Improved HTML element selection tool - Fix for Call to undefined function wp_get_current_user() - Few minor bug fixes, cosmetic changes and code improvements = 2.4.4 = - Fix for Fatal error: Call to undefined function mb_strtoupper() = 2.4.3 = - Added support for insertion before/after every N paragraphs (%N) - Added support for i18n - Fix for insertion on admin pages - Fix for client-side cookie check - Fix for loaded styles from other plugins/themes on the settings page - Fix for client-side insertion near HTML elements using :eq selector - Fix for deactivation feedback form not closing - Few minor bug fixes, cosmetic changes and code improvements = 2.4.2 = - Added support for visual HTML element selection - Fix for client-side insertion inside HTML elements - Few minor bug fixes, cosmetic changes and code improvements = 2.4.1 = - Added option to insert into HTML element (prepend, append, replace content) - Added option to remove HTML element - Added option to not show deactivation feedback form - Added support for negative relative positions for paragraph counting - Few minor bug fixes, cosmetic changes and code improvements = 2.4.0 = - Improved code for client-side insertion - Added support for usage tracking - Fix for compatibility with older PHP versions (below 5.4) - Few minor bug fixes, cosmetic changes and code improvements = 2.3.21 = - Added option to force showing admin toolbar when viewing site - Added additional debugging info for blocks in Ajax requests - Fix for viewport visibility detection - Fix for rotation with non-ASCII characters - Few minor bug fixes, cosmetic changes and code improvements = 2.3.20 = - Improved loading of settings - Fix for content processing in some ajax calls - Few minor bug fixes, cosmetic changes and code improvements = 2.3.19 = - Improved code for client-side insertion - Fix for rotation with shortcodes - Few minor bug fixes, cosmetic changes and code improvements = 2.3.18 = - Added support to schedule insertion for N days after publishing - Added support to schedule insertion only for posts published inside/outside time period (Pro only) - Added support to prevent activation of free Ad Inserter while Pro is active - Added url parameter to show block code - Improved Header/Footer code debugging - Few minor bug fixes, cosmetic changes and code improvements = 2.3.17 = - Added shortcode for ad blocking detection action - Few minor bug fixes, cosmetic changes and code improvements = 2.3.16 = - Added option to insert block only when WP loop is currently active - Added support for Better AMP plugin - Code generator for placeholders on https sites now generates https urls - Optimized loading of plugin settings - Few minor bug fixes, cosmetic changes and code improvements = 2.3.15 = - Fix for insertion on AMP pages = 2.3.14 = - Simplified AdSense integration - Added setting to define maximum number of blocks (ads) per page - Optimized the_content filter processing - Added setting for lazy loading offset (Pro only) - Fix for url parameter list when using client-side dynamic blocks - Few minor bug fixes, cosmetic changes and code improvements = 2.3.13 = - Added support for lazy loading (Pro only) - Fix for unwanted insertions with some paragraph settings - Few minor bug fixes, cosmetic changes and code improvements = 2.3.12 = - Fix for urlencode error - Few other minor bug fixes = 2.3.11 = - Added support for W3TC/client-side check for cookies (in url parameter list) to support showing ads based on visitor's cookie consent - Added support for W3TC/client-side check for referers - Improved paragraph processing - Few minor bug fixes, cosmetic changes and code improvements = 2.3.10 = - Added support for timed rotation - Added support for client-side insertion of dynamic blocks - Improved word count function - Few minor bug fixes, cosmetic changes and code improvements = 2.3.9 = - Added option to easily disable insertion of individual code block - Changes for compatibility with PHP 7.2 - Added non-interaction parameter to external tracking (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.3.8 = - Added support for rotation option shares - Added support for sticky ad settings and animations (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.3.7 = - Added support for ad labels - Blocked search indexing while debugging - Close button setting moved to tab Display (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.3.6 = - Added widget for debugging tools - Fix for AdSense ad overlays not displayed with some themes - Few minor bug fixes, cosmetic changes and code improvements = 2.3.5 = - Added display of header and footer code in Label blocks debugging function - Added AdSense ad overlays in Label blocks debugging function (experimental) - Fixed bug for removed square brackets in HTML element selectors - Fixed preview of AdSense ad units - Few minor bug fixes = 2.3.4 = - Added support for author:author-username items in taxonomy list - Fixed errors when downgrading from Pro - Few minor bug fixes = 2.3.3 = - Added list editors - Added Label blocks debugging function for AdSense Auto ads = 2.3.2 = - Added AdSense code generator for ad sizes using CSS media queries - Fix for slow updates caused by changed user agent (Pro only, credits Olivier Langlois) - Fix for client-side insertion of non-English characters before/after HTML element = 2.3.1 = - Added support for server-side insertion before/after any HTML element - Few minor bug fixes = 2.3.0 = - Added support for client-side insertion before/after any HTML element - Inplemented AdSense integration - Added option to define close button position - Fix for code generator import and code preview error with non ASCII characters - Fix for post/page exceptions and page types not processed in the header - Fix for close button in preview window - Fix for errors when rearranging blocks - Fix for errors when importing code - Few minor bug fixes, cosmetic changes and code improvements = 2.2.16 = - Fix for error when saving settings on multisite installation = 2.2.15 = - Fix for responsive AMP ads using center alignment = 2.2.14 = - Added code generator for placeholders - Added option to disable caching (works with WP Super Cache, W3 Total Cache and WP Rocket) - Added options to configure classes for wrapping div - Added support for external tracking via Google Analytics and Piwik (Pro only) - Added support for MaxMind geolocation databases (Pro only) - Added option for close button on sticky ads (Pro only) - Fix for no paragraph counting inside nested elements - Few minor bug fixes, cosmetic changes and code improvements = 2.2.13 = - Added option to disable inline alignment styles for code blocks (using alignment classes) - Fix for custom CSS codes with single quotation marks = 2.2.12 = - Fix for code block styles when block class name was not set = 2.2.11 = - Code block styles moved to classes - Code block list moved to the sidebar - Added preview buttons in code block list - Fix for ad blocking detection when using https (Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.2.10 = - Fix for rotation editor code import/export - Fix for errors when using old |rotate| separator - Few minor bug fixes, cosmetic changes and code improvements = 2.2.9 = - Output buffering is now disabled by default (for position Above header you need to enable it) - Fix for min. paragraph number not processed = 2.2.8 = - Added position for automatic insertion Above header (after `` tag) - Added rotation code editor - Added support to name rotation options - Added code generator for banners - Added code generator for AdSense - Added support to rearrange code blocks - Added support to copy any block settings - Added support for clipboard to copy/paste block settings - Added option to select ad blocking detection mode (Pro only) - Delayed insertion on posts now available for all insertion positions - Few minor bug fixes, cosmetic changes and code improvements = 2.2.7 = - Fix for duplicate amp-custom tag on AMP pages = 2.2.6 = - Fix for posts filter counter not counting - Added list with short overview of all code blocks - Added support for word count on blog pages - Added support for client code preview (no need to save it for preview) - Improved compatibility on AMP pages - Few minor bug fixes, cosmetic changes and code improvements = 2.2.5 = - Fix for issue with Ajax requests = 2.2.4 = - Added support to insert raw HTTP response header lines - Added support to check for individual exceptions for shortcodes - Added support to trigger ad blocking detection action only on individual pages - Added support for automatic insertion position Footer - Added support for custom hooks - Url parameter list now checks url parameters ($_GET) and cookies ($_COOKIE) - Fix for |count| separator not processed = 2.2.3 = - Added support to insert custom fields via shortcode [adinserter custom-field='CUSTOM_FIELD_NAME'] - Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items - Added support for post-type:POST_TYPE taxonomy list items - Added support for JavaScript based sticky widgets - Added support for ad blocking statistics (Pro only) - Added support for WP AMP and WP AMP Ninja plugins - Post/Page Word Count moved to Misc section (now works also on widgets) - Few minor bug fixes, cosmetic changes and code improvements = 2.2.2 = - Fix for mobile admin layout - Few other minor bug fixes = 2.2.1 = - Fix for header/footer scripts on AMP pages = 2.2.0 = - Added support for ad blocking detection (experimental) - Added support for [ADINSERTER AMP] shortcode to separate code for AMP pages - Added support for [ADINSERTER ROTATE] and [ADINSERTER COUNT] shortcodes - Added syntax highlighting for shortcodes and separators - Added option to define minimum number of words in paragraphs above - Added support for %N filter item to filter every N-th insertion - Added filter support when inserting for all paragraphs - Added style `clear: both;` to Default, Left, Right and Center alignments - Bug fix for errors when loading tracking charts (Pro only) - Many minor bug fixes, cosmetic changes and code improvements = 2.1.14 = - Fix for error when using older PHP versions (prior to 5.5) = 2.1.13 = - Fix for Fatal error: Can't use method return value in write context = 2.1.12 = - Added option to define tags inside which paragraphs are not counted - Added max insertions check when inserting for all paragraphs - Added support for inverted filter - Increased nonce lifespan to 48 hours when using tracking (Pro only) - Fixed wrong urls in debug menu when behind proxy - Few other bug fixes, cosmetic changes and code improvements = 2.1.11 = - Improved support for sticky widgets (works with most themes) - Added support for ad counting (|count| separator) - Added support to black/white-list arbitrary taxonomies (taxonomy, term or taxonomy:term) - Added support for automatic insertion before, between and after comments - Added processing of shortcodes in the header and footer code - Debugging function Show positions shows also page type - Fixed page type detection when Post page was set to static page and it was not homepage - Few minor bug fixes, cosmetic changes and code improvements = 2.1.10 = - Fix for shifted sidebars in some themes = 2.1.9 = - Added support for sticky widgets - Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img) - Impression and click tracking (beta, Pro only) - Few minor bug fixes, cosmetic changes and code improvements = 2.1.8 = - Fixed error when using server-side device detection = 2.1.7 = - Fixed error when using PHP 5.4 or earlier = 2.1.6 = - Added support for insertion before/after multiple paragraphs - Added initial support for impression and click tracking (Pro only) - Few bug fixes and cosmetic changes = 2.1.5 = - Added support to avoid insertion inside `
` and `
  • ` elements (image captions, lists) - Added support for exceptions for custom post types - Few minor bug fixes and code improvements = 2.1.4 = - Paragraph counting restored to standard functions - Added option to select paragraph counting functions with multibyte support (unicode characters) - Fixed bug for wrong paragraph counting in posts with blockquote sections in some cases - Fixed bug for wrong measuring of plugin processing time in some cases - Fixed bug for "Empty delimiter" warning = 2.1.3 = - Added support for counting paragraphs with multibyte (unicode) characters - Fixed bug for class name not saved - Few minor bug fixes and cosmetic changes = 2.1.2 = - Fixed bug for disabled settings page on multisite blogs = 2.1.1 = - Changes for compatibility with PHP 7.1 - Automatic rename of old pro plugin slug (Pro only) - Added support for additional Pro features (Pro only) - Few bug fixes and cosmetic changes = 2.1.0 = - Added support to insert ads in Ajax requests (e.g. in infinite scroll) - Added support to not include block classes when class name is empty - Added sticky positions (Pro only) - Bug fix for minimum user role not taken into account for exceptions list - Bug fix for IP database update cron event (Pro only) index.html000064400000000054146731142050006543 0ustar00strings.php000064400000051500146731142050006752 0ustar00Blocked because of Ad Blocker

    \n

    It seems that you are using some ad blocking software which is preventing the page from fully loading. Please whitelist this website or disable ad blocking software.

    ", 'ad-inserter')); define ('DEFAULT_VIEWPORT_NAME_1', _x('Desktop', 'Viewport name', 'ad-inserter')); define ('DEFAULT_VIEWPORT_NAME_2', _x('Tablet', 'Viewport name', 'ad-inserter')); define ('DEFAULT_VIEWPORT_NAME_3', _x('Phone', 'Viewport name', 'ad-inserter')); define ('DEFAULT_COUNTRY_GROUP_NAME', _x('Group', 'ad-inserter')); define ('AI_TEXT_INSERT', __('Insert', 'ad-inserter')); // translators: Menu items define ('AI_TEXT_DISABLED', __('Disabled', 'ad-inserter')); define ('AI_TEXT_BEFORE_POST', __('Before post', 'ad-inserter')); define ('AI_TEXT_AFTER_POST', __('After post', 'ad-inserter')); define ('AI_TEXT_BEFORE_CONTENT', __('Before content', 'ad-inserter')); define ('AI_TEXT_AFTER_CONTENT', __('After content', 'ad-inserter')); define ('AI_TEXT_BEFORE_PARAGRAPH', __('Before paragraph', 'ad-inserter')); define ('AI_TEXT_AFTER_PARAGRAPH', __('After paragraph', 'ad-inserter')); define ('AI_TEXT_BEFORE_EXCERPT', __('Before excerpt', 'ad-inserter')); define ('AI_TEXT_AFTER_EXCERPT', __('After excerpt', 'ad-inserter')); define ('AI_TEXT_BETWEEN_POSTS', __('Between posts', 'ad-inserter')); define ('AI_TEXT_BEFORE_COMMENTS', __('Before comments', 'ad-inserter')); define ('AI_TEXT_BETWEEN_COMMENTS', __('Between comments', 'ad-inserter')); define ('AI_TEXT_AFTER_COMMENTS', __('After comments', 'ad-inserter')); define ('AI_TEXT_ABOVE_HEADER', __('Above header', 'ad-inserter')); define ('AI_TEXT_FOOTER', __('Footer', 'ad-inserter')); define ('AI_TEXT_BEFORE_HTML_ELEMENT', __('Before HTML element', 'ad-inserter')); define ('AI_TEXT_AFTER_HTML_ELEMENT', __('After HTML element', 'ad-inserter')); define ('AI_TEXT_INSIDE_HTML_ELEMENT', __('Inside HTML element', 'ad-inserter')); define ('AI_TEXT_BEFORE_IMAGE', __('Before image', 'ad-inserter')); define ('AI_TEXT_AFTER_IMAGE', __('After image', 'ad-inserter')); define ('AI_TEXT_INLINE', __('Inline', 'ad-inserter')); define ('AI_TEXT_FILE', __('File', 'ad-inserter')); define('AI_TEXT_DO_NOT_INSERT', __('do not insert', 'ad-inserter')); define('AI_TEXT_TRY_TO_SHIFT_POSITION', __('try to shift position', 'ad-inserter')); define ('AI_TEXT_ABOVE', __('above', 'ad-inserter')); define ('AI_TEXT_BELOW', __('below', 'ad-inserter')); define ('AI_TEXT_ABOVE_AND_THEN_BELOW', __('above and then below', 'ad-inserter')); define ('AI_TEXT_BELOW_AND_THEN_ABOVE', __('below and then above', 'ad-inserter')); define ('AI_TEXT_DIRECTION_FROM_TOP', __('from top', 'ad-inserter')); define ('AI_TEXT_DIRECTION_FROM_BOTTOM',__('from bottom', 'ad-inserter')); define ('AI_TEXT_CONTAIN', _x('contain', 'paragraphs', 'ad-inserter')); define ('AI_TEXT_DO_NOT_CONTAIN', _x('do not contain', 'paragraphs', 'ad-inserter')); define ('AI_TEXT_DO_NOT_COUNT', __('Do not count', 'ad-inserter')); define ('AI_TEXT_COUNT_ONLY', __('Count only', 'ad-inserter')); define('AI_TEXT_DISPLAY_ALL_USERS', _x('all users', 'insert for', 'ad-inserter')); define('AI_TEXT_DISPLAY_LOGGED_IN_USERS', _x('logged in users', 'insert for', 'ad-inserter')); define('AI_TEXT_DISPLAY_NOT_LOGGED_IN_USERS', _x('not logged in users', 'insert for', 'ad-inserter')); define('AI_TEXT_DISPLAY_ADMINISTRATORS', _x('administrators', 'insert for', 'ad-inserter')); define('AI_TEXT_BLACK_LIST', __('Black list', 'ad-inserter')); define('AI_TEXT_WHITE_LIST', __('White list', 'ad-inserter')); define('AI_TEXT_DEFAULT', _x('Default', 'alignment', 'ad-inserter')); define('AI_TEXT_LEFT', _x('Left', 'alignment', 'ad-inserter')); define('AI_TEXT_RIGHT', _x('Right', 'alignment', 'ad-inserter')); define('AI_TEXT_CENTER', _x('Center', 'alignment', 'ad-inserter')); define('AI_TEXT_POSITION_CENTER', _x('Center', 'position', 'ad-inserter')); define('AI_TEXT_FLOAT_LEFT', _x('Float left', 'alignment', 'ad-inserter')); define('AI_TEXT_FLOAT_RIGHT', _x('Float right', 'alignment', 'ad-inserter')); define('AI_TEXT_NO_WRAPPING', _x('No wrapping', 'alignment', 'ad-inserter')); define('AI_TEXT_CUSTOM_CSS', __('Custom CSS', 'ad-inserter')); define('AI_TEXT_STICKY_LEFT', __('Sticky left', 'ad-inserter')); define('AI_TEXT_STICKY_RIGHT', __('Sticky right', 'ad-inserter')); define('AI_TEXT_STICKY_TOP', __('Sticky top', 'ad-inserter')); define('AI_TEXT_STICKY_BOTTOM', __('Sticky bottom', 'ad-inserter')); define('AI_TEXT_STICKY', _x('Sticky', 'alignment', 'ad-inserter')); define ('AI_TEXT_AUTO_COUNTER', _x('auto counter', 'using', 'ad-inserter')); define ('AI_TEXT_PHP_FUNCTION_CALLS_COUNTER', _x('PHP function calls counter', 'using', 'ad-inserter')); define ('AI_TEXT_CONTENT_PROCESSING_COUNTER', _x('content processing counter', 'using', 'ad-inserter')); define ('AI_TEXT_EXCERPT_PROCESSING_COUNTER', _x('excerpt processing counter', 'using', 'ad-inserter')); define ('AI_TEXT_BEFORE_POST_PROCESSING_COUNTER', _x('before post processing counter', 'using', 'ad-inserter')); define ('AI_TEXT_AFTER_POST_PROCESSING_COUNTER', _x('after post processing counter', 'using', 'ad-inserter')); define ('AI_TEXT_WIDGET_DRAWING_COUNTER', _x('widget drawing counter', 'using', 'ad-inserter')); define ('AI_TEXT_SUBPAGES_COUNTER', _x('subpages counter', 'using', 'ad-inserter')); define ('AI_TEXT_POSTS_COUNTER', _x('posts counter', 'using', 'ad-inserter')); define ('AI_TEXT_PARAGRAPHS_COUNTER', _x('paragraphs counter', 'using', 'ad-inserter')); define ('AI_TEXT_COMMENTS_COUNTER', _x('comments counter', 'using', 'ad-inserter')); define ('AI_TEXT_IMAGES_COUNTER', _x('images counter', 'using', 'ad-inserter')); define ('AI_TEXT_POSTS_NO_INDIVIDUALL_EXCEPTIONS', ''); define ('AI_TEXT_POSTS_INDIVIDUALLY_DISABLED', _x('Individually disabled', 'posts', 'ad-inserter')); define ('AI_TEXT_POSTS_INDIVIDUALLY_ENABLED', _x('Individually enabled', 'posts', 'ad-inserter')); define ('AI_TEXT_PAGES_NO_INDIVIDUAL_EXCEPTIONS', ''); define ('AI_TEXT_PAGES_INDIVIDUALLY_DISABLED', _x('Individually disabled', 'static pages', 'ad-inserter')); define ('AI_TEXT_PAGES_INDIVIDUALLY_ENABLED', _x('Individually enabled', 'static pages', 'ad-inserter')); define ('AI_TEXT_SERVER_SIDE', __('Server-side', 'ad-inserter')); define ('AI_TEXT_CLIENT_SIDE', _x('Client-side', 'Insertion', 'ad-inserter')); define ('AI_TEXT_CLIENT_SIDE_SHOW', _x('Client-side show', 'Dynamic blocks', 'ad-inserter')); define ('AI_TEXT_CLIENT_SIDE_INSERT', _x('Client-side insert', 'Dynamic blocks', 'ad-inserter')); define ('AI_TEXT_SERVER_SIDE_W3TC', _x('Server-side using W3 Total Cache', 'Insertion', 'ad-inserter')); //define ('AI_TEXT_CLIENT_SIDE_DOM_READY', _x('Client-side when DOM ready', 'Insertion', 'ad-inserter')); define ('AI_TEXT_PREPEND_CONTENT', __('Prepend content', 'ad-inserter')); define ('AI_TEXT_APPEND_CONTENT', __('Append content', 'ad-inserter')); define ('AI_TEXT_REPLACE_CONTENT', __('Replace content', 'ad-inserter')); define ('AI_TEXT_REPLACE_ELEMENT', __('Replace element', 'ad-inserter')); define ('AI_TEXT_DESKTOP_DEVICES', __('desktop devices', 'ad-inserter')); define ('AI_TEXT_MOBILE_DEVICES', __('mobile devices', 'ad-inserter')); define ('AI_TEXT_TABLET_DEVICES', __('tablet devices', 'ad-inserter')); define ('AI_TEXT_PHONE_DEVICES', __('phone devices', 'ad-inserter')); define ('AI_TEXT_DESKTOP_TABLET_DEVICES', __('desktop and tablet devices', 'ad-inserter')); define ('AI_TEXT_DESKTOP_PHONE_DEVICES', __('desktop and phone devices', 'ad-inserter')); define ('AI_TEXT_ALL_DEVICES', __('all devices', 'ad-inserter')); define ('AI_TEXT_STICK_TO_THE_LEFT', __('Stick to the left', 'ad-inserter')); define ('AI_TEXT_STICK_TO_THE_CONTENT_LEFT', __('Stick to the content left', 'ad-inserter')); define ('AI_TEXT_STICK_TO_THE_CONTENT_RIGHT', __('Stick to the content right', 'ad-inserter')); define ('AI_TEXT_STICK_TO_THE_RIGHT', __('Stick to the right', 'ad-inserter')); define ('AI_TEXT_STICK_TO_THE_TOP', __('Stick to the top', 'ad-inserter')); define ('AI_TEXT_SCROLL_WITH_THE_CONTENT', __('Scroll with the content', 'ad-inserter')); define ('AI_TEXT_STICK_TO_THE_BOTTOM', __('Stick to the bottom', 'ad-inserter')); define ('AI_TEXT_FADE', __('Fade', 'ad-inserter')); define ('AI_TEXT_SLIDE', __('Slide', 'ad-inserter')); define ('AI_TEXT_SLIDE_FADE', __('Slide and Fade', 'ad-inserter')); define ('AI_TEXT_FLIP', __('Flip', 'ad-inserter')); define ('AI_TEXT_ZOOM_IN', __('Zoom In', 'ad-inserter')); define ('AI_TEXT_ZOOM_OUT', __('Zoom Out', 'ad-inserter')); define ('AI_TEXT_TURN', __('Turn', 'ad-inserter')); define ('AI_TEXT_PAGE_LOADED', __('Page loaded', 'ad-inserter')); define ('AI_TEXT_PAGE_SCROLLED_PC', __('Page scrolled (%)', 'ad-inserter')); define ('AI_TEXT_PAGE_SCROLLED_PX', __('Page scrolled (px)', 'ad-inserter')); define ('AI_TEXT_ELEMENT_SCROLLS_IN', __('Element scrolls in', 'ad-inserter')); define ('AI_TEXT_ELEMENT_SCROLLS_OUT', __('Element scrolls out', 'ad-inserter')); define('AI_TEXT_DEFAULT_BKG_REPEAT', _x('Default', 'image repeat', 'ad-inserter')); define('AI_TEXT_NO', __('No', 'ad-inserter')); define('AI_TEXT_YES', __('Yes', 'ad-inserter')); define('AI_TEXT_HORIZONTALY', __('Horizontally', 'ad-inserter')); define('AI_TEXT_VERTICALLY', __('Vertically', 'ad-inserter')); define('AI_TEXT_SPACE', __('Space', 'ad-inserter')); define('AI_TEXT_ROUND', __('Round', 'ad-inserter')); define('AI_TEXT_DEFAULT_BKG_SIZE', _x('Default', 'image size', 'ad-inserter')); define('AI_TEXT_COVER', __('Cover', 'ad-inserter')); define('AI_TEXT_FIT_BKG_SIZE', _x('Fit', 'image size', 'ad-inserter')); define('AI_TEXT_FILL', __('Fill', 'ad-inserter')); define ('AI_TEXT_INSERT_IMMEDIATELY', __('Insert immediately', 'ad-inserter')); define ('AI_TEXT_DELAY_INSERTION', __('Delay insertion', 'ad-inserter')); define ('AI_TEXT_INSERT_BETWEEN_DATES', __('Insert between dates', 'ad-inserter')); define ('AI_TEXT_INSERT_OUTSIDE_DATES', __('Insert outside dates', 'ad-inserter')); define ('AI_TEXT_INSERT_ONLY', __('Insert only', 'ad-inserter')); define ('AI_TEXT_INSERT_PUBLISHED_BETWEEN_DATES', __('Insert for posts published between dates', 'ad-inserter')); define ('AI_TEXT_INSERT_PUBLISHED_OUTSIDE_DATES', __('Insert for posts published outside dates', 'ad-inserter')); define ('AI_TEXT_FUNCTIONS_STANDARD', _x('Standard', 'functions', 'ad-inserter')); define ('AI_TEXT_STANDARD', _x('Standard', 'detection', 'ad-inserter')); define ('AI_TEXT_MULTIBYTE', _x('Multibyte', 'functions', 'ad-inserter')); define ('AI_TEXT_NONE', _x('None', 'action', 'ad-inserter')); define ('AI_TEXT_BUTTON_NONE', _x('None', 'button', 'ad-inserter')); define ('AI_TEXT_POPUP_MESSAGE', __('Popup Message', 'ad-inserter')); define ('AI_TEXT_REDIRECTION', __('Redirection', 'ad-inserter')); define ('AI_TEXT_DO_NOTHING', __('Do nothing', 'ad-inserter')); define ('AI_TEXT_REPLACE', __('Replace', 'ad-inserter')); define ('AI_TEXT_SHOW', _x('Show', 'Action when ad blocking detected', 'ad-inserter')); define ('AI_TEXT_HIDE', _x('Hide', 'Action when ad blocking detected', 'ad-inserter')); define ('AI_TEXT_INTERNAL', _x('Internal', 'tracking', 'ad-inserter')); define ('AI_TEXT_ADVANCED', _x('Advanced', 'detection', 'ad-inserter')); define ('AI_TEXT_ENABLED', __('Enabled', 'ad-inserter')); define ('AI_TEXT_AUTO', _x('Auto', 'Manual loading', 'ad-inserter')); define ('AI_TEXT_ALWAYS', _x('Always', 'Manual loading', 'ad-inserter')); define ('AI_TEXT_TOP_RIGHT', __('Top right', 'ad-inserter')); define ('AI_TEXT_TOP_LEFT', __('Top left', 'ad-inserter')); define ('AI_TEXT_BOTTOM_RIGHT', __('Bottom right', 'ad-inserter')); define ('AI_TEXT_BOTTOM_LEFT', __('Bottom left', 'ad-inserter')); define ('AI_TEXT_ADSENSE_STANDARD', _x('Standard', 'AdSense Ad Type', 'ad-inserter')); define ('AI_TEXT_LINK', _x('Link', 'AdSense Ad Type', 'ad-inserter')); define ('AI_TEXT_IN_ARTICLE', _x('In-article', 'AdSense Ad Type', 'ad-inserter')); define ('AI_TEXT_IN_FEED', _x('In-feed', 'AdSense Ad Type', 'ad-inserter')); define ('AI_TEXT_MATCHED_CONTENT', _x('Matched content', 'AdSense Ad Type', 'ad-inserter')); define ('AI_TEXT_ADSENSE_AUTO', _x('Auto Ads', 'AdSense Ad Type', 'ad-inserter')); define ('AI_TEXT_ADSENSE_AMP_ONLY', _x('AMP Only', 'AdSense Ad Type', 'ad-inserter')); define ('AI_TEXT_ADSENSE_DISABLED', _x('Disabled', 'AMP ad', 'ad-inserter')); define ('AI_TEXT_ABOVE_THE_FOLD', __('Above the fold', 'ad-inserter')); define ('AI_TEXT_BELOW_THE_FOLD', __('Below the fold', 'ad-inserter')); define ('AI_TEXT_STICKY_AMP', _x('Sticky', 'AMP ad', 'ad-inserter')); define ('AI_TEXT_FIXED', _x('Fixed', 'size', 'ad-inserter')); define ('AI_TEXT_RESPONSIVE', _x('Responsive', 'size', 'ad-inserter')); define ('AI_TEXT_FIXED_BY_VIEWPORT', _x('Fixed by viewport', 'size', 'ad-inserter')); define ('AI_TEXT_SETTINGS_SUBMENU', __('Settings submenu', 'ad-inserter')); define ('AI_TEXT_TOP_MENU', __('Top menu', 'ad-inserter')); // Translators: %s: Ad Inserter Pro define ('DEFAULT_REPORT_HEADER_TITLE', sprintf (__('%s Report', 'ad-inserter'), 'Ad Inserter Pro')); define ('DEFAULT_REPORT_HEADER_DESCRIPTION', __('Impressions and clicks', 'ad-inserter')); define ('DEFAULT_REPORT_FOOTER', AD_INSERTER_NAME . ' '. __('Advanced WordPress Ad Management Plugin', 'ad-inserter') . ' https://adinserter.pro/'); global $ai_admin_translations, $ai_front_translations, $wp_version; $ai_admin_translations = array ( 'hide' => _x('Hide', 'Button', 'ad-inserter'), 'show' => _x('Show', 'Button', 'ad-inserter'), 'insertion_expired' => __('Insertion expired', 'ad-inserter'), 'duration' => __('Duration', 'ad-inserter'), 'invalid_end_date' => __('Invalid end date - must be after start date', 'ad-inserter'), 'invalid_start_date' => __('Invalid start date - only data for 1 year back is available', 'ad-inserter'), 'invalid_date_range' => __('Invalid date range - only data for 1 year can be displayed', 'ad-inserter'), 'days_0' => _n('day', 'days', 0, 'ad-inserter'), 'days_1' => _n('day', 'days', 1, 'ad-inserter'), 'days_2' => _n('day', 'days', 2, 'ad-inserter'), 'days_3' => _n('day', 'days', 3, 'ad-inserter'), 'days_4' => _n('day', 'days', 4, 'ad-inserter'), 'days_5' => _n('day', 'days', 5, 'ad-inserter'), 'warning' => __('Warning', 'ad-inserter'), 'delete' => __('Delete', 'ad-inserter'), 'delete_all' => __('Delete all', 'ad-inserter'), 'switch' => __('Switch', 'ad-inserter'), 'cancel' => __('Cancel', 'ad-inserter'), 'ok' => __('OK', 'ad-inserter'), 'delete_all_statistics' => __('Delete all statistics data?', 'ad-inserter'), 'rotation_active' => __('Rotation code editor active. Click on the rotation button to generate code.', 'ad-inserter'), // translators: %s: dates 'delete_statistics_between' => sprintf (__('Delete statistics data between %s and %s?', 'ad-inserter'), '{start_date}', '{end_date}'), 'delete_website' => __('Delete website?', 'ad-inserter'), 'cancel_rearrangement' => __('Cancel block order rearrangement', 'ad-inserter'), 'rearrange_block_order' => __('Rearrange block order', 'ad-inserter'), 'downloading' => __('downloading...', 'ad-inserter'), 'download_error' => __('download error', 'ad-inserter'), 'update_error' => __('update error', 'ad-inserter'), 'updating' => __('Updating...', 'ad-inserter'), 'loading' => __('Loading...', 'ad-inserter'), 'error' => __('ERROR', 'ad-inserter'), 'error_reloading_settings' => __('Error reloading settings', 'ad-inserter'), 'google_adsense_homepage' => __('Google AdSense Homepage', 'ad-inserter'), 'search' => _x('Search...', 'Search field placeholder', 'ad-inserter'), 'filter' => _x('Filter...', 'Search field placeholder', 'ad-inserter'), 'filter_title' => __('Use filter to limit names in the list', 'ad-inserter'), 'button_filter' => _x('Filter', 'Button', 'ad-inserter'), 'position_not_checked' => __('Position not checked yet', 'ad-inserter'), 'position_not_available' => __('Position not available', 'ad-inserter'), 'position_might_not_available'=> __('Theme check | Selected position for automatic insertion might not be not available on this page type', 'ad-inserter'), 'position_available' => __('Position available', 'ad-inserter'), 'select_header_image' => __('Select or upload header image', 'ad-inserter'), 'select_banner_image' => __('Select or upload banner image', 'ad-inserter'), 'select_background_image' => __('Select or upload background image', 'ad-inserter'), 'use_this_image' => __('Use this image', 'ad-inserter'), 'switch_to_physical_ads_txt' => __('Switching to physical ads.txt file will delete virtual ads.txt file.', 'ad-inserter'), 'day_mo' => _x('MO', 'Monday', 'ad-inserter'), 'day_tu' => _x('TU', 'Tuesday', 'ad-inserter'), 'day_we' => _x('WE', 'Wednesday', 'ad-inserter'), 'day_th' => _x('TH', 'Thursday', 'ad-inserter'), 'day_fr' => _x('FR', 'Friday', 'ad-inserter'), 'day_sa' => _x('SA', 'Saturday', 'ad-inserter'), 'day_su' => _x('SU', 'Sunday', 'ad-inserter'), ); $ai_front_translations = array ( // 'wp_ai' => $wp_version . '+' . AD_INSERTER_VERSION, // Debugging 'insertion_before' => __('BEFORE', 'ad-inserter'), 'insertion_after' => __('AFTER', 'ad-inserter'), 'insertion_prepend' => __('PREPEND CONTENT', 'ad-inserter'), 'insertion_append' => __('APPEND CONTENT', 'ad-inserter'), 'insertion_replace_content' => __('REPLACE CONTENT', 'ad-inserter'), 'insertion_replace_element' => __('REPLACE ELEMENT', 'ad-inserter'), 'visible' => _x('VISIBLE', 'Block', 'ad-inserter'), 'hidden' => _x('HIDDEN', 'Block', 'ad-inserter'), 'fallback' => _x('FALLBACK', 'alternative block', 'ad-inserter'), 'automatically_placed' => __('Automatically placed by AdSense Auto ads code', 'ad-inserter'), // Element selection 'cancel' => __('Cancel', 'ad-inserter'), 'use' => __('Use', 'ad-inserter'), 'add' => __('Add', 'ad-inserter'), 'parent' => _x('Parent', 'Element', 'ad-inserter'), 'cancel_element_selection' => __('Cancel element selection', 'ad-inserter'), 'select_parent_element' => __('Select parent element', 'ad-inserter'), 'css_selector' => __('CSS selector', 'ad-inserter'), 'use_current_selector' => __('Use current selector', 'ad-inserter'), 'element' => __('ELEMENT', 'ad-inserter'), 'path' => __('PATH', 'ad-inserter'), 'selector' => __('SELECTOR', 'ad-inserter'), ); ad-inserter.php000064400002043535146731142050007511 0ustar00H   '; $statuses .= 'F   '; $statuses .= 'JS   '; $statuses .= 'CSS   '; $statuses .= 'HTML   '; $statuses .= 'PHP   '; $statuses .= 'BLOCKS'; $insertion_disabled = $disable_block_insertions || $disable_php_processing || $disable_html_code || $disable_css_code || $disable_js_code || $disable_footer_code || $disable_header_code; $ai_wp_data [AI_DEBUG_MENU_ITEMS] = array (); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) == 0) $debug_blocks = 1; else $debug_blocks = 0; $debug_blocks_class = $debug_blocks == 0 ? ' on' : ''; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) == 0) $debug_positions = 0; else $debug_positions = ''; $debug_positions_class = $debug_positions === '' ? ' on' : ''; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) == 0) $debug_tags = 1; else $debug_tags = 0; $debug_tags_class = $debug_tags == 0 ? ' on' : ''; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) == 0) $debug_processing = 1; else $debug_processing = 0; $debug_processing_class = $debug_processing == 0 ? ' on' : ''; if (!isset ($_GET [AI_URL_DEBUG_PROCESSING_FE_]) || $_GET [AI_URL_DEBUG_PROCESSING_FE_] == 0) $debug_processing_fe = 1; else $debug_processing_fe = 0; $debug_processing__fe_class = $debug_processing_fe == 0 ? ' on' : ''; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) $debug_no_insertion = 1; else $debug_no_insertion = 0; $debug_no_insertion_class = $debug_no_insertion == 0 ? ' on' : ''; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING) == 0) $debug_ad_blocking = 1; else $debug_ad_blocking = 0; $debug_ad_blocking_class = $debug_ad_blocking == 0 ? ' on' : ''; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) == 0) $debug_ad_blocking_status = 1; else $debug_ad_blocking_status = 0; $debug_ad_blocking_status_class = $debug_ad_blocking_status == 0 ? ' on' : ''; $debug_settings_on = $debug_blocks == 0 || $debug_positions === '' || $debug_tags == 0 || $debug_processing == 0 || $debug_no_insertion == 0 || $debug_ad_blocking == 0 || $debug_ad_blocking_status == 0; $debug_settings_class = $debug_settings_on ? ' on' : ''; if ($insertion_disabled) $debug_settings_class .= ' red'; $top_menu_url = $debug_settings_on ? (defined ('AI_DEBUGGING_DEMO') ? get_permalink () : add_query_arg (AI_URL_DEBUG, '0', remove_debug_parameters_from_url ())) : add_query_arg (array (AI_URL_DEBUG_BLOCKS => '1', AI_URL_DEBUG_POSITIONS => '0'), remove_debug_parameters_from_url ()); $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar', 'group' => true ); $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar-settings', // 'parent' => 'ai-toolbar', // 'title' => ''.AD_INSERTER_NAME . (defined ('AI_DEBUGGING_DEMO') ? ' Debugging DEMO' : ($debug_settings_on ? ' Debugging' : '')), 'title' => ''.AD_INSERTER_NAME . (defined ('AI_DEBUGGING_DEMO') ? ' ' . _x('Debugging DEMO', 'Menu item', 'ad-inserter') : ($debug_settings_on ? '' : '')), 'href' => $top_menu_url, // 'meta' => $debug_settings_on ? array ('title' => 'Turn Debugging Off') : array (), ); if ($insertion_disabled) { $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar-status', 'parent' => 'ai-toolbar-settings', 'title' => ' '.$statuses, ); } $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar-blocks', 'parent' => 'ai-toolbar-settings', 'title' => '' . _x('Label Blocks', 'Menu item, to label blocks', 'ad-inserter'), 'href' => set_url_parameter (AI_URL_DEBUG_BLOCKS, $debug_blocks), ); $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar-positions', 'parent' => 'ai-toolbar-settings', 'title' => '' . _x('Show Positions', 'Menu item', 'ad-inserter'), 'href' => set_url_parameter (AI_URL_DEBUG_POSITIONS, $debug_positions), ); $paragraph_blocks = array (); for ($block = 0; $block <= 96; $block ++) { $obj = $block_object [$block]; $automatic_insertion = $obj->get_automatic_insertion(); if ($block == 0 || !$obj->get_disable_insertion () && ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH)) { $block_tags = trim ($block_object [$block]->get_paragraph_tags ()); $direction = $block_object [$block]->get_direction_type() == AI_DIRECTION_FROM_TOP ? 't' : 'b'; $paragraph_min_words = intval ($obj->get_minimum_paragraph_words()); $paragraph_max_words = intval ($obj->get_maximum_paragraph_words()); $paragraph_text_type = $obj->get_paragraph_text_type (); $paragraph_text = trim (html_entity_decode ($obj->get_paragraph_text())); $inside_blockquote = $obj->get_count_inside_blockquote (); $count_inside_type = $obj->get_count_inside (); $count_inside_elements = $obj->get_count_inside_elements (); $that_contain_type = $obj->get_count_inside_elements_contain (); $that_contain_text = trim (html_entity_decode ($obj->get_count_inside_elements_text ())); if ($block_tags != '') { $found = false; foreach ($paragraph_blocks as $index => $paragraph_block) { if ($paragraph_block ['tags'] == $block_tags && $paragraph_block ['direction'] == $direction && $paragraph_block ['min'] == $paragraph_min_words && $paragraph_block ['max'] == $paragraph_max_words && $paragraph_block ['text_type'] == $paragraph_text_type && $paragraph_block ['text'] == $paragraph_text && $paragraph_block ['blockquote'] == $inside_blockquote && $paragraph_block ['inside_type'] == $count_inside_type && $paragraph_block ['inside_elemets'] == $count_inside_elements && $paragraph_block ['contain_type'] == $that_contain_type && $paragraph_block ['contain_text'] == $that_contain_text ) { $found = true; break; } } if ($found) array_push ($paragraph_blocks [$index]['blocks'], $block); else $paragraph_blocks []= array ('blocks' => array ($block), 'tags' => $block_tags, 'direction' => $direction, 'min' => $paragraph_min_words, 'max' => $paragraph_max_words, 'text_type' => $paragraph_text_type, 'text' => $paragraph_text, 'blockquote' => $inside_blockquote, 'inside_type' => $count_inside_type, 'inside_elemets' => $count_inside_elements, 'contain_type' => $that_contain_type, 'contain_text' => $that_contain_text, ); } } } $no_paragraph_counting_inside = get_no_paragraph_counting_inside (); foreach ($paragraph_blocks as $index => $paragraph_block) { $debug_block_active = $debug_positions === '' && in_array ($ai_wp_data [AI_WP_DEBUG_BLOCK], $paragraph_block ['blocks']); $block_class = $debug_block_active ? ' on' : ''; // $block_class = $debug_positions === '' && in_array ($ai_wp_data [AI_WP_DEBUG_BLOCK], $paragraph_block ['blocks']) ? ' on' : ''; $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar-positions-'.$index, 'parent' => 'ai-toolbar-positions', 'title' => ''. $paragraph_block ['tags']. ($paragraph_block ['direction'] == 'b' ? ' ' : ''). ($paragraph_block ['min'] != 0 ? ' min '.$paragraph_block ['min']. ' ' : ''). ($paragraph_block ['max'] != 0 ? ' max '.$paragraph_block ['max']. ' ' : ''). ($paragraph_block ['blockquote'] ? ' +[' . $no_paragraph_counting_inside . '] ' : ''). ($paragraph_block ['text'] != '' ? ($paragraph_block ['text_type'] == AI_DO_NOT_CONTAIN ? ' !has ' : ' has ').' ['.htmlentities ($paragraph_block ['text']).']' : ''). ($paragraph_block ['inside_elemets'] != '' ? ($paragraph_block ['inside_type'] == AI_COUNT_ONLY ? ' insEL' : ' !insEL ').' ['.$paragraph_block ['inside_elemets'].']' : ''). ($paragraph_block ['contain_text'] != '' ? ($paragraph_block ['contain_type'] == AI_CONTAIN ? ' elHAS' : ' !elHAS ').' ['.htmlentities ($paragraph_block ['contain_text']).']' : ''), // 'href' => set_url_parameter (AI_URL_DEBUG_POSITIONS, $paragraph_block ['blocks'][0]), 'href' => set_url_parameter (AI_URL_DEBUG_POSITIONS, $debug_block_active ? '' : $paragraph_block ['blocks'][0]), ); } $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar-tags', 'parent' => 'ai-toolbar-settings', 'title' => '' . _x('Show HTML Tags', 'Menu item', 'ad-inserter'), 'href' => set_url_parameter (AI_URL_DEBUG_TAGS, $debug_tags), ); $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar-no-insertion', 'parent' => 'ai-toolbar-settings', 'title' => '' . _x('Disable Insertion', 'Menu item', 'ad-inserter'), 'href' => set_url_parameter (AI_URL_DEBUG_NO_INSERTION, $debug_no_insertion), ); if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { if ($ai_wp_data [AI_ADB_DETECTION]) { $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar-adb-status', 'parent' => 'ai-toolbar-settings', 'title' => '' . _x('Ad Blocking Status', 'Menu item', 'ad-inserter'), 'href' => set_url_parameter (AI_URL_DEBUG_AD_BLOCKING_STATUS, $debug_ad_blocking_status), ); $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar-adb', 'parent' => 'ai-toolbar-settings', 'title' => '' . _x('Simulate Ad Blocking', 'Menu item', 'ad-inserter'), 'href' => set_url_parameter (AI_URL_DEBUG_AD_BLOCKING, $debug_ad_blocking), ); } } if (!defined ('AI_DEBUGGING_DEMO')) { $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar-processing', 'parent' => 'ai-toolbar-settings', 'title' => '' . _x('Log Processing', 'Menu item', 'ad-inserter'), 'href' => set_url_parameter (AI_URL_DEBUG_PROCESSING, $debug_processing), ); $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array ( 'id' => 'ai-toolbar-processing-fe', 'parent' => 'ai-toolbar-processing', 'title' => '' . _x('Show Log', 'Menu item', 'ad-inserter'), 'href' => set_url_parameter (AI_URL_DEBUG_PROCESSING_FE, $debug_processing_fe), ); } } function ai_toolbar ($wp_admin_bar) { global $ai_wp_data; ai_toolbar_menu_items (); foreach ($ai_wp_data [AI_DEBUG_MENU_ITEMS] as $menu_item) { $wp_admin_bar->add_node ($menu_item); } } function set_user () { global $ai_wp_data; if ($ai_wp_data [AI_WP_USER_SET]) return; if (is_user_logged_in ()) $ai_wp_data [AI_WP_USER] |= AI_USER_LOGGED_IN; if (current_user_role () >= 5) $ai_wp_data [AI_WP_USER] |= AI_USER_ADMINISTRATOR; // if (isset ($_GET [AI_URL_DEBUG_USER]) && $_GET [AI_URL_DEBUG_USER] != 0) $ai_wp_data [AI_WP_USER] = $_GET [AI_URL_DEBUG_USER]; $ai_wp_data [AI_WP_USER_SET] = true; } function set_page_type () { global $ai_wp_data, $wp_query; if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_NONE) return; if (is_front_page ()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_HOMEPAGE; elseif (is_single()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_POST; elseif (is_page()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_STATIC; elseif (is_feed()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_FEED; elseif (is_category()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_CATEGORY; elseif (is_archive() || (is_home () && !is_front_page ())) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ARCHIVE; elseif (is_admin()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ADMIN; // Admin pages may also be search pages or ajax requests elseif (is_search()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_SEARCH; elseif (is_404()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_404; if ( // AMP, AMP WP function_exists ('is_amp_endpoint') && is_amp_endpoint () || // AMP WP function_exists ('is_amp_wp') && is_amp_wp ($wp_query) || // AMP for WP - Accelerated Mobile Pages for WordPress function_exists ('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint () || // WP AMP Ninja isset ($_GET ['wpamp']) || // WP AMP - Accelerated Mobile Pages for WordPress function_exists ('is_wp_amp') && is_wp_amp () || // Better AMP - WordPress Complete AMP function_exists ('is_better_amp') && is_better_amp ($wp_query) || // PenCi Soledad AMP - WordPress Complete AMP function_exists ('is_penci_amp') && is_penci_amp ($wp_query) ) { $ai_wp_data [AI_WP_AMP_PAGE] = true; define ('AI_AMP_PAGE', true); } } function ai_log_message ($message) { global $ai_last_time, $ai_processing_log; $ai_processing_log []= rtrim (sprintf ("%4d %-50s", (microtime (true) - $ai_last_time) * 1000, $message)); } function ai_log_filter_content ($content_string) { $content_string = preg_replace ("/\[\[AI_[A|B]P([\d].?)\]\]/", "", $content_string); return str_replace (array ("", "\n", "\r"), array ("", "*n", "*r"), $content_string); } function ai_log_content (&$content) { if (strlen ($content) < 100) ai_log (ai_log_filter_content ($content) . ' ['.number_of_words ($content).' words]'); else ai_log (ai_log_filter_content (html_entity_decode (substr ($content, 0, 60))) . ' ... ' . ai_log_filter_content (html_entity_decode (substr ($content, - 60))) . ' ['.number_of_words ($content).' words]'); } function ai_filter_code ($code) { $code = preg_replace ("/\[\[AI_[A|B]P([\d].?)\]\]/", "", $code); return str_replace (array (""), array (""), $code); } function ai_dump_code ($code, $max_size = 0) { if ($max_size == 0) return ai_filter_code ($code); else if ($max_size != 0 && strlen ($code) < $max_size) return ai_filter_code ($code); else return ai_filter_code (html_entity_decode (substr ($code, 0, 120))) . ' ... ' . ai_filter_code (html_entity_decode (substr ($code, - 120))); } function ai_block_insertion_status ($block, $ai_last_check) { global $block_object; if ($block < 1 || $block > 96) $block = 0; if ($ai_last_check == AI_CHECK_INSERTED) return "INSERTED"; $status = "FAILED CHECK: "; $obj = $block_object [$block]; switch ($ai_last_check) { case AI_CHECK_PAGE_TYPE_FRONT_PAGE: $status .= "ENABLED ON HOMEPAGE"; break; case AI_CHECK_PAGE_TYPE_STATIC_PAGE: $status .= "ENABLED ON STATIC PAGE"; break; case AI_CHECK_PAGE_TYPE_POST: $status .= "ENABLED ON POST"; break; case AI_CHECK_PAGE_TYPE_CATEGORY: $status .= "ENABLED ON CATEGORY"; break; case AI_CHECK_PAGE_TYPE_SEARCH: $status .= "ENABLED ON SEARCH"; break; case AI_CHECK_PAGE_TYPE_ARCHIVE: $status .= "ENABLED ON ARCHIVE"; break; case AI_CHECK_PAGE_TYPE_FEED: $status .= "ENABLED ON FEED"; break; case AI_CHECK_PAGE_TYPE_404: $status .= "ENABLED ON 404"; break; case AI_CHECK_DESKTOP_DEVICES: $status .= "DESKTOP DEVICES"; break; case AI_CHECK_MOBILE_DEVICES: $status .= "MOBILE DEVICES"; break; case AI_CHECK_TABLET_DEVICES: $status .= "TABLET DEVICES"; break; case AI_CHECK_PHONE_DEVICES: $status .= "PHONE DEVICES"; break; case AI_CHECK_DESKTOP_TABLET_DEVICES: $status .= "DESKTOP TABLET DEVICES"; break; case AI_CHECK_DESKTOP_PHONE_DEVICES: $status .= "DESKTOP PHONE DEVICES"; break; case AI_CHECK_CATEGORY: $status .= "CATEGORY"; break; case AI_CHECK_TAG: $status .= "TAG"; break; case AI_CHECK_TAXONOMY: $status .= "TAXONOMY"; break; case AI_CHECK_ID: $status .= "ID"; break; case AI_CHECK_URL: $status .= "URL"; break; case AI_CHECK_URL_PARAMETER: $status .= "URL PARAMETER"; break; case AI_CHECK_COOKIE: $status .= "COOKIE"; break; case AI_CHECK_REFERER: $status .= "REFERRER ". $obj->get_ad_domain_list(); break; case AI_CHECK_CLIENT: $status .= "CLIENT ". $obj->get_client_list(); break; case AI_CHECK_IP_ADDRESS: $status .= "IP ADDRESS ". $obj->get_ad_ip_address_list(); break; case AI_CHECK_COUNTRY: $status .= "COUNTRY ". $obj->get_ad_country_list (true); break; case AI_CHECK_SCHEDULING: $status .= "SCHEDULING"; break; case AI_CHECK_CODE: $status .= "CODE EMPTY"; break; case AI_CHECK_LOGGED_IN_USER: $status .= "LOGGED-IN USER"; break; case AI_CHECK_NOT_LOGGED_IN_USER: $status .= "NOT LOGGED-IN USER"; break; case AI_CHECK_ADMINISTRATOR: $status .= "ADMINISTRATOR"; break; case AI_CHECK_INDIVIDUALLY_DISABLED: $status .= "INDIVIDUALLY DISABLED"; break; case AI_CHECK_INDIVIDUALLY_ENABLED: $status .= "INDIVIDUALLY ENABLED"; break; case AI_CHECK_DISABLED_MANUALLY: $status .= "DISABLED BY SHORTCODE"; break; case AI_CHECK_MAX_INSERTIONS: $status .= "MAX INSERTIONS " . $obj->get_maximum_insertions (); break; case AI_CHECK_MAX_PAGE_BLOCKS: $status .= "MAX PAGE BLOCKS " . get_max_page_blocks (); break; case AI_CHECK_FILTER: $status .= ($obj->get_inverted_filter() ? 'INVERTED ' : '') . "FILTER " . $obj->get_call_filter(); break; case AI_CHECK_PARAGRAPH_COUNTING: $status .= "PARAGRAPH COUNTING"; break; case AI_CHECK_IMAGE_COUNTING: $status .= "IMAGE COUNTING"; break; case AI_CHECK_MIN_NUMBER_OF_WORDS: $status .= "MIN NUMBER OF WORDS " . intval ($obj->get_minimum_words()); break; case AI_CHECK_MAX_NUMBER_OF_WORDS: $status .= "MAX NUMBER OF WORDS " . (intval ($obj->get_maximum_words()) == 0 ? 1000000 : intval ($obj->get_maximum_words())); break; case AI_CHECK_DEBUG_NO_INSERTION: $status .= "DEBUG NO INSERTION"; break; case AI_CHECK_MAX_IMPRESSIONS: $status .= "MAX IMPRESSIONS"; break; case AI_CHECK_LIMIT_IMPRESSIONS_PER_TIME_PERIOD: $status .= "LIMIT IMPRESSIONS PER TIME PERIOD"; break; case AI_CHECK_MAX_CLICKS: $status .= "MAX CLICKS"; break; case AI_CHECK_LIMIT_CLICKS_PER_TIME_PERIOD: $status .= "LIMIT CLICKS PER TIME PERIOD"; break; case AI_CHECK_CFP_IP_ADDRESS: $status .= "CLICK FRAUD PROTECTION IP ADDRESS"; break; case AI_CHECK_INSERTION_NOT_DISABLED: $status .= "INSERTION PAUSED"; break; case AI_CHECK_PARAGRAPH_TAGS: $status .= "PARAGRAPH TAGS"; break; case AI_CHECK_PARAGRAPHS_WITH_TAGS: $status .= "PARAGRAPHS WITH TAGS"; break; case AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE: $status .= "PARAGRAPHS AFTER NO COUNTING INSIDE"; break; case AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE_ELEMENTS: $status .= "PARAGRAPHS AFTER NO COUNTING INSIDE ELEMENTS"; break; case AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS: $status .= "PARAGRAPHS AFTER MIN MAX WORDS"; break; case AI_CHECK_PARAGRAPHS_AFTER_TEXT: $status .= "PARAGRAPHS AFTER TEXT"; break; case AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE: $status .= "PARAGRAPHS AFTER CLEARANCE"; break; case AI_CHECK_PARAGRAPHS_MIN_NUMBER: $status .= "PARAGRAPHS MIN NUMBER"; break; case AI_CHECK_PARAGRAPHS_MAX_NUMBER: $status .= "PARAGRAPHS MAX NUMBER"; break; case AI_CHECK_PARAGRAPH_NUMBER: $status .= "PARAGRAPH NUMBER " . $obj->get_paragraph_number(); break; case AI_CHECK_NO_PARAGRAPHS: $status .= "NO PARAGRAPHS"; break; case AI_CHECK_DO_NOT_INSERT: $status .= "PARAGRAPH CLEARANCE"; break; case AI_CHECK_AD_ABOVE: $status .= "PARAGRAPH CLEARANCE ABOVE"; break; case AI_CHECK_AD_BELOW: $status .= "PARAGRAPH CLEARANCE BELOW"; break; case AI_CHECK_SHORTCODE_ATTRIBUTES: $status .= "SHORTCODE ATTRIBUTES"; break; case AI_CHECK_ENABLED_PHP: $status .= "PHP FUNCTION ENABLED"; break; case AI_CHECK_ENABLED_SHORTCODE: $status .= "SHORTCODE ENABLED"; break; case AI_CHECK_ENABLED_WIDGET: $status .= "WIDGET ENABLED"; break; case AI_CUSTOM_FILTER_CHECK: $status .= "CUSTOM FILTER HOOK CHECK"; break; case AI_CHECK_NONE: $status = "BLOCK $block"; break; default: $status .= "?"; break; } $ai_last_check = AI_CHECK_NONE; return $status; } function ai_log_block_status ($block, $ai_last_check) { global $block_object, $block_insertion_log, $ad_inserter_globals, $ai_wp_data; if ($block >= 1 && $ai_last_check == AI_CHECK_INSERTED) { $obj = $block_object [$block]; $global_name = AI_BLOCK_COUNTER_NAME . $block; if ($obj->check_code_insertions !== null) { $block_insertion_log [] = sprintf ("% 2d BLOCK % 2d %s %s%s", $block, $block, 'CHECK', '('.$obj->check_code_insertions . ')', $ad_inserter_globals [$global_name] != 1 ? '['.$ad_inserter_globals [$global_name] . ']' : ''); return ''; } elseif ($obj->no_insertion_text != '') { $block_insertion_log [] = sprintf ("% 2d BLOCK % 2d %s %s", $block, $block, $obj->no_insertion_text, $ad_inserter_globals [$global_name] != 1 ? '['.$ad_inserter_globals [$global_name] . ']' : ''); return ''; } } return ai_log_block_insertion_status ($block, $ai_last_check); } function ai_log_block_insertion_status ($block, $ai_last_check) { global $block_insertion_log, $ad_inserter_globals; if ($block < 1) return 'NO BLOCK SHORTCODE'; $global_name = AI_BLOCK_COUNTER_NAME . $block; $block_status = ai_block_insertion_status ($block, $ai_last_check); $block_insertion_log [] = sprintf ("% 2d BLOCK % 2d %s %s", $block, $block, $block_status, $ai_last_check == AI_CHECK_INSERTED && $ad_inserter_globals [$global_name] != 1 ? '['.$ad_inserter_globals [$global_name] . ']' : ''); return "BLOCK $block " . $block_status; } function ai_log ($message = "") { global $ai_last_time, $ai_processing_log; if ($message != "") { if ($message [strlen ($message) - 1] == "\n") { ai_log_message (str_replace ("\n", "", $message)); $ai_processing_log []= ""; } else ai_log_message ($message); } else $ai_processing_log []= ""; $ai_last_time = microtime (true); } function remove_debug_parameters_from_url ($url = false) { if (defined ('AI_DEBUGGING_DEMO')) { $parameters = array (AI_URL_DEBUG, AI_URL_DEBUG_PROCESSING, AI_URL_DEBUG_PROCESSING_FE); } else { $parameters = array ( AI_URL_DEBUG, AI_URL_DEBUG_PROCESSING, AI_URL_DEBUG_PROCESSING_FE, AI_URL_DEBUG_PHP, AI_URL_DEBUG_BLOCKS, AI_URL_DEBUG_CODE, AI_URL_DEBUG_USER, AI_URL_DEBUG_TAGS, AI_URL_DEBUG_POSITIONS, AI_URL_DEBUG_NO_INSERTION, AI_URL_DEBUG_JAVASCRIPT, AI_URL_DEBUG_AD_BLOCKING, AI_URL_DEBUG_AD_BLOCKING_STATUS, AI_URL_DEBUG_COUNTRY, AI_URL_DEBUG_IP_ADDRESS, AI_URL_DEBUG_DISABLE_CSS_CODE, AI_URL_DEBUG_DISABLE_JS_CODE, AI_URL_DEBUG_DISABLE_PHP_PROCESSING, AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS, AI_URL_DEBUG_DISABLE_HEADER_CODE, AI_URL_DEBUG_DISABLE_FOOTER_CODE, ); if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { $parameters = array_merge ($parameters, array (AI_URL_DEBUG_AD_BLOCKING, AI_URL_DEBUG_AD_BLOCKING_STATUS)); } } return remove_query_arg ($parameters, $url); } function set_url_parameter ($parameter, $value) { return add_query_arg ($parameter, $value, remove_debug_parameters_from_url ()); } function number_of_words (&$content) { $text = str_replace ("\r", "", $content); $text = str_replace (array ("\n", " "), " ", $text); $text = preg_replace('#(.*?)#i', '', $text); $text = preg_replace('#(.*?)#i', '', $text); $text = htmlspecialchars_decode ($text); $text = trim (strip_tags ($text)); $text = preg_replace ('#\s+#', ' ', $text); if ($text == '') return 0; return count (explode (' ', $text)); } function ai_loop_check ($query, $action) { global $ai_wp_data; $ai_wp_data [AI_CONTEXT] = $action == 'loop_start' ? AI_CONTEXT_BEFORE_POST : AI_CONTEXT_AFTER_POST; if ($ai_wp_data [AI_WP_AMP_PAGE]) return true; if ($action == 'loop_end' && !method_exists ($query, 'is_main_query') && method_exists ($wp_query, 'is_main_query')) { $query = $wp_query; } if (isset ($query) && method_exists ($query, 'is_main_query')) { if ($query->is_main_query()) { if (isset ($ai_wp_data [AI_HEAD]) && !$ai_wp_data [AI_HEAD]) { return true; } } } return false; } function ai_process_head_codes ($head) { global $ai_wp_data; if (!get_disable_header_code ()) { if (!empty ($ai_wp_data [AI_HEAD_CODES])) { $head = str_replace ("", implode ("\n", $ai_wp_data [AI_HEAD_CODES]) . "\n", $head); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) { $head = str_replace ("<!--[AI_HEAD_CODES]-->", '' . str_replace (array ('<', '>'), array ('<', '>'), implode ("\\n", $ai_wp_data [AI_HEAD_CODES])) . '', $head); } } foreach ($ai_wp_data [AI_HEAD_GROUPS] as $group_name => $group_codes) { $group_code = implode ("\n", $group_codes); $head = str_replace ("", $group_code, $head); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) { $head = str_replace ("<!--[AI_HEAD_GROUPS $group_name]-->", str_replace (array ('<', '>'), array ('<', '>'), implode ("\\n", $group_codes)), $head); } } } $head = preg_replace ("##", '', $head); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) { $head = preg_replace ("#<!--\[AI(.+?)\]-->#", '', $head); } $head = preg_replace ("#\n#", '', $head); return ($head); } // Not used function ai_buffering_start_hook () { global $ai_wp_data; if (defined ('AI_BUFFERING')) { if (get_output_buffering ()) { if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { ai_buffering_start (); } } } } function ai_buffering_start () { global $ai_wp_data; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("BUFFERING START: level " . ob_get_level () ); } ob_start (); if (!defined ('AI_BUFFERING_START')) define ('AI_BUFFERING_START', true); } function ai_buffering_end () { global $ai_wp_data, $ai_total_plugin_time, $ai_db_options_extract, $block_object, $ad_inserter_globals; if (!defined ('AI_BUFFERING_START')) return; $page = ob_get_clean(); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("BUFFERING END: level " . ob_get_level ()); $start_time = microtime (true); } $matches = preg_split ('/()/i', $page, - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("BUFFER body tag matches: " . (count ($matches) - 1) / 2); ai_log ("PHP VERSION COMPARE to 5.4: " . (version_compare (phpversion (), "5.4", ">=") ? 'YES' : 'NO')); if (count ($matches) > 3) { ai_log ("NO BUFFER PROCESSING - more than one body tag found"); } if (version_compare (phpversion (), "5.4", "<")) { ai_log ("NO BUFFER PROCESSING - PHP version below 5.4"); } } if (version_compare (phpversion (), "5.4", ">=") && count ($matches) == 3) { if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("BUFFER PROCESSING"); } $head = $matches [0]; $body_tag = $matches [1]; $body = $matches [2]; if (isset ($ai_wp_data [AI_BODY_STYLE])) { if (preg_match ('#style=[\'"](.*?)[\'"]#i', $body_tag, $body_style)) { $old_style = $body_style [1]; if ($old_style != '') { $old_style = trim ($old_style, ' ;'); if ($old_style != '') { $old_style .= '; '; } } $new_style = $old_style . $ai_wp_data [AI_BODY_STYLE]; $body_tag = str_ireplace ($body_style [0], 'style="'.$new_style.'"', $body_tag); } else { $body_tag = str_replace ('>', ' style="' . $ai_wp_data [AI_BODY_STYLE] . '">', $body_tag); } } $body = preg_replace ('/\n/", '', $body); if (isset ($ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && class_exists ('DOMDocument')) { $php_version = explode ('.', PHP_VERSION); if ($php_version [0] >= 8) { // phpQuery for PHP 8 require_once ('includes/phpQuery_8.php'); } else // phpQuery for PHP 5.6 to PHP 7 require_once ('includes/phpQuery.php'); $no_closing_tag = array ('img', 'hr', 'br'); $multibyte = $ai_wp_data [AI_MBSTRING_LOADED] && get_paragraph_counting_functions() == AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS; foreach ($ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) { $obj = $block_object [$block]; $obj->clear_code_cache (); switch ($obj->get_automatic_insertion ()) { case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT: $insertion_position = 'before'; break; case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT: $insertion_position = 'after'; break; case AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT: switch ($obj->get_inside_element ()) { case AI_HTML_PREPEND_CONTENT: $insertion_position = 'prepend'; break; case AI_HTML_APPEND_CONTENT: $insertion_position = 'append'; break; case AI_HTML_REPLACE_CONTENT: $insertion_position = 'replace-content'; break; case AI_HTML_REPLACE_ELEMENT: $insertion_position = 'replace-element'; break; } break; } $selector = $obj->get_html_selector (); libxml_use_internal_errors (true); $content = phpQuery::newDocumentHTML ($body); libxml_use_internal_errors (false); foreach (pq ($selector) as $element) { if (in_array ($element->tagName, $no_closing_tag)) { switch ($insertion_position) { case 'replace-content': case 'prepend': case 'append': $insertion_position = 'after'; break; } } switch ($insertion_position) { case 'before': pq ($element)->before (AI_MARKER_START.$element->tagName.AI_MARKER_END); break; case 'after': pq ($element)->after (AI_MARKER_START.$element->tagName.AI_MARKER_END); break; case 'prepend': pq ($element)->prepend (AI_MARKER_START.$element->tagName.AI_MARKER_END); break; case 'append': pq ($element)->append (AI_MARKER_START.$element->tagName.AI_MARKER_END); break; case 'replace-content': pq ($element)->prepend (AI_MARKER_START.'-'.$element->tagName.'-'.AI_MARKER_END); pq ($element)->append (AI_MARKER_START.'='.$element->tagName.'='.AI_MARKER_END); break; case 'replace-element': pq ($element)->before (AI_MARKER_START.'-'.$element->tagName.'-'.AI_MARKER_END); pq ($element)->after (AI_MARKER_START.'='.$element->tagName.'='.AI_MARKER_END); break; } } switch ($insertion_position) { case 'replace-content': case 'replace-element': $markers = preg_split ('/('.AI_MARKER_START.'-.*?-'.AI_MARKER_END.')/', $content->htmlOuter (), - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $markers2 = preg_split ('/('.AI_MARKER_START.'=.*?='.AI_MARKER_END.')/', $content->htmlOuter (), - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); break; default: $markers = preg_split ('/('.AI_MARKER_START.'.*?'.AI_MARKER_END.')/', $content->htmlOuter (), - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); break; } $content_before = ''; $insertions = array (); foreach ($markers as $marker) { switch ($insertion_position) { case 'replace-content': case 'replace-element': $marker_start_string = AI_MARKER_START.'-'; break; default: $marker_start_string = AI_MARKER_START; break; } if (strpos ($marker, $marker_start_string) === 0) { switch ($insertion_position) { case 'replace-content': case 'replace-element': $tag = str_replace (array (AI_MARKER_START.'-', '-'.AI_MARKER_END), '', $marker); break; default: $tag = str_replace (array (AI_MARKER_START, AI_MARKER_END), '', $marker); break; } switch ($insertion_position) { case 'before': case 'replace-element': $tag_string = "<{$tag}"; break; case 'after': if (in_array ($tag, $no_closing_tag)) $tag_string = '>'; else $tag_string = ""; break; case 'prepend': case 'replace-content': $tag_string = "<{$tag}[^>]*>"; break; case 'append': $tag_string = ""; break; } preg_match_all ("#{$tag_string}#i", $content_before, $tag_matches); switch ($insertion_position) { case 'before': case 'replace-element': $insertions []= array ($tag_string, count ($tag_matches [0]) + 1); break; case 'after': $insertions []= array ($tag_string, count ($tag_matches [0])); break; case 'replace-content': case 'prepend': $insertions []= array ($tag_string, count ($tag_matches [0])); break; case 'append': $insertions []= array ($tag_string, count ($tag_matches [0]) + 1); break; } continue; } $content_before .= $marker; } switch ($insertion_position) { case 'replace-content': case 'replace-element': $content_before = ''; $insertions2 = array (); foreach ($markers2 as $marker) { if (strpos ($marker, AI_MARKER_START.'=') === 0) { $tag = str_replace (array (AI_MARKER_START.'=', '='.AI_MARKER_END), '', $marker); $tag_string = ""; preg_match_all ("#{$tag_string}#i", $content_before, $tag_matches); switch ($insertion_position) { case 'replace-content': $insertions2 []= array ($tag_string, count ($tag_matches [0]) + 1); break; case 'replace-element': $insertions2 []= array ($tag_string, count ($tag_matches [0])); break; } continue; } $content_before .= $marker; } break; } $insertion_offsets = array (); foreach ($insertions as $insertion) { $tag = $insertion [0]; $tag_counter = $insertion [1]; preg_match_all ("#$tag#i", $body, $org_tag_matches, PREG_OFFSET_CAPTURE); if (isset ($org_tag_matches [0][$tag_counter - 1])) { switch ($insertion_position) { case 'before': case 'replace-element': $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1]; break; case 'after': $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1] + strlen ($tag); break; case 'prepend': case 'replace-content': $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1] + strlen ($org_tag_matches [0][$tag_counter - 1][0]); break; case 'append': $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1]; break; } } } sort ($insertion_offsets); switch ($insertion_position) { case 'replace-content': case 'replace-element': $insertion_offsets2 = array (); foreach ($insertions2 as $insertion) { $tag = $insertion [0]; $tag_counter = $insertion [1]; preg_match_all ("#$tag#i", $body, $org_tag_matches, PREG_OFFSET_CAPTURE); if (isset ($org_tag_matches [0][$tag_counter - 1])) { switch ($insertion_position) { case 'replace-content': $insertion_offsets2 []= $org_tag_matches [0][$tag_counter - 1][1]; break; case 'replace-element': $insertion_offsets2 []= $org_tag_matches [0][$tag_counter - 1][1] + strlen ($tag); break; } } } sort ($insertion_offsets2); break; } $new_content = ''; $current_offset = 0; switch ($insertion_position) { case 'before': $action = 'before_html_element'; // translators: Debugging position name Before HTML element $action_name = __('Before', 'ad-inserter') . ' ' . $selector; break; case 'after': $action = 'after_html_element'; // translators: Debugging position name After HTML element $action_name = __('After', 'ad-inserter') . ' ' . $selector; break; case 'prepend': $action = 'prepend_html_element'; // translators: Debugging position name Prepend content of HTML element (before the content of the HTML element) $action_name = __('Prepend content', 'ad-inserter') . ' ' . $selector; break; case 'append': $action = 'append_html_element'; // translators: Debugging position name Append content of HTML element (after the content of the HTML element) $action_name = __('Append content', 'ad-inserter') . ' ' . $selector; break; case 'replace-content': $action = 'replace_content_html_element'; // translators: Debugging position name Replace content of HTML element $action_name = __('Replace content', 'ad-inserter') . ' ' . $selector; break; case 'replace-element': // translators: Debugging position name Replace HTML element $action = 'replace_html_element'; $action_name = __('Replace', 'ad-inserter') . ' ' . $selector; break; } $globals_name = 'AI_' . strtoupper ($action) . '_COUNTER'; unset ($ad_inserter_globals [$globals_name]); $ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] = array ($block); foreach ($insertion_offsets as $index => $insertion_offset) { if ($multibyte) $new_content .= mb_substr ($body, $current_offset, $insertion_offset - $current_offset); $new_content .= substr ($body, $current_offset, $insertion_offset - $current_offset); switch ($insertion_position) { case 'replace-content': case 'replace-element': if (isset ($insertion_offsets2 [$index])) { $current_offset = $insertion_offsets2 [$index]; } else $current_offset = $insertion_offset; break; default: $current_offset = $insertion_offset; break; } ob_start (); // Dummy ai_custom_hook ($action, AI_AUTOMATIC_INSERTION_DISABLED, $action_name); $new_content .= ob_get_clean(); } unset ($ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]); $new_content .= substr ($body, $current_offset); $body = $new_content; } } $head = ai_process_head_codes ($head); echo $head, $body_tag; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) { $class = AI_DEBUG_STATUS_CLASS.' status-ok'; // translators: Debugging message when output buffering is enabled echo "
    " . __('OUTPUT BUFFERING', 'ad-inserter') . '
    '; } // translators: Debugging position ai_custom_hook ('above_header', AI_AUTOMATIC_INSERTION_ABOVE_HEADER, 'Above Header', __('Above Header', 'ad-inserter')); echo $body; } else echo $page; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("BUFFER PROCESSING END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); // $ai_wp_data [AI_PROCESSING_TIME] = false; } } function ai_post_check ($post, $action) { global $ai_wp_data, $ad_inserter_globals; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) return false; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) return false; // Don't use the hook before the wp_head hook ends if (!isset ($ai_wp_data [AI_HEAD]) || $ai_wp_data [AI_HEAD]) { return false; } // in_the_loop () is not used on AMP pages (however, AMP plugin uses it) switch ($ai_wp_data [AI_WP_AMP_PAGE]) { case true: if ($ai_wp_data [AI_POST_POSITION] != AI_POST_POSITION_IN_POST) return false; // include_once (ABSPATH . 'wp-admin/includes/plugin.php'); // if (is_plugin_active ('amp/amp.php')) { // if (!in_the_loop()) return false; // } else { // // For other AMP plugins // if ($ai_wp_data [AI_POST_POSITION] != AI_POST_POSITION_IN_POST) return false; // } break; default: if (!in_the_loop()) return false; break; } // Skip insertion before the first post if (!defined ('AI_POST_CHECK')) { define ('AI_POST_CHECK', true); return false; } $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BETWEEN_POSTS; return true; } function ai_content_marker () { global $ai_wp_data; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_AJAX || get_disable_html_code ()) return; echo '', "\n"; } function ai_mark_loop_start () { global $ai_wp_data; $ai_wp_data [AI_POST_POSITION] = AI_POST_POSITION_IN_POST; } function ai_mark_loop_end () { global $ai_wp_data; $ai_wp_data [AI_POST_POSITION] = AI_POST_POSITION_AFTER_POST; } function ai_hook_function_loop_start ($hook_parameter) { ai_custom_hook ('loop_start', AI_AUTOMATIC_INSERTION_BEFORE_POST, AI_TEXT_ENG_BEFORE_POST, AI_TEXT_BEFORE_POST, $hook_parameter, 'ai_loop_check'); } function ai_hook_function_loop_end ($hook_parameter) { ai_custom_hook ('loop_end', AI_AUTOMATIC_INSERTION_AFTER_POST, AI_TEXT_ENG_AFTER_POST, AI_TEXT_AFTER_POST, $hook_parameter, 'ai_loop_check'); } function ai_hook_function_post ($hook_parameter) { ai_custom_hook ('the_post', AI_AUTOMATIC_INSERTION_BETWEEN_POSTS, AI_TEXT_ENG_BETWEEN_POSTS, AI_TEXT_BETWEEN_POSTS, $hook_parameter, 'ai_post_check'); } function ai_hook_function_footer () { ai_custom_hook ('wp_footer', AI_AUTOMATIC_INSERTION_FOOTER, AI_TEXT_ENG_FOOTER, AI_TEXT_FOOTER); } // Code for PHP VERSION >= 5.3.0 //function ai_get_custom_hook_function ($action, $insertion_type, $name) { // return function () use ($action, $insertion_type, $name) { // ai_custom_hook ($action, $insertion_type, $name); // }; //} // Code for PHP VERSION < 5.3.0 function ai_custom_hook_function_0 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [0]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [0]['index'] - 1, $ai_custom_hooks [0]['name']); } function ai_custom_hook_function_1 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [1]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [1]['index'] - 1, $ai_custom_hooks [1]['name']); } function ai_custom_hook_function_2 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [2]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [2]['index'] - 1, $ai_custom_hooks [2]['name']); } function ai_custom_hook_function_3 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [3]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [3]['index'] - 1, $ai_custom_hooks [3]['name']); } function ai_custom_hook_function_4 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [4]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [4]['index'] - 1, $ai_custom_hooks [4]['name']); } function ai_custom_hook_function_5 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [5]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [5]['index'] - 1, $ai_custom_hooks [5]['name']); } function ai_custom_hook_function_6 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [6]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [6]['index'] - 1, $ai_custom_hooks [6]['name']); } function ai_custom_hook_function_7 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [7]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [7]['index'] - 1, $ai_custom_hooks [7]['name']); } function ai_custom_hook_function_8 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [8]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [8]['index'] - 1, $ai_custom_hooks [8]['name']); } function ai_custom_hook_function_9 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [9]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [9]['index'] - 1, $ai_custom_hooks [9]['name']); } function ai_custom_hook_function_10 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [10]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [10]['index'] - 1, $ai_custom_hooks [10]['name']); } function ai_custom_hook_function_11 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [11]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [11]['index'] - 1, $ai_custom_hooks [11]['name']); } function ai_custom_hook_function_12 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [12]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [12]['index'] - 1, $ai_custom_hooks [12]['name']); } function ai_custom_hook_function_13 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [13]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [13]['index'] - 1, $ai_custom_hooks [13]['name']); } function ai_custom_hook_function_14 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [14]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [14]['index'] - 1, $ai_custom_hooks [14]['name']); } function ai_custom_hook_function_15 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [15]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [15]['index'] - 1, $ai_custom_hooks [15]['name']); } function ai_custom_hook_function_16 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [16]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [16]['index'] - 1, $ai_custom_hooks [16]['name']); } function ai_custom_hook_function_17 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [17]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [17]['index'] - 1, $ai_custom_hooks [17]['name']); } function ai_custom_hook_function_18 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [18]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [18]['index'] - 1, $ai_custom_hooks [18]['name']); } function ai_custom_hook_function_19 () { global $ai_custom_hooks; ai_custom_hook ($ai_custom_hooks [19]['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $ai_custom_hooks [19]['index'] - 1, $ai_custom_hooks [19]['name']); } function ai_wp_hook () { global $ai_wp_data, $ai_db_options_extract, $ad_inserter_globals, $ai_total_plugin_time, $ai_walker, $ai_custom_hooks, $block_object; if (defined ('AI_WP_HOOK')) return; define ('AI_WP_HOOK', true); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("WP HOOK START"); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } set_page_type (); set_user (); ai_http_header (); if (defined ('AI_NO_JQUERY')) { // Check again if the constant is defined in the wp_head hook $ai_wp_data [AI_NO_JQUERY_CODE] = true; } if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 && get_disable_caching ()) ai_disable_caching (); if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) { $ai_wp_data [AI_HTML_ELEMENT_SELECTION] = isset ($_POST ['html_element_selection']) ? (bool) $_POST ['html_element_selection'] : false; } if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_ADMIN && ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 && get_admin_toolbar_debugging () && (!is_multisite() || is_main_site () || multisite_settings_page_enabled ())) add_action ('admin_bar_menu', 'ai_toolbar', 9920); $url_debugging = get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 || defined ('AI_DEBUGGING_DEMO'); if (!is_admin() || defined ('DOING_AJAX') || defined ('AI_DEBUGGING_DEMO')) { if (isset ($_GET [AI_URL_DEBUG]) && $_GET [AI_URL_DEBUG] == 0) { if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) { unset ($_COOKIE ['AI_WP_DEBUGGING']); ai_setcookie ('AI_WP_DEBUGGING', '', time() - (15 * 60), COOKIEPATH); } if (isset ($_COOKIE ['AI_WP_DEBUG_BLOCK'])) { unset ($_COOKIE ['AI_WP_DEBUG_BLOCK']); ai_setcookie ('AI_WP_DEBUG_BLOCK', '', time() - (15 * 60), COOKIEPATH); } } else { $ai_wp_data [AI_WP_DEBUGGING] = isset ($_COOKIE ['AI_WP_DEBUGGING']) ? $ai_wp_data [AI_WP_DEBUGGING] | ($_COOKIE ['AI_WP_DEBUGGING'] & ~AI_DEBUG_PROCESSING) : $ai_wp_data [AI_WP_DEBUGGING]; $ai_wp_data [AI_WP_DEBUG_BLOCK] = isset ($_COOKIE ['AI_WP_DEBUG_BLOCK']) ? $_COOKIE ['AI_WP_DEBUG_BLOCK'] : 0; if (isset ($_GET [AI_URL_DEBUG_BLOCKS])) if ($_GET [AI_URL_DEBUG_BLOCKS] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_BLOCKS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_BLOCKS; if (isset ($_GET [AI_URL_DEBUG_TAGS])) if ($_GET [AI_URL_DEBUG_TAGS] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_TAGS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_TAGS; if (isset ($_GET [AI_URL_DEBUG_NO_INSERTION])) if ($_GET [AI_URL_DEBUG_NO_INSERTION] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_NO_INSERTION; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_NO_INSERTION; if (isset ($_GET [AI_URL_DEBUG_AD_BLOCKING_STATUS])) if ($_GET [AI_URL_DEBUG_AD_BLOCKING_STATUS] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_AD_BLOCKING_STATUS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_AD_BLOCKING_STATUS; if (isset ($_GET [AI_URL_DEBUG_AD_BLOCKING])) if ($_GET [AI_URL_DEBUG_AD_BLOCKING] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_AD_BLOCKING; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_AD_BLOCKING; if (isset ($_GET [AI_URL_DEBUG_POSITIONS])) { $secret = isset ($_GET ['ai-secret']) && $_GET ['ai-secret'] == ai_secret_key (); if ($secret) { ai_disable_caching (); } if ($_GET [AI_URL_DEBUG_POSITIONS] !== '' && ($url_debugging || $secret)) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_POSITIONS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_POSITIONS; if (is_numeric ($_GET [AI_URL_DEBUG_POSITIONS])) $ai_wp_data [AI_WP_DEBUG_BLOCK] = intval ($_GET [AI_URL_DEBUG_POSITIONS]); if ($ai_wp_data [AI_WP_DEBUG_BLOCK] < 0 || $ai_wp_data [AI_WP_DEBUG_BLOCK] > 96) $ai_wp_data [AI_WP_DEBUG_BLOCK] = 0; } if (!defined ('AI_DEBUGGING_DEMO')) { if ($ai_wp_data [AI_WP_DEBUGGING] != 0) { if (!isset ($_GET ['no-cookie'])) { ai_setcookie ('AI_WP_DEBUGGING', $ai_wp_data [AI_WP_DEBUGGING], time() + AI_COOKIE_TIME, COOKIEPATH); } } else if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) ai_setcookie ('AI_WP_DEBUGGING', '', time() - (15 * 60), COOKIEPATH); if ($ai_wp_data [AI_WP_DEBUG_BLOCK] != 0) { if (!isset ($_GET ['no-cookie'])) { ai_setcookie ('AI_WP_DEBUG_BLOCK', $ai_wp_data [AI_WP_DEBUG_BLOCK], time() + AI_COOKIE_TIME, COOKIEPATH); } } else if (isset ($_COOKIE ['AI_WP_DEBUG_BLOCK'])) ai_setcookie ('AI_WP_DEBUG_BLOCK', '', time() - (15 * 60), COOKIEPATH); if ($ai_wp_data [AI_WP_DEBUGGING] != 0 || isset ($_GET [AI_URL_DEBUG]) || isset ($_GET [AI_URL_DEBUG_BLOCKS]) || isset ($_GET [AI_URL_DEBUG_POSITIONS]) || isset ($_GET [AI_URL_DEBUG_TAGS]) || isset ($_GET [AI_URL_DEBUG_PROCESSING_FE])) { ai_disable_caching (); } if ($ai_wp_data [AI_FRONTEND_JS_DEBUGGING] && ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC && !defined ('AI_NO_W3TC')) { $ai_wp_data [AI_W3TC_DEBUGGING] = true; } } else { if ($ai_wp_data [AI_WP_DEBUGGING] != 0) { ai_disable_caching (); } } } } if ($ai_wp_data [AI_HTML_ELEMENT_SELECTION]) { add_filter ('show_admin_bar', '__return_false', 999999); $ai_wp_data [AI_WP_DEBUGGING] = 0; } elseif (($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) == 0 && ((get_remote_debugging () && ($ai_wp_data [AI_WP_DEBUGGING] != 0 || (isset ($_GET [AI_URL_DEBUG]) && $_GET [AI_URL_DEBUG] == 1))) || defined ('AI_DEBUGGING_DEMO'))) { function ai_login_adminbar ($wp_admin_bar) { $wp_admin_bar->add_menu (array ('id' => 'ai-toolbar-login', 'title' => _x('Log In', 'Menu item', 'ad-inserter'), 'href' => wp_login_url())); } add_filter ('show_admin_bar', '__return_true', 999999); add_action ('admin_bar_menu', 'ai_toolbar', 9920); if (!defined ('AI_DEBUGGING_DEMO')) { add_action ('admin_bar_menu', 'ai_login_adminbar' ); } } if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 && get_force_admin_toolbar ()) { add_filter ('show_admin_bar', '__return_true', 999999); } $debug_positions = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0; $debug_tags_positions = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS)) != 0; $debug_tags_positions_blocks = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS | AI_DEBUG_BLOCKS)) != 0; $plugin_priority = get_plugin_priority (); if (isset ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_tags_positions) add_filter ('the_content', 'ai_content_hook', $plugin_priority); if (isset ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_tags_positions_blocks) add_filter ('the_excerpt', 'ai_excerpt_hook', $plugin_priority); add_action ('loop_start', 'ai_mark_loop_start'); if (isset ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions) add_action ('loop_start', 'ai_hook_function_loop_start'); add_action ('loop_end', 'ai_mark_loop_end'); if (isset ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions) add_action ('loop_end', 'ai_hook_function_loop_end'); if (isset ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions) add_action ('the_post', 'ai_hook_function_post'); if ((isset ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0) || (isset ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0) || (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0) || $debug_positions) { $ai_wp_data [AI_NUMBER_OF_COMMENTS] = 0; add_filter ('comments_array' , 'ai_comments_array', 10, 2); add_filter ('wp_list_comments_args' , 'ai_wp_list_comments_args'); $ai_walker = new ai_Walker_Comment; } // Code for PHP VERSION >= 5.3.0 // foreach ($ai_custom_hooks as $index => $custom_hook) { // if (isset ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions) // add_action ($custom_hook ['action'], ai_get_custom_hook_function ($custom_hook ['action'], AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1, $custom_hook ['name']), $custom_hook ['priority']); // } // Code for PHP VERSION < 5.3.0 foreach ($ai_custom_hooks as $index => $custom_hook) { if ($index >= 20) break; // Skip custom hooks on standard WP hooks - they will be processed anyway switch ($custom_hook ['action']) { case 'wp_footer': // case 'wp_head': // no block processing on wp_head case 'the_content': case 'the_excerpt': case 'loop_start': case 'loop_end': // case 'the_post': // ai_custom_hook distinguishes between custom hooks and Between posts continue 2; } $hook_number = $custom_hook ['index']; // if (isset ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions) { if (get_hook_enabled ($hook_number) && isset ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions) { // There might be more than one hook with the same action - block can use only one hook $hook_used = false; foreach ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) { $obj = $block_object [$block]; if ($obj->get_automatic_insertion () == AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $hook_number - 1) { $hook_used = true; break; } } if ($hook_used) { add_action ($custom_hook ['action'], 'ai_custom_hook_function_' . $index, $custom_hook ['priority']); } } } if ($ai_wp_data [AI_STICK_TO_THE_CONTENT]) { if (trim (get_main_content_element () == '')) { if (!defined ('AI_CONTENT_MARKER_NO_LOOP_START')) { add_action ('loop_start', 'ai_content_marker'); } if (!defined ('AI_CONTENT_MARKER_NO_LOOP_END')) { add_action ('loop_end', 'ai_content_marker'); } if (!defined ('AI_CONTENT_MARKER_NO_GET_SIDEBAR')) { add_action ('get_sidebar', 'ai_content_marker'); } } } if ($ai_wp_data [AI_WP_AMP_PAGE] ) { // AMP, Accelerated Mobile Pages add_action ('amp_post_template_head', 'ai_amp_head_hook', 99999); add_action ('amp_post_template_css', 'ai_amp_css_hook', 99999); add_action ('wp_head', 'ai_amp_head_hook', 99999); add_action ('wp_head', 'ai_amp_css_hook_style', 99999); // WP AMP Ninja add_action ('wpamp_custom_script', 'ai_amp_head_hook', 99999); // No usable hook for custom CSS // add_action ('wpamp_custom_style', 'ai_amp_css_hook', 99999); // WP AMP - Accelerated Mobile Pages for WordPress add_action ('amphtml_template_head', 'ai_amp_head_hook', 99999); add_action ('amphtml_template_css', 'ai_amp_css_hook', 99999); // Better AMP - WordPress Complete AMP add_action ('better-amp/template/head', 'ai_amp_head_hook', 99999); // No usable hook for custom CSS // add_action ('better-amp/template/css', 'ai_amp_css_hook', 99999); // AMP WP - Google AMP For WordPress add_action ('amp_wp_template_head', 'ai_amp_head_hook', 99999); // No usable hook for custom CSS // add_action ('amp_wp_template_head', 'ai_amp_css_hook', 99999); } else // WP add_action ('wp_head', 'ai_wp_head_hook', 99999); $automatic_insertion_footer_hook = isset ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions; if ($ai_wp_data [AI_WP_AMP_PAGE]) { // AMP, Accelerated Mobile Pages if ($automatic_insertion_footer_hook) { add_action ('amp_post_template_footer', 'ai_hook_function_footer', 5); add_action ('wp_footer', 'ai_hook_function_footer', 5); } add_action ('amp_post_template_footer', 'ai_amp_footer_hook', 5); add_action ('wp_footer', 'ai_amp_footer_hook', 5); // WP AMP Ninja if ($automatic_insertion_footer_hook) add_action ('wpamp_google_analytics_code', 'ai_hook_function_footer', 5); add_action ('wpamp_google_analytics_code', 'ai_amp_footer_hook', 5); // WP AMP - Accelerated Mobile Pages for WordPress if ($automatic_insertion_footer_hook) add_action ('amphtml_after_footer', 'ai_hook_function_footer', 5); add_action ('amphtml_after_footer', 'ai_amp_footer_hook', 5); // Better AMP - WordPress Complete AMP if ($automatic_insertion_footer_hook) add_action ('better-amp/template/footer', 'ai_hook_function_footer', 5); add_action ('better-amp/template/footer', 'ai_amp_footer_hook', 5); // AMP WP - Google AMP For WordPress if ($automatic_insertion_footer_hook) add_action ('amp_wp_template_footer', 'ai_hook_function_footer', 5); add_action ('amp_wp_template_footer', 'ai_amp_footer_hook', 5); } else { // WP if ($automatic_insertion_footer_hook) add_action ('wp_footer', 'ai_hook_function_footer', 5); add_action ('wp_footer', 'ai_wp_footer_hook_end_buffering', 5); add_action ('wp_footer', 'ai_wp_footer_hook', 9999999); } if ($ai_wp_data [AI_WP_AMP_PAGE]) { // No scripts on AMP pages if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { $ai_wp_data [AI_ADB_DETECTION] = false; $ai_wp_data [AI_TRACKING] = false; } } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("WP HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } }; function ai_load_plugin_textdomain_hook () { unload_textdomain ('ad-inserter'); load_plugin_textdomain ('ad-inserter', false, basename (dirname (__FILE__)) . '/languages/'); } function ai_load_textdomain_mofile ($mo_file, $domain) { global $ai_wp_data; if (strpos ($mo_file, 'ad-inserter') !== false) { if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { switch (file_exists ($mo_file)) { case true: ai_log ("TRANSLATION FILE: " . $mo_file); break; default: ai_log ("FILE NOT FOUND: " . $mo_file); break; } } $path = explode ('/', $mo_file); $new_mo_file = dirname (__FILE__) . '/languages/' . end ($path); if (file_exists ($new_mo_file)) { if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("USING FILE: " . $new_mo_file); } return ($new_mo_file); } } return ($mo_file); } function ai_plugins_loaded () { global $ai_wp_data, $ai_total_plugin_time; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("PLUGINS LOADED START"); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } add_shortcode ('adinserter', 'ai_process_shortcodes'); add_shortcode ('ADINSERTER', 'ai_process_shortcodes'); // TO DO: check referrer add_filter ('pre_do_shortcode_tag', 'ai_pre_do_shortcode_tag', 10, 4); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("PLUGINS LOADED END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } } function ai_init_hook () { global $block_object, $ai_wp_data, $ai_db_options_extract, $ai_total_plugin_time; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("INIT HOOK START"); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } if ($ai_wp_data [AI_DISABLE_TRANSLATION]) { unload_textdomain ('ad-inserter'); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("TRANSLATION UNLOADED"); } } require_once AD_INSERTER_PLUGIN_DIR.'strings.php'; if (defined ('DOING_AJAX') && DOING_AJAX) { $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_AJAX; ai_load_extract (); ai_wp_hook (); } if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { if ($ai_wp_data [AI_ADB_DETECTION]) { if (function_exists ('ai_check_files')) ai_check_files (); } } // add_shortcode ('adinserter', 'ai_process_shortcodes'); // add_shortcode ('ADINSERTER', 'ai_process_shortcodes'); // // TO DO: check referrer // add_filter ('pre_do_shortcode_tag', 'ai_pre_do_shortcode_tag', 10, 4); // if (defined ('AI_BUFFERING')) { // if (get_output_buffering ()) { // if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { // ai_buffering_start (); // } // } // } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("INIT HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } } //function ai_upgrader_process_complete_hook ($upgrader_object, $options) { // global $ai_db_options, $ai_db_options_extract; // if (is_array ($options) && array_key_exists ('action', $options) && $options ['action'] == 'update' && array_key_exists ('type', $options)) { // if ($options ['type'] == 'plugin' && array_key_exists ('plugins', $options) && is_array ($options ['plugins']) && !empty ($options ['plugins'])) { // $this_plugin = plugin_basename (__FILE__); // foreach ($options ['plugins'] as $plugin) { // if ($plugin == $this_plugin) { // if (defined ('AI_EXTRACT_GENERATED') && isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'])) { // $ai_db_options [AI_OPTION_EXTRACT] = $ai_db_options_extract; // ai_update_option (AI_OPTION_NAME, $ai_db_options); // } // break; // } // } // } // } //} function ai_load_extract ($recreate = true) { global $ai_db_options, $ai_db_options_extract, $version_string, $subversion_string; if (isset ($ai_db_options_extract)) return true; $expected_extract_version = $version_string . $subversion_string . '-' . '96'; if (function_exists ('ai_system_output_check')) { $expected_extract_version .= 'P'; } if (isset ($ai_db_options [AI_OPTION_EXTRACT]['VERSION']) && $ai_db_options [AI_OPTION_EXTRACT]['VERSION'] == $expected_extract_version) { $ai_db_options_extract = $ai_db_options [AI_OPTION_EXTRACT]; return true; } else { if (($saved_extract = get_option (AI_EXTRACT_NAME)) === false || $saved_extract ['VERSION'] != $expected_extract_version) { if ($recreate) { $ai_db_options_extract = ai_generate_extract ($ai_db_options); $ai_db_options [AI_OPTION_EXTRACT] = $ai_db_options_extract; if (get_option (AI_OPTION_NAME) !== false && !defined ('AI_LOADED_REMOTE_SETTINGS')) { update_option (AI_EXTRACT_NAME, $ai_db_options_extract); } return true; } } else { $ai_db_options_extract = $saved_extract; $ai_db_options [AI_OPTION_EXTRACT] = $ai_db_options_extract; return true; } } return false; } function ai_wp_loaded_hook () { global $ai_total_plugin_time, $ai_wp_data; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("WP LOADED HOOK START"); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } ai_load_extract (); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } if (defined ('AI_EXTRACT_GENERATED')) ai_log ("EXTRACT GENERATED"); ai_log ("WP LOADED HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } } function ai_admin_menu_hook () { global $ai_settings_page; if (is_multisite() && !is_main_site () && !multisite_settings_page_enabled ()) return; $menu_position = get_menu_position (); if (isset ($_POST [AI_FORM_SAVE])) { if (isset ($_POST ['menu-for-link'])) { $menu_position = $_POST ['menu-for-link']; } else $menu_position = DEFAULT_MENU_FOR_LINK; } if ($menu_position == AI_SETTINGS_SUBMENU) { // translators: %s: Ad Inserter $ai_settings_page = add_submenu_page ('options-general.php', sprintf (__('%s Settings', 'ad-inserter'), AD_INSERTER_NAME), AD_INSERTER_NAME, 'manage_options', basename (__FILE__), 'ai_settings', defined ('AI_SETTINGS_MENU_PRIORITY') ? AI_SETTINGS_MENU_PRIORITY : DEFAULT_SETTINGS_SUBMENU_PRIORITY); } else { // translators: %s: Ad Inserter $ai_settings_page = add_menu_page (sprintf (__('%s Settings', 'ad-inserter'), AD_INSERTER_NAME), AD_INSERTER_NAME, 'manage_options', basename (__FILE__), 'ai_settings', 'dashicons-layout', defined ('AI_SETTINGS_MENU_PRIORITY') ? AI_SETTINGS_MENU_PRIORITY : DEFAULT_SETTINGS_MENU_PRIORITY); } add_action ('admin_enqueue_scripts', 'ai_admin_enqueue_scripts'); add_action ('admin_enqueue_scripts', 'ai_admin_enqueue_scripts_late', 99999); add_action ('admin_enqueue_scripts', 'ai_admin_remove_scripts', 99999); add_action ('admin_head', 'ai_admin_head'); add_filter ('clean_url', 'ai_clean_url', 999999, 2); } function ai_admin_head () { global $ai_settings_page, $hook_suffix; if ($hook_suffix == $ai_settings_page && wp_is_mobile()) { echo '', PHP_EOL; } } function ai_admin_enqueue_scripts ($hook_suffix) { global $ai_settings_page, $ai_admin_translations; if ($hook_suffix == $ai_settings_page) { wp_enqueue_style ('ai-admin-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), array (), null); wp_enqueue_style ('ai-colorpicker-css', plugins_url ('includes/colorpicker/css/bootstrap-colorpicker.min.css', AD_INSERTER_FILE), array (), AD_INSERTER_VERSION); if (function_exists ('ai_admin_enqueue_scripts_1')) ai_admin_enqueue_scripts_1 (); wp_enqueue_style ('ai-admin-multi-select', plugins_url ('css/multi-select.css', AD_INSERTER_FILE), array (), AD_INSERTER_VERSION); wp_enqueue_style ('ai-image-picker', plugins_url ('css/image-picker.css', __FILE__), array (), AD_INSERTER_VERSION); wp_add_inline_style ('ai-image-picker', '.thumbnail {border-radius: 6px;}'); wp_enqueue_style ('ai-combobox-css', plugins_url ('css/jquery.scombobox.min.css', __FILE__), array (), AD_INSERTER_VERSION); if (function_exists ('ai_admin_enqueue_scripts_2')) ai_admin_enqueue_scripts_2 (); wp_enqueue_script ('ai-colorpicker-js', plugins_url ('includes/colorpicker/js/bootstrap-colorpicker.min.js', AD_INSERTER_FILE ), array (), AD_INSERTER_VERSION, true); wp_enqueue_script ('ai-multi-select', plugins_url ('includes/js/jquery.multi-select.js', AD_INSERTER_FILE ), array (), AD_INSERTER_VERSION, true); wp_enqueue_script ('ai-quicksearch', plugins_url ('includes/js/jquery.quicksearch.js', AD_INSERTER_FILE ), array (), AD_INSERTER_VERSION, true); // Located in the header to load datepicker js file to prevent error when async tags used wp_enqueue_script ('ai-image-picker-js', plugins_url ('includes/js/image-picker.min.js', __FILE__ ), array ( 'jquery', 'jquery-ui-datepicker', ), AD_INSERTER_VERSION, false); if (AI_SYNTAX_HIGHLIGHTING && !defined ('AI_SAFE_MODE')) { wp_enqueue_script ('ai-ace', plugins_url ('includes/ace/ace.js', __FILE__ ), array (), AD_INSERTER_VERSION, true); // wp_enqueue_script ('ai-ace-ext-modelist', plugins_url ('includes/ace/ext-modelist.js', __FILE__ ), array (), AD_INSERTER_VERSION, true); wp_enqueue_script ('ai-ace-html', plugins_url ('includes/ace/mode-html.js', __FILE__ ), array (), AD_INSERTER_VERSION, true); wp_enqueue_script ('ai-ace-php', plugins_url ('includes/ace/mode-php.js', __FILE__ ), array (), AD_INSERTER_VERSION, true); if (get_syntax_highlighter_theme () == AI_SYNTAX_HIGHLIGHTER_THEME || isset ($_POST ["syntax-highlighter-theme"]) && $_POST ["syntax-highlighter-theme"] == AI_SYNTAX_HIGHLIGHTER_THEME) wp_enqueue_script ('ai-ace-theme', plugins_url ('includes/ace/theme-ad_inserter.js', __FILE__ ), array (), AD_INSERTER_VERSION, true); } wp_enqueue_script ('ai-combobox', plugins_url ('includes/js/jquery.scombobox.min.js', __FILE__), array ( 'jquery', ), AD_INSERTER_VERSION , true); $admin_script = get_backend_javascript_debugging () ? 'js/ad-inserter.js' : 'js/ad-inserter.min.js'; wp_enqueue_script ('ai-admin', plugins_url ($admin_script, __FILE__), array ( 'jquery', 'jquery-ui-tabs', 'jquery-ui-button', 'jquery-ui-tooltip', 'jquery-ui-datepicker', 'jquery-ui-dialog', ), AD_INSERTER_VERSION, true); wp_localize_script ('ai-admin', 'ai_admin', $ai_admin_translations); wp_enqueue_script ('ai-missed', plugins_url ('includes/js/missed.js', __FILE__), array (), AD_INSERTER_VERSION , true); } wp_enqueue_style ('ai-admin-gen', plugins_url ('css/ai-admin.css', __FILE__), array (), AD_INSERTER_VERSION); wp_enqueue_script ('ai-admin-gen', plugins_url ('includes/js/ai-admin.js', __FILE__ ), array (), AD_INSERTER_VERSION, true); } function ai_admin_enqueue_scripts_late ($hook_suffix) { global $ai_settings_page; if ($hook_suffix == $ai_settings_page) { // wp_enqueue_style ('ai-admin', plugins_url ('css/ad-inserter.css', __FILE__), array (), AD_INSERTER_VERSION); wp_enqueue_style ('ai-admin', plugins_url ('css/ai-settings.css', __FILE__), array (), AD_INSERTER_VERSION); wp_add_inline_style ('ai-admin', '.notice {margin: 5px 15px 15px 0;}'); } } function ai_admin_remove_scripts ($hook_suffix) { global $ai_settings_page; if ($hook_suffix == $ai_settings_page) { // Prevent converting emojis to images remove_action ('admin_print_scripts', 'print_emoji_detection_script'); // Fix for Publisher theme: remove scripts loaded on Ad Inserter admin page wp_deregister_script ('ace-editor-script'); wp_dequeue_script ('publisher-admin'); // Fix for Shell ClubSmart theme (titan framework) wp_dequeue_script ('tf-ace'); // Default settings wp_dequeue_script ('tf-ace-theme-chrome'); wp_dequeue_script ('tf-ace-mode-css'); // Fix for JNews theme wp_dequeue_style ('global-admin'); wp_dequeue_style ('selectize'); wp_dequeue_style ('select2'); wp_dequeue_style ('tooltipster'); wp_dequeue_style ('jnews-admin'); wp_dequeue_style ('vex'); // Fix for OptimizePress plugin: remove styles loaded on Ad Inserter admin page wp_dequeue_style ('optimizepress-admin-assets'); wp_dequeue_style ('optimizepress-admin-common'); wp_dequeue_style ('optimizepress-tiny-mce-css'); wp_dequeue_style ('optimizepress-dashicons'); // Fix for WP Nav Manager plugin: remove styles loaded on Ad Inserter admin page wp_dequeue_style ('wp-nav-manager-admin-style'); // Fix for Booking.com Product Helper plugin: remove styles loaded on Ad Inserter admin page wp_dequeue_style ('bookingcom-product-helper-css'); // Fix for WP BotWatch plugin: remove styles loaded on Ad Inserter admin page wp_dequeue_style ('wp-botwatch'); // Fix for All in One Schema.org Rich Snippets plugin: remove styles loaded on Ad Inserter admin page wp_dequeue_style ('admin_style'); wp_deregister_style ('admin_style'); // Fix for ACF for AMP plugin: remove styles loaded on Ad Inserter admin page wp_dequeue_style ('amp-acf-admin'); wp_deregister_style ('amp-acf-admin'); wp_dequeue_script ('ace_code_highlighter_js'); wp_dequeue_script ('ace_mode_js'); wp_dequeue_script ('custom_css_js'); wp_dequeue_script ('field-creator'); wp_dequeue_script ('amp_acf_field'); // Fix for WP Lightbox 2 plugin: remove styles loaded on Ad Inserter admin page wp_dequeue_style ('jquery-ui-style'); wp_deregister_style ('jquery-ui-style'); // Fix for Widget Options plugin: remove styles loaded on Ad Inserter admin page wp_dequeue_style ('widgetopts-jquery-ui'); wp_deregister_style ('widgetopts-jquery-ui'); } } function ai_set_footer_inline_scripts () { global $ai_wp_data; $adb_code = defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION] && !isset ($ai_wp_data [AI_ADB_SHORTCODE_DISABLED]); // Check again later in the footer $ai_wp_data [AI_FOOTER_INLINE_SCRIPTS] = get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW || get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT || // alerady in $ai_wp_data [AI_CLIENT_SIDE_INSERTION] isset ($ai_wp_data [AI_CLIENT_SIDE_ROTATION]) || ($ai_wp_data [AI_TRACKING] && !isset ($ai_wp_data [AI_TRACKING_SHORTCODE_DISABLED])) || $ai_wp_data [AI_STICKY_WIDGETS] || $ai_wp_data [AI_STICK_TO_THE_CONTENT] || $ai_wp_data [AI_ANIMATION] || $ai_wp_data [AI_CLOSE_BUTTONS] || $ai_wp_data [AI_HTML_ELEMENT_SELECTION] || $ai_wp_data [AI_LAZY_LOADING] || $ai_wp_data [AI_CLIENT_SIDE_INSERTION] || $adb_code || ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_BLOCKS | AI_DEBUG_POSITIONS)) != 0 || $ai_wp_data [AI_FRONTEND_JS_DEBUGGING] || $ai_wp_data [AI_CHECK_BLOCK] || $ai_wp_data [AI_CLIENT_SIDE_FILTER_CHECKS] || $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] != ''; } function ai_wp_enqueue_scripts_hook () { global $ai_wp_data, $wp_version, $wp_scripts, $ai_front_translations; // TEST // wp_deregister_script ('jquery'); ai_set_footer_inline_scripts (); if (!wp_script_is ('jquery', 'registered') && !wp_script_is ('jquery', 'printed')) { $ai_wp_data [AI_NO_JQUERY_CODE] = true; } if ($ai_wp_data [AI_FOOTER_INLINE_SCRIPTS] || ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_BLOCKS)) != 0 || !empty ($_GET) || get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 || $ai_wp_data [AI_ANIMATION]) { // Need jQuery: // $ai_wp_data [AI_HTML_ELEMENT_SELECTION] if (!$ai_wp_data [AI_NO_JQUERY_CODE]) { // Load jQuery on frontend when needed if (!get_wait_for_jquery () && isset ($wp_scripts->registered ['jquery'])) { wp_enqueue_script ('jquery'); } } if ($ai_wp_data [AI_HTML_ELEMENT_SELECTION] && !$ai_wp_data [AI_NO_JQUERY_CODE]) { wp_enqueue_script ('ai-jquery-js', plugins_url ('includes/js/ai-jquery.js', __FILE__), array ('jquery', 'jquery-ui-button'), $wp_version . '+' . AD_INSERTER_VERSION); wp_enqueue_style ('ai-html-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), array (), null); } if (!get_disable_css_code () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0)) { wp_enqueue_style ('dashicons'); if (get_remote_debugging () && isset ($_GET [AI_URL_DEBUG]) && $_GET [AI_URL_DEBUG]) { wp_enqueue_style ('ai-dashicons', includes_url ('css/dashicons.min.css'), array (), $wp_version); wp_enqueue_style ('ai-admin-bar', includes_url ('css/admin-bar.min.css'), array (), $wp_version); } } if (!get_disable_js_code () && $ai_wp_data [AI_ANIMATION]) { if (defined ('AI_STICKY_SETTINGS') && AI_STICKY_SETTINGS) { wp_enqueue_style ('ai-aos', plugins_url ('includes/aos/ai-aos.css', __FILE__), array (), AD_INSERTER_VERSION); wp_enqueue_script ('ai-aos-js', plugins_url ('includes/aos/aos.js', AD_INSERTER_FILE ), array (), AD_INSERTER_VERSION, true); } } } } function ai_clean_url ( $url, $original_url){ if (strpos ($url, 'async=') !== false && strpos ($url, '/plugins/ad-inserter') !== false) { // $url = $original_url; $url = str_replace ("' async='async", '', $url); } return $url; } function ai_get_client_side_styles () { return ".ai-rotate {position: relative;}\n" . ".ai-rotate-hidden {visibility: hidden;}\n" . ".ai-rotate-hidden-2 {position: absolute; top: 0; left: 0; width: 100%; height: 100%;}\n" . ".ai-list-data, .ai-ip-data, .ai-filter-check, .ai-fallback, .ai-list-block, .ai-list-block-ip, .ai-list-block-filter {".AI_ALIGNMENT_CSS_HIDDEN_LIST."}\n" . ".ai-list-data, .ai-ip-data, .ai-filter-check, .ai-fallback {min-width: 1px;}\n" . ""; } function ai_get_admin_toolbar_debugging_styles () { global $ai_wp_data; $css = ''; if (((get_admin_toolbar_debugging () && ((get_remote_debugging () && $ai_wp_data [AI_WP_DEBUGGING] != 0) || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)) || defined ('AI_DEBUGGING_DEMO')) && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { $css .= "#wp-admin-bar-ai-toolbar-settings .ab-icon:before { content: '\\f538'; top: 2px; color: rgba(240,245,250,.6)!important; } #wp-admin-bar-ai-toolbar-settings-default .ab-icon:before { top: 0px; } #wp-admin-bar-ai-toolbar-settings .ab-icon.on:before { color: #00f200!important; } #wp-admin-bar-ai-toolbar-settings .ab-icon.red:before { color: #f22!important; } #wp-admin-bar-ai-toolbar-settings-default li, #wp-admin-bar-ai-toolbar-settings-default a, #wp-admin-bar-ai-toolbar-settings-default li:hover, #wp-admin-bar-ai-toolbar-settings-default a:hover { border: 1px solid transparent; } ul li#wp-admin-bar-ai-toolbar-status { margin: 0 0 5px 0; } #wp-admin-bar-ai-toolbar-blocks .ab-icon:before { content: '\\f135'; } #wp-admin-bar-ai-toolbar-positions .ab-icon:before { content: '\\f207'; } #wp-admin-bar-ai-toolbar-positions-default .ab-icon:before { content: '\\f522'; } #wp-admin-bar-ai-toolbar-tags .ab-icon:before { content: '\\f475'; } #wp-admin-bar-ai-toolbar-no-insertion .ab-icon:before { content: '\\f214'; } #wp-admin-bar-ai-toolbar-adb-status .ab-icon:before { content: '\\f223'; } #wp-admin-bar-ai-toolbar-adb .ab-icon:before { content: '\\f160'; } #wp-admin-bar-ai-toolbar-processing .ab-icon:before { content: '\\f464'; } #wp-admin-bar-ai-toolbar-processing-fe .ab-icon:before { content: '\\f464'; } #wp-admin-bar-ai-toolbar-positions span.up-icon { padding-top: 2px; } #wp-admin-bar-ai-toolbar-positions .up-icon:before { font: 400 20px/1 dashicons; } .ai-insertion-status { line-height: 26px!important; height: 26px!important; white-space: nowrap; min-width: 140px; } #wp-admin-bar-ai-toolbar-settings .ab-sub-wrapper { width: max-content; width: -moz-max-content; } "; } if (get_admin_toolbar_mobile () && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { $css .= "@media screen and (max-width: 782px) { #wpadminbar #wp-admin-bar-ai-toolbar-settings { display: block; position: static; } #wpadminbar #wp-admin-bar-ai-toolbar-settings > .ab-item { white-space: nowrap; overflow: hidden; width: 52px; padding: 0; color: #a0a5aa; position: relative; } #wpadminbar .quicklinks .menupop ul li .ab-item, #wpadminbar .quicklinks .menupop.hover ul li .ab-item { min-height: 28px; } } "; } return $css; } function add_head_inline_styles () { global $ai_wp_data; if (get_disable_css_code ()) return; // Needed for iframes? $ai_wp_data [AI_CODE_FOR_IFRAME] $debugging = $ai_wp_data [AI_WP_DEBUGGING] != 0 || (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) && (isset ($_GET [AI_URL_DEBUG_PROCESSING_FE]) && $_GET [AI_URL_DEBUG_PROCESSING_FE] != 0 || isset ($_GET [AI_URL_DEBUG_CODE])); if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] || get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW || isset ($ai_wp_data [AI_CLIENT_SIDE_ROTATION]) || $ai_wp_data [AI_CLOSE_BUTTONS] || $ai_wp_data [AI_PARALLAX] || $ai_wp_data [AI_HTML_ELEMENT_SELECTION] || !get_inline_styles () || get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) || $debugging) { echo "\n"; } } function ai_get_js ($js_name, $replace_js_data = true) { global $ai_wp_data; $jq_js_name = $js_name . '.q'; if (!$ai_wp_data [AI_NO_JQUERY_CODE] && file_exists (AD_INSERTER_PLUGIN_DIR."includes/js/{$jq_js_name}.js")) { $js_name = $jq_js_name; } if ($ai_wp_data [AI_FRONTEND_JS_DEBUGGING] || !file_exists (AD_INSERTER_PLUGIN_DIR."includes/js/$js_name.min.js")) { $script = @file_get_contents (AD_INSERTER_PLUGIN_DIR."includes/js/$js_name.js"); } else $script = @file_get_contents (AD_INSERTER_PLUGIN_DIR."includes/js/$js_name.min.js"); $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; if ($debug_processing) ai_log ('LOADING JS CODE: '. $js_name); if (!$replace_js_data) return $script; return ai_replace_js_data ($script); } function ai_randomize_properties ($style, $z_index_min = null, $z_index_max = null) { $style = str_replace (''', '\'', $style); $style_array = explode (';', trim ($style, ';')); foreach ($style_array as $index => $property) { $property = trim ($property); if ($z_index_min != null && $z_index_max != null && strpos ($property, 'z-index') === 0) { $style_array [$index] = 'z-index: ' . rand ($z_index_min, $z_index_max); } if (strpos ($property, 'opacity') === 0) { $value = str_replace (array ('opacity', ':', ' ', ';'), '', $property); if (is_numeric ($value)) { $value = 100 * $value - 5 + rand (0, 10); if ($value > 100) $value = 100; $style_array [$index] = 'opacity: ' . ($value / 100); } } elseif (strpos ($property, '50%') !== false) { $style_array [$index] = str_replace ('50%', (47 + rand (0, 6)) . '.' . rand (1, 99) . '%', $style_array [$index]); } elseif (strpos ($property, '100%') !== false) { $style_array [$index] = str_replace ('100%', '100.' . rand (1, 99) . '%', $style_array [$index]); } elseif (strpos ($property, '#000') !== false) { $color = rand (0, 2) . rand (0, 9); $style_array [$index] = str_replace ('#000', '#' . $color . $color . $color, $style_array [$index]); } } shuffle ($style_array); return trim (implode ('; ', $style_array)) . ';'; } function ai_replace_js_data ($js) { global $block_object, $ai_wp_data; if (preg_match_all ('/AI_CONST_([_A-Z0-9]+)/', $js, $match)) { foreach ($match [1] as $index => $constant) { if (defined ($constant)) $js = str_replace ($match [0][$index], constant ($constant), $js); } } if (preg_match_all ('/AI_DATA_([_A-Z0-9]+)/', $js, $match)) { foreach ($match [1] as $index => $constant) { if (defined ($constant) && isset ($ai_wp_data [constant ($constant)])) $js = str_replace ($match [0][$index], $ai_wp_data [constant ($constant)], $js); } } if (preg_match_all ('/AI_DATAB_([_A-Z0-9]+)/', $js, $match)) { foreach ($match [1] as $index => $constant) { if (defined ($constant) && isset ($ai_wp_data [constant ($constant)])) $js = str_replace ($match [0][$index], $ai_wp_data [constant ($constant)] ? 1 : 0, $js); } } if (preg_match_all ('/AI_DBG_([_A-Z0-9]+)/', $js, $match)) { foreach ($match [1] as $index => $constant) { if (defined ($constant)) $js = str_replace ($match [0][$index], ($ai_wp_data [AI_WP_DEBUGGING] & constant ($constant)) != 0 ? 1 : 0, $js); } } if (preg_match_all ('/AI_FUNC_([_A-Z0-9]+)/', $js, $match)) { foreach ($match [1] as $index => $function) { $function = strtolower ($function); if (function_exists ($function)) $js = str_replace ($match [0][$index], call_user_func ($function), $js); } } if (preg_match_all ('/AI_FUNCH_([_A-Z0-9]+)/', $js, $match)) { foreach ($match [1] as $index => $function) { $function = strtolower ($function); if (function_exists ($function)) $js = str_replace ($match [0][$index], html_entity_decode (call_user_func ($function)), $js); } } if (preg_match_all ('/AI_FUNCB_([_A-Z0-9]+)/', $js, $match)) { foreach ($match [1] as $index => $function) { $function = strtolower ($function); if (function_exists ($function)) $js = str_replace ($match [0][$index], call_user_func ($function) ? 1 : 0, $js); } } if (preg_match_all ('/AI_FUNCT_([_A-Z0-9]+)/', $js, $match)) { foreach ($match [1] as $index => $function) { $function = strtolower ($function); if (function_exists ($function)) $js = str_replace ($match [0][$index], call_user_func ($function, true), $js); } } if (preg_match_all ('/AI_POST_([_A-Z0-9]+)/', $js, $match)) { foreach ($match [1] as $index => $post) { $post_name = strtolower ($post); $js = str_replace ($match [0][$index], isset ($_POST [$post_name]) ? sanitize_text_field (urldecode ($_POST [$post_name])) : '', $js); } } if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { if (strpos ($js, 'AI_ADB_OVERLAY_WINDOW') !== false || strpos ($js, 'AI_ADB_MSG_HTML') !== false) { $adb = $block_object [AI_ADB_MESSAGE_OPTION_NAME]; $tags = array ('div', 'span', 'ins', 'section', 'kbd'); $message_tag = $tags [rand (0, count ($tags) - 1)]; $overlay_tag = $tags [rand (0, count ($tags) - 1)]; $basic_adb_overlay_css = AI_BASIC_ADB_OVERLAY_CSS; $basic_adb_message_css = AI_BASIC_ADB_MESSAGE_CSS; if (strpos ($js, 'AI_ADB_STATUS_MESSAGE') === false) { $basic_adb_overlay_css = str_replace ('pointer', 'no-drop', $basic_adb_overlay_css); $basic_adb_message_css = str_replace ('pointer', 'no-drop', $basic_adb_message_css); } // $overlay_code = "jQuery ('<".$overlay_tag.">', {attr: {'style': b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_overlay_css, 1110002, 9914998)) . ai_randomize_properties (get_overlay_css ())) . "')}})"; $overlay_code = "var e = document.createElement ('".$overlay_tag."'); e.style = b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_overlay_css, 1110002, 9914998)) . ai_randomize_properties (get_overlay_css ())) . "');"; for ($level = 1; $level <= 5; $level ++) { switch (rand (1, 10)) { case 1: case 2: case 3: case 4: $tag = 'div'; break; case 5: case 6: case 7: $tag = $tags [rand (0, count ($tags) - 1)]; break; default: continue 2; } // $overlay_code .= ".append (jQuery ('
    ')).append (jQuery ('
    ', {attr: {'style': b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_overlay_css, 100, 99999))) . "')}}))"; $overlay_code .= "var f = document.createElement ('div'); f.style = b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_overlay_css, 100, 99999))) . "');"; $overlay_code .= "e.append (f); e.append (document.createElement ('div'));"; // $overlay_code = "jQuery ('<".$tag.">').append (" . $overlay_code . ')'; $overlay_code .= "f = document.createElement ('".$tag."'); f.append (e); e = f;"; // if (rand (1, 10) > 5) $overlay_code .= ".append (jQuery ('
    ', {attr: {'style': b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_overlay_css, 100, 99999))) . "')}}))"; if (rand (1, 10) > 5) $overlay_code .= "var f = document.createElement ('div'); f.style = b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_overlay_css, 100, 99999))) . "'); e.append (f);"; // if (rand (1, 10) > 5) $overlay_code .= ".append (jQuery ('
    '))"; if (rand (1, 10) > 5) $overlay_code .= "e.append (document.createElement ('div'));"; // if (rand (1, 10) > 5) $overlay_code .= ".prepend (jQuery ('
    ', {attr: {'style': b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_overlay_css, 100, 99999))) . "')}}))"; if (rand (1, 10) > 5) $overlay_code .= "var f = document.createElement ('div'); f.style = b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_overlay_css, 100, 99999))) . "'); e.prepend (f);"; // if (rand (1, 10) > 5) $overlay_code .= ".prepend (jQuery ('
    '))"; if (rand (1, 10) > 5) $overlay_code .= "e.prepend (document.createElement ('div'));"; } $overlay_code = '(function () {' . $overlay_code . ' return e;})()'; $js = str_replace ('AI_ADB_OVERLAY_WINDOW', $overlay_code, $js); $message_code = "jQuery ('<".$message_tag.">', {attr: {'style': b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_message_css, 96610999, 99919998)) . ai_randomize_properties (get_message_css ())) . "')}, 'html': b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), do_shortcode ($adb->ai_getCode ()))) . "')})"; $message_code = "var e = document.createElement ('".$message_tag."'); e.style = b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_message_css, 96610999, 99919998)) . ai_randomize_properties (get_message_css ())) . "');"; $message_code .= "e.innerHTML = b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), do_shortcode ($adb->ai_getCode ()))) . "');"; for ($level = 1; $level <= 5; $level ++) { switch (rand (1, 10)) { case 1: case 2: case 3: $tag = 'div'; break; case 4: case 5: $tag = 'p'; break; case 6: case 7: $tag = $tags [rand (0, count ($tags) - 1)]; break; default: continue 2; } // $message_code .= ".append (jQuery ('

    ')).append (jQuery ('

    ', {attr: {'style': b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_message_css, 10000, 999999))) . "')}}))"; $message_code .= "var f = document.createElement ('div'); f.style = b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_message_css, 10000, 999999))) . "');"; $message_code .= "e.append (document.createElement ('p')); e.append (f);"; // $message_code = "jQuery ('<".$tag.">').append (" . $message_code . ')'; $message_code .= "f = document.createElement ('".$tag."'); f.append (e); e = f;"; // if (rand (1, 10) > 7) $message_code .= ".append (jQuery ('
    ', {attr: {'style': b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_message_css, 10000, 999999))) . "')}}))"; if (rand (1, 10) > 7) $message_code .= "var f = document.createElement ('div'); f.style = b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_message_css, 10000, 999999))) . "'); e.append (f);"; // if (rand (1, 10) > 7) $message_code .= ".append (jQuery ('

    '))"; if (rand (1, 10) > 7) $message_code .= "e.append (document.createElement ('p'));"; // if (rand (1, 10) > 7) $message_code .= ".prepend (jQuery ('

    ', {attr: {'style': b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_message_css, 10000, 999999))) . "')}}))"; if (rand (1, 10) > 7) $message_code .= "var f = document.createElement ('div'); f.style = b64d ('" . base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_message_css, 10000, 999999))) . "'); e.prepend (f);"; // if (rand (1, 10) > 7) $message_code .= ".prepend (jQuery ('

    '))"; if (rand (1, 10) > 7) $message_code .= "e.prepend (document.createElement ('p'));"; // if (rand (1, 10) > 3) $message_code .= ".prepend (jQuery ('

    '))"; if (rand (1, 10) > 3) $message_code .= "e.prepend (document.createElement ('p'));"; } $message_code = '(function () {' . $message_code . ' return e;})()'; $js = str_replace ('AI_ADB_MESSAGE_WINDOW', $message_code, $js); // $js = str_replace ('AI_ADB_MSG_HTML', base64_encode (str_replace (array ("\r", "\n"), array ('', ''), do_shortcode ($adb->ai_getCode ()))), $js); $js = str_replace ('AI_ADB_MSG_HTML', str_replace (array ("\r", "\n", '"'), array ('', '', '"'), preg_replace ( '@<(script|style)[^>]*?'.'>.*?@si', '', do_shortcode ($adb->ai_getCode ()))), $js); // $js = str_replace ('AI_ADB_MSG_STYLE', base64_encode (str_replace (array ("\r", "\n"), array ('', ''), ai_randomize_properties ($basic_adb_message_css, 100000, 9999999) . ai_randomize_properties (get_message_css ()))), $js); $js = str_replace ('AI_ADB_MSG_STYLE', str_replace (array ("\r", "\n", '"'), array ('', '', '"'), ai_randomize_properties ($basic_adb_message_css, 100000, 9999999) . ai_randomize_properties (get_message_css ())), $js); switch (rand (1, 20)) { case 1: $message_tag = 'section'; break; case 2: $message_tag = 'article'; break; case 3: $message_tag = 'span'; break; case 4: $message_tag = 'header'; break; case 5: $message_tag = 'footer'; break; case 6: $message_tag = 'nav'; break; case 7: $message_tag = 'aside'; break; case 8: $message_tag = 'h5'; break; case 9: $message_tag = 'h6'; break; default: $message_tag = 'div'; break; } $js = str_replace ('AI_ADB_MSG_TAG', $message_tag, $js); $js_name_node = 'n'.rand (10000, 10000000); $js_name_index = 'i'.rand (10000, 10000000); $html_tags = array (); if (rand (1, 10) > 3) $html_tags []= 'DIV'; if (rand (1, 10) > 4) $html_tags []= 'P'; if (rand (1, 10) > 5) $html_tags []= 'SPAN'; if (rand (1, 10) > 5) $html_tags []= 'A'; if (rand (1, 10) > 5) $html_tags []= 'ARTICLE'; if (rand (1, 10) > 5) $html_tags []= 'H1'; if (rand (1, 10) > 5) $html_tags []= 'H2'; if (rand (1, 10) > 5) $html_tags []= 'H3'; if (rand (1, 10) > 5) $html_tags []= 'H4'; if (rand (1, 10) > 5) $html_tags []= 'H5'; if (rand (1, 10) > 5) $html_tags []= 'H6'; if (rand (1, 10) > 5) $html_tags []= 'BUTTON'; if (rand (1, 10) > 6) $html_tags []= 'IFRAME'; if (rand (1, 10) > 6) $html_tags []= 'HEADER'; if (rand (1, 10) > 5) $html_tags []= 'FOOTER'; if (rand (1, 10) > 7) $html_tags []= 'UL'; if (rand (1, 10) > 7) $html_tags []= 'OL'; if (rand (1, 10) > 5) $html_tags []= 'LI'; if (rand (1, 10) > 5) $html_tags []= 'NAV'; if (rand (1, 10) > 5) $html_tags []= 'SECTION'; if (rand (1, 10) > 5) $html_tags []= 'ASIDE'; if (empty ($html_tags)) $html_tags = array ('DIV, P, LI'); shuffle ($html_tags); switch (rand (1, 10)) { case 1: $js_code_1 = 'var '.$js_name_node.' = document.getElementsByTagName ("'. ($html_tags [0]) .'"); for (var '.$js_name_index.'=0; '.$js_name_index.' < '.$js_name_node.'.length; '.$js_name_index.'++) {'; break; default: $js_code_1 = 'var '.$js_name_node.' = document.body.querySelectorAll ("'.(implode (', ', $html_tags)).'"); for (var '.$js_name_index.'=0; '.$js_name_index.' < '.$js_name_node.'.length; '.$js_name_index.'++) {'; break; } $js_code_3 = '}'; $js_code_css = array (); if (rand (1, 10) > 2) $js_code_css []= 'style.filter = "blur('.rand (1, 4).'px) brightness('.rand (60, 80).'%)"'; if (rand (1, 10) > 4) $js_code_css []= 'style.cursor = "no-drop"'; if (rand (1, 10) > 3) $js_code_css []= 'style.cursor = "grab"'; if (rand (1, 10) > 5) $js_code_css []= 'style.cursor = "grabbing"'; if (rand (1, 10) > 6) $js_code_css []= 'style.cursor = "wait"'; if (rand (1, 10) > 7) $js_code_css []= 'style.cursor = "not-allowed"'; if (rand (1, 10) > 8) $js_code_css []= 'style.cursor = "cell"'; if (rand (1, 10) > 9) $js_code_css []= 'style.cursor = "all-scroll"'; if (rand (1, 10) > 2) $js_code_css []= 'style.background = "rgba('.rand (31, 55).', '.rand (31, 55).', '.rand (31, 55).', '.(rand (50, 80)/100).')"'; if (rand (1, 10) > 6) $js_code_css []= 'style.opacity = "0.'.rand (55, 84).'"'; if (rand (1, 10) > 6) $js_code_css []= 'style.zIndex = "'.rand (1, 12345).'"'; if (rand (1, 10) > 7) $js_code_css []= 'style.textTransform = "uppercase"'; if (rand (1, 10) > 8) $js_code_css []= 'style.letterSpacing = "'.rand (0, 5).'px"'; if (rand (1, 10) > 8) $js_code_css []= 'style.border = "'.rand (2, 25).'px solid"'; if (rand (1, 10) > 8) $js_code_css []= 'style.color = "rgba('.rand (1, 255).', '.rand (1, 255).', '.rand (1, 255).', '.(rand (20, 50)/100).')"'; if (rand (1, 10) > 6) $js_code_css []= 'style.fontFamily = "sans-serif"'; if (rand (1, 10) > 7) $js_code_css []= 'style.fontFamily = "serif"'; if (rand (1, 10) > 8) $js_code_css []= 'style.fontFamily = "sans-serif"'; if (rand (1, 10) > 6) $js_code_css []= 'style.fontFamily = "arial"'; if (rand (1, 10) > 6) $js_code_css []= 'style.fontFamily = "monospace"'; if (rand (1, 10) > 8) $js_code_css []= 'style.visibility = "hidden"'; if (rand (1, 10) > 8) $js_code_css []= 'style.visibility = "collapse"'; if (rand (1, 10) > 9) $js_code_css []= 'style.display = "list-item"'; if (rand (1, 10) > 9) $js_code_css []= 'style.display = "inline"'; if (rand (1, 10) > 3) $js_code_css []= 'style.margin = "'.rand (500, 2345).'px"'; if (rand (1, 10) > 4) $js_code_css []= 'style.padding = "'.rand (500, 2345).'px"'; if (rand (1, 10) > 7) $js_code_css []= 'remove ()'; else if (rand (1, 10) > 7) $js_code_css []= 'parentNode.removeChild (@@)'; $js_code_2 = ''; foreach ($js_code_css as $js_code_css_line) { $js_code_css_line = str_replace ('@@', $js_name_node.'['.$js_name_index.']', $js_code_css_line); $js_code_2 .= $js_name_node.'['.$js_name_index.'].'.$js_code_css_line.';'; } // $js = str_replace ('AI_ADB_HTML', base64_encode ($js_code_1.$js_code_2.$js_code_3), $js); // $js = str_replace ('var AI_ADB_HTML=1;', $js_code_1.$js_code_2.$js_code_3, $js); $js = str_replace ('AI_ADB_HTML=1;', $js_code_1.$js_code_2.$js_code_3, $js); $body_js_code = ''; if (rand (1, 10) > 5) $body_js_code .= 'document.body.style.background = "rgba('.rand (11, 35).', '.rand (11, 35).', '.rand (11, 35).', '.(rand (60, 90)/100).')";'; if (rand (1, 10) > 6) $body_js_code .= 'document.body.style.backgroundColor = "rgba('.rand (21, 45).', '.rand (21, 45).', '.rand (21, 45).', '.(rand (60, 90)/100).')";'; if (rand (1, 10) > 6) $body_js_code .= 'document.body.style.margin = "'.rand (400, 4345).'px";'; // $js = str_replace ('var AI_ADB_HTML=2;', $body_js_code, $js); $js = str_replace ('AI_ADB_HTML=2', $body_js_code, $js); $js = str_replace ('AI_ADB_SELECTORS', get_adb_selectors (true), $js); $redirection_page = get_redirection_page (); if ($redirection_page != 0) $url = get_permalink ($redirection_page); else $url = trim (get_custom_redirection_url ()); $js = str_replace ('AI_ADB_REDIRECTION_PAGE', $url, $js); if (($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_AD_BLOCKING_STATUS | AI_DEBUG_POSITIONS | AI_DEBUG_BLOCKS)) != 0) { // translators: AD BLOCKING DETECTED, PAGE VIEWS: n - NO ACTION // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=1', '(jQuery("#ai-adb-status").text ("' . __('AD BLOCKING DETECTED, PAGE VIEWS', 'ad-inserter') . '" + ": " + window.ai_d1 + " - " + "' . __('NO ACTION', 'ad-inserter') . '"),jQuery("#ai-adb-bar").addClass ("adb-on"))', $js); // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=2', '(jQuery("#ai-adb-status").text ("' . __('AD BLOCKING DETECTED, COOKIE DETECTED - NO ACTION', 'ad-inserter') . '"),jQuery("#ai-adb-bar").addClass ("adb-on"))', $js); // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=3', '(jQuery("#ai-adb-status").text ("' . __('AD BLOCKING DETECTED - ACTION', 'ad-inserter') . '"),jQuery("#ai-adb-bar").addClass ("adb-on"))', $js); // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=4', '(jQuery("#ai-adb-status").text ("' . __('AD BLOCKING NOT DETECTED', 'ad-inserter') . '"),jQuery("#ai-adb-bar").addClass ("adb-off"))', $js); // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=5', '(jQuery("#ai-adb-status").text ("' . __('AD BLOCKING DETECTION COOKIES DELETED', 'ad-inserter') . '"))', $js); // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=6', '(jQuery("#ai-adb-status").text ("' . __('AD BLOCKING DETECTED - NO ACTION', 'ad-inserter') . '"),jQuery("#ai-adb-bar").addClass ("adb-on"))', $js); // translators: AD BLOCKING DETECTED, PAGE VIEWS: n - NO ACTION $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=1', 'if (document.querySelector("#ai-adb-status") != null) document.querySelector("#ai-adb-status").innerText = "' . __('AD BLOCKING DETECTED, PAGE VIEWS', 'ad-inserter') . '" + ": " + window.ai_d1 + " - " + "' . __('NO ACTION', 'ad-inserter') . '";if (document.querySelector("#ai-adb-bar") != null) document.querySelector("#ai-adb-bar").classList.add ("adb-on");', $js); $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=2', 'if (document.querySelector("#ai-adb-status") != null) document.querySelector("#ai-adb-status").innerText = "' . __('AD BLOCKING DETECTED, COOKIE DETECTED - NO ACTION', 'ad-inserter') . '"; if (document.querySelector("#ai-adb-bar") != null) document.querySelector("#ai-adb-bar").classList.add ("adb-on");', $js); $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=3', 'if (document.querySelector("#ai-adb-status") != null) document.querySelector("#ai-adb-status").innerText = "' . __('AD BLOCKING DETECTED - ACTION', 'ad-inserter') . '"; if (document.querySelector("#ai-adb-bar") != null) document.querySelector("#ai-adb-bar").classList.add ("adb-on");', $js); $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=4', 'if (document.querySelector("#ai-adb-status") != null) document.querySelector("#ai-adb-status").innerText = "' . __('AD BLOCKING NOT DETECTED', 'ad-inserter') . '"; if (document.querySelector("#ai-adb-bar") != null) document.querySelector("#ai-adb-bar").classList.add ("adb-off");', $js); $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=5', 'if (document.querySelector("#ai-adb-status") != null) document.querySelector("#ai-adb-status").innerText = "' . __('AD BLOCKING DETECTION COOKIES DELETED', 'ad-inserter') . '";', $js); $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=6', 'if (document.querySelector("#ai-adb-status") != null) document.querySelector("#ai-adb-status").innerText = "' . __('AD BLOCKING DETECTED - NO ACTION', 'ad-inserter') . '"; if (document.querySelector("#ai-adb-bar") != null) document.querySelector("#ai-adb-bar").classList.add ("adb-on");', $js); } else { // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=1', '(0)', $js); // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=2', '(0)', $js); // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=3', '(0)', $js); // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=4', '(0)', $js); // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=5', '(0)', $js); // $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=6', '(0)', $js); $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=1', '', $js); $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=2', '', $js); $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=3', '', $js); $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=4', '', $js); $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=5', '', $js); $js = str_replace ('window.AI_ADB_STATUS_MESSAGE=6', '', $js); } } } // $js = str_replace ('AI_ADB_ATTR_NAME', "b64d ('" . base64_encode ('data-'.(defined ('AI_ADB_ATTR') ? AI_ADB_ATTR : 'data-mask')) . "')", $js); $js = str_replace ('AI_ADB_ATTR_NAME', "'" . base64_encode ('data-'.(defined ('AI_ADB_ATTR') ? AI_ADB_ATTR : 'data-mask')) . "'", $js); $js = str_replace ('AI_NONCE', wp_create_nonce ("adinserter_data"), $js); $js = str_replace ('AI_AJAXURL', admin_url ('admin-ajax.php'), $js); $js = str_replace ('AI_SITE_URL', wp_make_link_relative (get_site_url()), $js); $js = str_replace ('AI_HOME_URL', home_url (), $js); if (defined ('AI_STATISTICS') && AI_STATISTICS) { $js = str_replace ('AI_INTERNAL_TRACKING', get_internal_tracking () == AI_ENABLED ? 1 : 0, $js); $js = str_replace ('AI_EXTERNAL_TRACKING', get_external_tracking () == AI_ENABLED ? 1 : 0, $js); $js = str_replace ('AI_DEBUG_TRACKING', isset ($_GET [AI_URL_DEBUG_TRACKING]) && $_GET [AI_URL_DEBUG_TRACKING] ? 1 : 0, $js); $js = str_replace ('AI_EXT_CATEGORY', get_external_tracking_category (), $js); $js = str_replace ('AI_EXT_ACTION', get_external_tracking_action (), $js); $js = str_replace ('AI_EXT_LABEL', get_external_tracking_label (), $js); $current_user = wp_get_current_user (); $wp_username = $current_user->user_login; $js = str_replace ('WP_USERNAME', $wp_username, $js); $js = str_replace ('AI_TRACK_PAGEVIEWS', get_track_pageviews () == AI_TRACKING_ENABLED && $ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME] ? 1 : 0, $js); $js = str_replace ('AI_ADVANCED_CLICK_DETECTION', get_click_detection () == AI_CLICK_DETECTION_ADVANCED ? 1 : 0, $js); if (!isset ($ai_wp_data [AI_VIEWPORT_WIDTHS])) { $viewport_data = array (); for ($viewport = 1; $viewport <= 6; $viewport ++) { $viewport_name = get_viewport_name ($viewport); $viewport_width = get_viewport_width ($viewport); if ($viewport_name != '') { $viewport_data []= array ('index' => $viewport, 'name' => $viewport_name, 'width' => $viewport_width); } } usort ($viewport_data, 'ai_compare_viewport'); $viewport_widthss = array (); $viewport_indexes = array (); $viewport_names = array (); foreach ($viewport_data as $viewport) { $viewport_widthss []= $viewport ['width']; $viewport_indexes []= $viewport ['index']; $viewport_names []= $viewport ['name']; } $ai_wp_data [AI_VIEWPORT_WIDTHS] = $viewport_widthss; $ai_wp_data [AI_VIEWPORT_INDEXES] = $viewport_indexes; $ai_wp_data [AI_VIEWPORT_NAMES] = $viewport_names; } $js = str_replace ('AI_VIEWPORT_WIDTHS', '[' . implode (',', $ai_wp_data [AI_VIEWPORT_WIDTHS]) . ']', $js); $js = str_replace ('AI_VIEWPORT_INDEXES', '[' . implode (',', $ai_wp_data [AI_VIEWPORT_INDEXES]) . ']', $js); $js = str_replace ('AI_VIEWPORT_NAMES', base64_encode ('["' . implode ('","', $ai_wp_data [AI_VIEWPORT_NAMES]) . '"]'), $js); } // Deprecated $js = str_replace ('AI_BLOCK_CLASS_NAME', get_block_class_name (true), $js); if (function_exists ('ai_replace_js_data_2')) ai_replace_js_data_2 ($js); else { $js = str_replace ('AI_ADB_CONTENT_CSS_BEGIN_CLASS', 'wp-slider0-pre90', $js); $js = str_replace ('AI_ADB_CONTENT_CSS_END_CLASS', 'wp-slider1-pre91', $js); $js = str_replace ('AI_ADB_CONTENT_DELETE_BEGIN_CLASS', 'wp-slider2-pre92', $js); $js = str_replace ('AI_ADB_CONTENT_DELETE_END_CLASS', 'wp-slider3-pre93', $js); $js = str_replace ('AI_ADB_CONTENT_REPLACE_BEGIN_CLASS', 'wp-slider4-pre94', $js); $js = str_replace ('AI_ADB_CONTENT_REPLACE_END_CLASS', 'wp-slider5-pre95', $js); $js = str_replace ('ai-adb-url', AD_INSERTER_PLUGIN_URL . 'js/', $js); } return $js; } function ai_adb_code () { return ai_get_js ('ai-adb', false); } //function ai_ao_override_js_replacetag ($replacetag) { // return array ("","replace"); //} function ai_adb_external_scripts () { $code = ''; // if (!defined ('AI_ADB_NO_DOUBLECLICK_NET')) { // $code .= '' . "\n"; // } if (!defined ('AI_ADB_NO_GOOGLE_ANALYTICS')) { $code .= '' . "\n"; } if (!defined ('AI_ADB_NO_MEDIA_NET')) { $code .= '' . "\n"; } if (!defined ('AI_ADB_NO_AMAZON-ADSYSTEM')) { $code .= '' . "\n"; } if (!defined ('AI_ADB_NO_QUANT')) { $code .= '' . "\n"; } return $code; } //function ai_replace_prefix ($js_code) { // if (!defined ('AI_ADB_PREFIX')) { // $seed = date ('Y-m-d H'); // $key = $seed.'AI_'; // if (defined ('NONCE_KEY')) { // $key .= NONCE_KEY; // } // if (defined ('AUTH_KEY')) { // $key .= AUTH_KEY; // $auth_key = $seed.AUTH_KEY; // } else $auth_key = $seed.'#AI_'; // define ('AI_ADB_PREFIX', substr (substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 ($seed.$auth_key))), 0, 4) . preg_replace ("/[^A-Za-z0-9]+/", '', strtolower (md5 ($seed.$key))), 0, 8) . '_'); // } //// return preg_replace ("/ai_/", AI_ADB_PREFIX, $js_code); // return preg_replace ("/ai_adb/", AI_ADB_PREFIX, $js_code); //} function add_footer_inline_scripts () { global $ai_wp_data, $wp_version; if (get_disable_js_code ()) return; $adb_code = defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION] && !isset ($ai_wp_data [AI_ADB_SHORTCODE_DISABLED]) && !$ai_wp_data [AI_WP_AMP_PAGE]; if ($adb_code) { if (function_exists ('add_footer_inline_scripts_1')) add_footer_inline_scripts_1 (); else { echo '', "\n"; echo '', "\n"; if (get_adb_external_scripts ()) { echo ai_adb_external_scripts (); } if (!defined ('AI_ADB_NO_BANNER_AD')) { echo '

    ', "\n"; } if (!defined ('AI_ADB_NO_ADS_JS')) { echo '', "\n"; } if (!defined ('AI_ADB_NO_SPONSORS_JS')) { echo '', "\n"; } if (!defined ('AI_ADB_NO_BANNER_JS')) { echo '', "\n"; } if (!defined ('AI_ADB_NO_300x250_JS')) { echo '', "\n"; } echo '', "\n"; echo '', "\n"; } } // Use updated flags ai_set_footer_inline_scripts (); $inline_js = ai_inline_js (); if ($ai_wp_data [AI_FOOTER_INLINE_SCRIPTS]) { if (!$inline_js) { echo '', "\n"; } echo "\n"; if (!$inline_js) { echo '', "\n"; } } if (!$inline_js) { if ($ai_wp_data [AI_FRONTEND_JS_DEBUGGING] || !file_exists (AD_INSERTER_PLUGIN_DIR."js/ai-functions.min.js")) { $script = 'ai-functions.js'; } else $script = 'ai-functions.min.js'; echo '', "\n"; } } function ai_admin_notice_hook () { global $current_screen, $ai_db_options, $ai_wp_data, $ai_db_options_extract; global $ai_settings_page, $hook_suffix; // $sidebar_widgets = wp_get_sidebars_widgets(); // $sidebars_with_deprecated_widgets = array (); // foreach ($sidebar_widgets as $sidebar_widget_index => $sidebar_widget) { // if (is_array ($sidebar_widget)) // foreach ($sidebar_widget as $widget) { // if (preg_match ("/ai_widget([\d]+)/", $widget, $widget_number)) { // if (isset ($widget_number [1]) && is_numeric ($widget_number [1])) { // $is_widget = $ai_db_options [$widget_number [1]][AI_OPTION_AUTOMATIC_INSERTION] == AD_SELECT_WIDGET; // } else $is_widget = false; // $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_widget_index]['name']; // if ($is_widget && $sidebar_name != "") // $sidebars_with_deprecated_widgets [$sidebar_widget_index] = $sidebar_name; // } // } // } // if (!empty ($sidebars_with_deprecated_widgets)) { // echo "

    Warning: You are using deprecated Ad Inserter widgets in the following sidebars: ", // implode (", ", $sidebars_with_deprecated_widgets), // ". Please replace them with the new 'Ad Inserter' code block widget. See FAQ for details.

    "; // } if (function_exists ('ai_admin_notices')) ai_admin_notices (); else { if (/*$hook_suffix == $ai_settings_page &&*/ is_super_admin () && !wp_is_mobile () && isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL])) { if (isset ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]) && is_string ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]) && strlen ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]) != 0) { $used_blocks = count (unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS])); } else $used_blocks = 0; $notice_option = get_option ('ai-notice-review'); if ($notice_option === false && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20) $notice_option = 'later'; if (($notice_option === false && $used_blocks >= 2 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 2) || ($notice_option == 'later' && $used_blocks >= 2 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20)) { if ($notice_option == 'later') { // Translators: 1: number of blocks, 2: Ad Inserter $message = sprintf (_n('Hey, you are now using %1$s %2$s block.', 'Hey, you are now using %1$s %2$s blocks.', $used_blocks, 'ad-inserter'), "{$used_blocks}", "Ad Inserter"); $option = '
    '; } else { // Translators: %s: Ad Inserter $message = sprintf (__("Hey, you are using %s and I hope you're happy with it.", 'ad-inserter'), 'Ad Inserter'); $option = ''; } ?>

    ', /* translators: 1: AMPforWP Plugin Manager, 2: Ad Inserter */ sprintf (__('Warning: %1$s %3$s disabled %4$s %2$s on AMP pages.', 'ad-inserter'), 'AMPforWP Plugin Manager', AD_INSERTER_NAME, '', ''), '

    '; } if (version_compare (phpversion (), "5.6", "<")) { echo '

    ', /* translators: 1: Ad Inserter, 2, 3: HTML tags */ sprintf (__('Warning: %1$s requires PHP 5.6 or newer. %2$s Please update! %3$s', 'ad-inserter'), AD_INSERTER_NAME, '', ''), '

    '; } if (defined ('AI_SETTINGS_ERROR')) { echo '

    ', /* translators: 1: Ad Inserter, 2, 3: HTML tags */ _e ('Error: plugin settings corrupt', 'ad-inserter'), '

    '; } } } function ai_plugin_action_links ($links) { if (is_multisite() && !is_main_site () && !multisite_settings_page_enabled ()) return $links; $settings_page = get_menu_position () == AI_SETTINGS_SUBMENU ? 'options-general.php?page=ad-inserter.php' : 'admin.php?page=ad-inserter.php'; $settings_link = ''._x('Settings', 'Menu item', 'ad-inserter') . ''; array_unshift ($links, $settings_link); return $links; } function ai_after_plugin_row_1 ($plugin_file, $plugin_data, $status) { global $ad_inserter_globals; if (ai_ampforwp_check_disabled ()) { $plugins_css = "\n" . ''."\n"; echo $plugins_css; echo '

    ', /* translators: 1: AMPforWP Plugin Manager, 2: Ad Inserter, 3, 4: HTML tags */ sprintf (__('Warning: %1$s %3$s disabled %4$s %2$s on AMP pages.', 'ad-inserter'), 'AMPforWP Plugin Manager', AD_INSERTER_NAME, '', ''), '

    '; } } function ai_set_plugin_meta ($links, $file) { if ($file == plugin_basename (__FILE__)) { if (is_multisite() && !is_main_site ()) { foreach ($links as $index => $link) { if (stripos ($link, "update") !== false) unset ($links [$index]); } } if (!is_multisite () || is_main_site ()) { $settings_page = get_menu_position () == AI_SETTINGS_SUBMENU ? 'options-general.php?page=ad-inserter.php' : 'admin.php?page=ad-inserter.php'; $inserted = '' . __('Safe mode', 'ad-inserter') . ''; array_splice ($links, 4, 0, $inserted); if (function_exists ('ai_set_plugin_meta_2')) { ai_set_plugin_meta_2 ($links); } elseif (file_exists (AD_INSERTER_PLUGIN_DIR.'includes/js/ai-load.js')) { $inserted = 'WP'; array_splice ($links, 1, 0, $inserted); } } } return $links; } function current_user_role ($user_role_name = "") { $role_values = array ("super-admin" => 6, "administrator" => 5, "editor" => 4, "author" => 3, "contributor" => 2, "subscriber" => 1); global $wp_roles; if ($user_role_name != "") { return isset ($role_values [$user_role_name]) ? $role_values [$user_role_name] : 0; } $user_role = 0; $current_user = wp_get_current_user(); $roles = $current_user->roles; // Fix for empty roles if (isset ($current_user->caps) && count ($current_user->caps) != 0) { $caps = $current_user->caps; foreach ($role_values as $role_name => $role_value) { if (isset ($caps [$role_name]) && $caps [$role_name]) $roles []= $role_name; } } foreach ($roles as $role) { $current_user_role = isset ($role_values [$role]) ? $role_values [$role] : 0; if ($current_user_role > $user_role) $user_role = $current_user_role; } return $user_role; } function ai_current_user_role_ok () { return current_user_role () >= current_user_role (get_minimum_user_role ()); } function ai_add_meta_box_hook() { global $ai_wp_data, $block_object; if (!ai_current_user_role_ok ()) return; if (is_multisite() && !is_main_site () && !multisite_exceptions_enabled ()) return; $exceptions_posts = false; $exceptions_pages = false; for ($block = 1; $block <= 96; $block ++) { $obj = $block_object [$block]; if ($obj->get_exceptions_enabled ()) { if ($obj->get_display_settings_post ()) { $exceptions_posts = true; } if ($obj->get_display_settings_page ()) { $exceptions_pages = true; } if ($exceptions_posts && $exceptions_pages) { break; } } } $screens = array (); if ($exceptions_posts) { $screens []= 'post'; } if ($exceptions_pages) { $screens []= 'page'; } if (empty ($screens)) return; $args = array ( 'public' => true, '_builtin' => false ); $custom_post_types = get_post_types ($args, 'names', 'and'); $screens = array_values (array_merge ($screens, $custom_post_types)); foreach ($screens as $screen) { add_meta_box ( 'adinserter_sectionid', // translators: %s: Ad Inserter sprintf (_x('%s Individual Exceptions', 'Meta box name', 'ad-inserter'), AD_INSERTER_NAME), 'ai_meta_box_callback', $screen ); } } function ai_meta_box_callback ($post) { global $block_object; // Add an nonce field so we can check for it later. wp_nonce_field ('adinserter_meta_box', 'adinserter_meta_box_nonce'); $post_type = get_post_type ($post); $post_type_object = get_post_type_object ($post_type); $page_type_name = $post_type_object->labels->name; $page_type_name1 = $post_type_object->labels->singular_name; /* * Use get_post_meta() to retrieve an existing value * from the database and use the value for the form. */ $post_meta = get_post_meta ($post->ID, '_adinserter_block_exceptions', true); $selected_blocks = explode (",", $post_meta); ob_start (); echo ''; echo ''; echo ' '; echo ' '; // echo ' '; echo ' '; // translators: For this post or page if ($post_type == 'page') echo ' '; else echo ' '; echo ''; echo ''; $rows = 0; for ($block = 1; $block <= 96; $block ++) { $obj = $block_object [$block]; $exceptions_enabled = $obj->get_exceptions_enabled (); $exceptions_function = $obj->get_exceptions_function (); if ($post_type == 'page') { $page_name1 = _x('pages', 'Enabled/disabled on all', 'ad-inserter'); $general_enabled = $obj->get_display_settings_page(); } else { $page_name1 = _x('posts', 'Enabled/disabled on all', 'ad-inserter'); $general_enabled = $obj->get_display_settings_post(); } if (!$general_enabled || !$exceptions_enabled) continue; $individual_option_enabled = $general_enabled && $exceptions_enabled; $individual_text_enabled = $exceptions_function == AI_DEFAULT_INSERTION_ENABLED; if ($rows % 2 != 0) $background = "#F0F0F0"; else $background = "#FFF"; echo ''; echo ' '; $settings_page = get_menu_position () == AI_SETTINGS_SUBMENU ? 'options-general.php?page=ad-inserter.php' : 'admin.php?page=ad-inserter.php'; echo ' '; // echo ' '; echo ' '; echo ' '; echo ''; $rows ++; } echo ''; echo '
    ', __('Block', 'ad-inserter') . '', __('Name', 'ad-inserter') . '', __('Automatic insertion', 'ad-inserter') . '', __('Default insertion', 'ad-inserter') . '', _x('For this', 'Page', 'ad-inserter'), ' ', $page_type_name1, '', _x('For this', 'Post', 'ad-inserter'), ' ', $page_type_name1, '
    ', $obj->number, '', $obj->get_ad_name(), '', $obj->get_automatic_insertion_text(), ''; if ($individual_option_enabled) { if ($individual_text_enabled) echo __('Enabled', 'ad-inserter'); else echo __('Disabled', 'ad-inserter'); } else { if ($general_enabled) echo __('No individual exceptions', 'ad-inserter'); else // translators: Not enabled for pages or posts echo __('Not enabled for', 'ad-inserter') . ' ', $page_name1; } echo ' '; if ($individual_option_enabled) { echo ''; echo ''; } else { if (in_array ($block, $selected_blocks)) { echo ''; } } echo '
    '; $exceptions_table = ob_get_clean (); if ($rows == 0) { // translators: No individual exceptions enabled for pages or posts echo '

    ', __('No block has individual exceptions enabled', 'ad-inserter'), '

    '; } else echo $exceptions_table; $settings_page = get_menu_position () == AI_SETTINGS_SUBMENU ? 'options-general.php?page=ad-inserter.php' : 'admin.php?page=ad-inserter.php'; // translators: 1: Ad Inserter Settings (page), 2: Tag / Archive pages echo '

    ', //; sprintf (__('Default insertion can be configured for each block on %1$s page - button next to %2$s checkbox.', 'ad-inserter'), // translators: %s: Ad Inserter '' . sprintf (__('%s Settings', 'ad-inserter'), AD_INSERTER_NAME) . '', ''.__('Tag / Archive pages', 'ad-inserter').''), '
    ', __('When individual exceptions for a block are enabled, a checkbox will be listed here to change default insertion for this post or page.', 'ad-inserter'), '
    ', __('This way you can individually enable or disable blocks on specific posts or pages.', 'ad-inserter'), '
    '; printf (__('For more information check page %s', 'ad-inserter'), // translators: Ad Inserter Exceptions documentation page 'Ad Inserter ' . __('Individual Exceptions', 'ad-inserter') . '.

    '); } function ai_save_meta_box_data_hook ($post_id) { // Check if our nonce is set. if (!isset ($_POST ['adinserter_meta_box_nonce'])) return; // Verify that the nonce is valid. if (!wp_verify_nonce ($_POST ['adinserter_meta_box_nonce'], 'adinserter_meta_box')) return; // If this is an autosave, our form has not been submitted, so we don't want to do anything. if (defined ('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; // Check the user's permissions. if (isset ($_POST ['post_type'])) { if ($_POST ['post_type'] == 'page') { if (!current_user_can ('edit_page', $post_id)) return; } else { if (!current_user_can ('edit_post', $post_id)) return; } } /* OK, it's safe for us to save the data now. */ $selected = array (); for ($block = 1; $block <= 96; $block ++) { $option_name = 'adinserter_selected_block_' . $block; if (isset ($_POST [$option_name]) && $_POST [$option_name]) $selected []= $block; } if (!empty ($selected)) { // Update the meta field in the database. update_post_meta ($post_id, '_adinserter_block_exceptions', implode (",", $selected)); } else delete_post_meta ($post_id, '_adinserter_block_exceptions'); } function ai_widgets_init_hook () { if (is_multisite() && !is_main_site () && !multisite_widgets_enabled ()) return; register_widget ('ai_widget'); } function get_page_type_debug_info ($text = '') { global $ai_wp_data; switch ($ai_wp_data [AI_WP_PAGE_TYPE]) { case AI_PT_STATIC: $page_type = __('STATIC PAGE', 'ad-inserter'); break; case AI_PT_POST: $page_type = __('POST', 'ad-inserter'); break; case AI_PT_HOMEPAGE: $page_type = __('HOMEPAGE', 'ad-inserter'); break; case AI_PT_CATEGORY: $page_type = __('CATEGORY PAGE', 'ad-inserter'); break; case AI_PT_SEARCH: $page_type = __('SEARCH PAGE', 'ad-inserter'); break; case AI_PT_ARCHIVE: $page_type = __('ARCHIVE PAGE', 'ad-inserter'); break; case AI_PT_404: $page_type = __('ERROR 404 PAGE', 'ad-inserter'); break; case AI_PT_AJAX: $page_type = __('AJAX CALL', 'ad-inserter'); break; default: $page_type = __('UNKNOWN PAGE TYPE', 'ad-inserter'); break; } $class = AI_DEBUG_PAGE_TYPE_CLASS; $page_type = "
    ".$text.$page_type."
    "; return $page_type; } function get_adb_status_debug_info () { global $ai_wp_data; $page_type = ''; if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { if ($ai_wp_data [AI_ADB_DETECTION]) { $title = __('Click to delete ad blocking detection cokies', 'ad-inserter'); $status = __('AD BLOCKING STATUS UNKNOWN', 'ad-inserter'); $events = ''; if (isset ($_GET ['ai-debug-adb-events']) && $_GET ['ai-debug-adb-events']) { $events = ""; } $page_type = "
    $status$events
    "; } } return $page_type; } function ai_header_noindex () { global $ai_wp_data; if ($ai_wp_data [AI_WP_DEBUGGING] != 0 || $ai_wp_data [AI_CODE_FOR_IFRAME]) { echo ''; if ($ai_wp_data [AI_WP_DEBUGGING] != 0) { echo ' '; } echo "\n"; } } function get_code_debug_block ($name, $message, $right_text, $code, $inserted_code, $javascript = false) { if (strpos ($code, 'enable_page_level_ads') !== false) // translators: %s: AdSense Auto Ads $message = sprintf (__('Code for %s detected - Code will automatically insert AdSense ads at optimal positions', 'ad-inserter') . ' ', 'AdSense Auto Ads'); $debug_script = new ai_block_labels ('ai-debug-script'); $debug_block_start = $debug_script->block_start (); $debug_block_start .= $debug_script->bar ($name, '', $message, $right_text); if ($javascript) $debug_block_start = str_replace (array ('"', "\n", "\r"), array ("'", "\\n", ''), $debug_block_start); $debug_block_end = $debug_script->block_end (); if ($javascript) $debug_block_end = str_replace (array ('"', "\n", "\r"), array ("'", "\\n", ''), $debug_block_end); $html_code = htmlspecialchars ($code); if ($javascript) $html_code = str_replace (array ("\n", "\r"), array ("\\n", ''), $html_code); $html_inserted_code = htmlspecialchars ($inserted_code); if ($javascript) $html_inserted_code = str_replace (array ("\n", "\r"), array ("\\n", ''), $html_inserted_code); return $debug_block_start . "
    " . $html_code . "
    " . $html_inserted_code . "
    " . $debug_block_end; } function ai_http_header () { global $block_object, $ai_wp_data; $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_HTTP_HEADER; $obj = $block_object [AI_HEADER_OPTION_NAME]; $obj->clear_code_cache (); if ($obj->get_enable_manual ()) { if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) { // Prevent group activation when processing code for HTTP headers $ai_wp_data [AI_NO_GROUP_ACTIVATION] = true; $processed_code = do_shortcode ($obj->ai_getCode ()); unset ($ai_wp_data [AI_NO_GROUP_ACTIVATION]); if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) { $codes = explode (AD_HTTP_SEPARATOR, $processed_code); $processed_code = $codes [0]; } else $processed_code = ''; $header_lines = explode ("\n", $processed_code); foreach ($header_lines as $header_line) { if (trim ($header_line) != '' && strpos ($header_line, ':') !== false) { header (trim ($header_line)); } } } } } function ai_wp_head_hook () { global $block_object, $ai_wp_data, $ai_total_plugin_time/*, $ai_front_translations*/; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("HEAD HOOK START"); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } $ai_wp_data [AI_HEAD] = true; // $adb_code = defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION] && !isset ($ai_wp_data [AI_ADB_SHORTCODE_DISABLED]); if (defined ('AI_BUFFERING')) { if (get_output_buffering ()) { if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { ai_buffering_start (); } } } if (!get_disable_js_code () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) && (($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_BLOCKS)) != 0 || (isset ($_GET [AI_URL_DEBUG_PROCESSING_FE]) && $_GET [AI_URL_DEBUG_PROCESSING_FE] != 0))) { echo '', "\n"; // if ($adb_code) { // echo "\n"; // } else { echo "\n"; // } echo '', "\n"; } $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE; ai_header_noindex (); add_head_inline_styles (); $header_code = ''; $header = $block_object [AI_HEADER_OPTION_NAME]; if ($header->get_enable_manual ()) { if (!$header->get_debug_disable_insertion () && !get_disable_header_code ()) { if ($header->check_server_side_detection ()) { if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $header->get_enable_404()) { $processed_code = do_shortcode ($header->ai_getCode ()); if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) { $codes = explode (AD_HTTP_SEPARATOR, $processed_code); $processed_code = ltrim ($codes [1]); } if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) { $codes = explode (AD_AMP_SEPARATOR, $processed_code); $processed_code = $codes [0]; } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = ''; $header_code = $processed_code; echo $processed_code; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (strlen ($processed_code) != 0) ai_log ("HEAD CODE: " . strlen ($processed_code) . ' characters'); } } } } else { if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ('HEAD CODE DEBUG NO INSERTION'); } } } if (defined ('AI_BUFFERING')) { if (get_output_buffering () && !get_disable_header_code ()) { $ai_head_codes = ""; echo $ai_head_codes; // $header_code .= $ai_head_codes; // Don't count this code } } if (!$ai_wp_data [AI_CODE_FOR_IFRAME]) { if ($ai_wp_data [AI_WP_DEBUGGING] != 0 && isset ($_GET ['ai-debug-code']) && !defined ('AI_DEBUGGING_DEMO')) { if (is_numeric ($_GET ['ai-debug-code']) && $_GET ['ai-debug-code'] >= 1 && $_GET ['ai-debug-code'] <= 96) { $obj = $block_object [(int) $_GET ['ai-debug-code']]; $block_name = $obj->number . '   ' . $obj->get_ad_name (); if (!$header->get_debug_disable_insertion ()) { $ai_wp_debugging = $ai_wp_data [AI_WP_DEBUGGING]; $ai_wp_data [AI_WP_DEBUGGING] = 0; $code_for_insertion = $obj->get_code_for_insertion (); $ai_wp_data [AI_WP_DEBUGGING] = $ai_wp_debugging; } else $code_for_insertion = ''; // $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= " jQuery('body').prepend (\"" . get_code_debug_block (' ' . $block_name, '', __('Code for insertion', 'ad-inserter') . ' ' . strlen ($code_for_insertion) . ' ' . _n('character', 'characters', strlen ($code_for_insertion), 'ad-inserter') . ' ', $obj->ai_getCode (), $code_for_insertion, true) . "\"); $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= "document.querySelector ('body').insertAdjacentHTML ('afterbegin', \"" . get_code_debug_block (' ' . $block_name, '', __('Code for insertion', 'ad-inserter') . ' ' . strlen ($code_for_insertion) . ' ' . _n('character', 'characters', strlen ($code_for_insertion), 'ad-inserter') . ' ', $obj->ai_getCode (), $code_for_insertion, true) . "\"); "; } } if (!get_disable_js_code () && $ai_wp_data [AI_IFRAMES]) { echo "\n"; } if (!ai_inline_js () /*&& $ai_wp_data [AI_IFRAMES]*/) { echo "\n"; } if (!get_disable_js_code () && ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_BLOCKS)) != 0) { // $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= ' setTimeout (function(){jQuery(\'body\').prepend ("' . get_page_type_debug_info () . '");}, 1); $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= 'setTimeout (function(){document.querySelector (\'body\').insertAdjacentHTML (\'afterbegin\', "' . get_page_type_debug_info () . '");}, 1); '; } if (!get_disable_header_code () && isset ($_GET ['ai-debug-code']) && !defined ('AI_DEBUGGING_DEMO')) { // $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= " jQuery('body').prepend (\"" . get_code_debug_block (' ' . __('Header code', 'ad-inserter') . ' ' . ($header->get_enable_manual () ? '' : ' ' . _x('DISABLED', 'Header code', 'ad-inserter')), '<head>...</head>', strlen ($header_code) . ' ' . _n('character inserted', 'characters inserted', strlen ($header_code), 'ad-inserter') . ' ', $header->ai_getCode (), $header_code, true) . "\"); $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= "document.querySelector ('body').insertAdjacentHTML ('afterbegin', \"" . get_code_debug_block (' ' . __('Header code', 'ad-inserter') . ' ' . ($header->get_enable_manual () ? '' : ' ' . _x('DISABLED', 'Header code', 'ad-inserter')), '<head>...</head>', strlen ($header_code) . ' ' . _n('character inserted', 'characters inserted', strlen ($header_code), 'ad-inserter') . ' ', $header->ai_getCode (), $header_code, true) . "\"); "; } } // After Header code info if (!$ai_wp_data [AI_CODE_FOR_IFRAME]) { if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { // No scripts on AMP pages if (($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_AD_BLOCKING_STATUS | AI_DEBUG_POSITIONS | AI_DEBUG_BLOCKS)) != 0 && $ai_wp_data [AI_ADB_DETECTION]) { // $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= " jQuery('body').prepend (\"" . get_adb_status_debug_info () . "\"); $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= "document.querySelector ('body').insertAdjacentHTML ('afterbegin', \"" . get_adb_status_debug_info () . "\"); "; } } if (($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_AD_BLOCKING_STATUS | AI_DEBUG_BLOCKS)) != 0) { // $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= " jQuery('body').prepend (\"\"); $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= "document.querySelector ('body').insertAdjacentHTML ('afterbegin', \"\"); "; if (!$ai_wp_data [AI_UNFILTERED_HTML]) { // $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= " jQuery('body').prepend (\"
    ".__('UNFILTERED HTML DISABLED', 'ad-inserter')."
    \"); $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= "document.querySelector ('body').insertAdjacentHTML ('afterbegin', \"
    ".__('UNFILTERED HTML DISABLED', 'ad-inserter')."
    \"); "; } } } // if (!get_disable_js_code () && $ai_wp_data [AI_CODE_FOR_IFRAME]) { // echo '', "\n"; // } $ai_wp_data [AI_HEAD] = false; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("HEAD HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } } function ai_amp_head_hook () { global $block_object, $ai_wp_data, $ai_total_plugin_time; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("AMP HEAD HOOK START"); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } $ai_wp_data [AI_HEAD] = true; if (defined ('AI_BUFFERING')) { if (get_output_buffering ()) { if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) { ai_buffering_start (); } } } $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE; ai_header_noindex (); $header = $block_object [AI_HEADER_OPTION_NAME]; if ($header->get_enable_manual ()) { if (!$header->get_debug_disable_insertion () && !get_disable_header_code ()) { if ($header->check_server_side_detection ()) { if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $header->get_enable_404()) { $processed_code = do_shortcode ($header->ai_getCode ()); if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) { $codes = explode (AD_HTTP_SEPARATOR, $processed_code); $processed_code = ltrim ($codes [1]); } // ai_log ("ai_amp_head_hook "); if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) { $codes = explode (AD_AMP_SEPARATOR, $processed_code); $processed_code = ltrim ($codes [1]); echo $processed_code; // ai_log ("ai_amp_head_hook " . $processed_code); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (strlen ($processed_code) != 0) ai_log ("HEAD CODE: " . strlen ($processed_code) . ' bytes'); } } } } } } if (defined ('AI_BUFFERING')) { if (get_output_buffering () && !get_disable_header_code ()) { $ai_head_codes = ""; echo $ai_head_codes; } } $ai_wp_data [AI_HEAD] = false; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("AMP HEAD HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } } function ai_front_translations_code () { global $ai_front_translations, $ai_wp_data; // if (get_disable_js_code () || (!$ai_wp_data [AI_HTML_ELEMENT_SELECTION] && $ai_wp_data [AI_WP_DEBUGGING] == 0)) return ''; // if (!$ai_wp_data [AI_HTML_ELEMENT_SELECTION] /*&& $ai_wp_data [AI_WP_DEBUGGING] == 0*/) return ''; $object_name = 'ai_front'; $l10n = $ai_front_translations; $code = '/* $value) { if (!is_scalar ($value)) continue; $l10n [$key] = html_entity_decode ((string) $value, ENT_QUOTES, 'UTF-8'); } // $code .= "var $object_name = " . wp_json_encode ($l10n) . ";\n"; $code .= "$object_name = " . wp_json_encode ($l10n) . ";\n"; $code .= '/* ]]> */ '; return ($code); } function ai_amp_css_hook () { global $ai_wp_data; if (get_disable_css_code ()) return; $ai_wp_data [AI_AMP_CSS] = 'AMP CSS HOOK'; if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { $viewport_css = get_viewport_css (); $viewport_css = str_replace ('!important', '', $viewport_css); echo $viewport_css; } if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES || $ai_wp_data [AI_WP_DEBUGGING] != 0) { if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES) { if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css_base (); echo get_alignment_css (); echo str_replace ('!important', '', ai_get_admin_toolbar_debugging_styles ()); echo ".ai-align-left * {margin: 0 auto 0 0; text-align: left;}\n"; echo ".ai-align-right * {margin: 0 0 0 auto; text-align: right;}\n"; echo ".ai-center * {margin: 0 auto; text-align: center; }\n"; } if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css (); } } function ai_amp_css_hook_style () { echo "\n"; } function ai_wp_footer_hook_end_buffering () { global $ai_wp_data, $ai_total_plugin_time; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("FOOTER HOOK TO END BUFFERING START"); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } if (defined ('AI_BUFFERING')) { if (get_output_buffering ()) { if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { ai_buffering_end (); } } } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("FOOTER HOOK TO END BUFFERING END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } } function ai_wp_footer_hook () { global $block_object, $ai_wp_data, $ad_inserter_globals, $ai_total_plugin_time; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("FOOTER HOOK START"); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } // if (defined ('AI_BUFFERING')) { // if (get_output_buffering ()) { // if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX && !$ai_wp_data [AI_CODE_FOR_IFRAME]) { // ai_buffering_end (); // } // } // } if ($ai_wp_data [AI_DISABLE_CACHING]) ai_disable_caching (); $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER; $footer_code = ''; if (function_exists ('add_footer_scripts')) { add_footer_scripts (); } $footer = $block_object [AI_FOOTER_OPTION_NAME]; $footer->clear_code_cache (); if ($footer->get_enable_manual ()) { if (!$footer->get_debug_disable_insertion () && !get_disable_footer_code ()) { if ($footer->check_server_side_detection ()) { if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $footer->get_enable_404()) { $processed_code = do_shortcode ($footer->ai_getCode ()); if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) { $codes = explode (AD_AMP_SEPARATOR, $processed_code); $processed_code = $codes [0]; } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = ''; $footer_code = $processed_code; echo $processed_code; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (strlen ($processed_code) != 0) ai_log ("FOOTER CODE: " . strlen ($processed_code) . ' characters'); } } } } else { if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ('FOOTER CODE DEBUG NO INSERTION'); } } } if (!$ai_wp_data [AI_CODE_FOR_IFRAME]) { if (!get_disable_footer_code () && isset ($_GET ['ai-debug-code']) && !defined ('AI_DEBUGGING_DEMO')) { echo get_code_debug_block (' ' . __('Footer code', 'ad-inserter') . ' ' . ($footer->get_enable_manual () ? '' : ' ' . _x('DISABLED', 'Footer code', 'ad-inserter')), '...</body>', strlen ($footer_code).' ' . _n('character inserted', 'characters inserted', strlen ($footer_code), 'ad-inserter'), $footer->ai_getCode (), $footer_code); } if (!get_disable_js_code () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) && (($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_BLOCKS)) != 0 || (isset ($_GET [AI_URL_DEBUG_PROCESSING_FE]) && $_GET [AI_URL_DEBUG_PROCESSING_FE] != 0))) { if (!$ai_wp_data [AI_UNFILTERED_HTML]) { echo "
    ".__('UNFILTERED HTML DISABLED', 'ad-inserter')."
    \n"; } $class_0 = AI_DEBUG_STATUS_CLASS.' status-error'; $class_1 = AI_DEBUG_STATUS_CLASS.' status-ok'; $javascript_text = "
    " . __('JAVASCRIPT NOT WORKING', 'ad-inserter') . "
    "; $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] .= str_replace ('AI_HTML_CODE', $javascript_text, ai_get_js ('ai-errors-footer', false)); echo $javascript_text, "\n"; echo get_page_type_debug_info () , "\n"; // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 && isset ($_GET [AI_URL_DEBUG_PROCESSING_FE]) && $_GET [AI_URL_DEBUG_PROCESSING_FE] != 0) { // echo "\n
    \n\n";
    //        ai_write_debug_info (true);
    //        echo "\n
    \n"; // } } } if (!(defined ('DOING_AJAX') && DOING_AJAX) || $ai_wp_data [AI_CODE_FOR_IFRAME]) { add_footer_inline_scripts (); if (function_exists ('ai_add_footer_html')) { ai_add_footer_html (); } } if (function_exists ('ai_debug_footer')) { ai_debug_footer (); } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("FOOTER HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } if (!$ai_wp_data [AI_CODE_FOR_IFRAME]) { if ((get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)) { if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 && isset ($_GET [AI_URL_DEBUG_PROCESSING_FE]) && $_GET [AI_URL_DEBUG_PROCESSING_FE] != 0) { echo "\n
    \n\n";
            ai_write_debug_info (true);
            echo "\n
    \n"; } } } } function ai_amp_footer_hook () { global $block_object, $ai_wp_data, $ai_total_plugin_time; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("AMP FOOTER HOOK START"); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } if (defined ('AI_BUFFERING')) { if (get_output_buffering ()) { if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) { ai_buffering_end (); } } } $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER; $footer = $block_object [AI_FOOTER_OPTION_NAME]; $footer->clear_code_cache (); if ($footer->get_enable_manual ()) { if (!$footer->get_debug_disable_insertion () && !get_disable_footer_code ()) { if ($footer->check_server_side_detection ()) { if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $footer->get_enable_404()) { $processed_code = do_shortcode ($footer->ai_getCode ()); if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) { $codes = explode (AD_AMP_SEPARATOR, $processed_code); $processed_code = ltrim ($codes [1]); echo $processed_code; } } } } } if (!isset ($ai_wp_data [AI_AMP_CSS])) { if (ai_amp_plugin_custom_css ()) { ai_amp_css_hook_style (); $ai_wp_data [AI_AMP_CSS] = 'AMP FOOTER STYLE'; } } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) { echo get_page_type_debug_info ('AMP ') , "\n"; } if ((get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) && ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 && isset ($_GET [AI_URL_DEBUG_PROCESSING_FE]) && $_GET [AI_URL_DEBUG_PROCESSING_FE] != 0) { echo "\n
    \n\n";
        ai_write_debug_info (true);
        echo "\n
    \n"; } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("AMP FOOTER HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } } function ai_write_debug_info ($write_processing_log = false) { global $block_object, $ai_last_time, $ai_total_plugin_time, $ai_total_block_php_time, $ai_total_hook_php_time, $ai_processing_log, $ai_db_options_extract, $ai_wp_data, $ai_db_options, $block_insertion_log, $ai_custom_hooks, $version_string, $subversion_string, $filter_hooks, $wpdb; ob_start (); echo sprintf ("%-25s%s", AD_INSERTER_NAME, AD_INSERTER_VERSION); if (function_exists ('ai_debug_log')) { ai_debug_log (); } echo "\n\n"; if (($install_timestamp = get_option (AI_INSTALL_NAME)) !== false) { echo "INSTALLED: ", date ("Y-m-d H:i:s", $install_timestamp + get_option ('gmt_offset') * 3600); if (isset ($ai_wp_data [AI_INSTALL_TIME_DIFFERENCE])) { printf (' (%04d-%02d-%02d %02d:%02d:%02d, %d days ago)', $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->y, $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->m, $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->d, $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->h, $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->i, $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->s, isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL]) ? $ai_wp_data [AI_DAYS_SINCE_INSTAL] : null); } echo "\n"; } echo "GENERATED (WP time): ", date ("Y-m-d H:i:s", time() + get_option ('gmt_offset') * 3600), "\n"; echo "GENERATED (Server time): ", date ("Y-m-d H:i:s", time()), "\n"; echo "PLUGIN CODE PROCESSING: ", number_format (($ai_total_plugin_time - $ai_total_block_php_time - $ai_total_hook_php_time) * 1000, 2, '.' , ''), " ms\n"; echo "PLUGIN HOOKS PROCESSING: ", number_format ($ai_total_hook_php_time * 1000, 2, '.' , ''), " ms\n"; echo "BLOCK CODE PROCESSING: ", number_format ($ai_total_block_php_time * 1000, 2, '.' , ''), " ms\n"; echo "TOTAL PROCESSING TIME: ", number_format ($ai_total_plugin_time * 1000, 2, '.' , ''), " ms\n"; // echo "MEMORY USED: ", number_format (memory_get_usage (true) / 1024 / 1024, 2, '.' , ''), " MB\n"; // echo "PEAK MEMORY USED: ", number_format (memory_get_peak_usage (true) / 1024 / 1024, 2, '.' , ''), " MB\n"; echo "SETTINGS: "; if (isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'])) echo (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][0].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][1]), '.', (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][2].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][3]), '.', (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][4].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][5]); echo "\n"; echo "SETTINGS SIZE: ", strlen (serialize (ai_get_option (AI_OPTION_NAME))), "\n"; echo "SETTINGS TIMESTAMP: "; echo isset ($ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP']) ? date ("Y-m-d H:i:s", $ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP'] + get_option ('gmt_offset') * 3600) : "", "\n"; $expected_extract_version = $version_string . $subversion_string . '-' . '96'; if (function_exists ('ai_system_output_check')) { $expected_extract_version .= 'P'; } $extract_source = ''; $saved_settings = ai_get_option (AI_OPTION_NAME); if (isset ($saved_settings [AI_OPTION_EXTRACT]['VERSION']) && $saved_settings [AI_OPTION_EXTRACT]['VERSION'] == $expected_extract_version) { $saved_extract = $saved_settings [AI_OPTION_EXTRACT]; $extract_source = 'SAVED SETTINGS'; } else { $saved_extract = get_option (AI_EXTRACT_NAME); $extract_source = defined ('AI_EXTRACT_GENERATED') ? "REGENERATED" : 'SAVED EXTRACT'; } echo "SETTINGS EXTRACT: "; if (isset ($saved_extract ['VERSION'])) { $extract_subversion_blocks = explode ('-', $saved_extract ['VERSION']); array_shift ($extract_subversion_blocks); echo (int) ($saved_extract ['VERSION'][0].$saved_extract ['VERSION'][1]), '.', (int) ($saved_extract ['VERSION'][2].$saved_extract ['VERSION'][3]), '.', (int) ($saved_extract ['VERSION'][4].$saved_extract ['VERSION'][5]), '-', implode ('-', $extract_subversion_blocks); } echo"\n"; echo "EXTRACT TIMESTAMP: "; echo isset ($saved_extract ['TIMESTAMP']) ? date ("Y-m-d H:i:s", $saved_extract ['TIMESTAMP'] + get_option ('gmt_offset') * 3600) : "", "\n"; echo "EXTRACT SOURCE: ", $extract_source, "\n"; echo "USER: "; if (($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) == AI_USER_LOGGED_IN) echo "LOGGED-IN "; else echo "NOT LOGGED-IN "; if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) == AI_USER_ADMINISTRATOR) echo "ADMINISTRATOR"; $current_user = wp_get_current_user(); echo "\n"; echo "USERNAME: ", $current_user->user_login, "\n"; echo 'USER ROLES: ', implode (', ', $current_user->roles), "\n"; echo 'MIN.USER FOR EXCEPTIONS: ', get_minimum_user_role (), "\n"; echo "PAGE TYPE: "; switch ($ai_wp_data [AI_WP_PAGE_TYPE]) { case AI_PT_STATIC: echo "STATIC PAGE"; break; case AI_PT_POST: echo "POST"; break; case AI_PT_HOMEPAGE: echo "HOMEPAGE"; break; case AI_PT_CATEGORY: echo "CATEGORY PAGE"; break; case AI_PT_ARCHIVE: echo "ARCHIVE PAGE"; break; case AI_PT_SEARCH: echo "SEARCH PAGE"; break; case AI_PT_404: echo "404 PAGE"; break; case AI_PT_ADMIN: echo "ADMIN"; break; case AI_PT_FEED: echo "FEED"; break; case AI_PT_AJAX: echo "AJAX"; break; case AI_PT_ANY: echo "ANY ?"; break; case AI_PT_NONE: echo "NONE ?"; break; default: echo "?"; break; } echo "\n"; switch ($ai_wp_data [AI_WP_PAGE_TYPE]) { case AI_PT_STATIC: case AI_PT_POST: $queried_object_id = ''; $queried_object = get_queried_object (); if ($queried_object) { $queried_object_id = $queried_object->ID; } echo 'PUBLISHED: ', date ("Y-m-d H:i:s", get_the_date ('U')), "\n"; echo 'ID: ', ai_get_post_id (); echo " (get_the_ID: ", get_the_ID (), ", get_queried_object: ", $queried_object_id, defined ('AI_USE_GET_QUERIED_OBJECT') && AI_USE_GET_QUERIED_OBJECT ? ', AI_USE_GET_QUERIED_OBJECT SET' : "", ")"; echo "\n"; echo 'POST TYPE: ', get_post_type (), "\n"; echo 'AUTHOR: ', strtolower (get_the_author_meta ('user_login')), ' (', get_the_author_meta ('display_name'), ")\n"; // $author = get_the_author_meta ('display_name'); // $author_login = get_the_author_meta ('user_login'); // $author_name = get_the_author_meta ('first_name') . " " . get_the_author_meta ('last_name'); $category_data = get_the_category(); $categories = array (); foreach ($category_data as $category) { $categories []= $category->name . ' ('.$category->slug.')'; } echo 'CATEGORIES: ', implode (', ', $categories), "\n"; $category_data = get_categories (); $categories = array (); foreach ($category_data as $category) { if (ai_post_is_in_child_categories ($category->slug)) { $categories []= $category->name . ' ('.$category->slug.')'; } } echo 'PARENT CATEGORIES: ', implode (', ', $categories), "\n"; echo 'PRIMARY CATEGORY: ', ai_primary_category (), "\n"; $tag_data = wp_get_post_tags (get_the_ID()); $tags = array (); foreach ($tag_data as $tag) { $tags []= $tag->name . ' ('.$tag->slug.')'; } echo 'TAGS: ', implode (', ', $tags), "\n"; $taxonomies = array (); $taxonomy_names = get_post_taxonomies (); foreach ($taxonomy_names as $taxonomy_name) { $terms = get_the_terms (0, $taxonomy_name); if (is_array ($terms)) { foreach ($terms as $term) { $taxonomies [] = strtolower ($term->taxonomy) . ':' . strtolower ($term->slug); } } } echo 'TAXONOMIES: ', implode (', ', $taxonomies), "\n"; $taxonomy_data = get_taxonomies (); $taxonomies = array (); foreach ($taxonomy_data as $taxonomy) { $terms = get_terms ($taxonomy); foreach ($terms as $term) { if (ai_post_is_in_child_taxonomies ($taxonomy, $term->slug)) { $taxonomies []= $term->name . ' ('.$taxonomy.':'.$term->slug.')'; } } } echo 'PARENT TAXONOMIES: ', implode (', ', $taxonomies), "\n"; if (isset ($_GET [AI_URL_DEBUG_META])) { $post_meta = get_post_meta (get_the_ID()); $meta_string = array (); foreach ($post_meta as $key => $post_meta_field) { foreach ($post_meta_field as $post_meta_field_item) { $meta_string []= $key . ':' . $post_meta_field_item; } } echo 'POST META: ', str_replace (array ("", "\n", "\r"), array ("[!--", "--]", "*n", "*r"), implode (', ', $meta_string)), "\n"; } break; case AI_PT_CATEGORY: $category_data = get_queried_object(); $categories = array (); if ($category_data instanceof WP_Term) { $categories []= $category_data->slug; } echo 'CATEGORY: ', implode (', ', $categories), "\n"; break; case AI_PT_ARCHIVE: $tag_data = wp_get_post_tags (get_the_ID()); $tags = array (); foreach ($tag_data as $tag) { $tags []= $tag->slug; } echo 'TAG: ', implode (', ', $tags), "\n"; break; } echo 'AMP PAGE: ', ($ai_wp_data [AI_WP_AMP_PAGE] ? 'YES' : 'NO'), "\n"; if ($ai_wp_data [AI_WP_AMP_PAGE]) { echo 'AMP CSS: ', (isset ($ai_wp_data [AI_AMP_CSS]) ? $ai_wp_data [AI_AMP_CSS] : ''), "\n"; } echo 'URL: ', esc_attr ($ai_wp_data [AI_WP_URL]), "\n"; echo 'REFERRER: ', isset ($_SERVER['HTTP_REFERER']) ? strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) . ' ('. remove_debug_parameters_from_url ($_SERVER['HTTP_REFERER']).')' : "", "\n"; if (function_exists ('ai_debug')) ai_debug (); if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] || 1) { for ($viewport = 1; $viewport <= 6; $viewport ++) { $viewport_name = get_viewport_name ($viewport); $viewport_width = get_viewport_width ($viewport); if ($viewport_name != '') { echo 'VIEWPORT ', $viewport, ': ', sprintf ("%-16s min width %s", $viewport_name.' ', $viewport_width), " px\n"; } } } echo 'SERVER-SIDE DETECTION: ', $ai_wp_data [AI_SERVER_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n"; if ($ai_wp_data [AI_SERVER_SIDE_DETECTION]) { echo 'SERVER-SIDE DEVICE: '; if (AI_DESKTOP) echo "DESKTOP\n"; elseif (AI_TABLET) echo "TABLET\n"; elseif (AI_PHONE) echo "PHONE\n"; else echo "?\n"; } echo 'CLIENT-SIDE DETECTION: ', $ai_wp_data [AI_CLIENT_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n"; echo 'DISABLE CACHING: ', $ai_wp_data [AI_DISABLE_CACHING] ? 'USED' : "NOT USED", "\n"; echo 'STICKY WIDGETS: ', $ai_wp_data [AI_STICKY_WIDGETS] ? 'USED' : "NOT USED", "\n"; if (function_exists ('ai_debug_features')) ai_debug_features (); $enabled_custom_hooks = array (); foreach ($ai_custom_hooks as $ai_custom_hook) { $hook = $ai_custom_hook ['index']; $enabled_custom_hooks [] = $ai_custom_hook ['action']; } for ($hook = 1; $hook <= 20; $hook ++) { $name = str_replace (array ('<', '>'), array ('<', '>'), get_hook_name ($hook)); $action = get_hook_action ($hook); if (get_hook_enabled ($hook) /*&& $name != '' && $action != ''*/) { $priority = get_hook_priority ($hook); echo 'CUSTOM HOOK ', sprintf ("%2d", $hook), ': ', sprintf ("%-30s %-35s %d %s", $name, $action, $priority, !in_array ($action, $enabled_custom_hooks) ? 'INVALID' : ''), "\n"; } } echo 'BLOCK CLASS NAME: ', get_block_class_name (), "\n"; echo 'INLINE STYLES: ', get_inline_styles () ? 'ENABLED' : 'DISABLED', "\n"; echo 'DYNAMIC BLOCKS: '; switch (get_dynamic_blocks()) { case AI_DYNAMIC_BLOCKS_SERVER_SIDE: echo AI_TEXT_ENG_SERVER_SIDE; break; case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC: echo AI_TEXT_ENG_SERVER_SIDE_W3TC; break; case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW: echo AI_TEXT_ENG_CLIENT_SIDE_SHOW; break; case AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT: echo AI_TEXT_ENG_CLIENT_SIDE_INSERT; break; } echo "\n"; echo 'STICKY WIDGET MODE: '; switch (get_sticky_widget_mode ()) { case AI_STICKY_WIDGET_MODE_CSS: echo AI_TEXT_CSS; break; case AI_STICKY_WIDGET_MODE_CSS_PUSH: echo AI_TEXT_CSS_PUSH; break; case AI_STICKY_WIDGET_MODE_JS: echo AI_TEXT_JS; break; } echo "\n"; echo 'PARAGRAPH COUNTING: '; switch (get_paragraph_counting_functions()) { case AI_STANDARD_PARAGRAPH_COUNTING_FUNCTIONS: echo AI_TEXT_ENG_STANDARD; break; case AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS: echo AI_TEXT_ENG_MULTIBYTE; break; } echo "\n"; echo 'NO PAR. COUNTING INSIDE: ', get_no_paragraph_counting_inside (), "\n"; if (defined ('AI_BUFFERING')) { echo 'OUTPUT BUFFERING: '; switch (get_output_buffering()) { case AI_OUTPUT_BUFFERING_DISABLED: echo AI_TEXT_ENG_DISABLED; break; case AI_OUTPUT_BUFFERING_ENABLED: echo AI_TEXT_ENG_ENABLED; break; } echo "\n"; } echo 'AD LABEL: ', get_ad_label (), "\n"; echo 'AD LABEL HTML CODE: ', trim (ai_ad_label_code (), "\n"), "\n"; if (defined ('AI_STICKY_SETTINGS') && AI_STICKY_SETTINGS) { echo 'MAIN CONTENT: ', get_main_content_element (), "\n"; } echo 'PLUGIN PRIORITY: ', get_plugin_priority (), "\n"; echo 'TAB SETUP DELAY: ', get_tab_setup_delay (), "\n"; echo 'ADMIN DISABLE CACHING: ', get_disable_caching () ? 'ENABLED' : 'DISABLED', "\n"; echo 'DON\'T USE jQuery CODE: ', defined ('AI_NO_JQUERY') ? 'PHP CONSTANT' : (isset ($_GET [AI_URL_DEBUG_NO_JQUERY]) && !empty ($_GET [AI_URL_DEBUG_NO_JQUERY]) ? 'URL PARAMETER' : 'NOT SET'), "\n"; echo 'WAIT FOR JQUERY: ', get_wait_for_jquery () ? 'ENABLED' : 'DISABLED', "\n"; echo 'jQuery LOADED: ', wp_script_is ('jquery', 'registered') || wp_script_is ('jquery', 'printed') ? 'YES' : 'NO', "\n"; echo 'PLAIN JS CODE: ', $ai_wp_data [AI_NO_JQUERY_CODE] ? 'YES' : 'NO', "\n"; echo 'JAVASCRIPT CODE: ', get_javascript_code_mode () == AI_JAVASCRIPT_CODE_INLINE ? AI_TEXT_ENG_INLINE : AI_TEXT_ENG_FILE, "\n"; echo 'DO NOT CACHE CONSTANTS: ', defined ('DONOTCACHEPAGE') ? 'DONOTCACHEPAGE ' : '', defined ('DONOTCACHEOBJECT') ? 'DONOTCACHEOBJECT ' : '', defined ('DONOTCACHEDB') ? 'DONOTCACHEDB ' : '', "\n"; $virtual_ads_txt = get_option (AI_ADS_TXT_NAME); $virtual_ads_txt_lines = explode ("\n", $virtual_ads_txt); echo 'VIRTUAL ADS.TXT: ', $virtual_ads_txt !== false ? count ($virtual_ads_txt_lines). ' LINES' : 'NOT USED', "\n"; echo 'HEADER: ', $block_object [AI_HEADER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n"; echo 'FOOTER: ', $block_object [AI_FOOTER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n"; if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { echo 'AD BLOCKING DETECTION: ', $ai_wp_data [AI_ADB_DETECTION] ? 'ENABLED' : 'DISABLED', "\n"; echo 'DISABLED BY SHORTCODE: ', isset ($ai_wp_data [AI_ADB_SHORTCODE_DISABLED]) ? 'YES' : "NO", "\n"; if ($ai_wp_data [AI_ADB_DETECTION]) { echo 'ADB ACTION: '; switch (get_adb_action (true)) { case AI_ADB_ACTION_NONE: echo AI_TEXT_ENG_NONE; break; case AI_ADB_ACTION_MESSAGE: echo AI_TEXT_ENG_POPUP_MESSAGE; break; case AI_ADB_ACTION_REDIRECTION: echo AI_TEXT_ENG_REDIRECTION; break; } echo "\n"; echo 'ADB NO ACTION: '; switch (get_adb_no_action (true)) { case AI_ADB_NO_ACTION_NONE: echo AI_TEXT_ENG_NONE; break; case AI_ADB_NO_ACTION_LOGGED_IN: echo AI_TEXT_ENG_DISPLAY_LOGGED_IN_USERS; break; case AI_ADB_NO_ACTION_ADMINISTRATORS: echo AI_TEXT_ENG_DISPLAY_ADMINISTRATORS; break; } echo "\n"; echo 'ADB DELAY ACTION: ', get_delay_action (), "\n"; echo 'ADB NO ACTION PERIOD: ', get_no_action_period (), "\n"; echo 'ADB SELECTORS: ', get_adb_selectors (true), "\n"; if (function_exists ('ai_debug')) { echo 'ADB DETECTION: ', get_adb_detection () == AI_ADB_DETECTION_ADVANCED ? 'ADVANCED' : 'STANDARD', "\n"; } echo 'ADB EXTERNAL SCRIPTS: ', get_adb_external_scripts () ? 'ON' : 'OFF', "\n"; $redirection_page = get_redirection_page (); echo 'ADB REDIRECTION PAGE: ', $redirection_page != 0 ? get_the_title ($redirection_page) . ' (' . get_permalink ($redirection_page) . ')' : 'Custom Url', "\n"; echo 'ADB REDIRECTION URL: ', get_custom_redirection_url (), "\n"; echo 'ADB MESSAGE: ', str_replace (array (""), array (""), $block_object [AI_ADB_MESSAGE_OPTION_NAME]->ai_getCode ()), "\n"; echo 'ADB MESSAGE CSS: ', get_message_css (), "\n"; echo 'ADB OVERLAY CSS: ', get_overlay_css (), "\n"; echo 'ADB UNDISMISSIBLE: ', get_undismissible_message (true) ? 'ON' : 'OFF', "\n"; } } if (isset ($_SERVER ['HTTP_USER_AGENT'])) { echo 'USER AGENT: ', $_SERVER ['HTTP_USER_AGENT'], "\n"; } if (isset ($_SERVER ['HTTP_ACCEPT_LANGUAGE'])) { echo 'LANGUAGE: ', $_SERVER ['HTTP_ACCEPT_LANGUAGE'], "\n"; } if (isset ($ai_wp_data [AI_CLIENTS]) && isset ($ai_wp_data [AI_AGENT])) { $agent = $ai_wp_data [AI_AGENT]; if (!empty ($ai_wp_data [AI_CLIENTS])) { $ai_wp_data [AI_CLIENTS] = array_unique ($ai_wp_data [AI_CLIENTS]); foreach ($ai_wp_data [AI_CLIENTS] as $client) { echo sprintf (" %-23s", $client.':'), check_client_list ($client, true) ? 'YES' : 'NO', "\n"; } } } if (!empty ($filter_hooks)) { echo "\n"; foreach ($filter_hooks as $filter_hook) { echo "ACTIVE FILTER HOOK: "; foreach ($filter_hook as $index => $filter_hook_data) { if ($index != 0) echo ", "; echo $filter_hook_data; } echo "\n"; } } if (isset ($_GET [AI_URL_DEBUG_TRACKING]) && $_GET [AI_URL_DEBUG_TRACKING]) { if ($log = get_transient ('ai_debug_tracking')) { echo 'TRACKING LOG: ', "\n"; echo $log; echo "\n"; } } echo "\n"; // if ($block_object [AI_HEADER_OPTION_NAME]->get_enable_manual ()) { // echo "HEADER CODE ========================================================\n"; // echo ai_dump_code ($block_object [AI_HEADER_OPTION_NAME]->ai_getCode ()); // echo "\n====================================================================\n\n"; // } // if ($block_object [AI_FOOTER_OPTION_NAME]->get_enable_manual ()) { // echo "FOOTER CODE ========================================================\n"; // echo ai_dump_code ($block_object [AI_FOOTER_OPTION_NAME]->ai_getCode ()); // echo "\n====================================================================\n\n"; // } $default = new ai_Block (1); echo "BLOCK SETTINGS Po Pa Hp Cp Ap Sp AM Aj Fe 404 Wi Sh PHP\n"; for ($block = 1; $block <= 96; $block ++) { $obj = $block_object [$block]; $settings = ""; $insertion_settings = ''; $alignment_settings = ''; $default_settings = true; // $display_type = ''; foreach (array_keys ($default->wp_options) as $key){ switch ($key) { case AI_OPTION_CODE: case AI_OPTION_BLOCK_NAME: continue 2; case AI_OPTION_DISPLAY_ON_PAGES: case AI_OPTION_DISPLAY_ON_POSTS: case AI_OPTION_DISPLAY_ON_HOMEPAGE: case AI_OPTION_DISPLAY_ON_CATEGORY_PAGES: case AI_OPTION_DISPLAY_ON_SEARCH_PAGES: case AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES: case AI_OPTION_ENABLE_AMP: case AI_OPTION_ENABLE_AJAX: case AI_OPTION_ENABLE_FEED: case AI_OPTION_ENABLE_404: case AI_OPTION_ENABLE_MANUAL: case AI_OPTION_ENABLE_WIDGET: case AI_OPTION_ENABLE_PHP_CALL: if ($obj->wp_options [$key] != $default->wp_options [$key]) $default_settings = false; continue 2; } // if (gettype ($obj->wp_options [$key]) == 'string' && gettype ($default->wp_options [$key]) == 'integer') { // $default->wp_options [$key] = strval ($default->wp_options [$key]); // } // elseif (gettype ($obj->wp_options [$key]) == 'integer' && gettype ($default->wp_options [$key]) == 'string') { // $default->wp_options [$key] = intval ($default->wp_options [$key]); // } // if ($obj->wp_options [$key] !== $default->wp_options [$key]) { if ($obj->wp_options [$key] != $default->wp_options [$key]) { $default_settings = false; switch ($key) { case AI_OPTION_AUTOMATIC_INSERTION: $insertion_settings = $obj->get_automatic_insertion_text (false, false); break; case AI_OPTION_SERVER_SIDE_INSERTION: $settings .= "[" . $key . ": " . $obj->get_automatic_insertion_text (true, false) . ']'; break; case AI_OPTION_ALIGNMENT_TYPE: $alignment_settings = $obj->get_alignment_type_text (false); break; case AI_OPTION_ENABLED_ON_WHICH_PAGES: $settings .= "[" . $key . ": " . $obj->get_ad_enabled_on_which_pages_text (false) . ']'; break; case AI_OPTION_ENABLED_ON_WHICH_POSTS: $settings .= "[" . $key . ": " . $obj->get_ad_enabled_on_which_posts_text (false) . ']'; break; case AI_OPTION_EXCEPTIONS_FUNCTION: $settings .= "[" . $key . ": " . $obj->get_exceptions_function_text (false) . ']'; break; case AI_OPTION_FILTER_TYPE: $settings .= "[" . $key . ": " . $obj->get_filter_type_text (false) . ']'; break; case AI_OPTION_AVOID_ACTION: $settings .= "[" . $key . ": " . $obj->get_avoid_action_text (false) . ']'; break; case AI_OPTION_AVOID_DIRECTION: $settings .= "[" . $key . ": " . $obj->get_avoid_direction_text (false) . ']'; break; case AI_OPTION_DIRECTION_TYPE: $settings .= "[" . $key . ": " . $obj->get_direction_type_text (false) . ']'; break; case AI_OPTION_PARAGRAPH_TEXT_TYPE: $settings .= "[" . $key . ": " . $obj->get_paragraph_text_type_text (false) . ']'; break; case AI_OPTION_COUNT_INSIDE: $settings .= "[" . $key . ": " . $obj->get_count_inside_text (false) . ']'; break; case AI_OPTION_COUNT_INSIDE_ELEMENTS_CONTAIN: $settings .= "[" . $key . ": " . $obj->get_count_inside_elements_contain_text (false) . ']'; break; case AI_OPTION_DISPLAY_FOR_USERS: $settings .= "[" . $key . ": " . $obj->get_display_for_users_text (false) . ']'; break; case AI_OPTION_DISPLAY_FOR_DEVICES: $settings .= "[" . $key . ": " . $obj->get_display_for_devices_text (false) . ']'; break; case AI_OPTION_PARAGRAPH_TEXT: case AI_OPTION_COUNT_INSIDE_ELEMENTS_TEXT: case AI_OPTION_AVOID_TEXT_ABOVE: case AI_OPTION_AVOID_TEXT_BELOW: case AI_OPTION_HTML_SELECTOR: if ($write_processing_log) $settings .= "[" . $key . ": " . ai_log_filter_content (html_entity_decode ($obj->wp_options [$key])) . ']'; else $settings .= "[" . $key . ": " . $obj->wp_options [$key] . ']'; break; default: $settings .= "[" . $key . ": " . $obj->wp_options [$key] . ']'; break; } // $settings .= ' ['.gettype ($obj->wp_options [$key]).':'.$obj->wp_options [$key].'#'.gettype ($default->wp_options [$key]).':'.$default->wp_options [$key].'] '; } else switch ($key) { case AI_OPTION_AUTOMATIC_INSERTION: $insertion_settings = $obj->get_automatic_insertion_text (false, false); break; case AI_OPTION_ALIGNMENT_TYPE: $alignment_settings = $obj->get_alignment_type_text (false); break; } } if ($default_settings && $settings == '') continue; $settings = ' [' . $insertion_settings . '][' . $alignment_settings . ']' . $settings; echo sprintf ("%2d %-21s ", $block, $ai_wp_data [AI_MBSTRING_LOADED] ? mb_substr ($obj->get_ad_name(), 0, 21) : substr ($obj->get_ad_name(), 0, 21)); echo $obj->get_display_settings_post() ? "o" : ".", " "; echo $obj->get_display_settings_page() ? "o" : ".", " "; echo $obj->get_display_settings_home() ? "o" : ".", " "; echo $obj->get_display_settings_category() ? "o" : ".", " "; echo $obj->get_display_settings_archive() ? "o" : ".", " "; echo $obj->get_display_settings_search() ? "o" : ".", " "; echo $obj->get_enable_amp() ? "o" : ".", " "; echo $obj->get_enable_ajax() ? "o" : ".", " "; echo $obj->get_enable_feed() ? "o" : ".", " "; echo $obj->get_enable_404() ? "o" : ".", " "; echo $obj->get_enable_widget() ? "x" : ".", " "; echo $obj->get_enable_manual() ? "x" : ".", " "; echo $obj->get_enable_php_call() ? "x" : ".", " "; echo $settings, "\n"; } echo "\n"; $args = array ( 'public' => true, '_builtin' => false ); $custom_post_types = get_post_types ($args, 'names', 'and'); $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types)); $args = array ( 'posts_per_page' => AI_LIST_EXCEPTIONS_LIMIT, 'offset' => 0, 'category' => '', 'category_name' => '', 'orderby' => 'type', 'order' => 'ASC', 'include' => '', 'exclude' => '', 'meta_query' => array ( array ( 'key' => '_adinserter_block_exceptions', 'value' => '', 'compare' => '!=' ) ), 'post_type' => $screens, 'post_mime_type' => '', 'post_parent' => '', 'author' => '', 'author_name' => '', 'post_status' => '', 'suppress_filters' => true ); $posts_pages = get_posts ($args); if (count ($posts_pages) != 0) { echo "EXCEPTIONS FOR BLOCKS ID TYPE TITLE URL\n"; foreach ($posts_pages as $page) { $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true); if ($post_meta == '') continue; $post_type_object = get_post_type_object ($page->post_type); echo sprintf ("%-24s %-6s %-24s %-64s %s", $post_meta, $page->ID, $post_type_object->labels->singular_name, mb_substr ($page->post_title, 0, 64), get_permalink ($page->ID)), "\n"; } echo "\n"; } echo "TOTAL BLOCKS\n"; if (count ($ai_db_options_extract [ABOVE_HEADER_HOOK_BLOCKS][AI_PT_ANY])) echo "ABOVE HEADER: ", implode (", ", $ai_db_options_extract [ABOVE_HEADER_HOOK_BLOCKS][AI_PT_ANY]), "\n"; if (count ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][AI_PT_ANY])) echo "CONTENT HOOK: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][AI_PT_ANY]), "\n"; if (count ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][AI_PT_ANY])) echo "EXCERPT HOOK: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][AI_PT_ANY]), "\n"; if (count ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY])) echo "LOOP START HOOK: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY]), "\n"; if (count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY])) echo "LOOP END HOOK: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]), "\n"; if (count ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY])) echo "POST HOOK: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]), "\n"; if (count ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY])) echo "BEFORE COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n"; if (count ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY])) echo "BETWEEN COMMENTS HOOK ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n"; if (count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY])) echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n"; if (count ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][AI_PT_ANY])) echo "FOOTER HOOK: ", implode (", ", $ai_db_options_extract [FOOTER_HOOK_BLOCKS][AI_PT_ANY]), "\n"; foreach ($ai_custom_hooks as $index => $custom_hook) { switch ($custom_hook ['action']) { case 'wp_footer': // case 'wp_head': case 'the_content': case 'the_excerpt': case 'loop_start': case 'loop_end': // case 'the_post': continue 2; } if (count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][AI_PT_ANY])) { $blocks_using_hook = array (); foreach ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) { $obj = $block_object [$block]; if ($obj->get_automatic_insertion () == AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1) { $blocks_using_hook [] = $block; } } if (!empty ($blocks_using_hook)) { echo substr (strtoupper (str_replace (array ('<', '>'), array ('<', '>'), get_hook_name ($custom_hook ['index']))) . " HOOK: ", 0, 25), implode (", ", $blocks_using_hook), "\n"; } } } if (count ($ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][AI_PT_ANY])) echo "HTML ELEMENT: ", implode (", ", $ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][AI_PT_ANY]), "\n"; echo "\nBLOCKS FOR THIS PAGE TYPE\n"; if (isset ($ai_db_options_extract [ABOVE_HEADER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [ABOVE_HEADER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) echo "ABOVE HEADER: ", implode (", ", $ai_db_options_extract [ABOVE_HEADER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n"; if (isset ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) echo "CONTENT HOOK: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n"; if (isset ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) echo "EXCERPT HOOK: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n"; if (isset ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) echo "LOOP START HOOK: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n"; if (isset ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) echo "LOOP END HOOK: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n"; if (isset ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) echo "POST HOOK: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n"; if (isset ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n"; if (isset ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) echo "BETWEEN COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n"; if (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n"; if (isset ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) echo "FOOTER HOOK ", implode (", ", $ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n"; foreach ($ai_custom_hooks as $index => $custom_hook) { switch ($custom_hook ['action']) { case 'wp_footer': // case 'wp_head': case 'the_content': case 'the_excerpt': case 'loop_start': case 'loop_end': // case 'the_post': continue 2; } if (isset ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) { $blocks_using_hook = array (); foreach ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) { $obj = $block_object [$block]; if ($obj->get_automatic_insertion () == AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1) { $blocks_using_hook [] = $block; } } if (!empty ($blocks_using_hook)) { echo substr (strtoupper (str_replace (array ('<', '>'), array ('<', '>'), get_hook_name ($custom_hook ['index']))) . " HOOK: ", 0, 25), implode (", ", $blocks_using_hook), "\n"; } } } if (isset ($ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) echo "HTML ELEMENT: ", implode (", ", $ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n"; echo "\nDISABLED BLOCKS: ", isset ($ai_wp_data [AI_DISABLED_BLOCKS]) ? implode (', ', $ai_wp_data [AI_DISABLED_BLOCKS]) : '', "\n"; if ($write_processing_log) { echo "\nTIME EVENT\n"; echo "======================================\n"; foreach ($ai_processing_log as $log_line) { echo $log_line, "\n"; } sort ($block_insertion_log); echo "\nINSERTION SUMMARY\n"; echo "======================================\n"; foreach ($block_insertion_log as $log_line) { echo substr ($log_line, 3), "\n"; } echo "\n\n"; echo "SERVER_ADDR: ", isset ($_SERVER ['SERVER_ADDR']) ? $_SERVER ['SERVER_ADDR'] : '', "\n"; echo "HTTP_CF_CONNECTING_IP: ", isset ($_SERVER ['HTTP_CF_CONNECTING_IP']) ? $_SERVER ['HTTP_CF_CONNECTING_IP'] : '', "\n"; echo "HTTP_CLIENT_IP: ", isset ($_SERVER ['HTTP_CLIENT_IP']) ? $_SERVER ['HTTP_CLIENT_IP'] : '', "\n"; echo "HTTP_INCAP_CLIENT_IP: ", isset ($_SERVER ['HTTP_INCAP_CLIENT_IP']) ? $_SERVER ['HTTP_INCAP_CLIENT_IP'] : '', "\n"; echo "HTTP_X_FORWARDED_FOR: ", isset ($_SERVER ['HTTP_X_FORWARDED_FOR']) ? $_SERVER ['HTTP_X_FORWARDED_FOR'] : '', "\n"; echo "HTTP_X_FORWARDED: ", isset ($_SERVER ['HTTP_X_FORWARDED']) ? $_SERVER ['HTTP_X_FORWARDED'] : '', "\n"; echo "HTTP_X_CLUSTER_CLIENT_IP:", isset ($_SERVER ['HTTP_X_CLUSTER_CLIENT_IP']) ? $_SERVER ['HTTP_X_CLUSTER_CLIENT_IP'] : '', "\n"; echo "HTTP_FORWARDED_FOR: ", isset ($_SERVER ['HTTP_FORWARDED_FOR']) ? $_SERVER ['HTTP_FORWARDED_FOR'] : '', "\n"; echo "HTTP_FORWARDED: ", isset ($_SERVER ['HTTP_FORWARDED']) ? $_SERVER ['HTTP_FORWARDED'] : '', "\n"; echo "REMOTE_ADDR: ", isset ($_SERVER ['REMOTE_ADDR']) ? $_SERVER ['REMOTE_ADDR'] : '', "\n"; echo "\n"; echo 'AI_NO_PHP_PROCESSING: ', defined ('AI_NO_PHP_PROCESSING') ? 'SET' : "NO", "\n"; echo 'DISALLOW_FILE_EDIT: ', defined ('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT ? 'SET' : "NO", "\n"; echo 'DISALLOW_FILE_MODS: ', defined ('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS ? 'SET' : "NO", "\n"; echo 'DISALLOW_UNFILTERED_HTML:', defined ('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML ? 'SET' : "NO", "\n"; echo 'AI_NO_ADSENSE_API: ', defined ('AI_NO_ADSENSE_API') ? 'SET' : "NO", "\n"; echo "\n"; echo 'W3TC_DYNAMIC_SECURITY: ', defined ('W3TC_DYNAMIC_SECURITY') ? 'SET' : "NO", "\n"; echo "\n"; echo "MULTISITE: ", is_multisite() ? "YES" : "NO", "\n"; if (is_multisite()) { echo "MAIN SITE: ", is_main_site () ? "YES" : "NO", "\n"; echo "SITE COUNT: ", get_blog_count(), "\n"; } echo "OPTIONS DATABASE TABLE: ", $wpdb->prefix, "options\n"; echo "site_url: ", site_url (), "\n"; echo "home_url: ", home_url (), "\n"; if (is_multisite()) { echo "network_home_url: ", network_home_url (), "\n"; } echo "ABSPATH: ", ABSPATH, "\n"; echo "WP_CONTENT_DIR: ", WP_CONTENT_DIR, "\n"; echo "\n"; echo "PHP: ", phpversion(), "\n"; echo "mbstring: ", $ai_wp_data [AI_MBSTRING_LOADED] ? 'LOADED' : 'NO', "\n"; echo "Default charset: ", ini_get ("default_charset"), "\n"; echo "Memory Limit: ", ini_get ('memory_limit'), "\n"; echo "Upload Max Filesize: ", ini_get ('upload_max_filesize'), "\n"; echo "Post Max Size: ", ini_get ('post_max_size'), "\n"; echo "Max Execution Time: ", ini_get ('max_execution_time'), "\n"; echo "Max Input Vars: ", ini_get ('max_input_vars'), "\n"; echo "Display Errors: ", ini_get ('display_errors'), "\n"; echo "cURL: ", function_exists ('curl_version') ? 'ENABLED' : 'DISABLED', "\n"; echo "fsockopen: ", function_exists ('fsockopen') ? 'ENABLED' : 'DISABLED', "\n"; echo "DOMDocument: ", class_exists ('DOMDocument') ? 'YES' : 'NO', "\n"; echo "\n\n"; global $wp_version; echo "Wordpress: ", $wp_version, "\n"; $current_theme = wp_get_theme(); echo "Current Theme: ", $current_theme->get ('Name') . " " . $current_theme->get ('Version'), "\n"; echo "\n"; echo "A INSTALLED PLUGINS\n"; echo "======================================\n"; if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $all_plugins = get_plugins(); $active_plugins = get_option ('active_plugins'); $active_sitewide_plugins = is_multisite () ? get_site_option ('active_sitewide_plugins') : false; foreach ($all_plugins as $plugin_path => $plugin) { $multisite_status = ' '; if ($active_sitewide_plugins !== false) { $multisite_status = array_key_exists ($plugin_path, $active_sitewide_plugins) ? '# ' : ' '; } echo in_array ($plugin_path, $active_plugins) ? '* ' : $multisite_status, html_entity_decode ($plugin ["Name"]), ' ', $plugin ["Version"], "\n"; } } $log = ob_get_clean (); $log = str_replace (array ('<', '>'), array ('<', '>'), $log); echo $log; } function ai_shutdown_hook () { global $ai_wp_data, $ad_inserter_globals; $global_name = implode ('_', array ( 'AI', 'STATUS') ); if (function_exists ('ai_system_output')) ai_system_output (); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 && (get_remote_debugging () || (isset ($ad_inserter_globals [$global_name]) && $ad_inserter_globals [$global_name] == 1) || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)) { if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_HOMEPAGE || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_CATEGORY || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_SEARCH || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ARCHIVE || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_NONE || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ANY) { echo "\n\n"; } } } function ai_activation_hook () { ai_add_rewrite_rules (); flush_rewrite_rules(); } function ai_deactivation_hook () { flush_rewrite_rules(); } function ai_check_multisite_options (&$multisite_options) { if (!isset ($multisite_options ['MULTISITE_SETTINGS_PAGE'])) $multisite_options ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE; if (!isset ($multisite_options ['MULTISITE_WIDGETS'])) $multisite_options ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS; if (!isset ($multisite_options ['MULTISITE_PHP_PROCESSING'])) $multisite_options ['MULTISITE_PHP_PROCESSING'] = DEFAULT_MULTISITE_PHP_PROCESSING; if (!isset ($multisite_options ['MULTISITE_EXCEPTIONS'])) $multisite_options ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS; if (!isset ($multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'])) $multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS; if (!isset ($multisite_options ['MULTISITE_SITE_ADMIN_PAGE'])) $multisite_options ['MULTISITE_SITE_ADMIN_PAGE'] = DEFAULT_MULTISITE_SITE_ADMIN_PAGE; if (function_exists ('ai_check_multisite_options_2')) ai_check_multisite_options_2 ($multisite_options); } function ai_check_limits ($value, $min, $max, $default) { if (!is_numeric ($value)) { $value = $default; } $value = intval ($value); if ($value < $min) { $value = $min; } if ($value > $max) { $value = $max; } return $value; } function ai_check_plugin_options ($plugin_options = array ()) { global $version_string; $plugin_options ['VERSION'] = $version_string; if (!isset ($plugin_options ['SYNTAX_HIGHLIGHTER_THEME'])) $plugin_options ['SYNTAX_HIGHLIGHTER_THEME'] = DEFAULT_SYNTAX_HIGHLIGHTER_THEME; if (!isset ($plugin_options ['BLOCK_CLASS_NAME'])) $plugin_options ['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME; if (!isset ($plugin_options ['BLOCK_CLASS'])) $plugin_options ['BLOCK_CLASS'] = DEFAULT_BLOCK_CLASS; if (!isset ($plugin_options ['BLOCK_NUMBER_CLASS'])) $plugin_options ['BLOCK_NUMBER_CLASS'] = DEFAULT_BLOCK_NUMBER_CLASS; if (!isset ($plugin_options ['BLOCK_NAME_CLASS'])) $plugin_options ['BLOCK_NAME_CLASS'] = DEFAULT_BLOCK_NAME_CLASS; if (!isset ($plugin_options ['INLINE_STYLES'])) $plugin_options ['INLINE_STYLES'] = DEFAULT_INLINE_STYLES; if (!isset ($plugin_options ['MINIMUM_USER_ROLE'])) $plugin_options ['MINIMUM_USER_ROLE'] = DEFAULT_MINIMUM_USER_ROLE; if (!isset ($plugin_options ['STICKY_WIDGET_MODE'])) $plugin_options ['STICKY_WIDGET_MODE'] = DEFAULT_STICKY_WIDGET_MODE; if (!isset ($plugin_options ['STICKY_WIDGET_MARGIN'])) $plugin_options ['STICKY_WIDGET_MARGIN'] = DEFAULT_STICKY_WIDGET_MARGIN; $plugin_options ['STICKY_WIDGET_MARGIN'] = ai_check_limits ($plugin_options ['STICKY_WIDGET_MARGIN'], 0, 999, DEFAULT_STICKY_WIDGET_MARGIN); if (!isset ($plugin_options ['LAZY_LOADING_OFFSET'])) $plugin_options ['LAZY_LOADING_OFFSET'] = DEFAULT_LAZY_LOADING_OFFSET; $plugin_options ['LAZY_LOADING_OFFSET'] = ai_check_limits ($plugin_options ['LAZY_LOADING_OFFSET'], 0, 9999, DEFAULT_LAZY_LOADING_OFFSET); if (!isset ($plugin_options ['MAX_PAGE_BLOCKS'])) $plugin_options ['MAX_PAGE_BLOCKS'] = DEFAULT_MAX_PAGE_BLOCKS; $plugin_options ['MAX_PAGE_BLOCKS'] = ai_check_limits ($plugin_options ['MAX_PAGE_BLOCKS'], 0, 9999, DEFAULT_MAX_PAGE_BLOCKS); if (!isset ($plugin_options ['PLUGIN_PRIORITY'])) $plugin_options ['PLUGIN_PRIORITY'] = DEFAULT_PLUGIN_PRIORITY; $plugin_options ['PLUGIN_PRIORITY'] = ai_check_limits ($plugin_options ['PLUGIN_PRIORITY'], 0, 999999, DEFAULT_PLUGIN_PRIORITY); if (!isset ($plugin_options ['TAB_SETUP_DELAY'])) $plugin_options ['TAB_SETUP_DELAY'] = DEFAULT_TAB_SETUP_DELAY; $plugin_options ['TAB_SETUP_DELAY'] = ai_check_limits ($plugin_options ['TAB_SETUP_DELAY'], 0, 9999, DEFAULT_TAB_SETUP_DELAY); if (!isset ($plugin_options ['CLICK_FRAUD_PROTECTION'])) $plugin_options ['CLICK_FRAUD_PROTECTION'] = DEFAULT_CLICK_FRAUD_PROTECTION; if (!isset ($plugin_options ['CLICK_FRAUD_PROTECTION_TIME'])) $plugin_options ['CLICK_FRAUD_PROTECTION_TIME'] = DEFAULT_CLICK_FRAUD_PROTECTION_TIME; if (!isset ($plugin_options ['GLOBAL_VISITOR_LIMIT_CPT'])) $plugin_options ['GLOBAL_VISITOR_LIMIT_CPT'] = DEFAULT_GLOBAL_VISITOR_LIMIT_CPT; if (!isset ($plugin_options ['GLOBAL_VISITOR_LIMIT_TIME'])) $plugin_options ['GLOBAL_VISITOR_LIMIT_TIME'] = DEFAULT_GLOBAL_VISITOR_LIMIT_TIME; if (!isset ($plugin_options ['CFP_BLOCK_IP_ADDRESS'])) $plugin_options ['CFP_BLOCK_IP_ADDRESS'] = DEFAULT_CFP_BLOCK_IP_ADDRESS; if (!isset ($plugin_options ['DYNAMIC_BLOCKS'])) $plugin_options ['DYNAMIC_BLOCKS'] = DEFAULT_DYNAMIC_BLOCKS; if (!isset ($plugin_options ['PARAGRAPH_COUNTING_FUNCTIONS'])) $plugin_options ['PARAGRAPH_COUNTING_FUNCTIONS'] = DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS; if (!isset ($plugin_options ['OUTPUT_BUFFERING'])) $plugin_options ['OUTPUT_BUFFERING'] = DEFAULT_OUTPUT_BUFFERING; if (!isset ($plugin_options ['DISABLE_CACHING'])) $plugin_options ['DISABLE_CACHING'] = DEFAULT_DISABLE_CACHING; if (!isset ($plugin_options ['MENU_FOR_LINK'])) $plugin_options ['MENU_FOR_LINK'] = DEFAULT_MENU_FOR_LINK; if (!isset ($plugin_options ['WAIT_FOR_JQUERY'])) $plugin_options ['WAIT_FOR_JQUERY'] = DEFAULT_WAIT_FOR_JQUERY; if (!isset ($plugin_options ['JAVASCRIPT_CODE_MODE'])) $plugin_options ['JAVASCRIPT_CODE_MODE'] = DEFAULT_JAVASCRIPT_CODE_MODE; if (!isset ($plugin_options ['NO_PARAGRAPH_COUNTING_INSIDE'])) $plugin_options ['NO_PARAGRAPH_COUNTING_INSIDE'] = DEFAULT_NO_PARAGRAPH_COUNTING_INSIDE; if (!isset ($plugin_options ['AD_LABEL'])) $plugin_options ['AD_LABEL'] = DEFAULT_AD_TITLE; if (!isset ($plugin_options ['MAIN_CONTENT_ELEMENT'])) $plugin_options ['MAIN_CONTENT_ELEMENT'] = DEFAULT_MAIN_CONTENT_ELEMENT; if (!isset ($plugin_options ['ADB_DEVICES'])) $plugin_options ['ADB_DEVICES'] = AI_DEFAULT_ADB_DEVICES; if (!isset ($plugin_options ['ADB_ACTION'])) $plugin_options ['ADB_ACTION'] = AI_DEFAULT_ADB_ACTION; if (!isset ($plugin_options ['ADB_NO_ACTION'])) $plugin_options ['ADB_NO_ACTION'] = AI_DEFAULT_ADB_NO_ACTION; if (!isset ($plugin_options ['ADB_DELAY_ACTION'])) $plugin_options ['ADB_DELAY_ACTION'] = ''; if (!isset ($plugin_options ['ADB_NO_ACTION_PERIOD'])) $plugin_options ['ADB_NO_ACTION_PERIOD'] = AI_DEFAULT_ADB_NO_ACTION_PERIOD; if (!isset ($plugin_options ['ADB_SELECTORS'])) $plugin_options ['ADB_SELECTORS'] = ''; if (!isset ($plugin_options ['ADB_REDIRECTION_PAGE'])) $plugin_options ['ADB_REDIRECTION_PAGE'] = AI_DEFAULT_ADB_REDIRECTION_PAGE; if (!isset ($plugin_options ['ADB_CUSTOM_REDIRECTION_URL'])) $plugin_options ['ADB_CUSTOM_REDIRECTION_URL'] = ''; if (!isset ($plugin_options ['ADB_OVERLAY_CSS'])) $plugin_options ['ADB_OVERLAY_CSS'] = AI_DEFAULT_ADB_OVERLAY_CSS; if (!isset ($plugin_options ['ADB_MESSAGE_CSS'])) $plugin_options ['ADB_MESSAGE_CSS'] = AI_DEFAULT_ADB_MESSAGE_CSS; if (!isset ($plugin_options ['ADB_UNDISMISSIBLE_MESSAGE'])) $plugin_options ['ADB_UNDISMISSIBLE_MESSAGE'] = AI_DEFAULT_ADB_UNDISMISSIBLE_MESSAGE; if (!isset ($plugin_options ['ADB_EXTERNAL_SCRIPTS'])) $plugin_options ['ADB_EXTERNAL_SCRIPTS'] = AI_DEFAULT_ADB_EXTERNAL_SCRIPTS; if (!isset ($plugin_options ['ADB_NO_UNDISMISSIBLE_MESSAGE'])) $plugin_options ['ADB_NO_UNDISMISSIBLE_MESSAGE'] = AI_DEFAULT_ADB_NO_UNDISMISSIBLE_MESSAGE; if (!isset ($plugin_options ['ADMIN_TOOLBAR_DEBUGGING'])) $plugin_options ['ADMIN_TOOLBAR_DEBUGGING'] = DEFAULT_ADMIN_TOOLBAR_DEBUGGING; if (!isset ($plugin_options ['ADMIN_TOOLBAR_MOBILE'])) $plugin_options ['ADMIN_TOOLBAR_MOBILE'] = DEFAULT_ADMIN_TOOLBAR_MOBILE; if (!isset ($plugin_options ['FORCE_ADMIN_TOOLBAR'])) $plugin_options ['FORCE_ADMIN_TOOLBAR'] = DEFAULT_FORCE_ADMIN_TOOLBAR; if (!isset ($plugin_options ['REMOTE_DEBUGGING'])) $plugin_options ['REMOTE_DEBUGGING'] = DEFAULT_REMOTE_DEBUGGING; if (!isset ($plugin_options ['DISABLE_TRANSLATION'])) $plugin_options ['DISABLE_TRANSLATION'] = DEFAULT_DISABLE_TRANSLATION; if (!isset ($plugin_options ['BACKEND_JS_DEBUGGING'])) $plugin_options ['BACKEND_JS_DEBUGGING'] = DEFAULT_BACKEND_JS_DEBUGGING; if (!isset ($plugin_options ['FRONTEND_JS_DEBUGGING'])) $plugin_options ['FRONTEND_JS_DEBUGGING'] = DEFAULT_FRONTEND_JS_DEBUGGING; if (!isset ($plugin_options ['DISABLE_BLOCK_INSERTIONS'])) $plugin_options ['DISABLE_BLOCK_INSERTIONS'] = DEFAULT_DISABLE_BLOCK_INSERTIONS; if (!isset ($plugin_options ['DISABLE_PHP_PROCESSING'])) $plugin_options ['DISABLE_PHP_PROCESSING'] = DEFAULT_DISABLE_PHP_PROCESSING; if (!isset ($plugin_options ['DISABLE_HTML_CODE'])) $plugin_options ['DISABLE_HTML_CODE'] = DEFAULT_DISABLE_HTML_CODE; if (!isset ($plugin_options ['DISABLE_CSS_CODE'])) $plugin_options ['DISABLE_CSS_CODE'] = DEFAULT_DISABLE_CSS_CODE; if (!isset ($plugin_options ['DISABLE_JS_CODE'])) $plugin_options ['DISABLE_JS_CODE'] = DEFAULT_DISABLE_JS_CODE; if (!isset ($plugin_options ['DISABLE_HEADER_CODE'])) $plugin_options ['DISABLE_HEADER_CODE'] = DEFAULT_DISABLE_HEADER_CODE; if (!isset ($plugin_options ['DISABLE_FOOTER_CODE'])) $plugin_options ['DISABLE_FOOTER_CODE'] = DEFAULT_DISABLE_FOOTER_CODE; $min_width_0_defined = false; for ($viewport = 1; $viewport <= 6; $viewport ++) { $viewport_name_option_name = 'VIEWPORT_NAME_' . $viewport; $viewport_width_option_name = 'VIEWPORT_WIDTH_' . $viewport; if (!isset ($plugin_options [$viewport_name_option_name])) $plugin_options [$viewport_name_option_name] = defined ("DEFAULT_VIEWPORT_NAME_" . $viewport) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport) : ""; if ($viewport == 1 && $plugin_options [$viewport_name_option_name] == '') $plugin_options [$viewport_name_option_name] = constant ("DEFAULT_VIEWPORT_NAME_1"); if ($plugin_options [$viewport_name_option_name] != '') { $last_viewport_width_option_name = $viewport_width_option_name; if (!isset ($plugin_options [$viewport_width_option_name])) $plugin_options [$viewport_width_option_name] = defined ("DEFAULT_VIEWPORT_WIDTH_" . $viewport) ? constant ("DEFAULT_VIEWPORT_WIDTH_" . $viewport) : 0; $viewport_width = $plugin_options [$viewport_width_option_name]; if ($viewport > 1) { $previous_viewport_option_width = $plugin_options ['VIEWPORT_WIDTH_' . ($viewport - 1)]; } if (!is_numeric ($viewport_width)) { if ($viewport == 1) $viewport_width = constant ("DEFAULT_VIEWPORT_WIDTH_1"); else $viewport_width = $previous_viewport_option_width - 1; } if ($viewport_width > 9999) { $viewport_width = 9999; } // if ($viewport > 1) { // if ($viewport_width >= $previous_viewport_option_width) // $viewport_width = $previous_viewport_option_width - 1; // } $viewport_width = intval ($viewport_width); if ($viewport_width < 0) { $viewport_width = 0; } if ($viewport_width == 0) { $min_width_0_defined = true; } $plugin_options [$viewport_width_option_name] = $viewport_width; } else $plugin_options [$viewport_width_option_name] = ''; } if (!$min_width_0_defined) { $plugin_options [$last_viewport_width_option_name] = 0; } for ($constant = 1; $constant <= 6; $constant ++) { $constant_name_option_name = 'CONSTANT_NAME_' . $constant; $constant_value_option_name = 'CONSTANT_VALUE_' . $constant; if (!isset ($plugin_options [$constant_name_option_name])) $plugin_options [$constant_name_option_name] = ""; if (!isset ($plugin_options [$constant_value_option_name])) $plugin_options [$constant_value_option_name] = ""; } for ($hook = 1; $hook <= 20; $hook ++) { $hook_enabled_settins_name = 'HOOK_ENABLED_' . $hook; $hook_name_settins_name = 'HOOK_NAME_' . $hook; $hook_action_settins_name = 'HOOK_ACTION_' . $hook; $hook_priority_settins_name = 'HOOK_PRIORITY_' . $hook; if (!isset ($plugin_options [$hook_enabled_settins_name])) $plugin_options [$hook_enabled_settins_name] = AI_DISABLED; if (!isset ($plugin_options [$hook_name_settins_name])) $plugin_options [$hook_name_settins_name] = ''; if (!isset ($plugin_options [$hook_action_settins_name])) $plugin_options [$hook_action_settins_name] = ''; if (!isset ($plugin_options [$hook_priority_settins_name]) || !is_numeric ($plugin_options [$hook_priority_settins_name])) $plugin_options [$hook_priority_settins_name] = DEFAULT_CUSTOM_HOOK_PRIORITY; } if (function_exists ('ai_check_options')) ai_check_options ($plugin_options); return ($plugin_options); } function option_stripslashes (&$options) { $options = wp_unslash ($options); } // Deprecated function ai_get_old_option ($option_name) { $options = get_option ($option_name); option_stripslashes ($options); return ($options); } function ai_get_option ($option_name, $default = false) { $ai_db_options = get_option ($option_name, $default); if ($ai_db_options === false) { return $ai_db_options; } if (is_string ($ai_db_options) && substr ($ai_db_options, 0, 4) === ':AI:') { $ai_db_options = unserialize (base64_decode (substr ($ai_db_options, 4), true)); } return $ai_db_options; } function ai_update_option ($option_name, $value) { update_option ($option_name, ':AI:'. base64_encode (serialize ($value))); } function ai_save_options ($options, $multisite_options = null, $blocks_org = null, $blocks_new = null) { if (function_exists ('ai_save_remote_settings')) { if (ai_save_remote_settings ($options, $multisite_options, $blocks_org, $blocks_new)) return; } $options = apply_filters ('ai_save_options', $options); $multisite_options = apply_filters ('ai_save_multisite_options', $multisite_options); // Generate and save extract ai_update_option (AI_OPTION_NAME, $options); ai_load_settings (); $options [AI_OPTION_EXTRACT] = ai_generate_extract ($options); $ai_db_options_extract = $options [AI_OPTION_EXTRACT]; $options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'] = generate_viewport_css (); $options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'] = generate_alignment_css (); $options [AI_OPTION_GLOBAL]['TIMESTAMP'] = time (); if (!get_option (AI_INSTALL_NAME)) { update_option (AI_INSTALL_NAME, time ()); } if (is_multisite () && !is_main_site ()) { unset ($options [AI_OPTION_GLOBAL]['PLUGIN_TYPE']); unset ($options [AI_OPTION_GLOBAL]['PLUGIN_STATUS']); unset ($options [AI_OPTION_GLOBAL]['PLUGIN_STATUS_COUNTER']); } ai_update_option (AI_OPTION_NAME, $options); update_option (AI_EXTRACT_NAME, $ai_db_options_extract); // Multisite if (is_array ($multisite_options) && is_multisite () && is_main_site ()) { update_site_option (AI_OPTION_NAME, $multisite_options); } ai_load_settings (); if (is_array ($blocks_org) && is_array ($blocks_new)) { ai_update_block_numbers ($blocks_org, $blocks_new); } } function ai_load_options () { global $ai_db_options, $ai_db_options_multisite, $ai_wp_data; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD OPTIONS START"); if (function_exists ('ai_load_remote_settings')) { if (ai_load_remote_settings ()) { if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD OPTIONS END"); return; } } if (is_multisite ()) { $ai_db_options_multisite = get_site_option (AI_OPTION_NAME, array ()); option_stripslashes ($ai_db_options_multisite); } if (is_multisite () && multisite_main_for_all_blogs () && defined ('BLOG_ID_CURRENT_SITE')) { $ai_db_options = get_blog_option (BLOG_ID_CURRENT_SITE, AI_OPTION_NAME, array ()); if (is_string ($ai_db_options) && substr ($ai_db_options, 0, 4) === ':AI:') { $ai_db_options = unserialize (base64_decode (substr ($ai_db_options, 4), true)); } option_stripslashes ($ai_db_options); } else { $ai_db_options = ai_get_option (AI_OPTION_NAME, array ()); option_stripslashes ($ai_db_options); } if (is_multisite () && !is_main_site () && defined ('BLOG_ID_CURRENT_SITE')) { $ai_db_options_main = get_blog_option (BLOG_ID_CURRENT_SITE, AI_OPTION_NAME, array ()); if (is_string ($ai_db_options_main) && substr ($ai_db_options_main, 0, 4) === ':AI:') { $ai_db_options_main = unserialize (base64_decode (substr ($ai_db_options_main, 4), true)); } if (isset ($ai_db_options_main [AI_OPTION_GLOBAL]['PLUGIN_TYPE'])) $ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_TYPE'] = $ai_db_options_main [AI_OPTION_GLOBAL]['PLUGIN_TYPE']; if (isset ($ai_db_options_main [AI_OPTION_GLOBAL]['PLUGIN_STATUS'])) $ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_STATUS'] = $ai_db_options_main [AI_OPTION_GLOBAL]['PLUGIN_STATUS']; if (isset ($ai_db_options_main [AI_OPTION_GLOBAL]['PLUGIN_STATUS_COUNTER'])) $ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_STATUS_COUNTER'] = $ai_db_options_main [AI_OPTION_GLOBAL]['PLUGIN_STATUS_COUNTER']; } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD OPTIONS END"); } function get_viewport_css () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'])) $ai_db_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'] = generate_viewport_css (); return ($ai_db_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS']); } function get_alignment_css () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS']) || isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] < '020211' ) $ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'] = generate_alignment_css (); return (str_replace (''', "'", $ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'])); } function get_syntax_highlighter_theme () { global $ai_db_options; // return 'ad-inserter'; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['SYNTAX_HIGHLIGHTER_THEME'])) $ai_db_options [AI_OPTION_GLOBAL]['SYNTAX_HIGHLIGHTER_THEME'] = DEFAULT_SYNTAX_HIGHLIGHTER_THEME; return ($ai_db_options [AI_OPTION_GLOBAL]['SYNTAX_HIGHLIGHTER_THEME']); } function get_block_class_name ($default_if_empty = false) { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME'])) $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME; if ($default_if_empty && $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME'] == '') return (DEFAULT_BLOCK_CLASS_NAME); return ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME']); } function get_block_class () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS'])) $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS'] = DEFAULT_BLOCK_CLASS; return ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS']); } function get_block_number_class () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NUMBER_CLASS'])) $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NUMBER_CLASS'] = DEFAULT_BLOCK_NUMBER_CLASS; return ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NUMBER_CLASS']); } function get_block_name_class () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NAME_CLASS'])) $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NAME_CLASS'] = DEFAULT_BLOCK_NAME_CLASS; return ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NAME_CLASS']); } function get_inline_styles () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['INLINE_STYLES'])) $ai_db_options [AI_OPTION_GLOBAL]['INLINE_STYLES'] = DEFAULT_INLINE_STYLES; return ($ai_db_options [AI_OPTION_GLOBAL]['INLINE_STYLES']); } function get_minimum_user_role () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['MINIMUM_USER_ROLE'])) $ai_db_options [AI_OPTION_GLOBAL]['MINIMUM_USER_ROLE'] = DEFAULT_MINIMUM_USER_ROLE; return ($ai_db_options [AI_OPTION_GLOBAL]['MINIMUM_USER_ROLE']); } function get_sticky_widget_mode () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE'])) $ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE'] = DEFAULT_STICKY_WIDGET_MODE; return ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE']); } function get_sticky_widget_margin () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MARGIN'])) $ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MARGIN'] = DEFAULT_STICKY_WIDGET_MARGIN; return ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MARGIN']); } function get_lazy_loading_offset () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['LAZY_LOADING_OFFSET'])) $ai_db_options [AI_OPTION_GLOBAL]['LAZY_LOADING_OFFSET'] = DEFAULT_LAZY_LOADING_OFFSET; return ($ai_db_options [AI_OPTION_GLOBAL]['LAZY_LOADING_OFFSET']); } function get_click_fraud_protection () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['CLICK_FRAUD_PROTECTION'])) $ai_db_options [AI_OPTION_GLOBAL]['CLICK_FRAUD_PROTECTION'] = DEFAULT_CLICK_FRAUD_PROTECTION; return ($ai_db_options [AI_OPTION_GLOBAL]['CLICK_FRAUD_PROTECTION']); } function get_click_fraud_protection_time () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['CLICK_FRAUD_PROTECTION_TIME'])) $ai_db_options [AI_OPTION_GLOBAL]['CLICK_FRAUD_PROTECTION_TIME'] = DEFAULT_CLICK_FRAUD_PROTECTION_TIME; return ($ai_db_options [AI_OPTION_GLOBAL]['CLICK_FRAUD_PROTECTION_TIME']); } function get_global_visitor_limit_clicks_per_time_period () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['GLOBAL_VISITOR_LIMIT_CPT'])) $ai_db_options [AI_OPTION_GLOBAL]['GLOBAL_VISITOR_LIMIT_CPT'] = DEFAULT_GLOBAL_VISITOR_LIMIT_CPT; $option = $ai_db_options [AI_OPTION_GLOBAL]['GLOBAL_VISITOR_LIMIT_CPT']; if ($option == '0') $option = ''; return ($option); } function get_global_visitor_limit_clicks_time_period () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['GLOBAL_VISITOR_LIMIT_TIME'])) $ai_db_options [AI_OPTION_GLOBAL]['GLOBAL_VISITOR_LIMIT_TIME'] = DEFAULT_GLOBAL_VISITOR_LIMIT_TIME; $option = $ai_db_options [AI_OPTION_GLOBAL]['GLOBAL_VISITOR_LIMIT_TIME']; if ($option == '0') $option = ''; return ($option); } function get_cfp_block_ip_address () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['CFP_BLOCK_IP_ADDRESS'])) $ai_db_options [AI_OPTION_GLOBAL]['CFP_BLOCK_IP_ADDRESS'] = DEFAULT_CFP_BLOCK_IP_ADDRESS; return ($ai_db_options [AI_OPTION_GLOBAL]['CFP_BLOCK_IP_ADDRESS']); } function get_max_page_blocks () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['MAX_PAGE_BLOCKS'])) $ai_db_options [AI_OPTION_GLOBAL]['MAX_PAGE_BLOCKS'] = DEFAULT_MAX_PAGE_BLOCKS; return ($ai_db_options [AI_OPTION_GLOBAL]['MAX_PAGE_BLOCKS']); } function get_plugin_priority () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_PRIORITY'])) $ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_PRIORITY'] = DEFAULT_PLUGIN_PRIORITY; return ($ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_PRIORITY']); } function get_tab_setup_delay () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['TAB_SETUP_DELAY'])) $ai_db_options [AI_OPTION_GLOBAL]['TAB_SETUP_DELAY'] = DEFAULT_TAB_SETUP_DELAY; return ($ai_db_options [AI_OPTION_GLOBAL]['TAB_SETUP_DELAY']); } function get_dynamic_blocks(){ global $ai_db_options, $ai_wp_data; if (isset ($ai_wp_data [AI_DYNAMIC_BLOCKS])) { return ($ai_wp_data [AI_DYNAMIC_BLOCKS]); } if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DYNAMIC_BLOCKS'])) $ai_db_options [AI_OPTION_GLOBAL]['DYNAMIC_BLOCKS'] = DEFAULT_DYNAMIC_BLOCKS; return ($ai_db_options [AI_OPTION_GLOBAL]['DYNAMIC_BLOCKS']); } function get_paragraph_counting_functions(){ global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['PARAGRAPH_COUNTING_FUNCTIONS'])) $ai_db_options [AI_OPTION_GLOBAL]['PARAGRAPH_COUNTING_FUNCTIONS'] = DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS; return ($ai_db_options [AI_OPTION_GLOBAL]['PARAGRAPH_COUNTING_FUNCTIONS']); } function get_output_buffering(){ global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING'])) $ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING'] = DEFAULT_OUTPUT_BUFFERING; return ($ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING']); } function get_menu_position (){ global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['MENU_FOR_LINK'])) $ai_db_options [AI_OPTION_GLOBAL]['MENU_FOR_LINK'] = DEFAULT_MENU_FOR_LINK; return ($ai_db_options [AI_OPTION_GLOBAL]['MENU_FOR_LINK']); } function get_disable_caching (){ global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_CACHING'])) $ai_db_options [AI_OPTION_GLOBAL]['DISABLE_CACHING'] = DEFAULT_DISABLE_CACHING; return ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_CACHING']); } function get_wait_for_jquery (){ global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['WAIT_FOR_JQUERY'])) $ai_db_options [AI_OPTION_GLOBAL]['WAIT_FOR_JQUERY'] = DEFAULT_WAIT_FOR_JQUERY; return ($ai_db_options [AI_OPTION_GLOBAL]['WAIT_FOR_JQUERY']); } function get_javascript_code_mode (){ global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['JAVASCRIPT_CODE_MODE'])) $ai_db_options [AI_OPTION_GLOBAL]['JAVASCRIPT_CODE_MODE'] = DEFAULT_JAVASCRIPT_CODE_MODE; return ($ai_db_options [AI_OPTION_GLOBAL]['JAVASCRIPT_CODE_MODE']); } function get_no_paragraph_counting_inside () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['NO_PARAGRAPH_COUNTING_INSIDE'])) $ai_db_options [AI_OPTION_GLOBAL]['NO_PARAGRAPH_COUNTING_INSIDE'] = DEFAULT_NO_PARAGRAPH_COUNTING_INSIDE; return (str_replace (array ('<', '>'), '', $ai_db_options [AI_OPTION_GLOBAL]['NO_PARAGRAPH_COUNTING_INSIDE'])); } function get_ad_label ($decode = false) { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL'])) $ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL'] = DEFAULT_AD_TITLE; if ($decode) return (html_entity_decode ($ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL'])); return ($ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL']); } function get_main_content_element () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['MAIN_CONTENT_ELEMENT'])) $ai_db_options [AI_OPTION_GLOBAL]['MAIN_CONTENT_ELEMENT'] = DEFAULT_MAIN_CONTENT_ELEMENT; return ($ai_db_options [AI_OPTION_GLOBAL]['MAIN_CONTENT_ELEMENT']); } function get_force_admin_toolbar () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['FORCE_ADMIN_TOOLBAR'])) $ai_db_options [AI_OPTION_GLOBAL]['FORCE_ADMIN_TOOLBAR'] = DEFAULT_FORCE_ADMIN_TOOLBAR; return ($ai_db_options [AI_OPTION_GLOBAL]['FORCE_ADMIN_TOOLBAR']); } function get_admin_toolbar_debugging () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_DEBUGGING'] = DEFAULT_ADMIN_TOOLBAR_DEBUGGING; return ($ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_DEBUGGING']); } function get_admin_toolbar_mobile () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_MOBILE'])) $ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_MOBILE'] = DEFAULT_ADMIN_TOOLBAR_MOBILE; return ($ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_MOBILE']); } function get_remote_debugging () { global $ai_db_options; if (function_exists ('ai_remote_debugging')) return ai_remote_debugging (); if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['REMOTE_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['REMOTE_DEBUGGING'] = DEFAULT_REMOTE_DEBUGGING; return ($ai_db_options [AI_OPTION_GLOBAL]['REMOTE_DEBUGGING']); } function get_disable_translation () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_TRANSLATION'])) $ai_db_options [AI_OPTION_GLOBAL]['DISABLE_TRANSLATION'] = DEFAULT_DISABLE_TRANSLATION; return ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_TRANSLATION']); } function get_backend_javascript_debugging () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BACKEND_JS_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['BACKEND_JS_DEBUGGING'] = DEFAULT_BACKEND_JS_DEBUGGING; return ($ai_db_options [AI_OPTION_GLOBAL]['BACKEND_JS_DEBUGGING']); } function get_frontend_javascript_debugging () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['FRONTEND_JS_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['FRONTEND_JS_DEBUGGING'] = DEFAULT_FRONTEND_JS_DEBUGGING; return ($ai_db_options [AI_OPTION_GLOBAL]['FRONTEND_JS_DEBUGGING']); } function get_disable_block_insertions () { global $ai_db_options; if (isset ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]) && $_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS] == 'all' && get_remote_debugging ()) return true; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_BLOCK_INSERTIONS'])) $ai_db_options [AI_OPTION_GLOBAL]['DISABLE_BLOCK_INSERTIONS'] = DEFAULT_DISABLE_BLOCK_INSERTIONS; return ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_BLOCK_INSERTIONS']); } function get_disable_php_processing () { global $ai_db_options; if (isset ($_GET [AI_URL_DEBUG_DISABLE_PHP_PROCESSING]) && $_GET [AI_URL_DEBUG_DISABLE_PHP_PROCESSING] && get_remote_debugging ()) return true; if (isset ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]) && get_remote_debugging ()) { if ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS] == 'php') return true; if (strpos ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS], '-') !== false) { $blocks = explode ('-', $_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]); if (in_array ('php', $blocks)) return true; } } if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_PHP_PROCESSING'])) $ai_db_options [AI_OPTION_GLOBAL]['DISABLE_PHP_PROCESSING'] = DEFAULT_DISABLE_PHP_PROCESSING; return ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_PHP_PROCESSING']); } function get_disable_html_code () { global $ai_db_options; if (isset ($_GET [AI_URL_DEBUG_DISABLE_HTML_CODE]) && $_GET [AI_URL_DEBUG_DISABLE_HTML_CODE] && get_remote_debugging ()) return true; if (isset ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]) && get_remote_debugging ()) { if ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS] == 'html') return true; if (strpos ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS], '-') !== false) { $blocks = explode ('-', $_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]); if (in_array ('html', $blocks)) return true; } } if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_HTML_CODE'])) $ai_db_options [AI_OPTION_GLOBAL]['DISABLE_HTML_CODE'] = DEFAULT_DISABLE_CSS_CODE; return ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_HTML_CODE']); } function get_disable_css_code () { global $ai_db_options; if (isset ($_GET [AI_URL_DEBUG_DISABLE_CSS_CODE]) && $_GET [AI_URL_DEBUG_DISABLE_CSS_CODE] && get_remote_debugging ()) return true; if (isset ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]) && get_remote_debugging ()) { if ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS] == 'css') return true; if (strpos ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS], '-') !== false) { $blocks = explode ('-', $_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]); if (in_array ('css', $blocks)) return true; } } if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_CSS_CODE'])) $ai_db_options [AI_OPTION_GLOBAL]['DISABLE_CSS_CODE'] = DEFAULT_DISABLE_CSS_CODE; return ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_CSS_CODE']); } function get_disable_js_code () { global $ai_db_options; if (isset ($_GET [AI_URL_DEBUG_DISABLE_JS_CODE]) && $_GET [AI_URL_DEBUG_DISABLE_JS_CODE] && get_remote_debugging ()) return true; if (isset ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]) && get_remote_debugging ()) { if ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS] == 'js') return true; if (strpos ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS], '-') !== false) { $blocks = explode ('-', $_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]); if (in_array ('js', $blocks)) return true; } } if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_JS_CODE'])) $ai_db_options [AI_OPTION_GLOBAL]['DISABLE_JS_CODE'] = DEFAULT_DISABLE_JS_CODE; return ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_JS_CODE']); } function get_disable_header_code () { global $ai_db_options; if (isset ($_GET [AI_URL_DEBUG_DISABLE_HEADER_CODE]) && $_GET [AI_URL_DEBUG_DISABLE_HEADER_CODE] && get_remote_debugging ()) return true; if (isset ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]) && get_remote_debugging ()) { if ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS] == 'h') return true; if (strpos ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS], '-') !== false) { $blocks = explode ('-', $_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]); if (in_array ('h', $blocks)) return true; } } if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_HEADER_CODE'])) $ai_db_options [AI_OPTION_GLOBAL]['DISABLE_HEADER_CODE'] = DEFAULT_DISABLE_HEADER_CODE; return ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_HEADER_CODE']); } function get_disable_footer_code () { global $ai_db_options; if (isset ($_GET [AI_URL_DEBUG_DISABLE_FOOTER_CODE]) && $_GET [AI_URL_DEBUG_DISABLE_FOOTER_CODE] && get_remote_debugging ()) return true; if (isset ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]) && get_remote_debugging ()) { if ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS] == 'f') return true; if (strpos ($_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS], '-') !== false) { $blocks = explode ('-', $_GET [AI_URL_DEBUG_DISABLE_BLOCK_INSERTIONS]); if (in_array ('f', $blocks)) return true; } } if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_FOOTER_CODE'])) $ai_db_options [AI_OPTION_GLOBAL]['DISABLE_FOOTER_CODE'] = DEFAULT_DISABLE_FOOTER_CODE; return ($ai_db_options [AI_OPTION_GLOBAL]['DISABLE_FOOTER_CODE']); } function get_blocks_sticky () { if (!function_exists ('ai_block_list_buttons')) return false; $current_flags = get_option (AI_FLAGS_NAME, 0); return (($current_flags & AD_FLAGS_BLOCKS_STICKY) != 0); } function get_settings_hidden () { if (!function_exists ('ai_block_list_buttons')) return false; $current_flags = get_option (AI_FLAGS_NAME, 0); return (($current_flags & AD_FLAGS_SETTINGS_HIDDEN) != 0); } function get_viewport_name ($viewport_number) { global $ai_db_options; $viewport_settins_name = 'VIEWPORT_NAME_' . $viewport_number; if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name] = defined ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) : ""; return ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]); } function get_viewport_width ($viewport_number) { global $ai_db_options; $viewport_settins_name = 'VIEWPORT_WIDTH_' . $viewport_number; if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name] = defined ("DEFAULT_VIEWPORT_WIDTH_" . $viewport_number) ? constant ("DEFAULT_VIEWPORT_WIDTH_" . $viewport_number) : ""; return ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]); } function get_constant_name ($constant_number) { global $ai_db_options; $constant_settins_name = 'CONSTANT_NAME_' . $constant_number; if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$constant_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$constant_settins_name] = ""; return ($ai_db_options [AI_OPTION_GLOBAL][$constant_settins_name]); } function get_constant_value ($constant_number) { global $ai_db_options; $constant_settins_name = 'CONSTANT_VALUE_' . $constant_number; if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$constant_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$constant_settins_name] = ""; return ($ai_db_options [AI_OPTION_GLOBAL][$constant_settins_name]); } function get_hook_enabled ($hook_number) { global $ai_db_options; $hook_settins_name = 'HOOK_ENABLED_' . $hook_number; if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = AI_DISABLED; return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]); } function get_hook_name ($hook_number) { global $ai_db_options; $hook_settins_name = 'HOOK_NAME_' . $hook_number; if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = ""; return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]); } function get_hook_action ($hook_number) { global $ai_db_options; $hook_settins_name = 'HOOK_ACTION_' . $hook_number; if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = ""; return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]); } function get_hook_priority ($hook_number) { global $ai_db_options; $hook_settins_name = 'HOOK_PRIORITY_' . $hook_number; if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = DEFAULT_CUSTOM_HOOK_PRIORITY; return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]); } function get_country_group_name ($group_number) { global $ai_db_options; $country_group_settins_name = 'COUNTRY_GROUP_NAME_' . $group_number; if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$country_group_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$country_group_settins_name] = DEFAULT_COUNTRY_GROUP_NAME . ' ' . $group_number; return ($ai_db_options [AI_OPTION_GLOBAL][$country_group_settins_name]); } function get_group_country_list ($group_number) { global $ai_db_options; $group_countries_settins_name = 'GROUP_COUNTRIES_' . $group_number; if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$group_countries_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$group_countries_settins_name] = ''; return ($ai_db_options [AI_OPTION_GLOBAL][$group_countries_settins_name]); } function multisite_settings_page_enabled () { global $ai_db_options_multisite; if (ai_remote ('multisite', is_multisite ())) { if (!isset ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'])) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE; if ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] == '') $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE; if (multisite_main_for_all_blogs ()) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = AI_DISABLED; elseif (current_user_can ('manage_network_plugins')) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = AI_ENABLED; return ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE']); } return DEFAULT_MULTISITE_SETTINGS_PAGE; } function multisite_widgets_enabled () { global $ai_db_options_multisite; if (ai_remote ('multisite', is_multisite ())) { if (!isset ($ai_db_options_multisite ['MULTISITE_WIDGETS'])) $ai_db_options_multisite ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS; if ($ai_db_options_multisite ['MULTISITE_WIDGETS'] == '') $ai_db_options_multisite ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS; return ($ai_db_options_multisite ['MULTISITE_WIDGETS']); } return DEFAULT_MULTISITE_WIDGETS; } function multisite_php_processing () { global $ai_db_options_multisite; if (ai_remote ('multisite', is_multisite ())) { if (function_exists ('ai_filter_multisite_settings')) { if (!isset ($ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'])) $ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'] = DEFAULT_MULTISITE_PHP_PROCESSING; if ($ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'] == '') $ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'] = DEFAULT_MULTISITE_PHP_PROCESSING; return ($ai_db_options_multisite ['MULTISITE_PHP_PROCESSING']); } return AI_ENABLED; } return DEFAULT_MULTISITE_PHP_PROCESSING; } function multisite_exceptions_enabled () { global $ai_db_options_multisite; if (ai_remote ('multisite', is_multisite ())) { if (!isset ($ai_db_options_multisite ['MULTISITE_EXCEPTIONS'])) $ai_db_options_multisite ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS; if ($ai_db_options_multisite ['MULTISITE_EXCEPTIONS'] == '') $ai_db_options_multisite ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS; return ($ai_db_options_multisite ['MULTISITE_EXCEPTIONS']); } return DEFAULT_MULTISITE_EXCEPTIONS; } function multisite_main_for_all_blogs () { global $ai_db_options_multisite; if (ai_remote ('multisite', is_multisite ())) { if (!isset ($ai_db_options_multisite ['MULTISITE_MAIN_FOR_ALL_BLOGS'])) $ai_db_options_multisite ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS; if ($ai_db_options_multisite ['MULTISITE_MAIN_FOR_ALL_BLOGS'] == '') $ai_db_options_multisite ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS; return ($ai_db_options_multisite ['MULTISITE_MAIN_FOR_ALL_BLOGS']); } return DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS; } function multisite_site_admin_page () { global $ai_db_options_multisite; if (ai_remote ('multisite', is_multisite ())) { if (!isset ($ai_db_options_multisite ['MULTISITE_SITE_ADMIN_PAGE'])) $ai_db_options_multisite ['MULTISITE_SITE_ADMIN_PAGE'] = DEFAULT_MULTISITE_SITE_ADMIN_PAGE; if (multisite_main_for_all_blogs ()) $ai_db_options_multisite ['MULTISITE_SITE_ADMIN_PAGE'] = AI_DISABLED; return ($ai_db_options_multisite ['MULTISITE_SITE_ADMIN_PAGE']); } return DEFAULT_MULTISITE_SITE_ADMIN_PAGE; } function get_adb_devices () { global $ai_db_options, $ai_wp_data; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_DEVICES'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_DEVICES'] = AI_DEFAULT_ADB_DEVICES; return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_DEVICES']); } function get_adb_action ($saved_value = false) { global $ai_db_options, $ai_wp_data; if (!$saved_value) { if ($ai_wp_data [AI_CODE_FOR_IFRAME]) return AI_ADB_ACTION_NONE; switch (get_adb_no_action ()) { case AI_ADB_NO_ACTION_LOGGED_IN: if (($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) return AI_ADB_ACTION_NONE; break; case AI_ADB_NO_ACTION_ADMINISTRATORS: if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) return AI_ADB_ACTION_NONE; break; } if (isset ($ai_wp_data [AI_ADB_SHORTCODE_ACTION])) return ($ai_wp_data [AI_ADB_SHORTCODE_ACTION]); } if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION'] = AI_DEFAULT_ADB_ACTION; return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION']); } function get_adb_no_action ($saved_value = false) { global $ai_db_options, $ai_wp_data; if (!$saved_value) { if ($ai_wp_data [AI_CODE_FOR_IFRAME]) return AI_ADB_NO_ACTION_NONE; } if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION'] = AI_DEFAULT_ADB_NO_ACTION; return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION']); } function get_delay_action ($return_number = false) { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION'] = ''; if ($return_number) { $value = trim ($ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION']); if ($value == '') $value = 0; // if (is_numeric ($value)) return $value; else return 0; } return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION']); } function get_no_action_period ($return_number = false) { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION_PERIOD'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION_PERIOD'] = AI_DEFAULT_ADB_NO_ACTION_PERIOD; if ($return_number) { $value = trim ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION_PERIOD']); if ($value == '') $value = 0; if (is_numeric ($value)) return $value; else return AI_DEFAULT_ADB_NO_ACTION_PERIOD; } return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION_PERIOD']); } function get_adb_selectors ($decode = false) { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'] = ''; if ($decode) return (html_entity_decode ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'])); else return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS']); } function get_redirection_page ($return_number = false) { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_REDIRECTION_PAGE'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_REDIRECTION_PAGE'] = AI_DEFAULT_ADB_REDIRECTION_PAGE; if ($return_number) { $value = trim ($ai_db_options [AI_OPTION_GLOBAL]['ADB_REDIRECTION_PAGE']); if ($value == '') $value = 0; if (is_numeric ($value)) return $value; else return AI_DEFAULT_ADB_REDIRECTION_PAGE; } return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_REDIRECTION_PAGE']); } function get_custom_redirection_url () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_CUSTOM_REDIRECTION_URL'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_CUSTOM_REDIRECTION_URL'] = ''; return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_CUSTOM_REDIRECTION_URL']); } function get_adb_external_scripts () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_EXTERNAL_SCRIPTS'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_EXTERNAL_SCRIPTS'] = AI_DEFAULT_ADB_EXTERNAL_SCRIPTS; return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_EXTERNAL_SCRIPTS']); } function get_message_css () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_MESSAGE_CSS'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_MESSAGE_CSS'] = AI_DEFAULT_ADB_MESSAGE_CSS; return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_MESSAGE_CSS']); } function get_overlay_css () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_OVERLAY_CSS'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_OVERLAY_CSS'] = AI_DEFAULT_ADB_OVERLAY_CSS; return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_OVERLAY_CSS']); } function get_undismissible_message ($saved_value = false) { global $ai_db_options, $ai_wp_data; if (!$saved_value) { switch (get_no_undismissible_message ()) { case AI_ADB_NO_ACTION_LOGGED_IN: if (($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) return AI_DISABLED; break; case AI_ADB_NO_ACTION_ADMINISTRATORS: if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) return AI_DISABLED; break; } } if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_UNDISMISSIBLE_MESSAGE'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_UNDISMISSIBLE_MESSAGE'] = AI_DEFAULT_ADB_UNDISMISSIBLE_MESSAGE; return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_UNDISMISSIBLE_MESSAGE']); } function get_no_undismissible_message () { global $ai_db_options; if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_UNDISMISSIBLE_MESSAGE'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_UNDISMISSIBLE_MESSAGE'] = AI_DEFAULT_ADB_NO_UNDISMISSIBLE_MESSAGE; return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_UNDISMISSIBLE_MESSAGE']); } function filter_html_class ($str){ $str = str_replace (array ("\\\""), array ("\""), $str); $str = sanitize_html_class ($str); return $str; } function filter_string ($str){ $str = str_replace (array ("\\\""), array ("\""), $str); $str = str_replace (array ("\"", "<", ">"), "", $str); $str = trim (esc_html ($str)); return $str; } function filter_string_tags ($str){ $str = str_replace (array ("\\\""), array ("\""), $str); $str = str_replace (array ("\""), "", $str); $str = str_replace (array ("<", ">"), array ("<", ">"), $str); $str = trim (esc_html ($str)); return $str; } function filter_option ($option, $value, $delete_escaped_backslashes = true){ if ($delete_escaped_backslashes) $value = str_replace (array ("\\\""), array ("\""), $value); if ($option == 'ADB_SELECTORS' || $option == AI_OPTION_HTML_SELECTOR || $option == AI_OPTION_ANIMATION_TRIGGER_VALUE || $option == 'MAIN_CONTENT_ELEMENT') { $value = str_replace (array ("\\", "/", "?", "\"", "'", "'", '"'), "", $value); $value = esc_html ($value); } elseif ($option == AI_OPTION_DOMAIN_LIST || $option == 'NO_PARAGRAPH_COUNTING_INSIDE' || $option == AI_OPTION_BACKGROUND_COLOR || $option == AI_OPTION_BLOCK_BACKGROUND_COLOR || $option == AI_OPTION_PARAGRAPH_TAGS || $option == AI_OPTION_COUNT_INSIDE_ELEMENTS || $option == AI_OPTION_IP_ADDRESS_LIST || $option == AI_OPTION_COUNTRY_LIST) { $value = str_replace (array ("\\", "/", "?", "\"", "'", "<", ">", "[", "]", "'", '"'), "", $value); $value = esc_html ($value); } elseif ($option == AI_OPTION_BLOCK_WIDTH || $option == AI_OPTION_BLOCK_HEIGHT) { $value = str_replace (array ("\"", "'", "<", ">", "[", "]", "'", '"'), "", $value); $value = esc_html ($value); } elseif ( $option == AI_OPTION_PARAGRAPH_TEXT || $option == AI_OPTION_COUNT_INSIDE_ELEMENTS_TEXT || $option == AI_OPTION_AVOID_TEXT_ABOVE || $option == AI_OPTION_AVOID_TEXT_BELOW || $option == AI_OPTION_CLIENT_LIST ) { $value = esc_html ($value); } elseif ($option == AI_OPTION_BLOCK_NAME || $option == AI_OPTION_GENERAL_TAG || $option == AI_OPTION_DOMAIN_LIST || $option == AI_OPTION_CATEGORY_LIST || $option == AI_OPTION_TAG_LIST || $option == AI_OPTION_TAXONOMY_LIST || $option == AI_OPTION_ID_LIST || $option == AI_OPTION_URL_LIST || $option == AI_OPTION_MIN_PARAGRAPHS || $option == AI_OPTION_MAX_PARAGRAPHS || $option == AI_OPTION_SKIP_FIRST_PARAGRAPHS || $option == AI_OPTION_SKIP_LAST_PARAGRAPHS || $option == AI_OPTION_MIN_WORDS_ABOVE || $option == AI_OPTION_AVOID_PARAGRAPHS_ABOVE || $option == AI_OPTION_AVOID_PARAGRAPHS_BELOW || $option == AI_OPTION_AVOID_TRY_LIMIT || $option == AI_OPTION_MIN_WORDS || $option == AI_OPTION_MAX_WORDS || $option == AI_OPTION_MIN_PARAGRAPH_WORDS || $option == AI_OPTION_MAX_PARAGRAPH_WORDS || $option == AI_OPTION_MAXIMUM_INSERTIONS || $option == AI_OPTION_AFTER_DAYS || $option == AI_OPTION_START_DATE || $option == AI_OPTION_END_DATE || $option == AI_OPTION_SCHEDULING_FALLBACK || $option == AI_OPTION_LIMITS_FALLBACK || $option == AI_OPTION_EXCERPT_NUMBER || $option == AI_OPTION_WAIT_FOR_DELAY || $option == AI_OPTION_HORIZONTAL_MARGIN || $option == AI_OPTION_VERTICAL_MARGIN || $option == AI_OPTION_ANIMATION_TRIGGER_OFFSET || $option == AI_OPTION_ANIMATION_TRIGGER_DELAY || $option == AI_OPTION_IFRAME_WIDTH || $option == AI_OPTION_IFRAME_HEIGHT || $option == AI_OPTION_STICKY_HEIGHT || $option == AI_OPTION_AUTO_CLOSE_TIME || $option == AI_OPTION_STAY_CLOSED_TIME || $option == AI_OPTION_DELAY_SHOWING || $option == AI_OPTION_SHOW_EVERY || $option == AI_OPTION_VISITOR_MAX_IMPRESSIONS || $option == AI_OPTION_VISITOR_LIMIT_IMPRESSIONS_PER_TIME_PERIOD || $option == AI_OPTION_VISITOR_LIMIT_IMPRESSIONS_TIME_PERIOD || $option == AI_OPTION_MAX_IMPRESSIONS || $option == AI_OPTION_LIMIT_IMPRESSIONS_PER_TIME_PERIOD || $option == AI_OPTION_LIMIT_IMPRESSIONS_TIME_PERIOD || $option == AI_OPTION_VISITOR_MAX_CLICKS || $option == AI_OPTION_VISITOR_LIMIT_CLICKS_PER_TIME_PERIOD || $option == AI_OPTION_VISITOR_LIMIT_CLICKS_TIME_PERIOD || $option == AI_OPTION_MAX_CLICKS || $option == AI_OPTION_LIMIT_CLICKS_PER_TIME_PERIOD || $option == AI_OPTION_LIMIT_CLICKS_TIME_PERIOD || $option == AI_OPTION_BACKGROUND_IMAGE || $option == AI_OPTION_PARALLAX . '_1' || $option == AI_OPTION_PARALLAX . '_2' || $option == AI_OPTION_PARALLAX . '_3' || $option == AI_OPTION_PARALLAX_IMAGE . '_1' || $option == AI_OPTION_PARALLAX_IMAGE . '_2' || $option == AI_OPTION_PARALLAX_IMAGE . '_3' || $option == AI_OPTION_PARALLAX_SHIFT . '_1' || $option == AI_OPTION_PARALLAX_SHIFT . '_2' || $option == AI_OPTION_PARALLAX_SHIFT . '_3' || $option == AI_OPTION_PARALLAX_LINK || $option == 'CLICK_FRAUD_PROTECTION_TIME' || $option == 'GLOBAL_VISITOR_LIMIT_CPT' || $option == 'GLOBAL_VISITOR_LIMIT_TIME' || $option == 'ADB_DELAY_ACTION' || $option == 'ADB_NO_ACTION_PERIOD' || $option == 'ADB_REDIRECTION_PAGE' || $option == 'ADB_CUSTOM_REDIRECTION_URL' || $option == AI_OPTION_CUSTOM_CSS || $option == 'HOOK_PRIORITY' || $option == 'ADB_OVERLAY_CSS' || $option == 'ADB_MESSAGE_CSS') { $value = str_replace (array ("\"", "<", ">", "[", "]"), "", $value); $value = esc_html ($value); } elseif ($option == AI_OPTION_PARAGRAPH_NUMBER) { $value = str_replace (array ("\"", "<", ">"), "", $value); $value = esc_html ($value); } elseif ($option == AI_OPTION_URL_PARAMETER_LIST || $option == AI_OPTION_COOKIE_LIST) { $value = str_replace (array ("\"", "<", ">"), "", $value); $value = esc_html ($value); } elseif ($option == 'AD_LABEL') { $value = str_replace (array ("\\"), "", $value); $value = esc_html ($value); } elseif ($option == 'REPORT_HEADER_TITLE' || $option == 'REPORT_HEADER_DESCRIPTION' || $option == 'EXTERNAL_TRACKING_CATEGORY' || $option == 'EXTERNAL_TRACKING_ACTION' || $option == 'EXTERNAL_TRACKING_LABEL' || $option == 'REPORT_FOOTER') { $value = str_replace (array ("\\", "?"), "", $value); $value = esc_html ($value); } elseif ( $option == 'REPORT_HEADER_IMAGE') { $value = str_replace (home_url () . '/', '', $value); $value = str_replace (array ("http://", "https://", ":". "\"", "<", ">", "[", "]"), "", $value); $value = esc_html ($value); } elseif ( $option == 'RECAPTCHA_THRESHOLD' ) { $value = str_replace (array (":". "\"", "<", ">", "[", "]"), "", $value); $value = esc_html ($value); } elseif ( $option == 'MAXMIND_LICENSE_KEY' || $option == 'GEO_DB' ) { $value = str_replace (array (":". "\"", "<", ">", "[", "]"), "", $value); } return $value; } function filter_option_hf ($option, $value){ $value = str_replace (array ("\\\""), array ("\""), $value); // if ($option == AI_OPTION_CODE ) { // } elseif ($option == AI_OPTION_ENABLE_MANUAL) { // } elseif ($option == AI_OPTION_PROCESS_PHP) { // } elseif ($option == AI_OPTION_ENABLE_404) { // } elseif ($option == AI_OPTION_DETECT_SERVER_SIDE) { // } elseif ($option == AI_OPTION_DISPLAY_FOR_DEVICES) { // } return $value; } function ai_ajax () { global $ai_wp_data; // check_ajax_referer ("adinserter_data", "ai_check"); // check_admin_referer ("adinserter_data", "ai_check"); if (isset ($_POST ["adsense-ad-units"])) { if (defined ('AI_ADSENSE_API')) { adsense_ad_name (); } } elseif (isset ($_GET ["block"])) { $block = sanitize_text_field ((int) $_GET ["block"]); if (is_numeric ($block) && $block >= 1 && $block <= 96) { global $block_object; $block = $block_object [$block]; if (isset ($_GET ["cookie_check"]) && $_GET ["cookie_check"] == 1) { $block->client_side_cookie_check = true; } if (isset ($_GET ["cookie_check_url"]) && $_GET ["cookie_check_url"] == 1) { $block->client_side_cookie_check_url = true; } if (isset ($_GET ["hide-debug-labels"]) && $_GET ["hide-debug-labels"] == 1) { $block->hide_debug_labels = true; } if ($block->get_iframe ()) echo $block->get_iframe_page (); } } elseif (isset ($_GET ["ads-txt"])) { $ads_txt = get_option (AI_ADS_TXT_NAME); if ($ads_txt === false) { wp_die ('Page not found', 404); } header ('Content-Type: text/plain'); echo esc_html ($ads_txt); wp_die (); } elseif (isset ($_GET ["remote-ads-txt"]) && !function_exists ('ai_ajax_processing_2')) { if (get_remote_debugging ()) { // Read-only access if ($_GET ["remote-ads-txt"] == 'save') { wp_die (); } $_GET ["virtual"] = get_option (AI_ADS_TXT_NAME) !== false ? '1' : '0'; ads_txt (sanitize_text_field ($_GET ["remote-ads-txt"])); } } elseif (isset ($_GET ["ai-get-settings"])) { if (get_remote_debugging ()) { global $ai_db_options, $ai_db_options_multisite; if (isset ($_GET ["ai-show-errors"])) { ini_set ('display_errors', 1); error_reporting (E_ALL); } if (function_exists ('ai_check_remote_settings')) { ai_check_remote_settings (); } $tracking = false; if (defined ('AI_PLUGIN_TRACKING') && AI_PLUGIN_TRACKING) { global $ai_dst; if (isset ($ai_dst) && is_object ($ai_dst) && $ai_dst->get_plugin_tracking () !== null) { $tracking = $ai_dst->get_tracking (); } } $plugin_data = array ( 'version' => AD_INSERTER_NAME . ' ' . AD_INSERTER_VERSION, 'install' => get_option (AI_INSTALL_NAME), 'install-time' => isset ($ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]) ? $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE] : '', 'since-install' => isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL]) ? $ai_wp_data [AI_DAYS_SINCE_INSTAL] : null, 'tracking' => $tracking, 'review' => get_option ('ai-notice-review', ''), 'pro' => false, 'write' => false, 'sidebar-widgets' => get_sidebar_widgets (), 'exceptions' => ai_get_exceptions (/*ai_current_user_role_ok () && */(!is_multisite() || is_main_site () || multisite_exceptions_enabled ())), 'current-theme' => wp_get_theme (), 'virtual-ads-txt' => get_option (AI_ADS_TXT_NAME) !== false, 'categories' => ai_get_category_list (), 'tags' => ai_get_tag_list (), 'taxonomies' => ai_get_taxonomy_list (), 'post-ids' => ai_get_post_id_list (), 'license-key' => '', 'type' => '', 'status' => '', 'last-update' => '', 'client' => false, 'counter' => '', ); if (function_exists ('ai_plugin_data')) { ai_plugin_data ($plugin_data); } echo '#', base64_encode (serialize ($plugin_data)), '#'; if (is_multisite()) { echo base64_encode (serialize ($ai_db_options_multisite)); } echo "#"; if (is_multisite() && multisite_main_for_all_blogs () && defined ('BLOG_ID_CURRENT_SITE')) { echo BLOG_ID_CURRENT_SITE; } echo "#"; if (function_exists ('ai_filter_remote_settings')) { ai_filter_remote_settings ($ai_db_options); } echo base64_encode (serialize ($ai_db_options)); } } elseif (isset ($_GET ["check-page"])) { if (get_remote_debugging ()) { ai_check_page (); } } elseif (function_exists ('ai_ajax_processing_2')) { ai_ajax_processing_2 (); } wp_die (); } function ai_ajax_backend () { global $preview_name, $preview_alignment, $preview_css; // check_ajax_referer ("adinserter_data", "ai_check"); check_admin_referer ("adinserter_data", "ai_check"); if (is_multisite() && !is_main_site () && !multisite_settings_page_enabled ()) { wp_die (); } if (!current_user_can ('manage_options')) { wp_die (); } if (isset ($_POST ["preview"])) { $block = urldecode ((int) $_POST ["preview"]); if (is_numeric ($block) && $block >= 1 && $block <= 96) { $preview_parameters = array (); if (isset ($_POST ['name'])) $preview_parameters ['name'] = base64_decode ($_POST ['name']); if (isset ($_POST ['code'])) $preview_parameters ['code'] = base64_decode ($_POST ['code']); if (isset ($_POST ['alignment'])) $preview_parameters ['alignment'] = base64_decode ($_POST ['alignment']); if (isset ($_POST ['horizontal'])) $preview_parameters ['horizontal'] = base64_decode ($_POST ['horizontal']); if (isset ($_POST ['vertical'])) $preview_parameters ['vertical'] = base64_decode ($_POST ['vertical']); if (isset ($_POST ['horizontal_margin'])) $preview_parameters ['horizontal_margin'] = base64_decode ($_POST ['horizontal_margin']); if (isset ($_POST ['vertical_margin'])) $preview_parameters ['vertical_margin'] = base64_decode ($_POST ['vertical_margin']); if (isset ($_POST ['animation'])) $preview_parameters ['animation'] = base64_decode ($_POST ['animation']); if (isset ($_POST ['alignment_css'])) $preview_parameters ['alignment_css'] = base64_decode ($_POST ['alignment_css']); if (isset ($_POST ['custom_css'])) $preview_parameters ['custom_css'] = base64_decode ($_POST ['custom_css']); if (isset ($_POST ['php'])) $preview_parameters ['php'] = $_POST ['php']; if (isset ($_POST ['close'])) $preview_parameters ['close'] = $_POST ['close']; if (isset ($_POST ['background'])) $preview_parameters ['background'] = $_POST ['background']; if (isset ($_POST ['body_background'])) $preview_parameters ['body_background'] = $_POST ['body_background']; if (isset ($_POST ['background_image'])) $preview_parameters ['background_image'] = base64_decode ($_POST ['background_image']); if (isset ($_POST ['background_color'])) $preview_parameters ['background_color'] = base64_decode ($_POST ['background_color']); if (isset ($_POST ['background_size'])) $preview_parameters ['background_size'] = base64_decode ($_POST ['background_size']); if (isset ($_POST ['background_repeat'])) $preview_parameters ['background_repeat'] = base64_decode ($_POST ['background_repeat']); if (isset ($_POST ['label'])) $preview_parameters ['label'] = $_POST ['label']; if (isset ($_POST ['sticky_block'])) $preview_parameters ['sticky_block'] = $_POST ['sticky_block']; if (isset ($_POST ['sticky_height'])) $preview_parameters ['sticky_height'] = $_POST ['sticky_height']; if (isset ($_POST ['read_only'])) $preview_parameters ['read_only'] = $_POST ['read_only']; if (isset ($_POST ['iframe'])) $preview_parameters ['iframe'] = $_POST ['iframe']; if (isset ($_POST ['check'])) $preview_parameters ['check'] = $_POST ['check']; if (isset ($_POST ['count'])) $preview_parameters ['count'] = $_POST ['count']; if (isset ($_POST ['rotate'])) $preview_parameters ['rotate'] = $_POST ['rotate']; if (isset ($_POST ['viewport'])) $preview_parameters ['viewport'] = $_POST ['viewport']; if (isset ($_POST ['fallback'])) $preview_parameters ['fallback'] = $_POST ['fallback']; if (function_exists ('ai_remote_preview')) { ai_remote_preview ($block, $preview_parameters); } require_once AD_INSERTER_PLUGIN_DIR.'includes/preview.php'; generate_code_preview ( $block, $preview_parameters ); } elseif ($_POST ["preview"] == 'adb') { require_once AD_INSERTER_PLUGIN_DIR.'includes/preview-adb.php'; $message = base64_decode ($_POST ["code"]); $process_php = isset ($_POST ["php"]) && $_POST ["php"] == 1; $head = null; $processed_message = null; $footer = null; if (function_exists ('ai_remote_preview_adb')) { ai_remote_preview_adb ($message, $process_php, $head, $processed_message, $footer); } generate_code_preview_adb ($message, $process_php, false, $head, $processed_message, $footer); } elseif ($_POST ["preview"] == 'adsense') { if (defined ('AI_ADSENSE_API')) { require_once AD_INSERTER_PLUGIN_DIR.'includes/preview.php'; require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php'; if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) { $adsense = new adsense_api(); $adsense_code = $adsense->getAdCode (base64_decode ($_POST ["slot_id"])); $adsense_error = $adsense->getError (); $preview_parameters = array ( "name" => isset ($_POST ["name"]) ? base64_decode ($_POST ["name"]) : 'ADSENSE CODE', "alignment" => '', "horizontal" => '', "vertical" => '', "alignment_css" => '', "custom_css" => '', "code" => $adsense_error == '' ? $adsense_code : '
    '.$adsense_error.'
    ', "php" => false, "label" => false, "close" => AI_CLOSE_NONE, "read_only" => true, ); generate_code_preview ( 0, // Default settings $preview_parameters ); } } } } elseif (isset ($_POST ["edit"])) { if (is_numeric ($_POST ["edit"]) && $_POST ["edit"] >= 1 && $_POST ["edit"] <= 96) { require_once AD_INSERTER_PLUGIN_DIR.'includes/editor.php'; $process_php = isset ($_POST ["php"]) && $_POST ["php"] == 1; generate_code_editor ((int) $_POST ["edit"], base64_decode ($_POST ["code"]), $process_php); } } if (isset ($_POST ["placeholder"])) { $block = urldecode ((int) $_POST ["block"]); if (is_numeric ($block) && $block >= 1 && $block <= 96) { require_once AD_INSERTER_PLUGIN_DIR.'includes/placeholders.php'; generate_placeholder_editor (str_replace (array ('"', "\\'"), array ('"', '''), urldecode ($_POST ["placeholder"])), $block); } } elseif (isset ($_POST ["generate-code"])) { $code_generator = new ai_code_generator (); echo json_encode ($code_generator->generate ($_POST)); } elseif (isset ($_POST ["import-code"])) { $code_generator = new ai_code_generator (); echo json_encode ($code_generator->import (base64_decode ($_POST ["import-code"]))); } elseif (isset ($_POST ["import-rotation-code"])) { $code_generator = new ai_code_generator (); echo json_encode ($code_generator->import_rotation (base64_decode ($_POST ["import-rotation-code"]))); } elseif (isset ($_POST ["generate-rotation-code"])) { $code_generator = new ai_code_generator (); echo json_encode ($code_generator->generate_rotation (json_decode (base64_decode ($_POST ['generate-rotation-code']), true))); } elseif (isset ($_GET ["image"])) { $filename = sanitize_file_name ($_GET ["image"]); header ("Content-Type: image/png"); header ("Content-Length: " . filesize (AD_INSERTER_PLUGIN_DIR.'images/'.$filename)); readfile (AD_INSERTER_PLUGIN_DIR.'images/'.$filename); } elseif (isset ($_GET ["css"])) { $filename = sanitize_file_name ($_GET ["css"]); header ("Content-Type: text/css"); header ("Content-Length: " . filesize (AD_INSERTER_PLUGIN_DIR.'css/'.$filename)); readfile (AD_INSERTER_PLUGIN_DIR.'css/'.$filename); } elseif (isset ($_GET ["js"])) { $filename = sanitize_file_name ($_GET ["js"]); header ("Content-Type: application/javascript"); header ("Content-Length: " . filesize (AD_INSERTER_PLUGIN_DIR.'js/'.$filename)); readfile (AD_INSERTER_PLUGIN_DIR.'js/'.$filename); } elseif (isset ($_GET ["rating"])) { $cache_time = $_GET ["rating"] == 'update' ? 0 * 60 : AI_TRANSIENT_RATING_EXPIRATION; if (!get_transient (AI_TRANSIENT_RATING) || !($transient_timeout = get_option ('_transient_timeout_' . AI_TRANSIENT_RATING)) || AI_TRANSIENT_RATING_EXPIRATION - ($transient_timeout - time ()) > $cache_time) { $args = (object) array ('slug' => 'ad-inserter'); $request = array ('action' => 'plugin_information', 'timeout' => 5, 'request' => serialize ($args)); $url = 'http://api.wordpress.org/plugins/info/1.0/'; $response = wp_remote_post ($url, array ('body' => $request)); $plugin_info = @unserialize ($response ['body']); if (isset ($plugin_info->ratings)) { $total_rating = 0; $total_count = 0; foreach ($plugin_info->ratings as $rating => $count) { $total_rating += $rating * $count; $total_count += $count; } $rating = number_format ($total_rating / $total_count, 4); set_transient (AI_TRANSIENT_RATING, $rating, AI_TRANSIENT_RATING_EXPIRATION); } } if ($rating = get_transient (AI_TRANSIENT_RATING)) { if ($rating > 1 && $rating <= 5) echo $rating; } } elseif (isset ($_POST ["notice"])) { update_option ('ai-notice-' . esc_html ($_POST ["notice"]), esc_html ($_POST ["click"])); } elseif (isset ($_POST ["notice-check"])) { echo esc_html ($_POST ["notice-check"]); } elseif (isset ($_GET ["list"])) { $search_text = esc_html (trim ($_GET ["list"])); $show_all_blocks = isset ($_GET ["all"]) && $_GET ["all"]; $start = (int) $_GET ["start"]; if ($start < 1 || $start > 96) $start = 1; $end = (int) $_GET ["end"]; if ($end < 1 || $end > 96 || $end < $start) $end = 16; $active = (int) $_GET ["active"]; if ($active < 1 || $active > 96) $active = 1; code_block_list ($start, $end, $search_text, $show_all_blocks, $active); } elseif (isset ($_GET ["adsense-list"])) { if (defined ('AI_ADSENSE_API')) { adsense_list (); } } elseif (isset ($_GET ["adsense-code"])) { if (defined ('AI_ADSENSE_API')) { ai_adsense_code (esc_html ($_GET ["adsense-code"])); } } elseif (isset ($_GET ["adsense-authorization-code"])) { if (defined ('AI_ADSENSE_API')) { if ($_GET ['adsense-authorization-code'] == '') { delete_option (AI_ADSENSE_CLIENT_IDS); delete_option (AI_ADSENSE_AUTH_CODE); delete_option (AI_ADSENSE_OWN_IDS); delete_transient (AI_TRANSIENT_ADSENSE_TOKEN_1); delete_transient (AI_TRANSIENT_ADSENSE_TOKEN); delete_transient (AI_TRANSIENT_ADSENSE_ADS); } elseif (base64_decode ($_GET ['adsense-authorization-code']) == 'own-ids') { update_option (AI_ADSENSE_OWN_IDS, '1'); delete_option (AI_ADSENSE_CLIENT_IDS); delete_option (AI_ADSENSE_AUTH_CODE); delete_transient (AI_TRANSIENT_ADSENSE_TOKEN_1); delete_transient (AI_TRANSIENT_ADSENSE_TOKEN); delete_transient (AI_TRANSIENT_ADSENSE_ADS); } // else update_option (AI_ADSENSE_AUTH_CODE, base64_decode ($_GET ['adsense-authorization-code'])); } } elseif (isset ($_GET ["adsense-client-id"])) { if (defined ('AI_ADSENSE_API')) { if ($_GET ['adsense-client-id'] == '') { delete_option (AI_ADSENSE_CLIENT_IDS); delete_option (AI_ADSENSE_AUTH_CODE); delete_transient (AI_TRANSIENT_ADSENSE_TOKEN_1); delete_transient (AI_TRANSIENT_ADSENSE_TOKEN); delete_transient (AI_TRANSIENT_ADSENSE_ADS); } else update_option (AI_ADSENSE_CLIENT_IDS, array ('ID' => base64_decode ($_GET ['adsense-client-id']), 'SECRET' => base64_decode ($_GET ['adsense-client-secret']))); } } elseif (isset ($_GET ["ads-txt"])) { if (!is_multisite() || is_main_site ()) { if (function_exists ('ai_remote_ads_txt') && ai_remote_ads_txt ()) { wp_die (); } ads_txt (esc_html ($_GET ["ads-txt"])); } } elseif (isset ($_GET ["settings"])) { generate_settings_form (); } elseif (isset ($_GET ["list-options"])) { generate_list_options (esc_html ($_GET ["list-options"])); } elseif (isset ($_GET ["update"])) { if ($_GET ["update"] == 'block-code-demo') { ai_block_code_demo (urldecode ($_GET ["block_class_name"]), esc_html ($_GET ["block_class"]), esc_html ($_GET ["block_number_class"]), esc_html ($_GET ["block_name_class"]), esc_html ($_GET ["inline_styles"])); } elseif (function_exists ('ai_ajax_backend_2')) { ai_ajax_backend_2 (); } } elseif (isset ($_GET ["check-page"])) { if (function_exists ('ai_check_remote_page') && ai_check_remote_page ()) { wp_die (); } ai_check_page (); } elseif (function_exists ('ai_ajax_backend_2')) { ai_ajax_backend_2 (); } wp_die (); } function ai_generate_extract (&$settings) { global $ai_custom_hooks, $ai_wp_data, $version_string, $subversion_string; if (!defined ('AI_EXTRACT_GENERATED')) define ('AI_EXTRACT_GENERATED', true); $obj = new ai_Block (1); $extract = array (); if (defined ('AI_BUFFERING')) { $above_header_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); $html_element_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); } $content_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); $excerpt_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); $loop_start_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); $loop_end_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); $post_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); $before_comments_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); $between_comments_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); $after_comments_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); $footer_hook_blocks = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); $custom_hook_blocks = array (); for ($custom_hook = 1; $custom_hook <= 20; $custom_hook ++) { $custom_hook_blocks [] = array (AI_PT_ANY => array (), AI_PT_HOMEPAGE => array(), AI_PT_CATEGORY => array(), AI_PT_SEARCH => array(), AI_PT_ARCHIVE => array(), AI_PT_STATIC => array(), AI_PT_POST => array(), AI_PT_404 => array(), AI_PT_FEED => array(), AI_PT_AJAX => array()); } // Get blocks used in sidebar widgets $sidebar_widgets = wp_get_sidebars_widgets(); $widget_options = get_option ('widget_ai_widget'); $widget_blocks = array (); foreach ($sidebar_widgets as $sidebar_index => $sidebar_widget) { if (is_array ($sidebar_widget) && isset ($GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'])) { $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name']; if ($sidebar_name != "") { foreach ($sidebar_widget as $widget) { if (preg_match ("/ai_widget-([\d]+)/", $widget, $widget_id)) { if (isset ($widget_id [1]) && is_numeric ($widget_id [1])) { $widget_option = $widget_options [$widget_id [1]]; $widget_block = $widget_option ['block']; if ($widget_block >= 1 && $widget_block <= 96) { $widget_blocks [] = $widget_block; } } } } } } } $widget_blocks = array_unique ($widget_blocks); // Generate extracted data $active_blocks = array (); $temp_ai_wp_data = $ai_wp_data; $ai_wp_data [AI_MOBILE_DETECT_JS] = false; $ai_wp_data [AI_SERVER_SIDE_DETECTION] = false; $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = false; $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT; $ai_wp_data [AI_STICK_TO_THE_CONTENT] = false; $ai_wp_data [AI_TRACKING] = false; $ai_wp_data [AI_CLOSE_BUTTONS] = false; $ai_wp_data [AI_PARALLAX] = false; $ai_wp_data [AI_CHECK_BLOCK] = false; $ai_wp_data [AI_IFRAMES] = false; $ai_wp_data [AI_ANIMATION] = false; $ai_wp_data [AI_LAZY_LOADING] = false; $ai_wp_data [AI_GEOLOCATION] = false; for ($block = 1; $block <= 96; $block ++) { if (!isset ($settings [$block])) continue; $obj->number = $block; $obj->wp_options = $settings [$block]; $page_types = array (); if ($obj->get_display_settings_home()) $page_types []= AI_PT_HOMEPAGE; if ($obj->get_display_settings_page()) $page_types []= AI_PT_STATIC; if ($obj->get_display_settings_post()) $page_types []= AI_PT_POST; if ($obj->get_display_settings_category()) $page_types []= AI_PT_CATEGORY; if ($obj->get_display_settings_search()) $page_types []= AI_PT_SEARCH; if ($obj->get_display_settings_archive()) $page_types []= AI_PT_ARCHIVE; if ($obj->get_enable_ajax()) $page_types []= AI_PT_AJAX; if ($obj->get_enable_feed()) $page_types []= AI_PT_FEED; if ($obj->get_enable_404()) $page_types []= AI_PT_404; $automatic_insertion = $obj->get_automatic_insertion(); $enabled_insertion = $obj->get_disable_insertion() == AI_DISABLED; if ($page_types && $enabled_insertion) { // Change insertion position to actual server-side insertion position switch ($automatic_insertion) { case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT: case AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT: case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT: switch ($obj->get_html_element_insertion ()) { case AI_HTML_INSERTION_SEREVR_SIDE: $automatic_insertion = AI_AUTOMATIC_INSERTION_OUTPUT_BUFFERING; break; default: $automatic_insertion = $obj->get_server_side_insertion (); break; } break; } switch ($automatic_insertion) { case AI_AUTOMATIC_INSERTION_ABOVE_HEADER: if (defined ('AI_BUFFERING')) { foreach ($page_types as $block_page_type) $above_header_hook_blocks [$block_page_type][]= $block; $above_header_hook_blocks [AI_PT_ANY][]= $block; } break; case AI_AUTOMATIC_INSERTION_OUTPUT_BUFFERING: if (defined ('AI_BUFFERING')) { foreach ($page_types as $block_page_type) $html_element_hook_blocks [$block_page_type][]= $block; $html_element_hook_blocks [AI_PT_ANY][]= $block; } break; case AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH: case AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH: case AI_AUTOMATIC_INSERTION_BEFORE_IMAGE: case AI_AUTOMATIC_INSERTION_AFTER_IMAGE: case AI_AUTOMATIC_INSERTION_BEFORE_CONTENT: case AI_AUTOMATIC_INSERTION_AFTER_CONTENT: foreach ($page_types as $block_page_type) $content_hook_blocks [$block_page_type][]= $block; $content_hook_blocks [AI_PT_ANY][]= $block; break; case AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT: case AI_AUTOMATIC_INSERTION_AFTER_EXCERPT: foreach ($page_types as $block_page_type) $excerpt_hook_blocks [$block_page_type][]= $block; $excerpt_hook_blocks [AI_PT_ANY][]= $block; break; case AI_AUTOMATIC_INSERTION_BEFORE_POST: foreach ($page_types as $block_page_type) $loop_start_hook_blocks [$block_page_type][]= $block; $loop_start_hook_blocks [AI_PT_ANY][]= $block; break; case AI_AUTOMATIC_INSERTION_AFTER_POST: foreach ($page_types as $block_page_type) $loop_end_hook_blocks [$block_page_type][]= $block; $loop_end_hook_blocks [AI_PT_ANY][]= $block; break; case AI_AUTOMATIC_INSERTION_BETWEEN_POSTS: foreach ($page_types as $block_page_type) $post_hook_blocks [$block_page_type][]= $block; $post_hook_blocks [AI_PT_ANY][]= $block; break; case AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS: foreach ($page_types as $block_page_type) $before_comments_hook_blocks [$block_page_type][]= $block; $before_comments_hook_blocks [AI_PT_ANY][]= $block; break; case AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS: foreach ($page_types as $block_page_type) $between_comments_hook_blocks [$block_page_type][]= $block; $between_comments_hook_blocks [AI_PT_ANY][]= $block; break; case AI_AUTOMATIC_INSERTION_AFTER_COMMENTS: foreach ($page_types as $block_page_type) $after_comments_hook_blocks [$block_page_type][]= $block; $after_comments_hook_blocks [AI_PT_ANY][]= $block; break; case AI_AUTOMATIC_INSERTION_FOOTER: foreach ($page_types as $block_page_type) $footer_hook_blocks [$block_page_type][]= $block; $footer_hook_blocks [AI_PT_ANY][]= $block; break; default: if ($automatic_insertion >= AI_AUTOMATIC_INSERTION_CUSTOM_HOOK && $automatic_insertion < AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + 20) { $hook_index = $automatic_insertion - AI_AUTOMATIC_INSERTION_CUSTOM_HOOK; foreach ($page_types as $block_page_type) $custom_hook_blocks [$hook_index][$block_page_type][]= $block; $custom_hook_blocks [$hook_index][AI_PT_ANY][]= $block; } break; } } $automatic = $automatic_insertion != AI_AUTOMATIC_INSERTION_DISABLED; $manual_widget = $obj->get_enable_widget() == AI_ENABLED; $manual_shortcode = $obj->get_enable_manual() == AI_ENABLED; $manual_php_function = $obj->get_enable_php_call() == AI_ENABLED; if ($enabled_insertion && ($automatic || ($manual_widget && in_array ($block, $widget_blocks)) || $manual_shortcode || $manual_php_function)) { $active_blocks []= $block; $obj->extract_features (); } } $extract [AI_EXTRACT_USED_BLOCKS] = serialize ($active_blocks); if (isset ($settings [AI_HEADER_OPTION_NAME])) { $obj->wp_options = $settings [AI_HEADER_OPTION_NAME]; if ($obj->get_enable_manual () && $obj->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true; } if (isset ($settings [AI_FOOTER_OPTION_NAME])) { $obj->wp_options = $settings [AI_FOOTER_OPTION_NAME]; if ($obj->get_enable_manual () && $obj->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true; } if (function_exists ('ai_global_extract_features')) { ai_global_extract_features (); } $extract [AI_EXTRACT_FEATURES] = array ( AI_MOBILE_DETECT_JS => $ai_wp_data [AI_MOBILE_DETECT_JS], AI_SERVER_SIDE_DETECTION => $ai_wp_data [AI_SERVER_SIDE_DETECTION], AI_CLIENT_SIDE_DETECTION => $ai_wp_data [AI_CLIENT_SIDE_DETECTION], AI_CLIENT_SIDE_INSERTION => $ai_wp_data [AI_CLIENT_SIDE_INSERTION], AI_STICK_TO_THE_CONTENT => $ai_wp_data [AI_STICK_TO_THE_CONTENT], AI_TRACKING => $ai_wp_data [AI_TRACKING], AI_CLOSE_BUTTONS => $ai_wp_data [AI_CLOSE_BUTTONS], AI_PARALLAX => $ai_wp_data [AI_PARALLAX], AI_CHECK_BLOCK => $ai_wp_data [AI_CHECK_BLOCK], AI_IFRAMES => $ai_wp_data [AI_IFRAMES], AI_ANIMATION => $ai_wp_data [AI_ANIMATION], AI_LAZY_LOADING => $ai_wp_data [AI_LAZY_LOADING], AI_GEOLOCATION => $ai_wp_data [AI_GEOLOCATION] ); $ai_wp_data = $temp_ai_wp_data; if (defined ('AI_BUFFERING')) { $extract [ABOVE_HEADER_HOOK_BLOCKS] = $above_header_hook_blocks; $extract [HTML_ELEMENT_HOOK_BLOCKS] = $html_element_hook_blocks; } $extract [CONTENT_HOOK_BLOCKS] = $content_hook_blocks; $extract [EXCERPT_HOOK_BLOCKS] = $excerpt_hook_blocks; $extract [LOOP_START_HOOK_BLOCKS] = $loop_start_hook_blocks; $extract [LOOP_END_HOOK_BLOCKS] = $loop_end_hook_blocks; $extract [POST_HOOK_BLOCKS] = $post_hook_blocks; $extract [BEFORE_COMMENTS_HOOK_BLOCKS] = $before_comments_hook_blocks; $extract [BETWEEN_COMMENTS_HOOK_BLOCKS] = $between_comments_hook_blocks; $extract [AFTER_COMMENTS_HOOK_BLOCKS] = $after_comments_hook_blocks; $extract [FOOTER_HOOK_BLOCKS] = $footer_hook_blocks; for ($custom_hook = 1; $custom_hook <= 20; $custom_hook ++) { $action = get_hook_action ($custom_hook); if (get_hook_enabled ($custom_hook) && get_hook_name ($custom_hook) != '' && $action != '') { $custom_hook_extract_index = $action . CUSTOM_HOOK_BLOCKS; if (isset ($extract [$custom_hook_extract_index])) { // Custom hook on WP hook used by the plugin - merge blocks foreach ($extract [$custom_hook_extract_index] as $page_type => $blocks) { $extract [$custom_hook_extract_index][$page_type] = array_merge ($blocks, $custom_hook_blocks [$custom_hook - 1][$page_type]); } } else $extract [$custom_hook_extract_index] = $custom_hook_blocks [$custom_hook - 1]; } } $extract_version = $version_string . $subversion_string . '-' . '96'; if (function_exists ('ai_system_output_check')) { $extract_version .= 'P'; } $extract ['VERSION'] = $extract_version; $extract ['TIMESTAMP'] = time (); return ($extract); } function ai_load_settings () { global $ai_db_options, $block_object, $ai_wp_data, $version_string, $ai_custom_hooks; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS START"); if (get_option (AI_OPTION_NAME) === false) { $initial_settings = ''; $initial_settings = apply_filters ('ai_initial_settings', $initial_settings); if (is_string ($initial_settings) && substr ($initial_settings, 0, 4) === ':AI:') { update_option (AI_OPTION_NAME, $initial_settings); } elseif (is_array ($initial_settings)) { $ai_db_options = $initial_settings; ai_save_options ($ai_db_options); } } ai_load_options (); if (!is_array ($ai_db_options)) { $ai_db_options = array (); define ('AI_SETTINGS_ERROR', true); } $extract_ok = ai_load_extract (false); $ai_custom_hooks = array (); for ($hook = 1; $hook <= 20; $hook ++) { $name = get_hook_name ($hook); $action = get_hook_action ($hook); if (get_hook_enabled ($hook) && $name != '' && $action != '') { $ai_custom_hooks [] = array ('index' => $hook, 'name' => $name, 'action' => $action, 'priority' => get_hook_priority ($hook)); } } $features_in_extract = $extract_ok && isset ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES]); if (isset ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) && is_string ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) && strlen ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) != 0) { $used_blocks = @unserialize ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]); } else $used_blocks = false; $obj = new ai_Block (0); // translators: block name (block with default settings) $obj->wp_options [AI_OPTION_BLOCK_NAME] = _x('Default', 'Block name', 'ad-inserter'); $block_object [0] = $obj; for ($block = 1; $block <= 96; $block ++) { $obj = new ai_Block ($block); $obj->load_options ($block); $block_object [$block] = $obj; if (!$features_in_extract && (!is_array ($used_blocks) || in_array ($block, $used_blocks))) $obj->extract_features (); } $adH = new ai_AdH(); $adF = new ai_AdF(); $adH->load_options (AI_HEADER_OPTION_NAME); $adF->load_options (AI_FOOTER_OPTION_NAME); $block_object [AI_HEADER_OPTION_NAME] = $adH; $block_object [AI_FOOTER_OPTION_NAME] = $adF; if ($features_in_extract) { $ai_wp_data [AI_MOBILE_DETECT_JS] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_MOBILE_DETECT_JS]; $ai_wp_data [AI_SERVER_SIDE_DETECTION] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_SERVER_SIDE_DETECTION]; $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_CLIENT_SIDE_DETECTION]; $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_CLIENT_SIDE_INSERTION]; $ai_wp_data [AI_STICK_TO_THE_CONTENT] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_STICK_TO_THE_CONTENT]; $ai_wp_data [AI_TRACKING] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_TRACKING]; $ai_wp_data [AI_CLOSE_BUTTONS] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_CLOSE_BUTTONS]; $ai_wp_data [AI_PARALLAX] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_PARALLAX]; $ai_wp_data [AI_CHECK_BLOCK] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_CHECK_BLOCK]; $ai_wp_data [AI_IFRAMES] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_IFRAMES]; $ai_wp_data [AI_ANIMATION] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_ANIMATION]; $ai_wp_data [AI_LAZY_LOADING] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_LAZY_LOADING]; $ai_wp_data [AI_GEOLOCATION] = $ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_FEATURES][AI_GEOLOCATION]; } else { if ($adH->get_enable_manual () && $adH->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true; if ($adF->get_enable_manual () && $adF->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true; } if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { $adA = new ai_AdA(); $adA->load_options (AI_ADB_MESSAGE_OPTION_NAME); $block_object [AI_ADB_MESSAGE_OPTION_NAME] = $adA; $ai_wp_data [AI_ADB_DETECTION] = $adA->get_enable_manual (); } if (($install_timestamp = get_option (AI_INSTALL_NAME)) !== false) { $install = new DateTime (date('Y-m-d H:i:s', $install_timestamp)); $now = new DateTime (date('Y-m-d H:i:s', time())); if (method_exists ($install, 'diff')) { $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE] = $install->diff ($now); $ai_wp_data [AI_DAYS_SINCE_INSTAL] = $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->days; } } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS END"); } function ai_compare_viewport ($a, $b) { if ($a ['width'] == $b ['width']) return 0; return ($a ['width'] > $b ['width']) ? - 1 : 1; } function generate_viewport_css () { $viewports = array (); for ($viewport = 1; $viewport <= 6; $viewport ++) { $viewport_name = get_viewport_name ($viewport); $viewport_width = get_viewport_width ($viewport); if ($viewport_name != '') { $viewports []= array ('index' => $viewport, 'name' => $viewport_name, 'width' => $viewport_width); } } usort ($viewports, 'ai_compare_viewport'); $viewport_styles = ''; $number_of_viewports = count ($viewports); if ($number_of_viewports != 0) { $viewport_styles = ".ai-viewports {--ai: 1;}\n"; // Mark unprocessed block for viewports, also dummy style to prevent not loading viewport rules when optimizers join them with other (broken) styles on the page foreach ($viewports as $index => $viewport) { if ($index == 0) { foreach (array_reverse ($viewports) as $index2 => $viewport2) { if ($index2 != $number_of_viewports - 1) { $viewport_styles .= ".ai-viewport-" . $viewport2 ['index'] . " { display: none !important;}\n"; } } $viewport_styles .= ".ai-viewport-".$viewports [0]['index']." { display: inherit !important;}\n"; $viewport_styles .= ".ai-viewport-0 { display: none !important;}\n"; } else { $viewport_styles .= "@media "; if ($viewport ['width'] != 0) $viewport_styles .= "(min-width: " . $viewport ['width'] . "px) and "; $viewport_styles .= "(max-width: " . ($viewports [$index - 1]['width'] - 1) . "px) {\n"; foreach ($viewports as $index2 => $viewport2) { if ($index2 == 0) $viewport_styles .= ".ai-viewport-" . $viewport2 ['index'] . " { display: none !important;}\n"; elseif ($index == $index2) $viewport_styles .= ".ai-viewport-" . $viewport2 ['index'] . " { display: inherit !important;}\n"; } $viewport_styles .= "}\n"; } } } return ($viewport_styles); } function get_main_alignment_css ($alt_styles_text) { if (strpos ($alt_styles_text, "||") !== false) { $styles = explode ("||", $alt_styles_text); return $styles [0]; } return $alt_styles_text; } function ai_change_css ($css, $property, $value) { $styles = explode (';', $css); $replaced = false; foreach ($styles as $index => $style) { if (strpos (trim ($style), $property) === 0) { $styles [$index] = preg_replace ('/\:\s*(.+)/', ': ' . $value, $styles [$index]); $replaced = true; break; } } $new_style = implode (';', $styles); if (!$replaced) { $new_style = rtrim ($new_style, '; '); return $new_style . '; ' . $property . ': ' . $value . ';'; } return $new_style; } function generate_alignment_css () { global $ai_db_options_extract, $block_object; $block_class_name = get_block_class_name (true) . '-'; $styles = array (); $styles [AI_ALIGNMENT_DEFAULT] = array (AI_TEXT_ENG_DEFAULT, get_main_alignment_css (AI_ALIGNMENT_CSS_DEFAULT)); $styles [AI_ALIGNMENT_LEFT] = array (AI_TEXT_ENG_LEFT, get_main_alignment_css (AI_ALIGNMENT_CSS_LEFT)); $styles [AI_ALIGNMENT_RIGHT] = array (AI_TEXT_ENG_RIGHT, get_main_alignment_css (AI_ALIGNMENT_CSS_RIGHT)); $styles [AI_ALIGNMENT_CENTER] = array (AI_TEXT_ENG_CENTER, get_main_alignment_css (AI_ALIGNMENT_CSS_CENTER)); $styles [AI_ALIGNMENT_FLOAT_LEFT] = array (AI_TEXT_ENG_FLOAT_LEFT, get_main_alignment_css (AI_ALIGNMENT_CSS_FLOAT_LEFT)); $styles [AI_ALIGNMENT_FLOAT_RIGHT] = array (AI_TEXT_ENG_FLOAT_RIGHT, get_main_alignment_css (AI_ALIGNMENT_CSS_FLOAT_RIGHT)); if (function_exists ('generate_alignment_css_2')) $styles = array_replace ($styles, generate_alignment_css_2 ()); $alignment_css = ''; $alignments = array (); $used_blocks = unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]); foreach ($used_blocks as $used_block) { $obj = $block_object [$used_block]; $alignment_type = $obj->get_alignment_type (); switch ($alignment_type) { case AI_ALIGNMENT_DEFAULT: case AI_ALIGNMENT_LEFT: case AI_ALIGNMENT_RIGHT: case AI_ALIGNMENT_CENTER: case AI_ALIGNMENT_FLOAT_LEFT: case AI_ALIGNMENT_FLOAT_RIGHT: // case AI_ALIGNMENT_STICKY_LEFT: // case AI_ALIGNMENT_STICKY_RIGHT: // case AI_ALIGNMENT_STICKY_TOP: // case AI_ALIGNMENT_STICKY_BOTTOM: $alignment_name = strtolower ($styles [$alignment_type][0]); if (!in_array ($alignment_name, $alignments)) { $alignments []= $alignment_name; $alignment_css .= '.' . $block_class_name . str_replace (' ', '-', $alignment_name) .' {' . $styles [$alignment_type][1] . "}\n"; } break; case AI_ALIGNMENT_STICKY: $sticky_css = $obj->alignment_style ($alignment_type); $alignment_name = strtolower (md5 ($sticky_css)); if (!in_array ($alignment_name, $alignments)) { $alignments []= $alignment_name; // $alignment_css .= '.' . $block_class_name . str_replace (' ', '-', $alignment_name) .' {' . $sticky_css . "}\n"; $alignment_css .= '.' . $block_class_name . $alignment_name .' {' . $sticky_css . "}\n"; } break; case AI_ALIGNMENT_CUSTOM_CSS: $custom_css = $obj->get_custom_css (); $alignment_name = strtolower (md5 ($custom_css)); if (!in_array ($alignment_name, $alignments)) { $alignments []= $alignment_name; // $alignment_css .= '.' . $block_class_name . str_replace (' ', '-', $alignment_name) .' {' . str_replace (''', "'", $custom_css) . "}\n"; $alignment_css .= '.' . $block_class_name . $alignment_name .' {' . str_replace (''', "'", $custom_css) . "}\n"; } break; } if ($alignment_type != AI_ALIGNMENT_CUSTOM_CSS) { $size_css = $obj->size_background_style (); // $size_name = strtolower (md5 ($size_css)); $size_name = ai_css_to_name ($size_css); if (!in_array ($size_name, $alignments)) { $alignments []= $size_name; $alignment_css .= '.' . $block_class_name . $size_name .' {' . str_replace (''', "'", $size_css) . "}\n"; } } } return $alignment_css; } function generate_debug_css_base () { ?> .ai-debug-block {padding: 0; margin: 0;} .ai-debug-tags {font-weight: bold; color: white; padding: 2px;} .ai-debug-positions {clear: both; text-align: center; padding: 10px 0; font-family: arial; font-weight: bold; line-height: 20px; border: 1px solid blue; color: blue; background: #eef;} .ai-debug-positions.ai-images {border: 1px solid #444; color: #444; background: #fff9ab;} .ai-debug-page-type {text-align: center; padding: 10px 0; font-family: arial; font-weight: bold; line-height: 20px; border: 1px solid #000; color: #000; background: #fff;} .ai-debug-status {clear: both; text-align: center; padding: 10px 0; font-family: arial; font-weight: bold; line-height: 20px; border: 1px solid #eee; color: #666; background: #eee;} .ai-debug-status.status-ok, .ai-debug-status.adb-off {border: 1px solid green; color: green; background: #efe;} .ai-debug-status.status-error, .ai-debug-status.adb-on {border: 1px solid red; color: red; background: #fee;} .ai-debug-adb {opacity: 0.85; cursor: pointer;} .ai-debug-widget {margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;} a.ai-debug-left {float: left; cursor: default; font-size: 10px; text-decoration: none; color: transparent; padding: 0px 10px 0 0; border: 0; box-shadow: none;} a.ai-debug-right {float: right; cursor: default; font-size: 10px; text-decoration: none; color: #88f; padding: 0px 10px 0 0; border: 0; box-shadow: none;} a.ai-debug-center {text-align: center; cursor: default; font-size: 10px; text-decoration: none; color: white; padding: 0px 10px 0 0; border: 0; box-shadow: none;} .ai-debug-invisible {display: none;} .ai-debug-content-hook-positions {color: blue;} .ai-debug-removed-html-tags {color: red;} .ai-debug-rnrn {background: #0ff; color: #000;} .ai-debug-p {background: #0a0;} .ai-debug-div {background: #46f;} .ai-debug-h {background: #d4e;} .ai-debug-img {background: #ee0; color: #000;} .ai-debug-pre {background: #222;} .ai-debug-span {background: #cff; color: #000;} .ai-debug-special {background: #fb0; color: #000;} .ai-debug-ad-overlay {position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: #8f8; opacity: 0.6; z-index: 999999990} .ai-debug-block ins.adsbygoogle[data-ad-status="unfilled"] .ai-debug-ad-overlay {display: none;} .ai-debug-block ins.adsbygoogle[data-ad-status="unfilled"] {background: url(https://via.placeholder.com/800x800/aaffaa/000000.png?text=NO%20AD%20SERVED); background-size: cover; background-repeat: no-repeat; background-position: center;} .ai-auto-ads {background-color: #84f;} .ai-no-slot {background-color: #48f;} .ai-debug-ad-info {position: absolute; top: 0; left: 0; overflow: hidden; width: auto; height: auto; font-family: arial; font-size: 11px; line-height: 11px; text-align: left; z-index: 999999991;} .ai-info {display: inline-block; padding: 2px 4px;} .ai-info-1 {background: #000; color: #fff;} .ai-info-2 {background: #fff; color: #000;} .ai-debug-block {outline: 1px solid;} .ai-debug-bar {background: #666;} .ai-debug-block kbd kbd {font-weight: normal;} .ai-debug-code {margin: 0; padding: 0; border: 0; font-family: monospace, sans-serif; font-size: 12px; line-height: 13px; background: #fff; color: #000;} .ai-debug-code.ai-code-org {float: left; max-width: 47%;} .ai-debug-code.ai-code-inserted {float: right; max-width: 47%;} .ai-debug-block.ai-debug-default {border-color: #e00; outline-color: #e00;} .ai-debug-bar.ai-debug-default {background: #e00;} .ai-debug-bar.ai-debug-no-wrapping kbd {color: #ff0;} .ai-debug-block.ai-debug-viewport-invisible {border-color: #00f; outline-color: #00f;} .ai-debug-bar.ai-debug-viewport-invisible {background: #00f;} .ai-debug-block.ai-debug-amp {border-color: #0c0; outline-color: #0c0;} .ai-debug-bar.ai-debug-amp {background: #0c0;} .ai-debug-block.ai-debug-fallback {border-color: #a0f; outline-color: #a0f;} .ai-debug-bar.ai-debug-fallback {background: #a0f;} .ai-debug-block.ai-debug-script {border-color: #00bae6; outline-color: #00bae6; background: #eee;} .ai-debug-bar.ai-debug-script {background: #00bae6;} .ai-debug-block.ai-debug-cookie {border-color: #9be3ff; outline-color: #9be3ff; background: #eee;} .ai-debug-bar.ai-debug-cookie {background: #9be3ff;} .ai-debug-bar.ai-debug-cookie kbd {color: #000;} .ai-debug-block.ai-debug-filter {border-color: #9be3ff; outline-color: #9be3ff; background: #eee;} .ai-debug-bar.ai-debug-filter {background: #9be3ff;} .ai-debug-bar.ai-debug-filter kbd {color: #000;} .ai-debug-block.ai-debug-adb-status {border-color: #000; outline-color: #000;} .ai-debug-bar.ai-debug-adb-status {background: #000;} .ai-debug-block.ai-debug-adsense {border-color: #e0a; outline-color: #e0a;} .ai-debug-bar.ai-debug-adsense {background: #e0a;} .ai-debug-block.ai-debug-adsense.ai-adsense-auto-ads {position: absolute; top: -20px; width: 100%;} .ai-debug-block.ai-debug-ajax {border-color: #ffd600; outline-color: #ffd600;} .ai-debug-bar.ai-debug-ajax {background: #ffd600;} .ai-debug-bar.ai-debug-ajax kbd {color: #000;} .ai-debug-block.ai-debug-iframe {border-color: #ff9e38; outline-color: #ff9e38; line-height: 1px;} .ai-debug-bar.ai-debug-iframe {background: #ff9e38;} .ai-debug-bar.ai-debug-iframe kbd {color: #000;} .ai-debug-block.ai-debug-iframe .ai-attributes {line-height: initial;} .ai-debug-adb-status.on kbd {color: #f00;} .ai-debug-adb-status.off kbd {color: #0f0;} .ai-debug-block.ai-debug-lists {border-color: #00c5be; outline-color: #00c5be;} .ai-debug-bar.ai-debug-lists {background: #00c5be;} .ai-debug-block.ai-debug-scheduling {border-color: #00c5be; outline-color: #00c5be;} .ai-debug-bar.ai-debug-scheduling {background: #00c5be;} .ai-debug-adb-hidden {visibility: hidden; display: none;} .ai-debug-adb-center {text-align: center; font-weight: bold; margin: 0; padding: 4px 0;} .ai-debug-bar {margin: 0; padding: 1px 0 1px 5px; color: white; font-size: 12px; font-family: arial; font-weight: normal; line-height: 20px; text-align: center; overflow: hidden; word-break: break-word;} .ai-debug-bar .ai-debug-text-left {float: left; text-align: left; margin-top: 3px;} .ai-debug-bar .ai-debug-text-right {float: right; text-align: right; padding-right: 3px; margin-top: 3px;} .ai-debug-bar .ai-debug-text-center {text-align: center;} .ai-debug-lists .ai-debug-text-left, .ai-debug-viewport-invisible .ai-debug-text-left, .ai-debug-filter .ai-debug-text-left {min-width: 40%;} .ai-debug-lists .ai-debug-text-right, .ai-debug-viewport-invisible .ai-debug-text-right, .ai-debug-filter .ai-debug-text-right {min-width: 40%;} .ai-debug-message {text-align: center; font-weight: bold;} .ai-debug-bar kbd {margin: 0; padding: 0; color: #fff; font-size: inherit; font-family: arial; background-color: transparent; text-shadow: none; border: 0; box-shadow: none;} .ai-debug-visibility-hidden {visibility: hidden} .ai-debug-display-none {display: none} .ai-debug-block pre {direction: ltr; text-align: left; margin: 0; padding: 2px 5px 2px; line-height: 14px; background: #fff; color: #000; font-family: monospace; font-size: 12px;} pre.ai-w3tc-debug {font-size: 12px;} pre.ai-w3tc-debug.ai-w3tc-run {color: #00f;} pre.ai-processing-log {direction: ltr; text-align: left; padding: 10px; background: #eee; color: #000; font-family: monospace; font-size: 12px; line-height: 18px; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;} .ai-debug-bar.ai-debug-lists.ai-debug-iab-tcf-2 kbd.ai-debug-text-left, .ai-debug-bar.ai-debug-lists.ai-debug-iab-tcf-2 kbd.ai-debug-text-right { min-width: 10%; } #ai-selector-data { position: fixed; top: 0; z-index: 999999; background: #fff; width: 100%; border: 1px solid #000; } #ai-selector-data kbd { background-color: #fff; box-shadow: none; } #ai-selector-data table { width: 100%; margin: 5px; } #ai-selector-data td { padding: 5px 10px; vertical-align: middle; } #ai-selector-data td button { margin: 0 15px; } #ai-selector-data .ui-button-text-only .ui-button-text { padding: 3px 10px; } #ai-selector-data td.data-name { width: 100px; } #ai-selector-element, #ai-selector-path { user-select: text; } #ai-selector { width: 100%; display: inline-block; border-radius: 4px; font-size: 12px; font-family: Courier, 'Courier New', monospace; font-weight: bold; } .ai-highlighted { outline: 3px dashed #00f; background: rgba(50, 140, 220, 0.2); cursor: default; } .ai-selected { outline: 3px dashed #f00; background: rgba(255, 0, 0, 0.2); } .ai-highlighted.ai-selected { } .ai-html-element { color: #00a; cursor: pointer; } .ai-html-element:hover { color: #00f; } #ai-selector-data .ui-button.ui-corner-all.ui-widget { border: 1px solid #d3d3d3; background: #e6e6e6 url() 50% 50% repeat-x; color: rgb(85, 85, 85); }

    ' . sprintf (__('Invalid data received - %s settings not saved.', 'ad-inserter'), AD_INSERTER_NAME) . '

    '; } $settings_data_valid = false; } } if (isset ($_POST [AI_FORM_SAVE]) && $settings_data_valid) { check_admin_referer ('save_adinserter_settings'); $subpage = 'main'; $start = 1; $end = 16; $button_keys = array (AI_FORM_SAVE, AI_FORM_CLEAR_EXCEPTIONS); $settings_ok = true; $settings_errors = array (); if (isset ($_GET ['start']) && is_numeric ($start) && $start >= 1 && $start <= 96) $start = (int) $_GET ['start']; else $start = 1; $end = min ($start + 15, 96); $invalid_blocks = array (); $import_switch_name = AI_OPTION_IMPORT . WP_FORM_FIELD_POSTFIX . '0'; if (isset ($_POST [$import_switch_name]) && $_POST [$import_switch_name] == "1") { // Import Ad Inserter settings $settings = str_replace (array ("\\\""), array ("\""), $_POST ["export_settings_0"]); if (substr ($settings, 0, 4) === ':AI:') { $settings = substr ($settings, 4); } $ai_options = ai_unserialize (base64_decode ($settings)); if ($ai_options === false) { // Use saved settings $ai_options = wp_slash ($ai_db_options); $invalid_blocks []= 0; $settings_ok = false; $settings_errors []= 'Import plugin settings: unserialize failed'; } else $ai_options = wp_slash ($ai_options); } else { // Try to import individual settings $ai_options = array (); $default_block = new ai_Block (1); for ($block = 1; $block <= 96; $block ++) { if (isset ($ai_db_options [$block])) $saved_settings = wp_slash ($ai_db_options [$block]); else $saved_settings = array (); if ($block < $start || $block > $end) { // Block not on the settings page $ai_options [$block] = $saved_settings; continue; } $import_switch_name = AI_OPTION_IMPORT . WP_FORM_FIELD_POSTFIX . $block; $import_name_switch_name = AI_OPTION_IMPORT_NAME . WP_FORM_FIELD_POSTFIX . $block; if (isset ($_POST [$import_switch_name]) && $_POST [$import_switch_name] == "1") { // Try to import block settings $exported_settings = ai_unserialize (base64_decode (str_replace (array ("\\\""), array ("\""), $_POST ["export_settings_" . $block]))); if ($exported_settings !== false) { $exported_settings = wp_slash ($exported_settings); foreach (array_keys ($default_block->wp_options) as $key){ if ($key == AI_OPTION_BLOCK_NAME && isset ($_POST [$import_name_switch_name]) && $_POST [$import_name_switch_name] != "1") { $form_field_name = $key . WP_FORM_FIELD_POSTFIX . $block; if (isset ($_POST [$form_field_name])){ $ai_options [$block][$key] = filter_option ($key, $_POST [$form_field_name]); } } else { if (isset ($exported_settings [$key])) { $ai_options [$block][$key] = filter_option ($key, $exported_settings [$key], false); } } } } else { // Block import failed - use existing settings $ai_options [$block] = $saved_settings; $invalid_blocks []= $block; } } else { // Process block settings foreach (array_keys ($default_block->wp_options) as $key){ $form_field_name = $key . WP_FORM_FIELD_POSTFIX . $block; if (isset ($_POST [$form_field_name])){ $field_value = $_POST [$form_field_name]; // if ($key == AI_OPTION_CODE && strpos ($field_value, ':AI:') === 0) { if ($key == AI_OPTION_CODE && substr ($field_value, 0, 4) === ':AI:') { $code = base64_decode (substr ($field_value, 4), true); if ($code !== false) { $field_value = wp_slash ($code); } else { $field_value = ''; $settings_ok = false; $settings_errors []= "Block $block code: base64_decode failed"; } } $ai_options [$block][$key] = filter_option ($key, $field_value); } } if (!isset ($ai_options [$block]) || count ($ai_options [$block]) == 0) { if (isset ($_POST ['block-parameters-' . $block])) { $block_options = json_decode (base64_decode ($_POST ['block-parameters-' . $block])); if (is_array ($block_options)) { foreach ($button_keys as $button_key) { $button_index = array_search ($button_key, $block_options); if ($button_index !== false) { unset ($block_options [$button_index]); } } if (count ($block_options) != 0) { $settings_ok = false; $settings_errors []= "Missing settings for block $block: " . implode (', ', $block_options); } } else { $settings_ok = false; $settings_errors []= "Invalid parameter names for block $block"; } } else { $settings_ok = false; $settings_errors []= "Missing parameter names for block $block"; } } } delete_option (str_replace ("#", $block, AD_ADx_OPTIONS)); } $default_block_H = new ai_AdH(); $wp_options = array (); foreach(array_keys ($default_block_H->wp_options) as $key){ $form_field_name = $key . WP_FORM_FIELD_POSTFIX . AI_HEADER_OPTION_NAME; if(isset ($_POST [$form_field_name])){ $field_value = $_POST [$form_field_name]; if ($key == AI_OPTION_CODE && strpos ($field_value, ':AI:') === 0) { $code = base64_decode (substr ($field_value, 4), true); if ($code !== false) { $field_value = wp_slash ($code); } else { $field_value = ''; $settings_ok = false; $settings_errors []= "Header code: base64_decode failed"; } } $wp_options [$key] = filter_option_hf ($key, $field_value); } } $ai_options [AI_HEADER_OPTION_NAME] = $wp_options; $default_block_F = new ai_AdF(); $wp_options = array (); foreach(array_keys($default_block_F->wp_options) as $key){ $form_field_name = $key . WP_FORM_FIELD_POSTFIX . AI_FOOTER_OPTION_NAME; if(isset ($_POST [$form_field_name])){ $field_value = $_POST [$form_field_name]; if ($key == AI_OPTION_CODE && strpos ($field_value, ':AI:') === 0) { $code = base64_decode (substr ($field_value, 4), true); if ($code !== false) { $field_value = wp_slash ($code); } else { $field_value = ''; $settings_ok = false; $settings_errors []= "Footer code: base64_decode failed"; } } $wp_options [$key] = filter_option_hf ($key, $field_value); } } $ai_options [AI_FOOTER_OPTION_NAME] = $wp_options; if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { $default_block_A = new ai_AdA(); $wp_options = array (); foreach(array_keys($default_block_A->wp_options) as $key){ $form_field_name = $key . WP_FORM_FIELD_POSTFIX . AI_ADB_MESSAGE_OPTION_NAME; if(isset ($_POST [$form_field_name])){ $field_value = $_POST [$form_field_name]; if ($key == AI_OPTION_CODE && strpos ($field_value, ':AI:') === 0) { $code = base64_decode (substr ($field_value, 4), true); if ($code !== false) { $field_value = wp_slash ($code); } else { $field_value = ''; $settings_ok = false; $settings_errors []= "Ad blocking message code: base64_decode failed"; } } $wp_options [$key] = filter_option_hf ($key, $field_value); } } $ai_options [AI_ADB_MESSAGE_OPTION_NAME] = $wp_options; } $options = array (); $ai_options = apply_filters ('ai_save_settings', $ai_options); if (function_exists ('ai_filter_global_settings')) ai_filter_global_settings ($options); if (isset ($_POST ['syntax-highlighter-theme'])) $options ['SYNTAX_HIGHLIGHTER_THEME'] = filter_string ($_POST ['syntax-highlighter-theme']); if (isset ($_POST ['block-class-name'])) $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']); if (isset ($_POST ['block-class'])) $options ['BLOCK_CLASS'] = filter_option ('BLOCK_CLASS', $_POST ['block-class']); if (isset ($_POST ['block-number-class'])) $options ['BLOCK_NUMBER_CLASS'] = filter_option ('BLOCK_NUMBER_CLASS', $_POST ['block-number-class']); if (isset ($_POST ['block-name-class'])) $options ['BLOCK_NAME_CLASS'] = filter_option ('BLOCK_NAME_CLASS', $_POST ['block-name-class']); if (isset ($_POST ['inline-styles'])) $options ['INLINE_STYLES'] = filter_option ('INLINE_STYLES', $_POST ['inline-styles']); if (isset ($_POST ['minimum-user-role'])) $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']); if (isset ($_POST ['sticky-widget-mode'])) $options ['STICKY_WIDGET_MODE'] = filter_option ('STICKY_WIDGET_MODE', $_POST ['sticky-widget-mode']); if (isset ($_POST ['sticky-widget-margin'])) $options ['STICKY_WIDGET_MARGIN'] = filter_option ('STICKY_WIDGET_MARGIN', $_POST ['sticky-widget-margin']); if (isset ($_POST ['lazy-loading-offset'])) $options ['LAZY_LOADING_OFFSET'] = filter_option ('LAZY_LOADING_OFFSET', $_POST ['lazy-loading-offset']); if (isset ($_POST ['cfp'])) $options ['CLICK_FRAUD_PROTECTION'] = filter_option ('CLICK_FRAUD_PROTECTION', $_POST ['cfp']); if (isset ($_POST ['cfp-time'])) $options ['CLICK_FRAUD_PROTECTION_TIME'] = filter_option ('CLICK_FRAUD_PROTECTION_TIME', $_POST ['cfp-time']); if (isset ($_POST ['global-visitor-limit-cpt'])) $options ['GLOBAL_VISITOR_LIMIT_CPT'] = filter_option ('GLOBAL_VISITOR_LIMIT_CPT', $_POST ['global-visitor-limit-cpt']); if (isset ($_POST ['global-visitor-limit-time'])) $options ['GLOBAL_VISITOR_LIMIT_TIME'] = filter_option ('GLOBAL_VISITOR_LIMIT_TIME', $_POST ['global-visitor-limit-time']); if (isset ($_POST ['cfp-block-ip-address'])) $options ['CFP_BLOCK_IP_ADDRESS'] = filter_option ('CFP_BLOCK_IP_ADDRESS', $_POST ['cfp-block-ip-address']); if (isset ($_POST ['max-page-blocks'])) $options ['MAX_PAGE_BLOCKS'] = filter_option ('MAX_PAGE_BLOCKS', $_POST ['max-page-blocks']); if (isset ($_POST ['plugin_priority'])) $options ['PLUGIN_PRIORITY'] = filter_option ('PLUGIN_PRIORITY', $_POST ['plugin_priority']); if (isset ($_POST ['tab-setup-delay'])) $options ['TAB_SETUP_DELAY'] = filter_option ('TAB_SETUP_DELAY', $_POST ['tab-setup-delay']); if (isset ($_POST ['dynamic_blocks'])) $options ['DYNAMIC_BLOCKS'] = filter_option ('DYNAMIC_BLOCKS', $_POST ['dynamic_blocks']); if (isset ($_POST ['paragraph_counting_functions'])) $options ['PARAGRAPH_COUNTING_FUNCTIONS'] = filter_option ('PARAGRAPH_COUNTING_FUNCTIONS', $_POST ['paragraph_counting_functions']); if (isset ($_POST ['output-buffering'])) $options ['OUTPUT_BUFFERING'] = filter_option ('OUTPUT_BUFFERING', $_POST ['output-buffering']); if (isset ($_POST ['disable-caching-admin'])) $options ['DISABLE_CACHING'] = filter_option ('DISABLE_CACHING', $_POST ['disable-caching-admin']); if (isset ($_POST ['menu-for-link'])) $options ['MENU_FOR_LINK'] = filter_option ('MENU_FOR_LINK', $_POST ['menu-for-link']); if (isset ($_POST ['wait-for-jquery'])) $options ['WAIT_FOR_JQUERY'] = filter_option ('WAIT_FOR_JQUERY', $_POST ['wait-for-jquery']); if (isset ($_POST ['javascript-code'])) $options ['JAVASCRIPT_CODE_MODE'] = filter_option ('JAVASCRIPT_CODE_MODE', $_POST ['javascript-code']); if (isset ($_POST ['no-paragraph-counting-inside'])) $options ['NO_PARAGRAPH_COUNTING_INSIDE'] = filter_option ('NO_PARAGRAPH_COUNTING_INSIDE', $_POST ['no-paragraph-counting-inside']); if (isset ($_POST ['ad-label'])) $options ['AD_LABEL'] = filter_option ('AD_LABEL', $_POST ['ad-label']); if (isset ($_POST ['main-content-element'])) $options ['MAIN_CONTENT_ELEMENT'] = filter_option ('MAIN_CONTENT_ELEMENT', $_POST ['main-content-element']); if (isset ($_POST [AI_OPTION_ADB_DEVICES])) $options ['ADB_DEVICES'] = filter_option ('ADB_DEVICES', $_POST [AI_OPTION_ADB_DEVICES]); if (isset ($_POST [AI_OPTION_ADB_ACTION])) $options ['ADB_ACTION'] = filter_option ('ADB_ACTION', $_POST [AI_OPTION_ADB_ACTION]); if (isset ($_POST [AI_OPTION_ADB_NO_ACTION])) $options ['ADB_NO_ACTION'] = filter_option ('ADB_NO_ACTION', $_POST [AI_OPTION_ADB_NO_ACTION]); if (isset ($_POST [AI_OPTION_ADB_DELAY_ACTION])) $options ['ADB_DELAY_ACTION'] = filter_option ('ADB_DELAY_ACTION', $_POST [AI_OPTION_ADB_DELAY_ACTION]); if (isset ($_POST [AI_OPTION_ADB_NO_ACTION_PERIOD])) $options ['ADB_NO_ACTION_PERIOD'] = filter_option ('ADB_NO_ACTION_PERIOD', $_POST [AI_OPTION_ADB_NO_ACTION_PERIOD]); if (isset ($_POST [AI_OPTION_ADB_SELECTORS])) $options ['ADB_SELECTORS'] = filter_option ('ADB_SELECTORS', $_POST [AI_OPTION_ADB_SELECTORS]); if (isset ($_POST [AI_OPTION_ADB_REDIRECTION_PAGE])) $options ['ADB_REDIRECTION_PAGE'] = filter_option ('ADB_REDIRECTION_PAGE', $_POST [AI_OPTION_ADB_REDIRECTION_PAGE]); if (isset ($_POST [AI_OPTION_ADB_CUSTOM_REDIRECTION_URL])) $options ['ADB_CUSTOM_REDIRECTION_URL'] = filter_option ('ADB_CUSTOM_REDIRECTION_URL', $_POST [AI_OPTION_ADB_CUSTOM_REDIRECTION_URL]); if (isset ($_POST [AI_OPTION_ADB_MESSAGE_CSS])) $options ['ADB_MESSAGE_CSS'] = filter_option ('ADB_MESSAGE_CSS', $_POST [AI_OPTION_ADB_MESSAGE_CSS]); if (isset ($_POST [AI_OPTION_ADB_OVERLAY_CSS])) $options ['ADB_OVERLAY_CSS'] = filter_option ('ADB_OVERLAY_CSS', $_POST [AI_OPTION_ADB_OVERLAY_CSS]); if (isset ($_POST [AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE])) $options ['ADB_UNDISMISSIBLE_MESSAGE'] = filter_option ('ADB_UNDISMISSIBLE_MESSAGE', $_POST [AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE]); if (isset ($_POST [AI_OPTION_ADB_EXTERNAL_SCRIPTS])) $options ['ADB_EXTERNAL_SCRIPTS'] = filter_option ('ADB_EXTERNAL_SCRIPTS', $_POST [AI_OPTION_ADB_EXTERNAL_SCRIPTS]); if (isset ($_POST [AI_OPTION_ADB_NO_UNDISMISSIBLE_MESSAGE]))$options ['ADB_NO_UNDISMISSIBLE_MESSAGE'] = filter_option ('ADB_NO_UNDISMISSIBLE_MESSAGE', $_POST [AI_OPTION_ADB_NO_UNDISMISSIBLE_MESSAGE]); if (isset ($_POST ['force_admin_toolbar'])) $options ['FORCE_ADMIN_TOOLBAR'] = filter_option ('FORCE_ADMIN_TOOLBAR', $_POST ['force_admin_toolbar']); if (isset ($_POST ['admin_toolbar_debugging'])) $options ['ADMIN_TOOLBAR_DEBUGGING'] = filter_option ('ADMIN_TOOLBAR_DEBUGGING', $_POST ['admin_toolbar_debugging']); if (isset ($_POST ['admin_toolbar_mobile'])) $options ['ADMIN_TOOLBAR_MOBILE'] = filter_option ('ADMIN_TOOLBAR_MOBILE', $_POST ['admin_toolbar_mobile']); if (isset ($_POST ['remote_debugging'])) $options ['REMOTE_DEBUGGING'] = filter_option ('REMOTE_DEBUGGING', $_POST ['remote_debugging']); if (isset ($_POST ['disable_translation'])) $options ['DISABLE_TRANSLATION'] = filter_option ('DISABLE_TRANSLATION', $_POST ['disable_translation']); if (isset ($_POST ['backend_js_debugging'])) $options ['BACKEND_JS_DEBUGGING'] = filter_option ('BACKEND_JS_DEBUGGING', $_POST ['backend_js_debugging']); if (isset ($_POST ['frontend_js_debugging'])) $options ['FRONTEND_JS_DEBUGGING'] = filter_option ('FRONTEND_JS_DEBUGGING', $_POST ['frontend_js_debugging']); if (isset ($_POST ['disable-blocks'])) $options ['DISABLE_BLOCK_INSERTIONS'] = filter_option ('DISABLE_BLOCK_INSERTIONS', $_POST ['disable-blocks']); if (isset ($_POST ['disable-php-processing'])) $options ['DISABLE_PHP_PROCESSING'] = filter_option ('DISABLE_PHP_PROCESSING', $_POST ['disable-php-processing']); if (isset ($_POST ['disable-html-code'])) $options ['DISABLE_HTML_CODE'] = filter_option ('DISABLE_HTML_CODE', $_POST ['disable-html-code']); if (isset ($_POST ['disable-css-code'])) $options ['DISABLE_CSS_CODE'] = filter_option ('DISABLE_CSS_CODE', $_POST ['disable-css-code']); if (isset ($_POST ['disable-js-code'])) $options ['DISABLE_JS_CODE'] = filter_option ('DISABLE_JS_CODE', $_POST ['disable-js-code']); if (isset ($_POST ['disable-footer-code'])) $options ['DISABLE_FOOTER_CODE'] = filter_option ('DISABLE_FOOTER_CODE', $_POST ['disable-footer-code']); if (isset ($_POST ['disable-header-code'])) $options ['DISABLE_HEADER_CODE'] = filter_option ('DISABLE_HEADER_CODE', $_POST ['disable-header-code']); for ($viewport = 1; $viewport <= 6; $viewport ++) { if (isset ($_POST ['viewport-name-'.$viewport])) $options ['VIEWPORT_NAME_'.$viewport] = filter_string ($_POST ['viewport-name-'.$viewport]); if (isset ($_POST ['viewport-width-'.$viewport])) $options ['VIEWPORT_WIDTH_'.$viewport] = filter_option ('viewport_width', $_POST ['viewport-width-'.$viewport]); } for ($constant = 1; $constant <= 6; $constant ++) { if (isset ($_POST ['constant-name-'.$constant])) $options ['CONSTANT_NAME_'.$constant] = filter_string ($_POST ['constant-name-'.$constant]); if (isset ($_POST ['constant-value-'.$constant])) $options ['CONSTANT_VALUE_'.$constant] = filter_string ($_POST ['constant-value-'.$constant]); } for ($hook = 1; $hook <= 20; $hook ++) { if (isset ($_POST ['hook-enabled-'.$hook])) $options ['HOOK_ENABLED_'.$hook] = filter_option ('HOOK_ENABLED', $_POST ['hook-enabled-'.$hook]); if (isset ($_POST ['hook-name-'.$hook])) $options ['HOOK_NAME_'.$hook] = filter_string_tags ($_POST ['hook-name-'.$hook]); if (isset ($_POST ['hook-action-'.$hook])) $options ['HOOK_ACTION_'.$hook] = filter_string ($_POST ['hook-action-'.$hook]); if (isset ($_POST ['hook-priority-'.$hook])) $options ['HOOK_PRIORITY_'.$hook] = filter_option ('HOOK_PRIORITY', $_POST ['hook-priority-'.$hook]); } $ai_options [AI_OPTION_GLOBAL] = ai_check_plugin_options ($options); } if (!empty ($invalid_blocks)) { if ($invalid_blocks [0] == 0) { // translators: %s: Ad Inserter echo '

    '. sprintf (__('Error importing %s settings.', 'ad-inserter'), AD_INSERTER_NAME) . '

    '; } else echo '

    '. _n('Error importing settings for block', 'Error importing settings for blocks:', count ($invalid_blocks), 'ad-inserter') , ' ', implode (', ', $invalid_blocks) . '

    '; } if ($settings_ok) { // Multisite $multisite_options = array (); if (function_exists ('ai_filter_multisite_settings')) ai_filter_multisite_settings ($multisite_options); ai_check_multisite_options ($multisite_options); ai_save_options ($ai_options, $multisite_options); if (function_exists ('ai_load_globals')) ai_load_globals (); if (defined ('AI_PLUGIN_TRACKING') && AI_PLUGIN_TRACKING) { if (isset ($_POST ['plugin-usage-tracking'])) { global $ai_dst; if (isset ($ai_dst) && is_object ($ai_dst)) { $ai_dst->set_tracking ((bool) $_POST ['plugin-usage-tracking']); } } } echo '

    ' . __('Settings saved.', 'ad-inserter') . '

    '; } else { // translators: %s: Ad Inserter echo '

    ' . sprintf (__('Invalid data received - %s settings not saved.', 'ad-inserter'), AD_INSERTER_NAME) . '

    '; if (!empty ($settings_errors)) { foreach ($settings_errors as $settings_error) { echo '
    ', $settings_error, '
    '; } } echo '
    '; } } elseif (isset ($_POST [AI_FORM_CLEAR]) && $settings_data_valid) { check_admin_referer ('save_adinserter_settings'); if (function_exists ('ai_clear_settings_2')) { $remote_cleared = ai_clear_settings_2 (); } else $remote_cleared = false; if (!$remote_cleared) { ai_clear_settings (); } echo '

    ' . __('Settings cleared.', 'ad-inserter') . '

    '; } elseif (isset ($_POST [AI_FORM_CLEAR_EXCEPTIONS]) && $settings_data_valid) { check_admin_referer ('save_adinserter_settings'); if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) { if (function_exists ('ai_clear_exceptions_2')) { $remote_cleared = ai_clear_exceptions_2 (); } else $remote_cleared = false; if (!$remote_cleared) { ai_clear_exceptions (); } } } elseif (isset ($_POST [AI_FORM_CLEAR_STATISTICS]) && is_numeric ($_POST [AI_FORM_CLEAR_STATISTICS]) && $settings_data_valid) { check_admin_referer ('save_adinserter_settings'); if (function_exists ('ai_clear_statistics_2')) { $remote_cleared = ai_clear_statistics_2 (); } else $remote_cleared = false; if (!$remote_cleared) { ai_clear_statistics (); } } generate_settings_form (); } function ai_adinserter ($block_parameter, $options, &$block) { global $block_object, $ad_inserter_globals, $ai_wp_data, $ai_last_check; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; if ($block_parameter == "") return ""; $block_number = $block_parameter; if (!is_numeric ($block_parameter)) { $function_block_parameter = strtolower ($block_parameter); for ($counter = 1; $counter <= 96; $counter ++) { $obj = $block_object [$counter]; $ad_name = strtolower (trim ($obj->get_ad_name())); if ($function_block_parameter == $ad_name) { $block_number = $counter; break; } } } if (!is_numeric ($block_number)) return ""; $block = (int) $block_number; if ($block < 1 || $block > 96) return ""; $globals_name = AI_PHP_FUNCTION_CALL_COUNTER_NAME . $block; if (!isset ($ad_inserter_globals [$globals_name])) { $ad_inserter_globals [$globals_name] = 1; } else $ad_inserter_globals [$globals_name] ++; if ($debug_processing) ai_log ("PHP FUNCTION CALL adinserter ($block_parameter".($options == '' ? '' : (', \''.$options.'\''))."), block $block [" . $ad_inserter_globals [$globals_name] . ']'); $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_PHP_FUNCTION; $options_array = array (); if (trim ($options) != '') { $options_array = explode (",", str_replace (" ", "", $options)); if (in_array ("server-side", $options_array)) { $ai_wp_data [AI_DYNAMIC_BLOCKS] = AI_DYNAMIC_BLOCKS_SERVER_SIDE; } elseif (in_array ("client-side-show", $options_array)) { $ai_wp_data [AI_DYNAMIC_BLOCKS] = AI_DYNAMIC_BLOCKS_CLIENT_SIDE_SHOW; } elseif (in_array ("client-side-insert", $options_array)) { $ai_wp_data [AI_DYNAMIC_BLOCKS] = AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT; } elseif (in_array ("server-side-w3c", $options_array)) { $ai_wp_data [AI_DYNAMIC_BLOCKS] = AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC; } } $obj = $block_object [$block]; $obj->clear_code_cache (); $ai_last_check = AI_CHECK_ENABLED_PHP; if (!$obj->get_enable_php_call ()) return ""; if (!$obj->check_server_side_detection ()) return ""; /* Deprecated */ if (!$obj->check_page_types_lists_users (in_array ("page-type", $options_array) || in_array ("ignore-page-type", $options_array))) return ""; if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return ""; if (!$obj->check_number_of_words ()) return ""; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) { // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true); $meta_value = ai_get_post_meta (); $selected_blocks = explode (",", $meta_value); if (!$obj->check_post_page_exceptions ($selected_blocks)) return ""; } $ai_last_check = AI_CHECK_DISABLED_MANUALLY; if (!$obj->check_disabled ()) return ""; $ai_last_check = AI_CHECK_INSERTION_NOT_DISABLED; if ($obj->get_disable_insertion () || get_disable_block_insertions ()) return ""; // Last check before counter check before insertion // $ai_last_check = AI_CHECK_CODE; // if ($obj->ai_getCode () == '') return ""; if ($obj->empty_code ()) return ""; $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled (); if ($max_page_blocks_enabled) { $ai_last_check = AI_CHECK_MAX_PAGE_BLOCKS; if ($ai_wp_data [AI_PAGE_BLOCKS] >= get_max_page_blocks ()) return ""; } if (!$obj->check_filter_hook ($debug_processing)) return ""; // Last check before insertion if (!$obj->check_and_increment_block_counter ()) return ""; // Increment page block counter if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++; $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION; if ($obj->get_debug_disable_insertion ()) return ""; $code = $obj->get_code_for_serverside_insertion (); // Must be after get_code_for_serverside_insertion () $ai_last_check = AI_CHECK_INSERTED; unset ($ai_wp_data [AI_DYNAMIC_BLOCKS]); return $code; } function adinserter ($block = '', $options = '') { global $ai_last_check, $ai_wp_data, $ai_total_plugin_time; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; if ($debug_processing) { $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } $ai_last_check = AI_CHECK_NONE; $block_number = 0; $code = ai_adinserter ($block, $options, $block_number); if ($debug_processing) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } if ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block_number, $ai_last_check)); ai_log ("PHP FUNCTION CALL END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } return $code; } function ai_content_hook ($content = '') { global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time, $special_element_tags; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return $content; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; $globals_name = AI_CONTENT_COUNTER_NAME; if (!isset ($ad_inserter_globals [$globals_name])) { $ad_inserter_globals [$globals_name] = 1; } else $ad_inserter_globals [$globals_name] ++; if (!is_string ($content)) { if ($debug_processing) { ai_log ("CONTENT HOOK START [" . $ad_inserter_globals [$globals_name] . (in_the_loop () ? ', IN THE LOOP' : ', NOT IN THE LOOP') . '] - CONTENT NOT STRING - NO PROCESING'); ai_log (""); } return $content; } // TEMP CHECK if (get_plugin_priority () % 2 == 1) { if (strpos ($content, '\n"; if ($debug_processing) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("CONTENT HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } return $content; } // Process Before/After Excerpt postion function ai_excerpt_hook ($content = '') { global $ad_inserter_globals, $block_object, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; $globals_name = AI_EXCERPT_COUNTER_NAME; if (!isset ($ad_inserter_globals [$globals_name])) { $ad_inserter_globals [$globals_name] = 1; } else $ad_inserter_globals [$globals_name] ++; if ($debug_processing) { ai_log ("EXCERPT HOOK START [" . $ad_inserter_globals [$globals_name] . ']'); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_EXCERPT; $ai_last_check = AI_CHECK_NONE; $current_block = 0; if (isset ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) foreach ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) { if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check)); if (!isset ($block_object [$block])) continue; $current_block = $block; $obj = $block_object [$block]; $obj->clear_code_cache (); if (!$obj->check_server_side_detection ()) continue; if (!$obj->check_page_types_lists_users ()) continue; if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue; $ai_last_check = AI_CHECK_DISABLED_MANUALLY; if (!$obj->check_disabled ()) continue; // Deprecated if ($obj->display_disabled ($content)) continue; $ai_last_check = AI_CHECK_INSERTION_NOT_DISABLED; if ($obj->get_disable_insertion () || get_disable_block_insertions ()) continue; // Last check before counter check before insertion // $ai_last_check = AI_CHECK_CODE; // if ($obj->ai_getCode () == '') continue; if ($obj->empty_code ()) continue; $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled (); if ($max_page_blocks_enabled) { $ai_last_check = AI_CHECK_MAX_PAGE_BLOCKS; if ($ai_wp_data [AI_PAGE_BLOCKS] >= get_max_page_blocks ()) continue; } if (!$obj->check_filter_hook ($debug_processing)) continue; // Last check before insertion if (!$obj->check_and_increment_block_counter ()) continue; // Increment page block counter if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++; $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION; if (!$obj->get_debug_disable_insertion ()) { $automatic_insertion = $obj->get_automatic_insertion (); if ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT) $content = $obj->get_code_for_serverside_insertion () . $content; else $content = $content . $obj->get_code_for_serverside_insertion (); $ai_last_check = AI_CHECK_INSERTED; } } if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check)); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) { $class = AI_DEBUG_POSITIONS_CLASS; $content = "
    " . ($ai_wp_data [AI_MBSTRING_LOADED] ? mb_strtoupper (AI_TEXT_BEFORE_EXCERPT) : strtoupper (AI_TEXT_BEFORE_EXCERPT)) . ' ' . $ad_inserter_globals [$globals_name]."
    ". $content . "
    " . ($ai_wp_data [AI_MBSTRING_LOADED] ? mb_strtoupper (AI_TEXT_AFTER_EXCERPT) : strtoupper (AI_TEXT_AFTER_EXCERPT)) . ' ' .$ad_inserter_globals [$globals_name]."
    "; // Remove word counts $content = preg_replace ("/\[\(\](.+?)\[\)\]/", "", $content); $content = preg_replace ("/\[\(\].*/", "", $content); // Color positions from the content hook // $content = preg_replace ("/((BEFORE|AFTER) (CONTENT|PARAGRAPH) ?[\d]*)/", " [$1] ", $content); $content = preg_replace ("/(" . ($ai_wp_data [AI_MBSTRING_LOADED] ? mb_strtoupper (AI_TEXT_BEFORE_CONTENT) : strtoupper (AI_TEXT_BEFORE_CONTENT)) . " ?[\d]*)/", " [$1] ", $content); $content = preg_replace ("/(" . ($ai_wp_data [AI_MBSTRING_LOADED] ? mb_strtoupper (AI_TEXT_AFTER_CONTENT) : strtoupper (AI_TEXT_AFTER_CONTENT)) . " ?[\d]*)/", " [$1] ", $content); $content = preg_replace ("/(" . ($ai_wp_data [AI_MBSTRING_LOADED] ? mb_strtoupper (AI_TEXT_BEFORE_PARAGRAPH) : strtoupper (AI_TEXT_BEFORE_PARAGRAPH)) . " ?[\d]*)/", " [$1] ", $content); $content = preg_replace ("/(" . ($ai_wp_data [AI_MBSTRING_LOADED] ? mb_strtoupper (AI_TEXT_AFTER_PARAGRAPH) : strtoupper (AI_TEXT_AFTER_PARAGRAPH)) . " ?[\d]*)/", " [$1] ", $content); } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) { // Remove marked tags from the content hook $content = preg_replace ("/<(.+?)>/", "", $content); // Color text to mark removed HTML tags $content = str_replace ('[' . __('HTML TAGS REMOVED', 'ad-inserter') . ']', '[' . __('HTML TAGS REMOVED', 'ad-inserter') . ']', $content); } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) { // Remove block labels from the content hook if (strpos ($content, '>[AI]<') === false) $content = preg_replace ("/\[AI\](.+?)\[\/AI\]/", "", $content); } if ($debug_processing) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("EXCERPT HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } return $content; } function ai_comments_array ($comments , $post_id ){ global $ai_wp_data; $thread_comments = get_option ('thread_comments'); $comment_counter = 0; foreach ($comments as $comment) { if (!$thread_comments || empty ($comment->comment_parent)) $comment_counter ++; } $ai_wp_data [AI_NUMBER_OF_COMMENTS] = $comment_counter; return $comments; } function ai_wp_list_comments_args ($args) { global $ai_wp_data; // print_r ($args); // $args['per_page'] = 3; // $args['page'] = 2; $ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'] = $args ['callback']; $args ['callback'] = 'ai_comment_callback'; $ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'] = $args ['end-callback']; $args ['end-callback'] = 'ai_comment_end_callback'; return $args; } // Process comments counter + Before Comments postion function ai_comment_callback ($comment, $args, $depth) { global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time, $ai_walker; if ($depth == 1) { if (!isset ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME])) { $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] = 1; } else $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] ++; } $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; if ($debug_processing) { ai_log ('COMMENT START HOOK START [' . $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] . ':'. $depth . ']'); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } if ($depth == 1 && $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] == 1) { $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BEFORE_COMMENTS; if ($args ['style'] == 'div') $tag = 'div'; else $tag = 'li'; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) { $class = AI_DEBUG_POSITIONS_CLASS; echo "<$tag>\n"; echo "
    " . __('BEFORE COMMENTS', 'ad-inserter') . '
    '; echo "\n"; } $ad_code = ""; $ai_last_check = AI_CHECK_NONE; $current_block = 0; if (isset ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) foreach ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) { if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check)); if (!isset ($block_object [$block])) continue; $current_block = $block; $obj = $block_object [$block]; $obj->clear_code_cache (); if (!$obj->check_server_side_detection ()) continue; if (!$obj->check_page_types_lists_users ()) continue; // No filter check if (!$obj->check_number_of_words ()) continue; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) { $meta_value = ai_get_post_meta (); $selected_blocks = explode (",", $meta_value); if (!$obj->check_post_page_exceptions ($selected_blocks)) continue; } $ai_last_check = AI_CHECK_DISABLED_MANUALLY; if (!$obj->check_disabled ()) continue; $ai_last_check = AI_CHECK_INSERTION_NOT_DISABLED; if ($obj->get_disable_insertion () || get_disable_block_insertions ()) continue; // Last check before counter check before insertion // $ai_last_check = AI_CHECK_CODE; // if ($obj->ai_getCode () == '') continue; if ($obj->empty_code ()) continue; $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled (); if ($max_page_blocks_enabled) { $ai_last_check = AI_CHECK_MAX_PAGE_BLOCKS; if ($ai_wp_data [AI_PAGE_BLOCKS] >= get_max_page_blocks ()) continue; } if (!$obj->check_filter_hook ($debug_processing)) continue; // Last check before insertion if (!$obj->check_and_increment_block_counter ()) continue; // Increment page block counter if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++; $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION; if (!$obj->get_debug_disable_insertion ()) { $ad_code .= $obj->get_code_for_serverside_insertion (); $ai_last_check = AI_CHECK_INSERTED; } } if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check)); if ($ad_code != '') { echo "<$tag>\n"; echo $ad_code; echo "\n"; } } if ($debug_processing) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("COMMENT START HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } if (!empty ($ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'])) { echo call_user_func ($ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'], $comment, $args, $depth ); } else { $ai_walker->comment_callback ($comment, $args, $depth); } } // Process Between Comments postion function ai_comment_end_callback ($comment, $args, $depth) { global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time; if ($args ['style'] == 'div') $tag = 'div'; else $tag = 'li'; if (!empty ($ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'])) { echo call_user_func ($ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'], $comment, $args, $depth); } else echo "\n"; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; if ($debug_processing) { ai_log ('COMMENT END HOOK START [' . $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] . ':'. ($depth + 1) . ']'); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } if ($depth == 0) { if (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] != 0 && !empty ($args ['per_page']) && !empty ($args ['page'])) { $number_of_comments_mod_per_page = $ai_wp_data [AI_NUMBER_OF_COMMENTS] % $args ['per_page']; if ($number_of_comments_mod_per_page != 0) { $last_page = (int) ($ai_wp_data [AI_NUMBER_OF_COMMENTS] / $args ['per_page']) + 1; $last_comment_number = $args ['page'] == $last_page ? $number_of_comments_mod_per_page : $args ['per_page']; } else $last_comment_number = $args ['per_page']; } else $last_comment_number = $ai_wp_data [AI_NUMBER_OF_COMMENTS]; if ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME] == $last_comment_number) { $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_AFTER_COMMENTS; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) { $class = AI_DEBUG_POSITIONS_CLASS; echo "<$tag>\n"; echo "
    " . __('AFTER COMMENTS', 'ad-inserter') . '
    '; echo "\n"; } $ad_code = ""; $ai_last_check = AI_CHECK_NONE; $current_block = 0; if (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) foreach ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) { if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check)); if (!isset ($block_object [$block])) continue; $current_block = $block; $obj = $block_object [$block]; $obj->clear_code_cache (); if (!$obj->check_server_side_detection ()) continue; if (!$obj->check_page_types_lists_users ()) continue; // No filter check if (!$obj->check_number_of_words ()) continue; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) { $meta_value = ai_get_post_meta (); $selected_blocks = explode (",", $meta_value); if (!$obj->check_post_page_exceptions ($selected_blocks)) continue; } $ai_last_check = AI_CHECK_DISABLED_MANUALLY; if (!$obj->check_disabled ()) continue; $ai_last_check = AI_CHECK_INSERTION_NOT_DISABLED; if ($obj->get_disable_insertion () || get_disable_block_insertions ()) continue; // Last check before counter check before insertion // $ai_last_check = AI_CHECK_CODE; // if ($obj->ai_getCode () == '') continue; if ($obj->empty_code ()) continue; $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled (); if ($max_page_blocks_enabled) { $ai_last_check = AI_CHECK_MAX_PAGE_BLOCKS; if ($ai_wp_data [AI_PAGE_BLOCKS] >= get_max_page_blocks ()) continue; } if (!$obj->check_filter_hook ($debug_processing)) continue; // Last check before insertion if (!$obj->check_and_increment_block_counter ()) continue; // Increment page block counter if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++; $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION; if (!$obj->get_debug_disable_insertion ()) { $ad_code .= $obj->get_code_for_serverside_insertion (); $ai_last_check = AI_CHECK_INSERTED; } } if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check)); if ($ad_code != '') { echo "<$tag>\n"; echo $ad_code; echo "\n"; } } else { $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BETWEEN_COMMENTS; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) { $class = AI_DEBUG_POSITIONS_CLASS; echo "<$tag>\n"; echo "
    " . __('BETWEEN COMMENTS', 'ad-inserter') . ' ' . $ad_inserter_globals [AI_COMMENT_COUNTER_NAME]."
    "; echo "\n"; } $ad_code = ""; $ai_last_check = AI_CHECK_NONE; $current_block = 0; if (isset ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) foreach ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) { if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check)); if (!isset ($block_object [$block])) continue; $current_block = $block; $obj = $block_object [$block]; $obj->clear_code_cache (); if (!$obj->check_server_side_detection ()) continue; if (!$obj->check_page_types_lists_users ()) continue; if (!$obj->check_filter ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME])) continue; if (!$obj->check_number_of_words ()) continue; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) { $meta_value = ai_get_post_meta (); $selected_blocks = explode (",", $meta_value); if (!$obj->check_post_page_exceptions ($selected_blocks)) continue; } $ai_last_check = AI_CHECK_DISABLED_MANUALLY; if (!$obj->check_disabled ()) continue; $ai_last_check = AI_CHECK_INSERTION_NOT_DISABLED; if ($obj->get_disable_insertion () || get_disable_block_insertions ()) continue; // Last check before counter check before insertion // $ai_last_check = AI_CHECK_CODE; // if ($obj->ai_getCode () == '') continue; if ($obj->empty_code ()) continue; $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled (); if ($max_page_blocks_enabled) { $ai_last_check = AI_CHECK_MAX_PAGE_BLOCKS; if ($ai_wp_data [AI_PAGE_BLOCKS] >= get_max_page_blocks ()) continue; } if (!$obj->check_filter_hook ($debug_processing)) continue; // Last check before insertion if (!$obj->check_and_increment_block_counter ()) continue; // Increment page block counter if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++; $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION; if (!$obj->get_debug_disable_insertion ()) { $ad_code .= $obj->get_code_for_serverside_insertion (); $ai_last_check = AI_CHECK_INSERTED; } } if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check)); if ($ad_code != '') { echo "<$tag>\n"; echo $ad_code; echo "\n"; } } } if ($debug_processing) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("COMMENT END HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } } function ai_custom_hook ($action, $insertion_type, $name, $translated_name = '', $hook_parameter = null, $hook_check = null) { global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return; if (is_admin()) return; if ($insertion_type < AI_AUTOMATIC_INSERTION_CUSTOM_HOOK) { $globals_name = 'AI_' . strtoupper ($action) .'_COUNTER'; $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE; } else { $globals_name = 'AI_' . strtoupper ($action) . '_' . $insertion_type . '_COUNTER'; $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_CUSTOM_HOOK + $insertion_type - AI_AUTOMATIC_INSERTION_CUSTOM_HOOK; } if (isset ($hook_check) && $insertion_type < AI_AUTOMATIC_INSERTION_CUSTOM_HOOK) { if (!call_user_func ($hook_check, $hook_parameter, $action)) return; } if ($debug_processing) { $hook_name = $ai_wp_data [AI_MBSTRING_LOADED] ? mb_strtoupper ($name) : strtoupper ($name); ai_log (str_replace (array ('<', '>'), array ('<', '>'), $hook_name) . " HOOK START"); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } if (!isset ($ad_inserter_globals [$globals_name])) { $ad_inserter_globals [$globals_name] = 1; } else $ad_inserter_globals [$globals_name] ++; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) { $counter = $ad_inserter_globals [$globals_name]; if ($counter == 1) $counter = ''; $class = AI_DEBUG_POSITIONS_CLASS; if ($translated_name == '') $translated_name = $name; $translated_hook_name = $ai_wp_data [AI_MBSTRING_LOADED] ? mb_strtoupper ($translated_name) : strtoupper ($translated_name); echo "
    ".$translated_hook_name." ".$counter."
    "; } if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) { // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true); $meta_value = ai_get_post_meta (); $selected_blocks = explode (",", $meta_value); } else $selected_blocks = array (); $ad_code = ""; $ai_last_check = AI_CHECK_NONE; $current_block = 0; if (isset ($ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]])) foreach ($ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) { if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check)); $ai_last_check = AI_CHECK_NONE; if (!isset ($block_object [$block])) continue; $current_block = $block; $obj = $block_object [$block]; if ($insertion_type >= AI_AUTOMATIC_INSERTION_CUSTOM_HOOK) { if ($obj->get_automatic_insertion () != $insertion_type) continue; } if (!in_the_loop () && $obj->get_only_in_the_loop ()) continue; $obj->clear_code_cache (); // Action can be called as insertion Between posts or as custom hook - uses the same $ai_db_options_extract index if ($action == 'the_post' && $insertion_type != $obj->get_automatic_insertion ()) continue; if (!$obj->check_server_side_detection ()) continue; if (!$obj->check_page_types_lists_users ()) continue; if (!$obj->check_post_page_exceptions ($selected_blocks)) continue; if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue; if (!$obj->check_number_of_words ()) continue; $ai_last_check = AI_CHECK_DISABLED_MANUALLY; if (!$obj->check_disabled ()) continue; $ai_last_check = AI_CHECK_INSERTION_NOT_DISABLED; if ($obj->get_disable_insertion () || get_disable_block_insertions ()) continue; // Last check before counter check before insertion if ($obj->empty_code ()) continue; $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled (); if ($max_page_blocks_enabled) { $ai_last_check = AI_CHECK_MAX_PAGE_BLOCKS; if ($ai_wp_data [AI_PAGE_BLOCKS] >= get_max_page_blocks ()) continue; } if (!$obj->check_filter_hook ($debug_processing)) continue; // Last check before insertion if (!$obj->check_and_increment_block_counter ()) continue; // Increment page block counter if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++; $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION; if (!$obj->get_debug_disable_insertion ()) { $block_code = $obj->get_code_for_serverside_insertion (); if ($action == 'wp_head') { // Replace div tag in the head with meta tag $block_code = preg_replace ("#
    ", $block_code); } $ad_code .= $block_code; $ai_last_check = AI_CHECK_INSERTED; } } if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check)); echo $ad_code; if ($debug_processing) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log (str_replace (array ('<', '>'), array ('<', '>'), $hook_name) . " HOOK END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } } function ai_pre_do_shortcode_tag ($return, $tag, $attr, $m) { global $ai_expand_only_rotate_count_check, $ai_wp_data; // Array //( // [0] => [ADINSERTER ROTATE='1'] // [1] => // [2] => ADINSERTER // [3] => ROTATE='1' // [4] => // [5] => // [6] => if ($ai_expand_only_rotate_count_check) { if (strtolower ($tag) == 'adinserter') { // Expand only ROTATE / COUNT / CHECK if (isset ($attr ['rotate']) || in_array ('ROTATE', $attr) || in_array ('rotate', $attr)) { return false; } elseif (isset ($attr ['count']) || in_array ('COUNT', $attr) || in_array ('count', $attr)) { return false; } elseif (isset ($attr ['check']) || in_array ('CHECK', $attr) || in_array ('check', $attr)) { return false; } else return $m [0]; } else return $m [0]; } return $return; } function ai_process_shortcode (&$block, $atts) { global $block_object, $ai_last_check, $ai_wp_data, $ad_inserter_globals; if ($atts == '') return ''; $parameters = shortcode_atts (array ( "block" => "", "code" => "", "name" => "", "group" => "", "ignore" => "", "disable" => "", "index" => "", "check" => "", "viewport" => "", "fallback" => "", "adb" => "", "tracking" => "", "css" => "", "text" => "", "selectors" => "", "amp" => "", "head" => "", "rotate" => "", "count" => "", "counter" => "", "http" => "", "custom-field" => "", "random" => "", "data" => "", "share" => "", "time" => "", "category" => "", "categories" => "", "tag" => "", "tags" => "", "taxonomy" => "", "taxonomies" => "", "id" => "", "ids" => "", "url" => "", "urls" => "", "url-parameter" => "", "url-parameters" => "", "cookie" => "", "cookies" => "", "referrer" => "", "referrers" => "", "client" => "", "clients" => "", "scheduling" => "", "ip-address" => "", "ip-addresses" => "", "country" => "", "countries" => "", ), $atts); $output = ""; if (function_exists ('ai_shortcode')) { $output = ai_shortcode ($parameters); if ($output != '') return $output; } if (($adb = trim ($parameters ['adb'])) != '') { // message html // message css // overlay css // undismissible // redirection page // redirection url switch (strtolower ($adb)) { case 'message': $ai_wp_data [AI_ADB_SHORTCODE_ACTION] = AI_ADB_ACTION_MESSAGE; break; case 'redirection': $ai_wp_data [AI_ADB_SHORTCODE_ACTION] = AI_ADB_ACTION_REDIRECTION; break; case 'no-action': $ai_wp_data [AI_ADB_SHORTCODE_ACTION] = AI_ADB_ACTION_NONE; break; case 'disabled': $ai_wp_data [AI_ADB_SHORTCODE_DISABLED] = true; break; case 'external-scripts': if (!get_adb_external_scripts ()) { return ai_adb_external_scripts (); } } return ""; } if (($tracking = trim ($parameters ['tracking'])) != '') { switch (strtolower ($tracking)) { case 'disabled': $ai_wp_data [AI_TRACKING_SHORTCODE_DISABLED] = true; break; } return ""; } $block = - 1; $code_only = false; $name_only = false; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; if ($parameters ['block'] == '' && $parameters ['code'] != '' && !($parameters ['viewport'] != '' || in_array ('VIEWPORT', $atts) || in_array ('viewport', $atts))) { $parameters ['block'] = $parameters ['code']; $code_only = true; } // To convert name attribute to block elseif ($parameters ['block'] == '' && $parameters ['name'] != '' && !($parameters ['rotate'] != '' || in_array ('ROTATE', $atts) || in_array ('rotate', $atts))) { $parameters ['block'] = $parameters ['name']; $name_only = true; } if (is_numeric ($parameters ['block']) && !$name_only) { $block = intval ($parameters ['block']); // } elseif ($parameters ['name'] != '' && !($parameters ['rotate'] != '' || in_array ('ROTATE', $atts) || in_array ('rotate', $atts))) { // $shortcode_name = strtolower ($parameters ['name']); } elseif ($parameters ['block'] != '' && !($parameters ['rotate'] != '' || in_array ('ROTATE', $atts) || in_array ('rotate', $atts))) { $shortcode_name = strtolower ($parameters ['block']); for ($counter = 1; $counter <= 96; $counter ++) { $obj = $block_object [$counter]; $ad_name = strtolower (trim ($obj->get_ad_name())); if ($shortcode_name == $ad_name && $obj->get_enable_manual ()) { $block = $counter; break; } } if ($block == - 1) { // Check if it is a reusable block with this name $query = new WP_Query ( array ( 'post_type' => 'wp_block', // reusable block 'title' => $parameters ['block'], 'post_status' => 'published', 'posts_per_page' => 1, ) ); if (!empty ($query->post)) { // Return reusable block return $query->post->post_content; } } } if ($block == - 1) { if (function_exists ('ai_check_separators')) { if ($parameters ['check'] != '' || in_array ('CHECK', $atts) || in_array ('check', $atts)) { if (!isset ($ai_wp_data [AI_SHORTCODES]['check'])) $ai_wp_data [AI_SHORTCODES]['check'] = array (); $ai_wp_data [AI_SHORTCODES]['check'] []= $parameters; return AD_CHECK_SEPARATOR; } } if ($parameters ['viewport'] != '' || in_array ('VIEWPORT', $atts) || in_array ('viewport', $atts)) { if (!isset ($ai_wp_data [AI_SHORTCODES]['viewport'])) $ai_wp_data [AI_SHORTCODES]['viewport'] = array (); $ai_wp_data [AI_SHORTCODES]['viewport'] []= $parameters; return '|viewport'. (count ($ai_wp_data [AI_SHORTCODES]['viewport']) - 1). '|'; } if ($parameters ['count'] != '' || in_array ('COUNT', $atts) || in_array ('count', $atts)) { if (!isset ($ai_wp_data [AI_SHORTCODES]['count'])) $ai_wp_data [AI_SHORTCODES]['count'] = array (); $ai_wp_data [AI_SHORTCODES]['count'] []= $parameters; // return AD_COUNT_SEPARATOR; return '|count'. (count ($ai_wp_data [AI_SHORTCODES]['count']) - 1). '|'; } if ($parameters ['rotate'] != '' || in_array ('ROTATE', $atts) || in_array ('rotate', $atts)) { if (!isset ($ai_wp_data [AI_SHORTCODES]['rotate'])) $ai_wp_data [AI_SHORTCODES]['rotate'] = array (); $ai_wp_data [AI_SHORTCODES]['rotate'] []= $parameters; // return AD_ROTATE_SEPARATOR; return '|rotate'. (count ($ai_wp_data [AI_SHORTCODES]['rotate']) - 1). '|'; } if ($parameters ['amp'] != '' || in_array ('AMP', $atts) || in_array ('amp', $atts)) { return AD_AMP_SEPARATOR; } if ($parameters ['head'] != '' || in_array ('HEAD', $atts) || in_array ('head', $atts)) { if (!isset ($ai_wp_data [AI_SHORTCODES]['head'])) $ai_wp_data [AI_SHORTCODES]['head'] = array (); $ai_wp_data [AI_SHORTCODES]['head'] []= $parameters; return AD_HEAD_SEPARATOR; } if ($parameters ['http'] != '' || in_array ('HTTP', $atts) || in_array ('http', $atts)) { return AD_HTTP_SEPARATOR; } if ($parameters ['fallback'] != '' || in_array ('FALLBACK', $atts) || in_array ('fallback', $atts)) { if (!isset ($ai_wp_data [AI_SHORTCODES]['fallback'])) $ai_wp_data [AI_SHORTCODES]['fallback'] = array (); $ai_wp_data [AI_SHORTCODES]['fallback'] []= $parameters; return AD_FALLBACK_SEPARATOR; } if ($parameters ['group'] != '' || in_array ('GROUP', $atts) || in_array ('group', $atts)) { // Prevent group activation if (isset ($ai_wp_data [AI_NO_GROUP_ACTIVATION]) && $ai_wp_data [AI_NO_GROUP_ACTIVATION]) { return ''; } if ($parameters ['group'] != '') { $parameters ['group'] = mb_strtolower ($parameters ['group']); if (strpos ($parameters ['group'], ',') !== false) { $group_names = explode (',', $parameters ['group']); foreach ($group_names as $index => $group_name) { $group_names [$index] = trim ($group_names [$index]); } } else $group_names = array (trim ($parameters ['group'])); } else $group_names = array (); return ''; } if ($parameters ['disable'] != '' || in_array ('DISABLE', $atts) || in_array ('disable', $atts)) { if (!isset ($ai_wp_data [AI_DISABLED_BLOCKS])) $ai_wp_data [AI_DISABLED_BLOCKS] = array (); $shortcode_disabled = explode (',', strtolower (str_replace (' ', '', $parameters ['disable']))); $ai_wp_data [AI_DISABLED_BLOCKS] = array_unique (array_merge ($ai_wp_data [AI_DISABLED_BLOCKS], $shortcode_disabled)); if ($debug_processing) { ai_log ('DISABLED BLOCKS: ' . implode (', ', $ai_wp_data [AI_DISABLED_BLOCKS])); } return ''; } if ($parameters ['custom-field'] != '') { $custom_field_name = trim ($parameters ['custom-field']); $default_value = null; if (trim ($parameters ['data']) != '') { $custom_field_value = trim ($parameters ['data']); if ($parameters ['data'][0] == ':') { $default_value = substr ($parameters ['data'], 1); } else { $ai_wp_data [AI_CUSTOM_FIELDS][$custom_field_name] = $custom_field_value; return ''; } } if (isset ($ai_wp_data [AI_CUSTOM_FIELDS][$custom_field_name])) { return $ai_wp_data [AI_CUSTOM_FIELDS][$custom_field_name]; } $post_meta = get_post_meta (get_the_ID (), $parameters ['custom-field']); if (is_array ($post_meta)) { $post_meta = implode (', ', $post_meta); } return empty ($post_meta) && $default_value !== null ? $default_value : $post_meta; } if ($parameters ['random'] != '' || isset ($atts ['RANDOM']) || isset ($atts ['random'])) { $random_value_limits = trim ($parameters ['random']); $random_value = ''; if ($random_value_limits == '') { // Not used $random_value = rand (); } else { if (strpos ($random_value_limits, ',') !== false) { $limits = explode (',', $random_value_limits); $random_value = rand ((int) $limits [0], (int) $limits [1]); } else $random_value = rand (0, (int) $random_value_limits); } return ($random_value); } if ($parameters ['data'] != '') { for ($constant = 1; $constant <= 6; $constant ++) { $constant_name = trim (get_constant_name ($constant)); if ($constant_name != '' && $parameters ['data'] == $constant_name) { return get_constant_value ($constant); } } if (strpos ($parameters ['data'], ',') !== false) { $data_tags = explode (',', $parameters ['data']); $data = array (); foreach ($data_tags as $data_tag) { $constant_found = false; for ($constant = 1; $constant <= 6; $constant ++) { $constant_name = trim (get_constant_name ($constant)); if ($constant_name != '' && $data_tag == $constant_name) { $data []= get_constant_value ($constant); $constant_found = true; break; } } if (!$constant_found) { $data []= replace_ai_tags ('{'.trim ($data_tag).'}'); } } return implode (', ', $data); } return replace_ai_tags ('{'.$parameters ['data'].'}'); } if ($parameters ['counter'] != '') { $counter_name = strtolower ($parameters ['counter']); switch ($counter_name) { case 'block': if (isset ($ai_wp_data [AI_CURRENT_BLOCK_NUMBER]) && isset ($ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $ai_wp_data [AI_CURRENT_BLOCK_NUMBER]])) { return $ad_inserter_globals [AI_BLOCK_COUNTER_NAME . $ai_wp_data [AI_CURRENT_BLOCK_NUMBER]]; } break; case 'content': if (isset ($ad_inserter_globals [AI_CONTENT_COUNTER_NAME])) { return $ad_inserter_globals [AI_CONTENT_COUNTER_NAME]; } break; case 'excerpt': if (isset ($ad_inserter_globals [AI_EXCERPT_COUNTER_NAME])) { return $ad_inserter_globals [AI_EXCERPT_COUNTER_NAME]; } break; case 'before-post': if (isset ($ad_inserter_globals [AI_LOOP_BEFORE_COUNTER_NAME])) { return $ad_inserter_globals [AI_LOOP_BEFORE_COUNTER_NAME]; } break; case 'after-post': if (isset ($ad_inserter_globals [AI_LOOP_AFTER_COUNTER_NAME])) { return $ad_inserter_globals [AI_LOOP_AFTER_COUNTER_NAME]; } break; case 'widget': if (isset ($ai_wp_data [AI_CURRENT_BLOCK_NUMBER]) && isset ($ad_inserter_globals [AI_WIDGET_COUNTER_NAME . $ai_wp_data [AI_CURRENT_BLOCK_NUMBER]])) { return $ad_inserter_globals [AI_WIDGET_COUNTER_NAME . $ai_wp_data [AI_CURRENT_BLOCK_NUMBER]]; } break; case 'php': if (isset ($ai_wp_data [AI_CURRENT_BLOCK_NUMBER]) && isset ($ad_inserter_globals [AI_PHP_FUNCTION_CALL_COUNTER_NAME . $ai_wp_data [AI_CURRENT_BLOCK_NUMBER]])) { return $ad_inserter_globals [AI_PHP_FUNCTION_CALL_COUNTER_NAME . $ai_wp_data [AI_CURRENT_BLOCK_NUMBER]]; } break; } return ''; } if ($parameters ['name'] != '') { $shortcode_name = strtolower ($parameters ['name']); switch ($shortcode_name) { case 'processing-log': if (/*get_remote_debugging () ||*/ ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) { ob_start (); echo "
    \n";
                ai_write_debug_info ();
                echo "
    "; return ob_get_clean (); } return ""; case 'debugging-tools': if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 || defined ('AI_DEBUGGING_DEMO')) { ob_start (); ai_write_debugging_tools (); return ob_get_clean (); } default: if (defined ('AI_BUFFERING')) { if (get_output_buffering () && !get_disable_header_code ()) { return ""; } } return ""; } } } $ai_last_check = AI_CHECK_SHORTCODE_ATTRIBUTES; if ($block < 1 || $block > 96) return ""; // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("SHORTCODE $block (".($parameters ['block'] != '' ? 'block="'.$parameters ['block'].'"' : '').($parameters ['name'] != '' ? 'name="'.$parameters ['name'].'"' : '').")"); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("SHORTCODE ADINSERTER ".($parameters ['block'] != '' ? 'block="'.$block.'" ' : '').($parameters ['name'] != '' ? 'name="'.$parameters ['name'].'"' : '').""); // IGNORE SETTINGS // page-type // *block-counter // CHECK SETTINGS // exceptions $ignore_array = array (); if (trim ($parameters ['ignore']) != '') { $ignore_array = explode (",", str_replace (" ", "", $parameters ['ignore'])); } $check_array = array (); if (trim ($parameters ['check']) != '') { $check_array = explode (",", str_replace (" ", "", $parameters ['check'])); } $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_SHORTCODE; $obj = $block_object [$block]; $obj->clear_code_cache (); $ai_last_check = AI_CHECK_ENABLED_SHORTCODE; if (!$obj->get_enable_manual ()) return ""; if (!$obj->check_server_side_detection ()) return ""; if (!$obj->check_page_types_lists_users (in_array ("page-type", $ignore_array))) return ""; if (in_array ("exceptions", $check_array)) { if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) { // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true); $meta_value = ai_get_post_meta (); $selected_blocks = explode (",", $meta_value); if (!$obj->check_post_page_exceptions ($selected_blocks)) return ""; } } $ai_last_check = AI_CHECK_DISABLED_MANUALLY; if (!$obj->check_disabled ()) return ""; $ai_last_check = AI_CHECK_INSERTION_NOT_DISABLED; if ($obj->get_disable_insertion () || get_disable_block_insertions ()) return ""; // Last check before counter check before insertion // $ai_last_check = AI_CHECK_CODE; // if ($obj->ai_getCode () == '') return ""; if ($obj->empty_code ()) return ""; $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled (); if ($max_page_blocks_enabled) { $ai_last_check = AI_CHECK_MAX_PAGE_BLOCKS; if ($ai_wp_data [AI_PAGE_BLOCKS] >= get_max_page_blocks ()) return ""; } if (!$obj->check_filter_hook ($debug_processing)) return ""; // Last check before insertion if (!$obj->check_and_increment_block_counter ()) return ""; // Increment page block counter if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++; $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION; if (!$obj->get_debug_disable_insertion ()) { if (isset ($ai_wp_data [AI_SHORTCODES]['force_serverside'])) { $saved_force_serverside = $ai_wp_data [AI_SHORTCODES]['force_serverside']; } if (isset ($ai_wp_data [AI_SHORTCODES]['viewport'])) { $saved_viewport = $ai_wp_data [AI_SHORTCODES]['viewport']; } if (isset ($ai_wp_data [AI_SHORTCODES]['check'])) { $saved_check = $ai_wp_data [AI_SHORTCODES]['check']; } if (isset ($ai_wp_data [AI_SHORTCODES]['count'])) { $saved_count = $ai_wp_data [AI_SHORTCODES]['count']; } if (isset ($ai_wp_data [AI_SHORTCODES]['rotate'])) { $saved_rotate = $ai_wp_data [AI_SHORTCODES]['rotate']; } if (isset ($ai_wp_data [AI_SHORTCODES]['head'])) { $saved_head = $ai_wp_data [AI_SHORTCODES]['head']; } if (isset ($ai_wp_data [AI_SHORTCODES]['fallback'])) { $saved_fallback = $ai_wp_data [AI_SHORTCODES]['fallback']; } if (isset ($ai_wp_data [AI_SHORTCODES]['atts'])) { $saved_atts = $ai_wp_data [AI_SHORTCODES]['atts']; } $ai_wp_data [AI_SHORTCODES]['atts'] = $atts; if (isset ($ai_wp_data [AI_CURRENT_BLOCK_NUMBER])) { $saved_block_number = $ai_wp_data [AI_CURRENT_BLOCK_NUMBER]; } if (isset ($ai_wp_data [AI_CURRENT_BLOCK_NAME])) { $saved_block_name = $ai_wp_data [AI_CURRENT_BLOCK_NAME]; } $code = $obj->get_code_for_serverside_insertion (true, false, $code_only); if (isset ($saved_force_serverside)) { $ai_wp_data [AI_SHORTCODES]['force_serverside'] = $saved_force_serverside; } else unset ($ai_wp_data [AI_SHORTCODES]['force_serverside']); if (isset ($saved_viewport)) { $ai_wp_data [AI_SHORTCODES]['viewport'] = $saved_viewport; } else unset ($ai_wp_data [AI_SHORTCODES]['viewport']); if (isset ($saved_check)) { $ai_wp_data [AI_SHORTCODES]['check'] = $saved_check; } else unset ($ai_wp_data [AI_SHORTCODES]['check']); if (isset ($saved_count)) { $ai_wp_data [AI_SHORTCODES]['count'] = $saved_count; } else unset ($ai_wp_data [AI_SHORTCODES]['count']); if (isset ($saved_rotate)) { $ai_wp_data [AI_SHORTCODES]['rotate'] = $saved_rotate; } else unset ($ai_wp_data [AI_SHORTCODES]['rotate']); if (isset ($saved_fallback)) { $ai_wp_data [AI_SHORTCODES]['fallback'] = $saved_fallback; } else unset ($ai_wp_data [AI_SHORTCODES]['fallback']); if (isset ($saved_head)) { $ai_wp_data [AI_SHORTCODES]['head'] = $saved_head; } else unset ($ai_wp_data [AI_SHORTCODES]['head']); if (isset ($saved_atts)) { $ai_wp_data [AI_SHORTCODES]['atts'] = $saved_atts; } else unset ($ai_wp_data [AI_SHORTCODES]['atts']); if (isset ($saved_block_number)) { $ai_wp_data [AI_CURRENT_BLOCK_NUMBER] = $saved_block_number; } else unset ($ai_wp_data [AI_CURRENT_BLOCK_NUMBER]); if (isset ($saved_block_number)) { $ai_wp_data [AI_CURRENT_BLOCK_NAME] = $saved_block_name; } else unset ($ai_wp_data [AI_CURRENT_BLOCK_NAME]); // Must be after get_code_for_serverside_insertion () $ai_last_check = AI_CHECK_INSERTED; return $code; } } function ai_process_shortcodes ($atts, $content, $tag) { global $ai_last_check, $ai_wp_data, $ai_total_plugin_time; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; if ($debug_processing) { $atts_string = ''; if (is_array ($atts)) foreach ($atts as $index => $att) { if (is_numeric ($index)) $atts_string .= $att.' '; else $atts_string .= $index.("='".$att."'").' '; } ai_log ("PROCESS SHORTCODES [$tag ".trim ($atts_string).']'); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } $ai_last_check = AI_CHECK_NONE; $block = - 1; $shortcode = ai_process_shortcode ($block, $atts); if ($debug_processing) { if ($block == - 1) { if (strlen ($shortcode) < 100) ai_log ('SHORTCODE TEXT: "' . ai_log_filter_content ($shortcode) . '"'); else ai_log ('SHORTCODE TEXT: "' . ai_log_filter_content (html_entity_decode (substr ($shortcode, 0, 60))) . ' ... ' . ai_log_filter_content (html_entity_decode (substr ($shortcode, - 60))) . '"'); } elseif ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check)); if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("SHORTCODE END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } return $shortcode; } function ai_add_attr_data (&$tag, $attr, $new_data) { if (trim ($tag) != '' && strpos ($tag, '"; } function ai_widget_draw ($args, $instance, &$block) { global $block_object, $ad_inserter_globals, $ai_wp_data, $ai_last_check; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; $block = isset ($instance ['block']) ? $instance ['block'] : 1; $sticky = isset ($instance ['sticky']) ? $instance ['sticky'] : 0; if ($block == 0 || $block == - 2) { if (!get_disable_block_insertions () && (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 || defined ('AI_DEBUGGING_DEMO'))) { ai_special_widget ($args, $instance, $block); } return; } if ($sticky) { $ai_wp_data [AI_STICKY_WIDGETS] = true; if ($block == - 1 && !get_disable_block_insertions ()) { // Dummy widget $before_widget = $args ['before_widget']; ai_add_attr_data ($before_widget, 'style', 'padding: 0; border: 0; margin: 0; color: transparent; background: transparent;'); ai_add_attr_data ($before_widget, 'class', 'ai-sticky-widget'); if ($debug_processing) echo ai_debug_widget_comment ('before_widget'); echo $before_widget; if ($debug_processing) echo ai_debug_widget_comment ('before_widget', true); if ($debug_processing) echo ai_debug_widget_comment ('after_widget'); // No sense for empty dummy widgets // if (get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_CSS_PUSH) { // echo '
    '; // } echo $args ['after_widget']; if ($debug_processing) echo ai_debug_widget_comment ('after_widget', true); return; } } if ($block < 1 || $block > 96) return; $title = !empty ($instance ['widget-title']) ? $instance ['widget-title'] : ''; $obj = $block_object [$block]; $obj->clear_code_cache (); $globals_name = AI_WIDGET_COUNTER_NAME . $block; if (!isset ($ad_inserter_globals [$globals_name])) { $ad_inserter_globals [$globals_name] = 1; } else $ad_inserter_globals [$globals_name] ++; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("WIDGET (". $obj->number . ') ['.$ad_inserter_globals [$globals_name] . ']'); $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_WIDGET; $ai_last_check = AI_CHECK_ENABLED_WIDGET; if (!$obj->get_enable_widget ()) return; if (!$obj->check_server_side_detection ()) return; if (!$obj->check_page_types_lists_users ()) return; if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return; if (!$obj->check_number_of_words ()) return; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) { // $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true); $meta_value = ai_get_post_meta (); $selected_blocks = explode (",", $meta_value); if (!$obj->check_post_page_exceptions ($selected_blocks)) return; } $ai_last_check = AI_CHECK_DISABLED_MANUALLY; if (!$obj->check_disabled ()) return; $ai_last_check = AI_CHECK_INSERTION_NOT_DISABLED; if ($obj->get_disable_insertion () || get_disable_block_insertions ()) return; // Last check before counter check before insertion $ai_last_check = AI_CHECK_CODE; if ($obj->ai_getCode () == '') { if ($sticky) { $before_widget = $args ['before_widget']; ai_add_attr_data ($before_widget, 'style', 'padding: 0; border: 0; margin: 0; color: transparent; background: transparent;'); ai_add_attr_data ($before_widget, 'class', 'ai-sticky-widget'); if ($debug_processing) echo ai_debug_widget_comment ('before_widget'); echo $before_widget; if ($debug_processing) echo ai_debug_widget_comment ('before_widget', true); if ($debug_processing) echo ai_debug_widget_comment ('after_widget'); // No sense for empty widgets // if (get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_CSS_PUSH) { // echo '
    '; // } echo $args ['after_widget']; if ($debug_processing) echo ai_debug_widget_comment ('after_widget', true); } return; } $max_page_blocks_enabled = $obj->get_max_page_blocks_enabled (); if ($max_page_blocks_enabled) { $ai_last_check = AI_CHECK_MAX_PAGE_BLOCKS; if ($ai_wp_data [AI_PAGE_BLOCKS] >= get_max_page_blocks ()) return; } if (!$obj->check_filter_hook ($debug_processing)) return; // Last check before insertion if (!$obj->check_and_increment_block_counter ()) return; // Increment page block counter if ($max_page_blocks_enabled) $ai_wp_data [AI_PAGE_BLOCKS] ++; $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION; if (!$obj->get_debug_disable_insertion ()) { $viewport_classes = $obj->get_client_side_action () == AI_CLIENT_SIDE_ACTION_INSERT ? '' : trim ($obj->get_viewport_classes ()); $sticky_class = $sticky ? ' ai-sticky-widget' : ''; $widget_classes = trim ($viewport_classes . $sticky_class); $before_widget = $args ['before_widget']; if ($widget_classes != "") { ai_add_attr_data ($before_widget, 'class', $widget_classes); } if ($debug_processing) echo ai_debug_widget_comment ('before_widget'); echo $before_widget; if ($debug_processing) echo ai_debug_widget_comment ('before_widget', true); if (!empty ($title)) { if ($debug_processing) echo ai_debug_widget_comment ('before_title'); echo $args ['before_title']; if ($debug_processing) echo ai_debug_widget_comment ('before_title', true); echo apply_filters ('widget_title', $title); if ($debug_processing) echo ai_debug_widget_comment ('after_title'); echo $args ['after_title']; if ($debug_processing) echo ai_debug_widget_comment ('after_title', true); } $obj->needs_class = true; echo $obj->get_code_for_serverside_insertion (false); if ($debug_processing) echo ai_debug_widget_comment ('after_widget'); if ($sticky && get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_CSS_PUSH) { echo '
    '; } echo $args ['after_widget']; if ($debug_processing) echo ai_debug_widget_comment ('after_widget', true); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && $obj->get_detection_client_side () && $obj->get_client_side_action () == AI_CLIENT_SIDE_ACTION_SHOW) echo $obj->get_code_for_serverside_insertion (false, true); $ai_last_check = AI_CHECK_INSERTED; } } function ai_write_debugging_tools () { global $ai_wp_data; ai_toolbar_menu_items (); echo " "; echo '
      '; foreach ($ai_wp_data [AI_DEBUG_MENU_ITEMS] as $menu_item) { if (isset ($menu_item ['parent'])) { if ($menu_item ['parent'] == 'ai-toolbar-settings') { if ($menu_item ['id'] == 'ai-toolbar-status') { echo '
    • '; echo $menu_item ['title']; echo "
    • \n"; } else { echo '
    • '; echo '', $menu_item ['title'], ''; echo "
    • \n"; } } elseif ($menu_item ['parent'] == 'ai-toolbar-positions') { echo '
    • '; echo '', $menu_item ['title'], ''; echo "
    • \n"; } } else if ($menu_item ['id'] == 'ai-toolbar-settings') { echo '
    • '; echo '', $menu_item ['title'], ''; echo "
    • \n"; } } echo '
    '; } function ai_special_widget ($args, $instance, $block) { global $ai_wp_data, $ai_db_options, $block_object; $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0; $sticky = isset ($instance ['sticky']) ? $instance ['sticky'] : 0; if ($sticky) { $ai_wp_data [AI_STICKY_WIDGETS] = true; ai_add_attr_data ($args ['before_widget'], 'class', 'ai-sticky-widget'); } if ($debug_processing) echo ai_debug_widget_comment ('before_widget'); echo $args ['before_widget']; if ($debug_processing) echo ai_debug_widget_comment ('before_widget', true); $title = !empty ($instance ['widget-title']) ? $instance ['widget-title'] : ''; if (!empty ($title)) { if ($debug_processing) echo ai_debug_widget_comment ('before_title'); echo $args ['before_title']; if ($debug_processing) echo ai_debug_widget_comment ('before_title', true); echo apply_filters ('widget_title', $title); if ($debug_processing) echo ai_debug_widget_comment ('after_title'); echo $args ['after_title']; if ($debug_processing) echo ai_debug_widget_comment ('after_title', true); } switch ($block) { case 0: // Processing log echo "\n"; ai_write_debug_info (); echo ""; if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION]) { for ($viewport = 1; $viewport <= 6; $viewport ++) { $viewport_name = get_viewport_name ($viewport); if ($viewport_name != '') { echo "
    \n";
                echo "CLIENT-SIDE DEVICE:      ", $viewport_name;
                echo "
    "; } } } break; case - 2: // Debugging tools if ($sticky && get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_CSS_PUSH) { echo "
    \n"; } ai_write_debugging_tools (); if ($sticky && get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_CSS_PUSH) { echo "
    \n"; } break; } if ($debug_processing) echo ai_debug_widget_comment ('after_widget'); if ($sticky && get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_CSS_PUSH) { echo '
    '; } echo $args ['after_widget']; if ($debug_processing) echo ai_debug_widget_comment ('after_widget', true); } function ai_pro () { if (!function_exists ('ai_remote_plugin_data')) return false; return ai_remote_plugin_data ('pro', true); } function ai_remote ($name, $default_data = false) { if (!function_exists ('ai_remote_plugin_data')) return $default_data; return ai_remote_plugin_data ($name, $default_data); } function ai_is_json ($string, $return_data = false) { $data = json_decode ($string); return (json_last_error () == JSON_ERROR_NONE) ? ($return_data ? $data : true) : false; } function ai_structured_data_item ($indexes, $data, $value = '!@!') { if (is_object ($data)) $data = (array) $data; if (empty ($indexes)) { if ($value == '!@!') return true; return $data == $value; } if (!is_array ($data)) return false; // Workaround because after json decode array indexes are strings and can't be accessed $data = array_combine (array_keys ($data), array_values ($data)); $index = array_shift ($indexes); if ($index == '*') { foreach ($data as $data_index => $data_item) { if (ai_structured_data_item ($indexes, $data_item, $value)) return true; } } elseif (isset ($data [$index])) { return ai_structured_data_item ($indexes, $data [$index], $value); } return false; } function ai_structured_data ($data, $selector, $value = '') { if (!is_array ($data)) return false; if (strpos ($selector, '[') === false) return false; $indexes = explode ('[', str_replace (array (']', ' '), '', $selector)); return ai_structured_data_item ($indexes, $data, $value); } function check_url_parameter_cookie_list ($list, $white_list, $parameters, &$found) { $parameter_list = trim ($list); $return = $white_list; $found = false; $query_string = isset ($_SERVER ['QUERY_STRING']) ? trim ($_SERVER ['QUERY_STRING']) != '' : false; if ($parameter_list == AD_EMPTY_DATA) return true; if (count ($parameters) == 0 && strpos ($list, '#') === false) { return !$return; } $found = true; $parameter_data = array (); foreach ($parameters as $index => $parameter) { $parameter_data [$index] = false; if (is_string ($parameter)) { $data = trim (stripslashes ($parameter)); if (strpos ($data, '{') === 0) { $parameter_data [$index] = ai_is_json ($data, true); } $parameters [$index] = urlencode ($parameter); } } $parameters_listed = explode (",", $parameter_list); foreach ($parameters_listed as $index => $parameter_listed) { if (trim ($parameter_listed) == "") unset ($parameters_listed [$index]); else $parameters_listed [$index] = trim ($parameter_listed); } foreach ($parameters_listed as $parameter) { if ($parameter == '#') { if (!$query_string) return $return; } elseif (strpos ($parameter, "=") !== false) { $parameter_value = explode ("=", $parameter); if (array_key_exists ($parameter_value [0], $parameters) && $parameters [$parameter_value [0]] == $parameter_value [1]) return $return; if (ai_structured_data ($parameter_data, $parameter_value [0], $parameter_value [1])) return $return; } else { if (array_key_exists ($parameter, $parameters)) return $return; if (ai_structured_data ($parameter_data, $parameter)) return $return; } } $found = false; return !$return; } function check_url_parameter_list ($url_parameters, $white_list, &$found) { return check_url_parameter_cookie_list ($url_parameters, $white_list, $_GET, $found); } function check_cookie_list ($url_parameters, $white_list) { $dummy = false; return check_url_parameter_cookie_list ($url_parameters, $white_list, $_COOKIE, $dummy); } function check_url_parameter_and_cookie_list ($url_parameters, $white_list) { $dummy = false; return check_url_parameter_cookie_list ($url_parameters, $white_list, array_merge ($_COOKIE, $_GET), $dummy); } function check_scheduled_rotation ($scheduling) { If (strpos ($scheduling, '=') === false) return false; $result = true; if (strpos ($scheduling, '^') !== false) { $result = false; $scheduling = substr ($scheduling, 1); } $scheduling_data_array = explode ('=', $scheduling); if (strpos ($scheduling_data_array [0], '%') !== false) { $scheduling_data_time = explode ('%', $scheduling_data_array [0]); } else $scheduling_data_time = array ($scheduling_data_array [0]); $time_unit = strtolower (trim ($scheduling_data_time [0])); $time_division = isset ($scheduling_data_time [1]) ? trim ($scheduling_data_time [1]) : 0; $scheduling_time_option = str_replace (' ', '', ($scheduling_data_array [1])); $current_time = current_time ('timestamp'); $time_value = 0; switch ($time_unit) { case 's': $time_value = ltrim (date ('s', $current_time), '0'); break; case 'i': $time_value = ltrim (date ('i', $current_time), '0'); break; case 'h': $time_value = date ('G', $current_time); break; case 'd': $time_value = date ('j', $current_time); break; case 'm': $time_value = date ('n', $current_time); break; case 'y': $time_value = date ('Y', $current_time); break; case 'w': $time_value = date ('w', $current_time); if ($time_value == 0) $time_value = 6; else $time_value = $time_value - 1; } $time_modulo = $time_division != 0 ? $time_value % $time_division : $time_value; $scheduling_time_options = explode (',', $scheduling_time_option); foreach ($scheduling_time_options as $time_option) { if (strpos ($time_option, '-') !== false) { $time_limits = explode ('-', $time_option); if ($time_modulo >= $time_limits [0] && $time_modulo <= $time_limits [1]) return $result; } else if ($time_modulo == $time_option) return $result; } return !$result; } function check_scheduling_time ($start_time, $end_time, $days_in_week, $between) { if (!function_exists ('ai_scheduling_options')) return true; $current_time = current_time ('timestamp'); if (strpos ($start_time, '-') === false && strpos ($end_time, '-') === false) { $current_time -= (strtotime (current_time ('Y-m-d'))); if ($current_time < 0) { $current_time += 24 * 3600; } } $start_time = strtotime ($start_time, $current_time); $end_time = strtotime ($end_time, $current_time); $current_weekday = date ('w', $current_time); if ($current_weekday == 0) $current_weekday = 6; else $current_weekday --; $weekdays = explode (',', $days_in_week); if (isset ($weekdays [0]) and $weekdays [0] === '') $weekdays = array (); $insertion_enabled = $current_time >= $start_time && $current_time < $end_time && in_array ($current_weekday, $weekdays); return ($between ? $insertion_enabled : !$insertion_enabled); } function check_referer_list ($referers, $white_list) { if (isset ($_GET ['referrer'])) { $referer_host = esc_html ($_GET ['referrer']); } elseif (isset ($_SERVER['HTTP_REFERER'])) { $referer_host = strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST)); } else $referer_host = ''; // echo " referers='$referers' referer_host='$referer_host' "; $return = $white_list; $domains = strtolower (trim ($referers)); if ($domains == AD_EMPTY_DATA) return true; $domains = explode (",", $domains); foreach ($domains as $domain) { $domain = trim ($domain); if ($domain == "") continue; if ($domain [0] == '*') { if ($domain [strlen ($domain) - 1] == '*') { $domain = substr ($domain, 1, strlen ($domain) - 2); if (strpos ($referer_host, $domain) !== false) return $return; } else { $domain = substr ($domain, 1); if (substr ($referer_host, - strlen ($domain)) == $domain) return $return; } } elseif ($domain [strlen ($domain) - 1] == '*') { $domain = substr ($domain, 0, strlen ($domain) - 1); if (strpos ($referer_host, $domain) === 0) return $return; } if ($domain == "#") { if ($referer_host == "") return $return; } elseif ($domain == $referer_host) return $return; } return !$return; } function check_client_list ($clients, $white_list) { global $ai_wp_data; $languages = array ( 'af' => 'Afrikaans', 'sq' => 'Albanian', 'an' => 'Aragonese', 'ar*' => 'Arabic (Standard)', 'ar-dz' => 'Arabic (Algeria)', 'ar-bh' => 'Arabic (Bahrain)', 'ar-eg' => 'Arabic (Egypt)', 'ar-iq' => 'Arabic (Iraq)', 'ar-jo' => 'Arabic (Jordan)', 'ar-kw' => 'Arabic (Kuwait)', 'ar-lb' => 'Arabic (Lebanon)', 'ar-ly' => 'Arabic (Libya)', 'ar-ma' => 'Arabic (Morocco)', 'ar-om' => 'Arabic (Oman)', 'ar-qa' => 'Arabic (Qatar)', 'ar-sa' => 'Arabic (Saudi Arabia)', 'ar-sy' => 'Arabic (Syria)', 'ar-tn' => 'Arabic (Tunisia)', 'ar-ae' => 'Arabic (U.A.E.)', 'ar-ye' => 'Arabic (Yemen)', 'hy' => 'Armenian', 'as' => 'Assamese', 'ast' => 'Asturian', 'az' => 'Azerbaijani', 'eu' => 'Basque', 'bg' => 'Bulgarian', 'be' => 'Belarusian', 'bn' => 'Bengali', 'bs' => 'Bosnian', 'br' => 'Breton', 'my' => 'Burmese', 'ca' => 'Catalan', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh*' => 'Chinese', 'zh-hk' => 'Chinese (Hong Kong)', 'zh-cn' => 'Chinese (PRC)', 'zh-sg' => 'Chinese (Singapore)', 'zh-tw' => 'Chinese (Taiwan)', 'cv' => 'Chuvash', 'co' => 'Corsican', 'cr' => 'Cree', 'hr' => 'Croatian', 'cs' => 'Czech', 'da' => 'Danish', 'nl*' => 'Dutch (Standard)', 'nl-be' => 'Dutch (Belgian)', 'en*' => 'English', 'en-au' => 'English (Australia)', 'en-bz' => 'English (Belize)', 'en-ca' => 'English (Canada)', 'en-ie' => 'English (Ireland)', 'en-jm' => 'English (Jamaica)', 'en-nz' => 'English (New Zealand)', 'en-ph' => 'English (Philippines)', 'en-za' => 'English (South Africa)', 'en-tt' => 'English (Trinidad & Tobago)', 'en-gb' => 'English (United Kingdom)', 'en-us' => 'English (United States)', 'en-zw' => 'English (Zimbabwe)', 'eo' => 'Esperanto', 'et' => 'Estonian', 'fo' => 'Faeroese', 'fa' => 'Persian', 'fj' => 'Fijian', 'fi' => 'Finnish', 'fr*' => 'French (Standard)', 'fr-be' => 'French (Belgium)', 'fr-ca' => 'French (Canada)', 'fr-fr' => 'French (France)', 'fr-lu' => 'French (Luxembourg)', 'fr-mc' => 'French (Monaco)', 'fr-ch' => 'French (Switzerland)', 'fy' => 'Frisian', 'fur' => 'Friulian', 'gd*' => 'Scots Gaelic', 'gd-ie' => 'Gaelic (Irish)', 'gl' => 'Galacian', 'ka' => 'Georgian', 'de*' => 'German (Standard)', 'de-at' => 'German (Austria)', 'de-de' => 'German (Germany)', 'de-li' => 'German (Liechtenstein)', 'de-lu' => 'German (Luxembourg)', 'de-ch' => 'German (Switzerland)', 'el' => 'Greek', 'gu' => 'Gujurati', 'ht' => 'Haitian', 'he' => 'Hebrew', 'hi' => 'Hindi', 'hu' => 'Hungarian', 'is' => 'Icelandic', 'id' => 'Indonesian', 'iu' => 'Inuktitut', 'ga' => 'Irish', 'it*' => 'Italian (Standard)', 'it-ch' => 'Italian (Switzerland)', 'ja' => 'Japanese', 'kn' => 'Kannada', 'ks' => 'Kashmiri', 'kk' => 'Kazakh', 'km' => 'Khmer', 'ky' => 'Kirghiz', 'tlh' => 'Klingon', 'ko*' => 'Korean', 'ko-kp' => 'Korean (North Korea)', 'ko-kr' => 'Korean (South Korea)', 'la' => 'Latin', 'lv' => 'Latvian', 'lt' => 'Lithuanian', 'lb' => 'Luxembourgish', 'mk' => 'Macedonian', 'ms' => 'Malay', 'ml' => 'Malayalam', 'mt' => 'Maltese', 'mi' => 'Maori', 'mr' => 'Marathi', 'mo' => 'Moldavian', 'nv' => 'Navajo', 'ng' => 'Ndonga', 'ne' => 'Nepali', 'no' => 'Norwegian', 'nb' => 'Norwegian (Bokmal)', 'nn' => 'Norwegian (Nynorsk)', 'oc' => 'Occitan', 'or' => 'Oriya', 'om' => 'Oromo', 'fa-ir' => 'Persian/Iran', 'pl' => 'Polish', 'pt*' => 'Portuguese', 'pt-br' => 'Portuguese (Brazil)', 'pa*' => 'Punjabi', 'pa-in' => 'Punjabi (India)', 'pa-pk' => 'Punjabi (Pakistan)', 'qu' => 'Quechua', 'rm' => 'Rhaeto-Romanic', 'ro*' => 'Romanian', 'ro-mo' => 'Romanian (Moldavia)', 'ru*' => 'Russian', 'ru-mo' => 'Russian (Moldavia)', 'sz' => 'Sami (Lappish)', 'sg' => 'Sango', 'sa' => 'Sanskrit', 'sc' => 'Sardinian', 'sd' => 'Sindhi', 'si' => 'Singhalese', 'sr' => 'Serbian', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'so' => 'Somani', 'sb' => 'Sorbian', 'es*' => 'Spanish', 'es-ar' => 'Spanish (Argentina)', 'es-bo' => 'Spanish (Bolivia)', 'es-cl' => 'Spanish (Chile)', 'es-co' => 'Spanish (Colombia)', 'es-cr' => 'Spanish (Costa Rica)', 'es-do' => 'Spanish (Dominican Republic)', 'es-ec' => 'Spanish (Ecuador)', 'es-sv' => 'Spanish (El Salvador)', 'es-gt' => 'Spanish (Guatemala)', 'es-hn' => 'Spanish (Honduras)', 'es-mx' => 'Spanish (Mexico)', 'es-ni' => 'Spanish (Nicaragua)', 'es-pa' => 'Spanish (Panama)', 'es-py' => 'Spanish (Paraguay)', 'es-pe' => 'Spanish (Peru)', 'es-pr' => 'Spanish (Puerto Rico)', 'es-es' => 'Spanish (Spain)', 'es-uy' => 'Spanish (Uruguay)', 'es-ve' => 'Spanish (Venezuela)', 'sx' => 'Sutu', 'sw' => 'Swahili', 'sv*' => 'Swedish', 'sv-fi' => 'Swedish (Finland)', 'sv-sv' => 'Swedish (Sweden)', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Teluga', 'th' => 'Thai', 'tig' => 'Tigre', 'ts' => 'Tsonga', 'tn' => 'Tswana', 'tr' => 'Turkish', 'tk' => 'Turkmen', 'uk' => 'Ukrainian', 'hsb' => 'Upper Sorbian', 'ur' => 'Urdu', 've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapuk', 'wa' => 'Walloon', 'cy' => 'Welsh', 'xh' => 'Xhosa', 'ji' => 'Yiddish', 'zu' => 'Zulu', ); if (version_compare (phpversion (), "5.6", ">=")) { if (!isset ($ai_wp_data [AI_AGENT])) { require_once AD_INSERTER_PLUGIN_DIR.'includes/agent/Agent.php'; $agent = new Agent(); $ai_wp_data [AI_AGENT] = $agent; } else $agent = $ai_wp_data [AI_AGENT]; $language = isset ($_SERVER ['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER ['HTTP_ACCEPT_LANGUAGE'] : ''; $return = $white_list; if ($clients == AD_EMPTY_DATA) return true; $clients = explode (",", $clients); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (!isset ($ai_wp_data [AI_CLIENTS])) $ai_wp_data [AI_CLIENTS] = array (); foreach ($clients as $client) { $client = trim ($client); if ($client == "") continue; $ai_wp_data [AI_CLIENTS][] = $client; } } foreach ($clients as $client) { $client = trim ($client); if ($client == "") continue; $check_language = false; if (strpos ($client, 'language:') === 0) { $check_language = true; $client = substr ($client, 9); } if ($check_language) { if ($client [0] == '*') { if ($client [strlen ($client) - 1] == '*') { $client = substr ($client, 1, strlen ($client) - 2); if (stripos ($language, $client) !== false) return $return; } else { $client = substr ($client, 1); if (strtolower (substr ($language, - strlen ($client))) == strtolower ($client)) return $return; } } elseif ($client [strlen ($client) - 1] == '*') { $client = substr ($client, 0, strlen ($client) - 1); if (stripos ($language, $client) === 0) return $return; } elseif (strtolower ($client) == strtolower ($language)) return $return; } else { if ($client [0] == '*') { if ($client [strlen ($client) - 1] == '*') { $client = substr ($client, 1, strlen ($client) - 2); if (stripos ($agent->getUserAgent (), $client) !== false) return $return; } else { $client = substr ($client, 1); if (strtolower (substr ($agent->getUserAgent (), - strlen ($client))) == strtolower ($client)) return $return; } } elseif ($client [strlen ($client) - 1] == '*') { $client = substr ($client, 0, strlen ($client) - 1); if (stripos ($agent->getUserAgent (), $client) === 0) return $return; } elseif ($agent->is ($client)) return $return; } } return !$return; } else { return true; } } function ai_check_block ($block) { global $ai_delay_showing_pageviews; $ai_cookie_name = 'aiBLOCKS'; if (isset ($_COOKIE [$ai_cookie_name])) { $ai_cookie = json_decode (stripslashes ($_COOKIE [$ai_cookie_name])); } else $ai_cookie = new stdClass(); if (isset ($ai_delay_showing_pageviews)) { if (!isset ($ai_cookie->$block)) { $ai_cookie->$block = new stdClass(); } if (!isset ($ai_cookie->$block->d)) { $ai_cookie->$block->d = $ai_delay_showing_pageviews; } unset ($ai_delay_showing_pageviews); } if (isset ($ai_cookie)) { if (isset ($ai_cookie->$block) && is_object ($ai_cookie->$block)) { foreach ($ai_cookie->$block as $property => $value) { switch ($property) { case 'x': $closed_for = $value - time (); if ($closed_for > 0) { return false; } else { ai_set_cookie ($block, 'x', ''); } break; case 'd': if ($value != 0) { return false; } break; case 'i': if ($value == 0) { return false; } elseif ($value < 0) { $closed_for = - $value - time (); if ($closed_for > 0) { return false; } else { ai_set_cookie ($block, 'i', ''); if (!isset ($ai_cookie->$block->c) && !isset ($ai_cookie->$block->x)) { ai_set_cookie ($block, 'h', ''); } } } break; case 'ipt': if ($value == 0 && isset ($ai_cookie->$block->it)) { $closed_for = $ai_cookie->$block->it - time (); if ($closed_for > 0) { return false; } } break; case 'c': if ($value == 0) { return false; } elseif ($value < 0) { $closed_for = - $value - time (); if ($closed_for > 0) { return false; } else { ai_set_cookie ($block, 'c', ''); if (!isset ($ai_cookie->$block->i) && !isset ($ai_cookie->$block->x)) { ai_set_cookie ($block, 'h', ''); } } } break; case 'cpt': if ($value == 0 && isset ($ai_cookie->$block->ct)) { $closed_for = $ai_cookie->$block->ct - time (); if ($closed_for > 0) { return false; } } break; } } if (isset ($ai_cookie->G) && is_object ($ai_cookie->G) && isset ($ai_cookie->G->cpt)) { if ($ai_cookie->G->cpt == 0 && isset ($ai_cookie->$block->ct)) { $closed_for = $ai_cookie->$block->ct - time (); if ($closed_for > 0) { return false; } } } } } return true; } function ai_get_category_list () { if (function_exists ('ai_remote_plugin_data')) { $data = ai_remote_plugin_data ('categories'); if (is_array ($data)) return $data; } $args = array ("hide_empty" => 0, 'number' => AI_MAX_LIST_ITEMS); return (get_categories ($args)); } function ai_get_tag_list () { if (function_exists ('ai_remote_plugin_data')) { $data = ai_remote_plugin_data ('tags'); if (is_array ($data)) return $data; } $args = array ('number' => AI_MAX_LIST_ITEMS); return (get_tags ($args)); } function ai_get_taxonomy_list () { if (function_exists ('ai_remote_plugin_data')) { $data = ai_remote_plugin_data ('taxonomies'); if (is_array ($data)) return $data; } $term_data = get_terms (); $taxonomies = array (); foreach ($term_data as $term) { if ($term->taxonomy == 'category') continue; if ($term->taxonomy == 'post_tag') continue; $taxonomies [strtolower ($term->taxonomy) . ':' . strtolower ($term->slug)] = $term->name; if (count ($taxonomies) >= AI_MAX_LIST_ITEMS) break; } $args = array ( 'public' => true, ); $custom_post_types = get_post_types ($args, 'objects', 'and'); foreach ($custom_post_types as $custom_post_type => $custom_post_data) { $taxonomies ['post-type:' . strtolower ($custom_post_type)] = $custom_post_data->labels->singular_name; } $editable_roles = get_editable_roles (); foreach ($editable_roles as $editable_role_slug => $editable_role) { $taxonomies ['user-role:' . strtolower ($editable_role_slug)] = $editable_role ['name']; } $taxonomies ['user:logged-in'] = 'User logged in'; $taxonomies ['user:not-logged-in'] = 'User not logged in'; $users = get_users (); foreach ($users as $user) { $taxonomies ['user:' . strtolower ($user->data->user_login)] = $user->data->display_name; $taxonomies ['author:' . strtolower ($user->data->user_login)] = $user->data->display_name; if (count ($taxonomies) >= AI_MAX_LIST_ITEMS) break; } ksort ($taxonomies); return $taxonomies; } function ai_get_post_id_list () { if (function_exists ('ai_remote_plugin_data')) { $data = ai_remote_plugin_data ('post-ids'); if (is_array ($data)) return $data; } $args = array ( 'public' => true, '_builtin' => false ); $custom_post_types = get_post_types ($args, 'names', 'and'); $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types)); $args = array ( 'posts_per_page' => 3 * AI_MAX_LIST_ITEMS, 'offset' => 0, 'category' => '', 'category_name' => '', 'orderby' => 'ID', 'order' => 'ASC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => $screens, 'post_mime_type' => '', 'post_parent' => '', 'author' => '', 'author_name' => '', 'post_status' => '', 'suppress_filters' => true, ); $posts_pages = get_posts ($args); $posts_pages = array_slice ($posts_pages, 0, AI_MAX_LIST_ITEMS); foreach ($posts_pages as $index => $post_page) { unset ($posts_pages [$index]->post_content); } return $posts_pages; } function ai_check_filter_hook ($block) { // Called by W3TC code and Ajax requests $check = apply_filters ("ai_block_insertion_check", true, $block, false); // Called with false as $server_side_check = client-side check or W3TC check so null should not be returned from the filter hook - return false if ($check === null) { return false; } return $check; } function ai_set_cookie ($block, $property, $value) { $ai_cookie_name = 'aiBLOCKS'; if (isset ($_COOKIE [$ai_cookie_name])) { $ai_cookie = json_decode (stripslashes ($_COOKIE [$ai_cookie_name])); } else $ai_cookie = new stdClass(); // print_r ($ai_cookie); if ($value == '') { if (isset ($ai_cookie->$block) && is_object ($ai_cookie->$block)) { unset ($ai_cookie->$block->$property); $ai_cookie_array = (array) $ai_cookie->$block; if (empty ($ai_cookie_array)) { unset ($ai_cookie->$block); } } } else { if (!isset ($ai_cookie->$block)) { $ai_cookie->$block = new stdClass(); } $ai_cookie->$block->$property = $value; } $ai_cookie_array = (array) $ai_cookie; if (empty ($ai_cookie_array)) { unset ($_COOKIE [$ai_cookie_name]); ai_setcookie ($ai_cookie_name, null, - 1, '/'); } else { // $_COOKIE [$ai_cookie_name] = addslashes (json_encode ($ai_cookie)); $_COOKIE [$ai_cookie_name] = json_encode ($ai_cookie); ai_setcookie ($ai_cookie_name, $_COOKIE [$ai_cookie_name], time () + 365 * 24 * 3600, '/'); } // if (isset ($_COOKIE [$ai_cookie_name])) { // print_r ($_COOKIE [$ai_cookie_name]); // } else echo "NO COOKIE
    "; } function get_paragraph_start_positions ($content, $multibyte, $paragraph_end_positions, $paragraph_start_strings, &$paragraph_positions, &$active_paragraph_positions) { foreach ($paragraph_start_strings as $paragraph_start_string) { if (trim ($paragraph_start_string) == '') continue; $last_position = - 1; $paragraph_start_string = trim ($paragraph_start_string); if ($paragraph_start_string == "#") { $paragraph_start = "\r\n\r\n"; if (!in_array (0, $paragraph_positions)) { $paragraph_positions [] = 0; $active_paragraph_positions [0] = 1; } } else $paragraph_start = '<' . $paragraph_start_string; if ($multibyte) { $paragraph_start_len = mb_strlen ($paragraph_start); while (mb_stripos ($content, $paragraph_start, $last_position + 1) !== false) { $last_position = mb_stripos ($content, $paragraph_start, $last_position + 1); if ($paragraph_start_string == "#") { $paragraph_positions [] = $last_position + 4; $active_paragraph_positions [$last_position + 4] = 1; } elseif (mb_substr ($content, $last_position + $paragraph_start_len, 1) == ">" || mb_substr ($content, $last_position + $paragraph_start_len, 1) == " ") { $paragraph_positions [] = $last_position; $active_paragraph_positions [$last_position] = 1; } } } else { $paragraph_start_len = strlen ($paragraph_start); while (stripos ($content, $paragraph_start, $last_position + 1) !== false) { $last_position = stripos ($content, $paragraph_start, $last_position + 1); if ($paragraph_start_string == "#") { $paragraph_positions [] = $last_position + 4; $active_paragraph_positions [$last_position + 4] = 1; } elseif ($content [$last_position + $paragraph_start_len] == ">" || $content [$last_position + $paragraph_start_len] == " ") { $paragraph_positions [] = $last_position; $active_paragraph_positions [$last_position] = 1; } } } } // Consistency check if (count ($paragraph_end_positions) != 0) { foreach ($paragraph_end_positions as $index => $paragraph_end_position) { if ($index == 0) { if (!isset ($paragraph_positions [$index]) || $paragraph_positions [$index] >= $paragraph_end_position) { $paragraph_positions [$index] = 0; } } else { if (!isset ($paragraph_positions [$index]) || $paragraph_positions [$index] >= $paragraph_end_position || $paragraph_positions [$index] <= $paragraph_end_positions [$index - 1]) { $paragraph_positions [$index] = $paragraph_end_positions [$index - 1] + 1; } } } } } function get_paragraph_end_positions ($content, $multibyte, $paragraph_start_positions, $paragraph_end_strings, &$paragraph_positions, &$active_paragraph_positions) { $no_closing_tag = array ('img', 'hr', 'br'); foreach ($paragraph_end_strings as $paragraph_end_string) { $last_position = - 1; $paragraph_end_string = trim ($paragraph_end_string); if ($paragraph_end_string == '') continue; if (in_array ($paragraph_end_string, $no_closing_tag)) { if (preg_match_all ("/<$paragraph_end_string([^>]*?)>/", $content, $images)) { foreach ($images [0] as $paragraph_end) { if ($multibyte) { $last_position = mb_stripos ($content, $paragraph_end, $last_position + 1) + mb_strlen ($paragraph_end) - 1; $paragraph_positions [] = $last_position; $active_paragraph_positions [$last_position] = 1; } else { $last_position = stripos ($content, $paragraph_end, $last_position + 1) + strlen ($paragraph_end) - 1; $paragraph_positions [] = $last_position; $active_paragraph_positions [$last_position] = 1; } } } continue; } elseif ($paragraph_end_string == "#") { $paragraph_end = "\r\n\r\n"; if (!in_array ($last_content_position, $paragraph_positions)) { $paragraph_positions [] = $last_content_position; $active_paragraph_positions [$last_content_position] = 1; } } else $paragraph_end = ''; if ($multibyte) { while (mb_stripos ($content, $paragraph_end, $last_position + 1) !== false) { $last_position = mb_stripos ($content, $paragraph_end, $last_position + 1) + mb_strlen ($paragraph_end) - 1; if ($paragraph_end_string == "#") { $paragraph_positions [] = $last_position - 4; $active_paragraph_positions [$last_position - 4] = 1; } else { $paragraph_positions [] = $last_position; $active_paragraph_positions [$last_position] = 1; } } } else { while (stripos ($content, $paragraph_end, $last_position + 1) !== false) { $last_position = stripos ($content, $paragraph_end, $last_position + 1) + strlen ($paragraph_end) - 1; if ($paragraph_end_string == "#") { $paragraph_positions [] = $last_position - 4; $active_paragraph_positions [$last_position - 4] = 1; } else { $paragraph_positions [] = $last_position; $active_paragraph_positions [$last_position] = 1; } } } } // Consistency check if (count ($paragraph_start_positions) != 0) { foreach ($paragraph_start_positions as $index => $paragraph_start_position) { if ($index == count ($paragraph_start_positions) - 1) { if (!isset ($paragraph_positions [$index]) || $paragraph_positions [$index] <= $paragraph_start_position) { $paragraph_positions [$index] = strlen ($content) - 1; } } else { if (!isset ($paragraph_positions [$index]) || $paragraph_positions [$index] <= $paragraph_start_position || $paragraph_positions [$index] >= $paragraph_start_positions [$index + 1]) { $paragraph_positions [$index] = $paragraph_start_positions [$index + 1] - 1; } } } } } function ai_secret_key () { $key = ''; if (defined ('NONCE_KEY')) { $key = NONCE_KEY; } $key .= AD_INSERTER_VERSION; return (substr (preg_replace ("/[^A-Za-z]+/", '', base64_encode ($key)), 0, 16)); } //function ai_the_generator ($generator) { //// return preg_replace ('/content="(.*?)"/', 'content="$1, '.AD_INSERTER_NAME.' '. AD_INSERTER_VERSION.'"', $generator); // return $generator . PHP_EOL . ''; //} function ai_ampforwp_check_disabled () { if (is_multisite()) { $option_active_plugins = array_merge (array_flip (get_site_option ('active_sitewide_plugins', array ())), get_option ('active_plugins', array ())); } else $option_active_plugins = get_option ('active_plugins'); $present = false; foreach ($option_active_plugins as $option_active_plugin) { if ($option_active_plugin == AD_INSERTER_SLUG . '/ad-inserter.php') { $present = true; break; } } if (!$present) return false; if (function_exists ('ampforwp_api_request_disable_plugin')) { $option_active_plugins = ampforwp_api_request_disable_plugin ($option_active_plugins); } $disabled = true; foreach ($option_active_plugins as $option_active_plugin) { if ($option_active_plugin == AD_INSERTER_SLUG . '/ad-inserter.php') { $disabled = false; break; } } return $disabled; } function ai_amp_plugin_custom_css () { if (is_multisite()) { $option_active_plugins = array_merge (array_flip (get_site_option ('active_sitewide_plugins', array ())), get_option ('active_plugins', array ())); } else $option_active_plugins = get_option ('active_plugins'); // echo "
    ";
    //  print_r ($option_active_plugins);
    //  echo "
    "; foreach ($option_active_plugins as $option_active_plugin) { if ($option_active_plugin == 'amp-wp/amp-wp.php') { return true; } if ($option_active_plugin == 'better-amp/better-amp.php') { return true; } } return false; } function ai_primary_category () { $primary_category = ai_rank_math_primary_category (); if ($primary_category != '') { return $primary_category; } // Returns the first category if primary category is not defined $primary_category = ai_yoast_primary_category (); return $primary_category; } function ai_yoast_primary_category () { $primary_category = ''; $category = get_the_category (); // If post has a category assigned. if ($category) { if (class_exists ('WPSEO_Primary_Term')) { // Show the post's 'Primary' category, if this Yoast feature is available, & one is set $wpseo_primary_term = new WPSEO_Primary_Term ('category', get_the_id ()); $wpseo_primary_term = $wpseo_primary_term->get_primary_term (); $term = get_term ($wpseo_primary_term); if (is_wp_error ($term)) { // Default to first category (not Yoast) if an error is returned $primary_category = $category [0]->slug; } else { // Yoast Primary category $primary_category = $term->slug; } } else { // Default, display the first category in WP's list of assigned categories $primary_category = $category [0]->slug; } } return $primary_category; } function ai_rank_math_primary_category () { $primary_category = ''; if (class_exists ('RankMath')) { $primary_cat_id = get_post_meta (get_the_id (), 'rank_math_primary_category', true); if ($primary_cat_id) { $category = get_term ($primary_cat_id, 'category'); $primary_category = $category->slug; } } return $primary_category; } function ai_is_page_builder () { // echo $_SERVER ['HTTP_HOST'], ' ', $_SERVER ['REQUEST_URI'], "
    \n"; // global $ai_wp_data; // echo $ai_wp_data [AI_WP_PAGE_TYPE], "
    \n"; // Elemetor if (class_exists ('Elementor\Plugin') && (\Elementor\Plugin::$instance->editor->is_edit_mode () || \Elementor\Plugin::$instance->preview->is_preview_mode ())) { return true; } return false; } function ai_add_rewrite_rules () { if (get_option (AI_ADS_TXT_NAME) !== false) { add_rewrite_rule ('ads\.txt', str_replace (home_url () .'/', '', admin_url ('admin-ajax.php?action=ai_ajax&ads-txt=')), 'top'); } if (function_exists ('ai_add_rewrite_rules_2')) ai_add_rewrite_rules_2 (); } function ai_js_dom_ready ($js_code, $script_tag = true, $script_class = '') { $id = rand (100000, 999999) . rand (100000, 999999); $id_fn = ''; $code = ''; $inline_js = ai_inline_js (); if (!$inline_js) { $id_fn = '_fn'; } if ($script_class != '') { $script_class = ' class="' . $script_class . '"'; } if ($script_tag) { $code .= " "; $js_code = '/* AI_JS */' . $js_code . '/* AI_JS */'; } $code .= "ai_run_{$id} = function(){{$js_code}};"; if (!$inline_js) { $code .= "ai_run_{$id}{$id_fn} = function(){ai_wait_for_functions ().then (ai_run_{$id})}"; } $code .= " "; if ($script_tag) { $code .= " "; } $code .= "if (document.readyState === 'complete' || (document.readyState !== 'loading' && !document.documentElement.doScroll)) ai_run_{$id}{$id_fn} (); else document.addEventListener ('DOMContentLoaded', ai_run_{$id}{$id_fn});"; if ($script_tag) { $code .= " "; } return ($code); } function ai_extract_js_code ($code) { global $ai_wp_data; if (strpos ($code, '') !== false) { if (preg_match_all ('#/\* AI_JS \*/(.+?)/\* AI_JS \*/#s', $code, $js_matches)) { $js_code_dom_ready = ''; foreach ($js_matches [1] as $js_code) { $js_code_dom_ready .= $js_code."\n"; } $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] = $js_code_dom_ready . $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY]; } $code = preg_replace ('#(.+?)#s', '', $code); } return $code; } function ai_strip_js_markers ($code) { $code = preg_replace ('##s', '', $code); $code = preg_replace ('#/\* AI_JS \*/#s', '', $code); return ($code); } function ai_strip_w3tc_markers ($code) { if (defined ('W3TC_DYNAMIC_SECURITY')) { // $code = preg_replace ('#(.+?)#s', '', $code); $code = preg_replace ('##s', '', $code); } return ($code); } function ai_extract_debug_bar ($ai_code) { if (preg_match ('#
    #s', $ai_code, $match)) { $debug_bar = str_replace (array ('ai-debug-default', 'debug-viewport-invisible'), '', $match [0]); $debug_bar = preg_replace ('#(.*?)#s', $ai_code, $match)) { $w3tc_debug = $match [0]; } else $w3tc_debug = ''; return '
    ' . $debug_bar . $w3tc_debug . '
    '; } } function ai_w3tc_debug_info ($w3tc_debug, $class = '') { return '
    ' . implode ("\n", $w3tc_debug) . "
    \n"; } function ai_w3tc_block_start ($block) { global $ai_w3tc_nesting_level; if (!isset ($ai_w3tc_nesting_level)) { $ai_w3tc_nesting_level = 0; } $ai_w3tc_nesting_level ++; if ($ai_w3tc_nesting_level > 1) { ai_w3tc_log_run (''); } ai_w3tc_log_run ("BLOCK $block W3TC START"); } function ai_w3tc_block_end ($block, $ai_code, $ai_enabled, $ai_fallback, $ai_index) { global $ai_w3tc_debugging, $ai_w3tc_nesting_level; if (!isset ($ai_w3tc_nesting_level)) { $ai_w3tc_nesting_level = 0; } ai_w3tc_log_run ("BLOCK $block W3TC END" . ($ai_enabled ? '' : ': NOT ENABLED') . ' [' . (isset ($ai_fallback) ? $ai_fallback : '') . ',' . (isset ($ai_index) ? $ai_index : '') . ']'); $ai_w3tc_nesting_level --; if ($ai_w3tc_nesting_level != 0) { ai_w3tc_log_run (''); return $ai_code = str_replace ("", '', $ai_code); } // Placeholder for additional messages $ai_w3tc_debugging []= ""; $new_code = str_replace ("", ai_w3tc_debug_info ($ai_w3tc_debugging, "ai-w3tc-run"), $ai_code); $ai_w3tc_debugging = array (); return $new_code; } function ai_w3tc_block_end_message ($message, $ai_code) { return str_replace ("", $message . "\n", $ai_code); } function ai_w3tc_log_run ($w3tc_debug_text, $css = '') { global $ai_w3tc_debugging, $ai_w3tc_nesting_level; if (!isset ($ai_w3tc_debugging)) { $ai_w3tc_debugging = array (); } if (!isset ($ai_w3tc_nesting_level)) { $ai_w3tc_nesting_level = 0; } if ($css != '') { if (is_array ($w3tc_debug_text)) { foreach ($w3tc_debug_text as $index => $w3tc_debug_line) { $w3tc_debug_text [$index] = "" . $w3tc_debug_text [$index] . ''; } array_unshift ($w3tc_debug_text, "\n"); } else $w3tc_debug_text = "" . $w3tc_debug_text . ''; } if (isset ($ai_w3tc_nesting_level) && $ai_w3tc_nesting_level > 1) { if (is_array ($w3tc_debug_text)) { foreach ($w3tc_debug_text as $index => $w3tc_debug_line) { $w3tc_debug_text [$index] = str_repeat (' ', $ai_w3tc_nesting_level - 1) . $w3tc_debug_text [$index]; } array_unshift ($w3tc_debug_text, "\n"); } else $w3tc_debug_text = str_repeat (' ', $ai_w3tc_nesting_level - 1) . $w3tc_debug_text; } if (is_array ($w3tc_debug_text)) { $ai_w3tc_debugging = array_merge ($ai_w3tc_debugging, $w3tc_debug_text); } else $ai_w3tc_debugging []= $w3tc_debug_text; } function ai_w3tc_execute_php ($code, &$ai_index, &$ai_fallback) { global $ai_wp_data; if (strpos ($code, '(.*?)#', $code, $php_codes); // $html_codes = explode ('[?#?]', preg_replace ('#(.*?)#', '[?#?]', $code)); preg_match_all ('##', $code, $php_codes); $html_codes = explode ('[?#?]', preg_replace ('##', '[?#?]', $code)); ob_start (); if ($ai_wp_data [AI_W3TC_DEBUGGING]) { ai_w3tc_log_run (' EXECUTE PHP' . ' ['.(isset ($ai_fallback) ? $ai_fallback : '') . ',' . (isset ($ai_index) ? $ai_index : '').']'); } foreach ($html_codes as $index => $html_code) { if ($html_code != '') { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { ai_w3tc_log_run (' HTML: ' . strlen ($html_code) . ' bytes'); } echo $html_code; } if ($index < count ($html_codes) - 1) { if ($ai_wp_data [AI_W3TC_DEBUGGING]) { ai_w3tc_log_run ($w3tc_info []= ' PHP: ' . strlen ($php_codes [1][$index]) . ' bytes'); } eval ($php_codes [1][$index]); } } $html = ob_get_clean(); if ($ai_wp_data [AI_W3TC_DEBUGGING]) { ai_w3tc_log_run (' EXECUTE END' . ' ['.(isset ($ai_fallback) ? $ai_fallback : '') . ',' . (isset ($ai_index) ? $ai_index : '').']'); } return ($html); } function ai_get_post_id () { $queried_object = get_queried_object (); $post_id = get_the_ID (); if (defined ('AI_USE_GET_QUERIED_OBJECT') && AI_USE_GET_QUERIED_OBJECT && $queried_object && isset ($queried_object->ID)) { return $queried_object->ID; } if ($queried_object && $post_id) { return $post_id; } if ($queried_object && isset ($queried_object->ID)) { return $queried_object->ID; } return $post_id; } function ai_get_post_meta () { $meta_value = get_post_meta (ai_get_post_id (), '_adinserter_block_exceptions', true); return $meta_value; } function ai_post_is_in_child_categories ($category) { $category_to_check = get_term_by ('slug', $category, 'category'); if ($category_to_check) { $post_id = ai_get_post_id (); $children = get_term_children ($category_to_check->term_id, 'category'); if ($children && in_category ($children, $post_id)) return true; } return false; } function ai_post_is_in_child_taxonomies ($taxonomy, $term) { $taxonomy_to_check = get_term_by ('slug', $term, $taxonomy); if ($taxonomy_to_check) { $post_id = ai_get_post_id (); $children = get_term_children ($taxonomy_to_check->term_id, $taxonomy); if ($children && has_term ($children, $taxonomy, $post_id)) return true; } return false; } function ai_get_permalink ($id) { if (defined ('AI_CONNECTED_WEBSITE')) { $connected_website = get_transient (AI_CONNECTED_WEBSITE); if ($connected_website !== false) return ''; } return (get_permalink ($id)); } function ai_get_edit_post_link ($id) { if (defined ('AI_CONNECTED_WEBSITE')) { $connected_website = get_transient (AI_CONNECTED_WEBSITE); if ($connected_website !== false) return ''; } return (get_edit_post_link ($id)); } function ai_setcookie ($name, $value, $expire, $path, $samesite = 'Lax') { if (PHP_VERSION_ID < 70300) { setcookie ($name, $value, $expire, $path . '; samesite=' . $samesite); return; } setcookie ($name, $value, [ 'expires' => $expire, 'path' => $path, 'samesite' => $samesite, ]); } function ai_process_viewport_separators ($code, $shortcode_data) { global $ai_wp_data; $viewport_shortcode_data = $shortcode_data ['viewport']; preg_match_all ('/\|viewport([0-9]+?)\|/', $code, $matches); if (count ($matches [1]) != 0) { $viewport_parameters = array (); foreach ($matches [1] as $match) { $viewport_parameters []= $viewport_shortcode_data [$match]; } if ($ai_wp_data [AI_WP_AMP_PAGE]) { $code = preg_replace ('/\|viewport([0-9]+?)\|/', '', $code); } else $code = preg_replace ('/\|viewport([0-9]+?)\|/', AD_VIEWPORT_SEPARATOR, $code); } $processed_code = $code; if (strpos ($code, AD_VIEWPORT_SEPARATOR) !== false) { $processed_code = ''; $codes = explode (AD_VIEWPORT_SEPARATOR, $code); if (trim ($codes [0]) == '') { unset ($codes [0]); $codes = array_values ($codes); } else array_unshift ($viewport_parameters, array ('viewport' => '', 'code' => '')); foreach ($codes as $viewport_code_index => $viewport_code) { $viewport_code = ai_process_fallback_separator ($viewport_code, $shortcode_data); $separator_viewports = explode (',', strtolower ($viewport_parameters [$viewport_code_index]['viewport'])); foreach ($separator_viewports as $index => $separator_viewport) { $separator_viewports [$index] = trim ($separator_viewport); } $viewport_classes = ''; for ($viewport = 1; $viewport <= 6; $viewport ++) { $viewport_name = strtolower (get_viewport_name ($viewport)); if ($viewport_name != '') { $viewport_found = in_array ($viewport_name, $separator_viewports); if ($viewport_found) { $viewport_classes .= " ai-viewport-" . $viewport; } } } if ($viewport_classes == '') { if ($viewport_parameters [$viewport_code_index]['viewport'] != '') { // Invalid viewport - Code will never be inserted continue; } } $viewport_classes = trim ($viewport_classes); if ($viewport_classes != '') { $viewport_class = " class='" . $viewport_classes . "'"; } else $viewport_class = ''; $insert_code = get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT; switch (strtolower ($viewport_parameters [$viewport_code_index]['code'])) { case 'insert': $insert_code = true; break; case 'show': $insert_code = false; break; } if ($insert_code) { $code_id = 'ai-viewport-code-' . rand (1000, 9999) . rand (1000, 9999); if ($viewport_classes != '') { $viewport_classes = 'ai-viewports ' . $viewport_classes . ' '; } $ai_code = base64_encode (ai_strip_js_markers ($viewport_code)); $processed_code .= "
    \n"; if (!get_disable_js_code ()) { // $js_code = "ai_insert_code (document.getElementsByClassName ('$code_id') [0]);"; $js_code = "ai_insert_code_by_class ('$code_id');"; $processed_code .= ai_strip_js_markers (ai_js_dom_ready ($js_code)); } } else { if ($viewport_class != '') { $processed_code .= "\n" . $viewport_code . "\n
    \n"; } else $processed_code .= $viewport_code; } } } return $processed_code; } function ai_process_fallback_separator ($code, $shortcode_data) { global $ai_wp_data; $fallback_shortcode_data = $shortcode_data ['fallback']; $processed_code = $code; if (strpos ($code, AD_FALLBACK_SEPARATOR) !== false) { $codes = explode (AD_FALLBACK_SEPARATOR, $code); $processed_code = $codes [0]; // AdSense unfilled if (strtolower ($fallback_shortcode_data [0]['fallback']) == 'adsense') { $insert_code = get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE_INSERT; switch (strtolower ($fallback_shortcode_data [0]['code'])) { case 'insert': $insert_code = true; break; case 'show': $insert_code = false; break; } $empty_fallback_code_class = trim ($codes [1]) == '' ? " ai-empty-code" : ''; $processed_code = "
    " . $processed_code . "
    \n"; if ($insert_code) { $ai_code = base64_encode (ai_strip_js_markers (trim ($codes [1]))); $processed_code .= "
    \n"; } else { $processed_code .= "
    \n" . trim ($codes [1]) . "\n
    \n"; } } } return $processed_code; } function replace_ai_tags ($content, $general_tag = '') { global $ai_wp_data; if (preg_match_all ('#\[ADINSERTER (.+)\]#i', $content, $matches)) { if (count ($matches [0])) { foreach ($matches [0] as $match) { $content = str_replace ($match, do_shortcode ($match), $content); } } } if (strpos ($content, '{') === false) return $content; if (isset ($ai_wp_data [AI_SHORTCODES]['atts']) && is_array ($ai_wp_data [AI_SHORTCODES]['atts']) && !empty ($ai_wp_data [AI_SHORTCODES]['atts'])) { foreach ($ai_wp_data [AI_SHORTCODES]['atts'] as $name => $value) { $content = preg_replace ("/\{\#$name(\:[^{}]*?)?\#\}/i", $value, $content); } } if (!isset ($ai_wp_data [AI_TAGS])) { $general_tag = str_replace ("&", " and ", $general_tag); $title = $general_tag; $short_title = $general_tag; $category = $general_tag; $categories = $general_tag; $categories_array = array (); $category_slugs_array = array (); $categories_spaces = $general_tag; $short_category = $general_tag; $tag = $general_tag; $tags = $general_tag; $tags_array = array (); $tag_slugs_array = array (); $tags_spaces = $general_tag; $categories_single_quotes = $general_tag; $categories_double_quotes = $general_tag; $smart_tag = $general_tag; if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_CATEGORY) { $wp_categories = get_queried_object (); if (!empty ($wp_categories) && $wp_categories instanceof WP_Term) { $first_category = $wp_categories; $category = str_replace ("&", "and", $first_category->name); if ($category == _x('Uncategorized', 'category name', 'ad-inserter')) $category = $general_tag; } else { $category = $general_tag; } if (strpos ($category, ",") !== false) { $short_category = trim (substr ($category, 0, strpos ($category, ","))); } else $short_category = $category; if (strpos ($short_category, "and") !== false) { $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and"))); } $title = $category; $title = str_replace ("&", "and", $title); $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3)); $tag = $short_title; $smart_tag = $short_title; // $wp_categories = get_the_category(); // if (!empty ($wp_categories)) { // foreach ($wp_categories as $single_category) { // $categories_array [] = str_replace (array ("&", "#"), array ("and", ""), isset ($single_category->name) ? $single_category->name : ''); // $category_slugs_array [] = $single_category->slug; // } $wp_categories = get_queried_object(); if ($wp_categories instanceof WP_Term) { $categories_array [] = str_replace (array ("&", "#"), array ("and", ""), isset ($wp_categories->name) ? $wp_categories->name : ''); $category_slugs_array [] = $wp_categories->slug; $categories = implode (',', $categories_array); $categories_spaces = implode (' ', $categories_array); $categories_single_quotes = implode ("','", $categories_array); if ($categories_single_quotes != '') $categories_single_quotes = "'".$categories_single_quotes."'"; $categories_double_quotes = implode ('","', $categories_array); if ($categories_double_quotes != '') $categories_double_quotes = '"'.$categories_double_quotes.'"'; } } elseif (is_tag ()) { $title = single_tag_title('', false); $title = str_replace (array ("&", "#", '"', "'"), array ("and", "", '', ''), $title); $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3)); $category = $short_title; if (strpos ($category, ",") !== false) { $short_category = trim (substr ($category, 0, strpos ($category, ","))); } else $short_category = $category; if (strpos ($short_category, "and") !== false) { $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and"))); } $tag = $short_title; $smart_tag = $short_title; $wp_tags = get_the_tags (); if (!empty ($wp_tags)) { foreach ($wp_tags as $single_tag) { $tags_array [] = str_replace (array ("&", "#"), array ("and", ""), isset ($single_tag->name) ? $single_tag->name : ''); $tag_slugs_array [] = $single_tag->slug; } $tags = implode (',', $tags_array); $tags_spaces = implode (' ', $tags_array); } } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_SEARCH) { $title = get_search_query(); $title = str_replace ("&", "and", $title); $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3)); $category = $short_title; if (strpos ($category, ",") !== false) { $short_category = trim (substr ($category, 0, strpos ($category, ","))); } else $short_category = $category; if (strpos ($short_category, "and") !== false) { $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and"))); } $tag = $short_title; $smart_tag = $short_title; } elseif ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) { $title = get_the_title(); $title = str_replace (array ("&", '"', "'"), array ("and", '', ''), $title); $short_title = implode (" ", array_slice (explode (" ", $title), 0, 3)); $wp_categories = get_the_category(); if (!empty ($wp_categories)) { foreach ($wp_categories as $single_category) { if (isset ($single_category->slug)) { $categories_array [] = str_replace (array ("&", "#"), array ("and", ""), isset ($single_category->name) ? $single_category->name : ''); $category_slugs_array [] = $single_category->slug; } } $categories = implode (',', $categories_array); $categories_spaces = implode (' ', $categories_array); $categories_single_quotes = implode ("','", $categories_array); if ($categories_single_quotes != '') $categories_single_quotes = "'".$categories_single_quotes."'"; $categories_double_quotes = implode ('","', $categories_array); if ($categories_double_quotes != '') $categories_double_quotes = '"'.$categories_double_quotes.'"'; $first_category = $categories_array [0]; $category = $first_category; if ($category == _x('Uncategorized', 'category name', 'ad-inserter')) $category = $general_tag; } else { $category = $short_title; } if (strpos ($category, ",") !== false) { $short_category = trim (substr ($category, 0, strpos ($category, ","))); } else $short_category = $category; if (strpos ($short_category, "and") !== false) { $short_category = trim (substr ($short_category, 0, strpos ($short_category, "and"))); } $wp_tags = get_the_tags(); if (!empty ($wp_tags)) { foreach ($wp_tags as $single_tag) { $tags_array [] = str_replace (array ("&", "#"), array ("and", ""), isset ($single_tag->name) ? $single_tag->name : ''); $tag_slugs_array [] = $single_tag->slug; } $tags = implode (',', $tags_array); $tags_spaces = implode (' ', $tags_array); $first_tag = $tags_array [0]; $tag = $first_tag; $tag_array = array (); foreach ($wp_tags as $tag_data) { if (isset ($tag_data->name)) $tag_array [] = explode (" ", $tag_data->name); } $selected_tag = ''; if (count ($tag_array [0]) == 2) $selected_tag = $tag_array [0]; elseif (count ($tag_array) > 1 && count ($tag_array [1]) == 2) $selected_tag = $tag_array [1]; elseif (count ($tag_array) > 2 && count ($tag_array [2]) == 2) $selected_tag = $tag_array [2]; elseif (count ($tag_array) > 3 && count ($tag_array [3]) == 2) $selected_tag = $tag_array [3]; elseif (count ($tag_array) > 4 && count ($tag_array [4]) == 2) $selected_tag = $tag_array [4]; if ($selected_tag == '' && count ($tag_array) >= 2 && count ($tag_array [0]) == 1 && count ($tag_array [1]) == 1) { if (isset ($tag_array [0][0]) && isset ($tag_array [1][0])) { if (strpos ($tag_array [0][0], $tag_array [1][0]) !== false) $tag_array = array_slice ($tag_array, 1, count ($tag_array) - 1); } if (isset ($tag_array [0][0]) && isset ($tag_array [1][0])) { if (strpos ($tag_array [1][0], $tag_array [0][0]) !== false) $tag_array = array_slice ($tag_array, 1, count ($tag_array) - 1); } if (isset ($tag_array [0][0]) && isset ($tag_array [1][0])) { if (count ($tag_array) >= 2 && count ($tag_array [0]) == 1 && count ($tag_array [1]) == 1) { $selected_tag = array ($tag_array [0][0], $tag_array [1][0]); } } } if ($selected_tag == '') { $first_tag = $tags_array [0]; $smart_tag = implode (" ", array_slice (explode (" ", $first_tag), 0, 3)); } else $smart_tag = implode (" ", $selected_tag); $smart_tag = str_replace (array ("&", "#"), array ("and", ""), $smart_tag); } else { $tag = $category; $smart_tag = $category; } } $title = str_replace (array ("'", '"'), array ("’", "”"), $title); $title = html_entity_decode ($title, ENT_QUOTES, "utf-8"); $short_title = str_replace (array ("'", '"'), array ("’", "”"), $short_title); $short_title = html_entity_decode ($short_title, ENT_QUOTES, "utf-8"); $search_query = ""; if (isset ($_SERVER['HTTP_REFERER'])) { $referrer = $_SERVER['HTTP_REFERER']; } else $referrer = ''; if (preg_match ("/[\.\/](google|yahoo|bing|ask)\.[a-z\.]{2,5}[\/]/i", $referrer, $search_engine)){ $referrer_query = parse_url ($referrer); $referrer_query = isset ($referrer_query ["query"]) ? $referrer_query ["query"] : ""; parse_str ($referrer_query, $value); $search_query = isset ($value ["q"]) ? $value ["q"] : ""; if ($search_query == "") { $search_query = isset ($value ["p"]) ? $value ["p"] : ""; } } if ($search_query == "") $search_query = $smart_tag; // $author = get_the_author_meta ('display_name'); // $author_name = get_the_author_meta ('first_name') . " " . get_the_author_meta ('last_name'); // if ($author_name == ' ') $author_name = $author; $url = remove_debug_parameters_from_url ((isset ($_SERVER ['HTTPS']) && $_SERVER ['HTTPS'] === 'on' ? "https" : "http") . '://'. $_SERVER ['HTTP_HOST'] . $_SERVER ['REQUEST_URI']); $post_id = ai_get_post_id (); $ai_wp_data [AI_TAGS]['TITLE'] = $title; $ai_wp_data [AI_TAGS]['SHORT_TITLE'] = $short_title; $ai_wp_data [AI_TAGS]['CATEGORY'] = $category; $ai_wp_data [AI_TAGS]['CATEGORIES'] = $categories; $ai_wp_data [AI_TAGS]['CATEGORIES_ARRAY'] = $categories_array; $ai_wp_data [AI_TAGS]['CATEGORY_SLUGS_ARRAY'] = $category_slugs_array; $ai_wp_data [AI_TAGS]['CATEGORIES_SPACES'] = $categories_spaces; $ai_wp_data [AI_TAGS]['CATEGORIES_SINGLE_QUOTES'] = $categories_single_quotes; $ai_wp_data [AI_TAGS]['CATEGORIES_DOUBLE_QUOTES'] = $categories_double_quotes; $ai_wp_data [AI_TAGS]['SHORT_CATEGORY'] = $short_category; $ai_wp_data [AI_TAGS]['TAG'] = $tag; $ai_wp_data [AI_TAGS]['TAGS'] = $tags; $ai_wp_data [AI_TAGS]['TAGS_ARRAY'] = $tags_array; $ai_wp_data [AI_TAGS]['TAG_SLUGS_ARRAY'] = $tag_slugs_array; $ai_wp_data [AI_TAGS]['TAGS_SPACES'] = $tags_spaces; $ai_wp_data [AI_TAGS]['SMART_TAG'] = $smart_tag; $ai_wp_data [AI_TAGS]['SEARCH_QUERY'] = $search_query; // $ai_wp_data [AI_TAGS]['AUTHOR'] = $author; // $ai_wp_data [AI_TAGS]['AUTHOR_NAME'] = $author_name; $ai_wp_data [AI_TAGS]['POST_ID'] = $post_id; $ai_wp_data [AI_TAGS]['URL'] = $url; } // Author should not be cached $author = get_the_author_meta ('display_name'); $author_login = get_the_author_meta ('user_login'); $author_name = get_the_author_meta ('first_name') . " " . get_the_author_meta ('last_name'); if ($author_name == ' ') $author_name = $author; $ai_wp_data [AI_TAGS]['AUTHOR'] = $author; $ai_wp_data [AI_TAGS]['AUTHOR_NAME'] = $author_name; $ai_wp_data [AI_TAGS]['AUTHOR_LOGIN'] = $author_login; $ad_data = preg_replace ("/{title}/i", $ai_wp_data [AI_TAGS]['TITLE'], $content); $ad_data = preg_replace ("/{short-title}/i", $ai_wp_data [AI_TAGS]['SHORT_TITLE'], $ad_data); $ad_data = preg_replace ("/{category}/i", $ai_wp_data [AI_TAGS]['CATEGORY'], $ad_data); $ad_data = preg_replace ("/{categories}/i", $ai_wp_data [AI_TAGS]['CATEGORIES'], $ad_data); $ad_data = preg_replace ("/{categories-spaces}/i", $ai_wp_data [AI_TAGS]['CATEGORIES_SPACES'], $ad_data); $ad_data = preg_replace ("/{categories-single-quotes}/i", $ai_wp_data [AI_TAGS]['CATEGORIES_SINGLE_QUOTES'], $ad_data); $ad_data = preg_replace ("/{categories-double-quotes}/i", $ai_wp_data [AI_TAGS]['CATEGORIES_DOUBLE_QUOTES'], $ad_data); $ad_data = preg_replace ("/{short-category}/i", $ai_wp_data [AI_TAGS]['SHORT_CATEGORY'], $ad_data); $ad_data = preg_replace ("/{tag}/i", $ai_wp_data [AI_TAGS]['TAG'], $ad_data); $ad_data = preg_replace ("/{tags}/i", $ai_wp_data [AI_TAGS]['TAGS'], $ad_data); $ad_data = preg_replace ("/{tags-spaces}/i", $ai_wp_data [AI_TAGS]['TAGS_SPACES'], $ad_data); $ad_data = preg_replace ("/{smart-tag}/i", $ai_wp_data [AI_TAGS]['SMART_TAG'], $ad_data); $ad_data = preg_replace ("/{search-query}/i", $ai_wp_data [AI_TAGS]['SEARCH_QUERY'], $ad_data); $ad_data = preg_replace ("/{author}/i", $ai_wp_data [AI_TAGS]['AUTHOR'], $ad_data); $ad_data = preg_replace ("/{author-name}/i", $ai_wp_data [AI_TAGS]['AUTHOR_NAME'], $ad_data); $ad_data = preg_replace ("/{author-login}/i", $ai_wp_data [AI_TAGS]['AUTHOR_LOGIN'], $ad_data); $ad_data = preg_replace ("/{post-id}/i", $ai_wp_data [AI_TAGS]['POST_ID'], $ad_data); $ad_data = preg_replace ("/{short_title}/i", $ai_wp_data [AI_TAGS]['SHORT_TITLE'], $ad_data); $ad_data = preg_replace ("/{short_category}/i", $ai_wp_data [AI_TAGS]['SHORT_CATEGORY'], $ad_data); $ad_data = preg_replace ("/{smart_tag}/i", $ai_wp_data [AI_TAGS]['SMART_TAG'], $ad_data); $ad_data = preg_replace ("/{search_query}/i", $ai_wp_data [AI_TAGS]['SEARCH_QUERY'], $ad_data); $ad_data = preg_replace ("/{author_name}/i", $ai_wp_data [AI_TAGS]['AUTHOR_NAME'], $ad_data); $ad_data = preg_replace ("/{block-number}/i", isset ($ai_wp_data [AI_CURRENT_BLOCK_NUMBER]) ? $ai_wp_data [AI_CURRENT_BLOCK_NUMBER] : '', $ad_data); $ad_data = preg_replace ("/{block-name}/i", isset ($ai_wp_data [AI_CURRENT_BLOCK_NAME]) ? $ai_wp_data [AI_CURRENT_BLOCK_NAME] : '', $ad_data); $ad_data = preg_replace ("/{block-name-encoded}/i", isset ($ai_wp_data [AI_CURRENT_BLOCK_NAME]) ? urlencode ($ai_wp_data [AI_CURRENT_BLOCK_NAME]) : '', $ad_data); $ad_data = preg_replace ("/{url}/i", $ai_wp_data [AI_TAGS]['URL'], $ad_data); if (preg_match ("/{reusable-block-([\d]+)}/i", $ad_data, $block_match)) { $block_id = $block_match [1]; $reusable_block = ''; if (!empty ($block_id) && (int) $block_id == $block_id) { $reusable_block = get_post_field ('post_content', $block_id); } $ad_data = preg_replace ("/".$block_match [0]."/i", $reusable_block, $ad_data); } if (preg_match_all ("/{tag-([\d+])}/i", $ad_data, $tag_matches)) { foreach ($tag_matches [1] as $tag_index) { $tag_to_replace = isset ($ai_wp_data [AI_TAGS]['TAGS_ARRAY'][$tag_index - 1]) ? $ai_wp_data [AI_TAGS]['TAGS_ARRAY'][$tag_index - 1] : ''; $ad_data = preg_replace ("/{tag-$tag_index}/i", $tag_to_replace, $ad_data); } } if (preg_match_all ("/{tag-slug-([\d+])}/i", $ad_data, $tag_matches)) { foreach ($tag_matches [1] as $tag_index) { $tag_to_replace = isset ($ai_wp_data [AI_TAGS]['TAG_SLUGS_ARRAY'][$tag_index - 1]) ? $ai_wp_data [AI_TAGS]['TAG_SLUGS_ARRAY'][$tag_index - 1] : ''; $ad_data = preg_replace ("/{tag-slug-$tag_index}/i", $tag_to_replace, $ad_data); } } if (preg_match_all ("/{category-([\d+])}/i", $ad_data, $category_matches)) { foreach ($category_matches [1] as $category_index) { $category_to_replace = isset ($ai_wp_data [AI_TAGS]['CATEGORIES_ARRAY'][$category_index - 1]) ? $ai_wp_data [AI_TAGS]['CATEGORIES_ARRAY'][$category_index - 1] : ''; $ad_data = preg_replace ("/{category-$category_index}/i", $category_to_replace, $ad_data); } } if (preg_match_all ("/{category-slug-([\d+])}/i", $ad_data, $category_matches)) { foreach ($category_matches [1] as $category_index) { $category_to_replace = isset ($ai_wp_data [AI_TAGS]['CATEGORY_SLUGS_ARRAY'][$category_index - 1]) ? $ai_wp_data [AI_TAGS]['CATEGORY_SLUGS_ARRAY'][$category_index - 1] : ''; $ad_data = preg_replace ("/{category-slug-$category_index}/i", $category_to_replace, $ad_data); } } if (function_exists ('ai_tags')) ai_tags ($ad_data); // Replace default values {tag:default} $default_value_tags = preg_match_all ("/\{\#[a-zA-Z\-_][a-zA-Z0-9\-_]*?\:(.*?)\#\}/", $ad_data, $matches); if ($default_value_tags) { foreach ($matches [0] as $index => $match) { $ad_data = str_replace ($match, $matches [1][$index], $ad_data); } } return $ad_data; } function ai_ad_label_code () { global $ai_wp_data; $ad_label = get_ad_label (true); $ad_label = apply_filters ("ai_ad_label", $ad_label); if (strpos ($ad_label, '<') === false && strpos ($ad_label, '>') === false) { $ad_label = '
    ' . $ad_label . '
    '; } $unfiltered_html = $ai_wp_data [AI_UNFILTERED_HTML]; if (defined ('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML) { $unfiltered_html = false; } if (!$unfiltered_html) { $ad_label = wp_kses ($ad_label, 'post'); } return $ad_label .= "\n"; } function ai_php_enabled () { $php_enabled = !(defined ('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT) && !(defined ('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS); return apply_filters ('ai_php_enabled', $php_enabled); } function ai_inline_js () { // return (get_wait_for_jquery () || !defined ('AI_EXTERNAL_JS')); return (get_wait_for_jquery () == AI_WAIT_FOR_JQUERY_ENABLED || (get_javascript_code_mode () == AI_JAVASCRIPT_CODE_INLINE && !defined ('AI_EXTERNAL_JS'))); } function ai_unserialize ($string) { // Clear objects - O:5:"Class":0:{} // $string = preg_replace ('#o:\d+:"[a-z0-9_]+":\d+:{.*?}#i', '', $string); return @unserialize ($string, ['allowed_classes' => false]); } // =========================================================================================== global $block_object, $ai_wp_data, $ad_inserter_globals, $ai_last_check, $ai_last_time, $ai_total_plugin_time, $ai_total_block_php_time, $ai_total_hook_php_time, $ai_processing_log, $ai_db_options_extract, $ai_db_options, $block_insertion_log; if (!defined ('AD_INSERTER_PLUGIN_DIR')) define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__)); define ('AI_WP_DEBUGGING_', 0); define ('AI_DEBUG_PROCESSING_', 0x01); define ('AI_URL_DEBUG_', 'ai-debug'); define ('AI_URL_DEBUG_PROCESSING_', 'ai-debug-processing'); define ('AI_URL_DEBUG_PROCESSING_FE_', 'ai-debug-processing-fe'); define ('AI_URL_DEBUG_PHP_', 'ai-debug-php'); if (isset ($_GET [AI_URL_DEBUG_PHP_]) && $_GET [AI_URL_DEBUG_PHP_] != '') { if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) { ini_set ('display_errors', 1); error_reporting (E_ALL); } } $ai_wp_data [AI_WP_DEBUGGING_] = 0; $start_time = 0; if (!is_admin()) { if (!isset ($_GET [AI_URL_DEBUG_]) || $_GET [AI_URL_DEBUG_] != 0) if (isset ($_GET [AI_URL_DEBUG_PROCESSING_]) || isset ($_GET [AI_URL_DEBUG_PROCESSING_FE_]) || (isset ($_COOKIE ['AI_WP_DEBUGGING']) && ($_COOKIE ['AI_WP_DEBUGGING'] & AI_DEBUG_PROCESSING_) != 0)) { if ((isset ($_GET [AI_URL_DEBUG_PROCESSING_]) && $_GET [AI_URL_DEBUG_PROCESSING_] == 1) || (isset ($_GET [AI_URL_DEBUG_PROCESSING_FE_]) && $_GET [AI_URL_DEBUG_PROCESSING_FE_] == 1)) { $ai_wp_data [AI_WP_DEBUGGING_] |= AI_DEBUG_PROCESSING_; $ai_total_plugin_time = 0; $start_time = microtime (true); $ai_total_block_php_time = 0; $ai_total_hook_php_time = 0; $ai_last_time = microtime (true); $ai_processing_log = array (); ai_log ('INITIALIZATION START'); } } } // Version check global $wp_version, $version_string, $subversion_string, $filter_hooks; if (version_compare ($wp_version, "4.6", "<")) { exit ('Ad Inserter ' . __('requires WordPress 4.6 or newer', 'ad-inserter') . '. '. __('Please update!', 'ad-inserter') . ''); } //if (version_compare (phpversion (), "5.6", "<")) { // exit ('Ad Inserter ' . __('requires PHP 5.6 or newer', 'ad-inserter') . '. '. __('Please update!', 'ad-inserter') . ''); //} $filter_hooks = array (); if (isset ($_GET ['ai-safe-mode'])) { define ('AI_SAFE_MODE', 1); } //include required files require_once AD_INSERTER_PLUGIN_DIR.'class.php'; require_once AD_INSERTER_PLUGIN_DIR.'constants.php'; require_once AD_INSERTER_PLUGIN_DIR.'settings.php'; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("AFTER REQUIRE: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms"); $subversion_array = explode ("-", AD_INSERTER_VERSION); $subversion_string = isset ($subversion_array [1]) ? '-'.$subversion_array [1] : ''; $version_array = explode (".", $subversion_array [0]); $version_string = ""; foreach ($version_array as $number) { $version_string .= sprintf ("%02d", $number); } $ai_wp_data [AI_WP_URL] = remove_debug_parameters_from_url (); $ad_inserter_globals = array (); $block_object = array (); $block_insertion_log = array (); $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE; $ai_wp_data [AI_WP_AMP_PAGE] = false; $ai_wp_data [AI_WP_USER_SET] = false; $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN; $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE; $ai_wp_data [AI_SERVER_SIDE_DETECTION] = false; $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = false; $ai_wp_data [AI_MOBILE_DETECT_JS] = false; $ai_wp_data [AI_TRACKING] = false; $ai_wp_data [AI_STICKY_WIDGETS] = false; $ai_wp_data [AI_STICK_TO_THE_CONTENT] = false; $ai_wp_data [AI_ANIMATION] = false; $ai_wp_data [AI_CLOSE_BUTTONS] = false; $ai_wp_data [AI_IFRAMES] = false; $ai_wp_data [AI_DISABLE_CACHING] = false; $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = false; $ai_wp_data [AI_LAZY_LOADING] = false; $ai_wp_data [AI_PAGE_BLOCKS] = 0; $ai_wp_data [AI_GEOLOCATION] = false; //$ai_wp_data [AI_HTML_ELEMENT_SELECTION] = isset ($_POST ['html_element_selection']) ? (bool) $_POST ['html_element_selection'] : false; $ai_wp_data [AI_HTML_ELEMENT_SELECTION] = false; $ai_wp_data [AI_MBSTRING_LOADED] = extension_loaded ('mbstring'); $ai_wp_data [AI_PROCESSING_TIME] = false; $ai_wp_data [AI_FORCE_SERVERSIDE_CODE] = false; $ai_wp_data [AI_CODE_FOR_IFRAME] = false; $ai_wp_data [AI_HEAD_CODES] = array (); $ai_wp_data [AI_HEAD_GROUPS] = array (); $ai_wp_data [AI_ACTIVE_GROUP_NAMES] = array (); $ai_wp_data [AI_CHECK_BLOCK] = false; $ai_wp_data [AI_POST_POSITION] = AI_POST_POSITION_BEFORE_POST; $ai_wp_data [AI_FOOTER_JS_CODE_DOM_READY] = ''; $ai_wp_data [AI_FOOTER_INLINE_SCRIPTS] = false; $ai_wp_data [AI_W3TC_DEBUGGING] = false; $ai_wp_data [AI_CLIENT_SIDE_FILTER_CHECKS] = false; $ai_wp_data [AI_PARALLAX] = false; $ai_wp_data [AI_PHP_PROCESSING] = ai_php_enabled (); $ai_wp_data [AI_UNFILTERED_HTML] = !(defined ('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML); ai_load_settings (); $ai_wp_data [AI_NO_JQUERY_CODE] = defined ('AI_NO_JQUERY') || !get_wait_for_jquery () || (isset ($_GET [AI_URL_DEBUG_NO_JQUERY]) && !empty ($_GET [AI_URL_DEBUG_NO_JQUERY])); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("AFTER LOAD SETTINGS: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms"); $ai_wp_data [AI_BACKEND_JS_DEBUGGING] = get_backend_javascript_debugging (); $ai_wp_data [AI_FRONTEND_JS_DEBUGGING] = get_frontend_javascript_debugging (); if (isset ($_GET [AI_URL_DEBUG_PHP]) && $_GET [AI_URL_DEBUG_PHP] == '1') { if (get_remote_debugging ()) { ini_set ('display_errors', 1); error_reporting (E_ALL); } } if (isset ($_GET [AI_URL_DEBUG_JAVASCRIPT]) && $_GET [AI_URL_DEBUG_JAVASCRIPT] == '1' || isset ($_GET [AI_URL_DEBUG_TRACKING]) && $_GET [AI_URL_DEBUG_TRACKING] == '1') { if (get_remote_debugging ()) { $ai_wp_data [AI_FRONTEND_JS_DEBUGGING] = true; } } if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { $ai_wp_data [AI_ADB_DETECTION] = $block_object [AI_ADB_MESSAGE_OPTION_NAME]->get_enable_manual (); $logged_in_key = defined ('LOGGED_IN_KEY') ? LOGGED_IN_KEY : 'key'; if ($ai_wp_data [AI_ADB_DETECTION]) { $key = '#AI'; if (defined ('AUTH_KEY')) { $key .= AUTH_KEY; } if (defined ('NONCE_KEY')) { $key .= NONCE_KEY; } $adb_2_name = AI_ADB_2_DEFAULT_NAME; define ('AI_ADB_COOKIE_VALUE', substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 ($logged_in_key.md5 ($key)))), 0, 8)); $script_path = AD_INSERTER_PLUGIN_DIR.'js'; $script = $script_path.'/sponsors.js'; if (is_writable ($script_path) && is_writable ($script)) { $adb_2_name = substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 ($logged_in_key).md5 ($key))), 0, 8); $js_ok = false; if (file_exists ($script)) { if (strpos (file_get_contents ($script), $adb_2_name) !== false) $js_ok = true; } if (!$js_ok) { file_put_contents ($script, 'window.' . $adb_2_name . '=true;'); define ('AI_ADB_2_FILE_RECREATED', true); } } define ('AI_ADB_2_NAME', $adb_2_name); } } if (function_exists ('ai_load_globals')) ai_load_globals ($start_time); if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("AFTER LOAD GLOBALS: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms"); if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC) { if (!in_array ('w3-total-cache/w3-total-cache.php', get_option ('active_plugins'))) { define ('AI_NO_W3TC', true); if (!defined ('W3TC_DYNAMIC_SECURITY')) define ('W3TC_DYNAMIC_SECURITY', 'W3 Total Cache plugin not active'); } if (!defined ('W3TC_DYNAMIC_SECURITY')) { $string = AD_INSERTER_PLUGIN_DIR; if (defined ('AUTH_KEY')) $string .= AUTH_KEY; if (defined ('LOGGED_IN_KEY')) $string .= LOGGED_IN_KEY; define ('W3TC_DYNAMIC_SECURITY', md5 ($string)); } } if ($ai_wp_data [AI_SERVER_SIDE_DETECTION] && !is_admin ()) { require_once AD_INSERTER_PLUGIN_DIR.'includes/mobiledetect/Mobile_Detect.php'; $detect = new ai_Mobile_Detect; define ('AI_MOBILE', $detect->isMobile ()); define ('AI_TABLET', $detect->isTablet ()); define ('AI_PHONE', AI_MOBILE && !AI_TABLET); define ('AI_DESKTOP', !AI_MOBILE); } else { define ('AI_MOBILE', true); define ('AI_TABLET', true); define ('AI_PHONE', true); define ('AI_DESKTOP', true); } if (isset ($_POST [AI_FORM_SAVE])) define ('AI_SYNTAX_HIGHLIGHTING', isset ($_POST ["syntax-highlighter-theme"]) && $_POST ["syntax-highlighter-theme"] != AI_OPTION_DISABLED); else define ('AI_SYNTAX_HIGHLIGHTING', get_syntax_highlighter_theme () != AI_OPTION_DISABLED); if (isset ($_POST [AI_FORM_SAVE])) { $ai_wp_data [AI_DISABLE_TRANSLATION] = isset ($_POST ['disable_translation']) ? $_POST ['disable_translation'] : DEFAULT_DISABLE_TRANSLATION; } else $ai_wp_data [AI_DISABLE_TRANSLATION] = get_disable_translation () || (isset ($_GET [AI_URL_DEBUG_TRANSLATION]) && get_remote_debugging ()); if (!$ai_wp_data [AI_DISABLE_TRANSLATION]) { add_action ('plugins_loaded', 'ai_load_plugin_textdomain_hook'); add_filter ('load_textdomain_mofile', 'ai_load_textdomain_mofile', 10, 2); } add_action ('plugins_loaded', 'ai_plugins_loaded'); add_action ('init', 'ai_init_hook'); add_action ('wp_loaded', 'ai_wp_loaded_hook'); add_action ('admin_menu', 'ai_admin_menu_hook'); add_action ('admin_notices', 'ai_admin_notice_hook'); add_action ('wp', 'ai_wp_hook'); add_action ('wp_enqueue_scripts', 'ai_wp_enqueue_scripts_hook' ); //add_action ('upgrader_process_complete', 'ai_upgrader_process_complete_hook', 10, 2); if (function_exists ('ai_system_output_check')) $ai_system_output = ai_system_output_check (); else $ai_system_output = false; //if (defined ('AI_BUFFERING')) { // add_action ('get_header', 'ai_buffering_start_hook', 99999); //} if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 || $ai_system_output) { add_action ('shutdown', 'ai_shutdown_hook', 0); } register_activation_hook (AD_INSERTER_PLUGIN_DIR.'ad-inserter.php', 'ai_activation_hook'); register_deactivation_hook (AD_INSERTER_PLUGIN_DIR.'ad-inserter.php', 'ai_deactivation_hook' ); add_action ('widgets_init', 'ai_widgets_init_hook'); add_action ('add_meta_boxes', 'ai_add_meta_box_hook'); add_action ('save_post', 'ai_save_meta_box_data_hook'); if (function_exists ('ai_hooks')) ai_hooks (); add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links'); add_action ('after_plugin_row_' . AD_INSERTER_SLUG . '/ad-inserter.php', 'ai_after_plugin_row_1', 10, 3); add_filter ('plugin_row_meta', 'ai_set_plugin_meta', 99999, 2); //add_filter ('the_generator', 'ai_the_generator'); // If using Autoptimize plugin //add_filter ('autoptimize_filter_js_replacetag','ai_ao_override_js_replacetag', 10, 1); if (is_admin () === true) { add_action ('wp_ajax_ai_ajax_backend', 'ai_ajax_backend'); add_action ('wp_ajax_ai_ajax', 'ai_ajax'); add_action ('wp_ajax_nopriv_ai_ajax', 'ai_ajax'); } if (!get_option (AI_INSTALL_NAME)) { update_option (AI_INSTALL_NAME, time ()); } if (defined ('AI_PLUGIN_TRACKING') && AI_PLUGIN_TRACKING) { add_action ('plugins_loaded', 'ai_install_dst'); function ai_install_dst () { global $ai_wp_data, $ai_total_plugin_time; if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { ai_log ("PLUGINS LOADED INSTALL DST START"); $ai_processing_time_active = $ai_wp_data [AI_PROCESSING_TIME]; $ai_wp_data [AI_PROCESSING_TIME] = true; $start_time = microtime (true); } if (!class_exists ('DST_Client')) { require_once dirname (__FILE__) . '/includes/dst/dst.php'; } if (!function_exists ('ai_start_dst') && defined ('DST_Client::DST_FILTER_OPTIONS')) { function ai_start_dst () { global $ai_dst; $dst_settings = array ( 'main_file' => __FILE__, 'tracking_url' => 'https://analytics.adinserter.pro/', 'track_local' => true, 'tracking' => DST_Client::DST_TRACKING_OPTIN, 'use_email' => DST_Client::DST_USE_EMAIL_OFF, 'multisite_tracking' => DST_Client::DST_MULTISITE_SITES_TRACKING_WAIT_FOR_MAIN, 'deactivation_form' => true, 'admin_ip_tracking' => true, 'notice_icon' => AD_INSERTER_PLUGIN_IMAGES_URL.'icon-50x50.jpg', ); if (function_exists ('ai_dst_settings')) ai_dst_settings ($dst_settings); $ai_dst = new DST_Client ($dst_settings); } function ai_notice_text ($text) { $text = // translators: Opt-in message: Thank you for installing Ad Inserter (plugin name with HTML tags will be added) __("Thank you for installing", 'ad-inserter') . ' [STRONG][NAME][/STRONG]. ' . // translators: Opt-in message: %s: HTML tags sprintf (__("We would like to %s track its usage %s on your site. This is completely optional and can be disabled at any time.", 'ad-inserter'), '', '') . '[P]' . __("We don't record any sensitive data, only information regarding the WordPress environment and plugin usage, which will help us to make improvements to the plugin.", 'ad-inserter'); return $text; } function ai_dst_options ($options) { global $ai_db_options, $ai_db_options_extract; if (isset ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]) && is_string ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]) && strlen ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]) != 0) { $used_blocks = count (unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS])); } else $used_blocks = ''; $install_timestamp = get_option (AI_INSTALL_NAME); if ($install_timestamp) { $install_date = $install_timestamp; } else $install_date = ''; if (isset ($ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP'])) { $settings_date = $ai_db_options [AI_OPTION_GLOBAL]['TIMESTAMP']; } else $settings_date = ''; $count_posts = wp_count_posts (); $options ['posts'] = is_numeric ($count_posts->publish) ? $count_posts->publish : 0; $options ['blocks'] = $used_blocks; $options ['installation'] = $install_date; $options ['settings'] = $settings_date; $options ['notice_review'] = ($review = get_option ('ai-notice-review')) ? $review : ''; $options ['remote_debugging'] = get_remote_debugging (); $options ['block_class'] = get_block_class_name (); if (function_exists ('ai_dst_options_2')) ai_dst_options_2 ($options); return ($options); } function ai_dst_form_text ($form) { $form ['body'] = '

    ' . // translators: Deactivation message: %s: HTML tags sprintf (__("Looking for %s Documentation, %s %s Common Settings, %s %s Quick Start %s or help for %s AdSense ads? %s The plugin doesn't work with your theme? %s Let us know %s and we'll try to help you.", 'ad-inserter'), '', '', '', '', '', '', '', '', '', '') . '

    ' . $form ['body']; return ($form); } add_filter (DST_Client::DST_FILTER_OPTIN_NOTICE_TEXT . AD_INSERTER_SLUG, 'ai_notice_text'); add_filter (DST_Client::DST_FILTER_OPTIONS . AD_INSERTER_SLUG, 'ai_dst_options'); add_filter (DST_Client::DST_FILTER_FORM_TEXT . AD_INSERTER_SLUG, 'ai_dst_form_text'); ai_start_dst (); } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { if (!$ai_processing_time_active) { $ai_total_plugin_time += microtime (true) - $start_time; $ai_wp_data [AI_PROCESSING_TIME] = false; } ai_log ("PLUGINS LOADED INSTALL DST END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } } } if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) { $ai_total_plugin_time += microtime (true) - $start_time; ai_log ("INITIALIZATION END: ". number_format (1000 * (microtime (true) - $start_time), 2)." ms\n"); } // =========================================================================================== if (!class_exists ('ai_widget')) { class ai_widget extends WP_Widget { function __construct () { parent::__construct ( false, // Base ID AD_INSERTER_NAME, // Name array ( // Args 'classname' => 'ai_widget', // translators: %s: Ad Inserter 'description' => sprintf (__('%s block.', 'ad-inserter'), AD_INSERTER_NAME) ) ); } function form ($instance) { global $block_object; // Output admin widget options form $widget_title = !empty ($instance ['widget-title']) ? $instance ['widget-title'] : ''; $block = isset ($instance ['block']) ? $instance ['block'] : 1; if ($block > 96) $block = 1; $sticky = isset ($instance ['sticky']) ? $instance ['sticky'] : 0; // translators: widget title if ($block == 0) $title = __('Processing log', 'ad-inserter'); // translators: widget title elseif ($block == - 1) $title = __('Dummy widget', 'ad-inserter'); // translators: widget title elseif ($block == - 2) $title = __('Debugging tools', 'ad-inserter'); elseif ($block >= 1) { $obj = $block_object [$block]; $title = '[' . $block . '] ' . $obj->get_ad_name(); if (!empty ($widget_title)) $title .= ' - ' . $widget_title; // translators: block status (widget title) if ($obj->get_disable_insertion ()) $title .= ' - ' . _x('PAUSED', 'block', 'ad-inserter') . ' '; if (!$obj->get_enable_widget ()) $title .= ' - ' . __('WIDGET DISABLED', 'ad-inserter'); } else $title = __('Unknown block', 'ad-inserter'); $url_parameters = '&start=' . (intval (($block - 1) / 16) * 16 + 1); $settings_page = get_menu_position () == AI_SETTINGS_SUBMENU ? 'options-general.php?page=ad-inserter.php' : 'admin.php?page=ad-inserter.php'; ?>

    ' value="0" /> ' name='get_field_name ('sticky'); ?>' value='1' >

    WARNING: Please note that saving settings in Ad Inserter will clear all settings that are available only in the Pro version (additional block and plugin settings)!", 'ad-inserter'); ?>

    ЮVh=2qAB ! (D⛖飵M 't?5c)J{sU;}ڢ]-7iww\G3qP3J<ճ€S|_eyP_%&ec׵m] m ZaVjce RNM|bv.0 ‡0{ndq3R]-eI/ZW|S-Ͷ={aQu4~jpO |6I 0*"aA1 )T x;VGFv}[kg>" wzAſ]T';Bd[BsԫF>zqPZ񽤓4f![ k}i^n~/[͸jd2R0㠄$Q&\1JYu픒HqQ]WڽDi=CiS/d#q Vty2C,j JR7$RT&Ǜ9ZQ1c$o'z9R^BOx/"qeMysٔaiC(BЂ;WBHR(0Su6k^r#拄xz*:KZ.CEm9HHP9wEӌ=7H]kv(u>)P :>8{i}BTƚ-e jժˏJQuRJA#XZ8=alRP2lzY'zjy&Mݪ 4GCH!G *Xh 䓺=%e+oPئ7ow|JgK̓oצB.B0d2JjK<%;lqVWz1?䫿ŢġB BUw/<=iyHٵ}tm)OܡC?"OŔωP$[o* x{l?OdJ55rOrBxՁ{ VRb `6ב6HD,^պjkhT!#uF~zr=8kMҧY^{^#g= %9O{LÅ7'rK.45[Bވr'd]A33-5Cf+ .OKi v:XZt 먕qZ>'hdxG#TiG#)Ԍ |VҶ!lm-ǖzj4Vb||f7q,UʲtI>9YiWA~wܟXH}W=9=YB[2tNb!xPw-[Ar+PXDwJ֟*)N FFt#$q-^u(aO0Ǯ MsJih҈CM%[@U}/Bw;@IZFT-Ny:*E9rw[T'S}0#T"!ی2 KG*Z A]jgU\jz}˜5[-0{'P0UvI$3,n޵=Ժ&&$[>"-t)[>z"zcGy<(a ie8~zm|CLy4Gq\Ayq<Ȟ*ʤ[\^* ;6O$y^Y4:cnISsbx(\iY>y E winr!%JV8u;UÆnpi͋e/!>(.4EJ9oKkS=;T,d'qᱦ)r=VصR,[d`RggQ.>uLv$ɈYKov2}=zFrcqeFcv%1樒ߗ}^P e ( B B % *ZR:p+gofܹ r\9FZХBK!4FC?H(ydo3dbB^! )Ϸ_Vʵ_}J!5ǖFC?H(ydo3b™ Ij1:+rcw/z mMUT.q8pU>RhOWFC?H( qI &(ýWR@Kuo zLkFAȯ>n: LO)0=F2k ]丞ѦT<#)޶&=?LVZ*ZTy56r8͙omX(PF (Q(PD$+ߋ?So_O8vATpAuz`q,%`$mw 2m=C<##^ib?}zs/=&/~_qP>̾ iGݦE!\}T #ǐ7 ˎ;0Nĕcn1]ZVtdl>@u5jM5 mEuein ;ҚjOJU#6{Ko_e"K#2⃂Gfm̺]mx'#bETA]:Ԫ߻`mIԊJ**)$SvP3Р#54=ݾT>VʇУ=} ''1G7󴆲fSm+M\;4+U>(h{O4;Ӱf3he."n!X褩`B -v?w+ cw9UTQi7^J{_j&`Xz-2Ւs1U^{ï+7סã~ҿ#}zmD8A'VP36XOf=xu>F߇Xϻ+^eƾ2p;3Jia щP dl<({jA)aR#CJpN39&IVA8~7⫗=wfu<׭ ̀p2RdHaycR2oR6y0K*ۺ 4-0羔p[6@miByy VA󕜓ڧF4 Omھv@yyN. R)_˔"Uia_?ԡItEws!Ь%6;` [4UVʺYȚR{dVw-ʶ3ffz\\!HgMVٍL>gH&` ۘOp{ >(!Z[8s%G|E=b?лiCȇG}4p-jʤ~]:ԯ[HQ/9L?%+.C[nVm CrSᶃDKct$ mp5N5K-u8eZ.A_)\ʵ LuILQm* ~jL3ookrL;JA]+\PFI5t׹>Lnv{bКu6@BZEIí{ꆧT[ `>B7qŷ]^#[Xiq!2> )~/'^RH 5n}uxP&FT`bl8=_N) @wJA;SE Rx EJʂK#`H8`w=?,c*H?ѩqEHrN7=̒5DXry;lkK#72}izh ~ҳ:2oW|Okӧ/e3Gة>pVyU1MBlz駭vYg!mD03}4Z?]bM]~ Z51rTJ-;ߥBu r: JSt@ŏSo Ggz5 r̺(c1݇Q$Q3?RA'S]^J!<뇪(ԓV"nenjw۩+eaJxTGGG*&`3G=)ѽ[pV XVw¥W1;y,,IqZ ZFFG[IQx)eY w|+.E-,8w {o`ⶨ6BڒUطGTs()T;eIiI <I7?UD}cU3 t k]It$zQRF][^P/e }zXp۔&ĻS$GLxGLD q^$Re!)Fw1\Ǎzv *5t)Ѭwit?'חTmNSDuR*R8/~56:z딇KHq AR_5 JGN*.Z#8$Hj.u! hnE??0OH\>Y  S ;d2yyAL=w-6%M=T0;sRQEw Ü3p\4,!ԤvE5h備H *API;M.gGrs,v *m[䁹)zJ5jǮ QL_'ShQNJZ |:hOQϥczl7[r8RWfIE'wZ a SB {D3}4ޫ.;JJ-e9K#vT3&s!>‚r`/fM <$r>;%Ɛ5P\tR PrseԪR\TVe( `ޜ- L2aiJm+$E}-dm֚m 9<8K=raۯAKNbr; _9p<3]JKrP6ps$Zܒ"RUBWiQn"kBl B`kII7`FJtuvmftI#bB\S@z =RB#\[sț9V"5%)R#Sqx{m*=A Hr7P}sռ%GWlzU2XY >ـ7IQQt ]^.)63nfrsE 9@D $TN7"Gufy,;:nqӑ&2ND$9zҦ!&Gc]}N{& q\;o KnsR}--2݂Ũus~5i%˲h%C?p2j 1~S;ݴkOD żTKs )<#{) 1WWx:Gk&3P&\>̄}ǖГФcIН.3^-#YN(z( f@Z[V=[tPI$1*7zI#B3΢1*!p\ qx BRIVz`u>X N@w8!!YK!˝j>jSᑂ}u)W 2ޅ=0iH+uGG0#9 mZWPXӮ԰Գ6${}TN'9w'hF.lN+OvŨrŚZ@Kr]SXPGY#^Z:gjI!GVfJNHJ7t{IZ̰tV*W߫J"vGMvmjDHFbb\ Iyo]2=sLK!L\X)AlrMWNsv ~RoҴ9b _vYm&uJvЎ~b#/&k8ʘ%)%YQXIiM{2,oYGc."9ԤV{:xӻb&PKDf־U''mUv˫)i H#A6HP#9fJ"%` 7>4*Jj0,u$ќ2A:m>Pv6H (iNd ]A쌤<2T + nl8X砺>i(>kP#ԩ&j$t|ָ{7]L-\=t"ʋW!Lxf;E3ʥ+#R$&mn*LD[SME%$gm.#z 4r8T4e>(emS.H=ZР>0a{܋6(X 1Rh8Èگ7LhmRAOq8GN#L>D8&d *q棈Є%*Ivj4G<{N~؇vioJ>dIxT~LOzSVLBUU P,i|:1tTE%<q;ГetRre> | V3:fKd}~QLqoi `zVEmak  'n4RٍQ4XRWfdfl'8http://ns.adobe.com/xap/1.0/ 00599DEC88AFD379FB54D654052E077F 0533C6BB00C1DD6BE56630A08913300F 07B4A1C9A59F8A04ECD73B3CC65A3E5A 07C8D728849BB47DEDF47438AE70AC1A 07F797FD521C8DD086F0F358BCEE08EF 09338BC404BDADE129FA37EDED29BCFC 0A330ACF220D4EA0E1B1D1F3D2B75F41 0B232A9B543705AA6EBF28E2479EABF7 0C9D68DDECC11E309687458D26AE60F5 0E6A1F25F98CE4A295DAC86053184324 109C18F45EDD7A4A86F9BFFB29824D5E 10DD06585D77085BD5E50308FDA1E660 10FCDF3C0415B3BBB02CF44B90F8D6E3 15F5C1BC21D293A7E1606C8DEFA424A5 1C9B415BFE697A56AB15E9C5C54E66EF 1CD4715CE9F41C5226F72B06F2ED7A89 1E0D3A3664AF6C5118872A59BDBC8146 1E6DE62646E2E91A454FEE6E97019D45 1F906B9F3C6E9A171CFE065E311FF885 20F6CFA26CD259B52265DE5B3F2E0294 2A44994DBD012765BEAEEA8ABD86DCC9 2FA5E8F5326F31708F60CB8D600AC074 313C2BF86E68069C185A84BB4E6BA7CF 358793FB4E86B0250B5FA08309D41DAD 36A014AA999BED8A09BB533F4EC43A85 3799F4C7163D76C3DA6324A8FAA04600 41263266829E1239566974AB88D9F4EF 42B0B69FB747D73067ACFC5132936734 48DEBBDD8B33C2DD9A7A25ADBFC50680 496B88CE2DC1C02762A77BB29C5AE453 4C7F435012CEEFB47CF19EC51CE7BED6 51233FFC6B2DAD4925E7FDBD07FED17B 51E03AC9BB65DC1F81A921D46482BB9D 577825DFA9197C8AEEF425722E495160 5EA1625A59B681F8E073D3F857E692DC 633FA9BB7B1F38DD873ED7C726A1AE28 649A4B13862B00A4789791074EE35296 6622C1A46D811FCED9F2620FF55C5F9D 6F1C221EA45BB4B346560CD15B7E1C80 709B5863F703E74111CFE54C52CD999A 7271CE9E8BEF69D0E5CDD7C2DB2C7254 728266F8AEC2A5EE8F918D6C03B2E432 745908E89650661C6138EAAFD0352848 78BF03119D5981F65C7F86E5E4305874 7D00860DFA9D54E5EF76EA1393D19C9E 7DC7AC4900452A9D7F4F0EA671BB3C35 7F16352B7E51B6DD5CD845EFF625B774 821FB0C3C924EC1C20E6FB6B47CCF606 8B04A49A7246492C48E85C89421D1FCD 8B53BE27011F52B057145F409E5B2C08 8BC366704BE94D81770B780F6AC29C51 925443CDF0CB03A899D27BE493F7182F 9348A901E872E5AC7DC185E802C35ECC 94ABA1AD1AE5E9A3F941A9A92B2CAEED 9D821C050C851698D9809EFF53D41E5C A03F12CD155FAF177B16AE4A0D4F15BF A087F9BBFD4C5EBE646E5634A3C6A3DA A22C3C8E891C10162A4680CA76AAB20A A2715B60BBE9F657AE46AA13ED08CCFA A8173C13C8E4D90243766A5844D7638D A8AFACA68A8EB1B40C371E6DA55F6772 A8B8C7B75218C53F5B4646049328E604 A98D464C47BB8934BFCDC28A8A7B21EB AA13888C4B5642B2D390056898CD2A00 AD22F88623C86E8B60AA7D5C984F4495 B32311BC4735EEF2E24CDFFA26F69180 BB33B0F2103351BAD5C6FAE22D1FBE1A BE5BB085026CF96C471E5E45F8B7E0E1 BF20B595D2A13030D8B481BED6DB2DA3 BFC3BFF7799991D4D8BA1A379EF711A3 C044FDC16D26D2DB4B102D605650CB04 C48913A34CF0640C82E1A82A5E3606C5 C4D4746514D893F63ED7EA36056DE22D C5448739577CCEA0112756CFEC751C71 D1A187FC7CFFD8FE5F4213E9DA264FC7 D7AD019A48F23DBE01573C7A2535774F D9F2109FC65DB475968C2F3EEB43C173 DA45DE7D66FC34330EE2B3E3CB627AF9 EE0408E4BAE6E24F576267507289BD2F F4CD26396B32CE850AF735B5F4DF0BA0 F7121E962388DB88F30161D58D3060B4 F90FA269629778AFA723AE0E7375845D FD633D490470BF4D2621D477680439EC adobe:docid:photoshop:268e54d8-ad96-11e6-9875-c3ae9fe9b346 adobe:docid:photoshop:2a59b17c-dcc7-11e6-837e-9c42691083e8 adobe:docid:photoshop:2d0698d5-abdc-11e6-b149-85202e9dcfc7 adobe:docid:photoshop:4158b484-dcc7-11e6-837e-9c42691083e8 adobe:docid:photoshop:5558be49-dbce-1177-ab74-a19abbfe5183 adobe:docid:photoshop:5c2ada9e-c82a-4c42-a001-2938ef771d3c adobe:docid:photoshop:5dc8381b-9a4d-1842-beda-d4cdd957b27f adobe:docid:photoshop:6f08e69c-6f30-6345-a3b9-8ffcc31546ef adobe:docid:photoshop:73c10a4b-248b-f940-9f1f-dfe6ba72c230 adobe:docid:photoshop:86d125b8-f60e-8d45-843f-497b7a35c557 adobe:docid:photoshop:9175e5d5-82f4-9744-b09f-89bed622cc69 adobe:docid:photoshop:a1289762-4b71-fd4d-8a14-735ec142fc9f adobe:docid:photoshop:ac5278a4-e963-d744-bfaf-a0706f313565 adobe:docid:photoshop:c6f6e563-0a9d-f646-afc7-e48dc5531f11 adobe:docid:photoshop:d1283862-1d24-bb4c-bf20-bf6c6c671880 adobe:docid:photoshop:d7a30376-750f-a141-ae2c-7810495ce369 adobe:docid:photoshop:ec58a44f-900c-e34c-bb1f-fc2b0bdc11e9 uuid:18317BB61454DD11B072AAB0678C6EC0 uuid:33F867AF77B0DD118BB88B63F587CB88 uuid:AEB72E0F065BE21190E6A53B8DEAD2D4 uuid:BAF36C8477B0DD118BB88B63F587CB88 xmp.did:018011740720681183D1B7155E0063D6 xmp.did:0280117407206811822A8DD347035589 xmp.did:0280117407206811822AE41C914C1686 xmp.did:04157CAC262D11E58547B515CFE93C26 xmp.did:058011740720681183D18FFDC0EE7A2A xmp.did:07D64A4A80BEE511850C97A9C358DB5D xmp.did:0880117407206811822A9D48829E614E xmp.did:09F9F4BF4EABE211B304C27C3A7348DE xmp.did:1ABC1A91C930E3119FEDA52BE0ECF468 xmp.did:210df20c-2bdc-a245-8468-bb2373d445e4 xmp.did:271790e7-c17b-2045-8d0f-fcc48173fd2f xmp.did:291f6c60-43a0-aa47-aac8-9ee6d6689e03 xmp.did:2F4B4B4CE929E011A014897789896DBE xmp.did:33EBFD7C072068118083DCA71E68BBCE xmp.did:38ccb7d3-baa2-4d45-9022-17c1c8456f96 xmp.did:3B665E6D422EE21198B2FAEE9FB93FAD xmp.did:4B41B34A08206811822ACF19180E81B2 xmp.did:4c0383bf-ceee-2548-9da5-931b192dcbbd xmp.did:50dabc4a-2411-7f4f-9959-2a44c05ce311 xmp.did:59c0351a-61f6-8f49-a6e8-90e15e8b3e9b xmp.did:5B5B472C08206811822ACB6E691C24FF xmp.did:5C81318856FD11E680B1BE05A91D299F xmp.did:5FA7C617ADCE11E49E7AF0F29752DE80 xmp.did:5FA7C61FADCE11E49E7AF0F29752DE80 xmp.did:5FD1E3FAADCE11E49E7AF0F29752DE80 xmp.did:60AC9636392911E396C9D7FB51F41FBF xmp.did:6588AB2708206811822AAE066D9BD385 xmp.did:67310723ADCF11E49BE6F9F1B1E4BE86 xmp.did:6B18ED2B09206811822AA56E3BF141E6 xmp.did:6fecbf38-97ef-49dc-9236-d7f74d6fd234 xmp.did:71CD42FF07206811822AECF9DD639D3E xmp.did:730c5884-6066-fe42-8417-0289b26a87af xmp.did:7623F5E469EF11E693D49CDFE8DC4142 xmp.did:7D04D006CF5EE211AAC2972AE1B78D81 xmp.did:7a34502e-468a-c741-b916-0a5833b37a15 xmp.did:847678728B30E011A851E97219B738EB xmp.did:879429ca-b04b-144a-88b5-dc4b560dc849 xmp.did:8CF1E12208206811822A846271F1967B xmp.did:8E73F883665DE511A04D991EFD9AD566 xmp.did:90EF34C5C84111E3B553CF8512AFA90D xmp.did:93F0067308206811822A8ACFDFF16C2A xmp.did:956ACC61C84111E3B553CF8512AFA90D xmp.did:95ED3A62C84111E3B553CF8512AFA90D xmp.did:983bac09-bf39-8045-bf6e-6254de390d83 xmp.did:98a7ecab-ff62-f04d-97f1-d09506489261 xmp.did:A35C883921A8E211B1F1F4EE24B0D37A xmp.did:C073799A07206811808382444E3CD50D xmp.did:C0F85CE7AB39E21195FEBBF63031080C xmp.did:C473799A07206811808382444E3CD50D xmp.did:C92518F2EAF011E2A1B0C590D1E4749B xmp.did:D9D4CE3908206811822AA56E3BF141E6 xmp.did:E3D8EF35646F11E2B4C5B0E48626874B xmp.did:EBD9C7450A206811822ABB58BDE15284 xmp.did:F2DF51DC072068118083B3CB38A72423 xmp.did:ac392b14-21a5-3244-9067-cf8102e47a14 xmp.did:aceb1982-7525-a94b-916e-d19cb60bbbb0 xmp.did:b0e9bea9-1df3-f94b-bda9-dbe6e16b97dc xmp.did:c0018f82-4194-cf42-aec7-e9281d5f8c7d xmp.did:c7210d8a-526e-f841-9325-7305615e29cc xmp.did:d337ca5a-de17-ce40-9f65-47f9a3332a50 xmp.did:d829aad8-4e14-3d47-af9a-65103f51b1b5 xmp.did:f154d5ed-58a6-4231-a61e-0d7f3718c019 xmp.did:f4e274f8-93cc-874b-8407-5432174b5893 xmp.did:f8230346-b777-4575-a8c1-44248ca36c28 xmp.did:fc7a3868-622f-d841-aa8f-b946306700e0 xmp.did:fe943ebe-7e53-4c41-912f-141b4c594374 (2Photoshop 3.08BIMZ%G8BIM%}Ǿ pvN8BIM: printOutputPstSboolInteenumInteImg printSixteenBitbool printerNameTEXTprintProofSetupObjc Proof Setup proofSetupBltnenum builtinProof proofCMYK8BIM;-printOutputOptionsCptnboolClbrboolRgsMboolCrnCboolCntCboolLblsboolNgtvboolEmlDboolIntrboolBckgObjcRGBCRd doub@oGrn doub@oBl doub@oBrdTUntF#RltBld UntF#RltRsltUntF#Pxl@R vectorDataboolPgPsenumPgPsPgPCLeftUntF#RltTop UntF#RltScl UntF#Prc@YcropWhenPrintingboolcropRectBottomlong cropRectLeftlong cropRectRightlong cropRectToplong8BIMHH8BIM&?8BIM Z8BIM8BIM 8BIM' 8BIMH/fflff/ff2Z5-8BIMp8BIM 8BIM8BIM08BIM- 8BIM@@`9@p8BIM8BIM_Ad type 3 (B) 250x250nullboundsObjcRct1Top longLeftlongBtomlongRghtlongslicesVlLsObjcslicesliceIDlonggroupIDlongoriginenum ESliceOrigin autoGeneratedTypeenum ESliceTypeImg boundsObjcRct1Top longLeftlongBtomlongRghtlongurlTEXTnullTEXTMsgeTEXTaltTagTEXTcellTextIsHTMLboolcellTextTEXT horzAlignenumESliceHorzAligndefault vertAlignenumESliceVertAligndefault bgColorTypeenumESliceBGColorTypeNone topOutsetlong leftOutsetlong bottomOutsetlong rightOutsetlong8BIM( ?8BIM8BIMY8BIM , Adobe_CMAdobed            " ?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?I%)$,l֍@8hUi4ܛ}1 c$`?uEZNXѥm;mҊ֟Lu!lY=N/F!]ֿL!l@ QsSөw[.Ϣ۬ƭò~KG}Sn!VnU˫˭ӧrrlV4z~7}?-EHU_Odt'u݈f\s0RbfU=7O%~Y{ᆰ_WGDzzͮvPi[ղk^:In!ud്v_?[6]v7Qã?m;.׷轩)S:v%N2us.mfsY];"P31ef[_.ztk_۬dߪXyw̜kse )^w˰ѳm7ӭ2.ǿoq_Wm?:=#O%2OB wPWP|I;)*5t~Ε/da"]e6㾦dcu?2j}~~X}O uɆĒI%?I%f59-zfk~G*qw]NV.6f5Ul}s1):NfSkyU4p^+×PA r?%O2C oO#,pܫv;~vN^?Zjrz_=*k?6Fգk1^fGռwqĭnD}YE87bH#o鏨c#|\y%/ތaRgz]Ot<@>̌ZLFص/n?u^n3Q%{[s>(ueѳNOa;mFO,#B!2Rϒ_hcM='xuV<Um֏Wr}?izU[=Sm6>2_v^c*}ΦΗ0Vq+:ȹ_ܚvSgw[=u,f֝evW&qh}ks2oׯ_JCK87g驕RMm ֵX11 \vGA=6^lòUCEؖXK?XZ:ٛk|; 幾%xou2lߩ׳k_camP`ˠ:OC/wfUceHJWO F)Y_N5s##:ҳO\?8;[C)pic13kٻٽ%ud`Sp/ϫ̿?/,_Co}A /vN%_}t9&곞(SIdB15gmev?fܒaZ𸞉$II%)$IJ\os6}!n.7rJ{=Kc,>Wk۔v8~/؆2J}#k)mW_L6eNhnvFkS??:0 |  24ŵ mzOdPU&}Zϣ˃c#OW;3'_Sj4yV1ӓ]bdVeonjW3{S^S{J&N;&&g1Wck:O׌ o}L5W2ap;,!-f&v"@:=QUG.e2Zր=k~k>3} Ŵ2_cA@{?yNZ9}v1Smoc&Dg|ʨu@-ꦶ;s;+S.,~uAy< kkw殇'[Xr(Z6;6QC3=qapMzo[OֶoHkXl.:}~C^- }X2F"r!8H{^d_kPCsX͕]kbJ$ Շ[Cxkeo]F/z?kͺקdP7:?vU,sXSYxz4Id)lb@x}辶rq?Qn^e\ёgA.if^_A-Yٹg?*MX\,k{15\r> &-~3ĭ ?7+dSXc]U=HJHC%4ח&D]7ծ:XU./*;?9qeΌX5#N7-.:u |g}'qk?ԽjDhj4_y/r?`8uj ۪PFtq?=0}=~%/x%]S.' kJ$Yèw=|~{?Y @c:u n[XpmcC\Njq7"Yw~ZYUKjy{\IsճߺfM@f㞬Ki5$K} 't׫1njpԮ|R / $= S?8>>%۪3ح7⚍VC1=:]iкGghgEZ,e?,aremzGUzva׵ƗCZαm{܋_LMu:Xem i?Gn?J_`uql]eXm{kW _e5Z뭰@G~;tUOеX@=_՗zmX+fwpѐݭvx;O9k300 o?s+{vgVM OʚX1omi Lgrb8/|sV`?%:Hc sf5V0z\LƳ ף!v1)fV鋭ۙgos}a2SoR}dV&[߹u~Y&OP1e:EvUmKuVz=OJ+VXT>U`e,s#ǿvѹT՝+ƚ 쯱h'تK'-M}+ݍEAU73ʽ'T(mfO߻췢d`.wIь[s,nELv=/.Նȧ!oi =:'^taL۾C\-,wjk%`oNuyb^(}ޝ鹞߽̱?HF.:P;n&p-E̺ۻ:,}t7IYZ:7Qzy]?:]ۯyŵˢU,gsߏF+7]_?AW!p`-n#gor,g+6]w5_dO?l{/Wc]MNmy.nϳ2}G4>c}' 痷ْY[ kq/hiU1VO^?WNy&Lcf7vUs}OK_m}YP%Ǿ1ʳ+6>Ac\j{ίmͯث:DΞP~u~:wSEi !]uʺ e6ǿGzX.Ith': ൽj@+K0Om$AH8JN  =XDv uT]8:S+$Y^=kX(f`n[auuz^:{ڐGMKd1c<&D^ tl)7u^93װ.s/vEN럃77&5gen8Lǫ*eT\/coSթ\VGwYdo[jxo}S?/)꤂0[)"W[C{ߕZZz?'Uov*MwhjfevCns+XlKwPS(༽8}E-8yyqi_KCAlY&'mjXڍ7}D56-kfK(z~!F?ns.bYbF:hvf"rB12Ye[Ci%}ǵǟU<4xO#ڍ- ?m'oq~uN#SƟcbUA4)Wqh<@ K ӟҔųߎdp ^K`?P*{vPNYsSRBJR\ _TzY}6V &u}&cge"3]~ZˍViw.+_מcslŖ0^ _o_`C&;~ޞ2 6s|:g$ 1?WgMnmyEVʨݕo}}v׊7jmV7=g?1q#u:[?#r^{tL녹Lm[KZ5z7}{?FMW"ƌ5P{?ES[],inK2Yel޹/۝kۅ?s?—1g1C,G]qm*QM0kW̱=DX󙏄Y+-[Y"C>?wk?~bmukHUWX缽$Os9adHK.A(>IbY4^{t ?ԯuLS3ó< YM|ﴹr$%M;l|}8Ӭ#)=C İgۭq BTUuGJQҕlnAngM:J4MinIgn_Ar77[tYOf~=)Y(J:R(J:R(J:R(J:R(J:R(J:R}G)jI@X>V0 Ft!ՔJJoVw`wXÇ'J?P~ Uòl-`$D 39H TDtޮwuU7 bN-:dkgcA&Sdфy$SEO;LUؖ.* C)RRU$t_FvoOqW' d85TʝK0㊕3zad@[a={ G*˄H[}]{ʒ Nu̿_'^{V+F"G$iȩ*_fko`7GW^+=|Ǫ?fY)P>wOc 3ߓk;wfxz- ,R53GFZ.u!^nn"بS!msž#E{UQW(+퓀5wh;3"tݨz)'JɝzfjT}凮-LV._UJ|O9VOJ4T t5E}ooCoh}`'>n~{T*q5QNRQhX6f)Z rh/z?hi,~)GJQҔt)GJQҔt)GJQҔt)GJQҔt)GJQҔt)Q~1^մP,Uĭ;Y,baFOvaOk F[ڈK!RYmvmnnt]gM XhU*$!H04̨LɮkRk^I{|WO K~-m+tϿoOn)UD3FaG꣹:m l  g'u%J- ^nJL*Ռӂv_O,';rѢTV|%1VT{Q9? ]aF,Q}%YI2*;aɁvΤI$zVi}I;Nǻ< j^PDn%ZT3zM(:ϧ?,_bIq'YcB'ԡה:(z p:뗧K=艒ft{m*A#c[&߆VVRO((+Vū}S=J`S*H굥CZLj޻rQZ,HqE5dC-=[b3 zn_=t.q<"3FtjJJkmJ% Ypt˪za!k,dsUR(%K*\wXb9::ٵrvvWH`0H ΋O&ZOQMGOK>3MJs>5J}ʩHdvZ@%bIuJI$rCk,}~];\+C n9#PehO@)U%rOjGkfBb~OOM$鱜}jWU]̖zk-(]22O@)S]2=m,о+E7킃W2fQ2$F)H=z\2dz KG!Ǧɀ2U Pqff;G*kS/}hY}n={|-=~zuXU22$. M @mڻav;/kB+C& oP"!Y%Cwhgu+Z7ר(oK;JShfYaI H Y#-ȬSۭ;fz&>2@ͧܕcݞ2eZAHQ Kʫȅ*myC{iv|5FstZSrZm"h.xs_COzAڝE^wC\%KX0ʮ# w^諡R]=M]b~E;U3;U3cf,FCǥ*ѻuNiw}eVZ-|VO3Ǐ\ӽ(1Xҕ1.}Dn=cZsj7~W~oUɌ֋SII)gIP-LqWPm (J:R(J:R-~!cY<;MUU=R AȿMᨳ#(LzZ[x.0iOxS: >v{]۸LzolzYkCGnxT8G(KKYqfIT޼QS|J:(dyLx쏸~=AS¿T{yfc䡋G̈WM7VZ8H5>[ˉbn[ >viJs@(e0cXR},О}O,j>ok=T'醒i47K];`Z[\RS-:*OL XvwR_=czv?Žv rpLbB5~ KSB嶀sAI;jV4Ru*QW(%Q- SL|-c~NKRr6*g>c|;ms` )OP,Чi{7ryx #sZ+\w*g38(*GnD`,f3hY86vyҨ0{[.wWkJҷ`A%h܌R'ҷ<[)M`nה²/MA΢ *O'J*:,R;~o7%ٶIk,>(Y> RҎA C RRP*9]lN}S;[Qmw*i_T)qqZ{o\Ie_n=}7n<ҘSH%m\ˠUEh'EވM<$oVloۥ(J쁻h֏NP Ji1;w۾TC`L)]-@mXhwzjY]JZGݶ?v }_hғ;JwAZX۠'[r ?rcRg;'8Ȼ';޽o[k~qtCkp&ʂOE++ޔ=T #z-)]t)Z4ף;Rhmn]~?1T^,B*GʺzF|o(JJmi엻qZ+pޕ~]}nG;zJRGߥ+(J:R(J&O^.$6M_s[m]}OG_[ps|1[!qGϩM<=3Q4I܄GcUe^?aZqٽʙrݥ{ pY-NmT[l#JVug*2)2m]692.؍V[ކE; fb$v VR+Uտc\KgJW@})GJVHǚ-;u+~)GJV-?OyWsN)GJQҔt)GJV\n!gs2o$L< 'ۮX~ W ȟQ_\|UoŜ)ܬ%˖O{+Ew ץnG:1>K+pe:E% *-k=u9;o獷Bs-v \Bv5Ngb*lBp!^\idzۖzrf_wKަu'Ao K_ *{W v e4aE_CHէJ:xyV5Xὺb跼ZD$_ZFKKZOT 1 #9y 2]6 cU͕RdVH[pD r䆮1 I@)N!#*JT5(,Tln*qMܕ v 27 ]PH'rWmbt{k569)oWZzMV=Xԣ>vkmo bmB<]âwB[K5Q==hܻޟN)>gJ.u/5P+LR!kJS;'* #ȴS47%? =0 9ZeL **6HF3› R.-}:^彟iv՜Sjvtm6ZA+lvKU@,,񩊩J雥+jw?K5Nm*;'=v dGdϭ>zjsIYjUijd#dkRD>Yk&MSi~CϷM^g{yO%?W(Nt$Կzdcs _Du7;?Xn ŊhZMjyNvTuڠ &J1*)R9/֜V=t{;QϦԔQ%E0ʡ"5(d-n JPG%N!_dN!YȬ1]R]#K;%/\}X}EgܥT(; =7qr'qǦ W HA?J" vwݿ|76݅nGQvۓof0R8)hF7&5wX)I7L>͸!Uּ?w~+Zn$=>蓩R wCmڈw=i_a+i0m31tcJm |<p 11Q"jܚI#m ud^eWc,;۵dRyc`=s(@JU3{TʴZ_vKmOkR%V/se*)$u <{>!E F2b+I 9umY?{UI1Ƕ=4E|[ÉRV)5JfEp$rڙj>4ڶ>Vnx#Tgջxs^9Z}$+H) WFh*eFt>pg-,PXmڰQODIF[eyt"0y7/,pL_í6 uII0:oIh33j]~c=$IMTJjV0ҏ`cs,rѦTڇUVƊqJ 4VHV51/v I M/1!&b$9 D=Ԗ\* H$HLduwi3oBNsf%Yifd!i5+d ~ tvzu_}82@ofR3Hd˘ruI5PO>At okW]U!o|ZcfO5TrX)lc`2T{={V[rlB̻FG._TSzޔbF-8!M-z'US\O[=B DYI[AHȲ|gjƑJA|c8%S0f9KܵkӾ˟GKQN"'ƲX-A\ NVYb]qJYSO&bDǪ9Nc.ip->Nts;K4/>vi>\a5oMA- ֗,j+u-5lNgz"ZvHkR;c) L2It_+7ap[SA9SEJRR$[z}{GlPj[}²m:8?.;_lΗ{X0|k[ٺ-wu}?loU僷Z]+^10eլVmkhďJ|Q[ =ee^5$]8|:{+ɘ}umxh 5Xr-Ab8vd-P2;5]5dh$c(ѩ Q#Wax p)\pųE`[q]$+:B2FOϵ᫝Zsͬ5M:U#S!ƒku*sZrUM2+ȻJ8oaA6:{mJR4%&;?qc]jk]tTZwN酊i֪C Q*jMr} 0 ~vŸB_+%]R($keޥiO+Wg[n] 3Ϣ ΃iޠH#+0ێ8vJ֕/FO{(N;α 񞛉嬷%<z{)e[E-:B1jIV緒b]o?!% h]Q.O{u;;t)GJQҔt)GJQҕ F=( yij\ @svm^* Lqij7IR]NF_h[Mpy!J)VqmݷiTDkK|Da d] Ν[kad^{R}&m[>=nX-6=;e+eQGu3ny<^VKQRR'i˥bҔtFnW‡%lPe6܂dd4muTgo d}mXNFU<εSs-I Rgi XPvYwMtOts i֖,axl;D6OqY\<$ZIٝ&']q2εטo.:ԣ$~'ԚYh&%r.W-]bW8*hĈHg)?'gmRm6*:Y3* 7JD'I 0 IvuYQ jF Mm;q֬5S4Γ%R02,O,JE%\HQ$f;ܝ' :V+`e3چb*У$+#ZkLSWI.uU[n¨\i^Y²y.WaI;Ę8ohq.($$')OgZmٟm:CX=98j{t] rOI5 S @![s8Kpnˤ@TN` ^sIUa γK9ަEm2Ohm0FHu ۰c(=6Ve@ *$y~ ǁcYk_TUMt\fڒFXceyL_l]a0 JZnr"@ɂ>5,ve?8ͯ'fM]rm)=,qA!>qwq 9XU*SE$zm.+.g h 0&~ks'jLp9j .=r*Ҭ ' ;*I%\X gya\ںGvHTF`A$fRդscԼXlص%Qk-.?duUKRkYL$y$cTI3*) qXow7V,)KmBQnRH d^(J:R(J:R(J:R+O:KK֡w=z3]etx+E uj6FO< Vп~fJl_in#؇sR'l6L7~X#t.mvS-%jNLJbeDֶ]ܷjZD* I=+ECc\3^&*+-ڝX@QH*)I HYޟݧS?sqI/~G z~_vNOۈէ|1Oѭk+?7ϧm?k?WA;KWMGzWE F U`o!d+A?uAٷsS_ժI'i) Ow|W&-2ܻQƩ\ji\c2eV!w!X ;WoSyIQLz=oO !b"fJVE҈Ne%D KZԛԋl}i-UZ֢]I!R꼜+fEr -_JQҔt)GJQҔt)GJQҔt)GJQҔt)GJQҔtB/S_}BՏJ31~{fj2%h.4NwPTaG6'+~߷n ?YҕۗC42/V˷j;Rl0w B- <*odBIл(f YmvxnT- 1%@ۧZH-L0\6VH@qwAYD$)c1 Q N#8?;qW\;״9x&~1Fo_?\nW0?5?OC ":?oީ`_;OS5{HX$n?t{K6ݽa\_'A1I{9xnj^ѭEu4'Elpѫ=5knkS%(ZjQ-8ҕY#NNF01^p[2ɖkH%I O{0Gm|_q-} l\6TL@֡s$^wےP<^3_ܿJQҔt)GJQҔt)GJQҔtAUEvUOQ^Bq-uv'Uʮ^SMJ&7 a:(LSfau<1m9Qw݀.錆yhuT}P3@;|5?ͻ yJ(?Lb~^7:?uT+@` v.ǏvoUοW\iZzzoJ ÕvK_cO5^S"JOb'`\¿_U6 e qq uD b>ms1ݫ~괥@#Zg]87{fyVEٖgS Ȳ mf{O݌>k?R ;`4?u3*|TM 8*Z>5H>lJU9(O}SMM~oc\.;JXoW7:.W柺(JjgGv-~|p1jJUd @_sָ+>kt5-~0sW@#ؾG7Ez|{W$NJEfE=ə;Yb^Jɕw?vz?Wr/Ku;7ϑ>mqڽ+.>?GV/hr| TyWEcI[CqR9v,+ 2>܇\mBj=?FW7 uNaA_K8ES ɼ^ΞeP7 b9SeR͕6ƽg쏶VTO!)jC/T4)4I&a(?mbsX4c9: A$sFSc?ޏ᫮pQ_mѥCnDtGc"OE!fYZ/ }@ uOƆtQǗJ m!* iUs ';JF3mq:}t;HnBOobA 7۔( myuƧ+(H+3_T~4I\ Bu1V{E*X(d 8w + %~2[>F~=+j*:Αnv bbU12ȱ<' 9ٛ}i?2Ƨa G2}fےE\:[5TWR Җ+GG6!~qsK(dgZA0dU#`xG)&F Vra9Uj:Yp{e-ّ8#2Ȥp_y QLZăϖT8 JHyP] 6H[hCޔֺJQҔt)GJQҔt)GJV^_B$Eqܜ&oPR ùKAϮs#m`nU=*7T+-)(R8HrXI"W3R $ *6RZPrz #<5KCl2oALJ+DIiС@rP9ޥ+qDzTRk3۬{J/1vԢeƉ1xIVA"uX"SuAmd<#*O*R왑wޏ4ېyf .xDfHt}fVCis!.oH+l7 ē?_,گ ٕ*,<+rwgoE6RXSEPB8x!_iw NR t?M:SY,WtYOyn7҅Ѩs5c"qV$)<Dp'II Asw:)P):}ͪH=jH{`?i%D*G8 )| EʞH0ΜwA\*yoV-,?ti)cZf%FHyI.}٧m%J:iI PN]>NQ{hicH@S6(HY" =•~ҴeoM-@$f  o r?iI2FӤR~1>~u";z @K*{ aYٕ8;% 4ߖh)AJwwۧb9l]9 e=iΧ旟݃n oaJ`8RD>duX Ƃu~-N͛Cu7!P!GvmJoktAiuk, $up m>Ԍ #Yw~W_**:bX%a]%6NE 󙞕15_ S]Sav1_-xDZߏi|!"͒%,B(wc M|w'=ϸzzpm2Zg_Pn9(w H m}aB.`tMdY˴mÖ -ILHV-IZ.UѾ3*3le4+U]++/W h~*dZɥ c@5_)J)GJQҔtGໞҾ٨qJL,LڶaإFUt6CT%ܻLÊUJ߾7Sҕ~igj^cw %Ϭ=:z秷iXQZBUfP[`X=)ZԼ[W%L]50J COo$h(H*b$rʁcoSbq`4[tL4!-6ߞ#`z!!֠&9_~1Pی;\i>~c.2No]LPbRLK\*VM/5(]