Ad Inserter – WordPress Ads Management with AdSense Header Integration - Version 2.3.8

Version Description

  • Added support rotation option shares
  • Added support for sticky ad settings and animations (Pro only)
  • Few minor bug fixes, cosmetic changes and code improvements
Download this release

Release Info

Developer spacetime
Plugin Icon 128x128 Ad Inserter – WordPress Ads Management with AdSense Header Integration
Version 2.3.8
Comparing to
See all releases

Code changes from version 2.3.7 to 2.3.8

ad-inserter.php CHANGED
@@ -1,6312 +1,6419 @@
1
- <?php
2
-
3
- /*
4
- Plugin Name: Ad Inserter
5
- Version: 2.3.7
6
- Description: Ad management plugin with advanced advertising options to automatically insert ad codes on your website
7
- Author: Igor Funa
8
- Author URI: http://igorfuna.com/
9
- Plugin URI: http://adinserter.pro/documentation
10
- */
11
-
12
- /*
13
-
14
- Change Log
15
-
16
- Ad Inserter 2.3.7 - 2018-03-27
17
- - Added support for ad labels
18
- - Blocked search indexing while debugging
19
- - Few minor bug fixes, cosmetic changes and code improvements
20
-
21
- Ad Inserter 2.3.6 - 2018-03-20
22
- - Added widget for debugging tools
23
- - Fix for AdSense ad overlays not displayed with some themes
24
- - Few minor bug fixes, cosmetic changes and code improvements
25
-
26
- Ad Inserter 2.3.5 - 2018-03-13
27
- - Added display of header and footer code in Label blocks debugging function
28
- - Added AdSense ad overlays in Label blocks debugging function (experimental)
29
- - Fixed bug for removed square brackets in HTML element selectors
30
- - Fixed preview of AdSense ad units
31
- - Few minor bug fixes
32
-
33
- Ad Inserter 2.3.4 - 2018-03-05
34
- - Added support for author:author-username items in taxonomy list
35
- - Fixed errors when downgrading from Pro
36
- - Few minor bug fixes
37
-
38
- Ad Inserter 2.3.3 - 2018-02-08
39
- - Added list editors
40
- - Added Label blocks debugging function for AdSense Auto ads
41
-
42
- Ad Inserter 2.3.2 - 2018-02-01
43
- - Added AdSense code generator for ad sizes using CSS media queries
44
- - Fix for slow updates caused by changed user agent (Pro only, credits Olivier Langlois, https://juicingforyourmanhood.com/affiliate_tools.html)
45
- - Fix for client-side insertion of non-English characters before/after HTML element
46
-
47
- Ad Inserter 2.3.1 - 2018-01-25
48
- - Added support for server-side insertion before/after any HTML element
49
- - Few minor bug fixes
50
-
51
- Ad Inserter 2.3.0 - 2018-01-21
52
- - Added support for client-side insertion before/after any HTML element
53
- - Inplemented AdSense integration
54
- - Added option to define close button position
55
- - Fix for code generator import and code preview error with non ASCII characters
56
- - Fix for post/page exceptions and page types not processed in the header
57
- - Fix for close button in preview window
58
- - Fix for errors when rearranging blocks
59
- - Fix for errors when importing code
60
- - Few minor bug fixes, cosmetic changes and code improvements
61
-
62
- Ad Inserter 2.2.16 - 2018-01-04
63
- - Fix for error when saving settings on multisite installation
64
-
65
- Ad Inserter 2.2.15 - 2018-01-04
66
- - Fix for responsive AMP ads using center alignment
67
-
68
- Ad Inserter 2.2.14 - 2018-01-04
69
- - Added code generator for placeholders
70
- - Added option to disable caching (works with WP Super Cache, W3 Total Cache and WP Rocket)
71
- - Added shortcut option to generate only block code (no wrapping div)
72
- - Added options to configure classes for wrapping div
73
- - Added support for external tracking via Google Analytics and Piwik (Pro only)
74
- - Added support for MaxMind geolocation databases (Pro only)
75
- - Added option for close button on sticky ads (Pro only)
76
- - Fix for no paragraph counting inside nested elements
77
- - Few minor bug fixes, cosmetic changes and code improvements
78
-
79
- Ad Inserter 2.2.13 - 2017-12-25
80
- - Added option to disable inline alignment styles for code blocks (using alignment classes)
81
- - Fix for custom CSS codes with single quotation marks
82
-
83
- Ad Inserter 2.2.12 - 2017-12-25
84
- - Fix for code block styles when block class name was not set
85
-
86
- Ad Inserter 2.2.11 - 2017-12-25
87
- - Code block styles moved to classes
88
- - Code block list moved to the sidebar
89
- - Added preview buttons in code block list
90
- - Fix for ad blocking detection when using https (Pro only)
91
- - Few minor bug fixes, cosmetic changes and code improvements
92
-
93
- Ad Inserter 2.2.10 - 2017-12-10
94
- - Fix for rotation editor code import/export
95
- - Fix for errors when using old |rotate| separator
96
- - Few minor bug fixes, cosmetic changes and code improvements
97
-
98
- Ad Inserter 2.2.9 - 2017-12-09
99
- - Output buffering is now disabled by default (for position Above header you need to enable it)
100
- - Fix for min. paragraph number not processed
101
-
102
- Ad Inserter 2.2.8 - 2017-12-08
103
- - Added position for automatic insertion Above header (after `<body>` tag)
104
- - Added rotation code editor
105
- - Added support to name rotation options
106
- - Added code generator for banners
107
- - Added code generator for AdSense
108
- - Added support to rearrange code blocks
109
- - Added support to copy any block settings
110
- - Added support for clipboard to copy/paste block settings
111
- - Added option to select ad blocking detection mode (Pro only)
112
- - Delayed insertion on posts now available for all insertion positions
113
- - Few minor bug fixes, cosmetic changes and code improvements
114
-
115
- Ad Inserter 2.2.7 - 2017-11-08
116
- - Fix for duplicate amp-custom tag on AMP pages
117
-
118
- Ad Inserter 2.2.6 - 2017-11-07
119
- - Fix for posts filter counter not counting
120
- - Added list with short overview of all code blocks
121
- - Added support for word count on blog pages
122
- - Added support for client code preview (no need to save it for preview)
123
- - Improved compatibility on AMP pages
124
- - Few minor bug fixes, cosmetic changes and code improvements
125
-
126
- Ad Inserter 2.2.5 - 2017-10-15
127
- - Fix for issue with Ajax requests
128
-
129
- Ad Inserter 2.2.4 - 2017-10-14
130
- - Added support to insert raw HTTP response header lines
131
- - Added support to check for individual exceptions for shortcodes
132
- - Added support to trigger ad blocking detection action only on individual pages
133
- - Added support for automatic insertion position Footer
134
- - Added support for custom hooks
135
- - Url parameter list now checks url parameters ($_GET) and cookies ($_COOKIE)
136
- - Fix for |count| separator not processed
137
-
138
- Ad Inserter 2.2.3 - 2017-09-26
139
- - Added support to insert custom fields via shortcode [adinserter custom-field='CUSTOM_FIELD_NAME']
140
- - Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items
141
- - Added support for post-type:POST_TYPE taxonomy list items
142
- - Added support for JavaScript based sticky widgets
143
- - Added support for ad blocking statistics (Pro only)
144
- - Added support for WP AMP and WP AMP Ninja plugins
145
- - Post/Page Word Count moved to Misc section (now works also on widgets)
146
- - Few minor bug fixes, cosmetic changes and code improvements
147
-
148
- Ad Inserter 2.2.2 - 2017-08-28
149
- - Fix for mobile admin layout
150
- - Few other minor bug fixes
151
-
152
- Ad Inserter 2.2.1 - 2017-08-27
153
- - Fix for header/footer scripts on AMP pages
154
-
155
- Ad Inserter 2.2.0 - 2017-08-27
156
- - Added support for ad blocking detection (experimental)
157
- - Added support for [ADINSERTER AMP] shortcode to separate code for AMP pages
158
- - Added support for [ADINSERTER ROTATE] and [ADINSERTER COUNT] shortcodes
159
- - Added syntax highlighting for shortcodes and separators
160
- - Added style `clear: both;` to Default, Left, Right and Center alignments
161
- - Bug fix for errors when loading tracking charts (Pro only)
162
- - Many minor bug fixes, cosmetic changes and code improvements
163
-
164
- Ad Inserter 2.1.14 - 2017-08-07
165
- - Fix for error when using older PHP versions (prior to 5.5)
166
-
167
- Ad Inserter 2.1.13 - 2017-08-07
168
- - Fix for Fatal error: Can't use method return value in write context
169
-
170
- Ad Inserter 2.1.12 - 2017-08-07
171
- - Added option to define tags inside which paragraphs are not counted
172
- - Added max insertions check when inserting for all paragraphs
173
- - Added support for inverted filter
174
- - Added option to define minimum number of words in paragraphs above (experimental)
175
- - Added support for %N filter item to filter every N-th insertion (experimental)
176
- - Added filter support when inserting for all paragraphs (experimental)
177
- - Increased nonce lifespan to 48 hours when using tracking (Pro only)
178
- - Fixed wrong urls in debug menu when behind proxy
179
-
180
- Ad Inserter 2.1.11 - 2017-07-21
181
- - Improved support for sticky widgets
182
- - Added support for ad counting (|count| separator)
183
- - Added support to black/white-list arbitrary taxonomies (taxonomy, term or taxonomy:term)
184
- - Added support for automatic insertion before, between and after comments
185
- - Added processing of shortcodes in the header and footer code
186
- - Debugging function Show positions shows also page type
187
- - Fixed page type detection when Post page was set to static page and it was not homepage
188
- - Few minor bug fixes, cosmetic changes and code improvements
189
-
190
- Ad Inserter 2.1.10 - 2017-07-01
191
- - Fix for shifted sidebars in some themes
192
-
193
- Ad Inserter 2.1.9 - 2017-06-30
194
- - Added support for sticky widgets
195
- - Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img)
196
- - Impression and click tracking (beta, Pro only)
197
- - Few minor bug fixes, cosmetic changes and code improvements
198
-
199
- Ad Inserter 2.1.8 - 2017-05-18
200
- - Fixed error when using server-side device detection
201
-
202
- Ad Inserter 2.1.7 - 2017-05-13
203
- - Fixed error when using PHP 5.4 or earlier
204
-
205
- Ad Inserter 2.1.6 - 2017-05-12
206
- - Added support for insertion before/after multiple paragraphs
207
- - Added initial support for impression and click tracking (Pro only)
208
- - Few bug fixes and cosmetic changes
209
-
210
- Ad Inserter 2.1.5 - 6 April 2017
211
- - Added support to avoid insertion inside <figure> and <li> elements (image captions, lists)
212
- - Added support for exceptions for custom post types
213
- - Few minor bug fixes and code improvements
214
-
215
- Ad Inserter 2.1.4 - 12 March 2017
216
- - Paragraph counting restored to standard functions
217
- - Added option to select paragraph counting functions with multibyte support (unicode characters)
218
- - Fixed bug for wrong paragraph counting in posts with blockquote sections in some cases
219
- - Fixed bug for wrong measuring of plugin processing time in some cases
220
- - Fixed bug for "Empty delimiter" warning
221
-
222
- Ad Inserter 2.1.3 - 11 March 2017
223
- - Added support for counting paragraphs with multibyte (unicode) characters
224
- - Fixed bug for class name not saved
225
- - Few minor bug fixes and cosmetic changes
226
-
227
- Ad Inserter 2.1.2 - 1 March 2017
228
- - Fixed bug for disabled settings page on multisite blogs
229
-
230
- Ad Inserter 2.1.1 - 26 February 2017
231
- - Changes for compatibility with PHP 7.1
232
- - Automatic rename of old pro plugin slug (Pro only)
233
- - Added support for additional Pro features (Pro only)
234
- - Few bug fixes and cosmetic changes
235
-
236
- Ad Inserter 2.1.0 - 10 February 2017
237
- - Added support to insert ads in Ajax requests (e.g. in infinite scroll)
238
- - Added support to not include block classes when class name is empty
239
- - Added sticky positions (Pro only)
240
- - Bug fix for minimum user role not taken into account for exceptions list
241
- - Bug fix for IP database update cron event (Pro only)
242
-
243
- Ad Inserter 2.0.14 - 2 February 2017
244
- - Fixed issue for responsive ads not displayed when using Left, Center or Right alignment
245
-
246
- Ad Inserter 2.0.13 - 1 February 2017
247
- - Added icons for Automatic insertion and alignment
248
- - Automatic insertion None changed to Disabled
249
- - Alignment None changed to Default
250
- - Changed database option data for Automatic insertion and Alignment settings
251
- - Improved CSS 3 code for Left, Center and Right alignment
252
- - Click on CSS code starts editing
253
- - Page/Post exceptions listed in debug output
254
- - Different plugin slug for Pro version
255
- - Few minor bug fixes and cosmetic changes
256
-
257
- Ad Inserter 2.0.12 - 29 January 2017
258
- - Bug fix for page/post exceptions list
259
-
260
- Ad Inserter 2.0.11 - 29 January 2017
261
- - Bug fix for settings page not loading
262
-
263
- Ad Inserter 2.0.10 - 26 January 2017
264
- - Added option to insert ads between posts on blog pages
265
- - Added option to check and manage post/page exceptions for each block
266
- - Added option to check and manage all post/page exceptions (Pro only)
267
- - Added option for multisite installations to disable PHP processing on sub-sites (Pro only)
268
- - Added license status notifications (Pro only)
269
-
270
- Ad Inserter 2.0.9 - 8 January 2017
271
- - Added support for uppercase {country_ISO2} and lowercase {country_iso2} tag (Pro only)
272
- - Removed inclusion of dummy css and js file
273
- - Bug fix: Client-side dynamic blocks were not enabled if not using W3 Total Cache
274
-
275
- Ad Inserter 2.0.8 - 6 January 2017
276
- - Added support for client-side rotation (works with caching)
277
- - Added support for server-side rotation with W3 Total Cache
278
- - Added support for client-side country detection (works with caching, Pro only)
279
- - Added support for server-side country detection with W3 Total Cache (Pro only)
280
- - Added debugging functions to measure plugin processing time
281
- - Added option to black/white-list IP addresses (Pro only)
282
- - Added option for fallback code when scheduling between dates expires (Pro only)
283
- - On multisite installations Ad Inserter debug menu item on sites is available only if settings page is enabled
284
- - Added option for multisite installations to use Ad Inserter settings of main site for all blogs
285
- - Added flags to country list (Pro only)
286
- - Bug fix: Code preview did not work if Wordpress was installed in a folder
287
- - Few minor bug fixes and cosmetic changes
288
-
289
- Ad Inserter 2.0.7 - 23 December 2016
290
- - Delayed display moved to Misc group
291
- - Added option for scheduling to insert code only between specified dates (Pro only)
292
- - Added option for Geo targeting (Pro only)
293
- - Few minor bug fixes and cosmetic changes
294
-
295
- Ad Inserter 2.0.6 - 25 November 2016
296
- - Added support to filter subpages created by the <!--nextpage--> tag
297
- - Added option to import block name (Pro only)
298
- - Cookie deleted only when it exists and debugging is disabled
299
- - Few minor bug fixes
300
-
301
- Ad Inserter 2.0.5 - 8 october 2016
302
- - Cookie created only when debugging is enabled
303
- - Few minor bug fixes
304
-
305
- Ad Inserter 2.0.4 - 30 September 2016
306
- - Bug fix: Cursor position always at the end of block name
307
- - State of debugging functions saved to cookie
308
- - Few minor bug fixes
309
-
310
- Ad Inserter 2.0.3 - 26 September 2016
311
- - Debugging functions in admin toolbar available only for administrators
312
- - Added option to hide debugging functions in admin toolbar
313
- - Added shortcode for debugger
314
- - Few minor bug fixes
315
-
316
- Ad Inserter 2.0.2 - 25 September 2016
317
- - Changed javascript version check to get plugin version from the HTML page
318
- - Added warning if old cached version of CSS file is loaded on the settings page
319
- - Added warning if version query parameter for js/css files is removed due to inappropriate caching
320
-
321
- Ad Inserter 2.0.1 - 24 September 2016
322
- - Bug fix: Shortcodes called by name were not displayed
323
-
324
- Ad Inserter 2.0.0 - 23 September 2016
325
- - Redesigned user interface
326
- - Added many debugging tools for easier troubleshooting
327
- - New feature: Code preview tool with visual CSS editor
328
- - New feature: Label inserted blocks
329
- - New feature: Show available positions for automatic insertion
330
- - New feature: Show HTML tags in posts/static pages
331
- - New feature: Log Ad Inserter processing
332
- - Improved loading speed of the settings page
333
- - Improved block insertion processing speed
334
- - Added support to avoid insertion near images, headers and other elements
335
- - Added option to avoid insertion in feeds
336
- - Added option to display code blocks only to administrators
337
- - Added option for publishig date check for display positions Before/After Content
338
- - Added option for server-side device check for header and footer code
339
- - Added option for maximum page/post words
340
- - Added option for maximum paragraph words
341
- - Added option to black/white-list post IDs
342
- - Added option to black/white-list url query parameters
343
- - Added warning if the settings page is blocked by ad blocker
344
- - Added warning if old cached version of javascript is loaded on the settings page
345
- - Added support for multisite installations to disable settings, widgets and exceptions on network sites (Pro only)
346
- - Block names can be edited by clicking on the name
347
- - Filters now work also on posts and single pages
348
- - CSS code for client-side detection moved to inline CSS
349
- - Bug fix: Minimum user roles for exception editing was not calculated properly
350
- - Bug fix: Server-side detection checkbox was not saved properly
351
- - Many other minor bug fixes, code improvements and cosmetic changes
352
-
353
- Ad Inserter 1.7.0 - 16 August 2016
354
- - Bug fix: Shortcodes did not ignore post/static page exceptions
355
- - Slightly redesigned user interface
356
- - Excerpt/Post number(s) renamed to Filter as it now works on all display positions
357
- - Widget setting removed from Automatic display to Manual display section
358
- - Added support to disable widgets (standalone checkbox in Manual display)
359
- - Added call counter/filter for widgets
360
- - Added support to edit CSS for predefined styles
361
- - Few other minor bug fixes, code improvements and cosmetic changes
362
-
363
- Ad Inserter 1.6.7 - 9 August 2016
364
- - Bug fix: Block code textarea was not escaped
365
- - Added checks for page types for shortcodes
366
- - Added support for Before/After Post position call counter/filter
367
- - Few minor cosmetic changes
368
-
369
- Ad Inserter 1.6.6 - 5 August 2016
370
- - Bug fix: Display on Homepage and other blog pages might get disabled - important if you were using PHP function call or shortcode (import of settings from 1.6.4)
371
- - Few minor cosmetic changes
372
- - Requirements changed to WordPress 4.0 or newer
373
- - Added initial support for Pro version
374
-
375
- Ad Inserter 1.6.5 - 1 August 2016
376
- - Fixed bug: Wrong counting of max insertions
377
- - Change: display position Before Title was renamed to Before Post
378
- - Added support for display position After Post
379
- - Added support for posts with no <p> tags (paragraphs separated with \r\n\r\n characters)
380
- - Added support for paragraph processing on homepage, category, archive and search pages
381
- - Added support for custom viewports
382
- - Added support for PHP function call counter
383
- - Added support to disable code block on error 404 pages
384
- - Added support to debug paragraph tags
385
-
386
- Ad Inserter 1.6.4 - 15 May 2016
387
- - Fixed bug: For shortcodes in posts the url was not checked
388
- - Optimizations for device detection
389
-
390
- Ad Inserter 1.6.3 - 6 April 2016
391
- - Removed deprecated code (fixes PHP 7 deprecated warnings)
392
- - Added support for paragraphs with div and other HTML tags (h1, h2, h3,...)
393
-
394
- Ad Inserter 1.6.2 - 2 April 2016
395
- - Removed deprecated code (fixes PHP Fatal error Call to a member function get_display_type)
396
- - Added support to change plugin processing priority
397
-
398
- Ad Inserter 1.6.1 - 28 February 2016
399
- - Fixed bug: For shortcodes in posts the date was not checked
400
- - Fixed error with some templates "Call to undefined method is_main_query()"
401
- - Added support for minumum number of page/post words for Before/After content display option
402
- - Added support for {author} and {author_name} tags
403
-
404
- Ad Inserter 1.6.0 - 9 January 2016
405
- - Added support for client-side device detection
406
- - Many code improvements
407
- - Improved plugin processing speed
408
- - Removed support for deprecated tags for manual insertion {adinserter n}
409
- - Few minor bug fixes
410
-
411
- Ad Inserter 1.5.8 - 20 December 2015
412
- - Fixed notice "Undefined index: adinserter_selected_block_" when saving page or post
413
-
414
- Ad Inserter 1.5.7 - 20 December 2015
415
- - Fixed notice "has_cap was called with an argument that is deprecated since version 2.0!"
416
- - Few minor bug fixes and code improvements
417
- - Added support to blacklist or whitelist url patterns: /url-start*. *url-pattern*, *url-end
418
- - Added support to define minimum number of words in paragraphs
419
- - Added support to define minimum user role for page/post Ad Inserter exceptions editing
420
- - Added support to limit insertions of individual code blocks
421
- - Added support to filter direct visits (no referer)
422
-
423
- Ad Inserter 1.5.6 - 14 August 2015
424
- - Fixed Security Vulnerability: Plugin was vulnerable to Cross-Site Scripting (XSS)
425
- - Few bug fixes and code improvements
426
-
427
- Ad Inserter 1.5.5 - 6 June 2015
428
- - Few bug fixes and code improvements
429
- - Added support to export and import all Ad Inserter settings
430
-
431
- Ad Inserter 1.5.4 - 31 May 2015
432
- - Many code optimizations and cosmetic changes
433
- - Header and Footer code blocks moved to settings tab (#)
434
- - Added support to process shortcodes of other plugins used in Ad Inserter code blocks
435
- - Added support to white-list or black-list individual urls
436
- - Added support to export and import settings for code blocks
437
- - Added support to specify excerpts for block insertion
438
- - Added support to specify text that must be present when counting paragraphs
439
-
440
- Ad Inserter 1.5.3 - 2 May 2015
441
- - Fixed Security Vulnerability: Plugin was vulnerable to a combination of CSRF/XSS attacks (credits to Kaustubh Padwad)
442
- - Fixed bug: In some cases deprecated widgets warning reported errors
443
- - Added support to white-list or black-list tags
444
- - Added support for category slugs in category list
445
- - Added support for relative paragraph positions
446
- - Added support for individual code block exceptions on post/page editor page
447
- - Added support for minimum number of words
448
- - Added support to disable syntax highlighting editor (to allow using copy/paste on mobile devices)
449
-
450
- Ad Inserter 1.5.2 - 15 March 2015
451
- - Fixed bug: Widget titles might be displayed at wrong sidebar positions
452
- - Change: Default code block CSS class name was changed from ad-inserter to code-block to prevent Ad Blockers from blocking Ad Inserter divs
453
- - Added warning message if deprecated widgets are used
454
- - Added support to display blocks on desktop + tablet and desktop + phone devices
455
-
456
- Ad Inserter 1.5.1 - 3 March 2015
457
- - Few fixes to solve plugin incompatibility issues
458
- - Added support to disable all ads on specific page
459
-
460
- Ad Inserter 1.5.0 - 2 March 2015
461
- - Added support to display blocks on all, desktop or mobile devices
462
- - Added support for new widgets API - one widget for all code blocks with multiple instances
463
- - Added support to change wrapping code CSS class name
464
- - Fixed bug: Display block N days after post is published was not working properly
465
- - Fixed bug: Display block after paragraph in some cases was not working propery
466
-
467
- Ad Inserter 1.4.1 - 29 December 2014
468
- - Fixed bug: Code blocks configured as widgets were not displayed properly on widgets admin page
469
-
470
- Ad Inserter 1.4.0 - 21 December 2014
471
- - Added support to skip paragraphs with specified text
472
- - Added position After paragraph
473
- - Added support for header and footer scripts
474
- - Added support for custom CSS styles
475
- - Added support to display blocks to all, logged in or not logged in users
476
- - Added support for syntax highlighting
477
- - Added support for shortcodes
478
- - Added classes to block wrapping divs
479
- - Few bugs fixed
480
-
481
- Ad Inserter 1.3.5 - 18 March 2014
482
- - Fixed bug: missing echo for PHP function call example
483
-
484
- Ad Inserter 1.3.4 - 15 March 2014
485
- - Added option for no code wrapping with div
486
- - Added option to insert block codes from PHP code
487
- - Changed HTML codes to disable display on specific pages
488
- - Selected code block position is preserved after settings are saved
489
- - Manual insertion can be enabled or disabled regardless of primary display setting
490
- - Fixed bug: in some cases Before Title display setting inserted code into RSS feed
491
-
492
- Ad Inserter 1.3.3 - 8 January 2014
493
- - Added option to insert ads also before or after the excerpt
494
- - Fixed bug: in some cases many errors reported after activating the plugin
495
- - Few minor bugs fixed
496
- - Few minor cosmetic changes
497
-
498
- Ad Inserter 1.3.2 - 4 December 2013
499
- - Fixed blank settings page caused by incompatibility with some themes or plugins
500
-
501
- Ad Inserter 1.3.1 - 3 December 2013
502
- - Added option to insert ads also on pages
503
- - Added option to process PHP code
504
- - Few bugs fixed
505
-
506
- Ad Inserter 1.3.0 - 27 November 2013
507
- - Number of ad slots increased to 16
508
- - New tabbed admin interface
509
- - Ads can be manually inserted also with {adinserter AD_NUMBER} tag
510
- - Fixed bug: only the last ad block set to Before Title was displayed
511
- - Few other minor bugs fixed
512
- - Few cosmetic changes
513
-
514
- Ad Inserter 1.2.1 - 19 November 2013
515
- - Fixed problem: || in ad code (e.g. asynchronous code for AdSense) causes only part of the code to be inserted (|| to rotate ads is replaced with |rotate|)
516
-
517
- Ad Inserter 1.2.0 - 15/05/2012
518
- - Fixed bug: manual tags in posts lists were not removed
519
- - Added position Before title
520
- - Added support for minimum number of paragraphs
521
- - Added support for page display options for Widget and Before title positions
522
- - Alignment now works for all display positions
523
-
524
- Ad Inserter 1.1.3 - 07/04/2012
525
- - Fixed bug for {search_query}: When the tag is empty {smart_tag} is used in all cases
526
- - Few changes in the settings page
527
-
528
- Ad Inserter 1.1.2 - 16/07/2011
529
- - Fixed error with multisite/network installations
530
-
531
- Ad Inserter 1.1.1 - 16/07/2011
532
- - Fixed bug in Float Right setting display
533
-
534
- Ad Inserter 1.1.0 - 05/06/2011
535
- - Added option to manually display individual ads
536
- - Added new ad alignments: left, center, right
537
- - Added {search_query} tag
538
- - Added support for category black list and white list
539
-
540
- Ad Inserter 1.0.4 - 19/12/2010
541
- - HTML entities for {title} and {short_title} are now decoded
542
- - Added {tag} to display the first tag
543
-
544
- Ad Inserter 1.0.3 - 05/12/2010
545
- - Fixed bug for rotating ads
546
-
547
- Ad Inserter 1.0.2 - 04/12/2010
548
- - Added support for rotating ads
549
-
550
- Ad Inserter 1.0.1 - 17/11/2010
551
- - Added support for different sidebar implementations
552
-
553
- Ad Inserter 1.0.0 - 14/11/2010
554
- - Initial release
555
-
556
- */
557
-
558
-
559
- global $block_object, $ai_wp_data, $ad_inserter_globals, $ai_last_check, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_db_options, $block_insertion_log;
560
-
561
- if (!defined ('AD_INSERTER_PLUGIN_DIR'))
562
- define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
563
-
564
- define ('AI_WP_DEBUGGING_', 0);
565
- define ('AI_DEBUG_PROCESSING_', 0x01);
566
- define ('AI_URL_DEBUG_', 'ai-debug');
567
- define ('AI_URL_DEBUG_PROCESSING_', 'ai-debug-processing');
568
- define ('AI_URL_DEBUG_PHP_', 'ai-debug-php');
569
-
570
- if (isset ($_GET [AI_URL_DEBUG_PHP_]) && $_GET [AI_URL_DEBUG_PHP_] != '') {
571
- if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) {
572
- ini_set ('display_errors', 1);
573
- error_reporting (E_ALL);
574
- }
575
- }
576
-
577
- $ai_wp_data [AI_WP_DEBUGGING_] = 0;
578
-
579
- if (!is_admin()) {
580
- if (!isset ($_GET [AI_URL_DEBUG_]))
581
- if (isset ($_GET [AI_URL_DEBUG_PROCESSING_]) || (isset ($_COOKIE ['AI_WP_DEBUGGING']) && ($_COOKIE ['AI_WP_DEBUGGING'] & AI_DEBUG_PROCESSING_) != 0)) {
582
- if (!isset ($_GET [AI_URL_DEBUG_PROCESSING_]) || $_GET [AI_URL_DEBUG_PROCESSING_] == 1) {
583
- $ai_wp_data [AI_WP_DEBUGGING_] |= AI_DEBUG_PROCESSING_;
584
-
585
- $ai_total_plugin_time = 0;
586
- $start_time = microtime (true);
587
- $ai_total_php_time = 0;
588
- $ai_last_time = microtime (true);
589
- $ai_processing_log = array ();
590
- ai_log ("INITIALIZATION START");
591
- }
592
- }
593
- }
594
-
595
- // Version check
596
- global $wp_version, $version_string;
597
-
598
- if (version_compare ($wp_version, "4.0", "<")) {
599
- exit ('Ad Inserter requires WordPress 4.0 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update!</a>');
600
- }
601
-
602
- //include required files
603
- require_once AD_INSERTER_PLUGIN_DIR.'class.php';
604
- require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
605
- require_once AD_INSERTER_PLUGIN_DIR.'settings.php';
606
-
607
- $version_array = explode (".", AD_INSERTER_VERSION);
608
- $version_string = "";
609
- foreach ($version_array as $number) {
610
- $version_string .= sprintf ("%02d", $number);
611
- }
612
-
613
- $ai_wp_data [AI_WP_URL] = remove_debug_parameters_from_url ();
614
-
615
- $ad_inserter_globals = array ();
616
- $block_object = array ();
617
- $block_insertion_log = array ();
618
-
619
- $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
620
- $ai_wp_data [AI_WP_AMP_PAGE] = false;
621
- $ai_wp_data [AI_WP_USER_SET] = false;
622
- $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN;
623
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
624
-
625
- $ai_wp_data [AI_SERVER_SIDE_DETECTION] = false;
626
- $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = false;
627
- $ai_wp_data [AI_TRACKING] = false;
628
- $ai_wp_data [AI_STICKY_WIDGETS] = false;
629
- $ai_wp_data [AI_STICK_TO_THE_CONTENT] = false;
630
- $ai_wp_data [AI_CLOSE_BUTTONS] = false;
631
- $ai_wp_data [AI_DISABLE_CACHING] = false;
632
- $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = false;
633
-
634
- ai_load_settings ();
635
-
636
- $ai_wp_data [AI_BACKEND_JS_DEBUGGING] = get_backend_javascript_debugging ();
637
- $ai_wp_data [AI_FRONTEND_JS_DEBUGGING] = get_frontend_javascript_debugging ();
638
-
639
- if (isset ($_GET [AI_URL_DEBUG_PHP]) && $_GET [AI_URL_DEBUG_PHP] == '1') {
640
- if (get_remote_debugging ()) {
641
- ini_set ('display_errors', 1);
642
- error_reporting (E_ALL);
643
- }
644
- }
645
-
646
- if (isset ($_GET [AI_URL_DEBUG_JAVASCRIPT]) && $_GET [AI_URL_DEBUG_JAVASCRIPT] == '1') {
647
- if (get_remote_debugging ()) {
648
- $ai_wp_data [AI_FRONTEND_JS_DEBUGGING] = true;
649
- }
650
- }
651
-
652
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
653
- $ai_wp_data [AI_ADB_DETECTION] = $block_object [AI_ADB_MESSAGE_OPTION_NAME]->get_enable_manual ();
654
-
655
- if ($ai_wp_data [AI_ADB_DETECTION]) {
656
- $adb_2_name = AI_ADB_2_DEFAULT_NAME;
657
- define ('AI_ADB_COOKIE_VALUE', substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 (LOGGED_IN_KEY.md5 (NONCE_KEY)))), 0, 8));
658
-
659
- $script_path = AD_INSERTER_PLUGIN_DIR.'js';
660
- $script = $script_path.'/sponsors.js';
661
-
662
- if (is_writable ($script_path) && is_writable ($script)) {
663
- $adb_2_name = substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 (LOGGED_IN_KEY).md5 (NONCE_KEY))), 0, 8);
664
-
665
- $js_ok = false;
666
- if (file_exists ($script)) {
667
- if (strpos (file_get_contents ($script), $adb_2_name) !== false) $js_ok = true;
668
- }
669
-
670
- if (!$js_ok) {
671
- file_put_contents ($script, 'window.' . $adb_2_name . '=true;');
672
- define ('AI_ADB_2_FILE_RECREATED', true);
673
- }
674
- }
675
-
676
- define ('AI_ADB_2_NAME', $adb_2_name);
677
-
678
- if (function_exists ('ai_check_files')) ai_check_files ();
679
- }
680
- }
681
-
682
- if (function_exists ('ai_load_globals')) ai_load_globals ();
683
-
684
- if (get_dynamic_blocks ()) {
685
- if (!in_array ('w3-total-cache/w3-total-cache.php', get_option ('active_plugins'))) {
686
- define ('AI_NO_W3TC', true);
687
- if (!defined ('W3TC_DYNAMIC_SECURITY')) define ('W3TC_DYNAMIC_SECURITY', 'W3 Total Cache plugin not active');
688
- }
689
- if (!defined ('W3TC_DYNAMIC_SECURITY')) {
690
- $string = AD_INSERTER_PLUGIN_DIR;
691
- if (defined ('AUTH_KEY')) $string .= AUTH_KEY;
692
- if (defined ('LOGGED_IN_KEY')) $string .= LOGGED_IN_KEY;
693
-
694
- define ('W3TC_DYNAMIC_SECURITY', md5 ($string));
695
- }
696
- }
697
-
698
-
699
- $adH = $block_object [AI_HEADER_OPTION_NAME];
700
- $adF = $block_object [AI_FOOTER_OPTION_NAME];
701
- if ($adH->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
702
- if ($adF->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
703
-
704
- if ($ai_wp_data [AI_SERVER_SIDE_DETECTION]) {
705
- require_once AD_INSERTER_PLUGIN_DIR.'includes/Mobile_Detect.php';
706
-
707
- $detect = new ai_Mobile_Detect;
708
-
709
- define ('AI_MOBILE', $detect->isMobile ());
710
- define ('AI_TABLET', $detect->isTablet ());
711
- define ('AI_PHONE', AI_MOBILE && !AI_TABLET);
712
- define ('AI_DESKTOP', !AI_MOBILE);
713
- } else {
714
- define ('AI_MOBILE', true);
715
- define ('AI_TABLET', true);
716
- define ('AI_PHONE', true);
717
- define ('AI_DESKTOP', true);
718
- }
719
-
720
- if (isset ($_POST [AI_FORM_SAVE]))
721
- define ('AI_SYNTAX_HIGHLIGHTING', isset ($_POST ["syntax-highlighter-theme"]) && $_POST ["syntax-highlighter-theme"] != AI_OPTION_DISABLED); else
722
- define ('AI_SYNTAX_HIGHLIGHTING', get_syntax_highlighter_theme () != AI_OPTION_DISABLED);
723
-
724
-
725
- add_action ('wp_loaded', 'ai_wp_loaded_hook');
726
- add_action ('admin_menu', 'ai_admin_menu_hook');
727
- add_action ('init', 'ai_init_hook');
728
- add_action ('admin_notices', 'ai_admin_notice_hook');
729
- add_action ('wp', 'ai_wp_hook');
730
- add_action( 'wp_enqueue_scripts', 'ai_wp_enqueue_scripts_hook' );
731
-
732
- if (function_exists ('ai_system_output_check')) $ai_system_output = ai_system_output_check (); else $ai_system_output = false;
733
-
734
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 || $ai_system_output)
735
- add_action ('shutdown', 'ai_shutdown_hook');
736
-
737
- add_action ('widgets_init', 'ai_widgets_init_hook');
738
- add_action ('add_meta_boxes', 'ai_add_meta_box_hook');
739
- add_action ('save_post', 'ai_save_meta_box_data_hook');
740
-
741
- if (function_exists ('ai_hooks')) ai_hooks ();
742
-
743
- add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
744
- add_filter ('plugin_row_meta', 'ai_set_plugin_meta', 10, 2);
745
-
746
- if (is_admin () === true) {
747
- add_action ('wp_ajax_ai_ajax_backend', 'ai_ajax_backend');
748
- add_action ('wp_ajax_ai_ajax', 'ai_ajax');
749
- add_action ('wp_ajax_nopriv_ai_ajax', 'ai_ajax');
750
- }
751
-
752
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
753
- $ai_total_plugin_time += microtime (true) - $start_time;
754
- ai_log ("INITIALIZATION END\n");
755
- }
756
-
757
-
758
-
759
-
760
- //add_filter ('the_generator', 'ai_the_generator');
761
-
762
- //function ai_the_generator ($generator) {
763
- // return preg_replace ('/content="(.*?)"/', 'content="$1, '.AD_INSERTER_NAME.' '. AD_INSERTER_VERSION.'"', $generator);
764
- //}
765
-
766
-
767
-
768
-
769
- function ai_wp_default_editor () {
770
- return 'tinymce';
771
- }
772
-
773
- function ai_wp_default_editor_html () {
774
- return 'html';
775
- }
776
-
777
- function ai_disable_caching () {
778
- // WP Super Cache, W3 Total Cache, WP Rocket
779
- if (!defined('DONOTCACHEPAGE'))
780
- define('DONOTCACHEPAGE', true);
781
-
782
- if (!defined('DONOTCACHEOBJECT'))
783
- define('DONOTCACHEOBJECT', true);
784
-
785
- if (!defined('DONOTCACHEDB'))
786
- define('DONOTCACHEDB', true);
787
-
788
- if (!headers_sent () && !is_user_logged_in ()) {
789
- header('Cache-Control: private, proxy-revalidate, s-maxage=0');
790
- }
791
- }
792
-
793
- function ai_toolbar_menu_items () {
794
- global $block_object, $ai_wp_data;
795
-
796
- if (isset ($ai_wp_data [AI_DEBUG_MENU_ITEMS])) return;
797
-
798
- $ai_wp_data [AI_DEBUG_MENU_ITEMS] = array ();
799
-
800
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) == 0) $debug_blocks = 1; else $debug_blocks = 0;
801
- $debug_blocks_class = $debug_blocks == 0 ? ' on' : '';
802
-
803
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) == 0) $debug_positions = 0; else $debug_positions = '';
804
- $debug_positions_class = $debug_positions === '' ? ' on' : '';
805
-
806
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) == 0) $debug_tags = 1; else $debug_tags = 0;
807
- $debug_tags_class = $debug_tags == 0 ? ' on' : '';
808
-
809
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) == 0) $debug_processing = 1; else $debug_processing = 0;
810
- $debug_processing_class = $debug_processing == 0 ? ' on' : '';
811
-
812
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) $debug_no_insertion = 1; else $debug_no_insertion = 0;
813
- $debug_no_insertion_class = $debug_no_insertion == 0 ? ' on' : '';
814
-
815
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING) == 0) $debug_ad_blocking = 1; else $debug_ad_blocking = 0;
816
- $debug_ad_blocking_class = $debug_ad_blocking == 0 ? ' on' : '';
817
-
818
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) == 0) $debug_ad_blocking_status = 1; else $debug_ad_blocking_status = 0;
819
- $debug_ad_blocking_status_class = $debug_ad_blocking_status == 0 ? ' on' : '';
820
-
821
- $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;
822
-
823
- $debug_settings_class = $debug_settings_on ? ' on' : '';
824
- $top_menu_url = $debug_settings_on ? add_query_arg (AI_URL_DEBUG, '0', remove_debug_parameters_from_url ()) :
825
- add_query_arg (array (AI_URL_DEBUG_BLOCKS => '1', AI_URL_DEBUG_POSITIONS => '0'), remove_debug_parameters_from_url ());
826
-
827
- $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
828
- 'id' => 'ai-toolbar',
829
- 'group' => true
830
- );
831
-
832
- $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
833
- 'id' => 'ai-toolbar-settings',
834
- // 'parent' => 'ai-toolbar',
835
- 'title' => '<span class="ab-icon'.$debug_settings_class.'"></span>'.AD_INSERTER_NAME,
836
- 'href' => $top_menu_url,
837
- );
838
-
839
- $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
840
- 'id' => 'ai-toolbar-blocks',
841
- 'parent' => 'ai-toolbar-settings',
842
- 'title' => '<span class="ab-icon'.$debug_blocks_class.'"></span>Label Blocks',
843
- 'href' => set_url_parameter (AI_URL_DEBUG_BLOCKS, $debug_blocks),
844
- );
845
-
846
- $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
847
- 'id' => 'ai-toolbar-positions',
848
- 'parent' => 'ai-toolbar-settings',
849
- 'title' => '<span class="ab-icon'.$debug_positions_class.'"></span>Show Positions',
850
- 'href' => set_url_parameter (AI_URL_DEBUG_POSITIONS, $debug_positions),
851
- );
852
-
853
- $paragraph_blocks = array ();
854
- for ($block = 0; $block <= AD_INSERTER_BLOCKS; $block ++) {
855
- $obj = $block_object [$block];
856
- $automatic_insertion = $obj->get_automatic_insertion();
857
- if ($block == 0 || $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH) {
858
-
859
- $block_tags = trim ($block_object [$block]->get_paragraph_tags ());
860
- $direction = $block_object [$block]->get_direction_type() == AD_DIRECTION_FROM_TOP ? 't' : 'b';
861
- $paragraph_min_words = intval ($obj->get_minimum_paragraph_words());
862
- $paragraph_max_words = intval ($obj->get_maximum_paragraph_words());
863
- $paragraph_text_type = $obj->get_paragraph_text_type ();
864
- $paragraph_text = trim (html_entity_decode ($obj->get_paragraph_text()));
865
- $inside_blockquote = $obj->get_count_inside_blockquote ();
866
-
867
- if ($block_tags != '') {
868
- $found = false;
869
- foreach ($paragraph_blocks as $index => $paragraph_block) {
870
- if ($paragraph_block ['tags'] == $block_tags &&
871
- $paragraph_block ['direction'] == $direction &&
872
- $paragraph_block ['min'] == $paragraph_min_words &&
873
- $paragraph_block ['max'] == $paragraph_max_words &&
874
- $paragraph_block ['text_type'] == $paragraph_text_type &&
875
- $paragraph_block ['text'] == $paragraph_text &&
876
- $paragraph_block ['blockquote'] == $inside_blockquote
877
- ) {
878
- $found = true;
879
- break;
880
- }
881
- }
882
- if ($found) array_push ($paragraph_blocks [$index]['blocks'], $block); else
883
- $paragraph_blocks []= array ('blocks' => array ($block),
884
- 'tags' => $block_tags,
885
- 'direction' => $direction,
886
- 'min' => $paragraph_min_words,
887
- 'max' => $paragraph_max_words,
888
- 'text_type' => $paragraph_text_type,
889
- 'text' => $paragraph_text,
890
- 'blockquote' => $inside_blockquote,
891
- );
892
- }
893
- }
894
- }
895
-
896
- $no_paragraph_counting_inside = get_no_paragraph_counting_inside ();
897
-
898
- foreach ($paragraph_blocks as $index => $paragraph_block) {
899
- $block_class = $debug_positions === '' && in_array ($ai_wp_data [AI_WP_DEBUG_BLOCK], $paragraph_block ['blocks']) ? ' on' : '';
900
- $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
901
- 'id' => 'ai-toolbar-positions-'.$index,
902
- 'parent' => 'ai-toolbar-positions',
903
- 'title' => '<span class="ab-icon'.$block_class.'"></span>'.
904
- $paragraph_block ['tags'].
905
- ($paragraph_block ['direction'] == 'b' ? ' <span class="dashicons dashicons-arrow-up-alt up-icon"></span>' : '').
906
- ($paragraph_block ['min'] != 0 ? ' min '.$paragraph_block ['min']. ' ' : '').
907
- ($paragraph_block ['max'] != 0 ? ' max '.$paragraph_block ['max']. ' ' : '').
908
- ($paragraph_block ['blockquote'] ? ' +[' . $no_paragraph_counting_inside . '] ' : '').
909
- ($paragraph_block ['text'] != '' ? ($paragraph_block ['text_type'] == AD_DO_NOT_CONTAIN ? ' NC ' : ' C ').' ['.htmlentities ($paragraph_block ['text']).']' : ''),
910
- 'href' => set_url_parameter (AI_URL_DEBUG_POSITIONS, $paragraph_block ['blocks'][0]),
911
- );
912
- }
913
-
914
- $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
915
- 'id' => 'ai-toolbar-tags',
916
- 'parent' => 'ai-toolbar-settings',
917
- 'title' => '<span class="ab-icon'.$debug_tags_class.'"></span>Show HTML Tags',
918
- 'href' => set_url_parameter (AI_URL_DEBUG_TAGS, $debug_tags),
919
- );
920
-
921
- $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
922
- 'id' => 'ai-toolbar-no-insertion',
923
- 'parent' => 'ai-toolbar-settings',
924
- 'title' => '<span class="ab-icon'.$debug_no_insertion_class.'"></span>Disable Insertion',
925
- 'href' => set_url_parameter (AI_URL_DEBUG_NO_INSERTION, $debug_no_insertion),
926
- );
927
-
928
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
929
- if ($ai_wp_data [AI_ADB_DETECTION]) {
930
- $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
931
- 'id' => 'ai-toolbar-adb-status',
932
- 'parent' => 'ai-toolbar-settings',
933
- 'title' => '<span class="ab-icon'.$debug_ad_blocking_status_class.'"></span>Ad Blocking Status',
934
- 'href' => set_url_parameter (AI_URL_DEBUG_AD_BLOCKING_STATUS, $debug_ad_blocking_status),
935
- );
936
-
937
- $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
938
- 'id' => 'ai-toolbar-adb',
939
- 'parent' => 'ai-toolbar-settings',
940
- 'title' => '<span class="ab-icon'.$debug_ad_blocking_class.'"></span>Simulate Ad Blocking',
941
- 'href' => set_url_parameter (AI_URL_DEBUG_AD_BLOCKING, $debug_ad_blocking),
942
- );
943
- }
944
- }
945
-
946
- $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
947
- 'id' => 'ai-toolbar-processing',
948
- 'parent' => 'ai-toolbar-settings',
949
- 'title' => '<span class="ab-icon'.$debug_processing_class.'"></span>Log Processing',
950
- 'href' => set_url_parameter (AI_URL_DEBUG_PROCESSING, $debug_processing),
951
- );
952
- }
953
-
954
- function ai_toolbar ($wp_admin_bar) {
955
- global $ai_wp_data;
956
-
957
- ai_toolbar_menu_items ();
958
-
959
- foreach ($ai_wp_data [AI_DEBUG_MENU_ITEMS] as $menu_item) {
960
- $wp_admin_bar->add_node ($menu_item);
961
- }
962
- }
963
-
964
- function set_user () {
965
- global $ai_wp_data;
966
-
967
- if ($ai_wp_data [AI_WP_USER_SET]) return;
968
-
969
- // $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN;
970
-
971
- if (is_user_logged_in ()) $ai_wp_data [AI_WP_USER] |= AI_USER_LOGGED_IN;
972
- if (current_user_role () >= 5) $ai_wp_data [AI_WP_USER] |= AI_USER_ADMINISTRATOR;
973
-
974
- // if (isset ($_GET [AI_URL_DEBUG_USER]) && $_GET [AI_URL_DEBUG_USER] != 0) $ai_wp_data [AI_WP_USER] = $_GET [AI_URL_DEBUG_USER];
975
-
976
- $ai_wp_data [AI_WP_USER_SET] = true;
977
- }
978
-
979
- function set_page_type () {
980
- global $ai_wp_data;
981
-
982
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_NONE) return;
983
-
984
- if (is_front_page ()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_HOMEPAGE;
985
- elseif (is_single()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_POST;
986
- elseif (is_page()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_STATIC;
987
- elseif (is_feed()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_FEED;
988
- elseif (is_category()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_CATEGORY;
989
- elseif (is_archive() || (is_home () && !is_front_page ())) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ARCHIVE;
990
- elseif (is_search()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_SEARCH;
991
- elseif (is_404()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_404;
992
- elseif (is_admin()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ADMIN;
993
-
994
- if (
995
- // AMP, Accelerated Mobile Pages
996
- function_exists ('is_amp_endpoint') && is_amp_endpoint () ||
997
-
998
- // WP AMP Ninja
999
- isset ($_GET ['wpamp']) ||
1000
-
1001
- // WP AMP - Accelerated Mobile Pages for WordPress
1002
- function_exists ('is_wp_amp') && is_wp_amp ()
1003
- ) {
1004
- $ai_wp_data [AI_WP_AMP_PAGE] = true;
1005
- define ('AI_AMP_PAGE', true);
1006
- }
1007
- }
1008
-
1009
- function ai_log_message ($message) {
1010
- global $ai_last_time, $ai_processing_log;
1011
- $ai_processing_log []= rtrim (sprintf ("%4d %-50s", (microtime (true) - $ai_last_time) * 1000, $message));
1012
- }
1013
-
1014
- function ai_log_filter_content ($content_string) {
1015
-
1016
- $content_string = preg_replace ("/\[\[AI_[A|B]P([\d].?)\]\]/", "", $content_string);
1017
- return str_replace (array ("<!--", "-->", "\n", "\r"), array ("[!--", "--]", "*n", "*r"), $content_string);
1018
- }
1019
-
1020
- function ai_log_content (&$content) {
1021
- if (strlen ($content) < 100) ai_log (ai_log_filter_content ($content) . ' ['.number_of_words ($content).']'); else
1022
- 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).']');
1023
- }
1024
-
1025
- function ai_block_insertion_status ($block, $ai_last_check) {
1026
- global $block_object;
1027
-
1028
- if ($block < 1 || $block > AD_INSERTER_BLOCKS) $block = 0;
1029
-
1030
- if ($ai_last_check == AI_CHECK_INSERTED) return "INSERTED";
1031
- $status = "FAILED CHECK: ";
1032
- $obj = $block_object [$block];
1033
- switch ($ai_last_check) {
1034
- case AI_CHECK_PAGE_TYPE_FRONT_PAGE: $status .= "ENABLED ON HOMEPAGE"; break;
1035
- case AI_CHECK_PAGE_TYPE_STATIC_PAGE: $status .= "ENABLED ON STATIC PAGE"; break;
1036
- case AI_CHECK_PAGE_TYPE_POST: $status .= "ENABLED ON POST"; break;
1037
- case AI_CHECK_PAGE_TYPE_CATEGORY: $status .= "ENABLED ON CATEGORY"; break;
1038
- case AI_CHECK_PAGE_TYPE_SEARCH: $status .= "ENABLED ON SEARCH"; break;
1039
- case AI_CHECK_PAGE_TYPE_ARCHIVE: $status .= "ENABLED ON ARCHIVE"; break;
1040
- case AI_CHECK_PAGE_TYPE_FEED: $status .= "ENABLED ON FEED"; break;
1041
- case AI_CHECK_PAGE_TYPE_404: $status .= "ENABLED ON 404"; break;
1042
-
1043
- case AI_CHECK_DESKTOP_DEVICES: $status .= "DESKTOP DEVICES"; break;
1044
- case AI_CHECK_MOBILE_DEVICES: $status .= "MOBILE DEVICES"; break;
1045
- case AI_CHECK_TABLET_DEVICES: $status .= "TABLET DEVICES"; break;
1046
- case AI_CHECK_PHONE_DEVICES: $status .= "PHONE DEVICES"; break;
1047
- case AI_CHECK_DESKTOP_TABLET_DEVICES: $status .= "DESKTOP TABLET DEVICES"; break;
1048
- case AI_CHECK_DESKTOP_PHONE_DEVICES: $status .= "DESKTOP PHONE DEVICES"; break;
1049
-
1050
- case AI_CHECK_CATEGORY: $status .= "CATEGORY"; break;
1051
- case AI_CHECK_TAG: $status .= "TAG"; break;
1052
- case AI_CHECK_TAXONOMY: $status .= "TAXONOMY"; break;
1053
- case AI_CHECK_ID: $status .= "ID"; break;
1054
- case AI_CHECK_URL: $status .= "URL"; break;
1055
- case AI_CHECK_URL_PARAMETER: $status .= "URL PARAMETER"; break;
1056
- case AI_CHECK_REFERER: $status .= "REFERER ". $obj->get_ad_domain_list(); break;
1057
- case AI_CHECK_IP_ADDRESS: $status .= "IP ADDRESS ". $obj->get_ad_ip_address_list(); break;
1058
- case AI_CHECK_COUNTRY: $status .= "COUNTRY ". $obj->get_ad_country_list (true); break;
1059
- case AI_CHECK_SCHEDULING: $status .= "SCHEDULING"; break;
1060
- case AI_CHECK_CODE: $status .= "CODE NOT EMPTY"; break;
1061
- case AI_CHECK_LOGGED_IN_USER: $status .= "LOGGED-IN USER"; break;
1062
- case AI_CHECK_NOT_LOGGED_IN_USER: $status .= "NOT LOGGED-IN USER"; break;
1063
- case AI_CHECK_ADMINISTRATOR: $status .= "ADMINISTRATOR"; break;
1064
-
1065
- case AI_CHECK_INDIVIDUALLY_DISABLED: $status .= "INDIVIDUALLY DISABLED"; break;
1066
- case AI_CHECK_INDIVIDUALLY_ENABLED: $status .= "INDIVIDUALLY ENABLED"; break;
1067
- case AI_CHECK_DISABLED_MANUALLY: $status .= "DISABLED BY HTML COMMENT"; break;
1068
-
1069
- case AI_CHECK_MAX_INSERTIONS: $status .= "MAX INSERTIONS " . $obj->get_maximum_insertions (); break;
1070
- case AI_CHECK_FILTER: $status .= ($obj->get_inverted_filter() ? 'INVERTED ' : '') . "FILTER " . $obj->get_call_filter(); break;
1071
- case AI_CHECK_PARAGRAPH_COUNTING: $status .= "PARAGRAPH COUNTING"; break;
1072
- case AI_CHECK_MIN_NUMBER_OF_WORDS: $status .= "MIN NUMBER OF WORDS " . intval ($obj->get_minimum_words()); break;
1073
- 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;
1074
- case AI_CHECK_DEBUG_NO_INSERTION: $status .= "DEBUG NO INSERTION"; break;
1075
- case AI_CHECK_PARAGRAPH_TAGS: $status .= "PARAGRAPH TAGS"; break;
1076
- case AI_CHECK_PARAGRAPHS_WITH_TAGS: $status .= "PARAGRAPHS WITH TAGS"; break;
1077
- case AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE: $status .= "PARAGRAPHS AFTER NO COUNTING INSIDE"; break;
1078
- case AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS: $status .= "PARAGRAPHS AFTER MIN MAX WORDS"; break;
1079
- case AI_CHECK_PARAGRAPHS_AFTER_TEXT: $status .= "PARAGRAPHS AFTER TEXT"; break;
1080
- case AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE: $status .= "PARAGRAPHS AFTER CLEARANCE"; break;
1081
- case AI_CHECK_PARAGRAPHS_MIN_NUMBER: $status .= "PARAGRAPHS MIN NUMBER"; break;
1082
- case AI_CHECK_PARAGRAPH_NUMBER: $status .= "PARAGRAPH NUMBER " . $obj->get_paragraph_number(); break;
1083
-
1084
- case AI_CHECK_DO_NOT_INSERT: $status .= "PARAGRAPH CLEARANCE"; break;
1085
- case AI_CHECK_AD_ABOVE: $status .= "PARAGRAPH CLEARANCE ABOVE"; break;
1086
- case AI_CHECK_AD_BELOW: $status .= "PARAGRAPH CLEARANCE BELOW"; break;
1087
- case AI_CHECK_SHORTCODE_ATTRIBUTES: $status .= "SHORTCODE ATTRIBUTES"; break;
1088
-
1089
- case AI_CHECK_ENABLED_PHP: $status .= "ENABLED PHP FUNCTION"; break;
1090
- case AI_CHECK_ENABLED_SHORTCODE: $status .= "ENABLED SHORTCODE"; break;
1091
- case AI_CHECK_ENABLED_WIDGET: $status .= "ENABLED WIDGET"; break;
1092
-
1093
- case AI_CHECK_NONE: $status = "BLOCK $block"; break;
1094
- default: $status .= "?"; break;
1095
- }
1096
- $ai_last_check = AI_CHECK_NONE;
1097
- return $status;
1098
- }
1099
-
1100
- function ai_log_block_status ($block, $ai_last_check) {
1101
- global $block_insertion_log, $ad_inserter_globals;
1102
-
1103
- if ($block < 1) return 'NO BLOCK SHORTCODE';
1104
-
1105
- $global_name = AI_BLOCK_COUNTER_NAME . $block;
1106
-
1107
- $block_status = ai_block_insertion_status ($block, $ai_last_check);
1108
- $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] . ']' : '');
1109
-
1110
- return "BLOCK $block " . $block_status;
1111
- }
1112
-
1113
- function ai_log ($message = "") {
1114
- global $ai_last_time, $ai_processing_log;
1115
-
1116
- if ($message != "") {
1117
- if ($message [strlen ($message) - 1] == "\n") {
1118
- ai_log_message (str_replace ("\n", "", $message));
1119
- $ai_processing_log []= "";
1120
- } else ai_log_message ($message);
1121
- } else $ai_processing_log []= "";
1122
- $ai_last_time = microtime (true);
1123
- }
1124
-
1125
- function remove_debug_parameters_from_url ($url = false) {
1126
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1127
- $parameters = array (AI_URL_DEBUG, AI_URL_DEBUG_PROCESSING, AI_URL_DEBUG_BLOCKS, AI_URL_DEBUG_USER, AI_URL_DEBUG_TAGS, AI_URL_DEBUG_POSITIONS, AI_URL_DEBUG_NO_INSERTION, AI_URL_DEBUG_AD_BLOCKING, AI_URL_DEBUG_AD_BLOCKING_STATUS);
1128
- } else
1129
- $parameters = array (AI_URL_DEBUG, AI_URL_DEBUG_PROCESSING, AI_URL_DEBUG_BLOCKS, AI_URL_DEBUG_USER, AI_URL_DEBUG_TAGS, AI_URL_DEBUG_POSITIONS, AI_URL_DEBUG_NO_INSERTION);
1130
-
1131
- return remove_query_arg ($parameters, $url);
1132
- }
1133
-
1134
- function set_url_parameter ($parameter, $value) {
1135
- return add_query_arg ($parameter, $value, remove_debug_parameters_from_url ());
1136
- }
1137
-
1138
- function number_of_words (&$content) {
1139
- $text = str_replace ("\r", "", $content);
1140
- $text = str_replace (array ("\n", " "), " ", $text);
1141
- $text = str_replace (" ", " ", $text);
1142
- $text = strip_tags ($text);
1143
- if ($text == '') return 0;
1144
- return count (explode (" ", $text));
1145
- }
1146
-
1147
- function ai_loop_check ($query, $action) {
1148
- global $ai_wp_data;
1149
-
1150
- $ai_wp_data [AI_CONTEXT] = $action == 'loop_start' ? AI_CONTEXT_BEFORE_POST : AI_CONTEXT_AFTER_POST;
1151
-
1152
- if ($ai_wp_data [AI_WP_AMP_PAGE]) return true;
1153
-
1154
- if (isset ($query) && method_exists ($query, 'is_main_query')) {
1155
- if ($query->is_main_query()) return true;
1156
- }
1157
-
1158
- return false;
1159
- }
1160
-
1161
-
1162
- function ai_buffering_start () {
1163
- global $ai_wp_data;
1164
-
1165
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1166
- ai_log ("BUFFERING START: level " . ob_get_level () );
1167
- }
1168
-
1169
- ob_start ();
1170
- define ('AI_BUFFERING_START', true);
1171
- }
1172
-
1173
- function ai_buffering_end () {
1174
- global $ai_wp_data, $ai_total_plugin_time, $ai_db_options_extract, $block_object;
1175
-
1176
- if (!defined ('AI_BUFFERING_START')) return;
1177
-
1178
- $page = ob_get_clean();
1179
-
1180
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1181
- ai_log ("BUFFERING END: level " . ob_get_level ());
1182
- $start_time = microtime (true);
1183
- }
1184
-
1185
- // TEST
1186
- // $page = ai_content_hook ($page);
1187
-
1188
- $matches = preg_split ('/(<body.*?'.'>)/i', $page, - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
1189
-
1190
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1191
- ai_log ("BUFFER body matches: " . count ($matches));
1192
- }
1193
-
1194
- if (count ($matches) == 3) {
1195
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1196
- ai_log ("BUFFER PROCESSING");
1197
- }
1198
-
1199
- $body = $matches [2];
1200
-
1201
- if (isset ($ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && class_exists ('DOMDocument')) {
1202
- require_once ('includes/phpQuery.php');
1203
-
1204
- $no_closing_tag = array ('img', 'hr', 'br');
1205
- $multibyte = get_paragraph_counting_functions() == AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS;
1206
-
1207
- foreach ($ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
1208
-
1209
- $obj = $block_object [$block];
1210
- $obj->clear_code_cache ();
1211
-
1212
- $insert_after = $obj->get_automatic_insertion () == AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT;
1213
- $selector = $obj->get_html_selector ();
1214
-
1215
- libxml_use_internal_errors(true);
1216
- $content = phpQuery::newDocumentHTML ($body);
1217
- libxml_use_internal_errors(false);
1218
- foreach (pq ($selector) as $element){
1219
- if ($insert_after)
1220
- pq ($element)->after (AI_MARKER_START.$element->tagName.AI_MARKER_END); else
1221
- pq ($element)->before (AI_MARKER_START.$element->tagName.AI_MARKER_END);
1222
- }
1223
-
1224
- $markers = preg_split ('/('.AI_MARKER_START.'.*?'.AI_MARKER_END.')/', $content->htmlOuter (), - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
1225
-
1226
- $content_before = '';
1227
- $insertions = array ();
1228
- foreach ($markers as $marker) {
1229
- if (strpos ($marker, AI_MARKER_START) === 0) {
1230
- $tag = str_replace (array (AI_MARKER_START, AI_MARKER_END), '', $marker);
1231
-
1232
- if ($insert_after && in_array ($tag, $no_closing_tag)) $tag_string = '>'; else
1233
- $tag_string = $insert_after ? "</{$tag}>" : "<{$tag}";
1234
-
1235
- preg_match_all ("#{$tag_string}#i", $content_before, $tag_matches);
1236
- $insertions []= array ($tag_string, $insert_after ? count ($tag_matches [0]) : count ($tag_matches [0]) + 1);
1237
- continue;
1238
- }
1239
- $content_before .= $marker;
1240
- }
1241
-
1242
- $insertion_offsets = array ();
1243
- foreach ($insertions as $insertion) {
1244
- $tag = $insertion [0];
1245
- $tag_counter = $insertion [1];
1246
- preg_match_all ("#$tag#i", $body, $org_tag_matches, PREG_OFFSET_CAPTURE);
1247
- if (isset ($org_tag_matches [0][$tag_counter - 1])) {
1248
- if ($insert_after)
1249
- $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1] + strlen ($tag); else
1250
- $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1];
1251
- }
1252
- }
1253
-
1254
- sort ($insertion_offsets);
1255
-
1256
- $new_content = '';
1257
- $current_offset = 0;
1258
- foreach ($insertion_offsets as $insertion_offset) {
1259
- if ($multibyte)
1260
- $new_content .= mb_substr ($body, $current_offset, $insertion_offset - $current_offset);
1261
- $new_content .= substr ($body, $current_offset, $insertion_offset - $current_offset);
1262
-
1263
- $current_offset = $insertion_offset;
1264
-
1265
- ob_start ();
1266
-
1267
- $action = ($insert_after ? 'after' : 'before') . '_html_element';
1268
- $action_name = ($insert_after ? 'After ' : 'Before ') . $selector;
1269
-
1270
- $ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] = array ($block);
1271
- ai_custom_hook ($action, $action_name);
1272
- unset ($ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]);
1273
-
1274
- $new_content .= ob_get_clean();
1275
- }
1276
- $new_content .= substr ($body, $current_offset);
1277
-
1278
- $body = $new_content;
1279
- }
1280
- }
1281
-
1282
- echo $matches [0], $matches [1];
1283
-
1284
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
1285
- $class = AI_DEBUG_STATUS_CLASS;
1286
- echo "<section class='$class'>OUTPUT BUFFERING</section>";
1287
- }
1288
-
1289
- ai_custom_hook ('above_header', 'Above Header');
1290
- echo $body;
1291
- } else echo $page;
1292
-
1293
- // echo ai_content_hook ($matches [2]);
1294
-
1295
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1296
- $ai_total_plugin_time += microtime (true) - $start_time;
1297
- ai_log ("BUFFERING END PROCESSING\n");
1298
- }
1299
- }
1300
-
1301
- function ai_post_check ($post, $action) {
1302
- global $ai_wp_data, $ad_inserter_globals;
1303
-
1304
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) return false;
1305
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) return false;
1306
-
1307
- // Not used on AMP pages (yet)
1308
- if (!$ai_wp_data [AI_WP_AMP_PAGE]) {
1309
- if (!in_the_loop()) return false;
1310
- }
1311
-
1312
- // Skip insertion before the first post
1313
- if (!defined ('AI_POST_CHECK')) {
1314
- define ('AI_POST_CHECK', true);
1315
- return false;
1316
- }
1317
-
1318
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BETWEEN_POSTS;
1319
-
1320
- return true;
1321
- }
1322
-
1323
-
1324
- function ai_content_marker () {
1325
- echo '<span class="ai-content"></span>', "\n";
1326
- }
1327
-
1328
- function ai_hook_function_loop_start ($hook_parameter) {
1329
- ai_custom_hook ('loop_start', AI_TEXT_BEFORE_POST, $hook_parameter, 'ai_loop_check');
1330
- }
1331
-
1332
- function ai_hook_function_loop_end ($hook_parameter) {
1333
- ai_custom_hook ('loop_end', AI_TEXT_AFTER_POST, $hook_parameter, 'ai_loop_check');
1334
- }
1335
-
1336
- function ai_hook_function_post ($hook_parameter) {
1337
- ai_custom_hook ('the_post', AI_TEXT_BETWEEN_POSTS, $hook_parameter, 'ai_post_check');
1338
- }
1339
-
1340
- function ai_hook_function_footer () {
1341
- ai_custom_hook ('wp_footer', AI_TEXT_FOOTER);
1342
- }
1343
-
1344
-
1345
- // Code for PHP VERSION >= 5.3.0
1346
- //function ai_get_custom_hook_function ($action, $name) {
1347
- // return function () use ($action, $name) {
1348
- // ai_custom_hook ($action, $name);
1349
- // };
1350
- //}
1351
-
1352
-
1353
- // Code for PHP VERSION < 5.3.0
1354
- function ai_custom_hook_function_0 () {
1355
- global $ai_custom_hooks;
1356
- ai_custom_hook ($ai_custom_hooks [0]['action'], $ai_custom_hooks [0]['name']);
1357
- }
1358
-
1359
- function ai_custom_hook_function_1 () {
1360
- global $ai_custom_hooks;
1361
- ai_custom_hook ($ai_custom_hooks [1]['action'], $ai_custom_hooks [1]['name']);
1362
- }
1363
-
1364
- function ai_custom_hook_function_2 () {
1365
- global $ai_custom_hooks;
1366
- ai_custom_hook ($ai_custom_hooks [2]['action'], $ai_custom_hooks [2]['name']);
1367
- }
1368
-
1369
- function ai_custom_hook_function_3 () {
1370
- global $ai_custom_hooks;
1371
- ai_custom_hook ($ai_custom_hooks [3]['action'], $ai_custom_hooks [3]['name']);
1372
- }
1373
-
1374
- function ai_custom_hook_function_4 () {
1375
- global $ai_custom_hooks;
1376
- ai_custom_hook ($ai_custom_hooks [4]['action'], $ai_custom_hooks [4]['name']);
1377
- }
1378
-
1379
- function ai_custom_hook_function_5 () {
1380
- global $ai_custom_hooks;
1381
- ai_custom_hook ($ai_custom_hooks [5]['action'], $ai_custom_hooks [5]['name']);
1382
- }
1383
-
1384
- function ai_custom_hook_function_6 () {
1385
- global $ai_custom_hooks;
1386
- ai_custom_hook ($ai_custom_hooks [6]['action'], $ai_custom_hooks [6]['name']);
1387
- }
1388
-
1389
- function ai_custom_hook_function_7 () {
1390
- global $ai_custom_hooks;
1391
- ai_custom_hook ($ai_custom_hooks [7]['action'], $ai_custom_hooks [7]['name']);
1392
- }
1393
-
1394
- function ai_custom_hook_function_8 () {
1395
- global $ai_custom_hooks;
1396
- ai_custom_hook ($ai_custom_hooks [8]['action'], $ai_custom_hooks [8]['name']);
1397
- }
1398
-
1399
- function ai_custom_hook_function_9 () {
1400
- global $ai_custom_hooks;
1401
- ai_custom_hook ($ai_custom_hooks [9]['action'], $ai_custom_hooks [9]['name']);
1402
- }
1403
-
1404
- function ai_wp_hook () {
1405
- global $ai_wp_data, $ai_db_options_extract, $ai_total_plugin_time, $ai_walker, $ai_custom_hooks;
1406
-
1407
- if (defined ('AI_WP_HOOK')) return;
1408
- define ('AI_WP_HOOK', true);
1409
-
1410
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1411
- ai_log ("WP HOOK START");
1412
- $start_time = microtime (true);
1413
- }
1414
-
1415
- set_page_type ();
1416
- set_user ();
1417
-
1418
- ai_http_header ();
1419
-
1420
- if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) ai_disable_caching ();
1421
-
1422
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_ADMIN &&
1423
- ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 &&
1424
- get_admin_toolbar_debugging () &&
1425
- (!is_multisite() || is_main_site () || multisite_settings_page_enabled ()))
1426
- add_action ('admin_bar_menu', 'ai_toolbar', 9920);
1427
-
1428
- $url_debugging = get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0;
1429
-
1430
- if (!is_admin() || defined ('DOING_AJAX')) {
1431
- if (isset ($_GET [AI_URL_DEBUG]) && $_GET [AI_URL_DEBUG] == 0) {
1432
- if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) {
1433
- unset ($_COOKIE ['AI_WP_DEBUGGING']);
1434
- setcookie ('AI_WP_DEBUGGING', '', time() - (15 * 60), COOKIEPATH);
1435
- }
1436
- if (isset ($_COOKIE ['AI_WP_DEBUG_BLOCK'])) {
1437
- unset ($_COOKIE ['AI_WP_DEBUG_BLOCK']);
1438
- setcookie ('AI_WP_DEBUG_BLOCK', '', time() - (15 * 60), COOKIEPATH);
1439
- }
1440
- } else {
1441
- $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];
1442
- $ai_wp_data [AI_WP_DEBUG_BLOCK] = isset ($_COOKIE ['AI_WP_DEBUG_BLOCK']) ? $_COOKIE ['AI_WP_DEBUG_BLOCK'] : 0;
1443
-
1444
- if (isset ($_GET [AI_URL_DEBUG_BLOCKS]))
1445
- 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;
1446
-
1447
- if (isset ($_GET [AI_URL_DEBUG_TAGS]))
1448
- 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;
1449
-
1450
- if (isset ($_GET [AI_URL_DEBUG_NO_INSERTION]))
1451
- 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;
1452
-
1453
- if (isset ($_GET [AI_URL_DEBUG_AD_BLOCKING_STATUS]))
1454
- 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;
1455
-
1456
- if (isset ($_GET [AI_URL_DEBUG_AD_BLOCKING]))
1457
- 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;
1458
-
1459
- if (isset ($_GET [AI_URL_DEBUG_POSITIONS])) {
1460
- if ($_GET [AI_URL_DEBUG_POSITIONS] !== '' && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_POSITIONS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_POSITIONS;
1461
- if (is_numeric ($_GET [AI_URL_DEBUG_POSITIONS])) $ai_wp_data [AI_WP_DEBUG_BLOCK] = intval ($_GET [AI_URL_DEBUG_POSITIONS]);
1462
- if ($ai_wp_data [AI_WP_DEBUG_BLOCK] < 0 || $ai_wp_data [AI_WP_DEBUG_BLOCK] > AD_INSERTER_BLOCKS) $ai_wp_data [AI_WP_DEBUG_BLOCK] = 0;
1463
- }
1464
-
1465
- if ($ai_wp_data [AI_WP_DEBUGGING] != 0)
1466
- setcookie ('AI_WP_DEBUGGING', $ai_wp_data [AI_WP_DEBUGGING], time() + AI_COOKIE_TIME, COOKIEPATH); else
1467
- if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) setcookie ('AI_WP_DEBUGGING', '', time() - (15 * 60), COOKIEPATH);
1468
-
1469
- if ($ai_wp_data [AI_WP_DEBUG_BLOCK] != 0)
1470
- setcookie ('AI_WP_DEBUG_BLOCK', $ai_wp_data [AI_WP_DEBUG_BLOCK], time() + AI_COOKIE_TIME, COOKIEPATH); else
1471
- if (isset ($_COOKIE ['AI_WP_DEBUG_BLOCK'])) setcookie ('AI_WP_DEBUG_BLOCK', '', time() - (15 * 60), COOKIEPATH);
1472
- }
1473
- }
1474
-
1475
- $debug_positions = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0;
1476
- $debug_tags_positions = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS)) != 0;
1477
- $debug_tags_positions_blocks = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS | AI_DEBUG_BLOCKS)) != 0;
1478
-
1479
- $plugin_priority = get_plugin_priority ();
1480
-
1481
- 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)
1482
- add_filter ('the_content', 'ai_content_hook', $plugin_priority);
1483
-
1484
- 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)
1485
- add_filter ('the_excerpt', 'ai_excerpt_hook', $plugin_priority);
1486
-
1487
- 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)
1488
- // add_action ('loop_start', 'ai_loop_start_hook');
1489
- add_action ('loop_start', 'ai_hook_function_loop_start');
1490
-
1491
- 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)
1492
- // add_action ('loop_end', 'ai_loop_end_hook');
1493
- add_action ('loop_end', 'ai_hook_function_loop_end');
1494
-
1495
- 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)
1496
- // add_action ('the_post', 'ai_post_hook');
1497
- add_action ('the_post', 'ai_hook_function_post');
1498
-
1499
- 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) ||
1500
- (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) ||
1501
- (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) ||
1502
- $debug_positions) {
1503
- $ai_wp_data [AI_NUMBER_OF_COMMENTS] = 0;
1504
- add_filter ('comments_array' , 'ai_comments_array', 10, 2);
1505
- add_filter ('wp_list_comments_args' , 'ai_wp_list_comments_args');
1506
- $ai_walker = new ai_Walker_Comment;
1507
- }
1508
-
1509
-
1510
- // Code for PHP VERSION >= 5.3.0
1511
- // foreach ($ai_custom_hooks as $index => $custom_hook) {
1512
- // 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)
1513
- // add_action ($custom_hook ['action'], ai_get_custom_hook_function ($custom_hook ['action'], $custom_hook ['name']), $custom_hook ['priority']);
1514
- // }
1515
-
1516
- // Code for PHP VERSION < 5.3.0
1517
- foreach ($ai_custom_hooks as $index => $custom_hook) {
1518
- if ($index > 9) break;
1519
-
1520
- // Skip custom hooks on standard WP hooks - they will be processed anyway
1521
- switch ($custom_hook ['action']) {
1522
- case 'wp_footer':
1523
- case 'wp_head':
1524
- case 'the_content':
1525
- case 'the_excerpt':
1526
- case 'loop_start':
1527
- case 'loop_end':
1528
- case 'the_post':
1529
- continue 2;
1530
- }
1531
-
1532
- 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)
1533
- add_action ($custom_hook ['action'], 'ai_custom_hook_function_' . $index, $custom_hook ['priority']);
1534
- }
1535
-
1536
- if ($ai_wp_data [AI_STICK_TO_THE_CONTENT]) {
1537
- add_action ('loop_start', 'ai_content_marker');
1538
- add_action ('loop_end', 'ai_content_marker');
1539
- add_action ('get_sidebar', 'ai_content_marker');
1540
- }
1541
-
1542
- if ($ai_wp_data [AI_WP_AMP_PAGE] ) {
1543
- // AMP, Accelerated Mobile Pages
1544
- add_action ('amp_post_template_head', 'ai_amp_head_hook', 99999);
1545
- add_action ('amp_post_template_css', 'ai_amp_css_hook', 99999);
1546
-
1547
- // WP AMP Ninja
1548
- add_action ('wpamp_custom_script', 'ai_amp_head_hook', 99999);
1549
- // No usable hook for custom CSS
1550
- // add_action ('wpamp_custom_style', 'ai_amp_css_hook', 99999);
1551
-
1552
- // WP AMP - Accelerated Mobile Pages for WordPress
1553
- add_action ('amphtml_template_head', 'ai_amp_head_hook', 99999);
1554
- add_action ('amphtml_template_css', 'ai_amp_css_hook', 99999);
1555
- } else
1556
- // WP
1557
- add_action ('wp_head', 'ai_wp_head_hook', 99999);
1558
-
1559
- $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;
1560
- if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1561
- // AMP, Accelerated Mobile Pages
1562
- if ($automatic_insertion_footer_hook)
1563
- add_action ('amp_post_template_footer', 'ai_hook_function_footer', 5);
1564
- add_action ('amp_post_template_footer', 'ai_amp_footer_hook', 5);
1565
-
1566
- // WP AMP Ninja
1567
- if ($automatic_insertion_footer_hook)
1568
- add_action ('wpamp_google_analytics_code', 'ai_hook_function_footer', 5);
1569
- add_action ('wpamp_google_analytics_code', 'ai_amp_footer_hook', 5);
1570
-
1571
- // WP AMP - Accelerated Mobile Pages for WordPress
1572
- if ($automatic_insertion_footer_hook)
1573
- add_action ('amphtml_after_footer', 'ai_hook_function_footer', 5);
1574
- add_action ('amphtml_after_footer', 'ai_amp_footer_hook', 5);
1575
- } else {
1576
- // WP
1577
- if ($automatic_insertion_footer_hook)
1578
- add_action ('wp_footer', 'ai_hook_function_footer', 5);
1579
- add_action ('wp_footer', 'ai_wp_footer_hook', 5);
1580
- }
1581
-
1582
- if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1583
- // No scripts on AMP pages
1584
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1585
- $ai_wp_data [AI_ADB_DETECTION] = false;
1586
- $ai_wp_data [AI_TRACKING] = false;
1587
- }
1588
- }
1589
-
1590
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1591
- $ai_total_plugin_time += microtime (true) - $start_time;
1592
- ai_log ("WP HOOK END\n");
1593
- }
1594
- };
1595
-
1596
- function ai_init_hook() {
1597
- global $block_object, $ai_wp_data, $ai_db_options_extract;
1598
-
1599
- if (defined ('DOING_AJAX') && DOING_AJAX) {
1600
- $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_AJAX;
1601
-
1602
- ai_wp_hook ();
1603
- }
1604
-
1605
- add_shortcode ('adinserter', 'ai_process_shortcodes');
1606
- add_shortcode ('ADINSERTER', 'ai_process_shortcodes');
1607
-
1608
- add_filter ('pre_do_shortcode_tag', 'ai_pre_do_shortcode_tag', 10, 4);
1609
- }
1610
-
1611
- function ai_wp_loaded_hook () {
1612
- global $ai_db_options, $ai_db_options_extract, $version_string;
1613
-
1614
- if (isset ($ai_db_options [AI_OPTION_EXTRACT]) &&
1615
- isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] == $version_string &&
1616
- isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS]) &&
1617
- isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS][AI_PT_AJAX]) &&
1618
- isset ($ai_db_options [AI_OPTION_EXTRACT][BETWEEN_COMMENTS_HOOK_BLOCKS]) &&
1619
- isset ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) &&
1620
- @unserialize ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) !== false &&
1621
- isset ($ai_db_options [AI_OPTION_EXTRACT][FOOTER_HOOK_BLOCKS]))
1622
- $ai_db_options_extract = $ai_db_options [AI_OPTION_EXTRACT]; else
1623
- $ai_db_options_extract = ai_generate_extract ($ai_db_options);
1624
- }
1625
-
1626
- function ai_admin_menu_hook () {
1627
- global $ai_settings_page;
1628
-
1629
- if (is_multisite() && !is_main_site () && !multisite_settings_page_enabled ()) return;
1630
-
1631
- $ai_settings_page = add_submenu_page ('options-general.php', AD_INSERTER_NAME.' Options', AD_INSERTER_NAME, 'manage_options', basename(__FILE__), 'ai_settings');
1632
- add_action ('admin_enqueue_scripts', 'ai_admin_enqueue_scripts');
1633
- // add_action ('admin_head', 'ai_admin_head');
1634
- add_filter ('clean_url', 'ai_clean_url', 999999, 2);
1635
- }
1636
-
1637
- function ai_admin_head () {
1638
- global $ai_settings_page, $hook_suffix;
1639
-
1640
- // if ($hook_suffix == $ai_settings_page && wp_is_mobile()) {
1641
- // echo "<meta name='viewport' content='width=762'>\n";
1642
- // }
1643
- }
1644
-
1645
- function ai_admin_enqueue_scripts ($hook_suffix) {
1646
- global $ai_settings_page;
1647
-
1648
- if ($hook_suffix == $ai_settings_page) {
1649
- wp_enqueue_style ('ai-admin-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), array (), null);
1650
-
1651
- if (function_exists ('ai_admin_enqueue_scripts_1')) ai_admin_enqueue_scripts_1 ();
1652
-
1653
- wp_enqueue_style ('ai-admin-multi-select', plugins_url ('css/multi-select.css', AD_INSERTER_FILE), array (), AD_INSERTER_VERSION);
1654
- wp_enqueue_style ('ai-image-picker', plugins_url ('css/image-picker.css', __FILE__), array (), AD_INSERTER_VERSION);
1655
- wp_add_inline_style ('ai-image-picker', '.thumbnail {border-radius: 6px;}');
1656
-
1657
- wp_enqueue_style ('ai-combobox-css', plugins_url ('css/jquery.scombobox.min.css', __FILE__), array (), AD_INSERTER_VERSION);
1658
-
1659
- wp_enqueue_style ('ai-admin-css', plugins_url ('css/ad-inserter.css', __FILE__), array (), AD_INSERTER_VERSION);
1660
-
1661
- wp_add_inline_style ('ai-admin-css', '.notice {margin: 5px 15px 15px 0;}');
1662
-
1663
- if (function_exists ('ai_admin_enqueue_scripts_2')) ai_admin_enqueue_scripts_2 ();
1664
-
1665
- wp_enqueue_script ('ai-multi-select', plugins_url ('includes/js/jquery.multi-select.js', AD_INSERTER_FILE ), array (), AD_INSERTER_VERSION, true);
1666
- wp_enqueue_script ('ai-quicksearch', plugins_url ('includes/js/jquery.quicksearch.js', AD_INSERTER_FILE ), array (), AD_INSERTER_VERSION, true);
1667
-
1668
- // Located in the header to load datepicker js file to prevent error when async tags used
1669
- wp_enqueue_script ('ai-image-picker-js', plugins_url ('includes/js/image-picker.min.js', __FILE__ ), array (
1670
- 'jquery',
1671
- 'jquery-ui-datepicker',
1672
- ), AD_INSERTER_VERSION, false);
1673
-
1674
- if (AI_SYNTAX_HIGHLIGHTING) {
1675
- wp_enqueue_script ('ai-ace', plugins_url ('includes/ace/ace.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1676
- // wp_enqueue_script ('ai-ace-ext-modelist', plugins_url ('includes/ace/ext-modelist.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1677
- wp_enqueue_script ('ai-ace-html', plugins_url ('includes/ace/mode-html.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1678
- wp_enqueue_script ('ai-ace-php', plugins_url ('includes/ace/mode-php.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1679
-
1680
- if (get_syntax_highlighter_theme () == AI_SYNTAX_HIGHLIGHTER_THEME || isset ($_POST ["syntax-highlighter-theme"]) && $_POST ["syntax-highlighter-theme"] == AI_SYNTAX_HIGHLIGHTER_THEME)
1681
- wp_enqueue_script ('ai-ace-theme', plugins_url ('includes/ace/theme-ad_inserter.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1682
- }
1683
-
1684
- wp_enqueue_script ('ai-admin-js', plugins_url ('js/ad-inserter.js', __FILE__), array (
1685
- 'jquery',
1686
- 'jquery-ui-tabs',
1687
- 'jquery-ui-button',
1688
- 'jquery-ui-tooltip',
1689
- 'jquery-ui-datepicker',
1690
- 'jquery-ui-dialog',
1691
- ), AD_INSERTER_VERSION, true);
1692
-
1693
- wp_enqueue_script ('ai-combobox', plugins_url ('includes/js/jquery.scombobox.min.js', __FILE__), array (
1694
- 'jquery',
1695
- ), AD_INSERTER_VERSION , true);
1696
- wp_enqueue_script ('ai-missed', plugins_url ('includes/js/missed.js', __FILE__), array (), AD_INSERTER_VERSION , true);
1697
- }
1698
-
1699
- wp_enqueue_style ('ai-admin-css-gen', plugins_url ('css/ai-admin.css', __FILE__), array (), AD_INSERTER_VERSION);
1700
- wp_enqueue_script ('ai-admin-js-gen', plugins_url ('includes/js/ai-admin.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1701
- }
1702
-
1703
- function ai_wp_enqueue_scripts_hook () {
1704
- global $ai_wp_data;
1705
-
1706
- $footer_inline_scripts =
1707
- get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE ||
1708
- $ai_wp_data [AI_TRACKING] ||
1709
- $ai_wp_data [AI_STICKY_WIDGETS] ||
1710
- $ai_wp_data [AI_STICK_TO_THE_CONTENT] ||
1711
- $ai_wp_data [AI_CLOSE_BUTTONS] ||
1712
- (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION]);
1713
-
1714
- if ($footer_inline_scripts || $ai_wp_data [AI_CLIENT_SIDE_INSERTION] || $ai_wp_data [AI_FRONTEND_JS_DEBUGGING] || ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_BLOCKS)) != 0) {
1715
- // force loading of jquery on frontend
1716
- wp_enqueue_script ('ai-jquery-js', plugins_url ('includes/js/ai-jquery.js', __FILE__ ), array (
1717
- 'jquery',
1718
- ));
1719
- if ($ai_wp_data [AI_FRONTEND_JS_DEBUGGING]) {
1720
- wp_add_inline_script ('ai-jquery-js', 'ai_debugging = true;');
1721
- }
1722
- if ($ai_wp_data [AI_CLIENT_SIDE_INSERTION]) {
1723
- wp_add_inline_script ('ai-jquery-js', ai_get_js ('ai-insert', false));
1724
- }
1725
-
1726
- if (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) {
1727
- wp_enqueue_style ('dashicons');
1728
- }
1729
- }
1730
- }
1731
-
1732
- function ai_clean_url ( $url, $original_url){
1733
- if (strpos ($url, 'async=') !== false && strpos ($url, '/plugins/ad-inserter') !== false) {
1734
- // $url = $original_url;
1735
- $url = str_replace ("' async='async", '', $url);
1736
- }
1737
- return $url;
1738
- }
1739
-
1740
- function add_head_inline_styles_and_scripts () {
1741
- global $ai_wp_data;
1742
-
1743
- if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] ||
1744
- get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE ||
1745
- get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) ||
1746
- $ai_wp_data [AI_WP_DEBUGGING] != 0) {
1747
-
1748
- echo "<style type='text/css'>\n";
1749
-
1750
- if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION]) echo get_viewport_css ();
1751
-
1752
- if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
1753
- echo ".ai-rotate {position: relative;}\n";
1754
- echo ".ai-rotate-option {visibility: hidden;}\n";
1755
- echo ".ai-rotate-options {visibility: hidden; position: absolute; top: 0; left: 0; width: 100%; height: 100%;}\n";
1756
- echo ".ai-ip-data, .ai-ip-data-block {visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999;}\n";
1757
- }
1758
-
1759
- if ($ai_wp_data [AI_CLOSE_BUTTONS]) {
1760
- echo ".ai-close {position: relative;}\n";
1761
- // echo ".ai-close-width {width: auto !important;}\n";
1762
- echo ".ai-close-button {position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; background: url(".plugins_url ('css/images/close-button.png', AD_INSERTER_FILE).") no-repeat center center; cursor: pointer; z-index: 9; display: none;}\n";
1763
- echo ".ai-close-show {display: block;}\n";
1764
- echo ".ai-close-left {right: unset; left: -10px;}\n";
1765
- echo ".ai-close-bottom {top: unset; bottom: -11px;}\n";
1766
- }
1767
-
1768
- // if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES)
1769
- echo get_alignment_css ();
1770
-
1771
- // After alignment CSS to override width
1772
- if ($ai_wp_data [AI_CLOSE_BUTTONS]) {
1773
- echo ".ai-close-fit {width: fit-content; width: -moz-fit-content;}\n";
1774
- }
1775
-
1776
- if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css ();
1777
-
1778
- if (get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0))
1779
- echo "#wp-admin-bar-ai-toolbar-settings .ab-icon:before {
1780
- content: '\\f111';
1781
- top: 2px;
1782
- color: rgba(240,245,250,.6)!important;
1783
- }
1784
- #wp-admin-bar-ai-toolbar-settings-default .ab-icon:before {
1785
- top: 0px;
1786
- }
1787
- #wp-admin-bar-ai-toolbar-settings .ab-icon.on:before {
1788
- color: #00f200!important;
1789
- }
1790
- #wp-admin-bar-ai-toolbar-settings-default li, #wp-admin-bar-ai-toolbar-settings-default a,
1791
- #wp-admin-bar-ai-toolbar-settings-default li:hover, #wp-admin-bar-ai-toolbar-settings-default a:hover {
1792
- border: 1px solid transparent;
1793
- }
1794
- #wp-admin-bar-ai-toolbar-blocks .ab-icon:before {
1795
- content: '\\f135';
1796
- }
1797
- #wp-admin-bar-ai-toolbar-positions .ab-icon:before {
1798
- content: '\\f207';
1799
- }
1800
- #wp-admin-bar-ai-toolbar-positions-default .ab-icon:before {
1801
- content: '\\f522';
1802
- }
1803
- #wp-admin-bar-ai-toolbar-tags .ab-icon:before {
1804
- content: '\\f475';
1805
- }
1806
- #wp-admin-bar-ai-toolbar-no-insertion .ab-icon:before {
1807
- content: '\\f214';
1808
- }
1809
- #wp-admin-bar-ai-toolbar-adb-status .ab-icon:before {
1810
- content: '\\f223';
1811
- }
1812
- #wp-admin-bar-ai-toolbar-adb .ab-icon:before {
1813
- content: '\\f160';
1814
- }
1815
- #wp-admin-bar-ai-toolbar-processing .ab-icon:before {
1816
- content: '\\f464';
1817
- }
1818
- #wp-admin-bar-ai-toolbar-positions span.up-icon {
1819
- padding-top: 2px;
1820
- }
1821
- #wp-admin-bar-ai-toolbar-positions .up-icon:before {
1822
- font: 400 20px/1 dashicons;
1823
- }
1824
- ";
1825
-
1826
- echo "</style>\n";
1827
- // No scripts on AMP pages
1828
- }
1829
- }
1830
-
1831
- function ai_get_js ($js_name, $replace_js_data = true) {
1832
- global $ai_wp_data;
1833
-
1834
- if ($ai_wp_data [AI_FRONTEND_JS_DEBUGGING]) {
1835
- $script = file_get_contents (AD_INSERTER_PLUGIN_DIR."includes/js/$js_name.js");
1836
- } else $script = file_get_contents (AD_INSERTER_PLUGIN_DIR."includes/js/$js_name.min.js");
1837
- if (!$replace_js_data) return $script;
1838
- return ai_replace_js_data ($script, $js_name);
1839
- }
1840
-
1841
- function ai_replace_js_data ($js) {
1842
- global $block_object, $ai_wp_data;
1843
-
1844
- if (preg_match_all ('/AI_CONST_([_A-Z0-9]+)/', $js, $match)) {
1845
- foreach ($match [1] as $index => $constant) {
1846
- if (defined ($constant))
1847
- $js = str_replace ($match [0][$index], constant ($constant), $js);
1848
- }
1849
- }
1850
-
1851
- if (preg_match_all ('/AI_DATA_([_A-Z0-9]+)/', $js, $match)) {
1852
- foreach ($match [1] as $index => $constant) {
1853
- if (defined ($constant) && isset ($ai_wp_data [constant ($constant)]))
1854
- $js = str_replace ($match [0][$index], $ai_wp_data [constant ($constant)], $js);
1855
- }
1856
- }
1857
-
1858
- if (preg_match_all ('/AI_DATAB_([_A-Z0-9]+)/', $js, $match)) {
1859
- foreach ($match [1] as $index => $constant) {
1860
- if (defined ($constant) && isset ($ai_wp_data [constant ($constant)]))
1861
- $js = str_replace ($match [0][$index], $ai_wp_data [constant ($constant)] ? 1 : 0, $js);
1862
- }
1863
- }
1864
-
1865
- if (preg_match_all ('/AI_DBG_([_A-Z0-9]+)/', $js, $match)) {
1866
- foreach ($match [1] as $index => $constant) {
1867
- if (defined ($constant))
1868
- $js = str_replace ($match [0][$index], ($ai_wp_data [AI_WP_DEBUGGING] & constant ($constant)) != 0 ? 1 : 0, $js);
1869
- }
1870
- }
1871
-
1872
- if (preg_match_all ('/AI_FUNC_([_A-Z0-9]+)/', $js, $match)) {
1873
- foreach ($match [1] as $index => $function) {
1874
- $function = strtolower ($function);
1875
- if (function_exists ($function))
1876
- $js = str_replace ($match [0][$index], call_user_func ($function), $js);
1877
- }
1878
- }
1879
-
1880
- if (preg_match_all ('/AI_FUNCB_([_A-Z0-9]+)/', $js, $match)) {
1881
- foreach ($match [1] as $index => $function) {
1882
- $function = strtolower ($function);
1883
- if (function_exists ($function))
1884
- $js = str_replace ($match [0][$index], call_user_func ($function) ? 1 : 0, $js);
1885
- }
1886
- }
1887
-
1888
- if (preg_match_all ('/AI_FUNCT_([_A-Z0-9]+)/', $js, $match)) {
1889
- foreach ($match [1] as $index => $function) {
1890
- $function = strtolower ($function);
1891
- if (function_exists ($function))
1892
- $js = str_replace ($match [0][$index], call_user_func ($function, true), $js);
1893
- }
1894
- }
1895
-
1896
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1897
- if (strpos ($js, 'AI_ADB_STATUS_MESSAGE') !== false) {
1898
- $adb = $block_object [AI_ADB_MESSAGE_OPTION_NAME];
1899
-
1900
- $js = str_replace ('AI_ADB_OVERLAY_WINDOW', "jQuery ('<div>', {attr: {'style': jQuery.base64Decode ('" . base64_encode (str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), AI_BASIC_ADB_OVERLAY_CSS) . get_overlay_css ()) . "')}})", $js);
1901
- $js = str_replace ('AI_ADB_MESSAGE_WINDOW', "jQuery ('<div>', {attr: {'style': jQuery.base64Decode ('" . base64_encode (str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), AI_BASIC_ADB_MESSAGE_CSS) . get_message_css ()) . "')}, 'html': jQuery.base64Decode ('" .
1902
- base64_encode (str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), do_shortcode ($adb->ai_getCode ()))) . "')})", $js);
1903
-
1904
- // $js = str_replace ('AI_ADB_SELECTORS', str_replace (' ', '', get_adb_selectors (true)), $js);
1905
- $js = str_replace ('AI_ADB_SELECTORS', get_adb_selectors (true), $js);
1906
-
1907
- $redirection_page = get_redirection_page ();
1908
- if ($redirection_page != 0) $url = get_permalink ($redirection_page); else $url = trim (get_custom_redirection_url ());
1909
- $js = str_replace ('AI_ADB_REDIRECTION_PAGE', $url, $js);
1910
-
1911
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) != 0) {
1912
- $js = str_replace ('var AI_ADB_STATUS_MESSAGE=1', '$("#ai-adb-status").text ("DETECTED, " + d1 + " PAGE VIEW" + (d1 == 1 ? "" : "S") + " - NO ACTION");', $js);
1913
- $js = str_replace ('var AI_ADB_STATUS_MESSAGE=2', '$("#ai-adb-status").text ("DETECTED, COOKIE DETECTED - NO ACTION");', $js);
1914
- $js = str_replace ('var AI_ADB_STATUS_MESSAGE=3', '$("#ai-adb-status").text ("DETECTED - ACTION");', $js);
1915
- $js = str_replace ('var AI_ADB_STATUS_MESSAGE=4', 'jQuery("#ai-adb-status").text ("NOT DETECTED");', $js);
1916
- $js = str_replace ('var AI_ADB_STATUS_MESSAGE=5', '$("#ai-adb-status").text ("COOKIES DELETED");', $js);
1917
- } else {
1918
- $js = str_replace ('var AI_ADB_STATUS_MESSAGE=1', '', $js);
1919
- $js = str_replace ('var AI_ADB_STATUS_MESSAGE=2', '', $js);
1920
- $js = str_replace ('var AI_ADB_STATUS_MESSAGE=3', '', $js);
1921
- $js = str_replace ('var AI_ADB_STATUS_MESSAGE=4', '{}', $js);
1922
- $js = str_replace ('var AI_ADB_STATUS_MESSAGE=5', '', $js);
1923
- }
1924
- }
1925
- }
1926
-
1927
- $js = str_replace ('AI_NONCE', wp_create_nonce ("adinserter_data"), $js);
1928
- $js = str_replace ('AI_AJAXURL', admin_url ('admin-ajax.php'), $js);
1929
- $js = str_replace ('AI_SITE_URL', wp_make_link_relative (get_site_url()), $js);
1930
- if (defined ('AI_STATISTICS') && AI_STATISTICS) {
1931
- $js = str_replace ('AI_INTERNAL_TRACKING', get_internal_tracking () == AI_ENABLED ? 1 : 0, $js);
1932
- $js = str_replace ('AI_EXTERNAL_TRACKING', get_external_tracking () == AI_ENABLED ? 1 : 0, $js);
1933
- $js = str_replace ('AI_TRACK_PAGEVIEWS', get_track_pageviews () == AI_TRACKING_ENABLED ? 1 : 0, $js);
1934
- $js = str_replace ('AI_ADVANCED_CLICK_DETECTION', get_click_detection () == AI_CLICK_DETECTION_ADVANCED ? 1 : 0, $js);
1935
-
1936
- if (!isset ($ai_wp_data [AI_VIEWPORTS])) {
1937
- $viewports = array ();
1938
- $viewport_names = array ();
1939
- for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1940
- $viewport_name = get_viewport_name ($viewport);
1941
- $viewport_width = get_viewport_width ($viewport);
1942
- if ($viewport_name != '') {
1943
- $viewports [$viewport] = $viewport_width;
1944
- $viewport_names [$viewport] = $viewport_name;
1945
- }
1946
- }
1947
- $ai_wp_data [AI_VIEWPORTS] = $viewports;
1948
- $ai_wp_data [AI_VIEWPORT_NAMES] = $viewport_names;
1949
- }
1950
- $js = str_replace ('AI_VIEWPORTS', '[' . implode (',', $ai_wp_data [AI_VIEWPORTS]) . ']', $js);
1951
- $js = str_replace ('AI_VIEWPORT_NAMES', base64_encode ('["' . implode ('","', $ai_wp_data [AI_VIEWPORT_NAMES]) . '"]'), $js);
1952
- }
1953
- // Deprecated
1954
- $js = str_replace ('AI_BLOCK_CLASS_NAME', get_block_class_name (true), $js);
1955
-
1956
- if (function_exists ('ai_replace_js_data_2')) ai_replace_js_data_2 ($js);
1957
-
1958
- return $js;
1959
- }
1960
-
1961
- function ai_adb_code () {
1962
- return ai_get_js ('ai-adb', false);
1963
- }
1964
-
1965
- function add_footer_inline_scripts () {
1966
- global $ai_wp_data, $wp_version;
1967
-
1968
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1969
-
1970
- if ($ai_wp_data [AI_ADB_DETECTION]) {
1971
- if (function_exists ('add_footer_inline_scripts_1')) add_footer_inline_scripts_1 (); else {
1972
- echo '<div id="banner-advert-container" class="ad-inserter chitika-ad" style="position:absolute; z-index: -10; height: 1px; width: 1px; top: -1px; left: -1px;"><img id="adsense" class="SponsorAds adsense" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"></div>', "\n";
1973
- echo "<script type='text/javascript' src='", plugins_url ('js/ads.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
1974
- echo "<script type='text/javascript' src='", plugins_url ('js/sponsors.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
1975
- }
1976
- }
1977
-
1978
- }
1979
-
1980
- $footer_inline_scripts =
1981
- get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE ||
1982
- $ai_wp_data [AI_TRACKING] ||
1983
- $ai_wp_data [AI_STICKY_WIDGETS] ||
1984
- $ai_wp_data [AI_STICK_TO_THE_CONTENT] ||
1985
- $ai_wp_data [AI_CLOSE_BUTTONS] ||
1986
- (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION]);
1987
-
1988
- if (($footer_inline_scripts || $ai_wp_data [AI_CLIENT_SIDE_INSERTION]) && !wp_script_is ('jquery', 'done')) {
1989
- // Should not insert as it is forced in the header if jquery needed in the footer
1990
- echo "<script type='text/javascript' src='", includes_url ('js/jquery/jquery.js'), "?ver=", $wp_version, "'></script>\n";
1991
- echo "<script type='text/javascript' src='", includes_url ('js/jquery/jquery-migrate.min.js'), "?ver=", $wp_version, "'></script>\n";
1992
- }
1993
-
1994
- if ($ai_wp_data [AI_STICKY_WIDGETS] && get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_JS) {
1995
- // echo "<script type='text/javascript' src='", plugins_url ('includes/js/ResizeSensor.min.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
1996
- echo "<script type='text/javascript' src='", plugins_url ('includes/js/theia-sticky-sidebar.min.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
1997
- }
1998
-
1999
- if ($footer_inline_scripts) echo "<script type='text/javascript'>\n";
2000
-
2001
- if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
2002
- echo ai_get_js ('ai-rotate');
2003
- }
2004
-
2005
- if ($ai_wp_data [AI_STICKY_WIDGETS]) {
2006
- echo ai_get_js ('ai-sidebar');
2007
- }
2008
-
2009
- if ($ai_wp_data [AI_STICK_TO_THE_CONTENT]) {
2010
- echo ai_get_js ('ai-sticky');
2011
- }
2012
-
2013
- if ($ai_wp_data [AI_CLOSE_BUTTONS]) {
2014
- echo ai_get_js ('ai-close');
2015
- }
2016
-
2017
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
2018
- if ($ai_wp_data [AI_ADB_DETECTION]) {
2019
- if (!function_exists ('add_footer_inline_scripts_2')) echo ai_replace_js_data (ai_adb_code ());
2020
- }
2021
- }
2022
-
2023
- if (function_exists ('add_footer_inline_scripts_2')) {
2024
- add_footer_inline_scripts_2 ();
2025
- }
2026
-
2027
- if ($footer_inline_scripts) echo "\n</script>\n";
2028
- }
2029
-
2030
- function ai_admin_notice_hook () {
2031
- global $current_screen, $ai_db_options, $ai_wp_data, $ai_db_options_extract;
2032
- global $ai_settings_page, $hook_suffix;
2033
-
2034
- // $sidebar_widgets = wp_get_sidebars_widgets();
2035
- // $sidebars_with_deprecated_widgets = array ();
2036
-
2037
- // foreach ($sidebar_widgets as $sidebar_widget_index => $sidebar_widget) {
2038
- // if (is_array ($sidebar_widget))
2039
- // foreach ($sidebar_widget as $widget) {
2040
- // if (preg_match ("/ai_widget([\d]+)/", $widget, $widget_number)) {
2041
- // if (isset ($widget_number [1]) && is_numeric ($widget_number [1])) {
2042
- // $is_widget = $ai_db_options [$widget_number [1]][AI_OPTION_AUTOMATIC_INSERTION] == AD_SELECT_WIDGET;
2043
- // } else $is_widget = false;
2044
- // $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_widget_index]['name'];
2045
- // if ($is_widget && $sidebar_name != "")
2046
- // $sidebars_with_deprecated_widgets [$sidebar_widget_index] = $sidebar_name;
2047
- // }
2048
- // }
2049
- // }
2050
-
2051
- // if (!empty ($sidebars_with_deprecated_widgets)) {
2052
- // echo "<div class='notice notice-warning'><p><strong>Warning</strong>: You are using deprecated Ad Inserter widgets in the following sidebars: ",
2053
- // implode (", ", $sidebars_with_deprecated_widgets),
2054
- // ". Please replace them with the new 'Ad Inserter' code block widget. See <a href='https://wordpress.org/plugins/ad-inserter/faq/' target='_blank'>FAQ</a> for details.</p></div>";
2055
- // }
2056
-
2057
- if (function_exists ('ai_admin_notices')) ai_admin_notices (); else {
2058
- if (/*$hook_suffix == $ai_settings_page &&*/ is_super_admin () && !wp_is_mobile () && isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL])) {
2059
-
2060
- $used_blocks = count (unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]));
2061
-
2062
- $notice_option = get_option ('ai-notice-review');
2063
- if ($notice_option === false && $ai_wp_data [AI_DAYS_SINCE_INSTAL] >= 40) $notice_option = 'later';
2064
-
2065
- if (($notice_option === false && $used_blocks >= 2 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] < 40) ||
2066
-
2067
- ($notice_option == 'later' && ($used_blocks >= 5 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 50 ||
2068
- $used_blocks >= 2 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 70))) {
2069
-
2070
- if ($notice_option == 'later') {
2071
- $message = "Hey, you are now using <strong>{$used_blocks} Ad Inserter</strong> code blocks.";
2072
- $option = '<div class="ai-notice-text-button ai-notice-dismiss" data-notice="no">No, thank you.</div>';
2073
- } else {
2074
- $message = "Hey, you've been using <strong>Ad Inserter</strong> for a while now, and I hope you're happy with it.";
2075
- $option = '<div class="ai-notice-text-button ai-notice-dismiss" data-notice="later">Not now, maybe later.</div>';
2076
- }
2077
- ?>
2078
- <div class="notice notice-info ai-notice ai-no-phone" style="display: none;" data-notice="review" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" >
2079
- <div class="ai-notice-element">
2080
- <img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>icon-50x50.jpg" style="width: 50px; margin: 5px 10px 0px 10px;" />
2081
- </div>
2082
- <div class="ai-notice-element" style="width: 100%; padding: 0 10px 0;">
2083
- <p><?php echo $message; ?>
2084
- I would really appreciate it if you could give the plugin a 5-star rating on WordPres.<br />
2085
- Positive reviews are a great incentive to fix bugs and to add new features for better monetization of your website.
2086
- Thank you! - Igor
2087
- </p>
2088
- </div>
2089
- <div class="ai-notice-element ai-notice-buttons last">
2090
- <button class="button-primary ai-notice-dismiss" data-notice="yes">
2091
- <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/" class="ai-notice-dismiss" target="_blank" data-notice="yes">Rate Ad Inserter</a>
2092
- </button>
2093
- <?php echo $option; ?>
2094
- <div class="ai-notice-text-button ai-notice-dismiss" data-notice="already">I already did.</div>
2095
- </div>
2096
- </div>
2097
-
2098
- <?php
2099
- }
2100
- }
2101
- }
2102
-
2103
- }
2104
-
2105
- function ai_plugin_action_links ($links) {
2106
- if (is_multisite() && !is_main_site () && !multisite_settings_page_enabled ()) return $links;
2107
-
2108
- $settings_link = '<a href="'.admin_url ('options-general.php?page=ad-inserter.php').'">Settings</a>';
2109
- array_unshift ($links, $settings_link);
2110
- return $links;
2111
- }
2112
-
2113
- function ai_set_plugin_meta ($links, $file) {
2114
- if ($file == plugin_basename (__FILE__)) {
2115
- if (is_multisite() && !is_main_site ()) {
2116
- foreach ($links as $index => $link) {
2117
- if (stripos ($link, "update") !== false) unset ($links [$index]);
2118
- }
2119
- }
2120
- // if (stripos (AD_INSERTER_NAME, "pro") === false) {
2121
- // $new_links = array ('donate' => '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank">Donate</a>');
2122
- // $links = array_merge ($links, $new_links);
2123
- // }
2124
- }
2125
- return $links;
2126
- }
2127
-
2128
-
2129
- function current_user_role ($user_role_name = "") {
2130
- $role_values = array ("super-admin" => 6, "administrator" => 5, "editor" => 4, "author" => 3, "contributor" => 2, "subscriber" => 1);
2131
- global $wp_roles;
2132
-
2133
- if ($user_role_name != "") {
2134
- return isset ($role_values [$user_role_name]) ? $role_values [$user_role_name] : 0;
2135
- }
2136
-
2137
- $user_role = 0;
2138
- $current_user = wp_get_current_user();
2139
- $roles = $current_user->roles;
2140
-
2141
- // Fix for empty roles
2142
- if (isset ($current_user->caps) && count ($current_user->caps) != 0) {
2143
- $caps = $current_user->caps;
2144
- foreach ($role_values as $role_name => $role_value) {
2145
- if (isset ($caps [$role_name]) && $caps [$role_name]) $roles []= $role_name;
2146
- }
2147
- }
2148
-
2149
- foreach ($roles as $role) {
2150
- $current_user_role = isset ($role_values [$role]) ? $role_values [$role] : 0;
2151
- if ($current_user_role > $user_role) $user_role = $current_user_role;
2152
- }
2153
-
2154
- return $user_role;
2155
- }
2156
-
2157
-
2158
- function ai_current_user_role_ok () {
2159
- return current_user_role () >= current_user_role (get_minimum_user_role ());
2160
- }
2161
-
2162
-
2163
- function ai_add_meta_box_hook() {
2164
-
2165
- if (!ai_current_user_role_ok ()) return;
2166
-
2167
- if (is_multisite() && !is_main_site () && !multisite_exceptions_enabled ()) return;
2168
-
2169
- $screens = array ('post', 'page');
2170
-
2171
- $args = array (
2172
- 'public' => true,
2173
- '_builtin' => false
2174
- );
2175
- $custom_post_types = get_post_types ($args, 'names', 'and');
2176
- $screens = array_values (array_merge ($screens, $custom_post_types));
2177
-
2178
- foreach ($screens as $screen) {
2179
- add_meta_box (
2180
- 'adinserter_sectionid',
2181
- AD_INSERTER_NAME.' Individual Exceptions',
2182
- 'ai_meta_box_callback',
2183
- $screen
2184
- );
2185
- }
2186
- }
2187
-
2188
- function ai_meta_box_callback ($post) {
2189
- global $block_object;
2190
-
2191
- // Add an nonce field so we can check for it later.
2192
- wp_nonce_field ('adinserter_meta_box', 'adinserter_meta_box_nonce');
2193
-
2194
- $post_type = get_post_type ($post);
2195
- $post_type_object = get_post_type_object ($post_type);
2196
- $page_type_name = $post_type_object->labels->name;
2197
- $page_type_name1 = $post_type_object->labels->singular_name;
2198
-
2199
- /*
2200
- * Use get_post_meta() to retrieve an existing value
2201
- * from the database and use the value for the form.
2202
- */
2203
- $post_meta = get_post_meta ($post->ID, '_adinserter_block_exceptions', true);
2204
- $selected_blocks = explode (",", $post_meta);
2205
-
2206
- ob_start ();
2207
-
2208
- echo '<table>';
2209
- echo '<thead style="font-weight: bold;">';
2210
- echo ' <td>Block</td>';
2211
- echo ' <td style="padding: 0 10px 0 10px;">Name</td>';
2212
- echo ' <td style="padding: 0 10px 0 10px;">Automatic Insertion</td>';
2213
-
2214
- if ($post_type == 'page')
2215
- echo ' <td style="padding: 0 10px 0 10px;">Default insertion for pages</td>'; else
2216
- echo ' <td style="padding: 0 10px 0 10px;">Default insertion for posts</td>';
2217
-
2218
- echo ' <td style="padding: 0 10px 0 10px;">For this ', $page_type_name1, '</td>';
2219
- echo '</thead>';
2220
- echo '<tbody>';
2221
- $rows = 0;
2222
- for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2223
- $obj = $block_object [$block];
2224
-
2225
- if ($post_type == 'page') {
2226
- $page_name = 'pages';
2227
- $enabled_on = $obj->get_ad_enabled_on_which_pages ();
2228
- $general_enabled = $obj->get_display_settings_page();
2229
- } else {
2230
- $page_name = 'posts';
2231
- $enabled_on = $obj->get_ad_enabled_on_which_posts ();
2232
- $general_enabled = $obj->get_display_settings_post();
2233
- }
2234
-
2235
- if (!$general_enabled || $enabled_on == AI_NO_INDIVIDUAL_EXCEPTIONS) continue;
2236
-
2237
- $individual_option_enabled = $general_enabled && ($enabled_on == AI_INDIVIDUALLY_DISABLED || $enabled_on == AI_INDIVIDUALLY_ENABLED);
2238
- $individual_text_enabled = $enabled_on == AI_INDIVIDUALLY_DISABLED;
2239
-
2240
- if ($rows % 2 != 0) $background = "#F0F0F0"; else $background = "#FFF";
2241
- echo '<tr style="background: ', $background, ';">';
2242
- echo ' <td style="text-align: right;">', $obj->number, '</td>';
2243
- if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($block); else $url_parameters = "";
2244
- echo ' <td style="padding: 0 10px 0 10px;"><a href="', admin_url ('options-general.php?page=ad-inserter.php'), $url_parameters, '&tab=', $block, '" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">', $obj->get_ad_name(), '</a></td>';
2245
- echo ' <td style="padding: 0 10px 0 10px;">', $obj->get_automatic_insertion_text(), '</td>';
2246
- echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
2247
-
2248
- if ($individual_option_enabled) {
2249
- if ($individual_text_enabled) echo 'Enabled'; else echo 'Disabled';
2250
- } else {
2251
- if ($general_enabled) echo 'Enabled on all ', $page_name; else
2252
- echo 'Disabled on all ', $page_name;
2253
- }
2254
- echo ' </td>';
2255
- echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
2256
-
2257
- if ($individual_option_enabled) {
2258
- echo '<input type="checkbox" style="border-radius: 5px;" name="adinserter_selected_block_', $block, '" id="ai-selected-block-', $block, '" value="1"', in_array ($block, $selected_blocks) ? ' checked': '', ' />';
2259
- echo '<label for="ai-selected-block-', $block, '">';
2260
- if (!$individual_text_enabled) echo 'Enabled'; else echo 'Disabled';
2261
- echo '</label>';
2262
- } else {
2263
- if (in_array ($block, $selected_blocks)) {
2264
- echo '<span style="margin-left: 6px;">&bull;</span>';
2265
- }
2266
- }
2267
-
2268
- echo ' </td>';
2269
- echo '</tr>';
2270
- $rows ++;
2271
- }
2272
-
2273
- echo '</tbody>';
2274
- echo '</table>';
2275
-
2276
- $exceptions_table = ob_get_clean ();
2277
-
2278
- if ($rows == 0) {
2279
- echo '<p><strong>No individual exceptions enabled for ', $page_name, '</strong>.</p>';
2280
- } else echo $exceptions_table;
2281
-
2282
- echo '<p>Default insertion for ', $page_name, ' for each code block can be configured on <a href="', admin_url ('options-general.php?page=ad-inserter.php'), '" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">',
2283
- AD_INSERTER_NAME, ' Settings</a> page - selection next to <strong>Posts</strong> / <strong>Static pages</strong> checkbox.<br />',
2284
- 'Default value is <strong>blank</strong> and means no individual exceptions (even if previously defined here).<br />',
2285
- 'Set to <strong>Individually disabled</strong> or <strong>Individually enabled</strong> to enable individual exception settings on this page.<br />',
2286
- 'For more information check <a href="https://adinserter.pro/exceptions" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">Ad Inserter Exceptions</a>.</p>';
2287
- }
2288
-
2289
- function ai_save_meta_box_data_hook ($post_id) {
2290
- // Check if our nonce is set.
2291
- if (!isset ($_POST ['adinserter_meta_box_nonce'])) return;
2292
-
2293
- // Verify that the nonce is valid.
2294
- if (!wp_verify_nonce ($_POST ['adinserter_meta_box_nonce'], 'adinserter_meta_box')) return;
2295
-
2296
- // If this is an autosave, our form has not been submitted, so we don't want to do anything.
2297
- if (defined ('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
2298
-
2299
- // Check the user's permissions.
2300
-
2301
- if (isset ($_POST ['post_type'])) {
2302
- if ($_POST ['post_type'] == 'page') {
2303
- if (!current_user_can ('edit_page', $post_id)) return;
2304
- } else {
2305
- if (!current_user_can ('edit_post', $post_id)) return;
2306
- }
2307
- }
2308
-
2309
- /* OK, it's safe for us to save the data now. */
2310
-
2311
- $selected = array ();
2312
- for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2313
- $option_name = 'adinserter_selected_block_' . $block;
2314
- if (isset ($_POST [$option_name]) && $_POST [$option_name]) $selected []= $block;
2315
- }
2316
-
2317
- // Update the meta field in the database.
2318
- update_post_meta ($post_id, '_adinserter_block_exceptions', implode (",", $selected));
2319
- }
2320
-
2321
- function ai_widgets_init_hook () {
2322
- if (is_multisite() && !is_main_site () && !multisite_widgets_enabled ()) return;
2323
- register_widget ('ai_widget');
2324
- }
2325
-
2326
- function get_page_type_debug_info ($text = '') {
2327
- global $ai_wp_data;
2328
-
2329
- switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
2330
- case AI_PT_STATIC:
2331
- $page_type = 'STATIC PAGE';
2332
- break;
2333
- case AI_PT_POST:
2334
- $page_type = 'POST';
2335
- break;
2336
- case AI_PT_HOMEPAGE:
2337
- $page_type = 'HOMEPAGE';
2338
- break;
2339
- case AI_PT_CATEGORY:
2340
- $page_type = 'CATEGORY PAGE';
2341
- break;
2342
- case AI_PT_SEARCH:
2343
- $page_type = 'SEARCH PAGE';
2344
- break;
2345
- case AI_PT_ARCHIVE:
2346
- $page_type = 'ARCHIVE PAGE';
2347
- break;
2348
- case AI_PT_404:
2349
- $page_type = 'ERROR 404 PAGE';
2350
- break;
2351
- case AI_PT_AJAX:
2352
- $page_type = 'AJAX CALL';
2353
- break;
2354
- default:
2355
- $page_type = 'UNKNOWN PAGE TYPE';
2356
- break;
2357
- }
2358
- $class = AI_DEBUG_PAGE_TYPE_CLASS;
2359
-
2360
- $page_type = "<section class='$class'>".$text.$page_type."</section>";
2361
-
2362
- return $page_type;
2363
- }
2364
-
2365
- function get_adb_status_debug_info () {
2366
- global $ai_wp_data;
2367
-
2368
- $page_type = '';
2369
-
2370
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
2371
- if ($ai_wp_data [AI_ADB_DETECTION]) {
2372
- $page_type = "<section id='ai-adb-bar' class='".AI_DEBUG_STATUS_CLASS.' '.AI_DEBUG_ADB_CLASS."' title='Click to delete ad blocking detection cokies'>AD BLOCKING <span id='ai-adb-status'>STATUS UNKNOWN</span></section>";
2373
- }
2374
- }
2375
-
2376
- return $page_type;
2377
- }
2378
-
2379
-
2380
- function ai_header_noindex () {
2381
- global $ai_wp_data;
2382
-
2383
- if ($ai_wp_data [AI_WP_DEBUGGING] != 0) {
2384
- echo '<meta name="robots" content="noindex"> <!-- ', AD_INSERTER_NAME, ' debugging enabled (', $ai_wp_data [AI_WP_DEBUGGING], ') -->', "\n";
2385
- }
2386
- }
2387
-
2388
- function get_header_footer_debug_block ($name, $title, $code, $javascript = false) {
2389
- $message = '';
2390
- if (strpos ($code, 'enable_page_level_ads') !== false)
2391
- $message = 'Code for <a style="text-decoration: none; color: #fff; font-weight: bold; box-shadow: none;" href="https://adinserter.pro/adsense-ads#auto-ads" target="_blank">AdSense Auto Ads</a> detected - Code will automatically insert AdSense ads at optimal positions ';
2392
-
2393
- $debug_script = new ai_block_labels ('ai-debug-script');
2394
- $debug_block_start = $debug_script->block_start ();
2395
- $debug_block_start .= $debug_script->bar ($name, '', $message, $title);
2396
- if ($javascript) $debug_block_start = str_replace (array ('"', "\n", "\r"), array ("'", "\\n", ''), $debug_block_start);
2397
-
2398
- $debug_block_end = $debug_script->block_end ();
2399
- if ($javascript) $debug_block_end = str_replace (array ('"', "\n", "\r"), array ("'", "\\n", ''), $debug_block_end);
2400
-
2401
- $html_code = htmlspecialchars ($code);
2402
- if ($javascript) $html_code = str_replace (array ("\n", "\r"), array ("\\n", ''), $html_code);
2403
-
2404
- return $debug_block_start . "<pre class='ai-debug-code'>". $html_code . "</pre>" . $debug_block_end;
2405
- }
2406
-
2407
- function ai_http_header () {
2408
- global $block_object, $ai_wp_data;
2409
-
2410
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_HTTP_HEADER;
2411
-
2412
- $obj = $block_object [AI_HEADER_OPTION_NAME];
2413
- $obj->clear_code_cache ();
2414
-
2415
- if ($obj->get_enable_manual ()) {
2416
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
2417
- $processed_code = do_shortcode ($obj->ai_getCode ());
2418
-
2419
- if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
2420
- $codes = explode (AD_HTTP_SEPARATOR, $processed_code);
2421
- $processed_code = $codes [0];
2422
- } else $processed_code = '';
2423
-
2424
- $header_lines = explode ("\n", $processed_code);
2425
- foreach ($header_lines as $header_line) {
2426
- if (trim ($header_line) != '' && strpos ($header_line, ':') !== false)
2427
- header (trim ($header_line));
2428
- }
2429
- }
2430
- }
2431
- }
2432
-
2433
- function ai_wp_head_hook () {
2434
- global $block_object, $ai_wp_data, $ai_total_plugin_time;
2435
-
2436
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2437
- ai_log ("HEAD HOOK START");
2438
- $start_time = microtime (true);
2439
- }
2440
-
2441
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
2442
-
2443
- ai_header_noindex ();
2444
-
2445
- add_head_inline_styles_and_scripts ();
2446
-
2447
- $header_code = null;
2448
-
2449
- $obj = $block_object [AI_HEADER_OPTION_NAME];
2450
- // $obj->clear_code_cache (); // cleared at ai_http_header
2451
-
2452
- if ($obj->get_enable_manual ()) {
2453
- if ($obj->check_server_side_detection ()) {
2454
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
2455
- $header_code = '';
2456
-
2457
- $processed_code = do_shortcode ($obj->ai_getCode ());
2458
-
2459
- if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
2460
- $codes = explode (AD_HTTP_SEPARATOR, $processed_code);
2461
- $processed_code = ltrim ($codes [1]);
2462
- }
2463
-
2464
- if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
2465
- $codes = explode (AD_AMP_SEPARATOR, $processed_code);
2466
- $processed_code = $codes [0];
2467
- } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
2468
-
2469
- $header_code = $processed_code;
2470
-
2471
- echo $processed_code;
2472
- }
2473
- }
2474
- }
2475
-
2476
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
2477
- // No scripts on AMP pages
2478
- // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) != 0 && $ai_wp_data [AI_ADB_DETECTION] && !$ai_wp_data [AI_WP_AMP_PAGE]) {
2479
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) != 0 && $ai_wp_data [AI_ADB_DETECTION] /*&& !$ai_wp_data [AI_WP_AMP_PAGE]*/) {
2480
- echo "<script>
2481
- jQuery(document).ready(function($) {
2482
- $('body').prepend (\"", get_adb_status_debug_info () , "\");
2483
- });
2484
- </script>\n";
2485
- }
2486
- }
2487
-
2488
- // No scripts on AMP pages
2489
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
2490
- echo "<script>
2491
- jQuery(document).ready(function($) {
2492
- $('body').prepend (\"", get_page_type_debug_info () , "\");
2493
- });
2494
- </script>\n";
2495
- }
2496
-
2497
- if ($header_code !== null && ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2498
- echo "<script>\n";
2499
- echo " jQuery(document).ready(function($) {
2500
- $('body').prepend (\"" . get_header_footer_debug_block (' Header code ', '&lt;head&gt;...&lt;/head&gt;', $header_code, true) . "\");
2501
- });
2502
- </script>\n";
2503
- }
2504
-
2505
- if (defined ('AI_ADSENSE_OVERLAY') && ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2506
- echo "<script>\n";
2507
- echo ai_get_js ('ai-ads');
2508
- echo "</script>\n";
2509
- }
2510
-
2511
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2512
- echo "<script>
2513
- jQuery(document).ready(function($) {
2514
- setTimeout (function() {
2515
- var google_auto_placed = jQuery ('.google-auto-placed');
2516
- google_auto_placed.before ('<section class=\"ai-debug-bar ai-debug-adsense\">Automatically placed by AdSense Auto ads code</section>');
2517
- }, 3000);
2518
- });
2519
- </script>\n";
2520
- }
2521
-
2522
- if (defined ('AI_BUFFERING')) {
2523
- if (get_output_buffering ()) {
2524
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2525
- ai_buffering_start ();
2526
- }
2527
- }
2528
- }
2529
-
2530
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2531
- $ai_total_plugin_time += microtime (true) - $start_time;
2532
- ai_log ("HEAD HOOK END\n");
2533
- }
2534
- }
2535
-
2536
- function ai_amp_head_hook () {
2537
- global $block_object, $ai_wp_data, $ai_total_plugin_time;
2538
-
2539
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2540
- ai_log ("HEAD HOOK START");
2541
- $start_time = microtime (true);
2542
- }
2543
-
2544
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
2545
-
2546
- ai_header_noindex ();
2547
-
2548
- $obj = $block_object [AI_HEADER_OPTION_NAME];
2549
- // $obj->clear_code_cache (); // cleared at ai_http_header
2550
-
2551
- if ($obj->get_enable_manual ()) {
2552
- if ($obj->check_server_side_detection ()) {
2553
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
2554
- $processed_code = do_shortcode ($obj->ai_getCode ());
2555
-
2556
- if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
2557
- $codes = explode (AD_HTTP_SEPARATOR, $processed_code);
2558
- $processed_code = ltrim ($codes [1]);
2559
- }
2560
-
2561
- if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
2562
- $codes = explode (AD_AMP_SEPARATOR, $processed_code);
2563
- $processed_code = ltrim ($codes [1]);
2564
- echo $processed_code;
2565
- }
2566
- }
2567
- }
2568
- }
2569
-
2570
- if (defined ('AI_BUFFERING')) {
2571
- if (get_output_buffering ()) {
2572
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2573
- ai_buffering_start ();
2574
- }
2575
- }
2576
- }
2577
-
2578
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2579
- $ai_total_plugin_time += microtime (true) - $start_time;
2580
- ai_log ("HEAD HOOK END\n");
2581
- }
2582
- }
2583
-
2584
- function ai_amp_css_hook () {
2585
- global $ai_wp_data;
2586
-
2587
- if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES || $ai_wp_data [AI_WP_DEBUGGING] != 0) {
2588
-
2589
- if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES) {
2590
- echo get_alignment_css ();
2591
-
2592
- echo ".ai-align-left * {margin: 0 auto 0 0; text-align: left;}\n";
2593
- echo ".ai-align-right * {margin: 0 0 0 auto; text-align: right;}\n";
2594
- echo ".ai-center * {margin: 0 auto; text-align: center; }\n";
2595
- }
2596
-
2597
- if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css ();
2598
- }
2599
- }
2600
-
2601
-
2602
- function ai_wp_footer_hook () {
2603
- global $block_object, $ai_wp_data, $ai_total_plugin_time;
2604
-
2605
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2606
- ai_log ("FOOTER HOOK START");
2607
- $start_time = microtime (true);
2608
- }
2609
-
2610
- if (defined ('AI_BUFFERING')) {
2611
- if (get_output_buffering ()) {
2612
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2613
- ai_buffering_end ();
2614
- }
2615
- }
2616
- }
2617
-
2618
- if ($ai_wp_data [AI_DISABLE_CACHING]) ai_disable_caching ();
2619
-
2620
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
2621
- $footer_code = null;
2622
-
2623
- $footer = $block_object [AI_FOOTER_OPTION_NAME];
2624
- $footer->clear_code_cache ();
2625
-
2626
- if ($footer->get_enable_manual ()) {
2627
- if ($footer->check_server_side_detection ()) {
2628
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $footer->get_enable_404()) {
2629
- $footer_code = '';
2630
- $processed_code = do_shortcode ($footer->ai_getCode ());
2631
-
2632
- if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
2633
- $codes = explode (AD_AMP_SEPARATOR, $processed_code);
2634
- $processed_code = $codes [0];
2635
- } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
2636
-
2637
- $footer_code = $processed_code;
2638
-
2639
- echo $processed_code;
2640
- }
2641
- }
2642
- }
2643
-
2644
- if (!(defined ('DOING_AJAX') && DOING_AJAX)) {
2645
- add_footer_inline_scripts ();
2646
- }
2647
-
2648
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
2649
- echo get_page_type_debug_info () , "\n";
2650
- }
2651
-
2652
- if ($footer_code !== null && ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2653
- echo get_header_footer_debug_block (' Footer code ', '...&lt;/body&gt;', $footer_code);
2654
- }
2655
-
2656
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2657
- $ai_total_plugin_time += microtime (true) - $start_time;
2658
- ai_log ("FOOTER HOOK END\n");
2659
- }
2660
- }
2661
-
2662
- function ai_amp_footer_hook () {
2663
- global $block_object, $ai_wp_data, $ai_total_plugin_time;
2664
-
2665
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2666
- ai_log ("FOOTER HOOK START");
2667
- $start_time = microtime (true);
2668
- }
2669
-
2670
- if (defined ('AI_BUFFERING')) {
2671
- if (get_output_buffering ()) {
2672
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2673
- ai_buffering_end ();
2674
- }
2675
- }
2676
- }
2677
-
2678
- // if (!(defined ('DOING_AJAX') && DOING_AJAX) && !$ai_wp_data [AI_WP_AMP_PAGE]) {
2679
- // add_footer_inline_scripts ();
2680
- // }
2681
-
2682
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
2683
-
2684
- $obj = $block_object [AI_FOOTER_OPTION_NAME];
2685
- $obj->clear_code_cache ();
2686
-
2687
- if ($obj->get_enable_manual ()) {
2688
- if ($obj->check_server_side_detection ()) {
2689
- if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
2690
- $processed_code = do_shortcode ($obj->ai_getCode ());
2691
-
2692
- if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
2693
- $codes = explode (AD_AMP_SEPARATOR, $processed_code);
2694
- $processed_code = ltrim ($codes [1]);
2695
- echo $processed_code;
2696
- }
2697
- }
2698
- }
2699
- }
2700
-
2701
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
2702
- echo get_page_type_debug_info ('AMP ') , "\n";
2703
- }
2704
-
2705
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2706
- $ai_total_plugin_time += microtime (true) - $start_time;
2707
- ai_log ("FOOTER HOOK END\n");
2708
- }
2709
- }
2710
-
2711
- function ai_write_debug_info ($write_processing_log = false) {
2712
- global $block_object, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_wp_data, $ai_db_options, $block_insertion_log, $ai_custom_hooks;
2713
-
2714
- echo sprintf ("%-25s%s", AD_INSERTER_NAME, AD_INSERTER_VERSION);
2715
- if (function_exists ('ai_debug_header')) ai_debug_header ();
2716
- echo "\n\n";
2717
- if (($install_timestamp = get_option (AI_INSTALL_NAME)) !== false) {
2718
- echo "INSTALLED: ", date ("Y-m-d H:i:s", $install_timestamp + get_option ('gmt_offset') * 3600);
2719
- if (isset ($ai_wp_data [AI_INSTALL_TIME_DIFFERENCE])) {
2720
- printf (' (%04d-%02d-%02d %02d:%02d:%02d, %d days)', $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->y,
2721
- $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->m,
2722
- $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->d,
2723
- $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->h,
2724
- $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->i,
2725
- $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->s,
2726
- isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL]) ? $ai_wp_data [AI_DAYS_SINCE_INSTAL] : null);
2727
- }
2728
- echo "\n";
2729
- }
2730
- echo "GENERATED (WP time): ", date ("Y-m-d H:i:s", time() + get_option ('gmt_offset') * 3600), "\n";
2731
- echo "GENERATED (Server time): ", date ("Y-m-d H:i:s", time()), "\n";
2732
- echo "PLUGIN CODE PROCESSING: ", number_format (($ai_total_plugin_time - $ai_total_php_time) * 1000, 2, '.' , ''), " ms\n";
2733
- echo "USER CODE PROCESSING: ", number_format ($ai_total_php_time * 1000, 2, '.' , ''), " ms\n";
2734
- echo "TOTAL PROCESSING TIME: ", number_format ($ai_total_plugin_time * 1000, 2, '.' , ''), " ms\n";
2735
-
2736
- echo "SETTINGS: ";
2737
- if (isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']))
2738
- echo (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][0].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][1]), '.',
2739
- (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][2].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][3]), '.',
2740
- (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][4].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][5]);
2741
-
2742
- echo "\n";
2743
- echo "SETTINGS TIMESTAMP: ";
2744
- 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";
2745
- echo "SETTINGS EXTRACT: ", defined ('AI_GENERATE_EXTRACT') ? "NO" : "YES", "\n";
2746
- echo "MULTISITE: ", is_multisite() ? "YES" : "NO", "\n";
2747
- if (is_multisite()) {
2748
- echo "MAIN SITE: ", is_main_site () ? "YES" : "NO", "\n";
2749
- }
2750
-
2751
- echo "USER: ";
2752
- if (($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) == AI_USER_LOGGED_IN) echo "LOGGED-IN "; else echo "NOT LOGGED-IN ";
2753
- if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) == AI_USER_ADMINISTRATOR) echo "ADMINISTRATOR";
2754
- $current_user = wp_get_current_user();
2755
- echo "\n";
2756
- echo "USERNAME: ", $current_user->user_login, "\n";
2757
- echo 'USER ROLES: ', implode (', ', $current_user->roles), "\n";
2758
- echo 'MIN.USER FOR EXCEPTIONS: ', get_minimum_user_role (), "\n";
2759
- echo "PAGE TYPE: ";
2760
- switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
2761
- case AI_PT_STATIC: echo "STATIC PAGE"; break;
2762
- case AI_PT_POST: echo "POST"; break;
2763
- case AI_PT_HOMEPAGE: echo "HOMEPAGE"; break;
2764
- case AI_PT_CATEGORY: echo "CATEGORY PAGE"; break;
2765
- case AI_PT_ARCHIVE: echo "ARCHIVE PAGE"; break;
2766
- case AI_PT_SEARCH: echo "SEARCH PAGE"; break;
2767
- case AI_PT_404: echo "404 PAGE"; break;
2768
- case AI_PT_ADMIN: echo "ADMIN"; break;
2769
- case AI_PT_FEED: echo "FEED"; break;
2770
- case AI_PT_AJAX: echo "AJAX"; break;
2771
- case AI_PT_ANY: echo "ANY ?"; break;
2772
- case AI_PT_NONE: echo "NONE ?"; break;
2773
- default: echo "?"; break;
2774
- }
2775
- echo "\n";
2776
-
2777
- switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
2778
- case AI_PT_STATIC:
2779
- case AI_PT_POST:
2780
- echo 'ID: ', get_the_ID(), "\n";
2781
- echo 'POST TYPE: ', get_post_type (), "\n";
2782
- $category_data = get_the_category();
2783
- $categories = array ();
2784
- foreach ($category_data as $category) {
2785
- $categories []= $category->name . ' ('.$category->slug.')';
2786
- }
2787
- echo 'CATEGORIES: ', implode (', ', $categories), "\n";
2788
- $tag_data = wp_get_post_tags (get_the_ID());
2789
- $tags = array ();
2790
- foreach ($tag_data as $tag) {
2791
- $tags []= $tag->name . ' ('.$tag->slug.')';
2792
- }
2793
- echo 'TAGS: ', implode (', ', $tags), "\n";
2794
- $taxonomies = array ();
2795
- $taxonomy_names = get_post_taxonomies ();
2796
- foreach ($taxonomy_names as $taxonomy_name) {
2797
- $terms = get_the_terms (0, $taxonomy_name);
2798
- if (is_array ($terms)) {
2799
- foreach ($terms as $term) {
2800
- $taxonomies [] = strtolower ($term->taxonomy) . ':' . strtolower ($term->slug);
2801
- }
2802
- }
2803
- }
2804
- echo 'TAXONOMIES: ', implode (', ', $taxonomies), "\n";
2805
-
2806
- $post_meta = get_post_meta (get_the_ID());
2807
- $meta_string = array ();
2808
- foreach ($post_meta as $key => $post_meta_field) {
2809
- foreach ($post_meta_field as $post_meta_field_item) {
2810
- $meta_string []= $key . ':' . $post_meta_field_item;
2811
- }
2812
- }
2813
- echo 'POST META: ', implode (', ', $meta_string), "\n";
2814
-
2815
- break;
2816
- case AI_PT_CATEGORY:
2817
- $category_data = get_the_category();
2818
- $categories = array ();
2819
- foreach ($category_data as $category) {
2820
- $categories []= $category->slug;
2821
- }
2822
- echo 'CATEGORY: ', implode (', ', $categories), "\n";
2823
- break;
2824
- case AI_PT_ARCHIVE:
2825
- $tag_data = wp_get_post_tags (get_the_ID());
2826
- $tags = array ();
2827
- foreach ($tag_data as $tag) {
2828
- $tags []= $tag->slug;
2829
- }
2830
- echo 'TAG: ', implode (', ', $tags), "\n";
2831
- break;
2832
- }
2833
-
2834
- echo 'AMP PAGE: ', ($ai_wp_data [AI_WP_AMP_PAGE] ? 'YES' : 'NO'), "\n";
2835
-
2836
- echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
2837
- echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) . ' ('. remove_debug_parameters_from_url ($_SERVER['HTTP_REFERER']).')' : "", "\n";
2838
- if (function_exists ('ai_debug')) ai_debug ();
2839
- echo 'CLIENT-SIDE DETECTION: ', $ai_wp_data [AI_CLIENT_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
2840
- echo 'CLIENT-SIDE INSERTION: ', $ai_wp_data [AI_CLIENT_SIDE_INSERTION] ? 'USED' : "NOT USED", "\n";
2841
- if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] || 1) {
2842
- for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
2843
- $viewport_name = get_viewport_name ($viewport);
2844
- $viewport_width = get_viewport_width ($viewport);
2845
- if ($viewport_name != '') {
2846
- echo 'VIEWPORT ', $viewport, ': ', sprintf ("%-16s min width %s", $viewport_name.' ', $viewport_width), " px\n";
2847
- }
2848
- }
2849
- }
2850
- echo 'SERVER-SIDE DETECTION: ', $ai_wp_data [AI_SERVER_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
2851
- if ($ai_wp_data [AI_SERVER_SIDE_DETECTION]) {
2852
- echo 'SERVER-SIDE DEVICE: ';
2853
- if (AI_DESKTOP) echo "DESKTOP\n";
2854
- elseif (AI_TABLET) echo "TABLET\n";
2855
- elseif (AI_PHONE) echo "PHONE\n";
2856
- else echo "?\n";
2857
- }
2858
-
2859
- $enabled_custom_hooks = array ();
2860
- foreach ($ai_custom_hooks as $ai_custom_hook) {
2861
- $hook = $ai_custom_hook ['index'];
2862
- $enabled_custom_hooks [] = $ai_custom_hook ['action'];
2863
- }
2864
- for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
2865
- $name = str_replace (array ('&lt;', '&gt;'), array ('<', '>'), get_hook_name ($hook));
2866
- $action = get_hook_action ($hook);
2867
- if (get_hook_enabled ($hook) /*&& $name != '' && $action != ''*/) {
2868
- $priority = get_hook_priority ($hook);
2869
- echo 'CUSTOM HOOK ', $hook, ': ', sprintf ("%-30s %-35s %d %s", $name, $action, $priority, !in_array ($action, $enabled_custom_hooks) ? 'INVALID' : ''), "\n";
2870
- }
2871
- }
2872
- echo 'BLOCK CLASS NAME: ', get_block_class_name (), "\n";
2873
- echo 'INLINE STYLES: ', get_inline_styles () ? 'ENABLED' : 'DISABLED', "\n";
2874
- echo 'DYNAMIC BLOCKS: ';
2875
- switch (get_dynamic_blocks()) {
2876
- case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
2877
- echo AI_TEXT_SERVER_SIDE;
2878
- break;
2879
- case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
2880
- echo AI_TEXT_SERVER_SIDE_W3TC;
2881
- break;
2882
- case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
2883
- echo AI_TEXT_CLIENT_SIDE;
2884
- break;
2885
- }
2886
- echo "\n";
2887
- echo 'PARAGRAPH COUNTING: ';
2888
- switch (get_paragraph_counting_functions()) {
2889
- case AI_STANDARD_PARAGRAPH_COUNTING_FUNCTIONS:
2890
- echo AI_TEXT_STANDARD;
2891
- break;
2892
- case AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS:
2893
- echo AI_TEXT_MULTIBYTE;
2894
- break;
2895
- }
2896
- echo "\n";
2897
- echo 'NO PAR. COUNTING INSIDE: ', get_no_paragraph_counting_inside (), "\n";
2898
- if (defined ('AI_BUFFERING')) {
2899
- echo 'OUTPUT BUFFERING: ';
2900
- switch (get_output_buffering()) {
2901
- case AI_OUTPUT_BUFFERING_DISABLED:
2902
- echo AI_TEXT_DISABLED;
2903
- break;
2904
- case AI_OUTPUT_BUFFERING_ENABLED:
2905
- echo AI_TEXT_ENABLED;
2906
- break;
2907
- }
2908
- echo "\n";
2909
- }
2910
- echo 'AD LABEL: ', get_ad_label (), "\n";
2911
- echo 'PLUGIN PRIORITY: ', get_plugin_priority (), "\n";
2912
- echo 'HEADER CODE: ', $block_object [AI_HEADER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
2913
- echo 'FOOTER CODE: ', $block_object [AI_FOOTER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
2914
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
2915
- echo 'AD BLOCKING DETECTION: ', $ai_wp_data [AI_ADB_DETECTION] ? 'ENABLED' : 'DISABLED', "\n";
2916
- if ($ai_wp_data [AI_ADB_DETECTION]) {
2917
- echo 'ADB ACTION: ';
2918
- switch (get_adb_action ()) {
2919
- case AI_ADB_ACTION_NONE:
2920
- echo AI_TEXT_NONE;
2921
- break;
2922
- case AI_ADB_ACTION_MESSAGE:
2923
- echo AI_TEXT_POPUP_MESSAGE;
2924
- break;
2925
- case AI_ADB_ACTION_REDIRECTION:
2926
- echo AI_TEXT_REDIRECTION;
2927
- break;
2928
- }
2929
- echo "\n";
2930
- echo 'ADB DELAY ACTION: ', get_delay_action (), "\n";
2931
- echo 'ADB NO ACTION PERIOD: ', get_no_action_period (), "\n";
2932
- echo 'ADB SELECTORS: ', get_adb_selectors (true), "\n";
2933
- $redirection_page = get_redirection_page ();
2934
- echo 'ADB REDIRECTION PAGE: ', $redirection_page != 0 ? get_the_title ($redirection_page) . ' (' . get_permalink ($redirection_page) . ')' : 'Custom Url', "\n";
2935
- echo 'ADB REDIRECTION URL: ', get_custom_redirection_url (), "\n";
2936
- echo 'ADB MESSAGE: ', $block_object [AI_ADB_MESSAGE_OPTION_NAME]->ai_getCode (), "\n";
2937
- echo 'ADB MESSAGE CSS: ', get_message_css (), "\n";
2938
- echo 'ADB OVERLAY CSS: ', get_overlay_css (), "\n";
2939
- echo 'ADB UNDISMISSIBLE: ', get_undismissible_message () ? 'ON' : 'OFF', "\n";
2940
- }
2941
- }
2942
-
2943
- echo "\n";
2944
-
2945
- $default = new ai_Block (1);
2946
-
2947
- echo "BLOCK SETTINGS Po Pa Hp Cp Ap Sp AM Aj Fe 404 Wi Sh PHP\n";
2948
- for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2949
- $obj = $block_object [$block];
2950
-
2951
- $settings = "";
2952
- $insertion_settings = '';
2953
- $alignment_settings = '';
2954
- $default_settings = true;
2955
- // $display_type = '';
2956
- foreach (array_keys ($default->wp_options) as $key){
2957
- switch ($key) {
2958
- case AI_OPTION_CODE:
2959
- case AI_OPTION_BLOCK_NAME:
2960
- continue 2;
2961
- case AI_OPTION_DISPLAY_ON_PAGES:
2962
- case AI_OPTION_DISPLAY_ON_POSTS:
2963
- case AI_OPTION_DISPLAY_ON_HOMEPAGE:
2964
- case AI_OPTION_DISPLAY_ON_CATEGORY_PAGES:
2965
- case AI_OPTION_DISPLAY_ON_SEARCH_PAGES:
2966
- case AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES:
2967
- case AI_OPTION_ENABLE_AMP:
2968
- case AI_OPTION_ENABLE_AJAX:
2969
- case AI_OPTION_ENABLE_FEED:
2970
- case AI_OPTION_ENABLE_404:
2971
- case AI_OPTION_ENABLE_MANUAL:
2972
- case AI_OPTION_ENABLE_WIDGET:
2973
- case AI_OPTION_ENABLE_PHP_CALL:
2974
- if ($obj->wp_options [$key] != $default->wp_options [$key]) $default_settings = false;
2975
- continue 2;
2976
- }
2977
-
2978
- // if (gettype ($obj->wp_options [$key]) == 'string' && gettype ($default->wp_options [$key]) == 'integer') {
2979
- // $default->wp_options [$key] = strval ($default->wp_options [$key]);
2980
- // }
2981
- // elseif (gettype ($obj->wp_options [$key]) == 'integer' && gettype ($default->wp_options [$key]) == 'string') {
2982
- // $default->wp_options [$key] = intval ($default->wp_options [$key]);
2983
- // }
2984
-
2985
- // if ($obj->wp_options [$key] !== $default->wp_options [$key]) {
2986
- if ($obj->wp_options [$key] != $default->wp_options [$key]) {
2987
- $default_settings = false;
2988
- switch ($key) {
2989
- case AI_OPTION_AUTOMATIC_INSERTION:
2990
- $insertion_settings = $obj->get_automatic_insertion_text();
2991
- break;
2992
- case AI_OPTION_SERVER_SIDE_INSERTION:
2993
- $settings .= "[" . $key . ": " . $obj->get_automatic_insertion_text (true) . ']';
2994
- break;
2995
- case AI_OPTION_ALIGNMENT_TYPE:
2996
- $alignment_settings = $obj->get_alignment_type_text ();
2997
- break;
2998
- case AI_OPTION_ENABLED_ON_WHICH_PAGES:
2999
- $settings .= "[" . $key . ": " . $obj->get_ad_enabled_on_which_pages_text () . ']';
3000
- break;
3001
- case AI_OPTION_ENABLED_ON_WHICH_POSTS:
3002
- $settings .= "[" . $key . ": " . $obj->get_ad_enabled_on_which_posts_text () . ']';
3003
- break;
3004
- case AI_OPTION_PARAGRAPH_TEXT:
3005
- case AI_OPTION_AVOID_TEXT_ABOVE:
3006
- case AI_OPTION_AVOID_TEXT_BELOW:
3007
- case AI_OPTION_HTML_SELECTOR:
3008
- if ($write_processing_log)
3009
- $settings .= "[" . $key . ": " . ai_log_filter_content (html_entity_decode ($obj->wp_options [$key])) . ']'; else
3010
- $settings .= "[" . $key . ": " . $obj->wp_options [$key] . ']';
3011
- break;
3012
- case AI_OPTION_FILTER_TYPE:
3013
- $settings .= "[" . $key . ": " . $obj->get_filter_type_text () . ']';
3014
- break;
3015
- default:
3016
- $settings .= "[" . $key . ": " . $obj->wp_options [$key] . ']';
3017
- break;
3018
- }
3019
-
3020
- // $settings .= ' ['.gettype ($obj->wp_options [$key]).':'.$obj->wp_options [$key].'#'.gettype ($default->wp_options [$key]).':'.$default->wp_options [$key].'] ';
3021
-
3022
- } else
3023
- switch ($key) {
3024
- case AI_OPTION_AUTOMATIC_INSERTION:
3025
- $insertion_settings = $obj->get_automatic_insertion_text ();
3026
- break;
3027
- case AI_OPTION_ALIGNMENT_TYPE:
3028
- $alignment_settings = $obj->get_alignment_type_text ();
3029
- break;
3030
- }
3031
- }
3032
- if ($default_settings && $settings == '') continue;
3033
- $settings = ' [' . $insertion_settings . '][' . $alignment_settings . ']' . $settings;
3034
-
3035
- echo sprintf ("%2d %-21s ", $block, substr ($obj->get_ad_name(), 0, 21));
3036
-
3037
- echo $obj->get_display_settings_post() ? "o" : ".", " ";
3038
- echo $obj->get_display_settings_page() ? "o" : ".", " ";
3039
- echo $obj->get_display_settings_home() ? "o" : ".", " ";
3040
- echo $obj->get_display_settings_category() ? "o" : ".", " ";
3041
- echo $obj->get_display_settings_archive() ? "o" : ".", " ";
3042
- echo $obj->get_display_settings_search() ? "o" : ".", " ";
3043
- echo $obj->get_enable_amp() ? "o" : ".", " ";
3044
- echo $obj->get_enable_ajax() ? "o" : ".", " ";
3045
- echo $obj->get_enable_feed() ? "o" : ".", " ";
3046
- echo $obj->get_enable_404() ? "o" : ".", " ";
3047
- echo $obj->get_enable_widget() ? "x" : ".", " ";
3048
- echo $obj->get_enable_manual() ? "x" : ".", " ";
3049
- echo $obj->get_enable_php_call() ? "x" : ".", " ";
3050
-
3051
- echo $settings, "\n";
3052
- }
3053
- echo "\n";
3054
-
3055
- $args = array (
3056
- 'public' => true,
3057
- '_builtin' => false
3058
- );
3059
- $custom_post_types = get_post_types ($args, 'names', 'and');
3060
- $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types));
3061
-
3062
- $args = array (
3063
- 'posts_per_page' => 100,
3064
- 'offset' => 0,
3065
- 'category' => '',
3066
- 'category_name' => '',
3067
- 'orderby' => 'type',
3068
- 'order' => 'ASC',
3069
- 'include' => '',
3070
- 'exclude' => '',
3071
- 'meta_key' => '_adinserter_block_exceptions',
3072
- 'meta_value' => '',
3073
- 'post_type' => $screens,
3074
- 'post_mime_type' => '',
3075
- 'post_parent' => '',
3076
- 'author' => '',
3077
- 'author_name' => '',
3078
- 'post_status' => '',
3079
- 'suppress_filters' => true
3080
- );
3081
- $posts_pages = get_posts ($args);
3082
-
3083
- if (count ($posts_pages) != 0) {
3084
- echo "EXCEPTIONS FOR BLOCKS ID TYPE TITLE URL\n";
3085
- foreach ($posts_pages as $page) {
3086
- $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
3087
- if ($post_meta == '') continue;
3088
- $post_type_object = get_post_type_object ($page->post_type);
3089
- echo sprintf ("%-24s %-6s %-24s %-64s %s", $post_meta, $page->ID, $post_type_object->labels->singular_name, substr ($page->post_title, 0, 64), get_permalink ($page->ID)), "\n";
3090
- }
3091
- echo "\n";
3092
- }
3093
-
3094
- echo "TOTAL BLOCKS\n";
3095
- if (count ($ai_db_options_extract [ABOVE_HEADER_HOOK_BLOCKS][AI_PT_ANY]))
3096
- echo "ABOVE HEADER: ", implode (", ", $ai_db_options_extract [ABOVE_HEADER_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3097
- if (count ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][AI_PT_ANY]))
3098
- echo "CONTENT HOOK: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3099
- if (count ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][AI_PT_ANY]))
3100
- echo "EXCERPT HOOK: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3101
- if (count ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY]))
3102
- echo "LOOP START HOOK: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3103
- if (count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]))
3104
- echo "LOOP END HOOK: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3105
- if (count ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]))
3106
- echo "POST HOOK: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3107
- if (count ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
3108
- echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3109
- if (count ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
3110
- echo "BETWEEN COMMENTS HOOK ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3111
- if (count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
3112
- echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3113
- if (count ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][AI_PT_ANY]))
3114
- echo "FOOTER HOOK: ", implode (", ", $ai_db_options_extract [FOOTER_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3115
- foreach ($ai_custom_hooks as $hook_index => $custom_hook) {
3116
-
3117
- switch ($custom_hook ['action']) {
3118
- case 'wp_footer':
3119
- case 'wp_head':
3120
- case 'the_content':
3121
- case 'the_excerpt':
3122
- case 'loop_start':
3123
- case 'loop_end':
3124
- case 'the_post':
3125
- continue 2;
3126
- }
3127
-
3128
- if (count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][AI_PT_ANY]))
3129
- echo substr (strtoupper (str_replace (array ('&lt;', '&gt;'), array ('<', '>'), get_hook_name ($custom_hook ['index']))) . " HOOK: ", 0, 25), implode (", ", $ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3130
- }
3131
- if (count ($ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][AI_PT_ANY]))
3132
- echo "HTML ELEMENT: ", implode (", ", $ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3133
-
3134
- echo "\nBLOCKS FOR THIS PAGE TYPE\n";
3135
- 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]]))
3136
- echo "ABOVE HEADER: ", implode (", ", $ai_db_options_extract [ABOVE_HEADER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3137
- 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]]))
3138
- echo "CONTENT HOOK: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3139
- 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]]))
3140
- echo "EXCERPT HOOK: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3141
- 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]]))
3142
- echo "LOOP START HOOK: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3143
- 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]]))
3144
- echo "LOOP END HOOK: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3145
- 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]]))
3146
- echo "POST HOOK: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3147
- 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]]))
3148
- echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3149
- 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]]))
3150
- echo "BETWEEN COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3151
- 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]]))
3152
- echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3153
- 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]]))
3154
- echo "FOOTER HOOK ", implode (", ", $ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3155
- foreach ($ai_custom_hooks as $hook_index => $custom_hook) {
3156
-
3157
- switch ($custom_hook ['action']) {
3158
- case 'wp_footer':
3159
- case 'wp_head':
3160
- case 'the_content':
3161
- case 'the_excerpt':
3162
- case 'loop_start':
3163
- case 'loop_end':
3164
- case 'the_post':
3165
- continue 2;
3166
- }
3167
-
3168
- 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]]))
3169
- echo substr (strtoupper (str_replace (array ('&lt;', '&gt;'), array ('<', '>'), get_hook_name ($custom_hook ['index']))) . " HOOK: ", 0, 25), implode (", ", $ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3170
- }
3171
- 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]]))
3172
- echo "HTML ELEMENT: ", implode (", ", $ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3173
-
3174
- if ($write_processing_log) {
3175
- echo "\nTIME EVENT\n";
3176
- echo "======================================\n";
3177
-
3178
- foreach ($ai_processing_log as $log_line) {
3179
- echo $log_line, "\n";
3180
- }
3181
-
3182
- sort ($block_insertion_log);
3183
- echo "\nINSERTION SUMMARY\n";
3184
- echo "======================================\n";
3185
- foreach ($block_insertion_log as $log_line) {
3186
- echo substr ($log_line, 3), "\n";
3187
- }
3188
- echo "\n\n";
3189
-
3190
- echo "PHP: ", phpversion(), "\n";
3191
- echo "Memory Limit: ", ini_get ('memory_limit'), "\n";
3192
- echo "Upload Max Filesize: ", ini_get ('upload_max_filesize'), "\n";
3193
- echo "Post Max Size: ", ini_get ('post_max_size'), "\n";
3194
- echo "Max Execution Time: ", ini_get ('max_execution_time'), "\n";
3195
- echo "Max Input Vars: ", ini_get ('max_input_vars'), "\n";
3196
- echo "Display Errors: ", ini_get ('display_errors'), "\n";
3197
- echo "cURL: ", function_exists ('curl_version') ? 'ENABLED' : 'DISABLED', "\n";
3198
- echo "fsockopen: ", function_exists ('fsockopen') ? 'ENABLED' : 'DISABLED', "\n";
3199
- echo "DOMDocument: ", class_exists ('DOMDocument') ? 'YES' : 'NO', "\n";
3200
- echo "\n\n";
3201
-
3202
- global $wp_version;
3203
- echo "Wordpress: ", $wp_version, "\n";
3204
- $current_theme = wp_get_theme();
3205
-
3206
- echo "Current Theme: ", $current_theme->get ('Name') . " " . $current_theme->get ('Version'), "\n";
3207
- echo "\n";
3208
- echo "A INSTALLED PLUGINS\n";
3209
- echo "======================================\n";
3210
-
3211
- if ( ! function_exists( 'get_plugins' ) ) {
3212
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
3213
- }
3214
- $all_plugins = get_plugins();
3215
- $active_plugins = get_option ('active_plugins');
3216
- $active_sitewide_plugins = is_multisite () ? get_site_option ('active_sitewide_plugins') : false;
3217
-
3218
- foreach ($all_plugins as $plugin_path => $plugin) {
3219
- $multisite_status = ' ';
3220
- if ($active_sitewide_plugins !== false) {
3221
- $multisite_status = array_key_exists ($plugin_path, $active_sitewide_plugins) ? '# ' : ' ';
3222
- }
3223
- echo in_array ($plugin_path, $active_plugins) ? '* ' : $multisite_status, html_entity_decode ($plugin ["Name"]), ' ', $plugin ["Version"], "\n";
3224
- }
3225
- }
3226
-
3227
-
3228
- }
3229
-
3230
- function ai_shutdown_hook () {
3231
- global $ai_wp_data;
3232
-
3233
- if (function_exists ('ai_system_output')) ai_system_output ();
3234
-
3235
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)) {
3236
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_HOMEPAGE ||
3237
- $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC ||
3238
- $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST ||
3239
- $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_CATEGORY ||
3240
- $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_SEARCH ||
3241
- $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ARCHIVE ||
3242
- $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 ||
3243
- $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_NONE ||
3244
- $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ANY) {
3245
- echo "\n<!--\n\n";
3246
- ai_write_debug_info (true);
3247
- echo "\n-->\n";
3248
- }
3249
- }
3250
- }
3251
-
3252
- function ai_check_multisite_options (&$multisite_options) {
3253
- if (!isset ($multisite_options ['MULTISITE_SETTINGS_PAGE'])) $multisite_options ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
3254
- if (!isset ($multisite_options ['MULTISITE_WIDGETS'])) $multisite_options ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS;
3255
- if (!isset ($multisite_options ['MULTISITE_PHP_PROCESSING'])) $multisite_options ['MULTISITE_PHP_PROCESSING'] = DEFAULT_MULTISITE_PHP_PROCESSING;
3256
- if (!isset ($multisite_options ['MULTISITE_EXCEPTIONS'])) $multisite_options ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS;
3257
- if (!isset ($multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'])) $multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS;
3258
-
3259
- if (function_exists ('ai_check_multisite_options_2')) ai_check_multisite_options_2 ($multisite_options);
3260
- }
3261
-
3262
- function ai_check_plugin_options ($plugin_options = array ()) {
3263
- global $version_string;
3264
-
3265
- $plugin_options ['VERSION'] = $version_string;
3266
-
3267
- if (!isset ($plugin_options ['SYNTAX_HIGHLIGHTER_THEME'])) $plugin_options ['SYNTAX_HIGHLIGHTER_THEME'] = DEFAULT_SYNTAX_HIGHLIGHTER_THEME;
3268
-
3269
- if (!isset ($plugin_options ['BLOCK_CLASS_NAME'])) $plugin_options ['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME;
3270
- if (!isset ($plugin_options ['BLOCK_CLASS'])) $plugin_options ['BLOCK_CLASS'] = DEFAULT_BLOCK_CLASS;
3271
- if (!isset ($plugin_options ['BLOCK_NUMBER_CLASS'])) $plugin_options ['BLOCK_NUMBER_CLASS'] = DEFAULT_BLOCK_NUMBER_CLASS;
3272
- if (!isset ($plugin_options ['INLINE_STYLES'])) $plugin_options ['INLINE_STYLES'] = DEFAULT_INLINE_STYLES;
3273
-
3274
- if (!isset ($plugin_options ['MINIMUM_USER_ROLE'])) $plugin_options ['MINIMUM_USER_ROLE'] = DEFAULT_MINIMUM_USER_ROLE;
3275
-
3276
- if (!isset ($plugin_options ['STICKY_WIDGET_MODE'])) $plugin_options ['STICKY_WIDGET_MODE'] = DEFAULT_STICKY_WIDGET_MODE;
3277
-
3278
- if (!isset ($plugin_options ['STICKY_WIDGET_MARGIN'])) $plugin_options ['STICKY_WIDGET_MARGIN'] = DEFAULT_STICKY_WIDGET_MARGIN;
3279
- $sticky_widget_margin = $plugin_options ['STICKY_WIDGET_MARGIN'];
3280
- if (!is_numeric ($sticky_widget_margin)) {
3281
- $sticky_widget_margin = DEFAULT_STICKY_WIDGET_MARGIN;
3282
- }
3283
- $sticky_widget_margin = intval ($sticky_widget_margin);
3284
- if ($sticky_widget_margin < 0) {
3285
- $sticky_widget_margin = 0;
3286
- }
3287
- if ($sticky_widget_margin > 999) {
3288
- $sticky_widget_margin = 999;
3289
- }
3290
- $plugin_options ['STICKY_WIDGET_MARGIN'] = $sticky_widget_margin;
3291
-
3292
-
3293
- if (!isset ($plugin_options ['PLUGIN_PRIORITY'])) $plugin_options ['PLUGIN_PRIORITY'] = DEFAULT_PLUGIN_PRIORITY;
3294
- $plugin_priority = $plugin_options ['PLUGIN_PRIORITY'];
3295
- if (!is_numeric ($plugin_priority)) {
3296
- $plugin_priority = DEFAULT_PLUGIN_PRIORITY;
3297
- }
3298
- $plugin_priority = intval ($plugin_priority);
3299
- if ($plugin_priority < 0) {
3300
- $plugin_priority = 0;
3301
- }
3302
- if ($plugin_priority > 999999) {
3303
- $plugin_priority = 999999;
3304
- }
3305
- $plugin_options ['PLUGIN_PRIORITY'] = $plugin_priority;
3306
-
3307
-
3308
- if (!isset ($plugin_options ['DYNAMIC_BLOCKS'])) $plugin_options ['DYNAMIC_BLOCKS'] = DEFAULT_DYNAMIC_BLOCKS;
3309
- if (!isset ($plugin_options ['PARAGRAPH_COUNTING_FUNCTIONS'])) $plugin_options ['PARAGRAPH_COUNTING_FUNCTIONS'] = DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS;
3310
- if (!isset ($plugin_options ['OUTPUT_BUFFERING'])) $plugin_options ['OUTPUT_BUFFERING'] = DEFAULT_OUTPUT_BUFFERING;
3311
- if (!isset ($plugin_options ['NO_PARAGRAPH_COUNTING_INSIDE'])) $plugin_options ['NO_PARAGRAPH_COUNTING_INSIDE'] = DEFAULT_NO_PARAGRAPH_COUNTING_INSIDE;
3312
- if (!isset ($plugin_options ['AD_LABEL'])) $plugin_options ['AD_LABEL'] = DEFAULT_AD_TITLE;
3313
- if (!isset ($plugin_options ['ADB_ACTION'])) $plugin_options ['ADB_ACTION'] = AI_DEFAULT_ADB_ACTION;
3314
- if (!isset ($plugin_options ['ADB_DELAY_ACTION'])) $plugin_options ['ADB_DELAY_ACTION'] = '';
3315
- if (!isset ($plugin_options ['ADB_NO_ACTION_PERIOD'])) $plugin_options ['ADB_NO_ACTION_PERIOD'] = AI_DEFAULT_ADB_NO_ACTION_PERIOD;
3316
- if (!isset ($plugin_options ['ADB_SELECTORS'])) $plugin_options ['ADB_SELECTORS'] = '';
3317
- if (!isset ($plugin_options ['ADB_REDIRECTION_PAGE'])) $plugin_options ['ADB_REDIRECTION_PAGE'] = AI_DEFAULT_ADB_REDIRECTION_PAGE;
3318
- if (!isset ($plugin_options ['ADB_CUSTOM_REDIRECTION_URL'])) $plugin_options ['ADB_CUSTOM_REDIRECTION_URL'] = '';
3319
- if (!isset ($plugin_options ['ADB_OVERLAY_CSS'])) $plugin_options ['ADB_OVERLAY_CSS'] = AI_DEFAULT_ADB_OVERLAY_CSS;
3320
- if (!isset ($plugin_options ['ADB_MESSAGE_CSS'])) $plugin_options ['ADB_MESSAGE_CSS'] = AI_DEFAULT_ADB_MESSAGE_CSS;
3321
- if (!isset ($plugin_options ['ADB_UNDISMISSIBLE_MESSAGE'])) $plugin_options ['ADB_UNDISMISSIBLE_MESSAGE'] = AI_DEFAULT_ADB_UNDISMISSIBLE_MESSAGE;
3322
- if (!isset ($plugin_options ['ADMIN_TOOLBAR_DEBUGGING'])) $plugin_options ['ADMIN_TOOLBAR_DEBUGGING'] = DEFAULT_ADMIN_TOOLBAR_DEBUGGING;
3323
- if (!isset ($plugin_options ['REMOTE_DEBUGGING'])) $plugin_options ['REMOTE_DEBUGGING'] = DEFAULT_REMOTE_DEBUGGING;
3324
- if (!isset ($plugin_options ['BACKEND_JS_DEBUGGING'])) $plugin_options ['BACKEND_JS_DEBUGGING'] = DEFAULT_BACKEND_JS_DEBUGGING;
3325
- if (!isset ($plugin_options ['FRONTEND_JS_DEBUGGING'])) $plugin_options ['FRONTEND_JS_DEBUGGING'] = DEFAULT_FRONTEND_JS_DEBUGGING;
3326
-
3327
- for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
3328
- $viewport_name_option_name = 'VIEWPORT_NAME_' . $viewport;
3329
- $viewport_width_option_name = 'VIEWPORT_WIDTH_' . $viewport;
3330
-
3331
- if (!isset ($plugin_options [$viewport_name_option_name])) $plugin_options [$viewport_name_option_name] =
3332
- defined ("DEFAULT_VIEWPORT_NAME_" . $viewport) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport) : "";
3333
-
3334
- if ($viewport == 1 && $plugin_options [$viewport_name_option_name] == '')
3335
- $plugin_options [$viewport_name_option_name] = constant ("DEFAULT_VIEWPORT_NAME_1");
3336
-
3337
- if ($plugin_options [$viewport_name_option_name] != '') {
3338
- if (!isset ($plugin_options [$viewport_width_option_name])) $plugin_options [$viewport_width_option_name] =
3339
- defined ("DEFAULT_VIEWPORT_WIDTH_" . $viewport) ? constant ("DEFAULT_VIEWPORT_WIDTH_" . $viewport) : 0;
3340
-
3341
- $viewport_width = $plugin_options [$viewport_width_option_name];
3342
-
3343
- if ($viewport > 1) {
3344
- $previous_viewport_option_width = $plugin_options ['VIEWPORT_WIDTH_' . ($viewport - 1)];
3345
- }
3346
-
3347
- if (!is_numeric ($viewport_width)) {
3348
- if ($viewport == 1)
3349
- $viewport_width = constant ("DEFAULT_VIEWPORT_WIDTH_1"); else
3350
- $viewport_width = $previous_viewport_option_width - 1;
3351
-
3352
- }
3353
- if ($viewport_width > 9999) {
3354
- $viewport_width = 9999;
3355
- }
3356
-
3357
- if ($viewport > 1) {
3358
- if ($viewport_width >= $previous_viewport_option_width)
3359
- $viewport_width = $previous_viewport_option_width - 1;
3360
- }
3361
-
3362
- $viewport_width = intval ($viewport_width);
3363
- if ($viewport_width < 0) {
3364
- $viewport_width = 0;
3365
- }
3366
-
3367
- $plugin_options [$viewport_width_option_name] = $viewport_width;
3368
- } else $plugin_options [$viewport_width_option_name] = '';
3369
- }
3370
-
3371
- for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
3372
- $hook_enabled_settins_name = 'HOOK_ENABLED_' . $hook;
3373
- $hook_name_settins_name = 'HOOK_NAME_' . $hook;
3374
- $hook_action_settins_name = 'HOOK_ACTION_' . $hook;
3375
- $hook_priority_settins_name = 'HOOK_PRIORITY_' . $hook;
3376
-
3377
- if (!isset ($plugin_options [$hook_enabled_settins_name])) $plugin_options [$hook_enabled_settins_name] = AI_DISABLED;
3378
- if (!isset ($plugin_options [$hook_name_settins_name])) $plugin_options [$hook_name_settins_name] = '';
3379
- if (!isset ($plugin_options [$hook_action_settins_name])) $plugin_options [$hook_action_settins_name] = '';
3380
- if (!isset ($plugin_options [$hook_priority_settins_name]) || !is_int ($plugin_options [$hook_priority_settins_name])) $plugin_options [$hook_priority_settins_name] = DEFAULT_CUSTOM_HOOK_PRIORITY;
3381
- }
3382
-
3383
- if (function_exists ('ai_check_options')) ai_check_options ($plugin_options);
3384
-
3385
- return ($plugin_options);
3386
- }
3387
-
3388
- function option_stripslashes (&$options) {
3389
- $options = wp_unslash ($options);
3390
-
3391
- // if (is_array ($options)) {
3392
- // foreach ($options as $key => $option) {
3393
- // option_stripslashes ($options [$key]);
3394
- // }
3395
- // } else if (is_string ($options)) $options = stripslashes ($options);
3396
- }
3397
-
3398
- // Deprecated
3399
- function ai_get_option ($option_name) {
3400
- $options = get_option ($option_name);
3401
- option_stripslashes ($options);
3402
- return ($options);
3403
- }
3404
-
3405
- function ai_load_options () {
3406
- global $ai_db_options, $ai_db_options_multisite, $ai_wp_data;
3407
-
3408
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD OPTIONS START");
3409
-
3410
- if (is_multisite()) {
3411
- $ai_db_options_multisite = get_site_option (AI_OPTION_NAME);
3412
- option_stripslashes ($ai_db_options_multisite);
3413
- }
3414
-
3415
- if (is_multisite() && multisite_main_for_all_blogs () && defined ('BLOG_ID_CURRENT_SITE')) {
3416
- $ai_db_options = get_blog_option (BLOG_ID_CURRENT_SITE, AI_OPTION_NAME);
3417
- option_stripslashes ($ai_db_options);
3418
- } else {
3419
- $ai_db_options = get_option (AI_OPTION_NAME);
3420
- option_stripslashes ($ai_db_options);
3421
- }
3422
-
3423
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD OPTIONS END");
3424
- }
3425
-
3426
- function get_viewport_css () {
3427
- global $ai_db_options;
3428
-
3429
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'])) $ai_db_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'] = generate_viewport_css ();
3430
-
3431
- return ($ai_db_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS']);
3432
- }
3433
-
3434
- function get_alignment_css () {
3435
- global $ai_db_options;
3436
-
3437
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS']) ||
3438
- isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] < '020211'
3439
- ) $ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'] = generate_alignment_css ();
3440
-
3441
- return (str_replace ('&#039;', "'", $ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS']));
3442
- }
3443
-
3444
- function get_syntax_highlighter_theme () {
3445
- global $ai_db_options;
3446
-
3447
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['SYNTAX_HIGHLIGHTER_THEME'])) $ai_db_options [AI_OPTION_GLOBAL]['SYNTAX_HIGHLIGHTER_THEME'] = DEFAULT_SYNTAX_HIGHLIGHTER_THEME;
3448
-
3449
- return ($ai_db_options [AI_OPTION_GLOBAL]['SYNTAX_HIGHLIGHTER_THEME']);
3450
- }
3451
-
3452
- function get_block_class_name ($default_if_empty = false) {
3453
- global $ai_db_options;
3454
-
3455
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME'])) $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME;
3456
-
3457
- if ($default_if_empty && $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME'] == '') return (DEFAULT_BLOCK_CLASS_NAME);
3458
-
3459
- return ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME']);
3460
- }
3461
-
3462
- function get_block_class () {
3463
- global $ai_db_options;
3464
-
3465
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS'])) $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS'] = DEFAULT_BLOCK_CLASS;
3466
-
3467
- return ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS']);
3468
- }
3469
-
3470
- function get_block_number_class () {
3471
- global $ai_db_options;
3472
-
3473
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NUMBER_CLASS'])) $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NUMBER_CLASS'] = DEFAULT_BLOCK_NUMBER_CLASS;
3474
-
3475
- return ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NUMBER_CLASS']);
3476
- }
3477
-
3478
- function get_inline_styles () {
3479
- global $ai_db_options;
3480
-
3481
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['INLINE_STYLES'])) $ai_db_options [AI_OPTION_GLOBAL]['INLINE_STYLES'] = DEFAULT_INLINE_STYLES;
3482
-
3483
- return ($ai_db_options [AI_OPTION_GLOBAL]['INLINE_STYLES']);
3484
- }
3485
-
3486
- function get_minimum_user_role () {
3487
- global $ai_db_options;
3488
-
3489
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['MINIMUM_USER_ROLE'])) $ai_db_options [AI_OPTION_GLOBAL]['MINIMUM_USER_ROLE'] = DEFAULT_MINIMUM_USER_ROLE;
3490
-
3491
- return ($ai_db_options [AI_OPTION_GLOBAL]['MINIMUM_USER_ROLE']);
3492
- }
3493
-
3494
- function get_sticky_widget_mode () {
3495
- global $ai_db_options;
3496
-
3497
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE'])) $ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE'] = DEFAULT_STICKY_WIDGET_MODE;
3498
-
3499
- return ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE']);
3500
- }
3501
-
3502
- function get_sticky_widget_margin () {
3503
- global $ai_db_options;
3504
-
3505
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MARGIN'])) $ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MARGIN'] = DEFAULT_STICKY_WIDGET_MARGIN;
3506
-
3507
- return ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MARGIN']);
3508
- }
3509
-
3510
- function get_plugin_priority () {
3511
- global $ai_db_options;
3512
-
3513
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_PRIORITY'])) $ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_PRIORITY'] = DEFAULT_PLUGIN_PRIORITY;
3514
-
3515
- return ($ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_PRIORITY']);
3516
- }
3517
-
3518
- function get_dynamic_blocks(){
3519
- global $ai_db_options;
3520
-
3521
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DYNAMIC_BLOCKS'])) $ai_db_options [AI_OPTION_GLOBAL]['DYNAMIC_BLOCKS'] = DEFAULT_DYNAMIC_BLOCKS;
3522
-
3523
- return ($ai_db_options [AI_OPTION_GLOBAL]['DYNAMIC_BLOCKS']);
3524
- }
3525
-
3526
- function get_paragraph_counting_functions(){
3527
- global $ai_db_options;
3528
-
3529
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['PARAGRAPH_COUNTING_FUNCTIONS'])) $ai_db_options [AI_OPTION_GLOBAL]['PARAGRAPH_COUNTING_FUNCTIONS'] = DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS;
3530
-
3531
- return ($ai_db_options [AI_OPTION_GLOBAL]['PARAGRAPH_COUNTING_FUNCTIONS']);
3532
- }
3533
-
3534
- function get_output_buffering(){
3535
- global $ai_db_options;
3536
-
3537
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING'])) $ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING'] = DEFAULT_OUTPUT_BUFFERING;
3538
-
3539
- return ($ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING']);
3540
- }
3541
-
3542
- function get_no_paragraph_counting_inside () {
3543
- global $ai_db_options;
3544
-
3545
- 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;
3546
-
3547
- return (str_replace (array ('<', '>'), '', $ai_db_options [AI_OPTION_GLOBAL]['NO_PARAGRAPH_COUNTING_INSIDE']));
3548
- }
3549
-
3550
- function get_ad_label ($decode = false) {
3551
- global $ai_db_options;
3552
-
3553
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL'])) $ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL'] = DEFAULT_AD_TITLE;
3554
-
3555
- if ($decode) return (html_entity_decode ($ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL']));
3556
-
3557
- return ($ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL']);
3558
- }
3559
-
3560
- function get_admin_toolbar_debugging () {
3561
- global $ai_db_options;
3562
-
3563
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_DEBUGGING'] = DEFAULT_ADMIN_TOOLBAR_DEBUGGING;
3564
-
3565
- return ($ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_DEBUGGING']);
3566
- }
3567
-
3568
- function get_remote_debugging () {
3569
- global $ai_db_options;
3570
-
3571
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['REMOTE_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['REMOTE_DEBUGGING'] = DEFAULT_REMOTE_DEBUGGING;
3572
-
3573
- return ($ai_db_options [AI_OPTION_GLOBAL]['REMOTE_DEBUGGING']);
3574
- }
3575
-
3576
- function get_backend_javascript_debugging () {
3577
- global $ai_db_options;
3578
-
3579
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BACKEND_JS_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['BACKEND_JS_DEBUGGING'] = DEFAULT_BACKEND_JS_DEBUGGING;
3580
-
3581
- return ($ai_db_options [AI_OPTION_GLOBAL]['BACKEND_JS_DEBUGGING']);
3582
- }
3583
-
3584
- function get_frontend_javascript_debugging () {
3585
- global $ai_db_options;
3586
-
3587
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['FRONTEND_JS_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['FRONTEND_JS_DEBUGGING'] = DEFAULT_FRONTEND_JS_DEBUGGING;
3588
-
3589
- return ($ai_db_options [AI_OPTION_GLOBAL]['FRONTEND_JS_DEBUGGING']);
3590
- }
3591
-
3592
- function get_viewport_name ($viewport_number) {
3593
- global $ai_db_options;
3594
-
3595
- $viewport_settins_name = 'VIEWPORT_NAME_' . $viewport_number;
3596
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]))
3597
- $ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name] = defined ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) : "";
3598
-
3599
- return ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]);
3600
- }
3601
-
3602
- function get_viewport_width ($viewport_number) {
3603
- global $ai_db_options;
3604
-
3605
- $viewport_settins_name = 'VIEWPORT_WIDTH_' . $viewport_number;
3606
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]))
3607
- $ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name] = defined ("DEFAULT_VIEWPORT_WIDTH_" . $viewport_number) ? constant ("DEFAULT_VIEWPORT_WIDTH_" . $viewport_number) : "";
3608
-
3609
- return ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]);
3610
- }
3611
-
3612
- function get_hook_enabled ($hook_number) {
3613
- global $ai_db_options;
3614
-
3615
- $hook_settins_name = 'HOOK_ENABLED_' . $hook_number;
3616
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = AI_DISABLED;
3617
-
3618
- return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
3619
- }
3620
-
3621
- function get_hook_name ($hook_number) {
3622
- global $ai_db_options;
3623
-
3624
- $hook_settins_name = 'HOOK_NAME_' . $hook_number;
3625
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = "";
3626
-
3627
- return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
3628
- }
3629
-
3630
- function get_hook_action ($hook_number) {
3631
- global $ai_db_options;
3632
-
3633
- $hook_settins_name = 'HOOK_ACTION_' . $hook_number;
3634
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = "";
3635
-
3636
- return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
3637
- }
3638
-
3639
- function get_hook_priority ($hook_number) {
3640
- global $ai_db_options;
3641
-
3642
- $hook_settins_name = 'HOOK_PRIORITY_' . $hook_number;
3643
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = DEFAULT_CUSTOM_HOOK_PRIORITY;
3644
-
3645
- return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
3646
- }
3647
-
3648
- function get_country_group_name ($group_number) {
3649
- global $ai_db_options;
3650
-
3651
- $country_group_settins_name = 'COUNTRY_GROUP_NAME_' . $group_number;
3652
- 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;
3653
-
3654
- return ($ai_db_options [AI_OPTION_GLOBAL][$country_group_settins_name]);
3655
- }
3656
-
3657
- function get_group_country_list ($group_number) {
3658
- global $ai_db_options;
3659
-
3660
- $group_countries_settins_name = 'GROUP_COUNTRIES_' . $group_number;
3661
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$group_countries_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$group_countries_settins_name] = '';
3662
-
3663
- return ($ai_db_options [AI_OPTION_GLOBAL][$group_countries_settins_name]);
3664
- }
3665
-
3666
- function multisite_settings_page_enabled () {
3667
- global $ai_db_options_multisite;
3668
-
3669
- if (is_multisite()) {
3670
- if (!isset ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'])) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
3671
- if ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] == '') $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
3672
-
3673
- if (multisite_main_for_all_blogs ()) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = AI_DISABLED;
3674
-
3675
- return ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE']);
3676
- }
3677
-
3678
- return DEFAULT_MULTISITE_SETTINGS_PAGE;
3679
- }
3680
-
3681
- function multisite_widgets_enabled () {
3682
- global $ai_db_options_multisite;
3683
-
3684
- if (is_multisite()) {
3685
- if (!isset ($ai_db_options_multisite ['MULTISITE_WIDGETS'])) $ai_db_options_multisite ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS;
3686
- if ($ai_db_options_multisite ['MULTISITE_WIDGETS'] == '') $ai_db_options_multisite ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS;
3687
-
3688
- return ($ai_db_options_multisite ['MULTISITE_WIDGETS']);
3689
- }
3690
-
3691
- return DEFAULT_MULTISITE_WIDGETS;
3692
- }
3693
-
3694
- function multisite_php_processing () {
3695
- global $ai_db_options_multisite;
3696
-
3697
- if (is_multisite()) {
3698
- if (!isset ($ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'])) $ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'] = DEFAULT_MULTISITE_PHP_PROCESSING;
3699
- if ($ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'] == '') $ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'] = DEFAULT_MULTISITE_PHP_PROCESSING;
3700
-
3701
- return ($ai_db_options_multisite ['MULTISITE_PHP_PROCESSING']);
3702
- }
3703
-
3704
- return DEFAULT_MULTISITE_WIDGETS;
3705
- }
3706
-
3707
- function multisite_exceptions_enabled () {
3708
- global $ai_db_options_multisite;
3709
-
3710
- if (is_multisite()) {
3711
- if (!isset ($ai_db_options_multisite ['MULTISITE_EXCEPTIONS'])) $ai_db_options_multisite ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS;
3712
- if ($ai_db_options_multisite ['MULTISITE_EXCEPTIONS'] == '') $ai_db_options_multisite ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS;
3713
-
3714
- return ($ai_db_options_multisite ['MULTISITE_EXCEPTIONS']);
3715
- }
3716
-
3717
- return DEFAULT_MULTISITE_EXCEPTIONS;
3718
- }
3719
-
3720
- function multisite_main_for_all_blogs () {
3721
- global $ai_db_options_multisite;
3722
-
3723
- if (is_multisite()) {
3724
- 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;
3725
- 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;
3726
-
3727
- return ($ai_db_options_multisite ['MULTISITE_MAIN_FOR_ALL_BLOGS']);
3728
- }
3729
-
3730
- return DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS;
3731
- }
3732
-
3733
- function get_adb_action ($saved_value = false) {
3734
- global $ai_db_options, $ai_wp_data;
3735
-
3736
- if (!$saved_value) {
3737
- if (isset ($ai_wp_data [AI_ADB_SHORTCODE_ACTION])) return ($ai_wp_data [AI_ADB_SHORTCODE_ACTION]);
3738
- }
3739
-
3740
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION'] = AI_DEFAULT_ADB_ACTION;
3741
-
3742
- return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION']);
3743
- }
3744
-
3745
- function get_delay_action ($return_number = false) {
3746
- global $ai_db_options;
3747
-
3748
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION'] = '';
3749
-
3750
- if ($return_number) {
3751
- $value = trim ($ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION']);
3752
- if ($value == '') $value = 0;
3753
- if (is_numeric ($value)) return $value; else return 0;
3754
- }
3755
-
3756
- return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION']);
3757
- }
3758
-
3759
- function get_no_action_period ($return_number = false) {
3760
- global $ai_db_options;
3761
-
3762
- 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;
3763
-
3764
- if ($return_number) {
3765
- $value = trim ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION_PERIOD']);
3766
- if ($value == '') $value = 0;
3767
- if (is_numeric ($value)) return $value; else return AI_DEFAULT_ADB_NO_ACTION_PERIOD;
3768
- }
3769
-
3770
- return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION_PERIOD']);
3771
- }
3772
-
3773
- function get_adb_selectors ($decode = false) {
3774
- global $ai_db_options;
3775
-
3776
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'] = '';
3777
-
3778
- if ($decode)
3779
- return (html_entity_decode ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'])); else
3780
- return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS']);
3781
- }
3782
-
3783
- function get_redirection_page ($return_number = false) {
3784
- global $ai_db_options;
3785
-
3786
- 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;
3787
-
3788
- if ($return_number) {
3789
- $value = trim ($ai_db_options [AI_OPTION_GLOBAL]['ADB_REDIRECTION_PAGE']);
3790
- if ($value == '') $value = 0;
3791
- if (is_numeric ($value)) return $value; else return AI_DEFAULT_ADB_REDIRECTION_PAGE;
3792
- }
3793
-
3794
- return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_REDIRECTION_PAGE']);
3795
- }
3796
-
3797
- function get_custom_redirection_url () {
3798
- global $ai_db_options;
3799
-
3800
- if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_CUSTOM_REDIRECTION_URL'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_CUSTOM_REDIRECTION_URL'] = '';
3801
-
3802
- return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_CUSTOM_REDIRECTION_URL']);
3803
- }
3804
-
3805
- function get_message_css () {
3806
- global $ai_db_options;
3807
-
3808
- 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;
3809
-
3810
- return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_MESSAGE_CSS']);
3811
- }
3812
-
3813
- function get_overlay_css () {
3814
- global $ai_db_options;
3815
-
3816
- 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;
3817
-
3818
- return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_OVERLAY_CSS']);
3819
- }
3820
-
3821
- function get_undismissible_message () {
3822
- global $ai_db_options;
3823
-
3824
- 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;
3825
-
3826
- return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_UNDISMISSIBLE_MESSAGE']);
3827
- }
3828
-
3829
- function filter_html_class ($str){
3830
-
3831
- $str = str_replace (array ("\\\""), array ("\""), $str);
3832
- $str = sanitize_html_class ($str);
3833
-
3834
- return $str;
3835
- }
3836
-
3837
- function filter_string ($str){
3838
-
3839
- $str = str_replace (array ("\\\""), array ("\""), $str);
3840
- $str = str_replace (array ("\"", "<", ">"), "", $str);
3841
- $str = trim (esc_html ($str));
3842
-
3843
- return $str;
3844
- }
3845
-
3846
- function filter_string_tags ($str){
3847
-
3848
- $str = str_replace (array ("\\\""), array ("\""), $str);
3849
- $str = str_replace (array ("\""), "", $str);
3850
- $str = str_replace (array ("<", ">"), array ("&lt;", "&gt;"), $str);
3851
- $str = trim (esc_html ($str));
3852
-
3853
- return $str;
3854
- }
3855
-
3856
- function filter_option ($option, $value, $delete_escaped_backslashes = true){
3857
- if ($delete_escaped_backslashes)
3858
- $value = str_replace (array ("\\\""), array ("\""), $value);
3859
-
3860
- if ($option == 'ADB_SELECTORS' ||
3861
- $option == AI_OPTION_HTML_SELECTOR) {
3862
- // $value = str_replace (array ("\\", "/", "?", "\"", "'", "<", ">", "'", '"'), "", $value);
3863
- $value = str_replace (array ("\\", "/", "?", "\"", "'", "'", '"'), "", $value);
3864
- $value = esc_html ($value);
3865
- }
3866
- elseif ($option == AI_OPTION_DOMAIN_LIST ||
3867
- $option == 'NO_PARAGRAPH_COUNTING_INSIDE' ||
3868
- $option == AI_OPTION_PARAGRAPH_TAGS ||
3869
- $option == AI_OPTION_IP_ADDRESS_LIST ||
3870
- $option == AI_OPTION_COUNTRY_LIST) {
3871
- $value = str_replace (array ("\\", "/", "?", "\"", "'", "<", ">", "[", "]", "'", '"'), "", $value);
3872
- $value = esc_html ($value);
3873
- }
3874
- elseif (
3875
- $option == AI_OPTION_PARAGRAPH_TEXT ||
3876
- $option == AI_OPTION_AVOID_TEXT_ABOVE ||
3877
- $option == AI_OPTION_AVOID_TEXT_BELOW
3878
- ) {
3879
- $value = esc_html ($value);
3880
- }
3881
- elseif ($option == AI_OPTION_BLOCK_NAME ||
3882
- $option == AI_OPTION_GENERAL_TAG ||
3883
- $option == AI_OPTION_DOMAIN_LIST ||
3884
- $option == AI_OPTION_CATEGORY_LIST ||
3885
- $option == AI_OPTION_TAG_LIST ||
3886
- $option == AI_OPTION_ID_LIST ||
3887
- $option == AI_OPTION_URL_LIST ||
3888
- $option == AI_OPTION_URL_PARAMETER_LIST ||
3889
- $option == AI_OPTION_PARAGRAPH_TEXT_TYPE ||
3890
- $option == AI_OPTION_PARAGRAPH_NUMBER ||
3891
- $option == AI_OPTION_MIN_PARAGRAPHS ||
3892
- $option == AI_OPTION_MIN_WORDS_ABOVE ||
3893
- $option == AI_OPTION_AVOID_PARAGRAPHS_ABOVE ||
3894
- $option == AI_OPTION_AVOID_PARAGRAPHS_BELOW ||
3895
- $option == AI_OPTION_AVOID_TRY_LIMIT ||
3896
- $option == AI_OPTION_MIN_WORDS ||
3897
- $option == AI_OPTION_MAX_WORDS ||
3898
- $option == AI_OPTION_MIN_PARAGRAPH_WORDS ||
3899
- $option == AI_OPTION_MAX_PARAGRAPH_WORDS ||
3900
- $option == AI_OPTION_MAXIMUM_INSERTIONS ||
3901
- $option == AI_OPTION_AFTER_DAYS ||
3902
- $option == AI_OPTION_START_DATE ||
3903
- $option == AI_OPTION_END_DATE ||
3904
- $option == AI_OPTION_FALLBACK ||
3905
- $option == AI_OPTION_EXCERPT_NUMBER ||
3906
- $option == 'ADB_DELAY_ACTION' ||
3907
- $option == 'ADB_NO_ACTION_PERIOD' ||
3908
- $option == 'ADB_REDIRECTION_PAGE' ||
3909
- $option == 'ADB_CUSTOM_REDIRECTION_URL' ||
3910
- $option == AI_OPTION_CUSTOM_CSS ||
3911
- $option == 'HOOK_PRIORITY' ||
3912
- $option == 'ADB_OVERLAY_CSS' ||
3913
- $option == 'ADB_MESSAGE_CSS') {
3914
- $value = str_replace (array ("\"", "<", ">", "[", "]"), "", $value);
3915
- $value = esc_html ($value);
3916
- }
3917
- elseif ($option == 'AD_LABEL' ) {
3918
- $value = str_replace (array ("\\", "?"), "", $value);
3919
- $value = esc_html ($value);
3920
- }
3921
-
3922
- return $value;
3923
- }
3924
-
3925
- function filter_option_hf ($option, $value){
3926
- $value = str_replace (array ("\\\""), array ("\""), $value);
3927
-
3928
- // if ($option == AI_OPTION_CODE ) {
3929
- // } elseif ($option == AI_OPTION_ENABLE_MANUAL) {
3930
- // } elseif ($option == AI_OPTION_PROCESS_PHP) {
3931
- // } elseif ($option == AI_OPTION_ENABLE_404) {
3932
- // } elseif ($option == AI_OPTION_DETECT_SERVER_SIDE) {
3933
- // } elseif ($option == AI_OPTION_DISPLAY_FOR_DEVICES) {
3934
- // }
3935
-
3936
- return $value;
3937
- }
3938
-
3939
- function ai_ajax () {
3940
-
3941
- // check_ajax_referer ("adinserter_data", "ai_check");
3942
- // check_admin_referer ("adinserter_data", "ai_check");
3943
-
3944
- if (isset ($_POST ["adsense-ad-units"])) {
3945
- if (defined ('AI_ADSENSE_API')) {
3946
- adsense_ad_name ($_POST ["adsense-ad-units"]);
3947
- }
3948
- }
3949
-
3950
- elseif (function_exists ('ai_ajax_processing_2')) {
3951
- ai_ajax_processing_2 ();
3952
- }
3953
-
3954
- wp_die ();
3955
- }
3956
-
3957
- function ai_ajax_backend () {
3958
- global $preview_name, $preview_alignment, $preview_css;
3959
-
3960
- // check_ajax_referer ("adinserter_data", "ai_check");
3961
- check_admin_referer ("adinserter_data", "ai_check");
3962
-
3963
- if (isset ($_POST ["preview"])) {
3964
- $block = urldecode ($_POST ["preview"]);
3965
- if (is_numeric ($block) && $block >= 1 && $block <= AD_INSERTER_BLOCKS) {
3966
- require_once AD_INSERTER_PLUGIN_DIR.'includes/preview.php';
3967
- generate_code_preview (
3968
- $block,
3969
- isset ($_POST ["name"]) ? base64_decode ($_POST ["name"]) : null,
3970
- isset ($_POST ["alignment"]) ? base64_decode ($_POST ["alignment"]) : null,
3971
- isset ($_POST ["horizontal"]) ? base64_decode ($_POST ["horizontal"]) : null,
3972
- isset ($_POST ["vertical"]) ? base64_decode ($_POST ["vertical"]) : null,
3973
- isset ($_POST ["alignment_css"]) ? base64_decode ($_POST ["alignment_css"]) : null,
3974
- isset ($_POST ["custom_css"]) ? base64_decode ($_POST ["custom_css"]) : null,
3975
- isset ($_POST ["code"]) ? base64_decode ($_POST ["code"]) : null,
3976
- isset ($_POST ["php"]) ? $_POST ["php"] == 1 : null,
3977
- isset ($_POST ["label"]) ? $_POST ["label"] == 1 : null,
3978
- isset ($_POST ["close"]) ? $_POST ["close"] : null,
3979
- isset ($_POST ["read_only"]) ? true : false
3980
- );
3981
- }
3982
- elseif ($block == 'adb') {
3983
- require_once AD_INSERTER_PLUGIN_DIR.'includes/preview-adb.php';
3984
- // generate_code_preview_adb (wp_unslash (urldecode (base64_decode ($_POST ["code"]))), urldecode ($_POST ["php"]) == 1);
3985
- generate_code_preview_adb (base64_decode ($_POST ["code"]), $_POST ["php"] == 1);
3986
- }
3987
- elseif ($block == 'adsense') {
3988
-
3989
- if (defined ('AI_ADSENSE_API')) {
3990
- require_once AD_INSERTER_PLUGIN_DIR.'includes/preview.php';
3991
- require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php';
3992
-
3993
- if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) {
3994
-
3995
- $adsense = new adsense_api();
3996
-
3997
- $adsense_code = $adsense->getAdCode (base64_decode ($_POST ["slot_id"]));
3998
- $adsense_error = $adsense->getError ();
3999
-
4000
- generate_code_preview (
4001
- 0,
4002
- isset ($_POST ["name"]) ? base64_decode ($_POST ["name"]) : 'ADSENSE CODE',
4003
- '',
4004
- '',
4005
- '',
4006
- '',
4007
- '',
4008
- $adsense_error == '' ? $adsense_code : '<div style="color: red;">'.$adsense_error.'</div>',
4009
- false,
4010
- AI_CLOSE_NONE,
4011
- true
4012
- );
4013
-
4014
- }
4015
- }
4016
- }
4017
- }
4018
-
4019
- elseif (isset ($_POST ["edit"])) {
4020
- if (is_numeric ($_POST ["edit"]) && $_POST ["edit"] >= 1 && $_POST ["edit"] <= AD_INSERTER_BLOCKS) {
4021
- require_once AD_INSERTER_PLUGIN_DIR.'includes/editor.php';
4022
- // generate_code_editor ($_POST ["edit"], wp_unslash (urldecode (base64_decode ($_POST ["code"]))), urldecode ($_POST ["php"]) == 1);
4023
- generate_code_editor ($_POST ["edit"], base64_decode ($_POST ["code"]), $_POST ["php"] == 1);
4024
- }
4025
- }
4026
-
4027
- if (isset ($_POST ["placeholder"])) {
4028
- $block = urldecode ($_POST ["block"]);
4029
- if (is_numeric ($block) && $block >= 1 && $block <= AD_INSERTER_BLOCKS) {
4030
- require_once AD_INSERTER_PLUGIN_DIR.'includes/placeholders.php';
4031
-
4032
- generate_placeholder_editor (str_replace (array ('"', "\\'"), array ('&quot', '&#039'), urldecode ($_POST ["placeholder"])), $block);
4033
- }
4034
- }
4035
-
4036
- elseif (isset ($_POST ["generate-code"])) {
4037
- $code_generator = new ai_code_generator ();
4038
-
4039
- echo json_encode ($code_generator->generate ($_POST));
4040
- }
4041
-
4042
- elseif (isset ($_POST ["import-code"])) {
4043
- $code_generator = new ai_code_generator ();
4044
-
4045
- echo json_encode ($code_generator->import (base64_decode ($_POST ["import-code"])));
4046
- }
4047
-
4048
- elseif (isset ($_POST ["import-rotation-code"])) {
4049
- $code_generator = new ai_code_generator ();
4050
-
4051
- echo json_encode ($code_generator->import_rotation (base64_decode ($_POST ["import-rotation-code"])));
4052
- }
4053
-
4054
- elseif (isset ($_POST ["generate-rotation-code"])) {
4055
- $code_generator = new ai_code_generator ();
4056
-
4057
- echo json_encode ($code_generator->generate_rotation (json_decode (base64_decode ($_POST ['generate-rotation-code']), true)));
4058
- }
4059
-
4060
- elseif (isset ($_GET ["image"])) {
4061
- header ("Content-Type: image/png");
4062
- header ("Content-Length: " . filesize (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]));
4063
- readfile (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]);
4064
- }
4065
-
4066
- elseif (isset ($_GET ["rating"])) {
4067
- $cache_time = $_GET ["rating"] == 'update' ? 0 * 60 : AI_TRANSIENT_RATING_EXPIRATION;
4068
- if (!get_transient (AI_TRANSIENT_RATING) || !($transient_timeout = get_option ('_transient_timeout_' . AI_TRANSIENT_RATING)) || AI_TRANSIENT_RATING_EXPIRATION - ($transient_timeout - time ()) > $cache_time) {
4069
- $args = (object) array ('slug' => 'ad-inserter');
4070
- $request = array ('action' => 'plugin_information', 'timeout' => 5, 'request' => serialize ($args));
4071
- $url = 'http://api.wordpress.org/plugins/info/1.0/';
4072
- $response = wp_remote_post ($url, array ('body' => $request));
4073
- $plugin_info = @unserialize ($response ['body']);
4074
- if (isset ($plugin_info->ratings)) {
4075
- $total_rating = 0;
4076
- $total_count = 0;
4077
- foreach ($plugin_info->ratings as $rating => $count) {
4078
- $total_rating += $rating * $count;
4079
- $total_count += $count;
4080
- }
4081
- $rating = number_format ($total_rating / $total_count, 4);
4082
- set_transient (AI_TRANSIENT_RATING, $rating, AI_TRANSIENT_RATING_EXPIRATION);
4083
- }
4084
- }
4085
- if ($rating = get_transient (AI_TRANSIENT_RATING)) {
4086
- if ($rating > 1 && $rating <= 5) echo $rating;
4087
- }
4088
- }
4089
-
4090
- elseif (isset ($_POST ["notice"])) {
4091
- update_option ('ai-notice-' . $_POST ["notice"], $_POST ["click"]);
4092
- }
4093
-
4094
- elseif (isset ($_POST ["notice-check"])) {
4095
- echo $_POST ["notice-check"];
4096
- }
4097
-
4098
- elseif (isset ($_GET ["list"])) {
4099
- code_block_list ();
4100
- }
4101
-
4102
- elseif (isset ($_GET ["adsense-list"])) {
4103
- if (defined ('AI_ADSENSE_API')) {
4104
- adsense_list ();
4105
- }
4106
- }
4107
-
4108
- elseif (isset ($_GET ["adsense-code"])) {
4109
- if (defined ('AI_ADSENSE_API')) {
4110
- ai_adsense_code ($_GET ["adsense-code"]);
4111
- }
4112
- }
4113
-
4114
- elseif (isset ($_GET ["adsense-authorization-code"])) {
4115
- if (defined ('AI_ADSENSE_API')) {
4116
- if ($_GET ['adsense-authorization-code'] == '') {
4117
- delete_option (AI_ADSENSE_CLIENT_IDS);
4118
- delete_option (AI_ADSENSE_AUTH_CODE);
4119
-
4120
- delete_transient (AI_TRANSIENT_ADSENSE_TOKEN);
4121
- delete_transient (AI_TRANSIENT_ADSENSE_ADS);
4122
- } else update_option (AI_ADSENSE_AUTH_CODE, base64_decode ($_GET ['adsense-authorization-code']));
4123
- }
4124
- }
4125
-
4126
- elseif (isset ($_GET ["adsense-client-id"])) {
4127
- if (defined ('AI_ADSENSE_API')) {
4128
- if ($_GET ['adsense-client-id'] == '') {
4129
- delete_option (AI_ADSENSE_CLIENT_IDS);
4130
- delete_option (AI_ADSENSE_AUTH_CODE);
4131
-
4132
- delete_transient (AI_TRANSIENT_ADSENSE_TOKEN);
4133
- delete_transient (AI_TRANSIENT_ADSENSE_ADS);
4134
- } else update_option (AI_ADSENSE_CLIENT_IDS, array ('ID' => base64_decode ($_GET ['adsense-client-id']), 'SECRET' => base64_decode ($_GET ['adsense-client-secret'])));
4135
- }
4136
- }
4137
-
4138
- elseif (isset ($_GET ["settings"])) {
4139
- generate_settings_form ();
4140
- }
4141
-
4142
- elseif (isset ($_GET ["list-options"])) {
4143
- generate_list_options ($_GET ["list-options"]);
4144
- }
4145
-
4146
- elseif (isset ($_GET ["update"])) {
4147
- if ($_GET ["update"] == 'block-code-demo') {
4148
- ai_block_code_demo (urldecode ($_GET ["block_class_name"]), $_GET ["block_class"], $_GET ["block_number_class"], $_GET ["inline_styles"]);
4149
- }
4150
- elseif (function_exists ('ai_ajax_backend_2')) {
4151
- ai_ajax_backend_2 ();
4152
- }
4153
- }
4154
-
4155
- elseif (function_exists ('ai_ajax_backend_2')) {
4156
- ai_ajax_backend_2 ();
4157
- }
4158
-
4159
- wp_die ();
4160
- }
4161
-
4162
- function ai_generate_extract (&$settings) {
4163
- global $ai_custom_hooks;
4164
-
4165
- if (!defined ('AI_GENERATE_EXTRACT'))
4166
- define ('AI_GENERATE_EXTRACT', true);
4167
-
4168
- $obj = new ai_Block (1);
4169
-
4170
- $extract = array ();
4171
-
4172
- if (defined ('AI_BUFFERING')) {
4173
- $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());
4174
- $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());
4175
- }
4176
-
4177
- $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());
4178
- $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());
4179
- $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());
4180
- $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());
4181
- $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());
4182
- $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());
4183
- $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());
4184
- $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());
4185
- $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());
4186
- $custom_hook_blocks = array ();
4187
- for ($custom_hook = 1; $custom_hook <= AD_INSERTER_HOOKS; $custom_hook ++) {
4188
- $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());
4189
- }
4190
-
4191
- // Get blocks used in sidebar widgets
4192
- $sidebar_widgets = wp_get_sidebars_widgets();
4193
- $widget_options = get_option ('widget_ai_widget');
4194
-
4195
- $widget_blocks = array ();
4196
- foreach ($sidebar_widgets as $sidebar_index => $sidebar_widget) {
4197
- if (is_array ($sidebar_widget) && isset ($GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'])) {
4198
- $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'];
4199
- if ($sidebar_name != "") {
4200
- foreach ($sidebar_widget as $widget) {
4201
- if (preg_match ("/ai_widget-([\d]+)/", $widget, $widget_id)) {
4202
- if (isset ($widget_id [1]) && is_numeric ($widget_id [1])) {
4203
- $widget_option = $widget_options [$widget_id [1]];
4204
- $widget_block = $widget_option ['block'];
4205
- if ($widget_block >= 1 && $widget_block <= AD_INSERTER_BLOCKS) {
4206
- $widget_blocks [] = $widget_block;
4207
- }
4208
- }
4209
- }
4210
- }
4211
- }
4212
- }
4213
- }
4214
- $widget_blocks = array_unique ($widget_blocks);
4215
-
4216
- // Generate extracted data
4217
- $active_blocks = array ();
4218
- for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
4219
-
4220
- if (!isset ($settings [$block])) continue;
4221
-
4222
- $obj->number = $block;
4223
- $obj->wp_options = $settings [$block];
4224
-
4225
- $page_types = array ();
4226
- if ($obj->get_display_settings_home()) $page_types []= AI_PT_HOMEPAGE;
4227
- if ($obj->get_display_settings_page()) $page_types []= AI_PT_STATIC;
4228
- if ($obj->get_display_settings_post()) $page_types []= AI_PT_POST;
4229
- if ($obj->get_display_settings_category()) $page_types []= AI_PT_CATEGORY;
4230
- if ($obj->get_display_settings_search()) $page_types []= AI_PT_SEARCH;
4231
- if ($obj->get_display_settings_archive()) $page_types []= AI_PT_ARCHIVE;
4232
- if ($obj->get_enable_ajax()) $page_types []= AI_PT_AJAX;
4233
- if ($obj->get_enable_feed()) $page_types []= AI_PT_FEED;
4234
- if ($obj->get_enable_404()) $page_types []= AI_PT_404;
4235
-
4236
- $automatic_insertion = $obj->get_automatic_insertion();
4237
-
4238
- if ($page_types) {
4239
-
4240
- // Change insertion position to actual server-side insertion position
4241
- switch ($automatic_insertion) {
4242
- case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT:
4243
- case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
4244
- switch ($obj->get_html_element_insertion ()) {
4245
- case AI_HTML_INSERTION_SEREVR_SIDE:
4246
- $automatic_insertion = AI_AUTOMATIC_INSERTION_OUTPUT_BUFFERING;
4247
- break;
4248
- default:
4249
- $automatic_insertion = $obj->get_server_side_insertion ();
4250
- break;
4251
- }
4252
- break;
4253
- }
4254
-
4255
- switch ($automatic_insertion) {
4256
- case AI_AUTOMATIC_INSERTION_ABOVE_HEADER:
4257
- if (defined ('AI_BUFFERING')) {
4258
- foreach ($page_types as $block_page_type) $above_header_hook_blocks [$block_page_type][]= $block;
4259
- $above_header_hook_blocks [AI_PT_ANY][]= $block;
4260
- }
4261
- break;
4262
- case AI_AUTOMATIC_INSERTION_OUTPUT_BUFFERING:
4263
- if (defined ('AI_BUFFERING')) {
4264
- foreach ($page_types as $block_page_type) $html_element_hook_blocks [$block_page_type][]= $block;
4265
- $html_element_hook_blocks [AI_PT_ANY][]= $block;
4266
- }
4267
- break;
4268
- case AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH:
4269
- case AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH:
4270
- case AI_AUTOMATIC_INSERTION_BEFORE_CONTENT:
4271
- case AI_AUTOMATIC_INSERTION_AFTER_CONTENT:
4272
- foreach ($page_types as $block_page_type) $content_hook_blocks [$block_page_type][]= $block;
4273
- $content_hook_blocks [AI_PT_ANY][]= $block;
4274
- break;
4275
- case AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT:
4276
- case AI_AUTOMATIC_INSERTION_AFTER_EXCERPT:
4277
- foreach ($page_types as $block_page_type) $excerpt_hook_blocks [$block_page_type][]= $block;
4278
- $excerpt_hook_blocks [AI_PT_ANY][]= $block;
4279
- break;
4280
- case AI_AUTOMATIC_INSERTION_BEFORE_POST:
4281
- foreach ($page_types as $block_page_type) $loop_start_hook_blocks [$block_page_type][]= $block;
4282
- $loop_start_hook_blocks [AI_PT_ANY][]= $block;
4283
- break;
4284
- case AI_AUTOMATIC_INSERTION_AFTER_POST:
4285
- foreach ($page_types as $block_page_type) $loop_end_hook_blocks [$block_page_type][]= $block;
4286
- $loop_end_hook_blocks [AI_PT_ANY][]= $block;
4287
- break;
4288
- case AI_AUTOMATIC_INSERTION_BETWEEN_POSTS:
4289
- foreach ($page_types as $block_page_type) $post_hook_blocks [$block_page_type][]= $block;
4290
- $post_hook_blocks [AI_PT_ANY][]= $block;
4291
- break;
4292
- case AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS:
4293
- foreach ($page_types as $block_page_type) $before_comments_hook_blocks [$block_page_type][]= $block;
4294
- $before_comments_hook_blocks [AI_PT_ANY][]= $block;
4295
- break;
4296
- case AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS:
4297
- foreach ($page_types as $block_page_type) $between_comments_hook_blocks [$block_page_type][]= $block;
4298
- $between_comments_hook_blocks [AI_PT_ANY][]= $block;
4299
- break;
4300
- case AI_AUTOMATIC_INSERTION_AFTER_COMMENTS:
4301
- foreach ($page_types as $block_page_type) $after_comments_hook_blocks [$block_page_type][]= $block;
4302
- $after_comments_hook_blocks [AI_PT_ANY][]= $block;
4303
- break;
4304
- case AI_AUTOMATIC_INSERTION_FOOTER:
4305
- foreach ($page_types as $block_page_type) $footer_hook_blocks [$block_page_type][]= $block;
4306
- $footer_hook_blocks [AI_PT_ANY][]= $block;
4307
- break;
4308
- default:
4309
- if ($automatic_insertion >= AI_AUTOMATIC_INSERTION_CUSTOM_HOOK && $automatic_insertion < AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + AD_INSERTER_HOOKS) {
4310
- $hook_index = $automatic_insertion - AI_AUTOMATIC_INSERTION_CUSTOM_HOOK;
4311
- foreach ($page_types as $block_page_type) $custom_hook_blocks [$hook_index][$block_page_type][]= $block;
4312
- $custom_hook_blocks [$hook_index][AI_PT_ANY][]= $block;
4313
- }
4314
- break;
4315
- }
4316
- }
4317
-
4318
- $automatic = $automatic_insertion != AI_AUTOMATIC_INSERTION_DISABLED;
4319
- $manual_widget = $obj->get_enable_widget() == AI_ENABLED;
4320
- $manual_shortcode = $obj->get_enable_manual() == AI_ENABLED;
4321
- $manual_php_function = $obj->get_enable_php_call() == AI_ENABLED;
4322
- if ($automatic || ($manual_widget && in_array ($block, $widget_blocks)) || $manual_shortcode || $manual_php_function) {
4323
- $active_blocks []= $block;
4324
- }
4325
- }
4326
-
4327
- $extract [AI_EXTRACT_USED_BLOCKS] = serialize ($active_blocks);
4328
-
4329
-
4330
- if (defined ('AI_BUFFERING')) {
4331
- $extract [ABOVE_HEADER_HOOK_BLOCKS] = $above_header_hook_blocks;
4332
- $extract [HTML_ELEMENT_HOOK_BLOCKS] = $html_element_hook_blocks;
4333
- }
4334
- $extract [CONTENT_HOOK_BLOCKS] = $content_hook_blocks;
4335
- $extract [EXCERPT_HOOK_BLOCKS] = $excerpt_hook_blocks;
4336
- $extract [LOOP_START_HOOK_BLOCKS] = $loop_start_hook_blocks;
4337
- $extract [LOOP_END_HOOK_BLOCKS] = $loop_end_hook_blocks;
4338
- $extract [POST_HOOK_BLOCKS] = $post_hook_blocks;
4339
- $extract [BEFORE_COMMENTS_HOOK_BLOCKS] = $before_comments_hook_blocks;
4340
- $extract [BETWEEN_COMMENTS_HOOK_BLOCKS] = $between_comments_hook_blocks;
4341
- $extract [AFTER_COMMENTS_HOOK_BLOCKS] = $after_comments_hook_blocks;
4342
- $extract [FOOTER_HOOK_BLOCKS] = $footer_hook_blocks;
4343
-
4344
- for ($custom_hook = 1; $custom_hook <= AD_INSERTER_HOOKS; $custom_hook ++) {
4345
- $action = get_hook_action ($custom_hook);
4346
-
4347
- if (get_hook_enabled ($custom_hook) && get_hook_name ($custom_hook) != '' && $action != '') {
4348
-
4349
- $custom_hook_extract_index = $action . CUSTOM_HOOK_BLOCKS;
4350
-
4351
- if (isset ($extract [$custom_hook_extract_index])) {
4352
- // Custom hook on WP hook used by the plugin - merge blocks
4353
- foreach ($extract [$custom_hook_extract_index] as $page_type => $blocks) {
4354
- $extract [$custom_hook_extract_index][$page_type] = array_merge ($blocks, $custom_hook_blocks [$custom_hook - 1][$page_type]);
4355
- }
4356
- } else $extract [$custom_hook_extract_index] = $custom_hook_blocks [$custom_hook - 1];
4357
-
4358
- }
4359
- }
4360
-
4361
- return ($extract);
4362
- }
4363
-
4364
- function ai_load_settings () {
4365
- global $ai_db_options, $block_object, $ai_wp_data, $version_string, $ai_custom_hooks;
4366
- // global $ai_db_options_extract;
4367
-
4368
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS START");
4369
-
4370
- ai_load_options ();
4371
-
4372
- $ai_custom_hooks = array ();
4373
- for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
4374
- $name = get_hook_name ($hook);
4375
- $action = get_hook_action ($hook);
4376
-
4377
- if (get_hook_enabled ($hook) && $name != '' && $action != '') {
4378
- $ai_custom_hooks [] = array ('index' => $hook, 'name' => $name, 'action' => $action, 'priority' => get_hook_priority ($hook));
4379
- }
4380
- }
4381
-
4382
- // Sidebars and widgets not loaded yet - moved to ai_wp_loaded_hook
4383
- // if (isset ($ai_db_options [AI_OPTION_EXTRACT]) &&
4384
- // isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] == $version_string &&
4385
- // isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS]) &&
4386
- // isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS][AI_PT_AJAX]) &&
4387
- // isset ($ai_db_options [AI_OPTION_EXTRACT][BETWEEN_COMMENTS_HOOK_BLOCKS]) &&
4388
- // isset ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) &&
4389
- // @unserialize ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) !== false &&
4390
- // isset ($ai_db_options [AI_OPTION_EXTRACT][FOOTER_HOOK_BLOCKS]))
4391
- // $ai_db_options_extract = $ai_db_options [AI_OPTION_EXTRACT]; else
4392
- // $ai_db_options_extract = ai_generate_extract ($ai_db_options);
4393
-
4394
- $obj = new ai_Block (0);
4395
- $obj->wp_options [AI_OPTION_BLOCK_NAME] = 'Default';
4396
- $block_object [0] = $obj;
4397
- for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
4398
- $obj = new ai_Block ($block);
4399
- $obj->load_options ($block);
4400
- $block_object [$block] = $obj;
4401
-
4402
- if ($obj->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
4403
- if ($obj->get_detection_client_side ()) {
4404
- $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = true;
4405
-
4406
- if ($obj->get_client_side_action () == AI_CLIENT_SIDE_ACTION_INSERT) {
4407
- $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = true;
4408
- }
4409
- }
4410
-
4411
- // if ($obj->get_tracking ()) $ai_wp_data [AI_TRACKING] = true;
4412
- // if ($obj->get_close_button () != AI_CLOSE_NONE) $ai_wp_data [AI_CLOSE_BUTTONS] = true;
4413
- if (function_exists ('ai_load_settings_2')) ai_load_settings_2 ($obj);
4414
-
4415
- if ($obj->stick_to_the_content_class () != '') $ai_wp_data [AI_STICK_TO_THE_CONTENT] = true;
4416
-
4417
- switch ($obj->get_automatic_insertion()) {
4418
- case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT:
4419
- case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
4420
- if ($obj->get_html_element_insertion () != AI_HTML_INSERTION_SEREVR_SIDE) $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = true;
4421
- break;
4422
- }
4423
- }
4424
-
4425
- $adH = new ai_AdH();
4426
- $adF = new ai_AdF();
4427
- $adH->load_options (AI_HEADER_OPTION_NAME);
4428
- $adF->load_options (AI_FOOTER_OPTION_NAME);
4429
- $block_object [AI_HEADER_OPTION_NAME] = $adH;
4430
- $block_object [AI_FOOTER_OPTION_NAME] = $adF;
4431
-
4432
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
4433
- $adA = new ai_AdA();
4434
- $adA->load_options (AI_ADB_MESSAGE_OPTION_NAME);
4435
- $block_object [AI_ADB_MESSAGE_OPTION_NAME] = $adA;
4436
- $ai_wp_data [AI_ADB_DETECTION] = $adA->get_enable_manual ();
4437
- }
4438
-
4439
- if (($install_timestamp = get_option (AI_INSTALL_NAME)) !== false) {
4440
- $install = new DateTime (date('Y-m-d H:i:s', $install_timestamp));
4441
- $now = new DateTime (date('Y-m-d H:i:s', time()));
4442
- if (method_exists ($install, 'diff')) {
4443
- $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE] = $install->diff ($now);
4444
- $ai_wp_data [AI_DAYS_SINCE_INSTAL] = $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->days;
4445
- }
4446
- }
4447
-
4448
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS END");
4449
- }
4450
-
4451
-
4452
- function generate_viewport_css () {
4453
-
4454
- $viewports = array ();
4455
- for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
4456
- $viewport_name = get_viewport_name ($viewport);
4457
- $viewport_width = get_viewport_width ($viewport);
4458
- if ($viewport_name != '') {
4459
- $viewports []= array ('index' => $viewport, 'name' => $viewport_name, 'width' => $viewport_width);
4460
- }
4461
- }
4462
-
4463
- $viewport_styles = '';
4464
- if (count ($viewports) != 0) {
4465
- foreach ($viewports as $index => $viewport) {
4466
- if ($viewport ['index'] == 1) {
4467
- foreach (array_reverse ($viewports) as $index2 => $viewport2) {
4468
- if ($viewport2 ['index'] != 1) {
4469
- $viewport_styles .= ".ai-viewport-" . $viewport2 ['index'] . " { display: none !important;}\n";
4470
- }
4471
- }
4472
- $viewport_styles .= ".ai-viewport-1 { display: inherit !important;}\n";
4473
- $viewport_styles .= ".ai-viewport-0 { display: none !important;}\n";
4474
- } else {
4475
- $viewport_styles .= "@media ";
4476
- if ($index != count ($viewports) - 1)
4477
- $viewport_styles .= "(min-width: " . $viewport ['width'] . "px) and ";
4478
- $viewport_styles .= "(max-width: " . ($viewports [$index - 1]['width'] - 1) . "px) {\n";
4479
- foreach ($viewports as $index2 => $viewport2) {
4480
- if ($viewport2 ['index'] == 1)
4481
- $viewport_styles .= ".ai-viewport-" . $viewport2 ['index'] . " { display: none !important;}\n";
4482
- elseif ($viewport ['index'] == $viewport2 ['index'])
4483
- $viewport_styles .= ".ai-viewport-" . $viewport2 ['index'] . " { display: inherit !important;}\n";
4484
-
4485
- }
4486
- $viewport_styles .= "}\n";
4487
- }
4488
- }
4489
- }
4490
- return ($viewport_styles);
4491
- }
4492
-
4493
- function get_main_alignment_css ($alt_styles_text) {
4494
- if (strpos ($alt_styles_text, "||") !== false) {
4495
- $styles = explode ("||", $alt_styles_text);
4496
- return $styles [0];
4497
- }
4498
- return $alt_styles_text;
4499
- }
4500
-
4501
- function generate_alignment_css () {
4502
- global $ai_db_options_extract, $block_object;
4503
-
4504
- $block_class_name = get_block_class_name (true) . '-';
4505
-
4506
- $styles = array ();
4507
-
4508
- $styles [AI_ALIGNMENT_DEFAULT] = array (AI_TEXT_DEFAULT, get_main_alignment_css (AI_ALIGNMENT_CSS_DEFAULT));
4509
- $styles [AI_ALIGNMENT_LEFT] = array (AI_TEXT_LEFT, get_main_alignment_css (AI_ALIGNMENT_CSS_LEFT));
4510
- $styles [AI_ALIGNMENT_RIGHT] = array (AI_TEXT_RIGHT, get_main_alignment_css (AI_ALIGNMENT_CSS_RIGHT));
4511
- $styles [AI_ALIGNMENT_CENTER] = array (AI_TEXT_CENTER, get_main_alignment_css (AI_ALIGNMENT_CSS_CENTER));
4512
- $styles [AI_ALIGNMENT_FLOAT_LEFT] = array (AI_TEXT_FLOAT_LEFT, get_main_alignment_css (AI_ALIGNMENT_CSS_FLOAT_LEFT));
4513
- $styles [AI_ALIGNMENT_FLOAT_RIGHT] = array (AI_TEXT_FLOAT_RIGHT, get_main_alignment_css (AI_ALIGNMENT_CSS_FLOAT_RIGHT));
4514
-
4515
- if (function_exists ('generate_alignment_css_2')) $styles = array_replace ($styles, generate_alignment_css_2 ());
4516
-
4517
- $alignment_css = '';
4518
- $alignments = array ();
4519
- $used_blocks = unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]);
4520
- foreach ($used_blocks as $used_block) {
4521
- $obj = $block_object [$used_block];
4522
- $alignment_type = $obj->get_alignment_type ();
4523
-
4524
- switch ($alignment_type) {
4525
- case AI_ALIGNMENT_DEFAULT:
4526
- case AI_ALIGNMENT_LEFT:
4527
- case AI_ALIGNMENT_RIGHT:
4528
- case AI_ALIGNMENT_CENTER:
4529
- case AI_ALIGNMENT_FLOAT_LEFT:
4530
- case AI_ALIGNMENT_FLOAT_RIGHT:
4531
- case AI_ALIGNMENT_STICKY_LEFT:
4532
- case AI_ALIGNMENT_STICKY_RIGHT:
4533
- case AI_ALIGNMENT_STICKY_TOP:
4534
- case AI_ALIGNMENT_STICKY_BOTTOM:
4535
- $alignment_name = strtolower ($styles [$alignment_type][0]);
4536
- if (in_array ($alignment_name, $alignments)) continue;
4537
- $alignments []= $alignment_name;
4538
- $alignment_css .= '.' . $block_class_name . str_replace (' ', '-', $alignment_name) .' {' . $styles [$alignment_type][1] . "}\n";
4539
- break;
4540
- case AI_ALIGNMENT_STICKY:
4541
- $sticky_css = $obj->alignment_style ($alignment_type);
4542
- $alignment_name = strtolower (md5 ($sticky_css));
4543
- if (in_array ($alignment_name, $alignments)) continue;
4544
- $alignments []= $alignment_name;
4545
- $alignment_css .= '.' . $block_class_name . str_replace (' ', '-', $alignment_name) .' {' . $sticky_css . "}\n";
4546
- break;
4547
- case AI_ALIGNMENT_CUSTOM_CSS:
4548
- $custom_css = $obj->get_custom_css ();
4549
- $alignment_name = strtolower (md5 ($custom_css));
4550
- if (in_array ($alignment_name, $alignments)) continue;
4551
- $alignments []= $alignment_name;
4552
- $alignment_css .= '.' . $block_class_name . str_replace (' ', '-', $alignment_name) .' {' . str_replace ('&#039;', "'", $custom_css) . "}\n";
4553
- break;
4554
- }
4555
- }
4556
-
4557
- return $alignment_css;
4558
- }
4559
-
4560
- function generate_debug_css () {
4561
- ?>
4562
- .ai-debug-tags {font-weight: bold; color: white; padding: 2px;}
4563
- .ai-debug-positions {clear: both; text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;}
4564
- .ai-debug-page-type {text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid green; color: green; background: #efe;}
4565
- .ai-debug-status {clear: both; text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid red; color: red; background: #fee;}
4566
- .ai-debug-adb {opacity: 0.85; cursor: pointer;}
4567
- .ai-debug-widget {margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;}
4568
- a.ai-debug-left {float: left; font-size: 10px; text-decoration: none; color: transparent; padding: 0px 10px 0 0; box-shadow: none;}
4569
- a.ai-debug-right {float: right; font-size: 10px; text-decoration: none; color: #88f; padding: 0px 10px 0 0; box-shadow: none;}
4570
- a.ai-debug-center {text-align: center; font-size: 10px; text-decoration: none; color: white; padding: 0px 10px 0 0; box-shadow: none;}
4571
- .ai-debug-invisible {display: none;}
4572
- .ai-debug-content-hook-positions {color: blue;}
4573
- .ai-debug-removed-html-tags {color: red;}
4574
- .ai-debug-rnrn {background: #0ff; color: #000;}
4575
- .ai-debug-p {background: #0a0;}
4576
- .ai-debug-div {background: #46f;}
4577
- .ai-debug-h {background: #d4e;}
4578
- .ai-debug-img {background: #ee0; color: #000;}
4579
- .ai-debug-pre {background: #222;}
4580
- .ai-debug-special {background: #fb0; color: #000;}
4581
-
4582
- .ai-debug-ad-overlay {position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: #8f8; opacity: 0.6; z-index': '999999990}
4583
- .ai-auto-ads {background-color: #84f;}
4584
- .ai-no-slot {background-color: #48f;}
4585
- .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;}
4586
- .ai-info {display: inline-block; padding: 2px 4px;}
4587
- .ai-info-1 {background: #000; color: #fff;}
4588
- .ai-info-2 {background: #fff; color: #000;}
4589
-
4590
- section.ai-debug-block, .ai-debug-block section {
4591
- padding: 0;
4592
- margin: 0;
4593
- }
4594
- .ai-debug-code {margin: 0; padding: 0; border: 0; font-family: monospace; font-size: 12px; line-height: 13px;}
4595
-
4596
- .ai-debug-block {border: 1px solid;}
4597
-
4598
- .ai-debug-block.ai-debug-default {border-color: #e00;}
4599
- .ai-debug-bar.ai-debug-default {background: #e00;}
4600
-
4601
- .ai-debug-block.ai-debug-viewport-invisible { border-color: #00f;}
4602
- .ai-debug-bar.ai-debug-viewport-invisible {background: #00f;}
4603
-
4604
- .ai-debug-block.ai-debug-amp {border-color: #0c0;}
4605
- .ai-debug-bar.ai-debug-amp {background: #0c0;}
4606
-
4607
- .ai-debug-block.ai-debug-normal {border-color: #222;}
4608
- .ai-debug-bar.ai-debug-normal {background: #222;}
4609
-
4610
- .ai-debug-block.ai-debug-fallback {border-color: #a0f;}
4611
- .ai-debug-bar.ai-debug-fallback {background: #a0f;}
4612
-
4613
- .ai-debug-block.ai-debug-script {border-color: #00bae6;}
4614
- .ai-debug-bar.ai-debug-script {background: #00bae6;}
4615
-
4616
- .ai-debug-block.ai-debug-adb-status {border-color: #000;}
4617
- .ai-debug-bar.ai-debug-adb-status {background: #000;}
4618
-
4619
- .ai-debug-block.ai-debug-adsense {border-color: #e0a;}
4620
- .ai-debug-bar.ai-debug-adsense {background: #e0a;}
4621
-
4622
- .ai-debug-adb-status.on {color: #f00;}
4623
- .ai-debug-adb-status.off {color: #0f0;}
4624
-
4625
- .ai-debug-block.ai-debug-ip {border-color: #00c5be;}
4626
- .ai-debug-bar.ai-debug-ip {background: #00c5be;}
4627
-
4628
- .ai-debug-adb-hidden {visibility: hidden; display: none;}
4629
- .ai-debug-adb-center {text-align: center; font-weight: bold; margin: 0; padding: 4px 0;}
4630
-
4631
- .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;}
4632
-
4633
- .ai-debug-bar .ai-debug-text-left {float: left;}
4634
- .ai-debug-bar .ai-debug-text-right {float: right; padding-right: 3px;}
4635
- .ai-debug-bar .ai-debug-text-center {text-align: center;}
4636
-
4637
- .ai-debug-message {text-align: center; font-weight: bold;}
4638
-
4639
- .ai-debug-bar kbd {padding: 0; color: #fff; font-size: inherit; font-family: arial; background-color: transparent; box-shadow: none;}
4640
-
4641
- <?php
4642
- }
4643
-
4644
- function ai_settings () {
4645
- global $ai_db_options, $block_object, $wpdb, $ai_db_options_extract;
4646
-
4647
- if (isset ($_POST [AI_FORM_SAVE])) {
4648
-
4649
- // echo count ($_POST);
4650
- // print_r ($_POST);
4651
-
4652
- check_admin_referer ('save_adinserter_settings');
4653
-
4654
- $subpage = 'main';
4655
- $start = 1;
4656
- $end = 16;
4657
- if (function_exists ('ai_settings_parameters')) ai_settings_parameters ($subpage, $start, $end);
4658
-
4659
- $invalid_blocks = array ();
4660
-
4661
- $import_switch_name = AI_OPTION_IMPORT . WP_FORM_FIELD_POSTFIX . '0';
4662
- if (isset ($_POST [$import_switch_name]) && $_POST [$import_switch_name] == "1") {
4663
- // Import Ad Inserter settings
4664
- $ai_options = @unserialize (base64_decode (str_replace (array ("\\\""), array ("\""), $_POST ["export_settings_0"])));
4665
-
4666
- if ($ai_options === false) {
4667
- // Use saved settings
4668
- $ai_options = wp_slash ($ai_db_options);
4669
- $invalid_blocks []= 0;
4670
- } else $ai_options = wp_slash ($ai_options);
4671
- } else {
4672
- // Try to import individual settings
4673
- $ai_options = array ();
4674
-
4675
- $default_block = new ai_Block (1);
4676
- for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
4677
- // ###
4678
- // $default_block = new ai_Block ($block);
4679
-
4680
- if (isset ($ai_db_options [$block])) $saved_settings = wp_slash ($ai_db_options [$block]); else
4681
- // ###
4682
- // $saved_settings = wp_slash ($default_block->wp_options);
4683
- $saved_settings = array ();
4684
-
4685
- if ($block < $start || $block > $end) {
4686
- // Block not on the settings page
4687
- $ai_options [$block] = $saved_settings;
4688
- continue;
4689
- }
4690
-
4691
- $import_switch_name = AI_OPTION_IMPORT . WP_FORM_FIELD_POSTFIX . $block;
4692
- $import_name_switch_name = AI_OPTION_IMPORT_NAME . WP_FORM_FIELD_POSTFIX . $block;
4693
- if (isset ($_POST [$import_switch_name]) && $_POST [$import_switch_name] == "1") {
4694
-
4695
- // Try to import block settings
4696
- $exported_settings = @unserialize (base64_decode (str_replace (array ("\\\""), array ("\""), $_POST ["export_settings_" . $block])));
4697
-
4698
- if ($exported_settings !== false) {
4699
- $exported_settings = wp_slash ($exported_settings);
4700
- foreach (array_keys ($default_block->wp_options) as $key){
4701
- if ($key == AI_OPTION_BLOCK_NAME && isset ($_POST [$import_name_switch_name]) && $_POST [$import_name_switch_name] != "1") {
4702
- $form_field_name = $key . WP_FORM_FIELD_POSTFIX . $block;
4703
- if (isset ($_POST [$form_field_name])){
4704
- // ###
4705
- // $default_block->wp_options [$key] = filter_option ($key, $_POST [$form_field_name]);
4706
-
4707
- // Save only non-default settings
4708
- $ai_options [$block][$key] = filter_option ($key, $_POST [$form_field_name]);
4709
- }
4710
- } else {
4711
- if (isset ($exported_settings [$key])) {
4712
- // ###
4713
- // $default_block->wp_options [$key] = filter_option ($key, $exported_settings [$key], false);
4714
-
4715
- $ai_options [$block][$key] = filter_option ($key, $exported_settings [$key], false);
4716
- }
4717
- }
4718
- }
4719
- } else {
4720
- // Block import failed - use existing settings
4721
- $default_block->wp_options = $saved_settings;
4722
- $invalid_blocks []= $block;
4723
- }
4724
- } else {
4725
- // Process block settings
4726
- foreach (array_keys ($default_block->wp_options) as $key){
4727
- $form_field_name = $key . WP_FORM_FIELD_POSTFIX . $block;
4728
- if (isset ($_POST [$form_field_name])){
4729
-
4730
- // ### Store non-default settings
4731
- // $default_block->wp_options [$key] = filter_option ($key, $_POST [$form_field_name]);
4732
-
4733
- // Save only non-default settings
4734
- $ai_options [$block][$key] = filter_option ($key, $_POST [$form_field_name]);
4735
- }
4736
- }
4737
- }
4738
-
4739
- // ### Copy complete block settings
4740
- // $ai_options [$block] = $default_block->wp_options;
4741
-
4742
- delete_option (str_replace ("#", $block, AD_ADx_OPTIONS));
4743
- }
4744
-
4745
- $default_block_H = new ai_AdH();
4746
- $wp_options = array ();
4747
- foreach(array_keys ($default_block_H->wp_options) as $key){
4748
- $form_field_name = $key . WP_FORM_FIELD_POSTFIX . AI_HEADER_OPTION_NAME;
4749
- if(isset ($_POST [$form_field_name])){
4750
- // ###
4751
- // $default_block_H->wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4752
- $wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4753
- }
4754
- }
4755
- // ###
4756
- // $ai_options [AI_HEADER_OPTION_NAME] = $default_block_H->wp_options;
4757
- $ai_options [AI_HEADER_OPTION_NAME] = $wp_options;
4758
-
4759
- $default_block_F = new ai_AdF();
4760
- $wp_options = array ();
4761
- foreach(array_keys($default_block_F->wp_options) as $key){
4762
- $form_field_name = $key . WP_FORM_FIELD_POSTFIX . AI_FOOTER_OPTION_NAME;
4763
- if(isset ($_POST [$form_field_name])){
4764
- // ###
4765
- // $default_block_F->wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4766
- $wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4767
- }
4768
- }
4769
- // $ai_options [AI_FOOTER_OPTION_NAME] = $default_block_F->wp_options;
4770
- $ai_options [AI_FOOTER_OPTION_NAME] = $wp_options;
4771
-
4772
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
4773
- $default_block_A = new ai_AdA();
4774
- $wp_options = array ();
4775
- foreach(array_keys($default_block_A->wp_options) as $key){
4776
- $form_field_name = $key . WP_FORM_FIELD_POSTFIX . AI_ADB_MESSAGE_OPTION_NAME;
4777
- if(isset ($_POST [$form_field_name])){
4778
- // ###
4779
- // $default_block_A->wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4780
- $wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4781
- }
4782
- }
4783
- // ###
4784
- // $ai_options [AI_ADB_MESSAGE_OPTION_NAME] = $default_block_A->wp_options;
4785
- $ai_options [AI_ADB_MESSAGE_OPTION_NAME] = $wp_options;
4786
- }
4787
-
4788
- $options = array ();
4789
-
4790
- if (function_exists ('ai_filter_global_settings')) ai_filter_global_settings ($options);
4791
-
4792
- if (isset ($_POST ['syntax-highlighter-theme'])) $options ['SYNTAX_HIGHLIGHTER_THEME'] = filter_string ($_POST ['syntax-highlighter-theme']);
4793
- if (isset ($_POST ['block-class-name'])) $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']);
4794
- if (isset ($_POST ['block-class'])) $options ['BLOCK_CLASS'] = filter_option ('BLOCK_CLASS', $_POST ['block-class']);
4795
- if (isset ($_POST ['block-number-class'])) $options ['BLOCK_NUMBER_CLASS'] = filter_option ('BLOCK_NUMBER_CLASS', $_POST ['block-number-class']);
4796
- if (isset ($_POST ['inline-styles'])) $options ['INLINE_STYLES'] = filter_option ('INLINE_STYLES', $_POST ['inline-styles']);
4797
- if (isset ($_POST ['minimum-user-role'])) $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']);
4798
- if (isset ($_POST ['sticky-widget-mode'])) $options ['STICKY_WIDGET_MODE'] = filter_option ('STICKY_WIDGET_MODE', $_POST ['sticky-widget-mode']);
4799
- if (isset ($_POST ['sticky-widget-margin'])) $options ['STICKY_WIDGET_MARGIN'] = filter_option ('STICKY_WIDGET_MARGIN', $_POST ['sticky-widget-margin']);
4800
- if (isset ($_POST ['plugin_priority'])) $options ['PLUGIN_PRIORITY'] = filter_option ('PLUGIN_PRIORITY', $_POST ['plugin_priority']);
4801
- if (isset ($_POST ['dynamic_blocks'])) $options ['DYNAMIC_BLOCKS'] = filter_option ('DYNAMIC_BLOCKS', $_POST ['dynamic_blocks']);
4802
- if (isset ($_POST ['paragraph_counting_functions'])) $options ['PARAGRAPH_COUNTING_FUNCTIONS'] = filter_option ('PARAGRAPH_COUNTING_FUNCTIONS', $_POST ['paragraph_counting_functions']);
4803
- if (isset ($_POST ['output-buffering'])) $options ['OUTPUT_BUFFERING'] = filter_option ('OUTPUT_BUFFERING', $_POST ['output-buffering']);
4804
- if (isset ($_POST ['no-paragraph-counting-inside'])) $options ['NO_PARAGRAPH_COUNTING_INSIDE'] = filter_option ('NO_PARAGRAPH_COUNTING_INSIDE', $_POST ['no-paragraph-counting-inside']);
4805
- if (isset ($_POST ['ad-label'])) $options ['AD_LABEL'] = filter_option ('AD_LABEL', $_POST ['ad-label']);
4806
- if (isset ($_POST [AI_OPTION_ADB_ACTION])) $options ['ADB_ACTION'] = filter_option ('ADB_ACTION', $_POST [AI_OPTION_ADB_ACTION]);
4807
- if (isset ($_POST [AI_OPTION_ADB_DELAY_ACTION])) $options ['ADB_DELAY_ACTION'] = filter_option ('ADB_DELAY_ACTION', $_POST [AI_OPTION_ADB_DELAY_ACTION]);
4808
- 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]);
4809
- if (isset ($_POST [AI_OPTION_ADB_SELECTORS])) $options ['ADB_SELECTORS'] = filter_option ('ADB_SELECTORS', $_POST [AI_OPTION_ADB_SELECTORS]);
4810
- if (isset ($_POST [AI_OPTION_ADB_REDIRECTION_PAGE])) $options ['ADB_REDIRECTION_PAGE'] = filter_option ('ADB_REDIRECTION_PAGE', $_POST [AI_OPTION_ADB_REDIRECTION_PAGE]);
4811
- 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]);
4812
- if (isset ($_POST [AI_OPTION_ADB_MESSAGE_CSS])) $options ['ADB_MESSAGE_CSS'] = filter_option ('ADB_MESSAGE_CSS', $_POST [AI_OPTION_ADB_MESSAGE_CSS]);
4813
- if (isset ($_POST [AI_OPTION_ADB_OVERLAY_CSS])) $options ['ADB_OVERLAY_CSS'] = filter_option ('ADB_OVERLAY_CSS', $_POST [AI_OPTION_ADB_OVERLAY_CSS]);
4814
- if (isset ($_POST [AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE])) $options ['ADB_UNDISMISSIBLE_MESSAGE'] = filter_option ('ADB_UNDISMISSIBLE_MESSAGE', $_POST [AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE]);
4815
- if (isset ($_POST ['admin_toolbar_debugging'])) $options ['ADMIN_TOOLBAR_DEBUGGING'] = filter_option ('ADMIN_TOOLBAR_DEBUGGING', $_POST ['admin_toolbar_debugging']);
4816
- if (isset ($_POST ['remote_debugging'])) $options ['REMOTE_DEBUGGING'] = filter_option ('REMOTE_DEBUGGING', $_POST ['remote_debugging']);
4817
- if (isset ($_POST ['backend_js_debugging'])) $options ['BACKEND_JS_DEBUGGING'] = filter_option ('BACKEND_JS_DEBUGGING', $_POST ['backend_js_debugging']);
4818
- if (isset ($_POST ['frontend_js_debugging'])) $options ['FRONTEND_JS_DEBUGGING'] = filter_option ('FRONTEND_JS_DEBUGGING', $_POST ['frontend_js_debugging']);
4819
-
4820
- for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
4821
- if (isset ($_POST ['viewport-name-'.$viewport])) $options ['VIEWPORT_NAME_'.$viewport] = filter_string ($_POST ['viewport-name-'.$viewport]);
4822
- if (isset ($_POST ['viewport-width-'.$viewport])) $options ['VIEWPORT_WIDTH_'.$viewport] = filter_option ('viewport_width', $_POST ['viewport-width-'.$viewport]);
4823
- }
4824
-
4825
- for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
4826
- if (isset ($_POST ['hook-enabled-'.$hook])) $options ['HOOK_ENABLED_'.$hook] = filter_option ('HOOK_ENABLED', $_POST ['hook-enabled-'.$hook]);
4827
- if (isset ($_POST ['hook-name-'.$hook])) $options ['HOOK_NAME_'.$hook] = filter_string_tags ($_POST ['hook-name-'.$hook]);
4828
- if (isset ($_POST ['hook-action-'.$hook])) $options ['HOOK_ACTION_'.$hook] = filter_string ($_POST ['hook-action-'.$hook]);
4829
- if (isset ($_POST ['hook-priority-'.$hook])) $options ['HOOK_PRIORITY_'.$hook] = filter_option ('HOOK_PRIORITY', $_POST ['hook-enabled-'.$hook]);
4830
- }
4831
-
4832
- // $options ['VIEWPORT_CSS'] = generate_viewport_css ();
4833
- // $options ['ALIGNMENT_CSS'] = generate_alignment_css ();
4834
-
4835
- $ai_options [AI_OPTION_GLOBAL] = ai_check_plugin_options ($options);
4836
- }
4837
-
4838
- if (!empty ($invalid_blocks)) {
4839
- if ($invalid_blocks [0] == 0) {
4840
- echo "<div class='error' style='margin: 5px 15px 2px 0px; padding: 10px;'>Error importing ", AD_INSERTER_NAME, " settings.</div>";
4841
- } else echo "<div class='error' style='margin: 5px 15px 2px 0px; padding: 10px;'>Error importing settings for block", count ($invalid_blocks) == 1 ? "" : "s:", " ", implode (", ", $invalid_blocks), ".</div>";
4842
- }
4843
-
4844
- // Generate and save extract
4845
- // Save new options as some function may need new settings
4846
- update_option (AI_OPTION_NAME, $ai_options);
4847
- ai_load_settings ();
4848
-
4849
- $ai_options [AI_OPTION_EXTRACT] = ai_generate_extract ($ai_options);
4850
- $ai_db_options_extract = $ai_options [AI_OPTION_EXTRACT];
4851
-
4852
- $ai_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'] = generate_viewport_css ();
4853
- $ai_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'] = generate_alignment_css ();
4854
-
4855
- $ai_options [AI_OPTION_GLOBAL]['TIMESTAMP'] = time ();
4856
-
4857
- if (get_option (AI_INSTALL_NAME) === false) {
4858
- update_option (AI_INSTALL_NAME, time ());
4859
- }
4860
-
4861
- update_option (AI_OPTION_NAME, $ai_options);
4862
-
4863
- // Multisite
4864
- if (is_multisite () && is_main_site ()) {
4865
- $options = array ();
4866
- if (function_exists ('ai_filter_multisite_settings')) ai_filter_multisite_settings ($options);
4867
- ai_check_multisite_options ($options);
4868
- update_site_option (AI_OPTION_NAME, $options);
4869
- }
4870
-
4871
- ai_load_settings ();
4872
-
4873
- if (function_exists ('ai_load_globals')) ai_load_globals ();
4874
-
4875
- delete_option (str_replace ("#", "Header", AD_ADx_OPTIONS));
4876
- delete_option (str_replace ("#", "Footer", AD_ADx_OPTIONS));
4877
- delete_option (AD_OPTIONS);
4878
-
4879
- echo "<div class='notice notice-success is-dismissible' style='margin: 5px 15px 2px 0px;'><p><strong>Settings saved.</strong></p></div>";
4880
- } elseif (isset ($_POST [AI_FORM_CLEAR])) {
4881
-
4882
- check_admin_referer ('save_adinserter_settings');
4883
-
4884
- for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
4885
- delete_option (str_replace ("#", $block, AD_ADx_OPTIONS));
4886
- }
4887
-
4888
- delete_option (str_replace ("#", "Header", AD_ADx_OPTIONS));
4889
- delete_option (str_replace ("#", "Footer", AD_ADx_OPTIONS));
4890
- delete_option (AD_OPTIONS);
4891
-
4892
- delete_option (AI_OPTION_NAME);
4893
-
4894
- if (is_multisite () && is_main_site ()) {
4895
- delete_site_option (AI_OPTION_NAME, $options);
4896
- }
4897
-
4898
- delete_option (AI_ADSENSE_AUTH_CODE);
4899
-
4900
- delete_transient (AI_TRANSIENT_ADSENSE_TOKEN);
4901
- delete_transient (AI_TRANSIENT_ADSENSE_ADS);
4902
-
4903
- if (function_exists ('ai_load_globals')) {
4904
- delete_option (WP_AD_INSERTER_PRO_LICENSE);
4905
- $wpdb->query ("DROP TABLE IF EXISTS " . AI_STATISTICS_DB_TABLE);
4906
- }
4907
-
4908
- if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
4909
-
4910
- $args = array (
4911
- 'public' => true,
4912
- '_builtin' => false
4913
- );
4914
- $custom_post_types = get_post_types ($args, 'names', 'and');
4915
- $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types));
4916
-
4917
- $args = array (
4918
- 'posts_per_page' => 100,
4919
- 'offset' => 0,
4920
- 'category' => '',
4921
- 'category_name' => '',
4922
- 'orderby' => 'type',
4923
- 'order' => 'ASC',
4924
- 'include' => '',
4925
- 'exclude' => '',
4926
- 'meta_key' => '_adinserter_block_exceptions',
4927
- 'meta_value' => '',
4928
- 'post_type' => $screens,
4929
- 'post_mime_type' => '',
4930
- 'post_parent' => '',
4931
- 'author' => '',
4932
- 'author_name' => '',
4933
- 'post_status' => '',
4934
- 'suppress_filters' => true
4935
- );
4936
- $posts_pages = get_posts ($args);
4937
-
4938
- foreach ($posts_pages as $page) {
4939
- delete_post_meta ($page->ID, '_adinserter_block_exceptions');
4940
- }
4941
- }
4942
-
4943
- ai_load_settings ();
4944
-
4945
- // Generate extract
4946
- $ai_options [AI_OPTION_EXTRACT] = ai_generate_extract ($ai_options);
4947
- $ai_db_options_extract = $ai_options [AI_OPTION_EXTRACT];
4948
-
4949
- if (function_exists ('ai_load_globals')) ai_load_globals ();
4950
-
4951
- echo "<div class='notice notice-warning is-dismissible' style='margin: 5px 15px 2px 0px;'><p><strong>Settings cleared.</strong></p></div>";
4952
- } elseif (isset ($_POST [AI_FORM_CLEAR_EXCEPTIONS])) {
4953
- if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
4954
-
4955
- $args = array (
4956
- 'public' => true,
4957
- '_builtin' => false
4958
- );
4959
- $custom_post_types = get_post_types ($args, 'names', 'and');
4960
- $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types));
4961
-
4962
- $args = array (
4963
- 'posts_per_page' => 100,
4964
- 'offset' => 0,
4965
- 'category' => '',
4966
- 'category_name' => '',
4967
- 'orderby' => 'type',
4968
- 'order' => 'ASC',
4969
- 'include' => '',
4970
- 'exclude' => '',
4971
- 'meta_key' => '_adinserter_block_exceptions',
4972
- 'meta_value' => '',
4973
- 'post_type' => $screens,
4974
- 'post_mime_type' => '',
4975
- 'post_parent' => '',
4976
- 'author' => '',
4977
- 'author_name' => '',
4978
- 'post_status' => '',
4979
- 'suppress_filters' => true
4980
- );
4981
- $posts_pages = get_posts ($args);
4982
-
4983
- if ($_POST [AI_FORM_CLEAR_EXCEPTIONS] == "\xe2\x9d\x8c") {
4984
- foreach ($posts_pages as $page) {
4985
- delete_post_meta ($page->ID, '_adinserter_block_exceptions');
4986
- }
4987
- }
4988
- elseif (strpos ($_POST [AI_FORM_CLEAR_EXCEPTIONS], 'id=') === 0) {
4989
- $id = str_replace ('id=', '', $_POST [AI_FORM_CLEAR_EXCEPTIONS]);
4990
- if (is_numeric ($id)) {
4991
- delete_post_meta ($id, '_adinserter_block_exceptions');
4992
- }
4993
- }
4994
- elseif (is_numeric ($_POST [AI_FORM_CLEAR_EXCEPTIONS])) {
4995
- foreach ($posts_pages as $page) {
4996
- $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
4997
- $selected_blocks = explode (",", $post_meta);
4998
- if (($key = array_search ($_POST [AI_FORM_CLEAR_EXCEPTIONS], $selected_blocks)) !== false) {
4999
- unset ($selected_blocks [$key]);
5000
- update_post_meta ($page->ID, '_adinserter_block_exceptions', implode (",", $selected_blocks));
5001
- }
5002
- }
5003
- }
5004
- }
5005
- } elseif (isset ($_POST [AI_FORM_CLEAR_STATISTICS]) && is_numeric ($_POST [AI_FORM_CLEAR_STATISTICS])) {
5006
- if ($_POST [AI_FORM_CLEAR_STATISTICS] != 0) {
5007
- $wpdb->query ("DELETE FROM " . AI_STATISTICS_DB_TABLE . " WHERE block = " . $_POST [AI_FORM_CLEAR_STATISTICS]);
5008
- } else $wpdb->query ("DROP TABLE IF EXISTS " . AI_STATISTICS_DB_TABLE);
5009
- }
5010
-
5011
- generate_settings_form ();
5012
- }
5013
-
5014
-
5015
- function ai_adinserter ($ad_number = '', $ignore = ''){
5016
- global $block_object, $ad_inserter_globals, $ai_wp_data, $ai_last_check;
5017
-
5018
- $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5019
-
5020
- if ($ad_number == "") return "";
5021
- if (!is_numeric ($ad_number)) return "";
5022
- $ad_number = (int) $ad_number;
5023
- if ($ad_number < 1 || $ad_number > AD_INSERTER_BLOCKS) return "";
5024
-
5025
- $globals_name = AI_PHP_FUNCTION_CALL_COUNTER_NAME . $ad_number;
5026
-
5027
- if (!isset ($ad_inserter_globals [$globals_name])) {
5028
- $ad_inserter_globals [$globals_name] = 1;
5029
- } else $ad_inserter_globals [$globals_name] ++;
5030
-
5031
- if ($debug_processing) ai_log ("PHP FUNCTION CALL adinserter ($ad_number".($ignore == '' ? '' : (', \''.$ignore.'\'')).") [" . $ad_inserter_globals [$globals_name] . ']');
5032
-
5033
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_PHP_FUNCTION;
5034
-
5035
- $ignore_array = array ();
5036
- if (trim ($ignore) != '') {
5037
- $ignore_array = explode (",", str_replace (" ", "", $ignore));
5038
- }
5039
-
5040
- $obj = $block_object [$ad_number];
5041
- $obj->clear_code_cache ();
5042
-
5043
- $ai_last_check = AI_CHECK_ENABLED_PHP;
5044
- if (!$obj->get_enable_php_call ()) return "";
5045
- if (!$obj->check_server_side_detection ()) return "";
5046
- if (!$obj->check_page_types_lists_users (in_array ("page-type", $ignore_array))) return "";
5047
- if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return "";
5048
- if (!$obj->check_number_of_words ()) return "";
5049
-
5050
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
5051
- $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
5052
- $selected_blocks = explode (",", $meta_value);
5053
-
5054
- if (!$obj->check_post_page_exceptions ($selected_blocks)) return "";
5055
- }
5056
-
5057
- // Last check before counter check before insertion
5058
- $ai_last_check = AI_CHECK_CODE;
5059
- if ($obj->ai_getCode () == '') return "";
5060
-
5061
- // Last check before insertion
5062
- if (!$obj->check_and_increment_block_counter ()) return "";
5063
-
5064
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5065
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) != 0) return "";
5066
-
5067
- $ai_last_check = AI_CHECK_INSERTED;
5068
- return $obj->get_code_for_serverside_insertion ();
5069
- }
5070
-
5071
- function adinserter ($block = '', $ignore = '') {
5072
- global $ai_last_check, $ai_wp_data, $ai_total_plugin_time;
5073
-
5074
- $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5075
- if ($debug_processing) $start_time = microtime (true);
5076
-
5077
- $ai_last_check = AI_CHECK_NONE;
5078
- $code = ai_adinserter ($block, $ignore);
5079
-
5080
- if ($debug_processing) {
5081
- $ai_total_plugin_time += microtime (true) - $start_time;
5082
- if ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
5083
- ai_log ("PHP FUNCTION CALL END\n");
5084
- }
5085
-
5086
- return $code;
5087
- }
5088
-
5089
-
5090
-
5091
- function ai_content_hook ($content = '') {
5092
- global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time, $special_element_tags;
5093
-
5094
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
5095
-
5096
- $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5097
- $globals_name = AI_CONTENT_COUNTER_NAME;
5098
-
5099
- $special_element_tags = explode (',', str_replace (' ', '', get_no_paragraph_counting_inside ()));
5100
-
5101
- if (!isset ($ad_inserter_globals [$globals_name])) {
5102
- $ad_inserter_globals [$globals_name] = 1;
5103
- } else $ad_inserter_globals [$globals_name] ++;
5104
-
5105
- if ($debug_processing) {
5106
- ai_log ("CONTENT HOOK START [" . $ad_inserter_globals [$globals_name] . ']');
5107
- $start_time = microtime (true);
5108
- }
5109
-
5110
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_CONTENT;
5111
-
5112
- $content_words = number_of_words ($content);
5113
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5114
-
5115
- $positions_inserted = false;
5116
- if ($ai_wp_data [AI_WP_DEBUG_BLOCK] == 0) {
5117
- $preview = $block_object [0];
5118
- $content = $preview->before_paragraph ($content, true);
5119
- $content = $preview->after_paragraph ($content, true);
5120
- $positions_inserted = true;
5121
- }
5122
- }
5123
-
5124
- if ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) {
5125
- if ($debug_processing) ai_log_content ($content);
5126
-
5127
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
5128
- $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
5129
- $selected_blocks = explode (",", $meta_value);
5130
- } else $selected_blocks = array ();
5131
-
5132
- $ai_last_check = AI_CHECK_NONE;
5133
- $current_block = 0;
5134
-
5135
- if (isset ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5136
- foreach ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5137
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5138
-
5139
- if (!isset ($block_object [$block])) continue;
5140
-
5141
- $ai_last_check = AI_CHECK_NONE;
5142
- $current_block = $block;
5143
-
5144
- $obj = $block_object [$block];
5145
- $obj->clear_code_cache ();
5146
-
5147
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0 && !$positions_inserted && $ai_wp_data [AI_WP_DEBUG_BLOCK] <= $block) {
5148
- $preview = $block_object [$ai_wp_data [AI_WP_DEBUG_BLOCK]];
5149
- $content = $preview->before_paragraph ($content, true);
5150
- $content = $preview->after_paragraph ($content, true);
5151
- $positions_inserted = true;
5152
- }
5153
-
5154
- if (!$obj->check_server_side_detection ()) continue;
5155
- if (!$obj->check_page_types_lists_users ()) continue;
5156
- if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
5157
- if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
5158
- if (!$obj->check_number_of_words ($content, $content_words)) continue;
5159
-
5160
- // Deprecated
5161
- $ai_last_check = AI_CHECK_DISABLED_MANUALLY;
5162
- if ($obj->display_disabled ($content)) continue;
5163
-
5164
- // Last check before counter check before insertion
5165
- $ai_last_check = AI_CHECK_CODE;
5166
- if ($obj->ai_getCode () == '') continue;
5167
-
5168
- // Last check before insertion
5169
- if (!$obj->check_block_counter ()) continue;
5170
-
5171
- $automatic_insertion = $obj->get_automatic_insertion();
5172
-
5173
- if ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH) {
5174
- $ai_last_check = AI_CHECK_PARAGRAPH_COUNTING;
5175
- $content = $obj->before_paragraph ($content);
5176
- }
5177
- elseif ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH) {
5178
- $ai_last_check = AI_CHECK_PARAGRAPH_COUNTING;
5179
- $content = $obj->after_paragraph ($content);
5180
- }
5181
- elseif ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT) {
5182
- $obj->increment_block_counter ();
5183
-
5184
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5185
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5186
- $content = $obj->get_code_for_serverside_insertion () . $content;
5187
- $ai_last_check = AI_CHECK_INSERTED;
5188
- }
5189
- }
5190
- elseif ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT) {
5191
- $obj->increment_block_counter ();
5192
-
5193
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5194
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5195
- $content = $content . $obj->get_code_for_serverside_insertion ();
5196
- $ai_last_check = AI_CHECK_INSERTED;
5197
- }
5198
- }
5199
- }
5200
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5201
- }
5202
-
5203
-
5204
- if (function_exists ('ai_content')) ai_content ($content);
5205
-
5206
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
5207
- $class = AI_DEBUG_TAGS_CLASS;
5208
-
5209
- $content = preg_replace ("/\r\n\r\n/", "\r\n\r\n<kbd class='$class ai-debug-rnrn'>\\r\\n\\r\\n</kbd>", $content);
5210
-
5211
- $content = preg_replace ("/<p>/i", "<p><kbd class='$class ai-debug-p'>&lt;p&gt;</kbd>", $content);
5212
- // $content = preg_replace ("/<p ([^>]*?)>/i", "<p$1><kbd class='$class ai-debug-p'>&lt;p$1&gt;</kbd>", $content); // Full p tags
5213
- $content = preg_replace ("/<p ([^>]*?)>/i", "<p$1><kbd class='$class ai-debug-p'>&lt;p&gt;</kbd>", $content);
5214
- // $content = preg_replace ("/<div([^>]*?)>/i", "<div$1><kbd class='$class ai-debug-div'>&lt;div$1&gt;</kbd>", $content); // Full div tags
5215
- $content = preg_replace ("/<div([^>]*?)>/i", "<div$1><kbd class='$class ai-debug-div'>&lt;div&gt;</kbd>", $content);
5216
- $content = preg_replace ("/<h([1-6])([^>]*?)>/i", "<h$1$2><kbd class='$class ai-debug-h'>&lt;h$1&gt;</kbd>", $content);
5217
- $content = preg_replace ("/<img([^>]*?)>/i", "<img$1><kbd class='$class ai-debug-img'>&lt;img$1&gt;</kbd>", $content);
5218
- $content = preg_replace ("/<pre([^>]*?)>/i", "<pre$1><kbd class='$class ai-debug-pre'>&lt;pre&gt;</kbd>", $content);
5219
- $content = preg_replace ("/<(?!section|ins|script|kbd|a|strong|pre|p|div|h[1-6]|img)([a-z0-9]+)([^>]*?)>/i", "<$1$2><kbd class='$class ai-debug-special'>&lt;$1$2&gt;</kbd>", $content);
5220
-
5221
- $content = preg_replace ("/<\/p>/i", "<kbd class='$class ai-debug-p'>&lt;/p&gt;</kbd></p>", $content);
5222
- $content = preg_replace ("/<\/div>/i", "<kbd class='$class ai-debug-div'>&lt;/div&gt;</kbd></div>", $content);
5223
- $content = preg_replace ("/<\/h([1-6])>/i", "<kbd class='$class ai-debug-h'>&lt;/h$1&gt;</kbd></h$1>", $content);
5224
- $content = preg_replace ("/<\/pre>/i", "<kbd class='$class ai-debug-pre'>&lt;/pre&gt;</kbd></pre>", $content);
5225
- $content = preg_replace ("/<\/(?!section|ins|script|kbd|a|strong|pre|p|div|h[1-6])([a-z0-9]+)>/i", "<kbd class='$class ai-debug-special'>&lt;/$1&gt;</kbd></$1>", $content);
5226
- }
5227
-
5228
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5229
- $class = AI_DEBUG_POSITIONS_CLASS;
5230
-
5231
- if (!$positions_inserted) {
5232
- $preview = $block_object [$ai_wp_data [AI_WP_DEBUG_BLOCK]];
5233
- $content = $preview->before_paragraph ($content, true);
5234
- $content = $preview->after_paragraph ($content, true);
5235
- }
5236
-
5237
- $content = preg_replace ("/\[\[AI_BP([\d]+?)\]\]/", "<section class='$class'>BEFORE PARAGRAPH $1</section>", $content);
5238
- $content = preg_replace ("/\[\[AI_AP([\d]+?)\]\]/", "<section class='$class'>AFTER PARAGRAPH $1</section>", $content);
5239
-
5240
- $counter = $ad_inserter_globals [$globals_name];
5241
- if ($counter == 1) $counter = '';
5242
-
5243
- $content = "<section class='$class'><a class='ai-debug-left'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a> BEFORE CONTENT ".$counter."<a class='ai-debug-right'>".$content_words." words</a></section>". $content;
5244
-
5245
- if ($ai_wp_data [AI_WP_AMP_PAGE]) {
5246
- $content = get_page_type_debug_info ('AMP ') . $content;
5247
- }
5248
-
5249
- $content = $content . "<section class='$class'>AFTER CONTENT ".$counter."</section>";
5250
-
5251
- $content = $content . get_page_type_debug_info ();
5252
-
5253
- if ($ai_wp_data [AI_WP_AMP_PAGE]) {
5254
- $content = $content . get_page_type_debug_info ('AMP ');
5255
- }
5256
- }
5257
-
5258
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
5259
- $content = '<kbd class="ai-debug-invisible">[HTML TAGS REMOVED]</kbd>' . $content;
5260
- }
5261
-
5262
- if ($debug_processing) {
5263
- $ai_total_plugin_time += microtime (true) - $start_time;
5264
- ai_log ("CONTENT HOOK END\n");
5265
- }
5266
-
5267
- return $content;
5268
- }
5269
-
5270
- // Process Before/After Excerpt postion
5271
- function ai_excerpt_hook ($content = '') {
5272
- global $ad_inserter_globals, $block_object, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
5273
-
5274
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
5275
-
5276
- $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5277
- $globals_name = AI_EXCERPT_COUNTER_NAME;
5278
-
5279
- if (!isset ($ad_inserter_globals [$globals_name])) {
5280
- $ad_inserter_globals [$globals_name] = 1;
5281
- } else $ad_inserter_globals [$globals_name] ++;
5282
-
5283
- if ($debug_processing) {
5284
- ai_log ("EXCERPT HOOK START [" . $ad_inserter_globals [$globals_name] . ']');
5285
- $start_time = microtime (true);
5286
- }
5287
-
5288
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_EXCERPT;
5289
-
5290
- $ai_last_check = AI_CHECK_NONE;
5291
- $current_block = 0;
5292
-
5293
- if (isset ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5294
- foreach ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5295
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5296
-
5297
- if (!isset ($block_object [$block])) continue;
5298
-
5299
- $current_block = $block;
5300
- $obj = $block_object [$block];
5301
- $obj->clear_code_cache ();
5302
-
5303
- if (!$obj->check_server_side_detection ()) continue;
5304
- if (!$obj->check_page_types_lists_users ()) continue;
5305
- if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
5306
-
5307
- // Deprecated
5308
- $ai_last_check = AI_CHECK_DISABLED_MANUALLY;
5309
- if ($obj->display_disabled ($content)) continue;
5310
-
5311
- // Last check before counter check before insertion
5312
- $ai_last_check = AI_CHECK_CODE;
5313
- if ($obj->ai_getCode () == '') continue;
5314
-
5315
- // Last check before insertion
5316
- if (!$obj->check_and_increment_block_counter ()) continue;
5317
-
5318
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5319
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5320
-
5321
- $automatic_insertion = $obj->get_automatic_insertion ();
5322
- if ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT)
5323
- $content = $obj->get_code_for_serverside_insertion () . $content; else
5324
- $content = $content . $obj->get_code_for_serverside_insertion ();
5325
-
5326
- $ai_last_check = AI_CHECK_INSERTED;
5327
- }
5328
- }
5329
-
5330
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5331
-
5332
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5333
- $class = AI_DEBUG_POSITIONS_CLASS;
5334
-
5335
- $content = "<section class='$class'>BEFORE EXCERPT ".$ad_inserter_globals [$globals_name]."</section>". $content . "<section class='$class'>AFTER EXCERPT ".$ad_inserter_globals [$globals_name]."</section>";
5336
-
5337
- // Color positions from the content hook
5338
- $content = preg_replace ("/((BEFORE|AFTER) (CONTENT|PARAGRAPH) ?[\d]*)/", "<span class='ai-debug-content-hook-positions'> [$1] </span>", $content);
5339
- }
5340
-
5341
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
5342
- // Remove marked tags from the content hook
5343
- $content = preg_replace ("/&lt;(.+?)&gt;/", "", $content);
5344
-
5345
- // Color text to mark removed HTML tags
5346
- $content = str_replace ('[HTML TAGS REMOVED]', "<span class='ai-debug-removed-html-tags'>[HTML TAGS REMOVED]</span>", $content);
5347
- }
5348
-
5349
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
5350
- // Remove block labels from the content hook
5351
- if (strpos ($content, '>[AI]<') === false)
5352
- $content = preg_replace ("/\[AI\](.+?)\[\/AI\]/", "", $content);
5353
- }
5354
-
5355
- if ($debug_processing) {
5356
- $ai_total_plugin_time += microtime (true) - $start_time;
5357
- ai_log ("EXCERPT HOOK END\n");
5358
- }
5359
-
5360
- return $content;
5361
- }
5362
-
5363
- function ai_comments_array ($comments , $post_id ){
5364
- global $ai_wp_data;
5365
-
5366
- $thread_comments = get_option ('thread_comments');
5367
- $comment_counter = 0;
5368
- foreach ($comments as $comment) {
5369
- if (!$thread_comments || empty ($comment->comment_parent))
5370
- $comment_counter ++;
5371
- }
5372
- $ai_wp_data [AI_NUMBER_OF_COMMENTS] = $comment_counter;
5373
-
5374
- return $comments;
5375
- }
5376
-
5377
- function ai_wp_list_comments_args ($args) {
5378
- global $ai_wp_data;
5379
-
5380
- // print_r ($args);
5381
- // $args['per_page'] = 3;
5382
- // $args['page'] = 2;
5383
-
5384
- $ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'] = $args ['callback'];
5385
- $args ['callback'] = 'ai_comment_callback';
5386
-
5387
- $ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'] = $args ['end-callback'];
5388
- $args ['end-callback'] = 'ai_comment_end_callback';
5389
-
5390
- return $args;
5391
- }
5392
-
5393
- // Process comments counter + Before Comments postion
5394
- function ai_comment_callback ($comment, $args, $depth) {
5395
- global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time, $ai_walker;
5396
-
5397
- if ($depth == 1) {
5398
- if (!isset ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME])) {
5399
- $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] = 1;
5400
- } else $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] ++;
5401
- }
5402
-
5403
- $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5404
- if ($debug_processing) {
5405
- ai_log ('COMMENT START HOOK START [' . $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] . ':'. $depth . ']');
5406
- $start_time = microtime (true);
5407
- }
5408
-
5409
- if ($depth == 1 && $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] == 1) {
5410
-
5411
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BEFORE_COMMENTS;
5412
-
5413
- if ($args ['style'] == 'div') $tag = 'div'; else $tag = 'li';
5414
-
5415
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5416
-
5417
- $class = AI_DEBUG_POSITIONS_CLASS;
5418
-
5419
- echo "<$tag>\n";
5420
- echo "<section class='$class'>BEFORE COMMENTS</section>";
5421
- echo "</$tag>\n";
5422
- }
5423
-
5424
- $ad_code = "";
5425
-
5426
- $ai_last_check = AI_CHECK_NONE;
5427
- $current_block = 0;
5428
-
5429
- if (isset ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5430
- foreach ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5431
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5432
-
5433
- if (!isset ($block_object [$block])) continue;
5434
-
5435
- $current_block = $block;
5436
-
5437
- $obj = $block_object [$block];
5438
- $obj->clear_code_cache ();
5439
-
5440
- if (!$obj->check_server_side_detection ()) continue;
5441
- if (!$obj->check_page_types_lists_users ()) continue;
5442
- // No filter check
5443
-
5444
- // Last check before counter check before insertion
5445
- $ai_last_check = AI_CHECK_CODE;
5446
- if ($obj->ai_getCode () == '') continue;
5447
-
5448
- // Last check before insertion
5449
- if (!$obj->check_and_increment_block_counter ()) continue;
5450
-
5451
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5452
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5453
- $ad_code .= $obj->get_code_for_serverside_insertion ();
5454
- $ai_last_check = AI_CHECK_INSERTED;
5455
- }
5456
- }
5457
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5458
-
5459
- echo "<$tag>\n";
5460
- echo $ad_code;
5461
- echo "</$tag>\n";
5462
- }
5463
-
5464
- if ($debug_processing) {
5465
- $ai_total_plugin_time += microtime (true) - $start_time;
5466
- ai_log ("COMMENT END HOOK END\n");
5467
- }
5468
-
5469
- if (!empty ($ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'])) {
5470
- echo call_user_func ($ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'], $comment, $args, $depth );
5471
- } else {
5472
- $ai_walker->comment_callback ($comment, $args, $depth);
5473
- }
5474
- }
5475
-
5476
- // Process Between Comments postion
5477
- function ai_comment_end_callback ($comment, $args, $depth) {
5478
- global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
5479
-
5480
- if ($args ['style'] == 'div') $tag = 'div'; else $tag = 'li';
5481
-
5482
- if (!empty ($ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'])) {
5483
- echo call_user_func ($ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'], $comment, $args, $depth);
5484
- } else echo "</$tag><!-- #comment-## -->\n";
5485
-
5486
- $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5487
- if ($debug_processing) {
5488
- ai_log ('COMMENT END HOOK START [' . $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] . ':'. ($depth + 1) . ']');
5489
- $start_time = microtime (true);
5490
- }
5491
-
5492
- if ($depth == 0) {
5493
-
5494
- if (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) &&
5495
- $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] != 0 &&
5496
- !empty ($args ['per_page']) && !empty ($args ['page'])) {
5497
- $number_of_comments_mod_per_page = $ai_wp_data [AI_NUMBER_OF_COMMENTS] % $args ['per_page'];
5498
- if ($number_of_comments_mod_per_page != 0) {
5499
- $last_page = (int) ($ai_wp_data [AI_NUMBER_OF_COMMENTS] / $args ['per_page']) + 1;
5500
- $last_comment_number = $args ['page'] == $last_page ? $number_of_comments_mod_per_page : $args ['per_page'];
5501
- } else $last_comment_number = $args ['per_page'];
5502
- } else $last_comment_number = $ai_wp_data [AI_NUMBER_OF_COMMENTS];
5503
-
5504
- if ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME] == $last_comment_number) {
5505
-
5506
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_AFTER_COMMENTS;
5507
-
5508
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5509
-
5510
- $class = AI_DEBUG_POSITIONS_CLASS;
5511
-
5512
- echo "<$tag>\n";
5513
- echo "<section class='$class'>AFTER COMMENTS</section>";
5514
- echo "</$tag>\n";
5515
- }
5516
-
5517
- $ad_code = "";
5518
-
5519
- $ai_last_check = AI_CHECK_NONE;
5520
- $current_block = 0;
5521
-
5522
- if (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5523
- foreach ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5524
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5525
-
5526
- if (!isset ($block_object [$block])) continue;
5527
-
5528
- $current_block = $block;
5529
-
5530
- $obj = $block_object [$block];
5531
- $obj->clear_code_cache ();
5532
-
5533
- if (!$obj->check_server_side_detection ()) continue;
5534
- if (!$obj->check_page_types_lists_users ()) continue;
5535
- // No filter check
5536
-
5537
- // Last check before counter check before insertion
5538
- $ai_last_check = AI_CHECK_CODE;
5539
- if ($obj->ai_getCode () == '') continue;
5540
-
5541
- // Last check before insertion
5542
- if (!$obj->check_and_increment_block_counter ()) continue;
5543
-
5544
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5545
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5546
- $ad_code .= $obj->get_code_for_serverside_insertion ();
5547
- $ai_last_check = AI_CHECK_INSERTED;
5548
- }
5549
- }
5550
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5551
-
5552
- echo "<$tag>\n";
5553
- echo $ad_code;
5554
- echo "</$tag>\n";
5555
- } else {
5556
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BETWEEN_COMMENTS;
5557
-
5558
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5559
-
5560
- $class = AI_DEBUG_POSITIONS_CLASS;
5561
-
5562
- echo "<$tag>\n";
5563
- echo "<section class='$class'>BETWEEN COMMENTS ".$ad_inserter_globals [AI_COMMENT_COUNTER_NAME]."</section>";
5564
- echo "</$tag>\n";
5565
- }
5566
-
5567
- $ad_code = "";
5568
-
5569
- $ai_last_check = AI_CHECK_NONE;
5570
- $current_block = 0;
5571
-
5572
- if (isset ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5573
- foreach ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5574
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5575
-
5576
- if (!isset ($block_object [$block])) continue;
5577
-
5578
- $current_block = $block;
5579
-
5580
- $obj = $block_object [$block];
5581
- $obj->clear_code_cache ();
5582
-
5583
- if (!$obj->check_server_side_detection ()) continue;
5584
- if (!$obj->check_page_types_lists_users ()) continue;
5585
- if (!$obj->check_filter ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME])) continue;
5586
-
5587
- // Last check before counter check before insertion
5588
- $ai_last_check = AI_CHECK_CODE;
5589
- if ($obj->ai_getCode () == '') continue;
5590
-
5591
- // Last check before insertion
5592
- if (!$obj->check_and_increment_block_counter ()) continue;
5593
-
5594
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5595
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5596
- $ad_code .= $obj->get_code_for_serverside_insertion ();
5597
- $ai_last_check = AI_CHECK_INSERTED;
5598
- }
5599
- }
5600
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5601
-
5602
- echo "<$tag>\n";
5603
- echo $ad_code;
5604
- echo "</$tag>\n";
5605
- }
5606
- }
5607
-
5608
- if ($debug_processing) {
5609
- $ai_total_plugin_time += microtime (true) - $start_time;
5610
- ai_log ("COMMENT END HOOK END\n");
5611
- }
5612
- }
5613
-
5614
- function ai_custom_hook ($action, $name, $hook_parameter = null, $hook_check = null) {
5615
- global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
5616
-
5617
- $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5618
-
5619
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
5620
-
5621
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
5622
-
5623
- if (isset ($hook_check)) {
5624
- if (!call_user_func ($hook_check, $hook_parameter, $action)) return;
5625
- }
5626
-
5627
- $hook_name = strtoupper ($name);
5628
-
5629
- if ($debug_processing) {
5630
- ai_log (str_replace (array ('&LT;', '&GT;'), array ('<', '>'), $hook_name) . " HOOK START");
5631
- $start_time = microtime (true);
5632
- }
5633
-
5634
- $globals_name = 'AI_' . strtoupper ($action) . '_COUNTER';
5635
-
5636
- if (!isset ($ad_inserter_globals [$globals_name])) {
5637
- $ad_inserter_globals [$globals_name] = 1;
5638
- } else $ad_inserter_globals [$globals_name] ++;
5639
-
5640
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5641
-
5642
- $counter = $ad_inserter_globals [$globals_name];
5643
- if ($counter == 1) $counter = '';
5644
-
5645
- $class = AI_DEBUG_POSITIONS_CLASS;
5646
-
5647
- echo "<section class='$class'>".$hook_name." ".$counter."</section>";
5648
- }
5649
-
5650
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
5651
- $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
5652
- $selected_blocks = explode (",", $meta_value);
5653
- } else $selected_blocks = array ();
5654
-
5655
- $ad_code = "";
5656
-
5657
- $ai_last_check = AI_CHECK_NONE;
5658
- $current_block = 0;
5659
-
5660
- if (isset ($ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5661
- foreach ($ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5662
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5663
-
5664
- if (!isset ($block_object [$block])) continue;
5665
-
5666
- $current_block = $block;
5667
-
5668
- $obj = $block_object [$block];
5669
- $obj->clear_code_cache ();
5670
-
5671
- if (!$obj->check_server_side_detection ()) continue;
5672
- if (!$obj->check_page_types_lists_users ()) continue;
5673
- if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
5674
- if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
5675
- if (!$obj->check_number_of_words ()) continue;
5676
-
5677
- // Last check before counter check before insertion
5678
- $ai_last_check = AI_CHECK_CODE;
5679
- if ($obj->ai_getCode () == '') continue;
5680
-
5681
- // Last check before insertion
5682
- if (!$obj->check_and_increment_block_counter ()) continue;
5683
-
5684
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5685
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5686
- $ad_code .= $obj->get_code_for_serverside_insertion ();
5687
- $ai_last_check = AI_CHECK_INSERTED;
5688
- }
5689
- }
5690
- if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5691
-
5692
- echo $ad_code;
5693
-
5694
- if ($debug_processing) {
5695
- $ai_total_plugin_time += microtime (true) - $start_time;
5696
- ai_log (str_replace (array ('&LT;', '&GT;'), array ('<', '>'), $hook_name) . " HOOK END\n");
5697
- }
5698
- }
5699
-
5700
-
5701
- function ai_pre_do_shortcode_tag ($return, $tag, $attr, $m) {
5702
- global $ai_expand_only_rotate;
5703
-
5704
- // Array
5705
- //(
5706
- // [0] => [ADINSERTER ROTATE='1']
5707
- // [1] =>
5708
- // [2] => ADINSERTER
5709
- // [3] => ROTATE='1'
5710
- // [4] =>
5711
- // [5] =>
5712
- // [6] =>
5713
-
5714
- if (strtolower ($tag) == 'adinserter') {
5715
- if ($ai_expand_only_rotate) {
5716
- // Expand only ROTATE
5717
- if (isset ($attr ['rotate']) || in_array ('ROTATE', $attr) || in_array ('rotate', $atts)) {
5718
- return false;
5719
- } else return $m [0];
5720
- }
5721
- }
5722
-
5723
- return $return;
5724
- }
5725
-
5726
- function ai_process_shortcode (&$block, $atts) {
5727
- global $block_object, $ai_last_check, $ai_wp_data;
5728
-
5729
- if ($atts == '') return '';
5730
-
5731
- $parameters = shortcode_atts (array (
5732
- "block" => "",
5733
- "code" => "",
5734
- "name" => "",
5735
- "ignore" => "",
5736
- "check" => "",
5737
- // "debugger" => "",
5738
- "adb" => "",
5739
- "css" => "",
5740
- "text" => "",
5741
- "selectors" => "",
5742
- "amp" => "",
5743
- "rotate" => "",
5744
- "count" => "",
5745
- "http" => "",
5746
- "custom-field" => "",
5747
- "data" => "",
5748
- ), $atts);
5749
-
5750
-
5751
- $output = "";
5752
- if (function_exists ('ai_shortcode')) {
5753
- $output = ai_shortcode ($parameters);
5754
- if ($output != '') return $output;
5755
- }
5756
-
5757
- if (($adb = trim ($parameters ['adb'])) != '') {
5758
- // message html
5759
- // message css
5760
- // overlay css
5761
- // undismissible
5762
-
5763
- // redirection page
5764
- // redirection url
5765
-
5766
- switch (strtolower ($adb)) {
5767
- case 'message':
5768
- $ai_wp_data [AI_ADB_SHORTCODE_ACTION] = AI_ADB_ACTION_MESSAGE;
5769
- break;
5770
- case 'redirection':
5771
- $ai_wp_data [AI_ADB_SHORTCODE_ACTION] = AI_ADB_ACTION_REDIRECTION;
5772
- break;
5773
- }
5774
- return "";
5775
- }
5776
-
5777
- $block = - 1;
5778
- $code_only = false;
5779
-
5780
- if ($parameters ['block'] == '' && $parameters ['code'] != '') {
5781
- $parameters ['block'] = $parameters ['code'];
5782
- $code_only = true;
5783
- }
5784
-
5785
- if (is_numeric ($parameters ['block'])) {
5786
- $block = intval ($parameters ['block']);
5787
- } elseif ($parameters ['name'] != '') {
5788
- $shortcode_name = strtolower ($parameters ['name']);
5789
- for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
5790
- $obj = $block_object [$counter];
5791
- $ad_name = strtolower (trim ($obj->get_ad_name()));
5792
- if ($shortcode_name == $ad_name) {
5793
- $block = $counter;
5794
- break;
5795
- }
5796
- }
5797
- }
5798
-
5799
- if ($block == - 1) {
5800
- if ($parameters ['count'] != '' || in_array ('COUNT', $atts) || in_array ('count', $atts)) {
5801
- if (!isset ($ai_wp_data [AI_SHORTCODES]['count'])) $ai_wp_data [AI_SHORTCODES]['count'] = array ();
5802
- $ai_wp_data [AI_SHORTCODES]['count'] []= $parameters;
5803
- return AD_COUNT_SEPARATOR;
5804
- }
5805
- if ($parameters ['rotate'] != '' || in_array ('ROTATE', $atts) || in_array ('rotate', $atts)) {
5806
- if (!isset ($ai_wp_data [AI_SHORTCODES]['rotate'])) $ai_wp_data [AI_SHORTCODES]['rotate'] = array ();
5807
- $ai_wp_data [AI_SHORTCODES]['rotate'] []= $parameters;
5808
- return AD_ROTATE_SEPARATOR;
5809
- }
5810
- if ($parameters ['amp'] != '' || in_array ('AMP', $atts) || in_array ('amp', $atts)) {
5811
- return AD_AMP_SEPARATOR;
5812
- }
5813
- if ($parameters ['http'] != '' || in_array ('HTTP', $atts) || in_array ('http', $atts)) {
5814
- return AD_HTTP_SEPARATOR;
5815
- }
5816
- if ($parameters ['custom-field'] != '') {
5817
- $post_meta = get_post_meta (get_the_ID(), $parameters ['custom-field']);
5818
- if (is_array ($post_meta)) {
5819
- $post_meta = implode (', ', $post_meta);
5820
- }
5821
- return $post_meta;
5822
- }
5823
- if ($parameters ['data'] != '') {
5824
- return '{'.$parameters ['data'].'}';
5825
- }
5826
- if ($parameters ['name'] != '') {
5827
- switch (strtolower ($parameters ['name'])) {
5828
- case 'processing-log':
5829
- if (/*get_remote_debugging () ||*/ ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) {
5830
- ob_start ();
5831
- echo "<pre style='", AI_DEBUG_WIDGET_STYLE, "'>\n";
5832
- ai_write_debug_info ();
5833
- echo "</pre>";
5834
- return ob_get_clean ();
5835
- }
5836
- return "";
5837
- case 'debugging-tools':
5838
- if (/*get_remote_debugging () ||*/ ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) {
5839
- ai_write_debugging_tools ();
5840
- }
5841
- return "";
5842
- }
5843
- }
5844
- }
5845
-
5846
- $ai_last_check = AI_CHECK_SHORTCODE_ATTRIBUTES;
5847
- if ($block < 1 || $block > AD_INSERTER_BLOCKS) return "";
5848
-
5849
- 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'].'"' : '').")");
5850
-
5851
- // IGNORE SETTINGS
5852
- // page-type
5853
- // *block-counter
5854
-
5855
- // CHECK SETTINGS
5856
- // exceptions
5857
-
5858
- $ignore_array = array ();
5859
- if (trim ($parameters ['ignore']) != '') {
5860
- $ignore_array = explode (",", str_replace (" ", "", $parameters ['ignore']));
5861
- }
5862
-
5863
- $check_array = array ();
5864
- if (trim ($parameters ['check']) != '') {
5865
- $check_array = explode (",", str_replace (" ", "", $parameters ['check']));
5866
- }
5867
-
5868
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_SHORTCODE;
5869
-
5870
- $obj = $block_object [$block];
5871
- $obj->clear_code_cache ();
5872
-
5873
- $ai_last_check = AI_CHECK_ENABLED_SHORTCODE;
5874
- if (!$obj->get_enable_manual ()) return "";
5875
-
5876
- if (!$obj->check_server_side_detection ()) return "";
5877
- if (!$obj->check_page_types_lists_users (in_array ("page-type", $ignore_array))) return "";
5878
-
5879
- if (in_array ("exceptions", $check_array)) {
5880
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
5881
- $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
5882
- $selected_blocks = explode (",", $meta_value);
5883
- if (!$obj->check_post_page_exceptions ($selected_blocks)) return "";
5884
- }
5885
- }
5886
-
5887
- // Last check before counter check before insertion
5888
- $ai_last_check = AI_CHECK_CODE;
5889
- if ($obj->ai_getCode () == '') return "";
5890
-
5891
- // Last check before insertion
5892
- if (!$obj->check_and_increment_block_counter ()) return "";
5893
-
5894
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5895
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5896
- $ai_last_check = AI_CHECK_INSERTED;
5897
- return $obj->get_code_for_serverside_insertion (true, false, $code_only);
5898
- }
5899
- }
5900
-
5901
- function ai_process_shortcodes ($atts, $content, $tag) {
5902
- global $ai_last_check, $ai_wp_data, $ai_total_plugin_time;
5903
-
5904
- $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5905
- if ($debug_processing) {
5906
- $atts_string = '';
5907
- if (is_array ($atts))
5908
- foreach ($atts as $index => $att) {
5909
- if (is_numeric ($index))
5910
- $atts_string .= $att.' '; else
5911
- $atts_string .= $index.("='".$att."'").' ';
5912
- }
5913
- ai_log ("PROCESS SHORTCODES [$tag ".trim ($atts_string).']');
5914
- $start_time = microtime (true);
5915
- }
5916
- $ai_last_check = AI_CHECK_NONE;
5917
- $block = - 1;
5918
- $shortcode = ai_process_shortcode ($block, $atts);
5919
-
5920
- if ($debug_processing) {
5921
- $ai_total_plugin_time += microtime (true) - $start_time;
5922
- if ($block == - 1) {
5923
- if (strlen ($shortcode) < 100) ai_log ('SHORTCODE TEXT: "' . ai_log_filter_content ($shortcode) . '"'); else
5924
- 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))) . '"');
5925
- }
5926
- elseif ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
5927
- ai_log ("SHORTCODE END\n");
5928
- }
5929
-
5930
- return $shortcode;
5931
- }
5932
-
5933
- //function process_shortcodes_lc ($atts, $content, $tag) {
5934
- // return process_shortcodes ($atts, 'adinserter');
5935
- //}
5936
-
5937
- //function process_shortcodes_uc ($atts, $content, $tag) {
5938
- // return process_shortcodes ($atts, 'ADINSERTER');
5939
- //}
5940
-
5941
-
5942
- class ai_widget extends WP_Widget {
5943
-
5944
- function __construct () {
5945
- parent::__construct (
5946
- false, // Base ID
5947
- AD_INSERTER_NAME, // Name
5948
- array ( // Args
5949
- 'classname' => 'ai_widget',
5950
- 'description' => AD_INSERTER_NAME.' code block widget.')
5951
- );
5952
- }
5953
-
5954
- function form ($instance) {
5955
- global $block_object;
5956
-
5957
- // Output admin widget options form
5958
-
5959
- $widget_title = !empty ($instance ['widget-title']) ? $instance ['widget-title'] : '';
5960
- $block = isset ($instance ['block']) ? $instance ['block'] : 1;
5961
- if ($block > AD_INSERTER_BLOCKS) $block = 1;
5962
- $sticky = isset ($instance ['sticky']) ? $instance ['sticky'] : 0;
5963
-
5964
- if ($block == 0) $title = 'Processing Log';
5965
- elseif ($block == - 1) $title = 'Dummy Widget';
5966
- elseif ($block == - 2) $title = 'Debugging Tools';
5967
- elseif ($block >= 1) {
5968
- $obj = $block_object [$block];
5969
-
5970
- $title = '[' . $block . '] ' . $obj->get_ad_name();
5971
- if (!empty ($widget_title)) $title .= ' - ' . $widget_title;
5972
- if (!$obj->get_enable_widget ()) $title .= ' - DISABLED';
5973
- } else $title = "Unknown block";
5974
-
5975
- $url_parameters = "";
5976
- if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($block);
5977
-
5978
- ?>
5979
- <input id="<?php echo $this->get_field_id ('title'); ?>" name="<?php echo $this->get_field_name ('title'); ?>" type="hidden" value="<?php echo esc_attr ($title); ?>">
5980
-
5981
- <p>
5982
- <label for="<?php echo $this->get_field_id ('widget-title'); ?>">Title: &nbsp;</label>
5983
- <input id="<?php echo $this->get_field_id ('widget-title'); ?>" name="<?php echo $this->get_field_name ('widget-title'); ?>" type="text" value="<?php echo esc_attr ($widget_title); ?>" style="width: 88%;">
5984
- </p>
5985
-
5986
- <p>
5987
- <label for="<?php echo $this->get_field_id ('block'); ?>"><a href='<?php echo admin_url ('options-general.php?page=ad-inserter.php'), $url_parameters, "&tab=", $block; ?>' title='Click for block settings' style='text-decoration: none;'>Block</a>:</label>
5988
- <select id="<?php echo $this->get_field_id ('block'); ?>" name="<?php echo $this->get_field_name('block'); ?>" style="width: 88%;">
5989
- <?php
5990
- for ($block_index = 1; $block_index <= AD_INSERTER_BLOCKS; $block_index ++) {
5991
- $obj = $block_object [$block_index];
5992
- ?>
5993
- <option value='<?php echo $block_index; ?>' <?php if ($block_index == $block) echo 'selected="selected"'; ?>><?php echo $block_index, ' - ', $obj->get_ad_name(), !$obj->get_enable_widget ()? ' - DISABLED' : ''; ?></option>
5994
- <?php } ?>
5995
- <option value='-2' <?php if ($block == - 2) echo 'selected="selected"'; ?>>Debugging Tools</option>
5996
- <option value='0' <?php if ($block == 0) echo 'selected="selected"'; ?>>Processing Log</option>
5997
- <option value='-1' <?php if ($block == - 1) echo 'selected="selected"'; ?>>Dummy Widget</option>
5998
- </select>
5999
- </p>
6000
-
6001
- <p>
6002
- <input type="hidden" name='<?php echo $this->get_field_name ('sticky'); ?>' value="0" />
6003
- <input type='checkbox' id='<?php echo $this->get_field_id ('sticky'); ?>' name='<?php echo $this->get_field_name ('sticky'); ?>' value='1' <?php if ($sticky) echo 'checked '; ?>>
6004
- <label for='<?php echo $this->get_field_id ('sticky'); ?>'>Sticky</label>
6005
- </p>
6006
- <?php
6007
- }
6008
-
6009
- function update ($new_instance, $old_instance) {
6010
- // Save widget options
6011
- $instance = $old_instance;
6012
-
6013
- $instance ['widget-title'] = (!empty ($new_instance ['widget-title'])) ? strip_tags ($new_instance ['widget-title']) : '';
6014
- $instance ['title'] = (!empty ($new_instance ['title'])) ? strip_tags ($new_instance ['title']) : '';
6015
- $instance ['block'] = (isset ($new_instance ['block'])) ? $new_instance ['block'] : 1;
6016
- $instance ['sticky'] = (isset ($new_instance ['sticky'])) ? $new_instance ['sticky'] : 0;
6017
-
6018
- return $instance;
6019
- }
6020
-
6021
- function widget ($args, $instance) {
6022
- global $ai_last_check, $ai_wp_data, $ai_total_plugin_time;
6023
-
6024
- $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
6025
- if ($debug_processing) $start_time = microtime (true);
6026
-
6027
- $ai_last_check = AI_CHECK_NONE;
6028
-
6029
- $block = 0;
6030
- ai_widget_draw ($args, $instance, $block);
6031
-
6032
- if ($debug_processing) {
6033
- $ai_total_plugin_time += microtime (true) - $start_time;
6034
- if ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
6035
- ai_log ("WIDGET END\n");
6036
- }
6037
- }
6038
- }
6039
-
6040
- function ai_add_attr_data (&$tag, $attr, $new_data) {
6041
-
6042
- if (trim ($tag) != '' && strpos ($tag, '<!--') === false) {
6043
- if (stripos ($tag, $attr."=") !== false) {
6044
- preg_match ("/$attr=[\'\"](.+?)[\'\"]/", $tag, $classes);
6045
- $tag = str_replace ($classes [1], $classes [1]. ' ' . $new_data, $tag);
6046
- return true;
6047
- }
6048
- elseif (strpos ($tag, ">") !== false) {
6049
- $tag = str_replace ('>', ' ' . $attr . '="' . $new_data . '">', $tag);
6050
- return true;
6051
- }
6052
- }
6053
-
6054
- return false;
6055
- }
6056
-
6057
- function ai_widget_draw ($args, $instance, &$block) {
6058
- global $block_object, $ad_inserter_globals, $ai_wp_data, $ai_last_check;
6059
-
6060
- $block = isset ($instance ['block']) ? $instance ['block'] : 1;
6061
- $sticky = isset ($instance ['sticky']) ? $instance ['sticky'] : 0;
6062
-
6063
- if ($block == 0 || $block == - 2) {
6064
- if (/*get_remote_debugging () ||*/ ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) {
6065
- ai_special_widget ($args, $instance, $block);
6066
- }
6067
- return;
6068
- }
6069
-
6070
- if ($sticky) {
6071
- $ai_wp_data [AI_STICKY_WIDGETS] = true;
6072
- if ($block == - 1) {
6073
- $before_widget = $args ['before_widget'];
6074
- ai_add_attr_data ($before_widget, 'style', 'padding: 0; border: 0; margin: 0; color: transparent; background: transparent;');
6075
- ai_add_attr_data ($before_widget, 'class', 'ai-sticky-widget');
6076
- echo $before_widget;
6077
- echo $args ['after_widget'];
6078
- return;
6079
- }
6080
- }
6081
-
6082
- if ($block < 1 || $block > AD_INSERTER_BLOCKS) return;
6083
-
6084
- $title = !empty ($instance ['widget-title']) ? $instance ['widget-title'] : '';
6085
-
6086
- $obj = $block_object [$block];
6087
- $obj->clear_code_cache ();
6088
-
6089
- $globals_name = AI_WIDGET_COUNTER_NAME . $block;
6090
-
6091
- if (!isset ($ad_inserter_globals [$globals_name])) {
6092
- $ad_inserter_globals [$globals_name] = 1;
6093
- } else $ad_inserter_globals [$globals_name] ++;
6094
-
6095
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0)
6096
- ai_log ("WIDGET (". $obj->number . ') ['.$ad_inserter_globals [$globals_name] . ']');
6097
-
6098
- $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_WIDGET;
6099
-
6100
- $ai_last_check = AI_CHECK_ENABLED_WIDGET;
6101
- if (!$obj->get_enable_widget ()) return;
6102
- if (!$obj->check_server_side_detection ()) return;
6103
- if (!$obj->check_page_types_lists_users ()) return;
6104
- if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return;
6105
- if (!$obj->check_number_of_words ()) return;
6106
-
6107
- if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
6108
- $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
6109
- $selected_blocks = explode (",", $meta_value);
6110
- if (!$obj->check_post_page_exceptions ($selected_blocks)) return;
6111
- }
6112
-
6113
- // Last check before counter check before insertion
6114
- $ai_last_check = AI_CHECK_CODE;
6115
- if ($obj->ai_getCode () == '') {
6116
- if ($sticky) {
6117
- $before_widget = $args ['before_widget'];
6118
- ai_add_attr_data ($before_widget, 'style', 'padding: 0; border: 0; margin: 0; color: transparent; background: transparent;');
6119
- ai_add_attr_data ($before_widget, 'class', 'ai-sticky-widget');
6120
- echo $before_widget;
6121
- echo $args ['after_widget'];
6122
- }
6123
- return;
6124
- }
6125
-
6126
- // Last check before insertion
6127
- if (!$obj->check_and_increment_block_counter ()) return;
6128
-
6129
- $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
6130
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
6131
-
6132
- $viewport_classes = $obj->get_client_side_action () == AI_CLIENT_SIDE_ACTION_INSERT ? '' : trim ($obj->get_viewport_classes ());
6133
- $sticky_class = $sticky ? ' ai-sticky-widget' : '';
6134
- $widget_classes = trim ($viewport_classes . $sticky_class);
6135
-
6136
- if ($widget_classes != "") {
6137
- $before_widget = $args ['before_widget'];
6138
- ai_add_attr_data ($before_widget, 'class', $widget_classes);
6139
- echo $before_widget;
6140
- } else echo $args ['before_widget'];
6141
-
6142
- if (!empty ($title)) {
6143
- echo $args ['before_title'], apply_filters ('widget_title', $title), $args ['after_title'];
6144
- }
6145
-
6146
- echo $obj->get_code_for_serverside_insertion (false);
6147
-
6148
- echo $args ['after_widget'];
6149
-
6150
- $ai_last_check = AI_CHECK_INSERTED;
6151
-
6152
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && $obj->get_detection_client_side())
6153
- echo $obj->get_code_for_serverside_insertion (false, true);
6154
- }
6155
- }
6156
-
6157
- function ai_write_debugging_tools () {
6158
- global $ai_wp_data;
6159
-
6160
- ai_toolbar_menu_items ();
6161
-
6162
-
6163
- echo "<style>
6164
-
6165
- ul.ai-debug-tools {
6166
- list-style: none;
6167
- background: #000;
6168
- color: #eee;
6169
- margin: 0;
6170
- padding: 10px;
6171
- font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif;
6172
- font-size: 14px;
6173
- line-height: 22px;
6174
- }
6175
-
6176
- ul.ai-debug-tools li {
6177
- margin: 0;
6178
- padding: 0;
6179
- border: 0;
6180
- }
6181
-
6182
- ul.ai-debug-tools a, ul.ai-debug-tools a:link, ul.ai-debug-tools a:visited {
6183
- text-decoration: none;
6184
- color: #aaa;
6185
- }
6186
-
6187
- ul.ai-debug-tools a:hover {
6188
- color: #5faff9!important;
6189
- }
6190
-
6191
- ul.ai-debug-tools .ab-icon {
6192
- position: relative;
6193
- font: 400 20px/1 dashicons;
6194
- speak: none;
6195
- padding: 4px 0;
6196
- -webkit-font-smoothing: antialiased;
6197
- -moz-osx-font-smoothing: grayscale;
6198
- background-image: none!important;
6199
- margin-right: 6px;
6200
- vertical-align: text-top;
6201
- }
6202
-
6203
- ul.ai-debug-tools .ai-debug-tools-title {
6204
- padding-bottom: 10px;
6205
- }
6206
-
6207
- .ai-debug-tools-title .ab-icon:before {
6208
- content: '\\f111';
6209
- top: 2px;
6210
- color: rgba(240,245,250,.6)!important;
6211
- }
6212
- ul.ai-debug-tools .ab-icon.on:before {
6213
- color: #00f200!important;
6214
- }
6215
- .ai-debug-ai-toolbar-blocks .ab-icon:before {
6216
- content: '\\f135';
6217
- }
6218
- .ai-debug-ai-toolbar-positions .ab-icon:before {
6219
- content: '\\f207';
6220
- }
6221
- ul.ai-debug-tools .ai-debug-tools-positions {
6222
- margin-left: 22px;
6223
- }
6224
- .ai-debug-tools-positions .ab-icon:before {
6225
- content: '\\f522';
6226
- }
6227
- .ai-debug-ai-toolbar-tags .ab-icon:before {
6228
- content: '\\f475';
6229
- }
6230
- .ai-debug-ai-toolbar-no-insertion .ab-icon:before {
6231
- content: '\\f214';
6232
- }
6233
- .ai-debug-ai-toolbar-adb-status .ab-icon:before {
6234
- content: '\\f223';
6235
- }
6236
- .ai-debug-ai-toolbar-adb .ab-icon:before {
6237
- content: '\\f160';
6238
- }
6239
- .ai-debug-ai-toolbar-processing .ab-icon:before {
6240
- content: '\\f464';
6241
- }
6242
- </style>
6243
- ";
6244
- echo '
6245
- <ul class="ai-debug-tools">
6246
- ';
6247
- foreach ($ai_wp_data [AI_DEBUG_MENU_ITEMS] as $menu_item) {
6248
- if (isset ($menu_item ['parent'])) {
6249
- if ($menu_item ['parent'] == 'ai-toolbar-settings') {
6250
- echo ' <li class="ai-debug-', $menu_item ['id'], '">';
6251
- echo '<a href="', $menu_item ['href'], '">', $menu_item ['title'], '</a>';
6252
- echo "</li>\n";
6253
- }
6254
- elseif ($menu_item ['parent'] == 'ai-toolbar-positions') {
6255
- echo ' <li class="ai-debug-', $menu_item ['id'], ' ai-debug-tools-positions">';
6256
- echo '<a href="', $menu_item ['href'], '">', $menu_item ['title'], '</a>';
6257
- echo "</li>\n";
6258
- }
6259
- } else if ($menu_item ['id'] == 'ai-toolbar-settings') {
6260
- echo ' <li class="ai-debug-', $menu_item ['id'], ' ai-debug-tools-title">';
6261
- // echo '<a href="', $menu_item ['href'], '">', $menu_item ['title'], '</a>';
6262
- // echo '<a href="', $menu_item ['href'], '">', str_replace (AD_INSERTER_NAME, 'Debugging', $menu_item ['title']), '</a>';
6263
- echo '<a href="', $menu_item ['href'], '">', $menu_item ['title'], ' Debugging</a>';
6264
- echo "</li>\n";
6265
- }
6266
- }
6267
-
6268
- echo '</ul>
6269
- ';
6270
- }
6271
-
6272
- function ai_special_widget ($args, $instance, $block) {
6273
- global $ai_wp_data, $ai_db_options, $block_object;
6274
-
6275
- $sticky = isset ($instance ['sticky']) ? $instance ['sticky'] : 0;
6276
-
6277
- if ($sticky) {
6278
- $ai_wp_data [AI_STICKY_WIDGETS] = true;
6279
- ai_add_attr_data ($args ['before_widget'], 'class', 'ai-sticky-widget');
6280
- echo $args ['before_widget'];
6281
- } else echo $args ['before_widget'];
6282
-
6283
- $title = !empty ($instance ['widget-title']) ? $instance ['widget-title'] : '';
6284
-
6285
- if (!empty ($title)) {
6286
- echo $args ['before_title'], apply_filters ('widget_title', $title), $args ['after_title'];
6287
- }
6288
-
6289
- switch ($block) {
6290
- case 0:
6291
- echo "<pre style='", AI_DEBUG_WIDGET_STYLE, "'>\n";
6292
- ai_write_debug_info ();
6293
- echo "</pre>";
6294
-
6295
- if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION]) {
6296
- for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
6297
- $viewport_name = get_viewport_name ($viewport);
6298
- if ($viewport_name != '') {
6299
- echo "<pre class='ai-viewport-" . $viewport ."' style='", AI_DEBUG_WIDGET_STYLE, "'>\n";
6300
- echo "CLIENT-SIDE DEVICE: ", $viewport_name;
6301
- echo "</pre>";
6302
- }
6303
- }
6304
- }
6305
- break;
6306
- case - 2:
6307
- ai_write_debugging_tools ();
6308
- break;
6309
- }
6310
-
6311
- echo $args ['after_widget'];
6312
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ Plugin Name: Ad Inserter
5
+ Version: 2.3.8
6
+ Description: Ad management plugin with advanced advertising options to automatically insert ad codes on your website
7
+ Author: Igor Funa
8
+ Author URI: http://igorfuna.com/
9
+ Plugin URI: http://adinserter.pro/documentation
10
+ */
11
+
12
+ /*
13
+
14
+ Change Log
15
+
16
+ Ad Inserter 2.3.8 - 2018-04-17
17
+ - Added support rotation option shares
18
+ - Added support for sticky ad settings and animations (Pro only)
19
+ - Few minor bug fixes, cosmetic changes and code improvements
20
+
21
+ Ad Inserter 2.3.7 - 2018-03-27
22
+ - Added support for ad labels
23
+ - Blocked search indexing while debugging
24
+ - Close button setting moved to tab Display (Pro only)
25
+ - Few minor bug fixes, cosmetic changes and code improvements
26
+
27
+ Ad Inserter 2.3.6 - 2018-03-20
28
+ - Added widget for debugging tools
29
+ - Fix for AdSense ad overlays not displayed with some themes
30
+ - Few minor bug fixes, cosmetic changes and code improvements
31
+
32
+ Ad Inserter 2.3.5 - 2018-03-13
33
+ - Added display of header and footer code in Label blocks debugging function
34
+ - Added AdSense ad overlays in Label blocks debugging function (experimental)
35
+ - Fixed bug for removed square brackets in HTML element selectors
36
+ - Fixed preview of AdSense ad units
37
+ - Few minor bug fixes
38
+
39
+ Ad Inserter 2.3.4 - 2018-03-05
40
+ - Added support for author:author-username items in taxonomy list
41
+ - Fixed errors when downgrading from Pro
42
+ - Few minor bug fixes
43
+
44
+ Ad Inserter 2.3.3 - 2018-02-08
45
+ - Added list editors
46
+ - Added Label blocks debugging function for AdSense Auto ads
47
+
48
+ Ad Inserter 2.3.2 - 2018-02-01
49
+ - Added AdSense code generator for ad sizes using CSS media queries
50
+ - Fix for slow updates caused by changed user agent (Pro only, credits Olivier Langlois, https://juicingforyourmanhood.com/affiliate_tools.html)
51
+ - Fix for client-side insertion of non-English characters before/after HTML element
52
+
53
+ Ad Inserter 2.3.1 - 2018-01-25
54
+ - Added support for server-side insertion before/after any HTML element
55
+ - Few minor bug fixes
56
+
57
+ Ad Inserter 2.3.0 - 2018-01-21
58
+ - Added support for client-side insertion before/after any HTML element
59
+ - Inplemented AdSense integration
60
+ - Added option to define close button position
61
+ - Fix for code generator import and code preview error with non ASCII characters
62
+ - Fix for post/page exceptions and page types not processed in the header
63
+ - Fix for close button in preview window
64
+ - Fix for errors when rearranging blocks
65
+ - Fix for errors when importing code
66
+ - Few minor bug fixes, cosmetic changes and code improvements
67
+
68
+ Ad Inserter 2.2.16 - 2018-01-04
69
+ - Fix for error when saving settings on multisite installation
70
+
71
+ Ad Inserter 2.2.15 - 2018-01-04
72
+ - Fix for responsive AMP ads using center alignment
73
+
74
+ Ad Inserter 2.2.14 - 2018-01-04
75
+ - Added code generator for placeholders
76
+ - Added option to disable caching (works with WP Super Cache, W3 Total Cache and WP Rocket)
77
+ - Added shortcut option to generate only block code (no wrapping div)
78
+ - Added options to configure classes for wrapping div
79
+ - Added support for external tracking via Google Analytics and Piwik (Pro only)
80
+ - Added support for MaxMind geolocation databases (Pro only)
81
+ - Added option for close button on sticky ads (Pro only)
82
+ - Fix for no paragraph counting inside nested elements
83
+ - Few minor bug fixes, cosmetic changes and code improvements
84
+
85
+ Ad Inserter 2.2.13 - 2017-12-25
86
+ - Added option to disable inline alignment styles for code blocks (using alignment classes)
87
+ - Fix for custom CSS codes with single quotation marks
88
+
89
+ Ad Inserter 2.2.12 - 2017-12-25
90
+ - Fix for code block styles when block class name was not set
91
+
92
+ Ad Inserter 2.2.11 - 2017-12-25
93
+ - Code block styles moved to classes
94
+ - Code block list moved to the sidebar
95
+ - Added preview buttons in code block list
96
+ - Fix for ad blocking detection when using https (Pro only)
97
+ - Few minor bug fixes, cosmetic changes and code improvements
98
+
99
+ Ad Inserter 2.2.10 - 2017-12-10
100
+ - Fix for rotation editor code import/export
101
+ - Fix for errors when using old |rotate| separator
102
+ - Few minor bug fixes, cosmetic changes and code improvements
103
+
104
+ Ad Inserter 2.2.9 - 2017-12-09
105
+ - Output buffering is now disabled by default (for position Above header you need to enable it)
106
+ - Fix for min. paragraph number not processed
107
+
108
+ Ad Inserter 2.2.8 - 2017-12-08
109
+ - Added position for automatic insertion Above header (after `<body>` tag)
110
+ - Added rotation code editor
111
+ - Added support to name rotation options
112
+ - Added code generator for banners
113
+ - Added code generator for AdSense
114
+ - Added support to rearrange code blocks
115
+ - Added support to copy any block settings
116
+ - Added support for clipboard to copy/paste block settings
117
+ - Added option to select ad blocking detection mode (Pro only)
118
+ - Delayed insertion on posts now available for all insertion positions
119
+ - Few minor bug fixes, cosmetic changes and code improvements
120
+
121
+ Ad Inserter 2.2.7 - 2017-11-08
122
+ - Fix for duplicate amp-custom tag on AMP pages
123
+
124
+ Ad Inserter 2.2.6 - 2017-11-07
125
+ - Fix for posts filter counter not counting
126
+ - Added list with short overview of all code blocks
127
+ - Added support for word count on blog pages
128
+ - Added support for client code preview (no need to save it for preview)
129
+ - Improved compatibility on AMP pages
130
+ - Few minor bug fixes, cosmetic changes and code improvements
131
+
132
+ Ad Inserter 2.2.5 - 2017-10-15
133
+ - Fix for issue with Ajax requests
134
+
135
+ Ad Inserter 2.2.4 - 2017-10-14
136
+ - Added support to insert raw HTTP response header lines
137
+ - Added support to check for individual exceptions for shortcodes
138
+ - Added support to trigger ad blocking detection action only on individual pages
139
+ - Added support for automatic insertion position Footer
140
+ - Added support for custom hooks
141
+ - Url parameter list now checks url parameters ($_GET) and cookies ($_COOKIE)
142
+ - Fix for |count| separator not processed
143
+
144
+ Ad Inserter 2.2.3 - 2017-09-26
145
+ - Added support to insert custom fields via shortcode [adinserter custom-field='CUSTOM_FIELD_NAME']
146
+ - Added support for user:USERNAME and user-role:USER_ROLE taxonomy list items
147
+ - Added support for post-type:POST_TYPE taxonomy list items
148
+ - Added support for JavaScript based sticky widgets
149
+ - Added support for ad blocking statistics (Pro only)
150
+ - Added support for WP AMP and WP AMP Ninja plugins
151
+ - Post/Page Word Count moved to Misc section (now works also on widgets)
152
+ - Few minor bug fixes, cosmetic changes and code improvements
153
+
154
+ Ad Inserter 2.2.2 - 2017-08-28
155
+ - Fix for mobile admin layout
156
+ - Few other minor bug fixes
157
+
158
+ Ad Inserter 2.2.1 - 2017-08-27
159
+ - Fix for header/footer scripts on AMP pages
160
+
161
+ Ad Inserter 2.2.0 - 2017-08-27
162
+ - Added support for ad blocking detection (experimental)
163
+ - Added support for [ADINSERTER AMP] shortcode to separate code for AMP pages
164
+ - Added support for [ADINSERTER ROTATE] and [ADINSERTER COUNT] shortcodes
165
+ - Added syntax highlighting for shortcodes and separators
166
+ - Added style `clear: both;` to Default, Left, Right and Center alignments
167
+ - Bug fix for errors when loading tracking charts (Pro only)
168
+ - Many minor bug fixes, cosmetic changes and code improvements
169
+
170
+ Ad Inserter 2.1.14 - 2017-08-07
171
+ - Fix for error when using older PHP versions (prior to 5.5)
172
+
173
+ Ad Inserter 2.1.13 - 2017-08-07
174
+ - Fix for Fatal error: Can't use method return value in write context
175
+
176
+ Ad Inserter 2.1.12 - 2017-08-07
177
+ - Added option to define tags inside which paragraphs are not counted
178
+ - Added max insertions check when inserting for all paragraphs
179
+ - Added support for inverted filter
180
+ - Added option to define minimum number of words in paragraphs above (experimental)
181
+ - Added support for %N filter item to filter every N-th insertion (experimental)
182
+ - Added filter support when inserting for all paragraphs (experimental)
183
+ - Increased nonce lifespan to 48 hours when using tracking (Pro only)
184
+ - Fixed wrong urls in debug menu when behind proxy
185
+
186
+ Ad Inserter 2.1.11 - 2017-07-21
187
+ - Improved support for sticky widgets
188
+ - Added support for ad counting (|count| separator)
189
+ - Added support to black/white-list arbitrary taxonomies (taxonomy, term or taxonomy:term)
190
+ - Added support for automatic insertion before, between and after comments
191
+ - Added processing of shortcodes in the header and footer code
192
+ - Debugging function Show positions shows also page type
193
+ - Fixed page type detection when Post page was set to static page and it was not homepage
194
+ - Few minor bug fixes, cosmetic changes and code improvements
195
+
196
+ Ad Inserter 2.1.10 - 2017-07-01
197
+ - Fix for shifted sidebars in some themes
198
+
199
+ Ad Inserter 2.1.9 - 2017-06-30
200
+ - Added support for sticky widgets
201
+ - Added support to insert code after images (Automatic Insertion: After Paragraph, Paragraphs with tags: img)
202
+ - Impression and click tracking (beta, Pro only)
203
+ - Few minor bug fixes, cosmetic changes and code improvements
204
+
205
+ Ad Inserter 2.1.8 - 2017-05-18
206
+ - Fixed error when using server-side device detection
207
+
208
+ Ad Inserter 2.1.7 - 2017-05-13
209
+ - Fixed error when using PHP 5.4 or earlier
210
+
211
+ Ad Inserter 2.1.6 - 2017-05-12
212
+ - Added support for insertion before/after multiple paragraphs
213
+ - Added initial support for impression and click tracking (Pro only)
214
+ - Few bug fixes and cosmetic changes
215
+
216
+ Ad Inserter 2.1.5 - 6 April 2017
217
+ - Added support to avoid insertion inside <figure> and <li> elements (image captions, lists)
218
+ - Added support for exceptions for custom post types
219
+ - Few minor bug fixes and code improvements
220
+
221
+ Ad Inserter 2.1.4 - 12 March 2017
222
+ - Paragraph counting restored to standard functions
223
+ - Added option to select paragraph counting functions with multibyte support (unicode characters)
224
+ - Fixed bug for wrong paragraph counting in posts with blockquote sections in some cases
225
+ - Fixed bug for wrong measuring of plugin processing time in some cases
226
+ - Fixed bug for "Empty delimiter" warning
227
+
228
+ Ad Inserter 2.1.3 - 11 March 2017
229
+ - Added support for counting paragraphs with multibyte (unicode) characters
230
+ - Fixed bug for class name not saved
231
+ - Few minor bug fixes and cosmetic changes
232
+
233
+ Ad Inserter 2.1.2 - 1 March 2017
234
+ - Fixed bug for disabled settings page on multisite blogs
235
+
236
+ Ad Inserter 2.1.1 - 26 February 2017
237
+ - Changes for compatibility with PHP 7.1
238
+ - Automatic rename of old pro plugin slug (Pro only)
239
+ - Added support for additional Pro features (Pro only)
240
+ - Few bug fixes and cosmetic changes
241
+
242
+ Ad Inserter 2.1.0 - 10 February 2017
243
+ - Added support to insert ads in Ajax requests (e.g. in infinite scroll)
244
+ - Added support to not include block classes when class name is empty
245
+ - Added sticky positions (Pro only)
246
+ - Bug fix for minimum user role not taken into account for exceptions list
247
+ - Bug fix for IP database update cron event (Pro only)
248
+
249
+ Ad Inserter 2.0.14 - 2 February 2017
250
+ - Fixed issue for responsive ads not displayed when using Left, Center or Right alignment
251
+
252
+ Ad Inserter 2.0.13 - 1 February 2017
253
+ - Added icons for Automatic insertion and alignment
254
+ - Automatic insertion None changed to Disabled
255
+ - Alignment None changed to Default
256
+ - Changed database option data for Automatic insertion and Alignment settings
257
+ - Improved CSS 3 code for Left, Center and Right alignment
258
+ - Click on CSS code starts editing
259
+ - Page/Post exceptions listed in debug output
260
+ - Different plugin slug for Pro version
261
+ - Few minor bug fixes and cosmetic changes
262
+
263
+ Ad Inserter 2.0.12 - 29 January 2017
264
+ - Bug fix for page/post exceptions list
265
+
266
+ Ad Inserter 2.0.11 - 29 January 2017
267
+ - Bug fix for settings page not loading
268
+
269
+ Ad Inserter 2.0.10 - 26 January 2017
270
+ - Added option to insert ads between posts on blog pages
271
+ - Added option to check and manage post/page exceptions for each block
272
+ - Added option to check and manage all post/page exceptions (Pro only)
273
+ - Added option for multisite installations to disable PHP processing on sub-sites (Pro only)
274
+ - Added license status notifications (Pro only)
275
+
276
+ Ad Inserter 2.0.9 - 8 January 2017
277
+ - Added support for uppercase {country_ISO2} and lowercase {country_iso2} tag (Pro only)
278
+ - Removed inclusion of dummy css and js file
279
+ - Bug fix: Client-side dynamic blocks were not enabled if not using W3 Total Cache
280
+
281
+ Ad Inserter 2.0.8 - 6 January 2017
282
+ - Added support for client-side rotation (works with caching)
283
+ - Added support for server-side rotation with W3 Total Cache
284
+ - Added support for client-side country detection (works with caching, Pro only)
285
+ - Added support for server-side country detection with W3 Total Cache (Pro only)
286
+ - Added debugging functions to measure plugin processing time
287
+ - Added option to black/white-list IP addresses (Pro only)
288
+ - Added option for fallback code when scheduling between dates expires (Pro only)
289
+ - On multisite installations Ad Inserter debug menu item on sites is available only if settings page is enabled
290
+ - Added option for multisite installations to use Ad Inserter settings of main site for all blogs
291
+ - Added flags to country list (Pro only)
292
+ - Bug fix: Code preview did not work if Wordpress was installed in a folder
293
+ - Few minor bug fixes and cosmetic changes
294
+
295
+ Ad Inserter 2.0.7 - 23 December 2016
296
+ - Delayed display moved to Misc group
297
+ - Added option for scheduling to insert code only between specified dates (Pro only)
298
+ - Added option for Geo targeting (Pro only)
299
+ - Few minor bug fixes and cosmetic changes
300
+
301
+ Ad Inserter 2.0.6 - 25 November 2016
302
+ - Added support to filter subpages created by the <!--nextpage--> tag
303
+ - Added option to import block name (Pro only)
304
+ - Cookie deleted only when it exists and debugging is disabled
305
+ - Few minor bug fixes
306
+
307
+ Ad Inserter 2.0.5 - 8 october 2016
308
+ - Cookie created only when debugging is enabled
309
+ - Few minor bug fixes
310
+
311
+ Ad Inserter 2.0.4 - 30 September 2016
312
+ - Bug fix: Cursor position always at the end of block name
313
+ - State of debugging functions saved to cookie
314
+ - Few minor bug fixes
315
+
316
+ Ad Inserter 2.0.3 - 26 September 2016
317
+ - Debugging functions in admin toolbar available only for administrators
318
+ - Added option to hide debugging functions in admin toolbar
319
+ - Added shortcode for debugger
320
+ - Few minor bug fixes
321
+
322
+ Ad Inserter 2.0.2 - 25 September 2016
323
+ - Changed javascript version check to get plugin version from the HTML page
324
+ - Added warning if old cached version of CSS file is loaded on the settings page
325
+ - Added warning if version query parameter for js/css files is removed due to inappropriate caching
326
+
327
+ Ad Inserter 2.0.1 - 24 September 2016
328
+ - Bug fix: Shortcodes called by name were not displayed
329
+
330
+ Ad Inserter 2.0.0 - 23 September 2016
331
+ - Redesigned user interface
332
+ - Added many debugging tools for easier troubleshooting
333
+ - New feature: Code preview tool with visual CSS editor
334
+ - New feature: Label inserted blocks
335
+ - New feature: Show available positions for automatic insertion
336
+ - New feature: Show HTML tags in posts/static pages
337
+ - New feature: Log Ad Inserter processing
338
+ - Improved loading speed of the settings page
339
+ - Improved block insertion processing speed
340
+ - Added support to avoid insertion near images, headers and other elements
341
+ - Added option to avoid insertion in feeds
342
+ - Added option to display code blocks only to administrators
343
+ - Added option for publishig date check for display positions Before/After Content
344
+ - Added option for server-side device check for header and footer code
345
+ - Added option for maximum page/post words
346
+ - Added option for maximum paragraph words
347
+ - Added option to black/white-list post IDs
348
+ - Added option to black/white-list url query parameters
349
+ - Added warning if the settings page is blocked by ad blocker
350
+ - Added warning if old cached version of javascript is loaded on the settings page
351
+ - Added support for multisite installations to disable settings, widgets and exceptions on network sites (Pro only)
352
+ - Block names can be edited by clicking on the name
353
+ - Filters now work also on posts and single pages
354
+ - CSS code for client-side detection moved to inline CSS
355
+ - Bug fix: Minimum user roles for exception editing was not calculated properly
356
+ - Bug fix: Server-side detection checkbox was not saved properly
357
+ - Many other minor bug fixes, code improvements and cosmetic changes
358
+
359
+ Ad Inserter 1.7.0 - 16 August 2016
360
+ - Bug fix: Shortcodes did not ignore post/static page exceptions
361
+ - Slightly redesigned user interface
362
+ - Excerpt/Post number(s) renamed to Filter as it now works on all display positions
363
+ - Widget setting removed from Automatic display to Manual display section
364
+ - Added support to disable widgets (standalone checkbox in Manual display)
365
+ - Added call counter/filter for widgets
366
+ - Added support to edit CSS for predefined styles
367
+ - Few other minor bug fixes, code improvements and cosmetic changes
368
+
369
+ Ad Inserter 1.6.7 - 9 August 2016
370
+ - Bug fix: Block code textarea was not escaped
371
+ - Added checks for page types for shortcodes
372
+ - Added support for Before/After Post position call counter/filter
373
+ - Few minor cosmetic changes
374
+
375
+ Ad Inserter 1.6.6 - 5 August 2016
376
+ - Bug fix: Display on Homepage and other blog pages might get disabled - important if you were using PHP function call or shortcode (import of settings from 1.6.4)
377
+ - Few minor cosmetic changes
378
+ - Requirements changed to WordPress 4.0 or newer
379
+ - Added initial support for Pro version
380
+
381
+ Ad Inserter 1.6.5 - 1 August 2016
382
+ - Fixed bug: Wrong counting of max insertions
383
+ - Change: display position Before Title was renamed to Before Post
384
+ - Added support for display position After Post
385
+ - Added support for posts with no <p> tags (paragraphs separated with \r\n\r\n characters)
386
+ - Added support for paragraph processing on homepage, category, archive and search pages
387
+ - Added support for custom viewports
388
+ - Added support for PHP function call counter
389
+ - Added support to disable code block on error 404 pages
390
+ - Added support to debug paragraph tags
391
+
392
+ Ad Inserter 1.6.4 - 15 May 2016
393
+ - Fixed bug: For shortcodes in posts the url was not checked
394
+ - Optimizations for device detection
395
+
396
+ Ad Inserter 1.6.3 - 6 April 2016
397
+ - Removed deprecated code (fixes PHP 7 deprecated warnings)
398
+ - Added support for paragraphs with div and other HTML tags (h1, h2, h3,...)
399
+
400
+ Ad Inserter 1.6.2 - 2 April 2016
401
+ - Removed deprecated code (fixes PHP Fatal error Call to a member function get_display_type)
402
+ - Added support to change plugin processing priority
403
+
404
+ Ad Inserter 1.6.1 - 28 February 2016
405
+ - Fixed bug: For shortcodes in posts the date was not checked
406
+ - Fixed error with some templates "Call to undefined method is_main_query()"
407
+ - Added support for minumum number of page/post words for Before/After content display option
408
+ - Added support for {author} and {author_name} tags
409
+
410
+ Ad Inserter 1.6.0 - 9 January 2016
411
+ - Added support for client-side device detection
412
+ - Many code improvements
413
+ - Improved plugin processing speed
414
+ - Removed support for deprecated tags for manual insertion {adinserter n}
415
+ - Few minor bug fixes
416
+
417
+ Ad Inserter 1.5.8 - 20 December 2015
418
+ - Fixed notice "Undefined index: adinserter_selected_block_" when saving page or post
419
+
420
+ Ad Inserter 1.5.7 - 20 December 2015
421
+ - Fixed notice "has_cap was called with an argument that is deprecated since version 2.0!"
422
+ - Few minor bug fixes and code improvements
423
+ - Added support to blacklist or whitelist url patterns: /url-start*. *url-pattern*, *url-end
424
+ - Added support to define minimum number of words in paragraphs
425
+ - Added support to define minimum user role for page/post Ad Inserter exceptions editing
426
+ - Added support to limit insertions of individual code blocks
427
+ - Added support to filter direct visits (no referer)
428
+
429
+ Ad Inserter 1.5.6 - 14 August 2015
430
+ - Fixed Security Vulnerability: Plugin was vulnerable to Cross-Site Scripting (XSS)
431
+ - Few bug fixes and code improvements
432
+
433
+ Ad Inserter 1.5.5 - 6 June 2015
434
+ - Few bug fixes and code improvements
435
+ - Added support to export and import all Ad Inserter settings
436
+
437
+ Ad Inserter 1.5.4 - 31 May 2015
438
+ - Many code optimizations and cosmetic changes
439
+ - Header and Footer code blocks moved to settings tab (#)
440
+ - Added support to process shortcodes of other plugins used in Ad Inserter code blocks
441
+ - Added support to white-list or black-list individual urls
442
+ - Added support to export and import settings for code blocks
443
+ - Added support to specify excerpts for block insertion
444
+ - Added support to specify text that must be present when counting paragraphs
445
+
446
+ Ad Inserter 1.5.3 - 2 May 2015
447
+ - Fixed Security Vulnerability: Plugin was vulnerable to a combination of CSRF/XSS attacks (credits to Kaustubh Padwad)
448
+ - Fixed bug: In some cases deprecated widgets warning reported errors
449
+ - Added support to white-list or black-list tags
450
+ - Added support for category slugs in category list
451
+ - Added support for relative paragraph positions
452
+ - Added support for individual code block exceptions on post/page editor page
453
+ - Added support for minimum number of words
454
+ - Added support to disable syntax highlighting editor (to allow using copy/paste on mobile devices)
455
+
456
+ Ad Inserter 1.5.2 - 15 March 2015
457
+ - Fixed bug: Widget titles might be displayed at wrong sidebar positions
458
+ - Change: Default code block CSS class name was changed from ad-inserter to code-block to prevent Ad Blockers from blocking Ad Inserter divs
459
+ - Added warning message if deprecated widgets are used
460
+ - Added support to display blocks on desktop + tablet and desktop + phone devices
461
+
462
+ Ad Inserter 1.5.1 - 3 March 2015
463
+ - Few fixes to solve plugin incompatibility issues
464
+ - Added support to disable all ads on specific page
465
+
466
+ Ad Inserter 1.5.0 - 2 March 2015
467
+ - Added support to display blocks on all, desktop or mobile devices
468
+ - Added support for new widgets API - one widget for all code blocks with multiple instances
469
+ - Added support to change wrapping code CSS class name
470
+ - Fixed bug: Display block N days after post is published was not working properly
471
+ - Fixed bug: Display block after paragraph in some cases was not working propery
472
+
473
+ Ad Inserter 1.4.1 - 29 December 2014
474
+ - Fixed bug: Code blocks configured as widgets were not displayed properly on widgets admin page
475
+
476
+ Ad Inserter 1.4.0 - 21 December 2014
477
+ - Added support to skip paragraphs with specified text
478
+ - Added position After paragraph
479
+ - Added support for header and footer scripts
480
+ - Added support for custom CSS styles
481
+ - Added support to display blocks to all, logged in or not logged in users
482
+ - Added support for syntax highlighting
483
+ - Added support for shortcodes
484
+ - Added classes to block wrapping divs
485
+ - Few bugs fixed
486
+
487
+ Ad Inserter 1.3.5 - 18 March 2014
488
+ - Fixed bug: missing echo for PHP function call example
489
+
490
+ Ad Inserter 1.3.4 - 15 March 2014
491
+ - Added option for no code wrapping with div
492
+ - Added option to insert block codes from PHP code
493
+ - Changed HTML codes to disable display on specific pages
494
+ - Selected code block position is preserved after settings are saved
495
+ - Manual insertion can be enabled or disabled regardless of primary display setting
496
+ - Fixed bug: in some cases Before Title display setting inserted code into RSS feed
497
+
498
+ Ad Inserter 1.3.3 - 8 January 2014
499
+ - Added option to insert ads also before or after the excerpt
500
+ - Fixed bug: in some cases many errors reported after activating the plugin
501
+ - Few minor bugs fixed
502
+ - Few minor cosmetic changes
503
+
504
+ Ad Inserter 1.3.2 - 4 December 2013
505
+ - Fixed blank settings page caused by incompatibility with some themes or plugins
506
+
507
+ Ad Inserter 1.3.1 - 3 December 2013
508
+ - Added option to insert ads also on pages
509
+ - Added option to process PHP code
510
+ - Few bugs fixed
511
+
512
+ Ad Inserter 1.3.0 - 27 November 2013
513
+ - Number of ad slots increased to 16
514
+ - New tabbed admin interface
515
+ - Ads can be manually inserted also with {adinserter AD_NUMBER} tag
516
+ - Fixed bug: only the last ad block set to Before Title was displayed
517
+ - Few other minor bugs fixed
518
+ - Few cosmetic changes
519
+
520
+ Ad Inserter 1.2.1 - 19 November 2013
521
+ - Fixed problem: || in ad code (e.g. asynchronous code for AdSense) causes only part of the code to be inserted (|| to rotate ads is replaced with |rotate|)
522
+
523
+ Ad Inserter 1.2.0 - 15/05/2012
524
+ - Fixed bug: manual tags in posts lists were not removed
525
+ - Added position Before title
526
+ - Added support for minimum number of paragraphs
527
+ - Added support for page display options for Widget and Before title positions
528
+ - Alignment now works for all display positions
529
+
530
+ Ad Inserter 1.1.3 - 07/04/2012
531
+ - Fixed bug for {search_query}: When the tag is empty {smart_tag} is used in all cases
532
+ - Few changes in the settings page
533
+
534
+ Ad Inserter 1.1.2 - 16/07/2011
535
+ - Fixed error with multisite/network installations
536
+
537
+ Ad Inserter 1.1.1 - 16/07/2011
538
+ - Fixed bug in Float Right setting display
539
+
540
+ Ad Inserter 1.1.0 - 05/06/2011
541
+ - Added option to manually display individual ads
542
+ - Added new ad alignments: left, center, right
543
+ - Added {search_query} tag
544
+ - Added support for category black list and white list
545
+
546
+ Ad Inserter 1.0.4 - 19/12/2010
547
+ - HTML entities for {title} and {short_title} are now decoded
548
+ - Added {tag} to display the first tag
549
+
550
+ Ad Inserter 1.0.3 - 05/12/2010
551
+ - Fixed bug for rotating ads
552
+
553
+ Ad Inserter 1.0.2 - 04/12/2010
554
+ - Added support for rotating ads
555
+
556
+ Ad Inserter 1.0.1 - 17/11/2010
557
+ - Added support for different sidebar implementations
558
+
559
+ Ad Inserter 1.0.0 - 14/11/2010
560
+ - Initial release
561
+
562
+ */
563
+
564
+
565
+ global $block_object, $ai_wp_data, $ad_inserter_globals, $ai_last_check, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_db_options, $block_insertion_log;
566
+
567
+ if (!defined ('AD_INSERTER_PLUGIN_DIR'))
568
+ define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
569
+
570
+ define ('AI_WP_DEBUGGING_', 0);
571
+ define ('AI_DEBUG_PROCESSING_', 0x01);
572
+ define ('AI_URL_DEBUG_', 'ai-debug');
573
+ define ('AI_URL_DEBUG_PROCESSING_', 'ai-debug-processing');
574
+ define ('AI_URL_DEBUG_PHP_', 'ai-debug-php');
575
+
576
+ if (isset ($_GET [AI_URL_DEBUG_PHP_]) && $_GET [AI_URL_DEBUG_PHP_] != '') {
577
+ if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) {
578
+ ini_set ('display_errors', 1);
579
+ error_reporting (E_ALL);
580
+ }
581
+ }
582
+
583
+ $ai_wp_data [AI_WP_DEBUGGING_] = 0;
584
+
585
+ if (!is_admin()) {
586
+ if (!isset ($_GET [AI_URL_DEBUG_]))
587
+ if (isset ($_GET [AI_URL_DEBUG_PROCESSING_]) || (isset ($_COOKIE ['AI_WP_DEBUGGING']) && ($_COOKIE ['AI_WP_DEBUGGING'] & AI_DEBUG_PROCESSING_) != 0)) {
588
+ if (!isset ($_GET [AI_URL_DEBUG_PROCESSING_]) || $_GET [AI_URL_DEBUG_PROCESSING_] == 1) {
589
+ $ai_wp_data [AI_WP_DEBUGGING_] |= AI_DEBUG_PROCESSING_;
590
+
591
+ $ai_total_plugin_time = 0;
592
+ $start_time = microtime (true);
593
+ $ai_total_php_time = 0;
594
+ $ai_last_time = microtime (true);
595
+ $ai_processing_log = array ();
596
+ ai_log ("INITIALIZATION START");
597
+ }
598
+ }
599
+ }
600
+
601
+ // Version check
602
+ global $wp_version, $version_string;
603
+
604
+ if (version_compare ($wp_version, "4.0", "<")) {
605
+ exit ('Ad Inserter requires WordPress 4.0 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update!</a>');
606
+ }
607
+
608
+ //include required files
609
+ require_once AD_INSERTER_PLUGIN_DIR.'class.php';
610
+ require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
611
+ require_once AD_INSERTER_PLUGIN_DIR.'settings.php';
612
+
613
+ $version_array = explode (".", AD_INSERTER_VERSION);
614
+ $version_string = "";
615
+ foreach ($version_array as $number) {
616
+ $version_string .= sprintf ("%02d", $number);
617
+ }
618
+
619
+ $ai_wp_data [AI_WP_URL] = remove_debug_parameters_from_url ();
620
+
621
+ $ad_inserter_globals = array ();
622
+ $block_object = array ();
623
+ $block_insertion_log = array ();
624
+
625
+ $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_NONE;
626
+ $ai_wp_data [AI_WP_AMP_PAGE] = false;
627
+ $ai_wp_data [AI_WP_USER_SET] = false;
628
+ $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN;
629
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
630
+
631
+ $ai_wp_data [AI_SERVER_SIDE_DETECTION] = false;
632
+ $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = false;
633
+ $ai_wp_data [AI_TRACKING] = false;
634
+ $ai_wp_data [AI_STICKY_WIDGETS] = false;
635
+ $ai_wp_data [AI_STICK_TO_THE_CONTENT] = false;
636
+ $ai_wp_data [AI_ANIMATION] = false;
637
+ $ai_wp_data [AI_CLOSE_BUTTONS] = false;
638
+ $ai_wp_data [AI_DISABLE_CACHING] = false;
639
+ $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = false;
640
+
641
+ ai_load_settings ();
642
+
643
+ $ai_wp_data [AI_BACKEND_JS_DEBUGGING] = get_backend_javascript_debugging ();
644
+ $ai_wp_data [AI_FRONTEND_JS_DEBUGGING] = get_frontend_javascript_debugging ();
645
+
646
+ if (isset ($_GET [AI_URL_DEBUG_PHP]) && $_GET [AI_URL_DEBUG_PHP] == '1') {
647
+ if (get_remote_debugging ()) {
648
+ ini_set ('display_errors', 1);
649
+ error_reporting (E_ALL);
650
+ }
651
+ }
652
+
653
+ if (isset ($_GET [AI_URL_DEBUG_JAVASCRIPT]) && $_GET [AI_URL_DEBUG_JAVASCRIPT] == '1') {
654
+ if (get_remote_debugging ()) {
655
+ $ai_wp_data [AI_FRONTEND_JS_DEBUGGING] = true;
656
+ }
657
+ }
658
+
659
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
660
+ $ai_wp_data [AI_ADB_DETECTION] = $block_object [AI_ADB_MESSAGE_OPTION_NAME]->get_enable_manual ();
661
+
662
+ if ($ai_wp_data [AI_ADB_DETECTION]) {
663
+ $adb_2_name = AI_ADB_2_DEFAULT_NAME;
664
+ define ('AI_ADB_COOKIE_VALUE', substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 (LOGGED_IN_KEY.md5 (NONCE_KEY)))), 0, 8));
665
+
666
+ $script_path = AD_INSERTER_PLUGIN_DIR.'js';
667
+ $script = $script_path.'/sponsors.js';
668
+
669
+ if (is_writable ($script_path) && is_writable ($script)) {
670
+ $adb_2_name = substr (preg_replace ("/[^A-Za-z]+/", '', strtolower (md5 (LOGGED_IN_KEY).md5 (NONCE_KEY))), 0, 8);
671
+
672
+ $js_ok = false;
673
+ if (file_exists ($script)) {
674
+ if (strpos (file_get_contents ($script), $adb_2_name) !== false) $js_ok = true;
675
+ }
676
+
677
+ if (!$js_ok) {
678
+ file_put_contents ($script, 'window.' . $adb_2_name . '=true;');
679
+ define ('AI_ADB_2_FILE_RECREATED', true);
680
+ }
681
+ }
682
+
683
+ define ('AI_ADB_2_NAME', $adb_2_name);
684
+
685
+ if (function_exists ('ai_check_files')) ai_check_files ();
686
+ }
687
+ }
688
+
689
+ if (function_exists ('ai_load_globals')) ai_load_globals ();
690
+
691
+ if (get_dynamic_blocks ()) {
692
+ if (!in_array ('w3-total-cache/w3-total-cache.php', get_option ('active_plugins'))) {
693
+ define ('AI_NO_W3TC', true);
694
+ if (!defined ('W3TC_DYNAMIC_SECURITY')) define ('W3TC_DYNAMIC_SECURITY', 'W3 Total Cache plugin not active');
695
+ }
696
+ if (!defined ('W3TC_DYNAMIC_SECURITY')) {
697
+ $string = AD_INSERTER_PLUGIN_DIR;
698
+ if (defined ('AUTH_KEY')) $string .= AUTH_KEY;
699
+ if (defined ('LOGGED_IN_KEY')) $string .= LOGGED_IN_KEY;
700
+
701
+ define ('W3TC_DYNAMIC_SECURITY', md5 ($string));
702
+ }
703
+ }
704
+
705
+
706
+ $adH = $block_object [AI_HEADER_OPTION_NAME];
707
+ $adF = $block_object [AI_FOOTER_OPTION_NAME];
708
+ if ($adH->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
709
+ if ($adF->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
710
+
711
+ if ($ai_wp_data [AI_SERVER_SIDE_DETECTION]) {
712
+ require_once AD_INSERTER_PLUGIN_DIR.'includes/Mobile_Detect.php';
713
+
714
+ $detect = new ai_Mobile_Detect;
715
+
716
+ define ('AI_MOBILE', $detect->isMobile ());
717
+ define ('AI_TABLET', $detect->isTablet ());
718
+ define ('AI_PHONE', AI_MOBILE && !AI_TABLET);
719
+ define ('AI_DESKTOP', !AI_MOBILE);
720
+ } else {
721
+ define ('AI_MOBILE', true);
722
+ define ('AI_TABLET', true);
723
+ define ('AI_PHONE', true);
724
+ define ('AI_DESKTOP', true);
725
+ }
726
+
727
+ if (isset ($_POST [AI_FORM_SAVE]))
728
+ define ('AI_SYNTAX_HIGHLIGHTING', isset ($_POST ["syntax-highlighter-theme"]) && $_POST ["syntax-highlighter-theme"] != AI_OPTION_DISABLED); else
729
+ define ('AI_SYNTAX_HIGHLIGHTING', get_syntax_highlighter_theme () != AI_OPTION_DISABLED);
730
+
731
+
732
+ add_action ('wp_loaded', 'ai_wp_loaded_hook');
733
+ add_action ('admin_menu', 'ai_admin_menu_hook');
734
+ add_action ('init', 'ai_init_hook');
735
+ add_action ('admin_notices', 'ai_admin_notice_hook');
736
+ add_action ('wp', 'ai_wp_hook');
737
+ add_action( 'wp_enqueue_scripts', 'ai_wp_enqueue_scripts_hook' );
738
+
739
+ if (function_exists ('ai_system_output_check')) $ai_system_output = ai_system_output_check (); else $ai_system_output = false;
740
+
741
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 || $ai_system_output)
742
+ add_action ('shutdown', 'ai_shutdown_hook');
743
+
744
+ add_action ('widgets_init', 'ai_widgets_init_hook');
745
+ add_action ('add_meta_boxes', 'ai_add_meta_box_hook');
746
+ add_action ('save_post', 'ai_save_meta_box_data_hook');
747
+
748
+ if (function_exists ('ai_hooks')) ai_hooks ();
749
+
750
+ add_filter ('plugin_action_links_'.plugin_basename (__FILE__), 'ai_plugin_action_links');
751
+ add_filter ('plugin_row_meta', 'ai_set_plugin_meta', 10, 2);
752
+
753
+ if (is_admin () === true) {
754
+ add_action ('wp_ajax_ai_ajax_backend', 'ai_ajax_backend');
755
+ add_action ('wp_ajax_ai_ajax', 'ai_ajax');
756
+ add_action ('wp_ajax_nopriv_ai_ajax', 'ai_ajax');
757
+ }
758
+
759
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
760
+ $ai_total_plugin_time += microtime (true) - $start_time;
761
+ ai_log ("INITIALIZATION END\n");
762
+ }
763
+
764
+
765
+
766
+
767
+ //add_filter ('the_generator', 'ai_the_generator');
768
+
769
+ //function ai_the_generator ($generator) {
770
+ // return preg_replace ('/content="(.*?)"/', 'content="$1, '.AD_INSERTER_NAME.' '. AD_INSERTER_VERSION.'"', $generator);
771
+ //}
772
+
773
+
774
+
775
+
776
+ function ai_wp_default_editor () {
777
+ return 'tinymce';
778
+ }
779
+
780
+ function ai_wp_default_editor_html () {
781
+ return 'html';
782
+ }
783
+
784
+ function ai_disable_caching () {
785
+ // WP Super Cache, W3 Total Cache, WP Rocket
786
+ if (!defined('DONOTCACHEPAGE'))
787
+ define('DONOTCACHEPAGE', true);
788
+
789
+ if (!defined('DONOTCACHEOBJECT'))
790
+ define('DONOTCACHEOBJECT', true);
791
+
792
+ if (!defined('DONOTCACHEDB'))
793
+ define('DONOTCACHEDB', true);
794
+
795
+ if (!headers_sent () && !is_user_logged_in ()) {
796
+ header('Cache-Control: private, proxy-revalidate, s-maxage=0');
797
+ }
798
+ }
799
+
800
+ function ai_toolbar_menu_items () {
801
+ global $block_object, $ai_wp_data;
802
+
803
+ if (isset ($ai_wp_data [AI_DEBUG_MENU_ITEMS])) return;
804
+
805
+ $ai_wp_data [AI_DEBUG_MENU_ITEMS] = array ();
806
+
807
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) == 0) $debug_blocks = 1; else $debug_blocks = 0;
808
+ $debug_blocks_class = $debug_blocks == 0 ? ' on' : '';
809
+
810
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) == 0) $debug_positions = 0; else $debug_positions = '';
811
+ $debug_positions_class = $debug_positions === '' ? ' on' : '';
812
+
813
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) == 0) $debug_tags = 1; else $debug_tags = 0;
814
+ $debug_tags_class = $debug_tags == 0 ? ' on' : '';
815
+
816
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) == 0) $debug_processing = 1; else $debug_processing = 0;
817
+ $debug_processing_class = $debug_processing == 0 ? ' on' : '';
818
+
819
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) $debug_no_insertion = 1; else $debug_no_insertion = 0;
820
+ $debug_no_insertion_class = $debug_no_insertion == 0 ? ' on' : '';
821
+
822
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING) == 0) $debug_ad_blocking = 1; else $debug_ad_blocking = 0;
823
+ $debug_ad_blocking_class = $debug_ad_blocking == 0 ? ' on' : '';
824
+
825
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) == 0) $debug_ad_blocking_status = 1; else $debug_ad_blocking_status = 0;
826
+ $debug_ad_blocking_status_class = $debug_ad_blocking_status == 0 ? ' on' : '';
827
+
828
+ $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;
829
+
830
+ $debug_settings_class = $debug_settings_on ? ' on' : '';
831
+ $top_menu_url = $debug_settings_on ? add_query_arg (AI_URL_DEBUG, '0', remove_debug_parameters_from_url ()) :
832
+ add_query_arg (array (AI_URL_DEBUG_BLOCKS => '1', AI_URL_DEBUG_POSITIONS => '0'), remove_debug_parameters_from_url ());
833
+
834
+ $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
835
+ 'id' => 'ai-toolbar',
836
+ 'group' => true
837
+ );
838
+
839
+ $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
840
+ 'id' => 'ai-toolbar-settings',
841
+ // 'parent' => 'ai-toolbar',
842
+ 'title' => '<span class="ab-icon'.$debug_settings_class.'"></span>'.AD_INSERTER_NAME,
843
+ 'href' => $top_menu_url,
844
+ );
845
+
846
+ $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
847
+ 'id' => 'ai-toolbar-blocks',
848
+ 'parent' => 'ai-toolbar-settings',
849
+ 'title' => '<span class="ab-icon'.$debug_blocks_class.'"></span>Label Blocks',
850
+ 'href' => set_url_parameter (AI_URL_DEBUG_BLOCKS, $debug_blocks),
851
+ );
852
+
853
+ $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
854
+ 'id' => 'ai-toolbar-positions',
855
+ 'parent' => 'ai-toolbar-settings',
856
+ 'title' => '<span class="ab-icon'.$debug_positions_class.'"></span>Show Positions',
857
+ 'href' => set_url_parameter (AI_URL_DEBUG_POSITIONS, $debug_positions),
858
+ );
859
+
860
+ $paragraph_blocks = array ();
861
+ for ($block = 0; $block <= AD_INSERTER_BLOCKS; $block ++) {
862
+ $obj = $block_object [$block];
863
+ $automatic_insertion = $obj->get_automatic_insertion();
864
+ if ($block == 0 || $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH) {
865
+
866
+ $block_tags = trim ($block_object [$block]->get_paragraph_tags ());
867
+ $direction = $block_object [$block]->get_direction_type() == AD_DIRECTION_FROM_TOP ? 't' : 'b';
868
+ $paragraph_min_words = intval ($obj->get_minimum_paragraph_words());
869
+ $paragraph_max_words = intval ($obj->get_maximum_paragraph_words());
870
+ $paragraph_text_type = $obj->get_paragraph_text_type ();
871
+ $paragraph_text = trim (html_entity_decode ($obj->get_paragraph_text()));
872
+ $inside_blockquote = $obj->get_count_inside_blockquote ();
873
+
874
+ if ($block_tags != '') {
875
+ $found = false;
876
+ foreach ($paragraph_blocks as $index => $paragraph_block) {
877
+ if ($paragraph_block ['tags'] == $block_tags &&
878
+ $paragraph_block ['direction'] == $direction &&
879
+ $paragraph_block ['min'] == $paragraph_min_words &&
880
+ $paragraph_block ['max'] == $paragraph_max_words &&
881
+ $paragraph_block ['text_type'] == $paragraph_text_type &&
882
+ $paragraph_block ['text'] == $paragraph_text &&
883
+ $paragraph_block ['blockquote'] == $inside_blockquote
884
+ ) {
885
+ $found = true;
886
+ break;
887
+ }
888
+ }
889
+ if ($found) array_push ($paragraph_blocks [$index]['blocks'], $block); else
890
+ $paragraph_blocks []= array ('blocks' => array ($block),
891
+ 'tags' => $block_tags,
892
+ 'direction' => $direction,
893
+ 'min' => $paragraph_min_words,
894
+ 'max' => $paragraph_max_words,
895
+ 'text_type' => $paragraph_text_type,
896
+ 'text' => $paragraph_text,
897
+ 'blockquote' => $inside_blockquote,
898
+ );
899
+ }
900
+ }
901
+ }
902
+
903
+ $no_paragraph_counting_inside = get_no_paragraph_counting_inside ();
904
+
905
+ foreach ($paragraph_blocks as $index => $paragraph_block) {
906
+ $block_class = $debug_positions === '' && in_array ($ai_wp_data [AI_WP_DEBUG_BLOCK], $paragraph_block ['blocks']) ? ' on' : '';
907
+ $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
908
+ 'id' => 'ai-toolbar-positions-'.$index,
909
+ 'parent' => 'ai-toolbar-positions',
910
+ 'title' => '<span class="ab-icon'.$block_class.'"></span>'.
911
+ $paragraph_block ['tags'].
912
+ ($paragraph_block ['direction'] == 'b' ? ' <span class="dashicons dashicons-arrow-up-alt up-icon"></span>' : '').
913
+ ($paragraph_block ['min'] != 0 ? ' min '.$paragraph_block ['min']. ' ' : '').
914
+ ($paragraph_block ['max'] != 0 ? ' max '.$paragraph_block ['max']. ' ' : '').
915
+ ($paragraph_block ['blockquote'] ? ' +[' . $no_paragraph_counting_inside . '] ' : '').
916
+ ($paragraph_block ['text'] != '' ? ($paragraph_block ['text_type'] == AD_DO_NOT_CONTAIN ? ' NC ' : ' C ').' ['.htmlentities ($paragraph_block ['text']).']' : ''),
917
+ 'href' => set_url_parameter (AI_URL_DEBUG_POSITIONS, $paragraph_block ['blocks'][0]),
918
+ );
919
+ }
920
+
921
+ $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
922
+ 'id' => 'ai-toolbar-tags',
923
+ 'parent' => 'ai-toolbar-settings',
924
+ 'title' => '<span class="ab-icon'.$debug_tags_class.'"></span>Show HTML Tags',
925
+ 'href' => set_url_parameter (AI_URL_DEBUG_TAGS, $debug_tags),
926
+ );
927
+
928
+ $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
929
+ 'id' => 'ai-toolbar-no-insertion',
930
+ 'parent' => 'ai-toolbar-settings',
931
+ 'title' => '<span class="ab-icon'.$debug_no_insertion_class.'"></span>Disable Insertion',
932
+ 'href' => set_url_parameter (AI_URL_DEBUG_NO_INSERTION, $debug_no_insertion),
933
+ );
934
+
935
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
936
+ if ($ai_wp_data [AI_ADB_DETECTION]) {
937
+ $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
938
+ 'id' => 'ai-toolbar-adb-status',
939
+ 'parent' => 'ai-toolbar-settings',
940
+ 'title' => '<span class="ab-icon'.$debug_ad_blocking_status_class.'"></span>Ad Blocking Status',
941
+ 'href' => set_url_parameter (AI_URL_DEBUG_AD_BLOCKING_STATUS, $debug_ad_blocking_status),
942
+ );
943
+
944
+ $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
945
+ 'id' => 'ai-toolbar-adb',
946
+ 'parent' => 'ai-toolbar-settings',
947
+ 'title' => '<span class="ab-icon'.$debug_ad_blocking_class.'"></span>Simulate Ad Blocking',
948
+ 'href' => set_url_parameter (AI_URL_DEBUG_AD_BLOCKING, $debug_ad_blocking),
949
+ );
950
+ }
951
+ }
952
+
953
+ $ai_wp_data [AI_DEBUG_MENU_ITEMS][] = array (
954
+ 'id' => 'ai-toolbar-processing',
955
+ 'parent' => 'ai-toolbar-settings',
956
+ 'title' => '<span class="ab-icon'.$debug_processing_class.'"></span>Log Processing',
957
+ 'href' => set_url_parameter (AI_URL_DEBUG_PROCESSING, $debug_processing),
958
+ );
959
+ }
960
+
961
+ function ai_toolbar ($wp_admin_bar) {
962
+ global $ai_wp_data;
963
+
964
+ ai_toolbar_menu_items ();
965
+
966
+ foreach ($ai_wp_data [AI_DEBUG_MENU_ITEMS] as $menu_item) {
967
+ $wp_admin_bar->add_node ($menu_item);
968
+ }
969
+ }
970
+
971
+ function set_user () {
972
+ global $ai_wp_data;
973
+
974
+ if ($ai_wp_data [AI_WP_USER_SET]) return;
975
+
976
+ // $ai_wp_data [AI_WP_USER] = AI_USER_NOT_LOGGED_IN;
977
+
978
+ if (is_user_logged_in ()) $ai_wp_data [AI_WP_USER] |= AI_USER_LOGGED_IN;
979
+ if (current_user_role () >= 5) $ai_wp_data [AI_WP_USER] |= AI_USER_ADMINISTRATOR;
980
+
981
+ // if (isset ($_GET [AI_URL_DEBUG_USER]) && $_GET [AI_URL_DEBUG_USER] != 0) $ai_wp_data [AI_WP_USER] = $_GET [AI_URL_DEBUG_USER];
982
+
983
+ $ai_wp_data [AI_WP_USER_SET] = true;
984
+ }
985
+
986
+ function set_page_type () {
987
+ global $ai_wp_data;
988
+
989
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_NONE) return;
990
+
991
+ if (is_front_page ()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_HOMEPAGE;
992
+ elseif (is_single()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_POST;
993
+ elseif (is_page()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_STATIC;
994
+ elseif (is_feed()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_FEED;
995
+ elseif (is_category()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_CATEGORY;
996
+ elseif (is_archive() || (is_home () && !is_front_page ())) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ARCHIVE;
997
+ elseif (is_search()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_SEARCH;
998
+ elseif (is_404()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_404;
999
+ elseif (is_admin()) $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_ADMIN;
1000
+
1001
+ if (
1002
+ // AMP, Accelerated Mobile Pages
1003
+ function_exists ('is_amp_endpoint') && is_amp_endpoint () ||
1004
+
1005
+ // WP AMP Ninja
1006
+ isset ($_GET ['wpamp']) ||
1007
+
1008
+ // WP AMP - Accelerated Mobile Pages for WordPress
1009
+ function_exists ('is_wp_amp') && is_wp_amp ()
1010
+ ) {
1011
+ $ai_wp_data [AI_WP_AMP_PAGE] = true;
1012
+ define ('AI_AMP_PAGE', true);
1013
+ }
1014
+ }
1015
+
1016
+ function ai_log_message ($message) {
1017
+ global $ai_last_time, $ai_processing_log;
1018
+ $ai_processing_log []= rtrim (sprintf ("%4d %-50s", (microtime (true) - $ai_last_time) * 1000, $message));
1019
+ }
1020
+
1021
+ function ai_log_filter_content ($content_string) {
1022
+
1023
+ $content_string = preg_replace ("/\[\[AI_[A|B]P([\d].?)\]\]/", "", $content_string);
1024
+ return str_replace (array ("<!--", "-->", "\n", "\r"), array ("[!--", "--]", "*n", "*r"), $content_string);
1025
+ }
1026
+
1027
+ function ai_log_content (&$content) {
1028
+ if (strlen ($content) < 100) ai_log (ai_log_filter_content ($content) . ' ['.number_of_words ($content).']'); else
1029
+ 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).']');
1030
+ }
1031
+
1032
+ function ai_block_insertion_status ($block, $ai_last_check) {
1033
+ global $block_object;
1034
+
1035
+ if ($block < 1 || $block > AD_INSERTER_BLOCKS) $block = 0;
1036
+
1037
+ if ($ai_last_check == AI_CHECK_INSERTED) return "INSERTED";
1038
+ $status = "FAILED CHECK: ";
1039
+ $obj = $block_object [$block];
1040
+ switch ($ai_last_check) {
1041
+ case AI_CHECK_PAGE_TYPE_FRONT_PAGE: $status .= "ENABLED ON HOMEPAGE"; break;
1042
+ case AI_CHECK_PAGE_TYPE_STATIC_PAGE: $status .= "ENABLED ON STATIC PAGE"; break;
1043
+ case AI_CHECK_PAGE_TYPE_POST: $status .= "ENABLED ON POST"; break;
1044
+ case AI_CHECK_PAGE_TYPE_CATEGORY: $status .= "ENABLED ON CATEGORY"; break;
1045
+ case AI_CHECK_PAGE_TYPE_SEARCH: $status .= "ENABLED ON SEARCH"; break;
1046
+ case AI_CHECK_PAGE_TYPE_ARCHIVE: $status .= "ENABLED ON ARCHIVE"; break;
1047
+ case AI_CHECK_PAGE_TYPE_FEED: $status .= "ENABLED ON FEED"; break;
1048
+ case AI_CHECK_PAGE_TYPE_404: $status .= "ENABLED ON 404"; break;
1049
+
1050
+ case AI_CHECK_DESKTOP_DEVICES: $status .= "DESKTOP DEVICES"; break;
1051
+ case AI_CHECK_MOBILE_DEVICES: $status .= "MOBILE DEVICES"; break;
1052
+ case AI_CHECK_TABLET_DEVICES: $status .= "TABLET DEVICES"; break;
1053
+ case AI_CHECK_PHONE_DEVICES: $status .= "PHONE DEVICES"; break;
1054
+ case AI_CHECK_DESKTOP_TABLET_DEVICES: $status .= "DESKTOP TABLET DEVICES"; break;
1055
+ case AI_CHECK_DESKTOP_PHONE_DEVICES: $status .= "DESKTOP PHONE DEVICES"; break;
1056
+
1057
+ case AI_CHECK_CATEGORY: $status .= "CATEGORY"; break;
1058
+ case AI_CHECK_TAG: $status .= "TAG"; break;
1059
+ case AI_CHECK_TAXONOMY: $status .= "TAXONOMY"; break;
1060
+ case AI_CHECK_ID: $status .= "ID"; break;
1061
+ case AI_CHECK_URL: $status .= "URL"; break;
1062
+ case AI_CHECK_URL_PARAMETER: $status .= "URL PARAMETER"; break;
1063
+ case AI_CHECK_REFERER: $status .= "REFERER ". $obj->get_ad_domain_list(); break;
1064
+ case AI_CHECK_IP_ADDRESS: $status .= "IP ADDRESS ". $obj->get_ad_ip_address_list(); break;
1065
+ case AI_CHECK_COUNTRY: $status .= "COUNTRY ". $obj->get_ad_country_list (true); break;
1066
+ case AI_CHECK_SCHEDULING: $status .= "SCHEDULING"; break;
1067
+ case AI_CHECK_CODE: $status .= "CODE NOT EMPTY"; break;
1068
+ case AI_CHECK_LOGGED_IN_USER: $status .= "LOGGED-IN USER"; break;
1069
+ case AI_CHECK_NOT_LOGGED_IN_USER: $status .= "NOT LOGGED-IN USER"; break;
1070
+ case AI_CHECK_ADMINISTRATOR: $status .= "ADMINISTRATOR"; break;
1071
+
1072
+ case AI_CHECK_INDIVIDUALLY_DISABLED: $status .= "INDIVIDUALLY DISABLED"; break;
1073
+ case AI_CHECK_INDIVIDUALLY_ENABLED: $status .= "INDIVIDUALLY ENABLED"; break;
1074
+ case AI_CHECK_DISABLED_MANUALLY: $status .= "DISABLED BY HTML COMMENT"; break;
1075
+
1076
+ case AI_CHECK_MAX_INSERTIONS: $status .= "MAX INSERTIONS " . $obj->get_maximum_insertions (); break;
1077
+ case AI_CHECK_FILTER: $status .= ($obj->get_inverted_filter() ? 'INVERTED ' : '') . "FILTER " . $obj->get_call_filter(); break;
1078
+ case AI_CHECK_PARAGRAPH_COUNTING: $status .= "PARAGRAPH COUNTING"; break;
1079
+ case AI_CHECK_MIN_NUMBER_OF_WORDS: $status .= "MIN NUMBER OF WORDS " . intval ($obj->get_minimum_words()); break;
1080
+ 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;
1081
+ case AI_CHECK_DEBUG_NO_INSERTION: $status .= "DEBUG NO INSERTION"; break;
1082
+ case AI_CHECK_PARAGRAPH_TAGS: $status .= "PARAGRAPH TAGS"; break;
1083
+ case AI_CHECK_PARAGRAPHS_WITH_TAGS: $status .= "PARAGRAPHS WITH TAGS"; break;
1084
+ case AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE: $status .= "PARAGRAPHS AFTER NO COUNTING INSIDE"; break;
1085
+ case AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS: $status .= "PARAGRAPHS AFTER MIN MAX WORDS"; break;
1086
+ case AI_CHECK_PARAGRAPHS_AFTER_TEXT: $status .= "PARAGRAPHS AFTER TEXT"; break;
1087
+ case AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE: $status .= "PARAGRAPHS AFTER CLEARANCE"; break;
1088
+ case AI_CHECK_PARAGRAPHS_MIN_NUMBER: $status .= "PARAGRAPHS MIN NUMBER"; break;
1089
+ case AI_CHECK_PARAGRAPH_NUMBER: $status .= "PARAGRAPH NUMBER " . $obj->get_paragraph_number(); break;
1090
+
1091
+ case AI_CHECK_DO_NOT_INSERT: $status .= "PARAGRAPH CLEARANCE"; break;
1092
+ case AI_CHECK_AD_ABOVE: $status .= "PARAGRAPH CLEARANCE ABOVE"; break;
1093
+ case AI_CHECK_AD_BELOW: $status .= "PARAGRAPH CLEARANCE BELOW"; break;
1094
+ case AI_CHECK_SHORTCODE_ATTRIBUTES: $status .= "SHORTCODE ATTRIBUTES"; break;
1095
+
1096
+ case AI_CHECK_ENABLED_PHP: $status .= "ENABLED PHP FUNCTION"; break;
1097
+ case AI_CHECK_ENABLED_SHORTCODE: $status .= "ENABLED SHORTCODE"; break;
1098
+ case AI_CHECK_ENABLED_WIDGET: $status .= "ENABLED WIDGET"; break;
1099
+
1100
+ case AI_CHECK_NONE: $status = "BLOCK $block"; break;
1101
+ default: $status .= "?"; break;
1102
+ }
1103
+ $ai_last_check = AI_CHECK_NONE;
1104
+ return $status;
1105
+ }
1106
+
1107
+ function ai_log_block_status ($block, $ai_last_check) {
1108
+ global $block_insertion_log, $ad_inserter_globals;
1109
+
1110
+ if ($block < 1) return 'NO BLOCK SHORTCODE';
1111
+
1112
+ $global_name = AI_BLOCK_COUNTER_NAME . $block;
1113
+
1114
+ $block_status = ai_block_insertion_status ($block, $ai_last_check);
1115
+ $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] . ']' : '');
1116
+
1117
+ return "BLOCK $block " . $block_status;
1118
+ }
1119
+
1120
+ function ai_log ($message = "") {
1121
+ global $ai_last_time, $ai_processing_log;
1122
+
1123
+ if ($message != "") {
1124
+ if ($message [strlen ($message) - 1] == "\n") {
1125
+ ai_log_message (str_replace ("\n", "", $message));
1126
+ $ai_processing_log []= "";
1127
+ } else ai_log_message ($message);
1128
+ } else $ai_processing_log []= "";
1129
+ $ai_last_time = microtime (true);
1130
+ }
1131
+
1132
+ function remove_debug_parameters_from_url ($url = false) {
1133
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1134
+ $parameters = array (AI_URL_DEBUG, AI_URL_DEBUG_PROCESSING, AI_URL_DEBUG_BLOCKS, AI_URL_DEBUG_USER, AI_URL_DEBUG_TAGS, AI_URL_DEBUG_POSITIONS, AI_URL_DEBUG_NO_INSERTION, AI_URL_DEBUG_AD_BLOCKING, AI_URL_DEBUG_AD_BLOCKING_STATUS);
1135
+ } else
1136
+ $parameters = array (AI_URL_DEBUG, AI_URL_DEBUG_PROCESSING, AI_URL_DEBUG_BLOCKS, AI_URL_DEBUG_USER, AI_URL_DEBUG_TAGS, AI_URL_DEBUG_POSITIONS, AI_URL_DEBUG_NO_INSERTION);
1137
+
1138
+ return remove_query_arg ($parameters, $url);
1139
+ }
1140
+
1141
+ function set_url_parameter ($parameter, $value) {
1142
+ return add_query_arg ($parameter, $value, remove_debug_parameters_from_url ());
1143
+ }
1144
+
1145
+ function number_of_words (&$content) {
1146
+ $text = str_replace ("\r", "", $content);
1147
+ $text = str_replace (array ("\n", " "), " ", $text);
1148
+ $text = str_replace (" ", " ", $text);
1149
+ $text = strip_tags ($text);
1150
+ if ($text == '') return 0;
1151
+ return count (explode (" ", $text));
1152
+ }
1153
+
1154
+ function ai_loop_check ($query, $action) {
1155
+ global $ai_wp_data;
1156
+
1157
+ $ai_wp_data [AI_CONTEXT] = $action == 'loop_start' ? AI_CONTEXT_BEFORE_POST : AI_CONTEXT_AFTER_POST;
1158
+
1159
+ if ($ai_wp_data [AI_WP_AMP_PAGE]) return true;
1160
+
1161
+ if (isset ($query) && method_exists ($query, 'is_main_query')) {
1162
+ if ($query->is_main_query()) return true;
1163
+ }
1164
+
1165
+ return false;
1166
+ }
1167
+
1168
+
1169
+ function ai_buffering_start () {
1170
+ global $ai_wp_data;
1171
+
1172
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1173
+ ai_log ("BUFFERING START: level " . ob_get_level () );
1174
+ }
1175
+
1176
+ ob_start ();
1177
+ define ('AI_BUFFERING_START', true);
1178
+ }
1179
+
1180
+ function ai_buffering_end () {
1181
+ global $ai_wp_data, $ai_total_plugin_time, $ai_db_options_extract, $block_object;
1182
+
1183
+ if (!defined ('AI_BUFFERING_START')) return;
1184
+
1185
+ $page = ob_get_clean();
1186
+
1187
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1188
+ ai_log ("BUFFERING END: level " . ob_get_level ());
1189
+ $start_time = microtime (true);
1190
+ }
1191
+
1192
+ // TEST
1193
+ // $page = ai_content_hook ($page);
1194
+
1195
+ $matches = preg_split ('/(<body.*?'.'>)/i', $page, - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
1196
+
1197
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1198
+ ai_log ("BUFFER body matches: " . count ($matches));
1199
+ }
1200
+
1201
+ if (count ($matches) == 3) {
1202
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1203
+ ai_log ("BUFFER PROCESSING");
1204
+ }
1205
+
1206
+ $body = $matches [2];
1207
+
1208
+ if (isset ($ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && class_exists ('DOMDocument')) {
1209
+ require_once ('includes/phpQuery.php');
1210
+
1211
+ $no_closing_tag = array ('img', 'hr', 'br');
1212
+ $multibyte = get_paragraph_counting_functions() == AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS;
1213
+
1214
+ foreach ($ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
1215
+
1216
+ $obj = $block_object [$block];
1217
+ $obj->clear_code_cache ();
1218
+
1219
+ $insert_after = $obj->get_automatic_insertion () == AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT;
1220
+ $selector = $obj->get_html_selector ();
1221
+
1222
+ libxml_use_internal_errors(true);
1223
+ $content = phpQuery::newDocumentHTML ($body);
1224
+ libxml_use_internal_errors(false);
1225
+ foreach (pq ($selector) as $element){
1226
+ if ($insert_after)
1227
+ pq ($element)->after (AI_MARKER_START.$element->tagName.AI_MARKER_END); else
1228
+ pq ($element)->before (AI_MARKER_START.$element->tagName.AI_MARKER_END);
1229
+ }
1230
+
1231
+ $markers = preg_split ('/('.AI_MARKER_START.'.*?'.AI_MARKER_END.')/', $content->htmlOuter (), - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
1232
+
1233
+ $content_before = '';
1234
+ $insertions = array ();
1235
+ foreach ($markers as $marker) {
1236
+ if (strpos ($marker, AI_MARKER_START) === 0) {
1237
+ $tag = str_replace (array (AI_MARKER_START, AI_MARKER_END), '', $marker);
1238
+
1239
+ if ($insert_after && in_array ($tag, $no_closing_tag)) $tag_string = '>'; else
1240
+ $tag_string = $insert_after ? "</{$tag}>" : "<{$tag}";
1241
+
1242
+ preg_match_all ("#{$tag_string}#i", $content_before, $tag_matches);
1243
+ $insertions []= array ($tag_string, $insert_after ? count ($tag_matches [0]) : count ($tag_matches [0]) + 1);
1244
+ continue;
1245
+ }
1246
+ $content_before .= $marker;
1247
+ }
1248
+
1249
+ $insertion_offsets = array ();
1250
+ foreach ($insertions as $insertion) {
1251
+ $tag = $insertion [0];
1252
+ $tag_counter = $insertion [1];
1253
+ preg_match_all ("#$tag#i", $body, $org_tag_matches, PREG_OFFSET_CAPTURE);
1254
+ if (isset ($org_tag_matches [0][$tag_counter - 1])) {
1255
+ if ($insert_after)
1256
+ $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1] + strlen ($tag); else
1257
+ $insertion_offsets []= $org_tag_matches [0][$tag_counter - 1][1];
1258
+ }
1259
+ }
1260
+
1261
+ sort ($insertion_offsets);
1262
+
1263
+ $new_content = '';
1264
+ $current_offset = 0;
1265
+ foreach ($insertion_offsets as $insertion_offset) {
1266
+ if ($multibyte)
1267
+ $new_content .= mb_substr ($body, $current_offset, $insertion_offset - $current_offset);
1268
+ $new_content .= substr ($body, $current_offset, $insertion_offset - $current_offset);
1269
+
1270
+ $current_offset = $insertion_offset;
1271
+
1272
+ ob_start ();
1273
+
1274
+ $action = ($insert_after ? 'after' : 'before') . '_html_element';
1275
+ $action_name = ($insert_after ? 'After ' : 'Before ') . $selector;
1276
+
1277
+ $ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] = array ($block);
1278
+ ai_custom_hook ($action, $action_name);
1279
+ unset ($ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]);
1280
+
1281
+ $new_content .= ob_get_clean();
1282
+ }
1283
+ $new_content .= substr ($body, $current_offset);
1284
+
1285
+ $body = $new_content;
1286
+ }
1287
+ }
1288
+
1289
+ echo $matches [0], $matches [1];
1290
+
1291
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
1292
+ $class = AI_DEBUG_STATUS_CLASS;
1293
+ echo "<section class='$class'>OUTPUT BUFFERING</section>";
1294
+ }
1295
+
1296
+ ai_custom_hook ('above_header', 'Above Header');
1297
+ echo $body;
1298
+ } else echo $page;
1299
+
1300
+ // echo ai_content_hook ($matches [2]);
1301
+
1302
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1303
+ $ai_total_plugin_time += microtime (true) - $start_time;
1304
+ ai_log ("BUFFERING END PROCESSING\n");
1305
+ }
1306
+ }
1307
+
1308
+ function ai_post_check ($post, $action) {
1309
+ global $ai_wp_data, $ad_inserter_globals;
1310
+
1311
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST) return false;
1312
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) return false;
1313
+
1314
+ // Not used on AMP pages (yet)
1315
+ if (!$ai_wp_data [AI_WP_AMP_PAGE]) {
1316
+ if (!in_the_loop()) return false;
1317
+ }
1318
+
1319
+ // Skip insertion before the first post
1320
+ if (!defined ('AI_POST_CHECK')) {
1321
+ define ('AI_POST_CHECK', true);
1322
+ return false;
1323
+ }
1324
+
1325
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BETWEEN_POSTS;
1326
+
1327
+ return true;
1328
+ }
1329
+
1330
+
1331
+ function ai_content_marker () {
1332
+ echo '<span class="ai-content"></span>', "\n";
1333
+ }
1334
+
1335
+ function ai_hook_function_loop_start ($hook_parameter) {
1336
+ ai_custom_hook ('loop_start', AI_TEXT_BEFORE_POST, $hook_parameter, 'ai_loop_check');
1337
+ }
1338
+
1339
+ function ai_hook_function_loop_end ($hook_parameter) {
1340
+ ai_custom_hook ('loop_end', AI_TEXT_AFTER_POST, $hook_parameter, 'ai_loop_check');
1341
+ }
1342
+
1343
+ function ai_hook_function_post ($hook_parameter) {
1344
+ ai_custom_hook ('the_post', AI_TEXT_BETWEEN_POSTS, $hook_parameter, 'ai_post_check');
1345
+ }
1346
+
1347
+ function ai_hook_function_footer () {
1348
+ ai_custom_hook ('wp_footer', AI_TEXT_FOOTER);
1349
+ }
1350
+
1351
+
1352
+ // Code for PHP VERSION >= 5.3.0
1353
+ //function ai_get_custom_hook_function ($action, $name) {
1354
+ // return function () use ($action, $name) {
1355
+ // ai_custom_hook ($action, $name);
1356
+ // };
1357
+ //}
1358
+
1359
+
1360
+ // Code for PHP VERSION < 5.3.0
1361
+ function ai_custom_hook_function_0 () {
1362
+ global $ai_custom_hooks;
1363
+ ai_custom_hook ($ai_custom_hooks [0]['action'], $ai_custom_hooks [0]['name']);
1364
+ }
1365
+
1366
+ function ai_custom_hook_function_1 () {
1367
+ global $ai_custom_hooks;
1368
+ ai_custom_hook ($ai_custom_hooks [1]['action'], $ai_custom_hooks [1]['name']);
1369
+ }
1370
+
1371
+ function ai_custom_hook_function_2 () {
1372
+ global $ai_custom_hooks;
1373
+ ai_custom_hook ($ai_custom_hooks [2]['action'], $ai_custom_hooks [2]['name']);
1374
+ }
1375
+
1376
+ function ai_custom_hook_function_3 () {
1377
+ global $ai_custom_hooks;
1378
+ ai_custom_hook ($ai_custom_hooks [3]['action'], $ai_custom_hooks [3]['name']);
1379
+ }
1380
+
1381
+ function ai_custom_hook_function_4 () {
1382
+ global $ai_custom_hooks;
1383
+ ai_custom_hook ($ai_custom_hooks [4]['action'], $ai_custom_hooks [4]['name']);
1384
+ }
1385
+
1386
+ function ai_custom_hook_function_5 () {
1387
+ global $ai_custom_hooks;
1388
+ ai_custom_hook ($ai_custom_hooks [5]['action'], $ai_custom_hooks [5]['name']);
1389
+ }
1390
+
1391
+ function ai_custom_hook_function_6 () {
1392
+ global $ai_custom_hooks;
1393
+ ai_custom_hook ($ai_custom_hooks [6]['action'], $ai_custom_hooks [6]['name']);
1394
+ }
1395
+
1396
+ function ai_custom_hook_function_7 () {
1397
+ global $ai_custom_hooks;
1398
+ ai_custom_hook ($ai_custom_hooks [7]['action'], $ai_custom_hooks [7]['name']);
1399
+ }
1400
+
1401
+ function ai_custom_hook_function_8 () {
1402
+ global $ai_custom_hooks;
1403
+ ai_custom_hook ($ai_custom_hooks [8]['action'], $ai_custom_hooks [8]['name']);
1404
+ }
1405
+
1406
+ function ai_custom_hook_function_9 () {
1407
+ global $ai_custom_hooks;
1408
+ ai_custom_hook ($ai_custom_hooks [9]['action'], $ai_custom_hooks [9]['name']);
1409
+ }
1410
+
1411
+ function ai_wp_hook () {
1412
+ global $ai_wp_data, $ai_db_options_extract, $ai_total_plugin_time, $ai_walker, $ai_custom_hooks;
1413
+
1414
+ if (defined ('AI_WP_HOOK')) return;
1415
+ define ('AI_WP_HOOK', true);
1416
+
1417
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1418
+ ai_log ("WP HOOK START");
1419
+ $start_time = microtime (true);
1420
+ }
1421
+
1422
+ set_page_type ();
1423
+ set_user ();
1424
+
1425
+ ai_http_header ();
1426
+
1427
+ if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) ai_disable_caching ();
1428
+
1429
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_ADMIN &&
1430
+ ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 &&
1431
+ get_admin_toolbar_debugging () &&
1432
+ (!is_multisite() || is_main_site () || multisite_settings_page_enabled ()))
1433
+ add_action ('admin_bar_menu', 'ai_toolbar', 9920);
1434
+
1435
+ $url_debugging = get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0;
1436
+
1437
+ if (!is_admin() || defined ('DOING_AJAX')) {
1438
+ if (isset ($_GET [AI_URL_DEBUG]) && $_GET [AI_URL_DEBUG] == 0) {
1439
+ if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) {
1440
+ unset ($_COOKIE ['AI_WP_DEBUGGING']);
1441
+ setcookie ('AI_WP_DEBUGGING', '', time() - (15 * 60), COOKIEPATH);
1442
+ }
1443
+ if (isset ($_COOKIE ['AI_WP_DEBUG_BLOCK'])) {
1444
+ unset ($_COOKIE ['AI_WP_DEBUG_BLOCK']);
1445
+ setcookie ('AI_WP_DEBUG_BLOCK', '', time() - (15 * 60), COOKIEPATH);
1446
+ }
1447
+ } else {
1448
+ $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];
1449
+ $ai_wp_data [AI_WP_DEBUG_BLOCK] = isset ($_COOKIE ['AI_WP_DEBUG_BLOCK']) ? $_COOKIE ['AI_WP_DEBUG_BLOCK'] : 0;
1450
+
1451
+ if (isset ($_GET [AI_URL_DEBUG_BLOCKS]))
1452
+ 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;
1453
+
1454
+ if (isset ($_GET [AI_URL_DEBUG_TAGS]))
1455
+ 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;
1456
+
1457
+ if (isset ($_GET [AI_URL_DEBUG_NO_INSERTION]))
1458
+ 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;
1459
+
1460
+ if (isset ($_GET [AI_URL_DEBUG_AD_BLOCKING_STATUS]))
1461
+ 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;
1462
+
1463
+ if (isset ($_GET [AI_URL_DEBUG_AD_BLOCKING]))
1464
+ 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;
1465
+
1466
+ if (isset ($_GET [AI_URL_DEBUG_POSITIONS])) {
1467
+ if ($_GET [AI_URL_DEBUG_POSITIONS] !== '' && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_POSITIONS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_POSITIONS;
1468
+ if (is_numeric ($_GET [AI_URL_DEBUG_POSITIONS])) $ai_wp_data [AI_WP_DEBUG_BLOCK] = intval ($_GET [AI_URL_DEBUG_POSITIONS]);
1469
+ if ($ai_wp_data [AI_WP_DEBUG_BLOCK] < 0 || $ai_wp_data [AI_WP_DEBUG_BLOCK] > AD_INSERTER_BLOCKS) $ai_wp_data [AI_WP_DEBUG_BLOCK] = 0;
1470
+ }
1471
+
1472
+ if ($ai_wp_data [AI_WP_DEBUGGING] != 0)
1473
+ setcookie ('AI_WP_DEBUGGING', $ai_wp_data [AI_WP_DEBUGGING], time() + AI_COOKIE_TIME, COOKIEPATH); else
1474
+ if (isset ($_COOKIE ['AI_WP_DEBUGGING'])) setcookie ('AI_WP_DEBUGGING', '', time() - (15 * 60), COOKIEPATH);
1475
+
1476
+ if ($ai_wp_data [AI_WP_DEBUG_BLOCK] != 0)
1477
+ setcookie ('AI_WP_DEBUG_BLOCK', $ai_wp_data [AI_WP_DEBUG_BLOCK], time() + AI_COOKIE_TIME, COOKIEPATH); else
1478
+ if (isset ($_COOKIE ['AI_WP_DEBUG_BLOCK'])) setcookie ('AI_WP_DEBUG_BLOCK', '', time() - (15 * 60), COOKIEPATH);
1479
+ }
1480
+ }
1481
+
1482
+ $debug_positions = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0;
1483
+ $debug_tags_positions = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS)) != 0;
1484
+ $debug_tags_positions_blocks = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS | AI_DEBUG_BLOCKS)) != 0;
1485
+
1486
+ $plugin_priority = get_plugin_priority ();
1487
+
1488
+ 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)
1489
+ add_filter ('the_content', 'ai_content_hook', $plugin_priority);
1490
+
1491
+ 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)
1492
+ add_filter ('the_excerpt', 'ai_excerpt_hook', $plugin_priority);
1493
+
1494
+ 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)
1495
+ // add_action ('loop_start', 'ai_loop_start_hook');
1496
+ add_action ('loop_start', 'ai_hook_function_loop_start');
1497
+
1498
+ 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)
1499
+ // add_action ('loop_end', 'ai_loop_end_hook');
1500
+ add_action ('loop_end', 'ai_hook_function_loop_end');
1501
+
1502
+ 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)
1503
+ // add_action ('the_post', 'ai_post_hook');
1504
+ add_action ('the_post', 'ai_hook_function_post');
1505
+
1506
+ 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) ||
1507
+ (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) ||
1508
+ (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) ||
1509
+ $debug_positions) {
1510
+ $ai_wp_data [AI_NUMBER_OF_COMMENTS] = 0;
1511
+ add_filter ('comments_array' , 'ai_comments_array', 10, 2);
1512
+ add_filter ('wp_list_comments_args' , 'ai_wp_list_comments_args');
1513
+ $ai_walker = new ai_Walker_Comment;
1514
+ }
1515
+
1516
+
1517
+ // Code for PHP VERSION >= 5.3.0
1518
+ // foreach ($ai_custom_hooks as $index => $custom_hook) {
1519
+ // 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)
1520
+ // add_action ($custom_hook ['action'], ai_get_custom_hook_function ($custom_hook ['action'], $custom_hook ['name']), $custom_hook ['priority']);
1521
+ // }
1522
+
1523
+ // Code for PHP VERSION < 5.3.0
1524
+ foreach ($ai_custom_hooks as $index => $custom_hook) {
1525
+ if ($index > 9) break;
1526
+
1527
+ // Skip custom hooks on standard WP hooks - they will be processed anyway
1528
+ switch ($custom_hook ['action']) {
1529
+ case 'wp_footer':
1530
+ // case 'wp_head': // no block processing on wp_head
1531
+ case 'the_content':
1532
+ case 'the_excerpt':
1533
+ case 'loop_start':
1534
+ case 'loop_end':
1535
+ case 'the_post':
1536
+ continue 2;
1537
+ }
1538
+
1539
+ 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)
1540
+ add_action ($custom_hook ['action'], 'ai_custom_hook_function_' . $index, $custom_hook ['priority']);
1541
+ }
1542
+
1543
+ if ($ai_wp_data [AI_STICK_TO_THE_CONTENT]) {
1544
+ add_action ('loop_start', 'ai_content_marker');
1545
+ add_action ('loop_end', 'ai_content_marker');
1546
+ add_action ('get_sidebar', 'ai_content_marker');
1547
+ }
1548
+
1549
+ if ($ai_wp_data [AI_WP_AMP_PAGE] ) {
1550
+ // AMP, Accelerated Mobile Pages
1551
+ add_action ('amp_post_template_head', 'ai_amp_head_hook', 99999);
1552
+ add_action ('amp_post_template_css', 'ai_amp_css_hook', 99999);
1553
+
1554
+ // WP AMP Ninja
1555
+ add_action ('wpamp_custom_script', 'ai_amp_head_hook', 99999);
1556
+ // No usable hook for custom CSS
1557
+ // add_action ('wpamp_custom_style', 'ai_amp_css_hook', 99999);
1558
+
1559
+ // WP AMP - Accelerated Mobile Pages for WordPress
1560
+ add_action ('amphtml_template_head', 'ai_amp_head_hook', 99999);
1561
+ add_action ('amphtml_template_css', 'ai_amp_css_hook', 99999);
1562
+ } else
1563
+ // WP
1564
+ add_action ('wp_head', 'ai_wp_head_hook', 99999);
1565
+
1566
+ $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;
1567
+ if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1568
+ // AMP, Accelerated Mobile Pages
1569
+ if ($automatic_insertion_footer_hook)
1570
+ add_action ('amp_post_template_footer', 'ai_hook_function_footer', 5);
1571
+ add_action ('amp_post_template_footer', 'ai_amp_footer_hook', 5);
1572
+
1573
+ // WP AMP Ninja
1574
+ if ($automatic_insertion_footer_hook)
1575
+ add_action ('wpamp_google_analytics_code', 'ai_hook_function_footer', 5);
1576
+ add_action ('wpamp_google_analytics_code', 'ai_amp_footer_hook', 5);
1577
+
1578
+ // WP AMP - Accelerated Mobile Pages for WordPress
1579
+ if ($automatic_insertion_footer_hook)
1580
+ add_action ('amphtml_after_footer', 'ai_hook_function_footer', 5);
1581
+ add_action ('amphtml_after_footer', 'ai_amp_footer_hook', 5);
1582
+ } else {
1583
+ // WP
1584
+ if ($automatic_insertion_footer_hook)
1585
+ add_action ('wp_footer', 'ai_hook_function_footer', 5);
1586
+ add_action ('wp_footer', 'ai_wp_footer_hook', 5);
1587
+ }
1588
+
1589
+ if ($ai_wp_data [AI_WP_AMP_PAGE]) {
1590
+ // No scripts on AMP pages
1591
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1592
+ $ai_wp_data [AI_ADB_DETECTION] = false;
1593
+ $ai_wp_data [AI_TRACKING] = false;
1594
+ }
1595
+ }
1596
+
1597
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
1598
+ $ai_total_plugin_time += microtime (true) - $start_time;
1599
+ ai_log ("WP HOOK END\n");
1600
+ }
1601
+ };
1602
+
1603
+ function ai_init_hook() {
1604
+ global $block_object, $ai_wp_data, $ai_db_options_extract;
1605
+
1606
+ if (defined ('DOING_AJAX') && DOING_AJAX) {
1607
+ $ai_wp_data [AI_WP_PAGE_TYPE] = AI_PT_AJAX;
1608
+
1609
+ ai_wp_hook ();
1610
+ }
1611
+
1612
+ add_shortcode ('adinserter', 'ai_process_shortcodes');
1613
+ add_shortcode ('ADINSERTER', 'ai_process_shortcodes');
1614
+
1615
+ add_filter ('pre_do_shortcode_tag', 'ai_pre_do_shortcode_tag', 10, 4);
1616
+ }
1617
+
1618
+ function ai_wp_loaded_hook () {
1619
+ global $ai_db_options, $ai_db_options_extract, $version_string;
1620
+
1621
+ if (isset ($ai_db_options [AI_OPTION_EXTRACT]) &&
1622
+ isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] == $version_string &&
1623
+ isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS]) &&
1624
+ isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS][AI_PT_AJAX]) &&
1625
+ isset ($ai_db_options [AI_OPTION_EXTRACT][BETWEEN_COMMENTS_HOOK_BLOCKS]) &&
1626
+ isset ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) &&
1627
+ @unserialize ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) !== false &&
1628
+ isset ($ai_db_options [AI_OPTION_EXTRACT][FOOTER_HOOK_BLOCKS]))
1629
+ $ai_db_options_extract = $ai_db_options [AI_OPTION_EXTRACT]; else
1630
+ $ai_db_options_extract = ai_generate_extract ($ai_db_options);
1631
+ }
1632
+
1633
+ function ai_admin_menu_hook () {
1634
+ global $ai_settings_page;
1635
+
1636
+ if (is_multisite() && !is_main_site () && !multisite_settings_page_enabled ()) return;
1637
+
1638
+ $ai_settings_page = add_submenu_page ('options-general.php', AD_INSERTER_NAME.' Options', AD_INSERTER_NAME, 'manage_options', basename(__FILE__), 'ai_settings');
1639
+ add_action ('admin_enqueue_scripts', 'ai_admin_enqueue_scripts');
1640
+ add_action ('admin_enqueue_scripts', 'ai_admin_remove_scripts', 99999);
1641
+ // add_action ('admin_head', 'ai_admin_head');
1642
+ add_filter ('clean_url', 'ai_clean_url', 999999, 2);
1643
+ }
1644
+
1645
+ function ai_admin_head () {
1646
+ global $ai_settings_page, $hook_suffix;
1647
+
1648
+ // if ($hook_suffix == $ai_settings_page && wp_is_mobile()) {
1649
+ // echo "<meta name='viewport' content='width=762'>\n";
1650
+ // }
1651
+ }
1652
+
1653
+ function ai_admin_enqueue_scripts ($hook_suffix) {
1654
+ global $ai_settings_page;
1655
+
1656
+ if ($hook_suffix == $ai_settings_page) {
1657
+ wp_enqueue_style ('ai-admin-jquery-ui', plugins_url ('css/jquery-ui-1.10.3.custom.min.css', __FILE__), array (), null);
1658
+
1659
+ if (function_exists ('ai_admin_enqueue_scripts_1')) ai_admin_enqueue_scripts_1 ();
1660
+
1661
+ wp_enqueue_style ('ai-admin-multi-select', plugins_url ('css/multi-select.css', AD_INSERTER_FILE), array (), AD_INSERTER_VERSION);
1662
+ wp_enqueue_style ('ai-image-picker', plugins_url ('css/image-picker.css', __FILE__), array (), AD_INSERTER_VERSION);
1663
+ wp_add_inline_style ('ai-image-picker', '.thumbnail {border-radius: 6px;}');
1664
+
1665
+ wp_enqueue_style ('ai-combobox-css', plugins_url ('css/jquery.scombobox.min.css', __FILE__), array (), AD_INSERTER_VERSION);
1666
+
1667
+ wp_enqueue_style ('ai-admin-css', plugins_url ('css/ad-inserter.css', __FILE__), array (), AD_INSERTER_VERSION);
1668
+
1669
+ wp_add_inline_style ('ai-admin-css', '.notice {margin: 5px 15px 15px 0;}');
1670
+
1671
+ if (function_exists ('ai_admin_enqueue_scripts_2')) ai_admin_enqueue_scripts_2 ();
1672
+
1673
+ wp_enqueue_script ('ai-multi-select', plugins_url ('includes/js/jquery.multi-select.js', AD_INSERTER_FILE ), array (), AD_INSERTER_VERSION, true);
1674
+ wp_enqueue_script ('ai-quicksearch', plugins_url ('includes/js/jquery.quicksearch.js', AD_INSERTER_FILE ), array (), AD_INSERTER_VERSION, true);
1675
+
1676
+ // Located in the header to load datepicker js file to prevent error when async tags used
1677
+ wp_enqueue_script ('ai-image-picker-js', plugins_url ('includes/js/image-picker.min.js', __FILE__ ), array (
1678
+ 'jquery',
1679
+ 'jquery-ui-datepicker',
1680
+ ), AD_INSERTER_VERSION, false);
1681
+
1682
+ if (AI_SYNTAX_HIGHLIGHTING) {
1683
+ wp_enqueue_script ('ai-ace', plugins_url ('includes/ace/ace.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1684
+ // wp_enqueue_script ('ai-ace-ext-modelist', plugins_url ('includes/ace/ext-modelist.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1685
+ wp_enqueue_script ('ai-ace-html', plugins_url ('includes/ace/mode-html.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1686
+ wp_enqueue_script ('ai-ace-php', plugins_url ('includes/ace/mode-php.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1687
+
1688
+ if (get_syntax_highlighter_theme () == AI_SYNTAX_HIGHLIGHTER_THEME || isset ($_POST ["syntax-highlighter-theme"]) && $_POST ["syntax-highlighter-theme"] == AI_SYNTAX_HIGHLIGHTER_THEME)
1689
+ wp_enqueue_script ('ai-ace-theme', plugins_url ('includes/ace/theme-ad_inserter.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1690
+ }
1691
+
1692
+ wp_enqueue_script ('ai-admin-js', plugins_url ('js/ad-inserter.js', __FILE__), array (
1693
+ 'jquery',
1694
+ 'jquery-ui-tabs',
1695
+ 'jquery-ui-button',
1696
+ 'jquery-ui-tooltip',
1697
+ 'jquery-ui-datepicker',
1698
+ 'jquery-ui-dialog',
1699
+ ), AD_INSERTER_VERSION, true);
1700
+
1701
+ wp_enqueue_script ('ai-combobox', plugins_url ('includes/js/jquery.scombobox.min.js', __FILE__), array (
1702
+ 'jquery',
1703
+ ), AD_INSERTER_VERSION , true);
1704
+ wp_enqueue_script ('ai-missed', plugins_url ('includes/js/missed.js', __FILE__), array (), AD_INSERTER_VERSION , true);
1705
+ }
1706
+
1707
+ wp_enqueue_style ('ai-admin-css-gen', plugins_url ('css/ai-admin.css', __FILE__), array (), AD_INSERTER_VERSION);
1708
+ wp_enqueue_script ('ai-admin-js-gen', plugins_url ('includes/js/ai-admin.js', __FILE__ ), array (), AD_INSERTER_VERSION, true);
1709
+ }
1710
+
1711
+ // Fix for Publisher theme: remove scripts loaded on Ad Inserter admin page
1712
+ function ai_admin_remove_scripts ($hook_suffix) {
1713
+ global $ai_settings_page;
1714
+
1715
+ if ($hook_suffix == $ai_settings_page) {
1716
+ wp_deregister_script ('ace-editor-script');
1717
+ wp_dequeue_script ('publisher-admin');
1718
+ }
1719
+ }
1720
+
1721
+ function ai_wp_enqueue_scripts_hook () {
1722
+ global $ai_wp_data;
1723
+
1724
+ $footer_inline_scripts =
1725
+ get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE ||
1726
+ $ai_wp_data [AI_TRACKING] ||
1727
+ $ai_wp_data [AI_STICKY_WIDGETS] ||
1728
+ $ai_wp_data [AI_STICK_TO_THE_CONTENT] ||
1729
+ $ai_wp_data [AI_ANIMATION] ||
1730
+ $ai_wp_data [AI_CLOSE_BUTTONS] ||
1731
+ (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION]);
1732
+
1733
+ if ($footer_inline_scripts ||
1734
+ ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_BLOCKS)) != 0 ||
1735
+ $ai_wp_data [AI_FRONTEND_JS_DEBUGGING] ||
1736
+ $ai_wp_data [AI_CLIENT_SIDE_INSERTION] ||
1737
+ get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 ||
1738
+ $ai_wp_data [AI_ANIMATION]) {
1739
+
1740
+ // force loading of jquery on frontend
1741
+ wp_enqueue_script ('ai-jquery-js', plugins_url ('includes/js/ai-jquery.js', __FILE__ ), array (
1742
+ 'jquery',
1743
+ ));
1744
+
1745
+ if ($ai_wp_data [AI_FRONTEND_JS_DEBUGGING]) {
1746
+ wp_add_inline_script ('ai-jquery-js', 'ai_debugging = true;');
1747
+ }
1748
+
1749
+ if ($ai_wp_data [AI_CLIENT_SIDE_INSERTION]) {
1750
+ wp_add_inline_script ('ai-jquery-js', ai_get_js ('ai-insert', false));
1751
+ }
1752
+
1753
+ if (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) {
1754
+ wp_enqueue_style ('dashicons');
1755
+ }
1756
+
1757
+ if ($ai_wp_data [AI_ANIMATION]) {
1758
+ if (defined ('AI_STICKY_SETTINGS') && AI_STICKY_SETTINGS) {
1759
+ wp_enqueue_style ('ai-aos', plugins_url ('includes/aos/ai-aos.css', __FILE__), array (), AD_INSERTER_VERSION);
1760
+ wp_enqueue_script ('ai-aos-js', plugins_url ('includes/aos/aos.js', AD_INSERTER_FILE ), array (), AD_INSERTER_VERSION, true);
1761
+ }
1762
+ }
1763
+ }
1764
+ }
1765
+
1766
+ function ai_clean_url ( $url, $original_url){
1767
+ if (strpos ($url, 'async=') !== false && strpos ($url, '/plugins/ad-inserter') !== false) {
1768
+ // $url = $original_url;
1769
+ $url = str_replace ("' async='async", '', $url);
1770
+ }
1771
+ return $url;
1772
+ }
1773
+
1774
+ function add_head_inline_styles_and_scripts () {
1775
+ global $ai_wp_data;
1776
+
1777
+ if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] ||
1778
+ get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE ||
1779
+ $ai_wp_data [AI_CLOSE_BUTTONS] ||
1780
+ !get_inline_styles () ||
1781
+ get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0) ||
1782
+ $ai_wp_data [AI_WP_DEBUGGING] != 0) {
1783
+
1784
+ echo "<style type='text/css'>\n";
1785
+
1786
+ if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION]) echo get_viewport_css ();
1787
+
1788
+ if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
1789
+ echo ".ai-rotate {position: relative;}\n";
1790
+ echo ".ai-rotate-option {visibility: hidden;}\n";
1791
+ echo ".ai-rotate-options {visibility: hidden; position: absolute; top: 0; left: 0; width: 100%; height: 100%;}\n";
1792
+ echo ".ai-ip-data, .ai-ip-data-block {visibility: hidden; position: absolute; width: 100%; height: 100%; z-index: -9999;}\n";
1793
+ }
1794
+
1795
+ if ($ai_wp_data [AI_CLOSE_BUTTONS]) {
1796
+ echo ".ai-close {position: relative;}\n";
1797
+ // echo ".ai-close-width {width: auto !important;}\n";
1798
+ echo ".ai-close-button {position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; background: url(".plugins_url ('css/images/close-button.png', AD_INSERTER_FILE).") no-repeat center center; cursor: pointer; z-index: 9; display: none;}\n";
1799
+ echo ".ai-close-show {display: block;}\n";
1800
+ echo ".ai-close-left {right: unset; left: -10px;}\n";
1801
+ echo ".ai-close-bottom {top: unset; bottom: -11px;}\n";
1802
+ }
1803
+
1804
+ // if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES)
1805
+ if (!get_inline_styles ()) {
1806
+ echo get_alignment_css ();
1807
+ }
1808
+
1809
+ // After alignment CSS to override width
1810
+ if ($ai_wp_data [AI_CLOSE_BUTTONS]) {
1811
+ echo ".ai-close-fit {width: fit-content; width: -moz-fit-content;}\n";
1812
+ }
1813
+
1814
+ if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css ();
1815
+
1816
+ if (get_admin_toolbar_debugging () && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0))
1817
+ echo "#wp-admin-bar-ai-toolbar-settings .ab-icon:before {
1818
+ content: '\\f111';
1819
+ top: 2px;
1820
+ color: rgba(240,245,250,.6)!important;
1821
+ }
1822
+ #wp-admin-bar-ai-toolbar-settings-default .ab-icon:before {
1823
+ top: 0px;
1824
+ }
1825
+ #wp-admin-bar-ai-toolbar-settings .ab-icon.on:before {
1826
+ color: #00f200!important;
1827
+ }
1828
+ #wp-admin-bar-ai-toolbar-settings-default li, #wp-admin-bar-ai-toolbar-settings-default a,
1829
+ #wp-admin-bar-ai-toolbar-settings-default li:hover, #wp-admin-bar-ai-toolbar-settings-default a:hover {
1830
+ border: 1px solid transparent;
1831
+ }
1832
+ #wp-admin-bar-ai-toolbar-blocks .ab-icon:before {
1833
+ content: '\\f135';
1834
+ }
1835
+ #wp-admin-bar-ai-toolbar-positions .ab-icon:before {
1836
+ content: '\\f207';
1837
+ }
1838
+ #wp-admin-bar-ai-toolbar-positions-default .ab-icon:before {
1839
+ content: '\\f522';
1840
+ }
1841
+ #wp-admin-bar-ai-toolbar-tags .ab-icon:before {
1842
+ content: '\\f475';
1843
+ }
1844
+ #wp-admin-bar-ai-toolbar-no-insertion .ab-icon:before {
1845
+ content: '\\f214';
1846
+ }
1847
+ #wp-admin-bar-ai-toolbar-adb-status .ab-icon:before {
1848
+ content: '\\f223';
1849
+ }
1850
+ #wp-admin-bar-ai-toolbar-adb .ab-icon:before {
1851
+ content: '\\f160';
1852
+ }
1853
+ #wp-admin-bar-ai-toolbar-processing .ab-icon:before {
1854
+ content: '\\f464';
1855
+ }
1856
+ #wp-admin-bar-ai-toolbar-positions span.up-icon {
1857
+ padding-top: 2px;
1858
+ }
1859
+ #wp-admin-bar-ai-toolbar-positions .up-icon:before {
1860
+ font: 400 20px/1 dashicons;
1861
+ }
1862
+ ";
1863
+
1864
+ echo "</style>\n";
1865
+ // No scripts on AMP pages
1866
+ }
1867
+ }
1868
+
1869
+ function ai_get_js ($js_name, $replace_js_data = true) {
1870
+ global $ai_wp_data;
1871
+
1872
+ if ($ai_wp_data [AI_FRONTEND_JS_DEBUGGING]) {
1873
+ $script = file_get_contents (AD_INSERTER_PLUGIN_DIR."includes/js/$js_name.js");
1874
+ } else $script = file_get_contents (AD_INSERTER_PLUGIN_DIR."includes/js/$js_name.min.js");
1875
+ if (!$replace_js_data) return $script;
1876
+ return ai_replace_js_data ($script, $js_name);
1877
+ }
1878
+
1879
+ function ai_replace_js_data ($js) {
1880
+ global $block_object, $ai_wp_data;
1881
+
1882
+ if (preg_match_all ('/AI_CONST_([_A-Z0-9]+)/', $js, $match)) {
1883
+ foreach ($match [1] as $index => $constant) {
1884
+ if (defined ($constant))
1885
+ $js = str_replace ($match [0][$index], constant ($constant), $js);
1886
+ }
1887
+ }
1888
+
1889
+ if (preg_match_all ('/AI_DATA_([_A-Z0-9]+)/', $js, $match)) {
1890
+ foreach ($match [1] as $index => $constant) {
1891
+ if (defined ($constant) && isset ($ai_wp_data [constant ($constant)]))
1892
+ $js = str_replace ($match [0][$index], $ai_wp_data [constant ($constant)], $js);
1893
+ }
1894
+ }
1895
+
1896
+ if (preg_match_all ('/AI_DATAB_([_A-Z0-9]+)/', $js, $match)) {
1897
+ foreach ($match [1] as $index => $constant) {
1898
+ if (defined ($constant) && isset ($ai_wp_data [constant ($constant)]))
1899
+ $js = str_replace ($match [0][$index], $ai_wp_data [constant ($constant)] ? 1 : 0, $js);
1900
+ }
1901
+ }
1902
+
1903
+ if (preg_match_all ('/AI_DBG_([_A-Z0-9]+)/', $js, $match)) {
1904
+ foreach ($match [1] as $index => $constant) {
1905
+ if (defined ($constant))
1906
+ $js = str_replace ($match [0][$index], ($ai_wp_data [AI_WP_DEBUGGING] & constant ($constant)) != 0 ? 1 : 0, $js);
1907
+ }
1908
+ }
1909
+
1910
+ if (preg_match_all ('/AI_FUNC_([_A-Z0-9]+)/', $js, $match)) {
1911
+ foreach ($match [1] as $index => $function) {
1912
+ $function = strtolower ($function);
1913
+ if (function_exists ($function))
1914
+ $js = str_replace ($match [0][$index], call_user_func ($function), $js);
1915
+ }
1916
+ }
1917
+
1918
+ if (preg_match_all ('/AI_FUNCH_([_A-Z0-9]+)/', $js, $match)) {
1919
+ foreach ($match [1] as $index => $function) {
1920
+ $function = strtolower ($function);
1921
+ if (function_exists ($function))
1922
+ $js = str_replace ($match [0][$index], html_entity_decode (call_user_func ($function)), $js);
1923
+ }
1924
+ }
1925
+
1926
+ if (preg_match_all ('/AI_FUNCB_([_A-Z0-9]+)/', $js, $match)) {
1927
+ foreach ($match [1] as $index => $function) {
1928
+ $function = strtolower ($function);
1929
+ if (function_exists ($function))
1930
+ $js = str_replace ($match [0][$index], call_user_func ($function) ? 1 : 0, $js);
1931
+ }
1932
+ }
1933
+
1934
+ if (preg_match_all ('/AI_FUNCT_([_A-Z0-9]+)/', $js, $match)) {
1935
+ foreach ($match [1] as $index => $function) {
1936
+ $function = strtolower ($function);
1937
+ if (function_exists ($function))
1938
+ $js = str_replace ($match [0][$index], call_user_func ($function, true), $js);
1939
+ }
1940
+ }
1941
+
1942
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
1943
+ if (strpos ($js, 'AI_ADB_STATUS_MESSAGE') !== false) {
1944
+ $adb = $block_object [AI_ADB_MESSAGE_OPTION_NAME];
1945
+
1946
+ $js = str_replace ('AI_ADB_OVERLAY_WINDOW', "jQuery ('<div>', {attr: {'style': jQuery.base64Decode ('" . base64_encode (str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), AI_BASIC_ADB_OVERLAY_CSS) . get_overlay_css ()) . "')}})", $js);
1947
+ $js = str_replace ('AI_ADB_MESSAGE_WINDOW', "jQuery ('<div>', {attr: {'style': jQuery.base64Decode ('" . base64_encode (str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), AI_BASIC_ADB_MESSAGE_CSS) . get_message_css ()) . "')}, 'html': jQuery.base64Decode ('" .
1948
+ base64_encode (str_replace (array ("'", "\r", "\n"), array ("\'", '', ''), do_shortcode ($adb->ai_getCode ()))) . "')})", $js);
1949
+
1950
+ // $js = str_replace ('AI_ADB_SELECTORS', str_replace (' ', '', get_adb_selectors (true)), $js);
1951
+ $js = str_replace ('AI_ADB_SELECTORS', get_adb_selectors (true), $js);
1952
+
1953
+ $redirection_page = get_redirection_page ();
1954
+ if ($redirection_page != 0) $url = get_permalink ($redirection_page); else $url = trim (get_custom_redirection_url ());
1955
+ $js = str_replace ('AI_ADB_REDIRECTION_PAGE', $url, $js);
1956
+
1957
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) != 0) {
1958
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=1', '$("#ai-adb-status").text ("DETECTED, " + d1 + " PAGE VIEW" + (d1 == 1 ? "" : "S") + " - NO ACTION");', $js);
1959
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=2', '$("#ai-adb-status").text ("DETECTED, COOKIE DETECTED - NO ACTION");', $js);
1960
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=3', '$("#ai-adb-status").text ("DETECTED - ACTION");', $js);
1961
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=4', 'jQuery("#ai-adb-status").text ("NOT DETECTED");', $js);
1962
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=5', '$("#ai-adb-status").text ("COOKIES DELETED");', $js);
1963
+ } else {
1964
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=1', '', $js);
1965
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=2', '', $js);
1966
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=3', '', $js);
1967
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=4', '{}', $js);
1968
+ $js = str_replace ('var AI_ADB_STATUS_MESSAGE=5', '', $js);
1969
+ }
1970
+ }
1971
+ }
1972
+
1973
+ $js = str_replace ('AI_NONCE', wp_create_nonce ("adinserter_data"), $js);
1974
+ $js = str_replace ('AI_AJAXURL', admin_url ('admin-ajax.php'), $js);
1975
+ $js = str_replace ('AI_SITE_URL', wp_make_link_relative (get_site_url()), $js);
1976
+ if (defined ('AI_STATISTICS') && AI_STATISTICS) {
1977
+ $js = str_replace ('AI_INTERNAL_TRACKING', get_internal_tracking () == AI_ENABLED ? 1 : 0, $js);
1978
+ $js = str_replace ('AI_EXTERNAL_TRACKING', get_external_tracking () == AI_ENABLED ? 1 : 0, $js);
1979
+ $js = str_replace ('AI_TRACK_PAGEVIEWS', get_track_pageviews () == AI_TRACKING_ENABLED ? 1 : 0, $js);
1980
+ $js = str_replace ('AI_ADVANCED_CLICK_DETECTION', get_click_detection () == AI_CLICK_DETECTION_ADVANCED ? 1 : 0, $js);
1981
+
1982
+ if (!isset ($ai_wp_data [AI_VIEWPORTS])) {
1983
+ $viewports = array ();
1984
+ $viewport_names = array ();
1985
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1986
+ $viewport_name = get_viewport_name ($viewport);
1987
+ $viewport_width = get_viewport_width ($viewport);
1988
+ if ($viewport_name != '') {
1989
+ $viewports [$viewport] = $viewport_width;
1990
+ $viewport_names [$viewport] = $viewport_name;
1991
+ }
1992
+ }
1993
+ $ai_wp_data [AI_VIEWPORTS] = $viewports;
1994
+ $ai_wp_data [AI_VIEWPORT_NAMES] = $viewport_names;
1995
+ }
1996
+ $js = str_replace ('AI_VIEWPORTS', '[' . implode (',', $ai_wp_data [AI_VIEWPORTS]) . ']', $js);
1997
+ $js = str_replace ('AI_VIEWPORT_NAMES', base64_encode ('["' . implode ('","', $ai_wp_data [AI_VIEWPORT_NAMES]) . '"]'), $js);
1998
+ }
1999
+ // Deprecated
2000
+ $js = str_replace ('AI_BLOCK_CLASS_NAME', get_block_class_name (true), $js);
2001
+
2002
+ if (function_exists ('ai_replace_js_data_2')) ai_replace_js_data_2 ($js);
2003
+
2004
+ return $js;
2005
+ }
2006
+
2007
+ function ai_adb_code () {
2008
+ return ai_get_js ('ai-adb', false);
2009
+ }
2010
+
2011
+ function add_footer_inline_scripts () {
2012
+ global $ai_wp_data, $wp_version;
2013
+
2014
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
2015
+
2016
+ if ($ai_wp_data [AI_ADB_DETECTION]) {
2017
+ if (function_exists ('add_footer_inline_scripts_1')) add_footer_inline_scripts_1 (); else {
2018
+ echo '<div id="banner-advert-container" class="ad-inserter chitika-ad" style="position:absolute; z-index: -10; height: 1px; width: 1px; top: -1px; left: -1px;"><img id="adsense" class="SponsorAds adsense" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"></div>', "\n";
2019
+ echo "<script type='text/javascript' src='", plugins_url ('js/ads.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
2020
+ echo "<script type='text/javascript' src='", plugins_url ('js/sponsors.js', __FILE__ ), "?ver=", rand (1, 9999999), "'></script>\n";
2021
+ }
2022
+ }
2023
+
2024
+ }
2025
+
2026
+ // Update also $footer_inline_scripts in ai_wp_enqueue_scripts_hook
2027
+ $footer_inline_scripts =
2028
+ get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE ||
2029
+ $ai_wp_data [AI_TRACKING] ||
2030
+ $ai_wp_data [AI_STICKY_WIDGETS] ||
2031
+ $ai_wp_data [AI_STICK_TO_THE_CONTENT] ||
2032
+ $ai_wp_data [AI_ANIMATION] ||
2033
+ $ai_wp_data [AI_CLOSE_BUTTONS] ||
2034
+ (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION && $ai_wp_data [AI_ADB_DETECTION]);
2035
+
2036
+ if (($footer_inline_scripts || $ai_wp_data [AI_CLIENT_SIDE_INSERTION]) && !wp_script_is ('jquery', 'done')) {
2037
+ // Should not insert as it is forced in the header if jquery needed in the footer
2038
+ echo "<script type='text/javascript' src='", includes_url ('js/jquery/jquery.js'), "?ver=", $wp_version, "'></script>\n";
2039
+ echo "<script type='text/javascript' src='", includes_url ('js/jquery/jquery-migrate.min.js'), "?ver=", $wp_version, "'></script>\n";
2040
+ }
2041
+
2042
+ if ($ai_wp_data [AI_STICKY_WIDGETS] && get_sticky_widget_mode() == AI_STICKY_WIDGET_MODE_JS) {
2043
+ // echo "<script type='text/javascript' src='", plugins_url ('includes/js/ResizeSensor.min.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
2044
+ echo "<script type='text/javascript' src='", plugins_url ('includes/js/theia-sticky-sidebar.min.js', __FILE__ ), "?ver=", AD_INSERTER_VERSION, "'></script>\n";
2045
+ }
2046
+
2047
+ if ($footer_inline_scripts) echo "<script type='text/javascript'>\n";
2048
+
2049
+ if (get_dynamic_blocks () == AI_DYNAMIC_BLOCKS_CLIENT_SIDE) {
2050
+ echo ai_get_js ('ai-rotate');
2051
+ }
2052
+
2053
+ if ($ai_wp_data [AI_STICKY_WIDGETS]) {
2054
+ echo ai_get_js ('ai-sidebar');
2055
+ }
2056
+
2057
+ if ($ai_wp_data [AI_STICK_TO_THE_CONTENT] || $ai_wp_data [AI_ANIMATION]) {
2058
+ echo ai_get_js ('ai-sticky');
2059
+ }
2060
+
2061
+ if ($ai_wp_data [AI_CLOSE_BUTTONS]) {
2062
+ echo ai_get_js ('ai-close');
2063
+ }
2064
+
2065
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
2066
+ if ($ai_wp_data [AI_ADB_DETECTION]) {
2067
+ if (!function_exists ('add_footer_inline_scripts_2')) echo ai_replace_js_data (ai_adb_code ());
2068
+ }
2069
+ }
2070
+
2071
+ if (function_exists ('add_footer_inline_scripts_2')) {
2072
+ add_footer_inline_scripts_2 ();
2073
+ }
2074
+
2075
+ if ($footer_inline_scripts) echo "\n</script>\n";
2076
+
2077
+ if (function_exists ('add_footer_inline_footer_html')) {
2078
+ add_footer_inline_footer_html ();
2079
+ }
2080
+ }
2081
+
2082
+ function ai_admin_notice_hook () {
2083
+ global $current_screen, $ai_db_options, $ai_wp_data, $ai_db_options_extract;
2084
+ global $ai_settings_page, $hook_suffix;
2085
+
2086
+ // $sidebar_widgets = wp_get_sidebars_widgets();
2087
+ // $sidebars_with_deprecated_widgets = array ();
2088
+
2089
+ // foreach ($sidebar_widgets as $sidebar_widget_index => $sidebar_widget) {
2090
+ // if (is_array ($sidebar_widget))
2091
+ // foreach ($sidebar_widget as $widget) {
2092
+ // if (preg_match ("/ai_widget([\d]+)/", $widget, $widget_number)) {
2093
+ // if (isset ($widget_number [1]) && is_numeric ($widget_number [1])) {
2094
+ // $is_widget = $ai_db_options [$widget_number [1]][AI_OPTION_AUTOMATIC_INSERTION] == AD_SELECT_WIDGET;
2095
+ // } else $is_widget = false;
2096
+ // $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_widget_index]['name'];
2097
+ // if ($is_widget && $sidebar_name != "")
2098
+ // $sidebars_with_deprecated_widgets [$sidebar_widget_index] = $sidebar_name;
2099
+ // }
2100
+ // }
2101
+ // }
2102
+
2103
+ // if (!empty ($sidebars_with_deprecated_widgets)) {
2104
+ // echo "<div class='notice notice-warning'><p><strong>Warning</strong>: You are using deprecated Ad Inserter widgets in the following sidebars: ",
2105
+ // implode (", ", $sidebars_with_deprecated_widgets),
2106
+ // ". Please replace them with the new 'Ad Inserter' code block widget. See <a href='https://wordpress.org/plugins/ad-inserter/faq/' target='_blank'>FAQ</a> for details.</p></div>";
2107
+ // }
2108
+
2109
+ if (function_exists ('ai_admin_notices')) ai_admin_notices (); else {
2110
+ if (/*$hook_suffix == $ai_settings_page &&*/ is_super_admin () && !wp_is_mobile () && isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL])) {
2111
+
2112
+ $used_blocks = count (unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]));
2113
+
2114
+ $notice_option = get_option ('ai-notice-review');
2115
+ if ($notice_option === false && $ai_wp_data [AI_DAYS_SINCE_INSTAL] >= 40) $notice_option = 'later';
2116
+
2117
+ if (($notice_option === false && $used_blocks >= 2 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] < 40) ||
2118
+
2119
+ ($notice_option == 'later' && ($used_blocks >= 5 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 50 ||
2120
+ $used_blocks >= 2 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 70))) {
2121
+
2122
+ if ($notice_option == 'later') {
2123
+ $message = "Hey, you are now using <strong>{$used_blocks} Ad Inserter</strong> code blocks.";
2124
+ $option = '<div class="ai-notice-text-button ai-notice-dismiss" data-notice="no">No, thank you.</div>';
2125
+ } else {
2126
+ $message = "Hey, you've been using <strong>Ad Inserter</strong> for a while now, and I hope you're happy with it.";
2127
+ $option = '<div class="ai-notice-text-button ai-notice-dismiss" data-notice="later">Not now, maybe later.</div>';
2128
+ }
2129
+ ?>
2130
+ <div class="notice notice-info ai-notice ai-no-phone" style="display: none;" data-notice="review" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>" >
2131
+ <div class="ai-notice-element">
2132
+ <img src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>icon-50x50.jpg" style="width: 50px; margin: 5px 10px 0px 10px;" />
2133
+ </div>
2134
+ <div class="ai-notice-element" style="width: 100%; padding: 0 10px 0;">
2135
+ <p><?php echo $message; ?>
2136
+ I would really appreciate it if you could give the plugin a 5-star rating on WordPres.<br />
2137
+ Positive reviews are a great incentive to fix bugs and to add new features for better monetization of your website.
2138
+ Thank you! - Igor
2139
+ </p>
2140
+ </div>
2141
+ <div class="ai-notice-element ai-notice-buttons last">
2142
+ <button class="button-primary ai-notice-dismiss" data-notice="yes">
2143
+ <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/" class="ai-notice-dismiss" target="_blank" data-notice="yes">Rate Ad Inserter</a>
2144
+ </button>
2145
+ <?php echo $option; ?>
2146
+ <div class="ai-notice-text-button ai-notice-dismiss" data-notice="already">I already did.</div>
2147
+ </div>
2148
+ </div>
2149
+
2150
+ <?php
2151
+ }
2152
+ }
2153
+ }
2154
+
2155
+ }
2156
+
2157
+ function ai_plugin_action_links ($links) {
2158
+ if (is_multisite() && !is_main_site () && !multisite_settings_page_enabled ()) return $links;
2159
+
2160
+ $settings_link = '<a href="'.admin_url ('options-general.php?page=ad-inserter.php').'">Settings</a>';
2161
+ array_unshift ($links, $settings_link);
2162
+ return $links;
2163
+ }
2164
+
2165
+ function ai_set_plugin_meta ($links, $file) {
2166
+ if ($file == plugin_basename (__FILE__)) {
2167
+ if (is_multisite() && !is_main_site ()) {
2168
+ foreach ($links as $index => $link) {
2169
+ if (stripos ($link, "update") !== false) unset ($links [$index]);
2170
+ }
2171
+ }
2172
+ // if (stripos (AD_INSERTER_NAME, "pro") === false) {
2173
+ // $new_links = array ('donate' => '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4" target="_blank">Donate</a>');
2174
+ // $links = array_merge ($links, $new_links);
2175
+ // }
2176
+ }
2177
+ return $links;
2178
+ }
2179
+
2180
+
2181
+ function current_user_role ($user_role_name = "") {
2182
+ $role_values = array ("super-admin" => 6, "administrator" => 5, "editor" => 4, "author" => 3, "contributor" => 2, "subscriber" => 1);
2183
+ global $wp_roles;
2184
+
2185
+ if ($user_role_name != "") {
2186
+ return isset ($role_values [$user_role_name]) ? $role_values [$user_role_name] : 0;
2187
+ }
2188
+
2189
+ $user_role = 0;
2190
+ $current_user = wp_get_current_user();
2191
+ $roles = $current_user->roles;
2192
+
2193
+ // Fix for empty roles
2194
+ if (isset ($current_user->caps) && count ($current_user->caps) != 0) {
2195
+ $caps = $current_user->caps;
2196
+ foreach ($role_values as $role_name => $role_value) {
2197
+ if (isset ($caps [$role_name]) && $caps [$role_name]) $roles []= $role_name;
2198
+ }
2199
+ }
2200
+
2201
+ foreach ($roles as $role) {
2202
+ $current_user_role = isset ($role_values [$role]) ? $role_values [$role] : 0;
2203
+ if ($current_user_role > $user_role) $user_role = $current_user_role;
2204
+ }
2205
+
2206
+ return $user_role;
2207
+ }
2208
+
2209
+
2210
+ function ai_current_user_role_ok () {
2211
+ return current_user_role () >= current_user_role (get_minimum_user_role ());
2212
+ }
2213
+
2214
+
2215
+ function ai_add_meta_box_hook() {
2216
+
2217
+ if (!ai_current_user_role_ok ()) return;
2218
+
2219
+ if (is_multisite() && !is_main_site () && !multisite_exceptions_enabled ()) return;
2220
+
2221
+ $screens = array ('post', 'page');
2222
+
2223
+ $args = array (
2224
+ 'public' => true,
2225
+ '_builtin' => false
2226
+ );
2227
+ $custom_post_types = get_post_types ($args, 'names', 'and');
2228
+ $screens = array_values (array_merge ($screens, $custom_post_types));
2229
+
2230
+ foreach ($screens as $screen) {
2231
+ add_meta_box (
2232
+ 'adinserter_sectionid',
2233
+ AD_INSERTER_NAME.' Individual Exceptions',
2234
+ 'ai_meta_box_callback',
2235
+ $screen
2236
+ );
2237
+ }
2238
+ }
2239
+
2240
+ function ai_meta_box_callback ($post) {
2241
+ global $block_object;
2242
+
2243
+ // Add an nonce field so we can check for it later.
2244
+ wp_nonce_field ('adinserter_meta_box', 'adinserter_meta_box_nonce');
2245
+
2246
+ $post_type = get_post_type ($post);
2247
+ $post_type_object = get_post_type_object ($post_type);
2248
+ $page_type_name = $post_type_object->labels->name;
2249
+ $page_type_name1 = $post_type_object->labels->singular_name;
2250
+
2251
+ /*
2252
+ * Use get_post_meta() to retrieve an existing value
2253
+ * from the database and use the value for the form.
2254
+ */
2255
+ $post_meta = get_post_meta ($post->ID, '_adinserter_block_exceptions', true);
2256
+ $selected_blocks = explode (",", $post_meta);
2257
+
2258
+ ob_start ();
2259
+
2260
+ echo '<table>';
2261
+ echo '<thead style="font-weight: bold;">';
2262
+ echo ' <td>Block</td>';
2263
+ echo ' <td style="padding: 0 10px 0 10px;">Name</td>';
2264
+ echo ' <td style="padding: 0 10px 0 10px;">Automatic Insertion</td>';
2265
+
2266
+ if ($post_type == 'page')
2267
+ echo ' <td style="padding: 0 10px 0 10px;">Default insertion for pages</td>'; else
2268
+ echo ' <td style="padding: 0 10px 0 10px;">Default insertion for posts</td>';
2269
+
2270
+ echo ' <td style="padding: 0 10px 0 10px;">For this ', $page_type_name1, '</td>';
2271
+ echo '</thead>';
2272
+ echo '<tbody>';
2273
+ $rows = 0;
2274
+ for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2275
+ $obj = $block_object [$block];
2276
+
2277
+ if ($post_type == 'page') {
2278
+ $page_name = 'pages';
2279
+ $enabled_on = $obj->get_ad_enabled_on_which_pages ();
2280
+ $general_enabled = $obj->get_display_settings_page();
2281
+ } else {
2282
+ $page_name = 'posts';
2283
+ $enabled_on = $obj->get_ad_enabled_on_which_posts ();
2284
+ $general_enabled = $obj->get_display_settings_post();
2285
+ }
2286
+
2287
+ if (!$general_enabled || $enabled_on == AI_NO_INDIVIDUAL_EXCEPTIONS) continue;
2288
+
2289
+ $individual_option_enabled = $general_enabled && ($enabled_on == AI_INDIVIDUALLY_DISABLED || $enabled_on == AI_INDIVIDUALLY_ENABLED);
2290
+ $individual_text_enabled = $enabled_on == AI_INDIVIDUALLY_DISABLED;
2291
+
2292
+ if ($rows % 2 != 0) $background = "#F0F0F0"; else $background = "#FFF";
2293
+ echo '<tr style="background: ', $background, ';">';
2294
+ echo ' <td style="text-align: right;">', $obj->number, '</td>';
2295
+ if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($block); else $url_parameters = "";
2296
+ echo ' <td style="padding: 0 10px 0 10px;"><a href="', admin_url ('options-general.php?page=ad-inserter.php'), $url_parameters, '&tab=', $block, '" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">', $obj->get_ad_name(), '</a></td>';
2297
+ echo ' <td style="padding: 0 10px 0 10px;">', $obj->get_automatic_insertion_text(), '</td>';
2298
+ echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
2299
+
2300
+ if ($individual_option_enabled) {
2301
+ if ($individual_text_enabled) echo 'Enabled'; else echo 'Disabled';
2302
+ } else {
2303
+ if ($general_enabled) echo 'Enabled on all ', $page_name; else
2304
+ echo 'Disabled on all ', $page_name;
2305
+ }
2306
+ echo ' </td>';
2307
+ echo ' <td style="padding: 0 10px 0 10px; text-align: left;">';
2308
+
2309
+ if ($individual_option_enabled) {
2310
+ echo '<input type="checkbox" style="border-radius: 5px;" name="adinserter_selected_block_', $block, '" id="ai-selected-block-', $block, '" value="1"', in_array ($block, $selected_blocks) ? ' checked': '', ' />';
2311
+ echo '<label for="ai-selected-block-', $block, '">';
2312
+ if (!$individual_text_enabled) echo 'Enabled'; else echo 'Disabled';
2313
+ echo '</label>';
2314
+ } else {
2315
+ if (in_array ($block, $selected_blocks)) {
2316
+ echo '<span style="margin-left: 6px;">&bull;</span>';
2317
+ }
2318
+ }
2319
+
2320
+ echo ' </td>';
2321
+ echo '</tr>';
2322
+ $rows ++;
2323
+ }
2324
+
2325
+ echo '</tbody>';
2326
+ echo '</table>';
2327
+
2328
+ $exceptions_table = ob_get_clean ();
2329
+
2330
+ if ($rows == 0) {
2331
+ echo '<p><strong>No individual exceptions enabled for ', $page_name, '</strong>.</p>';
2332
+ } else echo $exceptions_table;
2333
+
2334
+ echo '<p>Default insertion for ', $page_name, ' for each code block can be configured on <a href="', admin_url ('options-general.php?page=ad-inserter.php'), '" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">',
2335
+ AD_INSERTER_NAME, ' Settings</a> page - selection next to <strong>Posts</strong> / <strong>Static pages</strong> checkbox.<br />',
2336
+ 'Default value is <strong>blank</strong> and means no individual exceptions (even if previously defined here).<br />',
2337
+ 'Set to <strong>Individually disabled</strong> or <strong>Individually enabled</strong> to enable individual exception settings on this page.<br />',
2338
+ 'For more information check <a href="https://adinserter.pro/exceptions" style="text-decoration: none; box-shadow: 0 0 0;" target="_blank">Ad Inserter Exceptions</a>.</p>';
2339
+ }
2340
+
2341
+ function ai_save_meta_box_data_hook ($post_id) {
2342
+ // Check if our nonce is set.
2343
+ if (!isset ($_POST ['adinserter_meta_box_nonce'])) return;
2344
+
2345
+ // Verify that the nonce is valid.
2346
+ if (!wp_verify_nonce ($_POST ['adinserter_meta_box_nonce'], 'adinserter_meta_box')) return;
2347
+
2348
+ // If this is an autosave, our form has not been submitted, so we don't want to do anything.
2349
+ if (defined ('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
2350
+
2351
+ // Check the user's permissions.
2352
+
2353
+ if (isset ($_POST ['post_type'])) {
2354
+ if ($_POST ['post_type'] == 'page') {
2355
+ if (!current_user_can ('edit_page', $post_id)) return;
2356
+ } else {
2357
+ if (!current_user_can ('edit_post', $post_id)) return;
2358
+ }
2359
+ }
2360
+
2361
+ /* OK, it's safe for us to save the data now. */
2362
+
2363
+ $selected = array ();
2364
+ for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
2365
+ $option_name = 'adinserter_selected_block_' . $block;
2366
+ if (isset ($_POST [$option_name]) && $_POST [$option_name]) $selected []= $block;
2367
+ }
2368
+
2369
+ // Update the meta field in the database.
2370
+ update_post_meta ($post_id, '_adinserter_block_exceptions', implode (",", $selected));
2371
+ }
2372
+
2373
+ function ai_widgets_init_hook () {
2374
+ if (is_multisite() && !is_main_site () && !multisite_widgets_enabled ()) return;
2375
+ register_widget ('ai_widget');
2376
+ }
2377
+
2378
+ function get_page_type_debug_info ($text = '') {
2379
+ global $ai_wp_data;
2380
+
2381
+ switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
2382
+ case AI_PT_STATIC:
2383
+ $page_type = 'STATIC PAGE';
2384
+ break;
2385
+ case AI_PT_POST:
2386
+ $page_type = 'POST';
2387
+ break;
2388
+ case AI_PT_HOMEPAGE:
2389
+ $page_type = 'HOMEPAGE';
2390
+ break;
2391
+ case AI_PT_CATEGORY:
2392
+ $page_type = 'CATEGORY PAGE';
2393
+ break;
2394
+ case AI_PT_SEARCH:
2395
+ $page_type = 'SEARCH PAGE';
2396
+ break;
2397
+ case AI_PT_ARCHIVE:
2398
+ $page_type = 'ARCHIVE PAGE';
2399
+ break;
2400
+ case AI_PT_404:
2401
+ $page_type = 'ERROR 404 PAGE';
2402
+ break;
2403
+ case AI_PT_AJAX:
2404
+ $page_type = 'AJAX CALL';
2405
+ break;
2406
+ default:
2407
+ $page_type = 'UNKNOWN PAGE TYPE';
2408
+ break;
2409
+ }
2410
+ $class = AI_DEBUG_PAGE_TYPE_CLASS;
2411
+
2412
+ $page_type = "<section class='$class'>".$text.$page_type."</section>";
2413
+
2414
+ return $page_type;
2415
+ }
2416
+
2417
+ function get_adb_status_debug_info () {
2418
+ global $ai_wp_data;
2419
+
2420
+ $page_type = '';
2421
+
2422
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
2423
+ if ($ai_wp_data [AI_ADB_DETECTION]) {
2424
+ $page_type = "<section id='ai-adb-bar' class='".AI_DEBUG_STATUS_CLASS.' '.AI_DEBUG_ADB_CLASS."' title='Click to delete ad blocking detection cokies'>AD BLOCKING <span id='ai-adb-status'>STATUS UNKNOWN</span></section>";
2425
+ }
2426
+ }
2427
+
2428
+ return $page_type;
2429
+ }
2430
+
2431
+
2432
+ function ai_header_noindex () {
2433
+ global $ai_wp_data;
2434
+
2435
+ if ($ai_wp_data [AI_WP_DEBUGGING] != 0) {
2436
+ echo '<meta name="robots" content="noindex"> <!-- ', AD_INSERTER_NAME, ' debugging enabled (', $ai_wp_data [AI_WP_DEBUGGING], ') -->', "\n";
2437
+ }
2438
+ }
2439
+
2440
+ function get_header_footer_debug_block ($name, $title, $code, $javascript = false) {
2441
+ $message = '';
2442
+ if (strpos ($code, 'enable_page_level_ads') !== false)
2443
+ $message = 'Code for <a style="text-decoration: none; color: #fff; font-weight: bold; box-shadow: none;" href="https://adinserter.pro/adsense-ads#auto-ads" target="_blank">AdSense Auto Ads</a> detected - Code will automatically insert AdSense ads at optimal positions ';
2444
+
2445
+ $debug_script = new ai_block_labels ('ai-debug-script');
2446
+ $debug_block_start = $debug_script->block_start ();
2447
+ $debug_block_start .= $debug_script->bar ($name, '', $message, $title);
2448
+ if ($javascript) $debug_block_start = str_replace (array ('"', "\n", "\r"), array ("'", "\\n", ''), $debug_block_start);
2449
+
2450
+ $debug_block_end = $debug_script->block_end ();
2451
+ if ($javascript) $debug_block_end = str_replace (array ('"', "\n", "\r"), array ("'", "\\n", ''), $debug_block_end);
2452
+
2453
+ $html_code = htmlspecialchars ($code);
2454
+ if ($javascript) $html_code = str_replace (array ("\n", "\r"), array ("\\n", ''), $html_code);
2455
+
2456
+ return $debug_block_start . "<pre class='ai-debug-code'>". $html_code . "</pre>" . $debug_block_end;
2457
+ }
2458
+
2459
+ function ai_http_header () {
2460
+ global $block_object, $ai_wp_data;
2461
+
2462
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_HTTP_HEADER;
2463
+
2464
+ $obj = $block_object [AI_HEADER_OPTION_NAME];
2465
+ $obj->clear_code_cache ();
2466
+
2467
+ if ($obj->get_enable_manual ()) {
2468
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
2469
+ $processed_code = do_shortcode ($obj->ai_getCode ());
2470
+
2471
+ if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
2472
+ $codes = explode (AD_HTTP_SEPARATOR, $processed_code);
2473
+ $processed_code = $codes [0];
2474
+ } else $processed_code = '';
2475
+
2476
+ $header_lines = explode ("\n", $processed_code);
2477
+
2478
+ foreach ($header_lines as $header_line) {
2479
+ if (trim ($header_line) != '' && strpos ($header_line, ':') !== false) {
2480
+ header (trim ($header_line));
2481
+ }
2482
+ }
2483
+ }
2484
+ }
2485
+ }
2486
+
2487
+ function ai_wp_head_hook () {
2488
+ global $block_object, $ai_wp_data, $ai_total_plugin_time;
2489
+
2490
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2491
+ ai_log ("HEAD HOOK START");
2492
+ $start_time = microtime (true);
2493
+ }
2494
+
2495
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
2496
+
2497
+ ai_header_noindex ();
2498
+
2499
+ add_head_inline_styles_and_scripts ();
2500
+
2501
+ $header_code = null;
2502
+
2503
+ $obj = $block_object [AI_HEADER_OPTION_NAME];
2504
+ // $obj->clear_code_cache (); // cleared at ai_http_header
2505
+
2506
+ if ($obj->get_enable_manual ()) {
2507
+ if ($obj->check_server_side_detection ()) {
2508
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
2509
+ $header_code = '';
2510
+
2511
+ $processed_code = do_shortcode ($obj->ai_getCode ());
2512
+
2513
+ if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
2514
+ $codes = explode (AD_HTTP_SEPARATOR, $processed_code);
2515
+ $processed_code = ltrim ($codes [1]);
2516
+ }
2517
+
2518
+ if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
2519
+ $codes = explode (AD_AMP_SEPARATOR, $processed_code);
2520
+ $processed_code = $codes [0];
2521
+ } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
2522
+
2523
+ $header_code = $processed_code;
2524
+
2525
+ echo $processed_code;
2526
+ }
2527
+ }
2528
+ }
2529
+
2530
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
2531
+ // No scripts on AMP pages
2532
+ // if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) != 0 && $ai_wp_data [AI_ADB_DETECTION] && !$ai_wp_data [AI_WP_AMP_PAGE]) {
2533
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_AD_BLOCKING_STATUS) != 0 && $ai_wp_data [AI_ADB_DETECTION] /*&& !$ai_wp_data [AI_WP_AMP_PAGE]*/) {
2534
+ echo "<script>
2535
+ jQuery(document).ready(function($) {
2536
+ $('body').prepend (\"", get_adb_status_debug_info () , "\");
2537
+ });
2538
+ </script>\n";
2539
+ }
2540
+ }
2541
+
2542
+ // No scripts on AMP pages
2543
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
2544
+ echo "<script>
2545
+ jQuery(document).ready(function($) {
2546
+ $('body').prepend (\"", get_page_type_debug_info () , "\");
2547
+ });
2548
+ </script>\n";
2549
+ }
2550
+
2551
+ if ($header_code !== null && ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2552
+ echo "<script>\n";
2553
+ echo " jQuery(document).ready(function($) {
2554
+ $('body').prepend (\"" . get_header_footer_debug_block (' Header code ', '&lt;head&gt;...&lt;/head&gt;', $header_code, true) . "\");
2555
+ });
2556
+ </script>\n";
2557
+ }
2558
+
2559
+ if (defined ('AI_ADSENSE_OVERLAY') && ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2560
+ echo "<script>\n";
2561
+ echo ai_get_js ('ai-ads');
2562
+ echo "</script>\n";
2563
+ }
2564
+
2565
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2566
+ echo "<script>
2567
+ jQuery(document).ready(function($) {
2568
+ setTimeout (function() {
2569
+ var google_auto_placed = jQuery ('.google-auto-placed');
2570
+ google_auto_placed.before ('<section class=\"ai-debug-bar ai-debug-adsense\">Automatically placed by AdSense Auto ads code</section>');
2571
+ }, 3000);
2572
+ });
2573
+ </script>\n";
2574
+ }
2575
+
2576
+ if (defined ('AI_BUFFERING')) {
2577
+ if (get_output_buffering ()) {
2578
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2579
+ ai_buffering_start ();
2580
+ }
2581
+ }
2582
+ }
2583
+
2584
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2585
+ $ai_total_plugin_time += microtime (true) - $start_time;
2586
+ ai_log ("HEAD HOOK END\n");
2587
+ }
2588
+ }
2589
+
2590
+ function ai_amp_head_hook () {
2591
+ global $block_object, $ai_wp_data, $ai_total_plugin_time;
2592
+
2593
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2594
+ ai_log ("HEAD HOOK START");
2595
+ $start_time = microtime (true);
2596
+ }
2597
+
2598
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
2599
+
2600
+ ai_header_noindex ();
2601
+
2602
+ $obj = $block_object [AI_HEADER_OPTION_NAME];
2603
+ // $obj->clear_code_cache (); // cleared at ai_http_header
2604
+
2605
+ if ($obj->get_enable_manual ()) {
2606
+ if ($obj->check_server_side_detection ()) {
2607
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
2608
+ $processed_code = do_shortcode ($obj->ai_getCode ());
2609
+
2610
+ if (strpos ($processed_code, AD_HTTP_SEPARATOR) !== false) {
2611
+ $codes = explode (AD_HTTP_SEPARATOR, $processed_code);
2612
+ $processed_code = ltrim ($codes [1]);
2613
+ }
2614
+
2615
+ if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
2616
+ $codes = explode (AD_AMP_SEPARATOR, $processed_code);
2617
+ $processed_code = ltrim ($codes [1]);
2618
+ echo $processed_code;
2619
+ }
2620
+ }
2621
+ }
2622
+ }
2623
+
2624
+ if (defined ('AI_BUFFERING')) {
2625
+ if (get_output_buffering ()) {
2626
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2627
+ ai_buffering_start ();
2628
+ }
2629
+ }
2630
+ }
2631
+
2632
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2633
+ $ai_total_plugin_time += microtime (true) - $start_time;
2634
+ ai_log ("HEAD HOOK END\n");
2635
+ }
2636
+ }
2637
+
2638
+ function ai_amp_css_hook () {
2639
+ global $ai_wp_data;
2640
+
2641
+ if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES || $ai_wp_data [AI_WP_DEBUGGING] != 0) {
2642
+
2643
+ if (defined ('AI_AMP_HEADER_STYLES') && AI_AMP_HEADER_STYLES) {
2644
+ echo get_alignment_css ();
2645
+
2646
+ echo ".ai-align-left * {margin: 0 auto 0 0; text-align: left;}\n";
2647
+ echo ".ai-align-right * {margin: 0 0 0 auto; text-align: right;}\n";
2648
+ echo ".ai-center * {margin: 0 auto; text-align: center; }\n";
2649
+ }
2650
+
2651
+ if ($ai_wp_data [AI_WP_DEBUGGING] != 0) generate_debug_css ();
2652
+ }
2653
+ }
2654
+
2655
+
2656
+ function ai_wp_footer_hook () {
2657
+ global $block_object, $ai_wp_data, $ai_total_plugin_time;
2658
+
2659
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2660
+ ai_log ("FOOTER HOOK START");
2661
+ $start_time = microtime (true);
2662
+ }
2663
+
2664
+ if (defined ('AI_BUFFERING')) {
2665
+ if (get_output_buffering ()) {
2666
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2667
+ ai_buffering_end ();
2668
+ }
2669
+ }
2670
+ }
2671
+
2672
+ if ($ai_wp_data [AI_DISABLE_CACHING]) ai_disable_caching ();
2673
+
2674
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
2675
+ $footer_code = null;
2676
+
2677
+ $footer = $block_object [AI_FOOTER_OPTION_NAME];
2678
+ $footer->clear_code_cache ();
2679
+
2680
+ if ($footer->get_enable_manual ()) {
2681
+ if ($footer->check_server_side_detection ()) {
2682
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $footer->get_enable_404()) {
2683
+ $footer_code = '';
2684
+ $processed_code = do_shortcode ($footer->ai_getCode ());
2685
+
2686
+ if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
2687
+ $codes = explode (AD_AMP_SEPARATOR, $processed_code);
2688
+ $processed_code = $codes [0];
2689
+ } elseif ($ai_wp_data [AI_WP_AMP_PAGE]) $processed_code = '';
2690
+
2691
+ $footer_code = $processed_code;
2692
+
2693
+ echo $processed_code;
2694
+ }
2695
+ }
2696
+ }
2697
+
2698
+ if (!(defined ('DOING_AJAX') && DOING_AJAX)) {
2699
+ add_footer_inline_scripts ();
2700
+ }
2701
+
2702
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
2703
+ echo get_page_type_debug_info () , "\n";
2704
+ }
2705
+
2706
+ if ($footer_code !== null && ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
2707
+ echo get_header_footer_debug_block (' Footer code ', '...&lt;/body&gt;', $footer_code);
2708
+ }
2709
+
2710
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2711
+ $ai_total_plugin_time += microtime (true) - $start_time;
2712
+ ai_log ("FOOTER HOOK END\n");
2713
+ }
2714
+ }
2715
+
2716
+ function ai_amp_footer_hook () {
2717
+ global $block_object, $ai_wp_data, $ai_total_plugin_time;
2718
+
2719
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2720
+ ai_log ("FOOTER HOOK START");
2721
+ $start_time = microtime (true);
2722
+ }
2723
+
2724
+ if (defined ('AI_BUFFERING')) {
2725
+ if (get_output_buffering ()) {
2726
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_AJAX) {
2727
+ ai_buffering_end ();
2728
+ }
2729
+ }
2730
+ }
2731
+
2732
+ // if (!(defined ('DOING_AJAX') && DOING_AJAX) && !$ai_wp_data [AI_WP_AMP_PAGE]) {
2733
+ // add_footer_inline_scripts ();
2734
+ // }
2735
+
2736
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_FOOTER;
2737
+
2738
+ $obj = $block_object [AI_FOOTER_OPTION_NAME];
2739
+ $obj->clear_code_cache ();
2740
+
2741
+ if ($obj->get_enable_manual ()) {
2742
+ if ($obj->check_server_side_detection ()) {
2743
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_404 || $obj->get_enable_404()) {
2744
+ $processed_code = do_shortcode ($obj->ai_getCode ());
2745
+
2746
+ if (strpos ($processed_code, AD_AMP_SEPARATOR) !== false) {
2747
+ $codes = explode (AD_AMP_SEPARATOR, $processed_code);
2748
+ $processed_code = ltrim ($codes [1]);
2749
+ echo $processed_code;
2750
+ }
2751
+ }
2752
+ }
2753
+ }
2754
+
2755
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
2756
+ echo get_page_type_debug_info ('AMP ') , "\n";
2757
+ }
2758
+
2759
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
2760
+ $ai_total_plugin_time += microtime (true) - $start_time;
2761
+ ai_log ("FOOTER HOOK END\n");
2762
+ }
2763
+ }
2764
+
2765
+ function ai_write_debug_info ($write_processing_log = false) {
2766
+ global $block_object, $ai_last_time, $ai_total_plugin_time, $ai_total_php_time, $ai_processing_log, $ai_db_options_extract, $ai_wp_data, $ai_db_options, $block_insertion_log, $ai_custom_hooks;
2767
+
2768
+ echo sprintf ("%-25s%s", AD_INSERTER_NAME, AD_INSERTER_VERSION);
2769
+ if (function_exists ('ai_debug_header')) ai_debug_header ();
2770
+ echo "\n\n";
2771
+ if (($install_timestamp = get_option (AI_INSTALL_NAME)) !== false) {
2772
+ echo "INSTALLED: ", date ("Y-m-d H:i:s", $install_timestamp + get_option ('gmt_offset') * 3600);
2773
+ if (isset ($ai_wp_data [AI_INSTALL_TIME_DIFFERENCE])) {
2774
+ printf (' (%04d-%02d-%02d %02d:%02d:%02d, %d days)', $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->y,
2775
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->m,
2776
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->d,
2777
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->h,
2778
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->i,
2779
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->s,
2780
+ isset ($ai_wp_data [AI_DAYS_SINCE_INSTAL]) ? $ai_wp_data [AI_DAYS_SINCE_INSTAL] : null);
2781
+ }
2782
+ echo "\n";
2783
+ }
2784
+ echo "GENERATED (WP time): ", date ("Y-m-d H:i:s", time() + get_option ('gmt_offset') * 3600), "\n";
2785
+ echo "GENERATED (Server time): ", date ("Y-m-d H:i:s", time()), "\n";
2786
+ echo "PLUGIN CODE PROCESSING: ", number_format (($ai_total_plugin_time - $ai_total_php_time) * 1000, 2, '.' , ''), " ms\n";
2787
+ echo "USER CODE PROCESSING: ", number_format ($ai_total_php_time * 1000, 2, '.' , ''), " ms\n";
2788
+ echo "TOTAL PROCESSING TIME: ", number_format ($ai_total_plugin_time * 1000, 2, '.' , ''), " ms\n";
2789
+
2790
+ echo "SETTINGS: ";
2791
+ if (isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']))
2792
+ echo (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][0].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][1]), '.',
2793
+ (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][2].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][3]), '.',
2794
+ (int) ($ai_db_options [AI_OPTION_GLOBAL]['VERSION'][4].$ai_db_options [AI_OPTION_GLOBAL]['VERSION'][5]);
2795
+
2796
+ echo "\n";
2797
+ echo "SETTINGS TIMESTAMP: ";
2798
+ 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";
2799
+ echo "SETTINGS EXTRACT: ", defined ('AI_GENERATE_EXTRACT') ? "NO" : "YES", "\n";
2800
+ echo "MULTISITE: ", is_multisite() ? "YES" : "NO", "\n";
2801
+ if (is_multisite()) {
2802
+ echo "MAIN SITE: ", is_main_site () ? "YES" : "NO", "\n";
2803
+ }
2804
+
2805
+ echo "USER: ";
2806
+ if (($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) == AI_USER_LOGGED_IN) echo "LOGGED-IN "; else echo "NOT LOGGED-IN ";
2807
+ if (($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) == AI_USER_ADMINISTRATOR) echo "ADMINISTRATOR";
2808
+ $current_user = wp_get_current_user();
2809
+ echo "\n";
2810
+ echo "USERNAME: ", $current_user->user_login, "\n";
2811
+ echo 'USER ROLES: ', implode (', ', $current_user->roles), "\n";
2812
+ echo 'MIN.USER FOR EXCEPTIONS: ', get_minimum_user_role (), "\n";
2813
+ echo "PAGE TYPE: ";
2814
+ switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
2815
+ case AI_PT_STATIC: echo "STATIC PAGE"; break;
2816
+ case AI_PT_POST: echo "POST"; break;
2817
+ case AI_PT_HOMEPAGE: echo "HOMEPAGE"; break;
2818
+ case AI_PT_CATEGORY: echo "CATEGORY PAGE"; break;
2819
+ case AI_PT_ARCHIVE: echo "ARCHIVE PAGE"; break;
2820
+ case AI_PT_SEARCH: echo "SEARCH PAGE"; break;
2821
+ case AI_PT_404: echo "404 PAGE"; break;
2822
+ case AI_PT_ADMIN: echo "ADMIN"; break;
2823
+ case AI_PT_FEED: echo "FEED"; break;
2824
+ case AI_PT_AJAX: echo "AJAX"; break;
2825
+ case AI_PT_ANY: echo "ANY ?"; break;
2826
+ case AI_PT_NONE: echo "NONE ?"; break;
2827
+ default: echo "?"; break;
2828
+ }
2829
+ echo "\n";
2830
+
2831
+ switch ($ai_wp_data [AI_WP_PAGE_TYPE]) {
2832
+ case AI_PT_STATIC:
2833
+ case AI_PT_POST:
2834
+ echo 'ID: ', get_the_ID(), "\n";
2835
+ echo 'POST TYPE: ', get_post_type (), "\n";
2836
+ $category_data = get_the_category();
2837
+ $categories = array ();
2838
+ foreach ($category_data as $category) {
2839
+ $categories []= $category->name . ' ('.$category->slug.')';
2840
+ }
2841
+ echo 'CATEGORIES: ', implode (', ', $categories), "\n";
2842
+ $tag_data = wp_get_post_tags (get_the_ID());
2843
+ $tags = array ();
2844
+ foreach ($tag_data as $tag) {
2845
+ $tags []= $tag->name . ' ('.$tag->slug.')';
2846
+ }
2847
+ echo 'TAGS: ', implode (', ', $tags), "\n";
2848
+ $taxonomies = array ();
2849
+ $taxonomy_names = get_post_taxonomies ();
2850
+ foreach ($taxonomy_names as $taxonomy_name) {
2851
+ $terms = get_the_terms (0, $taxonomy_name);
2852
+ if (is_array ($terms)) {
2853
+ foreach ($terms as $term) {
2854
+ $taxonomies [] = strtolower ($term->taxonomy) . ':' . strtolower ($term->slug);
2855
+ }
2856
+ }
2857
+ }
2858
+ echo 'TAXONOMIES: ', implode (', ', $taxonomies), "\n";
2859
+
2860
+ $post_meta = get_post_meta (get_the_ID());
2861
+ $meta_string = array ();
2862
+ foreach ($post_meta as $key => $post_meta_field) {
2863
+ foreach ($post_meta_field as $post_meta_field_item) {
2864
+ $meta_string []= $key . ':' . $post_meta_field_item;
2865
+ }
2866
+ }
2867
+ echo 'POST META: ', implode (', ', $meta_string), "\n";
2868
+
2869
+ break;
2870
+ case AI_PT_CATEGORY:
2871
+ $category_data = get_the_category();
2872
+ $categories = array ();
2873
+ foreach ($category_data as $category) {
2874
+ $categories []= $category->slug;
2875
+ }
2876
+ echo 'CATEGORY: ', implode (', ', $categories), "\n";
2877
+ break;
2878
+ case AI_PT_ARCHIVE:
2879
+ $tag_data = wp_get_post_tags (get_the_ID());
2880
+ $tags = array ();
2881
+ foreach ($tag_data as $tag) {
2882
+ $tags []= $tag->slug;
2883
+ }
2884
+ echo 'TAG: ', implode (', ', $tags), "\n";
2885
+ break;
2886
+ }
2887
+
2888
+ echo 'AMP PAGE: ', ($ai_wp_data [AI_WP_AMP_PAGE] ? 'YES' : 'NO'), "\n";
2889
+
2890
+ echo 'URL: ', $ai_wp_data [AI_WP_URL], "\n";
2891
+ echo 'REFERER: ', isset ($_SERVER['HTTP_REFERER']) ? strtolower (parse_url ($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) . ' ('. remove_debug_parameters_from_url ($_SERVER['HTTP_REFERER']).')' : "", "\n";
2892
+ if (function_exists ('ai_debug')) ai_debug ();
2893
+ echo 'CLIENT-SIDE DETECTION: ', $ai_wp_data [AI_CLIENT_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
2894
+ echo 'CLIENT-SIDE INSERTION: ', $ai_wp_data [AI_CLIENT_SIDE_INSERTION] ? 'USED' : "NOT USED", "\n";
2895
+ if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION] || 1) {
2896
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
2897
+ $viewport_name = get_viewport_name ($viewport);
2898
+ $viewport_width = get_viewport_width ($viewport);
2899
+ if ($viewport_name != '') {
2900
+ echo 'VIEWPORT ', $viewport, ': ', sprintf ("%-16s min width %s", $viewport_name.' ', $viewport_width), " px\n";
2901
+ }
2902
+ }
2903
+ }
2904
+ echo 'SERVER-SIDE DETECTION: ', $ai_wp_data [AI_SERVER_SIDE_DETECTION] ? 'USED' : "NOT USED", "\n";
2905
+ if ($ai_wp_data [AI_SERVER_SIDE_DETECTION]) {
2906
+ echo 'SERVER-SIDE DEVICE: ';
2907
+ if (AI_DESKTOP) echo "DESKTOP\n";
2908
+ elseif (AI_TABLET) echo "TABLET\n";
2909
+ elseif (AI_PHONE) echo "PHONE\n";
2910
+ else echo "?\n";
2911
+ }
2912
+
2913
+ $enabled_custom_hooks = array ();
2914
+ foreach ($ai_custom_hooks as $ai_custom_hook) {
2915
+ $hook = $ai_custom_hook ['index'];
2916
+ $enabled_custom_hooks [] = $ai_custom_hook ['action'];
2917
+ }
2918
+ for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
2919
+ $name = str_replace (array ('&lt;', '&gt;'), array ('<', '>'), get_hook_name ($hook));
2920
+ $action = get_hook_action ($hook);
2921
+ if (get_hook_enabled ($hook) /*&& $name != '' && $action != ''*/) {
2922
+ $priority = get_hook_priority ($hook);
2923
+ echo 'CUSTOM HOOK ', $hook, ': ', sprintf ("%-30s %-35s %d %s", $name, $action, $priority, !in_array ($action, $enabled_custom_hooks) ? 'INVALID' : ''), "\n";
2924
+ }
2925
+ }
2926
+ echo 'BLOCK CLASS NAME: ', get_block_class_name (), "\n";
2927
+ echo 'INLINE STYLES: ', get_inline_styles () ? 'ENABLED' : 'DISABLED', "\n";
2928
+ echo 'DYNAMIC BLOCKS: ';
2929
+ switch (get_dynamic_blocks()) {
2930
+ case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
2931
+ echo AI_TEXT_SERVER_SIDE;
2932
+ break;
2933
+ case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
2934
+ echo AI_TEXT_SERVER_SIDE_W3TC;
2935
+ break;
2936
+ case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
2937
+ echo AI_TEXT_CLIENT_SIDE;
2938
+ break;
2939
+ }
2940
+ echo "\n";
2941
+ echo 'PARAGRAPH COUNTING: ';
2942
+ switch (get_paragraph_counting_functions()) {
2943
+ case AI_STANDARD_PARAGRAPH_COUNTING_FUNCTIONS:
2944
+ echo AI_TEXT_STANDARD;
2945
+ break;
2946
+ case AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS:
2947
+ echo AI_TEXT_MULTIBYTE;
2948
+ break;
2949
+ }
2950
+ echo "\n";
2951
+ echo 'NO PAR. COUNTING INSIDE: ', get_no_paragraph_counting_inside (), "\n";
2952
+ if (defined ('AI_BUFFERING')) {
2953
+ echo 'OUTPUT BUFFERING: ';
2954
+ switch (get_output_buffering()) {
2955
+ case AI_OUTPUT_BUFFERING_DISABLED:
2956
+ echo AI_TEXT_DISABLED;
2957
+ break;
2958
+ case AI_OUTPUT_BUFFERING_ENABLED:
2959
+ echo AI_TEXT_ENABLED;
2960
+ break;
2961
+ }
2962
+ echo "\n";
2963
+ }
2964
+ echo 'AD LABEL: ', get_ad_label (), "\n";
2965
+ if (defined ('AI_STICKY_SETTINGS') && AI_STICKY_SETTINGS) {
2966
+ echo 'MAIN CONTENT: ', get_main_content_element (), "\n";
2967
+ }
2968
+ echo 'PLUGIN PRIORITY: ', get_plugin_priority (), "\n";
2969
+ echo 'HEADER CODE: ', $block_object [AI_HEADER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
2970
+ echo 'FOOTER CODE: ', $block_object [AI_FOOTER_OPTION_NAME]->get_enable_manual () ? 'ENABLED' : 'DISABLED', "\n";
2971
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
2972
+ echo 'AD BLOCKING DETECTION: ', $ai_wp_data [AI_ADB_DETECTION] ? 'ENABLED' : 'DISABLED', "\n";
2973
+ if ($ai_wp_data [AI_ADB_DETECTION]) {
2974
+ echo 'ADB ACTION: ';
2975
+ switch (get_adb_action ()) {
2976
+ case AI_ADB_ACTION_NONE:
2977
+ echo AI_TEXT_NONE;
2978
+ break;
2979
+ case AI_ADB_ACTION_MESSAGE:
2980
+ echo AI_TEXT_POPUP_MESSAGE;
2981
+ break;
2982
+ case AI_ADB_ACTION_REDIRECTION:
2983
+ echo AI_TEXT_REDIRECTION;
2984
+ break;
2985
+ }
2986
+ echo "\n";
2987
+ echo 'ADB DELAY ACTION: ', get_delay_action (), "\n";
2988
+ echo 'ADB NO ACTION PERIOD: ', get_no_action_period (), "\n";
2989
+ echo 'ADB SELECTORS: ', get_adb_selectors (true), "\n";
2990
+ $redirection_page = get_redirection_page ();
2991
+ echo 'ADB REDIRECTION PAGE: ', $redirection_page != 0 ? get_the_title ($redirection_page) . ' (' . get_permalink ($redirection_page) . ')' : 'Custom Url', "\n";
2992
+ echo 'ADB REDIRECTION URL: ', get_custom_redirection_url (), "\n";
2993
+ echo 'ADB MESSAGE: ', $block_object [AI_ADB_MESSAGE_OPTION_NAME]->ai_getCode (), "\n";
2994
+ echo 'ADB MESSAGE CSS: ', get_message_css (), "\n";
2995
+ echo 'ADB OVERLAY CSS: ', get_overlay_css (), "\n";
2996
+ echo 'ADB UNDISMISSIBLE: ', get_undismissible_message () ? 'ON' : 'OFF', "\n";
2997
+ }
2998
+ }
2999
+
3000
+ echo "\n";
3001
+
3002
+ $default = new ai_Block (1);
3003
+
3004
+ echo "BLOCK SETTINGS Po Pa Hp Cp Ap Sp AM Aj Fe 404 Wi Sh PHP\n";
3005
+ for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
3006
+ $obj = $block_object [$block];
3007
+
3008
+ $settings = "";
3009
+ $insertion_settings = '';
3010
+ $alignment_settings = '';
3011
+ $default_settings = true;
3012
+ // $display_type = '';
3013
+ foreach (array_keys ($default->wp_options) as $key){
3014
+ switch ($key) {
3015
+ case AI_OPTION_CODE:
3016
+ case AI_OPTION_BLOCK_NAME:
3017
+ continue 2;
3018
+ case AI_OPTION_DISPLAY_ON_PAGES:
3019
+ case AI_OPTION_DISPLAY_ON_POSTS:
3020
+ case AI_OPTION_DISPLAY_ON_HOMEPAGE:
3021
+ case AI_OPTION_DISPLAY_ON_CATEGORY_PAGES:
3022
+ case AI_OPTION_DISPLAY_ON_SEARCH_PAGES:
3023
+ case AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES:
3024
+ case AI_OPTION_ENABLE_AMP:
3025
+ case AI_OPTION_ENABLE_AJAX:
3026
+ case AI_OPTION_ENABLE_FEED:
3027
+ case AI_OPTION_ENABLE_404:
3028
+ case AI_OPTION_ENABLE_MANUAL:
3029
+ case AI_OPTION_ENABLE_WIDGET:
3030
+ case AI_OPTION_ENABLE_PHP_CALL:
3031
+ if ($obj->wp_options [$key] != $default->wp_options [$key]) $default_settings = false;
3032
+ continue 2;
3033
+ }
3034
+
3035
+ // if (gettype ($obj->wp_options [$key]) == 'string' && gettype ($default->wp_options [$key]) == 'integer') {
3036
+ // $default->wp_options [$key] = strval ($default->wp_options [$key]);
3037
+ // }
3038
+ // elseif (gettype ($obj->wp_options [$key]) == 'integer' && gettype ($default->wp_options [$key]) == 'string') {
3039
+ // $default->wp_options [$key] = intval ($default->wp_options [$key]);
3040
+ // }
3041
+
3042
+ // if ($obj->wp_options [$key] !== $default->wp_options [$key]) {
3043
+ if ($obj->wp_options [$key] != $default->wp_options [$key]) {
3044
+ $default_settings = false;
3045
+ switch ($key) {
3046
+ case AI_OPTION_AUTOMATIC_INSERTION:
3047
+ $insertion_settings = $obj->get_automatic_insertion_text();
3048
+ break;
3049
+ case AI_OPTION_SERVER_SIDE_INSERTION:
3050
+ $settings .= "[" . $key . ": " . $obj->get_automatic_insertion_text (true) . ']';
3051
+ break;
3052
+ case AI_OPTION_ALIGNMENT_TYPE:
3053
+ $alignment_settings = $obj->get_alignment_type_text ();
3054
+ break;
3055
+ case AI_OPTION_ENABLED_ON_WHICH_PAGES:
3056
+ $settings .= "[" . $key . ": " . $obj->get_ad_enabled_on_which_pages_text () . ']';
3057
+ break;
3058
+ case AI_OPTION_ENABLED_ON_WHICH_POSTS:
3059
+ $settings .= "[" . $key . ": " . $obj->get_ad_enabled_on_which_posts_text () . ']';
3060
+ break;
3061
+ case AI_OPTION_PARAGRAPH_TEXT:
3062
+ case AI_OPTION_AVOID_TEXT_ABOVE:
3063
+ case AI_OPTION_AVOID_TEXT_BELOW:
3064
+ case AI_OPTION_HTML_SELECTOR:
3065
+ if ($write_processing_log)
3066
+ $settings .= "[" . $key . ": " . ai_log_filter_content (html_entity_decode ($obj->wp_options [$key])) . ']'; else
3067
+ $settings .= "[" . $key . ": " . $obj->wp_options [$key] . ']';
3068
+ break;
3069
+ case AI_OPTION_FILTER_TYPE:
3070
+ $settings .= "[" . $key . ": " . $obj->get_filter_type_text () . ']';
3071
+ break;
3072
+ default:
3073
+ $settings .= "[" . $key . ": " . $obj->wp_options [$key] . ']';
3074
+ break;
3075
+ }
3076
+
3077
+ // $settings .= ' ['.gettype ($obj->wp_options [$key]).':'.$obj->wp_options [$key].'#'.gettype ($default->wp_options [$key]).':'.$default->wp_options [$key].'] ';
3078
+
3079
+ } else
3080
+ switch ($key) {
3081
+ case AI_OPTION_AUTOMATIC_INSERTION:
3082
+ $insertion_settings = $obj->get_automatic_insertion_text ();
3083
+ break;
3084
+ case AI_OPTION_ALIGNMENT_TYPE:
3085
+ $alignment_settings = $obj->get_alignment_type_text ();
3086
+ break;
3087
+ }
3088
+ }
3089
+ if ($default_settings && $settings == '') continue;
3090
+ $settings = ' [' . $insertion_settings . '][' . $alignment_settings . ']' . $settings;
3091
+
3092
+ echo sprintf ("%2d %-21s ", $block, substr ($obj->get_ad_name(), 0, 21));
3093
+
3094
+ echo $obj->get_display_settings_post() ? "o" : ".", " ";
3095
+ echo $obj->get_display_settings_page() ? "o" : ".", " ";
3096
+ echo $obj->get_display_settings_home() ? "o" : ".", " ";
3097
+ echo $obj->get_display_settings_category() ? "o" : ".", " ";
3098
+ echo $obj->get_display_settings_archive() ? "o" : ".", " ";
3099
+ echo $obj->get_display_settings_search() ? "o" : ".", " ";
3100
+ echo $obj->get_enable_amp() ? "o" : ".", " ";
3101
+ echo $obj->get_enable_ajax() ? "o" : ".", " ";
3102
+ echo $obj->get_enable_feed() ? "o" : ".", " ";
3103
+ echo $obj->get_enable_404() ? "o" : ".", " ";
3104
+ echo $obj->get_enable_widget() ? "x" : ".", " ";
3105
+ echo $obj->get_enable_manual() ? "x" : ".", " ";
3106
+ echo $obj->get_enable_php_call() ? "x" : ".", " ";
3107
+
3108
+ echo $settings, "\n";
3109
+ }
3110
+ echo "\n";
3111
+
3112
+ $args = array (
3113
+ 'public' => true,
3114
+ '_builtin' => false
3115
+ );
3116
+ $custom_post_types = get_post_types ($args, 'names', 'and');
3117
+ $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types));
3118
+
3119
+ $args = array (
3120
+ 'posts_per_page' => 100,
3121
+ 'offset' => 0,
3122
+ 'category' => '',
3123
+ 'category_name' => '',
3124
+ 'orderby' => 'type',
3125
+ 'order' => 'ASC',
3126
+ 'include' => '',
3127
+ 'exclude' => '',
3128
+ 'meta_key' => '_adinserter_block_exceptions',
3129
+ 'meta_value' => '',
3130
+ 'post_type' => $screens,
3131
+ 'post_mime_type' => '',
3132
+ 'post_parent' => '',
3133
+ 'author' => '',
3134
+ 'author_name' => '',
3135
+ 'post_status' => '',
3136
+ 'suppress_filters' => true
3137
+ );
3138
+ $posts_pages = get_posts ($args);
3139
+
3140
+ if (count ($posts_pages) != 0) {
3141
+ echo "EXCEPTIONS FOR BLOCKS ID TYPE TITLE URL\n";
3142
+ foreach ($posts_pages as $page) {
3143
+ $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
3144
+ if ($post_meta == '') continue;
3145
+ $post_type_object = get_post_type_object ($page->post_type);
3146
+ echo sprintf ("%-24s %-6s %-24s %-64s %s", $post_meta, $page->ID, $post_type_object->labels->singular_name, substr ($page->post_title, 0, 64), get_permalink ($page->ID)), "\n";
3147
+ }
3148
+ echo "\n";
3149
+ }
3150
+
3151
+ echo "TOTAL BLOCKS\n";
3152
+ if (count ($ai_db_options_extract [ABOVE_HEADER_HOOK_BLOCKS][AI_PT_ANY]))
3153
+ echo "ABOVE HEADER: ", implode (", ", $ai_db_options_extract [ABOVE_HEADER_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3154
+ if (count ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][AI_PT_ANY]))
3155
+ echo "CONTENT HOOK: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3156
+ if (count ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][AI_PT_ANY]))
3157
+ echo "EXCERPT HOOK: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3158
+ if (count ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY]))
3159
+ echo "LOOP START HOOK: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3160
+ if (count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]))
3161
+ echo "LOOP END HOOK: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3162
+ if (count ($ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]))
3163
+ echo "POST HOOK: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3164
+ if (count ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
3165
+ echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3166
+ if (count ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
3167
+ echo "BETWEEN COMMENTS HOOK ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3168
+ if (count ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]))
3169
+ echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3170
+ if (count ($ai_db_options_extract [FOOTER_HOOK_BLOCKS][AI_PT_ANY]))
3171
+ echo "FOOTER HOOK: ", implode (", ", $ai_db_options_extract [FOOTER_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3172
+ foreach ($ai_custom_hooks as $hook_index => $custom_hook) {
3173
+
3174
+ switch ($custom_hook ['action']) {
3175
+ case 'wp_footer':
3176
+ // case 'wp_head':
3177
+ case 'the_content':
3178
+ case 'the_excerpt':
3179
+ case 'loop_start':
3180
+ case 'loop_end':
3181
+ case 'the_post':
3182
+ continue 2;
3183
+ }
3184
+
3185
+ if (count ($ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][AI_PT_ANY]))
3186
+ echo substr (strtoupper (str_replace (array ('&lt;', '&gt;'), array ('<', '>'), get_hook_name ($custom_hook ['index']))) . " HOOK: ", 0, 25), implode (", ", $ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3187
+ }
3188
+ if (count ($ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][AI_PT_ANY]))
3189
+ echo "HTML ELEMENT: ", implode (", ", $ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][AI_PT_ANY]), "\n";
3190
+
3191
+ echo "\nBLOCKS FOR THIS PAGE TYPE\n";
3192
+ 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]]))
3193
+ echo "ABOVE HEADER: ", implode (", ", $ai_db_options_extract [ABOVE_HEADER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3194
+ 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]]))
3195
+ echo "CONTENT HOOK: ", implode (", ", $ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3196
+ 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]]))
3197
+ echo "EXCERPT HOOK: ", implode (", ", $ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3198
+ 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]]))
3199
+ echo "LOOP START HOOK: ", implode (", ", $ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3200
+ 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]]))
3201
+ echo "LOOP END HOOK: ", implode (", ", $ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3202
+ 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]]))
3203
+ echo "POST HOOK: ", implode (", ", $ai_db_options_extract [POST_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3204
+ 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]]))
3205
+ echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3206
+ 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]]))
3207
+ echo "BETWEEN COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3208
+ 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]]))
3209
+ echo "AFTER COMMENTS HOOK: ", implode (", ", $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3210
+ 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]]))
3211
+ echo "FOOTER HOOK ", implode (", ", $ai_db_options_extract [FOOTER_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3212
+ foreach ($ai_custom_hooks as $hook_index => $custom_hook) {
3213
+
3214
+ switch ($custom_hook ['action']) {
3215
+ case 'wp_footer':
3216
+ // case 'wp_head':
3217
+ case 'the_content':
3218
+ case 'the_excerpt':
3219
+ case 'loop_start':
3220
+ case 'loop_end':
3221
+ case 'the_post':
3222
+ continue 2;
3223
+ }
3224
+
3225
+ 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]]))
3226
+ echo substr (strtoupper (str_replace (array ('&lt;', '&gt;'), array ('<', '>'), get_hook_name ($custom_hook ['index']))) . " HOOK: ", 0, 25), implode (", ", $ai_db_options_extract [$custom_hook ['action'] . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3227
+ }
3228
+ 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]]))
3229
+ echo "HTML ELEMENT: ", implode (", ", $ai_db_options_extract [HTML_ELEMENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]), "\n";
3230
+
3231
+ if ($write_processing_log) {
3232
+ echo "\nTIME EVENT\n";
3233
+ echo "======================================\n";
3234
+
3235
+ foreach ($ai_processing_log as $log_line) {
3236
+ echo $log_line, "\n";
3237
+ }
3238
+
3239
+ sort ($block_insertion_log);
3240
+ echo "\nINSERTION SUMMARY\n";
3241
+ echo "======================================\n";
3242
+ foreach ($block_insertion_log as $log_line) {
3243
+ echo substr ($log_line, 3), "\n";
3244
+ }
3245
+ echo "\n\n";
3246
+
3247
+ echo "PHP: ", phpversion(), "\n";
3248
+ echo "Memory Limit: ", ini_get ('memory_limit'), "\n";
3249
+ echo "Upload Max Filesize: ", ini_get ('upload_max_filesize'), "\n";
3250
+ echo "Post Max Size: ", ini_get ('post_max_size'), "\n";
3251
+ echo "Max Execution Time: ", ini_get ('max_execution_time'), "\n";
3252
+ echo "Max Input Vars: ", ini_get ('max_input_vars'), "\n";
3253
+ echo "Display Errors: ", ini_get ('display_errors'), "\n";
3254
+ echo "cURL: ", function_exists ('curl_version') ? 'ENABLED' : 'DISABLED', "\n";
3255
+ echo "fsockopen: ", function_exists ('fsockopen') ? 'ENABLED' : 'DISABLED', "\n";
3256
+ echo "DOMDocument: ", class_exists ('DOMDocument') ? 'YES' : 'NO', "\n";
3257
+ echo "\n\n";
3258
+
3259
+ global $wp_version;
3260
+ echo "Wordpress: ", $wp_version, "\n";
3261
+ $current_theme = wp_get_theme();
3262
+
3263
+ echo "Current Theme: ", $current_theme->get ('Name') . " " . $current_theme->get ('Version'), "\n";
3264
+ echo "\n";
3265
+ echo "A INSTALLED PLUGINS\n";
3266
+ echo "======================================\n";
3267
+
3268
+ if ( ! function_exists( 'get_plugins' ) ) {
3269
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
3270
+ }
3271
+ $all_plugins = get_plugins();
3272
+ $active_plugins = get_option ('active_plugins');
3273
+ $active_sitewide_plugins = is_multisite () ? get_site_option ('active_sitewide_plugins') : false;
3274
+
3275
+ foreach ($all_plugins as $plugin_path => $plugin) {
3276
+ $multisite_status = ' ';
3277
+ if ($active_sitewide_plugins !== false) {
3278
+ $multisite_status = array_key_exists ($plugin_path, $active_sitewide_plugins) ? '# ' : ' ';
3279
+ }
3280
+ echo in_array ($plugin_path, $active_plugins) ? '* ' : $multisite_status, html_entity_decode ($plugin ["Name"]), ' ', $plugin ["Version"], "\n";
3281
+ }
3282
+ }
3283
+
3284
+
3285
+ }
3286
+
3287
+ function ai_shutdown_hook () {
3288
+ global $ai_wp_data;
3289
+
3290
+ if (function_exists ('ai_system_output')) ai_system_output ();
3291
+
3292
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0 && (get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_LOGGED_IN) != 0)) {
3293
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_HOMEPAGE ||
3294
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC ||
3295
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST ||
3296
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_CATEGORY ||
3297
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_SEARCH ||
3298
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ARCHIVE ||
3299
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_404 ||
3300
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_NONE ||
3301
+ $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ANY) {
3302
+ echo "\n<!--\n\n";
3303
+ ai_write_debug_info (true);
3304
+ echo "\n-->\n";
3305
+ }
3306
+ }
3307
+ }
3308
+
3309
+ function ai_check_multisite_options (&$multisite_options) {
3310
+ if (!isset ($multisite_options ['MULTISITE_SETTINGS_PAGE'])) $multisite_options ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
3311
+ if (!isset ($multisite_options ['MULTISITE_WIDGETS'])) $multisite_options ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS;
3312
+ if (!isset ($multisite_options ['MULTISITE_PHP_PROCESSING'])) $multisite_options ['MULTISITE_PHP_PROCESSING'] = DEFAULT_MULTISITE_PHP_PROCESSING;
3313
+ if (!isset ($multisite_options ['MULTISITE_EXCEPTIONS'])) $multisite_options ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS;
3314
+ if (!isset ($multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'])) $multisite_options ['MULTISITE_MAIN_FOR_ALL_BLOGS'] = DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS;
3315
+
3316
+ if (function_exists ('ai_check_multisite_options_2')) ai_check_multisite_options_2 ($multisite_options);
3317
+ }
3318
+
3319
+ function ai_check_plugin_options ($plugin_options = array ()) {
3320
+ global $version_string;
3321
+
3322
+ $plugin_options ['VERSION'] = $version_string;
3323
+
3324
+ if (!isset ($plugin_options ['SYNTAX_HIGHLIGHTER_THEME'])) $plugin_options ['SYNTAX_HIGHLIGHTER_THEME'] = DEFAULT_SYNTAX_HIGHLIGHTER_THEME;
3325
+
3326
+ if (!isset ($plugin_options ['BLOCK_CLASS_NAME'])) $plugin_options ['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME;
3327
+ if (!isset ($plugin_options ['BLOCK_CLASS'])) $plugin_options ['BLOCK_CLASS'] = DEFAULT_BLOCK_CLASS;
3328
+ if (!isset ($plugin_options ['BLOCK_NUMBER_CLASS'])) $plugin_options ['BLOCK_NUMBER_CLASS'] = DEFAULT_BLOCK_NUMBER_CLASS;
3329
+ if (!isset ($plugin_options ['INLINE_STYLES'])) $plugin_options ['INLINE_STYLES'] = DEFAULT_INLINE_STYLES;
3330
+
3331
+ if (!isset ($plugin_options ['MINIMUM_USER_ROLE'])) $plugin_options ['MINIMUM_USER_ROLE'] = DEFAULT_MINIMUM_USER_ROLE;
3332
+
3333
+ if (!isset ($plugin_options ['STICKY_WIDGET_MODE'])) $plugin_options ['STICKY_WIDGET_MODE'] = DEFAULT_STICKY_WIDGET_MODE;
3334
+
3335
+ if (!isset ($plugin_options ['STICKY_WIDGET_MARGIN'])) $plugin_options ['STICKY_WIDGET_MARGIN'] = DEFAULT_STICKY_WIDGET_MARGIN;
3336
+ $sticky_widget_margin = $plugin_options ['STICKY_WIDGET_MARGIN'];
3337
+ if (!is_numeric ($sticky_widget_margin)) {
3338
+ $sticky_widget_margin = DEFAULT_STICKY_WIDGET_MARGIN;
3339
+ }
3340
+ $sticky_widget_margin = intval ($sticky_widget_margin);
3341
+ if ($sticky_widget_margin < 0) {
3342
+ $sticky_widget_margin = 0;
3343
+ }
3344
+ if ($sticky_widget_margin > 999) {
3345
+ $sticky_widget_margin = 999;
3346
+ }
3347
+ $plugin_options ['STICKY_WIDGET_MARGIN'] = $sticky_widget_margin;
3348
+
3349
+
3350
+ if (!isset ($plugin_options ['PLUGIN_PRIORITY'])) $plugin_options ['PLUGIN_PRIORITY'] = DEFAULT_PLUGIN_PRIORITY;
3351
+ $plugin_priority = $plugin_options ['PLUGIN_PRIORITY'];
3352
+ if (!is_numeric ($plugin_priority)) {
3353
+ $plugin_priority = DEFAULT_PLUGIN_PRIORITY;
3354
+ }
3355
+ $plugin_priority = intval ($plugin_priority);
3356
+ if ($plugin_priority < 0) {
3357
+ $plugin_priority = 0;
3358
+ }
3359
+ if ($plugin_priority > 999999) {
3360
+ $plugin_priority = 999999;
3361
+ }
3362
+ $plugin_options ['PLUGIN_PRIORITY'] = $plugin_priority;
3363
+
3364
+
3365
+ if (!isset ($plugin_options ['DYNAMIC_BLOCKS'])) $plugin_options ['DYNAMIC_BLOCKS'] = DEFAULT_DYNAMIC_BLOCKS;
3366
+ if (!isset ($plugin_options ['PARAGRAPH_COUNTING_FUNCTIONS'])) $plugin_options ['PARAGRAPH_COUNTING_FUNCTIONS'] = DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS;
3367
+ if (!isset ($plugin_options ['OUTPUT_BUFFERING'])) $plugin_options ['OUTPUT_BUFFERING'] = DEFAULT_OUTPUT_BUFFERING;
3368
+ if (!isset ($plugin_options ['NO_PARAGRAPH_COUNTING_INSIDE'])) $plugin_options ['NO_PARAGRAPH_COUNTING_INSIDE'] = DEFAULT_NO_PARAGRAPH_COUNTING_INSIDE;
3369
+ if (!isset ($plugin_options ['AD_LABEL'])) $plugin_options ['AD_LABEL'] = DEFAULT_AD_TITLE;
3370
+ if (!isset ($plugin_options ['MAIN_CONTENT_ELEMENT'])) $plugin_options ['MAIN_CONTENT_ELEMENT'] = DEFAULT_MAIN_CONTENT_ELEMENT;
3371
+ if (!isset ($plugin_options ['ADB_ACTION'])) $plugin_options ['ADB_ACTION'] = AI_DEFAULT_ADB_ACTION;
3372
+ if (!isset ($plugin_options ['ADB_DELAY_ACTION'])) $plugin_options ['ADB_DELAY_ACTION'] = '';
3373
+ if (!isset ($plugin_options ['ADB_NO_ACTION_PERIOD'])) $plugin_options ['ADB_NO_ACTION_PERIOD'] = AI_DEFAULT_ADB_NO_ACTION_PERIOD;
3374
+ if (!isset ($plugin_options ['ADB_SELECTORS'])) $plugin_options ['ADB_SELECTORS'] = '';
3375
+ if (!isset ($plugin_options ['ADB_REDIRECTION_PAGE'])) $plugin_options ['ADB_REDIRECTION_PAGE'] = AI_DEFAULT_ADB_REDIRECTION_PAGE;
3376
+ if (!isset ($plugin_options ['ADB_CUSTOM_REDIRECTION_URL'])) $plugin_options ['ADB_CUSTOM_REDIRECTION_URL'] = '';
3377
+ if (!isset ($plugin_options ['ADB_OVERLAY_CSS'])) $plugin_options ['ADB_OVERLAY_CSS'] = AI_DEFAULT_ADB_OVERLAY_CSS;
3378
+ if (!isset ($plugin_options ['ADB_MESSAGE_CSS'])) $plugin_options ['ADB_MESSAGE_CSS'] = AI_DEFAULT_ADB_MESSAGE_CSS;
3379
+ if (!isset ($plugin_options ['ADB_UNDISMISSIBLE_MESSAGE'])) $plugin_options ['ADB_UNDISMISSIBLE_MESSAGE'] = AI_DEFAULT_ADB_UNDISMISSIBLE_MESSAGE;
3380
+ if (!isset ($plugin_options ['ADMIN_TOOLBAR_DEBUGGING'])) $plugin_options ['ADMIN_TOOLBAR_DEBUGGING'] = DEFAULT_ADMIN_TOOLBAR_DEBUGGING;
3381
+ if (!isset ($plugin_options ['REMOTE_DEBUGGING'])) $plugin_options ['REMOTE_DEBUGGING'] = DEFAULT_REMOTE_DEBUGGING;
3382
+ if (!isset ($plugin_options ['BACKEND_JS_DEBUGGING'])) $plugin_options ['BACKEND_JS_DEBUGGING'] = DEFAULT_BACKEND_JS_DEBUGGING;
3383
+ if (!isset ($plugin_options ['FRONTEND_JS_DEBUGGING'])) $plugin_options ['FRONTEND_JS_DEBUGGING'] = DEFAULT_FRONTEND_JS_DEBUGGING;
3384
+
3385
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
3386
+ $viewport_name_option_name = 'VIEWPORT_NAME_' . $viewport;
3387
+ $viewport_width_option_name = 'VIEWPORT_WIDTH_' . $viewport;
3388
+
3389
+ if (!isset ($plugin_options [$viewport_name_option_name])) $plugin_options [$viewport_name_option_name] =
3390
+ defined ("DEFAULT_VIEWPORT_NAME_" . $viewport) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport) : "";
3391
+
3392
+ if ($viewport == 1 && $plugin_options [$viewport_name_option_name] == '')
3393
+ $plugin_options [$viewport_name_option_name] = constant ("DEFAULT_VIEWPORT_NAME_1");
3394
+
3395
+ if ($plugin_options [$viewport_name_option_name] != '') {
3396
+ if (!isset ($plugin_options [$viewport_width_option_name])) $plugin_options [$viewport_width_option_name] =
3397
+ defined ("DEFAULT_VIEWPORT_WIDTH_" . $viewport) ? constant ("DEFAULT_VIEWPORT_WIDTH_" . $viewport) : 0;
3398
+
3399
+ $viewport_width = $plugin_options [$viewport_width_option_name];
3400
+
3401
+ if ($viewport > 1) {
3402
+ $previous_viewport_option_width = $plugin_options ['VIEWPORT_WIDTH_' . ($viewport - 1)];
3403
+ }
3404
+
3405
+ if (!is_numeric ($viewport_width)) {
3406
+ if ($viewport == 1)
3407
+ $viewport_width = constant ("DEFAULT_VIEWPORT_WIDTH_1"); else
3408
+ $viewport_width = $previous_viewport_option_width - 1;
3409
+
3410
+ }
3411
+ if ($viewport_width > 9999) {
3412
+ $viewport_width = 9999;
3413
+ }
3414
+
3415
+ if ($viewport > 1) {
3416
+ if ($viewport_width >= $previous_viewport_option_width)
3417
+ $viewport_width = $previous_viewport_option_width - 1;
3418
+ }
3419
+
3420
+ $viewport_width = intval ($viewport_width);
3421
+ if ($viewport_width < 0) {
3422
+ $viewport_width = 0;
3423
+ }
3424
+
3425
+ $plugin_options [$viewport_width_option_name] = $viewport_width;
3426
+ } else $plugin_options [$viewport_width_option_name] = '';
3427
+ }
3428
+
3429
+ for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
3430
+ $hook_enabled_settins_name = 'HOOK_ENABLED_' . $hook;
3431
+ $hook_name_settins_name = 'HOOK_NAME_' . $hook;
3432
+ $hook_action_settins_name = 'HOOK_ACTION_' . $hook;
3433
+ $hook_priority_settins_name = 'HOOK_PRIORITY_' . $hook;
3434
+
3435
+ if (!isset ($plugin_options [$hook_enabled_settins_name])) $plugin_options [$hook_enabled_settins_name] = AI_DISABLED;
3436
+ if (!isset ($plugin_options [$hook_name_settins_name])) $plugin_options [$hook_name_settins_name] = '';
3437
+ if (!isset ($plugin_options [$hook_action_settins_name])) $plugin_options [$hook_action_settins_name] = '';
3438
+ if (!isset ($plugin_options [$hook_priority_settins_name]) || !is_int ($plugin_options [$hook_priority_settins_name])) $plugin_options [$hook_priority_settins_name] = DEFAULT_CUSTOM_HOOK_PRIORITY;
3439
+ }
3440
+
3441
+ if (function_exists ('ai_check_options')) ai_check_options ($plugin_options);
3442
+
3443
+ return ($plugin_options);
3444
+ }
3445
+
3446
+ function option_stripslashes (&$options) {
3447
+ $options = wp_unslash ($options);
3448
+
3449
+ // if (is_array ($options)) {
3450
+ // foreach ($options as $key => $option) {
3451
+ // option_stripslashes ($options [$key]);
3452
+ // }
3453
+ // } else if (is_string ($options)) $options = stripslashes ($options);
3454
+ }
3455
+
3456
+ // Deprecated
3457
+ function ai_get_option ($option_name) {
3458
+ $options = get_option ($option_name);
3459
+ option_stripslashes ($options);
3460
+ return ($options);
3461
+ }
3462
+
3463
+ function ai_load_options () {
3464
+ global $ai_db_options, $ai_db_options_multisite, $ai_wp_data;
3465
+
3466
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD OPTIONS START");
3467
+
3468
+ if (is_multisite()) {
3469
+ $ai_db_options_multisite = get_site_option (AI_OPTION_NAME);
3470
+ option_stripslashes ($ai_db_options_multisite);
3471
+ }
3472
+
3473
+ if (is_multisite() && multisite_main_for_all_blogs () && defined ('BLOG_ID_CURRENT_SITE')) {
3474
+ $ai_db_options = get_blog_option (BLOG_ID_CURRENT_SITE, AI_OPTION_NAME);
3475
+ option_stripslashes ($ai_db_options);
3476
+ } else {
3477
+ $ai_db_options = get_option (AI_OPTION_NAME);
3478
+ option_stripslashes ($ai_db_options);
3479
+ }
3480
+
3481
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD OPTIONS END");
3482
+ }
3483
+
3484
+ function get_viewport_css () {
3485
+ global $ai_db_options;
3486
+
3487
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'])) $ai_db_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'] = generate_viewport_css ();
3488
+
3489
+ return ($ai_db_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS']);
3490
+ }
3491
+
3492
+ function get_alignment_css () {
3493
+ global $ai_db_options;
3494
+
3495
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS']) ||
3496
+ isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] < '020211'
3497
+ ) $ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'] = generate_alignment_css ();
3498
+
3499
+ return (str_replace ('&#039;', "'", $ai_db_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS']));
3500
+ }
3501
+
3502
+ function get_syntax_highlighter_theme () {
3503
+ global $ai_db_options;
3504
+
3505
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['SYNTAX_HIGHLIGHTER_THEME'])) $ai_db_options [AI_OPTION_GLOBAL]['SYNTAX_HIGHLIGHTER_THEME'] = DEFAULT_SYNTAX_HIGHLIGHTER_THEME;
3506
+
3507
+ return ($ai_db_options [AI_OPTION_GLOBAL]['SYNTAX_HIGHLIGHTER_THEME']);
3508
+ }
3509
+
3510
+ function get_block_class_name ($default_if_empty = false) {
3511
+ global $ai_db_options;
3512
+
3513
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME'])) $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME'] = DEFAULT_BLOCK_CLASS_NAME;
3514
+
3515
+ if ($default_if_empty && $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME'] == '') return (DEFAULT_BLOCK_CLASS_NAME);
3516
+
3517
+ return ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS_NAME']);
3518
+ }
3519
+
3520
+ function get_block_class () {
3521
+ global $ai_db_options;
3522
+
3523
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS'])) $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS'] = DEFAULT_BLOCK_CLASS;
3524
+
3525
+ return ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_CLASS']);
3526
+ }
3527
+
3528
+ function get_block_number_class () {
3529
+ global $ai_db_options;
3530
+
3531
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NUMBER_CLASS'])) $ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NUMBER_CLASS'] = DEFAULT_BLOCK_NUMBER_CLASS;
3532
+
3533
+ return ($ai_db_options [AI_OPTION_GLOBAL]['BLOCK_NUMBER_CLASS']);
3534
+ }
3535
+
3536
+ function get_inline_styles () {
3537
+ global $ai_db_options;
3538
+
3539
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['INLINE_STYLES'])) $ai_db_options [AI_OPTION_GLOBAL]['INLINE_STYLES'] = DEFAULT_INLINE_STYLES;
3540
+
3541
+ return ($ai_db_options [AI_OPTION_GLOBAL]['INLINE_STYLES']);
3542
+ }
3543
+
3544
+ function get_minimum_user_role () {
3545
+ global $ai_db_options;
3546
+
3547
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['MINIMUM_USER_ROLE'])) $ai_db_options [AI_OPTION_GLOBAL]['MINIMUM_USER_ROLE'] = DEFAULT_MINIMUM_USER_ROLE;
3548
+
3549
+ return ($ai_db_options [AI_OPTION_GLOBAL]['MINIMUM_USER_ROLE']);
3550
+ }
3551
+
3552
+ function get_sticky_widget_mode () {
3553
+ global $ai_db_options;
3554
+
3555
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE'])) $ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE'] = DEFAULT_STICKY_WIDGET_MODE;
3556
+
3557
+ return ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MODE']);
3558
+ }
3559
+
3560
+ function get_sticky_widget_margin () {
3561
+ global $ai_db_options;
3562
+
3563
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MARGIN'])) $ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MARGIN'] = DEFAULT_STICKY_WIDGET_MARGIN;
3564
+
3565
+ return ($ai_db_options [AI_OPTION_GLOBAL]['STICKY_WIDGET_MARGIN']);
3566
+ }
3567
+
3568
+ function get_plugin_priority () {
3569
+ global $ai_db_options;
3570
+
3571
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_PRIORITY'])) $ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_PRIORITY'] = DEFAULT_PLUGIN_PRIORITY;
3572
+
3573
+ return ($ai_db_options [AI_OPTION_GLOBAL]['PLUGIN_PRIORITY']);
3574
+ }
3575
+
3576
+ function get_dynamic_blocks(){
3577
+ global $ai_db_options;
3578
+
3579
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['DYNAMIC_BLOCKS'])) $ai_db_options [AI_OPTION_GLOBAL]['DYNAMIC_BLOCKS'] = DEFAULT_DYNAMIC_BLOCKS;
3580
+
3581
+ return ($ai_db_options [AI_OPTION_GLOBAL]['DYNAMIC_BLOCKS']);
3582
+ }
3583
+
3584
+ function get_paragraph_counting_functions(){
3585
+ global $ai_db_options;
3586
+
3587
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['PARAGRAPH_COUNTING_FUNCTIONS'])) $ai_db_options [AI_OPTION_GLOBAL]['PARAGRAPH_COUNTING_FUNCTIONS'] = DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS;
3588
+
3589
+ return ($ai_db_options [AI_OPTION_GLOBAL]['PARAGRAPH_COUNTING_FUNCTIONS']);
3590
+ }
3591
+
3592
+ function get_output_buffering(){
3593
+ global $ai_db_options;
3594
+
3595
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING'])) $ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING'] = DEFAULT_OUTPUT_BUFFERING;
3596
+
3597
+ return ($ai_db_options [AI_OPTION_GLOBAL]['OUTPUT_BUFFERING']);
3598
+ }
3599
+
3600
+ function get_no_paragraph_counting_inside () {
3601
+ global $ai_db_options;
3602
+
3603
+ 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;
3604
+
3605
+ return (str_replace (array ('<', '>'), '', $ai_db_options [AI_OPTION_GLOBAL]['NO_PARAGRAPH_COUNTING_INSIDE']));
3606
+ }
3607
+
3608
+ function get_ad_label ($decode = false) {
3609
+ global $ai_db_options;
3610
+
3611
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL'])) $ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL'] = DEFAULT_AD_TITLE;
3612
+
3613
+ if ($decode) return (html_entity_decode ($ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL']));
3614
+
3615
+ return ($ai_db_options [AI_OPTION_GLOBAL]['AD_LABEL']);
3616
+ }
3617
+
3618
+ function get_main_content_element () {
3619
+ global $ai_db_options;
3620
+
3621
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['MAIN_CONTENT_ELEMENT'])) $ai_db_options [AI_OPTION_GLOBAL]['MAIN_CONTENT_ELEMENT'] = DEFAULT_MAIN_CONTENT_ELEMENT;
3622
+
3623
+ return ($ai_db_options [AI_OPTION_GLOBAL]['MAIN_CONTENT_ELEMENT']);
3624
+ }
3625
+
3626
+ function get_admin_toolbar_debugging () {
3627
+ global $ai_db_options;
3628
+
3629
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_DEBUGGING'] = DEFAULT_ADMIN_TOOLBAR_DEBUGGING;
3630
+
3631
+ return ($ai_db_options [AI_OPTION_GLOBAL]['ADMIN_TOOLBAR_DEBUGGING']);
3632
+ }
3633
+
3634
+ function get_remote_debugging () {
3635
+ global $ai_db_options;
3636
+
3637
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['REMOTE_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['REMOTE_DEBUGGING'] = DEFAULT_REMOTE_DEBUGGING;
3638
+
3639
+ return ($ai_db_options [AI_OPTION_GLOBAL]['REMOTE_DEBUGGING']);
3640
+ }
3641
+
3642
+ function get_backend_javascript_debugging () {
3643
+ global $ai_db_options;
3644
+
3645
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['BACKEND_JS_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['BACKEND_JS_DEBUGGING'] = DEFAULT_BACKEND_JS_DEBUGGING;
3646
+
3647
+ return ($ai_db_options [AI_OPTION_GLOBAL]['BACKEND_JS_DEBUGGING']);
3648
+ }
3649
+
3650
+ function get_frontend_javascript_debugging () {
3651
+ global $ai_db_options;
3652
+
3653
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['FRONTEND_JS_DEBUGGING'])) $ai_db_options [AI_OPTION_GLOBAL]['FRONTEND_JS_DEBUGGING'] = DEFAULT_FRONTEND_JS_DEBUGGING;
3654
+
3655
+ return ($ai_db_options [AI_OPTION_GLOBAL]['FRONTEND_JS_DEBUGGING']);
3656
+ }
3657
+
3658
+ function get_viewport_name ($viewport_number) {
3659
+ global $ai_db_options;
3660
+
3661
+ $viewport_settins_name = 'VIEWPORT_NAME_' . $viewport_number;
3662
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]))
3663
+ $ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name] = defined ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) ? constant ("DEFAULT_VIEWPORT_NAME_" . $viewport_number) : "";
3664
+
3665
+ return ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]);
3666
+ }
3667
+
3668
+ function get_viewport_width ($viewport_number) {
3669
+ global $ai_db_options;
3670
+
3671
+ $viewport_settins_name = 'VIEWPORT_WIDTH_' . $viewport_number;
3672
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]))
3673
+ $ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name] = defined ("DEFAULT_VIEWPORT_WIDTH_" . $viewport_number) ? constant ("DEFAULT_VIEWPORT_WIDTH_" . $viewport_number) : "";
3674
+
3675
+ return ($ai_db_options [AI_OPTION_GLOBAL][$viewport_settins_name]);
3676
+ }
3677
+
3678
+ function get_hook_enabled ($hook_number) {
3679
+ global $ai_db_options;
3680
+
3681
+ $hook_settins_name = 'HOOK_ENABLED_' . $hook_number;
3682
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = AI_DISABLED;
3683
+
3684
+ return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
3685
+ }
3686
+
3687
+ function get_hook_name ($hook_number) {
3688
+ global $ai_db_options;
3689
+
3690
+ $hook_settins_name = 'HOOK_NAME_' . $hook_number;
3691
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = "";
3692
+
3693
+ return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
3694
+ }
3695
+
3696
+ function get_hook_action ($hook_number) {
3697
+ global $ai_db_options;
3698
+
3699
+ $hook_settins_name = 'HOOK_ACTION_' . $hook_number;
3700
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = "";
3701
+
3702
+ return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
3703
+ }
3704
+
3705
+ function get_hook_priority ($hook_number) {
3706
+ global $ai_db_options;
3707
+
3708
+ $hook_settins_name = 'HOOK_PRIORITY_' . $hook_number;
3709
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name] = DEFAULT_CUSTOM_HOOK_PRIORITY;
3710
+
3711
+ return ($ai_db_options [AI_OPTION_GLOBAL][$hook_settins_name]);
3712
+ }
3713
+
3714
+ function get_country_group_name ($group_number) {
3715
+ global $ai_db_options;
3716
+
3717
+ $country_group_settins_name = 'COUNTRY_GROUP_NAME_' . $group_number;
3718
+ 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;
3719
+
3720
+ return ($ai_db_options [AI_OPTION_GLOBAL][$country_group_settins_name]);
3721
+ }
3722
+
3723
+ function get_group_country_list ($group_number) {
3724
+ global $ai_db_options;
3725
+
3726
+ $group_countries_settins_name = 'GROUP_COUNTRIES_' . $group_number;
3727
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL][$group_countries_settins_name])) $ai_db_options [AI_OPTION_GLOBAL][$group_countries_settins_name] = '';
3728
+
3729
+ return ($ai_db_options [AI_OPTION_GLOBAL][$group_countries_settins_name]);
3730
+ }
3731
+
3732
+ function multisite_settings_page_enabled () {
3733
+ global $ai_db_options_multisite;
3734
+
3735
+ if (is_multisite()) {
3736
+ if (!isset ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'])) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
3737
+ if ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] == '') $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = DEFAULT_MULTISITE_SETTINGS_PAGE;
3738
+
3739
+ if (multisite_main_for_all_blogs ()) $ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE'] = AI_DISABLED;
3740
+
3741
+ return ($ai_db_options_multisite ['MULTISITE_SETTINGS_PAGE']);
3742
+ }
3743
+
3744
+ return DEFAULT_MULTISITE_SETTINGS_PAGE;
3745
+ }
3746
+
3747
+ function multisite_widgets_enabled () {
3748
+ global $ai_db_options_multisite;
3749
+
3750
+ if (is_multisite()) {
3751
+ if (!isset ($ai_db_options_multisite ['MULTISITE_WIDGETS'])) $ai_db_options_multisite ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS;
3752
+ if ($ai_db_options_multisite ['MULTISITE_WIDGETS'] == '') $ai_db_options_multisite ['MULTISITE_WIDGETS'] = DEFAULT_MULTISITE_WIDGETS;
3753
+
3754
+ return ($ai_db_options_multisite ['MULTISITE_WIDGETS']);
3755
+ }
3756
+
3757
+ return DEFAULT_MULTISITE_WIDGETS;
3758
+ }
3759
+
3760
+ function multisite_php_processing () {
3761
+ global $ai_db_options_multisite;
3762
+
3763
+ if (is_multisite()) {
3764
+ if (!isset ($ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'])) $ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'] = DEFAULT_MULTISITE_PHP_PROCESSING;
3765
+ if ($ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'] == '') $ai_db_options_multisite ['MULTISITE_PHP_PROCESSING'] = DEFAULT_MULTISITE_PHP_PROCESSING;
3766
+
3767
+ return ($ai_db_options_multisite ['MULTISITE_PHP_PROCESSING']);
3768
+ }
3769
+
3770
+ return DEFAULT_MULTISITE_WIDGETS;
3771
+ }
3772
+
3773
+ function multisite_exceptions_enabled () {
3774
+ global $ai_db_options_multisite;
3775
+
3776
+ if (is_multisite()) {
3777
+ if (!isset ($ai_db_options_multisite ['MULTISITE_EXCEPTIONS'])) $ai_db_options_multisite ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS;
3778
+ if ($ai_db_options_multisite ['MULTISITE_EXCEPTIONS'] == '') $ai_db_options_multisite ['MULTISITE_EXCEPTIONS'] = DEFAULT_MULTISITE_EXCEPTIONS;
3779
+
3780
+ return ($ai_db_options_multisite ['MULTISITE_EXCEPTIONS']);
3781
+ }
3782
+
3783
+ return DEFAULT_MULTISITE_EXCEPTIONS;
3784
+ }
3785
+
3786
+ function multisite_main_for_all_blogs () {
3787
+ global $ai_db_options_multisite;
3788
+
3789
+ if (is_multisite()) {
3790
+ 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;
3791
+ 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;
3792
+
3793
+ return ($ai_db_options_multisite ['MULTISITE_MAIN_FOR_ALL_BLOGS']);
3794
+ }
3795
+
3796
+ return DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS;
3797
+ }
3798
+
3799
+ function get_adb_action ($saved_value = false) {
3800
+ global $ai_db_options, $ai_wp_data;
3801
+
3802
+ if (!$saved_value) {
3803
+ if (isset ($ai_wp_data [AI_ADB_SHORTCODE_ACTION])) return ($ai_wp_data [AI_ADB_SHORTCODE_ACTION]);
3804
+ }
3805
+
3806
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION'] = AI_DEFAULT_ADB_ACTION;
3807
+
3808
+ return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_ACTION']);
3809
+ }
3810
+
3811
+ function get_delay_action ($return_number = false) {
3812
+ global $ai_db_options;
3813
+
3814
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION'] = '';
3815
+
3816
+ if ($return_number) {
3817
+ $value = trim ($ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION']);
3818
+ if ($value == '') $value = 0;
3819
+ if (is_numeric ($value)) return $value; else return 0;
3820
+ }
3821
+
3822
+ return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_DELAY_ACTION']);
3823
+ }
3824
+
3825
+ function get_no_action_period ($return_number = false) {
3826
+ global $ai_db_options;
3827
+
3828
+ 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;
3829
+
3830
+ if ($return_number) {
3831
+ $value = trim ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION_PERIOD']);
3832
+ if ($value == '') $value = 0;
3833
+ if (is_numeric ($value)) return $value; else return AI_DEFAULT_ADB_NO_ACTION_PERIOD;
3834
+ }
3835
+
3836
+ return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_NO_ACTION_PERIOD']);
3837
+ }
3838
+
3839
+ function get_adb_selectors ($decode = false) {
3840
+ global $ai_db_options;
3841
+
3842
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'] = '';
3843
+
3844
+ if ($decode)
3845
+ return (html_entity_decode ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS'])); else
3846
+ return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_SELECTORS']);
3847
+ }
3848
+
3849
+ function get_redirection_page ($return_number = false) {
3850
+ global $ai_db_options;
3851
+
3852
+ 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;
3853
+
3854
+ if ($return_number) {
3855
+ $value = trim ($ai_db_options [AI_OPTION_GLOBAL]['ADB_REDIRECTION_PAGE']);
3856
+ if ($value == '') $value = 0;
3857
+ if (is_numeric ($value)) return $value; else return AI_DEFAULT_ADB_REDIRECTION_PAGE;
3858
+ }
3859
+
3860
+ return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_REDIRECTION_PAGE']);
3861
+ }
3862
+
3863
+ function get_custom_redirection_url () {
3864
+ global $ai_db_options;
3865
+
3866
+ if (!isset ($ai_db_options [AI_OPTION_GLOBAL]['ADB_CUSTOM_REDIRECTION_URL'])) $ai_db_options [AI_OPTION_GLOBAL]['ADB_CUSTOM_REDIRECTION_URL'] = '';
3867
+
3868
+ return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_CUSTOM_REDIRECTION_URL']);
3869
+ }
3870
+
3871
+ function get_message_css () {
3872
+ global $ai_db_options;
3873
+
3874
+ 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;
3875
+
3876
+ return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_MESSAGE_CSS']);
3877
+ }
3878
+
3879
+ function get_overlay_css () {
3880
+ global $ai_db_options;
3881
+
3882
+ 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;
3883
+
3884
+ return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_OVERLAY_CSS']);
3885
+ }
3886
+
3887
+ function get_undismissible_message () {
3888
+ global $ai_db_options;
3889
+
3890
+ 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;
3891
+
3892
+ return ($ai_db_options [AI_OPTION_GLOBAL]['ADB_UNDISMISSIBLE_MESSAGE']);
3893
+ }
3894
+
3895
+ function filter_html_class ($str){
3896
+
3897
+ $str = str_replace (array ("\\\""), array ("\""), $str);
3898
+ $str = sanitize_html_class ($str);
3899
+
3900
+ return $str;
3901
+ }
3902
+
3903
+ function filter_string ($str){
3904
+
3905
+ $str = str_replace (array ("\\\""), array ("\""), $str);
3906
+ $str = str_replace (array ("\"", "<", ">"), "", $str);
3907
+ $str = trim (esc_html ($str));
3908
+
3909
+ return $str;
3910
+ }
3911
+
3912
+ function filter_string_tags ($str){
3913
+
3914
+ $str = str_replace (array ("\\\""), array ("\""), $str);
3915
+ $str = str_replace (array ("\""), "", $str);
3916
+ $str = str_replace (array ("<", ">"), array ("&lt;", "&gt;"), $str);
3917
+ $str = trim (esc_html ($str));
3918
+
3919
+ return $str;
3920
+ }
3921
+
3922
+ function filter_option ($option, $value, $delete_escaped_backslashes = true){
3923
+ if ($delete_escaped_backslashes)
3924
+ $value = str_replace (array ("\\\""), array ("\""), $value);
3925
+
3926
+ if ($option == 'ADB_SELECTORS' ||
3927
+ $option == AI_OPTION_HTML_SELECTOR ||
3928
+ $option == AI_OPTION_ANIMATION_TRIGGER_VALUE ||
3929
+ $option == 'MAIN_CONTENT_ELEMENT') {
3930
+ // $value = str_replace (array ("\\", "/", "?", "\"", "'", "<", ">", "'", '"'), "", $value);
3931
+ $value = str_replace (array ("\\", "/", "?", "\"", "'", "'", '"'), "", $value);
3932
+ $value = esc_html ($value);
3933
+ }
3934
+ elseif ($option == AI_OPTION_DOMAIN_LIST ||
3935
+ $option == 'NO_PARAGRAPH_COUNTING_INSIDE' ||
3936
+ $option == AI_OPTION_PARAGRAPH_TAGS ||
3937
+ $option == AI_OPTION_IP_ADDRESS_LIST ||
3938
+ $option == AI_OPTION_COUNTRY_LIST) {
3939
+ $value = str_replace (array ("\\", "/", "?", "\"", "'", "<", ">", "[", "]", "'", '"'), "", $value);
3940
+ $value = esc_html ($value);
3941
+ }
3942
+ elseif (
3943
+ $option == AI_OPTION_PARAGRAPH_TEXT ||
3944
+ $option == AI_OPTION_AVOID_TEXT_ABOVE ||
3945
+ $option == AI_OPTION_AVOID_TEXT_BELOW
3946
+ ) {
3947
+ $value = esc_html ($value);
3948
+ }
3949
+ elseif ($option == AI_OPTION_BLOCK_NAME ||
3950
+ $option == AI_OPTION_GENERAL_TAG ||
3951
+ $option == AI_OPTION_DOMAIN_LIST ||
3952
+ $option == AI_OPTION_CATEGORY_LIST ||
3953
+ $option == AI_OPTION_TAG_LIST ||
3954
+ $option == AI_OPTION_ID_LIST ||
3955
+ $option == AI_OPTION_URL_LIST ||
3956
+ $option == AI_OPTION_URL_PARAMETER_LIST ||
3957
+ $option == AI_OPTION_PARAGRAPH_TEXT_TYPE ||
3958
+ $option == AI_OPTION_PARAGRAPH_NUMBER ||
3959
+ $option == AI_OPTION_MIN_PARAGRAPHS ||
3960
+ $option == AI_OPTION_MIN_WORDS_ABOVE ||
3961
+ $option == AI_OPTION_AVOID_PARAGRAPHS_ABOVE ||
3962
+ $option == AI_OPTION_AVOID_PARAGRAPHS_BELOW ||
3963
+ $option == AI_OPTION_AVOID_TRY_LIMIT ||
3964
+ $option == AI_OPTION_MIN_WORDS ||
3965
+ $option == AI_OPTION_MAX_WORDS ||
3966
+ $option == AI_OPTION_MIN_PARAGRAPH_WORDS ||
3967
+ $option == AI_OPTION_MAX_PARAGRAPH_WORDS ||
3968
+ $option == AI_OPTION_MAXIMUM_INSERTIONS ||
3969
+ $option == AI_OPTION_AFTER_DAYS ||
3970
+ $option == AI_OPTION_START_DATE ||
3971
+ $option == AI_OPTION_END_DATE ||
3972
+ $option == AI_OPTION_FALLBACK ||
3973
+ $option == AI_OPTION_EXCERPT_NUMBER ||
3974
+ $option == AI_OPTION_HORIZONTAL_MARGIN ||
3975
+ $option == AI_OPTION_VERTICAL_MARGIN ||
3976
+ $option == AI_OPTION_ANIMATION_TRIGGER_OFFSET ||
3977
+ $option == AI_OPTION_ANIMATION_TRIGGER_DELAY ||
3978
+ $option == 'ADB_DELAY_ACTION' ||
3979
+ $option == 'ADB_NO_ACTION_PERIOD' ||
3980
+ $option == 'ADB_REDIRECTION_PAGE' ||
3981
+ $option == 'ADB_CUSTOM_REDIRECTION_URL' ||
3982
+ $option == AI_OPTION_CUSTOM_CSS ||
3983
+ $option == 'HOOK_PRIORITY' ||
3984
+ $option == 'ADB_OVERLAY_CSS' ||
3985
+ $option == 'ADB_MESSAGE_CSS') {
3986
+ $value = str_replace (array ("\"", "<", ">", "[", "]"), "", $value);
3987
+ $value = esc_html ($value);
3988
+ }
3989
+ elseif ($option == 'AD_LABEL' ) {
3990
+ $value = str_replace (array ("\\", "?"), "", $value);
3991
+ $value = esc_html ($value);
3992
+ }
3993
+
3994
+ return $value;
3995
+ }
3996
+
3997
+ function filter_option_hf ($option, $value){
3998
+ $value = str_replace (array ("\\\""), array ("\""), $value);
3999
+
4000
+ // if ($option == AI_OPTION_CODE ) {
4001
+ // } elseif ($option == AI_OPTION_ENABLE_MANUAL) {
4002
+ // } elseif ($option == AI_OPTION_PROCESS_PHP) {
4003
+ // } elseif ($option == AI_OPTION_ENABLE_404) {
4004
+ // } elseif ($option == AI_OPTION_DETECT_SERVER_SIDE) {
4005
+ // } elseif ($option == AI_OPTION_DISPLAY_FOR_DEVICES) {
4006
+ // }
4007
+
4008
+ return $value;
4009
+ }
4010
+
4011
+ function ai_ajax () {
4012
+
4013
+ // check_ajax_referer ("adinserter_data", "ai_check");
4014
+ // check_admin_referer ("adinserter_data", "ai_check");
4015
+
4016
+ if (isset ($_POST ["adsense-ad-units"])) {
4017
+ if (defined ('AI_ADSENSE_API')) {
4018
+ adsense_ad_name ($_POST ["adsense-ad-units"]);
4019
+ }
4020
+ }
4021
+
4022
+ elseif (function_exists ('ai_ajax_processing_2')) {
4023
+ ai_ajax_processing_2 ();
4024
+ }
4025
+
4026
+ wp_die ();
4027
+ }
4028
+
4029
+ function ai_ajax_backend () {
4030
+ global $preview_name, $preview_alignment, $preview_css;
4031
+
4032
+ // check_ajax_referer ("adinserter_data", "ai_check");
4033
+ check_admin_referer ("adinserter_data", "ai_check");
4034
+
4035
+ if (isset ($_POST ["preview"])) {
4036
+ $block = urldecode ($_POST ["preview"]);
4037
+ if (is_numeric ($block) && $block >= 1 && $block <= AD_INSERTER_BLOCKS) {
4038
+ require_once AD_INSERTER_PLUGIN_DIR.'includes/preview.php';
4039
+
4040
+ $preview_parameters = array ();
4041
+
4042
+ if (isset ($_POST ['name'])) $preview_parameters ['name'] = base64_decode ($_POST ['name']);
4043
+ if (isset ($_POST ['code'])) $preview_parameters ['code'] = base64_decode ($_POST ['code']);
4044
+ if (isset ($_POST ['alignment'])) $preview_parameters ['alignment'] = base64_decode ($_POST ['alignment']);
4045
+ if (isset ($_POST ['horizontal'])) $preview_parameters ['horizontal'] = base64_decode ($_POST ['horizontal']);
4046
+ if (isset ($_POST ['vertical'])) $preview_parameters ['vertical'] = base64_decode ($_POST ['vertical']);
4047
+ if (isset ($_POST ['horizontal_margin'])) $preview_parameters ['horizontal_margin'] = base64_decode ($_POST ['horizontal_margin']);
4048
+ if (isset ($_POST ['vertical_margin'])) $preview_parameters ['vertical_margin'] = base64_decode ($_POST ['vertical_margin']);
4049
+ if (isset ($_POST ['animation'])) $preview_parameters ['animation'] = base64_decode ($_POST ['animation']);
4050
+ if (isset ($_POST ['alignment_css'])) $preview_parameters ['alignment_css'] = base64_decode ($_POST ['alignment_css']);
4051
+ if (isset ($_POST ['custom_css'])) $preview_parameters ['custom_css'] = base64_decode ($_POST ['custom_css']);
4052
+ if (isset ($_POST ['php'])) $preview_parameters ['php'] = $_POST ['php'];
4053
+ if (isset ($_POST ['close'])) $preview_parameters ['close'] = $_POST ['close'];
4054
+ if (isset ($_POST ['label'])) $preview_parameters ['label'] = $_POST ['label'];
4055
+ if (isset ($_POST ['read_only'])) $preview_parameters ['read_only'] = $_POST ['read_only'];
4056
+
4057
+ generate_code_preview (
4058
+ $block,
4059
+ $preview_parameters
4060
+ );
4061
+ }
4062
+ elseif ($block == 'adb') {
4063
+ require_once AD_INSERTER_PLUGIN_DIR.'includes/preview-adb.php';
4064
+ generate_code_preview_adb (base64_decode ($_POST ["code"]), $_POST ["php"] == 1);
4065
+ }
4066
+ elseif ($block == 'adsense') {
4067
+
4068
+ if (defined ('AI_ADSENSE_API')) {
4069
+ require_once AD_INSERTER_PLUGIN_DIR.'includes/preview.php';
4070
+ require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php';
4071
+
4072
+ if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) {
4073
+
4074
+ $adsense = new adsense_api();
4075
+
4076
+ $adsense_code = $adsense->getAdCode (base64_decode ($_POST ["slot_id"]));
4077
+ $adsense_error = $adsense->getError ();
4078
+
4079
+ $preview_parameters = array (
4080
+ "name" => isset ($_POST ["name"]) ? base64_decode ($_POST ["name"]) : 'ADSENSE CODE',
4081
+ "alignment" => '',
4082
+ "horizontal" => '',
4083
+ "vertical" => '',
4084
+ "alignment_css" => '',
4085
+ "custom_css" => '',
4086
+ "code" => $adsense_error == '' ? $adsense_code : '<div style="color: red;">'.$adsense_error.'</div>',
4087
+ "php" => false,
4088
+ "label" => false,
4089
+ "close" => AI_CLOSE_NONE,
4090
+ "read_only" => true,
4091
+ );
4092
+
4093
+ generate_code_preview (
4094
+ 0, // Default settings
4095
+ $preview_parameters
4096
+ );
4097
+
4098
+ }
4099
+ }
4100
+ }
4101
+ }
4102
+
4103
+ elseif (isset ($_POST ["edit"])) {
4104
+ if (is_numeric ($_POST ["edit"]) && $_POST ["edit"] >= 1 && $_POST ["edit"] <= AD_INSERTER_BLOCKS) {
4105
+ require_once AD_INSERTER_PLUGIN_DIR.'includes/editor.php';
4106
+ generate_code_editor ($_POST ["edit"], base64_decode ($_POST ["code"]), $_POST ["php"] == 1);
4107
+ }
4108
+ }
4109
+
4110
+ if (isset ($_POST ["placeholder"])) {
4111
+ $block = urldecode ($_POST ["block"]);
4112
+ if (is_numeric ($block) && $block >= 1 && $block <= AD_INSERTER_BLOCKS) {
4113
+ require_once AD_INSERTER_PLUGIN_DIR.'includes/placeholders.php';
4114
+
4115
+ generate_placeholder_editor (str_replace (array ('"', "\\'"), array ('&quot', '&#039'), urldecode ($_POST ["placeholder"])), $block);
4116
+ }
4117
+ }
4118
+
4119
+ elseif (isset ($_POST ["generate-code"])) {
4120
+ $code_generator = new ai_code_generator ();
4121
+
4122
+ echo json_encode ($code_generator->generate ($_POST));
4123
+ }
4124
+
4125
+ elseif (isset ($_POST ["import-code"])) {
4126
+ $code_generator = new ai_code_generator ();
4127
+
4128
+ echo json_encode ($code_generator->import (base64_decode ($_POST ["import-code"])));
4129
+ }
4130
+
4131
+ elseif (isset ($_POST ["import-rotation-code"])) {
4132
+ $code_generator = new ai_code_generator ();
4133
+
4134
+ echo json_encode ($code_generator->import_rotation (base64_decode ($_POST ["import-rotation-code"])));
4135
+ }
4136
+
4137
+ elseif (isset ($_POST ["generate-rotation-code"])) {
4138
+ $code_generator = new ai_code_generator ();
4139
+
4140
+ echo json_encode ($code_generator->generate_rotation (json_decode (base64_decode ($_POST ['generate-rotation-code']), true)));
4141
+ }
4142
+
4143
+ elseif (isset ($_GET ["image"])) {
4144
+ header ("Content-Type: image/png");
4145
+ header ("Content-Length: " . filesize (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]));
4146
+ readfile (AD_INSERTER_PLUGIN_DIR.'images/'.$_GET ["image"]);
4147
+ }
4148
+
4149
+ elseif (isset ($_GET ["rating"])) {
4150
+ $cache_time = $_GET ["rating"] == 'update' ? 0 * 60 : AI_TRANSIENT_RATING_EXPIRATION;
4151
+ if (!get_transient (AI_TRANSIENT_RATING) || !($transient_timeout = get_option ('_transient_timeout_' . AI_TRANSIENT_RATING)) || AI_TRANSIENT_RATING_EXPIRATION - ($transient_timeout - time ()) > $cache_time) {
4152
+ $args = (object) array ('slug' => 'ad-inserter');
4153
+ $request = array ('action' => 'plugin_information', 'timeout' => 5, 'request' => serialize ($args));
4154
+ $url = 'http://api.wordpress.org/plugins/info/1.0/';
4155
+ $response = wp_remote_post ($url, array ('body' => $request));
4156
+ $plugin_info = @unserialize ($response ['body']);
4157
+ if (isset ($plugin_info->ratings)) {
4158
+ $total_rating = 0;
4159
+ $total_count = 0;
4160
+ foreach ($plugin_info->ratings as $rating => $count) {
4161
+ $total_rating += $rating * $count;
4162
+ $total_count += $count;
4163
+ }
4164
+ $rating = number_format ($total_rating / $total_count, 4);
4165
+ set_transient (AI_TRANSIENT_RATING, $rating, AI_TRANSIENT_RATING_EXPIRATION);
4166
+ }
4167
+ }
4168
+ if ($rating = get_transient (AI_TRANSIENT_RATING)) {
4169
+ if ($rating > 1 && $rating <= 5) echo $rating;
4170
+ }
4171
+ }
4172
+
4173
+ elseif (isset ($_POST ["notice"])) {
4174
+ update_option ('ai-notice-' . $_POST ["notice"], $_POST ["click"]);
4175
+ }
4176
+
4177
+ elseif (isset ($_POST ["notice-check"])) {
4178
+ echo $_POST ["notice-check"];
4179
+ }
4180
+
4181
+ elseif (isset ($_GET ["list"])) {
4182
+ code_block_list ();
4183
+ }
4184
+
4185
+ elseif (isset ($_GET ["adsense-list"])) {
4186
+ if (defined ('AI_ADSENSE_API')) {
4187
+ adsense_list ();
4188
+ }
4189
+ }
4190
+
4191
+ elseif (isset ($_GET ["adsense-code"])) {
4192
+ if (defined ('AI_ADSENSE_API')) {
4193
+ ai_adsense_code ($_GET ["adsense-code"]);
4194
+ }
4195
+ }
4196
+
4197
+ elseif (isset ($_GET ["adsense-authorization-code"])) {
4198
+ if (defined ('AI_ADSENSE_API')) {
4199
+ if ($_GET ['adsense-authorization-code'] == '') {
4200
+ delete_option (AI_ADSENSE_CLIENT_IDS);
4201
+ delete_option (AI_ADSENSE_AUTH_CODE);
4202
+
4203
+ delete_transient (AI_TRANSIENT_ADSENSE_TOKEN);
4204
+ delete_transient (AI_TRANSIENT_ADSENSE_ADS);
4205
+ } else update_option (AI_ADSENSE_AUTH_CODE, base64_decode ($_GET ['adsense-authorization-code']));
4206
+ }
4207
+ }
4208
+
4209
+ elseif (isset ($_GET ["adsense-client-id"])) {
4210
+ if (defined ('AI_ADSENSE_API')) {
4211
+ if ($_GET ['adsense-client-id'] == '') {
4212
+ delete_option (AI_ADSENSE_CLIENT_IDS);
4213
+ delete_option (AI_ADSENSE_AUTH_CODE);
4214
+
4215
+ delete_transient (AI_TRANSIENT_ADSENSE_TOKEN);
4216
+ delete_transient (AI_TRANSIENT_ADSENSE_ADS);
4217
+ } else update_option (AI_ADSENSE_CLIENT_IDS, array ('ID' => base64_decode ($_GET ['adsense-client-id']), 'SECRET' => base64_decode ($_GET ['adsense-client-secret'])));
4218
+ }
4219
+ }
4220
+
4221
+ elseif (isset ($_GET ["settings"])) {
4222
+ generate_settings_form ();
4223
+ }
4224
+
4225
+ elseif (isset ($_GET ["list-options"])) {
4226
+ generate_list_options ($_GET ["list-options"]);
4227
+ }
4228
+
4229
+ elseif (isset ($_GET ["update"])) {
4230
+ if ($_GET ["update"] == 'block-code-demo') {
4231
+ ai_block_code_demo (urldecode ($_GET ["block_class_name"]), $_GET ["block_class"], $_GET ["block_number_class"], $_GET ["inline_styles"]);
4232
+ }
4233
+ elseif (function_exists ('ai_ajax_backend_2')) {
4234
+ ai_ajax_backend_2 ();
4235
+ }
4236
+ }
4237
+
4238
+ elseif (function_exists ('ai_ajax_backend_2')) {
4239
+ ai_ajax_backend_2 ();
4240
+ }
4241
+
4242
+ wp_die ();
4243
+ }
4244
+
4245
+ function ai_generate_extract (&$settings) {
4246
+ global $ai_custom_hooks;
4247
+
4248
+ if (!defined ('AI_GENERATE_EXTRACT'))
4249
+ define ('AI_GENERATE_EXTRACT', true);
4250
+
4251
+ $obj = new ai_Block (1);
4252
+
4253
+ $extract = array ();
4254
+
4255
+ if (defined ('AI_BUFFERING')) {
4256
+ $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());
4257
+ $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());
4258
+ }
4259
+
4260
+ $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());
4261
+ $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());
4262
+ $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());
4263
+ $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());
4264
+ $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());
4265
+ $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());
4266
+ $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());
4267
+ $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());
4268
+ $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());
4269
+ $custom_hook_blocks = array ();
4270
+ for ($custom_hook = 1; $custom_hook <= AD_INSERTER_HOOKS; $custom_hook ++) {
4271
+ $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());
4272
+ }
4273
+
4274
+ // Get blocks used in sidebar widgets
4275
+ $sidebar_widgets = wp_get_sidebars_widgets();
4276
+ $widget_options = get_option ('widget_ai_widget');
4277
+
4278
+ $widget_blocks = array ();
4279
+ foreach ($sidebar_widgets as $sidebar_index => $sidebar_widget) {
4280
+ if (is_array ($sidebar_widget) && isset ($GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'])) {
4281
+ $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'];
4282
+ if ($sidebar_name != "") {
4283
+ foreach ($sidebar_widget as $widget) {
4284
+ if (preg_match ("/ai_widget-([\d]+)/", $widget, $widget_id)) {
4285
+ if (isset ($widget_id [1]) && is_numeric ($widget_id [1])) {
4286
+ $widget_option = $widget_options [$widget_id [1]];
4287
+ $widget_block = $widget_option ['block'];
4288
+ if ($widget_block >= 1 && $widget_block <= AD_INSERTER_BLOCKS) {
4289
+ $widget_blocks [] = $widget_block;
4290
+ }
4291
+ }
4292
+ }
4293
+ }
4294
+ }
4295
+ }
4296
+ }
4297
+ $widget_blocks = array_unique ($widget_blocks);
4298
+
4299
+ // Generate extracted data
4300
+ $active_blocks = array ();
4301
+ for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
4302
+
4303
+ if (!isset ($settings [$block])) continue;
4304
+
4305
+ $obj->number = $block;
4306
+ $obj->wp_options = $settings [$block];
4307
+
4308
+ $page_types = array ();
4309
+ if ($obj->get_display_settings_home()) $page_types []= AI_PT_HOMEPAGE;
4310
+ if ($obj->get_display_settings_page()) $page_types []= AI_PT_STATIC;
4311
+ if ($obj->get_display_settings_post()) $page_types []= AI_PT_POST;
4312
+ if ($obj->get_display_settings_category()) $page_types []= AI_PT_CATEGORY;
4313
+ if ($obj->get_display_settings_search()) $page_types []= AI_PT_SEARCH;
4314
+ if ($obj->get_display_settings_archive()) $page_types []= AI_PT_ARCHIVE;
4315
+ if ($obj->get_enable_ajax()) $page_types []= AI_PT_AJAX;
4316
+ if ($obj->get_enable_feed()) $page_types []= AI_PT_FEED;
4317
+ if ($obj->get_enable_404()) $page_types []= AI_PT_404;
4318
+
4319
+ $automatic_insertion = $obj->get_automatic_insertion();
4320
+
4321
+ if ($page_types) {
4322
+
4323
+ // Change insertion position to actual server-side insertion position
4324
+ switch ($automatic_insertion) {
4325
+ case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT:
4326
+ case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
4327
+ switch ($obj->get_html_element_insertion ()) {
4328
+ case AI_HTML_INSERTION_SEREVR_SIDE:
4329
+ $automatic_insertion = AI_AUTOMATIC_INSERTION_OUTPUT_BUFFERING;
4330
+ break;
4331
+ default:
4332
+ $automatic_insertion = $obj->get_server_side_insertion ();
4333
+ break;
4334
+ }
4335
+ break;
4336
+ }
4337
+
4338
+ switch ($automatic_insertion) {
4339
+ case AI_AUTOMATIC_INSERTION_ABOVE_HEADER:
4340
+ if (defined ('AI_BUFFERING')) {
4341
+ foreach ($page_types as $block_page_type) $above_header_hook_blocks [$block_page_type][]= $block;
4342
+ $above_header_hook_blocks [AI_PT_ANY][]= $block;
4343
+ }
4344
+ break;
4345
+ case AI_AUTOMATIC_INSERTION_OUTPUT_BUFFERING:
4346
+ if (defined ('AI_BUFFERING')) {
4347
+ foreach ($page_types as $block_page_type) $html_element_hook_blocks [$block_page_type][]= $block;
4348
+ $html_element_hook_blocks [AI_PT_ANY][]= $block;
4349
+ }
4350
+ break;
4351
+ case AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH:
4352
+ case AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH:
4353
+ case AI_AUTOMATIC_INSERTION_BEFORE_CONTENT:
4354
+ case AI_AUTOMATIC_INSERTION_AFTER_CONTENT:
4355
+ foreach ($page_types as $block_page_type) $content_hook_blocks [$block_page_type][]= $block;
4356
+ $content_hook_blocks [AI_PT_ANY][]= $block;
4357
+ break;
4358
+ case AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT:
4359
+ case AI_AUTOMATIC_INSERTION_AFTER_EXCERPT:
4360
+ foreach ($page_types as $block_page_type) $excerpt_hook_blocks [$block_page_type][]= $block;
4361
+ $excerpt_hook_blocks [AI_PT_ANY][]= $block;
4362
+ break;
4363
+ case AI_AUTOMATIC_INSERTION_BEFORE_POST:
4364
+ foreach ($page_types as $block_page_type) $loop_start_hook_blocks [$block_page_type][]= $block;
4365
+ $loop_start_hook_blocks [AI_PT_ANY][]= $block;
4366
+ break;
4367
+ case AI_AUTOMATIC_INSERTION_AFTER_POST:
4368
+ foreach ($page_types as $block_page_type) $loop_end_hook_blocks [$block_page_type][]= $block;
4369
+ $loop_end_hook_blocks [AI_PT_ANY][]= $block;
4370
+ break;
4371
+ case AI_AUTOMATIC_INSERTION_BETWEEN_POSTS:
4372
+ foreach ($page_types as $block_page_type) $post_hook_blocks [$block_page_type][]= $block;
4373
+ $post_hook_blocks [AI_PT_ANY][]= $block;
4374
+ break;
4375
+ case AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS:
4376
+ foreach ($page_types as $block_page_type) $before_comments_hook_blocks [$block_page_type][]= $block;
4377
+ $before_comments_hook_blocks [AI_PT_ANY][]= $block;
4378
+ break;
4379
+ case AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS:
4380
+ foreach ($page_types as $block_page_type) $between_comments_hook_blocks [$block_page_type][]= $block;
4381
+ $between_comments_hook_blocks [AI_PT_ANY][]= $block;
4382
+ break;
4383
+ case AI_AUTOMATIC_INSERTION_AFTER_COMMENTS:
4384
+ foreach ($page_types as $block_page_type) $after_comments_hook_blocks [$block_page_type][]= $block;
4385
+ $after_comments_hook_blocks [AI_PT_ANY][]= $block;
4386
+ break;
4387
+ case AI_AUTOMATIC_INSERTION_FOOTER:
4388
+ foreach ($page_types as $block_page_type) $footer_hook_blocks [$block_page_type][]= $block;
4389
+ $footer_hook_blocks [AI_PT_ANY][]= $block;
4390
+ break;
4391
+ default:
4392
+ if ($automatic_insertion >= AI_AUTOMATIC_INSERTION_CUSTOM_HOOK && $automatic_insertion < AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + AD_INSERTER_HOOKS) {
4393
+ $hook_index = $automatic_insertion - AI_AUTOMATIC_INSERTION_CUSTOM_HOOK;
4394
+ foreach ($page_types as $block_page_type) $custom_hook_blocks [$hook_index][$block_page_type][]= $block;
4395
+ $custom_hook_blocks [$hook_index][AI_PT_ANY][]= $block;
4396
+ }
4397
+ break;
4398
+ }
4399
+ }
4400
+
4401
+ $automatic = $automatic_insertion != AI_AUTOMATIC_INSERTION_DISABLED;
4402
+ $manual_widget = $obj->get_enable_widget() == AI_ENABLED;
4403
+ $manual_shortcode = $obj->get_enable_manual() == AI_ENABLED;
4404
+ $manual_php_function = $obj->get_enable_php_call() == AI_ENABLED;
4405
+ if ($automatic || ($manual_widget && in_array ($block, $widget_blocks)) || $manual_shortcode || $manual_php_function) {
4406
+ $active_blocks []= $block;
4407
+ }
4408
+ }
4409
+
4410
+ $extract [AI_EXTRACT_USED_BLOCKS] = serialize ($active_blocks);
4411
+
4412
+
4413
+ if (defined ('AI_BUFFERING')) {
4414
+ $extract [ABOVE_HEADER_HOOK_BLOCKS] = $above_header_hook_blocks;
4415
+ $extract [HTML_ELEMENT_HOOK_BLOCKS] = $html_element_hook_blocks;
4416
+ }
4417
+ $extract [CONTENT_HOOK_BLOCKS] = $content_hook_blocks;
4418
+ $extract [EXCERPT_HOOK_BLOCKS] = $excerpt_hook_blocks;
4419
+ $extract [LOOP_START_HOOK_BLOCKS] = $loop_start_hook_blocks;
4420
+ $extract [LOOP_END_HOOK_BLOCKS] = $loop_end_hook_blocks;
4421
+ $extract [POST_HOOK_BLOCKS] = $post_hook_blocks;
4422
+ $extract [BEFORE_COMMENTS_HOOK_BLOCKS] = $before_comments_hook_blocks;
4423
+ $extract [BETWEEN_COMMENTS_HOOK_BLOCKS] = $between_comments_hook_blocks;
4424
+ $extract [AFTER_COMMENTS_HOOK_BLOCKS] = $after_comments_hook_blocks;
4425
+ $extract [FOOTER_HOOK_BLOCKS] = $footer_hook_blocks;
4426
+
4427
+ for ($custom_hook = 1; $custom_hook <= AD_INSERTER_HOOKS; $custom_hook ++) {
4428
+ $action = get_hook_action ($custom_hook);
4429
+
4430
+ if (get_hook_enabled ($custom_hook) && get_hook_name ($custom_hook) != '' && $action != '') {
4431
+
4432
+ $custom_hook_extract_index = $action . CUSTOM_HOOK_BLOCKS;
4433
+
4434
+ if (isset ($extract [$custom_hook_extract_index])) {
4435
+ // Custom hook on WP hook used by the plugin - merge blocks
4436
+ foreach ($extract [$custom_hook_extract_index] as $page_type => $blocks) {
4437
+ $extract [$custom_hook_extract_index][$page_type] = array_merge ($blocks, $custom_hook_blocks [$custom_hook - 1][$page_type]);
4438
+ }
4439
+ } else $extract [$custom_hook_extract_index] = $custom_hook_blocks [$custom_hook - 1];
4440
+
4441
+ }
4442
+ }
4443
+
4444
+ return ($extract);
4445
+ }
4446
+
4447
+ function ai_load_settings () {
4448
+ global $ai_db_options, $block_object, $ai_wp_data, $version_string, $ai_custom_hooks;
4449
+ // global $ai_db_options_extract;
4450
+
4451
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS START");
4452
+
4453
+ ai_load_options ();
4454
+
4455
+ $ai_custom_hooks = array ();
4456
+ for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
4457
+ $name = get_hook_name ($hook);
4458
+ $action = get_hook_action ($hook);
4459
+
4460
+ if (get_hook_enabled ($hook) && $name != '' && $action != '') {
4461
+ $ai_custom_hooks [] = array ('index' => $hook, 'name' => $name, 'action' => $action, 'priority' => get_hook_priority ($hook));
4462
+ }
4463
+ }
4464
+
4465
+ // Sidebars and widgets not loaded yet - moved to ai_wp_loaded_hook
4466
+ // if (isset ($ai_db_options [AI_OPTION_EXTRACT]) &&
4467
+ // isset ($ai_db_options [AI_OPTION_GLOBAL]['VERSION']) && $ai_db_options [AI_OPTION_GLOBAL]['VERSION'] == $version_string &&
4468
+ // isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS]) &&
4469
+ // isset ($ai_db_options [AI_OPTION_EXTRACT][POST_HOOK_BLOCKS][AI_PT_AJAX]) &&
4470
+ // isset ($ai_db_options [AI_OPTION_EXTRACT][BETWEEN_COMMENTS_HOOK_BLOCKS]) &&
4471
+ // isset ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) &&
4472
+ // @unserialize ($ai_db_options [AI_OPTION_EXTRACT][AI_EXTRACT_USED_BLOCKS]) !== false &&
4473
+ // isset ($ai_db_options [AI_OPTION_EXTRACT][FOOTER_HOOK_BLOCKS]))
4474
+ // $ai_db_options_extract = $ai_db_options [AI_OPTION_EXTRACT]; else
4475
+ // $ai_db_options_extract = ai_generate_extract ($ai_db_options);
4476
+
4477
+ $obj = new ai_Block (0);
4478
+ $obj->wp_options [AI_OPTION_BLOCK_NAME] = 'Default';
4479
+ $block_object [0] = $obj;
4480
+ for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
4481
+ $obj = new ai_Block ($block);
4482
+ $obj->load_options ($block);
4483
+ $block_object [$block] = $obj;
4484
+
4485
+ if ($obj->get_detection_server_side()) $ai_wp_data [AI_SERVER_SIDE_DETECTION] = true;
4486
+ if ($obj->get_detection_client_side ()) {
4487
+ $ai_wp_data [AI_CLIENT_SIDE_DETECTION] = true;
4488
+
4489
+ if ($obj->get_client_side_action () == AI_CLIENT_SIDE_ACTION_INSERT) {
4490
+ $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = true;
4491
+ }
4492
+ }
4493
+
4494
+ if (function_exists ('ai_load_settings_2')) ai_load_settings_2 ($obj);
4495
+
4496
+ if ($obj->stick_to_the_content_class () != '') $ai_wp_data [AI_STICK_TO_THE_CONTENT] = true;
4497
+
4498
+ switch ($obj->get_automatic_insertion()) {
4499
+ case AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT:
4500
+ case AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT:
4501
+ if ($obj->get_html_element_insertion () != AI_HTML_INSERTION_SEREVR_SIDE) $ai_wp_data [AI_CLIENT_SIDE_INSERTION] = true;
4502
+ break;
4503
+ }
4504
+ }
4505
+
4506
+ $adH = new ai_AdH();
4507
+ $adF = new ai_AdF();
4508
+ $adH->load_options (AI_HEADER_OPTION_NAME);
4509
+ $adF->load_options (AI_FOOTER_OPTION_NAME);
4510
+ $block_object [AI_HEADER_OPTION_NAME] = $adH;
4511
+ $block_object [AI_FOOTER_OPTION_NAME] = $adF;
4512
+
4513
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
4514
+ $adA = new ai_AdA();
4515
+ $adA->load_options (AI_ADB_MESSAGE_OPTION_NAME);
4516
+ $block_object [AI_ADB_MESSAGE_OPTION_NAME] = $adA;
4517
+ $ai_wp_data [AI_ADB_DETECTION] = $adA->get_enable_manual ();
4518
+ }
4519
+
4520
+ if (($install_timestamp = get_option (AI_INSTALL_NAME)) !== false) {
4521
+ $install = new DateTime (date('Y-m-d H:i:s', $install_timestamp));
4522
+ $now = new DateTime (date('Y-m-d H:i:s', time()));
4523
+ if (method_exists ($install, 'diff')) {
4524
+ $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE] = $install->diff ($now);
4525
+ $ai_wp_data [AI_DAYS_SINCE_INSTAL] = $ai_wp_data [AI_INSTALL_TIME_DIFFERENCE]->days;
4526
+ }
4527
+ }
4528
+
4529
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("LOAD SETTINGS END");
4530
+ }
4531
+
4532
+
4533
+ function generate_viewport_css () {
4534
+
4535
+ $viewports = array ();
4536
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
4537
+ $viewport_name = get_viewport_name ($viewport);
4538
+ $viewport_width = get_viewport_width ($viewport);
4539
+ if ($viewport_name != '') {
4540
+ $viewports []= array ('index' => $viewport, 'name' => $viewport_name, 'width' => $viewport_width);
4541
+ }
4542
+ }
4543
+
4544
+ $viewport_styles = '';
4545
+ if (count ($viewports) != 0) {
4546
+ foreach ($viewports as $index => $viewport) {
4547
+ if ($viewport ['index'] == 1) {
4548
+ foreach (array_reverse ($viewports) as $index2 => $viewport2) {
4549
+ if ($viewport2 ['index'] != 1) {
4550
+ $viewport_styles .= ".ai-viewport-" . $viewport2 ['index'] . " { display: none !important;}\n";
4551
+ }
4552
+ }
4553
+ $viewport_styles .= ".ai-viewport-1 { display: inherit !important;}\n";
4554
+ $viewport_styles .= ".ai-viewport-0 { display: none !important;}\n";
4555
+ } else {
4556
+ $viewport_styles .= "@media ";
4557
+ if ($index != count ($viewports) - 1)
4558
+ $viewport_styles .= "(min-width: " . $viewport ['width'] . "px) and ";
4559
+ $viewport_styles .= "(max-width: " . ($viewports [$index - 1]['width'] - 1) . "px) {\n";
4560
+ foreach ($viewports as $index2 => $viewport2) {
4561
+ if ($viewport2 ['index'] == 1)
4562
+ $viewport_styles .= ".ai-viewport-" . $viewport2 ['index'] . " { display: none !important;}\n";
4563
+ elseif ($viewport ['index'] == $viewport2 ['index'])
4564
+ $viewport_styles .= ".ai-viewport-" . $viewport2 ['index'] . " { display: inherit !important;}\n";
4565
+
4566
+ }
4567
+ $viewport_styles .= "}\n";
4568
+ }
4569
+ }
4570
+ }
4571
+ return ($viewport_styles);
4572
+ }
4573
+
4574
+ function get_main_alignment_css ($alt_styles_text) {
4575
+ if (strpos ($alt_styles_text, "||") !== false) {
4576
+ $styles = explode ("||", $alt_styles_text);
4577
+ return $styles [0];
4578
+ }
4579
+ return $alt_styles_text;
4580
+ }
4581
+
4582
+ function ai_change_css ($css, $property, $value) {
4583
+ $styles = explode (';', $css);
4584
+ $replaced = false;
4585
+ foreach ($styles as $index => $style) {
4586
+ if (strpos (trim ($style), $property) === 0) {
4587
+ $styles [$index] = preg_replace ('/\:\s*(.+)/', ': ' . $value, $styles [$index]);
4588
+ $replaced = true;
4589
+ break;
4590
+ }
4591
+ }
4592
+
4593
+ $new_style = implode (';', $styles);
4594
+
4595
+ if (!$replaced) {
4596
+ $new_style = rtrim ($new_style, '; ');
4597
+ return $new_style . '; ' . $property . ': ' . $value . ';';
4598
+ }
4599
+
4600
+ return $new_style;
4601
+ }
4602
+
4603
+ function generate_alignment_css () {
4604
+ global $ai_db_options_extract, $block_object;
4605
+
4606
+ $block_class_name = get_block_class_name (true) . '-';
4607
+
4608
+ $styles = array ();
4609
+
4610
+ $styles [AI_ALIGNMENT_DEFAULT] = array (AI_TEXT_DEFAULT, get_main_alignment_css (AI_ALIGNMENT_CSS_DEFAULT));
4611
+ $styles [AI_ALIGNMENT_LEFT] = array (AI_TEXT_LEFT, get_main_alignment_css (AI_ALIGNMENT_CSS_LEFT));
4612
+ $styles [AI_ALIGNMENT_RIGHT] = array (AI_TEXT_RIGHT, get_main_alignment_css (AI_ALIGNMENT_CSS_RIGHT));
4613
+ $styles [AI_ALIGNMENT_CENTER] = array (AI_TEXT_CENTER, get_main_alignment_css (AI_ALIGNMENT_CSS_CENTER));
4614
+ $styles [AI_ALIGNMENT_FLOAT_LEFT] = array (AI_TEXT_FLOAT_LEFT, get_main_alignment_css (AI_ALIGNMENT_CSS_FLOAT_LEFT));
4615
+ $styles [AI_ALIGNMENT_FLOAT_RIGHT] = array (AI_TEXT_FLOAT_RIGHT, get_main_alignment_css (AI_ALIGNMENT_CSS_FLOAT_RIGHT));
4616
+
4617
+ if (function_exists ('generate_alignment_css_2')) $styles = array_replace ($styles, generate_alignment_css_2 ());
4618
+
4619
+ $alignment_css = '';
4620
+ $alignments = array ();
4621
+ $used_blocks = unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]);
4622
+ foreach ($used_blocks as $used_block) {
4623
+ $obj = $block_object [$used_block];
4624
+ $alignment_type = $obj->get_alignment_type ();
4625
+
4626
+ switch ($alignment_type) {
4627
+ case AI_ALIGNMENT_DEFAULT:
4628
+ case AI_ALIGNMENT_LEFT:
4629
+ case AI_ALIGNMENT_RIGHT:
4630
+ case AI_ALIGNMENT_CENTER:
4631
+ case AI_ALIGNMENT_FLOAT_LEFT:
4632
+ case AI_ALIGNMENT_FLOAT_RIGHT:
4633
+ case AI_ALIGNMENT_STICKY_LEFT:
4634
+ case AI_ALIGNMENT_STICKY_RIGHT:
4635
+ case AI_ALIGNMENT_STICKY_TOP:
4636
+ case AI_ALIGNMENT_STICKY_BOTTOM:
4637
+ $alignment_name = strtolower ($styles [$alignment_type][0]);
4638
+ if (in_array ($alignment_name, $alignments)) continue;
4639
+ $alignments []= $alignment_name;
4640
+ $alignment_css .= '.' . $block_class_name . str_replace (' ', '-', $alignment_name) .' {' . $styles [$alignment_type][1] . "}\n";
4641
+ break;
4642
+ case AI_ALIGNMENT_STICKY:
4643
+ $sticky_css = $obj->alignment_style ($alignment_type);
4644
+ $alignment_name = strtolower (md5 ($sticky_css));
4645
+ if (in_array ($alignment_name, $alignments)) continue;
4646
+ $alignments []= $alignment_name;
4647
+ $alignment_css .= '.' . $block_class_name . str_replace (' ', '-', $alignment_name) .' {' . $sticky_css . "}\n";
4648
+ break;
4649
+ case AI_ALIGNMENT_CUSTOM_CSS:
4650
+ $custom_css = $obj->get_custom_css ();
4651
+ $alignment_name = strtolower (md5 ($custom_css));
4652
+ if (in_array ($alignment_name, $alignments)) continue;
4653
+ $alignments []= $alignment_name;
4654
+ $alignment_css .= '.' . $block_class_name . str_replace (' ', '-', $alignment_name) .' {' . str_replace ('&#039;', "'", $custom_css) . "}\n";
4655
+ break;
4656
+ }
4657
+ }
4658
+
4659
+ return $alignment_css;
4660
+ }
4661
+
4662
+ function generate_debug_css () {
4663
+ ?>
4664
+ .ai-debug-tags {font-weight: bold; color: white; padding: 2px;}
4665
+ .ai-debug-positions {clear: both; text-align: center; padding: 10px 0; font-family: arial; font-weight: bold; border: 1px solid blue; color: blue; background: #eef;}
4666
+ .ai-debug-page-type {text-align: center; padding: 10px 0; font-family: arial; font-weight: bold; border: 1px solid green; color: green; background: #efe;}
4667
+ .ai-debug-status {clear: both; text-align: center; padding: 10px 0; font-weight: bold; border: 1px solid red; color: red; background: #fee;}
4668
+ .ai-debug-adb {opacity: 0.85; cursor: pointer;}
4669
+ .ai-debug-widget {margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;}
4670
+ a.ai-debug-left {float: left; font-size: 10px; text-decoration: none; color: transparent; padding: 0px 10px 0 0; box-shadow: none;}
4671
+ a.ai-debug-right {float: right; font-size: 10px; text-decoration: none; color: #88f; padding: 0px 10px 0 0; box-shadow: none;}
4672
+ a.ai-debug-center {text-align: center; font-size: 10px; text-decoration: none; color: white; padding: 0px 10px 0 0; box-shadow: none;}
4673
+ .ai-debug-invisible {display: none;}
4674
+ .ai-debug-content-hook-positions {color: blue;}
4675
+ .ai-debug-removed-html-tags {color: red;}
4676
+ .ai-debug-rnrn {background: #0ff; color: #000;}
4677
+ .ai-debug-p {background: #0a0;}
4678
+ .ai-debug-div {background: #46f;}
4679
+ .ai-debug-h {background: #d4e;}
4680
+ .ai-debug-img {background: #ee0; color: #000;}
4681
+ .ai-debug-pre {background: #222;}
4682
+ .ai-debug-special {background: #fb0; color: #000;}
4683
+
4684
+ .ai-debug-ad-overlay {position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: #8f8; opacity: 0.6; z-index': '999999990}
4685
+ .ai-auto-ads {background-color: #84f;}
4686
+ .ai-no-slot {background-color: #48f;}
4687
+ .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;}
4688
+ .ai-info {display: inline-block; padding: 2px 4px;}
4689
+ .ai-info-1 {background: #000; color: #fff;}
4690
+ .ai-info-2 {background: #fff; color: #000;}
4691
+
4692
+ section.ai-debug-block {padding: 0; margin: 0;
4693
+ }
4694
+ .ai-debug-code {margin: 0; padding: 0; border: 0; font-family: monospace; font-size: 12px; line-height: 13px; background: #fff; color: #000;}
4695
+
4696
+ .ai-debug-block {border: 1px solid;}
4697
+
4698
+ .ai-debug-block.ai-debug-default {border-color: #e00;}
4699
+ .ai-debug-bar.ai-debug-default {background: #e00;}
4700
+
4701
+ .ai-debug-block.ai-debug-viewport-invisible { border-color: #00f;}
4702
+ .ai-debug-bar.ai-debug-viewport-invisible {background: #00f;}
4703
+
4704
+ .ai-debug-block.ai-debug-amp {border-color: #0c0;}
4705
+ .ai-debug-bar.ai-debug-amp {background: #0c0;}
4706
+
4707
+ .ai-debug-block.ai-debug-normal {border-color: #222;}
4708
+ .ai-debug-bar.ai-debug-normal {background: #222;}
4709
+
4710
+ .ai-debug-block.ai-debug-fallback {border-color: #a0f;}
4711
+ .ai-debug-bar.ai-debug-fallback {background: #a0f;}
4712
+
4713
+ .ai-debug-block.ai-debug-script {border-color: #00bae6;}
4714
+ .ai-debug-bar.ai-debug-script {background: #00bae6;}
4715
+
4716
+ .ai-debug-block.ai-debug-adb-status {border-color: #000;}
4717
+ .ai-debug-bar.ai-debug-adb-status {background: #000;}
4718
+
4719
+ .ai-debug-block.ai-debug-adsense {border-color: #e0a;}
4720
+ .ai-debug-bar.ai-debug-adsense {background: #e0a;}
4721
+
4722
+ .ai-debug-adb-status.on {color: #f00;}
4723
+ .ai-debug-adb-status.off {color: #0f0;}
4724
+
4725
+ .ai-debug-block.ai-debug-ip {border-color: #00c5be;}
4726
+ .ai-debug-bar.ai-debug-ip {background: #00c5be;}
4727
+
4728
+ .ai-debug-adb-hidden {visibility: hidden; display: none;}
4729
+ .ai-debug-adb-center {text-align: center; font-weight: bold; margin: 0; padding: 4px 0;}
4730
+
4731
+ .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;}
4732
+
4733
+ .ai-debug-bar .ai-debug-text-left {float: left;}
4734
+ .ai-debug-bar .ai-debug-text-right {float: right; padding-right: 3px;}
4735
+ .ai-debug-bar .ai-debug-text-center {text-align: center;}
4736
+
4737
+ .ai-debug-message {text-align: center; font-weight: bold;}
4738
+
4739
+ .ai-debug-bar kbd {padding: 0; color: #fff; font-size: inherit; font-family: arial; background-color: transparent; box-shadow: none;}
4740
+
4741
+ <?php
4742
+ }
4743
+
4744
+ function ai_settings () {
4745
+ global $ai_db_options, $block_object, $wpdb, $ai_db_options_extract;
4746
+
4747
+ if (isset ($_POST [AI_FORM_SAVE])) {
4748
+
4749
+ // echo count ($_POST);
4750
+ // print_r ($_POST);
4751
+
4752
+ check_admin_referer ('save_adinserter_settings');
4753
+
4754
+ $subpage = 'main';
4755
+ $start = 1;
4756
+ $end = 16;
4757
+ if (function_exists ('ai_settings_parameters')) ai_settings_parameters ($subpage, $start, $end);
4758
+
4759
+ $invalid_blocks = array ();
4760
+
4761
+ $import_switch_name = AI_OPTION_IMPORT . WP_FORM_FIELD_POSTFIX . '0';
4762
+ if (isset ($_POST [$import_switch_name]) && $_POST [$import_switch_name] == "1") {
4763
+ // Import Ad Inserter settings
4764
+ $ai_options = @unserialize (base64_decode (str_replace (array ("\\\""), array ("\""), $_POST ["export_settings_0"])));
4765
+
4766
+ if ($ai_options === false) {
4767
+ // Use saved settings
4768
+ $ai_options = wp_slash ($ai_db_options);
4769
+ $invalid_blocks []= 0;
4770
+ } else $ai_options = wp_slash ($ai_options);
4771
+ } else {
4772
+ // Try to import individual settings
4773
+ $ai_options = array ();
4774
+
4775
+ $default_block = new ai_Block (1);
4776
+ for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
4777
+ // ###
4778
+ // $default_block = new ai_Block ($block);
4779
+
4780
+ if (isset ($ai_db_options [$block])) $saved_settings = wp_slash ($ai_db_options [$block]); else
4781
+ // ###
4782
+ // $saved_settings = wp_slash ($default_block->wp_options);
4783
+ $saved_settings = array ();
4784
+
4785
+ if ($block < $start || $block > $end) {
4786
+ // Block not on the settings page
4787
+ $ai_options [$block] = $saved_settings;
4788
+ continue;
4789
+ }
4790
+
4791
+ $import_switch_name = AI_OPTION_IMPORT . WP_FORM_FIELD_POSTFIX . $block;
4792
+ $import_name_switch_name = AI_OPTION_IMPORT_NAME . WP_FORM_FIELD_POSTFIX . $block;
4793
+ if (isset ($_POST [$import_switch_name]) && $_POST [$import_switch_name] == "1") {
4794
+
4795
+ // Try to import block settings
4796
+ $exported_settings = @unserialize (base64_decode (str_replace (array ("\\\""), array ("\""), $_POST ["export_settings_" . $block])));
4797
+
4798
+ if ($exported_settings !== false) {
4799
+ $exported_settings = wp_slash ($exported_settings);
4800
+ foreach (array_keys ($default_block->wp_options) as $key){
4801
+ if ($key == AI_OPTION_BLOCK_NAME && isset ($_POST [$import_name_switch_name]) && $_POST [$import_name_switch_name] != "1") {
4802
+ $form_field_name = $key . WP_FORM_FIELD_POSTFIX . $block;
4803
+ if (isset ($_POST [$form_field_name])){
4804
+ // ###
4805
+ // $default_block->wp_options [$key] = filter_option ($key, $_POST [$form_field_name]);
4806
+
4807
+ // Save only non-default settings
4808
+ $ai_options [$block][$key] = filter_option ($key, $_POST [$form_field_name]);
4809
+ }
4810
+ } else {
4811
+ if (isset ($exported_settings [$key])) {
4812
+ // ###
4813
+ // $default_block->wp_options [$key] = filter_option ($key, $exported_settings [$key], false);
4814
+
4815
+ $ai_options [$block][$key] = filter_option ($key, $exported_settings [$key], false);
4816
+ }
4817
+ }
4818
+ }
4819
+ } else {
4820
+ // Block import failed - use existing settings
4821
+ $default_block->wp_options = $saved_settings;
4822
+ $invalid_blocks []= $block;
4823
+ }
4824
+ } else {
4825
+ // Process block settings
4826
+ foreach (array_keys ($default_block->wp_options) as $key){
4827
+ $form_field_name = $key . WP_FORM_FIELD_POSTFIX . $block;
4828
+ if (isset ($_POST [$form_field_name])){
4829
+
4830
+ // ### Store non-default settings
4831
+ // $default_block->wp_options [$key] = filter_option ($key, $_POST [$form_field_name]);
4832
+
4833
+ // Save only non-default settings
4834
+ $ai_options [$block][$key] = filter_option ($key, $_POST [$form_field_name]);
4835
+ }
4836
+ }
4837
+ }
4838
+
4839
+ // ### Copy complete block settings
4840
+ // $ai_options [$block] = $default_block->wp_options;
4841
+
4842
+ delete_option (str_replace ("#", $block, AD_ADx_OPTIONS));
4843
+ }
4844
+
4845
+ $default_block_H = new ai_AdH();
4846
+ $wp_options = array ();
4847
+ foreach(array_keys ($default_block_H->wp_options) as $key){
4848
+ $form_field_name = $key . WP_FORM_FIELD_POSTFIX . AI_HEADER_OPTION_NAME;
4849
+ if(isset ($_POST [$form_field_name])){
4850
+ // ###
4851
+ // $default_block_H->wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4852
+ $wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4853
+ }
4854
+ }
4855
+ // ###
4856
+ // $ai_options [AI_HEADER_OPTION_NAME] = $default_block_H->wp_options;
4857
+ $ai_options [AI_HEADER_OPTION_NAME] = $wp_options;
4858
+
4859
+ $default_block_F = new ai_AdF();
4860
+ $wp_options = array ();
4861
+ foreach(array_keys($default_block_F->wp_options) as $key){
4862
+ $form_field_name = $key . WP_FORM_FIELD_POSTFIX . AI_FOOTER_OPTION_NAME;
4863
+ if(isset ($_POST [$form_field_name])){
4864
+ // ###
4865
+ // $default_block_F->wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4866
+ $wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4867
+ }
4868
+ }
4869
+ // $ai_options [AI_FOOTER_OPTION_NAME] = $default_block_F->wp_options;
4870
+ $ai_options [AI_FOOTER_OPTION_NAME] = $wp_options;
4871
+
4872
+ if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
4873
+ $default_block_A = new ai_AdA();
4874
+ $wp_options = array ();
4875
+ foreach(array_keys($default_block_A->wp_options) as $key){
4876
+ $form_field_name = $key . WP_FORM_FIELD_POSTFIX . AI_ADB_MESSAGE_OPTION_NAME;
4877
+ if(isset ($_POST [$form_field_name])){
4878
+ // ###
4879
+ // $default_block_A->wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4880
+ $wp_options [$key] = filter_option_hf ($key, $_POST [$form_field_name]);
4881
+ }
4882
+ }
4883
+ // ###
4884
+ // $ai_options [AI_ADB_MESSAGE_OPTION_NAME] = $default_block_A->wp_options;
4885
+ $ai_options [AI_ADB_MESSAGE_OPTION_NAME] = $wp_options;
4886
+ }
4887
+
4888
+ $options = array ();
4889
+
4890
+ if (function_exists ('ai_filter_global_settings')) ai_filter_global_settings ($options);
4891
+
4892
+ if (isset ($_POST ['syntax-highlighter-theme'])) $options ['SYNTAX_HIGHLIGHTER_THEME'] = filter_string ($_POST ['syntax-highlighter-theme']);
4893
+ if (isset ($_POST ['block-class-name'])) $options ['BLOCK_CLASS_NAME'] = filter_html_class ($_POST ['block-class-name']);
4894
+ if (isset ($_POST ['block-class'])) $options ['BLOCK_CLASS'] = filter_option ('BLOCK_CLASS', $_POST ['block-class']);
4895
+ if (isset ($_POST ['block-number-class'])) $options ['BLOCK_NUMBER_CLASS'] = filter_option ('BLOCK_NUMBER_CLASS', $_POST ['block-number-class']);
4896
+ if (isset ($_POST ['inline-styles'])) $options ['INLINE_STYLES'] = filter_option ('INLINE_STYLES', $_POST ['inline-styles']);
4897
+ if (isset ($_POST ['minimum-user-role'])) $options ['MINIMUM_USER_ROLE'] = filter_string ($_POST ['minimum-user-role']);
4898
+ if (isset ($_POST ['sticky-widget-mode'])) $options ['STICKY_WIDGET_MODE'] = filter_option ('STICKY_WIDGET_MODE', $_POST ['sticky-widget-mode']);
4899
+ if (isset ($_POST ['sticky-widget-margin'])) $options ['STICKY_WIDGET_MARGIN'] = filter_option ('STICKY_WIDGET_MARGIN', $_POST ['sticky-widget-margin']);
4900
+ if (isset ($_POST ['plugin_priority'])) $options ['PLUGIN_PRIORITY'] = filter_option ('PLUGIN_PRIORITY', $_POST ['plugin_priority']);
4901
+ if (isset ($_POST ['dynamic_blocks'])) $options ['DYNAMIC_BLOCKS'] = filter_option ('DYNAMIC_BLOCKS', $_POST ['dynamic_blocks']);
4902
+ if (isset ($_POST ['paragraph_counting_functions'])) $options ['PARAGRAPH_COUNTING_FUNCTIONS'] = filter_option ('PARAGRAPH_COUNTING_FUNCTIONS', $_POST ['paragraph_counting_functions']);
4903
+ if (isset ($_POST ['output-buffering'])) $options ['OUTPUT_BUFFERING'] = filter_option ('OUTPUT_BUFFERING', $_POST ['output-buffering']);
4904
+ if (isset ($_POST ['no-paragraph-counting-inside'])) $options ['NO_PARAGRAPH_COUNTING_INSIDE'] = filter_option ('NO_PARAGRAPH_COUNTING_INSIDE', $_POST ['no-paragraph-counting-inside']);
4905
+ if (isset ($_POST ['ad-label'])) $options ['AD_LABEL'] = filter_option ('AD_LABEL', $_POST ['ad-label']);
4906
+ if (isset ($_POST ['main-content-element'])) $options ['MAIN_CONTENT_ELEMENT'] = filter_option ('MAIN_CONTENT_ELEMENT', $_POST ['main-content-element']);
4907
+ if (isset ($_POST [AI_OPTION_ADB_ACTION])) $options ['ADB_ACTION'] = filter_option ('ADB_ACTION', $_POST [AI_OPTION_ADB_ACTION]);
4908
+ if (isset ($_POST [AI_OPTION_ADB_DELAY_ACTION])) $options ['ADB_DELAY_ACTION'] = filter_option ('ADB_DELAY_ACTION', $_POST [AI_OPTION_ADB_DELAY_ACTION]);
4909
+ 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]);
4910
+ if (isset ($_POST [AI_OPTION_ADB_SELECTORS])) $options ['ADB_SELECTORS'] = filter_option ('ADB_SELECTORS', $_POST [AI_OPTION_ADB_SELECTORS]);
4911
+ if (isset ($_POST [AI_OPTION_ADB_REDIRECTION_PAGE])) $options ['ADB_REDIRECTION_PAGE'] = filter_option ('ADB_REDIRECTION_PAGE', $_POST [AI_OPTION_ADB_REDIRECTION_PAGE]);
4912
+ 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]);
4913
+ if (isset ($_POST [AI_OPTION_ADB_MESSAGE_CSS])) $options ['ADB_MESSAGE_CSS'] = filter_option ('ADB_MESSAGE_CSS', $_POST [AI_OPTION_ADB_MESSAGE_CSS]);
4914
+ if (isset ($_POST [AI_OPTION_ADB_OVERLAY_CSS])) $options ['ADB_OVERLAY_CSS'] = filter_option ('ADB_OVERLAY_CSS', $_POST [AI_OPTION_ADB_OVERLAY_CSS]);
4915
+ if (isset ($_POST [AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE])) $options ['ADB_UNDISMISSIBLE_MESSAGE'] = filter_option ('ADB_UNDISMISSIBLE_MESSAGE', $_POST [AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE]);
4916
+ if (isset ($_POST ['admin_toolbar_debugging'])) $options ['ADMIN_TOOLBAR_DEBUGGING'] = filter_option ('ADMIN_TOOLBAR_DEBUGGING', $_POST ['admin_toolbar_debugging']);
4917
+ if (isset ($_POST ['remote_debugging'])) $options ['REMOTE_DEBUGGING'] = filter_option ('REMOTE_DEBUGGING', $_POST ['remote_debugging']);
4918
+ if (isset ($_POST ['backend_js_debugging'])) $options ['BACKEND_JS_DEBUGGING'] = filter_option ('BACKEND_JS_DEBUGGING', $_POST ['backend_js_debugging']);
4919
+ if (isset ($_POST ['frontend_js_debugging'])) $options ['FRONTEND_JS_DEBUGGING'] = filter_option ('FRONTEND_JS_DEBUGGING', $_POST ['frontend_js_debugging']);
4920
+
4921
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
4922
+ if (isset ($_POST ['viewport-name-'.$viewport])) $options ['VIEWPORT_NAME_'.$viewport] = filter_string ($_POST ['viewport-name-'.$viewport]);
4923
+ if (isset ($_POST ['viewport-width-'.$viewport])) $options ['VIEWPORT_WIDTH_'.$viewport] = filter_option ('viewport_width', $_POST ['viewport-width-'.$viewport]);
4924
+ }
4925
+
4926
+ for ($hook = 1; $hook <= AD_INSERTER_HOOKS; $hook ++) {
4927
+ if (isset ($_POST ['hook-enabled-'.$hook])) $options ['HOOK_ENABLED_'.$hook] = filter_option ('HOOK_ENABLED', $_POST ['hook-enabled-'.$hook]);
4928
+ if (isset ($_POST ['hook-name-'.$hook])) $options ['HOOK_NAME_'.$hook] = filter_string_tags ($_POST ['hook-name-'.$hook]);
4929
+ if (isset ($_POST ['hook-action-'.$hook])) $options ['HOOK_ACTION_'.$hook] = filter_string ($_POST ['hook-action-'.$hook]);
4930
+ if (isset ($_POST ['hook-priority-'.$hook])) $options ['HOOK_PRIORITY_'.$hook] = filter_option ('HOOK_PRIORITY', $_POST ['hook-enabled-'.$hook]);
4931
+ }
4932
+
4933
+ // $options ['VIEWPORT_CSS'] = generate_viewport_css ();
4934
+ // $options ['ALIGNMENT_CSS'] = generate_alignment_css ();
4935
+
4936
+ $ai_options [AI_OPTION_GLOBAL] = ai_check_plugin_options ($options);
4937
+ }
4938
+
4939
+ if (!empty ($invalid_blocks)) {
4940
+ if ($invalid_blocks [0] == 0) {
4941
+ echo "<div class='error' style='margin: 5px 15px 2px 0px; padding: 10px;'>Error importing ", AD_INSERTER_NAME, " settings.</div>";
4942
+ } else echo "<div class='error' style='margin: 5px 15px 2px 0px; padding: 10px;'>Error importing settings for block", count ($invalid_blocks) == 1 ? "" : "s:", " ", implode (", ", $invalid_blocks), ".</div>";
4943
+ }
4944
+
4945
+ // Generate and save extract
4946
+ // Save new options as some function may need new settings
4947
+ update_option (AI_OPTION_NAME, $ai_options);
4948
+ ai_load_settings ();
4949
+
4950
+ $ai_options [AI_OPTION_EXTRACT] = ai_generate_extract ($ai_options);
4951
+ $ai_db_options_extract = $ai_options [AI_OPTION_EXTRACT];
4952
+
4953
+ $ai_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'] = generate_viewport_css ();
4954
+ $ai_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'] = generate_alignment_css ();
4955
+
4956
+ $ai_options [AI_OPTION_GLOBAL]['TIMESTAMP'] = time ();
4957
+
4958
+ if (get_option (AI_INSTALL_NAME) === false) {
4959
+ update_option (AI_INSTALL_NAME, time ());
4960
+ }
4961
+
4962
+ update_option (AI_OPTION_NAME, $ai_options);
4963
+
4964
+ // Multisite
4965
+ if (is_multisite () && is_main_site ()) {
4966
+ $options = array ();
4967
+ if (function_exists ('ai_filter_multisite_settings')) ai_filter_multisite_settings ($options);
4968
+ ai_check_multisite_options ($options);
4969
+ update_site_option (AI_OPTION_NAME, $options);
4970
+ }
4971
+
4972
+ ai_load_settings ();
4973
+
4974
+ if (function_exists ('ai_load_globals')) ai_load_globals ();
4975
+
4976
+ delete_option (str_replace ("#", "Header", AD_ADx_OPTIONS));
4977
+ delete_option (str_replace ("#", "Footer", AD_ADx_OPTIONS));
4978
+ delete_option (AD_OPTIONS);
4979
+
4980
+ echo "<div class='notice notice-success is-dismissible' style='margin: 5px 15px 2px 0px;'><p><strong>Settings saved.</strong></p></div>";
4981
+ } elseif (isset ($_POST [AI_FORM_CLEAR])) {
4982
+
4983
+ check_admin_referer ('save_adinserter_settings');
4984
+
4985
+ for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) {
4986
+ delete_option (str_replace ("#", $block, AD_ADx_OPTIONS));
4987
+ }
4988
+
4989
+ delete_option (str_replace ("#", "Header", AD_ADx_OPTIONS));
4990
+ delete_option (str_replace ("#", "Footer", AD_ADx_OPTIONS));
4991
+ delete_option (AD_OPTIONS);
4992
+
4993
+ delete_option (AI_OPTION_NAME);
4994
+
4995
+ if (is_multisite () && is_main_site ()) {
4996
+ delete_site_option (AI_OPTION_NAME, $options);
4997
+ }
4998
+
4999
+ delete_option (AI_ADSENSE_AUTH_CODE);
5000
+
5001
+ delete_transient (AI_TRANSIENT_ADSENSE_TOKEN);
5002
+ delete_transient (AI_TRANSIENT_ADSENSE_ADS);
5003
+
5004
+ if (function_exists ('ai_load_globals')) {
5005
+ delete_option (WP_AD_INSERTER_PRO_LICENSE);
5006
+ $wpdb->query ("DROP TABLE IF EXISTS " . AI_STATISTICS_DB_TABLE);
5007
+ }
5008
+
5009
+ if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
5010
+
5011
+ $args = array (
5012
+ 'public' => true,
5013
+ '_builtin' => false
5014
+ );
5015
+ $custom_post_types = get_post_types ($args, 'names', 'and');
5016
+ $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types));
5017
+
5018
+ $args = array (
5019
+ 'posts_per_page' => 100,
5020
+ 'offset' => 0,
5021
+ 'category' => '',
5022
+ 'category_name' => '',
5023
+ 'orderby' => 'type',
5024
+ 'order' => 'ASC',
5025
+ 'include' => '',
5026
+ 'exclude' => '',
5027
+ 'meta_key' => '_adinserter_block_exceptions',
5028
+ 'meta_value' => '',
5029
+ 'post_type' => $screens,
5030
+ 'post_mime_type' => '',
5031
+ 'post_parent' => '',
5032
+ 'author' => '',
5033
+ 'author_name' => '',
5034
+ 'post_status' => '',
5035
+ 'suppress_filters' => true
5036
+ );
5037
+ $posts_pages = get_posts ($args);
5038
+
5039
+ foreach ($posts_pages as $page) {
5040
+ delete_post_meta ($page->ID, '_adinserter_block_exceptions');
5041
+ }
5042
+ }
5043
+
5044
+ ai_load_settings ();
5045
+
5046
+ // Generate extract
5047
+ $ai_options [AI_OPTION_EXTRACT] = ai_generate_extract ($ai_options);
5048
+ $ai_db_options_extract = $ai_options [AI_OPTION_EXTRACT];
5049
+
5050
+ if (function_exists ('ai_load_globals')) ai_load_globals ();
5051
+
5052
+ echo "<div class='notice notice-warning is-dismissible' style='margin: 5px 15px 2px 0px;'><p><strong>Settings cleared.</strong></p></div>";
5053
+ } elseif (isset ($_POST [AI_FORM_CLEAR_EXCEPTIONS])) {
5054
+ if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
5055
+
5056
+ $args = array (
5057
+ 'public' => true,
5058
+ '_builtin' => false
5059
+ );
5060
+ $custom_post_types = get_post_types ($args, 'names', 'and');
5061
+ $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types));
5062
+
5063
+ $args = array (
5064
+ 'posts_per_page' => 100,
5065
+ 'offset' => 0,
5066
+ 'category' => '',
5067
+ 'category_name' => '',
5068
+ 'orderby' => 'type',
5069
+ 'order' => 'ASC',
5070
+ 'include' => '',
5071
+ 'exclude' => '',
5072
+ 'meta_key' => '_adinserter_block_exceptions',
5073
+ 'meta_value' => '',
5074
+ 'post_type' => $screens,
5075
+ 'post_mime_type' => '',
5076
+ 'post_parent' => '',
5077
+ 'author' => '',
5078
+ 'author_name' => '',
5079
+ 'post_status' => '',
5080
+ 'suppress_filters' => true
5081
+ );
5082
+ $posts_pages = get_posts ($args);
5083
+
5084
+ if ($_POST [AI_FORM_CLEAR_EXCEPTIONS] == "\xe2\x9d\x8c") {
5085
+ foreach ($posts_pages as $page) {
5086
+ delete_post_meta ($page->ID, '_adinserter_block_exceptions');
5087
+ }
5088
+ }
5089
+ elseif (strpos ($_POST [AI_FORM_CLEAR_EXCEPTIONS], 'id=') === 0) {
5090
+ $id = str_replace ('id=', '', $_POST [AI_FORM_CLEAR_EXCEPTIONS]);
5091
+ if (is_numeric ($id)) {
5092
+ delete_post_meta ($id, '_adinserter_block_exceptions');
5093
+ }
5094
+ }
5095
+ elseif (is_numeric ($_POST [AI_FORM_CLEAR_EXCEPTIONS])) {
5096
+ foreach ($posts_pages as $page) {
5097
+ $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
5098
+ $selected_blocks = explode (",", $post_meta);
5099
+ if (($key = array_search ($_POST [AI_FORM_CLEAR_EXCEPTIONS], $selected_blocks)) !== false) {
5100
+ unset ($selected_blocks [$key]);
5101
+ update_post_meta ($page->ID, '_adinserter_block_exceptions', implode (",", $selected_blocks));
5102
+ }
5103
+ }
5104
+ }
5105
+ }
5106
+ } elseif (isset ($_POST [AI_FORM_CLEAR_STATISTICS]) && is_numeric ($_POST [AI_FORM_CLEAR_STATISTICS])) {
5107
+ if ($_POST [AI_FORM_CLEAR_STATISTICS] != 0) {
5108
+ $wpdb->query ("DELETE FROM " . AI_STATISTICS_DB_TABLE . " WHERE block = " . $_POST [AI_FORM_CLEAR_STATISTICS]);
5109
+ } else $wpdb->query ("DROP TABLE IF EXISTS " . AI_STATISTICS_DB_TABLE);
5110
+ }
5111
+
5112
+ generate_settings_form ();
5113
+ }
5114
+
5115
+
5116
+ function ai_adinserter ($ad_number = '', $ignore = ''){
5117
+ global $block_object, $ad_inserter_globals, $ai_wp_data, $ai_last_check;
5118
+
5119
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5120
+
5121
+ if ($ad_number == "") return "";
5122
+ if (!is_numeric ($ad_number)) return "";
5123
+ $ad_number = (int) $ad_number;
5124
+ if ($ad_number < 1 || $ad_number > AD_INSERTER_BLOCKS) return "";
5125
+
5126
+ $globals_name = AI_PHP_FUNCTION_CALL_COUNTER_NAME . $ad_number;
5127
+
5128
+ if (!isset ($ad_inserter_globals [$globals_name])) {
5129
+ $ad_inserter_globals [$globals_name] = 1;
5130
+ } else $ad_inserter_globals [$globals_name] ++;
5131
+
5132
+ if ($debug_processing) ai_log ("PHP FUNCTION CALL adinserter ($ad_number".($ignore == '' ? '' : (', \''.$ignore.'\'')).") [" . $ad_inserter_globals [$globals_name] . ']');
5133
+
5134
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_PHP_FUNCTION;
5135
+
5136
+ $ignore_array = array ();
5137
+ if (trim ($ignore) != '') {
5138
+ $ignore_array = explode (",", str_replace (" ", "", $ignore));
5139
+ }
5140
+
5141
+ $obj = $block_object [$ad_number];
5142
+ $obj->clear_code_cache ();
5143
+
5144
+ $ai_last_check = AI_CHECK_ENABLED_PHP;
5145
+ if (!$obj->get_enable_php_call ()) return "";
5146
+ if (!$obj->check_server_side_detection ()) return "";
5147
+ if (!$obj->check_page_types_lists_users (in_array ("page-type", $ignore_array))) return "";
5148
+ if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return "";
5149
+ if (!$obj->check_number_of_words ()) return "";
5150
+
5151
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
5152
+ $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
5153
+ $selected_blocks = explode (",", $meta_value);
5154
+
5155
+ if (!$obj->check_post_page_exceptions ($selected_blocks)) return "";
5156
+ }
5157
+
5158
+ // Last check before counter check before insertion
5159
+ $ai_last_check = AI_CHECK_CODE;
5160
+ if ($obj->ai_getCode () == '') return "";
5161
+
5162
+ // Last check before insertion
5163
+ if (!$obj->check_and_increment_block_counter ()) return "";
5164
+
5165
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5166
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) != 0) return "";
5167
+
5168
+ $code = $obj->get_code_for_serverside_insertion ();
5169
+ // Must be after get_code_for_serverside_insertion ()
5170
+ $ai_last_check = AI_CHECK_INSERTED;
5171
+ return $code;
5172
+ }
5173
+
5174
+ function adinserter ($block = '', $ignore = '') {
5175
+ global $ai_last_check, $ai_wp_data, $ai_total_plugin_time;
5176
+
5177
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5178
+ if ($debug_processing) $start_time = microtime (true);
5179
+
5180
+ $ai_last_check = AI_CHECK_NONE;
5181
+ $code = ai_adinserter ($block, $ignore);
5182
+
5183
+ if ($debug_processing) {
5184
+ $ai_total_plugin_time += microtime (true) - $start_time;
5185
+ if ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
5186
+ ai_log ("PHP FUNCTION CALL END\n");
5187
+ }
5188
+
5189
+ return $code;
5190
+ }
5191
+
5192
+
5193
+
5194
+ function ai_content_hook ($content = '') {
5195
+ global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time, $special_element_tags;
5196
+
5197
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
5198
+
5199
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5200
+ $globals_name = AI_CONTENT_COUNTER_NAME;
5201
+
5202
+ $special_element_tags = explode (',', str_replace (' ', '', get_no_paragraph_counting_inside ()));
5203
+
5204
+ if (!isset ($ad_inserter_globals [$globals_name])) {
5205
+ $ad_inserter_globals [$globals_name] = 1;
5206
+ } else $ad_inserter_globals [$globals_name] ++;
5207
+
5208
+ if ($debug_processing) {
5209
+ ai_log ("CONTENT HOOK START [" . $ad_inserter_globals [$globals_name] . ']');
5210
+ $start_time = microtime (true);
5211
+ }
5212
+
5213
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_CONTENT;
5214
+
5215
+ $content_words = number_of_words ($content);
5216
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5217
+
5218
+ $positions_inserted = false;
5219
+ if ($ai_wp_data [AI_WP_DEBUG_BLOCK] == 0) {
5220
+ $preview = $block_object [0];
5221
+ $content = $preview->before_paragraph ($content, true);
5222
+ $content = $preview->after_paragraph ($content, true);
5223
+ $positions_inserted = true;
5224
+ }
5225
+ }
5226
+
5227
+ if ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) {
5228
+ if ($debug_processing) ai_log_content ($content);
5229
+
5230
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
5231
+ $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
5232
+ $selected_blocks = explode (",", $meta_value);
5233
+ } else $selected_blocks = array ();
5234
+
5235
+ $ai_last_check = AI_CHECK_NONE;
5236
+ $current_block = 0;
5237
+
5238
+ if (isset ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5239
+ foreach ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5240
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5241
+
5242
+ if (!isset ($block_object [$block])) continue;
5243
+
5244
+ $ai_last_check = AI_CHECK_NONE;
5245
+ $current_block = $block;
5246
+
5247
+ $obj = $block_object [$block];
5248
+ $obj->clear_code_cache ();
5249
+
5250
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0 && !$positions_inserted && $ai_wp_data [AI_WP_DEBUG_BLOCK] <= $block) {
5251
+ $preview = $block_object [$ai_wp_data [AI_WP_DEBUG_BLOCK]];
5252
+ $content = $preview->before_paragraph ($content, true);
5253
+ $content = $preview->after_paragraph ($content, true);
5254
+ $positions_inserted = true;
5255
+ }
5256
+
5257
+ if (!$obj->check_server_side_detection ()) continue;
5258
+ if (!$obj->check_page_types_lists_users ()) continue;
5259
+ if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
5260
+ if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
5261
+ if (!$obj->check_number_of_words ($content, $content_words)) continue;
5262
+
5263
+ // Deprecated
5264
+ $ai_last_check = AI_CHECK_DISABLED_MANUALLY;
5265
+ if ($obj->display_disabled ($content)) continue;
5266
+
5267
+ // Last check before counter check before insertion
5268
+ $ai_last_check = AI_CHECK_CODE;
5269
+ if ($obj->ai_getCode () == '') continue;
5270
+
5271
+ // Last check before insertion
5272
+ if (!$obj->check_block_counter ()) continue;
5273
+
5274
+ $automatic_insertion = $obj->get_automatic_insertion();
5275
+
5276
+ if ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH) {
5277
+ $ai_last_check = AI_CHECK_PARAGRAPH_COUNTING;
5278
+ $content = $obj->before_paragraph ($content);
5279
+ }
5280
+ elseif ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH) {
5281
+ $ai_last_check = AI_CHECK_PARAGRAPH_COUNTING;
5282
+ $content = $obj->after_paragraph ($content);
5283
+ }
5284
+ elseif ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT) {
5285
+ $obj->increment_block_counter ();
5286
+
5287
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5288
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5289
+ $content = $obj->get_code_for_serverside_insertion () . $content;
5290
+ $ai_last_check = AI_CHECK_INSERTED;
5291
+ }
5292
+ }
5293
+ elseif ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT) {
5294
+ $obj->increment_block_counter ();
5295
+
5296
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5297
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5298
+ $content = $content . $obj->get_code_for_serverside_insertion ();
5299
+ $ai_last_check = AI_CHECK_INSERTED;
5300
+ }
5301
+ }
5302
+ }
5303
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5304
+ }
5305
+
5306
+
5307
+ if (function_exists ('ai_content')) ai_content ($content);
5308
+
5309
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
5310
+ $class = AI_DEBUG_TAGS_CLASS;
5311
+
5312
+ $content = preg_replace ("/\r\n\r\n/", "\r\n\r\n<kbd class='$class ai-debug-rnrn'>\\r\\n\\r\\n</kbd>", $content);
5313
+
5314
+ $content = preg_replace ("/<p>/i", "<p><kbd class='$class ai-debug-p'>&lt;p&gt;</kbd>", $content);
5315
+ // $content = preg_replace ("/<p ([^>]*?)>/i", "<p$1><kbd class='$class ai-debug-p'>&lt;p$1&gt;</kbd>", $content); // Full p tags
5316
+ $content = preg_replace ("/<p ([^>]*?)>/i", "<p$1><kbd class='$class ai-debug-p'>&lt;p&gt;</kbd>", $content);
5317
+ // $content = preg_replace ("/<div([^>]*?)>/i", "<div$1><kbd class='$class ai-debug-div'>&lt;div$1&gt;</kbd>", $content); // Full div tags
5318
+ $content = preg_replace ("/<div([^>]*?)>/i", "<div$1><kbd class='$class ai-debug-div'>&lt;div&gt;</kbd>", $content);
5319
+ $content = preg_replace ("/<h([1-6])([^>]*?)>/i", "<h$1$2><kbd class='$class ai-debug-h'>&lt;h$1&gt;</kbd>", $content);
5320
+ $content = preg_replace ("/<img([^>]*?)>/i", "<img$1><kbd class='$class ai-debug-img'>&lt;img$1&gt;</kbd>", $content);
5321
+ $content = preg_replace ("/<pre([^>]*?)>/i", "<pre$1><kbd class='$class ai-debug-pre'>&lt;pre&gt;</kbd>", $content);
5322
+ $content = preg_replace ("/<(?!section|ins|script|kbd|a|strong|pre|p|div|h[1-6]|img)([a-z0-9]+)([^>]*?)>/i", "<$1$2><kbd class='$class ai-debug-special'>&lt;$1$2&gt;</kbd>", $content);
5323
+
5324
+ $content = preg_replace ("/<\/p>/i", "<kbd class='$class ai-debug-p'>&lt;/p&gt;</kbd></p>", $content);
5325
+ $content = preg_replace ("/<\/div>/i", "<kbd class='$class ai-debug-div'>&lt;/div&gt;</kbd></div>", $content);
5326
+ $content = preg_replace ("/<\/h([1-6])>/i", "<kbd class='$class ai-debug-h'>&lt;/h$1&gt;</kbd></h$1>", $content);
5327
+ $content = preg_replace ("/<\/pre>/i", "<kbd class='$class ai-debug-pre'>&lt;/pre&gt;</kbd></pre>", $content);
5328
+ $content = preg_replace ("/<\/(?!section|ins|script|kbd|a|strong|pre|p|div|h[1-6])([a-z0-9]+)>/i", "<kbd class='$class ai-debug-special'>&lt;/$1&gt;</kbd></$1>", $content);
5329
+ }
5330
+
5331
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5332
+ $class = AI_DEBUG_POSITIONS_CLASS;
5333
+
5334
+ if (!$positions_inserted) {
5335
+ $preview = $block_object [$ai_wp_data [AI_WP_DEBUG_BLOCK]];
5336
+ $content = $preview->before_paragraph ($content, true);
5337
+ $content = $preview->after_paragraph ($content, true);
5338
+ }
5339
+
5340
+ $content = preg_replace ("/\[\[AI_BP([\d]+?)\]\]/", "<section class='$class'>BEFORE PARAGRAPH $1</section>", $content);
5341
+ $content = preg_replace ("/\[\[AI_AP([\d]+?)\]\]/", "<section class='$class'>AFTER PARAGRAPH $1</section>", $content);
5342
+
5343
+ $counter = $ad_inserter_globals [$globals_name];
5344
+ if ($counter == 1) $counter = '';
5345
+
5346
+ $content = "<section class='$class'><a class='ai-debug-left'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a> BEFORE CONTENT ".$counter."<a class='ai-debug-right'>".$content_words." words</a></section>". $content;
5347
+
5348
+ if ($ai_wp_data [AI_WP_AMP_PAGE]) {
5349
+ $content = get_page_type_debug_info ('AMP ') . $content;
5350
+ }
5351
+
5352
+ $content = $content . "<section class='$class'>AFTER CONTENT ".$counter."</section>";
5353
+
5354
+ $content = $content . get_page_type_debug_info ();
5355
+
5356
+ if ($ai_wp_data [AI_WP_AMP_PAGE]) {
5357
+ $content = $content . get_page_type_debug_info ('AMP ');
5358
+ }
5359
+ }
5360
+
5361
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
5362
+ $content = '<kbd class="ai-debug-invisible">[HTML TAGS REMOVED]</kbd>' . $content;
5363
+ }
5364
+
5365
+ if ($debug_processing) {
5366
+ $ai_total_plugin_time += microtime (true) - $start_time;
5367
+ ai_log ("CONTENT HOOK END\n");
5368
+ }
5369
+
5370
+ return $content;
5371
+ }
5372
+
5373
+ // Process Before/After Excerpt postion
5374
+ function ai_excerpt_hook ($content = '') {
5375
+ global $ad_inserter_globals, $block_object, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
5376
+
5377
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
5378
+
5379
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5380
+ $globals_name = AI_EXCERPT_COUNTER_NAME;
5381
+
5382
+ if (!isset ($ad_inserter_globals [$globals_name])) {
5383
+ $ad_inserter_globals [$globals_name] = 1;
5384
+ } else $ad_inserter_globals [$globals_name] ++;
5385
+
5386
+ if ($debug_processing) {
5387
+ ai_log ("EXCERPT HOOK START [" . $ad_inserter_globals [$globals_name] . ']');
5388
+ $start_time = microtime (true);
5389
+ }
5390
+
5391
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_EXCERPT;
5392
+
5393
+ $ai_last_check = AI_CHECK_NONE;
5394
+ $current_block = 0;
5395
+
5396
+ if (isset ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5397
+ foreach ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5398
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5399
+
5400
+ if (!isset ($block_object [$block])) continue;
5401
+
5402
+ $current_block = $block;
5403
+ $obj = $block_object [$block];
5404
+ $obj->clear_code_cache ();
5405
+
5406
+ if (!$obj->check_server_side_detection ()) continue;
5407
+ if (!$obj->check_page_types_lists_users ()) continue;
5408
+ if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
5409
+
5410
+ // Deprecated
5411
+ $ai_last_check = AI_CHECK_DISABLED_MANUALLY;
5412
+ if ($obj->display_disabled ($content)) continue;
5413
+
5414
+ // Last check before counter check before insertion
5415
+ $ai_last_check = AI_CHECK_CODE;
5416
+ if ($obj->ai_getCode () == '') continue;
5417
+
5418
+ // Last check before insertion
5419
+ if (!$obj->check_and_increment_block_counter ()) continue;
5420
+
5421
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5422
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5423
+
5424
+ $automatic_insertion = $obj->get_automatic_insertion ();
5425
+ if ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT)
5426
+ $content = $obj->get_code_for_serverside_insertion () . $content; else
5427
+ $content = $content . $obj->get_code_for_serverside_insertion ();
5428
+
5429
+ $ai_last_check = AI_CHECK_INSERTED;
5430
+ }
5431
+ }
5432
+
5433
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5434
+
5435
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5436
+ $class = AI_DEBUG_POSITIONS_CLASS;
5437
+
5438
+ $content = "<section class='$class'>BEFORE EXCERPT ".$ad_inserter_globals [$globals_name]."</section>". $content . "<section class='$class'>AFTER EXCERPT ".$ad_inserter_globals [$globals_name]."</section>";
5439
+
5440
+ // Color positions from the content hook
5441
+ $content = preg_replace ("/((BEFORE|AFTER) (CONTENT|PARAGRAPH) ?[\d]*)/", "<span class='ai-debug-content-hook-positions'> [$1] </span>", $content);
5442
+ }
5443
+
5444
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_TAGS) != 0) {
5445
+ // Remove marked tags from the content hook
5446
+ $content = preg_replace ("/&lt;(.+?)&gt;/", "", $content);
5447
+
5448
+ // Color text to mark removed HTML tags
5449
+ $content = str_replace ('[HTML TAGS REMOVED]', "<span class='ai-debug-removed-html-tags'>[HTML TAGS REMOVED]</span>", $content);
5450
+ }
5451
+
5452
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0) {
5453
+ // Remove block labels from the content hook
5454
+ if (strpos ($content, '>[AI]<') === false)
5455
+ $content = preg_replace ("/\[AI\](.+?)\[\/AI\]/", "", $content);
5456
+ }
5457
+
5458
+ if ($debug_processing) {
5459
+ $ai_total_plugin_time += microtime (true) - $start_time;
5460
+ ai_log ("EXCERPT HOOK END\n");
5461
+ }
5462
+
5463
+ return $content;
5464
+ }
5465
+
5466
+ function ai_comments_array ($comments , $post_id ){
5467
+ global $ai_wp_data;
5468
+
5469
+ $thread_comments = get_option ('thread_comments');
5470
+ $comment_counter = 0;
5471
+ foreach ($comments as $comment) {
5472
+ if (!$thread_comments || empty ($comment->comment_parent))
5473
+ $comment_counter ++;
5474
+ }
5475
+ $ai_wp_data [AI_NUMBER_OF_COMMENTS] = $comment_counter;
5476
+
5477
+ return $comments;
5478
+ }
5479
+
5480
+ function ai_wp_list_comments_args ($args) {
5481
+ global $ai_wp_data;
5482
+
5483
+ // print_r ($args);
5484
+ // $args['per_page'] = 3;
5485
+ // $args['page'] = 2;
5486
+
5487
+ $ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'] = $args ['callback'];
5488
+ $args ['callback'] = 'ai_comment_callback';
5489
+
5490
+ $ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'] = $args ['end-callback'];
5491
+ $args ['end-callback'] = 'ai_comment_end_callback';
5492
+
5493
+ return $args;
5494
+ }
5495
+
5496
+ // Process comments counter + Before Comments postion
5497
+ function ai_comment_callback ($comment, $args, $depth) {
5498
+ global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time, $ai_walker;
5499
+
5500
+ if ($depth == 1) {
5501
+ if (!isset ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME])) {
5502
+ $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] = 1;
5503
+ } else $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] ++;
5504
+ }
5505
+
5506
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5507
+ if ($debug_processing) {
5508
+ ai_log ('COMMENT START HOOK START [' . $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] . ':'. $depth . ']');
5509
+ $start_time = microtime (true);
5510
+ }
5511
+
5512
+ if ($depth == 1 && $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] == 1) {
5513
+
5514
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BEFORE_COMMENTS;
5515
+
5516
+ if ($args ['style'] == 'div') $tag = 'div'; else $tag = 'li';
5517
+
5518
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5519
+
5520
+ $class = AI_DEBUG_POSITIONS_CLASS;
5521
+
5522
+ echo "<$tag>\n";
5523
+ echo "<section class='$class'>BEFORE COMMENTS</section>";
5524
+ echo "</$tag>\n";
5525
+ }
5526
+
5527
+ $ad_code = "";
5528
+
5529
+ $ai_last_check = AI_CHECK_NONE;
5530
+ $current_block = 0;
5531
+
5532
+ if (isset ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5533
+ foreach ($ai_db_options_extract [BEFORE_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5534
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5535
+
5536
+ if (!isset ($block_object [$block])) continue;
5537
+
5538
+ $current_block = $block;
5539
+
5540
+ $obj = $block_object [$block];
5541
+ $obj->clear_code_cache ();
5542
+
5543
+ if (!$obj->check_server_side_detection ()) continue;
5544
+ if (!$obj->check_page_types_lists_users ()) continue;
5545
+ // No filter check
5546
+
5547
+ // Last check before counter check before insertion
5548
+ $ai_last_check = AI_CHECK_CODE;
5549
+ if ($obj->ai_getCode () == '') continue;
5550
+
5551
+ // Last check before insertion
5552
+ if (!$obj->check_and_increment_block_counter ()) continue;
5553
+
5554
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5555
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5556
+ $ad_code .= $obj->get_code_for_serverside_insertion ();
5557
+ $ai_last_check = AI_CHECK_INSERTED;
5558
+ }
5559
+ }
5560
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5561
+
5562
+ echo "<$tag>\n";
5563
+ echo $ad_code;
5564
+ echo "</$tag>\n";
5565
+ }
5566
+
5567
+ if ($debug_processing) {
5568
+ $ai_total_plugin_time += microtime (true) - $start_time;
5569
+ ai_log ("COMMENT END HOOK END\n");
5570
+ }
5571
+
5572
+ if (!empty ($ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'])) {
5573
+ echo call_user_func ($ai_wp_data ['AI_COMMENTS_SAVED_CALLBACK'], $comment, $args, $depth );
5574
+ } else {
5575
+ $ai_walker->comment_callback ($comment, $args, $depth);
5576
+ }
5577
+ }
5578
+
5579
+ // Process Between Comments postion
5580
+ function ai_comment_end_callback ($comment, $args, $depth) {
5581
+ global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
5582
+
5583
+ if ($args ['style'] == 'div') $tag = 'div'; else $tag = 'li';
5584
+
5585
+ if (!empty ($ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'])) {
5586
+ echo call_user_func ($ai_wp_data ['AI_COMMENTS_SAVED_END_CALLBACK'], $comment, $args, $depth);
5587
+ } else echo "</$tag><!-- #comment-## -->\n";
5588
+
5589
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5590
+ if ($debug_processing) {
5591
+ ai_log ('COMMENT END HOOK START [' . $ad_inserter_globals [AI_COMMENT_COUNTER_NAME] . ':'. ($depth + 1) . ']');
5592
+ $start_time = microtime (true);
5593
+ }
5594
+
5595
+ if ($depth == 0) {
5596
+
5597
+ if (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) &&
5598
+ $ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] != 0 &&
5599
+ !empty ($args ['per_page']) && !empty ($args ['page'])) {
5600
+ $number_of_comments_mod_per_page = $ai_wp_data [AI_NUMBER_OF_COMMENTS] % $args ['per_page'];
5601
+ if ($number_of_comments_mod_per_page != 0) {
5602
+ $last_page = (int) ($ai_wp_data [AI_NUMBER_OF_COMMENTS] / $args ['per_page']) + 1;
5603
+ $last_comment_number = $args ['page'] == $last_page ? $number_of_comments_mod_per_page : $args ['per_page'];
5604
+ } else $last_comment_number = $args ['per_page'];
5605
+ } else $last_comment_number = $ai_wp_data [AI_NUMBER_OF_COMMENTS];
5606
+
5607
+ if ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME] == $last_comment_number) {
5608
+
5609
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_AFTER_COMMENTS;
5610
+
5611
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5612
+
5613
+ $class = AI_DEBUG_POSITIONS_CLASS;
5614
+
5615
+ echo "<$tag>\n";
5616
+ echo "<section class='$class'>AFTER COMMENTS</section>";
5617
+ echo "</$tag>\n";
5618
+ }
5619
+
5620
+ $ad_code = "";
5621
+
5622
+ $ai_last_check = AI_CHECK_NONE;
5623
+ $current_block = 0;
5624
+
5625
+ if (isset ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5626
+ foreach ($ai_db_options_extract [AFTER_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5627
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5628
+
5629
+ if (!isset ($block_object [$block])) continue;
5630
+
5631
+ $current_block = $block;
5632
+
5633
+ $obj = $block_object [$block];
5634
+ $obj->clear_code_cache ();
5635
+
5636
+ if (!$obj->check_server_side_detection ()) continue;
5637
+ if (!$obj->check_page_types_lists_users ()) continue;
5638
+ // No filter check
5639
+
5640
+ // Last check before counter check before insertion
5641
+ $ai_last_check = AI_CHECK_CODE;
5642
+ if ($obj->ai_getCode () == '') continue;
5643
+
5644
+ // Last check before insertion
5645
+ if (!$obj->check_and_increment_block_counter ()) continue;
5646
+
5647
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5648
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5649
+ $ad_code .= $obj->get_code_for_serverside_insertion ();
5650
+ $ai_last_check = AI_CHECK_INSERTED;
5651
+ }
5652
+ }
5653
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5654
+
5655
+ echo "<$tag>\n";
5656
+ echo $ad_code;
5657
+ echo "</$tag>\n";
5658
+ } else {
5659
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_BETWEEN_COMMENTS;
5660
+
5661
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5662
+
5663
+ $class = AI_DEBUG_POSITIONS_CLASS;
5664
+
5665
+ echo "<$tag>\n";
5666
+ echo "<section class='$class'>BETWEEN COMMENTS ".$ad_inserter_globals [AI_COMMENT_COUNTER_NAME]."</section>";
5667
+ echo "</$tag>\n";
5668
+ }
5669
+
5670
+ $ad_code = "";
5671
+
5672
+ $ai_last_check = AI_CHECK_NONE;
5673
+ $current_block = 0;
5674
+
5675
+ if (isset ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5676
+ foreach ($ai_db_options_extract [BETWEEN_COMMENTS_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5677
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5678
+
5679
+ if (!isset ($block_object [$block])) continue;
5680
+
5681
+ $current_block = $block;
5682
+
5683
+ $obj = $block_object [$block];
5684
+ $obj->clear_code_cache ();
5685
+
5686
+ if (!$obj->check_server_side_detection ()) continue;
5687
+ if (!$obj->check_page_types_lists_users ()) continue;
5688
+ if (!$obj->check_filter ($ad_inserter_globals [AI_COMMENT_COUNTER_NAME])) continue;
5689
+
5690
+ // Last check before counter check before insertion
5691
+ $ai_last_check = AI_CHECK_CODE;
5692
+ if ($obj->ai_getCode () == '') continue;
5693
+
5694
+ // Last check before insertion
5695
+ if (!$obj->check_and_increment_block_counter ()) continue;
5696
+
5697
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5698
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5699
+ $ad_code .= $obj->get_code_for_serverside_insertion ();
5700
+ $ai_last_check = AI_CHECK_INSERTED;
5701
+ }
5702
+ }
5703
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5704
+
5705
+ echo "<$tag>\n";
5706
+ echo $ad_code;
5707
+ echo "</$tag>\n";
5708
+ }
5709
+ }
5710
+
5711
+ if ($debug_processing) {
5712
+ $ai_total_plugin_time += microtime (true) - $start_time;
5713
+ ai_log ("COMMENT END HOOK END\n");
5714
+ }
5715
+ }
5716
+
5717
+ function ai_custom_hook ($action, $name, $hook_parameter = null, $hook_check = null) {
5718
+ global $block_object, $ad_inserter_globals, $ai_db_options_extract, $ai_wp_data, $ai_last_check, $ai_total_plugin_time;
5719
+
5720
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
5721
+
5722
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_ADMIN) return;
5723
+
5724
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_NONE;
5725
+
5726
+ if (isset ($hook_check)) {
5727
+ if (!call_user_func ($hook_check, $hook_parameter, $action)) return;
5728
+ }
5729
+
5730
+ $hook_name = strtoupper ($name);
5731
+
5732
+ if ($debug_processing) {
5733
+ ai_log (str_replace (array ('&LT;', '&GT;'), array ('<', '>'), $hook_name) . " HOOK START");
5734
+ $start_time = microtime (true);
5735
+ }
5736
+
5737
+ $globals_name = 'AI_' . strtoupper ($action) . '_COUNTER';
5738
+
5739
+ if (!isset ($ad_inserter_globals [$globals_name])) {
5740
+ $ad_inserter_globals [$globals_name] = 1;
5741
+ } else $ad_inserter_globals [$globals_name] ++;
5742
+
5743
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0) {
5744
+
5745
+ $counter = $ad_inserter_globals [$globals_name];
5746
+ if ($counter == 1) $counter = '';
5747
+
5748
+ $class = AI_DEBUG_POSITIONS_CLASS;
5749
+
5750
+ echo "<section class='$class'>".$hook_name." ".$counter."</section>";
5751
+ }
5752
+
5753
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
5754
+ $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
5755
+ $selected_blocks = explode (",", $meta_value);
5756
+ } else $selected_blocks = array ();
5757
+
5758
+ $ad_code = "";
5759
+
5760
+ $ai_last_check = AI_CHECK_NONE;
5761
+ $current_block = 0;
5762
+
5763
+ if (isset ($ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]))
5764
+ foreach ($ai_db_options_extract [$action . CUSTOM_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]] as $block) {
5765
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5766
+
5767
+ if (!isset ($block_object [$block])) continue;
5768
+
5769
+ $current_block = $block;
5770
+
5771
+ $obj = $block_object [$block];
5772
+ $obj->clear_code_cache ();
5773
+
5774
+ if (!$obj->check_server_side_detection ()) continue;
5775
+ if (!$obj->check_page_types_lists_users ()) continue;
5776
+ if (!$obj->check_post_page_exceptions ($selected_blocks)) continue;
5777
+ if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) continue;
5778
+ if (!$obj->check_number_of_words ()) continue;
5779
+
5780
+ // Last check before counter check before insertion
5781
+ $ai_last_check = AI_CHECK_CODE;
5782
+ if ($obj->ai_getCode () == '') continue;
5783
+
5784
+ // Last check before insertion
5785
+ if (!$obj->check_and_increment_block_counter ()) continue;
5786
+
5787
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
5788
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
5789
+ $ad_code .= $obj->get_code_for_serverside_insertion ();
5790
+ $ai_last_check = AI_CHECK_INSERTED;
5791
+ }
5792
+ }
5793
+ if ($debug_processing && $ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($current_block, $ai_last_check));
5794
+
5795
+ echo $ad_code;
5796
+
5797
+ if ($debug_processing) {
5798
+ $ai_total_plugin_time += microtime (true) - $start_time;
5799
+ ai_log (str_replace (array ('&LT;', '&GT;'), array ('<', '>'), $hook_name) . " HOOK END\n");
5800
+ }
5801
+ }
5802
+
5803
+
5804
+ function ai_pre_do_shortcode_tag ($return, $tag, $attr, $m) {
5805
+ global $ai_expand_only_rotate;
5806
+
5807
+ // Array
5808
+ //(
5809
+ // [0] => [ADINSERTER ROTATE='1']
5810
+ // [1] =>
5811
+ // [2] => ADINSERTER
5812
+ // [3] => ROTATE='1'
5813
+ // [4] =>
5814
+ // [5] =>
5815
+ // [6] =>
5816
+
5817
+ if (strtolower ($tag) == 'adinserter') {
5818
+ if ($ai_expand_only_rotate) {
5819
+ // Expand only ROTATE
5820
+ if (isset ($attr ['rotate']) || in_array ('ROTATE', $attr) || in_array ('rotate', $atts)) {
5821
+ return false;
5822
+ } else return $m [0];
5823
+ }
5824
+ }
5825
+
5826
+ return $return;
5827
+ }
5828
+
5829
+ function ai_process_shortcode (&$block, $atts) {
5830
+ global $block_object, $ai_last_check, $ai_wp_data;
5831
+
5832
+ if ($atts == '') return '';
5833
+
5834
+ $parameters = shortcode_atts (array (
5835
+ "block" => "",
5836
+ "code" => "",
5837
+ "name" => "",
5838
+ "ignore" => "",
5839
+ "check" => "",
5840
+ // "debugger" => "",
5841
+ "adb" => "",
5842
+ "css" => "",
5843
+ "text" => "",
5844
+ "selectors" => "",
5845
+ "amp" => "",
5846
+ "rotate" => "",
5847
+ "count" => "",
5848
+ "http" => "",
5849
+ "custom-field" => "",
5850
+ "data" => "",
5851
+ "share" => "",
5852
+ "time" => "",
5853
+ ), $atts);
5854
+
5855
+
5856
+ $output = "";
5857
+ if (function_exists ('ai_shortcode')) {
5858
+ $output = ai_shortcode ($parameters);
5859
+ if ($output != '') return $output;
5860
+ }
5861
+
5862
+ if (($adb = trim ($parameters ['adb'])) != '') {
5863
+ // message html
5864
+ // message css
5865
+ // overlay css
5866
+ // undismissible
5867
+
5868
+ // redirection page
5869
+ // redirection url
5870
+
5871
+ switch (strtolower ($adb)) {
5872
+ case 'message':
5873
+ $ai_wp_data [AI_ADB_SHORTCODE_ACTION] = AI_ADB_ACTION_MESSAGE;
5874
+ break;
5875
+ case 'redirection':
5876
+ $ai_wp_data [AI_ADB_SHORTCODE_ACTION] = AI_ADB_ACTION_REDIRECTION;
5877
+ break;
5878
+ }
5879
+ return "";
5880
+ }
5881
+
5882
+ $block = - 1;
5883
+ $code_only = false;
5884
+
5885
+ if ($parameters ['block'] == '' && $parameters ['code'] != '') {
5886
+ $parameters ['block'] = $parameters ['code'];
5887
+ $code_only = true;
5888
+ }
5889
+
5890
+ if (is_numeric ($parameters ['block'])) {
5891
+ $block = intval ($parameters ['block']);
5892
+ } elseif ($parameters ['name'] != '') {
5893
+ $shortcode_name = strtolower ($parameters ['name']);
5894
+ for ($counter = 1; $counter <= AD_INSERTER_BLOCKS; $counter ++) {
5895
+ $obj = $block_object [$counter];
5896
+ $ad_name = strtolower (trim ($obj->get_ad_name()));
5897
+ if ($shortcode_name == $ad_name) {
5898
+ $block = $counter;
5899
+ break;
5900
+ }
5901
+ }
5902
+ }
5903
+
5904
+ if ($block == - 1) {
5905
+ if ($parameters ['count'] != '' || in_array ('COUNT', $atts) || in_array ('count', $atts)) {
5906
+ if (!isset ($ai_wp_data [AI_SHORTCODES]['count'])) $ai_wp_data [AI_SHORTCODES]['count'] = array ();
5907
+ $ai_wp_data [AI_SHORTCODES]['count'] []= $parameters;
5908
+ return AD_COUNT_SEPARATOR;
5909
+ }
5910
+ if ($parameters ['rotate'] != '' || in_array ('ROTATE', $atts) || in_array ('rotate', $atts)) {
5911
+ if (!isset ($ai_wp_data [AI_SHORTCODES]['rotate'])) $ai_wp_data [AI_SHORTCODES]['rotate'] = array ();
5912
+ $ai_wp_data [AI_SHORTCODES]['rotate'] []= $parameters;
5913
+ return AD_ROTATE_SEPARATOR;
5914
+ }
5915
+ if ($parameters ['amp'] != '' || in_array ('AMP', $atts) || in_array ('amp', $atts)) {
5916
+ return AD_AMP_SEPARATOR;
5917
+ }
5918
+ if ($parameters ['http'] != '' || in_array ('HTTP', $atts) || in_array ('http', $atts)) {
5919
+ return AD_HTTP_SEPARATOR;
5920
+ }
5921
+ if ($parameters ['custom-field'] != '') {
5922
+ $post_meta = get_post_meta (get_the_ID(), $parameters ['custom-field']);
5923
+ if (is_array ($post_meta)) {
5924
+ $post_meta = implode (', ', $post_meta);
5925
+ }
5926
+ return $post_meta;
5927
+ }
5928
+ if ($parameters ['data'] != '') {
5929
+ return '{'.$parameters ['data'].'}';
5930
+ }
5931
+ if ($parameters ['name'] != '') {
5932
+ switch (strtolower ($parameters ['name'])) {
5933
+ case 'processing-log':
5934
+ if (/*get_remote_debugging () ||*/ ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) {
5935
+ ob_start ();
5936
+ echo "<pre style='", AI_DEBUG_WIDGET_STYLE, "'>\n";
5937
+ ai_write_debug_info ();
5938
+ echo "</pre>";
5939
+ return ob_get_clean ();
5940
+ }
5941
+ return "";
5942
+ case 'debugging-tools':
5943
+ if (/*get_remote_debugging () ||*/ ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) {
5944
+ ai_write_debugging_tools ();
5945
+ }
5946
+ return "";
5947
+ }
5948
+ }
5949
+ }
5950
+
5951
+ $ai_last_check = AI_CHECK_SHORTCODE_ATTRIBUTES;
5952
+ if ($block < 1 || $block > AD_INSERTER_BLOCKS) return "";
5953
+
5954
+ 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'].'"' : '').")");
5955
+
5956
+ // IGNORE SETTINGS
5957
+ // page-type
5958
+ // *block-counter
5959
+
5960
+ // CHECK SETTINGS
5961
+ // exceptions
5962
+
5963
+ $ignore_array = array ();
5964
+ if (trim ($parameters ['ignore']) != '') {
5965
+ $ignore_array = explode (",", str_replace (" ", "", $parameters ['ignore']));
5966
+ }
5967
+
5968
+ $check_array = array ();
5969
+ if (trim ($parameters ['check']) != '') {
5970
+ $check_array = explode (",", str_replace (" ", "", $parameters ['check']));
5971
+ }
5972
+
5973
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_SHORTCODE;
5974
+
5975
+ $obj = $block_object [$block];
5976
+ $obj->clear_code_cache ();
5977
+
5978
+ $ai_last_check = AI_CHECK_ENABLED_SHORTCODE;
5979
+ if (!$obj->get_enable_manual ()) return "";
5980
+
5981
+ if (!$obj->check_server_side_detection ()) return "";
5982
+ if (!$obj->check_page_types_lists_users (in_array ("page-type", $ignore_array))) return "";
5983
+
5984
+ if (in_array ("exceptions", $check_array)) {
5985
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
5986
+ $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
5987
+ $selected_blocks = explode (",", $meta_value);
5988
+ if (!$obj->check_post_page_exceptions ($selected_blocks)) return "";
5989
+ }
5990
+ }
5991
+
5992
+ // Last check before counter check before insertion
5993
+ $ai_last_check = AI_CHECK_CODE;
5994
+ if ($obj->ai_getCode () == '') return "";
5995
+
5996
+ // Last check before insertion
5997
+ if (!$obj->check_and_increment_block_counter ()) return "";
5998
+
5999
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
6000
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
6001
+ $code = $obj->get_code_for_serverside_insertion (true, false, $code_only);
6002
+ // Must be after et_code_for_serverside_insertion ()
6003
+ $ai_last_check = AI_CHECK_INSERTED;
6004
+ return $code;
6005
+ }
6006
+ }
6007
+
6008
+ function ai_process_shortcodes ($atts, $content, $tag) {
6009
+ global $ai_last_check, $ai_wp_data, $ai_total_plugin_time;
6010
+
6011
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
6012
+ if ($debug_processing) {
6013
+ $atts_string = '';
6014
+ if (is_array ($atts))
6015
+ foreach ($atts as $index => $att) {
6016
+ if (is_numeric ($index))
6017
+ $atts_string .= $att.' '; else
6018
+ $atts_string .= $index.("='".$att."'").' ';
6019
+ }
6020
+ ai_log ("PROCESS SHORTCODES [$tag ".trim ($atts_string).']');
6021
+ $start_time = microtime (true);
6022
+ }
6023
+ $ai_last_check = AI_CHECK_NONE;
6024
+ $block = - 1;
6025
+ $shortcode = ai_process_shortcode ($block, $atts);
6026
+
6027
+ if ($debug_processing) {
6028
+ $ai_total_plugin_time += microtime (true) - $start_time;
6029
+ if ($block == - 1) {
6030
+ if (strlen ($shortcode) < 100) ai_log ('SHORTCODE TEXT: "' . ai_log_filter_content ($shortcode) . '"'); else
6031
+ 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))) . '"');
6032
+ }
6033
+ elseif ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
6034
+ ai_log ("SHORTCODE END\n");
6035
+ }
6036
+
6037
+ return $shortcode;
6038
+ }
6039
+
6040
+ //function process_shortcodes_lc ($atts, $content, $tag) {
6041
+ // return process_shortcodes ($atts, 'adinserter');
6042
+ //}
6043
+
6044
+ //function process_shortcodes_uc ($atts, $content, $tag) {
6045
+ // return process_shortcodes ($atts, 'ADINSERTER');
6046
+ //}
6047
+
6048
+
6049
+ class ai_widget extends WP_Widget {
6050
+
6051
+ function __construct () {
6052
+ parent::__construct (
6053
+ false, // Base ID
6054
+ AD_INSERTER_NAME, // Name
6055
+ array ( // Args
6056
+ 'classname' => 'ai_widget',
6057
+ 'description' => AD_INSERTER_NAME.' code block widget.')
6058
+ );
6059
+ }
6060
+
6061
+ function form ($instance) {
6062
+ global $block_object;
6063
+
6064
+ // Output admin widget options form
6065
+
6066
+ $widget_title = !empty ($instance ['widget-title']) ? $instance ['widget-title'] : '';
6067
+ $block = isset ($instance ['block']) ? $instance ['block'] : 1;
6068
+ if ($block > AD_INSERTER_BLOCKS) $block = 1;
6069
+ $sticky = isset ($instance ['sticky']) ? $instance ['sticky'] : 0;
6070
+
6071
+ if ($block == 0) $title = 'Processing Log';
6072
+ elseif ($block == - 1) $title = 'Dummy Widget';
6073
+ elseif ($block == - 2) $title = 'Debugging Tools';
6074
+ elseif ($block >= 1) {
6075
+ $obj = $block_object [$block];
6076
+
6077
+ $title = '[' . $block . '] ' . $obj->get_ad_name();
6078
+ if (!empty ($widget_title)) $title .= ' - ' . $widget_title;
6079
+ if (!$obj->get_enable_widget ()) $title .= ' - DISABLED';
6080
+ } else $title = "Unknown block";
6081
+
6082
+ $url_parameters = "";
6083
+ if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($block);
6084
+
6085
+ ?>
6086
+ <input id="<?php echo $this->get_field_id ('title'); ?>" name="<?php echo $this->get_field_name ('title'); ?>" type="hidden" value="<?php echo esc_attr ($title); ?>">
6087
+
6088
+ <p>
6089
+ <label for="<?php echo $this->get_field_id ('widget-title'); ?>">Title: &nbsp;</label>
6090
+ <input id="<?php echo $this->get_field_id ('widget-title'); ?>" name="<?php echo $this->get_field_name ('widget-title'); ?>" type="text" value="<?php echo esc_attr ($widget_title); ?>" style="width: 88%;">
6091
+ </p>
6092
+
6093
+ <p>
6094
+ <label for="<?php echo $this->get_field_id ('block'); ?>"><a href='<?php echo admin_url ('options-general.php?page=ad-inserter.php'), $url_parameters, "&tab=", $block; ?>' title='Click for block settings' style='text-decoration: none;'>Block</a>:</label>
6095
+ <select id="<?php echo $this->get_field_id ('block'); ?>" name="<?php echo $this->get_field_name('block'); ?>" style="width: 88%;">
6096
+ <?php
6097
+ for ($block_index = 1; $block_index <= AD_INSERTER_BLOCKS; $block_index ++) {
6098
+ $obj = $block_object [$block_index];
6099
+ ?>
6100
+ <option value='<?php echo $block_index; ?>' <?php if ($block_index == $block) echo 'selected="selected"'; ?>><?php echo $block_index, ' - ', $obj->get_ad_name(), !$obj->get_enable_widget ()? ' - DISABLED' : ''; ?></option>
6101
+ <?php } ?>
6102
+ <option value='-2' <?php if ($block == - 2) echo 'selected="selected"'; ?>>Debugging Tools</option>
6103
+ <option value='0' <?php if ($block == 0) echo 'selected="selected"'; ?>>Processing Log</option>
6104
+ <option value='-1' <?php if ($block == - 1) echo 'selected="selected"'; ?>>Dummy Widget</option>
6105
+ </select>
6106
+ </p>
6107
+
6108
+ <p>
6109
+ <input type="hidden" name='<?php echo $this->get_field_name ('sticky'); ?>' value="0" />
6110
+ <input type='checkbox' id='<?php echo $this->get_field_id ('sticky'); ?>' name='<?php echo $this->get_field_name ('sticky'); ?>' value='1' <?php if ($sticky) echo 'checked '; ?>>
6111
+ <label for='<?php echo $this->get_field_id ('sticky'); ?>'>Sticky</label>
6112
+ </p>
6113
+ <?php
6114
+ }
6115
+
6116
+ function update ($new_instance, $old_instance) {
6117
+ // Save widget options
6118
+ $instance = $old_instance;
6119
+
6120
+ $instance ['widget-title'] = (!empty ($new_instance ['widget-title'])) ? strip_tags ($new_instance ['widget-title']) : '';
6121
+ $instance ['title'] = (!empty ($new_instance ['title'])) ? strip_tags ($new_instance ['title']) : '';
6122
+ $instance ['block'] = (isset ($new_instance ['block'])) ? $new_instance ['block'] : 1;
6123
+ $instance ['sticky'] = (isset ($new_instance ['sticky'])) ? $new_instance ['sticky'] : 0;
6124
+
6125
+ return $instance;
6126
+ }
6127
+
6128
+ function widget ($args, $instance) {
6129
+ global $ai_last_check, $ai_wp_data, $ai_total_plugin_time;
6130
+
6131
+ $debug_processing = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0;
6132
+ if ($debug_processing) $start_time = microtime (true);
6133
+
6134
+ $ai_last_check = AI_CHECK_NONE;
6135
+
6136
+ $block = 0;
6137
+ ai_widget_draw ($args, $instance, $block);
6138
+
6139
+ if ($debug_processing) {
6140
+ $ai_total_plugin_time += microtime (true) - $start_time;
6141
+ if ($ai_last_check != AI_CHECK_NONE) ai_log (ai_log_block_status ($block, $ai_last_check));
6142
+ ai_log ("WIDGET END\n");
6143
+ }
6144
+ }
6145
+ }
6146
+
6147
+ function ai_add_attr_data (&$tag, $attr, $new_data) {
6148
+
6149
+ if (trim ($tag) != '' && strpos ($tag, '<!--') === false) {
6150
+ if (stripos ($tag, $attr."=") !== false) {
6151
+ preg_match ("/$attr=[\'\"](.+?)[\'\"]/", $tag, $classes);
6152
+ $tag = str_replace ($classes [1], $classes [1]. ' ' . $new_data, $tag);
6153
+ return true;
6154
+ }
6155
+ elseif (strpos ($tag, ">") !== false) {
6156
+ $tag = str_replace ('>', ' ' . $attr . '="' . $new_data . '">', $tag);
6157
+ return true;
6158
+ }
6159
+ }
6160
+
6161
+ return false;
6162
+ }
6163
+
6164
+ function ai_widget_draw ($args, $instance, &$block) {
6165
+ global $block_object, $ad_inserter_globals, $ai_wp_data, $ai_last_check;
6166
+
6167
+ $block = isset ($instance ['block']) ? $instance ['block'] : 1;
6168
+ $sticky = isset ($instance ['sticky']) ? $instance ['sticky'] : 0;
6169
+
6170
+ if ($block == 0 || $block == - 2) {
6171
+ if (/*get_remote_debugging () ||*/ ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0) {
6172
+ ai_special_widget ($args, $instance, $block);
6173
+ }
6174
+ return;
6175
+ }
6176
+
6177
+ if ($sticky) {
6178
+ $ai_wp_data [AI_STICKY_WIDGETS] = true;
6179
+ if ($block == - 1) {
6180
+ $before_widget = $args ['before_widget'];
6181
+ ai_add_attr_data ($before_widget, 'style', 'padding: 0; border: 0; margin: 0; color: transparent; background: transparent;');
6182
+ ai_add_attr_data ($before_widget, 'class', 'ai-sticky-widget');
6183
+ echo $before_widget;
6184
+ echo $args ['after_widget'];
6185
+ return;
6186
+ }
6187
+ }
6188
+
6189
+ if ($block < 1 || $block > AD_INSERTER_BLOCKS) return;
6190
+
6191
+ $title = !empty ($instance ['widget-title']) ? $instance ['widget-title'] : '';
6192
+
6193
+ $obj = $block_object [$block];
6194
+ $obj->clear_code_cache ();
6195
+
6196
+ $globals_name = AI_WIDGET_COUNTER_NAME . $block;
6197
+
6198
+ if (!isset ($ad_inserter_globals [$globals_name])) {
6199
+ $ad_inserter_globals [$globals_name] = 1;
6200
+ } else $ad_inserter_globals [$globals_name] ++;
6201
+
6202
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0)
6203
+ ai_log ("WIDGET (". $obj->number . ') ['.$ad_inserter_globals [$globals_name] . ']');
6204
+
6205
+ $ai_wp_data [AI_CONTEXT] = AI_CONTEXT_WIDGET;
6206
+
6207
+ $ai_last_check = AI_CHECK_ENABLED_WIDGET;
6208
+ if (!$obj->get_enable_widget ()) return;
6209
+ if (!$obj->check_server_side_detection ()) return;
6210
+ if (!$obj->check_page_types_lists_users ()) return;
6211
+ if (!$obj->check_filter ($ad_inserter_globals [$globals_name])) return;
6212
+ if (!$obj->check_number_of_words ()) return;
6213
+
6214
+ if ($ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_POST || $ai_wp_data [AI_WP_PAGE_TYPE] == AI_PT_STATIC) {
6215
+ $meta_value = get_post_meta (get_the_ID (), '_adinserter_block_exceptions', true);
6216
+ $selected_blocks = explode (",", $meta_value);
6217
+ if (!$obj->check_post_page_exceptions ($selected_blocks)) return;
6218
+ }
6219
+
6220
+ // Last check before counter check before insertion
6221
+ $ai_last_check = AI_CHECK_CODE;
6222
+ if ($obj->ai_getCode () == '') {
6223
+ if ($sticky) {
6224
+ $before_widget = $args ['before_widget'];
6225
+ ai_add_attr_data ($before_widget, 'style', 'padding: 0; border: 0; margin: 0; color: transparent; background: transparent;');
6226
+ ai_add_attr_data ($before_widget, 'class', 'ai-sticky-widget');
6227
+ echo $before_widget;
6228
+ echo $args ['after_widget'];
6229
+ }
6230
+ return;
6231
+ }
6232
+
6233
+ // Last check before insertion
6234
+ if (!$obj->check_and_increment_block_counter ()) return;
6235
+
6236
+ $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
6237
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
6238
+
6239
+ $viewport_classes = $obj->get_client_side_action () == AI_CLIENT_SIDE_ACTION_INSERT ? '' : trim ($obj->get_viewport_classes ());
6240
+ $sticky_class = $sticky ? ' ai-sticky-widget' : '';
6241
+ $widget_classes = trim ($viewport_classes . $sticky_class);
6242
+
6243
+ if ($widget_classes != "") {
6244
+ $before_widget = $args ['before_widget'];
6245
+ ai_add_attr_data ($before_widget, 'class', $widget_classes);
6246
+ echo $before_widget;
6247
+ } else echo $args ['before_widget'];
6248
+
6249
+ if (!empty ($title)) {
6250
+ echo $args ['before_title'], apply_filters ('widget_title', $title), $args ['after_title'];
6251
+ }
6252
+
6253
+ echo $obj->get_code_for_serverside_insertion (false);
6254
+
6255
+ echo $args ['after_widget'];
6256
+
6257
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && $obj->get_detection_client_side())
6258
+ echo $obj->get_code_for_serverside_insertion (false, true);
6259
+
6260
+ $ai_last_check = AI_CHECK_INSERTED;
6261
+ }
6262
+ }
6263
+
6264
+ function ai_write_debugging_tools () {
6265
+ global $ai_wp_data;
6266
+
6267
+ ai_toolbar_menu_items ();
6268
+
6269
+
6270
+ echo "<style>
6271
+
6272
+ ul.ai-debug-tools {
6273
+ list-style: none;
6274
+ background: #000;
6275
+ color: #eee;
6276
+ margin: 0;
6277
+ padding: 10px;
6278
+ font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif;
6279
+ font-size: 14px;
6280
+ line-height: 22px;
6281
+ }
6282
+
6283
+ ul.ai-debug-tools li {
6284
+ margin: 0;
6285
+ padding: 0;
6286
+ border: 0;
6287
+ }
6288
+
6289
+ ul.ai-debug-tools a, ul.ai-debug-tools a:link, ul.ai-debug-tools a:visited {
6290
+ text-decoration: none;
6291
+ color: #aaa;
6292
+ }
6293
+
6294
+ ul.ai-debug-tools a:hover {
6295
+ color: #5faff9!important;
6296
+ }
6297
+
6298
+ ul.ai-debug-tools .ab-icon {
6299
+ position: relative;
6300
+ font: 400 20px/1 dashicons;
6301
+ speak: none;
6302
+ padding: 4px 0;
6303
+ -webkit-font-smoothing: antialiased;
6304
+ -moz-osx-font-smoothing: grayscale;
6305
+ background-image: none!important;
6306
+ margin-right: 6px;
6307
+ vertical-align: text-top;
6308
+ }
6309
+
6310
+ ul.ai-debug-tools .ai-debug-tools-title {
6311
+ padding-bottom: 10px;
6312
+ }
6313
+
6314
+ .ai-debug-tools-title .ab-icon:before {
6315
+ content: '\\f111';
6316
+ top: 2px;
6317
+ color: rgba(240,245,250,.6)!important;
6318
+ }
6319
+ ul.ai-debug-tools .ab-icon.on:before {
6320
+ color: #00f200!important;
6321
+ }
6322
+ .ai-debug-ai-toolbar-blocks .ab-icon:before {
6323
+ content: '\\f135';
6324
+ }
6325
+ .ai-debug-ai-toolbar-positions .ab-icon:before {
6326
+ content: '\\f207';
6327
+ }
6328
+ ul.ai-debug-tools .ai-debug-tools-positions {
6329
+ margin-left: 22px;
6330
+ }
6331
+ .ai-debug-tools-positions .ab-icon:before {
6332
+ content: '\\f522';
6333
+ }
6334
+ .ai-debug-ai-toolbar-tags .ab-icon:before {
6335
+ content: '\\f475';
6336
+ }
6337
+ .ai-debug-ai-toolbar-no-insertion .ab-icon:before {
6338
+ content: '\\f214';
6339
+ }
6340
+ .ai-debug-ai-toolbar-adb-status .ab-icon:before {
6341
+ content: '\\f223';
6342
+ }
6343
+ .ai-debug-ai-toolbar-adb .ab-icon:before {
6344
+ content: '\\f160';
6345
+ }
6346
+ .ai-debug-ai-toolbar-processing .ab-icon:before {
6347
+ content: '\\f464';
6348
+ }
6349
+ </style>
6350
+ ";
6351
+ echo '
6352
+ <ul class="ai-debug-tools">
6353
+ ';
6354
+ foreach ($ai_wp_data [AI_DEBUG_MENU_ITEMS] as $menu_item) {
6355
+ if (isset ($menu_item ['parent'])) {
6356
+ if ($menu_item ['parent'] == 'ai-toolbar-settings') {
6357
+ echo ' <li class="ai-debug-', $menu_item ['id'], '">';
6358
+ echo '<a href="', $menu_item ['href'], '">', $menu_item ['title'], '</a>';
6359
+ echo "</li>\n";
6360
+ }
6361
+ elseif ($menu_item ['parent'] == 'ai-toolbar-positions') {
6362
+ echo ' <li class="ai-debug-', $menu_item ['id'], ' ai-debug-tools-positions">';
6363
+ echo '<a href="', $menu_item ['href'], '">', $menu_item ['title'], '</a>';
6364
+ echo "</li>\n";
6365
+ }
6366
+ } else if ($menu_item ['id'] == 'ai-toolbar-settings') {
6367
+ echo ' <li class="ai-debug-', $menu_item ['id'], ' ai-debug-tools-title">';
6368
+ // echo '<a href="', $menu_item ['href'], '">', $menu_item ['title'], '</a>';
6369
+ // echo '<a href="', $menu_item ['href'], '">', str_replace (AD_INSERTER_NAME, 'Debugging', $menu_item ['title']), '</a>';
6370
+ echo '<a href="', $menu_item ['href'], '">', $menu_item ['title'], ' Debugging</a>';
6371
+ echo "</li>\n";
6372
+ }
6373
+ }
6374
+
6375
+ echo '</ul>
6376
+ ';
6377
+ }
6378
+
6379
+ function ai_special_widget ($args, $instance, $block) {
6380
+ global $ai_wp_data, $ai_db_options, $block_object;
6381
+
6382
+ $sticky = isset ($instance ['sticky']) ? $instance ['sticky'] : 0;
6383
+
6384
+ if ($sticky) {
6385
+ $ai_wp_data [AI_STICKY_WIDGETS] = true;
6386
+ ai_add_attr_data ($args ['before_widget'], 'class', 'ai-sticky-widget');
6387
+ echo $args ['before_widget'];
6388
+ } else echo $args ['before_widget'];
6389
+
6390
+ $title = !empty ($instance ['widget-title']) ? $instance ['widget-title'] : '';
6391
+
6392
+ if (!empty ($title)) {
6393
+ echo $args ['before_title'], apply_filters ('widget_title', $title), $args ['after_title'];
6394
+ }
6395
+
6396
+ switch ($block) {
6397
+ case 0:
6398
+ echo "<pre style='", AI_DEBUG_WIDGET_STYLE, "'>\n";
6399
+ ai_write_debug_info ();
6400
+ echo "</pre>";
6401
+
6402
+ if ($ai_wp_data [AI_CLIENT_SIDE_DETECTION]) {
6403
+ for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
6404
+ $viewport_name = get_viewport_name ($viewport);
6405
+ if ($viewport_name != '') {
6406
+ echo "<pre class='ai-viewport-" . $viewport ."' style='", AI_DEBUG_WIDGET_STYLE, "'>\n";
6407
+ echo "CLIENT-SIDE DEVICE: ", $viewport_name;
6408
+ echo "</pre>";
6409
+ }
6410
+ }
6411
+ }
6412
+ break;
6413
+ case - 2:
6414
+ ai_write_debugging_tools ();
6415
+ break;
6416
+ }
6417
+
6418
+ echo $args ['after_widget'];
6419
+ }
class.php CHANGED
@@ -352,16 +352,15 @@ abstract class ai_BaseCodeBlock {
352
  unset ($this->wp_options ['GENERATED_CODE']);
353
  }
354
 
355
- public function ai_getCode ($client_code = null, $process_php = null){
356
  global $block_object, $ai_total_php_time, $ai_wp_data;
357
 
358
  if ($this->fallback != 0) return $block_object [$this->fallback]->ai_getCode ();
359
 
360
  $obj = $this;
361
- $code = $client_code === null ? $obj->get_ad_data() : $client_code;
362
- $php = $process_php === null ? $obj->get_process_php () : $process_php;
363
 
364
- if ($php && (!is_multisite() || is_main_site () || multisite_php_processing ())) {
365
  $global_name = 'GENERATED_CODE';
366
  if (isset ($obj->wp_options [$global_name])) return $obj->wp_options [$global_name];
367
 
@@ -437,6 +436,14 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
437
  if (defined ('AI_STICKY_SETTINGS') && AI_STICKY_SETTINGS) {
438
  $this->wp_options [AI_OPTION_HORIZONTAL_POSITION] = DEFAULT_HORIZONTAL_POSITION;
439
  $this->wp_options [AI_OPTION_VERTICAL_POSITION] = DEFAULT_VERTICAL_POSITION;
 
 
 
 
 
 
 
 
440
  }
441
  $this->wp_options [AI_OPTION_GENERAL_TAG] = AD_GENERAL_TAG;
442
  $this->wp_options [AI_OPTION_SCHEDULING] = AI_SCHEDULING_OFF;
@@ -661,9 +668,19 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
661
  }
662
  }
663
 
664
- public function sticky_style ($vertical_position, $horizontal_position) {
665
  $style = "";
666
 
 
 
 
 
 
 
 
 
 
 
667
  switch ($vertical_position) {
668
  case AI_STICK_TO_THE_TOP:
669
  switch ($horizontal_position) {
@@ -674,19 +691,26 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
674
  $style = AI_ALIGNMENT_CSS_STICK_TO_THE_TOP_OFFSET;
675
  break;
676
  }
 
 
 
677
  break;
678
  case AI_STICK_VERTICAL_CENTER:
679
- switch ($horizontal_position) {
680
- case AI_STICK_HORIZONTAL_CENTER:
681
- $style = AI_ALIGNMENT_CSS_CENTER_VERTICAL_H;
682
- break;
683
- default:
684
- $style = AI_ALIGNMENT_CSS_CENTER_VERTICAL;
685
- break;
686
- }
 
687
  break;
688
  case AI_SCROLL_WITH_THE_CONTENT:
689
  $style = AI_ALIGNMENT_CSS_SCROLL_WITH_THE_CONTENT;
 
 
 
690
  break;
691
  case AI_STICK_TO_THE_BOTTOM:
692
  switch ($horizontal_position) {
@@ -697,36 +721,61 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
697
  $style = AI_ALIGNMENT_CSS_STICK_TO_THE_BOTTOM_OFFSET;
698
  break;
699
  }
 
 
 
700
  break;
701
  }
702
 
703
  switch ($horizontal_position) {
704
  case AI_STICK_TO_THE_LEFT:
705
  $style .= AI_ALIGNMENT_CSS_STICK_TO_THE_LEFT;
 
 
 
706
  break;
707
  case AI_STICK_TO_THE_CONTENT_LEFT:
708
  $style .= AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_LEFT;
 
 
 
 
 
 
709
  break;
710
  case AI_STICK_HORIZONTAL_CENTER:
711
- switch ($vertical_position) {
712
- case AI_STICK_VERTICAL_CENTER:
713
- $style .= AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL_V;
714
- break;
715
- default:
716
- $style .= AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL;
717
- break;
718
- }
 
719
  break;
720
  case AI_STICK_TO_THE_CONTENT_RIGHT:
721
  $style .= AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_RIGHT;
 
 
 
 
 
 
722
  break;
723
  case AI_STICK_TO_THE_RIGHT:
724
  switch ($vertical_position) {
725
  case AI_SCROLL_WITH_THE_CONTENT:
726
  $style .= AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT_SCROLL;
 
 
 
727
  break;
728
  default:
729
  $style .= AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT;
 
 
 
730
  break;
731
  }
732
  break;
@@ -738,31 +787,40 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
738
  public function stick_to_the_content_class () {
739
  $classes = array ();
740
 
741
- switch ($this->get_alignment_type ()) {
 
 
 
 
 
 
 
742
  case AI_ALIGNMENT_STICKY:
743
- switch ($this->get_horizontal_position ()) {
744
- case AI_STICK_TO_THE_CONTENT_LEFT:
745
- $classes []= 'ai-sticky-left';
746
- break;
747
- case AI_STICK_TO_THE_CONTENT_RIGHT:
748
- $classes []= 'ai-sticky-right';
749
- break;
750
- }
751
- switch ($this->get_vertical_position ()) {
 
752
  case AI_SCROLL_WITH_THE_CONTENT:
753
  $classes []= 'ai-sticky-scroll';
754
  break;
755
  }
756
  break;
757
  case AI_ALIGNMENT_CUSTOM_CSS:
758
- $custom_css = str_replace (' ', '', $this->get_custom_css ());
759
- if (strpos ($custom_css, 'position:fixed') !== false &&
760
- strpos ($custom_css, 'z-index:' . AI_STICKY_Z_INDEX) !== false &&
761
- strpos ($custom_css, 'display:none') !== false) {
762
- if (strpos ($custom_css, ';left:auto') !== false) $classes []= 'ai-sticky-left'; // ; to avoid margin-left:auto
763
- elseif (strpos ($custom_css, 'right:auto') !== false) $classes []= 'ai-sticky-right';
764
-
765
- if (strpos ($custom_css, 'margin-bottom:auto') !== false) $classes []= 'ai-sticky-scroll';
 
766
  }
767
  break;
768
  }
@@ -770,6 +828,162 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
770
  return implode (' ', $classes);
771
  }
772
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
773
  public function alignment_style ($alignment_type, $all_styles = false, $full_sticky_style = true) {
774
 
775
  $style = "";
@@ -807,7 +1021,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
807
  case AI_ALIGNMENT_STICKY:
808
  $style = AI_ALIGNMENT_CSS_STICKY;
809
  if ($full_sticky_style) {
810
- $style .= $this->sticky_style ($this->get_vertical_position (), $this->get_horizontal_position ());
811
  }
812
  break;
813
  case AI_ALIGNMENT_CUSTOM_CSS:
@@ -1370,8 +1584,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1370
  return $counters;
1371
  }
1372
 
1373
- public function ai_getAdLabel ($show_label = null) {
1374
- $label_enabled = $show_label === null ? $this->get_show_label () : $show_label;
1375
 
1376
  if (!$label_enabled) return '';
1377
 
@@ -1382,10 +1596,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1382
  return $ad_label .= "\n";
1383
  }
1384
 
1385
- public function ai_getProcessedCode ($hide_label = false, $force_server_side_code = false, $client_code = null, $process_php = null, $show_label = null) {
1386
  global $ai_wp_data, $ad_inserter_globals, $block_object;
1387
 
1388
- $code = $this->ai_getCode ($client_code, $process_php);
1389
 
1390
  // Clear the codes for cases when the code block is called more than once
1391
  $this->additional_code_before = '';
@@ -1394,10 +1608,10 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1394
  // Code for ad label, close button
1395
  $additional_code = '';
1396
 
1397
- $additional_code .= $this->ai_getAdLabel ($show_label);
1398
 
1399
  $alignment_type = $this->get_alignment_type ();
1400
- if ($this->get_close_button () != AI_CLOSE_NONE && !$ai_wp_data [AI_WP_AMP_PAGE] && $alignment_type != AI_ALIGNMENT_NO_WRAPPING && $client_code === null) {
1401
  switch ($this->get_close_button ()) {
1402
  case AI_CLOSE_TOP_RIGHT:
1403
  $button_class = 'ai-close-button';
@@ -1466,9 +1680,42 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1466
  $ads = array_values ($ads);
1467
  } else array_unshift ($ai_wp_data [AI_SHORTCODES]['rotate'], array ('name' => ''));
1468
 
 
1469
  $version_names = array ();
 
1470
  foreach ($ai_wp_data [AI_SHORTCODES]['rotate'] as $index => $option) {
1471
  $version_names []= isset ($option ['name']) && trim ($option ['name']) != '' ? $option ['name'] : chr (ord ('A') + $index);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1472
  }
1473
 
1474
  $amp_dynamic_blocks = $dynamic_blocks;
@@ -1476,17 +1723,29 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1476
 
1477
  switch ($amp_dynamic_blocks) {
1478
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
1479
- $this->code_version = mt_rand (1, count ($ads));
 
 
 
 
 
 
 
1480
  $processed_code = $additional_code . trim ($ads [$this->code_version - 1]);
1481
  $this->version_name = $version_names [$this->code_version - 1];
1482
  break;
1483
  case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
1484
  $this->code_version = '""';
1485
 
 
 
 
 
 
1486
  if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !get_inline_styles ()) {
1487
- $processed_code = "\n<div class='ai-rotate'>\n" . $additional_code;
1488
  } else
1489
- $processed_code = "\n<div class='ai-rotate' style='position: relative;'>\n" . $additional_code;
1490
 
1491
  foreach ($ads as $index => $ad) {
1492
 
@@ -1501,22 +1760,27 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1501
  switch ($index) {
1502
  case 0:
1503
  if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !get_inline_styles ()) {
1504
- $processed_code .= "<div class='ai-rotate-option'".$version_name_data.">\n".trim ($ad, "\n")."\n</div>\n";
1505
  } else
1506
- $processed_code .= "<div class='ai-rotate-option' style='visibility: hidden;'".$version_name_data.">\n".trim ($ad, "\n")."\n</div>\n";
1507
  break;
1508
  default:
1509
  if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !get_inline_styles ()) {
1510
- $processed_code .= "<div class='ai-rotate-option ai-rotate-options'".$version_name_data.">".trim ($ad, "\n")."\n</div>\n";
1511
  } else
1512
- $processed_code .= "<div class='ai-rotate-option' style='visibility: hidden; position: absolute; top: 0; left: 0; width: 100%; height: 100%;'".$version_name_data.">".trim ($ad, "\n")."\n</div>\n";
1513
  break;
1514
  }
1515
  }
1516
  $processed_code .= "</div>\n";
1517
  break;
1518
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
1519
- $this->w3tc_code = '$ai_code = unserialize (base64_decode (\''.base64_encode (serialize ($ads)).'\')); $ai_index = mt_rand (1, count ($ai_code)); $ai_code = base64_decode (\''.base64_encode ($additional_code).'\') . $ai_code [$ai_index - 1]; $ai_enabled = true;';
 
 
 
 
 
1520
  $processed_code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1521
  $processed_code .= $this->w3tc_code.' echo $ai_code;';
1522
  $processed_code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
@@ -1606,13 +1870,13 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1606
  }
1607
  }
1608
 
1609
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 /*&& !$hide_label*/) {
1610
  $processed_code = "<div class='ai-code'>\n" . $processed_code ."</div>\n";
1611
  }
1612
 
1613
- if (function_exists ('ai_adb_block_actions')) ai_adb_block_actions ($this, $hide_label);
1614
 
1615
- if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$hide_label) {
1616
  $title = '';
1617
  $fallback_block_name = '';
1618
 
@@ -1742,15 +2006,7 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1742
  $sticky_parameters = '';
1743
 
1744
  if (!$ai_wp_data [AI_WP_AMP_PAGE]) {
1745
- $stick_to_the_content_class = $this->stick_to_the_content_class ();
1746
-
1747
- if ($stick_to_the_content_class != '') {
1748
- $classes [] = 'ai-sticky-content';
1749
- $classes [] = $stick_to_the_content_class;
1750
-
1751
- // $classes [] = 'ai-sticky-parameters';
1752
- // $sticky_parameters = ' data-ai-parameters="'.base64_encode ('[3500,0,1500]').'"';
1753
- }
1754
  }
1755
 
1756
  if ($this->get_close_button () && !$ai_wp_data [AI_WP_AMP_PAGE]) {
@@ -1957,17 +2213,57 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
1957
  return $serverside_insertion_code;
1958
  }
1959
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1960
  public function get_ad_general_tag(){
1961
  $option = isset ($this->wp_options [AI_OPTION_GENERAL_TAG]) ? $this->wp_options [AI_OPTION_GENERAL_TAG] : "";
1962
  if ($option == '') $option = AD_GENERAL_TAG;
1963
  return $option;
1964
  }
1965
 
1966
- public function get_close_button (){
1967
- $option = isset ($this->wp_options [AI_OPTION_CLOSE_BUTTON]) ? $this->wp_options [AI_OPTION_CLOSE_BUTTON] : DEFAULT_CLOSE_BUTTON;
1968
- return $option;
1969
- }
1970
-
1971
  public function get_adb_block_action (){
1972
  $option = isset ($this->wp_options [AI_OPTION_ADB_BLOCK_ACTION]) ? $this->wp_options [AI_OPTION_ADB_BLOCK_ACTION] : DEFAULT_ADB_BLOCK_ACTION;
1973
  return $option;
@@ -2784,8 +3080,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
2784
 
2785
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
2786
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
2787
- $ai_last_check = AI_CHECK_INSERTED;
2788
  $inserted_code = $this->get_code_for_serverside_insertion ();
 
2789
  $inserted = true;
2790
  }
2791
  }
@@ -3381,8 +3677,8 @@ abstract class ai_CodeBlock extends ai_BaseCodeBlock {
3381
 
3382
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
3383
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
3384
- $ai_last_check = AI_CHECK_INSERTED;
3385
  $inserted_code = $this->get_code_for_serverside_insertion ();
 
3386
  $inserted = true;
3387
  }
3388
  }
@@ -4907,6 +5203,7 @@ class ai_code_generator {
4907
  array (
4908
  'code' => $code,
4909
  'name' => '',
 
4910
  ),
4911
  ),
4912
  );
@@ -4922,8 +5219,9 @@ class ai_code_generator {
4922
  foreach ($options as $index => $option) {
4923
  $option_code = trim ($option, "\n");
4924
  $option_name = isset ($ai_wp_data [AI_SHORTCODES]['rotate'][$index - 1]['name']) ? $ai_wp_data [AI_SHORTCODES]['rotate'][$index - 1]['name'] : '';
 
4925
  if ($index == 0 && $option_code == '') continue;
4926
- $data ['options'] []= array ('code' => $option_code, 'name' => $option_name);
4927
  }
4928
  }
4929
 
@@ -4939,9 +5237,10 @@ class ai_code_generator {
4939
  foreach ($rotation_data as $index => $rotation_data_row) {
4940
 
4941
  $name = trim ($rotation_data_row ['name']);
 
4942
  $code = trim ($rotation_data_row ['code'], "\n");
4943
 
4944
- if ($index != 0 || $name != '') {
4945
 
4946
  $shortcode = "" ;
4947
  if ($index != 0) $shortcode .= "\n\n";
@@ -4949,6 +5248,7 @@ class ai_code_generator {
4949
  $shortcode .= '[ADINSERTER ROTATE';
4950
 
4951
  if ($name != '') $shortcode .= ' name="'.str_replace ('"', '\'', $name).'"';
 
4952
  $shortcode .= "]\n\n";
4953
  } else $shortcode = '';
4954
 
352
  unset ($this->wp_options ['GENERATED_CODE']);
353
  }
354
 
355
+ public function ai_getCode (){
356
  global $block_object, $ai_total_php_time, $ai_wp_data;
357
 
358
  if ($this->fallback != 0) return $block_object [$this->fallback]->ai_getCode ();
359
 
360
  $obj = $this;
361
+ $code = $obj->get_ad_data();
 
362
 
363
+ if ($obj->get_process_php () && (!is_multisite() || is_main_site () || multisite_php_processing ())) {
364
  $global_name = 'GENERATED_CODE';
365
  if (isset ($obj->wp_options [$global_name])) return $obj->wp_options [$global_name];
366
 
436
  if (defined ('AI_STICKY_SETTINGS') && AI_STICKY_SETTINGS) {
437
  $this->wp_options [AI_OPTION_HORIZONTAL_POSITION] = DEFAULT_HORIZONTAL_POSITION;
438
  $this->wp_options [AI_OPTION_VERTICAL_POSITION] = DEFAULT_VERTICAL_POSITION;
439
+ $this->wp_options [AI_OPTION_HORIZONTAL_MARGIN] = DEFAULT_HORIZONTAL_MARGIN;
440
+ $this->wp_options [AI_OPTION_VERTICAL_MARGIN] = DEFAULT_VERTICAL_MARGIN;
441
+ $this->wp_options [AI_OPTION_ANIMATION] = DEFAULT_ANIMATION;
442
+ $this->wp_options [AI_OPTION_ANIMATION_TRIGGER] = DEFAULT_ANIMATION_TRIGGER;
443
+ $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_VALUE] = DEFAULT_ANIMATION_TRIGGER_VALUE;
444
+ $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_OFFSET] = DEFAULT_ANIMATION_TRIGGER_OFFSET;
445
+ $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_DELAY] = DEFAULT_ANIMATION_TRIGGER_DELAY;
446
+ $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_ONCE] = DEFAULT_ANIMATION_TRIGGER_ONCE;
447
  }
448
  $this->wp_options [AI_OPTION_GENERAL_TAG] = AD_GENERAL_TAG;
449
  $this->wp_options [AI_OPTION_SCHEDULING] = AI_SCHEDULING_OFF;
668
  }
669
  }
670
 
671
+ public function sticky_style ($horizontal_position, $vertical_position, $horizontal_margin = null, $vertical_margin = null) {
672
  $style = "";
673
 
674
+ if ($horizontal_margin === null) $horizontal_margin = trim ($this->get_horizontal_margin ());
675
+ if ($vertical_margin === null) $vertical_margin = trim ($this->get_vertical_margin ());
676
+
677
+ $animation = $this->get_animation () != AI_ANIMATION_NONE;
678
+
679
+ $main_content_fixed_width = is_numeric (get_main_content_element ());
680
+ if ($main_content_fixed_width) {
681
+ $main_content_shift = (int) (get_main_content_element () / 2);
682
+ }
683
+
684
  switch ($vertical_position) {
685
  case AI_STICK_TO_THE_TOP:
686
  switch ($horizontal_position) {
691
  $style = AI_ALIGNMENT_CSS_STICK_TO_THE_TOP_OFFSET;
692
  break;
693
  }
694
+ if ($vertical_margin != '') {
695
+ $style = ai_change_css ($style, 'top', $vertical_margin . 'px');
696
+ }
697
  break;
698
  case AI_STICK_VERTICAL_CENTER:
699
+ if ($animation) $style .= AI_ALIGNMENT_CSS_CENTER_VERTICAL_H_ANIM; else
700
+ switch ($horizontal_position) {
701
+ case AI_STICK_HORIZONTAL_CENTER:
702
+ $style = AI_ALIGNMENT_CSS_CENTER_VERTICAL_H_ANIM;
703
+ break;
704
+ default:
705
+ $style = AI_ALIGNMENT_CSS_CENTER_VERTICAL;
706
+ break;
707
+ }
708
  break;
709
  case AI_SCROLL_WITH_THE_CONTENT:
710
  $style = AI_ALIGNMENT_CSS_SCROLL_WITH_THE_CONTENT;
711
+ if ($vertical_margin != '') {
712
+ $style = ai_change_css ($style, 'top', $vertical_margin . 'px');
713
+ }
714
  break;
715
  case AI_STICK_TO_THE_BOTTOM:
716
  switch ($horizontal_position) {
721
  $style = AI_ALIGNMENT_CSS_STICK_TO_THE_BOTTOM_OFFSET;
722
  break;
723
  }
724
+ if ($vertical_margin != '') {
725
+ $style = ai_change_css ($style, 'bottom', $vertical_margin . 'px');
726
+ }
727
  break;
728
  }
729
 
730
  switch ($horizontal_position) {
731
  case AI_STICK_TO_THE_LEFT:
732
  $style .= AI_ALIGNMENT_CSS_STICK_TO_THE_LEFT;
733
+ if ($horizontal_margin != '') {
734
+ $style = ai_change_css ($style, 'left', $horizontal_margin . 'px');
735
+ }
736
  break;
737
  case AI_STICK_TO_THE_CONTENT_LEFT:
738
  $style .= AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_LEFT;
739
+ if ($horizontal_margin != '') {
740
+ $style = ai_change_css ($style, 'margin-right', $horizontal_margin . 'px');
741
+ }
742
+ if ($main_content_fixed_width) {
743
+ $style = $style . ai_change_css (AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_LEFT_W, 'right', 'calc(50% + ' . $main_content_shift . 'px)');
744
+ }
745
  break;
746
  case AI_STICK_HORIZONTAL_CENTER:
747
+ if ($animation) $style .= AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL_ANIM; else
748
+ switch ($vertical_position) {
749
+ case AI_STICK_VERTICAL_CENTER:
750
+ $style .= AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL_V;
751
+ break;
752
+ default:
753
+ $style .= AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL;
754
+ break;
755
+ }
756
  break;
757
  case AI_STICK_TO_THE_CONTENT_RIGHT:
758
  $style .= AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_RIGHT;
759
+ if ($horizontal_margin != '') {
760
+ $style = ai_change_css ($style, 'margin-left', $horizontal_margin . 'px');
761
+ }
762
+ if ($main_content_fixed_width) {
763
+ $style = $style . ai_change_css (AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_RIGHT_W, 'left', 'calc(50% + ' . $main_content_shift . 'px)');
764
+ }
765
  break;
766
  case AI_STICK_TO_THE_RIGHT:
767
  switch ($vertical_position) {
768
  case AI_SCROLL_WITH_THE_CONTENT:
769
  $style .= AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT_SCROLL;
770
+ if ($horizontal_margin != '') {
771
+ $style = ai_change_css ($style, 'margin-left', $horizontal_margin . 'px');
772
+ }
773
  break;
774
  default:
775
  $style .= AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT;
776
+ if ($horizontal_margin != '') {
777
+ $style = ai_change_css ($style, 'right', $horizontal_margin . 'px');
778
+ }
779
  break;
780
  }
781
  break;
787
  public function stick_to_the_content_class () {
788
  $classes = array ();
789
 
790
+ $alignment_type = $this->get_alignment_type ();
791
+ $custom_css = $this->get_custom_css ();
792
+ $horizontal_position = $this->get_horizontal_position ();
793
+ $vertical_position = $this->get_vertical_position ();
794
+
795
+ $main_content_fixed_width = is_numeric (get_main_content_element ());
796
+
797
+ switch ($alignment_type) {
798
  case AI_ALIGNMENT_STICKY:
799
+ if (!$main_content_fixed_width)
800
+ switch ($horizontal_position) {
801
+ case AI_STICK_TO_THE_CONTENT_LEFT:
802
+ $classes []= 'ai-sticky-left';
803
+ break;
804
+ case AI_STICK_TO_THE_CONTENT_RIGHT:
805
+ $classes []= 'ai-sticky-right';
806
+ break;
807
+ }
808
+ switch ($vertical_position) {
809
  case AI_SCROLL_WITH_THE_CONTENT:
810
  $classes []= 'ai-sticky-scroll';
811
  break;
812
  }
813
  break;
814
  case AI_ALIGNMENT_CUSTOM_CSS:
815
+ $clean_custom_css_code = str_replace (' ', '', $custom_css);
816
+ if (!$main_content_fixed_width &&
817
+ strpos ($clean_custom_css_code, 'position:fixed') !== false &&
818
+ strpos ($clean_custom_css_code, 'z-index:') !== false &&
819
+ strpos ($clean_custom_css_code, 'display:none') !== false) {
820
+ if (strpos ($clean_custom_css_code, ';left:auto') !== false) $classes []= 'ai-sticky-left'; // ; to avoid margin-left:auto
821
+ elseif (strpos ($clean_custom_css_code, 'right:auto') !== false) $classes []= 'ai-sticky-right';
822
+
823
+ if (strpos ($clean_custom_css_code, 'margin-bottom:auto') !== false) $classes []= 'ai-sticky-scroll';
824
  }
825
  break;
826
  }
828
  return implode (' ', $classes);
829
  }
830
 
831
+ public function sticky_parameters (&$classes, $preview = false) {
832
+ global $ai_wp_data;
833
+
834
+ $sticky_parameters = '';
835
+
836
+ $custom_sticky_css = false;
837
+ if ($this->get_alignment_type () == AI_ALIGNMENT_CUSTOM_CSS) {
838
+ $clean_custom_css_code = str_replace (' ', '', $this->get_custom_css ());
839
+ if (strpos ($clean_custom_css_code, 'position:fixed') !== false && strpos ($clean_custom_css_code, 'z-index:') !== false) $custom_sticky_css = true;
840
+ }
841
+
842
+ if ($this->get_alignment_type () == AI_ALIGNMENT_STICKY || $custom_sticky_css) {
843
+
844
+ $stick_to_the_content_class = $this->stick_to_the_content_class ();
845
+
846
+ if ($stick_to_the_content_class != '') {
847
+ $classes [] = 'ai-sticky-content';
848
+ $classes [] = $stick_to_the_content_class;
849
+ }
850
+
851
+ $horizontal_position = $this->get_horizontal_position ();
852
+ $vertical_position = $this->get_vertical_position ();
853
+ $animation = $this->get_animation ();
854
+
855
+ $direction = '';
856
+
857
+ switch ($horizontal_position) {
858
+ case AI_STICK_TO_THE_LEFT:
859
+ case AI_STICK_TO_THE_CONTENT_LEFT:
860
+ $direction = 'right';
861
+ break;
862
+ case AI_STICK_HORIZONTAL_CENTER:
863
+ $classes [] = 'ai-center-h';
864
+ switch ($vertical_position) {
865
+ case AI_STICK_TO_THE_TOP:
866
+ case AI_SCROLL_WITH_THE_CONTENT:
867
+ $direction = 'down';
868
+ break;
869
+ case AI_STICK_VERTICAL_CENTER:
870
+ $direction = 'left';
871
+ switch ($animation) {
872
+ case AI_ANIMATION_SLIDE:
873
+ case AI_ANIMATION_SLIDE_FADE:
874
+ $animation = AI_ANIMATION_FADE;
875
+ break;
876
+ case AI_ANIMATION_ZOOM_IN:
877
+ case AI_ANIMATION_ZOOM_OUT:
878
+ $direction = 'up';
879
+ break;
880
+ }
881
+ break;
882
+ case AI_STICK_TO_THE_BOTTOM:
883
+ $direction = 'up';
884
+ break;
885
+ }
886
+ break;
887
+ case AI_STICK_TO_THE_CONTENT_RIGHT:
888
+ case AI_STICK_TO_THE_RIGHT:
889
+ $direction = 'left';
890
+ break;
891
+ }
892
+
893
+ if ($vertical_position == AI_STICK_VERTICAL_CENTER) $classes [] = 'ai-center-v';
894
+
895
+ switch ($horizontal_position) {
896
+ case AI_STICK_TO_THE_LEFT:
897
+ if ($animation == AI_ANIMATION_TURN) $direction = 'left';
898
+ break;
899
+ case AI_STICK_TO_THE_RIGHT:
900
+ if ($animation == AI_ANIMATION_TURN) $direction = 'right';
901
+ break;
902
+ case AI_STICK_TO_THE_CONTENT_LEFT:
903
+ case AI_STICK_TO_THE_CONTENT_RIGHT:
904
+ if ($animation == AI_ANIMATION_SLIDE) $animation = AI_ANIMATION_SLIDE_FADE;
905
+ break;
906
+ }
907
+
908
+ switch ($animation) {
909
+ case AI_ANIMATION_FADE:
910
+ $sticky_parameters .= ' data-aos="fade"';
911
+ break;
912
+ case AI_ANIMATION_SLIDE:
913
+ $sticky_parameters .= ' data-aos="slide-'.$direction.'"';
914
+ break;
915
+ case AI_ANIMATION_SLIDE_FADE:
916
+ $sticky_parameters .= ' data-aos="fade-'.$direction.'"';
917
+ break;
918
+ case AI_ANIMATION_TURN:
919
+ $classes [] = 'ai-sticky-turn';
920
+ $sticky_parameters .= ' data-aos="flip-'.$direction.'"';
921
+ break;
922
+ case AI_ANIMATION_FLIP:
923
+ if ($direction == 'right') $direction = 'left';
924
+ elseif ($direction == 'left') $direction = 'right';
925
+ $sticky_parameters .= ' data-aos="flip-'.$direction.'"';
926
+ break;
927
+ case AI_ANIMATION_ZOOM_IN:
928
+ $sticky_parameters .= ' data-aos="zoom-in-'.$direction.'"';
929
+ break;
930
+ case AI_ANIMATION_ZOOM_OUT:
931
+ $sticky_parameters .= ' data-aos="zoom-out-'.$direction.'"';
932
+ break;
933
+ }
934
+
935
+ if (!$preview) {
936
+ switch ($this->get_animation_trigger ()) {
937
+ case AI_TRIGGER_PAGE_SCROLLED_PC:
938
+ $pc = $this->get_animation_trigger_value ();
939
+ if (!is_numeric ($pc)) $pc = 0;
940
+ $pc = intval ($pc);
941
+ if ($pc < 0) $pc = 0;
942
+ if ($pc > 100) $pc = 100;
943
+ $pc = number_format ($pc / 100, 2);
944
+ if (!isset ($ai_wp_data [AI_TRIGGER_ELEMENTS])) $ai_wp_data [AI_TRIGGER_ELEMENTS] = array ();
945
+ $ai_wp_data [AI_TRIGGER_ELEMENTS][$this->number] = $pc;
946
+ $sticky_parameters .= ' data-aos-anchor="#ai-position-'.$this->number.'" data-aos-anchor-placement="top-top"';
947
+ break;
948
+ case AI_TRIGGER_PAGE_SCROLLED_PX:
949
+ $px = $this->get_animation_trigger_value ();
950
+ if (!is_numeric ($px)) $px = 0;
951
+ $px = intval ($px);
952
+ if ($px < 0) $px = 0;
953
+ if (!isset ($ai_wp_data [AI_TRIGGER_ELEMENTS])) $ai_wp_data [AI_TRIGGER_ELEMENTS] = array ();
954
+ $ai_wp_data [AI_TRIGGER_ELEMENTS][$this->number] = $px;
955
+ $sticky_parameters .= ' data-aos-anchor="#ai-position-'.$this->number.'" data-aos-anchor-placement="top-top"';
956
+ break;
957
+ case AI_TRIGGER_ELEMENT_VISIBLE:
958
+ $sticky_parameters .= ' data-aos-anchor="'.$this->get_animation_trigger_value ().'"';
959
+ break;
960
+ }
961
+
962
+ $offset = $this->get_animation_trigger_offset ();
963
+ if (is_numeric ($offset)) {
964
+ $offset = intval ($offset);
965
+ if ($offset < -1000) $offset = - 1000;
966
+ elseif ($offset > 1000) $offset = 1000;
967
+
968
+ $sticky_parameters .= ' data-aos-offset="'.$offset.'"';
969
+ }
970
+
971
+ $delay = $this->get_animation_trigger_delay ();
972
+ if (is_numeric ($delay) && $delay > 0) {
973
+ $delay = intval ($delay);
974
+
975
+ $sticky_parameters .= ' data-aos-delay="'.$delay.'"';
976
+ }
977
+
978
+ if ($this->get_animation_trigger_once ()) {
979
+ $sticky_parameters .= ' data-aos-once="true"';
980
+ }
981
+ }
982
+ }
983
+
984
+ return $sticky_parameters;
985
+ }
986
+
987
  public function alignment_style ($alignment_type, $all_styles = false, $full_sticky_style = true) {
988
 
989
  $style = "";
1021
  case AI_ALIGNMENT_STICKY:
1022
  $style = AI_ALIGNMENT_CSS_STICKY;
1023
  if ($full_sticky_style) {
1024
+ $style .= $this->sticky_style ($this->get_horizontal_position (), $this->get_vertical_position ());
1025
  }
1026
  break;
1027
  case AI_ALIGNMENT_CUSTOM_CSS:
1584
  return $counters;
1585
  }
1586
 
1587
+ public function ai_getAdLabel () {
1588
+ $label_enabled = $this->get_show_label ();
1589
 
1590
  if (!$label_enabled) return '';
1591
 
1596
  return $ad_label .= "\n";
1597
  }
1598
 
1599
+ public function ai_getProcessedCode ($hide_debug_label = false, $force_server_side_code = false, $force_close_button = false) {
1600
  global $ai_wp_data, $ad_inserter_globals, $block_object;
1601
 
1602
+ $code = $this->ai_getCode ();
1603
 
1604
  // Clear the codes for cases when the code block is called more than once
1605
  $this->additional_code_before = '';
1608
  // Code for ad label, close button
1609
  $additional_code = '';
1610
 
1611
+ $additional_code .= $this->ai_getAdLabel ();
1612
 
1613
  $alignment_type = $this->get_alignment_type ();
1614
+ if ($force_close_button || ($this->get_close_button () != AI_CLOSE_NONE && !$ai_wp_data [AI_WP_AMP_PAGE] && $alignment_type != AI_ALIGNMENT_NO_WRAPPING)) {
1615
  switch ($this->get_close_button ()) {
1616
  case AI_CLOSE_TOP_RIGHT:
1617
  $button_class = 'ai-close-button';
1680
  $ads = array_values ($ads);
1681
  } else array_unshift ($ai_wp_data [AI_SHORTCODES]['rotate'], array ('name' => ''));
1682
 
1683
+ $shares = false;
1684
  $version_names = array ();
1685
+ $version_shares = array ();
1686
  foreach ($ai_wp_data [AI_SHORTCODES]['rotate'] as $index => $option) {
1687
  $version_names []= isset ($option ['name']) && trim ($option ['name']) != '' ? $option ['name'] : chr (ord ('A') + $index);
1688
+ if (isset ($option ['share'])) $shares = true;
1689
+ $version_shares []= isset ($option ['share']) && is_numeric ($option ['share']) ? intval ($option ['share']) : - 1;
1690
+ }
1691
+
1692
+ if ($shares) {
1693
+ $total_share = 0;
1694
+ $no_share = 0;
1695
+
1696
+ foreach ($version_shares as $index => $share) {
1697
+ if ($share < 0) $no_share ++; else $total_share += $share;
1698
+ }
1699
+
1700
+ if ($total_share > 100 || $no_share == 0) {
1701
+ $scale = $total_share / 100;
1702
+ } else $scale = 1;
1703
+
1704
+ foreach ($version_shares as $index => $share) {
1705
+ // Disable options with share 0
1706
+ if ($share == 0) $version_shares [$index] = - 1; else
1707
+ if ($share < 0) $version_shares [$index] = (100 - $total_share / $scale) / $no_share; else
1708
+ $version_shares [$index] = $share / $scale;
1709
+ }
1710
+
1711
+ $thresholds = array ();
1712
+ $total_share = 0;
1713
+ foreach ($version_shares as $index => $share) {
1714
+ if ($share >= 0) {
1715
+ $total_share += $share;
1716
+ $thresholds [] = round ($total_share);
1717
+ } else $thresholds [] = - 1;
1718
+ }
1719
  }
1720
 
1721
  $amp_dynamic_blocks = $dynamic_blocks;
1723
 
1724
  switch ($amp_dynamic_blocks) {
1725
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE:
1726
+ if ($shares) {
1727
+ $random_threshold = mt_rand (0, 100);
1728
+ foreach ($thresholds as $index => $threshold) {
1729
+ $this->code_version = $index + 1;
1730
+ if ($random_threshold <= $threshold) break;
1731
+ }
1732
+ } else $this->code_version = mt_rand (1, count ($ads));
1733
+
1734
  $processed_code = $additional_code . trim ($ads [$this->code_version - 1]);
1735
  $this->version_name = $version_names [$this->code_version - 1];
1736
  break;
1737
  case AI_DYNAMIC_BLOCKS_CLIENT_SIDE:
1738
  $this->code_version = '""';
1739
 
1740
+ $version_share_data = '';
1741
+ if ($shares) {
1742
+ $version_share_data = " data-shares='".base64_encode (json_encode ($thresholds))."'";
1743
+ }
1744
+
1745
  if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !get_inline_styles ()) {
1746
+ $processed_code = "\n<div class='ai-rotate'".$version_share_data.">\n" . $additional_code;
1747
  } else
1748
+ $processed_code = "\n<div class='ai-rotate'".$version_share_data." style='position: relative;'>\n" . $additional_code;
1749
 
1750
  foreach ($ads as $index => $ad) {
1751
 
1760
  switch ($index) {
1761
  case 0:
1762
  if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !get_inline_styles ()) {
1763
+ $processed_code .= "<div class='ai-rotate-option'".$version_name_data.">\n".trim ($ad, "\n\r")."</div>\n";
1764
  } else
1765
+ $processed_code .= "<div class='ai-rotate-option' style='visibility: hidden;'".$version_name_data.">\n".trim ($ad, "\n\r")."</div>\n";
1766
  break;
1767
  default:
1768
  if (defined ('AI_NORMAL_HEADER_STYLES') && AI_NORMAL_HEADER_STYLES && !get_inline_styles ()) {
1769
+ $processed_code .= "<div class='ai-rotate-option ai-rotate-options'".$version_name_data.">\n".trim ($ad, "\n\r")."</div>\n";
1770
  } else
1771
+ $processed_code .= "<div class='ai-rotate-option' style='visibility: hidden; position: absolute; top: 0; left: 0; width: 100%; height: 100%;'".$version_name_data.">\n".trim ($ad, "\n\r")."</div>\n";
1772
  break;
1773
  }
1774
  }
1775
  $processed_code .= "</div>\n";
1776
  break;
1777
  case AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC:
1778
+ if ($shares) {
1779
+ $ad_index_code = ' $ai_random_threshold = mt_rand (0, 100); $ai_thresholds = unserialize (\''.
1780
+ serialize ($thresholds).'\'); foreach ($ai_thresholds as $ai_option_index => $ai_threshold) {$ai_index = $ai_option_index + 1; if ($ai_random_threshold <= $ai_threshold) break;}';
1781
+ } else $ad_index_code = ' $ai_index = mt_rand (1, count ($ai_code));';
1782
+
1783
+ $this->w3tc_code = '$ai_code = unserialize (base64_decode (\''.base64_encode (serialize ($ads)).'\'));'.$ad_index_code.' $ai_code = base64_decode (\''.base64_encode ($additional_code).'\') . $ai_code [$ai_index - 1]; $ai_enabled = true;';
1784
  $processed_code = '<!-- mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1785
  $processed_code .= $this->w3tc_code.' echo $ai_code;';
1786
  $processed_code .= '<!-- /mfunc '.W3TC_DYNAMIC_SECURITY.' -->';
1870
  }
1871
  }
1872
 
1873
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 /*&& !$hide_debug_label*/) {
1874
  $processed_code = "<div class='ai-code'>\n" . $processed_code ."</div>\n";
1875
  }
1876
 
1877
+ if (function_exists ('ai_adb_block_actions')) ai_adb_block_actions ($this, $hide_debug_label);
1878
 
1879
+ if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_BLOCKS) != 0 && !$hide_debug_label) {
1880
  $title = '';
1881
  $fallback_block_name = '';
1882
 
2006
  $sticky_parameters = '';
2007
 
2008
  if (!$ai_wp_data [AI_WP_AMP_PAGE]) {
2009
+ $sticky_parameters = $this->sticky_parameters ($classes);
 
 
 
 
 
 
 
 
2010
  }
2011
 
2012
  if ($this->get_close_button () && !$ai_wp_data [AI_WP_AMP_PAGE]) {
2213
  return $serverside_insertion_code;
2214
  }
2215
 
2216
+ public function get_close_button (){
2217
+ $option = isset ($this->wp_options [AI_OPTION_CLOSE_BUTTON]) ? $this->wp_options [AI_OPTION_CLOSE_BUTTON] : DEFAULT_CLOSE_BUTTON;
2218
+ return $option;
2219
+ }
2220
+
2221
+ public function get_horizontal_margin (){
2222
+ $option = isset ($this->wp_options [AI_OPTION_HORIZONTAL_MARGIN]) ? $this->wp_options [AI_OPTION_HORIZONTAL_MARGIN] : DEFAULT_HORIZONTAL_MARGIN;
2223
+ return $option;
2224
+ }
2225
+
2226
+ public function get_vertical_margin () {
2227
+ $option = isset ($this->wp_options [AI_OPTION_VERTICAL_MARGIN]) ? $this->wp_options [AI_OPTION_VERTICAL_MARGIN] : DEFAULT_VERTICAL_MARGIN;
2228
+ return $option;
2229
+ }
2230
+
2231
+ public function get_animation () {
2232
+ $option = isset ($this->wp_options [AI_OPTION_ANIMATION]) ? $this->wp_options [AI_OPTION_ANIMATION] : DEFAULT_ANIMATION;
2233
+ return $option;
2234
+ }
2235
+
2236
+ public function get_animation_trigger () {
2237
+ $option = isset ($this->wp_options [AI_OPTION_ANIMATION_TRIGGER]) ? $this->wp_options [AI_OPTION_ANIMATION_TRIGGER] : DEFAULT_ANIMATION_TRIGGER;
2238
+ return $option;
2239
+ }
2240
+
2241
+ public function get_animation_trigger_value () {
2242
+ $option = isset ($this->wp_options [AI_OPTION_ANIMATION_TRIGGER_VALUE]) ? $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_VALUE] : DEFAULT_ANIMATION_TRIGGER_VALUE;
2243
+ return $option;
2244
+ }
2245
+
2246
+ public function get_animation_trigger_offset () {
2247
+ $option = isset ($this->wp_options [AI_OPTION_ANIMATION_TRIGGER_OFFSET]) ? $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_OFFSET] : DEFAULT_ANIMATION_TRIGGER_OFFSET;
2248
+ return $option;
2249
+ }
2250
+
2251
+ public function get_animation_trigger_delay () {
2252
+ $option = isset ($this->wp_options [AI_OPTION_ANIMATION_TRIGGER_DELAY]) ? $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_DELAY] : DEFAULT_ANIMATION_TRIGGER_DELAY;
2253
+ return $option;
2254
+ }
2255
+
2256
+ public function get_animation_trigger_once () {
2257
+ $option = isset ($this->wp_options [AI_OPTION_ANIMATION_TRIGGER_ONCE]) ? $this->wp_options [AI_OPTION_ANIMATION_TRIGGER_ONCE] : DEFAULT_ANIMATION_TRIGGER_ONCE;
2258
+ return $option;
2259
+ }
2260
+
2261
  public function get_ad_general_tag(){
2262
  $option = isset ($this->wp_options [AI_OPTION_GENERAL_TAG]) ? $this->wp_options [AI_OPTION_GENERAL_TAG] : "";
2263
  if ($option == '') $option = AD_GENERAL_TAG;
2264
  return $option;
2265
  }
2266
 
 
 
 
 
 
2267
  public function get_adb_block_action (){
2268
  $option = isset ($this->wp_options [AI_OPTION_ADB_BLOCK_ACTION]) ? $this->wp_options [AI_OPTION_ADB_BLOCK_ACTION] : DEFAULT_ADB_BLOCK_ACTION;
2269
  return $option;
3080
 
3081
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
3082
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
 
3083
  $inserted_code = $this->get_code_for_serverside_insertion ();
3084
+ $ai_last_check = AI_CHECK_INSERTED;
3085
  $inserted = true;
3086
  }
3087
  }
3677
 
3678
  $ai_last_check = AI_CHECK_DEBUG_NO_INSERTION;
3679
  if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_NO_INSERTION) == 0) {
 
3680
  $inserted_code = $this->get_code_for_serverside_insertion ();
3681
+ $ai_last_check = AI_CHECK_INSERTED;
3682
  $inserted = true;
3683
  }
3684
  }
5203
  array (
5204
  'code' => $code,
5205
  'name' => '',
5206
+ 'share' => '',
5207
  ),
5208
  ),
5209
  );
5219
  foreach ($options as $index => $option) {
5220
  $option_code = trim ($option, "\n");
5221
  $option_name = isset ($ai_wp_data [AI_SHORTCODES]['rotate'][$index - 1]['name']) ? $ai_wp_data [AI_SHORTCODES]['rotate'][$index - 1]['name'] : '';
5222
+ $option_share = isset ($ai_wp_data [AI_SHORTCODES]['rotate'][$index - 1]['share']) && is_numeric ($ai_wp_data [AI_SHORTCODES]['rotate'][$index - 1]['share']) ? intval ($ai_wp_data [AI_SHORTCODES]['rotate'][$index - 1]['share']) : '';
5223
  if ($index == 0 && $option_code == '') continue;
5224
+ $data ['options'] []= array ('code' => $option_code, 'name' => $option_name, 'share' => $option_share);
5225
  }
5226
  }
5227
 
5237
  foreach ($rotation_data as $index => $rotation_data_row) {
5238
 
5239
  $name = trim ($rotation_data_row ['name']);
5240
+ $share = trim ($rotation_data_row ['share']);
5241
  $code = trim ($rotation_data_row ['code'], "\n");
5242
 
5243
+ if ($index != 0 || $name != '' || $share != '') {
5244
 
5245
  $shortcode = "" ;
5246
  if ($index != 0) $shortcode .= "\n\n";
5248
  $shortcode .= '[ADINSERTER ROTATE';
5249
 
5250
  if ($name != '') $shortcode .= ' name="'.str_replace ('"', '\'', $name).'"';
5251
+ if ($share != '') $shortcode .= ' share="'.str_replace ('"', '\'', $share).'"';
5252
  $shortcode .= "]\n\n";
5253
  } else $shortcode = '';
5254
 
constants.php CHANGED
@@ -1,844 +1,896 @@
1
- <?php
2
-
3
- //ini_set ('display_errors', 1);
4
- //error_reporting (E_ALL);
5
-
6
- define ('AI_OPTION_NAME', 'ad_inserter');
7
- define ('AI_INSTALL_NAME', 'ai-install');
8
- define ('AI_OPTION_GLOBAL', 'global');
9
- define ('AI_OPTION_EXTRACT', 'extract');
10
- define ('AI_ADSENSE_CLIENT_IDS', 'ai-adsense-client-ids');
11
- define ('AI_ADSENSE_AUTH_CODE', 'ai-adsense-auth-code');
12
-
13
- if (!defined ('AD_INSERTER_PLUGIN_DIR'))
14
- define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
15
-
16
- if (!defined ('AD_INSERTER_FILE'))
17
- define ('AD_INSERTER_FILE', AD_INSERTER_PLUGIN_DIR.'ad-inserter.php');
18
-
19
- if (file_exists (AD_INSERTER_PLUGIN_DIR.'includes/functions.php')) {
20
- include_once AD_INSERTER_PLUGIN_DIR.'includes/functions.php';
21
- }
22
-
23
- if (!defined( 'AD_INSERTER_NAME'))
24
- define ('AD_INSERTER_NAME', 'Ad Inserter');
25
-
26
- if (!defined( 'AD_INSERTER_VERSION'))
27
- define ('AD_INSERTER_VERSION', '2.3.7');
28
-
29
- if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
30
- define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
31
-
32
- if (!defined ('AD_INSERTER_PLUGIN_DIRNAME'))
33
- define ('AD_INSERTER_PLUGIN_DIRNAME', dirname (AD_INSERTER_PLUGIN_BASENAME));
34
-
35
- if (!defined ('AD_INSERTER_PLUGIN_URL'))
36
- define ('AD_INSERTER_PLUGIN_URL', plugin_dir_url ( __FILE__));
37
-
38
- if (!defined ('AD_INSERTER_PLUGIN_IMAGES_URL'))
39
- define ('AD_INSERTER_PLUGIN_IMAGES_URL', AD_INSERTER_PLUGIN_URL. 'images/');
40
-
41
- define ('AD_EMPTY_DATA', '');
42
- define ('AD_ZERO', '0');
43
- define ('AD_ONE', '1');
44
- define ('AD_TWO', '2');
45
- define ('AD_GENERAL_TAG', '');
46
- define ('AD_NAME', 'Block');
47
-
48
- // Old options
49
- define ('AD_OPTIONS', 'AdInserterOptions'); // general plugin options
50
- define ('AD_ADx_OPTIONS', 'AdInserter#Options');
51
-
52
- // Options
53
- define ('WP_FORM_FIELD_POSTFIX', '_block_');
54
- define ('AI_HEADER_OPTION_NAME', 'h');
55
- define ('AI_FOOTER_OPTION_NAME', 'f');
56
- define ('AI_ADB_MESSAGE_OPTION_NAME', 'a');
57
-
58
- define ('AI_OPTION_CODE', 'code');
59
- define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
60
- define ('AI_OPTION_ENABLE_AMP', 'enable_amp');
61
- define ('AI_OPTION_ENABLE_WIDGET', 'enable_widget');
62
- define ('AI_OPTION_PROCESS_PHP', 'process_php');
63
- define ('AI_OPTION_SHOW_LABEL', 'show_label');
64
- define ('AI_OPTION_TRACKING', 'tracking');
65
- define ('AI_OPTION_ENABLE_AJAX', 'enable_ajax');
66
- define ('AI_OPTION_ENABLE_FEED', 'enable_feed');
67
- define ('AI_OPTION_ENABLE_404', 'enable_404');
68
- define ('AI_OPTION_DISABLE_CACHING', 'disable_caching');
69
- define ('AI_OPTION_BLOCK_NAME', 'name');
70
- define ('AI_OPTION_AUTOMATIC_INSERTION', 'display_type');
71
- define ('AI_OPTION_PARAGRAPH_NUMBER', 'paragraph_number');
72
- define ('AI_OPTION_MIN_PARAGRAPHS', 'min_paragraphs');
73
- define ('AI_OPTION_MIN_WORDS_ABOVE', 'min_words_above');
74
- define ('AI_OPTION_COUNT_INSIDE_BLOCKQUOTE', 'count_inside_blockquote');
75
- define ('AI_OPTION_MIN_WORDS', 'min_words');
76
- define ('AI_OPTION_MAX_WORDS', 'max_words');
77
- define ('AI_OPTION_MIN_PARAGRAPH_WORDS', 'min_paragraph_words');
78
- define ('AI_OPTION_MAX_PARAGRAPH_WORDS', 'max_paragraph_words');
79
- define ('AI_OPTION_PARAGRAPH_TAGS', 'paragraph_tags');
80
- define ('AI_OPTION_AVOID_PARAGRAPHS_ABOVE', 'avoid_paragraphs_above');
81
- define ('AI_OPTION_AVOID_PARAGRAPHS_BELOW', 'avoid_paragraphs_below');
82
- define ('AI_OPTION_AVOID_TEXT_ABOVE', 'avoid_text_above');
83
- define ('AI_OPTION_AVOID_TEXT_BELOW', 'avoid_text_below');
84
- define ('AI_OPTION_AVOID_ACTION', 'avoid_action');
85
- define ('AI_OPTION_AVOID_TRY_LIMIT', 'avoid_try_limit');
86
- define ('AI_OPTION_AVOID_DIRECTION', 'avoid_direction');
87
- define ('AI_OPTION_HTML_SELECTOR', 'html_selector');
88
- define ('AI_OPTION_SERVER_SIDE_INSERTION', 'server_side_insertion');
89
- define ('AI_OPTION_HTML_ELEMENT_INSERTION', 'html_insertion');
90
- define ('AI_OPTION_EXCERPT_NUMBER', 'excerpt_number'); // needs to be renamed
91
- define ('AI_OPTION_FILTER_TYPE', 'filter_type');
92
- define ('AI_OPTION_INVERTED_FILTER', 'inverted_filter');
93
- define ('AI_OPTION_DIRECTION_TYPE', 'direction_type');
94
- define ('AI_OPTION_ALIGNMENT_TYPE', 'alignment_type');
95
- define ('AI_OPTION_HORIZONTAL_POSITION', 'horizontal_position');
96
- define ('AI_OPTION_VERTICAL_POSITION', 'vertical_position');
97
- define ('AI_OPTION_GENERAL_TAG', 'general_tag');
98
- define ('AI_OPTION_SCHEDULING', 'scheduling');
99
- define ('AI_OPTION_AFTER_DAYS', 'after_days');
100
- define ('AI_OPTION_START_DATE', 'start_date');
101
- define ('AI_OPTION_END_DATE', 'end_date');
102
- define ('AI_OPTION_FALLBACK', 'fallback');
103
- define ('AI_OPTION_MAXIMUM_INSERTIONS', 'maximum_insertions');
104
- define ('AI_OPTION_ID_LIST', 'id_list');
105
- define ('AI_OPTION_ID_LIST_TYPE', 'id_list_type');
106
- define ('AI_OPTION_URL_LIST', 'url_list');
107
- define ('AI_OPTION_URL_LIST_TYPE', 'url_list_type');
108
- define ('AI_OPTION_URL_PARAMETER_LIST', 'url_parameter_list');
109
- define ('AI_OPTION_URL_PARAMETER_LIST_TYPE', 'url_parameter_list_type');
110
- define ('AI_OPTION_DOMAIN_LIST', 'domain_list');
111
- define ('AI_OPTION_DOMAIN_LIST_TYPE', 'domain_list_type');
112
- define ('AI_OPTION_IP_ADDRESS_LIST', 'ip_address_list');
113
- define ('AI_OPTION_IP_ADDRESS_LIST_TYPE', 'ip_address_list_type');
114
- define ('AI_OPTION_COUNTRY_LIST', 'country_list');
115
- define ('AI_OPTION_COUNTRY_LIST_TYPE', 'country_list_type');
116
- define ('AI_OPTION_CATEGORY_LIST', 'category_list');
117
- define ('AI_OPTION_CATEGORY_LIST_TYPE', 'category_list_type');
118
- define ('AI_OPTION_TAG_LIST', 'tag_list');
119
- define ('AI_OPTION_TAG_LIST_TYPE', 'tag_list_type');
120
- define ('AI_OPTION_TAXONOMY_LIST', 'taxonomy_list');
121
- define ('AI_OPTION_TAXONOMY_LIST_TYPE', 'taxonomy_list_type');
122
- define ('AI_OPTION_DISPLAY_ON_HOMEPAGE', 'display_on_homepage');
123
- define ('AI_OPTION_DISPLAY_ON_PAGES', 'display_on_pages');
124
- define ('AI_OPTION_DISPLAY_ON_POSTS', 'display_on_posts');
125
- define ('AI_OPTION_DISPLAY_ON_CATEGORY_PAGES', 'display_on_category_pages');
126
- define ('AI_OPTION_DISPLAY_ON_SEARCH_PAGES', 'display_on_search_pages');
127
- define ('AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES', 'display_on_archive_pages');
128
- define ('AI_OPTION_ENABLED_ON_WHICH_PAGES', 'enabled_on_which_pages');
129
- define ('AI_OPTION_ENABLED_ON_WHICH_POSTS', 'enabled_on_which_posts');
130
- define ('AI_OPTION_ENABLE_PHP_CALL', 'enable_php_call');
131
- define ('AI_OPTION_PARAGRAPH_TEXT', 'paragraph_text');
132
- define ('AI_OPTION_PARAGRAPH_TEXT_TYPE', 'paragraph_text_type');
133
- define ('AI_OPTION_CUSTOM_CSS', 'custom_css');
134
- define ('AI_OPTION_DISPLAY_FOR_USERS', 'display_for_users');
135
- define ('AI_OPTION_DISPLAY_FOR_DEVICES', 'display_for_devices');
136
- define ('AI_OPTION_DETECT_SERVER_SIDE', 'detect_server_side');
137
- define ('AI_OPTION_DETECT_CLIENT_SIDE', 'detect_client_side');
138
- define ('AI_OPTION_CLIENT_SIDE_ACTION', 'client_side_action');
139
- define ('AI_OPTION_DETECT_VIEWPORT', 'detect_viewport');
140
- define ('AI_OPTION_ADB_BLOCK_ACTION', 'adb-block-action');
141
- define ('AI_OPTION_ADB_BLOCK_REPLACEMENT', 'adb-block-replacement');
142
- define ('AI_OPTION_CLOSE_BUTTON', 'close-button');
143
-
144
- define ('AI_OPTION_DISABLED', 'disabled');
145
-
146
- define ('AI_OPTION_IMPORT', 'import');
147
- define ('AI_OPTION_IMPORT_NAME', 'import_name');
148
- define ('AI_OPTION_PLUGIN_STATUS', 'plugin_status');
149
-
150
- define ('AI_OPTION_ADB_ACTION', 'adb-action');
151
- define ('AI_OPTION_ADB_SELECTORS', 'adb-selectors');
152
- define ('AI_OPTION_ADB_DELAY_ACTION', 'adb-delay-action');
153
- define ('AI_OPTION_ADB_NO_ACTION_PERIOD', 'adb-no-action-period');
154
- define ('AI_OPTION_ADB_REDIRECTION_PAGE', 'adb-redirection-page');
155
- define ('AI_OPTION_ADB_CUSTOM_REDIRECTION_URL', 'adb-custom-redirection-url');
156
- define ('AI_OPTION_ADB_MESSAGE_CSS', 'adb-message-css');
157
- define ('AI_OPTION_ADB_OVERLAY_CSS', 'adb-overlay-css');
158
- define ('AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE', 'adb-undismissible-message');
159
-
160
-
161
- //misc
162
- define('AD_EMPTY_VALUE','');
163
-
164
- //define constant variable form
165
- define('AI_FORM_SAVE', 'ai_save');
166
- define('AI_FORM_CLEAR','ai_clear');
167
- define('AI_FORM_CLEAR_EXCEPTIONS', 'ai-clear-exceptions');
168
- define('AI_FORM_CLEAR_STATISTICS', 'ai-clear-statistics');
169
-
170
- define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
171
- define('AD_ROTATE_SEPARATOR', '|rotate|');
172
- define('AD_COUNT_SEPARATOR', '|count|');
173
- define('AD_AMP_SEPARATOR', '|amp|');
174
- define('AD_HTTP_SEPARATOR', '|http|');
175
-
176
- //form select options
177
- define('AD_SELECT_SELECTED','selected');
178
-
179
- //Automatic insertion options - Deprecated
180
- define('AD_SELECT_NONE','None');
181
- define('AD_SELECT_BEFORE_POST','Before Post');
182
- define('AD_SELECT_AFTER_POST','After Post');
183
- define('AD_SELECT_BEFORE_PARAGRAPH','Before Paragraph');
184
- define('AD_SELECT_AFTER_PARAGRAPH','After Paragraph');
185
- define('AD_SELECT_BEFORE_CONTENT','Before Content');
186
- define('AD_SELECT_AFTER_CONTENT','After Content');
187
- define('AD_SELECT_BEFORE_EXCERPT','Before Excerpt');
188
- define('AD_SELECT_AFTER_EXCERPT','After Excerpt');
189
- define('AD_SELECT_BETWEEN_POSTS','Between Posts');
190
- define('AD_SELECT_WIDGET','Widget'); // Deprecated
191
- define('AD_SELECT_BEFORE_TITLE','Before Title'); // Deprecated
192
- define('AD_SELECT_MANUAL','Manual'); // Deprecated
193
-
194
- define('AI_AUTOMATIC_INSERTION_DISABLED', 0);
195
- define('AI_AUTOMATIC_INSERTION_BEFORE_POST', 1);
196
- define('AI_AUTOMATIC_INSERTION_AFTER_POST', 2);
197
- define('AI_AUTOMATIC_INSERTION_BEFORE_CONTENT', 3);
198
- define('AI_AUTOMATIC_INSERTION_AFTER_CONTENT', 4);
199
- define('AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH', 5);
200
- define('AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH', 6);
201
- define('AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT', 7);
202
- define('AI_AUTOMATIC_INSERTION_AFTER_EXCERPT', 8);
203
- define('AI_AUTOMATIC_INSERTION_BETWEEN_POSTS', 9);
204
- define('AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS', 10);
205
- define('AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS', 11);
206
- define('AI_AUTOMATIC_INSERTION_AFTER_COMMENTS', 12);
207
- define('AI_AUTOMATIC_INSERTION_FOOTER', 13);
208
- define('AI_AUTOMATIC_INSERTION_ABOVE_HEADER', 14);
209
- define('AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT', 15);
210
- define('AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT', 16);
211
-
212
- define('AI_AUTOMATIC_INSERTION_OUTPUT_BUFFERING', 99);
213
- define('AI_AUTOMATIC_INSERTION_CUSTOM_HOOK', 100);
214
-
215
- define('AI_TEXT_DISABLED', 'Disabled');
216
- define('AI_TEXT_BEFORE_POST', 'Before Post');
217
- define('AI_TEXT_AFTER_POST', 'After Post');
218
- define('AI_TEXT_BEFORE_CONTENT', 'Before Content');
219
- define('AI_TEXT_AFTER_CONTENT', 'After Content');
220
- define('AI_TEXT_BEFORE_PARAGRAPH', 'Before Paragraph');
221
- define('AI_TEXT_AFTER_PARAGRAPH', 'After Paragraph');
222
- define('AI_TEXT_BEFORE_EXCERPT', 'Before Excerpt');
223
- define('AI_TEXT_AFTER_EXCERPT', 'After Excerpt');
224
- define('AI_TEXT_BETWEEN_POSTS', 'Between Posts');
225
- define('AI_TEXT_BEFORE_COMMENTS', 'Before Comments');
226
- define('AI_TEXT_BETWEEN_COMMENTS', 'Between Comments');
227
- define('AI_TEXT_AFTER_COMMENTS', 'After Comments');
228
- define('AI_TEXT_ABOVE_HEADER', 'Above Header');
229
- define('AI_TEXT_FOOTER', 'Footer');
230
- define('AI_TEXT_BEFORE_HTML_ELEMENT', 'Before HTML element');
231
- define('AI_TEXT_AFTER_HTML_ELEMENT', 'After HTML element');
232
-
233
- //Display options
234
- define('AD_DISPLAY_ALL_USERS','all users');
235
- define('AD_DISPLAY_LOGGED_IN_USERS','logged in users');
236
- define('AD_DISPLAY_NOT_LOGGED_IN_USERS','not logged in users');
237
- define('AD_DISPLAY_ADMINISTRATORS','administrators');
238
-
239
- define('AD_DISPLAY_ALL_DEVICES','all');
240
- define('AD_DISPLAY_DESKTOP_DEVICES','desktop');
241
- define('AD_DISPLAY_MOBILE_DEVICES','mobile');
242
- define('AD_DISPLAY_TABLET_DEVICES','tablet');
243
- define('AD_DISPLAY_PHONE_DEVICES','phone');
244
- define('AD_DISPLAY_DESKTOP_TABLET_DEVICES','desktop and tablet');
245
- define('AD_DISPLAY_DESKTOP_PHONE_DEVICES','desktop and phone');
246
-
247
- //Direction options
248
- define('AD_DIRECTION_FROM_TOP','From Top');
249
- define('AD_DIRECTION_FROM_BOTTOM','From Bottom');
250
-
251
- //Post-Page options
252
- // Deprecated
253
- define('AD_ENABLED_ON_ALL', 'On all');
254
- define('AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED', 'On all except selected');
255
- define('AD_ENABLED_ONLY_ON_SELECTED', 'Only on selected');
256
-
257
- define('AI_NO_INDIVIDUAL_EXCEPTIONS', 0);
258
- define('AI_INDIVIDUALLY_DISABLED', 1);
259
- define('AI_INDIVIDUALLY_ENABLED', 2);
260
-
261
- define('AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS', '');
262
- define('AI_TEXT_INDIVIDUALLY_DISABLED', 'Individually disabled');
263
- define('AI_TEXT_INDIVIDUALLY_ENABLED', 'Individually enabled');
264
-
265
- //Alignment options - Deprecated
266
- define('AD_ALIGNMENT_NO_WRAPPING','No Wrapping');
267
- define('AD_ALIGNMENT_CUSTOM_CSS','Custom CSS');
268
- define('AD_ALIGNMENT_NONE','None');
269
- define('AD_ALIGNMENT_LEFT','Align Left');
270
- define('AD_ALIGNMENT_RIGHT','Align Right');
271
- define('AD_ALIGNMENT_CENTER','Center');
272
- define('AD_ALIGNMENT_FLOAT_LEFT','Float Left');
273
- define('AD_ALIGNMENT_FLOAT_RIGHT','Float Right');
274
-
275
- define('AI_ALIGNMENT_DEFAULT', 0);
276
- define('AI_ALIGNMENT_LEFT', 1);
277
- define('AI_ALIGNMENT_RIGHT', 2);
278
- define('AI_ALIGNMENT_CENTER', 3);
279
- define('AI_ALIGNMENT_FLOAT_LEFT', 4);
280
- define('AI_ALIGNMENT_FLOAT_RIGHT', 5);
281
- define('AI_ALIGNMENT_NO_WRAPPING', 6);
282
- define('AI_ALIGNMENT_CUSTOM_CSS', 7);
283
- define('AI_ALIGNMENT_STICKY_LEFT', 8);
284
- define('AI_ALIGNMENT_STICKY_RIGHT', 9);
285
- define('AI_ALIGNMENT_STICKY_TOP', 10);
286
- define('AI_ALIGNMENT_STICKY_BOTTOM', 11);
287
- define('AI_ALIGNMENT_STICKY', 12);
288
-
289
- // Used also for alignment class names
290
- define('AI_TEXT_DEFAULT', 'Default');
291
- define('AI_TEXT_LEFT', 'Align Left');
292
- define('AI_TEXT_RIGHT', 'Align Right');
293
- define('AI_TEXT_CENTER', 'Center');
294
- define('AI_TEXT_FLOAT_LEFT', 'Float Left');
295
- define('AI_TEXT_FLOAT_RIGHT', 'Float Right');
296
- define('AI_TEXT_NO_WRAPPING', 'No Wrapping');
297
- define('AI_TEXT_CUSTOM_CSS', 'Custom CSS');
298
- define('AI_TEXT_STICKY_LEFT', 'Sticky Left');
299
- define('AI_TEXT_STICKY_RIGHT', 'Sticky Right');
300
- define('AI_TEXT_STICKY_TOP', 'Sticky Top');
301
- define('AI_TEXT_STICKY_BOTTOM', 'Sticky Bottom');
302
- define('AI_TEXT_STICKY', 'Sticky');
303
-
304
- define('AI_STICK_TO_THE_LEFT', 0);
305
- define('AI_STICK_TO_THE_CONTENT_LEFT', 1);
306
- define('AI_STICK_HORIZONTAL_CENTER', 2);
307
- define('AI_STICK_TO_THE_CONTENT_RIGHT', 3);
308
- define('AI_STICK_TO_THE_RIGHT', 4);
309
-
310
- define('AI_TEXT_STICK_TO_THE_LEFT', 'Stick to the left');
311
- define('AI_TEXT_STICK_TO_THE_CONTENT_LEFT', 'Stick to the content left');
312
- define('AI_TEXT_STICK_TO_THE_CONTENT_RIGHT', 'Stick to the content right');
313
- define('AI_TEXT_STICK_TO_THE_RIGHT', 'Stick to the right');
314
-
315
- define('AI_STICK_TO_THE_TOP', 0);
316
- define('AI_STICK_VERTICAL_CENTER', 1);
317
- define('AI_SCROLL_WITH_THE_CONTENT', 2);
318
- define('AI_STICK_TO_THE_BOTTOM', 3);
319
-
320
- define('AI_TEXT_STICK_TO_THE_TOP', 'Stick to the top');
321
- define('AI_TEXT_SCROLL_WITH_THE_CONTENT', 'Scroll with the content');
322
- define('AI_TEXT_STICK_TO_THE_BOTTOM', 'Stick to the bottom');
323
-
324
- define('AI_STICKY_Z_INDEX', 9995); // update ad-inserter.js
325
-
326
- define('AI_ALIGNMENT_CSS_DEFAULT', 'margin: 8px 0; clear: both;');
327
- define('AI_ALIGNMENT_CSS_LEFT', 'margin: 8px auto 8px 0; text-align: left; clear: both;||margin: 8px 0; text-align: left; clear: both; display: flex; justify-content: flex-start; flex-direction: column; align-items: flex-start;');
328
- define('AI_ALIGNMENT_CSS_RIGHT', 'margin: 8px 0 8px auto; text-align: right; clear: both;||margin: 8px 0; text-align: right; clear: both; display: flex; justify-content: flex-end; flex-direction: column; align-items: flex-end;');
329
- define('AI_ALIGNMENT_CSS_CENTER', 'margin: 8px auto; text-align: center; clear: both;||margin: 8px 0; text-align: center; clear: both; display: flex; justify-content: center; flex-direction: column; align-items: center;');
330
- define('AI_ALIGNMENT_CSS_FLOAT_LEFT', 'margin: 8px 8px 8px 0; float: left;');
331
- define('AI_ALIGNMENT_CSS_FLOAT_RIGHT', 'margin: 8px 0 8px 8px; float: right;');
332
- define('AI_ALIGNMENT_CSS_STICKY_LEFT', 'position: fixed; left: 0px; top: 100px; z-index: 9999;');
333
- define('AI_ALIGNMENT_CSS_STICKY_RIGHT', 'position: fixed; right: 0px; top: 100px; z-index: 9999;');
334
- define('AI_ALIGNMENT_CSS_STICKY_TOP', 'position: fixed; top: 0; text-align: center; left: 50%; transform: translate(-50%); width: 100%; z-index: 9999;||position: fixed; top: 0; left: 0; width: 100%; text-align: center; z-index: 9999;||position: fixed; top: 0; left: 0; width: 100%; text-align: center; display: flex; justify-content: center; z-index: 9999;');
335
- define('AI_ALIGNMENT_CSS_STICKY_BOTTOM', 'position: fixed; bottom: 0; text-align: center; left: 50%; transform: translate(-50%); width: 100%; z-index: 9999;||position: fixed; bottom: 0; left: 0; width: 100%; text-align: center; z-index: 9999;||position: fixed; bottom: 0; left: 0; width: 100%; text-align: center; display: flex; justify-content: center; z-index: 9999;');
336
- define('AI_ALIGNMENT_CSS_STICKY', 'position: fixed; z-index: '.AI_STICKY_Z_INDEX.';');
337
-
338
- define('AI_ALIGNMENT_CSS_STICK_TO_THE_TOP', ' top: 0px;');
339
- define('AI_ALIGNMENT_CSS_STICK_TO_THE_TOP_OFFSET', ' top: 100px;');
340
- define('AI_ALIGNMENT_CSS_CENTER_VERTICAL', ' top: 50%; transform: translate(0, -50%);');
341
- define('AI_ALIGNMENT_CSS_CENTER_VERTICAL_H', ' top: 50%;');
342
- define('AI_ALIGNMENT_CSS_SCROLL_WITH_THE_CONTENT', ' position: relative; margin-bottom: auto; width: fit-content; top: 100px; display: none;');
343
- define('AI_ALIGNMENT_CSS_STICK_TO_THE_BOTTOM', ' bottom: 0px;');
344
- define('AI_ALIGNMENT_CSS_STICK_TO_THE_BOTTOM_OFFSET', ' bottom: 100px;');
345
-
346
- define('AI_ALIGNMENT_CSS_STICK_TO_THE_LEFT', ' left: 0px;');
347
- define('AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_LEFT', ' left: auto; margin-right: 10px; width: fit-content; display: none;');
348
- define('AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL', ' text-align: center; left: 50%; transform: translate(-50%);');
349
- define('AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL_V', ' text-align: center; left: 50%; transform: translate(-50%, -50%);');
350
- define('AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_RIGHT', ' right: auto; margin-left: 10px; width: fit-content; display: none;');
351
- define('AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT', ' right: 0px;');
352
- define('AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT_SCROLL', ' margin-left: auto;');
353
-
354
- define('AI_ALIGNMENT_CSS_AMP_LEFT', 'display: flex; justify-content: flex-start;');
355
- define('AI_ALIGNMENT_CSS_AMP_RIGHT', 'display: flex; justify-content: flex-end;');
356
- define('AI_ALIGNMENT_CSS_AMP_CENTER', 'display: flex; justify-content: center;');
357
-
358
- //List Type
359
- define('AD_BLACK_LIST','Black List');
360
- define('AD_WHITE_LIST','White List');
361
-
362
- //Filter Type - Deprecated
363
- define ('AI_OPTION_FILTER_AUTO', 'Auto');
364
- define ('AI_OPTION_FILTER_PHP_FUNCTION_CALLS', 'PHP function calls');
365
- define ('AI_OPTION_FILTER_CONTENT_PROCESSING', 'Content processing');
366
- define ('AI_OPTION_FILTER_EXCERPT_PROCESSING', 'Excerpt processing');
367
- define ('AI_OPTION_FILTER_BEFORE_POST_PROCESSING', 'Before post processing');
368
- define ('AI_OPTION_FILTER_AFTER_POST_PROCESSING', 'After post processing');
369
- define ('AI_OPTION_FILTER_WIDGET_DRAWING', 'Widget drawing');
370
- define ('AI_OPTION_FILTER_SUBPAGES', 'Subpages');
371
- define ('AI_OPTION_FILTER_POSTS', 'Posts');
372
- define ('AI_OPTION_FILTER_COMMENTS', 'Comments');
373
-
374
-
375
- //Filter Type
376
- define ('AI_FILTER_AUTO', 0);
377
- define ('AI_FILTER_PHP_FUNCTION_CALLS', 1);
378
- define ('AI_FILTER_CONTENT_PROCESSING', 2);
379
- define ('AI_FILTER_EXCERPT_PROCESSING', 3);
380
- define ('AI_FILTER_BEFORE_POST_PROCESSING', 4);
381
- define ('AI_FILTER_AFTER_POST_PROCESSING', 5);
382
- define ('AI_FILTER_WIDGET_DRAWING', 6);
383
- define ('AI_FILTER_SUBPAGES', 7);
384
- define ('AI_FILTER_POSTS', 8);
385
- define ('AI_FILTER_PARAGRAPHS', 9);
386
- define ('AI_FILTER_COMMENTS', 10);
387
-
388
-
389
- define ('AI_TEXT_AUTO', 'Auto');
390
- define ('AI_TEXT_PHP_FUNCTION_CALLS', 'PHP function calls');
391
- define ('AI_TEXT_CONTENT_PROCESSING', 'Content processing');
392
- define ('AI_TEXT_EXCERPT_PROCESSING', 'Excerpt processing');
393
- define ('AI_TEXT_BEFORE_POST_PROCESSING', 'Before post processing');
394
- define ('AI_TEXT_AFTER_POST_PROCESSING', 'After post processing');
395
- define ('AI_TEXT_WIDGET_DRAWING', 'Widget drawing');
396
- define ('AI_TEXT_SUBPAGES', 'Subpages');
397
- define ('AI_TEXT_POSTS', 'Posts');
398
- define ('AI_TEXT_PARAGRAPHS', 'Paragraphs');
399
- define ('AI_TEXT_COMMENTS', 'Comments');
400
-
401
-
402
-
403
- //Counter names
404
- define ('AI_BLOCK_COUNTER_NAME', 'AI_BLOCK_COUNTER_');
405
- define ('AI_PHP_FUNCTION_CALL_COUNTER_NAME', 'AI_PHP_FUNCTION_CALL_COUNTER_');
406
- define ('AI_CONTENT_COUNTER_NAME', 'AI_CONTENT_COUNTER');
407
- define ('AI_EXCERPT_COUNTER_NAME', 'AI_EXCERPT_COUNTER');
408
- define ('AI_LOOP_BEFORE_COUNTER_NAME', 'AI_LOOP_START_COUNTER');
409
- define ('AI_LOOP_AFTER_COUNTER_NAME', 'AI_LOOP_END_COUNTER');
410
- define ('AI_WIDGET_COUNTER_NAME', 'AI_WIDGET_COUNTER_');
411
- define ('AI_POST_COUNTER_NAME', 'AI_THE_POST_COUNTER');
412
- define ('AI_COMMENT_COUNTER_NAME', 'AI_COMMENT_COUNTER');
413
- define ('AI_ADB_FALLBACK_DEPTH_NAME', 'AI_ADB_FALLBACK_DEPTH');
414
-
415
- //Text List Type
416
- define('AD_CONTAIN','contain');
417
- define('AD_DO_NOT_CONTAIN','do not contain');
418
-
419
- //Avoid text action
420
- define('AD_DO_NOT_INSERT','do not insert');
421
- define('AD_TRY_TO_SHIFT_POSITION','try to shift position');
422
-
423
- define('AD_ABOVE','above');
424
- define('AD_BELOW','below');
425
- define('AD_ABOVE_AND_THEN_BELOW','above and then below');
426
- define('AD_BELOW_AND_THEN_ABOVE','below and then above');
427
-
428
- // Scheduling
429
- define('AI_SCHEDULING_OFF', 0);
430
- define('AI_SCHEDULING_DELAY', 1);
431
- define('AI_SCHEDULING_BETWEEN_DATES', 2);
432
-
433
- define('AI_TEXT_OFF', 'Insert immediately');
434
- define('AI_TEXT_DELAY_INSERTION', 'Delay insertion');
435
- define('AI_TEXT_INSERT_BETWEEN_DATES', 'Insert between dates');
436
-
437
- // Dynamic blocks
438
- define('AI_DYNAMIC_BLOCKS_SERVER_SIDE', 0);
439
- define('AI_DYNAMIC_BLOCKS_CLIENT_SIDE', 1);
440
- define('AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC', 2);
441
-
442
- define('AI_TEXT_SERVER_SIDE', 'Server-side');
443
- define('AI_TEXT_CLIENT_SIDE', 'Client-side');
444
- define('AI_TEXT_SERVER_SIDE_W3TC', 'Server-side using W3 Total Cache');
445
-
446
- // Paragraph counting functions
447
- define('AI_STANDARD_PARAGRAPH_COUNTING_FUNCTIONS', 0);
448
- define('AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS', 1);
449
-
450
- define('AI_TEXT_STANDARD', 'Standard');
451
- define('AI_TEXT_MULTIBYTE', 'Multibyte');
452
-
453
- // Tracking
454
- define('AI_TRACKING_DISABLED', 0);
455
- define('AI_TRACKING_ENABLED', 1);
456
-
457
- // Ad Blocking
458
- define ('AI_ADB_ACTION_NONE', 0);
459
- define ('AI_ADB_ACTION_MESSAGE', 1);
460
- define ('AI_ADB_ACTION_REDIRECTION', 2);
461
-
462
- define ('AI_TEXT_NONE', 'None');
463
- define ('AI_TEXT_POPUP_MESSAGE', 'Popup Message');
464
- define ('AI_TEXT_REDIRECTION', 'Redirection');
465
-
466
- define ('AI_ADB_BLOCK_ACTION_DO_NOTHING', 0);
467
- define ('AI_ADB_BLOCK_ACTION_REPLACE', 1);
468
- define ('AI_ADB_BLOCK_ACTION_SHOW', 2);
469
- define ('AI_ADB_BLOCK_ACTION_HIDE', 3);
470
-
471
- define ('AI_TEXT_DO_NOTHING', 'Do nothnig');
472
- define ('AI_TEXT_REPLACE', 'Replace');
473
- define ('AI_TEXT_SHOW', 'Show');
474
- define ('AI_TEXT_HIDE', 'Hide');
475
-
476
- // Ad blocking detection
477
- define ('AI_ADB_DETECTION_STANDARD', 0);
478
- define ('AI_ADB_DETECTION_ADVANCED', 1);
479
-
480
- // Output buffering
481
- define ('AI_OUTPUT_BUFFERING_DISABLED', 0);
482
- define ('AI_OUTPUT_BUFFERING_ENABLED', 1);
483
-
484
- // Click detection
485
- define ('AI_CLICK_DETECTION_STANDARD', 0);
486
- define ('AI_CLICK_DETECTION_ADVANCED', 1);
487
-
488
- define ('AI_TEXT_INTERNAL', 'Internal');
489
- define ('AI_TEXT_ADVANCED', 'Advanced');
490
- define ('AI_TEXT_ENABLED', 'Enabled');
491
-
492
- // Sticky widget mode
493
- define ('AI_STICKY_WIDGET_MODE_CSS', 0);
494
- define ('AI_STICKY_WIDGET_MODE_JS', 1);
495
-
496
- define ('AI_TEXT_CSS', 'CSS');
497
- define ('AI_TEXT_JS', 'JavaScript ');
498
-
499
- define ('AI_GEO_DB_WEBNET77', 0);
500
- define ('AI_GEO_DB_MAXMIND', 1);
501
-
502
- define ('AI_TEXT_WEBNET77', 'Webnet77');
503
- define ('AI_TEXT_MAXMIND', 'MaxMind');
504
-
505
- define ('AI_CLOSE_NONE', 0);
506
- define ('AI_CLOSE_TOP_RIGHT', 1);
507
- define ('AI_CLOSE_TOP_LEFT', 2);
508
- define ('AI_CLOSE_BOTTOM_RIGHT', 3);
509
- define ('AI_CLOSE_BOTTOM_LEFT', 4);
510
-
511
- define ('AI_TEXT_TOP_RIGHT', 'Top right');
512
- define ('AI_TEXT_TOP_LEFT', 'Top left');
513
- define ('AI_TEXT_BOTTOM_RIGHT', 'Bottom right');
514
- define ('AI_TEXT_BOTTOM_LEFT', 'Bottom left');
515
-
516
- define ('AI_CLIENT_SIDE_ACTION_SHOW', 0);
517
- define ('AI_CLIENT_SIDE_ACTION_INSERT', 1);
518
-
519
- define ('AI_TEXT_INSERT', 'Insert');
520
-
521
- define ('AI_HTML_INSERTION_CLIENT_SIDE', 0);
522
- define ('AI_HTML_INSERTION_CLIENT_SIDE_DOM_READY', 1);
523
- define ('AI_HTML_INSERTION_SEREVR_SIDE', 2);
524
-
525
- define('AI_TEXT_CLIENT_SIDE_DOM_READY', 'Client-side when DOM ready');
526
-
527
- //Settings
528
- define ('AI_ENABLED', '1');
529
- define ('AI_DISABLED', '0');
530
-
531
- define ('AI_COOKIE_TIME', 3600);
532
-
533
- define ('AI_TRANSIENT_RATING', 'ai-rating');
534
- define ('AI_TRANSIENT_RATING_EXPIRATION', 48 * 3600);
535
-
536
- define ('AI_TRANSIENT_ADSENSE_TOKEN', 'ai-adsense');
537
-
538
- define ('AI_TRANSIENT_ADSENSE_ADS', 'ai-adsense-ads');
539
- define ('AI_TRANSIENT_ADSENSE_ADS_EXPIRATION', 24 * 3600);
540
-
541
- define ('AI_TRANSIENT_ADB_CLASS_1', 'ai-adb-class-1');
542
- define ('AI_TRANSIENT_ADB_CLASS_2', 'ai-adb-class-2');
543
- define ('AI_TRANSIENT_ADB_CLASS_3', 'ai-adb-class-3');
544
- define ('AI_TRANSIENT_ADB_CLASS_4', 'ai-adb-class-4');
545
- define ('AI_TRANSIENT_ADB_CLASS_5', 'ai-adb-class-5');
546
- define ('AI_TRANSIENT_ADB_CLASS_6', 'ai-adb-class-6');
547
- define ('AI_TRANSIENT_ADB_CLASS_EXPIRATION', 48 * 3600);
548
-
549
- define ('AI_TRANSIENT_ADB_FILES_VERSION', 'ai-adb-version');
550
-
551
- define ('AI_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
552
- define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', AI_SYNTAX_HIGHLIGHTER_THEME);
553
- define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
554
- define ('DEFAULT_BLOCK_CLASS', AI_ENABLED);
555
- define ('DEFAULT_BLOCK_NUMBER_CLASS', AI_ENABLED);
556
- define ('DEFAULT_INLINE_STYLES', AI_ENABLED);
557
- define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
558
- define ('DEFAULT_STICKY_WIDGET_MODE', AI_STICKY_WIDGET_MODE_CSS);
559
- define ('DEFAULT_STICKY_WIDGET_MARGIN', 15);
560
- define ('DEFAULT_PLUGIN_PRIORITY', 99999);
561
- define ('DEFAULT_DYNAMIC_BLOCKS', AI_DYNAMIC_BLOCKS_SERVER_SIDE);
562
- define ('DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS', AI_STANDARD_PARAGRAPH_COUNTING_FUNCTIONS);
563
- define ('DEFAULT_NO_PARAGRAPH_COUNTING_INSIDE', 'blockquote, figure, li');
564
- define ('DEFAULT_AD_TITLE', 'Advertisements');
565
- define ('DEFAULT_PARAGRAPH_TAGS', 'p');
566
- define ('DEFAULT_ADMIN_TOOLBAR_DEBUGGING', AI_ENABLED);
567
- define ('DEFAULT_REMOTE_DEBUGGING', AI_DISABLED);
568
- define ('DEFAULT_BACKEND_JS_DEBUGGING', AI_DISABLED);
569
- define ('DEFAULT_FRONTEND_JS_DEBUGGING', AI_DISABLED);
570
- define ('DEFAULT_MULTISITE_SETTINGS_PAGE', AI_ENABLED);
571
- define ('DEFAULT_MULTISITE_WIDGETS', AI_ENABLED);
572
- define ('DEFAULT_MULTISITE_PHP_PROCESSING', AI_ENABLED);
573
- define ('DEFAULT_MULTISITE_EXCEPTIONS', AI_ENABLED);
574
- define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AI_DISABLED);
575
- define ('DEFAULT_TRACKING', AI_TRACKING_DISABLED);
576
- define ('DEFAULT_INTERNAL_TRACKING', AI_ENABLED);
577
- define ('DEFAULT_EXTERNAL_TRACKING', AI_DISABLED);
578
- define ('DEFAULT_TRACKING_LOGGED_IN', AI_TRACKING_ENABLED);
579
- define ('DEFAULT_TRACK_PAGEVIEWS', AI_TRACKING_DISABLED);
580
- define ('DEFAULT_CLICK_DETECTION', AI_CLICK_DETECTION_STANDARD);
581
- define ('DEFAULT_ADB_BLOCK_ACTION', AI_ADB_BLOCK_ACTION_DO_NOTHING);
582
- define ('DEFAULT_ADB_DETECTION', AI_ADB_DETECTION_ADVANCED);
583
- define ('DEFAULT_CUSTOM_HOOK_PRIORITY', 10);
584
- define ('DEFAULT_OUTPUT_BUFFERING', AI_OUTPUT_BUFFERING_DISABLED);
585
- define ('DEFAULT_GEO_DB', AI_GEO_DB_WEBNET77);
586
- define ('DEFAULT_GEO_DB_UPDATES', AI_DISABLED);
587
- define ('DEFAULT_CLOSE_BUTTON', AI_CLOSE_NONE);
588
- define ('DEFAULT_SERVER_SIDE_INSERTION', AI_AUTOMATIC_INSERTION_FOOTER);
589
- define ('DEFAULT_HTML_ELEMENT_INSERTION', AI_HTML_INSERTION_CLIENT_SIDE_DOM_READY);
590
- define ('DEFAULT_CLIENT_SIDE_ACTION', AI_CLIENT_SIDE_ACTION_SHOW);
591
- define ('DEFAULT_HORIZONTAL_POSITION', AI_STICK_TO_THE_LEFT);
592
- define ('DEFAULT_VERTICAL_POSITION', AI_STICK_TO_THE_TOP);
593
-
594
- define ('AI_ADBLOCKING_DETECTION', true);
595
- define ('AI_NORMAL_HEADER_STYLES', true);
596
- define ('AI_AMP_HEADER_STYLES', true);
597
- define ('AI_CODE_GENERATOR', true);
598
- define ('AI_BUFFERING', true);
599
- define ('AI_ADSENSE_API', true);
600
- define ('AI_ADSENSE_OVERLAY', true);
601
- //define ('AI_STICKY_SETTINGS', true);
602
- define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
603
- define ('AI_ADB_2_DEFAULT_NAME', 'lfoswyekaaslsd');
604
- define ('AI_ADB_CONTENT_CSS_BEGIN', 'ai-adb-content-begin');
605
- define ('AI_ADB_CONTENT_CSS_END', 'ai-adb-content-end');
606
- define ('AI_ADB_CONTENT_DELETE_BEGIN', 'ai-adb-delete-begin');
607
- define ('AI_ADB_CONTENT_DELETE_END', 'ai-adb-delete-end');
608
- define ('AI_ADB_CONTENT_REPLACE_BEGIN', 'ai-adb-replace-begin');
609
- define ('AI_ADB_CONTENT_REPLACE_END', 'ai-adb-replace-end');
610
- define ('AI_BASIC_ADB_OVERLAY_CSS', "position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99998; user-select: none;");
611
- define ('AI_DEFAULT_ADB_OVERLAY_CSS', "background: #000; opacity: 0.85;");
612
- define ('AI_BASIC_ADB_MESSAGE_CSS', "position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 99999; background: #000; color: #fff; user-select: none;");
613
- define ('AI_DEFAULT_ADB_MESSAGE_CSS', "width: 300px; padding: 10px; border: 5px solid #f00; border-radius: 5px;");
614
- define ('AI_DEFAULT_ADB_MESSAGE', "<p><strong>Blocked because of Ad Blocker</strong></p>\n<p>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.</p>");
615
- define ('AI_DEFAULT_ADB_ACTION', AI_ADB_ACTION_NONE);
616
- define ('AI_DEFAULT_ADB_NO_ACTION_PERIOD', 30);
617
- define ('AI_DEFAULT_ADB_REDIRECTION_PAGE', 0);
618
- define ('AI_DEFAULT_ADB_UNDISMISSIBLE_MESSAGE', AI_DISABLED);
619
- define ('AI_ADB_VERSION_MASK', 0x7F);
620
- define ('AI_ADB_FLAG_BLOCKED', 0x80);
621
-
622
- define ('DEFAULT_VIEWPORT_NAME_1', "Desktop");
623
- define ('DEFAULT_VIEWPORT_NAME_2', "Tablet");
624
- define ('DEFAULT_VIEWPORT_NAME_3', "Phone");
625
-
626
- define ('DEFAULT_VIEWPORT_WIDTH_1', 980);
627
- define ('DEFAULT_VIEWPORT_WIDTH_2', 768);
628
- define ('DEFAULT_VIEWPORT_WIDTH_3', 0);
629
-
630
- define ('DEFAULT_COUNTRY_GROUP_NAME', "Group");
631
-
632
- define ('AI_MARKER_START', '%##');
633
- define ('AI_MARKER_END', '##%');
634
-
635
- define ('CONTENT_HOOK_BLOCKS', 'content_hook');
636
- define ('EXCERPT_HOOK_BLOCKS', 'excerpt_hook');
637
- define ('LOOP_START_HOOK_BLOCKS', 'loop_start_hook');
638
- define ('LOOP_END_HOOK_BLOCKS', 'loop_end_hook');
639
- define ('POST_HOOK_BLOCKS', 'the_post_hook');
640
- define ('BEFORE_COMMENTS_HOOK_BLOCKS', 'before_comments_hook');
641
- define ('BETWEEN_COMMENTS_HOOK_BLOCKS', 'between_comments_hook');
642
- define ('AFTER_COMMENTS_HOOK_BLOCKS', 'after_comments_hook');
643
- define ('FOOTER_HOOK_BLOCKS', 'wp_footer_hook');
644
- define ('ABOVE_HEADER_HOOK_BLOCKS', 'above_header_hook');
645
- define ('HTML_ELEMENT_HOOK_BLOCKS', 'html_element_hook');
646
- define ('CUSTOM_HOOK_BLOCKS', '_hook');
647
- define ('AI_EXTRACT_USED_BLOCKS', 'used_blocks');
648
-
649
- define ('AI_CHECK_NONE', - 1);
650
- define ('AI_CHECK_INSERTED', 0);
651
-
652
- define ('AI_CHECK_PAGE_TYPE_FRONT_PAGE', 1);
653
- define ('AI_CHECK_PAGE_TYPE_STATIC_PAGE', 2);
654
- define ('AI_CHECK_PAGE_TYPE_POST', 3);
655
- define ('AI_CHECK_PAGE_TYPE_CATEGORY', 4);
656
- define ('AI_CHECK_PAGE_TYPE_SEARCH', 5);
657
- define ('AI_CHECK_PAGE_TYPE_ARCHIVE', 6);
658
- define ('AI_CHECK_PAGE_TYPE_FEED', 7);
659
- define ('AI_CHECK_PAGE_TYPE_404', 8);
660
-
661
- define ('AI_CHECK_DESKTOP_DEVICES', 9);
662
- define ('AI_CHECK_MOBILE_DEVICES', 10);
663
- define ('AI_CHECK_TABLET_DEVICES', 11);
664
- define ('AI_CHECK_PHONE_DEVICES', 12);
665
- define ('AI_CHECK_DESKTOP_TABLET_DEVICES',13);
666
- define ('AI_CHECK_DESKTOP_PHONE_DEVICES', 14);
667
-
668
- define ('AI_CHECK_CATEGORY', 15);
669
- define ('AI_CHECK_TAG', 16);
670
- define ('AI_CHECK_URL', 17);
671
- define ('AI_CHECK_REFERER', 18);
672
- define ('AI_CHECK_SCHEDULING', 19);
673
- define ('AI_CHECK_CODE', 20);
674
- define ('AI_CHECK_LOGGED_IN_USER', 21);
675
- define ('AI_CHECK_NOT_LOGGED_IN_USER', 22);
676
- define ('AI_CHECK_ADMINISTRATOR', 23);
677
-
678
- define ('AI_CHECK_INDIVIDUALLY_DISABLED', 24);
679
- define ('AI_CHECK_INDIVIDUALLY_ENABLED', 25);
680
- define ('AI_CHECK_DISABLED_MANUALLY', 26);
681
- define ('AI_CHECK_MAX_INSERTIONS', 27);
682
- define ('AI_CHECK_FILTER', 28);
683
- define ('AI_CHECK_PARAGRAPH_COUNTING', 29);
684
- define ('AI_CHECK_ENABLED_PHP', 30);
685
- define ('AI_CHECK_ENABLED_SHORTCODE', 31);
686
- define ('AI_CHECK_PARAGRAPHS_MIN_NUMBER', 32);
687
-
688
- define ('AI_CHECK_DEBUG_NO_INSERTION', 33);
689
- define ('AI_CHECK_PARAGRAPH_TAGS', 34);
690
- define ('AI_CHECK_PARAGRAPHS_WITH_TAGS', 35);
691
- define ('AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE', 36);
692
- define ('AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS', 37);
693
- define ('AI_CHECK_PARAGRAPHS_AFTER_TEXT', 38);
694
- define ('AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE', 39);
695
- define ('AI_CHECK_ID', 40);
696
- define ('AI_CHECK_URL_PARAMETER', 41);
697
- define ('AI_CHECK_DO_NOT_INSERT', 42);
698
- define ('AI_CHECK_AD_ABOVE', 43);
699
- define ('AI_CHECK_AD_BELOW', 44);
700
- define ('AI_CHECK_SHORTCODE_ATTRIBUTES', 45);
701
- define ('AI_CHECK_COUNTRY', 46);
702
- define ('AI_CHECK_IP_ADDRESS', 47);
703
- define ('AI_CHECK_PARAGRAPH_NUMBER', 48);
704
- define ('AI_CHECK_MIN_NUMBER_OF_WORDS', 49);
705
- define ('AI_CHECK_MAX_NUMBER_OF_WORDS', 50);
706
- define ('AI_CHECK_TAXONOMY', 51);
707
- define ('AI_CHECK_ENABLED_WIDGET', 52);
708
-
709
- define ('AI_PT_NONE', - 1);
710
- define ('AI_PT_ANY', 0);
711
- define ('AI_PT_STATIC', 1);
712
- define ('AI_PT_POST', 2);
713
- define ('AI_PT_HOMEPAGE', 3);
714
- define ('AI_PT_CATEGORY', 4);
715
- define ('AI_PT_ARCHIVE', 5);
716
- define ('AI_PT_SEARCH', 6);
717
- define ('AI_PT_404', 7);
718
- define ('AI_PT_FEED', 8);
719
- define ('AI_PT_ADMIN', 9);
720
- define ('AI_PT_AJAX', 10);
721
-
722
- define ('AI_USER_NOT_LOGGED_IN', 0);
723
- define ('AI_USER_LOGGED_IN', 1);
724
- define ('AI_USER_ADMINISTRATOR', 2);
725
-
726
- define ('AI_WP_DEBUGGING', 0); // AI_WP_DEBUGGING_
727
- define ('AI_WP_PAGE_TYPE', 1);
728
- define ('AI_WP_USER_SET', 2);
729
- define ('AI_WP_USER', 3);
730
- define ('AI_WP_DEBUG_BLOCK', 4);
731
- define ('AI_WP_URL', 5);
732
- define ('AI_SERVER_SIDE_DETECTION', 6);
733
- define ('AI_CLIENT_SIDE_DETECTION', 7);
734
- define ('AI_CONTEXT', 8);
735
- define ('AI_TRACKING', 9);
736
- define ('AI_STICKY_WIDGETS', 10);
737
- define ('AI_NUMBER_OF_COMMENTS', 11);
738
- define ('AI_COMMENTS_SAVED_CALLBACK', 12);
739
- define ('AI_COMMENTS_SAVED_END_CALLBACK',13);
740
- define ('AI_ADB_DETECTION', 14);
741
- define ('AI_BACKEND_JS_DEBUGGING', 15);
742
- define ('AI_FRONTEND_JS_DEBUGGING', 16);
743
- define ('AI_WP_AMP_PAGE', 17);
744
- define ('AI_INSTALL_TIME_DIFFERENCE', 18);
745
- define ('AI_DAYS_SINCE_INSTAL', 19);
746
- define ('AI_TAGS', 20);
747
- define ('AI_VIEWPORTS', 21);
748
- define ('AI_WORD_COUNT', 22);
749
- define ('AI_ADB_SHORTCODE_ACTION', 23);
750
- define ('AI_SHORTCODES', 24);
751
- define ('AI_VIEWPORT_NAMES', 25);
752
- define ('AI_CLOSE_BUTTONS', 26);
753
- define ('AI_DISABLE_CACHING', 27);
754
- define ('AI_COUNT', 28);
755
- define ('AI_CLIENT_SIDE_INSERTION', 29);
756
- define ('AI_USER_AGENT', 30);
757
- define ('AI_STICK_TO_THE_CONTENT', 31);
758
- define ('AI_DEBUG_MENU_ITEMS', 32);
759
-
760
- define ('AI_CONTEXT_NONE', 0);
761
- define ('AI_CONTEXT_CONTENT', 1);
762
- define ('AI_CONTEXT_EXCERPT', 2);
763
- define ('AI_CONTEXT_BEFORE_POST', 3);
764
- define ('AI_CONTEXT_AFTER_POST', 4);
765
- define ('AI_CONTEXT_WIDGET', 5);
766
- define ('AI_CONTEXT_PHP_FUNCTION', 6);
767
- define ('AI_CONTEXT_SHORTCODE', 7);
768
- define ('AI_CONTEXT_HTTP_HEADER', 8);
769
- define ('AI_CONTEXT_HEADER', 9);
770
- define ('AI_CONTEXT_FOOTER', 10);
771
- define ('AI_CONTEXT_BETWEEN_POSTS', 11);
772
- define ('AI_CONTEXT_BEFORE_COMMENTS', 12);
773
- define ('AI_CONTEXT_BETWEEN_COMMENTS', 13);
774
- define ('AI_CONTEXT_AFTER_COMMENTS', 14);
775
-
776
- define ('AI_URL_DEBUG', 'ai-debug'); // AI_URL_DEBUG_
777
- define ('AI_URL_DEBUG_PROCESSING', 'ai-debug-processing'); // AI_URL_DEBUG_PROCESSING_
778
- define ('AI_URL_DEBUG_PHP', 'ai-debug-php'); // AI_URL_DEBUG_PHP
779
- define ('AI_URL_DEBUG_BLOCKS', 'ai-debug-blocks');
780
- define ('AI_URL_DEBUG_USER', 'ai-debug-user');
781
- define ('AI_URL_DEBUG_TAGS', 'ai-debug-tags');
782
- define ('AI_URL_DEBUG_POSITIONS', 'ai-debug-positions');
783
- define ('AI_URL_DEBUG_NO_INSERTION', 'ai-debug-no-insertion');
784
- define ('AI_URL_DEBUG_COUNTRY', 'ai-debug-country');
785
- define ('AI_URL_DEBUG_AD_BLOCKING' , 'ai-debug-adb');
786
- define ('AI_URL_DEBUG_AD_BLOCKING_STATUS', 'ai-debug-adb-status');
787
- define ('AI_URL_DEBUG_JAVASCRIPT', 'ai-debug-js');
788
-
789
- define ('AI_DEBUG_PROCESSING', 0x01); // AI_DEBUG_PROCESSING_
790
- define ('AI_DEBUG_BLOCKS', 0x02);
791
- define ('AI_DEBUG_TAGS', 0x04);
792
- define ('AI_DEBUG_POSITIONS', 0x08);
793
- define ('AI_DEBUG_NO_INSERTION', 0x10);
794
- define ('AI_DEBUG_AD_BLOCKING', 0x20);
795
- define ('AI_DEBUG_AD_BLOCKING_STATUS', 0x40);
796
-
797
- if (!defined ('AD_INSERTER_BLOCKS'))
798
- define ('AD_INSERTER_BLOCKS', 16);
799
-
800
- if (!defined ('AD_INSERTER_VIEWPORTS'))
801
- define ('AD_INSERTER_VIEWPORTS', 3);
802
-
803
- if (!defined ('AD_INSERTER_HOOKS'))
804
- define ('AD_INSERTER_HOOKS', 2);
805
-
806
- define ('AI_DEBUG_WIDGET_STYLE', 'margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;');
807
-
808
- define ('AI_DEBUG_TAGS_CLASS', 'ai-debug-tags');
809
- define ('AI_DEBUG_POSITIONS_CLASS', 'ai-debug-positions');
810
- define ('AI_DEBUG_PAGE_TYPE_CLASS', 'ai-debug-page-type');
811
- define ('AI_DEBUG_STATUS_CLASS', 'ai-debug-status');
812
- define ('AI_DEBUG_ADB_CLASS', 'ai-debug-adb');
813
- define ('AI_ADSENSE_BLOCK_CLASS', 'ai-adsense-');
814
-
815
- define ('AI_CODE_UNKNOWN', 100);
816
- define ('AI_CODE_BANNER', 0);
817
- define ('AI_CODE_ADSENSE', 1);
818
-
819
- define ('AI_ADSENSE_STANDARD', 0);
820
- define ('AI_ADSENSE_LINK', 1);
821
- define ('AI_ADSENSE_IN_ARTICLE', 2);
822
- define ('AI_ADSENSE_IN_FEED', 3);
823
- define ('AI_ADSENSE_MATCHED_CONTENT', 4);
824
- define ('AI_ADSENSE_AUTO', 5);
825
-
826
- define ('AI_ADSENSE_AMP_DISABLED', 0);
827
- define ('AI_ADSENSE_AMP_ABOVE_THE_FOLD', 1);
828
- define ('AI_ADSENSE_AMP_BELOW_THE_FOLD', 2);
829
-
830
- define ('AI_ADSENSE_SIZE_FIXED', 0);
831
- define ('AI_ADSENSE_SIZE_RESPONSIVE', 1);
832
- define ('AI_ADSENSE_SIZE_FIXED_BY_VIEWPORT', 2);
833
-
834
- define ('AI_TEXT_LINK', 'Link');
835
- define ('AI_TEXT_IN_ARTICLE', 'In-article');
836
- define ('AI_TEXT_IN_FEED', 'In-feed');
837
- define ('AI_TEXT_MATCHED_CONTENT', 'Matched content');
838
-
839
- define ('AI_TEXT_ABOVE_THE_FOLD', 'Above the fold');
840
- define ('AI_TEXT_BELOW_THE_FOLD', 'Below the fold');
841
-
842
- define ('AI_TEXT_FIXED', 'Fixed');
843
- define ('AI_TEXT_RESPONSIVE', 'Responsive');
844
- define ('AI_TEXT_FIXED_BY_VIEWPORT', 'Fixed by viewport');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //ini_set ('display_errors', 1);
4
+ //error_reporting (E_ALL);
5
+
6
+ define ('AI_OPTION_NAME', 'ad_inserter');
7
+ define ('AI_INSTALL_NAME', 'ai-install');
8
+ define ('AI_OPTION_GLOBAL', 'global');
9
+ define ('AI_OPTION_EXTRACT', 'extract');
10
+ define ('AI_ADSENSE_CLIENT_IDS', 'ai-adsense-client-ids');
11
+ define ('AI_ADSENSE_AUTH_CODE', 'ai-adsense-auth-code');
12
+
13
+ if (!defined ('AD_INSERTER_PLUGIN_DIR'))
14
+ define ('AD_INSERTER_PLUGIN_DIR', plugin_dir_path (__FILE__));
15
+
16
+ if (!defined ('AD_INSERTER_FILE'))
17
+ define ('AD_INSERTER_FILE', AD_INSERTER_PLUGIN_DIR.'ad-inserter.php');
18
+
19
+ if (file_exists (AD_INSERTER_PLUGIN_DIR.'includes/functions.php')) {
20
+ include_once AD_INSERTER_PLUGIN_DIR.'includes/functions.php';
21
+ }
22
+
23
+ if (!defined( 'AD_INSERTER_NAME'))
24
+ define ('AD_INSERTER_NAME', 'Ad Inserter');
25
+
26
+ if (!defined( 'AD_INSERTER_VERSION'))
27
+ define ('AD_INSERTER_VERSION', '2.3.8');
28
+
29
+ if (!defined ('AD_INSERTER_PLUGIN_BASENAME'))
30
+ define ('AD_INSERTER_PLUGIN_BASENAME', plugin_basename (__FILE__));
31
+
32
+ if (!defined ('AD_INSERTER_PLUGIN_DIRNAME'))
33
+ define ('AD_INSERTER_PLUGIN_DIRNAME', dirname (AD_INSERTER_PLUGIN_BASENAME));
34
+
35
+ if (!defined ('AD_INSERTER_PLUGIN_URL'))
36
+ define ('AD_INSERTER_PLUGIN_URL', plugin_dir_url ( __FILE__));
37
+
38
+ if (!defined ('AD_INSERTER_PLUGIN_IMAGES_URL'))
39
+ define ('AD_INSERTER_PLUGIN_IMAGES_URL', AD_INSERTER_PLUGIN_URL. 'images/');
40
+
41
+ define ('AD_EMPTY_DATA', '');
42
+ define ('AD_ZERO', '0');
43
+ define ('AD_ONE', '1');
44
+ define ('AD_TWO', '2');
45
+ define ('AD_GENERAL_TAG', '');
46
+ define ('AD_NAME', 'Block');
47
+
48
+ // Old options
49
+ define ('AD_OPTIONS', 'AdInserterOptions'); // general plugin options
50
+ define ('AD_ADx_OPTIONS', 'AdInserter#Options');
51
+
52
+ // Options
53
+ define ('WP_FORM_FIELD_POSTFIX', '_block_');
54
+ define ('AI_HEADER_OPTION_NAME', 'h');
55
+ define ('AI_FOOTER_OPTION_NAME', 'f');
56
+ define ('AI_ADB_MESSAGE_OPTION_NAME', 'a');
57
+
58
+ define ('AI_OPTION_CODE', 'code');
59
+ define ('AI_OPTION_ENABLE_MANUAL', 'enable_manual');
60
+ define ('AI_OPTION_ENABLE_AMP', 'enable_amp');
61
+ define ('AI_OPTION_ENABLE_WIDGET', 'enable_widget');
62
+ define ('AI_OPTION_PROCESS_PHP', 'process_php');
63
+ define ('AI_OPTION_SHOW_LABEL', 'show_label');
64
+ define ('AI_OPTION_TRACKING', 'tracking');
65
+ define ('AI_OPTION_ENABLE_AJAX', 'enable_ajax');
66
+ define ('AI_OPTION_ENABLE_FEED', 'enable_feed');
67
+ define ('AI_OPTION_ENABLE_404', 'enable_404');
68
+ define ('AI_OPTION_DISABLE_CACHING', 'disable_caching');
69
+ define ('AI_OPTION_BLOCK_NAME', 'name');
70
+ define ('AI_OPTION_AUTOMATIC_INSERTION', 'display_type');
71
+ define ('AI_OPTION_PARAGRAPH_NUMBER', 'paragraph_number');
72
+ define ('AI_OPTION_MIN_PARAGRAPHS', 'min_paragraphs');
73
+ define ('AI_OPTION_MIN_WORDS_ABOVE', 'min_words_above');
74
+ define ('AI_OPTION_COUNT_INSIDE_BLOCKQUOTE', 'count_inside_blockquote');
75
+ define ('AI_OPTION_MIN_WORDS', 'min_words');
76
+ define ('AI_OPTION_MAX_WORDS', 'max_words');
77
+ define ('AI_OPTION_MIN_PARAGRAPH_WORDS', 'min_paragraph_words');
78
+ define ('AI_OPTION_MAX_PARAGRAPH_WORDS', 'max_paragraph_words');
79
+ define ('AI_OPTION_PARAGRAPH_TAGS', 'paragraph_tags');
80
+ define ('AI_OPTION_AVOID_PARAGRAPHS_ABOVE', 'avoid_paragraphs_above');
81
+ define ('AI_OPTION_AVOID_PARAGRAPHS_BELOW', 'avoid_paragraphs_below');
82
+ define ('AI_OPTION_AVOID_TEXT_ABOVE', 'avoid_text_above');
83
+ define ('AI_OPTION_AVOID_TEXT_BELOW', 'avoid_text_below');
84
+ define ('AI_OPTION_AVOID_ACTION', 'avoid_action');
85
+ define ('AI_OPTION_AVOID_TRY_LIMIT', 'avoid_try_limit');
86
+ define ('AI_OPTION_AVOID_DIRECTION', 'avoid_direction');
87
+ define ('AI_OPTION_HTML_SELECTOR', 'html_selector');
88
+ define ('AI_OPTION_SERVER_SIDE_INSERTION', 'server_side_insertion');
89
+ define ('AI_OPTION_HTML_ELEMENT_INSERTION', 'html_insertion');
90
+ define ('AI_OPTION_EXCERPT_NUMBER', 'excerpt_number'); // needs to be renamed
91
+ define ('AI_OPTION_FILTER_TYPE', 'filter_type');
92
+ define ('AI_OPTION_INVERTED_FILTER', 'inverted_filter');
93
+ define ('AI_OPTION_DIRECTION_TYPE', 'direction_type');
94
+ define ('AI_OPTION_ALIGNMENT_TYPE', 'alignment_type');
95
+ define ('AI_OPTION_HORIZONTAL_POSITION', 'horizontal_position');
96
+ define ('AI_OPTION_VERTICAL_POSITION', 'vertical_position');
97
+ define ('AI_OPTION_GENERAL_TAG', 'general_tag');
98
+ define ('AI_OPTION_SCHEDULING', 'scheduling');
99
+ define ('AI_OPTION_AFTER_DAYS', 'after_days');
100
+ define ('AI_OPTION_START_DATE', 'start_date');
101
+ define ('AI_OPTION_END_DATE', 'end_date');
102
+ define ('AI_OPTION_FALLBACK', 'fallback');
103
+ define ('AI_OPTION_MAXIMUM_INSERTIONS', 'maximum_insertions');
104
+ define ('AI_OPTION_ID_LIST', 'id_list');
105
+ define ('AI_OPTION_ID_LIST_TYPE', 'id_list_type');
106
+ define ('AI_OPTION_URL_LIST', 'url_list');
107
+ define ('AI_OPTION_URL_LIST_TYPE', 'url_list_type');
108
+ define ('AI_OPTION_URL_PARAMETER_LIST', 'url_parameter_list');
109
+ define ('AI_OPTION_URL_PARAMETER_LIST_TYPE', 'url_parameter_list_type');
110
+ define ('AI_OPTION_DOMAIN_LIST', 'domain_list');
111
+ define ('AI_OPTION_DOMAIN_LIST_TYPE', 'domain_list_type');
112
+ define ('AI_OPTION_IP_ADDRESS_LIST', 'ip_address_list');
113
+ define ('AI_OPTION_IP_ADDRESS_LIST_TYPE', 'ip_address_list_type');
114
+ define ('AI_OPTION_COUNTRY_LIST', 'country_list');
115
+ define ('AI_OPTION_COUNTRY_LIST_TYPE', 'country_list_type');
116
+ define ('AI_OPTION_CATEGORY_LIST', 'category_list');
117
+ define ('AI_OPTION_CATEGORY_LIST_TYPE', 'category_list_type');
118
+ define ('AI_OPTION_TAG_LIST', 'tag_list');
119
+ define ('AI_OPTION_TAG_LIST_TYPE', 'tag_list_type');
120
+ define ('AI_OPTION_TAXONOMY_LIST', 'taxonomy_list');
121
+ define ('AI_OPTION_TAXONOMY_LIST_TYPE', 'taxonomy_list_type');
122
+ define ('AI_OPTION_DISPLAY_ON_HOMEPAGE', 'display_on_homepage');
123
+ define ('AI_OPTION_DISPLAY_ON_PAGES', 'display_on_pages');
124
+ define ('AI_OPTION_DISPLAY_ON_POSTS', 'display_on_posts');
125
+ define ('AI_OPTION_DISPLAY_ON_CATEGORY_PAGES', 'display_on_category_pages');
126
+ define ('AI_OPTION_DISPLAY_ON_SEARCH_PAGES', 'display_on_search_pages');
127
+ define ('AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES', 'display_on_archive_pages');
128
+ define ('AI_OPTION_ENABLED_ON_WHICH_PAGES', 'enabled_on_which_pages');
129
+ define ('AI_OPTION_ENABLED_ON_WHICH_POSTS', 'enabled_on_which_posts');
130
+ define ('AI_OPTION_ENABLE_PHP_CALL', 'enable_php_call');
131
+ define ('AI_OPTION_PARAGRAPH_TEXT', 'paragraph_text');
132
+ define ('AI_OPTION_PARAGRAPH_TEXT_TYPE', 'paragraph_text_type');
133
+ define ('AI_OPTION_CUSTOM_CSS', 'custom_css');
134
+ define ('AI_OPTION_DISPLAY_FOR_USERS', 'display_for_users');
135
+ define ('AI_OPTION_DISPLAY_FOR_DEVICES', 'display_for_devices');
136
+ define ('AI_OPTION_DETECT_SERVER_SIDE', 'detect_server_side');
137
+ define ('AI_OPTION_DETECT_CLIENT_SIDE', 'detect_client_side');
138
+ define ('AI_OPTION_CLIENT_SIDE_ACTION', 'client_side_action');
139
+ define ('AI_OPTION_DETECT_VIEWPORT', 'detect_viewport');
140
+ define ('AI_OPTION_ADB_BLOCK_ACTION', 'adb-block-action');
141
+ define ('AI_OPTION_ADB_BLOCK_REPLACEMENT', 'adb-block-replacement');
142
+ define ('AI_OPTION_CLOSE_BUTTON', 'close-button');
143
+ define ('AI_OPTION_HORIZONTAL_MARGIN', 'horizontal-margin');
144
+ define ('AI_OPTION_VERTICAL_MARGIN', 'vertical-margin');
145
+ define ('AI_OPTION_ANIMATION', 'animation');
146
+ define ('AI_OPTION_ANIMATION_TRIGGER', 'animation-trigger');
147
+ define ('AI_OPTION_ANIMATION_TRIGGER_VALUE', 'animation-trigger-value');
148
+ define ('AI_OPTION_ANIMATION_TRIGGER_OFFSET', 'animation-trigger-offset');
149
+ define ('AI_OPTION_ANIMATION_TRIGGER_DELAY', 'animation-trigger-delay');
150
+ define ('AI_OPTION_ANIMATION_TRIGGER_ONCE', 'animation-trigger-once');
151
+
152
+ define ('AI_OPTION_DISABLED', 'disabled');
153
+
154
+ define ('AI_OPTION_IMPORT', 'import');
155
+ define ('AI_OPTION_IMPORT_NAME', 'import_name');
156
+ define ('AI_OPTION_PLUGIN_STATUS', 'plugin_status');
157
+
158
+ define ('AI_OPTION_ADB_ACTION', 'adb-action');
159
+ define ('AI_OPTION_ADB_SELECTORS', 'adb-selectors');
160
+ define ('AI_OPTION_ADB_DELAY_ACTION', 'adb-delay-action');
161
+ define ('AI_OPTION_ADB_NO_ACTION_PERIOD', 'adb-no-action-period');
162
+ define ('AI_OPTION_ADB_REDIRECTION_PAGE', 'adb-redirection-page');
163
+ define ('AI_OPTION_ADB_CUSTOM_REDIRECTION_URL', 'adb-custom-redirection-url');
164
+ define ('AI_OPTION_ADB_MESSAGE_CSS', 'adb-message-css');
165
+ define ('AI_OPTION_ADB_OVERLAY_CSS', 'adb-overlay-css');
166
+ define ('AI_OPTION_ADB_UNDISMISSIBLE_MESSAGE', 'adb-undismissible-message');
167
+
168
+
169
+ //misc
170
+ define('AD_EMPTY_VALUE','');
171
+
172
+ //define constant variable form
173
+ define('AI_FORM_SAVE', 'ai_save');
174
+ define('AI_FORM_CLEAR', 'ai_clear');
175
+ define('AI_FORM_CLEAR_EXCEPTIONS', 'ai-clear-exceptions');
176
+ define('AI_FORM_CLEAR_STATISTICS', 'ai-clear-statistics');
177
+
178
+ define('AD_AUTHOR_SITE', '<!-- Powered by Ad Inserter Plugin By Spacetime -->');
179
+ define('AD_ROTATE_SEPARATOR', '|rotate|');
180
+ define('AD_COUNT_SEPARATOR', '|count|');
181
+ define('AD_AMP_SEPARATOR', '|amp|');
182
+ define('AD_HTTP_SEPARATOR', '|http|');
183
+
184
+ //form select options
185
+ define('AD_SELECT_SELECTED','selected');
186
+
187
+ //Automatic insertion options - Deprecated
188
+ define('AD_SELECT_NONE','None');
189
+ define('AD_SELECT_BEFORE_POST','Before Post');
190
+ define('AD_SELECT_AFTER_POST','After Post');
191
+ define('AD_SELECT_BEFORE_PARAGRAPH','Before Paragraph');
192
+ define('AD_SELECT_AFTER_PARAGRAPH','After Paragraph');
193
+ define('AD_SELECT_BEFORE_CONTENT','Before Content');
194
+ define('AD_SELECT_AFTER_CONTENT','After Content');
195
+ define('AD_SELECT_BEFORE_EXCERPT','Before Excerpt');
196
+ define('AD_SELECT_AFTER_EXCERPT','After Excerpt');
197
+ define('AD_SELECT_BETWEEN_POSTS','Between Posts');
198
+ define('AD_SELECT_WIDGET','Widget'); // Deprecated
199
+ define('AD_SELECT_BEFORE_TITLE','Before Title'); // Deprecated
200
+ define('AD_SELECT_MANUAL','Manual'); // Deprecated
201
+
202
+ define('AI_AUTOMATIC_INSERTION_DISABLED', 0);
203
+ define('AI_AUTOMATIC_INSERTION_BEFORE_POST', 1);
204
+ define('AI_AUTOMATIC_INSERTION_AFTER_POST', 2);
205
+ define('AI_AUTOMATIC_INSERTION_BEFORE_CONTENT', 3);
206
+ define('AI_AUTOMATIC_INSERTION_AFTER_CONTENT', 4);
207
+ define('AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH', 5);
208
+ define('AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH', 6);
209
+ define('AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT', 7);
210
+ define('AI_AUTOMATIC_INSERTION_AFTER_EXCERPT', 8);
211
+ define('AI_AUTOMATIC_INSERTION_BETWEEN_POSTS', 9);
212
+ define('AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS', 10);
213
+ define('AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS', 11);
214
+ define('AI_AUTOMATIC_INSERTION_AFTER_COMMENTS', 12);
215
+ define('AI_AUTOMATIC_INSERTION_FOOTER', 13);
216
+ define('AI_AUTOMATIC_INSERTION_ABOVE_HEADER', 14);
217
+ define('AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT', 15);
218
+ define('AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT', 16);
219
+
220
+ define('AI_AUTOMATIC_INSERTION_OUTPUT_BUFFERING', 99);
221
+ define('AI_AUTOMATIC_INSERTION_CUSTOM_HOOK', 100);
222
+
223
+ define('AI_TEXT_DISABLED', 'Disabled');
224
+ define('AI_TEXT_BEFORE_POST', 'Before Post');
225
+ define('AI_TEXT_AFTER_POST', 'After Post');
226
+ define('AI_TEXT_BEFORE_CONTENT', 'Before Content');
227
+ define('AI_TEXT_AFTER_CONTENT', 'After Content');
228
+ define('AI_TEXT_BEFORE_PARAGRAPH', 'Before Paragraph');
229
+ define('AI_TEXT_AFTER_PARAGRAPH', 'After Paragraph');
230
+ define('AI_TEXT_BEFORE_EXCERPT', 'Before Excerpt');
231
+ define('AI_TEXT_AFTER_EXCERPT', 'After Excerpt');
232
+ define('AI_TEXT_BETWEEN_POSTS', 'Between Posts');
233
+ define('AI_TEXT_BEFORE_COMMENTS', 'Before Comments');
234
+ define('AI_TEXT_BETWEEN_COMMENTS', 'Between Comments');
235
+ define('AI_TEXT_AFTER_COMMENTS', 'After Comments');
236
+ define('AI_TEXT_ABOVE_HEADER', 'Above Header');
237
+ define('AI_TEXT_FOOTER', 'Footer');
238
+ define('AI_TEXT_BEFORE_HTML_ELEMENT', 'Before HTML element');
239
+ define('AI_TEXT_AFTER_HTML_ELEMENT', 'After HTML element');
240
+
241
+ //Display options
242
+ define('AD_DISPLAY_ALL_USERS','all users');
243
+ define('AD_DISPLAY_LOGGED_IN_USERS','logged in users');
244
+ define('AD_DISPLAY_NOT_LOGGED_IN_USERS','not logged in users');
245
+ define('AD_DISPLAY_ADMINISTRATORS','administrators');
246
+
247
+ define('AD_DISPLAY_ALL_DEVICES','all');
248
+ define('AD_DISPLAY_DESKTOP_DEVICES','desktop');
249
+ define('AD_DISPLAY_MOBILE_DEVICES','mobile');
250
+ define('AD_DISPLAY_TABLET_DEVICES','tablet');
251
+ define('AD_DISPLAY_PHONE_DEVICES','phone');
252
+ define('AD_DISPLAY_DESKTOP_TABLET_DEVICES','desktop and tablet');
253
+ define('AD_DISPLAY_DESKTOP_PHONE_DEVICES','desktop and phone');
254
+
255
+ //Direction options
256
+ define('AD_DIRECTION_FROM_TOP','From Top');
257
+ define('AD_DIRECTION_FROM_BOTTOM','From Bottom');
258
+
259
+ //Post-Page options
260
+ // Deprecated
261
+ define('AD_ENABLED_ON_ALL', 'On all');
262
+ define('AD_ENABLED_ON_ALL_EXCEPT_ON_SELECTED', 'On all except selected');
263
+ define('AD_ENABLED_ONLY_ON_SELECTED', 'Only on selected');
264
+
265
+ define('AI_NO_INDIVIDUAL_EXCEPTIONS', 0);
266
+ define('AI_INDIVIDUALLY_DISABLED', 1);
267
+ define('AI_INDIVIDUALLY_ENABLED', 2);
268
+
269
+ define('AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS', '');
270
+ define('AI_TEXT_INDIVIDUALLY_DISABLED', 'Individually disabled');
271
+ define('AI_TEXT_INDIVIDUALLY_ENABLED', 'Individually enabled');
272
+
273
+ //Alignment options - Deprecated
274
+ define('AD_ALIGNMENT_NO_WRAPPING','No Wrapping');
275
+ define('AD_ALIGNMENT_CUSTOM_CSS','Custom CSS');
276
+ define('AD_ALIGNMENT_NONE','None');
277
+ define('AD_ALIGNMENT_LEFT','Align Left');
278
+ define('AD_ALIGNMENT_RIGHT','Align Right');
279
+ define('AD_ALIGNMENT_CENTER','Center');
280
+ define('AD_ALIGNMENT_FLOAT_LEFT','Float Left');
281
+ define('AD_ALIGNMENT_FLOAT_RIGHT','Float Right');
282
+
283
+ define('AI_ALIGNMENT_DEFAULT', 0);
284
+ define('AI_ALIGNMENT_LEFT', 1);
285
+ define('AI_ALIGNMENT_RIGHT', 2);
286
+ define('AI_ALIGNMENT_CENTER', 3);
287
+ define('AI_ALIGNMENT_FLOAT_LEFT', 4);
288
+ define('AI_ALIGNMENT_FLOAT_RIGHT', 5);
289
+ define('AI_ALIGNMENT_NO_WRAPPING', 6);
290
+ define('AI_ALIGNMENT_CUSTOM_CSS', 7);
291
+ define('AI_ALIGNMENT_STICKY_LEFT', 8);
292
+ define('AI_ALIGNMENT_STICKY_RIGHT', 9);
293
+ define('AI_ALIGNMENT_STICKY_TOP', 10);
294
+ define('AI_ALIGNMENT_STICKY_BOTTOM', 11);
295
+ define('AI_ALIGNMENT_STICKY', 12);
296
+
297
+ // Used also for alignment class names
298
+ define('AI_TEXT_DEFAULT', 'Default');
299
+ define('AI_TEXT_LEFT', 'Align Left');
300
+ define('AI_TEXT_RIGHT', 'Align Right');
301
+ define('AI_TEXT_CENTER', 'Center');
302
+ define('AI_TEXT_FLOAT_LEFT', 'Float Left');
303
+ define('AI_TEXT_FLOAT_RIGHT', 'Float Right');
304
+ define('AI_TEXT_NO_WRAPPING', 'No Wrapping');
305
+ define('AI_TEXT_CUSTOM_CSS', 'Custom CSS');
306
+ define('AI_TEXT_STICKY_LEFT', 'Sticky Left');
307
+ define('AI_TEXT_STICKY_RIGHT', 'Sticky Right');
308
+ define('AI_TEXT_STICKY_TOP', 'Sticky Top');
309
+ define('AI_TEXT_STICKY_BOTTOM', 'Sticky Bottom');
310
+ define('AI_TEXT_STICKY', 'Sticky');
311
+
312
+ define('AI_STICK_TO_THE_LEFT', 0);
313
+ define('AI_STICK_TO_THE_CONTENT_LEFT', 1);
314
+ define('AI_STICK_HORIZONTAL_CENTER', 2);
315
+ define('AI_STICK_TO_THE_CONTENT_RIGHT', 3);
316
+ define('AI_STICK_TO_THE_RIGHT', 4);
317
+
318
+ define('AI_TEXT_STICK_TO_THE_LEFT', 'Stick to the left');
319
+ define('AI_TEXT_STICK_TO_THE_CONTENT_LEFT', 'Stick to the content left');
320
+ define('AI_TEXT_STICK_TO_THE_CONTENT_RIGHT', 'Stick to the content right');
321
+ define('AI_TEXT_STICK_TO_THE_RIGHT', 'Stick to the right');
322
+
323
+ define('AI_STICK_TO_THE_TOP', 0);
324
+ define('AI_STICK_VERTICAL_CENTER', 1);
325
+ define('AI_SCROLL_WITH_THE_CONTENT', 2);
326
+ define('AI_STICK_TO_THE_BOTTOM', 3);
327
+
328
+ define('AI_TEXT_STICK_TO_THE_TOP', 'Stick to the top');
329
+ define('AI_TEXT_SCROLL_WITH_THE_CONTENT', 'Scroll with the content');
330
+ define('AI_TEXT_STICK_TO_THE_BOTTOM', 'Stick to the bottom');
331
+
332
+ define('AI_ANIMATION_NONE', 0);
333
+ define('AI_ANIMATION_FADE', 1);
334
+ define('AI_ANIMATION_SLIDE', 2);
335
+ define('AI_ANIMATION_SLIDE_FADE', 3);
336
+ define('AI_ANIMATION_FLIP', 4);
337
+ define('AI_ANIMATION_ZOOM_IN', 5);
338
+ define('AI_ANIMATION_ZOOM_OUT', 6);
339
+ define('AI_ANIMATION_TURN', 7);
340
+
341
+ define('AI_TEXT_FADE', 'Fade');
342
+ define('AI_TEXT_SLIDE', 'Slide');
343
+ define('AI_TEXT_SLIDE_FADE', 'Slide and Fade');
344
+ define('AI_TEXT_FLIP', 'Flip');
345
+ define('AI_TEXT_ZOOM_IN', 'Zoom In');
346
+ define('AI_TEXT_ZOOM_OUT', 'Zoom Out');
347
+ define('AI_TEXT_TURN', 'Turn');
348
+
349
+ define('AI_TRIGGER_PAGE_LOADED', 0);
350
+ define('AI_TRIGGER_PAGE_SCROLLED_PC', 1);
351
+ define('AI_TRIGGER_PAGE_SCROLLED_PX', 2);
352
+ define('AI_TRIGGER_ELEMENT_VISIBLE', 3);
353
+
354
+ define('AI_TEXT_PAGE_LOADED', 'Page loaded');
355
+ define('AI_TEXT_PAGE_SCROLLED_PC', 'Page scrolled (%)');
356
+ define('AI_TEXT_PAGE_SCROLLED_PX', 'Page scrolled (px)');
357
+ define('AI_TEXT_ELEMENT_VISIBLE', 'Element visible');
358
+
359
+ define('AI_STICKY_Z_INDEX', 9995); // update ad-inserter.js
360
+
361
+ define('AI_ALIGNMENT_CSS_DEFAULT', 'margin: 8px 0; clear: both;');
362
+ define('AI_ALIGNMENT_CSS_LEFT', 'margin: 8px auto 8px 0; text-align: left; clear: both;||margin: 8px 0; text-align: left; clear: both; display: flex; justify-content: flex-start; flex-direction: column; align-items: flex-start;');
363
+ define('AI_ALIGNMENT_CSS_RIGHT', 'margin: 8px 0 8px auto; text-align: right; clear: both;||margin: 8px 0; text-align: right; clear: both; display: flex; justify-content: flex-end; flex-direction: column; align-items: flex-end;');
364
+ define('AI_ALIGNMENT_CSS_CENTER', 'margin: 8px auto; text-align: center; clear: both;||margin: 8px 0; text-align: center; clear: both; display: flex; justify-content: center; flex-direction: column; align-items: center;');
365
+ define('AI_ALIGNMENT_CSS_FLOAT_LEFT', 'margin: 8px 8px 8px 0; float: left;');
366
+ define('AI_ALIGNMENT_CSS_FLOAT_RIGHT', 'margin: 8px 0 8px 8px; float: right;');
367
+ define('AI_ALIGNMENT_CSS_STICKY_LEFT', 'position: fixed; left: 0px; top: 100px; z-index: 9999;');
368
+ define('AI_ALIGNMENT_CSS_STICKY_RIGHT', 'position: fixed; right: 0px; top: 100px; z-index: 9999;');
369
+ define('AI_ALIGNMENT_CSS_STICKY_TOP', 'position: fixed; top: 0; text-align: center; left: 50%; transform: translate(-50%); width: 100%; z-index: 9999;||position: fixed; top: 0; left: 0; width: 100%; text-align: center; z-index: 9999;||position: fixed; top: 0; left: 0; width: 100%; text-align: center; display: flex; justify-content: center; z-index: 9999;');
370
+ define('AI_ALIGNMENT_CSS_STICKY_BOTTOM', 'position: fixed; bottom: 0; text-align: center; left: 50%; transform: translate(-50%); width: 100%; z-index: 9999;||position: fixed; bottom: 0; left: 0; width: 100%; text-align: center; z-index: 9999;||position: fixed; bottom: 0; left: 0; width: 100%; text-align: center; display: flex; justify-content: center; z-index: 9999;');
371
+ define('AI_ALIGNMENT_CSS_STICKY', 'position: fixed; z-index: '.AI_STICKY_Z_INDEX.';');
372
+
373
+ define('AI_ALIGNMENT_CSS_STICK_TO_THE_TOP', ' top: 0px;');
374
+ define('AI_ALIGNMENT_CSS_STICK_TO_THE_TOP_OFFSET', ' top: 100px;');
375
+ define('AI_ALIGNMENT_CSS_CENTER_VERTICAL', ' top: 50%; transform: translate(0, -50%);');
376
+ define('AI_ALIGNMENT_CSS_CENTER_VERTICAL_H_ANIM', ' top: 50%;');
377
+ //define('AI_ALIGNMENT_CSS_SCROLL_WITH_THE_CONTENT', ' position: relative; margin-bottom: auto; width: fit-content; top: 100px; display: none;');
378
+ define('AI_ALIGNMENT_CSS_SCROLL_WITH_THE_CONTENT', ' position: absolute; margin-bottom: auto; width: fit-content; top: 100px; display: none;');
379
+ define('AI_ALIGNMENT_CSS_STICK_TO_THE_BOTTOM', ' bottom: 0px;');
380
+ define('AI_ALIGNMENT_CSS_STICK_TO_THE_BOTTOM_OFFSET', ' bottom: 100px;');
381
+
382
+ define('AI_ALIGNMENT_CSS_STICK_TO_THE_LEFT', ' left: 0px;');
383
+ define('AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_LEFT', ' left: auto; margin-right: 10px; width: fit-content; display: none;');
384
+ define('AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL', ' text-align: center; left: 50%; transform: translate(-50%);');
385
+ define('AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL_V', ' text-align: center; left: 50%; transform: translate(-50%, -50%);');
386
+ define('AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL_ANIM', ' text-align: center; left: 50%;');
387
+ define('AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_RIGHT', ' right: auto; margin-left: 10px; width: fit-content; display: none;');
388
+ define('AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT', ' right: 0px;');
389
+ define('AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT_SCROLL', ' right: 0px; margin-left: auto;');
390
+
391
+ define('AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_LEFT_W', ' right: calc(50%); display: block;');
392
+ define('AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_RIGHT_W', ' left: calc(50%); display: block;');
393
+
394
+ define('AI_ALIGNMENT_CSS_AMP_LEFT', 'display: flex; justify-content: flex-start;');
395
+ define('AI_ALIGNMENT_CSS_AMP_RIGHT', 'display: flex; justify-content: flex-end;');
396
+ define('AI_ALIGNMENT_CSS_AMP_CENTER', 'display: flex; justify-content: center;');
397
+
398
+ //List Type
399
+ define('AD_BLACK_LIST','Black List');
400
+ define('AD_WHITE_LIST','White List');
401
+
402
+ //Filter Type - Deprecated
403
+ define ('AI_OPTION_FILTER_AUTO', 'Auto');
404
+ define ('AI_OPTION_FILTER_PHP_FUNCTION_CALLS', 'PHP function calls');
405
+ define ('AI_OPTION_FILTER_CONTENT_PROCESSING', 'Content processing');
406
+ define ('AI_OPTION_FILTER_EXCERPT_PROCESSING', 'Excerpt processing');
407
+ define ('AI_OPTION_FILTER_BEFORE_POST_PROCESSING', 'Before post processing');
408
+ define ('AI_OPTION_FILTER_AFTER_POST_PROCESSING', 'After post processing');
409
+ define ('AI_OPTION_FILTER_WIDGET_DRAWING', 'Widget drawing');
410
+ define ('AI_OPTION_FILTER_SUBPAGES', 'Subpages');
411
+ define ('AI_OPTION_FILTER_POSTS', 'Posts');
412
+ define ('AI_OPTION_FILTER_COMMENTS', 'Comments');
413
+
414
+
415
+ //Filter Type
416
+ define ('AI_FILTER_AUTO', 0);
417
+ define ('AI_FILTER_PHP_FUNCTION_CALLS', 1);
418
+ define ('AI_FILTER_CONTENT_PROCESSING', 2);
419
+ define ('AI_FILTER_EXCERPT_PROCESSING', 3);
420
+ define ('AI_FILTER_BEFORE_POST_PROCESSING', 4);
421
+ define ('AI_FILTER_AFTER_POST_PROCESSING', 5);
422
+ define ('AI_FILTER_WIDGET_DRAWING', 6);
423
+ define ('AI_FILTER_SUBPAGES', 7);
424
+ define ('AI_FILTER_POSTS', 8);
425
+ define ('AI_FILTER_PARAGRAPHS', 9);
426
+ define ('AI_FILTER_COMMENTS', 10);
427
+
428
+
429
+ define ('AI_TEXT_AUTO', 'Auto');
430
+ define ('AI_TEXT_PHP_FUNCTION_CALLS', 'PHP function calls');
431
+ define ('AI_TEXT_CONTENT_PROCESSING', 'Content processing');
432
+ define ('AI_TEXT_EXCERPT_PROCESSING', 'Excerpt processing');
433
+ define ('AI_TEXT_BEFORE_POST_PROCESSING', 'Before post processing');
434
+ define ('AI_TEXT_AFTER_POST_PROCESSING', 'After post processing');
435
+ define ('AI_TEXT_WIDGET_DRAWING', 'Widget drawing');
436
+ define ('AI_TEXT_SUBPAGES', 'Subpages');
437
+ define ('AI_TEXT_POSTS', 'Posts');
438
+ define ('AI_TEXT_PARAGRAPHS', 'Paragraphs');
439
+ define ('AI_TEXT_COMMENTS', 'Comments');
440
+
441
+
442
+
443
+ //Counter names
444
+ define ('AI_BLOCK_COUNTER_NAME', 'AI_BLOCK_COUNTER_');
445
+ define ('AI_PHP_FUNCTION_CALL_COUNTER_NAME', 'AI_PHP_FUNCTION_CALL_COUNTER_');
446
+ define ('AI_CONTENT_COUNTER_NAME', 'AI_CONTENT_COUNTER');
447
+ define ('AI_EXCERPT_COUNTER_NAME', 'AI_EXCERPT_COUNTER');
448
+ define ('AI_LOOP_BEFORE_COUNTER_NAME', 'AI_LOOP_START_COUNTER');
449
+ define ('AI_LOOP_AFTER_COUNTER_NAME', 'AI_LOOP_END_COUNTER');
450
+ define ('AI_WIDGET_COUNTER_NAME', 'AI_WIDGET_COUNTER_');
451
+ define ('AI_POST_COUNTER_NAME', 'AI_THE_POST_COUNTER');
452
+ define ('AI_COMMENT_COUNTER_NAME', 'AI_COMMENT_COUNTER');
453
+ define ('AI_ADB_FALLBACK_DEPTH_NAME', 'AI_ADB_FALLBACK_DEPTH');
454
+
455
+ //Text List Type
456
+ define('AD_CONTAIN','contain');
457
+ define('AD_DO_NOT_CONTAIN','do not contain');
458
+
459
+ //Avoid text action
460
+ define('AD_DO_NOT_INSERT','do not insert');
461
+ define('AD_TRY_TO_SHIFT_POSITION','try to shift position');
462
+
463
+ define('AD_ABOVE','above');
464
+ define('AD_BELOW','below');
465
+ define('AD_ABOVE_AND_THEN_BELOW','above and then below');
466
+ define('AD_BELOW_AND_THEN_ABOVE','below and then above');
467
+
468
+ // Scheduling
469
+ define('AI_SCHEDULING_OFF', 0);
470
+ define('AI_SCHEDULING_DELAY', 1);
471
+ define('AI_SCHEDULING_BETWEEN_DATES', 2);
472
+
473
+ define('AI_TEXT_OFF', 'Insert immediately');
474
+ define('AI_TEXT_DELAY_INSERTION', 'Delay insertion');
475
+ define('AI_TEXT_INSERT_BETWEEN_DATES', 'Insert between dates');
476
+
477
+ // Dynamic blocks
478
+ define('AI_DYNAMIC_BLOCKS_SERVER_SIDE', 0);
479
+ define('AI_DYNAMIC_BLOCKS_CLIENT_SIDE', 1);
480
+ define('AI_DYNAMIC_BLOCKS_SERVER_SIDE_W3TC', 2);
481
+
482
+ define('AI_TEXT_SERVER_SIDE', 'Server-side');
483
+ define('AI_TEXT_CLIENT_SIDE', 'Client-side');
484
+ define('AI_TEXT_SERVER_SIDE_W3TC', 'Server-side using W3 Total Cache');
485
+
486
+ // Paragraph counting functions
487
+ define('AI_STANDARD_PARAGRAPH_COUNTING_FUNCTIONS', 0);
488
+ define('AI_MULTIBYTE_PARAGRAPH_COUNTING_FUNCTIONS', 1);
489
+
490
+ define('AI_TEXT_STANDARD', 'Standard');
491
+ define('AI_TEXT_MULTIBYTE', 'Multibyte');
492
+
493
+ // Tracking
494
+ define('AI_TRACKING_DISABLED', 0);
495
+ define('AI_TRACKING_ENABLED', 1);
496
+
497
+ // Ad Blocking
498
+ define ('AI_ADB_ACTION_NONE', 0);
499
+ define ('AI_ADB_ACTION_MESSAGE', 1);
500
+ define ('AI_ADB_ACTION_REDIRECTION', 2);
501
+
502
+ define ('AI_TEXT_NONE', 'None');
503
+ define ('AI_TEXT_POPUP_MESSAGE', 'Popup Message');
504
+ define ('AI_TEXT_REDIRECTION', 'Redirection');
505
+
506
+ define ('AI_ADB_BLOCK_ACTION_DO_NOTHING', 0);
507
+ define ('AI_ADB_BLOCK_ACTION_REPLACE', 1);
508
+ define ('AI_ADB_BLOCK_ACTION_SHOW', 2);
509
+ define ('AI_ADB_BLOCK_ACTION_HIDE', 3);
510
+
511
+ define ('AI_TEXT_DO_NOTHING', 'Do nothnig');
512
+ define ('AI_TEXT_REPLACE', 'Replace');
513
+ define ('AI_TEXT_SHOW', 'Show');
514
+ define ('AI_TEXT_HIDE', 'Hide');
515
+
516
+ // Ad blocking detection
517
+ define ('AI_ADB_DETECTION_STANDARD', 0);
518
+ define ('AI_ADB_DETECTION_ADVANCED', 1);
519
+
520
+ // Output buffering
521
+ define ('AI_OUTPUT_BUFFERING_DISABLED', 0);
522
+ define ('AI_OUTPUT_BUFFERING_ENABLED', 1);
523
+
524
+ // Click detection
525
+ define ('AI_CLICK_DETECTION_STANDARD', 0);
526
+ define ('AI_CLICK_DETECTION_ADVANCED', 1);
527
+
528
+ define ('AI_TEXT_INTERNAL', 'Internal');
529
+ define ('AI_TEXT_ADVANCED', 'Advanced');
530
+ define ('AI_TEXT_ENABLED', 'Enabled');
531
+
532
+ // Sticky widget mode
533
+ define ('AI_STICKY_WIDGET_MODE_CSS', 0);
534
+ define ('AI_STICKY_WIDGET_MODE_JS', 1);
535
+
536
+ define ('AI_TEXT_CSS', 'CSS');
537
+ define ('AI_TEXT_JS', 'JavaScript ');
538
+
539
+ define ('AI_GEO_DB_WEBNET77', 0);
540
+ define ('AI_GEO_DB_MAXMIND', 1);
541
+
542
+ define ('AI_TEXT_WEBNET77', 'Webnet77');
543
+ define ('AI_TEXT_MAXMIND', 'MaxMind');
544
+
545
+ define ('AI_CLOSE_NONE', 0);
546
+ define ('AI_CLOSE_TOP_RIGHT', 1);
547
+ define ('AI_CLOSE_TOP_LEFT', 2);
548
+ define ('AI_CLOSE_BOTTOM_RIGHT', 3);
549
+ define ('AI_CLOSE_BOTTOM_LEFT', 4);
550
+
551
+ define ('AI_TEXT_TOP_RIGHT', 'Top right');
552
+ define ('AI_TEXT_TOP_LEFT', 'Top left');
553
+ define ('AI_TEXT_BOTTOM_RIGHT', 'Bottom right');
554
+ define ('AI_TEXT_BOTTOM_LEFT', 'Bottom left');
555
+
556
+ define ('AI_CLIENT_SIDE_ACTION_SHOW', 0);
557
+ define ('AI_CLIENT_SIDE_ACTION_INSERT', 1);
558
+
559
+ define ('AI_TEXT_INSERT', 'Insert');
560
+
561
+ define ('AI_HTML_INSERTION_CLIENT_SIDE', 0);
562
+ define ('AI_HTML_INSERTION_CLIENT_SIDE_DOM_READY', 1);
563
+ define ('AI_HTML_INSERTION_SEREVR_SIDE', 2);
564
+
565
+ define('AI_TEXT_CLIENT_SIDE_DOM_READY', 'Client-side when DOM ready');
566
+
567
+ //Settings
568
+ define ('AI_ENABLED', '1');
569
+ define ('AI_DISABLED', '0');
570
+
571
+ define ('AI_COOKIE_TIME', 3600);
572
+
573
+ define ('AI_TRANSIENT_RATING', 'ai-rating');
574
+ define ('AI_TRANSIENT_RATING_EXPIRATION', 48 * 3600);
575
+
576
+ define ('AI_TRANSIENT_ADSENSE_TOKEN', 'ai-adsense');
577
+
578
+ define ('AI_TRANSIENT_ADSENSE_ADS', 'ai-adsense-ads');
579
+ define ('AI_TRANSIENT_ADSENSE_ADS_EXPIRATION', 24 * 3600);
580
+
581
+ define ('AI_TRANSIENT_ADB_CLASS_1', 'ai-adb-class-1');
582
+ define ('AI_TRANSIENT_ADB_CLASS_2', 'ai-adb-class-2');
583
+ define ('AI_TRANSIENT_ADB_CLASS_3', 'ai-adb-class-3');
584
+ define ('AI_TRANSIENT_ADB_CLASS_4', 'ai-adb-class-4');
585
+ define ('AI_TRANSIENT_ADB_CLASS_5', 'ai-adb-class-5');
586
+ define ('AI_TRANSIENT_ADB_CLASS_6', 'ai-adb-class-6');
587
+ define ('AI_TRANSIENT_ADB_CLASS_EXPIRATION', 48 * 3600);
588
+
589
+ define ('AI_TRANSIENT_ADB_FILES_VERSION', 'ai-adb-version');
590
+
591
+ define ('AI_SYNTAX_HIGHLIGHTER_THEME', 'ad_inserter');
592
+ define ('DEFAULT_SYNTAX_HIGHLIGHTER_THEME', AI_SYNTAX_HIGHLIGHTER_THEME);
593
+ define ('DEFAULT_BLOCK_CLASS_NAME', 'code-block');
594
+ define ('DEFAULT_BLOCK_CLASS', AI_ENABLED);
595
+ define ('DEFAULT_BLOCK_NUMBER_CLASS', AI_ENABLED);
596
+ define ('DEFAULT_INLINE_STYLES', AI_ENABLED);
597
+ define ('DEFAULT_MINIMUM_USER_ROLE', 'administrator');
598
+ define ('DEFAULT_STICKY_WIDGET_MODE', AI_STICKY_WIDGET_MODE_CSS);
599
+ define ('DEFAULT_STICKY_WIDGET_MARGIN', 15);
600
+ define ('DEFAULT_PLUGIN_PRIORITY', 99999);
601
+ define ('DEFAULT_DYNAMIC_BLOCKS', AI_DYNAMIC_BLOCKS_SERVER_SIDE);
602
+ define ('DEFAULT_PARAGRAPH_COUNTING_FUNCTIONS', AI_STANDARD_PARAGRAPH_COUNTING_FUNCTIONS);
603
+ define ('DEFAULT_NO_PARAGRAPH_COUNTING_INSIDE', 'blockquote, figure, li');
604
+ define ('DEFAULT_AD_TITLE', 'Advertisements');
605
+ define ('DEFAULT_PARAGRAPH_TAGS', 'p');
606
+ define ('DEFAULT_ADMIN_TOOLBAR_DEBUGGING', AI_ENABLED);
607
+ define ('DEFAULT_REMOTE_DEBUGGING', AI_DISABLED);
608
+ define ('DEFAULT_BACKEND_JS_DEBUGGING', AI_DISABLED);
609
+ define ('DEFAULT_FRONTEND_JS_DEBUGGING', AI_DISABLED);
610
+ define ('DEFAULT_MULTISITE_SETTINGS_PAGE', AI_ENABLED);
611
+ define ('DEFAULT_MULTISITE_WIDGETS', AI_ENABLED);
612
+ define ('DEFAULT_MULTISITE_PHP_PROCESSING', AI_ENABLED);
613
+ define ('DEFAULT_MULTISITE_EXCEPTIONS', AI_ENABLED);
614
+ define ('DEFAULT_MULTISITE_MAIN_FOR_ALL_BLOGS', AI_DISABLED);
615
+ define ('DEFAULT_TRACKING', AI_TRACKING_DISABLED);
616
+ define ('DEFAULT_INTERNAL_TRACKING', AI_ENABLED);
617
+ define ('DEFAULT_EXTERNAL_TRACKING', AI_DISABLED);
618
+ define ('DEFAULT_TRACKING_LOGGED_IN', AI_TRACKING_ENABLED);
619
+ define ('DEFAULT_TRACK_PAGEVIEWS', AI_TRACKING_DISABLED);
620
+ define ('DEFAULT_CLICK_DETECTION', AI_CLICK_DETECTION_STANDARD);
621
+ define ('DEFAULT_ADB_BLOCK_ACTION', AI_ADB_BLOCK_ACTION_DO_NOTHING);
622
+ define ('DEFAULT_ADB_DETECTION', AI_ADB_DETECTION_ADVANCED);
623
+ define ('DEFAULT_CUSTOM_HOOK_PRIORITY', 10);
624
+ define ('DEFAULT_OUTPUT_BUFFERING', AI_OUTPUT_BUFFERING_DISABLED);
625
+ define ('DEFAULT_GEO_DB', AI_GEO_DB_WEBNET77);
626
+ define ('DEFAULT_GEO_DB_UPDATES', AI_DISABLED);
627
+ define ('DEFAULT_CLOSE_BUTTON', AI_CLOSE_NONE);
628
+ define ('DEFAULT_SERVER_SIDE_INSERTION', AI_AUTOMATIC_INSERTION_FOOTER);
629
+ define ('DEFAULT_HTML_ELEMENT_INSERTION', AI_HTML_INSERTION_CLIENT_SIDE_DOM_READY);
630
+ define ('DEFAULT_CLIENT_SIDE_ACTION', AI_CLIENT_SIDE_ACTION_SHOW);
631
+ define ('DEFAULT_HORIZONTAL_POSITION', AI_STICK_TO_THE_LEFT);
632
+ define ('DEFAULT_VERTICAL_POSITION', AI_STICK_TO_THE_TOP);
633
+ define ('DEFAULT_HORIZONTAL_MARGIN', '');
634
+ define ('DEFAULT_VERTICAL_MARGIN', '');
635
+ define ('DEFAULT_MAIN_CONTENT_ELEMENT', '');
636
+ define ('DEFAULT_ANIMATION', AI_ANIMATION_NONE);
637
+ define ('DEFAULT_ANIMATION_TRIGGER', AI_TRIGGER_PAGE_LOADED);
638
+ define ('DEFAULT_ANIMATION_TRIGGER_VALUE', '');
639
+ define ('DEFAULT_ANIMATION_TRIGGER_OFFSET', '');
640
+ define ('DEFAULT_ANIMATION_TRIGGER_DELAY', '');
641
+ define ('DEFAULT_ANIMATION_TRIGGER_ONCE', AI_DISABLED);
642
+
643
+
644
+ define ('AI_ADBLOCKING_DETECTION', true);
645
+ define ('AI_NORMAL_HEADER_STYLES', true);
646
+ define ('AI_AMP_HEADER_STYLES', true);
647
+ define ('AI_CODE_GENERATOR', true);
648
+ define ('AI_BUFFERING', true);
649
+ define ('AI_ADSENSE_API', true);
650
+ define ('AI_ADSENSE_OVERLAY', true);
651
+ define ('AI_STICKY_SETTINGS', true);
652
+ define ('AI_ADB_1_NAME', 'dqwpediwqswqma');
653
+ define ('AI_ADB_2_DEFAULT_NAME', 'lfoswyekaaslsd');
654
+ define ('AI_ADB_CONTENT_CSS_BEGIN', 'ai-adb-content-begin');
655
+ define ('AI_ADB_CONTENT_CSS_END', 'ai-adb-content-end');
656
+ define ('AI_ADB_CONTENT_DELETE_BEGIN', 'ai-adb-delete-begin');
657
+ define ('AI_ADB_CONTENT_DELETE_END', 'ai-adb-delete-end');
658
+ define ('AI_ADB_CONTENT_REPLACE_BEGIN', 'ai-adb-replace-begin');
659
+ define ('AI_ADB_CONTENT_REPLACE_END', 'ai-adb-replace-end');
660
+ define ('AI_BASIC_ADB_OVERLAY_CSS', "position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99998; user-select: none;");
661
+ define ('AI_DEFAULT_ADB_OVERLAY_CSS', "background: #000; opacity: 0.85;");
662
+ define ('AI_BASIC_ADB_MESSAGE_CSS', "position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 99999; background: #000; color: #fff; user-select: none;");
663
+ define ('AI_DEFAULT_ADB_MESSAGE_CSS', "width: 300px; padding: 10px; border: 5px solid #f00; border-radius: 5px;");
664
+ define ('AI_DEFAULT_ADB_MESSAGE', "<p><strong>Blocked because of Ad Blocker</strong></p>\n<p>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.</p>");
665
+ define ('AI_DEFAULT_ADB_ACTION', AI_ADB_ACTION_NONE);
666
+ define ('AI_DEFAULT_ADB_NO_ACTION_PERIOD', 30);
667
+ define ('AI_DEFAULT_ADB_REDIRECTION_PAGE', 0);
668
+ define ('AI_DEFAULT_ADB_UNDISMISSIBLE_MESSAGE', AI_DISABLED);
669
+ define ('AI_ADB_VERSION_MASK', 0x7F);
670
+ define ('AI_ADB_FLAG_BLOCKED', 0x80);
671
+
672
+ define ('DEFAULT_VIEWPORT_NAME_1', "Desktop");
673
+ define ('DEFAULT_VIEWPORT_NAME_2', "Tablet");
674
+ define ('DEFAULT_VIEWPORT_NAME_3', "Phone");
675
+
676
+ define ('DEFAULT_VIEWPORT_WIDTH_1', 980);
677
+ define ('DEFAULT_VIEWPORT_WIDTH_2', 768);
678
+ define ('DEFAULT_VIEWPORT_WIDTH_3', 0);
679
+
680
+ define ('DEFAULT_COUNTRY_GROUP_NAME', "Group");
681
+
682
+ define ('AI_MARKER_START', '%##');
683
+ define ('AI_MARKER_END', '##%');
684
+
685
+ define ('CONTENT_HOOK_BLOCKS', 'content_hook');
686
+ define ('EXCERPT_HOOK_BLOCKS', 'excerpt_hook');
687
+ define ('LOOP_START_HOOK_BLOCKS', 'loop_start_hook');
688
+ define ('LOOP_END_HOOK_BLOCKS', 'loop_end_hook');
689
+ define ('POST_HOOK_BLOCKS', 'the_post_hook');
690
+ define ('BEFORE_COMMENTS_HOOK_BLOCKS', 'before_comments_hook');
691
+ define ('BETWEEN_COMMENTS_HOOK_BLOCKS', 'between_comments_hook');
692
+ define ('AFTER_COMMENTS_HOOK_BLOCKS', 'after_comments_hook');
693
+ define ('FOOTER_HOOK_BLOCKS', 'wp_footer_hook');
694
+ define ('ABOVE_HEADER_HOOK_BLOCKS', 'above_header_hook');
695
+ define ('HTML_ELEMENT_HOOK_BLOCKS', 'html_element_hook');
696
+ define ('CUSTOM_HOOK_BLOCKS', '_hook');
697
+ define ('AI_EXTRACT_USED_BLOCKS', 'used_blocks');
698
+
699
+ define ('AI_CHECK_NONE', - 1);
700
+ define ('AI_CHECK_INSERTED', 0);
701
+
702
+ define ('AI_CHECK_PAGE_TYPE_FRONT_PAGE', 1);
703
+ define ('AI_CHECK_PAGE_TYPE_STATIC_PAGE', 2);
704
+ define ('AI_CHECK_PAGE_TYPE_POST', 3);
705
+ define ('AI_CHECK_PAGE_TYPE_CATEGORY', 4);
706
+ define ('AI_CHECK_PAGE_TYPE_SEARCH', 5);
707
+ define ('AI_CHECK_PAGE_TYPE_ARCHIVE', 6);
708
+ define ('AI_CHECK_PAGE_TYPE_FEED', 7);
709
+ define ('AI_CHECK_PAGE_TYPE_404', 8);
710
+
711
+ define ('AI_CHECK_DESKTOP_DEVICES', 9);
712
+ define ('AI_CHECK_MOBILE_DEVICES', 10);
713
+ define ('AI_CHECK_TABLET_DEVICES', 11);
714
+ define ('AI_CHECK_PHONE_DEVICES', 12);
715
+ define ('AI_CHECK_DESKTOP_TABLET_DEVICES',13);
716
+ define ('AI_CHECK_DESKTOP_PHONE_DEVICES', 14);
717
+
718
+ define ('AI_CHECK_CATEGORY', 15);
719
+ define ('AI_CHECK_TAG', 16);
720
+ define ('AI_CHECK_URL', 17);
721
+ define ('AI_CHECK_REFERER', 18);
722
+ define ('AI_CHECK_SCHEDULING', 19);
723
+ define ('AI_CHECK_CODE', 20);
724
+ define ('AI_CHECK_LOGGED_IN_USER', 21);
725
+ define ('AI_CHECK_NOT_LOGGED_IN_USER', 22);
726
+ define ('AI_CHECK_ADMINISTRATOR', 23);
727
+
728
+ define ('AI_CHECK_INDIVIDUALLY_DISABLED', 24);
729
+ define ('AI_CHECK_INDIVIDUALLY_ENABLED', 25);
730
+ define ('AI_CHECK_DISABLED_MANUALLY', 26);
731
+ define ('AI_CHECK_MAX_INSERTIONS', 27);
732
+ define ('AI_CHECK_FILTER', 28);
733
+ define ('AI_CHECK_PARAGRAPH_COUNTING', 29);
734
+ define ('AI_CHECK_ENABLED_PHP', 30);
735
+ define ('AI_CHECK_ENABLED_SHORTCODE', 31);
736
+ define ('AI_CHECK_PARAGRAPHS_MIN_NUMBER', 32);
737
+
738
+ define ('AI_CHECK_DEBUG_NO_INSERTION', 33);
739
+ define ('AI_CHECK_PARAGRAPH_TAGS', 34);
740
+ define ('AI_CHECK_PARAGRAPHS_WITH_TAGS', 35);
741
+ define ('AI_CHECK_PARAGRAPHS_AFTER_NO_COUNTING_INSIDE', 36);
742
+ define ('AI_CHECK_PARAGRAPHS_AFTER_MIN_MAX_WORDS', 37);
743
+ define ('AI_CHECK_PARAGRAPHS_AFTER_TEXT', 38);
744
+ define ('AI_CHECK_PARAGRAPHS_AFTER_CLEARANCE', 39);
745
+ define ('AI_CHECK_ID', 40);
746
+ define ('AI_CHECK_URL_PARAMETER', 41);
747
+ define ('AI_CHECK_DO_NOT_INSERT', 42);
748
+ define ('AI_CHECK_AD_ABOVE', 43);
749
+ define ('AI_CHECK_AD_BELOW', 44);
750
+ define ('AI_CHECK_SHORTCODE_ATTRIBUTES', 45);
751
+ define ('AI_CHECK_COUNTRY', 46);
752
+ define ('AI_CHECK_IP_ADDRESS', 47);
753
+ define ('AI_CHECK_PARAGRAPH_NUMBER', 48);
754
+ define ('AI_CHECK_MIN_NUMBER_OF_WORDS', 49);
755
+ define ('AI_CHECK_MAX_NUMBER_OF_WORDS', 50);
756
+ define ('AI_CHECK_TAXONOMY', 51);
757
+ define ('AI_CHECK_ENABLED_WIDGET', 52);
758
+
759
+ define ('AI_PT_NONE', - 1);
760
+ define ('AI_PT_ANY', 0);
761
+ define ('AI_PT_STATIC', 1);
762
+ define ('AI_PT_POST', 2);
763
+ define ('AI_PT_HOMEPAGE', 3);
764
+ define ('AI_PT_CATEGORY', 4);
765
+ define ('AI_PT_ARCHIVE', 5);
766
+ define ('AI_PT_SEARCH', 6);
767
+ define ('AI_PT_404', 7);
768
+ define ('AI_PT_FEED', 8);
769
+ define ('AI_PT_ADMIN', 9);
770
+ define ('AI_PT_AJAX', 10);
771
+
772
+ define ('AI_USER_NOT_LOGGED_IN', 0);
773
+ define ('AI_USER_LOGGED_IN', 1);
774
+ define ('AI_USER_ADMINISTRATOR', 2);
775
+
776
+ define ('AI_WP_DEBUGGING', 0); // AI_WP_DEBUGGING_
777
+ define ('AI_WP_PAGE_TYPE', 1);
778
+ define ('AI_WP_USER_SET', 2);
779
+ define ('AI_WP_USER', 3);
780
+ define ('AI_WP_DEBUG_BLOCK', 4);
781
+ define ('AI_WP_URL', 5);
782
+ define ('AI_SERVER_SIDE_DETECTION', 6);
783
+ define ('AI_CLIENT_SIDE_DETECTION', 7);
784
+ define ('AI_CONTEXT', 8);
785
+ define ('AI_TRACKING', 9);
786
+ define ('AI_STICKY_WIDGETS', 10);
787
+ define ('AI_NUMBER_OF_COMMENTS', 11);
788
+ define ('AI_COMMENTS_SAVED_CALLBACK', 12);
789
+ define ('AI_COMMENTS_SAVED_END_CALLBACK',13);
790
+ define ('AI_ADB_DETECTION', 14);
791
+ define ('AI_BACKEND_JS_DEBUGGING', 15);
792
+ define ('AI_FRONTEND_JS_DEBUGGING', 16);
793
+ define ('AI_WP_AMP_PAGE', 17);
794
+ define ('AI_INSTALL_TIME_DIFFERENCE', 18);
795
+ define ('AI_DAYS_SINCE_INSTAL', 19);
796
+ define ('AI_TAGS', 20);
797
+ define ('AI_VIEWPORTS', 21);
798
+ define ('AI_WORD_COUNT', 22);
799
+ define ('AI_ADB_SHORTCODE_ACTION', 23);
800
+ define ('AI_SHORTCODES', 24);
801
+ define ('AI_VIEWPORT_NAMES', 25);
802
+ define ('AI_CLOSE_BUTTONS', 26);
803
+ define ('AI_DISABLE_CACHING', 27);
804
+ define ('AI_COUNT', 28);
805
+ define ('AI_CLIENT_SIDE_INSERTION', 29);
806
+ define ('AI_USER_AGENT', 30);
807
+ define ('AI_STICK_TO_THE_CONTENT', 31);
808
+ define ('AI_DEBUG_MENU_ITEMS', 32);
809
+ define ('AI_ANIMATION', 33);
810
+ define ('AI_TRIGGER_ELEMENTS', 34);
811
+
812
+ define ('AI_CONTEXT_NONE', 0);
813
+ define ('AI_CONTEXT_CONTENT', 1);
814
+ define ('AI_CONTEXT_EXCERPT', 2);
815
+ define ('AI_CONTEXT_BEFORE_POST', 3);
816
+ define ('AI_CONTEXT_AFTER_POST', 4);
817
+ define ('AI_CONTEXT_WIDGET', 5);
818
+ define ('AI_CONTEXT_PHP_FUNCTION', 6);
819
+ define ('AI_CONTEXT_SHORTCODE', 7);
820
+ define ('AI_CONTEXT_HTTP_HEADER', 8);
821
+ define ('AI_CONTEXT_HEADER', 9);
822
+ define ('AI_CONTEXT_FOOTER', 10);
823
+ define ('AI_CONTEXT_BETWEEN_POSTS', 11);
824
+ define ('AI_CONTEXT_BEFORE_COMMENTS', 12);
825
+ define ('AI_CONTEXT_BETWEEN_COMMENTS', 13);
826
+ define ('AI_CONTEXT_AFTER_COMMENTS', 14);
827
+
828
+ define ('AI_URL_DEBUG', 'ai-debug'); // AI_URL_DEBUG_
829
+ define ('AI_URL_DEBUG_PROCESSING', 'ai-debug-processing'); // AI_URL_DEBUG_PROCESSING_
830
+ define ('AI_URL_DEBUG_PHP', 'ai-debug-php'); // AI_URL_DEBUG_PHP
831
+ define ('AI_URL_DEBUG_BLOCKS', 'ai-debug-blocks');
832
+ define ('AI_URL_DEBUG_USER', 'ai-debug-user');
833
+ define ('AI_URL_DEBUG_TAGS', 'ai-debug-tags');
834
+ define ('AI_URL_DEBUG_POSITIONS', 'ai-debug-positions');
835
+ define ('AI_URL_DEBUG_NO_INSERTION', 'ai-debug-no-insertion');
836
+ define ('AI_URL_DEBUG_COUNTRY', 'ai-debug-country');
837
+ define ('AI_URL_DEBUG_AD_BLOCKING' , 'ai-debug-adb');
838
+ define ('AI_URL_DEBUG_AD_BLOCKING_STATUS', 'ai-debug-adb-status');
839
+ define ('AI_URL_DEBUG_JAVASCRIPT', 'ai-debug-js');
840
+
841
+ define ('AI_DEBUG_PROCESSING', 0x01); // AI_DEBUG_PROCESSING_
842
+ define ('AI_DEBUG_BLOCKS', 0x02);
843
+ define ('AI_DEBUG_TAGS', 0x04);
844
+ define ('AI_DEBUG_POSITIONS', 0x08);
845
+ define ('AI_DEBUG_NO_INSERTION', 0x10);
846
+ define ('AI_DEBUG_AD_BLOCKING', 0x20);
847
+ define ('AI_DEBUG_AD_BLOCKING_STATUS', 0x40);
848
+
849
+ if (!defined ('AD_INSERTER_BLOCKS'))
850
+ define ('AD_INSERTER_BLOCKS', 16);
851
+
852
+ if (!defined ('AD_INSERTER_VIEWPORTS'))
853
+ define ('AD_INSERTER_VIEWPORTS', 3);
854
+
855
+ if (!defined ('AD_INSERTER_HOOKS'))
856
+ define ('AD_INSERTER_HOOKS', 2);
857
+
858
+ define ('AI_DEBUG_WIDGET_STYLE', 'margin: 0; padding: 0 5px; font-size: 10px; white-space: pre; overflow-x: auto; overflow-y: hidden;');
859
+
860
+ define ('AI_DEBUG_TAGS_CLASS', 'ai-debug-tags');
861
+ define ('AI_DEBUG_POSITIONS_CLASS', 'ai-debug-positions');
862
+ define ('AI_DEBUG_PAGE_TYPE_CLASS', 'ai-debug-page-type');
863
+ define ('AI_DEBUG_STATUS_CLASS', 'ai-debug-status');
864
+ define ('AI_DEBUG_ADB_CLASS', 'ai-debug-adb');
865
+ define ('AI_ADSENSE_BLOCK_CLASS', 'ai-adsense-');
866
+
867
+ define ('AI_CODE_UNKNOWN', 100);
868
+ define ('AI_CODE_BANNER', 0);
869
+ define ('AI_CODE_ADSENSE', 1);
870
+
871
+ define ('AI_ADSENSE_STANDARD', 0);
872
+ define ('AI_ADSENSE_LINK', 1);
873
+ define ('AI_ADSENSE_IN_ARTICLE', 2);
874
+ define ('AI_ADSENSE_IN_FEED', 3);
875
+ define ('AI_ADSENSE_MATCHED_CONTENT', 4);
876
+ define ('AI_ADSENSE_AUTO', 5);
877
+
878
+ define ('AI_ADSENSE_AMP_DISABLED', 0);
879
+ define ('AI_ADSENSE_AMP_ABOVE_THE_FOLD', 1);
880
+ define ('AI_ADSENSE_AMP_BELOW_THE_FOLD', 2);
881
+
882
+ define ('AI_ADSENSE_SIZE_FIXED', 0);
883
+ define ('AI_ADSENSE_SIZE_RESPONSIVE', 1);
884
+ define ('AI_ADSENSE_SIZE_FIXED_BY_VIEWPORT', 2);
885
+
886
+ define ('AI_TEXT_LINK', 'Link');
887
+ define ('AI_TEXT_IN_ARTICLE', 'In-article');
888
+ define ('AI_TEXT_IN_FEED', 'In-feed');
889
+ define ('AI_TEXT_MATCHED_CONTENT', 'Matched content');
890
+
891
+ define ('AI_TEXT_ABOVE_THE_FOLD', 'Above the fold');
892
+ define ('AI_TEXT_BELOW_THE_FOLD', 'Below the fold');
893
+
894
+ define ('AI_TEXT_FIXED', 'Fixed');
895
+ define ('AI_TEXT_RESPONSIVE', 'Responsive');
896
+ define ('AI_TEXT_FIXED_BY_VIEWPORT', 'Fixed by viewport');
css/ad-inserter.css CHANGED
@@ -1,1216 +1,1216 @@
1
- #ai-data {
2
- font-family: "2.3.7"; /* Used for version number of the file */
3
- }
4
-
5
- #blocked-warning {
6
- display: none;
7
- }
8
-
9
- .ui-widget, .ai-form td {
10
- font-family: sans-serif,Arial,Verdana;
11
- font-size: 12px!important;
12
- }
13
-
14
- .ai-form .ui-widget {
15
- position: relative;
16
- }
17
-
18
- .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
19
- font-family: sans-serif,Arial,Verdana;
20
- font-size: 12px;
21
- }
22
-
23
- .ui-widget-header {
24
- border: 1px solid #aaa !important;
25
- background: #ccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x !important;
26
- }
27
-
28
- .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active {
29
- background: #fff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x!important !important;
30
- }
31
-
32
- /*.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active, a.ui-button:active, .ui-button:active, .ui-button.ui-state-active:hover {*/
33
- /* border: 1px solid #d3d3d3;*/
34
- /* background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;*/
35
- /* color: #555;*/
36
- /*}*/
37
-
38
- .ui-state-highlight {
39
- background: #ff4;
40
- }
41
-
42
- button.ai-top-button {
43
- min-width: 52px;
44
- }
45
-
46
- .ai-top-button.ui-button-text-only .ui-button-text {
47
- padding: .4em 0.6em;
48
- }
49
-
50
- .adsense-list .ui-button-text, .select-image .ui-button-text {
51
- padding: 0.4em 0.5em;
52
- }
53
-
54
- .ace_editor {
55
- border: 1px solid #ddd;
56
- border-radius: 4px;
57
- }
58
-
59
- .ai-icon-gear {
60
- width: 16px;
61
- height: 16px;
62
- background: url('images/icons.png') 0 -40px;
63
- background-repeat: no-repeat;
64
- }
65
-
66
- .ai-icon-gear.on {
67
- background: url('images/icons.png') -20px -40px;
68
- }
69
-
70
- .ai-icon-gear.red {
71
- background: url('images/icons.png') -60px -40px;
72
- }
73
-
74
- a.simple-link {
75
- text-decoration: none;
76
- box-shadow: 0 0 0;
77
- }
78
-
79
- a.clear-link, a.clear-link:hover, a.clear-link:focus {
80
- color: transparent;
81
- text-decoration: none;
82
- box-shadow: 0 0 0;
83
- }
84
-
85
- .rounded {
86
- border-radius: 5px;
87
- }
88
-
89
- .ai-form.rounded input, .ai-form.rounded select {
90
- border-radius: 5px;
91
- }
92
-
93
- #ai-form div.rounded, #ai-sidebar div.rounded {
94
- margin: 8px 0;
95
- padding: 8px;
96
- border: 1px solid rgb(221, 221, 221);
97
- border-radius: 5px;
98
- }
99
-
100
- .ai-settings-table {
101
- border-spacing: 4px;
102
- }
103
-
104
- .ai-settings-table.left {
105
- float: left;
106
- width: 52%
107
- }
108
-
109
- .ai-settings-table.right {
110
- float: right;
111
- width: 48%
112
- }
113
-
114
- .ai-settings-table.ai-values td:first-child {
115
- width: 35%;
116
- }
117
-
118
- .ai-settings-table.fixed {
119
- table-layout: fixed;
120
- }
121
-
122
- /*#editor-1 {*/
123
- /* font-family: Courier, 'Courier New', monospace, tahoma;*/
124
- /* font-family: tahoma;*/
125
- /* font-size: 10px";*/
126
- /*}*/
127
-
128
- .nav-tab {
129
- border-top-left-radius: 5px;
130
- border-top-right-radius: 5px;
131
- }
132
- .nav-tab-active, .nav-tab-active:hover {
133
- background: #fff;
134
- }
135
-
136
- .exceptions a {
137
- text-decoration: none;
138
- }
139
- .exceptions th.page {
140
- text-align: left;
141
- }
142
- .exceptions tr.even {
143
- background: #f0f0f0;
144
- }
145
- .exceptions td.page {
146
- padding-right: 20px;
147
- }
148
- .exceptions th.id, .exceptions td.id {
149
- padding-right: 10px;
150
- text-align: right;
151
- }
152
- .exceptions th.type, .exceptions td.type {
153
- padding-right: 10px;
154
- text-align: left;
155
- }
156
- .exceptions th.page, .exceptions td.page {
157
- width: 90%;
158
- overflow: hidden;
159
- max-width: 240px;
160
- }
161
- .exceptions th.page-only, .exceptions td.page-only {
162
- width: 100%;
163
- }
164
- .exceptions th.block, .exceptions td.block {
165
- text-align: center;
166
- min-width: 22px;
167
- cursor: pointer;
168
- }
169
- .exceptions td.button-delete {
170
- cursor: pointer;
171
- }
172
- .small-button .ui-button-text-only .ui-button-text {
173
- padding: 0px;
174
- }
175
- .responsive-table td {
176
- white-space: nowrap;
177
- padding: 0;
178
- }
179
-
180
- .no-select {
181
- -webkit-user-select: none; /* Chrome all / Safari all */
182
- -moz-user-select: none; /* Firefox all */
183
- -ms-user-select: none; /* IE 10+ */
184
- user-select: none;
185
- }
186
- .select {
187
- -webkit-user-select: text;
188
- -moz-user-select: text;
189
- -ms-user-select: text;
190
- user-select: text;
191
- }
192
- .copy-blocker {
193
- position: absolute;
194
- user-select: text;
195
- height: 100%;
196
- }
197
-
198
- .ui-dialog {
199
- z-index: 10000 !important;
200
- }
201
- .ui-dialog .ui-dialog-titlebar-close {
202
- outline-color: transparent;
203
- }
204
- .no-title .ui-dialog-titlebar {
205
- display:none
206
- }
207
-
208
- .ai-form {
209
- width: 735px;
210
- }
211
-
212
- .ui-datepicker {
213
- z-index: 202!important;
214
- }
215
-
216
- div.ai-chart-container {
217
- position: relative;
218
- margin: 8px 0;
219
- }
220
-
221
- div.ai-chart-container.versions {
222
- display: inline-block;
223
- margin: 20px 20px 0;
224
- }
225
-
226
- div.ai-chart {
227
- width: 735px;
228
- height: 140px;
229
- }
230
-
231
- div.versions div.ai-chart {
232
- width: 200px;
233
- height: 140px;
234
- }
235
-
236
- div.legend div.ai-chart {
237
- height: 25px;
238
- }
239
-
240
- div.ai-chart-label {
241
- position: absolute;
242
- top: 13px;
243
- left: 44px;
244
- z-index: 202;
245
- opacity: 0.5;
246
- display: none;
247
- }
248
-
249
- div.ai-chart-container.versions div.ai-chart-label {
250
- z-index: 1;
251
- }
252
-
253
- div.versions div.ai-chart-label {
254
- top: -16px;
255
- left: 80px;
256
- }
257
-
258
- .legend div.ai-chart-label {
259
- top: 34px;
260
- }
261
-
262
- div.ai-tooltip {
263
- z-index: 203;
264
- }
265
-
266
- div.ai-tooltip .version {
267
- font-weight: bold;
268
- }
269
-
270
- #ai-settings {
271
- margin-right: 24px;
272
- }
273
-
274
- .ui-tabs .ui-tabs-nav li {
275
- margin: 1px 0.17em 0 0;
276
- }
277
-
278
- #ai-tabs a {
279
- width: 14px;
280
- text-align: center;
281
- font-size: 12px;
282
- }
283
- #ai-tabs {
284
- padding: .2em 0 0 .6em;
285
- }
286
-
287
- #ai-scroll-tabs {
288
- height: 42px;
289
- }
290
-
291
- #ai-plugin-settings-tabs li a {
292
- padding: .5em 0.4em;
293
- font-size: 12px;
294
- }
295
-
296
- #header-buttons {
297
- min-height: 26px;
298
- margin: 2px 0;
299
- float: right;
300
- }
301
-
302
- .max-input {
303
- display: table;
304
- width: 100%;
305
- }
306
-
307
- .simple-editor {
308
- width: 733px;
309
- min-width: 370px;
310
- height: 386px;
311
- }
312
-
313
- textarea.simple-editor {
314
- height: 388px;
315
- }
316
-
317
- .simple-editor.small {
318
- height: 190px;
319
- }
320
-
321
- textarea.simple-editor.small {
322
- height: 192px;
323
- }
324
-
325
- .ms-container {
326
- width: 100%;
327
- font-size: 12px;
328
- }
329
-
330
- .ms-container .ms-selectable, .ms-container .ms-selection {
331
- width: 47%;
332
- }
333
-
334
- .ms-container .ms-selectable li.ms-elem-selectable, .ms-container .ms-selection li.ms-elem-selection {
335
- padding: 1px 10px;
336
- font-size: 12px;
337
- }
338
-
339
- .ms-container dd, .ms-container li {
340
- /*.ms-container dd, li {*/
341
- margin-bottom: 4px;
342
- }
343
-
344
- .feature-list li, .ai-help li {
345
- margin-bottom: 2px;
346
- }
347
-
348
- .ms-container .search-input {
349
- width: 100%;
350
- border-radius: 4px;
351
- }
352
-
353
- .ms-container div.ms-selection {
354
- margin-top: 24px;
355
- }
356
-
357
- div.custom-range-controls {
358
- width: 696px;
359
- }
360
-
361
- input.ai-date-input {
362
- width: 85px;
363
- }
364
-
365
- .country-flags .ms-container .ms-selectable li.ms-elem-selectable, .country-flags .ms-container .ms-selection li.ms-elem-selection {
366
- padding-left: 30px;
367
- }
368
-
369
- .flag-icon {
370
- display: list-item;
371
- width: auto;
372
- line-height: inherit;
373
- }
374
- .flag-icon, .flag-icon-background {
375
- background-position: initial;
376
- }
377
-
378
- div.automatic-insertion {
379
- width: 56px;
380
- height: 56px;
381
- }
382
-
383
- ul.thumbnails.image_picker_selector li {
384
- margin: 0px 5px 4px 0px;
385
- cursor: pointer;
386
- }
387
-
388
- ul.thumbnails.image_picker_selector li .thumbnail {
389
- padding: 4px;
390
- }
391
-
392
- ul.thumbnails.image_picker_selector li .thumbnail.selected {
393
- background: #666;
394
- }
395
- li.automatic-insertion p {
396
- width: 57px;
397
- font-size: inherit;
398
- margin: 4px 0;
399
- }
400
-
401
- div.automatic-insertion img {
402
- width: 56px;
403
- height: 56px;
404
- }
405
-
406
- .ai-toolbar-button {
407
- display: table-cell;
408
- vertical-align: top;
409
- width: 28px;
410
- padding: 0 0 0 10px;
411
- }
412
-
413
- .ai-list-button {
414
- display: table-cell;
415
- margin-right: 2px;
416
- width: 20px;
417
- }
418
-
419
- .ai-toolbar-button.text {
420
- width: auto;
421
- }
422
-
423
- .ai-toolbar-button.small {
424
- width: 20px;
425
- }
426
-
427
- .ai-toolbar-button.ai-button-left {
428
- padding: 0 10px 0 0;
429
- }
430
-
431
- .checkbox-button {
432
- background-image: none, linear-gradient(to bottom, #f6f6f6 0, #eaeaea 100%);
433
- background-position: 50% 50%;
434
- background-color: #e3e3e3;
435
- border: solid 1px lightgrey;
436
- border-radius: 4px;
437
- -webkit-border-radius: 4px;
438
- -moz-border-radius: 4px;
439
- cursor: pointer;
440
- padding: 2px 2px;
441
- display: inline-block;
442
- margin: 0;
443
- font-family: inherit;
444
- line-height: 1.66em;
445
- text-align: center;
446
- cursor: pointer;
447
- text-decoration: none;
448
- -webkit-box-sizing: border-box;
449
- -moz-box-sizing: border-box;
450
- box-sizing: border-box;
451
- }
452
-
453
- .custom-range-controls .checkbox-button {
454
- border-radius: 3px;
455
- -webkit-border-radius: 3px;
456
- -moz-border-radius: 3px;
457
- }
458
-
459
- .ai-list-button .checkbox-button {
460
- border-radius: 3px;
461
- -webkit-border-radius: 3px;
462
- -moz-border-radius: 3px;
463
- }
464
-
465
- .text .checkbox-button {
466
- font-size: 11px;
467
- padding: 0px 5px 0px 4px;
468
- margin-top: 2px;
469
- }
470
-
471
- .ai-bw {
472
- filter: grayscale(100%);
473
- }
474
-
475
- .checkbox-icon {
476
- background-position: center;
477
- display: inline-block;
478
- float: left;
479
- width: 20px;
480
- height: 20px;
481
- overflow: hidden;
482
- background-repeat: no-repeat;
483
- font-size: 0;
484
- line-height: 0;
485
- text-indent: -3333px;
486
- text-align: center;
487
- vertical-align: middle;
488
- }
489
-
490
- .checkbox-icon.size-16 {
491
- width: 16px;
492
- height: 16px;
493
- }
494
-
495
- .checkbox-icon.size-img16 {
496
- width: 16px;
497
- height:16px;
498
- background-size: 16px 16px;
499
- }
500
-
501
- .checkbox-icon.size-16w {
502
- width: 17px;
503
- height: 16px;
504
- }
505
-
506
- .checkbox-icon.size-12 {
507
- width: 12px;
508
- height: 12px;
509
- margin: 3px 0;
510
- }
511
-
512
- .checkbox-icon.size-8 {
513
- width: 8px;
514
- height: 8px;
515
- }
516
-
517
- .checkbox-icon.icon-none {
518
- width: 10px;
519
- height: 12px;
520
- margin-top: 6px;
521
- }
522
-
523
- .list-button.lb-size-16 {
524
- width: 16px;
525
- height: 16px;
526
- }
527
-
528
- .list-button {
529
- margin: 0;
530
- background-image: url(images/ui-icons_888888_256x240.png)
531
- }
532
-
533
- img.automatic-insertion.im-disabled {
534
- background: url('images/insertions-alignmets.png') 0 0;
535
- }
536
-
537
- img.automatic-insertion.im-before-post {
538
- background: url('images/insertions-alignmets.png') -56px 0;
539
- }
540
-
541
- img.automatic-insertion.im-after-post {
542
- background: url('images/insertions-alignmets.png') -112px 0;
543
- }
544
-
545
- img.automatic-insertion.im-before-content {
546
- background: url('images/insertions-alignmets.png') -168px 0;
547
- }
548
-
549
- img.automatic-insertion.im-after-content {
550
- background: url('images/insertions-alignmets.png') -224px 0;
551
- }
552
-
553
- img.automatic-insertion.im-before-paragraph {
554
- background: url('images/insertions-alignmets.png') -280px 0;
555
- }
556
-
557
- img.automatic-insertion.im-after-paragraph {
558
- background: url('images/insertions-alignmets.png') -336px 0;
559
- }
560
-
561
- img.automatic-insertion.im-before-excerpts {
562
- background: url('images/insertions-alignmets.png') -392px 0;
563
- }
564
-
565
- img.automatic-insertion.im-after-excerpts {
566
- background: url('images/insertions-alignmets.png') 0 -56px;
567
- }
568
-
569
- img.automatic-insertion.im-between-posts {
570
- background: url('images/insertions-alignmets.png') -56px -56px;
571
- }
572
-
573
- img.automatic-insertion.im-before-comments {
574
- background: url('images/insertions-alignmets.png') -112px -56px;
575
- }
576
-
577
- img.automatic-insertion.im-between-comments {
578
- background: url('images/insertions-alignmets.png') -168px -56px;
579
- }
580
-
581
- img.automatic-insertion.im-after-comments {
582
- background: url('images/insertions-alignmets.png') -224px -56px;
583
- }
584
-
585
- img.automatic-insertion.im-footer {
586
- background: url('images/insertions-alignmets.png') -280px -56px;
587
- }
588
-
589
- img.automatic-insertion.im-custom-hook {
590
- background: url('images/insertions-alignmets.png') -336px -56px;
591
- }
592
-
593
- img.automatic-insertion.im-no-wrapping {
594
- background: url('images/insertions-alignmets.png') -392px -56px;
595
- }
596
-
597
- img.automatic-insertion.im-custom-css {
598
- background: url('images/insertions-alignmets.png') 0 -112px;
599
- }
600
-
601
- img.automatic-insertion.im-default {
602
- background: url('images/insertions-alignmets.png') -56px -112px;
603
- }
604
-
605
- img.automatic-insertion.im-align-left {
606
- background: url('images/insertions-alignmets.png') -112px -112px;
607
- }
608
-
609
- img.automatic-insertion.im-center {
610
- background: url('images/insertions-alignmets.png') -168px -112px;
611
- }
612
-
613
- img.automatic-insertion.im-align-right {
614
- background: url('images/insertions-alignmets.png') -224px -112px;
615
- }
616
-
617
- img.automatic-insertion.im-float-left {
618
- background: url('images/insertions-alignmets.png') -280px -112px;
619
- }
620
-
621
- img.automatic-insertion.im-float-right {
622
- background: url('images/insertions-alignmets.png') -336px -112px;
623
- }
624
-
625
- img.automatic-insertion.im-sticky-left {
626
- background: url('images/insertions-alignmets.png') -392px -112px;
627
- }
628
-
629
- img.automatic-insertion.im-sticky-right {
630
- background: url('images/insertions-alignmets.png') 0 -168px;
631
- }
632
-
633
- img.automatic-insertion.im-sticky-top {
634
- background: url('images/insertions-alignmets.png') -56px -168px;
635
- }
636
-
637
- img.automatic-insertion.im-sticky-bottom {
638
- background: url('images/insertions-alignmets.png') -112px -168px;
639
- }
640
-
641
- img.automatic-insertion.im-above-header {
642
- background: url('images/insertions-alignmets.png') -168px -168px;
643
- }
644
-
645
- img.automatic-insertion.im-before-html {
646
- background: url('images/insertions-alignmets.png') -224px -168px;
647
- }
648
-
649
- img.automatic-insertion.im-after-html {
650
- background: url('images/insertions-alignmets.png') -280px -168px;
651
- }
652
-
653
- img.automatic-insertion.im-sticky-content-left {
654
- background: url('images/insertions-alignmets.png') -336px -168px;
655
- }
656
-
657
- img.automatic-insertion.im-sticky-content-right {
658
- background: url('images/insertions-alignmets.png') -392px -168px;
659
- }
660
-
661
- img.automatic-insertion.im-sticky-center-horizontal {
662
- background: url('images/insertions-alignmets.png') 0 -224px;
663
- }
664
-
665
- img.automatic-insertion.im-sticky-center-vertical {
666
- background: url('images/insertions-alignmets.png') -56px -224px;
667
- }
668
-
669
- img.automatic-insertion.im-sticky-scroll {
670
- background: url('images/insertions-alignmets.png') -112px -224px;
671
- }
672
-
673
- img.automatic-insertion.im-sticky {
674
- background: url('images/insertions-alignmets.png') -168px -224px;
675
- }
676
-
677
- img.automatic-insertion.im-close-top-left {
678
- background: url('images/insertions-alignmets.png') -224px -224px;
679
- }
680
-
681
- img.automatic-insertion.im-close-top-right {
682
- background: url('images/insertions-alignmets.png') -280px -224px;
683
- }
684
-
685
- img.automatic-insertion.im-close-bottom-right {
686
- background: url('images/insertions-alignmets.png') -336px -224px;
687
- }
688
-
689
- img.automatic-insertion.im-close-bottom-left {
690
- background: url('images/insertions-alignmets.png') -392px -224px;
691
- }
692
-
693
- img.automatic-insertion.im-close-none {
694
- background: url('images/insertions-alignmets.png') -0px -280px;
695
- }
696
-
697
-
698
- img.automatic-insertion {
699
- background-size: 448px!important;
700
- }
701
-
702
-
703
- img.automatic-insertion.preview.im-no-wrapping {
704
- background: url('images/insertions-alignmets.png') -350px -50px;
705
- }
706
-
707
- img.automatic-insertion.preview.im-custom-css {
708
- background: url('images/insertions-alignmets.png') 0 -100px;
709
- }
710
-
711
- img.automatic-insertion.preview.im-default {
712
- background: url('images/insertions-alignmets.png') -50px -100px;
713
- }
714
-
715
- img.automatic-insertion.preview.im-align-left {
716
- background: url('images/insertions-alignmets.png') -100px -100px;
717
- }
718
-
719
- img.automatic-insertion.preview.im-center {
720
- background: url('images/insertions-alignmets.png') -150px -100px;
721
- }
722
-
723
- img.automatic-insertion.preview.im-align-right {
724
- background: url('images/insertions-alignmets.png') -200px -100px;
725
- }
726
-
727
- img.automatic-insertion.preview.im-float-left {
728
- background: url('images/insertions-alignmets.png') -250px -100px;
729
- }
730
-
731
- img.automatic-insertion.preview.im-float-right {
732
- background: url('images/insertions-alignmets.png') -300px -100px;
733
- }
734
-
735
- img.automatic-insertion.preview.im-sticky-left {
736
- background: url('images/insertions-alignmets.png') -350px -100px;
737
- }
738
-
739
- img.automatic-insertion.preview.im-sticky-right {
740
- background: url('images/insertions-alignmets.png') 0 -150px;
741
- }
742
-
743
- img.automatic-insertion.preview.im-sticky-top {
744
- background: url('images/insertions-alignmets.png') -50px -150px;
745
- }
746
-
747
- img.automatic-insertion.preview.im-sticky-bottom {
748
- background: url('images/insertions-alignmets.png') -100px -150px;
749
- }
750
-
751
- img.automatic-insertion.preview.im-sticky-content-left {
752
- background: url('images/insertions-alignmets.png') -300px -150px;
753
- }
754
-
755
- img.automatic-insertion.preview.im-sticky-content-right {
756
- background: url('images/insertions-alignmets.png') -350px -150px;
757
- }
758
-
759
- img.automatic-insertion.preview.im-sticky-content-right {
760
- background: url('images/insertions-alignmets.png') -350px -150px;
761
- }
762
-
763
- img.automatic-insertion.preview.im-sticky-center-horizontal {
764
- background: url('images/insertions-alignmets.png') 0 -200px;
765
- }
766
-
767
- img.automatic-insertion.preview.im-sticky-center-vertical {
768
- background: url('images/insertions-alignmets.png') -50px -200px;
769
- }
770
-
771
- img.automatic-insertion.preview.im-sticky-scroll {
772
- background: url('images/insertions-alignmets.png') -100px -200px;
773
- }
774
-
775
- img.automatic-insertion.preview.im-sticky {
776
- background: url('images/insertions-alignmets.png') -150px -200px;
777
- }
778
-
779
- img.automatic-insertion.preview.im-close-top-left {
780
- background: url('images/insertions-alignmets.png') -200px -200px;
781
- }
782
-
783
- img.automatic-insertion.preview.im-close-top-right {
784
- background: url('images/insertions-alignmets.png') -250px -200px;
785
- }
786
-
787
- img.automatic-insertion.preview.im-close-bottom-right {
788
- background: url('images/insertions-alignmets.png') -300px -200px;
789
- }
790
-
791
- img.automatic-insertion.preview.im-close-bottom-left {
792
- background: url('images/insertions-alignmets.png') -350px -200px;
793
- }
794
-
795
- img.automatic-insertion.preview.im-close-none {
796
- background: url('images/insertions-alignmets.png') -0px -250px;
797
- }
798
-
799
-
800
- img.automatic-insertion.preview {
801
- background-size: 400px!important;
802
- }
803
-
804
-
805
- .checkbox-icon.icon-tracking {
806
- background: url('images/icons.png') -40px -20px;
807
- }
808
-
809
- .checkbox-icon.icon-tracking.on {
810
- background: url('images/icons.png') -40px 0;
811
- }
812
-
813
- .tracking-disabled .checkbox-icon.icon-tracking.on {
814
- background: url('images/icons.png') -40px -40px;
815
- }
816
-
817
- .checkbox-icon.icon-tablet {
818
- background: url('images/icons.png') -20px -20px;
819
- }
820
-
821
- .checkbox-icon.icon-tablet.on {
822
- background: url('images/icons.png') -20px 0;
823
- }
824
-
825
- .checkbox-icon.icon-php {
826
- background: url('images/icons.png') 0 -20px;
827
- }
828
-
829
- .checkbox-icon.icon-php.on {
830
- background: url('images/icons.png') 0 0;
831
- }
832
-
833
- .checkbox-icon.icon-enabled {
834
- background: url('images/icons.png') -100px -20px;
835
- }
836
-
837
- .checkbox-icon.icon-enabled.on {
838
- background: url('images/icons.png') -100px 0;
839
- }
840
-
841
- .checkbox-icon.icon-export-import {
842
- background: url('images/icons.png') -80px -20px;
843
- }
844
-
845
- .checkbox-icon.icon-export-import.on {
846
- background: url('images/icons.png') -80px 0;
847
- }
848
-
849
- .checkbox-icon.icon-statistics {
850
- background: url('images/icons.png') -60px -20px;
851
- }
852
-
853
- .checkbox-icon.icon-statistics.on {
854
- background: url('images/icons.png') -60px 0;
855
- }
856
-
857
- .checkbox-icon.icon-adb {
858
- background: url('images/icons.png') -120px -20px;
859
- }
860
-
861
- .checkbox-icon.icon-adb.on {
862
- background: url('images/icons.png') -120px 0;
863
- }
864
-
865
- .checkbox-icon.icon-code {
866
- background: url('images/icons.png') 0 -80px;
867
- }
868
-
869
- .checkbox-icon.icon-code.on {
870
- background: url('images/icons.png') 0 -60px;
871
- }
872
-
873
- .checkbox-icon.icon-rotation {
874
- background: url('images/icons.png') -20px -80px;
875
- }
876
-
877
- .checkbox-icon.icon-rotation.on {
878
- background: url('images/icons.png') -20px -60px;
879
- }
880
-
881
- .checkbox-icon.icon-rotation.active {
882
- background: url('images/icons.png') -100px -40px;
883
- }
884
-
885
- .checkbox-icon.icon-generate {
886
- background: url('images/icons.png') -40px -80px;
887
- }
888
-
889
- .checkbox-icon.icon-generate.on {
890
- background: url('images/icons.png') -40px -60px;
891
- }
892
-
893
- .checkbox-icon.icon-import {
894
- background: url('images/icons.png') -60px -80px;
895
- }
896
-
897
- .checkbox-icon.icon-import.on {
898
- background: url('images/icons.png') -60px -60px;
899
- }
900
-
901
- .checkbox-icon.icon-edit {
902
- background: url('images/icons.png') -80px -40px;
903
- }
904
-
905
- .checkbox-icon.icon-minus {
906
- background: url('images/icons.png') -80px -80px;
907
- }
908
-
909
- .checkbox-icon.icon-plus {
910
- background: url('images/icons.png') -80px -60px;
911
- }
912
-
913
- .checkbox-icon.icon-tools {
914
- background: url('images/icons.png') -100px -80px;
915
- }
916
-
917
- .checkbox-icon.icon-tools.on {
918
- background: url('images/icons.png') -100px -60px;
919
- }
920
-
921
- .checkbox-icon.icon-copy {
922
- background: url('images/icons.png') -120px -80px;
923
- }
924
-
925
- .checkbox-icon.icon-copy.on {
926
- background: url('images/icons.png') -120px -60px;
927
- }
928
-
929
- .checkbox-icon.icon-paste {
930
- background: url('images/icons.png') -120px -40px;
931
- }
932
-
933
- .checkbox-icon.icon-paste-name {
934
- background: url('images/icons.png') -180px -40px;
935
- }
936
-
937
- .checkbox-icon.icon-paste-code {
938
- background: url('images/icons.png') -160px -40px;
939
- }
940
-
941
- .checkbox-icon.icon-paste-settings {
942
- background: url('images/icons.png') -140px -40px;
943
- }
944
-
945
- .checkbox-icon.icon-clear {
946
- background: url('images/icons.png') -160px -80px;
947
- }
948
-
949
- .checkbox-icon.icon-enabled-all {
950
- background: url('images/icons.png') -142px -22px;
951
- }
952
-
953
- .checkbox-icon.icon-enabled-all.on {
954
- background: url('images/icons.png') -142px -2px;
955
- }
956
-
957
-
958
- .checkbox-icon.icon-rearrange {
959
- background: url('images/icons.png') -140px -80px;
960
- }
961
-
962
- .checkbox-icon.icon-rearrange.on {
963
- background: url('images/icons.png') -140px -60px;
964
- }
965
-
966
- .checkbox-icon.icon-loading {
967
- background: url('images/icons.png') -163px -23px;
968
- }
969
-
970
- .checkbox-icon.icon-loading.on {
971
- background: url('images/icons.png') -163px -3px;
972
- }
973
-
974
- .checkbox-icon.icon-reload {
975
- background: url('images/icons.png') -161px -22px;
976
- }
977
-
978
- .checkbox-icon.icon-reload.on {
979
- background: url('images/icons.png') -161px -2px;
980
- }
981
-
982
- .checkbox-icon.icon-auto-refresh {
983
- background: url('images/icons.png') -180px -20px;
984
- }
985
-
986
- .checkbox-icon.icon-auto-refresh.on {
987
- background: url('images/icons.png') -180px 0;
988
- }
989
-
990
- /*.checkbox-icon.icon-ad-label {*/
991
- /* background: url('images/icons.png') -180px -80px;*/
992
- /*}*/
993
-
994
- /*.checkbox-icon.icon-ad-label.on {*/
995
- /* background: url('images/icons.png') -180px -60px;*/
996
- /*}*/
997
-
998
-
999
- .checkbox-icon.size-8.icon-stop {
1000
- background: #ddd;
1001
- }
1002
-
1003
- .checkbox-icon.size-8.icon-preview {
1004
- width: 0;
1005
- height: 0;
1006
- margin-left: 1px;
1007
- border-top: 4px solid transparent;
1008
- border-bottom: 4px solid transparent;
1009
- border-left: 7px solid #bbb;
1010
- }
1011
-
1012
- .checkbox-icon.size-8.icon-get {
1013
- width: 0;
1014
- height: 0;
1015
- border-left: 4px solid transparent;
1016
- border-right: 4px solid transparent;
1017
- border-top: 8px solid #888;
1018
- }
1019
-
1020
- .icon-adsense {
1021
- background: url('../images/ga-logo.png') 0px 0px;
1022
- background-size: cover;
1023
- }
1024
-
1025
- .ai-button .ui-button-text.ai-button-active {
1026
- background: #f44;
1027
- border: 1px solid #f44;
1028
- border-radius: 8px;
1029
- width: 5px;
1030
- height: 5px;
1031
- padding: 0;
1032
- margin: 1px 0px 1px 3px;
1033
- }
1034
-
1035
- .banner-preview {
1036
- float: left;
1037
- margin: 0 10px 0 0;
1038
- }
1039
-
1040
- .banner-preview img {
1041
- max-width: 100px;
1042
- max-height: 160px;
1043
- }
1044
-
1045
- .ai-banner-top .banner-preview img {
1046
- max-width: 718px;
1047
- max-height: 100px;
1048
- }
1049
-
1050
- .ai-banner-top table {
1051
- float: right;
1052
- }
1053
-
1054
- #ai-sidebar .notice-dismiss {
1055
- position: absolute;
1056
- top: 0;
1057
- right: 1px;
1058
- border: none;
1059
- margin: 0;
1060
- padding: 9px;
1061
- background: 0 0;
1062
- color: #72777c;
1063
- cursor: pointer;
1064
- }
1065
-
1066
- #ai-sidebar .notice-dismiss:focus {
1067
- outline: 0;
1068
- -webkit-box-shadow: none;
1069
- box-shadow: none;
1070
- }
1071
-
1072
- #ai-sidebar .notice-dismiss.ui-state-active, #ai-sidebar .notice-dismiss.ui-widget-content .ui-state-active, #ai-sidebar .notice-dismiss.ui-widget-header .ui-state-active {
1073
- background: 0 0!important;
1074
- }
1075
-
1076
- .ai-form .ai-dot {
1077
- font-size: 18px!important;
1078
- line-height: 16px;
1079
- }
1080
-
1081
- .ad-size .scombobox {
1082
- width: 80px;
1083
- display: inline-block;
1084
- margin: 1px 0;
1085
- }
1086
-
1087
- .scombobox-list p:hover, .scombobox-list p.scombobox-hovered {
1088
- background-color: #eaeaea;
1089
- }
1090
-
1091
- .scombobox-list p {
1092
- padding: 1px;
1093
- }
1094
-
1095
- .scombobox-display {
1096
- padding-right: 1px;
1097
- }
1098
-
1099
- @media (max-width: 782px) {
1100
- .auto-fold #wpcontent {
1101
- padding-left: 4px;
1102
- }
1103
- #wpwrap {
1104
- width: 762px;
1105
- }
1106
-
1107
- .ai-toolbar-button.small {
1108
- width: 20px;
1109
- height: 20px;
1110
- margin-right: 10px;
1111
- }
1112
-
1113
- .ai-toolbar-button.small .checkbox-icon {
1114
- margin: 4px 0px 0 4px;
1115
- }
1116
-
1117
- .checkbox-icon.size-16 {
1118
- width: 20px;
1119
- height: 20px;
1120
- }
1121
-
1122
- .checkbox-icon.size-img16 {
1123
- width: 24px;
1124
- height:24px;
1125
- background-size: 24px 24px;
1126
- }
1127
-
1128
- .ai-toolbar-button.small .checkbox-icon.size-img16 {
1129
- margin: 0;
1130
- }
1131
-
1132
- .checkbox-icon.size-16w {
1133
- width: 20px;
1134
- height: 20px;
1135
- }
1136
-
1137
- .list-button.lb-size-16 {
1138
- margin: 6px 0 0 4px;
1139
- padding: 0px 4px 2px 0px;
1140
- }
1141
-
1142
- .ad-size .scombobox {
1143
- width: 100px;
1144
- }
1145
-
1146
- .scombobox-list p {
1147
- font-size: 16px;
1148
- }
1149
- }
1150
-
1151
- @media(max-width: 768px) {
1152
- .text .checkbox-button {
1153
- padding: 2px 5px 2px 4px;
1154
- }
1155
- .ai-settings-table tr {
1156
- height: 40px;
1157
- }
1158
- .ai-settings-table input[type=text] {
1159
- height: 30px;
1160
- }
1161
- .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
1162
- font-family: sans-serif,Arial,Verdana;
1163
- font-size: 16px;
1164
- }
1165
- div.custom-range-controls {
1166
- width: 720px;
1167
- }
1168
- input.ai-date-input {
1169
- width: 90px;
1170
- padding: 3px 3px;
1171
- }
1172
- .ai-form .ai-dot {
1173
- font-size: 12px!important;
1174
- line-height: 18px;
1175
- }
1176
-
1177
- .banner-preview img {
1178
- max-width: 160px;
1179
- max-height: 160px;
1180
- }
1181
-
1182
- .ai-settings-table.left {
1183
- width: 60%
1184
- }
1185
-
1186
- .ai-settings-table.right {
1187
- width: 40%
1188
- }
1189
- }
1190
-
1191
- @media(min-width: 769px) {
1192
- #ai-form select {
1193
- line-height: 22px;
1194
- height: 22px;
1195
- }
1196
- }
1197
-
1198
- @media (min-width: 783px) and (max-width: 828px) {
1199
- .auto-fold #wpcontent, .auto-fold #wpfooter {
1200
- margin-left: 20px;
1201
- }
1202
- }
1203
-
1204
- @media screen and (max-width: 782px){
1205
- #wpbody .small-select select {
1206
- height: 32px;
1207
- font-size: 14px;
1208
- }
1209
-
1210
- #wpbody span.small-input-tags {
1211
- width: 22%;
1212
- }
1213
- }
1214
-
1215
-
1216
-
1
+ #ai-data {
2
+ font-family: "2.3.8"; /* Used for version number of the file */
3
+ }
4
+
5
+ #blocked-warning {
6
+ display: none;
7
+ }
8
+
9
+ .ui-widget, .ai-form td {
10
+ font-family: sans-serif,Arial,Verdana;
11
+ font-size: 12px!important;
12
+ }
13
+
14
+ .ai-form .ui-widget {
15
+ position: relative;
16
+ }
17
+
18
+ .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
19
+ font-family: sans-serif,Arial,Verdana;
20
+ font-size: 12px;
21
+ }
22
+
23
+ .ui-widget-header {
24
+ border: 1px solid #aaa !important;
25
+ background: #ccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x !important;
26
+ }
27
+
28
+ .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active {
29
+ background: #fff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x!important !important;
30
+ }
31
+
32
+ /*.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active, a.ui-button:active, .ui-button:active, .ui-button.ui-state-active:hover {*/
33
+ /* border: 1px solid #d3d3d3;*/
34
+ /* background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;*/
35
+ /* color: #555;*/
36
+ /*}*/
37
+
38
+ .ui-state-highlight {
39
+ background: #ff4;
40
+ }
41
+
42
+ button.ai-top-button {
43
+ min-width: 52px;
44
+ }
45
+
46
+ .ai-top-button.ui-button-text-only .ui-button-text {
47
+ padding: .4em 0.6em;
48
+ }
49
+
50
+ .adsense-list .ui-button-text, .select-image .ui-button-text {
51
+ padding: 0.4em 0.5em;
52
+ }
53
+
54
+ .ace_editor {
55
+ border: 1px solid #ddd;
56
+ border-radius: 4px;
57
+ }
58
+
59
+ .ai-icon-gear {
60
+ width: 16px;
61
+ height: 16px;
62
+ background: url('images/icons.png') 0 -40px;
63
+ background-repeat: no-repeat;
64
+ }
65
+
66
+ .ai-icon-gear.on {
67
+ background: url('images/icons.png') -20px -40px;
68
+ }
69
+
70
+ .ai-icon-gear.red {
71
+ background: url('images/icons.png') -60px -40px;
72
+ }
73
+
74
+ a.simple-link {
75
+ text-decoration: none;
76
+ box-shadow: 0 0 0;
77
+ }
78
+
79
+ a.clear-link, a.clear-link:hover, a.clear-link:focus {
80
+ color: transparent;
81
+ text-decoration: none;
82
+ box-shadow: 0 0 0;
83
+ }
84
+
85
+ .rounded {
86
+ border-radius: 5px;
87
+ }
88
+
89
+ .ai-form.rounded input, .ai-form.rounded select {
90
+ border-radius: 5px;
91
+ }
92
+
93
+ #ai-form div.rounded, #ai-sidebar div.rounded {
94
+ margin: 8px 0;
95
+ padding: 8px;
96
+ border: 1px solid rgb(221, 221, 221);
97
+ border-radius: 5px;
98
+ }
99
+
100
+ .ai-settings-table {
101
+ border-spacing: 4px;
102
+ }
103
+
104
+ .ai-settings-table.left {
105
+ float: left;
106
+ width: 52%
107
+ }
108
+
109
+ .ai-settings-table.right {
110
+ float: right;
111
+ width: 48%
112
+ }
113
+
114
+ .ai-settings-table.ai-values td:first-child {
115
+ width: 35%;
116
+ }
117
+
118
+ .ai-settings-table.fixed {
119
+ table-layout: fixed;
120
+ }
121
+
122
+ /*#editor-1 {*/
123
+ /* font-family: Courier, 'Courier New', monospace, tahoma;*/
124
+ /* font-family: tahoma;*/
125
+ /* font-size: 10px";*/
126
+ /*}*/
127
+
128
+ .nav-tab {
129
+ border-top-left-radius: 5px;
130
+ border-top-right-radius: 5px;
131
+ }
132
+ .nav-tab-active, .nav-tab-active:hover {
133
+ background: #fff;
134
+ }
135
+
136
+ .exceptions a {
137
+ text-decoration: none;
138
+ }
139
+ .exceptions th.page {
140
+ text-align: left;
141
+ }
142
+ .exceptions tr.even {
143
+ background: #f0f0f0;
144
+ }
145
+ .exceptions td.page {
146
+ padding-right: 20px;
147
+ }
148
+ .exceptions th.id, .exceptions td.id {
149
+ padding-right: 10px;
150
+ text-align: right;
151
+ }
152
+ .exceptions th.type, .exceptions td.type {
153
+ padding-right: 10px;
154
+ text-align: left;
155
+ }
156
+ .exceptions th.page, .exceptions td.page {
157
+ width: 90%;
158
+ overflow: hidden;
159
+ max-width: 240px;
160
+ }
161
+ .exceptions th.page-only, .exceptions td.page-only {
162
+ width: 100%;
163
+ }
164
+ .exceptions th.block, .exceptions td.block {
165
+ text-align: center;
166
+ min-width: 22px;
167
+ cursor: pointer;
168
+ }
169
+ .exceptions td.button-delete {
170
+ cursor: pointer;
171
+ }
172
+ .small-button .ui-button-text-only .ui-button-text {
173
+ padding: 0px;
174
+ }
175
+ .responsive-table td {
176
+ white-space: nowrap;
177
+ padding: 0;
178
+ }
179
+
180
+ .no-select {
181
+ -webkit-user-select: none; /* Chrome all / Safari all */
182
+ -moz-user-select: none; /* Firefox all */
183
+ -ms-user-select: none; /* IE 10+ */
184
+ user-select: none;
185
+ }
186
+ .select {
187
+ -webkit-user-select: text;
188
+ -moz-user-select: text;
189
+ -ms-user-select: text;
190
+ user-select: text;
191
+ }
192
+ .copy-blocker {
193
+ position: absolute;
194
+ user-select: text;
195
+ height: 100%;
196
+ }
197
+
198
+ .ui-dialog {
199
+ z-index: 10000 !important;
200
+ }
201
+ .ui-dialog .ui-dialog-titlebar-close {
202
+ outline-color: transparent;
203
+ }
204
+ .no-title .ui-dialog-titlebar {
205
+ display:none
206
+ }
207
+
208
+ .ai-form {
209
+ width: 735px;
210
+ }
211
+
212
+ .ui-datepicker {
213
+ z-index: 202!important;
214
+ }
215
+
216
+ div.ai-chart-container {
217
+ position: relative;
218
+ margin: 8px 0;
219
+ }
220
+
221
+ div.ai-chart-container.versions {
222
+ display: inline-block;
223
+ margin: 20px 20px 0;
224
+ }
225
+
226
+ div.ai-chart {
227
+ width: 735px;
228
+ height: 140px;
229
+ }
230
+
231
+ div.versions div.ai-chart {
232
+ width: 200px;
233
+ height: 140px;
234
+ }
235
+
236
+ div.legend div.ai-chart {
237
+ height: 25px;
238
+ }
239
+
240
+ div.ai-chart-label {
241
+ position: absolute;
242
+ top: 13px;
243
+ left: 44px;
244
+ z-index: 202;
245
+ opacity: 0.5;
246
+ display: none;
247
+ }
248
+
249
+ div.ai-chart-container.versions div.ai-chart-label {
250
+ z-index: 1;
251
+ }
252
+
253
+ div.versions div.ai-chart-label {
254
+ top: -16px;
255
+ left: 80px;
256
+ }
257
+
258
+ .legend div.ai-chart-label {
259
+ top: 34px;
260
+ }
261
+
262
+ div.ai-tooltip {
263
+ z-index: 203;
264
+ }
265
+
266
+ div.ai-tooltip .version {
267
+ font-weight: bold;
268
+ }
269
+
270
+ #ai-settings {
271
+ margin-right: 24px;
272
+ }
273
+
274
+ .ui-tabs .ui-tabs-nav li {
275
+ margin: 1px 0.17em 0 0;
276
+ }
277
+
278
+ #ai-tabs a {
279
+ width: 14px;
280
+ text-align: center;
281
+ font-size: 12px;
282
+ }
283
+ #ai-tabs {
284
+ padding: .2em 0 0 .6em;
285
+ }
286
+
287
+ #ai-scroll-tabs {
288
+ height: 42px;
289
+ }
290
+
291
+ #ai-plugin-settings-tabs li a {
292
+ padding: .5em 0.4em;
293
+ font-size: 12px;
294
+ }
295
+
296
+ #header-buttons {
297
+ min-height: 26px;
298
+ margin: 2px 0;
299
+ float: right;
300
+ }
301
+
302
+ .max-input {
303
+ display: table;
304
+ width: 100%;
305
+ }
306
+
307
+ .simple-editor {
308
+ width: 733px;
309
+ min-width: 370px;
310
+ height: 386px;
311
+ }
312
+
313
+ textarea.simple-editor {
314
+ height: 388px;
315
+ }
316
+
317
+ .simple-editor.small {
318
+ height: 190px;
319
+ }
320
+
321
+ textarea.simple-editor.small {
322
+ height: 192px;
323
+ }
324
+
325
+ .ms-container {
326
+ width: 100%;
327
+ font-size: 12px;
328
+ }
329
+
330
+ .ms-container .ms-selectable, .ms-container .ms-selection {
331
+ width: 47%;
332
+ }
333
+
334
+ .ms-container .ms-selectable li.ms-elem-selectable, .ms-container .ms-selection li.ms-elem-selection {
335
+ padding: 1px 10px;
336
+ font-size: 12px;
337
+ }
338
+
339
+ .ms-container dd, .ms-container li {
340
+ /*.ms-container dd, li {*/
341
+ margin-bottom: 4px;
342
+ }
343
+
344
+ .feature-list li, .ai-help li {
345
+ margin-bottom: 2px;
346
+ }
347
+
348
+ .ms-container .search-input {
349
+ width: 100%;
350
+ border-radius: 4px;
351
+ }
352
+
353
+ .ms-container div.ms-selection {
354
+ margin-top: 24px;
355
+ }
356
+
357
+ div.custom-range-controls {
358
+ width: 696px;
359
+ }
360
+
361
+ input.ai-date-input {
362
+ width: 85px;
363
+ }
364
+
365
+ .country-flags .ms-container .ms-selectable li.ms-elem-selectable, .country-flags .ms-container .ms-selection li.ms-elem-selection {
366
+ padding-left: 30px;
367
+ }
368
+
369
+ .flag-icon {
370
+ display: list-item;
371
+ width: auto;
372
+ line-height: inherit;
373
+ }
374
+ .flag-icon, .flag-icon-background {
375
+ background-position: initial;
376
+ }
377
+
378
+ div.automatic-insertion {
379
+ width: 56px;
380
+ height: 56px;
381
+ }
382
+
383
+ ul.thumbnails.image_picker_selector li {
384
+ margin: 0px 5px 4px 0px;
385
+ cursor: pointer;
386
+ }
387
+
388
+ ul.thumbnails.image_picker_selector li .thumbnail {
389
+ padding: 4px;
390
+ }
391
+
392
+ ul.thumbnails.image_picker_selector li .thumbnail.selected {
393
+ background: #666;
394
+ }
395
+ li.automatic-insertion p {
396
+ width: 57px;
397
+ font-size: inherit;
398
+ margin: 4px 0;
399
+ }
400
+
401
+ div.automatic-insertion img {
402
+ width: 56px;
403
+ height: 56px;
404
+ }
405
+
406
+ .ai-toolbar-button {
407
+ display: table-cell;
408
+ vertical-align: top;
409
+ width: 28px;
410
+ padding: 0 0 0 10px;
411
+ }
412
+
413
+ .ai-list-button {
414
+ display: table-cell;
415
+ margin-right: 2px;
416
+ width: 20px;
417
+ }
418
+
419
+ .ai-toolbar-button.text {
420
+ width: auto;
421
+ }
422
+
423
+ .ai-toolbar-button.small {
424
+ width: 20px;
425
+ }
426
+
427
+ .ai-toolbar-button.ai-button-left {
428
+ padding: 0 10px 0 0;
429
+ }
430
+
431
+ .checkbox-button {
432
+ background-image: none, linear-gradient(to bottom, #f6f6f6 0, #eaeaea 100%);
433
+ background-position: 50% 50%;
434
+ background-color: #e3e3e3;
435
+ border: solid 1px lightgrey;
436
+ border-radius: 4px;
437
+ -webkit-border-radius: 4px;
438
+ -moz-border-radius: 4px;
439
+ cursor: pointer;
440
+ padding: 2px 2px;
441
+ display: inline-block;
442
+ margin: 0;
443
+ font-family: inherit;
444
+ line-height: 1.66em;
445
+ text-align: center;
446
+ cursor: pointer;
447
+ text-decoration: none;
448
+ -webkit-box-sizing: border-box;
449
+ -moz-box-sizing: border-box;
450
+ box-sizing: border-box;
451
+ }
452
+
453
+ .custom-range-controls .checkbox-button {
454
+ border-radius: 3px;
455
+ -webkit-border-radius: 3px;
456
+ -moz-border-radius: 3px;
457
+ }
458
+
459
+ .ai-list-button .checkbox-button {
460
+ border-radius: 3px;
461
+ -webkit-border-radius: 3px;
462
+ -moz-border-radius: 3px;
463
+ }
464
+
465
+ .text .checkbox-button {
466
+ font-size: 11px;
467
+ padding: 0px 5px 0px 4px;
468
+ margin-top: 2px;
469
+ }
470
+
471
+ .ai-bw {
472
+ filter: grayscale(100%);
473
+ }
474
+
475
+ .checkbox-icon {
476
+ background-position: center;
477
+ display: inline-block;
478
+ float: left;
479
+ width: 20px;
480
+ height: 20px;
481
+ overflow: hidden;
482
+ background-repeat: no-repeat;
483
+ font-size: 0;
484
+ line-height: 0;
485
+ text-indent: -3333px;
486
+ text-align: center;
487
+ vertical-align: middle;
488
+ }
489
+
490
+ .checkbox-icon.size-16 {
491
+ width: 16px;
492
+ height: 16px;
493
+ }
494
+
495
+ .checkbox-icon.size-img16 {
496
+ width: 16px;
497
+ height:16px;
498
+ background-size: 16px 16px;
499
+ }
500
+
501
+ .checkbox-icon.size-16w {
502
+ width: 17px;
503
+ height: 16px;
504
+ }
505
+
506
+ .checkbox-icon.size-12 {
507
+ width: 12px;
508
+ height: 12px;
509
+ margin: 3px 0;
510
+ }
511
+
512
+ .checkbox-icon.size-8 {
513
+ width: 8px;
514
+ height: 8px;
515
+ }
516
+
517
+ .checkbox-icon.icon-none {
518
+ width: 10px;
519
+ height: 12px;
520
+ margin-top: 6px;
521
+ }
522
+
523
+ .list-button.lb-size-16 {
524
+ width: 16px;
525
+ height: 16px;
526
+ }
527
+
528
+ .list-button {
529
+ margin: 0;
530
+ background-image: url(images/ui-icons_888888_256x240.png)
531
+ }
532
+
533
+ img.automatic-insertion.im-disabled {
534
+ background: url('images/insertions-alignmets.png') 0 0;
535
+ }
536
+
537
+ img.automatic-insertion.im-before-post {
538
+ background: url('images/insertions-alignmets.png') -56px 0;
539
+ }
540
+
541
+ img.automatic-insertion.im-after-post {
542
+ background: url('images/insertions-alignmets.png') -112px 0;
543
+ }
544
+
545
+ img.automatic-insertion.im-before-content {
546
+ background: url('images/insertions-alignmets.png') -168px 0;
547
+ }
548
+
549
+ img.automatic-insertion.im-after-content {
550
+ background: url('images/insertions-alignmets.png') -224px 0;
551
+ }
552
+
553
+ img.automatic-insertion.im-before-paragraph {
554
+ background: url('images/insertions-alignmets.png') -280px 0;
555
+ }
556
+
557
+ img.automatic-insertion.im-after-paragraph {
558
+ background: url('images/insertions-alignmets.png') -336px 0;
559
+ }
560
+
561
+ img.automatic-insertion.im-before-excerpts {
562
+ background: url('images/insertions-alignmets.png') -392px 0;
563
+ }
564
+
565
+ img.automatic-insertion.im-after-excerpts {
566
+ background: url('images/insertions-alignmets.png') 0 -56px;
567
+ }
568
+
569
+ img.automatic-insertion.im-between-posts {
570
+ background: url('images/insertions-alignmets.png') -56px -56px;
571
+ }
572
+
573
+ img.automatic-insertion.im-before-comments {
574
+ background: url('images/insertions-alignmets.png') -112px -56px;
575
+ }
576
+
577
+ img.automatic-insertion.im-between-comments {
578
+ background: url('images/insertions-alignmets.png') -168px -56px;
579
+ }
580
+
581
+ img.automatic-insertion.im-after-comments {
582
+ background: url('images/insertions-alignmets.png') -224px -56px;
583
+ }
584
+
585
+ img.automatic-insertion.im-footer {
586
+ background: url('images/insertions-alignmets.png') -280px -56px;
587
+ }
588
+
589
+ img.automatic-insertion.im-custom-hook {
590
+ background: url('images/insertions-alignmets.png') -336px -56px;
591
+ }
592
+
593
+ img.automatic-insertion.im-no-wrapping {
594
+ background: url('images/insertions-alignmets.png') -392px -56px;
595
+ }
596
+
597
+ img.automatic-insertion.im-custom-css {
598
+ background: url('images/insertions-alignmets.png') 0 -112px;
599
+ }
600
+
601
+ img.automatic-insertion.im-default {
602
+ background: url('images/insertions-alignmets.png') -56px -112px;
603
+ }
604
+
605
+ img.automatic-insertion.im-align-left {
606
+ background: url('images/insertions-alignmets.png') -112px -112px;
607
+ }
608
+
609
+ img.automatic-insertion.im-center {
610
+ background: url('images/insertions-alignmets.png') -168px -112px;
611
+ }
612
+
613
+ img.automatic-insertion.im-align-right {
614
+ background: url('images/insertions-alignmets.png') -224px -112px;
615
+ }
616
+
617
+ img.automatic-insertion.im-float-left {
618
+ background: url('images/insertions-alignmets.png') -280px -112px;
619
+ }
620
+
621
+ img.automatic-insertion.im-float-right {
622
+ background: url('images/insertions-alignmets.png') -336px -112px;
623
+ }
624
+
625
+ img.automatic-insertion.im-sticky-left {
626
+ background: url('images/insertions-alignmets.png') -392px -112px;
627
+ }
628
+
629
+ img.automatic-insertion.im-sticky-right {
630
+ background: url('images/insertions-alignmets.png') 0 -168px;
631
+ }
632
+
633
+ img.automatic-insertion.im-sticky-top {
634
+ background: url('images/insertions-alignmets.png') -56px -168px;
635
+ }
636
+
637
+ img.automatic-insertion.im-sticky-bottom {
638
+ background: url('images/insertions-alignmets.png') -112px -168px;
639
+ }
640
+
641
+ img.automatic-insertion.im-above-header {
642
+ background: url('images/insertions-alignmets.png') -168px -168px;
643
+ }
644
+
645
+ img.automatic-insertion.im-before-html {
646
+ background: url('images/insertions-alignmets.png') -224px -168px;
647
+ }
648
+
649
+ img.automatic-insertion.im-after-html {
650
+ background: url('images/insertions-alignmets.png') -280px -168px;
651
+ }
652
+
653
+ img.automatic-insertion.im-sticky-content-left {
654
+ background: url('images/insertions-alignmets.png') -336px -168px;
655
+ }
656
+
657
+ img.automatic-insertion.im-sticky-content-right {
658
+ background: url('images/insertions-alignmets.png') -392px -168px;
659
+ }
660
+
661
+ img.automatic-insertion.im-sticky-center-horizontal {
662
+ background: url('images/insertions-alignmets.png') 0 -224px;
663
+ }
664
+
665
+ img.automatic-insertion.im-sticky-center-vertical {
666
+ background: url('images/insertions-alignmets.png') -56px -224px;
667
+ }
668
+
669
+ img.automatic-insertion.im-sticky-scroll {
670
+ background: url('images/insertions-alignmets.png') -112px -224px;
671
+ }
672
+
673
+ img.automatic-insertion.im-sticky {
674
+ background: url('images/insertions-alignmets.png') -168px -224px;
675
+ }
676
+
677
+ img.automatic-insertion.im-close-top-left {
678
+ background: url('images/insertions-alignmets.png') -224px -224px;
679
+ }
680
+
681
+ img.automatic-insertion.im-close-top-right {
682
+ background: url('images/insertions-alignmets.png') -280px -224px;
683
+ }
684
+
685
+ img.automatic-insertion.im-close-bottom-right {
686
+ background: url('images/insertions-alignmets.png') -336px -224px;
687
+ }
688
+
689
+ img.automatic-insertion.im-close-bottom-left {
690
+ background: url('images/insertions-alignmets.png') -392px -224px;
691
+ }
692
+
693
+ img.automatic-insertion.im-close-none {
694
+ background: url('images/insertions-alignmets.png') -0px -280px;
695
+ }
696
+
697
+
698
+ img.automatic-insertion {
699
+ background-size: 448px!important;
700
+ }
701
+
702
+
703
+ img.automatic-insertion.preview.im-no-wrapping {
704
+ background: url('images/insertions-alignmets.png') -350px -50px;
705
+ }
706
+
707
+ img.automatic-insertion.preview.im-custom-css {
708
+ background: url('images/insertions-alignmets.png') 0 -100px;
709
+ }
710
+
711
+ img.automatic-insertion.preview.im-default {
712
+ background: url('images/insertions-alignmets.png') -50px -100px;
713
+ }
714
+
715
+ img.automatic-insertion.preview.im-align-left {
716
+ background: url('images/insertions-alignmets.png') -100px -100px;
717
+ }
718
+
719
+ img.automatic-insertion.preview.im-center {
720
+ background: url('images/insertions-alignmets.png') -150px -100px;
721
+ }
722
+
723
+ img.automatic-insertion.preview.im-align-right {
724
+ background: url('images/insertions-alignmets.png') -200px -100px;
725
+ }
726
+
727
+ img.automatic-insertion.preview.im-float-left {
728
+ background: url('images/insertions-alignmets.png') -250px -100px;
729
+ }
730
+
731
+ img.automatic-insertion.preview.im-float-right {
732
+ background: url('images/insertions-alignmets.png') -300px -100px;
733
+ }
734
+
735
+ img.automatic-insertion.preview.im-sticky-left {
736
+ background: url('images/insertions-alignmets.png') -350px -100px;
737
+ }
738
+
739
+ img.automatic-insertion.preview.im-sticky-right {
740
+ background: url('images/insertions-alignmets.png') 0 -150px;
741
+ }
742
+
743
+ img.automatic-insertion.preview.im-sticky-top {
744
+ background: url('images/insertions-alignmets.png') -50px -150px;
745
+ }
746
+
747
+ img.automatic-insertion.preview.im-sticky-bottom {
748
+ background: url('images/insertions-alignmets.png') -100px -150px;
749
+ }
750
+
751
+ img.automatic-insertion.preview.im-sticky-content-left {
752
+ background: url('images/insertions-alignmets.png') -300px -150px;
753
+ }
754
+
755
+ img.automatic-insertion.preview.im-sticky-content-right {
756
+ background: url('images/insertions-alignmets.png') -350px -150px;
757
+ }
758
+
759
+ img.automatic-insertion.preview.im-sticky-content-right {
760
+ background: url('images/insertions-alignmets.png') -350px -150px;
761
+ }
762
+
763
+ img.automatic-insertion.preview.im-sticky-center-horizontal {
764
+ background: url('images/insertions-alignmets.png') 0 -200px;
765
+ }
766
+
767
+ img.automatic-insertion.preview.im-sticky-center-vertical {
768
+ background: url('images/insertions-alignmets.png') -50px -200px;
769
+ }
770
+
771
+ img.automatic-insertion.preview.im-sticky-scroll {
772
+ background: url('images/insertions-alignmets.png') -100px -200px;
773
+ }
774
+
775
+ img.automatic-insertion.preview.im-sticky {
776
+ background: url('images/insertions-alignmets.png') -150px -200px;
777
+ }
778
+
779
+ img.automatic-insertion.preview.im-close-top-left {
780
+ background: url('images/insertions-alignmets.png') -200px -200px;
781
+ }
782
+
783
+ img.automatic-insertion.preview.im-close-top-right {
784
+ background: url('images/insertions-alignmets.png') -250px -200px;
785
+ }
786
+
787
+ img.automatic-insertion.preview.im-close-bottom-right {
788
+ background: url('images/insertions-alignmets.png') -300px -200px;
789
+ }
790
+
791
+ img.automatic-insertion.preview.im-close-bottom-left {
792
+ background: url('images/insertions-alignmets.png') -350px -200px;
793
+ }
794
+
795
+ img.automatic-insertion.preview.im-close-none {
796
+ background: url('images/insertions-alignmets.png') -0px -250px;
797
+ }
798
+
799
+
800
+ img.automatic-insertion.preview {
801
+ background-size: 400px!important;
802
+ }
803
+
804
+
805
+ .checkbox-icon.icon-tracking {
806
+ background: url('images/icons.png') -40px -20px;
807
+ }
808
+
809
+ .checkbox-icon.icon-tracking.on {
810
+ background: url('images/icons.png') -40px 0;
811
+ }
812
+
813
+ .tracking-disabled .checkbox-icon.icon-tracking.on {
814
+ background: url('images/icons.png') -40px -40px;
815
+ }
816
+
817
+ .checkbox-icon.icon-tablet {
818
+ background: url('images/icons.png') -20px -20px;
819
+ }
820
+
821
+ .checkbox-icon.icon-tablet.on {
822
+ background: url('images/icons.png') -20px 0;
823
+ }
824
+
825
+ .checkbox-icon.icon-php {
826
+ background: url('images/icons.png') 0 -20px;
827
+ }
828
+
829
+ .checkbox-icon.icon-php.on {
830
+ background: url('images/icons.png') 0 0;
831
+ }
832
+
833
+ .checkbox-icon.icon-enabled {
834
+ background: url('images/icons.png') -100px -20px;
835
+ }
836
+
837
+ .checkbox-icon.icon-enabled.on {
838
+ background: url('images/icons.png') -100px 0;
839
+ }
840
+
841
+ .checkbox-icon.icon-export-import {
842
+ background: url('images/icons.png') -80px -20px;
843
+ }
844
+
845
+ .checkbox-icon.icon-export-import.on {
846
+ background: url('images/icons.png') -80px 0;
847
+ }
848
+
849
+ .checkbox-icon.icon-statistics {
850
+ background: url('images/icons.png') -60px -20px;
851
+ }
852
+
853
+ .checkbox-icon.icon-statistics.on {
854
+ background: url('images/icons.png') -60px 0;
855
+ }
856
+
857
+ .checkbox-icon.icon-adb {
858
+ background: url('images/icons.png') -120px -20px;
859
+ }
860
+
861
+ .checkbox-icon.icon-adb.on {
862
+ background: url('images/icons.png') -120px 0;
863
+ }
864
+
865
+ .checkbox-icon.icon-code {
866
+ background: url('images/icons.png') 0 -80px;
867
+ }
868
+
869
+ .checkbox-icon.icon-code.on {
870
+ background: url('images/icons.png') 0 -60px;
871
+ }
872
+
873
+ .checkbox-icon.icon-rotation {
874
+ background: url('images/icons.png') -20px -80px;
875
+ }
876
+
877
+ .checkbox-icon.icon-rotation.on {
878
+ background: url('images/icons.png') -20px -60px;
879
+ }
880
+
881
+ .checkbox-icon.icon-rotation.active {
882
+ background: url('images/icons.png') -100px -40px;
883
+ }
884
+
885
+ .checkbox-icon.icon-generate {
886
+ background: url('images/icons.png') -40px -80px;
887
+ }
888
+
889
+ .checkbox-icon.icon-generate.on {
890
+ background: url('images/icons.png') -40px -60px;
891
+ }
892
+
893
+ .checkbox-icon.icon-import {
894
+ background: url('images/icons.png') -60px -80px;
895
+ }
896
+
897
+ .checkbox-icon.icon-import.on {
898
+ background: url('images/icons.png') -60px -60px;
899
+ }
900
+
901
+ .checkbox-icon.icon-edit {
902
+ background: url('images/icons.png') -80px -40px;
903
+ }
904
+
905
+ .checkbox-icon.icon-minus {
906
+ background: url('images/icons.png') -80px -80px;
907
+ }
908
+
909
+ .checkbox-icon.icon-plus {
910
+ background: url('images/icons.png') -80px -60px;
911
+ }
912
+
913
+ .checkbox-icon.icon-tools {
914
+ background: url('images/icons.png') -100px -80px;
915
+ }
916
+
917
+ .checkbox-icon.icon-tools.on {
918
+ background: url('images/icons.png') -100px -60px;
919
+ }
920
+
921
+ .checkbox-icon.icon-copy {
922
+ background: url('images/icons.png') -120px -80px;
923
+ }
924
+
925
+ .checkbox-icon.icon-copy.on {
926
+ background: url('images/icons.png') -120px -60px;
927
+ }
928
+
929
+ .checkbox-icon.icon-paste {
930
+ background: url('images/icons.png') -120px -40px;
931
+ }
932
+
933
+ .checkbox-icon.icon-paste-name {
934
+ background: url('images/icons.png') -180px -40px;
935
+ }
936
+
937
+ .checkbox-icon.icon-paste-code {
938
+ background: url('images/icons.png') -160px -40px;
939
+ }
940
+
941
+ .checkbox-icon.icon-paste-settings {
942
+ background: url('images/icons.png') -140px -40px;
943
+ }
944
+
945
+ .checkbox-icon.icon-clear {
946
+ background: url('images/icons.png') -160px -80px;
947
+ }
948
+
949
+ .checkbox-icon.icon-enabled-all {
950
+ background: url('images/icons.png') -142px -22px;
951
+ }
952
+
953
+ .checkbox-icon.icon-enabled-all.on {
954
+ background: url('images/icons.png') -142px -2px;
955
+ }
956
+
957
+
958
+ .checkbox-icon.icon-rearrange {
959
+ background: url('images/icons.png') -140px -80px;
960
+ }
961
+
962
+ .checkbox-icon.icon-rearrange.on {
963
+ background: url('images/icons.png') -140px -60px;
964
+ }
965
+
966
+ .checkbox-icon.icon-loading {
967
+ background: url('images/icons.png') -163px -23px;
968
+ }
969
+
970
+ .checkbox-icon.icon-loading.on {
971
+ background: url('images/icons.png') -163px -3px;
972
+ }
973
+
974
+ .checkbox-icon.icon-reload {
975
+ background: url('images/icons.png') -161px -22px;
976
+ }
977
+
978
+ .checkbox-icon.icon-reload.on {
979
+ background: url('images/icons.png') -161px -2px;
980
+ }
981
+
982
+ .checkbox-icon.icon-auto-refresh {
983
+ background: url('images/icons.png') -180px -20px;
984
+ }
985
+
986
+ .checkbox-icon.icon-auto-refresh.on {
987
+ background: url('images/icons.png') -180px 0;
988
+ }
989
+
990
+ /*.checkbox-icon.icon-ad-label {*/
991
+ /* background: url('images/icons.png') -180px -80px;*/
992
+ /*}*/
993
+
994
+ /*.checkbox-icon.icon-ad-label.on {*/
995
+ /* background: url('images/icons.png') -180px -60px;*/
996
+ /*}*/
997
+
998
+
999
+ .checkbox-icon.size-8.icon-stop {
1000
+ background: #ddd;
1001
+ }
1002
+
1003
+ .checkbox-icon.size-8.icon-preview {
1004
+ width: 0;
1005
+ height: 0;
1006
+ margin-left: 1px;
1007
+ border-top: 4px solid transparent;
1008
+ border-bottom: 4px solid transparent;
1009
+ border-left: 7px solid #bbb;
1010
+ }
1011
+
1012
+ .checkbox-icon.size-8.icon-get {
1013
+ width: 0;
1014
+ height: 0;
1015
+ border-left: 4px solid transparent;
1016
+ border-right: 4px solid transparent;
1017
+ border-top: 8px solid #888;
1018
+ }
1019
+
1020
+ .icon-adsense {
1021
+ background: url('../images/ga-logo.png') 0px 0px;
1022
+ background-size: cover;
1023
+ }
1024
+
1025
+ .ai-button .ui-button-text.ai-button-active {
1026
+ background: #f44;
1027
+ border: 1px solid #f44;
1028
+ border-radius: 8px;
1029
+ width: 5px;
1030
+ height: 5px;
1031
+ padding: 0;
1032
+ margin: 1px 0px 1px 3px;
1033
+ }
1034
+
1035
+ .banner-preview {
1036
+ float: left;
1037
+ margin: 0 10px 0 0;
1038
+ }
1039
+
1040
+ .banner-preview img {
1041
+ max-width: 100px;
1042
+ max-height: 160px;
1043
+ }
1044
+
1045
+ .ai-banner-top .banner-preview img {
1046
+ max-width: 718px;
1047
+ max-height: 100px;
1048
+ }
1049
+
1050
+ .ai-banner-top table {
1051
+ float: right;
1052
+ }
1053
+
1054
+ #ai-sidebar .notice-dismiss {
1055
+ position: absolute;
1056
+ top: 0;
1057
+ right: 1px;
1058
+ border: none;
1059
+ margin: 0;
1060
+ padding: 9px;
1061
+ background: 0 0;
1062
+ color: #72777c;
1063
+ cursor: pointer;
1064
+ }
1065
+
1066
+ #ai-sidebar .notice-dismiss:focus {
1067
+ outline: 0;
1068
+ -webkit-box-shadow: none;
1069
+ box-shadow: none;
1070
+ }
1071
+
1072
+ #ai-sidebar .notice-dismiss.ui-state-active, #ai-sidebar .notice-dismiss.ui-widget-content .ui-state-active, #ai-sidebar .notice-dismiss.ui-widget-header .ui-state-active {
1073
+ background: 0 0!important;
1074
+ }
1075
+
1076
+ .ai-form .ai-dot {
1077
+ font-size: 18px!important;
1078
+ line-height: 16px;
1079
+ }
1080
+
1081
+ .ad-size .scombobox {
1082
+ width: 80px;
1083
+ display: inline-block;
1084
+ margin: 1px 0;
1085
+ }
1086
+
1087
+ .scombobox-list p:hover, .scombobox-list p.scombobox-hovered {
1088
+ background-color: #eaeaea;
1089
+ }
1090
+
1091
+ .scombobox-list p {
1092
+ padding: 1px;
1093
+ }
1094
+
1095
+ .scombobox-display {
1096
+ padding-right: 1px;
1097
+ }
1098
+
1099
+ @media (max-width: 782px) {
1100
+ .auto-fold #wpcontent {
1101
+ padding-left: 4px;
1102
+ }
1103
+ #wpwrap {
1104
+ width: 762px;
1105
+ }
1106
+
1107
+ .ai-toolbar-button.small {
1108
+ width: 20px;
1109
+ height: 20px;
1110
+ margin-right: 10px;
1111
+ }
1112
+
1113
+ .ai-toolbar-button.small .checkbox-icon {
1114
+ margin: 4px 0px 0 4px;
1115
+ }
1116
+
1117
+ .checkbox-icon.size-16 {
1118
+ width: 20px;
1119
+ height: 20px;
1120
+ }
1121
+
1122
+ .checkbox-icon.size-img16 {
1123
+ width: 24px;
1124
+ height:24px;
1125
+ background-size: 24px 24px;
1126
+ }
1127
+
1128
+ .ai-toolbar-button.small .checkbox-icon.size-img16 {
1129
+ margin: 0;
1130
+ }
1131
+
1132
+ .checkbox-icon.size-16w {
1133
+ width: 20px;
1134
+ height: 20px;
1135
+ }
1136
+
1137
+ .list-button.lb-size-16 {
1138
+ margin: 6px 0 0 4px;
1139
+ padding: 0px 4px 2px 0px;
1140
+ }
1141
+
1142
+ .ad-size .scombobox {
1143
+ width: 100px;
1144
+ }
1145
+
1146
+ .scombobox-list p {
1147
+ font-size: 16px;
1148
+ }
1149
+ }
1150
+
1151
+ @media(max-width: 768px) {
1152
+ .text .checkbox-button {
1153
+ padding: 2px 5px 2px 4px;
1154
+ }
1155
+ .ai-settings-table tr {
1156
+ height: 40px;
1157
+ }
1158
+ .ai-settings-table input[type=text] {
1159
+ height: 30px;
1160
+ }
1161
+ .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
1162
+ font-family: sans-serif,Arial,Verdana;
1163
+ font-size: 16px;
1164
+ }
1165
+ div.custom-range-controls {
1166
+ width: 720px;
1167
+ }
1168
+ input.ai-date-input {
1169
+ width: 90px;
1170
+ padding: 3px 3px;
1171
+ }
1172
+ .ai-form .ai-dot {
1173
+ font-size: 12px!important;
1174
+ line-height: 18px;
1175
+ }
1176
+
1177
+ .banner-preview img {
1178
+ max-width: 160px;
1179
+ max-height: 160px;
1180
+ }
1181
+
1182
+ .ai-settings-table.left {
1183
+ width: 60%
1184
+ }
1185
+
1186
+ .ai-settings-table.right {
1187
+ width: 40%
1188
+ }
1189
+ }
1190
+
1191
+ @media(min-width: 769px) {
1192
+ #ai-form select {
1193
+ line-height: 22px;
1194
+ height: 22px;
1195
+ }
1196
+ }
1197
+
1198
+ @media (min-width: 783px) and (max-width: 828px) {
1199
+ .auto-fold #wpcontent, .auto-fold #wpfooter {
1200
+ margin-left: 20px;
1201
+ }
1202
+ }
1203
+
1204
+ @media screen and (max-width: 782px){
1205
+ #wpbody .small-select select {
1206
+ height: 32px;
1207
+ font-size: 14px;
1208
+ }
1209
+
1210
+ #wpbody span.small-input-tags {
1211
+ width: 22%;
1212
+ }
1213
+ }
1214
+
1215
+
1216
+
includes/ace/mode-ai-html.js CHANGED
@@ -35,7 +35,7 @@ function add_ai_highlighting_rules (highlighter, highlight_rules) {
35
  highlighter.$ai_shortcodes = highlighter.$lang.arrayToMap ("adinserter".split ("|"));
36
  highlighter.$ai_separators1 = highlighter.$lang.arrayToMap ("http|rotate|count".split ("|"));
37
  highlighter.$ai_separators2 = highlighter.$lang.arrayToMap ("amp".split ("|"));
38
- highlighter.$ai_attributes = highlighter.$lang.arrayToMap ("block|name|ignore|check|debugger|adb|css|text|selectors|custom-field|data".split ("|"));
39
 
40
  //WP shortcodes
41
  highlighter.$rules ['start'].unshift (
35
  highlighter.$ai_shortcodes = highlighter.$lang.arrayToMap ("adinserter".split ("|"));
36
  highlighter.$ai_separators1 = highlighter.$lang.arrayToMap ("http|rotate|count".split ("|"));
37
  highlighter.$ai_separators2 = highlighter.$lang.arrayToMap ("amp".split ("|"));
38
+ highlighter.$ai_attributes = highlighter.$lang.arrayToMap ("block|code|name|ignore|check|debugger|adb|css|text|selectors|custom-field|data|share|time".split ("|"));
39
 
40
  //WP shortcodes
41
  highlighter.$rules ['start'].unshift (
includes/editor.php CHANGED
@@ -27,8 +27,13 @@ function generate_code_editor ($block, $client_code, $process_php) {
27
 
28
  $ai_wp_data [AI_WP_DEBUGGING] = 0;
29
 
30
- $obj = $block_object [$block];
31
- $code = $obj->ai_getCode ($client_code, $process_php);
 
 
 
 
 
32
 
33
  wp_enqueue_script ('ai-adb-js', plugins_url ('includes/js/ad-inserter-check.js', AD_INSERTER_FILE), array (
34
  'jquery',
27
 
28
  $ai_wp_data [AI_WP_DEBUGGING] = 0;
29
 
30
+ $obj = new ai_Block ($block);
31
+ $obj->wp_options = $block_object [$block]->wp_options;
32
+
33
+ $obj->wp_options [AI_OPTION_CODE] = $client_code;
34
+ $obj->wp_options [AI_OPTION_PROCESS_PHP] = $process_php;
35
+
36
+ $code = $obj->ai_getCode ();
37
 
38
  wp_enqueue_script ('ai-adb-js', plugins_url ('includes/js/ad-inserter-check.js', AD_INSERTER_FILE), array (
39
  'jquery',
includes/js/ai-rotate.js CHANGED
@@ -1,11 +1,21 @@
1
  jQuery (function ($) {
2
  $("div.ai-rotate").each (function () {
3
  var rotate_options = $(".ai-rotate-option", this);
4
- var random_index = Math.floor (Math.random () * rotate_options.length);
5
 
6
- var d = new Date();
7
- var n = d.getMilliseconds();
8
- if (n % 2) random_index = rotate_options.length - random_index - 1;
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  rotate_options.hide ();
11
  var option = $(rotate_options [random_index]);
1
  jQuery (function ($) {
2
  $("div.ai-rotate").each (function () {
3
  var rotate_options = $(".ai-rotate-option", this);
 
4
 
5
+ var thresholds_data = $(this).data ('shares');
6
+ if (typeof thresholds_data === 'string') {
7
+ var thresholds = JSON.parse (atob (thresholds_data));
8
+ var random_threshold = Math.round (Math.random () * 100);
9
+ for (var index = 0; index < thresholds.length; index ++) {
10
+ var random_index = index;
11
+ if (random_threshold <= thresholds [index]) break;
12
+ }
13
+ } else {
14
+ var random_index = Math.floor (Math.random () * rotate_options.length);
15
+ var d = new Date();
16
+ var n = d.getMilliseconds();
17
+ if (n % 2) random_index = rotate_options.length - random_index - 1;
18
+ }
19
 
20
  rotate_options.hide ();
21
  var option = $(rotate_options [random_index]);
includes/js/ai-rotate.min.js CHANGED
@@ -1,4 +1,5 @@
1
- jQuery(function($){$("div.ai-rotate").each(function(){var rotate_options=$(".ai-rotate-option",this);var random_index=Math.floor(Math.random()*rotate_options.length);var d=new Date;var n=d.getMilliseconds();if(n%2)random_index=rotate_options.length-random_index-1;rotate_options.hide();var option=$(rotate_options[random_index]);option.css({"display":"","visibility":"","position":"","width":"","height":"","top":"","left":""}).removeClass("ai-rotate-option").removeClass("ai-rotate-options");$(this).css({"position":""}).removeClass("ai-rotate");
2
- var option_name="";var debug_block_frame=$(this).closest(".ai-debug-block");if(typeof debug_block_frame!="undefined"){var option_name=atob(option.data("name"));var name_tag=debug_block_frame.find("kbd.ai-option-name");var nested_debug_block=debug_block_frame.find(".ai-debug-block");if(typeof nested_debug_block!="undefined"){var name_tag2=nested_debug_block.find("kbd.ai-option-name");name_tag=name_tag.slice(0,name_tag.length-name_tag2.length)}if(typeof name_tag!="undefined"){var separator=name_tag.first().data("separator");
3
- if(typeof separator=="undefined")separator="";name_tag.html(separator+option_name)}}var tracking_updated=false;var adb_show_wrapping_div=$(this).closest(".ai-adb-show");if(typeof adb_show_wrapping_div!="undefined")if(typeof adb_show_wrapping_div.data("ai-tracking")!="undefined"){var data=JSON.parse(atob(adb_show_wrapping_div.data("ai-tracking")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;data[3]=option_name;adb_show_wrapping_div.data("ai-tracking",btoa(JSON.stringify(data)));
4
- tracking_updated=true}}if(!tracking_updated){var wrapping_div=$(this).closest("div[data-ai]");if(typeof wrapping_div.data("ai")!="undefined"){var data=JSON.parse(atob(wrapping_div.data("ai")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;data[3]=option_name;wrapping_div.data("ai",btoa(JSON.stringify(data)))}}}})});
 
1
+ jQuery(function($){$("div.ai-rotate").each(function(){var rotate_options=$(".ai-rotate-option",this);var thresholds_data=$(this).data("shares");if(typeof thresholds_data==="string"){var thresholds=JSON.parse(atob(thresholds_data));var random_threshold=Math.round(Math.random()*100);for(var index=0;index<thresholds.length;index++){var random_index=index;if(random_threshold<=thresholds[index])break}}else{var random_index=Math.floor(Math.random()*rotate_options.length);var d=new Date;var n=d.getMilliseconds();
2
+ if(n%2)random_index=rotate_options.length-random_index-1}rotate_options.hide();var option=$(rotate_options[random_index]);option.css({"display":"","visibility":"","position":"","width":"","height":"","top":"","left":""}).removeClass("ai-rotate-option").removeClass("ai-rotate-options");$(this).css({"position":""}).removeClass("ai-rotate");var option_name="";var debug_block_frame=$(this).closest(".ai-debug-block");if(typeof debug_block_frame!="undefined"){var option_name=atob(option.data("name"));var name_tag=
3
+ debug_block_frame.find("kbd.ai-option-name");var nested_debug_block=debug_block_frame.find(".ai-debug-block");if(typeof nested_debug_block!="undefined"){var name_tag2=nested_debug_block.find("kbd.ai-option-name");name_tag=name_tag.slice(0,name_tag.length-name_tag2.length)}if(typeof name_tag!="undefined"){var separator=name_tag.first().data("separator");if(typeof separator=="undefined")separator="";name_tag.html(separator+option_name)}}var tracking_updated=false;var adb_show_wrapping_div=$(this).closest(".ai-adb-show");
4
+ if(typeof adb_show_wrapping_div!="undefined")if(typeof adb_show_wrapping_div.data("ai-tracking")!="undefined"){var data=JSON.parse(atob(adb_show_wrapping_div.data("ai-tracking")));if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;data[3]=option_name;adb_show_wrapping_div.data("ai-tracking",btoa(JSON.stringify(data)));tracking_updated=true}}if(!tracking_updated){var wrapping_div=$(this).closest("div[data-ai]");if(typeof wrapping_div.data("ai")!="undefined"){var data=JSON.parse(atob(wrapping_div.data("ai")));
5
+ if(typeof data!=="undefined"&&data.constructor===Array){data[1]=random_index+1;data[3]=option_name;wrapping_div.data("ai",btoa(JSON.stringify(data)))}}}})});
includes/preview-adb.php CHANGED
@@ -25,14 +25,18 @@ function ai_mce_buttons_2 ($buttons, $id) {
25
  return $buttons;
26
  }
27
 
28
- function generate_code_preview_adb ($client_code = null, $process_php = null) {
29
  global $block_object, $ai_wp_data;
30
 
31
  $ai_wp_data [AI_WP_DEBUGGING] = 0;
32
 
33
- $obj = $block_object [AI_ADB_MESSAGE_OPTION_NAME];
34
- // $adb_message = $obj->get_ad_data();
35
- $adb_message = $obj->ai_getCode ($client_code, $process_php);
 
 
 
 
36
 
37
  wp_enqueue_script ('ai-adb-js', plugins_url ('includes/js/ad-inserter-check.js', AD_INSERTER_FILE), array (
38
  'jquery',
25
  return $buttons;
26
  }
27
 
28
+ function generate_code_preview_adb ($client_code, $process_php) {
29
  global $block_object, $ai_wp_data;
30
 
31
  $ai_wp_data [AI_WP_DEBUGGING] = 0;
32
 
33
+ $obj = new ai_Block ($block);
34
+ $obj->wp_options = $block_object [AI_ADB_MESSAGE_OPTION_NAME]->wp_options;
35
+
36
+ $obj->wp_options [AI_OPTION_CODE] = $client_code;
37
+ $obj->wp_options [AI_OPTION_PROCESS_PHP] = $process_php;
38
+
39
+ $adb_message = $obj->ai_getCode ();
40
 
41
  wp_enqueue_script ('ai-adb-js', plugins_url ('includes/js/ad-inserter-check.js', AD_INSERTER_FILE), array (
42
  'jquery',
includes/preview.php CHANGED
@@ -1,1660 +1,2144 @@
1
- <?php
2
-
3
- //ini_set ('display_errors', 1);
4
- //error_reporting (E_ALL);
5
-
6
- function alt_styles_data ($alt_styles_text) {
7
- if (strpos ($alt_styles_text, "||") !== false) {
8
- $styles = explode ("||", $alt_styles_text);
9
- $alt_styles = array ();
10
- foreach ($styles as $index => $style) {
11
- $alt_styles ['css' . ($index + 1)] = str_replace ("'", '"', str_replace (array ("\"", "<", ">", "[", "]"), "", trim ($style)));
12
- }
13
- echo "data-alt-style='1' data-alt-styles='", json_encode ($alt_styles), "'";
14
- }
15
- }
16
-
17
- function padding_margin_code ($close_button, $class, $wrapper_css, $block_code) {
18
- ?>
19
- <div id='padding-background'></div>
20
- <div id='margin-background'></div>
21
- <div id='padding-background-white'></div>
22
- <div id='wrapper'<?php echo $class; ?> style='<?php echo $wrapper_css;
23
- ?>'>
24
- <span class='ai-close-button ai-close-hidden' style='display: none'></span>
25
- <?php echo $block_code; ?>
26
- </div>
27
- <!-- IE bug: use inline CSS: position: absolute;-->
28
- <div id='code-background-white' class= "code-background-white" style="position: absolute;"></div>
29
- <div id='code-overlay' class="code-overlay" style="position: absolute;"></div>
30
- <div id='ad-info-overlay'></div>
31
-
32
- <?php
33
- }
34
-
35
-
36
- function generate_code_preview (
37
- $block, $name = null,
38
- $alignment = null,
39
- $horizontal = null,
40
- $vertical = null,
41
- $alignment_css = null,
42
- $custom_css = null,
43
- $client_code = null,
44
- $process_php = null,
45
- $show_label = null,
46
- $close = null,
47
- $read_only = false) {
48
-
49
- global $block_object, $ai_wp_data;
50
-
51
- $ai_wp_data [AI_WP_DEBUGGING] = 0;
52
-
53
- $obj = $block_object [$block];
54
-
55
- $block_name = $name !== null ? $name : $obj->get_ad_name();
56
- $alignment_type = $alignment !== null ? $alignment : $obj->get_alignment_type();
57
- $horizontal_position = $horizontal !== null ? $horizontal : $obj->get_horizontal_position();
58
- $vertical_position = $vertical !== null ? $vertical : $obj->get_vertical_position();
59
- $wrapper_css = $alignment_css !== null ? $alignment_css : $obj->get_alignment_style ();
60
- $custom_css_code = $custom_css !== null ? $custom_css : $obj->get_custom_css();
61
- $close_button = $close !== null ? $close : $obj->get_close_button ();
62
-
63
- $sticky = false;
64
-
65
- switch ($alignment_type) {
66
- case AI_ALIGNMENT_STICKY:
67
- $sticky = true;
68
- break;
69
- case AI_ALIGNMENT_CUSTOM_CSS:
70
- $custom_css = str_replace (' ', '', $custom_css_code);
71
- if (strpos ($custom_css, 'position:fixed') !== false &&
72
- strpos ($custom_css, 'z-index:' . AI_STICKY_Z_INDEX) !== false) {
73
- $sticky = true;
74
- }
75
- break;
76
- }
77
-
78
- $classes = array ();
79
-
80
- $stick_to_the_content_class = $obj->stick_to_the_content_class ();
81
-
82
- if ($stick_to_the_content_class != '') {
83
- $sticky = true;
84
- $classes [] = 'ai-sticky-content';
85
- $classes [] = $stick_to_the_content_class;
86
- }
87
-
88
- // For non-sticky preview show close button only if enabled in block settings
89
- if ($sticky || $close_button != AI_CLOSE_NONE) {
90
- $classes [] = 'ai-close';
91
- }
92
-
93
- if (count ($classes) != 0) {
94
- $class = " class='" . trim (implode (' ', $classes)) . "'";
95
- } else $class = "";
96
-
97
- // Head code must be called before ai_getProcessedCode (to process head PHP)
98
- ob_start ();
99
- ai_wp_head_hook ();
100
- $head_code = ob_get_clean ();
101
-
102
- // Disable AdSense Auto ads (page level ads)
103
- $head_code = str_replace ('enable_page_level_ads', 'disabled_page_level_ads', $head_code);
104
-
105
- $block_code = $obj->ai_getProcessedCode (true, true, $client_code, $process_php, $show_label);
106
-
107
- // Fix for relative urls
108
- $block_code = str_replace ('src="wp-content', 'src="../wp-content', $block_code);
109
- $block_code = str_replace ("src='wp-content", "src='../wp-content", $block_code);
110
- $block_code = str_replace ('href="wp-content', 'href="../wp-content', $block_code);
111
- $block_code = str_replace ("href='wp-content", "href='../wp-content", $block_code);
112
-
113
- ?><html>
114
- <head>
115
- <title><?php echo AD_INSERTER_NAME; ?> <?php if ($sticky) echo 'Sticky '; ?>Code Preview</title>
116
- <meta name="viewport" content="width=device-width,initial-scale=1.0">
117
- <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
118
- <script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'></script>
119
- <link rel='stylesheet' href='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'>
120
- <script src='<?php echo plugins_url ('includes/js/jquery.mousewheel.min.js', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
121
- <script src='<?php echo plugins_url ('includes/js/jquery.ui.spinner.js', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
122
- <link rel='stylesheet' href='<?php echo plugins_url ('css/jquery.ui.spinner.css', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
123
- <link rel='stylesheet' href='<?php echo plugins_url ('css/image-picker.css', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
124
- <script src='<?php echo plugins_url ('includes/js/image-picker.js', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
125
- <script src='<?php echo plugins_url ('includes/js/ad-inserter-check.js', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
126
- <link rel='stylesheet' href='<?php echo plugins_url ('css/ad-inserter.css', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
127
- <script>
128
-
129
- // initialize_preview ();
130
- ajaxurl = "<?php echo admin_url ('admin-ajax.php'); ?>";
131
- var ai_preview = true;
132
- <?php echo get_frontend_javascript_debugging () ? 'ai_debugging = true;' : ''; ?>
133
- var sticky = <?php echo $sticky ? 'true' : 'false'; ?>;
134
- if (sticky) window.resizeTo (screen.width, screen.height);
135
-
136
- window.onkeydown = function( event ) {
137
- if (event.keyCode === 27 ) {
138
- window.close();
139
- }
140
- }
141
-
142
- function initialize_preview () {
143
-
144
- // var debug = <?php echo get_backend_javascript_debugging () ? 'true' : 'false'; ?>;
145
- var debug = typeof ai_debugging !== 'undefined';
146
- var block = <?php echo $block; ?>;
147
- var code_blocks;
148
- var spinning = false;
149
-
150
- var wrapper = $('#wrapper');
151
- var wrapping = $("#wrapper").attr ("style") != "";
152
-
153
- var spinner_margin_top;
154
- var spinner_margin_bottom;
155
- var spinner_margin_left;
156
- var spinner_margin_right;
157
- var spinner_padding_top;
158
- var spinner_padding_bottom;
159
- var spinner_padding_left;
160
- var spinner_padding_right;
161
-
162
- var AI_ALIGNMENT_DEFAULT = 0;
163
- var AI_ALIGNMENT_LEFT = 1;
164
- var AI_ALIGNMENT_RIGHT = 2;
165
- var AI_ALIGNMENT_CENTER = 3;
166
- var AI_ALIGNMENT_FLOAT_LEFT = 4;
167
- var AI_ALIGNMENT_FLOAT_RIGHT = 5;
168
- var AI_ALIGNMENT_NO_WRAPPING = 6;
169
- var AI_ALIGNMENT_CUSTOM_CSS = 7;
170
- var AI_ALIGNMENT_STICKY_LEFT = 8;
171
- var AI_ALIGNMENT_STICKY_RIGHT = 9;
172
- var AI_ALIGNMENT_STICKY_TOP = 10;
173
- var AI_ALIGNMENT_STICKY_BOTTOM = 11;
174
- var AI_ALIGNMENT_STICKY = 12;
175
-
176
- var AI_CLOSE_NONE = 0;
177
- var AI_CLOSE_TOP_RIGHT = 1;
178
- var AI_CLOSE_TOP_LEFT = 2;
179
- var AI_CLOSE_BOTTOM_RIGHT = 3;
180
- var AI_CLOSE_BOTTOM_LEFT = 4;
181
-
182
- var AI_STICK_TO_THE_LEFT = 0;
183
- var AI_STICK_TO_THE_CONTENT_LEFT = 1;
184
- var AI_STICK_HORIZONTAL_CENTER = 2;
185
- var AI_STICK_TO_THE_CONTENT_RIGHT = 3;
186
- var AI_STICK_TO_THE_RIGHT = 4;
187
-
188
- var AI_STICK_TO_THE_TOP = 0;
189
- var AI_STICK_VERTICAL_CENTER = 1;
190
- var AI_SCROLL_WITH_THE_CONTENT = 2;
191
- var AI_STICK_TO_THE_BOTTOM = 3;
192
-
193
- var STICKY_CONTEXT_NONE = 0;
194
- var STICKY_CONTEXT_INIT = 1;
195
- var STICKY_CONTEXT_BLOCK_ALIGNMENT = 2;
196
- var STICKY_CONTEXT_HORIZONTAL_POSITION = 3;
197
- var STICKY_CONTEXT_VERTICAL_POSITION = 4;
198
- var STICKY_CONTEXT_CUSTOM_CSS = 5;
199
-
200
- var sticky_context = STICKY_CONTEXT_INIT;
201
-
202
- var id_css_alignment_default = "#css-" + AI_ALIGNMENT_DEFAULT;
203
- var id_css_alignment_left = "#css-" + AI_ALIGNMENT_LEFT;
204
- var id_css_alignment_right = "#css-" + AI_ALIGNMENT_RIGHT;
205
- var id_css_alignment_center = "#css-" + AI_ALIGNMENT_CENTER;
206
- var id_css_alignment_float_left = "#css-" + AI_ALIGNMENT_FLOAT_LEFT;
207
- var id_css_alignment_float_right = "#css-" + AI_ALIGNMENT_FLOAT_RIGHT;
208
- var id_css_alignment_sticky_left = "#css-" + AI_ALIGNMENT_STICKY_LEFT;
209
- var id_css_alignment_sticky_right = "#css-" + AI_ALIGNMENT_STICKY_RIGHT;
210
- var id_css_alignment_sticky_top = "#css-" + AI_ALIGNMENT_STICKY_TOP;
211
- var id_css_alignment_sticky_bottom = "#css-" + AI_ALIGNMENT_STICKY_BOTTOM;
212
- var id_css_alignment_sticky = "#css-" + AI_ALIGNMENT_STICKY;
213
-
214
- function update_highlighting () {
215
- if ($('body').hasClass ("highlighted")) {
216
- $("#highlight-button").click ();
217
- $("#highlight-button").click ();
218
- }
219
- }
220
-
221
- function update_width () {
222
- $("#screen-width").text (window.innerWidth + " px");
223
- if (window.innerWidth != $(window).width()) $("#right-arrow").hide (); else $("#right-arrow").show ();
224
- }
225
-
226
- function update_wrapper_size () {
227
- if (typeof wrapper.width () != 'undefined' && typeof wrapper.height () != 'undefined') {
228
- var width = parseInt (wrapper.width ());
229
- var height = parseInt (wrapper.height ());
230
- $(".wrapper-size").html (width + "px &nbsp;&times;&nbsp; " + height + "px").show ();
231
- if (width * height != 0) $(".wrapper-size").css ("color", "#333"); else $(".wrapper-size").css ("color", "#c00");
232
- }
233
- }
234
-
235
- $(window).resize(function() {
236
- update_highlighting ();
237
- update_width ();
238
- update_wrapper_size ();
239
- });
240
-
241
- function load_from_settings () {
242
-
243
- if (window.opener != null && !window.opener.closed) {
244
- var settings = $(window.opener.document).contents();
245
-
246
-
247
- // // Replace document.write for old code that uses document.write
248
- // // Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
249
- // var oldDocumentWrite = document.write;
250
- // document.write = function(node){
251
- // $("#wrapper").append (node)
252
- // }
253
-
254
- // var simple_editor_switch = settings.find ('input#simple-editor-' + block);
255
- // if (!simple_editor_switch.is(":checked")) {
256
- // settings.find ('input#simple-editor-' + block).click ();
257
- // settings.find ('input#simple-editor-' + block).click ();
258
- // }
259
- // var code = settings.find ("#block-" + block).val();
260
- // wrapper.html (code);
261
-
262
- // // Restore document.write
263
- // setTimeout (function() {
264
- // document.write = oldDocumentWrite
265
- // }, 1000);
266
-
267
- // console.log (settings.find ("select#block-alignment-" + block + " option:selected").attr('value'));
268
-
269
- $("select#block-alignment").val (settings.find ("select#block-alignment-" + block + " option:selected").attr('value')).change();
270
- $("select#block-alignment option:selected").data ('alt-style', '1');
271
- $("#custom-css").val (settings.find ("#custom-css-" + block).val ());
272
- $("#block-name").text (settings.find ("#name-label-" + block).text ());
273
- $("select#close-button-0").val (settings.find ("select#close-button-" + block + " option:selected").attr('value')).change();
274
-
275
- if (sticky) {
276
- $("select#horizontal-position").val (settings.find ("select#horizontal-position-" + block + " option:selected").attr('value')).change();
277
- $("select#vertical-position").val (settings.find ("select#vertical-position-" + block + " option:selected").attr('value')).change();
278
- }
279
-
280
- process_display_elements ();
281
- }
282
- }
283
-
284
- function apply_to_settings () {
285
- if (window.opener != null && !window.opener.closed) {
286
- var settings = $(window.opener.document).contents ();
287
-
288
- var selected_alignment = $("select#block-alignment option:selected");
289
- var new_alignment = selected_alignment.attr('value');
290
- var new_custom_css = $("#custom-css").val ();
291
- var new_close_button = $("select#close-button-0 option:selected").attr('value');
292
-
293
- var alt_styles = selected_alignment.data ('alt-styles');
294
- if (typeof alt_styles != 'undefined') {
295
- css_index = selected_alignment.data ('alt-style')
296
- if (css_index != 1) {
297
- new_alignment = AI_ALIGNMENT_CUSTOM_CSS;
298
- new_custom_css = alt_styles ['css' + css_index].replace (/\"/g, "'");
299
- }
300
- }
301
-
302
- settings.find ("select#block-alignment-" + block).val (new_alignment).change ();
303
- if (new_alignment == AI_ALIGNMENT_CUSTOM_CSS) {
304
- settings.find ("#custom-css-" + block).val (new_custom_css);
305
- }
306
- settings.find ("select#close-button-" + block).val (new_close_button);
307
-
308
- if (sticky) {
309
- var new_horizontal_position = $("select#horizontal-position option:selected").attr('value');
310
- settings.find ("select#horizontal-position-" + block).val (new_horizontal_position);
311
-
312
- var new_vertical_position = $("select#vertical-position option:selected").attr('value');
313
- settings.find ("select#vertical-position-" + block).val (new_vertical_position);
314
- }
315
-
316
- window.opener.change_block_alignment (block);
317
- }
318
- }
319
-
320
- function update_focused_spinner (event) {
321
- if (spinner_margin_top.is (":focus")) spinner_margin_top.spinner( "stepUp", event.deltaY); else
322
- if (spinner_margin_bottom.is (":focus")) spinner_margin_bottom.spinner( "stepUp", event.deltaY); else
323
- if (spinner_margin_left.is (":focus")) spinner_margin_left.spinner( "stepUp", event.deltaY); else
324
- if (spinner_margin_right.is (":focus")) spinner_margin_right.spinner( "stepUp", event.deltaY); else
325
- if (spinner_padding_top.is (":focus")) spinner_padding_top.spinner( "stepUp", event.deltaY); else
326
- if (spinner_padding_bottom.is (":focus")) spinner_padding_bottom.spinner( "stepUp", event.deltaY); else
327
- if (spinner_padding_left.is (":focus")) spinner_padding_left.spinner( "stepUp", event.deltaY); else
328
- if (spinner_padding_right.is (":focus")) spinner_padding_right.spinner( "stepUp", event.deltaY);
329
- }
330
-
331
-
332
- $(window).on ('mousewheel', function (event) {
333
- if (!spinning) update_focused_spinner (event);
334
- });
335
-
336
-
337
- function create_spinner (selector, css_parameter, alignment) {
338
- var spinner_element = $(selector).spinner ({
339
- alignment: alignment,
340
- start: function (event, ui) {
341
- spinning = true;
342
- if (!$(this).is (":focus")) {
343
- update_focused_spinner (event)
344
- event.preventDefault();
345
- }
346
- },
347
- stop: function (event, ui) {
348
- spinning = false;
349
- wrapper.css (css_parameter, $(this).spinner ("value") + "px");
350
- update_custom_css ();
351
- update_highlighting ();
352
- update_wrapper_size ();
353
- }
354
- }).spinner ("option", "mouseWheel", true).spinner ("option", "min", 0).spinner ("option", "max", 600).spinner ("value", parseInt (wrapper.css (css_parameter))).show ();
355
-
356
- return spinner_element;
357
- }
358
-
359
-
360
- function process_display_elements () {
361
-
362
- // console.log ('process_display_elements');
363
-
364
- var style = "";
365
- $("#css-label").css('display', 'inline-block');
366
- $("#edit-css-button").css('display', 'inline-block');
367
-
368
- $(id_css_alignment_default).hide();
369
- $(id_css_alignment_left).hide();
370
- $("#css-" + AI_ALIGNMENT_RIGHT).hide();
371
- $("#css-" + AI_ALIGNMENT_CENTER).hide();
372
- $("#css-" + AI_ALIGNMENT_FLOAT_LEFT).hide();
373
- $("#css-" + AI_ALIGNMENT_FLOAT_RIGHT).hide();
374
- $("#css-" + AI_ALIGNMENT_STICKY_LEFT).hide();
375
- $("#css-" + AI_ALIGNMENT_STICKY_RIGHT).hide();
376
- $("#css-" + AI_ALIGNMENT_STICKY_TOP).hide();
377
- $("#css-" + AI_ALIGNMENT_STICKY_BOTTOM).hide();
378
- $("#css-" + AI_ALIGNMENT_STICKY).hide();
379
- $("#custom-css").hide();
380
- $("#css-no-wrapping").hide();
381
-
382
- $("#demo-box").show ();
383
- $("#demo-box-no-wrapping").hide ();
384
- wrapping = true;
385
-
386
- $("#css-index").text ('');
387
-
388
- var selected_alignment = $("select#block-alignment option:selected");
389
- var alignment = selected_alignment.attr ('value');
390
- var alt_styles = selected_alignment.data ('alt-styles');
391
- if (typeof alt_styles != 'undefined') {
392
- var alt_style_index = selected_alignment.data ('alt-style');
393
- var num_styles = Object.keys(alt_styles).length;
394
- if (alt_style_index > num_styles) {
395
- alt_style_index = 1;
396
- }
397
- $('#css-' + alignment).text (alt_styles ['css' + alt_style_index].replace (/\"/g, "'"));
398
- if (num_styles > 1) {
399
- $("#css-index").text (alt_style_index);
400
- }
401
- }
402
-
403
- if (alignment == AI_ALIGNMENT_DEFAULT) {
404
- $(id_css_alignment_default).css('display', 'inline-block');
405
- style = $(id_css_alignment_default).text ();
406
- } else
407
- if (alignment == AI_ALIGNMENT_LEFT) {
408
- $(id_css_alignment_left).css('display', 'inline-block');
409
- style = $(id_css_alignment_left).text ();
410
- } else
411
- if (alignment == AI_ALIGNMENT_RIGHT) {
412
- $(id_css_alignment_right).css('display', 'inline-block');
413
- style = $(id_css_alignment_right).text ();
414
- } else
415
- if (alignment == AI_ALIGNMENT_CENTER) {
416
- $(id_css_alignment_center).css('display', 'inline-block');
417
- style = $(id_css_alignment_center).text ();
418
- } else
419
- if (alignment == AI_ALIGNMENT_FLOAT_LEFT) {
420
- $(id_css_alignment_float_left).css('display', 'inline-block');
421
- style = $(id_css_alignment_float_left).text ();
422
- } else
423
- if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
424
- $(id_css_alignment_float_right).css('display', 'inline-block');
425
- style = $(id_css_alignment_float_right).text ();
426
- } else
427
- if (alignment == AI_ALIGNMENT_STICKY_LEFT) {
428
- $(id_css_alignment_sticky_left).css('display', 'inline-block');
429
- style = $(id_css_alignment_sticky_left).text ();
430
- } else
431
- if (alignment == AI_ALIGNMENT_STICKY_RIGHT) {
432
- $(id_css_alignment_sticky_right).css('display', 'inline-block');
433
- style = $(id_css_alignment_sticky_right).text ();
434
- } else
435
- if (alignment == AI_ALIGNMENT_STICKY_TOP) {
436
- $(id_css_alignment_sticky_top).css('display', 'inline-block');
437
- style = $(id_css_alignment_sticky_top).text ();
438
- } else
439
- if (alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
440
- $(id_css_alignment_sticky_bottom).css('display', 'inline-block');
441
- style = $(id_css_alignment_sticky_bottom).text ();
442
- } else
443
- if (alignment == AI_ALIGNMENT_STICKY) {
444
- $(id_css_alignment_sticky).css('display', 'inline-block');
445
- style = $(id_css_alignment_sticky).text ();
446
- } else
447
- if (alignment == AI_ALIGNMENT_CUSTOM_CSS) {
448
- // $("#alignment-editor").show();
449
- $("#custom-css").show();
450
- style = $("#custom-css").val ();
451
- } else
452
- if (alignment == AI_ALIGNMENT_NO_WRAPPING) {
453
- $("#css-no-wrapping").css('display', 'inline-block');
454
- $("#css-label").hide();
455
- $("#edit-css-button").hide();
456
-
457
- wrapping = false;
458
- style = "";
459
-
460
- $("#demo-box").hide ();
461
- $("#demo-box-no-wrapping").show ();
462
- }
463
-
464
- $("#wrapper").attr ("style", style);
465
-
466
- // console.log ('process_display_elements');
467
-
468
- if (wrapping) update_margin_padding ();
469
-
470
- update_highlighting ();
471
- update_wrapper_size ();
472
- }
473
-
474
- function update_custom_css () {
475
-
476
- // console.log ('update_custom_css');
477
-
478
- $("#custom-css").val ($("#wrapper").attr ("style"));
479
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
480
- $("#edit-css-button").click ();
481
- }
482
-
483
- function update_margin_padding () {
484
- if (wrapping) {
485
- spinner_margin_top.spinner ("value", parseInt (wrapper.css ("margin-top")));
486
- spinner_margin_bottom.spinner ("value", parseInt (wrapper.css ("margin-bottom")));
487
- spinner_margin_left.spinner ("value", parseInt (wrapper.css ("margin-left")));
488
- spinner_margin_right.spinner ("value", parseInt (wrapper.css ("margin-right")));
489
- spinner_padding_top.spinner ("value", parseInt (wrapper.css ("padding-top")));
490
- spinner_padding_bottom.spinner ("value", parseInt (wrapper.css ("padding-bottom")));
491
- spinner_padding_left.spinner ("value", parseInt (wrapper.css ("padding-left")));
492
- spinner_padding_right.spinner ("value", parseInt (wrapper.css ("padding-right")));
493
- }
494
- }
495
-
496
- function update_close_button () {
497
- var close_button = $("#wrapper").find ('.ai-close-button');
498
- if ($("#wrapper").hasClass ('ai-close') && typeof close_button != 'undefined') {
499
-
500
- var selected_alignment = $("select#block-alignment option:selected");
501
- var alignment = selected_alignment.attr ('value');
502
-
503
- if (alignment != AI_ALIGNMENT_NO_WRAPPING) {
504
- $("#close-button-selection").show ();
505
-
506
- var selected_close_button = $("#close-button-0 option:selected").attr('value');
507
- var button_class = 'ai-close-button';
508
-
509
- switch (parseInt (selected_close_button)) {
510
- case AI_CLOSE_NONE:
511
- button_class = 'ai-close-button ai-close-hidden';
512
- break;
513
- case AI_CLOSE_TOP_RIGHT:
514
- button_class = 'ai-close-button';
515
- break;
516
- case AI_CLOSE_TOP_LEFT:
517
- button_class = 'ai-close-button ai-close-left';
518
- break;
519
- case AI_CLOSE_BOTTOM_RIGHT:
520
- button_class = 'ai-close-button ai-close-bottom';
521
- break;
522
- case AI_CLOSE_BOTTOM_LEFT:
523
- button_class = 'ai-close-button ai-close-bottom ai-close-left';
524
- break;
525
- }
526
-
527
- close_button.attr ('class', button_class);
528
- } else {
529
- $("#close-button-selection").hide ();
530
- close_button.addClass ('ai-close-hidden');
531
- }
532
- }
533
- }
534
-
535
- function update_sticky_css (context) {
536
-
537
- // console.log ('update_sticky_css', context, 'sticky_context', sticky_context);
538
-
539
- if (sticky_context != context) return;
540
-
541
-
542
- var horizontal_position = $("select#horizontal-position option:selected").attr('value');
543
- var selected_horizontal_position = $("select#horizontal-position option:selected");
544
-
545
- var vertical_position = $("select#vertical-position option:selected").attr('value');
546
- var selected_vertical_position = $("select#vertical-position option:selected");
547
-
548
- var custom_vertical_position_css = selected_vertical_position.data ('css-' + horizontal_position);
549
-
550
- if (typeof custom_vertical_position_css != 'undefined') var vertical_position_css = custom_vertical_position_css; else
551
- var vertical_position_css = selected_vertical_position.data ('css');
552
-
553
- var custom_horizontal_position_css = selected_horizontal_position.data ('css-' + vertical_position);
554
-
555
- if (typeof custom_horizontal_position_css != 'undefined') var horizontal_position_css = custom_horizontal_position_css; else
556
- var horizontal_position_css = selected_horizontal_position.data ('css');
557
-
558
- $('#css-' + AI_ALIGNMENT_STICKY + ' .ai-sticky-css').text (vertical_position_css + horizontal_position_css);
559
-
560
- // console.log ('#css-' + AI_ALIGNMENT_STICKY + ' .ai-sticky-css', vertical_position_css + horizontal_position_css);
561
-
562
-
563
- $('#wrapper').removeClass ('ai-sticky-content').removeClass ('ai-sticky-left').removeClass ('ai-sticky-right').removeClass ('ai-sticky-scroll');
564
-
565
- switch (parseInt ($("select#block-alignment option:selected").attr('value'))) {
566
- case AI_ALIGNMENT_STICKY:
567
- if (horizontal_position == AI_STICK_TO_THE_CONTENT_LEFT) {
568
- $('#wrapper').addClass ('ai-sticky-content');
569
- $('#wrapper').addClass ('ai-sticky-left');
570
- } else
571
- if (horizontal_position == AI_STICK_TO_THE_CONTENT_RIGHT) {
572
- $('#wrapper').addClass ('ai-sticky-content');
573
- $('#wrapper').addClass ('ai-sticky-right');
574
- }
575
-
576
- if (vertical_position == AI_SCROLL_WITH_THE_CONTENT) {
577
- $('#wrapper').addClass ('ai-sticky-content');
578
- $('#wrapper').addClass ('ai-sticky-scroll');
579
- }
580
- break;
581
- case AI_ALIGNMENT_CUSTOM_CSS:
582
- var custom_css = $("#custom-css").val ().replace (/\s+/g, '');
583
-
584
- sticky_classes = [];
585
- if (window.opener != null && !window.opener.closed) {
586
- sticky_classes = window.opener.get_sticky_classes (custom_css);
587
- }
588
-
589
- sticky_classes.forEach(function (sticky_class) {
590
- $('#wrapper').addClass (sticky_class);
591
- });
592
- break;
593
- }
594
- }
595
-
596
- function update_sticky_elements (context) {
597
-
598
- // console.log ('update_sticky_elements', context, 'sticky_context', sticky_context);
599
-
600
- if (sticky_context != context) return;
601
-
602
- process_sticky_elements (jQuery);
603
- }
604
-
605
- var start_time = new Date().getTime();
606
-
607
- spinner_margin_top = create_spinner ("#spinner-margin-top", "margin-top", "horizontal").spinner ("option", "min", - $("#p1").outerHeight (true));
608
- spinner_margin_bottom = create_spinner ("#spinner-margin-bottom", "margin-bottom", "horizontal").spinner ("option", "min", - $("#p1").outerHeight (true));
609
- spinner_margin_left = create_spinner ("#spinner-margin-left", "margin-left", "vertical").spinner ("option", "min", - 600);
610
- spinner_margin_right = create_spinner ("#spinner-margin-right", "margin-right", "vertical").spinner ("option", "min", - 600);
611
- spinner_padding_top = create_spinner ("#spinner-padding-top", "padding-top", "horizontal");
612
- spinner_padding_bottom = create_spinner ("#spinner-padding-bottom", "padding-bottom", "horizontal");
613
- spinner_padding_left = create_spinner ("#spinner-padding-left", "padding-left", "vertical");
614
- spinner_padding_right = create_spinner ("#spinner-padding-right", "padding-right", "vertical");
615
-
616
- $("select#block-alignment").change (function() {
617
-
618
- if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_BLOCK_ALIGNMENT;
619
-
620
- // console.log ('select#block-alignment change', $("select#block-alignment option:selected").attr ('value'));
621
-
622
- if (sticky) update_sticky_css (STICKY_CONTEXT_BLOCK_ALIGNMENT);
623
-
624
- process_display_elements ();
625
- update_close_button ();
626
-
627
- // console.log ('select#block-alignment');
628
-
629
- if (sticky) update_sticky_elements (STICKY_CONTEXT_BLOCK_ALIGNMENT);
630
-
631
- if (sticky_context == STICKY_CONTEXT_BLOCK_ALIGNMENT) sticky_context = STICKY_CONTEXT_NONE;
632
- });
633
-
634
- $("select#close-button-0").change (function() {
635
- update_close_button ();
636
- update_highlighting ();
637
- });
638
-
639
- $("select#horizontal-position").change (function() {
640
- if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_HORIZONTAL_POSITION;
641
-
642
- // console.log ('select#horizontal-position change');
643
-
644
- if (sticky_context == STICKY_CONTEXT_HORIZONTAL_POSITION) $("select#block-alignment").val (AI_ALIGNMENT_STICKY).change();
645
- update_sticky_css (STICKY_CONTEXT_HORIZONTAL_POSITION);
646
- process_display_elements ();
647
- update_close_button ();
648
-
649
- // console.log ('select#horizontal-position');
650
-
651
- update_sticky_elements (STICKY_CONTEXT_HORIZONTAL_POSITION);
652
- update_highlighting ();
653
-
654
- if (sticky_context == STICKY_CONTEXT_HORIZONTAL_POSITION) sticky_context = STICKY_CONTEXT_NONE;
655
- });
656
-
657
- $("select#vertical-position").change (function() {
658
- if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_VERTICAL_POSITION;
659
-
660
- // console.log ('select#vertical-position change');
661
-
662
- if (sticky_context == STICKY_CONTEXT_VERTICAL_POSITION) $("select#block-alignment").val (AI_ALIGNMENT_STICKY).change();
663
- update_sticky_css (STICKY_CONTEXT_VERTICAL_POSITION);
664
- process_display_elements ();
665
- update_close_button ();
666
-
667
- // console.log ('select#vertical-position');
668
-
669
- update_sticky_elements (STICKY_CONTEXT_VERTICAL_POSITION);
670
- update_highlighting ();
671
-
672
- if (sticky_context == STICKY_CONTEXT_VERTICAL_POSITION) sticky_context = STICKY_CONTEXT_NONE;
673
- });
674
-
675
-
676
- $('.ai-close-button').click (function () {
677
- if ($('body').hasClass ("highlighted")) {
678
- setTimeout (function () {
679
- $("#highlight-button").click ();
680
- $("#highlight-button").click ();
681
- }, 10);
682
- }
683
- });
684
-
685
- $(".css-code").click (function () {
686
- if (!$('#custom-css').is(':visible')) {
687
- $("#edit-css-button").click ();
688
- }
689
- });
690
-
691
- $("#edit-css-button").button ({
692
- }).click (function () {
693
-
694
- $(id_css_alignment_default).hide();
695
- $(id_css_alignment_left).hide();
696
- $(id_css_alignment_right).hide();
697
- $(id_css_alignment_center).hide();
698
- $(id_css_alignment_float_left).hide();
699
- $(id_css_alignment_float_right).hide();
700
- $(id_css_alignment_sticky_left).hide();
701
- $(id_css_alignment_sticky_right).hide();
702
- $(id_css_alignment_sticky_top).hide();
703
- $(id_css_alignment_sticky_bottom).hide();
704
- $(id_css_alignment_sticky).hide();
705
-
706
- var alignment = $("select#block-alignment"+" option:selected").attr('value');
707
-
708
- if (alignment == AI_ALIGNMENT_DEFAULT) {
709
- $("#custom-css").show().val ($(id_css_alignment_default).text ());
710
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
711
- } else
712
- if (alignment == AI_ALIGNMENT_LEFT) {
713
- $("#custom-css").show().val ($(id_css_alignment_left).text ());
714
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
715
- } else
716
- if (alignment == AI_ALIGNMENT_RIGHT) {
717
- $("#custom-css").show().val ($(id_css_alignment_right).text ());
718
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
719
- } else
720
- if (alignment == AI_ALIGNMENT_CENTER) {
721
- $("#custom-css").show().val ($(id_css_alignment_center).text ());
722
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
723
- } else
724
- if (alignment == AI_ALIGNMENT_FLOAT_LEFT) {
725
- $("#custom-css").show().val ($(id_css_alignment_float_left).text ());
726
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
727
- } else
728
- if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
729
- $("#custom-css").show().val ($(id_css_alignment_float_right).text ());
730
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
731
- } else
732
- if (alignment == AI_ALIGNMENT_STICKY_LEFT) {
733
- $("#custom-css").show().val ($(id_css_alignment_sticky_left).text ());
734
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
735
- } else
736
- if (alignment == AI_ALIGNMENT_STICKY_RIGHT) {
737
- $("#custom-css").show().val ($(id_css_alignment_sticky_right).text ());
738
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
739
- }
740
- if (alignment == AI_ALIGNMENT_STICKY_TOP) {
741
- $("#custom-css").show().val ($(id_css_alignment_sticky_top).text ());
742
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
743
- } else
744
- if (alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
745
- $("#custom-css").show().val ($(id_css_alignment_sticky_bottom).text ());
746
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
747
- } else
748
- if (alignment == AI_ALIGNMENT_STICKY) {
749
- $("#custom-css").show().val ($(id_css_alignment_sticky).text ());
750
- $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
751
- }
752
- });
753
-
754
- $("#custom-css").on ('input', function() {
755
- if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_CUSTOM_CSS;
756
-
757
- // console.log ('#custom-css input');
758
-
759
- if (wrapping) $("#wrapper").attr ("style", $("#custom-css").val ());
760
- if (sticky) update_sticky_css (STICKY_CONTEXT_CUSTOM_CSS);
761
-
762
- // console.log ('#custom-css');
763
-
764
- if (sticky) update_sticky_elements (STICKY_CONTEXT_CUSTOM_CSS);
765
- update_margin_padding ();
766
- update_close_button ();
767
- update_highlighting ();
768
- update_wrapper_size ();
769
-
770
- if (sticky_context == STICKY_CONTEXT_CUSTOM_CSS) sticky_context = STICKY_CONTEXT_NONE;
771
- });
772
-
773
- $("#highlight-button").button ({
774
- }).click (function () {
775
- $('body').toggleClass ("highlighted");
776
-
777
- if (!$('body').hasClass ("highlighted")) {
778
- $(".highlighting").remove ();
779
- $('.ai-debug-ad-info').remove();
780
- return;
781
- }
782
-
783
- <?php
784
- if (defined ('AI_ADSENSE_OVERLAY')) {
785
- echo "
786
- ai_process_adsense_ads (jQuery);
787
- $('.ai-debug-ad-info').each (function () {
788
- var info_top = $(this).offset ().top;
789
- var info_left = $(this).offset ().left;
790
- var ad_width = $(this).parent ().width ();
791
- $(this).css ({top: info_top, left: info_left, width: ad_width});
792
- if ($('#wrapper').css ('position') == 'fixed') $(this).css ('position', 'fixed');
793
- $('#ad-info-overlay').append ($(this));
794
- });
795
- ";
796
- }
797
- ?>
798
-
799
- if (wrapping) {
800
-
801
- var overlay_position = '';
802
- if (wrapper.css ('position') == 'fixed') overlay_position = 'fixed';
803
- $('#margin-background').css ('position', overlay_position);
804
- $('#padding-background').css ('position', overlay_position);
805
- $('#padding-background-white').css ('position', overlay_position);
806
-
807
- var wrapper_offset = wrapper.offset ();
808
- var wrapper_left = wrapper_offset.left;
809
- var wrapper_top = wrapper_offset.top;
810
- var wrapper_width = wrapper.outerWidth (true);
811
- var wrapper_height = wrapper.outerHeight (true);
812
- var wrapper_outer_width = wrapper.outerWidth ();
813
- var wrapper_outer_height = wrapper.outerHeight ();
814
- var code_width = wrapper.width ();
815
- var code_height = wrapper.height ();
816
-
817
- var wrapper_margin_width = wrapper_width - wrapper_outer_width;
818
- var wrapper_margin_height = wrapper_height - wrapper_outer_height;
819
- var wrapper_margin_top = parseInt (wrapper.css ('margin-top'));
820
- var wrapper_margin_left = parseInt (wrapper.css ('margin-left'));
821
- var wrapper_border_width = wrapper.outerWidth () - wrapper.innerWidth ();
822
- var wrapper_border_height = wrapper.outerHeight () - wrapper.innerHeight ();
823
- var wrapper_border_top = parseInt (wrapper.css ('border-top-width'));
824
- var wrapper_border_left = parseInt (wrapper.css ('border-left-width'));
825
- var wrapper_padding_width = wrapper.innerWidth () - code_width;
826
- var wrapper_padding_height = wrapper.innerHeight () - code_height;
827
-
828
- if (debug) {
829
- console.log ("wrapper_left: " + wrapper_left);
830
- console.log ("wrapper_top: " + wrapper_top);
831
- console.log ("wrapper_width: " + wrapper_width);
832
- console.log ("wrapper_height: " + wrapper_height);
833
- console.log ("wrapper_margin_top: " + wrapper_margin_top);
834
- console.log ("wrapper_margin_left: " + wrapper_margin_left);
835
- console.log ("wrapper_border_top: " + wrapper_border_top);
836
- console.log ("wrapper_border_left: " + wrapper_border_left);
837
- console.log ("wrapper_outer_width: " + wrapper_outer_width);
838
- console.log ("wrapper_outer_height: " + wrapper_outer_height);
839
- console.log ("wrapper_margin_height: " + wrapper_margin_height);
840
- console.log ("wrapper_margin_width: " + wrapper_margin_width);
841
- console.log ("wrapper_margin_height: " + wrapper_margin_height);
842
- console.log ("wrapper_border_width: " + wrapper_border_width);
843
- console.log ("wrapper_border_height: " + wrapper_border_height);
844
- console.log ("wrapper_padding_width: " + wrapper_padding_width);
845
- console.log ("wrapper_padding_height: " + wrapper_padding_height);
846
- console.log ("code_width: " + code_width);
847
- console.log ("code_height: " + code_height);
848
- }
849
-
850
- $('#margin-background').show ();
851
- $("#padding-background-white").show ();
852
-
853
- $('#margin-background').css ('width', wrapper_width).css ('height', wrapper_height);
854
- $("#margin-background").offset ({top: wrapper_top - wrapper_margin_top, left: wrapper_left - wrapper_margin_left});
855
-
856
- $('#padding-background').css ('width', wrapper_outer_width - wrapper_border_width).css ('height', wrapper_outer_height - wrapper_border_height);
857
- $("#padding-background").offset ({top: wrapper_top + wrapper_border_top, left: wrapper_left + wrapper_border_left});
858
-
859
- $('#padding-background-white').css ('width', wrapper_outer_width - wrapper_border_width).css ('height', wrapper_outer_height - wrapper_border_height);
860
- $("#padding-background-white").offset ({top: wrapper_top + wrapper_border_top, left: wrapper_left + wrapper_border_left});
861
-
862
- code_blocks = wrapper.children ();
863
- } else {
864
- $('#margin-background').hide ();
865
- $("#padding-background-white").hide ();
866
-
867
- $('#padding-background').css ('width', $('#wrapper').outerWidth ()).css ('height', $('#wrapper').outerHeight ());
868
- $("#padding-background").offset ({top: $('#wrapper').offset ().top, left: $('#wrapper').offset ().left});
869
-
870
- code_blocks = wrapper.children ();
871
- }
872
-
873
- var code_index = 0;
874
- var overlay_div = $("#code-overlay");
875
- var overlay_background_div = $("#code-background-white");
876
- var last_code_div = "code-overlay";
877
- var last_bkg_div = "code-background-white";
878
- var invalid_tags = ['script', 'style'];
879
-
880
- // console.log ('code_blocks', code_blocks);
881
-
882
- var filtered_code_blocks = $();
883
- code_blocks.each (function () {
884
- var element_tag = $(this).prop("tagName").toLowerCase();
885
-
886
- // Don't highlight close button
887
- if (element_tag == 'span' && $(this).hasClass ('ai-close-button')) return true;
888
-
889
- if (element_tag == 'a') {
890
- var a_children = $(this).children ();
891
- if (a_children.length == 0)
892
- filtered_code_blocks = filtered_code_blocks.add ($(this)); else
893
- filtered_code_blocks = filtered_code_blocks.add (a_children);
894
- } else filtered_code_blocks = filtered_code_blocks.add ($(this));
895
- });
896
-
897
- // code_blocks.each (function () {
898
- filtered_code_blocks.each (function () {
899
- var element_tag = $(this).prop("tagName");
900
- if (typeof element_tag != 'undefined') element_tag = element_tag.toLowerCase();
901
-
902
- if (invalid_tags.indexOf (element_tag) < 0) {
903
- code_index ++;
904
- var element_offset = $(this).offset ();
905
-
906
- var element_display = $(this).css ('display');
907
- var element_left = element_offset.left;
908
- var element_top = element_offset.top;
909
- var element_outer_width = $(this).outerWidth ();
910
- var element_outer_height = $(this).outerHeight ();
911
-
912
- if (debug) {
913
- console.log ("");
914
- console.log ("element " + code_index + ": " + element_tag);
915
- console.log ("element_display: " + element_display);
916
- console.log ("element_left: " + element_left);
917
- console.log ("element_top: " + element_top);
918
- console.log ("element_outer_width: " + element_outer_width);
919
- console.log ("element_outer_height: " + element_outer_height);
920
- }
921
-
922
- if (element_display == 'none') return; // continue
923
-
924
- var overlay_div_position = overlay_div.css ('position');
925
- var overlay_background_div_position = overlay_background_div.css ('position');
926
- var fixed_offset_top = 0;
927
- var fixed_offset_left = 0;
928
- if (wrapper.css ('position') == 'fixed') {
929
- overlay_div_position = 'fixed';
930
- overlay_background_div_position = 'fixed';
931
- fixed_offset_top = $(document).scrollTop();
932
- fixed_offset_left = $(document).scrollLeft();
933
- }
934
-
935
- var new_id = "code-" + code_index;
936
- $("#" + last_code_div).after (overlay_div.clone ().
937
- css ('position', overlay_div_position).
938
- css ('width', element_outer_width).
939
- css ('height', element_outer_height).
940
- offset ({top: element_top - fixed_offset_top, left: element_left - fixed_offset_left}).
941
- attr ("id", new_id).
942
- addClass ("highlighting"));
943
- last_code_div = new_id;
944
-
945
- var new_bkg_id = "code-background-" + code_index;
946
- $("#" + last_bkg_div).after (overlay_background_div.clone ().
947
- css ('position', overlay_background_div_position).
948
- css ('width', element_outer_width).
949
- css ('height', element_outer_height).
950
- offset ({top: element_top - fixed_offset_top, left: element_left - fixed_offset_left}).
951
- attr ("id", new_bkg_id).
952
- addClass ("highlighting"));
953
- last_bkg_div = new_bkg_id;
954
- }
955
- });
956
- if (debug) console.log ("");
957
- });
958
-
959
- $("#use-button").button ({
960
- }).click (function () {
961
- apply_to_settings ();
962
- window.close();
963
- });
964
-
965
- $("#reset-button").button ({
966
- }).click (function () {
967
- load_from_settings ();
968
- });
969
-
970
- $("#cancel-button").button ({
971
- }).click (function () {
972
- window.close();
973
- });
974
-
975
- $(".viewport-box").click (function () {
976
- var new_width = parseInt ($(this).attr ("data")) - 1;
977
- if (window.innerWidth == new_width) {
978
- window.resizeTo (836, $(window).height());
979
- } else {
980
- // Add body margin
981
- window.resizeTo (new_width + 16, $(window).height());
982
- }
983
- });
984
-
985
- update_width ();
986
-
987
- update_close_button ();
988
-
989
- if (sticky) update_sticky_css (STICKY_CONTEXT_INIT);
990
-
991
- <?php if (!$read_only) : ?>
992
- load_from_settings ();
993
- <?php endif; ?>
994
-
995
- if (sticky) update_sticky_elements (STICKY_CONTEXT_INIT);
996
-
997
- setTimeout (update_wrapper_size, 500);
998
-
999
- var current_time = new Date().getTime();
1000
- if (debug) console.log ("TIME: " + ((current_time - start_time) / 1000).toFixed (3));
1001
-
1002
- var titles = new Array();
1003
- $("select#block-alignment").imagepicker({hide_select: false}).find ('option').each (function (index) {
1004
- titles.push ($(this).data ('title'));
1005
- });
1006
- $("select#block-alignment + ul").appendTo("#alignment-style").css ('padding-top', '10px').find ('li').each (function (index) {
1007
- $(this).attr ('title', titles [index]);
1008
- });
1009
-
1010
- if (sticky) {
1011
- var titles = new Array();
1012
- $("select#close-button-0").imagepicker({hide_select: false}).find ('option').each (function (index) {
1013
- titles.push ($(this).data ('title'));
1014
- });
1015
- $("select#close-button-0 + ul").appendTo("#close-buttons").css ('padding-top', '10px').find ('li').each (function (index) {
1016
- $(this).attr ('title', titles [index]);
1017
- });
1018
- }
1019
-
1020
- var titles = new Array();
1021
- $("select#horizontal-position").imagepicker({hide_select: false}).find ('option').each (function (index) {
1022
- titles.push ($(this).data ('title'));
1023
- });
1024
- $("select#horizontal-position + ul").appendTo("#horizontal-positions").css ('padding-top', '10px').find ('li').each (function (index) {
1025
- $(this).attr ('title', titles [index]);
1026
- });
1027
-
1028
- var titles = new Array();
1029
- $("select#vertical-position").imagepicker({hide_select: false}).find ('option').each (function (index) {
1030
- titles.push ($(this).data ('title'));
1031
- });
1032
- $("select#vertical-position + ul").appendTo("#vertical-positions").css ('padding-top', '10px').find ('li').each (function (index) {
1033
- $(this).attr ('title', titles [index]);
1034
- });
1035
-
1036
-
1037
- $("div.automatic-insertion").dblclick (function () {
1038
- var selected_alignment = $("select#block-alignment option:selected");
1039
- var alignment_value = selected_alignment.val ();
1040
- var alt_styles = selected_alignment.data ('alt-styles');
1041
- if (typeof alt_styles != 'undefined') {
1042
- var alt_style_index = selected_alignment.data ('alt-style');
1043
- var num_styles = Object.keys(alt_styles).length;
1044
- alt_style_index ++;
1045
- if (alt_style_index > num_styles) alt_style_index = 1;
1046
- selected_alignment.data ('alt-style', alt_style_index)
1047
- process_display_elements ();
1048
- }
1049
- });
1050
-
1051
- // Prevent anoter initialization of sticky elements on document ready
1052
- $('#wrapper').removeClass ('ai-sticky-content');
1053
-
1054
- sticky_context = STICKY_CONTEXT_NONE;
1055
- }
1056
-
1057
- jQuery(document).ready(function($) {
1058
- initialize_preview ();
1059
-
1060
- setTimeout (show_blocked_warning, 400);
1061
- });
1062
-
1063
- function show_blocked_warning () {
1064
- jQuery("#blocked-warning.warning-enabled").show ();
1065
- }
1066
-
1067
- </script>
1068
- <style>
1069
-
1070
- /*html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {*/
1071
- a, img {
1072
- border: 0;
1073
- font: inherit;
1074
- font-size: 100%;
1075
- font-style: inherit;
1076
- font-weight: inherit;
1077
- margin: 0;
1078
- outline: 0;
1079
- padding: 0;
1080
- vertical-align: baseline;
1081
- }
1082
-
1083
- body.sticky {
1084
- margin: 0;
1085
- }
1086
-
1087
- #main.sticky {
1088
- width: 728px;
1089
- margin: 100px auto;
1090
- }
1091
-
1092
- .responsive-table td {
1093
- white-space: nowrap;
1094
- }
1095
- .small-button .ui-button-text-only .ui-button-text {
1096
- padding: 0;
1097
- }
1098
- #margin-background {
1099
- z-index: 2;
1100
- position: absolute;
1101
- display: none;
1102
- }
1103
- .highlighted #margin-background {
1104
- background: rgba(255, 145, 0, 0.5);
1105
- display: block;
1106
- }
1107
- #padding-background-white {
1108
- z-index: 3;
1109
- position: absolute;
1110
- background: #fff;
1111
- width: 0px;
1112
- height: 0px;
1113
- display: none;
1114
- }
1115
- .highlighted #padding-background-white {
1116
- display: block;
1117
- }
1118
- #padding-background {
1119
- z-index: 4;
1120
- position: absolute;
1121
- display: none;
1122
- }
1123
- .highlighted #padding-background {
1124
- background: rgba(50, 220, 140, 0.5);
1125
- display: block;
1126
- }
1127
- #wrapper {
1128
- z-index: 6;
1129
- position: relative;
1130
- border: 0;
1131
- }
1132
- .code-background-white {
1133
- z-index: 5;
1134
- position: absolute;
1135
- background: #fff;
1136
- width: 0px;
1137
- height: 0px;
1138
- display: none;
1139
- }
1140
- .highlighted .code-background-white {
1141
- display: block;
1142
- }
1143
- .code-overlay {
1144
- z-index: 99999;
1145
- position: absolute;
1146
- display: none;
1147
- }
1148
- .highlighted .code-overlay {
1149
- background: rgba(50, 140, 220, 0.5);
1150
- display: block;
1151
- }
1152
- .ad-info-overlay {
1153
- position: absolute;
1154
- }
1155
-
1156
- table.screen td {
1157
- padding: 0;
1158
- font-size: 12px;
1159
- }
1160
-
1161
- table.demo-box {
1162
- width: 300px;
1163
- margin: 0 auto;
1164
- border: 1px solid #ccc;
1165
- }
1166
- #demo-box-no-wrapping {
1167
- height: 200px;
1168
- }
1169
- table.demo-box input {
1170
- display: none;
1171
- }
1172
- .demo-box td {
1173
- font-size: 12px;
1174
- padding: 0;
1175
- }
1176
- td.demo-wrapper-margin-lr, td.demo-wrapper-margin {
1177
- width: 22px;
1178
- height: 22px;
1179
- text-align: center;
1180
- }
1181
- td.demo-wrapper-margin-tb {
1182
- width: 300px;
1183
- height: 22px;
1184
- text-align: center;
1185
- }
1186
- .highlighted td.demo-wrapper-margin-tb, .highlighted td.demo-wrapper-margin-lr, .highlighted td.demo-wrapper-margin {
1187
- background: rgba(255, 145, 0, 0.5);
1188
- }
1189
- td.demo-code-padding-tb {
1190
- text-align: center;
1191
- }
1192
- td.demo-code-padding-lr {
1193
- width: 22px;
1194
- text-align: center;
1195
- }
1196
- td.demo-code {
1197
- text-align: center;
1198
- }
1199
- #demo-box td.demo-code {
1200
- height: 110px;
1201
- }
1202
- .highlighted td.demo-code, .highlighted td.demo-code-padding-lr, .highlighted td.demo-code-padding-tb {
1203
- background: rgba(50, 140, 220, 0.5);
1204
- }
1205
- td.demo-wrapper-background {
1206
- width: 80px;
1207
- text-align: center;
1208
- word-wrap: break-word;
1209
- white-space: normal;
1210
- }
1211
- .highlighted td.demo-wrapper-background {
1212
- background: rgba(50, 220, 140, 0.5);
1213
- }
1214
- .ui-widget-content {
1215
- background: transparent;
1216
- }
1217
- .ui-spinner {
1218
- border: 0;
1219
- }
1220
- .ui-spinner-horizontal, .ui-spinner-horizontal .ui-spinner-input {
1221
- height: 14px;
1222
- }
1223
- .ui-spinner-horizontal .ui-spinner-input {
1224
- width: 23px;
1225
- outline: 0;
1226
- margin: -1px 12px 0 12px;
1227
- }
1228
- .ui-spinner-vertical, .ui-spinner-vertical .ui-spinner-input {
1229
- width: 18px;
1230
- }
1231
- .ui-spinner-vertical .ui-spinner-input {
1232
- height: 11px;
1233
- outline: 0;
1234
- margin: 12px 0 12px 0;
1235
- font-size: 11px;
1236
- }
1237
-
1238
- .thumbnail {
1239
- border-radius: 6px;
1240
- }
1241
- ul.image_picker_selector {
1242
- overflow: hidden!important;
1243
- }
1244
-
1245
- div.automatic-insertion {
1246
- width: 50px;
1247
- height: 50px;
1248
- }
1249
-
1250
- li.automatic-insertion p {
1251
- width: 50px;
1252
- height: 50px;
1253
- }
1254
-
1255
- div.automatic-insertion img {
1256
- width: 50px;
1257
- height: 50px;
1258
- }
1259
-
1260
- select {
1261
- border-radius: 5px;
1262
- }
1263
- .ai-close-hidden {
1264
- visibility: hidden;
1265
- }
1266
-
1267
- .ai-debug-ad-info {position: absolute; top: 0; left: 0; overflow: hidden; width: auto; height: auto; font-size: 11px; line-height: 11px; text-align: left; z-index: 999999991;}
1268
- .ai-info {display: inline-block; padding: 2px 4px;}
1269
- .ai-info-1 {background: #000; color: #fff;}
1270
- .ai-info-2 {background: #fff; color: #000;}
1271
-
1272
- </style>
1273
- <?php echo $head_code; ?>
1274
- </head>
1275
- <body class="<?php if ($sticky) echo 'sticky'; ?>" style='font-family: arial; text-align: justify; overflow-x: hidden;'>
1276
-
1277
- <?php if ($sticky) padding_margin_code ($close_button, $class, $wrapper_css, $block_code); ?>
1278
-
1279
- <div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>"></div>
1280
-
1281
- <div style="margin: 0 -8px 10px; display: none;">
1282
- <table class="screen" cellspacing=0 cellpadding=0>
1283
- <tr>
1284
- <?php
1285
- $previous_width = 0;
1286
- $previous_name = '';
1287
- for ($viewport = AD_INSERTER_VIEWPORTS - 1; $viewport > 0; $viewport --) {
1288
- $viewport_name = get_viewport_name ($viewport);
1289
- $viewport_width = get_viewport_width ($viewport);
1290
- if ($viewport_name != '' && $viewport_width != 0) {
1291
- echo "<td class='viewport-box' data='", $viewport_width, "' style='background: #eee; text-align: center; border: 1px solid #888; border-left-width: 0; min-width: ", $viewport_width - $previous_width - 1, "px'>",
1292
- $previous_name, "<span style='float: left; margin-left: 5px;'>", $previous_width != 0 ? $previous_width . "px" : "", "</span></td>";
1293
- }
1294
- $previous_name = $viewport_name;
1295
- $previous_width = $viewport_width;
1296
- }
1297
- echo "<td style='background: #eee; text-align: left; border: 1px solid #888; border-left-width: 0; min-width: 2000px'><span style='margin-left: 30px;'>", get_viewport_name (1), "</span><span style='float: left; margin-left: 5px;'>", $previous_width != 0 ? $previous_width . "px" : "", "</span></td>";
1298
- ?>
1299
- </tr>
1300
- </table>
1301
- </div>
1302
-
1303
- <?php if (!$read_only) : ?>
1304
- <div style="margin: 10px -8px">
1305
- <table class="screen" cellspacing=0 cellspacing="0">
1306
- <tr>
1307
- <td><span>&#9667;</span></td>
1308
- <td style="width: 50%;"><div style="height: 2px; width: 100%; border-bottom: 1px solid #ddd;"></div></td>
1309
- <td id="screen-width" style="min-width: 45px; text-align: center; font-size: 12px;">820 px</td>
1310
- <td style="width: 50%;"><div style="height: 2px; width: 100%; border-bottom: 1px solid #ddd;"></div></td>
1311
- <td><span id="right-arrow" >&#9657;</span></td>
1312
- </tr>
1313
- </table>
1314
- </div>
1315
- <?php endif; ?>
1316
-
1317
- <div id="main" class="<?php if ($sticky) echo 'sticky'; ?>">
1318
-
1319
- <div id="blocked-warning" class="warning-enabled" style="padding: 2px 8px 2px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1320
- <div style="float: right; text-align: right; margin: 20px 0px 0px 0;">
1321
- This page was not loaded properly. Please check browser, plugins and ad blockers.
1322
- </div>
1323
- <h3 style="color: red;" title="Error loading page">PAGE BLOCKED</h3>
1324
-
1325
- <div style="clear: both;"></div>
1326
- </div>
1327
-
1328
- <div style="float: right; width: 90px; margin-left: 20px;">
1329
- <button id="highlight-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Highlight inserted code" >Highlight</button>
1330
- <?php if (!$read_only) : ?>
1331
- <button id="use-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Use current settings" >Use</button>
1332
- <button id="reset-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Reset to the block settings" >Reset</button>
1333
- <?php endif; ?>
1334
- <button id="cancel-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Close preview window" >Cancel</button>
1335
- </div>
1336
-
1337
- <?php if (!$read_only) : ?>
1338
- <div style="float: left; max-width: 300px; margin-right: 20px">
1339
- <?php else : ?>
1340
- <div style="float: left; max-width: 600px; margin-right: 20px">
1341
- <?php endif; ?>
1342
-
1343
- <h1 style="margin: 0;">Preview</h1>
1344
- <?php if ($block != 0) : ?>
1345
- <h2>Block <?php echo $block; ?></h2>
1346
- <?php else : ?>
1347
- <h2>AdSense ad unit</h2>
1348
- <?php endif; ?>
1349
- <h3 id="block-name" style="text-align: left;"><?php echo $block_name; ?></h3>
1350
- </div>
1351
-
1352
- <?php if (!$read_only) : ?>
1353
- <div style="float: left; min-height: 200px; margin: 0 auto;">
1354
- <table id="demo-box" class="demo-box" style="display: none;" cellspacing=0 cellspacing="0">
1355
- <tr>
1356
- <td class="demo-wrapper-margin-tb" style="border-right: 1px solid #ccc;" colspan="5">
1357
- <span style="float: left; margin-left: 43px;">margin</span>
1358
- <span style="float: right; margin-right: 70px">px</span>
1359
- <input id="spinner-margin-top" class=" spinner" name="value">
1360
- </td>
1361
- <td class="demo-wrapper-background"></td>
1362
- </tr>
1363
- <tr>
1364
- <td class="demo-wrapper-margin"></td>
1365
- <td class="demo-code-padding-tb" style="border-top:1px solid #ccc; border-left: 1px solid #ccc; border-right: 1px solid #ccc;" colspan="3">
1366
- <span style="float: left; margin-left: 14px;">padding</span>
1367
- <span style="float: right; margin-right: 48px">px</span>
1368
- <input id="spinner-padding-top" class=" spinner" name="value">
1369
- </td>
1370
- <td class="demo-wrapper-margin" style="border-right: 1px solid #ccc;"></td>
1371
- <td class="demo-wrapper-background"></td>
1372
- </tr>
1373
- <tr>
1374
- <td class="demo-wrapper-margin-lr">
1375
- <input id="spinner-margin-left" class=" spinner" name="value">
1376
- </td>
1377
- <td class="demo-code-padding-lr" style="border-left: 1px solid #ccc;">
1378
- <input id="spinner-padding-left" class=" spinner" name="value">
1379
- </td>
1380
- <td class="demo-code"><p>Code block</p><p class="wrapper-size">&nbsp;</p></td>
1381
- <td class="demo-code-padding-lr" style="border-right: 1px solid #ccc;">
1382
- <input id="spinner-padding-right" class=" spinner" name="value">
1383
- </td>
1384
- <td class="demo-wrapper-margin-lr" style="border-right: 1px solid #ccc;">
1385
- <input id="spinner-margin-right" class=" spinner" name="value">
1386
- </td>
1387
- <td class="demo-wrapper-background"></td>
1388
- </tr>
1389
- <tr>
1390
- <td class="demo-wrapper-margin"></td>
1391
- <td class="demo-code-padding-tb" style="border-bottom:1px solid #ccc; border-left: 1px solid #ccc; border-right: 1px solid #ccc;" colspan="3">
1392
- <input id="spinner-padding-bottom" class=" spinner" name="value">
1393
- </td>
1394
- <td class="demo-wrapper-margin" style="border-right: 1px solid #ccc;"></td>
1395
- <td class="demo-wrapper-background"></td>
1396
- </tr>
1397
- <tr>
1398
- <td class="demo-wrapper-margin-tb" style="border-right: 1px solid #ccc;" colspan="5">
1399
- <span style="float: left; margin-left: 6px;">wrapping div</span>
1400
- <span style="float: right; margin-right: 72px">&nbsp;</span>
1401
- <input id="spinner-margin-bottom" class=" spinner" name="value">
1402
- </td>
1403
- <td class="demo-wrapper-background">background</td>
1404
- </tr>
1405
- </table>
1406
-
1407
- <table id="demo-box-no-wrapping" class="demo-box" style="display: none;" cellspacing=0 cellspacing="0">
1408
- <tr>
1409
- <td class="demo-code" style="border-right: 1px solid #ccc;"><p>Code block</p><p class="wrapper-size">&nbsp;</p></td>
1410
- <td class="demo-wrapper-background">background</td>
1411
- </tr>
1412
- </table>
1413
- </div>
1414
- <?php endif; ?>
1415
-
1416
- <div style="clear: both;"></div>
1417
-
1418
- <?php if (!$read_only) : ?>
1419
- <div id="alignment-editor" style="margin: 20px 0;">
1420
- <?php else : ?>
1421
- <div id="alignment-editor" style="margin: 20px 0; display: none;">
1422
- <?php endif; ?>
1423
- <?php if (defined ('AI_STICKY_SETTINGS') && AI_STICKY_SETTINGS && $sticky) : ?>
1424
-
1425
- <div style="">
1426
-
1427
- <div style="float: left;">
1428
- Alignment and Style&nbsp;&nbsp;&nbsp;
1429
- <select id="block-alignment" style="width:120px;">
1430
- <?php if (function_exists ('ai_preview_style_options')) ai_preview_style_options ($obj, $alignment_type, true); ?>
1431
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-custom-css" value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" data-title="<?php echo AI_TEXT_CUSTOM_CSS; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
1432
- </select>
1433
- <span id="css-index" style="display: inline-block; min-width: 30px; min-height: 12px; margin: 0 0 0 10px; font-size: 14px;" title="CSS code index"></span>
1434
- <div id="alignment-style" style="margin: 4px 0; min-height: 74px;"></div>
1435
- </div>
1436
-
1437
- <div style="float: right;">
1438
- <?php if (function_exists ('ai_close_button')) ai_close_button (0, $close_button, $close_button); ?>
1439
- <div id="close-buttons" style="margin: 4px 0; min-height: 74px;"></div>
1440
- </div>
1441
- <div style="clear: both;"></div>
1442
-
1443
- </div>
1444
-
1445
- <div style="float: left;">
1446
- <div style="margin: 4px 0;">
1447
- Horizontal position
1448
- <select class="ai-image-selection" id="horizontal-position">
1449
- <option
1450
- data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1451
- data-img-class="automatic-insertion preview im-sticky-left"
1452
- data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_LEFT; ?>"
1453
- data-title="<?php echo AI_TEXT_STICK_TO_THE_LEFT; ?>"
1454
- value="<?php echo AI_STICK_TO_THE_LEFT; ?>"
1455
- <?php echo ($horizontal_position == AI_STICK_TO_THE_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_LEFT; ?></option>
1456
- <option
1457
- data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1458
- data-img-class="automatic-insertion preview im-sticky-content-left"
1459
- data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_LEFT; ?>"
1460
- data-title="<?php echo AI_TEXT_STICK_TO_THE_CONTENT_LEFT; ?>"
1461
- value="<?php echo AI_STICK_TO_THE_CONTENT_LEFT; ?>"
1462
- <?php echo ($horizontal_position == AI_STICK_TO_THE_CONTENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_CONTENT_LEFT; ?></option>
1463
- <option
1464
- data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1465
- data-img-class="automatic-insertion preview im-sticky-center-horizontal"
1466
- data-css="<?php echo AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL; ?>"
1467
- data-css-<?php echo AI_STICK_VERTICAL_CENTER; ?>="<?php echo AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL_V; ?>"
1468
- data-title="<?php echo AI_TEXT_CENTER; ?>"
1469
- value="<?php echo AI_STICK_HORIZONTAL_CENTER; ?>"
1470
- <?php echo ($horizontal_position == AI_STICK_HORIZONTAL_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
1471
- <option
1472
- data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1473
- data-img-class="automatic-insertion preview im-sticky-content-right"
1474
- data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_RIGHT; ?>"
1475
- data-title="<?php echo AI_TEXT_STICK_TO_THE_CONTENT_RIGHT; ?>"
1476
- value="<?php echo AI_STICK_TO_THE_CONTENT_RIGHT; ?>"
1477
- <?php echo ($horizontal_position == AI_STICK_TO_THE_CONTENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_CONTENT_RIGHT; ?></option>
1478
- <option
1479
- data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1480
- data-img-class="automatic-insertion preview im-sticky-right"
1481
- data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT; ?>"
1482
- data-css-<?php echo AI_SCROLL_WITH_THE_CONTENT; ?>="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT_SCROLL; ?>"
1483
- data-title="<?php echo AI_TEXT_STICK_TO_THE_RIGHT; ?>"
1484
- value="<?php echo AI_STICK_TO_THE_RIGHT; ?>"
1485
- <?php echo ($horizontal_position == AI_STICK_TO_THE_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_RIGHT; ?></option>
1486
- </select>
1487
- <div style="clear: both;"></div>
1488
- </div>
1489
-
1490
- <div id="horizontal-positions"></div>
1491
- </div>
1492
-
1493
- <div style="float: right;">
1494
- <div style="margin: 4px 0;">
1495
- Vertical position
1496
- <select id="vertical-position">
1497
- <option
1498
- data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1499
- data-img-class="automatic-insertion preview im-sticky-top"
1500
- data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_TOP_OFFSET; ?>"
1501
- data-css-<?php echo AI_STICK_HORIZONTAL_CENTER; ?>="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_TOP; ?>"
1502
- data-title="<?php echo AI_TEXT_STICK_TO_THE_TOP; ?>"
1503
- value="<?php echo AI_STICK_TO_THE_TOP; ?>"
1504
- <?php echo ($vertical_position == AI_STICK_TO_THE_TOP) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_TOP; ?></option>
1505
- <option
1506
- data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-sticky-center-vertical"
1507
- data-css="<?php echo AI_ALIGNMENT_CSS_CENTER_VERTICAL; ?>"
1508
- data-css-<?php echo AI_STICK_HORIZONTAL_CENTER; ?>="<?php echo AI_ALIGNMENT_CSS_CENTER_VERTICAL_H; ?>"
1509
- data-title="<?php echo AI_TEXT_CENTER; ?>"
1510
- value="<?php echo AI_STICK_VERTICAL_CENTER; ?>"
1511
- <?php echo ($vertical_position == AI_STICK_VERTICAL_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
1512
- <option
1513
- data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1514
- data-img-class="automatic-insertion preview im-sticky-scroll"
1515
- data-css="<?php echo AI_ALIGNMENT_CSS_SCROLL_WITH_THE_CONTENT; ?>"
1516
- data-title="<?php echo AI_TEXT_SCROLL_WITH_THE_CONTENT; ?>"
1517
- value="<?php echo AI_SCROLL_WITH_THE_CONTENT; ?>"
1518
- <?php echo ($vertical_position == AI_SCROLL_WITH_THE_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_SCROLL_WITH_THE_CONTENT; ?></option>
1519
- <option
1520
- data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1521
- data-img-class="automatic-insertion preview im-sticky-bottom"
1522
- data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_BOTTOM_OFFSET; ?>"
1523
- data-css-<?php echo AI_STICK_HORIZONTAL_CENTER; ?>="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_BOTTOM; ?>"
1524
- data-title="<?php echo AI_TEXT_STICK_TO_THE_BOTTOM; ?>"
1525
- value="<?php echo AI_STICK_TO_THE_BOTTOM; ?>"
1526
- <?php echo ($vertical_position == AI_STICK_TO_THE_BOTTOM) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_BOTTOM; ?></option>
1527
- </select>
1528
- <div style="clear: both;"></div>
1529
- </div>
1530
-
1531
- <div id="vertical-positions" style="margin-bottom: 4px;"></div>
1532
- </div>
1533
- <div style="clear: both;"></div>
1534
-
1535
- <?php else : ?>
1536
-
1537
- <div style="margin: 20px 0 0 0;">
1538
- Alignment and Style&nbsp;&nbsp;&nbsp;
1539
- <select id="block-alignment" style="width:120px;">
1540
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-default" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_DEFAULT, true)); ?> value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" data-title="<?php echo AI_TEXT_DEFAULT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
1541
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-align-left" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_LEFT; ?>" data-title="<?php echo AI_TEXT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
1542
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-center" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_CENTER, true)); ?> value="<?php echo AI_ALIGNMENT_CENTER; ?>" data-title="<?php echo AI_TEXT_CENTER; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
1543
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-align-right" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_RIGHT, true)); ?> value="<?php echo AI_ALIGNMENT_RIGHT; ?>" data-title="<?php echo AI_TEXT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_RIGHT; ?></option>
1544
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-float-left" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_FLOAT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" data-title="<?php echo AI_TEXT_FLOAT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_LEFT; ?></option>
1545
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-float-right" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_FLOAT_RIGHT, true)); ?> value="<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" data-title="<?php echo AI_TEXT_FLOAT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_RIGHT; ?></option>
1546
- <?php if (function_exists ('ai_preview_style_options')) ai_preview_style_options ($obj, $alignment_type); ?>
1547
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-custom-css" value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" data-title="<?php echo AI_TEXT_CUSTOM_CSS; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
1548
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-no-wrapping" value="<?php echo AI_ALIGNMENT_NO_WRAPPING; ?>" data-title="<?php echo AI_TEXT_NO_WRAPPING; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_WRAPPING; ?></option>
1549
- </select>
1550
- <span id="css-index" style="display: inline-block; min-width: 30px; min-height: 12px; margin: 0 0 0 10px; font-size: 14px;" title="CSS code index"></span>
1551
- &nbsp;&nbsp;&nbsp;
1552
- <span id="close-button-selection" style="display: <?php echo $alignment_type == AI_ALIGNMENT_NO_WRAPPING || $close_button == AI_CLOSE_NONE ? 'none': 'inline'; ?>;">
1553
- <?php if (function_exists ('ai_close_button')) ai_close_button (0, $close_button, $close_button); ?>
1554
- </span>
1555
- </div>
1556
-
1557
- <div id="alignment-style" style="margin: 4px 0; min-height: 74px;"></div>
1558
-
1559
- <?php endif; ?>
1560
-
1561
- <table class="responsive-table">
1562
- <tr>
1563
- <td style="vertical-align: middle; padding:0;">
1564
- <span id="css-label" style="vertical-align: middle; margin: 4px 0 0 0 0; width: 36px; font-size: 14px; font-weight: bold; display: none;">CSS</span>
1565
- </td>
1566
- <td style="width: 100%; height: 32px; padding:0;">
1567
- <input id="custom-css" style="width: 100%; display: inline-block; padding: 5px 0 0 3px; border-radius: 4px; display: none; font-size: 12px; font-family: Courier, 'Courier New', monospace; font-weight: bold;" type="text" value="<?php echo $custom_css_code; ?>" size="70" maxlength="500" title="Custom CSS code for wrapping div" />
1568
- <span style="width: 100%; display: inline-block; padding: 5px 0 0 2px; font-family: Courier, 'Courier New', monospace; font-size: 12px; font-weight: bold; cursor: pointer; white-space: normal;">
1569
- <span id="css-no-wrapping" style="vertical-align: middle; display: none;"></span>
1570
- <span id="css-<?php echo AI_ALIGNMENT_DEFAULT; ?>" class="css-code" style="vertical-align: middle; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_DEFAULT); ?></span>
1571
- <span id="css-<?php echo AI_ALIGNMENT_LEFT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_LEFT); ?></span>
1572
- <span id="css-<?php echo AI_ALIGNMENT_RIGHT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_RIGHT); ?></span>
1573
- <span id="css-<?php echo AI_ALIGNMENT_CENTER; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_CENTER); ?></span>
1574
- <span id="css-<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_FLOAT_LEFT); ?></span>
1575
- <span id="css-<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_FLOAT_RIGHT); ?></span>
1576
- <?php if (function_exists ('ai_preview_style_css')) ai_preview_style_css ($obj); ?>
1577
- </span>
1578
- </td>
1579
- <td padding:0;>
1580
- <button id="edit-css-button" type="button" style="margin: 0 0 0 10px; height: 30px; font-size: 12px; display: none;">Edit</button>
1581
- </td>
1582
- </tr>
1583
- </table>
1584
- </div>
1585
-
1586
- <?php if (!$sticky) { ?>
1587
-
1588
- <?php if (!$read_only) : ?>
1589
- <p id="p1">This is a preview of the code between dummy paragraphs. Here you can test various block alignments, visually edit margin and padding values of the wrapping div
1590
- or write CSS code directly and watch live preview. Highlight button highlights background, wrapping div margin and code area, while Reset button restores all the values to those of the current block.</p>
1591
- <?php elseif ($block != 0) : ?>
1592
- <p id="p1">This is a preview of the saved code block between dummy paragraphs. It shows the code with the alignment and style as it is set for this code block. Highlight button highlights background, wrapping div margin and code area.</p>
1593
- <?php else : ?>
1594
- <p id="p1">This is a preview of AdSense ad block between dummy paragraphs. AdSense ad code was loaded from your AdSense account. The ad block is displayed on a dummy page so it may be blank (no ads). Click on the Highlight button to highlight ad block.</p>
1595
- <?php endif; ?>
1596
-
1597
- <?php if (!$sticky) padding_margin_code ($close_button, $class, $wrapper_css, $block_code); ?>
1598
-
1599
- <?php if (!$read_only) : ?>
1600
- <p id="p2">You can resize the window (and refresh the page to reload ads) to check display with different screen widths.
1601
- Once you are satisfied with alignment click on the Use button and the settings will be copied to the active block.</p>
1602
- <p id="p3">Please note that the code, block name, alignment and style are taken from the current block settings (may not be saved).
1603
- <strong>No Wrapping</strong> style inserts the code as it is so margin and padding can't be set. However, you can use own HTML code for the block.</p>
1604
- <?php else : ?>
1605
- <?php endif; ?>
1606
-
1607
- <p id="p4">Ad Inserter can be configured to insert any code anywhere on the page. Each code with it's settings is called a code block.
1608
- Free Ad Inserter supports 16 code blocks, Ad Inserter Pro supports up to 96 code blocks (depending on the license type).
1609
- The settings page is divided into tabs - 16 code blocks and general plugin settings. Black number means inactive code block (code is not inserted anywhere),
1610
- red number means block is using automatic insertion, blue number means block is using manual insertion while violet number means block is using automatic and manual insertion.</p>
1611
-
1612
- <p id="p5">Few very important things you need to know in order to insert code and display some ad:
1613
- Enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call).
1614
- Enable display on at least one Wordpress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages).
1615
- Single pages (posts and static pages) have also additional setting for individual exceptions. Use default blank value unless you are using individual post/page exceptions.</p>
1616
-
1617
- <?php } else { ?>
1618
- <p id="p1">This is a preview of the code for sticky ads. Here you can test various horizontal and vertical alignments, close button locations, visually edit margin values
1619
- or write CSS code directly and watch live preview. Highlight button highlights background, margin and code area, while Reset button restores all the values to those of the current block.</p>
1620
-
1621
- <p id="p2">Ad Inserter can be configured to insert any code anywhere on the page. Each code with it's settings is called a code block.
1622
- Free Ad Inserter supports 16 code blocks, Ad Inserter Pro supports up to 96 code blocks (depending on the license type).
1623
- The settings page is divided into tabs - 16 code blocks and general plugin settings. Black number means inactive code block (code is not inserted anywhere),
1624
- red number means block is using automatic insertion, blue number means block is using manual insertion while violet number means block is using automatic and manual insertion.</p>
1625
-
1626
- <p id="p3">Few very important things you need to know in order to insert code and display some ad:
1627
- Enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call).
1628
- Enable display on at least one Wordpress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages).
1629
- Single pages (posts and static pages) have also additional setting for individual exceptions. Use default blank value unless you are using individual post/page exceptions.</p>
1630
-
1631
- <p id="p4">Ad Inserter can be configured to insert any code anywhere on the page. Each code with it's settings is called a code block.
1632
- Free Ad Inserter supports 16 code blocks, Ad Inserter Pro supports up to 96 code blocks (depending on the license type).
1633
- The settings page is divided into tabs - 16 code blocks and general plugin settings. Black number means inactive code block (code is not inserted anywhere),
1634
- red number means block is using automatic insertion, blue number means block is using manual insertion while violet number means block is using automatic and manual insertion.</p>
1635
-
1636
- <p id="p5">Few very important things you need to know in order to insert code and display some ad:
1637
- Enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call).
1638
- Enable display on at least one Wordpress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages).
1639
- Single pages (posts and static pages) have also additional setting for individual exceptions. Use default blank value unless you are using individual post/page exceptions.</p>
1640
- <?php } ?>
1641
-
1642
-
1643
- <span class="ai-content"></span>
1644
- </div>
1645
-
1646
- <?php ai_wp_footer_hook (); ?>
1647
- <script>
1648
- <?php if (function_exists ('ai_load_settings_2')) echo ai_get_js ('ai-close'); ?>
1649
- <?php
1650
- if ($sticky) echo ai_get_js ('ai-sticky');
1651
- if (defined ('AI_ADSENSE_OVERLAY')) {
1652
- echo ai_get_js ('ai-ads');
1653
- }
1654
- ?>
1655
- </script>
1656
- </body>
1657
- </html>
1658
- <?php
1659
- }
1660
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //ini_set ('display_errors', 1);
4
+ //error_reporting (E_ALL);
5
+
6
+ function alt_styles_data ($alt_styles_text) {
7
+ if (strpos ($alt_styles_text, "||") !== false) {
8
+ $styles = explode ("||", $alt_styles_text);
9
+ $alt_styles = array ();
10
+ foreach ($styles as $index => $style) {
11
+ $alt_styles ['css' . ($index + 1)] = str_replace ("'", '"', str_replace (array ("\"", "<", ">", "[", "]"), "", trim ($style)));
12
+ }
13
+ echo "data-alt-style='1' data-alt-styles='", json_encode ($alt_styles), "'";
14
+ }
15
+ }
16
+
17
+ function padding_margin_code ($close_button, $class, $sticky_parameters, $wrapper_css, $block_code) {
18
+ ?>
19
+ <div id='padding-background'></div>
20
+ <div id='margin-background'></div>
21
+ <div id='padding-background-white'></div>
22
+ <div id='wrapper'<?php echo $class; ?> style='<?php echo $wrapper_css;
23
+ ?>'<?php echo $sticky_parameters; ?>>
24
+ <?php echo $block_code; ?>
25
+ </div>
26
+ <!-- IE bug: use inline CSS: position: absolute;-->
27
+ <div id='code-background-white' class= "code-background-white" style="position: absolute;"></div>
28
+ <div id='code-overlay' class="code-overlay" style="position: absolute;"></div>
29
+ <div id='ad-info-overlay'></div>
30
+
31
+ <?php
32
+ }
33
+
34
+ function generate_code_preview (
35
+ $block,
36
+ $preview_parameters) {
37
+
38
+ global $block_object, $ai_wp_data;
39
+
40
+ $ai_wp_data [AI_WP_DEBUGGING] = 0;
41
+
42
+ $obj = new ai_Block ($block);
43
+ $obj->wp_options = $block_object [$block]->wp_options;
44
+
45
+ $block_name = isset ($preview_parameters ['name']) ? $preview_parameters ['name'] : $obj->get_ad_name();
46
+ $code = isset ($preview_parameters ['code']) ? $preview_parameters ['code'] : $obj->get_ad_data();
47
+ $alignment_type = isset ($preview_parameters ['alignment']) ? $preview_parameters ['alignment'] : $obj->get_alignment_type();
48
+ $horizontal_position = isset ($preview_parameters ['horizontal']) ? $preview_parameters ['horizontal'] : $obj->get_horizontal_position();
49
+ $vertical_position = isset ($preview_parameters ['vertical']) ? $preview_parameters ['vertical'] : $obj->get_vertical_position();
50
+ $horizontal_margin = isset ($preview_parameters ['horizontal_margin']) ? $preview_parameters ['horizontal_margin'] : $obj->get_horizontal_margin();
51
+ $vertical_margin = isset ($preview_parameters ['vertical_margin']) ? $preview_parameters ['vertical_margin'] : $obj->get_vertical_margin();
52
+ $animation = isset ($preview_parameters ['animation']) ? $preview_parameters ['animation'] : $obj->get_animation();
53
+ $wrapper_css = isset ($preview_parameters ['alignment_css']) ? $preview_parameters ['alignment_css'] : $obj->get_alignment_style ();
54
+ $custom_css_code = isset ($preview_parameters ['custom_css']) ? $preview_parameters ['custom_css'] : $obj->get_custom_css();
55
+ $close_button = isset ($preview_parameters ['close']) ? $preview_parameters ['close'] : $obj->get_close_button ();
56
+ $process_php = isset ($preview_parameters ['php']) ? $preview_parameters ['php'] : $obj->get_process_php ();
57
+ $show_label = isset ($preview_parameters ['label']) ? $preview_parameters ['label'] : $obj->get_show_label ();
58
+ $read_only = isset ($preview_parameters ['read_only']) ? $preview_parameters ['read_only'] : false;
59
+
60
+ $obj->wp_options [AI_OPTION_BLOCK_NAME] = $block_name;
61
+ $obj->wp_options [AI_OPTION_CODE] = $code;
62
+ $obj->wp_options [AI_OPTION_ALIGNMENT_TYPE] = $alignment_type;
63
+ $obj->wp_options [AI_OPTION_HORIZONTAL_POSITION] = $horizontal_position;
64
+ $obj->wp_options [AI_OPTION_VERTICAL_POSITION] = $vertical_position;
65
+ $obj->wp_options [AI_OPTION_HORIZONTAL_MARGIN] = $horizontal_margin;
66
+ $obj->wp_options [AI_OPTION_VERTICAL_MARGIN] = $vertical_margin;
67
+ $obj->wp_options [AI_OPTION_ANIMATION] = $animation;
68
+ $obj->wp_options [AI_OPTION_CLOSE_BUTTON] = $close_button;
69
+ $obj->wp_options [AI_OPTION_PROCESS_PHP] = $process_php;
70
+ $obj->wp_options [AI_OPTION_SHOW_LABEL] = $show_label;
71
+
72
+ $adsense = $block == 0;
73
+ $sticky = false;
74
+ $class = '';
75
+ $sticky_parameters = '';
76
+ $functions = function_exists ('ai_load_settings_2');
77
+
78
+ if (!$adsense) {
79
+ switch ($alignment_type) {
80
+ case AI_ALIGNMENT_STICKY:
81
+ $sticky = true;
82
+ break;
83
+ case AI_ALIGNMENT_CUSTOM_CSS:
84
+ $custom_css = str_replace (' ', '', $custom_css_code);
85
+ if (strpos ($custom_css, 'position:fixed') !== false && strpos ($custom_css, 'z-index:') !== false) $sticky = true;
86
+ break;
87
+ }
88
+
89
+ $classes = array ();
90
+
91
+ $sticky_parameters = $obj->sticky_parameters ($classes, true);
92
+
93
+ // For non-sticky preview show close button only if enabled in block settings
94
+ if ($sticky || $close_button != AI_CLOSE_NONE) {
95
+ $classes [] = 'ai-close';
96
+ }
97
+
98
+ if ($sticky) {
99
+ $classes [] = 'hide';
100
+ }
101
+
102
+ if (count ($classes) != 0) {
103
+ $class = " class='" . trim (implode (' ', $classes)) . "'";
104
+ }
105
+ }
106
+
107
+ // Head code must be called before ai_getProcessedCode (to process head PHP)
108
+ ob_start ();
109
+ ai_wp_head_hook ();
110
+ if ($functions && !$ai_wp_data [AI_CLOSE_BUTTONS]) {
111
+ echo "<style type='text/css'>\n";
112
+ echo ".ai-close {position: relative;}\n";
113
+ echo ".ai-close-button {position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; background: url(".plugins_url ('css/images/close-button.png', AD_INSERTER_FILE).") no-repeat center center; cursor: pointer; z-index: 9; display: none;}\n";
114
+ echo ".ai-close-show {display: block;}\n";
115
+ echo ".ai-close-left {right: unset; left: -10px;}\n";
116
+ echo ".ai-close-bottom {top: unset; bottom: -11px;}\n";
117
+ echo ".ai-close-fit {width: fit-content; width: -moz-fit-content;}\n";
118
+ echo "</style>\n";
119
+ }
120
+ $head_code = ob_get_clean ();
121
+
122
+ // Disable AdSense Auto ads (page level ads)
123
+ $head_code = str_replace ('enable_page_level_ads', 'disabled_page_level_ads', $head_code);
124
+
125
+ $block_code = $obj->ai_getProcessedCode (true, true, true);
126
+
127
+ // Fix for relative urls
128
+ $block_code = str_replace ('src="wp-content', 'src="../wp-content', $block_code);
129
+ $block_code = str_replace ("src='wp-content", "src='../wp-content", $block_code);
130
+ $block_code = str_replace ('href="wp-content', 'href="../wp-content', $block_code);
131
+ $block_code = str_replace ("href='wp-content", "href='../wp-content", $block_code);
132
+
133
+ ?><html>
134
+ <head>
135
+ <title><?php echo AD_INSERTER_NAME; ?> <?php if ($sticky) echo 'Sticky '; ?>Code Preview</title>
136
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
137
+ <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
138
+ <script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'></script>
139
+ <link rel='stylesheet' href='https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'>
140
+ <script src='<?php echo plugins_url ('includes/js/jquery.mousewheel.min.js', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
141
+ <script src='<?php echo plugins_url ('includes/js/jquery.ui.spinner.js', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
142
+ <link rel='stylesheet' href='<?php echo plugins_url ('css/jquery.ui.spinner.css', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
143
+ <link rel='stylesheet' href='<?php echo plugins_url ('css/image-picker.css', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
144
+ <script src='<?php echo plugins_url ('includes/js/image-picker.js', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
145
+ <?php if ($functions) : ?>
146
+ <link rel='stylesheet' href='<?php echo plugins_url ('includes/aos/ai-aos.css', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION.rand (1, 10000000); ?>'>
147
+ <script src='<?php echo plugins_url ('includes/aos/aos.js', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
148
+ <?php endif; ?>
149
+ <script src='<?php echo plugins_url ('includes/js/ad-inserter-check.js', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'></script>
150
+ <link rel='stylesheet' href='<?php echo plugins_url ('css/ad-inserter.css', AD_INSERTER_FILE); ?>?ver=<?php echo AD_INSERTER_VERSION; ?>'>
151
+ <script>
152
+
153
+ ajaxurl = "<?php echo admin_url ('admin-ajax.php'); ?>";
154
+ var ai_preview = true;
155
+ <?php echo get_frontend_javascript_debugging () ? 'ai_debugging = true;' : ''; ?>
156
+ var sticky = <?php echo $sticky ? 'true' : 'false'; ?>;
157
+ var remove_transform = <?php echo $sticky && $sticky_parameters != '' ? 'true' : 'false'; ?>;
158
+
159
+ if (sticky) window.moveTo (0, 0);
160
+ if (sticky) window.resizeTo (screen.width, screen.height - 40);
161
+
162
+ const main_content_fixed_width = <?php echo is_numeric (get_main_content_element ()) ? "true" : "false"; ?>;
163
+ const main_content_shift = <?php echo is_numeric (get_main_content_element ()) ? (int) (get_main_content_element () / 2) : 0; ?>;
164
+
165
+ window.onkeydown = function( event ) {
166
+ if (event.keyCode === 27 ) {
167
+ window.close();
168
+ }
169
+ }
170
+
171
+ function initialize_preview () {
172
+
173
+ var debug = typeof ai_debugging !== 'undefined';
174
+ var block = <?php echo $block; ?>;
175
+ var code_blocks;
176
+ var spinning = false;
177
+
178
+ var wrapper = $('#wrapper');
179
+ var wrapping = wrapper.attr ("style") != "";
180
+
181
+ var spinner_margin_top;
182
+ var spinner_margin_bottom;
183
+ var spinner_margin_left;
184
+ var spinner_margin_right;
185
+ var spinner_padding_top;
186
+ var spinner_padding_bottom;
187
+ var spinner_padding_left;
188
+ var spinner_padding_right;
189
+
190
+ var spinner_horizontal_margin;
191
+ var spinner_vertical_margin;
192
+
193
+ var AI_ALIGNMENT_DEFAULT = 0;
194
+ var AI_ALIGNMENT_LEFT = 1;
195
+ var AI_ALIGNMENT_RIGHT = 2;
196
+ var AI_ALIGNMENT_CENTER = 3;
197
+ var AI_ALIGNMENT_FLOAT_LEFT = 4;
198
+ var AI_ALIGNMENT_FLOAT_RIGHT = 5;
199
+ var AI_ALIGNMENT_NO_WRAPPING = 6;
200
+ var AI_ALIGNMENT_CUSTOM_CSS = 7;
201
+ var AI_ALIGNMENT_STICKY_LEFT = 8;
202
+ var AI_ALIGNMENT_STICKY_RIGHT = 9;
203
+ var AI_ALIGNMENT_STICKY_TOP = 10;
204
+ var AI_ALIGNMENT_STICKY_BOTTOM = 11;
205
+ var AI_ALIGNMENT_STICKY = 12;
206
+
207
+ var AI_CLOSE_NONE = 0;
208
+ var AI_CLOSE_TOP_RIGHT = 1;
209
+ var AI_CLOSE_TOP_LEFT = 2;
210
+ var AI_CLOSE_BOTTOM_RIGHT = 3;
211
+ var AI_CLOSE_BOTTOM_LEFT = 4;
212
+
213
+ var AI_STICK_TO_THE_LEFT = 0;
214
+ var AI_STICK_TO_THE_CONTENT_LEFT = 1;
215
+ var AI_STICK_HORIZONTAL_CENTER = 2;
216
+ var AI_STICK_TO_THE_CONTENT_RIGHT = 3;
217
+ var AI_STICK_TO_THE_RIGHT = 4;
218
+
219
+ var AI_STICK_TO_THE_TOP = 0;
220
+ var AI_STICK_VERTICAL_CENTER = 1;
221
+ var AI_SCROLL_WITH_THE_CONTENT = 2;
222
+ var AI_STICK_TO_THE_BOTTOM = 3;
223
+
224
+ var AI_ANIMATION_NONE = 0;
225
+ var AI_ANIMATION_FADE = 1;
226
+ var AI_ANIMATION_SLIDE = 2;
227
+ var AI_ANIMATION_SLIDE_FADE = 3;
228
+ var AI_ANIMATION_FLIP = 4;
229
+ var AI_ANIMATION_ZOOM_IN = 5;
230
+ var AI_ANIMATION_ZOOM_OUT = 6;
231
+ var AI_ANIMATION_TURN = 7;
232
+
233
+ var STICKY_CONTEXT_NONE = 0;
234
+ var STICKY_CONTEXT_INIT = 1;
235
+ var STICKY_CONTEXT_BLOCK_ALIGNMENT = 2;
236
+ var STICKY_CONTEXT_HORIZONTAL_POSITION = 3;
237
+ var STICKY_CONTEXT_VERTICAL_POSITION = 4;
238
+ var STICKY_CONTEXT_SPINNER = 5;
239
+ var STICKY_CONTEXT_CUSTOM_CSS = 6;
240
+ var STICKY_CONTEXT_ANIMATION = 7;
241
+
242
+ var sticky_context = STICKY_CONTEXT_INIT;
243
+
244
+ const ID_CSS_ALIGNMENT_DEFAULT = "#css-" + AI_ALIGNMENT_DEFAULT;
245
+ const ID_CSS_ALIGNMENT_LEFT = "#css-" + AI_ALIGNMENT_LEFT;
246
+ const ID_CSS_ALIGNMENT_RIGHT = "#css-" + AI_ALIGNMENT_RIGHT;
247
+ const ID_CSS_ALIGNMENT_CENTER = "#css-" + AI_ALIGNMENT_CENTER;
248
+ const ID_CSS_ALIGNMENT_FLOAT_LEFT = "#css-" + AI_ALIGNMENT_FLOAT_LEFT;
249
+ const ID_CSS_ALIGNMENT_FLOAT_RIGHT = "#css-" + AI_ALIGNMENT_FLOAT_RIGHT;
250
+ const ID_CSS_ALIGNMENT_STICKY_LEFT = "#css-" + AI_ALIGNMENT_STICKY_LEFT;
251
+ const ID_CSS_ALIGNMENT_STICKY_RIGHT = "#css-" + AI_ALIGNMENT_STICKY_RIGHT;
252
+ const ID_CSS_ALIGNMENT_STICKY_TOP = "#css-" + AI_ALIGNMENT_STICKY_TOP;
253
+ const ID_CSS_ALIGNMENT_STICKY_BOTTOM = "#css-" + AI_ALIGNMENT_STICKY_BOTTOM;
254
+ const ID_CSS_ALIGNMENT_STICKY = "#css-" + AI_ALIGNMENT_STICKY;
255
+
256
+ const AI_ALIGNMENT_CSS_STICKY = '<?php echo AI_ALIGNMENT_CSS_STICKY; ?>';
257
+
258
+ function update_highlighting () {
259
+ if ($('body').hasClass ("highlighted")) {
260
+ $("#highlight-button").click ();
261
+ $("#highlight-button").click ();
262
+ }
263
+ }
264
+
265
+ function update_width () {
266
+ $("#screen-width").text (window.innerWidth + " px");
267
+ if (window.innerWidth != $(window).width()) $("#right-arrow").hide (); else $("#right-arrow").show ();
268
+ }
269
+
270
+ function update_wrapper_size () {
271
+ if (typeof wrapper.width () != 'undefined' && typeof wrapper.height () != 'undefined') {
272
+ var width = parseInt (wrapper.width ());
273
+ var height = parseInt (wrapper.height ());
274
+ $(".wrapper-size").html (width + "px &nbsp;&times;&nbsp; " + height + "px").show ();
275
+ if (width * height != 0) $(".wrapper-size").css ("color", "#333"); else $(".wrapper-size").css ("color", "#c00");
276
+ }
277
+ }
278
+
279
+ $(window).resize(function() {
280
+ update_highlighting ();
281
+ update_width ();
282
+ update_wrapper_size ();
283
+ });
284
+
285
+ function load_from_settings () {
286
+
287
+ if (window.opener != null && !window.opener.closed) {
288
+ var settings = $(window.opener.document).contents();
289
+
290
+
291
+ // // Replace document.write for old code that uses document.write
292
+ // // Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
293
+ // var oldDocumentWrite = document.write;
294
+ // document.write = function(node){
295
+ // wrapper.append (node)
296
+ // }
297
+
298
+ // var simple_editor_switch = settings.find ('input#simple-editor-' + block);
299
+ // if (!simple_editor_switch.is(":checked")) {
300
+ // settings.find ('input#simple-editor-' + block).click ();
301
+ // settings.find ('input#simple-editor-' + block).click ();
302
+ // }
303
+ // var code = settings.find ("#block-" + block).val();
304
+ // wrapper.html (code);
305
+
306
+ // // Restore document.write
307
+ // setTimeout (function() {
308
+ // document.write = oldDocumentWrite
309
+ // }, 1000);
310
+
311
+ // console.log (settings.find ("select#block-alignment-" + block + " option:selected").attr('value'));
312
+
313
+ $("select#block-alignment").val (settings.find ("select#block-alignment-" + block + " option:selected").attr('value')).change();
314
+ $("select#block-alignment option:selected").data ('alt-style', '1');
315
+ $("#custom-css").val (settings.find ("#custom-css-" + block).val ());
316
+ $("#block-name").text (settings.find ("#name-label-" + block).text ());
317
+ $("select#close-button-0").val (settings.find ("select#close-button-" + block + " option:selected").attr('value')).change();
318
+
319
+ if (sticky) {
320
+ var alignment = $("select#block-alignment option:selected").attr ('value');
321
+
322
+ if (alignment == AI_ALIGNMENT_CUSTOM_CSS) {
323
+ spinner_horizontal_margin.spinner ("value", extract_horizontal_margin ($("#custom-css").val ()));
324
+ spinner_vertical_margin.spinner ("value", extract_vertical_margin ($("#custom-css").val ()));
325
+ } else {
326
+ spinner_horizontal_margin.spinner ("value", settings.find ("#horizontal-margin-" + block).val ());
327
+ spinner_vertical_margin.spinner ("value", settings.find ("#vertical-margin-" + block).val ());
328
+ }
329
+ $("select#horizontal-position").val (settings.find ("select#horizontal-position-" + block + " option:selected").attr('value')).change();
330
+ $("select#vertical-position").val (settings.find ("select#vertical-position-" + block + " option:selected").attr('value')).change();
331
+ $("select#animation").val (settings.find ("select#animation-" + block + " option:selected").attr('value')).change();
332
+ }
333
+
334
+ process_display_elements ();
335
+ }
336
+ }
337
+
338
+ function apply_to_settings () {
339
+ if (window.opener != null && !window.opener.closed) {
340
+ var settings = $(window.opener.document).contents ();
341
+
342
+ var selected_alignment = $("select#block-alignment option:selected");
343
+ var new_alignment = selected_alignment.attr('value');
344
+ var new_custom_css = $("#custom-css").val ();
345
+ var new_close_button = $("select#close-button-0 option:selected").attr('value');
346
+
347
+ var alt_styles = selected_alignment.data ('alt-styles');
348
+ if (typeof alt_styles != 'undefined') {
349
+ css_index = selected_alignment.data ('alt-style')
350
+ if (css_index != 1) {
351
+ new_alignment = AI_ALIGNMENT_CUSTOM_CSS;
352
+ new_custom_css = alt_styles ['css' + css_index].replace (/\"/g, "'");
353
+ }
354
+ }
355
+
356
+ settings.find ("select#block-alignment-" + block).val (new_alignment).change ();
357
+ if (new_alignment == AI_ALIGNMENT_CUSTOM_CSS) {
358
+ settings.find ("#custom-css-" + block).val (new_custom_css);
359
+ }
360
+ settings.find ("select#close-button-" + block).val (new_close_button);
361
+ settings.find ("select#close-button2-" + block).val (new_close_button);
362
+
363
+ if (sticky) {
364
+ var new_horizontal_position = $("select#horizontal-position option:selected").attr('value');
365
+ settings.find ("select#horizontal-position-" + block).val (new_horizontal_position);
366
+
367
+ var new_vertical_position = $("select#vertical-position option:selected").attr('value');
368
+ settings.find ("select#vertical-position-" + block).val (new_vertical_position);
369
+
370
+ var new_horizontal_margin = spinner_horizontal_margin.spinner ("value");
371
+ settings.find ("input#horizontal-margin-" + block).val (new_horizontal_margin);
372
+
373
+ var new_vertical_margin = spinner_vertical_margin.spinner ("value");
374
+ settings.find ("input#vertical-margin-" + block).val (new_vertical_margin);
375
+
376
+ var new_animation = $("select#animation option:selected").attr('value');
377
+ settings.find ("select#animation-" + block).val (new_animation).change ();
378
+ }
379
+
380
+ window.opener.change_block_alignment (block);
381
+ }
382
+ }
383
+
384
+ function update_focused_spinner (event) {
385
+ if (sticky) {
386
+ if (spinner_horizontal_margin.is (":focus")) spinner_horizontal_margin.spinner( "stepUp", event.deltaY); else
387
+ if (spinner_vertical_margin.is (":focus")) spinner_vertical_margin.spinner( "stepUp", event.deltaY);
388
+ } else {
389
+ if (spinner_margin_top.is (":focus")) spinner_margin_top.spinner( "stepUp", event.deltaY); else
390
+ if (spinner_margin_bottom.is (":focus")) spinner_margin_bottom.spinner( "stepUp", event.deltaY); else
391
+ if (spinner_margin_left.is (":focus")) spinner_margin_left.spinner( "stepUp", event.deltaY); else
392
+ if (spinner_margin_right.is (":focus")) spinner_margin_right.spinner( "stepUp", event.deltaY); else
393
+ if (spinner_padding_top.is (":focus")) spinner_padding_top.spinner( "stepUp", event.deltaY); else
394
+ if (spinner_padding_bottom.is (":focus")) spinner_padding_bottom.spinner( "stepUp", event.deltaY); else
395
+ if (spinner_padding_left.is (":focus")) spinner_padding_left.spinner( "stepUp", event.deltaY); else
396
+ if (spinner_padding_right.is (":focus")) spinner_padding_right.spinner( "stepUp", event.deltaY);
397
+ }
398
+ }
399
+
400
+
401
+ $(window).on ('mousewheel', function (event) {
402
+ if (!spinning) update_focused_spinner (event);
403
+ });
404
+
405
+
406
+ function create_spinner (selector, css_parameter, alignment) {
407
+ var spinner_element = $(selector).spinner ({
408
+ alignment: alignment,
409
+ start: function (event, ui) {
410
+ spinning = true;
411
+ if (!$(this).is (":focus")) {
412
+ update_focused_spinner (event)
413
+ event.preventDefault();
414
+ }
415
+ },
416
+ stop: function (event, ui) {
417
+ spinning = false;
418
+ wrapper.css (css_parameter, $(this).spinner ("value") + "px");
419
+ wrapper.attr ("data-css", wrapper.attr ('style'))
420
+ update_custom_css ();
421
+ update_highlighting ();
422
+ update_wrapper_size ();
423
+ }
424
+ }).spinner ("option", "mouseWheel", true).spinner ("option", "min", 0).spinner ("option", "max", 600).spinner ("value", parseInt (wrapper.css (css_parameter))).show ();
425
+
426
+ return spinner_element;
427
+ }
428
+
429
+ function create_spinner_sticky (selector, alignment) {
430
+ var spinner_element = $(selector).spinner ({
431
+ alignment: alignment,
432
+ start: function (event, ui) {
433
+ spinning = true;
434
+ if (!$(this).is (":focus")) {
435
+ update_focused_spinner (event)
436
+ event.preventDefault();
437
+ }
438
+ },
439
+ stop: function (event, ui) {
440
+ spinning = false;
441
+
442
+ if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_SPINNER;
443
+
444
+ update_sticky_css (STICKY_CONTEXT_SPINNER);
445
+ process_display_elements ();
446
+ update_close_button ();
447
+
448
+ update_sticky_elements (STICKY_CONTEXT_SPINNER);
449
+
450
+ var new_css = $('#css-' + AI_ALIGNMENT_STICKY).text ();
451
+ wrapper.attr ('data-css', new_css);
452
+ wrapper.attr ('style', new_css);
453
+ if (remove_transform) wrapper.css ('transform', '');
454
+ update_custom_css ();
455
+ update_sticky_elements (STICKY_CONTEXT_SPINNER);
456
+ update_highlighting ();
457
+
458
+ if (sticky_context == STICKY_CONTEXT_SPINNER) sticky_context = STICKY_CONTEXT_NONE;
459
+ }
460
+ }).spinner ("option", "mouseWheel", true).spinner ("option", "min", 0).spinner ("option", "max", 600).show ();
461
+
462
+ return spinner_element;
463
+ }
464
+
465
+
466
+ function process_display_elements () {
467
+
468
+ // console.log ('process_display_elements');
469
+
470
+ var style = "";
471
+ $("#css-label").css('display', 'inline-block');
472
+ $("#edit-css-button").css('display', 'inline-block');
473
+
474
+ $(ID_CSS_ALIGNMENT_DEFAULT).hide();
475
+ $(ID_CSS_ALIGNMENT_LEFT).hide();
476
+ $("#css-" + AI_ALIGNMENT_RIGHT).hide();
477
+ $("#css-" + AI_ALIGNMENT_CENTER).hide();
478
+ $("#css-" + AI_ALIGNMENT_FLOAT_LEFT).hide();
479
+ $("#css-" + AI_ALIGNMENT_FLOAT_RIGHT).hide();
480
+ $("#css-" + AI_ALIGNMENT_STICKY_LEFT).hide();
481
+ $("#css-" + AI_ALIGNMENT_STICKY_RIGHT).hide();
482
+ $("#css-" + AI_ALIGNMENT_STICKY_TOP).hide();
483
+ $("#css-" + AI_ALIGNMENT_STICKY_BOTTOM).hide();
484
+ $("#css-" + AI_ALIGNMENT_STICKY).hide();
485
+ $("#custom-css").hide();
486
+ $("#css-no-wrapping").hide();
487
+
488
+ $("#demo-box").show ();
489
+ $("#demo-box-no-wrapping").hide ();
490
+ wrapping = true;
491
+
492
+ $("#css-index").text ('');
493
+
494
+ var selected_alignment = $("select#block-alignment option:selected");
495
+ var alignment = selected_alignment.attr ('value');
496
+ var alt_styles = selected_alignment.data ('alt-styles');
497
+ if (typeof alt_styles != 'undefined') {
498
+ var alt_style_index = selected_alignment.data ('alt-style');
499
+ var num_styles = Object.keys(alt_styles).length;
500
+ if (alt_style_index > num_styles) {
501
+ alt_style_index = 1;
502
+ }
503
+ $('#css-' + alignment).text (alt_styles ['css' + alt_style_index].replace (/\"/g, "'"));
504
+ if (num_styles > 1) {
505
+ $("#css-index").text (alt_style_index);
506
+ }
507
+ }
508
+
509
+ if (alignment == AI_ALIGNMENT_DEFAULT) {
510
+ $(ID_CSS_ALIGNMENT_DEFAULT).css('display', 'inline-block');
511
+ style = $(ID_CSS_ALIGNMENT_DEFAULT).text ();
512
+ } else
513
+ if (alignment == AI_ALIGNMENT_LEFT) {
514
+ $(ID_CSS_ALIGNMENT_LEFT).css('display', 'inline-block');
515
+ style = $(ID_CSS_ALIGNMENT_LEFT).text ();
516
+ } else
517
+ if (alignment == AI_ALIGNMENT_RIGHT) {
518
+ $(ID_CSS_ALIGNMENT_RIGHT).css('display', 'inline-block');
519
+ style = $(ID_CSS_ALIGNMENT_RIGHT).text ();
520
+ } else
521
+ if (alignment == AI_ALIGNMENT_CENTER) {
522
+ $(ID_CSS_ALIGNMENT_CENTER).css('display', 'inline-block');
523
+ style = $(ID_CSS_ALIGNMENT_CENTER).text ();
524
+ } else
525
+ if (alignment == AI_ALIGNMENT_FLOAT_LEFT) {
526
+ $(ID_CSS_ALIGNMENT_FLOAT_LEFT).css('display', 'inline-block');
527
+ style = $(ID_CSS_ALIGNMENT_FLOAT_LEFT).text ();
528
+ } else
529
+ if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
530
+ $(ID_CSS_ALIGNMENT_FLOAT_RIGHT).css('display', 'inline-block');
531
+ style = $(ID_CSS_ALIGNMENT_FLOAT_RIGHT).text ();
532
+ } else
533
+ if (alignment == AI_ALIGNMENT_STICKY_LEFT) {
534
+ $(ID_CSS_ALIGNMENT_STICKY_LEFT).css('display', 'inline-block');
535
+ style = $(ID_CSS_ALIGNMENT_STICKY_LEFT).text ();
536
+ } else
537
+ if (alignment == AI_ALIGNMENT_STICKY_RIGHT) {
538
+ $(ID_CSS_ALIGNMENT_STICKY_RIGHT).css('display', 'inline-block');
539
+ style = $(ID_CSS_ALIGNMENT_STICKY_RIGHT).text ();
540
+ } else
541
+ if (alignment == AI_ALIGNMENT_STICKY_TOP) {
542
+ $(ID_CSS_ALIGNMENT_STICKY_TOP).css('display', 'inline-block');
543
+ style = $(ID_CSS_ALIGNMENT_STICKY_TOP).text ();
544
+ } else
545
+ if (alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
546
+ $(ID_CSS_ALIGNMENT_STICKY_BOTTOM).css('display', 'inline-block');
547
+ style = $(ID_CSS_ALIGNMENT_STICKY_BOTTOM).text ();
548
+ } else
549
+ if (alignment == AI_ALIGNMENT_STICKY) {
550
+ $(ID_CSS_ALIGNMENT_STICKY).css('display', 'inline-block');
551
+ style = $(ID_CSS_ALIGNMENT_STICKY).text ();
552
+ } else
553
+ if (alignment == AI_ALIGNMENT_CUSTOM_CSS) {
554
+ $("#custom-css").show();
555
+ style = $("#custom-css").val ();
556
+ } else
557
+ if (alignment == AI_ALIGNMENT_NO_WRAPPING) {
558
+ $("#css-no-wrapping").css('display', 'inline-block');
559
+ $("#css-label").hide();
560
+ $("#edit-css-button").hide();
561
+
562
+ wrapping = false;
563
+ style = "";
564
+
565
+ $("#demo-box").hide ();
566
+ $("#demo-box-no-wrapping").show ();
567
+ }
568
+
569
+ wrapper.attr ("data-css", style);
570
+ wrapper.attr ("style", style);
571
+ if (remove_transform) wrapper.css ('transform', '');
572
+
573
+ // console.log ('process_display_elements');
574
+
575
+ if (wrapping) update_margin_padding ();
576
+
577
+ update_highlighting ();
578
+ update_wrapper_size ();
579
+ }
580
+
581
+ function update_custom_css () {
582
+
583
+ // console.log ('update_custom_css');
584
+
585
+ $("#custom-css").val (wrapper.attr ("data-css"));
586
+ if (!sticky) {
587
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
588
+ $("#edit-css-button").click ();
589
+ }
590
+ }
591
+
592
+ function ai_css_value_px (css, property) {
593
+ var value = '';
594
+
595
+ styles = css.split (';');
596
+ styles.forEach ((style, index) => {
597
+ style = style.trim ();
598
+ if (style.indexOf (property) == 0) {
599
+ style_parts = style.split (':');
600
+ if (style_parts.length == 2) {
601
+ style_property = style_parts [0].trim ();
602
+ style_value = style_parts [1].trim ();
603
+ if (style_property == property && style_value.endsWith ('px')) {
604
+ value = parseInt (style_value);
605
+ }
606
+ }
607
+ }
608
+ });
609
+
610
+ return value;
611
+ }
612
+
613
+ function extract_horizontal_margin (style) {
614
+ var horizontal_margin = '';
615
+
616
+ if (style !== '') {
617
+ horizontal_margin = ai_css_value_px (style, 'left');
618
+ if (horizontal_margin == '') horizontal_margin = ai_css_value_px (style, 'right');
619
+ if (horizontal_margin == '') horizontal_margin = ai_css_value_px (style, 'margin-left');
620
+ if (horizontal_margin == '') horizontal_margin = ai_css_value_px (style, 'margin-right');
621
+
622
+ if (isNaN (horizontal_margin)) horizontal_margin = '';
623
+ }
624
+
625
+ return horizontal_margin;
626
+ }
627
+
628
+ function extract_vertical_margin (style) {
629
+ var vertical_margin = '';
630
+
631
+ if (style !== '') {
632
+ vertical_margin = ai_css_value_px (style, 'top');
633
+ if (vertical_margin == '') vertical_margin = ai_css_value_px (style, 'bottom');
634
+
635
+ if (isNaN (vertical_margin)) vertical_margin = '';
636
+ }
637
+
638
+ return vertical_margin;
639
+ }
640
+
641
+ function update_margin_padding () {
642
+ if (wrapping) {
643
+ if (sticky) {
644
+ if (sticky_context == STICKY_CONTEXT_CUSTOM_CSS) {
645
+ spinner_horizontal_margin.spinner ("value", extract_horizontal_margin (wrapper.attr ('data-css')));
646
+ spinner_vertical_margin.spinner ("value", extract_vertical_margin (wrapper.attr ('data-css')));
647
+ }
648
+ } else {
649
+ spinner_margin_top.spinner ("value", parseInt (wrapper.css ("margin-top")));
650
+ spinner_margin_bottom.spinner ("value", parseInt (wrapper.css ("margin-bottom")));
651
+ spinner_margin_left.spinner ("value", parseInt (wrapper.css ("margin-left")));
652
+ spinner_margin_right.spinner ("value", parseInt (wrapper.css ("margin-right")));
653
+ spinner_padding_top.spinner ("value", parseInt (wrapper.css ("padding-top")));
654
+ spinner_padding_bottom.spinner ("value", parseInt (wrapper.css ("padding-bottom")));
655
+ spinner_padding_left.spinner ("value", parseInt (wrapper.css ("padding-left")));
656
+ spinner_padding_right.spinner ("value", parseInt (wrapper.css ("padding-right")));
657
+ }
658
+ }
659
+ }
660
+
661
+ function update_close_button () {
662
+ var close_button = wrapper.find ('.ai-close-button');
663
+ if (wrapper.hasClass ('ai-close') && typeof close_button != 'undefined') {
664
+
665
+ var alignment = $("select#block-alignment option:selected").attr ('value');
666
+
667
+ if (alignment != AI_ALIGNMENT_NO_WRAPPING) {
668
+ $("#close-button-selection").show ();
669
+
670
+ var selected_close_button = $("#close-button-0 option:selected").attr('value');
671
+ var button_class = 'ai-close-button';
672
+
673
+ switch (parseInt (selected_close_button)) {
674
+ case AI_CLOSE_NONE:
675
+ button_class = 'ai-close-button ai-close-hidden';
676
+ break;
677
+ case AI_CLOSE_TOP_RIGHT:
678
+ button_class = 'ai-close-button';
679
+ break;
680
+ case AI_CLOSE_TOP_LEFT:
681
+ button_class = 'ai-close-button ai-close-left';
682
+ break;
683
+ case AI_CLOSE_BOTTOM_RIGHT:
684
+ button_class = 'ai-close-button ai-close-bottom';
685
+ break;
686
+ case AI_CLOSE_BOTTOM_LEFT:
687
+ button_class = 'ai-close-button ai-close-bottom ai-close-left';
688
+ break;
689
+ }
690
+
691
+ close_button.attr ('class', button_class);
692
+ } else {
693
+ $("#close-button-selection").hide ();
694
+ close_button.addClass ('ai-close-hidden');
695
+ }
696
+ }
697
+ }
698
+
699
+ function get_sticky_classes (custom_css) {
700
+
701
+ const SETTINGS = $(window.opener.document).contents();
702
+ const MAIN_CONTENT_ELEMENT = SETTINGS.find ('#main-content-element').val ().trim ();
703
+ const MAIN_CONTENT_FIXED_WIDTH = parseInt (MAIN_CONTENT_ELEMENT) == MAIN_CONTENT_ELEMENT;
704
+
705
+ custom_css = custom_css.replace (/\s+/g, '');
706
+ var sticky_classes = [];
707
+
708
+ if (custom_css.indexOf ("position:fixed") != - 1 &&
709
+ custom_css.indexOf ("z-index:") != - 1 &&
710
+ custom_css.indexOf ("display:none") != - 1) {
711
+ if (!MAIN_CONTENT_FIXED_WIDTH &&
712
+ custom_css.indexOf (";left:auto") != - 1) {
713
+ sticky_classes.push ('ai-sticky-content');
714
+ sticky_classes.push ('ai-sticky-left');
715
+ } else
716
+ if (!MAIN_CONTENT_FIXED_WIDTH &&
717
+ custom_css.indexOf ("right:auto") != - 1) {
718
+ sticky_classes.push ('ai-sticky-content');
719
+ sticky_classes.push ('ai-sticky-right');
720
+ };
721
+
722
+ if (custom_css.indexOf ("margin-bottom:auto") != - 1) {
723
+ sticky_classes.push ('ai-sticky-content');
724
+ sticky_classes.push ('ai-sticky-scroll');
725
+ };
726
+ }
727
+
728
+ // console.log ('sticky_classes', sticky_classes);
729
+
730
+ return sticky_classes;
731
+ }
732
+
733
+ function update_sticky_css (context) {
734
+
735
+ // console.log ('update_sticky_css', context, 'sticky_context', sticky_context);
736
+
737
+ if (sticky_context != context) return;
738
+
739
+ var alignment = parseInt ($("select#block-alignment option:selected").attr ('value'));
740
+ var horizontal_position = parseInt ($("select#horizontal-position option:selected").attr('value'));
741
+ var vertical_position = parseInt ($("select#vertical-position option:selected").attr('value'));
742
+
743
+ if (alignment != AI_ALIGNMENT_CUSTOM_CSS) {
744
+ var selected_horizontal_position = $("select#horizontal-position option:selected");
745
+ var selected_vertical_position = $("select#vertical-position option:selected");
746
+
747
+ var custom_vertical_position_css = selected_vertical_position.data ('css-' + horizontal_position);
748
+
749
+ if (typeof custom_vertical_position_css != 'undefined') var vertical_position_css = custom_vertical_position_css; else
750
+ var vertical_position_css = selected_vertical_position.data ('css');
751
+
752
+ var custom_horizontal_position_css = selected_horizontal_position.data ('css-' + vertical_position);
753
+
754
+ if (typeof custom_horizontal_position_css != 'undefined') var horizontal_position_css = custom_horizontal_position_css; else
755
+ var horizontal_position_css = selected_horizontal_position.data ('css');
756
+
757
+ var sticky_css = vertical_position_css + horizontal_position_css;
758
+ } else {
759
+ var sticky_css = $('#css-' + AI_ALIGNMENT_STICKY + ' .ai-sticky-css').text ();
760
+ }
761
+
762
+ var vertical_margin = spinner_vertical_margin.spinner ("value");
763
+ var horizontal_margin = spinner_horizontal_margin.spinner ("value");
764
+
765
+ if (vertical_margin == null) vertical_margin = '';
766
+ if (horizontal_margin == null) horizontal_margin = '';
767
+
768
+ sticky_css = window.opener.update_sticky_margins (sticky_css, horizontal_margin, vertical_margin);
769
+
770
+ if (main_content_fixed_width && parseInt (alignment) == AI_ALIGNMENT_STICKY) {
771
+ if (horizontal_position == AI_STICK_TO_THE_CONTENT_LEFT) {
772
+ sticky_css = sticky_css + ' right: calc(50% + ' + main_content_shift + 'px); display: block;';
773
+ }
774
+ if (horizontal_position == AI_STICK_TO_THE_CONTENT_RIGHT) {
775
+ sticky_css = sticky_css + ' left: calc(50% + ' + main_content_shift + 'px); display: block;';
776
+ }
777
+ }
778
+
779
+ $('#css-' + AI_ALIGNMENT_STICKY + ' .ai-sticky-css').text (sticky_css);
780
+
781
+ wrapper.removeClass ('ai-sticky-content').removeClass ('ai-sticky-left').removeClass ('ai-sticky-right').removeClass ('ai-sticky-scroll');
782
+
783
+ switch (parseInt (alignment)) {
784
+ case AI_ALIGNMENT_STICKY:
785
+ if (!main_content_fixed_width) {
786
+ if (horizontal_position == AI_STICK_TO_THE_CONTENT_LEFT) {
787
+ wrapper.addClass ('ai-sticky-content');
788
+ wrapper.addClass ('ai-sticky-left');
789
+ } else
790
+ if (horizontal_position == AI_STICK_TO_THE_CONTENT_RIGHT) {
791
+ wrapper.addClass ('ai-sticky-content');
792
+ wrapper.addClass ('ai-sticky-right');
793
+ }
794
+ }
795
+
796
+ if (vertical_position == AI_SCROLL_WITH_THE_CONTENT) {
797
+ wrapper.addClass ('ai-sticky-content');
798
+ wrapper.addClass ('ai-sticky-scroll');
799
+ }
800
+ break;
801
+ case AI_ALIGNMENT_CUSTOM_CSS:
802
+ var custom_css = $("#custom-css").val ().replace (/\s+/g, '');
803
+
804
+ sticky_classes = [];
805
+ if (window.opener != null && !window.opener.closed) {
806
+ sticky_classes = get_sticky_classes (custom_css);
807
+ }
808
+
809
+ // console.log ('sticky_classes', sticky_classes);
810
+
811
+ sticky_classes.forEach(function (sticky_class) {
812
+ wrapper.addClass (sticky_class);
813
+ });
814
+ break;
815
+ }
816
+
817
+ wrapper.removeClass ('ai-center-h').removeClass ('ai-center-v').removeClass ('ai-sticky-turn');
818
+ wrapper.attr ('data-aos', '');
819
+
820
+ var animation = parseInt ($("select#animation option:selected").attr ('value'));
821
+
822
+ var data_aos = '';
823
+ var direction = '';
824
+
825
+ switch (horizontal_position) {
826
+ case AI_STICK_TO_THE_LEFT:
827
+ case AI_STICK_TO_THE_CONTENT_LEFT:
828
+ direction = 'right';
829
+ break;
830
+ case AI_STICK_HORIZONTAL_CENTER:
831
+ wrapper.addClass ('ai-center-h');
832
+ switch (vertical_position) {
833
+ case AI_STICK_TO_THE_TOP:
834
+ case AI_SCROLL_WITH_THE_CONTENT:
835
+ direction = 'down';
836
+ break;
837
+ case AI_STICK_VERTICAL_CENTER:
838
+ direction = 'left';
839
+ switch (animation) {
840
+ case AI_ANIMATION_SLIDE:
841
+ case AI_ANIMATION_SLIDE_FADE:
842
+ animation = AI_ANIMATION_FADE;
843
+ break;
844
+ case AI_ANIMATION_ZOOM_IN:
845
+ case AI_ANIMATION_ZOOM_OUT:
846
+ direction = 'up';
847
+ break;
848
+ }
849
+ break;
850
+ case AI_STICK_TO_THE_BOTTOM:
851
+ direction = 'up';
852
+ break;
853
+ }
854
+ break;
855
+ case AI_STICK_TO_THE_CONTENT_RIGHT:
856
+ case AI_STICK_TO_THE_RIGHT:
857
+ direction = 'left';
858
+ break;
859
+ }
860
+
861
+ if (vertical_position == AI_STICK_VERTICAL_CENTER) wrapper.addClass ('ai-center-v');
862
+
863
+ // console.log ('direction', direction);
864
+ // console.log ('animation', animation);
865
+ // console.log ('horizontal_position', horizontal_position);
866
+
867
+ switch (horizontal_position) {
868
+ case AI_STICK_TO_THE_LEFT:
869
+ if (animation == AI_ANIMATION_TURN) direction = 'left';
870
+ break;
871
+ case AI_STICK_TO_THE_RIGHT:
872
+ if (animation == AI_ANIMATION_TURN) direction = 'right';
873
+ break;
874
+ case AI_STICK_TO_THE_CONTENT_LEFT:
875
+ case AI_STICK_TO_THE_CONTENT_RIGHT:
876
+ if (animation == AI_ANIMATION_SLIDE) animation = AI_ANIMATION_SLIDE_FADE;
877
+ break;
878
+ }
879
+
880
+ switch (animation) {
881
+ case AI_ANIMATION_FADE:
882
+ data_aos = 'fade';
883
+ break;
884
+ case AI_ANIMATION_SLIDE:
885
+ data_aos = 'slide-' + direction;
886
+ break;
887
+ case AI_ANIMATION_SLIDE_FADE:
888
+ data_aos = 'fade-' + direction;
889
+ break;
890
+ case AI_ANIMATION_TURN:
891
+ wrapper.addClass ('ai-sticky-turn');
892
+ data_aos = 'flip-' + direction;
893
+ break;
894
+ case AI_ANIMATION_FLIP:
895
+ if (direction == 'right') direction = 'left'; else
896
+ if (direction == 'left') direction = 'right';
897
+ data_aos = 'flip-' + direction;
898
+ break;
899
+ case AI_ANIMATION_ZOOM_IN:
900
+ data_aos = 'zoom-in-' + direction;
901
+ break;
902
+ case AI_ANIMATION_ZOOM_OUT:
903
+ data_aos = 'zoom-out-' + direction;
904
+ break;
905
+ }
906
+
907
+ remove_transform = false;
908
+ if (data_aos != '') {
909
+ wrapper.attr ('data-aos', data_aos);
910
+ remove_transform = true;
911
+ }
912
+ }
913
+
914
+ function update_sticky_elements (context) {
915
+
916
+ // console.log ('update_sticky_elements', context, 'sticky_context', sticky_context);
917
+
918
+ if (sticky_context != context) return;
919
+
920
+ if (sticky_context == STICKY_CONTEXT_INIT) {
921
+ setTimeout (function() {ai_process_sticky_elements (jQuery);}, 100);
922
+ } else ai_process_sticky_elements (jQuery);
923
+ }
924
+
925
+ var start_time = new Date().getTime();
926
+
927
+ if (sticky) {
928
+ spinner_horizontal_margin = create_spinner_sticky ("#spinner-horizontal-margin", "horizontal").spinner ("option", "min", - 600);
929
+ spinner_vertical_margin = create_spinner_sticky ("#spinner-vertical-margin", "horizontal").spinner ("option", "min", - 600);
930
+
931
+ spinner_horizontal_margin.spinner ("value", <?php echo $horizontal_margin; ?>);
932
+ spinner_vertical_margin.spinner ("value", <?php echo $vertical_margin; ?>);
933
+ } else {
934
+ spinner_margin_top = create_spinner ("#spinner-margin-top", "margin-top", "horizontal").spinner ("option", "min", - $("#p1").outerHeight (true));
935
+ spinner_margin_bottom = create_spinner ("#spinner-margin-bottom", "margin-bottom", "horizontal").spinner ("option", "min", - $("#p1").outerHeight (true));
936
+ spinner_margin_left = create_spinner ("#spinner-margin-left", "margin-left", "vertical").spinner ("option", "min", - 600);
937
+ spinner_margin_right = create_spinner ("#spinner-margin-right", "margin-right", "vertical").spinner ("option", "min", - 600);
938
+ spinner_padding_top = create_spinner ("#spinner-padding-top", "padding-top", "horizontal");
939
+ spinner_padding_bottom = create_spinner ("#spinner-padding-bottom", "padding-bottom", "horizontal");
940
+ spinner_padding_left = create_spinner ("#spinner-padding-left", "padding-left", "vertical");
941
+ spinner_padding_right = create_spinner ("#spinner-padding-right", "padding-right", "vertical");
942
+ }
943
+
944
+ $("select#block-alignment").change (function() {
945
+
946
+ if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_BLOCK_ALIGNMENT;
947
+
948
+ var alignment = $("select#block-alignment option:selected").attr ('value');
949
+
950
+ if (sticky && sticky_context == STICKY_CONTEXT_BLOCK_ALIGNMENT && alignment == AI_ALIGNMENT_CUSTOM_CSS) {
951
+ if ($("input#custom-css").val () == '') {
952
+ var vertical_margin = spinner_vertical_margin.spinner ("value");
953
+ var horizontal_margin = spinner_horizontal_margin.spinner ("value");
954
+
955
+ $('#css-' + AI_ALIGNMENT_STICKY + ' .ai-sticky-css').text (' top: ' + vertical_margin + 'px; left: ' + horizontal_margin + 'px;');
956
+ $("input#custom-css").val ($('#css-' + AI_ALIGNMENT_STICKY).text ());
957
+ }
958
+ }
959
+
960
+ // console.log ('select#block-alignment change', $("select#block-alignment option:selected").attr ('value'));
961
+
962
+ if (sticky) update_sticky_css (STICKY_CONTEXT_BLOCK_ALIGNMENT);
963
+
964
+ process_display_elements ();
965
+ update_close_button ();
966
+
967
+ // console.log ('select#block-alignment');
968
+
969
+ if (sticky) update_sticky_elements (STICKY_CONTEXT_BLOCK_ALIGNMENT);
970
+ if (sticky) update_highlighting ();
971
+
972
+ if (sticky_context == STICKY_CONTEXT_BLOCK_ALIGNMENT) sticky_context = STICKY_CONTEXT_NONE;
973
+ });
974
+
975
+ $("select#close-button-0").change (function() {
976
+ update_close_button ();
977
+ update_highlighting ();
978
+ });
979
+
980
+ $("select#horizontal-position").change (function() {
981
+ if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_HORIZONTAL_POSITION;
982
+
983
+ // console.log ('select#horizontal-position change');
984
+
985
+ if (sticky_context == STICKY_CONTEXT_HORIZONTAL_POSITION) $("select#block-alignment").val (AI_ALIGNMENT_STICKY).change();
986
+ update_sticky_css (STICKY_CONTEXT_HORIZONTAL_POSITION);
987
+ process_display_elements ();
988
+ update_close_button ();
989
+
990
+ // console.log ('select#horizontal-position');
991
+
992
+ update_sticky_elements (STICKY_CONTEXT_HORIZONTAL_POSITION);
993
+ update_highlighting ();
994
+
995
+ wrapper.css ('transition-property', 'none');
996
+ setTimeout (function() {wrapper.css ('transition-property', '');}, 10);
997
+
998
+ if (sticky_context == STICKY_CONTEXT_HORIZONTAL_POSITION) sticky_context = STICKY_CONTEXT_NONE;
999
+ });
1000
+
1001
+ $("select#vertical-position").change (function() {
1002
+ if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_VERTICAL_POSITION;
1003
+
1004
+ // console.log ('select#vertical-position change');
1005
+
1006
+
1007
+ if (sticky_context == STICKY_CONTEXT_VERTICAL_POSITION) $("select#block-alignment").val (AI_ALIGNMENT_STICKY).change();
1008
+ update_sticky_css (STICKY_CONTEXT_VERTICAL_POSITION);
1009
+ process_display_elements ();
1010
+ update_close_button ();
1011
+
1012
+ // console.log ('select#vertical-position');
1013
+
1014
+ update_sticky_elements (STICKY_CONTEXT_VERTICAL_POSITION);
1015
+ update_highlighting ();
1016
+
1017
+ wrapper.css ('transition-property', 'none');
1018
+ setTimeout (function() {wrapper.css ('transition-property', '');}, 10);
1019
+
1020
+ if (sticky_context == STICKY_CONTEXT_VERTICAL_POSITION) sticky_context = STICKY_CONTEXT_NONE;
1021
+ });
1022
+
1023
+
1024
+ $("select#animation").change (function() {
1025
+ if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_ANIMATION;
1026
+
1027
+ // console.log ('select#animation change');
1028
+
1029
+ // if (sticky_context == STICKY_CONTEXT_VERTICAL_POSITION) $("select#block-alignment").val (AI_ALIGNMENT_STICKY).change();
1030
+ update_sticky_css (STICKY_CONTEXT_ANIMATION);
1031
+ process_display_elements ();
1032
+ update_close_button ();
1033
+
1034
+ //// console.log ('select#vertical-position');
1035
+
1036
+ update_sticky_elements (STICKY_CONTEXT_ANIMATION);
1037
+ update_highlighting ();
1038
+
1039
+ wrapper.css ('transition-property', 'none');
1040
+ setTimeout (function() {wrapper.css ('transition-property', '');}, 10);
1041
+
1042
+ if (sticky_context == STICKY_CONTEXT_ANIMATION) sticky_context = STICKY_CONTEXT_NONE;
1043
+ });
1044
+
1045
+ $("#animate-button").button ({
1046
+ }).click (function () {
1047
+
1048
+ if ($('body').hasClass ("highlighted")) {
1049
+ $("#highlight-button").click ();
1050
+ }
1051
+
1052
+ wrapper.toggleClass ('aos-animate');
1053
+ });
1054
+
1055
+ $('.ai-close-button').click (function () {
1056
+ if ($('body').hasClass ("highlighted")) {
1057
+ setTimeout (function () {
1058
+ $("#highlight-button").click ();
1059
+ $("#highlight-button").click ();
1060
+ }, 10);
1061
+ }
1062
+ });
1063
+
1064
+ $(".css-code").click (function () {
1065
+ if (!$('#custom-css').is(':visible')) {
1066
+ $("#edit-css-button").click ();
1067
+ }
1068
+ });
1069
+
1070
+ $("#edit-css-button").button ({
1071
+ }).click (function () {
1072
+
1073
+ $(ID_CSS_ALIGNMENT_DEFAULT).hide();
1074
+ $(ID_CSS_ALIGNMENT_LEFT).hide();
1075
+ $(ID_CSS_ALIGNMENT_RIGHT).hide();
1076
+ $(ID_CSS_ALIGNMENT_CENTER).hide();
1077
+ $(ID_CSS_ALIGNMENT_FLOAT_LEFT).hide();
1078
+ $(ID_CSS_ALIGNMENT_FLOAT_RIGHT).hide();
1079
+ $(ID_CSS_ALIGNMENT_STICKY_LEFT).hide();
1080
+ $(ID_CSS_ALIGNMENT_STICKY_RIGHT).hide();
1081
+ $(ID_CSS_ALIGNMENT_STICKY_TOP).hide();
1082
+ $(ID_CSS_ALIGNMENT_STICKY_BOTTOM).hide();
1083
+ $(ID_CSS_ALIGNMENT_STICKY).hide();
1084
+
1085
+ var alignment = $("select#block-alignment"+" option:selected").attr('value');
1086
+
1087
+ if (alignment == AI_ALIGNMENT_DEFAULT) {
1088
+ $("#custom-css").show().val ($(ID_CSS_ALIGNMENT_DEFAULT).text ());
1089
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
1090
+ } else
1091
+ if (alignment == AI_ALIGNMENT_LEFT) {
1092
+ $("#custom-css").show().val ($(ID_CSS_ALIGNMENT_LEFT).text ());
1093
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
1094
+ } else
1095
+ if (alignment == AI_ALIGNMENT_RIGHT) {
1096
+ $("#custom-css").show().val ($(ID_CSS_ALIGNMENT_RIGHT).text ());
1097
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
1098
+ } else
1099
+ if (alignment == AI_ALIGNMENT_CENTER) {
1100
+ $("#custom-css").show().val ($(ID_CSS_ALIGNMENT_CENTER).text ());
1101
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
1102
+ } else
1103
+ if (alignment == AI_ALIGNMENT_FLOAT_LEFT) {
1104
+ $("#custom-css").show().val ($(ID_CSS_ALIGNMENT_FLOAT_LEFT).text ());
1105
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
1106
+ } else
1107
+ if (alignment == AI_ALIGNMENT_FLOAT_RIGHT) {
1108
+ $("#custom-css").show().val ($(ID_CSS_ALIGNMENT_FLOAT_RIGHT).text ());
1109
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
1110
+ } else
1111
+ if (alignment == AI_ALIGNMENT_STICKY_LEFT) {
1112
+ $("#custom-css").show().val ($(ID_CSS_ALIGNMENT_STICKY_LEFT).text ());
1113
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
1114
+ } else
1115
+ if (alignment == AI_ALIGNMENT_STICKY_RIGHT) {
1116
+ $("#custom-css").show().val ($(ID_CSS_ALIGNMENT_STICKY_RIGHT).text ());
1117
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
1118
+ }
1119
+ if (alignment == AI_ALIGNMENT_STICKY_TOP) {
1120
+ $("#custom-css").show().val ($(ID_CSS_ALIGNMENT_STICKY_TOP).text ());
1121
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
1122
+ } else
1123
+ if (alignment == AI_ALIGNMENT_STICKY_BOTTOM) {
1124
+ $("#custom-css").show().val ($(ID_CSS_ALIGNMENT_STICKY_BOTTOM).text ());
1125
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
1126
+ } else
1127
+ if (alignment == AI_ALIGNMENT_STICKY) {
1128
+ $("#custom-css").show().val ($(ID_CSS_ALIGNMENT_STICKY).text ());
1129
+ $("select#block-alignment").val (AI_ALIGNMENT_CUSTOM_CSS).change();
1130
+ }
1131
+ });
1132
+
1133
+ $("#custom-css").on ('input', function() {
1134
+ if (sticky_context == STICKY_CONTEXT_NONE) sticky_context = STICKY_CONTEXT_CUSTOM_CSS;
1135
+
1136
+ // console.log ('#custom-css input');
1137
+
1138
+ if (wrapping) {
1139
+ var custom_css = $("#custom-css").val ();
1140
+ wrapper.attr ("data-css", custom_css);
1141
+ wrapper.attr ("style", custom_css);
1142
+ }
1143
+ if (remove_transform) wrapper.css ('transform', '');
1144
+ if (sticky) update_sticky_css (STICKY_CONTEXT_CUSTOM_CSS);
1145
+
1146
+ // console.log ('#custom-css');
1147
+
1148
+ if (sticky) update_sticky_elements (STICKY_CONTEXT_CUSTOM_CSS);
1149
+ update_margin_padding ();
1150
+ update_close_button ();
1151
+ update_highlighting ();
1152
+ update_wrapper_size ();
1153
+
1154
+ if (sticky_context == STICKY_CONTEXT_CUSTOM_CSS) sticky_context = STICKY_CONTEXT_NONE;
1155
+ });
1156
+
1157
+ $("#highlight-button").button ({
1158
+ }).click (function () {
1159
+ $('body').toggleClass ("highlighted");
1160
+
1161
+ if (!$('body').hasClass ("highlighted")) {
1162
+ $(".highlighting").remove ();
1163
+ $('.ai-debug-ad-info').remove();
1164
+ return;
1165
+ }
1166
+
1167
+ <?php
1168
+ if (defined ('AI_ADSENSE_OVERLAY')) {
1169
+ echo "
1170
+ ai_process_adsense_ads (jQuery);
1171
+ $('.ai-debug-ad-info').each (function () {
1172
+ var info_top = $(this).offset ().top;
1173
+ var info_left = $(this).offset ().left;
1174
+ var ad_width = $(this).parent ().width ();
1175
+ $(this).css ({top: info_top, left: info_left, width: ad_width});
1176
+ if (wrapper.css ('position') == 'fixed') $(this).css ('position', 'fixed');
1177
+ $('#ad-info-overlay').append ($(this));
1178
+ });
1179
+ ";
1180
+ }
1181
+ ?>
1182
+
1183
+ if (wrapping) {
1184
+
1185
+ var overlay_position = '';
1186
+ if (wrapper.css ('position') == 'fixed') overlay_position = 'fixed';
1187
+ $('#margin-background').css ('position', overlay_position);
1188
+ $('#padding-background').css ('position', overlay_position);
1189
+ $('#padding-background-white').css ('position', overlay_position);
1190
+
1191
+ var wrapper_offset = wrapper.offset ();
1192
+ var wrapper_left = wrapper_offset.left;
1193
+ var wrapper_top = wrapper_offset.top;
1194
+ var wrapper_width = wrapper.outerWidth (true);
1195
+ var wrapper_height = wrapper.outerHeight (true);
1196
+ var wrapper_outer_width = wrapper.outerWidth ();
1197
+ var wrapper_outer_height = wrapper.outerHeight ();
1198
+ var code_width = wrapper.width ();
1199
+ var code_height = wrapper.height ();
1200
+
1201
+ var wrapper_margin_width = wrapper_width - wrapper_outer_width;
1202
+ var wrapper_margin_height = wrapper_height - wrapper_outer_height;
1203
+ var wrapper_margin_top = parseInt (wrapper.css ('margin-top'));
1204
+ var wrapper_margin_left = parseInt (wrapper.css ('margin-left'));
1205
+ var wrapper_border_width = wrapper.outerWidth () - wrapper.innerWidth ();
1206
+ var wrapper_border_height = wrapper.outerHeight () - wrapper.innerHeight ();
1207
+ var wrapper_border_top = parseInt (wrapper.css ('border-top-width'));
1208
+ var wrapper_border_left = parseInt (wrapper.css ('border-left-width'));
1209
+ var wrapper_padding_width = wrapper.innerWidth () - code_width;
1210
+ var wrapper_padding_height = wrapper.innerHeight () - code_height;
1211
+
1212
+ if (debug) {
1213
+ console.log ("wrapper_left: " + wrapper_left);
1214
+ console.log ("wrapper_top: " + wrapper_top);
1215
+ console.log ("wrapper_width: " + wrapper_width);
1216
+ console.log ("wrapper_height: " + wrapper_height);
1217
+ console.log ("wrapper_margin_top: " + wrapper_margin_top);
1218
+ console.log ("wrapper_margin_left: " + wrapper_margin_left);
1219
+ console.log ("wrapper_border_top: " + wrapper_border_top);
1220
+ console.log ("wrapper_border_left: " + wrapper_border_left);
1221
+ console.log ("wrapper_outer_width: " + wrapper_outer_width);
1222
+ console.log ("wrapper_outer_height: " + wrapper_outer_height);
1223
+ console.log ("wrapper_margin_height: " + wrapper_margin_height);
1224
+ console.log ("wrapper_margin_width: " + wrapper_margin_width);
1225
+ console.log ("wrapper_margin_height: " + wrapper_margin_height);
1226
+ console.log ("wrapper_border_width: " + wrapper_border_width);
1227
+ console.log ("wrapper_border_height: " + wrapper_border_height);
1228
+ console.log ("wrapper_padding_width: " + wrapper_padding_width);
1229
+ console.log ("wrapper_padding_height: " + wrapper_padding_height);
1230
+ console.log ("code_width: " + code_width);
1231
+ console.log ("code_height: " + code_height);
1232
+ }
1233
+
1234
+ $('#margin-background').show ();
1235
+ $("#padding-background-white").show ();
1236
+
1237
+ $('#margin-background').css ('width', wrapper_width).css ('height', wrapper_height);
1238
+ $("#margin-background").offset ({top: wrapper_top - wrapper_margin_top, left: wrapper_left - wrapper_margin_left});
1239
+
1240
+ $('#padding-background').css ('width', wrapper_outer_width - wrapper_border_width).css ('height', wrapper_outer_height - wrapper_border_height);
1241
+ $("#padding-background").offset ({top: wrapper_top + wrapper_border_top, left: wrapper_left + wrapper_border_left});
1242
+
1243
+ $('#padding-background-white').css ('width', wrapper_outer_width - wrapper_border_width).css ('height', wrapper_outer_height - wrapper_border_height);
1244
+ $("#padding-background-white").offset ({top: wrapper_top + wrapper_border_top, left: wrapper_left + wrapper_border_left});
1245
+
1246
+ code_blocks = wrapper.children ();
1247
+ } else {
1248
+ $('#margin-background').hide ();
1249
+ $("#padding-background-white").hide ();
1250
+
1251
+ $('#padding-background').css ('width', wrapper.outerWidth ()).css ('height', wrapper.outerHeight ());
1252
+ $("#padding-background").offset ({top: wrapper.offset ().top, left: wrapper.offset ().left});
1253
+
1254
+ code_blocks = wrapper.children ();
1255
+ }
1256
+
1257
+ var code_index = 0;
1258
+ var overlay_div = $("#code-overlay");
1259
+ var overlay_background_div = $("#code-background-white");
1260
+ var last_code_div = "code-overlay";
1261
+ var last_bkg_div = "code-background-white";
1262
+ var invalid_tags = ['script', 'style'];
1263
+
1264
+ // console.log ('code_blocks', code_blocks);
1265
+
1266
+ var filtered_code_blocks = $();
1267
+ code_blocks.each (function () {
1268
+ var element_tag = $(this).prop("tagName").toLowerCase();
1269
+
1270
+ // Don't highlight close button
1271
+ if (element_tag == 'span' && $(this).hasClass ('ai-close-button')) return true;
1272
+
1273
+ if (element_tag == 'a') {
1274
+ var a_children = $(this).children ();
1275
+ if (a_children.length == 0)
1276
+ filtered_code_blocks = filtered_code_blocks.add ($(this)); else
1277
+ filtered_code_blocks = filtered_code_blocks.add (a_children);
1278
+ } else filtered_code_blocks = filtered_code_blocks.add ($(this));
1279
+ });
1280
+
1281
+ // code_blocks.each (function () {
1282
+ filtered_code_blocks.each (function () {
1283
+ var element_tag = $(this).prop("tagName");
1284
+ if (typeof element_tag != 'undefined') element_tag = element_tag.toLowerCase();
1285
+
1286
+ if (invalid_tags.indexOf (element_tag) < 0) {
1287
+ code_index ++;
1288
+ var element_offset = $(this).offset ();
1289
+
1290
+ var element_display = $(this).css ('display');
1291
+ var element_left = element_offset.left;
1292
+ var element_top = element_offset.top;
1293
+ var element_outer_width = $(this).outerWidth ();
1294
+ var element_outer_height = $(this).outerHeight ();
1295
+
1296
+ if (debug) {
1297
+ console.log ("");
1298
+ console.log ("element " + code_index + ": " + element_tag);
1299
+ console.log ("element_display: " + element_display);
1300
+ console.log ("element_left: " + element_left);
1301
+ console.log ("element_top: " + element_top);
1302
+ console.log ("element_outer_width: " + element_outer_width);
1303
+ console.log ("element_outer_height: " + element_outer_height);
1304
+ }
1305
+
1306
+ if (element_display == 'none') return; // continue
1307
+
1308
+ var overlay_div_position = overlay_div.css ('position');
1309
+ var overlay_background_div_position = overlay_background_div.css ('position');
1310
+ var fixed_offset_top = 0;
1311
+ var fixed_offset_left = 0;
1312
+ if (wrapper.css ('position') == 'fixed') {
1313
+ overlay_div_position = 'fixed';
1314
+ overlay_background_div_position = 'fixed';
1315
+ fixed_offset_top = $(document).scrollTop();
1316
+ fixed_offset_left = $(document).scrollLeft();
1317
+ }
1318
+
1319
+ var new_id = "code-" + code_index;
1320
+ $("#" + last_code_div).after (overlay_div.clone ().
1321
+ css ('position', overlay_div_position).
1322
+ css ('width', element_outer_width).
1323
+ css ('height', element_outer_height).
1324
+ offset ({top: element_top - fixed_offset_top, left: element_left - fixed_offset_left}).
1325
+ attr ("id", new_id).
1326
+ addClass ("highlighting"));
1327
+ last_code_div = new_id;
1328
+
1329
+ var new_bkg_id = "code-background-" + code_index;
1330
+ $("#" + last_bkg_div).after (overlay_background_div.clone ().
1331
+ css ('position', overlay_background_div_position).
1332
+ css ('width', element_outer_width).
1333
+ css ('height', element_outer_height).
1334
+ offset ({top: element_top - fixed_offset_top, left: element_left - fixed_offset_left}).
1335
+ attr ("id", new_bkg_id).
1336
+ addClass ("highlighting"));
1337
+ last_bkg_div = new_bkg_id;
1338
+ }
1339
+ });
1340
+ if (debug) console.log ("");
1341
+ });
1342
+
1343
+ $("#use-button").button ({
1344
+ }).click (function () {
1345
+ apply_to_settings ();
1346
+ window.close();
1347
+ });
1348
+
1349
+ $("#reset-button").button ({
1350
+ }).click (function () {
1351
+ load_from_settings ();
1352
+ });
1353
+
1354
+ $("#cancel-button").button ({
1355
+ }).click (function () {
1356
+ window.close();
1357
+ });
1358
+
1359
+ $(".viewport-box").click (function () {
1360
+ var new_width = parseInt ($(this).attr ("data")) - 1;
1361
+ if (window.innerWidth == new_width) {
1362
+ window.resizeTo (836, $(window).height());
1363
+ } else {
1364
+ // Add body margin
1365
+ window.resizeTo (new_width + 16, $(window).height());
1366
+ }
1367
+ });
1368
+
1369
+ update_width ();
1370
+
1371
+ update_close_button ();
1372
+
1373
+ <?php if (!$read_only) : ?>
1374
+ load_from_settings ();
1375
+ <?php endif; ?>
1376
+
1377
+ if (sticky) {
1378
+ update_sticky_css (STICKY_CONTEXT_INIT);
1379
+ process_display_elements ();
1380
+ ai_process_sticky_elements_on_ready = false;
1381
+ update_sticky_elements (STICKY_CONTEXT_INIT);
1382
+ }
1383
+
1384
+ setTimeout (update_wrapper_size, 500);
1385
+
1386
+ var current_time = new Date().getTime();
1387
+ if (debug) console.log ("TIME: " + ((current_time - start_time) / 1000).toFixed (3));
1388
+
1389
+ var titles = new Array();
1390
+ $("select#block-alignment").imagepicker({hide_select: false}).find ('option').each (function (index) {
1391
+ titles.push ($(this).data ('title'));
1392
+ });
1393
+ $("select#block-alignment + ul").appendTo("#alignment-style").css ('padding-top', '10px').find ('li').each (function (index) {
1394
+ $(this).attr ('title', titles [index]);
1395
+ });
1396
+
1397
+ if (sticky) {
1398
+ var titles = new Array();
1399
+ $("select#close-button-0").imagepicker({hide_select: false}).find ('option').each (function (index) {
1400
+ titles.push ($(this).data ('title'));
1401
+ });
1402
+ $("select#close-button-0 + ul").appendTo("#close-buttons").css ('padding-top', '10px').find ('li').each (function (index) {
1403
+ $(this).attr ('title', titles [index]);
1404
+ });
1405
+ }
1406
+
1407
+ var titles = new Array();
1408
+ $("select#horizontal-position").imagepicker({hide_select: false}).find ('option').each (function (index) {
1409
+ titles.push ($(this).data ('title'));
1410
+ });
1411
+ $("select#horizontal-position + ul").appendTo("#horizontal-positions").css ('padding-top', '10px').find ('li').each (function (index) {
1412
+ $(this).attr ('title', titles [index]);
1413
+ });
1414
+
1415
+ var titles = new Array();
1416
+ $("select#vertical-position").imagepicker({hide_select: false}).find ('option').each (function (index) {
1417
+ titles.push ($(this).data ('title'));
1418
+ });
1419
+ $("select#vertical-position + ul").appendTo("#vertical-positions").css ('padding-top', '10px').find ('li').each (function (index) {
1420
+ $(this).attr ('title', titles [index]);
1421
+ });
1422
+
1423
+
1424
+ $("div.automatic-insertion").dblclick (function () {
1425
+ var selected_alignment = $("select#block-alignment option:selected");
1426
+ var alignment_value = selected_alignment.val ();
1427
+ var alt_styles = selected_alignment.data ('alt-styles');
1428
+ if (typeof alt_styles != 'undefined') {
1429
+ var alt_style_index = selected_alignment.data ('alt-style');
1430
+ var num_styles = Object.keys(alt_styles).length;
1431
+ alt_style_index ++;
1432
+ if (alt_style_index > num_styles) alt_style_index = 1;
1433
+ selected_alignment.data ('alt-style', alt_style_index)
1434
+ process_display_elements ();
1435
+ }
1436
+ });
1437
+
1438
+ if (sticky) {
1439
+ $('.spinner.normal').hide ();
1440
+ wrapper.removeClass ('hide');
1441
+ } else {
1442
+ $('.spinner.sticky').show ();
1443
+ }
1444
+
1445
+ sticky_context = STICKY_CONTEXT_NONE;
1446
+ }
1447
+
1448
+ jQuery(document).ready(function($) {
1449
+
1450
+ initialize_preview ();
1451
+
1452
+ setTimeout (show_blocked_warning, 400);
1453
+ });
1454
+
1455
+ function show_blocked_warning () {
1456
+ jQuery("#blocked-warning.warning-enabled").show ();
1457
+ }
1458
+
1459
+ </script>
1460
+ <style>
1461
+
1462
+ /*html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {*/
1463
+ a, img {
1464
+ border: 0;
1465
+ font: inherit;
1466
+ font-size: 100%;
1467
+ font-style: inherit;
1468
+ font-weight: inherit;
1469
+ margin: 0;
1470
+ outline: 0;
1471
+ padding: 0;
1472
+ vertical-align: baseline;
1473
+ }
1474
+
1475
+ body.sticky {
1476
+ margin: 0;
1477
+ }
1478
+
1479
+ #main.sticky {
1480
+ width: 728px;
1481
+ margin: 100px auto;
1482
+ }
1483
+
1484
+ .sticky #content {
1485
+ padding: 20px 10px;
1486
+ border: 1px solid #eee;
1487
+ border-radius: 5px;
1488
+ }
1489
+
1490
+ .responsive-table td {
1491
+ white-space: nowrap;
1492
+ }
1493
+ .small-button .ui-button-text-only .ui-button-text {
1494
+ padding: 0;
1495
+ }
1496
+ #margin-background {
1497
+ z-index: 2;
1498
+ position: absolute;
1499
+ display: none;
1500
+ }
1501
+ .highlighted #margin-background {
1502
+ background: rgba(255, 145, 0, 0.5);
1503
+ display: block;
1504
+ }
1505
+ #padding-background-white {
1506
+ z-index: 3;
1507
+ position: absolute;
1508
+ background: #fff;
1509
+ width: 0px;
1510
+ height: 0px;
1511
+ display: none;
1512
+ }
1513
+ .highlighted #padding-background-white {
1514
+ display: block;
1515
+ }
1516
+ #padding-background {
1517
+ z-index: 4;
1518
+ position: absolute;
1519
+ display: none;
1520
+ }
1521
+ .highlighted #padding-background {
1522
+ background: rgba(50, 220, 140, 0.5);
1523
+ display: block;
1524
+ }
1525
+ #wrapper {
1526
+ z-index: 6;
1527
+ position: relative;
1528
+ border: 0;
1529
+ }
1530
+
1531
+ #wrapper.hide {
1532
+ visibility: hidden;
1533
+ }
1534
+ .code-background-white {
1535
+ z-index: 5;
1536
+ position: absolute;
1537
+ background: #fff;
1538
+ width: 0px;
1539
+ height: 0px;
1540
+ display: none;
1541
+ }
1542
+ .highlighted .code-background-white {
1543
+ display: block;
1544
+ }
1545
+ .code-overlay {
1546
+ z-index: 99999;
1547
+ position: absolute;
1548
+ display: none;
1549
+ }
1550
+ .highlighted .code-overlay {
1551
+ background: rgba(50, 140, 220, 0.5);
1552
+ display: block;
1553
+ }
1554
+ .ad-info-overlay {
1555
+ position: absolute;
1556
+ }
1557
+
1558
+ table.screen td {
1559
+ padding: 0;
1560
+ font-size: 12px;
1561
+ }
1562
+
1563
+ table.demo-box {
1564
+ width: 300px;
1565
+ margin: 0 auto;
1566
+ border: 1px solid #ccc;
1567
+ }
1568
+ #demo-box-no-wrapping {
1569
+ height: 200px;
1570
+ }
1571
+ table.demo-box input {
1572
+ display: none;
1573
+ }
1574
+ .demo-box td {
1575
+ font-size: 12px;
1576
+ padding: 0;
1577
+ }
1578
+ td.demo-wrapper-margin-lr, td.demo-wrapper-margin {
1579
+ width: 22px;
1580
+ height: 22px;
1581
+ text-align: center;
1582
+ }
1583
+ td.demo-wrapper-margin-tb {
1584
+ width: 300px;
1585
+ height: 22px;
1586
+ text-align: center;
1587
+ }
1588
+ .highlighted td.demo-wrapper-margin-tb, .highlighted td.demo-wrapper-margin-lr, .highlighted td.demo-wrapper-margin {
1589
+ background: rgba(255, 145, 0, 0.5);
1590
+ }
1591
+ td.demo-code-padding-tb {
1592
+ text-align: center;
1593
+ }
1594
+ td.demo-code-padding-lr {
1595
+ width: 22px;
1596
+ text-align: center;
1597
+ }
1598
+ td.demo-code {
1599
+ text-align: center;
1600
+ }
1601
+ #demo-box td.demo-code {
1602
+ height: 110px;
1603
+ }
1604
+ .highlighted td.demo-code, .highlighted td.demo-code-padding-lr, .highlighted td.demo-code-padding-tb {
1605
+ background: rgba(50, 140, 220, 0.5);
1606
+ }
1607
+ td.demo-wrapper-background {
1608
+ width: 80px;
1609
+ text-align: center;
1610
+ word-wrap: break-word;
1611
+ white-space: normal;
1612
+ }
1613
+ .highlighted td.demo-wrapper-background {
1614
+ background: rgba(50, 220, 140, 0.5);
1615
+ }
1616
+ .ui-widget-content {
1617
+ background: transparent;
1618
+ }
1619
+ .ui-spinner {
1620
+ border: 0;
1621
+ }
1622
+ .ui-spinner-horizontal, .ui-spinner-horizontal .ui-spinner-input {
1623
+ height: 14px;
1624
+ }
1625
+ .ui-spinner-horizontal .ui-spinner-input {
1626
+ width: 23px;
1627
+ outline: 0;
1628
+ margin: -1px 12px 0 12px;
1629
+ }
1630
+
1631
+ .spinner.sticky .ui-spinner-horizontal .ui-spinner-input {
1632
+ width: 26px;
1633
+ margin-top: 0;
1634
+ height: 13px;
1635
+ font-size: 13px;
1636
+ }
1637
+
1638
+ .ui-spinner-vertical, .ui-spinner-vertical .ui-spinner-input {
1639
+ width: 18px;
1640
+ }
1641
+ .ui-spinner-vertical .ui-spinner-input {
1642
+ height: 11px;
1643
+ outline: 0;
1644
+ margin: 12px 0 12px 0;
1645
+ font-size: 11px;
1646
+ }
1647
+
1648
+ .thumbnail {
1649
+ border-radius: 6px;
1650
+ }
1651
+ ul.image_picker_selector {
1652
+ overflow: hidden!important;
1653
+ }
1654
+
1655
+ div.automatic-insertion {
1656
+ width: 50px;
1657
+ height: 50px;
1658
+ }
1659
+
1660
+ li.automatic-insertion p {
1661
+ width: 50px;
1662
+ height: 50px;
1663
+ }
1664
+
1665
+ div.automatic-insertion img {
1666
+ width: 50px;
1667
+ height: 50px;
1668
+ }
1669
+
1670
+ select {
1671
+ border-radius: 5px;
1672
+ }
1673
+ .ai-close-hidden {
1674
+ visibility: hidden;
1675
+ }
1676
+
1677
+ .ai-debug-ad-info {position: absolute; top: 0; left: 0; overflow: hidden; width: auto; height: auto; font-size: 11px; line-height: 11px; text-align: left; z-index: 999999991;}
1678
+ .ai-info {display: inline-block; padding: 2px 4px;}
1679
+ .ai-info-1 {background: #000; color: #fff;}
1680
+ .ai-info-2 {background: #fff; color: #000;}
1681
+
1682
+ </style>
1683
+ <?php echo $head_code; ?>
1684
+ </head>
1685
+ <body class="ai-preview <?php if ($sticky) echo 'sticky'; ?>" style='font-family: arial; text-align: justify; overflow-x: hidden;'>
1686
+
1687
+ <?php if ($sticky) padding_margin_code ($close_button, $class, $sticky_parameters, $wrapper_css, $block_code); ?>
1688
+
1689
+ <div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>"></div>
1690
+
1691
+ <div style="margin: 0 -8px 10px; display: none;">
1692
+ <table class="screen" cellspacing=0 cellpadding=0>
1693
+ <tr>
1694
+ <?php
1695
+ $previous_width = 0;
1696
+ $previous_name = '';
1697
+ for ($viewport = AD_INSERTER_VIEWPORTS - 1; $viewport > 0; $viewport --) {
1698
+ $viewport_name = get_viewport_name ($viewport);
1699
+ $viewport_width = get_viewport_width ($viewport);
1700
+ if ($viewport_name != '' && $viewport_width != 0) {
1701
+ echo "<td class='viewport-box' data='", $viewport_width, "' style='background: #eee; text-align: center; border: 1px solid #888; border-left-width: 0; min-width: ", $viewport_width - $previous_width - 1, "px'>",
1702
+ $previous_name, "<span style='float: left; margin-left: 5px;'>", $previous_width != 0 ? $previous_width . "px" : "", "</span></td>";
1703
+ }
1704
+ $previous_name = $viewport_name;
1705
+ $previous_width = $viewport_width;
1706
+ }
1707
+ echo "<td style='background: #eee; text-align: left; border: 1px solid #888; border-left-width: 0; min-width: 2000px'><span style='margin-left: 30px;'>", get_viewport_name (1), "</span><span style='float: left; margin-left: 5px;'>", $previous_width != 0 ? $previous_width . "px" : "", "</span></td>";
1708
+ ?>
1709
+ </tr>
1710
+ </table>
1711
+ </div>
1712
+
1713
+ <?php if (!$read_only) : ?>
1714
+ <div style="margin: 10px -8px 10px 0">
1715
+ <table class="screen" cellspacing=0 cellspacing="0">
1716
+ <tr>
1717
+ <td><span>&#9667;</span></td>
1718
+ <td style="width: 50%;"><div style="height: 2px; width: 100%; border-bottom: 1px solid #ddd;"></div></td>
1719
+ <td id="screen-width" style="min-width: 45px; text-align: center; font-size: 12px;">820 px</td>
1720
+ <td style="width: 50%;"><div style="height: 2px; width: 100%; border-bottom: 1px solid #ddd;"></div></td>
1721
+ <td><span id="right-arrow" >&#9657;</span></td>
1722
+ </tr>
1723
+ </table>
1724
+ </div>
1725
+ <?php endif; ?>
1726
+
1727
+ <div id="main" class="<?php if ($sticky) echo 'sticky'; ?>">
1728
+ <div id="content">
1729
+
1730
+ <div id="blocked-warning" class="warning-enabled" style="padding: 2px 8px 2px 8px; margin: 8px 0 8px 0; border: 1px solid rgb(221, 221, 221); border-radius: 5px;">
1731
+ <div style="float: right; text-align: right; margin: 20px 0px 0px 0;">
1732
+ This page was not loaded properly. Please check browser, plugins and ad blockers.
1733
+ </div>
1734
+ <h3 style="color: red;" title="Error loading page">PAGE BLOCKED</h3>
1735
+
1736
+ <div style="clear: both;"></div>
1737
+ </div>
1738
+
1739
+ <div style="float: right; width: 90px; margin-left: 20px;">
1740
+ <button id="highlight-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Highlight inserted code" >Highlight</button>
1741
+ <?php if (!$read_only) : ?>
1742
+ <button id="use-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Use current settings" >Use</button>
1743
+ <button id="reset-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Reset to the block settings" >Reset</button>
1744
+ <?php endif; ?>
1745
+ <button id="cancel-button" type="button" style="margin: 0 0 10px 0; font-size: 12px; width: 90px; height: 35px; float: right;" title="Close preview window" >Cancel</button>
1746
+ </div>
1747
+
1748
+ <?php if (!$read_only) : ?>
1749
+ <div style="float: left; max-width: 300px; margin-right: 20px">
1750
+ <?php else : ?>
1751
+ <div style="float: left; max-width: 600px; margin-right: 20px">
1752
+ <?php endif; ?>
1753
+
1754
+ <h1 style="margin: 0;">Preview</h1>
1755
+ <?php if ($block != 0) : ?>
1756
+ <h2>Block <?php echo $block; ?></h2>
1757
+ <?php else : ?>
1758
+ <h2>AdSense ad unit</h2>
1759
+ <?php endif; ?>
1760
+ <h3 id="block-name" style="text-align: left;"><?php echo $block_name; ?></h3>
1761
+ </div>
1762
+
1763
+
1764
+ <?php if (!$read_only) : ?>
1765
+ <div style="float: left; min-height: 200px; margin: 0 auto;">
1766
+ <table id="demo-box" class="demo-box" style="display: none;" cellspacing=0 cellspacing="0">
1767
+ <tr>
1768
+ <td class="demo-wrapper-margin-tb" style="border-right: 1px solid #ccc;" colspan="5">
1769
+ <span class="spinner normal">
1770
+ <span style="float: left; margin-left: 43px;">margin</span>
1771
+ <span style="float: right; margin-right: 70px">px</span>
1772
+ <input id="spinner-margin-top" name="value">
1773
+ </span>
1774
+ </td>
1775
+ <td class="demo-wrapper-background"></td>
1776
+ </tr>
1777
+ <tr>
1778
+ <td class="demo-wrapper-margin"></td>
1779
+ <td class="demo-code-padding-tb" style="border-top:1px solid #ccc; border-left: 1px solid #ccc; border-right: 1px solid #ccc;" colspan="3">
1780
+ <span class="spinner normal">
1781
+ <span style="float: left; margin-left: 14px;">padding</span>
1782
+ <span style="float: right; margin-right: 48px">px</span>
1783
+ <input id="spinner-padding-top" name="value">
1784
+ </span>
1785
+ </td>
1786
+ <td class="demo-wrapper-margin" style="border-right: 1px solid #ccc;"></td>
1787
+ <td class="demo-wrapper-background"></td>
1788
+ </tr>
1789
+ <tr>
1790
+ <td class="demo-wrapper-margin-lr">
1791
+ <span class="spinner normal">
1792
+ <input id="spinner-margin-left" name="value">
1793
+ </span>
1794
+ </td>
1795
+ <td class="demo-code-padding-lr" style="border-left: 1px solid #ccc;">
1796
+ <span class="spinner normal">
1797
+ <input id="spinner-padding-left" name="value">
1798
+ </span>
1799
+ </td>
1800
+ <td class="demo-code"><p>Code block</p><p class="wrapper-size">&nbsp;</p></td>
1801
+ <td class="demo-code-padding-lr" style="border-right: 1px solid #ccc;">
1802
+ <span class="spinner normal">
1803
+ <input id="spinner-padding-right" name="value">
1804
+ </span>
1805
+ </td>
1806
+ <td class="demo-wrapper-margin-lr" style="border-right: 1px solid #ccc;">
1807
+ <span class="spinner normal">
1808
+ <input id="spinner-margin-right" name="value">
1809
+ </span>
1810
+ </td>
1811
+ <td class="demo-wrapper-background"></td>
1812
+ </tr>
1813
+ <tr>
1814
+ <td class="demo-wrapper-margin"></td>
1815
+ <td class="demo-code-padding-tb" style="border-bottom:1px solid #ccc; border-left: 1px solid #ccc; border-right: 1px solid #ccc;" colspan="3">
1816
+ <span class="spinner normal">
1817
+ <input id="spinner-padding-bottom" name="value">
1818
+ </span>
1819
+ </td>
1820
+ <td class="demo-wrapper-margin" style="border-right: 1px solid #ccc;"></td>
1821
+ <td class="demo-wrapper-background"></td>
1822
+ </tr>
1823
+ <tr>
1824
+ <td class="demo-wrapper-margin-tb" style="border-right: 1px solid #ccc;" colspan="5">
1825
+ <span class="spinner normal">
1826
+ <span style="float: left; margin-left: 6px;">wrapping div</span>
1827
+ <span style="float: right; margin-right: 72px">&nbsp;</span>
1828
+ <input id="spinner-margin-bottom" name="value">
1829
+ </span>
1830
+ </td>
1831
+ <td class="demo-wrapper-background">background</td>
1832
+ </tr>
1833
+ </table>
1834
+
1835
+ <table id="demo-box-no-wrapping" class="demo-box" style="display: none;" cellspacing=0 cellspacing="0">
1836
+ <tr>
1837
+ <td class="demo-code" style="border-right: 1px solid #ccc;"><p>Code block</p><p class="wrapper-size">&nbsp;</p></td>
1838
+ <td class="demo-wrapper-background">background</td>
1839
+ </tr>
1840
+ </table>
1841
+ </div>
1842
+ <?php endif; ?>
1843
+
1844
+ <div style="clear: both;"></div>
1845
+
1846
+ <?php if (!$read_only) : ?>
1847
+ <div id="alignment-editor" style="margin: 20px 0;">
1848
+ <?php else : ?>
1849
+ <div id="alignment-editor" style="margin: 20px 0; display: none;">
1850
+ <?php endif; ?>
1851
+ <?php if (defined ('AI_STICKY_SETTINGS') && AI_STICKY_SETTINGS && $sticky) : ?>
1852
+
1853
+ <div style="">
1854
+
1855
+ <div style="float: left;">
1856
+ Alignment and Style&nbsp;&nbsp;&nbsp;
1857
+ <select id="block-alignment" style="width:120px;">
1858
+ <?php if (function_exists ('ai_preview_style_options')) ai_preview_style_options ($obj, $alignment_type, true); ?>
1859
+ <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-custom-css" value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" data-title="<?php echo AI_TEXT_CUSTOM_CSS; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
1860
+ </select>
1861
+ <span id="css-index" style="display: inline-block; min-width: 30px; min-height: 12px; margin: 0 0 0 10px; font-size: 14px;" title="CSS code index"></span>
1862
+ <div id="alignment-style" style="margin: 4px 0; min-height: 74px;"></div>
1863
+ </div>
1864
+
1865
+ <div style="float: right; text-align: right;">
1866
+ <?php if (function_exists ('ai_close_button_select')) ai_close_button_select (0, $close_button, $close_button, 'close-button-0'); ?>
1867
+ <div id="close-buttons" style="margin: 4px 0; min-height: 74px;"></div>
1868
+ </div>
1869
+ <div style="clear: both;"></div>
1870
+
1871
+ </div>
1872
+
1873
+ <div style="margin: 8px 0;">
1874
+ <div style="float: left;">
1875
+ <div style="margin: 4px 0;">
1876
+ Horizontal position
1877
+ <select class="ai-image-selection" id="horizontal-position">
1878
+ <option
1879
+ data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1880
+ data-img-class="automatic-insertion preview im-sticky-left"
1881
+ data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_LEFT; ?>"
1882
+ data-title="<?php echo AI_TEXT_STICK_TO_THE_LEFT; ?>"
1883
+ value="<?php echo AI_STICK_TO_THE_LEFT; ?>"
1884
+ <?php echo ($horizontal_position == AI_STICK_TO_THE_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_LEFT; ?></option>
1885
+ <option
1886
+ data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1887
+ data-img-class="automatic-insertion preview im-sticky-content-left"
1888
+ data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_LEFT; ?>"
1889
+ data-title="<?php echo AI_TEXT_STICK_TO_THE_CONTENT_LEFT; ?>"
1890
+ value="<?php echo AI_STICK_TO_THE_CONTENT_LEFT; ?>"
1891
+ <?php echo ($horizontal_position == AI_STICK_TO_THE_CONTENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_CONTENT_LEFT; ?></option>
1892
+ <option
1893
+ data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1894
+ data-img-class="automatic-insertion preview im-sticky-center-horizontal"
1895
+ data-css="<?php echo AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL; ?>"
1896
+ data-css-<?php echo AI_STICK_VERTICAL_CENTER; ?>="<?php echo AI_ALIGNMENT_CSS_STICK_CENTER_HORIZONTAL_V; ?>"
1897
+ data-title="<?php echo AI_TEXT_CENTER; ?>"
1898
+ value="<?php echo AI_STICK_HORIZONTAL_CENTER; ?>"
1899
+ <?php echo ($horizontal_position == AI_STICK_HORIZONTAL_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
1900
+ <option
1901
+ data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1902
+ data-img-class="automatic-insertion preview im-sticky-content-right"
1903
+ data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_CONTENT_RIGHT; ?>"
1904
+ data-title="<?php echo AI_TEXT_STICK_TO_THE_CONTENT_RIGHT; ?>"
1905
+ value="<?php echo AI_STICK_TO_THE_CONTENT_RIGHT; ?>"
1906
+ <?php echo ($horizontal_position == AI_STICK_TO_THE_CONTENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_CONTENT_RIGHT; ?></option>
1907
+ <option
1908
+ data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1909
+ data-img-class="automatic-insertion preview im-sticky-right"
1910
+ data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT; ?>"
1911
+ data-css-<?php echo AI_SCROLL_WITH_THE_CONTENT; ?>="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_RIGHT_SCROLL; ?>"
1912
+ data-title="<?php echo AI_TEXT_STICK_TO_THE_RIGHT; ?>"
1913
+ value="<?php echo AI_STICK_TO_THE_RIGHT; ?>"
1914
+ <?php echo ($horizontal_position == AI_STICK_TO_THE_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_RIGHT; ?></option>
1915
+ </select>
1916
+
1917
+ <div style="clear: both;"></div>
1918
+ </div>
1919
+
1920
+ <div id="horizontal-positions"></div>
1921
+
1922
+ <div class="spinner sticky" style="margin: 8px 0;">
1923
+ <span>Horizontal margin </span>
1924
+ <input id="spinner-horizontal-margin" name="value">
1925
+ <span> px</span>
1926
+ </div>
1927
+ </div>
1928
+
1929
+ <div style="float: right;">
1930
+ <div style="margin: 4px 0;">
1931
+ Vertical position
1932
+ <select id="vertical-position">
1933
+ <option
1934
+ data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1935
+ data-img-class="automatic-insertion preview im-sticky-top"
1936
+ data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_TOP_OFFSET; ?>"
1937
+ data-css-<?php echo AI_STICK_HORIZONTAL_CENTER; ?>="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_TOP; ?>"
1938
+ data-title="<?php echo AI_TEXT_STICK_TO_THE_TOP; ?>"
1939
+ value="<?php echo AI_STICK_TO_THE_TOP; ?>"
1940
+ <?php echo ($vertical_position == AI_STICK_TO_THE_TOP) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_TOP; ?></option>
1941
+ <option
1942
+ data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-sticky-center-vertical"
1943
+ data-css="<?php echo AI_ALIGNMENT_CSS_CENTER_VERTICAL; ?>"
1944
+ data-css-<?php echo AI_STICK_HORIZONTAL_CENTER; ?>="<?php echo AI_ALIGNMENT_CSS_CENTER_VERTICAL_H_ANIM; ?>"
1945
+ data-title="<?php echo AI_TEXT_CENTER; ?>"
1946
+ value="<?php echo AI_STICK_VERTICAL_CENTER; ?>"
1947
+ <?php echo ($vertical_position == AI_STICK_VERTICAL_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
1948
+ <option
1949
+ data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1950
+ data-img-class="automatic-insertion preview im-sticky-scroll"
1951
+ data-css="<?php echo AI_ALIGNMENT_CSS_SCROLL_WITH_THE_CONTENT; ?>"
1952
+ data-title="<?php echo AI_TEXT_SCROLL_WITH_THE_CONTENT; ?>"
1953
+ value="<?php echo AI_SCROLL_WITH_THE_CONTENT; ?>"
1954
+ <?php echo ($vertical_position == AI_SCROLL_WITH_THE_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_SCROLL_WITH_THE_CONTENT; ?></option>
1955
+ <option
1956
+ data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>"
1957
+ data-img-class="automatic-insertion preview im-sticky-bottom"
1958
+ data-css="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_BOTTOM_OFFSET; ?>"
1959
+ data-css-<?php echo AI_STICK_HORIZONTAL_CENTER; ?>="<?php echo AI_ALIGNMENT_CSS_STICK_TO_THE_BOTTOM; ?>"
1960
+ data-title="<?php echo AI_TEXT_STICK_TO_THE_BOTTOM; ?>"
1961
+ value="<?php echo AI_STICK_TO_THE_BOTTOM; ?>"
1962
+ <?php echo ($vertical_position == AI_STICK_TO_THE_BOTTOM) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_STICK_TO_THE_BOTTOM; ?></option>
1963
+ </select>
1964
+ <div style="clear: both;"></div>
1965
+ </div>
1966
+
1967
+ <div id="vertical-positions" style="float: right; margin-bottom: 4px;"></div>
1968
+
1969
+ <div style="clear: both;"></div>
1970
+
1971
+ <div class="spinner sticky" style="text-align: right; margin: 8px 0;">
1972
+ <spa>Vertical margin </span>
1973
+ <input id="spinner-vertical-margin" name="value">
1974
+ <span> px</span>
1975
+ </div>
1976
+ </div>
1977
+ <div style="clear: both;"></div>
1978
+ </div>
1979
+
1980
+ <div style="margin: 8px 0;">
1981
+ <span style="vertical-align: middle;">
1982
+ Animation
1983
+ <select id="animation">
1984
+ <option value="<?php echo AI_ANIMATION_NONE; ?>" <?php echo ($animation == AI_ANIMATION_NONE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NONE; ?></option>
1985
+ <option value="<?php echo AI_ANIMATION_FADE; ?>" <?php echo ($animation == AI_ANIMATION_FADE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FADE; ?></option>
1986
+ <option value="<?php echo AI_ANIMATION_SLIDE; ?>" <?php echo ($animation == AI_ANIMATION_SLIDE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_SLIDE; ?></option>
1987
+ <option value="<?php echo AI_ANIMATION_SLIDE_FADE; ?>" <?php echo ($animation == AI_ANIMATION_SLIDE_FADE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_SLIDE_FADE; ?></option>
1988
+ <option value="<?php echo AI_ANIMATION_TURN; ?>" <?php echo ($animation == AI_ANIMATION_TURN) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_TURN; ?></option>
1989
+ <option value="<?php echo AI_ANIMATION_FLIP; ?>" <?php echo ($animation == AI_ANIMATION_FLIP) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLIP; ?></option>
1990
+ <option value="<?php echo AI_ANIMATION_ZOOM_IN; ?>" <?php echo ($animation == AI_ANIMATION_ZOOM_IN) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_ZOOM_IN; ?></option>
1991
+ <option value="<?php echo AI_ANIMATION_ZOOM_OUT; ?>" <?php echo ($animation == AI_ANIMATION_ZOOM_OUT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_ZOOM_OUT; ?></option>
1992
+ </select>
1993
+ </span>
1994
+ <button id="animate-button" type="button" style="margin: 0 0 0 10px; height: 30px; font-size: 12px;">Animate</button>
1995
+ </div>
1996
+
1997
+
1998
+ <?php else : ?>
1999
+
2000
+ <div style="margin: 20px 0 0 0;">
2001
+ Alignment and Style&nbsp;&nbsp;&nbsp;
2002
+ <select id="block-alignment" style="width:120px;">
2003
+ <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-default" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_DEFAULT, true)); ?> value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" data-title="<?php echo AI_TEXT_DEFAULT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
2004
+ <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-align-left" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_LEFT; ?>" data-title="<?php echo AI_TEXT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
2005
+ <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-center" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_CENTER, true)); ?> value="<?php echo AI_ALIGNMENT_CENTER; ?>" data-title="<?php echo AI_TEXT_CENTER; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
2006
+ <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-align-right" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_RIGHT, true)); ?> value="<?php echo AI_ALIGNMENT_RIGHT; ?>" data-title="<?php echo AI_TEXT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_RIGHT; ?></option>
2007
+ <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-float-left" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_FLOAT_LEFT, true)); ?> value="<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" data-title="<?php echo AI_TEXT_FLOAT_LEFT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_LEFT; ?></option>
2008
+ <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-float-right" <?php alt_styles_data ($obj->alignment_style (AI_ALIGNMENT_FLOAT_RIGHT, true)); ?> value="<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" data-title="<?php echo AI_TEXT_FLOAT_RIGHT; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_RIGHT; ?></option>
2009
+ <?php if (function_exists ('ai_preview_style_options')) ai_preview_style_options ($obj, $alignment_type); ?>
2010
+ <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-custom-css" value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" data-title="<?php echo AI_TEXT_CUSTOM_CSS; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
2011
+ <option data-img-src="<?php echo plugins_url ('css/images/blank.png', AD_INSERTER_FILE); ?>" data-img-class="automatic-insertion preview im-no-wrapping" value="<?php echo AI_ALIGNMENT_NO_WRAPPING; ?>" data-title="<?php echo AI_TEXT_NO_WRAPPING; ?>" <?php echo ($alignment_type == AI_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_WRAPPING; ?></option>
2012
+ </select>
2013
+ <span id="css-index" style="display: inline-block; min-width: 30px; min-height: 12px; margin: 0 0 0 10px; font-size: 14px;" title="CSS code index"></span>
2014
+ &nbsp;&nbsp;&nbsp;
2015
+ <span id="close-button-selection" style="display: <?php echo $alignment_type == AI_ALIGNMENT_NO_WRAPPING || $close_button == AI_CLOSE_NONE ? 'none': 'inline'; ?>;">
2016
+ <?php if (function_exists ('ai_close_button_select')) ai_close_button_select (0, $close_button, $close_button, 'close-button-0'); ?>
2017
+ </span>
2018
+ </div>
2019
+
2020
+ <div id="alignment-style" style="margin: 4px 0; min-height: 74px;"></div>
2021
+
2022
+ <?php endif; ?>
2023
+
2024
+ <table class="responsive-table"<?php if ($sticky) echo 'style="height: 60px;"'; ?>>
2025
+ <tr>
2026
+ <td style="vertical-align: middle; padding:0;">
2027
+ <span id="css-label" style="vertical-align: middle; margin: 4px 0 0 0 0; width: 36px; font-size: 14px; font-weight: bold; display: none;">CSS</span>
2028
+ </td>
2029
+ <td style="width: 100%; height: 32px; padding:0;">
2030
+ <input id="custom-css" style="width: 100%; display: inline-block; padding: 5px 0 0 3px; border-radius: 4px; display: none; font-size: 12px; font-family: Courier, 'Courier New', monospace; font-weight: bold;" type="text" value="<?php echo $custom_css_code; ?>" size="70" maxlength="500" title="Custom CSS code for wrapping div" />
2031
+ <span style="width: 100%; display: inline-block; padding: 5px 0 0 2px; font-family: Courier, 'Courier New', monospace; font-size: 12px; font-weight: bold; cursor: pointer; white-space: normal;">
2032
+ <span id="css-no-wrapping" style="vertical-align: middle; display: none;"></span>
2033
+ <span id="css-<?php echo AI_ALIGNMENT_DEFAULT; ?>" class="css-code" style="vertical-align: middle; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_DEFAULT); ?></span>
2034
+ <span id="css-<?php echo AI_ALIGNMENT_LEFT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_LEFT); ?></span>
2035
+ <span id="css-<?php echo AI_ALIGNMENT_RIGHT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_RIGHT); ?></span>
2036
+ <span id="css-<?php echo AI_ALIGNMENT_CENTER; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_CENTER); ?></span>
2037
+ <span id="css-<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_FLOAT_LEFT); ?></span>
2038
+ <span id="css-<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" class="css-code" style="vertical-align: middle;display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_FLOAT_RIGHT); ?></span>
2039
+ <?php if (function_exists ('ai_preview_style_css')) ai_preview_style_css ($obj, $horizontal_position, $vertical_position, $horizontal_margin, $vertical_margin); ?>
2040
+ </span>
2041
+ </td>
2042
+ <td padding:0;>
2043
+ <button id="edit-css-button" type="button" style="margin: 0 0 0 10px; height: 30px; font-size: 12px; display: none;">Edit</button>
2044
+ </td>
2045
+ </tr>
2046
+ </table>
2047
+ </div>
2048
+
2049
+ <?php if (!$sticky) { ?>
2050
+
2051
+ <?php if (!$read_only) : ?>
2052
+ <p id="p1">This is a preview of the code between dummy paragraphs. Here you can test various block alignments, visually edit margin and padding values of the wrapping div
2053
+ or write CSS code directly and watch live preview. Highlight button highlights background, wrapping div margin and code area, while Reset button restores all the values to those of the current block.</p>
2054
+ <?php elseif (!$adsense) : ?>
2055
+ <p id="p1">This is a preview of the saved code block between dummy paragraphs. It shows the code with the alignment and style as it is set for this code block. Highlight button highlights background, wrapping div margin and code area.</p>
2056
+ <?php else : ?>
2057
+ <p id="p1">This is a preview of AdSense ad block between dummy paragraphs. AdSense ad code was loaded from your AdSense account. The ad block is displayed on a dummy page so it may be blank (no ads). Click on the Highlight button to highlight ad block.</p>
2058
+ <?php endif; ?>
2059
+
2060
+ <?php if (!$sticky) padding_margin_code ($close_button, $class, $sticky_parameters, $wrapper_css, $block_code); ?>
2061
+
2062
+ <?php if (!$read_only) : ?>
2063
+ <p id="p2">You can resize the window (and refresh the page to reload ads) to check display with different screen widths.
2064
+ Once you are satisfied with alignment click on the Use button and the settings will be copied to the active block.</p>
2065
+ <p id="p3">Please note that the code, block name, alignment and style are taken from the current block settings (may not be saved).
2066
+ <strong>No Wrapping</strong> style inserts the code as it is so margin and padding can't be set. However, you can use own HTML code for the block.</p>
2067
+ <?php else : ?>
2068
+ <?php endif; ?>
2069
+
2070
+ <p id="p4">Ad Inserter can be configured to insert any code anywhere on the page. Each code with it's settings is called a code block.
2071
+ Free Ad Inserter supports 16 code blocks, Ad Inserter Pro supports up to 96 code blocks (depending on the license type).
2072
+ The settings page is divided into tabs - 16 code blocks and general plugin settings. Black number means inactive code block (code is not inserted anywhere),
2073
+ red number means block is using automatic insertion, blue number means block is using manual insertion while violet number means block is using automatic and manual insertion.</p>
2074
+
2075
+ <p id="p5">Few very important things you need to know in order to insert code and display some ad:
2076
+ Enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call).
2077
+ Enable display on at least one Wordpress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages).
2078
+ Single pages (posts and static pages) have also additional setting for individual exceptions. Use default blank value unless you are using individual post/page exceptions.</p>
2079
+
2080
+ <?php } else { ?>
2081
+ <p id="p1">This is a preview of the code for sticky ads. Here you can test various horizontal and vertical alignments, close button locations, visually edit margin values
2082
+ or write CSS code directly and watch live preview. Highlight button highlights background, margin and code area, while Reset button restores all the values to those of the current block.</p>
2083
+
2084
+ <p id="p2">Ad Inserter can be configured to insert any code anywhere on the page. Each code with it's settings is called a code block.
2085
+ Free Ad Inserter supports 16 code blocks, Ad Inserter Pro supports up to 96 code blocks (depending on the license type).
2086
+ The settings page is divided into tabs - 16 code blocks and general plugin settings. Black number means inactive code block (code is not inserted anywhere),
2087
+ red number means block is using automatic insertion, blue number means block is using manual insertion while violet number means block is using automatic and manual insertion.</p>
2088
+
2089
+ <p id="p3">Few very important things you need to know in order to insert code and display some ad:
2090
+ Enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call).
2091
+ Enable display on at least one Wordpress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages).
2092
+ Single pages (posts and static pages) have also additional setting for individual exceptions. Use default blank value unless you are using individual post/page exceptions.</p>
2093
+
2094
+ <p id="p4">Ad Inserter can be configured to insert any code anywhere on the page. Each code with it's settings is called a code block.
2095
+ Free Ad Inserter supports 16 code blocks, Ad Inserter Pro supports up to 96 code blocks (depending on the license type).
2096
+ The settings page is divided into tabs - 16 code blocks and general plugin settings. Black number means inactive code block (code is not inserted anywhere),
2097
+ red number means block is using automatic insertion, blue number means block is using manual insertion while violet number means block is using automatic and manual insertion.</p>
2098
+
2099
+ <p id="p5">Few very important things you need to know in order to insert code and display some ad:
2100
+ Enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call).
2101
+ Enable display on at least one Wordpress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages).
2102
+ Single pages (posts and static pages) have also additional setting for individual exceptions. Use default blank value unless you are using individual post/page exceptions.</p>
2103
+
2104
+ <p id="p6">Ad Inserter can be configured to insert any code anywhere on the page. Each code with it's settings is called a code block.
2105
+ Free Ad Inserter supports 16 code blocks, Ad Inserter Pro supports up to 96 code blocks (depending on the license type).
2106
+ The settings page is divided into tabs - 16 code blocks and general plugin settings. Black number means inactive code block (code is not inserted anywhere),
2107
+ red number means block is using automatic insertion, blue number means block is using manual insertion while violet number means block is using automatic and manual insertion.</p>
2108
+
2109
+ <p id="p7">Few very important things you need to know in order to insert code and display some ad:
2110
+ Enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call).
2111
+ Enable display on at least one Wordpress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages).
2112
+ Single pages (posts and static pages) have also additional setting for individual exceptions. Use default blank value unless you are using individual post/page exceptions.</p>
2113
+
2114
+ <p id="p8">Ad Inserter can be configured to insert any code anywhere on the page. Each code with it's settings is called a code block.
2115
+ Free Ad Inserter supports 16 code blocks, Ad Inserter Pro supports up to 96 code blocks (depending on the license type).
2116
+ The settings page is divided into tabs - 16 code blocks and general plugin settings. Black number means inactive code block (code is not inserted anywhere),
2117
+ red number means block is using automatic insertion, blue number means block is using manual insertion while violet number means block is using automatic and manual insertion.</p>
2118
+
2119
+ <p id="p9">Few very important things you need to know in order to insert code and display some ad:
2120
+ Enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call).
2121
+ Enable display on at least one Wordpress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages).
2122
+ Single pages (posts and static pages) have also additional setting for individual exceptions. Use default blank value unless you are using individual post/page exceptions.</p>
2123
+ <?php } ?>
2124
+
2125
+ <span class="ai-content"></span>
2126
+ </div>
2127
+ </div>
2128
+
2129
+ <?php ai_wp_footer_hook (); ?>
2130
+ <script>
2131
+ <?php if (function_exists ('ai_load_settings_2')) echo ai_get_js ('ai-close'); ?>
2132
+ <?php
2133
+ if ($sticky) echo ai_get_js ('ai-sticky');
2134
+ if ($sticky) echo "setTimeout (function() {AOS.init();}, 200);\n";
2135
+ if (defined ('AI_ADSENSE_OVERLAY')) {
2136
+ echo ai_get_js ('ai-ads');
2137
+ }
2138
+ ?>
2139
+ </script>
2140
+ </body>
2141
+ </html>
2142
+ <?php
2143
+ }
2144
+
js/ad-inserter.js CHANGED
@@ -1,4 +1,4 @@
1
- var javascript_version = "2.3.7";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
@@ -261,6 +261,9 @@ function SyntaxHighlight (id, block, settings) {
261
  this.editor = editor = ace.edit(editDiv[0]);
262
  this.form = form = textarea.closest('form');
263
  this.session = session = editor.getSession();
 
 
 
264
  session.setValue(textarea.val());
265
 
266
  // copy back to textarea on form submit...
@@ -317,27 +320,12 @@ SyntaxHighlight.prototype.applySettings = function () {
317
  session.setUseSoftTabs(settings['use_soft_tabs'] == 1);
318
  };
319
 
320
- function get_sticky_classes (custom_css) {
321
  custom_css = custom_css.replace (/\s+/g, '');
322
- var sticky_classes = [];
323
- if (custom_css.indexOf ("position:fixed") != - 1 &&
324
- custom_css.indexOf ("z-index:9995") != - 1 &&
325
- custom_css.indexOf ("display:none") != - 1) {
326
- if (custom_css.indexOf (";left:auto") != - 1) {
327
- sticky_classes.push ('ai-sticky-content');
328
- sticky_classes.push ('ai-sticky-left');
329
- } else
330
- if (custom_css.indexOf ("right:auto") != - 1) {
331
- sticky_classes.push ('ai-sticky-content');
332
- sticky_classes.push ('ai-sticky-right');
333
- };
334
 
335
- if (custom_css.indexOf ("margin-bottom:auto") != - 1) {
336
- sticky_classes.push ('ai-sticky-content');
337
- sticky_classes.push ('ai-sticky-scroll');
338
- };
339
- }
340
- return sticky_classes;
341
  }
342
 
343
  function change_block_alignment (block) {
@@ -350,6 +338,73 @@ function change_banner_image (block) {
350
  jQuery ("input#banner-image-url-" + block).trigger ("input");
351
  }
352
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
 
354
  (function ($) {
355
  $.widget("toggle.checkboxButton", {
@@ -997,7 +1052,10 @@ jQuery(document).ready(function($) {
997
 
998
  $("#no-wrapping-warning-"+block).hide();
999
 
1000
- $("#sticky-settings-"+block).hide();
 
 
 
1001
 
1002
  var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
1003
 
@@ -1008,6 +1066,10 @@ jQuery(document).ready(function($) {
1008
  if ($("#client-side-detection-"+block).is(":checked")) {
1009
  $("#no-wrapping-warning-"+block).show();
1010
  }
 
 
 
 
1011
  } else
1012
  if (alignment == AI_ALIGNMENT_DEFAULT) {
1013
  $("#css-none-"+block).css('display', 'table-cell');
@@ -1016,6 +1078,10 @@ jQuery(document).ready(function($) {
1016
  $("#icons-css-code-" + block).show();
1017
  $("#custom-css-"+block).show();
1018
  configure_selection_icons (block);
 
 
 
 
1019
  } else
1020
  if (alignment == AI_ALIGNMENT_LEFT) {
1021
  $("#css-left-"+block).css('display', 'table-cell');
@@ -1046,7 +1112,8 @@ jQuery(document).ready(function($) {
1046
  } else
1047
  if (alignment == AI_ALIGNMENT_STICKY) {
1048
  $("#icons-css-code-" + block).show();
1049
- $("#sticky-settings-"+block).show();
 
1050
  $("#css-sticky-"+block).css('display', 'table-cell');
1051
  configure_selection_icons (block);
1052
  }
@@ -1855,9 +1922,12 @@ jQuery(document).ready(function($) {
1855
 
1856
  var sticky = false;
1857
 
1858
- var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
1859
- var horizontal = $("select#horizontal-position-"+block+" option:selected").attr('value');
1860
- var vertical = $("select#vertical-position-"+block+" option:selected").attr('value');
 
 
 
1861
 
1862
  var custom_css = $("#custom-css-"+block).val ();
1863
 
@@ -1866,8 +1936,8 @@ jQuery(document).ready(function($) {
1866
  alignment_css = $("#css-none-"+block).text ();
1867
  } else
1868
  if (alignment == AI_ALIGNMENT_CUSTOM_CSS) {
1869
- alignment_css = $("#custom-css-"+block).val();
1870
- sticky = get_sticky_classes (custom_css).length != 0;
1871
  } else
1872
  if (alignment == AI_ALIGNMENT_LEFT) {
1873
  alignment_css = $("#css-left-"+block).text ();
@@ -1897,13 +1967,12 @@ jQuery(document).ready(function($) {
1897
  alignment_css = $("#css-sticky-bottom-"+block).text ();
1898
  } else
1899
  if (alignment == AI_ALIGNMENT_STICKY) {
1900
- alignment_css = $("#css-sticky-"+block).text ();
1901
  sticky = true;
1902
  }
1903
 
1904
  var name = $("#name-label-"+block).text ();
1905
-
1906
- var code = $.base64Encode (get_editor_text (block));
1907
  var php = $("input#process-php-"+block).is(":checked") ? 1 : 0;
1908
  var label = $("input#show-label-"+block).is(":checked") ? 1 : 0;
1909
 
@@ -1923,7 +1992,24 @@ jQuery(document).ready(function($) {
1923
 
1924
  var nonce = $("#ai-form").attr ('nonce');
1925
 
1926
- var param = {'action': 'ai_ajax_backend', 'preview': block, 'ai_check': nonce, 'name': $.base64Encode (name), 'alignment': btoa (alignment), 'horizontal': btoa (horizontal), 'vertical': btoa (vertical), 'alignment_css': btoa (alignment_css), 'custom_css': btoa (custom_css), 'code': code, 'php': php, 'label': label, 'close': close_button};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1927
  window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
1928
  });
1929
 
@@ -1937,7 +2023,13 @@ jQuery(document).ready(function($) {
1937
  create_list_editor ('ip-address', tab);
1938
  create_list_selector ('country', tab);
1939
 
1940
- $('#tracking-' + tab).checkboxButton ();
 
 
 
 
 
 
1941
  $('#simple-editor-' + tab).checkboxButton ().click (function () {
1942
  var block = $(this).attr('id').replace ("simple-editor-", "");
1943
  if (block == active_tab) {
@@ -2355,6 +2447,16 @@ jQuery(document).ready(function($) {
2355
  duration: 50,
2356
  }
2357
  });
 
 
 
 
 
 
 
 
 
 
2358
  }
2359
 
2360
  function configure_sticky_css (block) {
@@ -2425,6 +2527,14 @@ jQuery(document).ready(function($) {
2425
  $(this).attr ('title', titles [index]);
2426
  });
2427
 
 
 
 
 
 
 
 
 
2428
  css_code_container.addClass ('configured');
2429
  }
2430
  }
@@ -2470,6 +2580,9 @@ jQuery(document).ready(function($) {
2470
  rotation_container.find ('input.option-name').each (function (index) {
2471
  if (index < options) $(this).val (code_data ['options'][index]['name']);
2472
  });
 
 
 
2473
  }
2474
  }
2475
  }).fail (function (xhr, status, error) {
@@ -2502,7 +2615,7 @@ jQuery(document).ready(function($) {
2502
  rotation_container.find ("div.rounded").each (function (index) {
2503
  var code_data = $('#option-' + block + '-' + (index + 1)).data ('code');
2504
  var code = typeof code_data == 'undefined' ? '' : $.base64Decode (code_data);
2505
- var option_data = {'name': $(this).find ('input.option-name').val (), 'code': code};
2506
 
2507
  rotation_data.push (option_data);
2508
  });
1
+ var javascript_version = "2.3.8";
2
  var ignore_key = true;
3
  var start = 1;
4
  var end = 16;
261
  this.editor = editor = ace.edit(editDiv[0]);
262
  this.form = form = textarea.closest('form');
263
  this.session = session = editor.getSession();
264
+
265
+ editor.$blockScrolling = Infinity;
266
+
267
  session.setValue(textarea.val());
268
 
269
  // copy back to textarea on form submit...
320
  session.setUseSoftTabs(settings['use_soft_tabs'] == 1);
321
  };
322
 
323
+ function is_sticky (custom_css) {
324
  custom_css = custom_css.replace (/\s+/g, '');
 
 
 
 
 
 
 
 
 
 
 
 
325
 
326
+ if (custom_css.indexOf ("position:fixed") != - 1 && custom_css.indexOf ("z-index:") != - 1) return true;
327
+
328
+ return false;
 
 
 
329
  }
330
 
331
  function change_block_alignment (block) {
338
  jQuery ("input#banner-image-url-" + block).trigger ("input");
339
  }
340
 
341
+ function ai_css_value_px (css, property) {
342
+ var found = false;
343
+
344
+ styles = css.split (';');
345
+ styles.forEach (function (style, index) {
346
+ style = style.trim ();
347
+ if (style.indexOf (property) == 0) {
348
+ style_parts = style.split (':');
349
+ if (style_parts.length == 2) {
350
+ style_property = style_parts [0].trim ();
351
+ style_value = style_parts [1].trim ();
352
+ if (style_property == property && style_value.endsWith ('px')) found = true;
353
+ }
354
+ }
355
+ });
356
+
357
+ return found;
358
+ }
359
+
360
+ function ai_change_css (css, property, value) {
361
+ var replaced = false;
362
+
363
+ styles = css.split (';');
364
+ styles.forEach (function (style, index) {
365
+ org_style = style;
366
+ style = style.trim ();
367
+ if (style.indexOf (property) == 0) {
368
+ style_parts = style.split (':');
369
+ if (style_parts.length == 2) {
370
+ style_property = style_parts [0].trim ();
371
+ style_value = style_parts [1].trim ();
372
+ if (style_property == property && style_value.endsWith ('px')) {
373
+ var org_style_parts = org_style.split (':');
374
+ styles [index] = org_style_parts [0] + ': ' + value + 'px';
375
+ replaced = true;
376
+ }
377
+ }
378
+ }
379
+ });
380
+
381
+ var new_style = styles.join (';');
382
+
383
+ if (!replaced) {
384
+ new_style = new_style.trim ();
385
+ if (new_style.length != 0 && new_style.slice (-1) == ';') new_style = new_style.substring (0, new_style.length - 1);
386
+ return new_style + '; ' + property + ': ' + value + ';';
387
+ }
388
+
389
+ return new_style;
390
+ }
391
+
392
+ function update_sticky_margins (style, horizontal_margin, vertical_margin) {
393
+
394
+ if (vertical_margin !== '') {
395
+ if (ai_css_value_px (style, 'top')) style = ai_change_css (style, 'top', vertical_margin);
396
+ if (ai_css_value_px (style, 'bottom')) style = ai_change_css (style, 'bottom', vertical_margin);
397
+ }
398
+
399
+ if (horizontal_margin !== '') {
400
+ if (ai_css_value_px (style, 'left')) style = ai_change_css (style, 'left', horizontal_margin); else
401
+ if (ai_css_value_px (style, 'right')) style = ai_change_css (style, 'right', horizontal_margin); else
402
+ if (ai_css_value_px (style, 'margin-left')) style = ai_change_css (style, 'margin-left', horizontal_margin); else
403
+ if (ai_css_value_px (style, 'margin-right')) style = ai_change_css (style, 'margin-right', horizontal_margin);
404
+ }
405
+
406
+ return style;
407
+ }
408
 
409
  (function ($) {
410
  $.widget("toggle.checkboxButton", {
1052
 
1053
  $("#no-wrapping-warning-"+block).hide();
1054
 
1055
+ $("#sticky-position-"+block).hide();
1056
+ $("#sticky-animation-"+block).hide();
1057
+
1058
+ $('#tracking-wrapping-warning-' + block).hide ();
1059
 
1060
  var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
1061
 
1066
  if ($("#client-side-detection-"+block).is(":checked")) {
1067
  $("#no-wrapping-warning-"+block).show();
1068
  }
1069
+
1070
+ if ($('#tracking-' + block).next ().find ('.checkbox-icon').hasClass ('on')) {
1071
+ $('#tracking-wrapping-warning-' + block).show ();
1072
+ }
1073
  } else
1074
  if (alignment == AI_ALIGNMENT_DEFAULT) {
1075
  $("#css-none-"+block).css('display', 'table-cell');
1078
  $("#icons-css-code-" + block).show();
1079
  $("#custom-css-"+block).show();
1080
  configure_selection_icons (block);
1081
+ if (is_sticky ($("#custom-css-"+block).val ())) {
1082
+ $("#sticky-position-"+block).show();
1083
+ $("#sticky-animation-"+block).show();
1084
+ }
1085
  } else
1086
  if (alignment == AI_ALIGNMENT_LEFT) {
1087
  $("#css-left-"+block).css('display', 'table-cell');
1112
  } else
1113
  if (alignment == AI_ALIGNMENT_STICKY) {
1114
  $("#icons-css-code-" + block).show();
1115
+ $("#sticky-position-"+block).show();
1116
+ $("#sticky-animation-"+block).show();
1117
  $("#css-sticky-"+block).css('display', 'table-cell');
1118
  configure_selection_icons (block);
1119
  }
1922
 
1923
  var sticky = false;
1924
 
1925
+ var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
1926
+ var horizontal = $("select#horizontal-position-"+block+" option:selected").attr('value');
1927
+ var vertical = $("select#vertical-position-"+block+" option:selected").attr('value');
1928
+ var horizontal_margin = $("#horizontal-margin-"+block).val ();
1929
+ var vertical_margin = $("#vertical-margin-"+block).val ();
1930
+ var animation = $("select#animation-"+block+" option:selected").attr('value');
1931
 
1932
  var custom_css = $("#custom-css-"+block).val ();
1933
 
1936
  alignment_css = $("#css-none-"+block).text ();
1937
  } else
1938
  if (alignment == AI_ALIGNMENT_CUSTOM_CSS) {
1939
+ alignment_css = custom_css;
1940
+ sticky = is_sticky (custom_css);
1941
  } else
1942
  if (alignment == AI_ALIGNMENT_LEFT) {
1943
  alignment_css = $("#css-left-"+block).text ();
1967
  alignment_css = $("#css-sticky-bottom-"+block).text ();
1968
  } else
1969
  if (alignment == AI_ALIGNMENT_STICKY) {
1970
+ alignment_css = update_sticky_margins ($("#css-sticky-"+block).text (), horizontal_margin, vertical_margin);
1971
  sticky = true;
1972
  }
1973
 
1974
  var name = $("#name-label-"+block).text ();
1975
+ var code = get_editor_text (block);
 
1976
  var php = $("input#process-php-"+block).is(":checked") ? 1 : 0;
1977
  var label = $("input#show-label-"+block).is(":checked") ? 1 : 0;
1978
 
1992
 
1993
  var nonce = $("#ai-form").attr ('nonce');
1994
 
1995
+ var param = {
1996
+ 'action': 'ai_ajax_backend',
1997
+ 'preview': block,
1998
+ 'ai_check': nonce,
1999
+ 'name': $.base64Encode (name),
2000
+ 'code': $.base64Encode (code),
2001
+ 'alignment': btoa (alignment),
2002
+ 'horizontal': btoa (horizontal),
2003
+ 'vertical': btoa (vertical),
2004
+ 'horizontal_margin': btoa (horizontal_margin),
2005
+ 'vertical_margin': btoa (vertical_margin),
2006
+ 'animation': btoa (animation),
2007
+ 'alignment_css': btoa (alignment_css),
2008
+ 'custom_css': btoa (custom_css),
2009
+ 'php': php,
2010
+ 'label': label,
2011
+ 'close': close_button
2012
+ };
2013
  window_open_post (ajaxurl, 'width='+window_width+',height='+window_height+',top='+window_top+',left='+window_left+',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no', 'preview', param);
2014
  });
2015
 
2023
  create_list_editor ('ip-address', tab);
2024
  create_list_selector ('country', tab);
2025
 
2026
+ $('#tracking-' + tab).checkboxButton ().click (function () {
2027
+ var block = $(this).attr('id').replace ("tracking-", "");
2028
+ var alignment = $("select#block-alignment-"+block+" option:selected").attr('value');
2029
+ var tracking = !$('#tracking-' + block).next ().find ('.checkbox-icon').hasClass ('on');
2030
+ if (tracking && alignment == AI_ALIGNMENT_NO_WRAPPING) $('#tracking-wrapping-warning-' + block).show (); else $('#tracking-wrapping-warning-' + block).hide ();
2031
+ });
2032
+
2033
  $('#simple-editor-' + tab).checkboxButton ().click (function () {
2034
  var block = $(this).attr('id').replace ("simple-editor-", "");
2035
  if (block == active_tab) {
2447
  duration: 50,
2448
  }
2449
  });
2450
+
2451
+ $("select#close-button-" + tab).change (function () {
2452
+ var block = $(this).attr('id').replace ("close-button-", "");
2453
+ $("select#close-button2-"+block+"").val ($("select#close-button-"+block+" option:selected").attr('value'));
2454
+ });
2455
+
2456
+ $("select#close-button2-" + tab).change (function () {
2457
+ var block = $(this).attr('id').replace ("close-button2-", "");
2458
+ $("select#close-button-"+block+"").val ($("select#close-button2-"+block+" option:selected").attr('value'));
2459
+ });
2460
  }
2461
 
2462
  function configure_sticky_css (block) {
2527
  $(this).attr ('title', titles [index]);
2528
  });
2529
 
2530
+ // var titles = new Array();
2531
+ // $("select#close-button-"+block).imagepicker({hide_select: false}).find ('option').each (function (index) {
2532
+ // titles.push ($(this).data ('title'));
2533
+ // });
2534
+ // $("select#close-button2-"+block+" + ul").appendTo("#close-buttons-"+block).css ('padding-top', '10px').find ('li').each (function (index) {
2535
+ // $(this).attr ('title', titles [index]);
2536
+ // });
2537
+
2538
  css_code_container.addClass ('configured');
2539
  }
2540
  }
2580
  rotation_container.find ('input.option-name').each (function (index) {
2581
  if (index < options) $(this).val (code_data ['options'][index]['name']);
2582
  });
2583
+ rotation_container.find ('input.option-share').each (function (index) {
2584
+ if (index < options) $(this).val (code_data ['options'][index]['share']);
2585
+ });
2586
  }
2587
  }
2588
  }).fail (function (xhr, status, error) {
2615
  rotation_container.find ("div.rounded").each (function (index) {
2616
  var code_data = $('#option-' + block + '-' + (index + 1)).data ('code');
2617
  var code = typeof code_data == 'undefined' ? '' : $.base64Decode (code_data);
2618
+ var option_data = {'name': $(this).find ('input.option-name').val (), 'share': $(this).find ('input.option-share').val (), 'code': code};
2619
 
2620
  rotation_data.push (option_data);
2621
  });
readme.txt CHANGED
@@ -6,10 +6,10 @@ Tags: ads, adsense, header footer code, ad management, sticky fixed widgets, adv
6
  Requires at least: 4.0
7
  Tested up to: 4.9
8
  Requires PHP: 5.3
9
- Stable tag: 2.3.6
10
  License: GPLv3
11
 
12
- Insert and manage ads: AdSense, Amazon, banners, ad rotation, sticky ad widgets, shortcodes, AMP, PHP, HTML, CSS, form, tracking, header, footer code
13
 
14
  == Description ==
15
 
@@ -26,7 +26,11 @@ Average Rating: 5 out of 5 stars
26
 
27
  > Perfect plugin to insert anything anywhere on your WordPress website
28
 
29
- Check Ad Inserter <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/">reviews</a>
 
 
 
 
30
 
31
  **Endorsed by Google**
32
 
@@ -84,6 +88,7 @@ Check <a href="https://affiliate-program.amazon.com/help/topic/t405" target="_bl
84
  * Use custom fields as defined in posts
85
  * Use post title, tags or categories to create contextual ads
86
  * PHP code processing
 
87
  * Ad rotation (server-side and client-side - works with caching)
88
  * Ad blocking detection - popup message, page redirection
89
  * Desktop/mobile device detection (server-side and client-side - works with caching)
@@ -93,6 +98,7 @@ Check <a href="https://affiliate-program.amazon.com/help/topic/t405" target="_bl
93
  * Function to visualize inserted code blocks
94
  * Function to visualize available insertion positions
95
  * Function to visualize HTML tags
 
96
 
97
  And Ad Inserter Pro - all-in-one <a href="http://adinserter.pro/" target="_blank">WordPress ad management plugin</a> has even more advanced features:
98
 
@@ -102,7 +108,10 @@ And Ad Inserter Pro - all-in-one <a href="http://adinserter.pro/" target="_blank
102
  * Ad impression and click tracking (works also with `<iframe>` Javascript ads like Google AdSense)
103
  * External tracking via Google Analytics or Piwik
104
  * A/B testing
105
- * Sticky ad positions with optional close button (left, top, right, bottom)
 
 
 
106
  * Scheduling with fallback option
107
  * Ad blocking detection - ad replacement, content protection
108
  * Ad blocking statistics
@@ -471,8 +480,6 @@ Use `*` to define url pattern to whitelist (enable) or blacklist (disable).
471
 
472
  For example, to exclude ads on pages that have /shop/ in url (page address) blacklist the following url: `*/shop/*`
473
 
474
- **WARNING:** Separate urls with SPACES.
475
-
476
 
477
  = How can I put an ad in the middle of the post regardless of the number of paragraphs? =
478
 
@@ -486,7 +493,18 @@ Use Before paragraph automatic insertion and put `2, 0.5` as paragraph number. Y
486
 
487
  = I'd like to rotate my ad codes based on percentage, for example show one ad 75% of the time and another one 25% of the time. Is that possible? =
488
 
489
- Yes, simply create block with 4 ads separated with [ADINSERTER ROTATE]: 3 times ad1 and 1 time ad2.
 
 
 
 
 
 
 
 
 
 
 
490
 
491
 
492
  = How can I show different ads to different visitors according to a url query parameter? =
@@ -626,6 +644,11 @@ AD CODE RIGHT
626
 
627
  == Changelog ==
628
 
 
 
 
 
 
629
  = 2.3.7 =
630
  - Added support for ad labels
631
  - Blocked search indexing while debugging
@@ -714,6 +737,11 @@ For the changelog of earlier versions, please refer to the separate changelog.tx
714
 
715
  == Upgrade Notice ==
716
 
 
 
 
 
 
717
  = 2.3.7 =
718
  Added support for ad labels;
719
  Blocked search indexing while debugging;
6
  Requires at least: 4.0
7
  Tested up to: 4.9
8
  Requires PHP: 5.3
9
+ Stable tag: 2.3.7
10
  License: GPLv3
11
 
12
+ Insert and manage ads: Amazon, AdSense ads, banner rotation, sticky widget ads, shortcodes, AMP, PHP, HTML, CSS, form, tracking, footer, header code
13
 
14
  == Description ==
15
 
26
 
27
  > Perfect plugin to insert anything anywhere on your WordPress website
28
 
29
+ Check <a href="https://wordpress.org/support/plugin/ad-inserter/reviews/">Ad Inserter reviews</a>
30
+
31
+ > The Best WordPress Ad Management Plugin?
32
+
33
+ Check <a href="https://wpmayor.com/ad-inserter-review-the-best-wordpress-ad-management-plugin/">Ad Inserter review</a> on WP Mayor
34
 
35
  **Endorsed by Google**
36
 
88
  * Use custom fields as defined in posts
89
  * Use post title, tags or categories to create contextual ads
90
  * PHP code processing
91
+ * Ad labels
92
  * Ad rotation (server-side and client-side - works with caching)
93
  * Ad blocking detection - popup message, page redirection
94
  * Desktop/mobile device detection (server-side and client-side - works with caching)
98
  * Function to visualize inserted code blocks
99
  * Function to visualize available insertion positions
100
  * Function to visualize HTML tags
101
+ * You name it :)
102
 
103
  And Ad Inserter Pro - all-in-one <a href="http://adinserter.pro/" target="_blank">WordPress ad management plugin</a> has even more advanced features:
104
 
108
  * Ad impression and click tracking (works also with `<iframe>` Javascript ads like Google AdSense)
109
  * External tracking via Google Analytics or Piwik
110
  * A/B testing
111
+ * Sticky ad positions with optional close button
112
+ * Sticky sidebar ads (stick to the screen or to the content)
113
+ * Sticky ad trigger (page scroll in % or px, HTML element visible)
114
+ * Sticky ad animations (fade, slide, turn, flip, zoom)
115
  * Scheduling with fallback option
116
  * Ad blocking detection - ad replacement, content protection
117
  * Ad blocking statistics
480
 
481
  For example, to exclude ads on pages that have /shop/ in url (page address) blacklist the following url: `*/shop/*`
482
 
 
 
483
 
484
  = How can I put an ad in the middle of the post regardless of the number of paragraphs? =
485
 
493
 
494
  = I'd like to rotate my ad codes based on percentage, for example show one ad 75% of the time and another one 25% of the time. Is that possible? =
495
 
496
+ Yes. Either use rotation code generator and define shares in percents or create code using `ROTATE` separator with attribute *share* where you define percentage of the rotation share:
497
+
498
+ `[ADINSERTER ROTATE share="75"]
499
+ ad_code_1
500
+ [ADINSERTER ROTATE share="25"]
501
+ ad_code_2`
502
+
503
+ If you omit one share value it will be automatically calculated:
504
+
505
+ `ad_code_1
506
+ [ADINSERTER ROTATE share="25"]
507
+ ad_code_2`
508
 
509
 
510
  = How can I show different ads to different visitors according to a url query parameter? =
644
 
645
  == Changelog ==
646
 
647
+ = 2.3.8 =
648
+ - Added support rotation option shares
649
+ - Added support for sticky ad settings and animations (Pro only)
650
+ - Few minor bug fixes, cosmetic changes and code improvements
651
+
652
  = 2.3.7 =
653
  - Added support for ad labels
654
  - Blocked search indexing while debugging
737
 
738
  == Upgrade Notice ==
739
 
740
+ = 2.3.8 =
741
+ Added support rotation option shares;
742
+ Added support for sticky ad settings and animations (Pro only);
743
+ Few minor bug fixes, cosmetic changes and code improvements
744
+
745
  = 2.3.7 =
746
  Added support for ad labels;
747
  Blocked search indexing while debugging;
settings.php CHANGED
@@ -1,3494 +1,3522 @@
1
- <?php
2
-
3
- require_once AD_INSERTER_PLUGIN_DIR.'constants.php';
4
-
5
- function generate_settings_form (){
6
-
7
- if (defined ('AI_ADSENSE_API')) {
8
- require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php';
9
- }
10
-
11
- global $ai_db_options, $block_object, $ai_wp_data, $ai_db_options_extract;
12
- global $rating_value, $rating_string, $rating_css, $ai_custom_hooks;
13
-
14
- wp_enqueue_media();
15
-
16
- $save_url = $_SERVER ['REQUEST_URI'];
17
- if (isset ($_GET ['tab'])) {
18
- $save_url = preg_replace ("/&tab=\d+/", "", $save_url);
19
- }
20
-
21
- $generate_all = false;
22
- if (isset ($_GET ['generate-all']) && $_GET ['generate-all'] == 1) {
23
- $generate_all = true;
24
- }
25
-
26
- $subpage = 'main';
27
- $start = 1;
28
- $end = 16;
29
- if (function_exists ('ai_settings_parameters')) ai_settings_parameters ($subpage, $start, $end);
30
-
31
- if (isset ($_POST ['ai-active-tab'])) {
32
- $active_tabs = json_decode ($_POST ['ai-active-tab']);
33
- if ($active_tabs == null) $active_tabs = array ($start, 0);
34
- }
35
-
36
- if (isset ($_GET ['settings'])) {
37
- $active_tab = $_GET ['settings'];
38
- if (isset ($_GET ['single'])) {
39
- $start = $active_tab;
40
- $end = $active_tab;
41
- } else {
42
- $start = intval (($active_tab - 1) / 16) * 16 + 1;
43
- $end = $start + 15;
44
- }
45
- }
46
- elseif (isset ($_GET ['tab'])) $active_tab = $_GET ['tab']; else
47
- $active_tab = isset ($active_tabs [0]) ? $active_tabs [0] : $start;
48
- if (!is_numeric ($active_tab)) $active_tab = 1;
49
- if ($active_tab != 0)
50
- if ($active_tab < $start || $active_tab > $end) $active_tab = $start;
51
-
52
- $active_tab_0 = isset ($active_tabs [1]) ? $active_tabs [1] : 0;
53
-
54
- $adH = $block_object [AI_HEADER_OPTION_NAME];
55
- $adF = $block_object [AI_FOOTER_OPTION_NAME];
56
-
57
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
58
- $adA = $block_object [AI_ADB_MESSAGE_OPTION_NAME];
59
- }
60
-
61
- $syntax_highlighter_theme = get_syntax_highlighter_theme ();
62
- $block_class_name = get_block_class_name ();
63
- $block_class = get_block_class ();
64
- $block_number_class = get_block_number_class ();
65
- $inline_styles = get_inline_styles ();
66
-
67
- $default = $block_object [0];
68
-
69
- $exceptions = false;
70
- $block_exceptions = array ();
71
- if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) {
72
- $args = array (
73
- 'public' => true,
74
- '_builtin' => false
75
- );
76
- $custom_post_types = get_post_types ($args, 'names', 'and');
77
- $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types));
78
-
79
- $args = array (
80
- 'posts_per_page' => 100,
81
- 'offset' => 0,
82
- 'category' => '',
83
- 'category_name' => '',
84
- 'orderby' => 'type',
85
- 'order' => 'ASC',
86
- 'include' => '',
87
- 'exclude' => '',
88
- 'meta_key' => '_adinserter_block_exceptions',
89
- 'meta_value' => '',
90
- 'post_type' => $screens,
91
- 'post_mime_type' => '',
92
- 'post_parent' => '',
93
- 'author' => '',
94
- 'author_name' => '',
95
- 'post_status' => '',
96
- 'suppress_filters' => true
97
- );
98
- $posts_pages = get_posts ($args);
99
-
100
- $exceptions = array ();
101
- foreach ($posts_pages as $page) {
102
- $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true);
103
- if ($post_meta == '') continue;
104
- $post_type_object = get_post_type_object ($page->post_type);
105
- $exceptions [$page->ID] = array ('type' => $page->post_type, 'name' => $post_type_object->labels->singular_name, 'title' => $page->post_title, 'blocks' => $post_meta);
106
-
107
- $selected_blocks = explode (",", $post_meta);
108
- foreach ($selected_blocks as $selected_block) {
109
- $block_exceptions [$selected_block][$page->ID] = array ('type' => $page->post_type, 'name' => $post_type_object->labels->singular_name, 'title' => $page->post_title);
110
- }
111
- }
112
- }
113
-
114
- if ($rating_string = get_transient (AI_TRANSIENT_RATING)) {
115
- if ($rating_string < 1 && $rating_string > 5) $rating_string = '';
116
- }
117
- $rating_css = $rating_string == '' ? 'width: 100%;' : 'width: '.number_format ($rating_string * 20, 4).'%;';
118
- $rating_value = $rating_string == '' ? '' : number_format ($rating_string, 1);
119
-
120
- if (isset ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS])) $used_blocks = unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]); else $used_blocks = array ();
121
-
122
- if (!isset ($_GET ['settings'])): // start of code only for normal settings
123
-
124
- if (function_exists ('ai_admin_settings_notices')) ai_admin_settings_notices ();
125
- ?>
126
-
127
- <div id="ai-data" style="display: none;" version="<?php echo AD_INSERTER_VERSION; ?>" theme="<?php echo $syntax_highlighter_theme; ?>" js_debugging="<?php echo $ai_wp_data [AI_BACKEND_JS_DEBUGGING] ? '1' : '0'; ?>" ></div>
128
- <?php
129
- if (function_exists ('ai_data_2')) ai_data_2 ();
130
- ?>
131
-
132
- <div id="ai-clipboard" style="display: none;"></div>
133
-
134
- <div style="clear: both;"></div>
135
-
136
- <div id="ai-settings" style="float: left;">
137
-
138
- <form id="ai-form" class="no-select rounded" style="float: left;" action="<?php echo $save_url; ?>" method="post" name="ai_form" start="<?php echo $start; ?>" end="<?php echo $end; ?>" nonce="<?php echo wp_create_nonce ("adinserter_data"); ?>">
139
-
140
- <div id="header" class="ai-form header rounded">
141
- <?php
142
- if (function_exists ('ai_settings_header')) ai_settings_header ($start, $active_tab); else { ?>
143
-
144
- <div style="float: left;">
145
- <h2 id="plugin_name" style="display: inline-block; margin: 5px 0;"><?php echo AD_INSERTER_NAME . ' ' . AD_INSERTER_VERSION ?></h2>
146
- </div>
147
- <div id="header-buttons">
148
- <img id="ai-loading" src="<?php echo AD_INSERTER_PLUGIN_IMAGES_URL; ?>loading.gif" style="width: 24px; height: 24px; vertical-align: middle; margin-right: 20px; display: none;" />
149
- <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('http://adinserter.pro/documentation')" title="<?php echo AD_INSERTER_NAME; ?> Documentation">Doc</button>
150
- <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter')" title="<?php echo AD_INSERTER_NAME; ?> support forum">Support</button>
151
- <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHGZEMRTR7WB4')" title="Support Free Ad Inserter development. If you are making money with Ad Inserter consider donating some small amount. Even 1 dollar counts. Thank you!">Donate</button>
152
- <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('https://wordpress.org/support/plugin/ad-inserter/reviews/')" title="If you like Ad Inserter and have a moment, please help me spread the word by reviewing the plugin on WordPres">Review</button>
153
- <button type="button" class="ai-top-button" style="display: none; margin: 0 10px 0 0; width: 62px; outline-color: transparent;" onclick="window.open('http://adinserter.pro/')" title="Need more code blocks, GEO targeting, impression and click tracking? Upgrade to Ad Inserter Pro">Go&nbsp;Pro</button>
154
- <button id="ai-list" type="button" class="ai-top-button" style="width: 62px; display: none; margin-right: 0px; outline-color: transparent;" title="Show list of all code blocks"><span>Blocks</span></button>
155
- </div>
156
-
157
- <div style="clear: both;"></div>
158
- <?php
159
- }
160
- ?>
161
- </div>
162
-
163
- <div id="javascript-warning" class="ai-form rounded" style="display: none;">
164
- <h2 id="javascript-version" style="float: left; color: red;" title="Loaded plugin javascript version">&nbsp;</h2>
165
- <div style="float: right; text-align: right; margin: 8px 5px 0px 0;">
166
- <span id="javascript-version-parameter" style="display: none;">Wrong or <a href="https://adinserter.pro/documentation#missing-version-parameter" class="simple-link" target="_blank">missing version parameter</a> for the javscript file, probably due to inappropriate caching.<br /></span>
167
- <span id="javascript-version-parameter-missing" style="display: none;">Missing version parameter for the javscript file, probably due to inappropriate caching.<br /></span>
168
- Incompatible (old) javscript file loaded, probably due to inappropriate caching.<br />
169
- Please delete browser's cache and all other caches used and then reload this page.
170
- </div>
171
- <div style="clear: both;"></div>
172
- </div>
173
-
174
- <div id="css-warning" class="ai-form rounded" style="display: none;">
175
- <h2 id="css-version" style="float: left; color: red;" title="Loaded plugin CSS version">&nbsp;</h2>
176
- <div style="float: right; text-align: right; margin: 8px 5px 0px 0;">
177
- <span id="css-version-parameter" style="display: none;">Wrong version parameter for the CSS file, probably due to inappropriate caching.<br /></span>
178
- <span id="css-version-parameter-missing" style="display: none;">Missing version parameter for the CSS file, probably due to inappropriate caching.<br /></span>
179
- Incompatible (old) CSS file loaded, probably due to inappropriate caching.<br />
180
- Please delete browser's cache and all other caches used and then reload this page.
181
- </div>
182
- <div style="clear: both;"></div>
183
- </div>
184
-
185
- <div id="blocked-warning" class="ai-form warning-enabled rounded">
186
- <h2 class="blocked-warning-text" style="float: left; color: red; margin: 7px 0;" title="Error loading page">WARNING</h2>
187
- <div style="float: right; text-align: right; width: 630px; margin: 8px 5px 0px 0;">
188
- Page may <a href="https://adinserter.pro/documentation#page-blocked" class="simple-link" target="_blank">not be loaded properly</a>.
189
- Check ad blocking software that may block CSS, Javascript or image files.
190
- </div>
191
- <div style="clear: both;"></div>
192
- </div>
193
-
194
- <div id="rotation-tabs" style="display: none;">
195
- <ul>
196
- <li class="ai-rotate-option"><a></a></li>
197
- </ul>
198
-
199
- <div class="responsive-table rounded">
200
- <table class="ai-settings-table" style="">
201
- <tr>
202
- <td style="padding-right: 7px;">
203
- Option Name
204
- </td>
205
- <td style="width: 100%;">
206
- <input class="option-name" style="width: 100%;" type="text" size="50" maxlength="200" />
207
- </td>
208
- <td style="width: 130px;">
209
- </td>
210
- </tr>
211
- </table>
212
- <div style="clear: both;"></div>
213
- </div>
214
-
215
- </div>
216
-
217
- <div id="ai-error-container" class="rounded" style="border-color: red; display: none;"></div>
218
-
219
- <div id="ai-container">
220
-
221
- <?php endif; // of code only for normal settings ?>
222
-
223
- <div id="ai-tab-container" class="ai-form rounded" style="padding-bottom: 1px;">
224
-
225
- <div id="dummy-tabs" style="height: 30px; padding: .2em .2em 0;"></div>
226
-
227
- <div id="ai-scroll-tabs" class="scroll_tabs_theme_light" style="display: none;">
228
- <?php
229
-
230
- for ($block = $start; $block <= $end; $block ++){
231
- echo " <span id='ai-scroll-tab-$block' rel='$block'>$block</span>";
232
- }
233
- ?>
234
- <span rel='0'>0</span>
235
- </div>
236
-
237
- <ul id="ai-tabs" style="display: none;">
238
- <?php
239
-
240
- $sidebars_with_widget = get_sidebar_widgets ();
241
-
242
- // $sidebar_widgets = wp_get_sidebars_widgets();
243
- // $widget_options = get_option ('widget_ai_widget');
244
-
245
- // $sidebars_with_widgets = array ();
246
- //// for ($block = $start; $block <= $end; $block ++){
247
- // for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++){
248
- // $sidebars_with_widget [$block]= array ();
249
- // }
250
- // foreach ($sidebar_widgets as $sidebar_index => $sidebar_widget) {
251
- // if (is_array ($sidebar_widget) && isset ($GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'])) {
252
- // $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'];
253
- // if ($sidebar_name != "") {
254
- // foreach ($sidebar_widget as $widget) {
255
- // if (preg_match ("/ai_widget-([\d]+)/", $widget, $widget_id)) {
256
- // if (isset ($widget_id [1]) && is_numeric ($widget_id [1])) {
257
- // $widget_option = $widget_options [$widget_id [1]];
258
- // $widget_block = $widget_option ['block'];
259
- //// if ($widget_block >= $start && $widget_block <= $end && !in_array ($sidebar_name, $sidebars_with_widget [$widget_block])) {
260
- // if ($widget_block >= 1 && $widget_block <= AD_INSERTER_BLOCKS && !in_array ($sidebar_name, $sidebars_with_widget [$widget_block])) {
261
- // $sidebars_with_widget [$widget_block] []= $sidebar_name;
262
- // }
263
- // }
264
- // }
265
- // }
266
- // }
267
- // }
268
- // }
269
-
270
- $manual_widget = array ();
271
- $manual_shortcode = array ();
272
- $manual_php_function = array ();
273
- $manual = array ();
274
- $sidebars = array ();
275
-
276
- for ($block = $start; $block <= $end; $block ++) {
277
- $obj = $block_object [$block];
278
-
279
- $automatic = $obj->get_automatic_insertion() != AI_AUTOMATIC_INSERTION_DISABLED;
280
-
281
- $manual_widget [$block] = $obj->get_enable_widget() == AI_ENABLED;
282
- $manual_shortcode [$block] = $obj->get_enable_manual() == AI_ENABLED;
283
- $manual_php_function [$block] = $obj->get_enable_php_call() == AI_ENABLED;
284
- $manual [$block] = ($manual_widget [$block] && !empty ($sidebars_with_widget [$block])) || $manual_shortcode [$block] || $manual_php_function [$block];
285
-
286
- $style = "";
287
- $ad_name = "";
288
- $sidebars [$block] = "";
289
- if ($automatic && $manual [$block]) $style = "font-weight: bold; color: #c4f;";
290
- elseif ($automatic) $style = "font-weight: bold; color: #e44;";
291
- elseif ($manual [$block]) $style = "font-weight: bold; color: #66f;";
292
-
293
- if (!empty ($sidebars_with_widget [$block])) $sidebars [$block] = implode (", ", $sidebars_with_widget [$block]);
294
-
295
- // if (!wp_is_mobile ()) {
296
- // $ad_name = $obj->get_ad_name();
297
-
298
- // $ad_name_functions = false;
299
- // if ($automatic) {
300
- // $ad_name .= ": ".$obj->get_automatic_insertion_text ();
301
- // $ad_name_functions = true;
302
- // }
303
-
304
- // //if (!empty ($sidebars_with_widget [$block])) $sidebars [$block] = implode (", ", $sidebars_with_widget [$block]);
305
- // if ($manual_widget [$block]) {
306
- // if ($sidebars [$block] != "") {
307
- // $ad_name .= $ad_name_functions ? ", " : ": ";
308
- // $ad_name .= "Widget used in: [".$sidebars [$block]."]";
309
- // $ad_name_functions = true;
310
- // }
311
- // } else {
312
- // if (!empty ($sidebars_with_widget [$block])) {
313
- // $ad_name .= $ad_name_functions ? ", " : ": ";
314
- // $ad_name .= "Widget DISABLED but used in: [".$sidebars [$block]."]";
315
- // $ad_name_functions = true;
316
- // }
317
- // }
318
-
319
- // if ($manual_shortcode [$block]) {
320
- // $ad_name .= $ad_name_functions ? ", " : ": ";
321
- // $ad_name .= "Shortcode";
322
- // $ad_name_functions = true;
323
- // }
324
- // if ($manual_php_function [$block]) {
325
- // $ad_name .= $ad_name_functions ? ", " : ": ";
326
- // $ad_name .= "PHP function";
327
- // $ad_name_functions = true;
328
- // }
329
- // }
330
-
331
- echo "
332
- <li id=\"ai-tab$block\" class=\"ai-tab\" title=\"$ad_name\"><a href=\"#tab-$block\"><span style=\"", $style, "\">$block</span></a></li>";
333
-
334
- }
335
-
336
- $enabled_k = count ($ai_custom_hooks) != 0;
337
- $enabled_h = $adH->get_enable_manual () && $adH->get_ad_data() != "";
338
- $enabled_f = $adF->get_enable_manual () && $adF->get_ad_data() != "";
339
- if ($enabled_h || $enabled_f) $class_hfa = " on"; else $class_hfa = "";
340
-
341
- $title_hfa = "";
342
- if ($enabled_h) $title_hfa .= ", Header code";
343
- if ($enabled_f) $title_hfa .= ", Footer code";
344
- $header_code_disabled = !$adH->get_enable_manual () && $adH->get_ad_data() != "";
345
- $footer_code_disabled = !$adF->get_enable_manual () && $adF->get_ad_data() != "";
346
-
347
- if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) {
348
- $enabled_a = $ai_wp_data [AI_ADB_DETECTION];
349
- if ($enabled_a) $title_hfa .= ", Ad blocking detection code";
350
- if ($enabled_a) $class_hfa = " on";
351
- }
352
-
353
- ?>
354
- <li id="ai-tab0" class="ai-tab" title="<?php echo AD_INSERTER_NAME ?> General Settings<?php echo $title_hfa ?>" style=" margin: 1px 0 0 0;"><a href="#tab-0" style="padding: 5px 14px 6px 12px;"><div class="ai-icon-gear<?php echo $class_hfa ?>"></div></a></li>
355
- </ul>
356
-
357
- <?php
358
-
359
- for ($block = $start; $block <= $end + 1; $block ++){
360
-
361
- if ($block <= $end) {
362
- $default->number = $block;
363
- $default->wp_options [AI_OPTION_BLOCK_NAME] = AD_NAME." ".$block;
364
-
365
- $tab_visible = $block == $active_tab || $generate_all;
366
-
367
- $obj = $block_object [$block];
368
- } else {
369
- $block = 999;
370
-
371
- $sidebars [$block] = "";
372
-
373
- $manual_widget [$block] = $obj->get_enable_widget() == AI_ENABLED;
374
- $manual_shortcode [$block] = $obj->get_enable_manual() == AI_ENABLED;
375
- $manual_php_function [$block] = $obj->get_enable_php_call() == AI_ENABLED;
376
- $manual [$block] = ($manual_widget [$block] && !empty ($sidebars_with_widget [$block])) || $manual_shortcode [$block] || $manual_php_function [$block];
377
-
378
- $default->number = 0;
379
- $default->wp_options [AI_OPTION_BLOCK_NAME] = AD_NAME." 0";
380
-
381
- $tab_visible = false;
382
-
383
- $obj = $default;
384
- }
385
-
386
- $client_side_devices = $obj->get_detection_client_side () == AI_ENABLED;
387
- $server_side_devices = $obj->get_detection_server_side () == AI_ENABLED;
388
- if ($client_side_devices) $client_side_style = "font-weight: bold; color: #66f;"; else $client_side_style = "";
389
- if ($server_side_devices) $server_side_style = "font-weight: bold; color: #66f;"; else $server_side_style = "";
390
-
391
- $show_devices = $client_side_devices || $server_side_devices == AI_ENABLED;
392
- if ($show_devices) $devices_style = "font-weight: bold; color: #66f;"; else $devices_style = "";
393
-
394
- $cat_list = $obj->get_ad_block_cat();
395
- $tag_list = $obj->get_ad_block_tag();
396
- $taxonomy_list = $obj->get_ad_block_taxonomy();
397
- $id_list = $obj->get_id_list();
398
- $url_list = $obj->get_ad_url_list();
399
- $url_parameter_list = $obj->get_url_parameter_list();
400
- $domain_list = $obj->get_ad_domain_list();
401
- if (function_exists ('ai_lists')) $lists = ai_lists ($obj); else $lists = false;
402
- $show_lists = $cat_list != '' || $tag_list != '' || $taxonomy_list != '' || $id_list != '' || $url_list != '' || $url_parameter_list != '' || $domain_list != '' || $lists;
403
- if ($show_lists) $lists_style = "font-weight: bold; color: #66f;"; else $lists_style = "";
404
-
405
- $show_manual = $manual [$block];
406
- if ($show_manual) $manual_style = "font-weight: bold; color: " . ($manual_widget [$block] || empty ($sidebars_with_widget [$block]) ? "#66f;" : "#e44;"); else $manual_style = "";
407
-
408
- $insertion_options =
409
- $obj->get_maximum_insertions () ||
410
- $obj->get_display_for_users() != AD_DISPLAY_ALL_USERS ||
411
- $obj->get_enable_amp () == AI_ENABLED ||
412
- $obj->get_enable_ajax () != AI_ENABLED ||
413
- $obj->get_enable_404 () == AI_ENABLED ||
414
- $obj->get_enable_feed () == AI_ENABLED ||
415
- $obj->get_disable_caching ();
416
-
417
- $word_count_options =
418
- intval ($obj->get_minimum_words()) != 0 ||
419
- intval ($obj->get_maximum_words()) != 0;
420
-
421
- $scheduling_active = $obj->get_scheduling() != AI_SCHEDULING_OFF;
422
-
423
- $filter_active = $obj->get_call_filter() || $obj->get_inverted_filter() != 0;
424
-
425
- $adb_block_action_active = $obj->get_adb_block_action () != AI_ADB_BLOCK_ACTION_DO_NOTHING;
426
-
427
- $display_options = $obj->get_show_label () || $obj->get_close_button ();
428
-
429
- $show_misc =
430
- $insertion_options ||
431
- $word_count_options ||
432
- $scheduling_active ||
433
- $filter_active ||
434
- $adb_block_action_active ||
435
- $display_options;
436
-
437
- if ($show_misc) $misc_style = "font-weight: bold; color: #66f;"; else $misc_style = "";
438
-
439
- if ($insertion_options) $insertion_style = "font-weight: bold; color: #66f;"; else $insertion_style = "";
440
- if ($word_count_options) $word_count_style = "font-weight: bold; color: #66f;"; else $word_count_style = "";
441
- if ($scheduling_active) $scheduling_style = "font-weight: bold; color: #66f;"; else $scheduling_style = "";
442
- if ($filter_active) $filter_style = "font-weight: bold; color: #66f;"; else $filter_style = "";
443
- if ($adb_block_action_active) $adb_style = "font-weight: bold; color: #66f;"; else $adb_style = "";
444
- if ($display_options) $display_style = "font-weight: bold; color: #66f;"; else $display_style = "";
445
-
446
- $automatic_insertion = $obj->get_automatic_insertion();
447
-
448
- $paragraph_settings =
449
- $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH ||
450
- $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH;
451
-
452
- $paragraph_counting =
453
- $obj->get_direction_type() != $default->get_direction_type() ||
454
- $obj->get_paragraph_tags() != $default->get_paragraph_tags() ||
455
- $obj->get_minimum_paragraph_words() != $default->get_minimum_paragraph_words() ||
456
- $obj->get_maximum_paragraph_words() != $default->get_maximum_paragraph_words() ||
457
- $obj->get_paragraph_text_type() != $default->get_paragraph_text_type() ||
458
- $obj->get_paragraph_text() != $default->get_paragraph_text() ||
459
- $obj->get_paragraph_number_minimum() != $default->get_paragraph_number_minimum() ||
460
- $obj->get_minimum_words_above() != $default->get_minimum_words_above() ||
461
- $obj->get_count_inside_blockquote() != $default->get_count_inside_blockquote();
462
-
463
- $paragraph_clearance =
464
- ($obj->get_avoid_text_above() != $default->get_avoid_text_above() && intval ($obj->get_avoid_paragraphs_above()) != 0) ||
465
- ($obj->get_avoid_text_below() != $default->get_avoid_text_below() && intval ($obj->get_avoid_paragraphs_below()) != 0);
466
-
467
- $html_settings =
468
- $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT ||
469
- $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT;
470
-
471
- $html_element_insertion = $obj->get_html_element_insertion ();
472
- $server_side_insertion = $obj->get_server_side_insertion ();
473
-
474
- $filter_type = $obj->get_filter_type();
475
-
476
- ?>
477
- <div id="tab-<?php echo $block; ?>" style="padding: 0;<?php echo $tab_visible ? "" : " display: none;" ?>">
478
- <div class="ai-toolbars">
479
-
480
- <div id="ai-main-toolbar-<?php echo $block; ?>" class="max-input" style="margin: 8px 0 0 2px; height: 28px; width: 731px;">
481
- <span id="name-label-container-<?php echo $block; ?>" style="display: table-cell; width: 100%; padding: 0; font-weight: bold; cursor: pointer;">
482
- <input id="name-edit-<?php echo $block; ?>" style="width: 100%; vertical-align: middle; font-size: 14px; display: none;" type="text" name="<?php echo AI_OPTION_BLOCK_NAME, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_name(); ?>" value="<?php echo $obj->get_ad_name() ?>" size="56" maxlength="120" />
483
- <span id="name-label-<?php echo $block; ?>" class="no-select" style="width: 100%; max-width: 490px; vertical-align: middle; font-size: 14px; display: inline-block; margin-top: 4px; margin-left: 7px; white-space: nowrap; overflow: hidden;"><?php echo $obj->get_ad_name() ?></span>
484
- </span>
485
- <?php if (AI_SYNTAX_HIGHLIGHTING) : ?>
486
- <span class="ai-toolbar-button ai-settings">
487
- <input type="checkbox" value="0" id="simple-editor-<?php echo $block; ?>" class="simple-editor-button" style="display: none;" />
488
- <label class="checkbox-button" for="simple-editor-<?php echo $block; ?>" title="Toggle Syntax Highlighting / Simple editor for mobile devices"><span class="checkbox-icon icon-tablet"></span></label>
489
- </span>
490
- <?php endif; ?>
491
-
492
- <?php if (defined ('AI_CODE_GENERATOR')) : ?>
493
- <span class="ai-toolbar-button ai-settings">
494
- <input type="checkbox" id="tools-button-<?php echo $block; ?>" style="display: none;" />
495
- <label class="checkbox-button tools-button" for="tools-button-<?php echo $block; ?>" title="Toggle tools"><span class="checkbox-icon icon-tools"></span></label>
496
- </span>
497
- <?php endif; ?>
498
-
499
- <?php if (!is_multisite() || is_main_site () || multisite_php_processing ()) : ?>
500
- <span class="ai-toolbar-button ai-settings">
501
- <input type="hidden" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
502
- <input type="checkbox" name="<?php echo AI_OPTION_PROCESS_PHP, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_process_php (); ?>" id="process-php-<?php echo $block; ?>" <?php if ($obj->get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
503
- <label class="checkbox-button" for="process-php-<?php echo $block; ?>" title="Process PHP code in block"><span class="checkbox-icon icon-php<?php if ($obj->get_process_php () == AI_ENABLED) echo ' on'; ?>"></span></label>
504
- </span>
505
- <?php endif; ?>
506
- <?php if (function_exists ('ai_settings_top_buttons_2')) ai_settings_top_buttons_2 ($block, $obj, $default); ?>
507
- </div>
508
-
509
- <div class="ai-settings">
510
- <div id="ai-tools-toolbar-<?php echo $block; ?>" class="ai-tools-toolbar max-input" style="margin: 8px 0 0 2px; height: 28px; width: 729px; padding: 0 0 0 2px; display: none;">
511
- <?php if (function_exists ('ai_settings_top_buttons_1')) ai_settings_top_buttons_1 ($block, $obj, $default); ?>
512
- <?php if (defined ('AI_CODE_GENERATOR')) : ?>
513
- <span class="ai-toolbar-button ai-button-left">
514
- <input type="checkbox" id="code-generator-<?php echo $block; ?>" style="display: none;" />
515
- <label class="checkbox-button code-generator-button" for="code-generator-<?php echo $block; ?>" title="Toggle code generator"><span class="checkbox-icon icon-code"></span></label>
516
- </span>
517
- <span class="ai-toolbar-button ai-button-left">
518
- <input type="checkbox" id="rotation-<?php echo $block; ?>" style="display: none;" />
519
- <label class="checkbox-button rotation-button" for="rotation-<?php echo $block; ?>" title="Toggle rotation editor"><span class="checkbox-icon icon-rotation"></span></label>
520
- </span>
521
- <span class="ai-toolbar-button ai-button-left">
522
- <input type="checkbox" id="visual-editor-<?php echo $block; ?>" style="display: none;" />
523
- <label class="checkbox-button" for="visual-editor-<?php echo $block; ?>" title="Open visual HTML editor"><span class="checkbox-icon icon-edit"></span></label>
524
- </span>
525
-
526
-
527
- <?php if (defined ('AI_ADSENSE_API')) : ?>
528
- <?php if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) : ?>
529
- <span style="display: table-cell; width: 6%;"></span>
530
-
531
- <span class="ai-toolbar-button ai-button-left">
532
- <input type="checkbox" id="ga-<?php echo $block; ?>" style="display: none;" />
533
- <label class="checkbox-button adsense-list" for="ga-<?php echo $block; ?>" title="Show AdSense ad units" ><span class="checkbox-icon icon-adsense ai-bw"></span></label>
534
- </span>
535
- <?php endif; ?>
536
- <?php endif; ?>
537
-
538
- <span style="display: table-cell; width: 100%;"></span>
539
-
540
- <span class="ai-toolbar-button" style="padding-right: 15px;">
541
- <input type="checkbox" id="clear-block-<?php echo $block; ?>" style="display: none;" />
542
- <label class="checkbox-button" for="clear-block-<?php echo $block; ?>" title="Clear block"><span class="checkbox-icon icon-clear"></span></label>
543
- </span>
544
-
545
- <span class="ai-toolbar-button">
546
- <input type="checkbox" id="copy-block-<?php echo $block; ?>" class="ai-copy" style="display: none;" />
547
- <label class="checkbox-button" for="copy-block-<?php echo $block; ?>" title="Copy block"><span class="checkbox-icon icon-copy"></span></label>
548
- </span>
549
- <span class="ai-toolbar-button">
550
- <input type="checkbox" id="paste-name-<?php echo $block; ?>" style="display: none;" />
551
- <label class="checkbox-button" for="paste-name-<?php echo $block; ?>" title="Paste name"><span class="checkbox-icon icon-paste-name"></span></label>
552
- </span>
553
- <span class="ai-toolbar-button">
554
- <input type="checkbox" id="paste-code-<?php echo $block; ?>" style="display: none;" />
555
- <label class="checkbox-button" for="paste-code-<?php echo $block; ?>" title="Paste code"><span class="checkbox-icon icon-paste-code"></span></label>
556
- </span>
557
- <span class="ai-toolbar-button">
558
- <input type="checkbox" id="paste-settings-<?php echo $block; ?>" style="display: none;" />
559
- <label class="checkbox-button" for="paste-settings-<?php echo $block; ?>" title="Paste settings"><span class="checkbox-icon icon-paste-settings"></span></label>
560
- </span>
561
- <span class="ai-toolbar-button">
562
- <input type="checkbox" id="paste-block-<?php echo $block; ?>" style="display: none;" />
563
- <label class="checkbox-button" for="paste-block-<?php echo $block; ?>" title="Paste block (name, code and settings)"><span class="checkbox-icon icon-paste"></span></label>
564
- </span>
565
- <?php endif; ?>
566
- </div>
567
- </div>
568
-
569
- </div>
570
-
571
- <?php if (function_exists ('ai_settings_container')) ai_settings_container ($block, $obj); ?>
572
-
573
- <div id="settings-<?php echo $block; ?>">
574
-
575
- <?php if (defined ('AI_CODE_GENERATOR')) : ?>
576
- <div id="ai-rotation-container-<?php echo $block; ?>" class='ai-rotate' style="padding: 0; margin: 8px 0; border: 0; display: none;">
577
-
578
- <div class="max-input" style="height: 28px; position: absolute; top: 4px; left: -6px;">
579
- <span style="display: table-cell; width: 100%;"></span>
580
- <span class="ai-toolbar-button">
581
- <input type="checkbox" id="remove-option-<?php echo $block; ?>" style="display: none;" />
582
- <label class="checkbox-button" for="remove-option-<?php echo $block; ?>" title="Remove option"><span class="checkbox-icon icon-minus"></span></label>
583
- </span>
584
- <span class="ai-toolbar-button">
585
- <input type="checkbox" id="add-option-<?php echo $block; ?>" style="display: none;" />
586
- <label class="checkbox-button" for="add-option-<?php echo $block; ?>" title="Add option"><span class="checkbox-icon icon-plus"></span></label>
587
- </span>
588
- </div>
589
-
590
- <ul>
591
- </ul>
592
-
593
- </div>
594
-
595
- <div id="ai-code-generator-container-<?php echo $block; ?>" style="padding: 0; margin: 8px 0; border: 0; display: none;">
596
-
597
- <div class="max-input" style="height: 28px; position: absolute; top: 4px; left: -6px;">
598
- <span style="display: table-cell; width: 100%;"></span>
599
- <span class="ai-toolbar-button">
600
- <input type="checkbox" id="import-code-<?php echo $block; ?>" style="display: none;" />
601
- <label class="checkbox-button" for="import-code-<?php echo $block; ?>" title="Import code"><span class="checkbox-icon icon-import"></span></label>
602
- </span>
603
- <span class="ai-toolbar-button">
604
- <input type="checkbox" id="generate-code-<?php echo $block; ?>" style="display: none;" />
605
- <label class="checkbox-button" for="generate-code-<?php echo $block; ?>" title="Generate code"><span class="checkbox-icon icon-generate"></span></label>
606
- </span>
607
- </div>
608
-
609
- <ul>
610
- <li id="ai-banner-<?php echo $block; ?>"><a href="#tab-banner-<?php echo $block; ?>">Banner</a></li>
611
- <li id="ai-adsense-pub-id-<?php echo $block; ?>"><a href="#tab-adsense-<?php echo $block; ?>">AdSense</a></li>
612
- </ul>
613
-
614
- <div id="tab-banner-<?php echo $block; ?>" class="ai-banner ai-banner-top responsive-table rounded">
615
- <div class="banner-preview">
616
- <!-- <a id="banner-link-<?php echo $block; ?>" class="clear-link" target="_blank"><img id="banner-image-<?php echo $block; ?>" src="//:0" style="display: none;" /></a>-->
617
- <a id="banner-link-<?php echo $block; ?>" class="clear-link" target="_blank"><img id="banner-image-<?php echo $block; ?>" src="" style="display: none;" /></a>
618
- </div>
619
- <table class="ai-settings-table">
620
- <tr>
621
- <td style="padding-right: 7px;">
622
- Image
623
- </td>
624
- <td style="width: 98%;">
625
- <input id="banner-image-url-<?php echo $block; ?>" style="width: 100%;" type="text" size="50" maxlength="200" />
626
- </td>
627
- </tr>
628
- <tr>
629
- <td>
630
- Link
631
- </td>
632
- <td>
633
- <input id="banner-url-<?php echo $block; ?>" style="width: 100%;" type="text" size="50" maxlength="200" />
634
- </td>
635
- </tr>
636
- <tr>
637
- <td>
638
- <input type="checkbox" id="open-new-tab-<?php echo $block; ?>" />
639
- </td>
640
- <td>
641
- <label for="open-new-tab-<?php echo $block; ?>" style="display: inline-block; margin-top: 6px;">Open link in a new tab</label>
642
- <button id="select-image-button-<?php echo $block; ?>" type="button" class='ai-button select-image' style="display: none; width: 120px; float: right; margin: 7px 0 0 0;">Select Image</button>
643
- <button id="select-placeholder-button-<?php echo $block; ?>" type="button" class='ai-button select-image' style="display: none; width: 120px; float: right; margin: 7px 10px 0 0;">Select Placeholder</button>
644
- </td>
645
- </tr>
646
- </table>
647
- <div style="clear: both;"></div>
648
- </div>
649
-
650
- <div id="tab-adsense-<?php echo $block; ?>" class="responsive-table rounded">
651
-
652
- <table class="ai-settings-table left">
653
- <tr>
654
- <td>
655
- Comment
656
- </td>
657
- <td style="width: 100%; padding-left: 7px;">
658
- <input id="adsense-comment-<?php echo $block; ?>" style="width: 100%;" type="text" size="30" maxlength="50" />
659
- </td>
660
- </tr>
661
-
662
- <tr>
663
- <td>
664
- Publisher ID
665
- </td>
666
- <td style="width: 100%; padding-left: 7px;">
667
- <input id="adsense-publisher-id-<?php echo $block; ?>" style="width: 100%;" type="text" size="30" maxlength="30" />
668
- </td>
669
- </tr>
670
-
671
- <tr>
672
- <td>
673
- Ad Slot ID
674
- </td>
675
- <td style="padding-left: 7px;">
676
- <input id="adsense-ad-slot-id-<?php echo $block; ?>" style="width: 100%;" type="text" size="30" maxlength="30" />
677
- </td>
678
- </tr>
679
-
680
- <tr>
681
- <td>
682
- Ad Type
683
- </td>
684
- <td style="padding-left: 7px;">
685
- <select id="adsense-type-<?php echo $block; ?>">
686
- <option value="<?php echo AI_ADSENSE_STANDARD; ?>" selected><?php echo AI_TEXT_STANDARD; ?></option>
687
- <option value="<?php echo AI_ADSENSE_LINK; ?>"><?php echo AI_TEXT_LINK; ?></option>
688
- <option value="<?php echo AI_ADSENSE_IN_ARTICLE; ?>"><?php echo AI_TEXT_IN_ARTICLE; ?></option>
689
- <option value="<?php echo AI_ADSENSE_IN_FEED; ?>"><?php echo AI_TEXT_IN_FEED; ?></option>
690
- <option value="<?php echo AI_ADSENSE_MATCHED_CONTENT; ?>"><?php echo AI_TEXT_MATCHED_CONTENT; ?></option>
691
- <option value="<?php echo AI_ADSENSE_AUTO; ?>"><?php echo AI_TEXT_AUTO; ?></option>
692
- </select>
693
- <div class="adsense-size" style="float: right;">
694
- Size
695
- <select id="adsense-size-<?php echo $block; ?>">
696
- <option value="<?php echo AI_ADSENSE_SIZE_FIXED; ?>" selected><?php echo AI_TEXT_FIXED; ?></option>
697
- <option value="<?php echo AI_ADSENSE_SIZE_FIXED_BY_VIEWPORT; ?>"><?php echo AI_TEXT_FIXED_BY_VIEWPORT; ?></option>
698
- <option value="<?php echo AI_ADSENSE_SIZE_RESPONSIVE; ?>"><?php echo AI_TEXT_RESPONSIVE; ?></option>
699
- </select>
700
- </div>
701
- </td>
702
- </tr>
703
-
704
- <tr>
705
- <td>
706
- AMP Ad
707
- </td>
708
- <td style="padding-left: 7px;">
709
- <select id="adsense-amp-<?php echo $block; ?>">
710
- <option value="<?php echo AI_ADSENSE_AMP_DISABLED; ?>" selected><?php echo AI_TEXT_DISABLED; ?></option>
711
- <option value="<?php echo AI_ADSENSE_AMP_ABOVE_THE_FOLD; ?>"><?php echo AI_TEXT_ABOVE_THE_FOLD; ?></option>
712
- <option value="<?php echo AI_ADSENSE_AMP_BELOW_THE_FOLD; ?>"><?php echo AI_TEXT_BELOW_THE_FOLD; ?></option>
713
- </select>
714
- </td>
715
- </tr>
716
-
717
- <tr>
718
- <td>
719
- </td>
720
- <td>
721
- <?php if (defined ('AI_ADSENSE_API')) : ?>
722
- <?php if (!defined ('AI_ADSENSE_AUTHORIZATION_CODE')) : ?>
723
- <button type="button" class='ai-button adsense-list' style="display: none; margin: 2px 0px 0px 7px;" title="Show AdSense ad units from your account">AdSense ad units</button>
724
- <?php endif; ?>
725
- <?php endif; ?>
726
- </td>
727
- </tr>
728
- </table>
729
-
730
- <table id="adsense-layout-<?php echo $block; ?>" class="ai-settings-table right">
731
- <tr>
732
- <td></td>
733
- <td>
734
- <input style="visibility: hidden;" type="text" size="1" maxlength="1" />
735
- </td>
736
- </tr>
737
-
738
- <tr>
739
- <td class="adsense-layout" style="padding-left: 7px;">
740
- Layout
741
- </td>
742
- <td class="adsense-layout" style="width: 100%; padding-left: 7px;">
743
- <input id="adsense-layout-<?php echo $block; ?>" style="width: 100%;" type="text" size="80" maxlength="100" />
744
- </td>
745
- </tr>
746
-
747
- <tr>
748
- <td class="adsense-layout" style="padding-left: 7px;">
749
- Layout Key
750
- </td>
751
- <td class="adsense-layout" style="padding-left: 7px;">
752
- <input id="adsense-layout-key-<?php echo $block; ?>" style="width: 100%;" type="text" size="80" maxlength="100" />
753
- </td>
754
- </tr>
755
-
756
- <tr>
757
- <td style="padding-left: 7px; padding-top: 1px; float: left;">
758
- <span class="adsense-fixed-size ad-size">
759
- <select class="adsense-ad-size fixed">
760
- <option value="&nbsp;" selected></option>
761
- <option value="300x250">300x250</option>
762
- <option value="336x280">336x280</option>
763
- <option value="728x90" >728x90</option>
764
- <option value="300x600">300x600</option>
765
- <option value="320x100">320x100</option>
766
- <option value="468x60" >468x60</option>
767
- <option value="234x60" >234x60</option>
768
- <option value="125x125">125x125</option>
769
- <option value="250x250">250x250</option>
770
- <option value="200x200">200x200</option>
771
- <option value="120x600">120x600</option>
772
- <option value="160x600">160x600</option>
773
- <option value="300x1050">300x1050</option>
774
- <option value="320x50">320x50</option>
775
- <option value="970x90">970x90</option>
776
- <option value="970x250">970x250</option>
777
- </select>
778
- </span>
779
- </td>
780
- <td>
781
- </td>
782
- </tr>
783
-
784
- </table>
785
-
786
- <table id="adsense-viewports-<?php echo $block; ?>" class="ai-settings-table right" style="display: none; width: auto;">
787
- <?php
788
- for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
789
- $viewport_name = get_viewport_name ($viewport);
790
- $viewport_width = get_viewport_width ($viewport);
791
- if ($viewport_name != '') { ?>
792
- <tr class="adsense-viewport ad-size">
793
- <td style="max-width: 210px; padding-left: 10px; overflow: hidden;">
794
- <?php echo $viewport_name; ?>
795
- </td>
796
- <td style="padding-left: 7px;">
797
- <select class="adsense-ad-size">
798
- <option value="&nbsp;" selected></option>
799
- <option value="300x250">300x250</option>
800
- <option value="336x280">336x280</option>
801
- <option value="728x90" >728x90</option>
802
- <option value="300x600">300x600</option>
803
- <option value="320x100">320x100</option>
804
- <option value="468x60" >468x60</option>
805
- <option value="234x60" >234x60</option>
806
- <option value="125x125">125x125</option>
807
- <option value="250x250">250x250</option>
808
- <option value="200x200">200x200</option>
809
- <option value="120x600">120x600</option>
810
- <option value="160x600">160x600</option>
811
- <option value="300x1050">300x1050</option>
812
- <option value="320x50">320x50</option>
813
- <option value="970x90">970x90</option>
814
- <option value="970x250">970x250</option>
815
- </select>
816
- </span>
817
- </td>
818
- </tr>
819
- <?php }
820
- }
821
- ?>
822
- </table>
823
-
824
- <div style="clear: both;"></div>
825
-
826
- </div>
827
-
828
- <!-- <div style="padding: 0; min-height: 28px;">-->
829
- <!-- <div style="float: left;">-->
830
- <!-- <button id="import-button2-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; margin-right: 4px;" title="">Import</button>-->
831
- <!-- </div>-->
832
- <!-- <div style="float: right;">-->
833
- <!-- <button id="generate-button2-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; margin-right: 4px;" title="">Generate</button>-->
834
- <!-- </div>-->
835
- <!-- <div style="clear: both;"></div>-->
836
- <!-- </div>-->
837
-
838
- </div>
839
- <?php endif; ?>
840
-
841
- <div style="margin: 8px 0;">
842
- <textarea id="block-<?php echo $block; ?>" class="simple-editor" style="background-color:#F9F9F9; font-family: Courier, 'Courier New', monospace; font-weight: bold;" name="<?php echo AI_OPTION_CODE, WP_FORM_FIELD_POSTFIX, $block; ?>" default=""><?php echo esc_textarea ($obj->get_ad_data()); ?></textarea>
843
- </div>
844
-
845
- <div style="padding: 0; min-height: 28px;">
846
- <div style="float: left;">
847
- <button id="lists-button-<?php echo $block; ?>" type="button" class='ai-button2' style="display: none; margin-right: 4px;" title="White/Black-list Category, Tag, Url, Referer (domain) or Country"><span style="<?php echo $lists_style; ?>">Lists</span></button>
848
- <button id="manual-button-<?php echo $block; ?>" type="button" class='ai-button2' style="display: none; margin-right: 4px;" title="Widget, Shortcode and PHP function call"><span style="<?php echo $manual_style; ?>">Manual</span></button>
849
- <button id="device-detection-button-<?php echo $block; ?>" class='ai-button2' type="button" style="display: none; margin-right: 4px;" title="Client/Server-side Device Detection (Desktop, Tablet, Phone,...)"><span style="<?php echo $devices_style; ?>">Devices</span></button>
850
- <button id="misc-button-<?php echo $block; ?>" type="button" class='ai-button2' style="display: none; margin-right: 4px;" title="Check for user status, Limit insertions, [error 404 page, Ajax requests, RSS feeds], Filter, Scheduling, General tag"><span style="<?php echo $misc_style; ?>">Misc</span></button>
851
- <button id="preview-button-<?php echo $block; ?>" type="button" class='ai-button2' style="display: none; margin-right: 4px;" title="Preview saved code above" site-url="<?php echo wp_make_link_relative (get_site_url()); ?>">Preview</button>
852
- </div>
853
- <div style="float: right;">
854
- <?php if (function_exists ('ai_settings_bottom_buttons')) ai_settings_bottom_buttons ($start, $end); else { ?>
855
- <input style="display: none; font-weight: bold;" name="<?php echo AI_FORM_SAVE; ?>" value="Save All Settings" type="submit" />
856
- <?php } ?>
857
- </div>
858
- <div style="clear: both;"></div>
859
- </div>
860
-
861
- <div class="rounded">
862
- <div style="float: left;">
863
- Automatic Insertion
864
- <select class="ai-image-selection" style="width:200px; margin-bottom: 3px;" id="display-type-<?php echo $block; ?>" name="<?php echo AI_OPTION_AUTOMATIC_INSERTION, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_automatic_insertion(); ?>">
865
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-disabled" value="<?php echo AI_AUTOMATIC_INSERTION_DISABLED; ?>" data-title="<?php echo AI_TEXT_DISABLED; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DISABLED; ?></option>
866
- <?php if (defined ('AI_BUFFERING') && get_output_buffering ()) : ?>
867
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-above-header" value="<?php echo AI_AUTOMATIC_INSERTION_ABOVE_HEADER; ?>" data-title="<?php echo AI_TEXT_ABOVE_HEADER; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_ABOVE_HEADER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_ABOVE_HEADER; ?></option>
868
- <?php endif; ?>
869
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-before-post" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_POST; ?>" data-title="<?php echo AI_TEXT_BEFORE_POST; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_POST; ?></option>
870
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-before-content" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_CONTENT; ?>" data-title="<?php echo AI_TEXT_BEFORE_CONTENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_CONTENT; ?></option>
871
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-before-paragraph" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH; ?>" data-title="<?php echo AI_TEXT_BEFORE_PARAGRAPH; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_PARAGRAPH; ?></option>
872
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-after-paragraph" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH; ?>" data-title="<?php echo AI_TEXT_AFTER_PARAGRAPH; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_PARAGRAPH; ?></option>
873
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-after-content" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_CONTENT; ?>" data-title="<?php echo AI_TEXT_AFTER_CONTENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_CONTENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_CONTENT; ?></option>
874
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-after-post" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_POST; ?>" data-title="<?php echo AI_TEXT_AFTER_POST; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_POST; ?></option>
875
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-before-excerpts" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT; ?>" data-title="<?php echo AI_TEXT_BEFORE_EXCERPT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_EXCERPT; ?></option>
876
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-after-excerpts" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_EXCERPT; ?>" data-title="<?php echo AI_TEXT_AFTER_EXCERPT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_EXCERPT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_EXCERPT; ?></option>
877
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-between-posts" value="<?php echo AI_AUTOMATIC_INSERTION_BETWEEN_POSTS; ?>" data-title="<?php echo AI_TEXT_BETWEEN_POSTS; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BETWEEN_POSTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BETWEEN_POSTS; ?></option>
878
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-before-comments" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS; ?>" data-title="<?php echo AI_TEXT_BEFORE_COMMENTS; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_COMMENTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_COMMENTS; ?></option>
879
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-between-comments" value="<?php echo AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS; ?>" data-title="<?php echo AI_TEXT_BETWEEN_COMMENTS; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BETWEEN_COMMENTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BETWEEN_COMMENTS; ?></option>
880
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-after-comments" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_COMMENTS; ?>" data-title="<?php echo AI_TEXT_AFTER_COMMENTS; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_COMMENTS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_COMMENTS; ?></option>
881
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-footer" value="<?php echo AI_AUTOMATIC_INSERTION_FOOTER; ?>" data-title="<?php echo AI_TEXT_FOOTER; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_FOOTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FOOTER; ?></option>
882
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-before-html" value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT; ?>" data-title="<?php echo AI_TEXT_BEFORE_HTML_ELEMENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_HTML_ELEMENT; ?></option>
883
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-after-html" value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT; ?>" data-title="<?php echo AI_TEXT_AFTER_HTML_ELEMENT; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_HTML_ELEMENT; ?></option>
884
- <?php foreach ($ai_custom_hooks as $hook_index => $custom_hook) { ?>
885
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-custom-hook" value="<?php echo AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1; ?>" data-title="<?php echo $custom_hook ['name']; ?>" <?php echo ($automatic_insertion == AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo $custom_hook ['name']; ?></option>
886
- <?php } ?>
887
- </select>
888
- </div>
889
-
890
- <div style="float: right;">
891
- Alignment and Style&nbsp;&nbsp;&nbsp;
892
- <select style="width:130px;" id="block-alignment-<?php echo $block; ?>" name="<?php echo AI_OPTION_ALIGNMENT_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_alignment_type(); ?>">
893
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-default" value="<?php echo AI_ALIGNMENT_DEFAULT; ?>" data-title="<?php echo AI_TEXT_DEFAULT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_DEFAULT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_DEFAULT; ?></option>
894
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-align-left" value="<?php echo AI_ALIGNMENT_LEFT; ?>" data-title="<?php echo AI_TEXT_LEFT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_LEFT; ?></option>
895
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-center" value="<?php echo AI_ALIGNMENT_CENTER; ?>" data-title="<?php echo AI_TEXT_CENTER; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_CENTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CENTER; ?></option>
896
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-align-right" value="<?php echo AI_ALIGNMENT_RIGHT; ?>" data-title="<?php echo AI_TEXT_RIGHT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_RIGHT; ?></option>
897
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-float-left" value="<?php echo AI_ALIGNMENT_FLOAT_LEFT; ?>" data-title="<?php echo AI_TEXT_FLOAT_LEFT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_FLOAT_LEFT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_LEFT; ?></option>
898
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-float-right" value="<?php echo AI_ALIGNMENT_FLOAT_RIGHT; ?>" data-title="<?php echo AI_TEXT_FLOAT_RIGHT; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_FLOAT_RIGHT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FLOAT_RIGHT; ?></option>
899
- <?php if (function_exists ('ai_style_options')) ai_style_options ($obj); ?>
900
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-custom-css" value="<?php echo AI_ALIGNMENT_CUSTOM_CSS; ?>" data-title="<?php echo AI_TEXT_CUSTOM_CSS; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_CUSTOM_CSS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CUSTOM_CSS; ?></option>
901
- <option data-img-src="<?php echo plugins_url ('css/images/blank.png', __FILE__); ?>" data-img-class="automatic-insertion im-no-wrapping" value="<?php echo AI_ALIGNMENT_NO_WRAPPING; ?>" data-title="<?php echo AI_TEXT_NO_WRAPPING; ?>" <?php echo ($obj->get_alignment_type() == AI_ALIGNMENT_NO_WRAPPING) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_WRAPPING; ?></option>
902
- </select>
903
- &nbsp;
904
- <button id="show-css-button-<?php echo $block; ?>" type="button" class='ai-button' style="min-width: 60px; margin-right: 0px;">Show</button>
905
- </div>
906
- <div style="clear: both;"></div>
907
-
908
- <div id="icons-css-code-<?php echo $block; ?>" style="margin: 4px 0 2px; display: none;">
909
- <div id="automatic-insertion-<?php echo $block; ?>"></div>
910
- <div id="alignment-style-<?php echo $block; ?>" style="margin-bottom: 4px;"></div>
911
-
912
- <?php if (function_exists ('ai_sticky_options')) ai_sticky_options ($block, $obj, $default); ?>
913
-
914
- <div class="max-input">
915
- <span id="css-label-<?php echo $block; ?>" style="display: table-cell; width: 36px; padding: 0; height: 26px; vertical-align: middle; margin: 4px 0 0 0; font-size: 14px; font-weight: bold;">CSS</span>
916
- <input id="custom-css-<?php echo $block; ?>" style="width: 100%; display: none; font-family: Courier, 'Courier New', monospace; font-weight: bold;" type="text" name="<?php echo AI_OPTION_CUSTOM_CSS, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_custom_css(); ?>" value="<?php echo $obj->get_custom_css(); ?>" maxlength="500" title="Custom CSS code for wrapping div" />
917
- <span style="display: table-cell; vertical-align: middle; font-family: Courier, 'Courier New', monospace; font-size: 12px; font-weight: bold; cursor: pointer;">
918
- <span id="css-no-wrapping-<?php echo $block; ?>" class='css-code' style="height: 18px; padding-left: 7px; display: none;"></span>
919
- <span id="css-none-<?php echo $block; ?>" class='css-code-<?php echo $block; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_DEFAULT); ?></span>
920
- <span id="css-left-<?php echo $block; ?>" class='css-code-<?php echo $block; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_LEFT); ?></span>
921
- <span id="css-right-<?php echo $block; ?>" class='css-code-<?php echo $block; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_RIGHT); ?></span>
922
- <span id="css-center-<?php echo $block; ?>" class='css-code-<?php echo $block; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_CENTER); ?></span>
923
- <span id="css-float-left-<?php echo $block; ?>" class='css-code-<?php echo $block; ?>' style="height: 18px; padding-left: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_FLOAT_LEFT); ?></span>
924
- <span id="css-float-right-<?php echo $block; ?>" class='css-code-<?php echo $block; ?>' style="height: 18px; padding-right: 7px; display: none;" title="CSS code for wrapping div, click to edit"><?php echo $obj->alignment_style (AI_ALIGNMENT_FLOAT_RIGHT); ?></span>
925
- <?php if (function_exists ('ai_style_css')) ai_style_css ($block, $obj); ?>
926
- </span>
927
- <span style="display:table-cell; width: 46px;" ><button id="edit-css-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: table-cell; padding: 0; margin: 0 0 0 8px;">Edit</button></span>
928
- </div>
929
- </div>
930
- </div>
931
-
932
- <div id="sticky-scroll-warning-<?php echo $block; ?>" class="rounded" style="display: none;">
933
- <span style="margin-top: 5px;"><strong><span style="color: red;">WARNING:</span></strong> vertical position <strong><?php echo AI_TEXT_SCROLL_WITH_THE_CONTENT; ?></strong> needs <strong>Output buffering</strong> enabled and automatic insertion <strong><?php echo AI_TEXT_ABOVE_HEADER; ?></strong>!</span>
934
- </div>
935
-
936
- <div class="responsive-table small-button rounded">
937
- <table>
938
- <tr>
939
- <td style="width: 70%; padding-bottom: 5px;">
940
- <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
941
- <input type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_POSTS, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_display_settings_post(); ?>" id="display-posts-<?php echo $block; ?>" title="Enable or disable insertion on posts" <?php if ($obj->get_display_settings_post()==AI_ENABLED) echo 'checked '; ?> />
942
-
943
- <select style="margin: 0 0 0 10px;" id="enabled-on-which-posts-<?php echo $block; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_POSTS, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_enabled_on_which_posts(); ?>" style="width:160px" title="Individual post exceptions (if enabled here) can be configured in post editor. Leave blank for no individual post exceptions.">
944
- <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
945
- <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
946
- <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_posts()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
947
- </select>
948
- &nbsp;
949
- <label for="display-posts-<?php echo $block; ?>" title="Individual post exceptions (if enabled here) can be configured in post editor. Leave blank for no individual post exceptions.">Posts</label>
950
-
951
- <?php
952
- if (!empty ($block_exceptions [$block])) {
953
- ?>
954
- <button id="exceptions-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; width: 15px; height: 15px; margin-left: 20px;" title="Toggle list of individual exceptions"></button>
955
- <?php
956
- }
957
- ?>
958
-
959
- </td>
960
- <td style="padding-left: 8px;">
961
- </td>
962
- <td style="padding-left: 8px;">
963
- <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
964
- <input id= "display-homepage-<?php echo $block; ?>" style="margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_HOMEPAGE, WP_FORM_FIELD_POSTFIX, $block; ?>" title="Enable or disable insertion on homepage: latest posts (including sub-pages), static page or theme homepage" value="1" default="<?php echo $default->get_display_settings_home(); ?>" <?php if ($obj->get_display_settings_home()==AI_ENABLED) echo 'checked '; ?> />
965
- <label for="display-homepage-<?php echo $block; ?>" title="Enable or disable insertion on homepage: latest posts (including sub-pages), static page or theme homepage">Homepage</label>
966
- </td>
967
- <td style="padding-left: 8px;">
968
- <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
969
- <input id= "display-category-<?php echo $block; ?>" style="margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_CATEGORY_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" title="Enable or disable insertion on category blog pages (including sub-pages)" value="1" default="<?php echo $default->get_display_settings_category(); ?>" <?php if ($obj->get_display_settings_category()==AI_ENABLED) echo 'checked '; ?> />
970
- <label for="display-category-<?php echo $block; ?>" title="Enable or disable insertion on category blog pages (including sub-pages)">Category pages</label>
971
- </td>
972
- </tr>
973
-
974
- <tr>
975
- <td style="width: 70%">
976
- <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
977
- <input type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_display_settings_page(); ?>" id="display-pages-<?php echo $block; ?>" title="Enable or disable insertion on static pages" <?php if ($obj->get_display_settings_page()==AI_ENABLED) echo 'checked '; ?> />
978
-
979
- <select style="margin: 0 0 0 10px;" id="enabled-on-which-pages-<?php echo $block; ?>" name="<?php echo AI_OPTION_ENABLED_ON_WHICH_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_enabled_on_which_pages(); ?>" style="width:160px" title="Individual static page exceptions (if enabled here) can be configured in page editor. Leave blank for no individual page exceptions.">
980
- <option value="<?php echo AI_NO_INDIVIDUAL_EXCEPTIONS; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_NO_INDIVIDUAL_EXCEPTIONS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_NO_INDIVIDUAL_EXCEPTIONS; ?></option>
981
- <option value="<?php echo AI_INDIVIDUALLY_DISABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_DISABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_DISABLED; ?></option>
982
- <option value="<?php echo AI_INDIVIDUALLY_ENABLED; ?>" <?php echo ($obj->get_ad_enabled_on_which_pages()==AI_INDIVIDUALLY_ENABLED) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_INDIVIDUALLY_ENABLED; ?></option>
983
- </select>
984
- &nbsp;
985
- <label for="display-pages-<?php echo $block; ?>" title="Individual static page exceptions (if enabled here) can be configured in page editor. Leave blank for no individual page exceptions.">Static pages</label>
986
- </td>
987
- <td style="padding-left: 8px;">
988
- </td>
989
- <td style="padding-left: 8px;">
990
- <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
991
- <input id= "display-search-<?php echo $block; ?>" style="margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_SEARCH_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" title="Enable or disable insertion on search blog pages" value="1" default="<?php echo $default->get_display_settings_search(); ?>" <?php if ($obj->get_display_settings_search()==AI_ENABLED) echo 'checked '; ?> />
992
- <label for="display-search-<?php echo $block; ?>" title="Enable or disable insertion on search blog pages">Search pages</label>
993
- </td>
994
- <td style="padding-left: 8px;">
995
- <input type="hidden" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
996
- <input id= "display-archive-<?php echo $block; ?>" style="margin-left: 10px;" type="checkbox" name="<?php echo AI_OPTION_DISPLAY_ON_ARCHIVE_PAGES, WP_FORM_FIELD_POSTFIX, $block; ?>" title="Enable or disable insertion on tag or archive blog pages" value="1" default="<?php echo $default->get_display_settings_archive(); ?>" <?php if ($obj->get_display_settings_archive()==AI_ENABLED) echo 'checked '; ?> />
997
- <label for="display-archive-<?php echo $block; ?>" title="Enable or disable insertion on tag or archive blog pages">Tag / Archive pages</label>
998
- </td>
999
- </tr>
1000
- </table>
1001
- </div>
1002
-
1003
- <div id="block-exceptions-<?php echo $block; ?>" class="responsive-table rounded" style="display: none;">
1004
- <?php
1005
-
1006
- if (!empty ($block_exceptions [$block])) {
1007
- ?>
1008
- <table class="exceptions" cellspacing=0 cellpadding=0><tbody>
1009
- <tr>
1010
- <th class="id">ID</th><th class="type">Type</th><th class="page page-only">&nbsp;Title</th><th>
1011
- <input id="clear-block-exceptions-<?php echo $block; ?>"
1012
- onclick="if (confirm('Are you sure you want to clear all exceptions for block <?php echo $block; ?>?')) {document.getElementById ('clear-block-exceptions-<?php echo $block; ?>').style.visibility = 'hidden'; document.getElementById ('clear-block-exceptions-<?php echo $block; ?>').style.fontSize = '1px'; document.getElementById ('clear-block-exceptions-<?php echo $block; ?>').value = '<?php echo $block; ?>'; return true;} return false"
1013
- title="Clear all exceptions for block <?php echo $block; ?>"
1014
- name="<?php echo AI_FORM_CLEAR_EXCEPTIONS; ?>"
1015
- value="&#x274C;"
1016
- type="submit"
1017
- style="padding: 1px 3px; border: 0; background: transparent; font-size: 8px; color: #e44;" /></th>
1018
- </tr>
1019
- <?php
1020
- foreach ($block_exceptions [$block] as $id => $exception) {
1021
- ?>
1022
- <tr>
1023
- <td class="id"><a href="<?php
1024
- echo get_permalink ($id); ?>" target="_blank" title="View" style="color: #222;"><?php
1025
- echo $id; ?></a></td><td class="type"><?php
1026
- echo $exception ['name']; ?></td><td class="page page-only"><a href="<?php
1027
- echo get_edit_post_link ($id); ?>" target="_blank" title="Edit" style="margin-left: 2px; color: #222;"><?php
1028
- echo $exception ['title']; ?></a></td><td></td>
1029
- </tr>
1030
- <?php
1031
- }
1032
- ?>
1033
-
1034
- </tbody></table>
1035
- <?php
1036
- };
1037
- ?>
1038
- </div>
1039
-
1040
- <div id="html-element-settings-<?php echo $block; ?>" class="rounded" style="<?php echo $html_settings ? "" : " display: none;" ?>">
1041
- <div class="max-input" style="margin: 0 0 8px 0;">
1042
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
1043
- HTML element(s)
1044
- &nbsp;&nbsp;
1045
- </span>
1046
- <span style="display: table-cell;">
1047
- <input
1048
- type="text"
1049
- name="<?php echo AI_OPTION_HTML_SELECTOR, WP_FORM_FIELD_POSTFIX, $block; ?>"
1050
- default="<?php echo $default->get_html_selector (); ?>"
1051
- value="<?php echo $obj->get_html_selector (); ?>"
1052
- title="HTML element selector or comma separated list of selectors (.class, #id)"
1053
- style="width: 100%;"
1054
- maxlength="80" />
1055
- </span>
1056
- </div>
1057
- <div class="max-input" style="margin: 8px 0 0 0;">
1058
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
1059
- Insertion
1060
- <select id="html-element-insertion-<?php echo $block; ?>" style="margin-bottom: 3px;" name="<?php echo AI_OPTION_HTML_ELEMENT_INSERTION, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_html_element_insertion (); ?>" title="Client-side insertion uses Javascript to insert code block when the page loads, server-side insertion inserts when the page is generated but needs Output buffering enabled">
1061
- <option value="<?php echo AI_HTML_INSERTION_CLIENT_SIDE; ?>" <?php echo ($html_element_insertion == AI_HTML_INSERTION_CLIENT_SIDE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CLIENT_SIDE; ?></option>
1062
- <option value="<?php echo AI_HTML_INSERTION_CLIENT_SIDE_DOM_READY; ?>" <?php echo ($html_element_insertion == AI_HTML_INSERTION_CLIENT_SIDE_DOM_READY) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_CLIENT_SIDE_DOM_READY; ?></option>
1063
- <?php if (defined ('AI_BUFFERING') && get_output_buffering ()) : ?>
1064
- <option value="<?php echo AI_HTML_INSERTION_SEREVR_SIDE; ?>" <?php echo ($html_element_insertion == AI_HTML_INSERTION_SEREVR_SIDE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_SERVER_SIDE; ?></option>
1065
- <?php endif; ?>
1066
- </select>
1067
- </span>
1068
- <span id="server-side-insertion-<?php echo $block; ?>" style="display: table-cell; white-space: nowrap;<?php if ($html_element_insertion == AI_HTML_INSERTION_SEREVR_SIDE) echo 'display: none;'; ?>">
1069
- &nbsp;
1070
- Javascript code position
1071
- <select style="max-width: 140px; margin-bottom: 3px;" name="<?php echo AI_OPTION_SERVER_SIDE_INSERTION, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_server_side_insertion (); ?>" title="Page position where the javascript code for client-side insertion will be inserted. Should be after the HTML element if not waiting for DOM ready.">
1072
- <option value="<?php echo AI_AUTOMATIC_INSERTION_BEFORE_POST; ?>" <?php echo ($server_side_insertion == AI_AUTOMATIC_INSERTION_BEFORE_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_BEFORE_POST; ?></option>
1073
- <option value="<?php echo AI_AUTOMATIC_INSERTION_AFTER_POST; ?>" <?php echo ($server_side_insertion == AI_AUTOMATIC_INSERTION_AFTER_POST) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_AFTER_POST; ?></option>
1074
- <option value="<?php echo AI_AUTOMATIC_INSERTION_FOOTER; ?>" <?php echo ($server_side_insertion == AI_AUTOMATIC_INSERTION_FOOTER) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AI_TEXT_FOOTER; ?></option>
1075
- <?php foreach ($ai_custom_hooks as $hook_index => $custom_hook) { ?>
1076
- <option value="<?php echo AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1; ?>" <?php echo ($server_side_insertion == AI_AUTOMATIC_INSERTION_CUSTOM_HOOK + $custom_hook ['index'] - 1) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo $custom_hook ['name']; ?></option>
1077
- <?php } ?>
1078
- </select>
1079
- </span>
1080
- </div>
1081
- </div>
1082
-
1083
- <div id="paragraph-settings-<?php echo $block; ?>" class="rounded" style="<?php echo $paragraph_settings ? "" : " display: none;" ?>">
1084
- <div style="float: left; margin-top: 1px;">
1085
- Paragraph(s)
1086
- <input
1087
- type="text"
1088
- name="<?php echo AI_OPTION_PARAGRAPH_NUMBER, WP_FORM_FIELD_POSTFIX, $block; ?>"
1089
- default="<?php echo $default->get_paragraph_number(); ?>"
1090
- value="<?php echo $obj->get_paragraph_number(); ?>"
1091
- title="Paragraph number or comma separated paragraph numbers or empty (means all paragraphs): 1 to N means paragraph number, 0 means random paragraph, value between 0 and 1 means relative position on the page (0.2 means paragraph at 20% of page height, 0.5 means paragraph halfway down the page, 0.9 means paragraph at 90% of page paragraphs, etc.)"
1092
- size="20"
1093
- maxlength="50" />
1094
- </div>
1095
-
1096
- <div style="float: right;">
1097
- <button id="counting-button-<?php echo $block; ?>" type="button" class='ai-button' style="min-width: 85px; margin-right: 8px; display: none;">Counting</button>
1098
- <button id="clearance-button-<?php echo $block; ?>" type="button" class='ai-button' style="min-width: 85px; margin-right: 0px; display: none;">Clearance</button>
1099
- </div>
1100
-
1101
- <div style="clear: both;"></div>
1102
- </div>
1103
-
1104
- <div id="paragraph-counting-<?php echo $block; ?>" class="rounded" style="<?php echo $paragraph_counting ? "" : "display: none;" ?>">
1105
- <div class="max-input" style="margin: 0 0 8px 0;">
1106
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
1107
- Count&nbsp;
1108
- <select name="<?php echo AI_OPTION_DIRECTION_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_direction_type(); ?>">
1109
- <option value="<?php echo AD_DIRECTION_FROM_TOP; ?>" <?php echo ($obj->get_direction_type()==AD_DIRECTION_FROM_TOP) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DIRECTION_FROM_TOP; ?></option>
1110
- <option value="<?php echo AD_DIRECTION_FROM_BOTTOM; ?>" <?php echo ($obj->get_direction_type()==AD_DIRECTION_FROM_BOTTOM) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DIRECTION_FROM_BOTTOM; ?></option>
1111
- </select>
1112
- paragraphs with tags&nbsp;
1113
- </span>
1114
- <span style="display: table-cell;">
1115
- <input
1116
- style="width: 100%;"
1117
- title="Comma separated HTML tag names, usually only 'p' tags are used"
1118
- type="text" name="<?php echo AI_OPTION_PARAGRAPH_TAGS, WP_FORM_FIELD_POSTFIX, $block; ?>"
1119
- default="<?php echo $default->get_paragraph_tags(); ?>"
1120
- value="<?php echo $obj->get_paragraph_tags(); ?>"
1121
- size="12"
1122
- maxlength="50"/>
1123
- </span>
1124
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
1125
- &nbsp;
1126
- that have between
1127
- <input
1128
- type="text"
1129
- name="<?php echo AI_OPTION_MIN_PARAGRAPH_WORDS, WP_FORM_FIELD_POSTFIX, $block; ?>"
1130
- default="<?php echo $default->get_minimum_paragraph_words(); ?>"
1131
- value="<?php echo $obj->get_minimum_paragraph_words(); ?>"
1132
- size="4"
1133
- maxlength="5" />
1134
- and
1135
- <input
1136
- type="text"
1137
- name="<?php echo AI_OPTION_MAX_PARAGRAPH_WORDS, WP_FORM_FIELD_POSTFIX, $block; ?>"
1138
- default="<?php echo $default->get_maximum_paragraph_words(); ?>"
1139
- value="<?php echo $obj->get_maximum_paragraph_words(); ?>"
1140
- title="Maximum number of paragraph words, leave empty for no limit"
1141
- size="4"
1142
- maxlength="5" />
1143
- words
1144
- </span>
1145
- </div>
1146
-
1147
- <div class="max-input" style="margin: 8px 0 8px 0;">
1148
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
1149
- and
1150
- <select style="margin-bottom: 3px;" name="<?php echo AI_OPTION_PARAGRAPH_TEXT_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_paragraph_text_type(); ?>">
1151
- <option value="<?php echo AD_CONTAIN; ?>" <?php echo ($obj->get_paragraph_text_type() == AD_CONTAIN) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_CONTAIN; ?></option>
1152
- <option value="<?php echo AD_DO_NOT_CONTAIN; ?>" <?php echo ($obj->get_paragraph_text_type() == AD_DO_NOT_CONTAIN) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DO_NOT_CONTAIN; ?></option>
1153
- </select>
1154
- </span>
1155
- <span class="small-input-tags" style="display: table-cell;">
1156
- <input
1157
- style="width: 100%;"
1158
- title="Comma separated text"
1159
- type="text"
1160
- name="<?php echo AI_OPTION_PARAGRAPH_TEXT, WP_FORM_FIELD_POSTFIX, $block; ?>"
1161
- default="<?php echo $default->get_paragraph_text(); ?>"
1162
- value="<?php echo $obj->get_paragraph_text(); ?>"
1163
- maxlength="200" />
1164
- </span>
1165
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
1166
- &nbsp;&nbsp;
1167
- Minimum number of paragraphs
1168
- <input
1169
- type="text"
1170
- name="<?php echo AI_OPTION_MIN_PARAGRAPHS, WP_FORM_FIELD_POSTFIX, $block; ?>"
1171
- default="<?php echo $default->get_paragraph_number_minimum(); ?>"
1172
- value="<?php echo $obj->get_paragraph_number_minimum() ?>"
1173
- size="2"
1174
- maxlength="3" />
1175
- </span>
1176
- </div>
1177
-
1178
- <div class="max-input" style="margin: 8px 0 0 0;">
1179
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
1180
- <input type="hidden" name="<?php echo AI_OPTION_COUNT_INSIDE_BLOCKQUOTE, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1181
- <input id= "ignore_blockquote-<?php echo $block; ?>" type="checkbox" name="<?php echo AI_OPTION_COUNT_INSIDE_BLOCKQUOTE, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_count_inside_blockquote(); ?>" <?php if ($obj->get_count_inside_blockquote()==AI_ENABLED) echo 'checked '; ?> />
1182
- <label for="ignore_blockquote-<?php echo $block; ?>" style="vertical-align: top;" title="Count also paragraphs inside <?php echo get_no_paragraph_counting_inside (); ?> elements - defined on general plugin settings page - Tab General">Count inside special elements</label>
1183
- </span>
1184
-
1185
- <span class="small-input-tags" style="display: table-cell;">
1186
- <input
1187
- style="width: 100%; visibility: hidden;"
1188
- />
1189
- </span>
1190
-
1191
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
1192
- &nbsp;&nbsp;
1193
- Minimum number of words in paragraphs above
1194
- <input
1195
- type="text"
1196
- name="<?php echo AI_OPTION_MIN_WORDS_ABOVE, WP_FORM_FIELD_POSTFIX, $block; ?>"
1197
- default="<?php echo $default->get_minimum_words_above(); ?>"
1198
- value="<?php echo $obj->get_minimum_words_above() ?>"
1199
- title="Used only with automatic insertion After paragraph and empty paragraph numbers"
1200
- size="2"
1201
- maxlength="4" />
1202
- </span>
1203
- </div>
1204
- </div>
1205
-
1206
- <div id="paragraph-clearance-<?php echo $block; ?>" class="rounded" style="<?php echo $paragraph_clearance ? "" : "display: none;" ?>">
1207
- <div class="max-input" style="margin: 0 0 8px 0">
1208
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
1209
- In
1210
- <input
1211
- type="text"
1212
- name="<?php echo AI_OPTION_AVOID_PARAGRAPHS_ABOVE, WP_FORM_FIELD_POSTFIX, $block; ?>"
1213
- default="<?php echo $default->get_avoid_paragraphs_above(); ?>"
1214
- value="<?php echo $obj->get_avoid_paragraphs_above(); ?>"
1215
- title="Number of paragraphs above to check, leave empty to disable checking"
1216
- size="2"
1217
- maxlength="3" />
1218
- paragraphs above avoid&nbsp;
1219
- </span>
1220
- <span style="display: table-cell;">
1221
- <input
1222
- style="width: 100%;"
1223
- title="Comma separated text"
1224
- type="text"
1225
- name="<?php echo AI_OPTION_AVOID_TEXT_ABOVE, WP_FORM_FIELD_POSTFIX, $block; ?>"
1226
- default="<?php echo $default->get_avoid_text_above(); ?>"
1227
- value="<?php echo $obj->get_avoid_text_above(); ?>"
1228
- maxlength="100" />
1229
- </span>
1230
- </div>
1231
-
1232
- <div class="max-input" style="margin: 8px 0">
1233
- <span style="display: table-cell; width: 1px; white-space: nowrap;">
1234
- In
1235
- <input
1236
- type="text"
1237
- name="<?php echo AI_OPTION_AVOID_PARAGRAPHS_BELOW, WP_FORM_FIELD_POSTFIX, $block; ?>"
1238
- default="<?php echo $default->get_avoid_paragraphs_below(); ?>"
1239
- value="<?php echo $obj->get_avoid_paragraphs_below(); ?>"
1240
- title="Number of paragraphs below to check, leave empty to disable checking"
1241
- size="2"
1242
- maxlength="3" />
1243
- paragraphs below avoid&nbsp;
1244
- </span>
1245
- <span style="display: table-cell;">
1246
- <input
1247
- style="width: 100%;"
1248
- title="Comma separated text"
1249
- type="text"
1250
- name="<?php echo AI_OPTION_AVOID_TEXT_BELOW, WP_FORM_FIELD_POSTFIX, $block; ?>"
1251
- default="<?php echo $default->get_avoid_text_below(); ?>"
1252
- value="<?php echo $obj->get_avoid_text_below(); ?>"
1253
- maxlength="100" />
1254
- </span>
1255
- </div>
1256
-
1257
- <div style="margin: 8px 0 0 0;">
1258
- If text is found
1259
- <select id="avoid-action-<?php echo $block; ?>" style="margin-bottom: 3px;" name="<?php echo AI_OPTION_AVOID_ACTION, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_avoid_action(); ?>">
1260
- <option value="<?php echo AD_DO_NOT_INSERT; ?>" <?php echo ($obj->get_avoid_action() == AD_DO_NOT_INSERT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DO_NOT_INSERT; ?></option>
1261
- <option value="<?php echo AD_TRY_TO_SHIFT_POSITION; ?>" <?php echo ($obj->get_avoid_action() == AD_TRY_TO_SHIFT_POSITION) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_TRY_TO_SHIFT_POSITION; ?></option>
1262
- </select>
1263
- <span id="check-up-to-<?php echo $block; ?>">
1264
- &mdash; check up to
1265
- <input
1266
- type="text"
1267
- name="<?php echo AI_OPTION_AVOID_TRY_LIMIT, WP_FORM_FIELD_POSTFIX, $block; ?>"
1268
- default="<?php echo $default->get_avoid_try_limit(); ?>"
1269
- value="<?php echo $obj->get_avoid_try_limit(); ?>"
1270
- size="2"
1271
- maxlength="3" />
1272
- paragraphs
1273
- <select style="margin-bottom: 3px;" name="<?php echo AI_OPTION_AVOID_DIRECTION, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_avoid_direction(); ?>">
1274
- <option value="<?php echo AD_ABOVE; ?>" <?php echo ($obj->get_avoid_direction() == AD_ABOVE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ABOVE; ?></option>
1275
- <option value="<?php echo AD_BELOW; ?>" <?php echo ($obj->get_avoid_direction() == AD_BELOW) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_BELOW; ?></option>
1276
- <option value="<?php echo AD_ABOVE_AND_THEN_BELOW; ?>" <?php echo ($obj->get_avoid_direction() == AD_ABOVE_AND_THEN_BELOW) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_ABOVE_AND_THEN_BELOW; ?></option>
1277
- <option value="<?php echo AD_BELOW_AND_THEN_ABOVE; ?>" <?php echo ($obj->get_avoid_direction() == AD_BELOW_AND_THEN_ABOVE) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_BELOW_AND_THEN_ABOVE; ?></option>
1278
- </select>
1279
- </span>
1280
- </div>
1281
- </div>
1282
-
1283
- <div class="responsive-table rounded" id="list-settings-<?php echo $block; ?>" style="<?php if (!$show_lists) echo ' display: none;'; ?>">
1284
- <table>
1285
- <tbody>
1286
- <tr>
1287
- <td>
1288
- Categories
1289
- </td>
1290
- <td>
1291
- <button id="category-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; outline: transparent; float: right; margin-top: 1px; width: 15px; height: 15px;" title="Toggle category editor"></button>
1292
- </td>
1293
- <td style="padding-right: 7px; width: 65%;">
1294
- <input id="category-list-<?php echo $block; ?>" class="ai-list-filter ai-list-custom" style="width: 100%;" title="Comma separated category slugs" type="text" name="<?php echo AI_OPTION_CATEGORY_LIST, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_block_cat(); ?>" value="<?php echo $cat_list; ?>" size="54" maxlength="500" />
1295
- </td>
1296
- <td style="padding-right: 7px;">
1297
- <input type="radio" name="<?php echo AI_OPTION_CATEGORY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="category-blacklist-<?php echo $block; ?>" default="<?php echo $default->get_ad_block_cat_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_cat_type() == AD_BLACK_LIST) echo 'checked '; ?> />
1298
- <label for="category-blacklist-<?php echo $block; ?>" title="Blacklist categories"><?php echo AD_BLACK_LIST; ?></label>
1299
- </td>
1300
- <td>
1301
- <input type="radio" name="<?php echo AI_OPTION_CATEGORY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="category-whitelist-<?php echo $block; ?>" default="<?php echo $default->get_ad_block_cat_type() == AD_WHITE_LIST; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_block_cat_type() == AD_WHITE_LIST) echo 'checked '; ?> />
1302
- <label for="category-whitelist-<?php echo $block; ?>" title="Whitelist categories"><?php echo AD_WHITE_LIST; ?></label>
1303
- </td>
1304
- </tr>
1305
- <tr>
1306
- <td colspan="5">
1307
- <select id="category-select-<?php echo $block; ?>" multiple="multiple" style="display: none;">
1308
- </select>
1309
- </td>
1310
- </tr>
1311
-
1312
- <tr>
1313
- <td>
1314
- Tags
1315
- </td>
1316
- <td>
1317
- <button id="tag-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; outline: transparent; float: right; margin-top: 1px; width: 15px; height: 15px;" title="Toggle tag editor"></button>
1318
- </td>
1319
- <td style="padding-right: 7px;">
1320
- <input id="tag-list-<?php echo $block; ?>" class="ai-list-filter ai-list-custom" style="width: 100%;" title="Comma separated tag slugs" type="text" name="<?php echo AI_OPTION_TAG_LIST, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_block_tag(); ?>" value="<?php echo $tag_list; ?>" size="54" maxlength="500"/>
1321
- </td>
1322
- <td style="padding-right: 7px;">
1323
- <input type="radio" name="<?php echo AI_OPTION_TAG_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="tag-blacklist-<?php echo $block; ?>" default="<?php echo $default->get_ad_block_tag_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_tag_type() == AD_BLACK_LIST) echo 'checked '; ?> />
1324
- <label for="tag-blacklist-<?php echo $block; ?>" title="Blacklist tags"><?php echo AD_BLACK_LIST; ?></label>
1325
- </td>
1326
- <td>
1327
- <input type="radio" name="<?php echo AI_OPTION_TAG_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="tag-whitelist-<?php echo $block; ?>" default="<?php echo $default->get_ad_block_tag_type() == AD_WHITE_LIST; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_block_tag_type() == AD_WHITE_LIST) echo 'checked '; ?> />
1328
- <label for="tag-whitelist-<?php echo $block; ?>" title="Whitelist tags"><?php echo AD_WHITE_LIST; ?></label>
1329
- </td>
1330
- </tr>
1331
- <tr>
1332
- <td colspan="5">
1333
- <select id="tag-select-<?php echo $block; ?>" multiple="multiple" style="display: none;">
1334
- </select>
1335
- </td>
1336
- </tr>
1337
-
1338
- <tr>
1339
- <td>
1340
- Taxonomies
1341
- </td>
1342
- <td>
1343
- <button id="taxonomy-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; outline: transparent; float: right; margin-top: 1px; width: 15px; height: 15px;" title="Toggle taxonomy editor"></button>
1344
- </td>
1345
- <td style="padding-right: 7px;">
1346
- <input id="taxonomy-list-<?php echo $block; ?>" class="ai-list-custom" style="width: 100%;" title="Comma separated slugs: taxonomy, term or taxonomy:term" type="text" name="<?php echo AI_OPTION_TAXONOMY_LIST, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_block_taxonomy(); ?>" value="<?php echo $taxonomy_list; ?>" size="54" maxlength="500" />
1347
- </td>
1348
- <td style="padding-right: 7px;">
1349
- <input type="radio" name="<?php echo AI_OPTION_TAXONOMY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="taxonomy-blacklist-<?php echo $block; ?>" default="<?php echo $default->get_ad_block_taxonomy_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_block_taxonomy_type() == AD_BLACK_LIST) echo 'checked '; ?> />
1350
- <label for="category-blacklist-<?php echo $block; ?>" title="Blacklist taxonomies"><?php echo AD_BLACK_LIST; ?></label>
1351
- </td>
1352
- <td>
1353
- <input type="radio" name="<?php echo AI_OPTION_TAXONOMY_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="taxonomy-whitelist-<?php echo $block; ?>" default="<?php echo $default->get_ad_block_taxonomy_type() == AD_WHITE_LIST; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_block_taxonomy_type() == AD_WHITE_LIST) echo 'checked '; ?> />
1354
- <label for="category-whitelist-<?php echo $block; ?>" title="Whitelist taxonomies"><?php echo AD_WHITE_LIST; ?></label>
1355
- </td>
1356
- </tr>
1357
- <tr>
1358
- <td colspan="5">
1359
- <select id="taxonomy-select-<?php echo $block; ?>" multiple="multiple" style="display: none;">
1360
- </select>
1361
- </td>
1362
- </tr>
1363
-
1364
- <tr>
1365
- <td>
1366
- Post IDs
1367
- </td>
1368
- <td>
1369
- <button id="id-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; outline: transparent; float: right; margin-top: 1px; width: 15px; height: 15px;" title="Toggle post/page ID editor"></button>
1370
- </td>
1371
- <td style="padding-right: 7px;">
1372
- <input id="id-list-<?php echo $block; ?>" class="ai-list-custom" style="width: 100%;" title="Comma separated post/page IDs" type="text" name="<?php echo AI_OPTION_ID_LIST, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_id_list(); ?>" value="<?php echo $id_list; ?>" size="54" maxlength="500"/>
1373
- </td>
1374
- <td style="padding-right: 7px;">
1375
- <input type="radio" name="<?php echo AI_OPTION_ID_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="id-blacklist-<?php echo $block; ?>" default="<?php echo $default->get_id_list_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_id_list_type() == AD_BLACK_LIST) echo 'checked '; ?> />
1376
- <label for="id-blacklist-<?php echo $block; ?>" title="Blacklist IDs"><?php echo AD_BLACK_LIST; ?></label>
1377
- </td>
1378
- <td>
1379
- <input type="radio" name="<?php echo AI_OPTION_ID_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="id-whitelist-<?php echo $block; ?>" default="<?php echo $default->get_id_list_type() == AD_WHITE_LIST; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_id_list_type() == AD_WHITE_LIST) echo 'checked '; ?> />
1380
- <label for="id-whitelist-<?php echo $block; ?>" title="Whitelist IDs"><?php echo AD_WHITE_LIST; ?></label>
1381
- </td>
1382
- </tr>
1383
- <tr>
1384
- <td colspan="5">
1385
- <select id="id-select-<?php echo $block; ?>" multiple="multiple" style="display: none;">
1386
- </select>
1387
- </td>
1388
- </tr>
1389
-
1390
- <tr>
1391
- <td>
1392
- Urls
1393
- </td>
1394
- <td>
1395
- <button id="url-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; outline: transparent; float: right; margin-top: 1px; width: 15px; height: 15px;" title="Toggle url editor"></button>
1396
- </td>
1397
- <td style="padding-right: 7px;">
1398
- <input id="url-list-<?php echo $block; ?>" class="ai-list-space ai-clean-protocol ai-clean-domain" style="width: 100%;" type="text" name="<?php echo AI_OPTION_URL_LIST, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_url_list(); ?>" value="<?php echo $url_list; ?>" size="54" maxlength="500" title="Comma separated urls (page addresses) starting with / after domain name (e.g. /permalink-url, use only when you need to taget a specific url not accessible by other means). You can also use partial urls with * (/url-start*. *url-pattern*, *url-end)" />
1399
- </td>
1400
- <td style="padding-right: 7px;">
1401
- <input type="radio" name="<?php echo AI_OPTION_URL_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="url-blacklist-<?php echo $block; ?>" default="<?php echo $default->get_ad_url_list_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_url_list_type() == AD_BLACK_LIST) echo 'checked '; ?> />
1402
- <label for="url-blacklist-<?php echo $block; ?>" title="Blacklist urls"><?php echo AD_BLACK_LIST; ?></label>
1403
- </td>
1404
- <td>
1405
- <input type="radio" name="<?php echo AI_OPTION_URL_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="url-whitelist-<?php echo $block; ?>" default="<?php echo $default->get_ad_url_list_type() == AD_WHITE_LIST; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_url_list_type() == AD_WHITE_LIST) echo 'checked '; ?> />
1406
- <label for="url-whitelist-<?php echo $block; ?>" title="Whitelist urls"><?php echo AD_WHITE_LIST; ?></label>
1407
- </td>
1408
- </tr>
1409
- <tr>
1410
- <td colspan="5">
1411
- <textarea id="url-editor-<?php echo $block; ?>" style="width: 100%; height: 220px; font-family: Courier, 'Courier New', monospace; font-weight: bold; display: none;"></textarea>
1412
- </td>
1413
- </tr>
1414
-
1415
- <tr>
1416
- <td>
1417
- Url parameters
1418
- &nbsp;
1419
- </td>
1420
- <td>
1421
- <button id="url-parameter-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; outline: transparent; float: right; margin-top: 1px; width: 15px; height: 15px;" title="Toggle url parameter editor"></button>
1422
- </td>
1423
- <td style="padding-right: 7px;">
1424
- <input id="url-parameter-list-<?php echo $block; ?>" style="width: 100%;" title="Comma separated url query parameters or cookies with optional values (use 'prameter', 'prameter=value', 'cookie' or 'cookie=value')" type="text" name="<?php echo AI_OPTION_URL_PARAMETER_LIST, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_url_parameter_list(); ?>" value="<?php echo $url_parameter_list; ?>" size="54" maxlength="500"/>
1425
- </td>
1426
- <td style="padding-right: 7px;">
1427
- <input type="radio" name="<?php echo AI_OPTION_URL_PARAMETER_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="url-parameter-blacklist-<?php echo $block; ?>" default="<?php echo $default->get_url_parameter_list_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_url_parameter_list_type() == AD_BLACK_LIST) echo 'checked '; ?> />
1428
- <label for="url-parameter-blacklist-<?php echo $block; ?>" title="Blacklist url parameters"><?php echo AD_BLACK_LIST; ?></label>
1429
- </td>
1430
- <td>
1431
- <input type="radio" name="<?php echo AI_OPTION_URL_PARAMETER_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="url-parameter-whitelist-<?php echo $block; ?>" default="<?php echo $default->get_url_parameter_list_type() == AD_WHITE_LIST; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_url_parameter_list_type() == AD_WHITE_LIST) echo 'checked '; ?> />
1432
- <label for="url-parameter-whitelist-<?php echo $block; ?>" title="Whitelist url parameters"><?php echo AD_WHITE_LIST; ?></label>
1433
- </td>
1434
- </tr>
1435
- <tr>
1436
- <td colspan="5">
1437
- <textarea id="url-parameter-editor-<?php echo $block; ?>" style="width: 100%; height: 220px; font-family: Courier, 'Courier New', monospace; font-weight: bold; display: none;"></textarea>
1438
- </td>
1439
- </tr>
1440
-
1441
- <tr>
1442
- <td>
1443
- Referers
1444
- </td>
1445
- <td>
1446
- <button id="referer-button-<?php echo $block; ?>" type="button" class='ai-button' style="display: none; outline: transparent; float: right; margin-top: 1px; width: 15px; height: 15px;" title="Toggle referer editor"></button>
1447
- </td>
1448
- <td style="padding-right: 7px;">
1449
- <input id="referer-list-<?php echo $block; ?>" class="ai-clean-protocol ai-only-domain ai-list-sort" style="width: 100%;" title="Comma separated domains, use # for no referer" type="text" name="<?php echo AI_OPTION_DOMAIN_LIST, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_ad_domain_list(); ?>" value="<?php echo $domain_list; ?>" size="54" maxlength="500"/>
1450
- </td>
1451
- <td style="padding-right: 7px;">
1452
- <input type="radio" name="<?php echo AI_OPTION_DOMAIN_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="referer-blacklist-<?php echo $block; ?>" default="<?php echo $default->get_ad_domain_list_type() == AD_BLACK_LIST; ?>" value="<?php echo AD_BLACK_LIST; ?>" <?php if ($obj->get_ad_domain_list_type() == AD_BLACK_LIST) echo 'checked '; ?> />
1453
- <label for="referer-blacklist-<?php echo $block; ?>" title="Blacklist referers"><?php echo AD_BLACK_LIST; ?></label>
1454
- </td>
1455
- <td>
1456
- <input type="radio" name="<?php echo AI_OPTION_DOMAIN_LIST_TYPE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="referer-whitelist-<?php echo $block; ?>" default="<?php echo $default->get_ad_domain_list_type() == AD_WHITE_LIST; ?>" value="<?php echo AD_WHITE_LIST; ?>" <?php if ($obj->get_ad_domain_list_type() == AD_WHITE_LIST) echo 'checked '; ?> />
1457
- <label for="referer-whitelist-<?php echo $block; ?>" title="Whitelist referers"><?php echo AD_WHITE_LIST; ?></label>
1458
- </td>
1459
- </tr>
1460
- <tr>
1461
- <td colspan="5">
1462
- <textarea id="referer-editor-<?php echo $block; ?>" style="width: 100%; height: 220px; font-family: Courier, 'Courier New', monospace; font-weight: bold; display: none;"></textarea>
1463
- </td>
1464
- </tr>
1465
-
1466
- <?php if (function_exists ('ai_list_rows')) ai_list_rows ($block, $default, $obj); ?>
1467
- </tbody>
1468
- </table>
1469
- </div>
1470
-
1471
- <div id="manual-settings-<?php echo $block; ?>" class="small-button rounded" style="text-align: left;<?php if (!$show_manual) echo ' display: none;'; ?>">
1472
- <table>
1473
- <tr>
1474
- <td style="padding: 4px 10px 4px 0;">
1475
- <input type="hidden" name="<?php echo AI_OPTION_ENABLE_WIDGET, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1476
- <input id="enable-widget-<?php echo $block; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_WIDGET, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_enable_widget(); ?>" <?php if ($obj->get_enable_widget () == AI_ENABLED) echo 'checked '; ?> />
1477
- <label for="enable-widget-<?php echo $block; ?>" title="Enable or disable widget for this code block">
1478
- Widget
1479
- </label>
1480
- </td>
1481
- <td>
1482
- <pre class="ai-sidebars" style= "margin: 0; display: inline; color: blue; white-space: pre-wrap; word-wrap: break-word;" title="Sidebars (or widget positions) where this widged is used"><?php echo $sidebars [$block], !empty ($sidebars [$block]) ? " &nbsp;" : ""; ?></pre>
1483
- </td>
1484
- </tr>
1485
- <tr>
1486
- <td style="padding: 4px 10px 4px 0;">
1487
- <input type="hidden" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1488
- <input type="checkbox" id="enable-shortcode-<?php echo $block; ?>" name="<?php echo AI_OPTION_ENABLE_MANUAL, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_enable_manual(); ?>" <?php if ($obj->get_enable_manual () == AI_ENABLED) echo 'checked '; ?> />
1489
- <label for="enable-shortcode-<?php echo $block; ?>" title="Enable or disable shortcode for manual insertion of this code block in posts and pages">
1490
- Shortcode
1491
- </label>
1492
- </td>
1493
- <td>
1494
- <pre class="select ai-block-number" style="margin: 0 5px 0 0; display: inline; color: blue; font-size: 11px; white-space: pre-wrap; word-wrap: break-word;">[adinserter block="<?php echo $block; ?>"]</pre>
1495
- <div class="copy-blocker"></div>
1496
- <span class="copy-blocker">or</span>
1497
- <pre class="select ai-block-name" style="margin: 0 0 0 20px; display: inline; color: blue; white-space: pre-wrap; word-wrap: break-word;">[adinserter name="<?php echo $obj->get_ad_name(); ?>"]</pre>
1498
- <div class="copy-blocker"></div>
1499
- </td>
1500
- </tr>
1501
- <tr>
1502
- <td style="padding: 4px 10px 4px 0;">
1503
- <input type="hidden" name="<?php echo AI_OPTION_ENABLE_PHP_CALL, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1504
- <input id="enable-php-call-<?php echo $block; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_PHP_CALL, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_enable_php_call(); ?>" <?php if ($manual_php_function [$block] == AI_ENABLED) echo 'checked '; ?> />
1505
- <label for="enable-php-call-<?php echo $block; ?>" title="Enable or disable PHP function call to insert this code block at any position in template file. If function is disabled for block it will return empty string.">
1506
- PHP function
1507
- </label>
1508
- </td>
1509
- <td class="select">
1510
- <pre class="ai-block-number" style="margin: 0; display: inline; color: blue; font-size: 11px; white-space: pre-wrap; word-wrap: break-word;">&lt;?php if (function_exists ('adinserter')) echo adinserter (<?php echo $block; ?>); ?&gt;</pre>
1511
- <div class="copy-blocker"></div>
1512
- </td>
1513
- </tr>
1514
- </table>
1515
- </div>
1516
-
1517
- <div id="device-detection-settings-<?php echo $block; ?>" style="<?php if (!$show_devices) echo 'display: none;'; ?>">
1518
-
1519
- <div id="ai-devices-container-<?php echo $block; ?>" style="padding: 0; margin 8px 0 0 0; border: 0;">
1520
- <ul id="ai-devices-tabs-<?php echo $block; ?>" style="display: none;">
1521
- <li id="ai-client-side-detection-<?php echo $block; ?>"><a href="#tab-client-side-<?php echo $block; ?>"><span style="<?php echo $client_side_style; ?>">Client-side device detection</span></a></li>
1522
- <li id="ai-server-side-detection<?php echo $block; ?>"><a href="#tab-server-side-<?php echo $block; ?>"><span style="<?php echo $server_side_style; ?>">Server-side device detection</span></a></li>
1523
- </ul>
1524
-
1525
- <div id="tab-client-side-<?php echo $block; ?>" class="rounded">
1526
- <div style="float: left; margin-top: 0px;">
1527
- <input type="hidden" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1528
- <input id="client-side-detection-<?php echo $block; ?>" type="checkbox" name="<?php echo AI_OPTION_DETECT_CLIENT_SIDE, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_detection_client_side(); ?>" <?php if ($obj->get_detection_client_side ()==AI_ENABLED) echo 'checked '; ?> />
1529
- <label for="client-side-detection-<?php echo $block; ?>" style="vertical-align: baseline;">Use client-side detection to </label>
1530
-
1531
- <select id="client-side-action-<?php echo $block; ?>" name="<?php echo AI_OPTION_CLIENT_SIDE_ACTION, WP_FORM_FIELD_POSTFIX, $block; ?>" style="margin: -4px 1px -2px 1px;" default="<?php echo $default->get_client_side_action (); ?>" title="Either show/hide or inseret when the page is loaded on wanted viewports">
1532
- <option value="<?php echo AI_CLIENT_SIDE_ACTION_SHOW; ?>" <?php echo ($obj->get_client_side_action () == AI_CLIENT_SIDE_ACTION_SHOW) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo strtolower (AI_TEXT_SHOW); ?></option>
1533
- <option value="<?php echo AI_CLIENT_SIDE_ACTION_INSERT; ?>" <?php echo ($obj->get_client_side_action () == AI_CLIENT_SIDE_ACTION_INSERT) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo strtolower (AI_TEXT_INSERT); ?></option>
1534
- </select>
1535
-
1536
- <label style="vertical-align: baseline;"> only on</label>
1537
- </div>
1538
-
1539
- <div style="float: left; margin: -5px 0 -2px 0;">
1540
- <?php
1541
-
1542
- $viewports = array ();
1543
- for ($viewport = 1; $viewport <= AD_INSERTER_VIEWPORTS; $viewport ++) {
1544
- $viewport_name = get_viewport_name ($viewport);
1545
- if ($viewport_name != '') $viewports [$viewport] = $viewport_name;
1546
- }
1547
- $number_of_viewports = count ($viewports);
1548
- $columns = 3;
1549
-
1550
- ?>
1551
- <table>
1552
- <tbody>
1553
- <?php
1554
-
1555
- $column = 0;
1556
- foreach ($viewports as $viewport => $viewport_name) {
1557
- if ($column % $columns == 0) {
1558
- ?>
1559
- <tr>
1560
- <?php
1561
- }
1562
- ?>
1563
- <td style='padding: 2px 0 0 20px;'>
1564
- <input type="hidden" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1565
- <input type="checkbox" name="<?php echo AI_OPTION_DETECT_VIEWPORT, '_', $viewport, WP_FORM_FIELD_POSTFIX, $block; ?>" id="viewport-<?php echo $viewport, "-", $block; ?>" value="1" default="<?php echo $default->get_detection_viewport ($viewport); ?>" <?php if ($obj->get_detection_viewport ($viewport)==AI_ENABLED) echo 'checked '; ?> />
1566
- <label for="viewport-<?php echo $viewport, "-", $block; ?>" title="Device min width <?php echo get_viewport_width ($viewport); ?> px"><?php echo $viewport_name; ?></label>
1567
- </td>
1568
- <?php
1569
- $column ++;
1570
- }
1571
- if ($column % $columns != 0) {
1572
- for ($fill = 1; $fill <= $columns - $column % $columns; $fill++) {
1573
- ?>
1574
- <td> </td>
1575
- <?php
1576
- }
1577
- ?>
1578
- </tr>
1579
- <?php
1580
- }
1581
- ?>
1582
- </tbody>
1583
- </table>
1584
- </div>
1585
- <div style="clear: both"></div>
1586
- </div>
1587
-
1588
- <div id="tab-server-side-<?php echo $block; ?>" class="rounded">
1589
- <input type="hidden" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1590
- <input type="checkbox" name="<?php echo AI_OPTION_DETECT_SERVER_SIDE, WP_FORM_FIELD_POSTFIX, $block; ?>" id="server-side-detection-<?php echo $block; ?>" value="1" default="<?php echo $default->get_detection_server_side(); ?>" <?php if ($obj->get_detection_server_side ()==AI_ENABLED) echo 'checked '; ?> />
1591
- <label for="server-side-detection-<?php echo $block; ?>" style="vertical-align: baseline;">Use server-side detection to insert code only for </label>
1592
-
1593
- <select id="display-for-devices-<?php echo $block; ?>" name="<?php echo AI_OPTION_DISPLAY_FOR_DEVICES, WP_FORM_FIELD_POSTFIX, $block; ?>" style="margin: -4px 1px -2px 1px;" default="<?php echo $default->get_display_for_devices(); ?>">
1594
- <option value="<?php echo AD_DISPLAY_DESKTOP_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_DEVICES; ?></option>
1595
- <option value="<?php echo AD_DISPLAY_MOBILE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_MOBILE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_MOBILE_DEVICES; ?></option>
1596
- <option value="<?php echo AD_DISPLAY_TABLET_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_TABLET_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_TABLET_DEVICES; ?></option>
1597
- <option value="<?php echo AD_DISPLAY_PHONE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_PHONE_DEVICES; ?></option>
1598
- <option value="<?php echo AD_DISPLAY_DESKTOP_TABLET_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_TABLET_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_TABLET_DEVICES; ?></option>
1599
- <option value="<?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?>" <?php echo ($obj->get_display_for_devices() == AD_DISPLAY_DESKTOP_PHONE_DEVICES) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_DESKTOP_PHONE_DEVICES; ?></option>
1600
- </select>
1601
- devices
1602
- </div>
1603
- </div>
1604
-
1605
- </div>
1606
-
1607
- <div id="misc-settings-<?php echo $block; ?>" style="<?php if (!$show_misc) echo 'display: none;'; ?>">
1608
- <div id="ai-misc-container-<?php echo $block; ?>" style="padding: 0; margin 8px 0 0 0; border: 0;">
1609
- <ul id="ai-misc-tabs-<?php echo $block; ?>" style="display: none;">
1610
- <li id="ai-misc-insertion-<?php echo $block; ?>"><a href="#tab-insertion-<?php echo $block; ?>"><span style="<?php echo $insertion_style; ?>">Insertion</span></a></li>
1611
- <li id="ai-misc-scheduling-<?php echo $block; ?>"><a href="#tab-scheduling-<?php echo $block; ?>"><span style="<?php echo $scheduling_style; ?>">Scheduling</span></a></li>
1612
- <li id="ai-misc-displey-<?php echo $block; ?>"><a href="#tab-display-<?php echo $block; ?>"><span style="<?php echo $display_style; ?>">Display</span></a></li>
1613
- <li id="ai-misc-word-count-<?php echo $block; ?>"><a href="#tab-word-count-<?php echo $block; ?>"><span style="<?php echo $word_count_style; ?>">Word Count</span></a></li>
1614
- <li id="ai-misc-filter-<?php echo $block; ?>"><a href="#tab-filter-<?php echo $block; ?>"><span style="<?php echo $filter_style; ?>">Filter</span></a></li>
1615
- <?php if (function_exists ('ai_adb_action_0')) ai_adb_action_0 ($block, $adb_style); ?>
1616
- <li id="ai-misc-general-<?php echo $block; ?>"><a href="#tab-general-<?php echo $block; ?>"><span style="<?php echo $general_style; ?>">General</span></a></li>
1617
- </ul>
1618
-
1619
- <div id="tab-insertion-<?php echo $block; ?>" class="max-input" style="padding: 0";>
1620
- <div class="rounded">
1621
- <table class="responsive-table" style="width: 70%">
1622
- <tbody>
1623
- <tr>
1624
- <td>
1625
- <input type="hidden" name="<?php echo AI_OPTION_ENABLE_AMP, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1626
- <input style="" id="enable-amp-<?php echo $block; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_AMP, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_enable_amp(true); ?>" <?php if ($obj->get_enable_amp (true) == AI_ENABLED) echo 'checked '; ?> />
1627
- <label for="enable-amp-<?php echo $block; ?>" style="<?php if (!$obj->get_enable_amp (true) && $obj->get_enable_amp ()) echo ' color: red;' ?>" title="<?php if (!$obj->get_enable_amp (true) && $obj->get_enable_amp ()) echo "Old settings for AMP pages detected. " ?>To insert different codes on normal and AMP pages separate them with [ADINSERTER AMP] separator. Here you can enable insertion on AMP pages only when you need to insert THE SAME CODE also on AMP pages (no AMP separator).">AMP pages</label>
1628
- </td>
1629
- <td>
1630
- <input type="hidden" name="<?php echo AI_OPTION_ENABLE_AJAX, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1631
- <input style="margin-left: 10px;" id="enable-ajax-<?php echo $block; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_AJAX, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_enable_ajax(); ?>" <?php if ($obj->get_enable_ajax () == AI_ENABLED) echo 'checked '; ?> />
1632
- <label for="enable-ajax-<?php echo $block; ?>" title="Enable or disable insertion for Ajax requests">Ajax requests</label>
1633
- </td>
1634
- <td>
1635
- <input type="hidden" name="<?php echo AI_OPTION_ENABLE_FEED, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1636
- <input style="margin-left: 10px;" id="enable-feed-<?php echo $block; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_FEED, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_enable_feed(); ?>" <?php if ($obj->get_enable_feed () == AI_ENABLED) echo 'checked '; ?> />
1637
- <label for="enable-feed-<?php echo $block; ?>" title="Enable or disable insertion in RSS feeds">RSS Feed</label>
1638
- </td>
1639
- <td>
1640
- <input type="hidden" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $block; ?>" value="0" />
1641
- <input style="margin-left: 10px;" id="enable-404-<?php echo $block; ?>" type="checkbox" name="<?php echo AI_OPTION_ENABLE_404, WP_FORM_FIELD_POSTFIX, $block; ?>" value="1" default="<?php echo $default->get_enable_404(); ?>" <?php if ($obj->get_enable_404 () == AI_ENABLED) echo 'checked '; ?> />
1642
- <label for="enable-404-<?php echo $block; ?>" title="Enable or disable insertion on page for Error 404: Page not found">Error 404 page</label>
1643
- </td>
1644
- <td>
1645
- </tr>
1646
- </tbody>
1647
- </table>
1648
-
1649
- </div>
1650
- <div class="rounded">
1651
-
1652
- <table class="responsive-table" style="width: 100%">
1653
- <tbody>
1654
- <tr>
1655
- <td>
1656
- Insert for
1657
- <select id="display-for-users-<?php echo $block; ?>" style="margin: 0 1px; width:160px" name="<?php echo AI_OPTION_DISPLAY_FOR_USERS, WP_FORM_FIELD_POSTFIX, $block; ?>" default="<?php echo $default->get_display_for_users(); ?>">
1658
- <option value="<?php echo AD_DISPLAY_ALL_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ALL_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ALL_USERS; ?></option>
1659
- <option value="<?php echo AD_DISPLAY_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_LOGGED_IN_USERS; ?></option>
1660
- <option value="<?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_NOT_LOGGED_IN_USERS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_NOT_LOGGED_IN_USERS; ?></option>
1661
- <option value="<?php echo AD_DISPLAY_ADMINISTRATORS; ?>" <?php echo ($obj->get_display_for_users()==AD_DISPLAY_ADMINISTRATORS) ? AD_SELECT_SELECTED : AD_EMPTY_VALUE; ?>><?php echo AD_DISPLAY_ADMINISTRATORS; ?></option>
1662
- </select>
1663
- </td>
1664
- <td>
1665
- Max <input type="text" style="width: 32px;" name="<?php echo