$end) $active_tab = $start; $active_tab_0 = isset ($active_tabs [1]) ? $active_tabs [1] : 0; $adH = $block_object [AI_HEADER_OPTION_NAME]; $adF = $block_object [AI_FOOTER_OPTION_NAME]; if (defined ('AI_ADBLOCKING_DETECTION') && AI_ADBLOCKING_DETECTION) { $adA = $block_object [AI_ADB_MESSAGE_OPTION_NAME]; } $syntax_highlighter_theme = get_syntax_highlighter_theme (); $block_class_name = get_block_class_name (); $block_class = get_block_class (); $block_number_class = get_block_number_class (); $inline_styles = get_inline_styles (); $default = $block_object [0]; $exceptions = false; $block_exceptions = array (); if (ai_current_user_role_ok () && (!is_multisite() || is_main_site () || multisite_exceptions_enabled ())) { $args = array ( 'public' => true, '_builtin' => false ); $custom_post_types = get_post_types ($args, 'names', 'and'); $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types)); $args = array ( 'posts_per_page' => 100, 'offset' => 0, 'category' => '', 'category_name' => '', 'orderby' => 'type', 'order' => 'ASC', 'include' => '', 'exclude' => '', 'meta_key' => '_adinserter_block_exceptions', 'meta_value' => '', 'post_type' => $screens, 'post_mime_type' => '', 'post_parent' => '', 'author' => '', 'author_name' => '', 'post_status' => '', 'suppress_filters' => true ); $posts_pages = get_posts ($args); $exceptions = array (); foreach ($posts_pages as $page) { $post_meta = get_post_meta ($page->ID, '_adinserter_block_exceptions', true); if ($post_meta == '') continue; $post_type_object = get_post_type_object ($page->post_type); $exceptions [$page->ID] = array ('type' => $page->post_type, 'name' => $post_type_object->labels->singular_name, 'title' => $page->post_title, 'blocks' => $post_meta); $selected_blocks = explode (",", $post_meta); foreach ($selected_blocks as $selected_block) { $block_exceptions [$selected_block][$page->ID] = array ('type' => $page->post_type, 'name' => $post_type_object->labels->singular_name, 'title' => $page->post_title); } } } $rating_string = ''; if ($rating_string = get_transient (AI_TRANSIENT_RATING)) { if ($rating_string < 1 && $rating_string > 5) $rating_string = ''; } $rating_css = $rating_string == '' ? 'width: 100%;' : 'width: '.number_format ($rating_string * 20, 4).'%;'; $rating_value = $rating_string == '' ? '' : number_format ($rating_string, 1); if (isset ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS])) $used_blocks = unserialize ($ai_db_options_extract [AI_EXTRACT_USED_BLOCKS]); else $used_blocks = array (); if (!isset ($_GET ['settings'])): // start of code only for normal settings if (function_exists ('ai_admin_settings_notices')) ai_admin_settings_notices (); ?>
">

WARNING

Page may not be loaded properly. Check ad blocking software that may block CSS, Javascript or image files.
number = $block; $default->wp_options [AI_OPTION_BLOCK_NAME] = AD_NAME." ".$block; $tab_visible = $block == $active_tab || $generate_all; $obj = $block_object [$block]; } else { $block = 999; $sidebars [$block] = ""; $manual_widget [$block] = $obj->get_enable_widget() == AI_ENABLED; $manual_shortcode [$block] = $obj->get_enable_manual() == AI_ENABLED; $manual_php_function [$block] = $obj->get_enable_php_call() == AI_ENABLED; $manual [$block] = ($manual_widget [$block] && !empty ($sidebars_with_widget [$block])) || $manual_shortcode [$block] || $manual_php_function [$block]; $default->number = 0; $default->wp_options [AI_OPTION_BLOCK_NAME] = AD_NAME." 0"; $tab_visible = false; $obj = $default; } $client_side_devices = $obj->get_detection_client_side () == AI_ENABLED; $server_side_devices = $obj->get_detection_server_side () == AI_ENABLED; if ($client_side_devices) $client_side_style = "font-weight: bold; color: #66f;"; else $client_side_style = ""; if ($server_side_devices) $server_side_style = "font-weight: bold; color: #66f;"; else $server_side_style = ""; $show_devices = $client_side_devices || $server_side_devices == AI_ENABLED; if ($show_devices) $devices_style = "font-weight: bold; color: #66f;"; else $devices_style = ""; $cat_list = $obj->get_ad_block_cat(); $tag_list = $obj->get_ad_block_tag(); $taxonomy_list = $obj->get_ad_block_taxonomy(); $id_list = $obj->get_id_list(); $url_list = $obj->get_ad_url_list(); $url_parameter_list = $obj->get_url_parameter_list(); $domain_list = $obj->get_ad_domain_list(); if (function_exists ('ai_lists')) $lists = ai_lists ($obj); else $lists = false; $show_lists = $cat_list != '' || $obj->get_ad_block_cat_type() == AD_WHITE_LIST || $tag_list != '' || $obj->get_ad_block_tag_type() == AD_WHITE_LIST || $taxonomy_list != '' || $obj->get_ad_block_taxonomy_type() == AD_WHITE_LIST || $id_list != '' || $obj->get_id_list_type() == AD_WHITE_LIST || $url_list != '' || $obj->get_ad_url_list_type() == AD_WHITE_LIST || $url_parameter_list != '' || $obj->get_url_parameter_list_type() == AD_WHITE_LIST || $domain_list != '' || $obj->get_ad_domain_list_type() == AD_WHITE_LIST || $lists; if ($show_lists) $lists_style = "font-weight: bold; color: #66f;"; else $lists_style = ""; $show_manual = $manual [$block] ||!empty ($sidebars_with_widget [$block]); if ($show_manual) $manual_style = "font-weight: bold; color: " . ($manual_widget [$block] || empty ($sidebars_with_widget [$block]) ? "#66f;" : "#e44;"); else $manual_style = ""; $insertion_options = $obj->get_maximum_insertions () || $obj->get_display_for_users() != AD_DISPLAY_ALL_USERS || $obj->get_enable_amp () == AI_ENABLED || $obj->get_enable_ajax () != AI_ENABLED || $obj->get_enable_404 () == AI_ENABLED || $obj->get_enable_feed () == AI_ENABLED || $obj->get_max_page_blocks_enabled () || $obj->get_only_in_the_loop () || $obj->get_disable_caching (); $word_count_options = intval ($obj->get_minimum_words()) != 0 || intval ($obj->get_maximum_words()) != 0; $scheduling_active = $obj->get_scheduling() != AI_SCHEDULING_OFF; $filter_active = $obj->get_call_filter() || $obj->get_inverted_filter() != 0; $adb_block_action_active = $obj->get_adb_block_action () != AI_ADB_BLOCK_ACTION_DO_NOTHING; $display_options = $obj->get_show_label () || $obj->get_lazy_loading () || $obj->get_close_button (); $show_misc = $insertion_options || $word_count_options || $scheduling_active || $filter_active || $adb_block_action_active || $display_options; if ($show_misc) $misc_style = "font-weight: bold; color: #66f;"; else $misc_style = ""; if ($insertion_options) $insertion_style = "font-weight: bold; color: #66f;"; else $insertion_style = ""; if ($word_count_options) $word_count_style = "font-weight: bold; color: #66f;"; else $word_count_style = ""; if ($scheduling_active) $scheduling_style = "font-weight: bold; color: #66f;"; else $scheduling_style = ""; if ($filter_active) $filter_style = "font-weight: bold; color: #66f;"; else $filter_style = ""; if ($adb_block_action_active) $adb_style = "font-weight: bold; color: #66f;"; else $adb_style = ""; if ($display_options) $display_style = "font-weight: bold; color: #66f;"; else $display_style = ""; $general_style = ''; $automatic_insertion = $obj->get_automatic_insertion(); $paragraph_settings = $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_PARAGRAPH || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_PARAGRAPH; $paragraph_counting = $obj->get_direction_type() != $default->get_direction_type() || $obj->get_paragraph_tags() != $default->get_paragraph_tags() || $obj->get_minimum_paragraph_words() != $default->get_minimum_paragraph_words() || $obj->get_maximum_paragraph_words() != $default->get_maximum_paragraph_words() || $obj->get_paragraph_text_type() != $default->get_paragraph_text_type() || $obj->get_paragraph_text() != $default->get_paragraph_text() || $obj->get_paragraph_number_minimum() != $default->get_paragraph_number_minimum() || $obj->get_minimum_words_above() != $default->get_minimum_words_above() || $obj->get_count_inside_blockquote() != $default->get_count_inside_blockquote(); $paragraph_clearance = ($obj->get_avoid_text_above() != $default->get_avoid_text_above() && intval ($obj->get_avoid_paragraphs_above()) != 0) || ($obj->get_avoid_text_below() != $default->get_avoid_text_below() && intval ($obj->get_avoid_paragraphs_below()) != 0); $html_settings = $automatic_insertion == AI_AUTOMATIC_INSERTION_BEFORE_HTML_ELEMENT || $automatic_insertion == AI_AUTOMATIC_INSERTION_AFTER_HTML_ELEMENT || $automatic_insertion == AI_AUTOMATIC_INSERTION_INSIDE_HTML_ELEMENT; $html_element_insertion = $obj->get_html_element_insertion (); $server_side_insertion = $obj->get_server_side_insertion (); $inside_element = $obj->get_inside_element (); $filter_type = $obj->get_filter_type(); ?>
">
get_ad_name() ?> get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" /> get_disable_insertion () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
Automatic Insertion
Alignment and Style     
get_display_settings_post()==AI_ENABLED) echo 'checked '; ?> />   get_display_settings_home()==AI_ENABLED) echo 'checked '; ?> /> get_display_settings_category()==AI_ENABLED) echo 'checked '; ?> />
get_display_settings_page()==AI_ENABLED) echo 'checked '; ?> />   get_display_settings_search()==AI_ENABLED) echo 'checked '; ?> /> get_display_settings_archive()==AI_ENABLED) echo 'checked '; ?> />
">
HTML element(s)      Action
Insertion   Javascript code position
">
Paragraph(s)
">
Count  paragraphs with tags    that have between and words
and    Minimum number of paragraphs
get_count_inside_blockquote()==AI_ENABLED) echo 'checked '; ?> />    Minimum number of words in paragraphs above
">
In paragraphs above avoid 
In paragraphs below avoid 
If text is found — check up to paragraphs
Categories get_ad_block_cat_type() == AD_BLACK_LIST) echo 'checked '; ?> /> get_ad_block_cat_type() == AD_WHITE_LIST) echo 'checked '; ?> />
Tags get_ad_block_tag_type() == AD_BLACK_LIST) echo 'checked '; ?> /> get_ad_block_tag_type() == AD_WHITE_LIST) echo 'checked '; ?> />
Taxonomies get_ad_block_taxonomy_type() == AD_BLACK_LIST) echo 'checked '; ?> /> get_ad_block_taxonomy_type() == AD_WHITE_LIST) echo 'checked '; ?> />
Post IDs get_id_list_type() == AD_BLACK_LIST) echo 'checked '; ?> /> get_id_list_type() == AD_WHITE_LIST) echo 'checked '; ?> />
Urls get_ad_url_list_type() == AD_BLACK_LIST) echo 'checked '; ?> /> get_ad_url_list_type() == AD_WHITE_LIST) echo 'checked '; ?> />
Url parameters   get_url_parameter_list_type() == AD_BLACK_LIST) echo 'checked '; ?> /> get_url_parameter_list_type() == AD_WHITE_LIST) echo 'checked '; ?> />
Referers get_ad_domain_list_type() == AD_BLACK_LIST) echo 'checked '; ?> /> get_ad_domain_list_type() == AD_WHITE_LIST) echo 'checked '; ?> />
get_enable_widget () == AI_ENABLED) echo 'checked '; ?> />
get_enable_manual () == AI_ENABLED) echo 'checked '; ?> />
[adinserter block=""]
or
[adinserter name="get_ad_name(); ?>"]
/>
<?php if (function_exists ('adinserter')) echo adinserter (); ?>
get_detection_client_side ()==AI_ENABLED) echo 'checked '; ?> />
$viewport_name) { if ($column % $columns == 0) { ?>
" value="1" default="get_detection_viewport ($viewport); ?>" get_detection_viewport ($viewport)==AI_ENABLED) echo 'checked '; ?> />
get_detection_server_side ()==AI_ENABLED) echo 'checked '; ?> /> devices
get_enable_amp (true) == AI_ENABLED) echo 'checked '; ?> /> get_enable_ajax () == AI_ENABLED) echo 'checked '; ?> /> get_enable_feed () == AI_ENABLED) echo 'checked '; ?> /> get_enable_404 () == AI_ENABLED) echo 'checked '; ?> />
Max insertions get_max_page_blocks_enabled () == AI_ENABLED) echo 'checked '; ?> />
Insert for get_only_in_the_loop () == AI_ENABLED) echo 'checked '; ?> /> get_disable_caching () == AI_ENABLED) echo 'checked '; ?> />
Filter insertions    using counter get_inverted_filter () == AI_ENABLED) echo 'checked '; ?> />
Post/Static page must have between and words
for days after publishing
get_show_label () == AI_ENABLED) echo 'checked '; ?> />
General tag  
">

Settings

get_plugin_tracking () !== null) { $plugin_tracking = $ai_dst->get_tracking (); ?>
Plugin priority
Output buffering
Syntax highlighting theme
Min. user role for ind. exceptions editing
Sticky widget mode
Sticky widget top margin px
Dynamic blocks
Functions for paragraph counting
No paragraph counting inside
Ad label
Max blocks per page
Plugin usage tracking
Block class name Block class /> Block number class /> Inline styles />
Preview of the block wrapping code

  BLOCK CODE
</div>
Viewport Settings used for client-side device detection
Viewport name    " size="15" maxlength="40" /> ' ?>    min width " size="4" maxlength="4" /> px ' ?>
Custom Hooks
/> action priority
get_enable_manual () == AI_ENABLED) echo 'checked '; ?> style="display: none;" /> get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />

HTML Page Header Code

Code in the
<head></head>
section of the HTML page DISABLED'; ?>
get_detection_server_side ()==AI_ENABLED) echo 'checked '; ?> /> devices get_enable_404 () == AI_ENABLED) echo 'checked '; ?> />
get_enable_manual () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />

Ad Blocking Detection

Delay Action page views
No Action Period days
Custom Selectors
0, 'child_of' => 0, 'selected' => get_redirection_page (true), 'echo' => 0, 'name' => AI_OPTION_ADB_REDIRECTION_PAGE, 'id' => 'redirection-page', 'class' => null, 'show_option_none' => 'Custom Url', 'show_option_no_change' => null, 'option_none_value' => '0', ); $dropdown_pages = wp_dropdown_pages ($args); $dropdown_pages = str_replace ('
Custom Redirection Url
Message HTML code
get_process_php () == AI_ENABLED) echo 'checked '; ?> style="display: none;" />
Message CSS
Overlay CSS
/>
/>
/>
/>
/>
2) $sidebar = 1; if ($number_of_used_blocks >= 4 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 5 || $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 10) $sidebar = 2; if ($number_of_used_blocks >= 12 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 7 || $number_of_used_blocks >= 8 && $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 10 || $ai_wp_data [AI_DAYS_SINCE_INSTAL] > 15) $sidebar = 3; if ($ai_wp_data [AI_DAYS_SINCE_INSTAL] > 20) $sidebar = 4; } else { if ($number_of_used_blocks >= 3) $sidebar = 4; } // $sidebar = 0; if (!function_exists ('ai_settings_side')) { switch ($sidebar) { case 0: break; case 1: break; case 2: sidebar_addense_alternative (); break; case 3: sidebar_support_review (); sidebar_addense_alternative (); break; case 4: sidebar_addense_alternative (); break; } } ?>
$sidebar_widget) { if (is_array ($sidebar_widget) && isset ($GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name'])) { $sidebar_name = $GLOBALS ['wp_registered_sidebars'][$sidebar_index]['name']; if ($sidebar_name != "") { foreach ($sidebar_widget as $widget) { if (preg_match ("/ai_widget-([\d]+)/", $widget, $widget_id)) { if (isset ($widget_id [1]) && is_numeric ($widget_id [1])) { $widget_option = $widget_options [$widget_id [1]]; $widget_block = $widget_option ['block']; // if ($widget_block >= $start && $widget_block <= $end && !in_array ($sidebar_name, $sidebars_with_widget [$widget_block])) { if ($widget_block >= 1 && $widget_block <= AD_INSERTER_BLOCKS && !in_array ($sidebar_name, $sidebars_with_widget [$widget_block])) { $sidebars_with_widget [$widget_block] []= $sidebar_name; } } } } } } } return $sidebars_with_widget; } function code_block_list_container () { ?> $block) { $new_block = $blocks_new [$index]; if ($block >= 1 && $block <= AD_INSERTER_BLOCKS && $new_block >= 1 && $new_block <= AD_INSERTER_BLOCKS) { $new_options [$block] = $current_options [$new_block]; } else $error = true; } if (!$error) { // Update AI_OPTION_FALLBACK and AI_OPTION_ADB_BLOCK_REPLACEMENT for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) { if (isset ($new_options [$block][AI_OPTION_FALLBACK])) { $ai_option_fallback = $new_options [$block][AI_OPTION_FALLBACK]; if ($ai_option_fallback != '') foreach ($blocks_new as $index => $org_block) { if ($ai_option_fallback == $org_block) { $new_options [$block][AI_OPTION_FALLBACK] = $blocks_org [$index]; } } } if (isset ($new_options [$block][AI_OPTION_ADB_BLOCK_REPLACEMENT])) { $ai_option_adb_block_replacement = $new_options [$block][AI_OPTION_ADB_BLOCK_REPLACEMENT]; if ($ai_option_adb_block_replacement != '') foreach ($blocks_new as $index => $org_block) { if ($ai_option_adb_block_replacement == $org_block) { $new_options [$block][AI_OPTION_ADB_BLOCK_REPLACEMENT] = $blocks_org [$index]; } } } } update_option (AI_OPTION_NAME, $new_options); ai_load_settings (); $new_options [AI_OPTION_EXTRACT] = ai_generate_extract ($new_options); $ai_db_options_extract = $new_options [AI_OPTION_EXTRACT]; $new_options [AI_OPTION_GLOBAL]['VIEWPORT_CSS'] = generate_viewport_css (); $new_options [AI_OPTION_GLOBAL]['ALIGNMENT_CSS'] = generate_alignment_css (); $new_options [AI_OPTION_GLOBAL]['TIMESTAMP'] = time (); update_option (AI_OPTION_NAME, $new_options); update_option (AI_EXTRACT_NAME, $ai_db_options_extract); ai_load_settings (); $ai_widgets = get_option ('widget_ai_widget'); if (is_array ($ai_widgets)) foreach ($ai_widgets as $widget_index => $ai_widget) { if (isset ($ai_widget ['block'])) { $widget_block = $ai_widget ['block']; if ($widget_block >= 1 && $widget_block <= AD_INSERTER_BLOCKS) { foreach ($blocks_new as $index => $org_block) { if ($widget_block == $org_block) { $ai_widgets [$widget_index]['block'] = $blocks_org [$index]; break; } } } } } update_option ('widget_ai_widget', $ai_widgets); if (defined ('AI_STATISTICS') && AI_STATISTICS) { // Update statistics - two passes to avoid duplicate entries $offset = 1000; // Lock table to prevent updates of old blocks $query = 'LOCK TABLES ' . AI_STATISTICS_DB_TABLE . ' WRITE;'; $update = $wpdb->query ($query); // Pass 1 - new blocks with offset $query = 'UPDATE ' . AI_STATISTICS_DB_TABLE . ' SET block= CASE '; foreach ($blocks_new as $index => $org_block) { $new_block = $blocks_org [$index] + $offset; $query .= "WHEN block= $org_block THEN $new_block "; } $query .= 'ELSE block END;'; $update = $wpdb->query ($query); // Pass 2 - remove offset $query = 'UPDATE ' . AI_STATISTICS_DB_TABLE . " SET block = block - $offset WHERE block >= $offset;"; $update = $wpdb->query ($query); // Unlock table $query = 'UNLOCK TABLES;'; $update = $wpdb->query ($query); } } } } $sidebars_with_widget = get_sidebar_widgets (); ob_start (); $search_text = trim ($_GET ["list"]); $show_all_blocks = isset ($_GET ["all"]) && $_GET ["all"]; $start = trim ($_GET ["start"]); $end = trim ($_GET ["end"]); if ($search_text != '') $search_array = explode (' ', $search_text); else $search_array = array (); $blocks = array (); $row_counter = 0; for ($block = 1; $block <= AD_INSERTER_BLOCKS; $block ++) { $obj = $block_object [$block]; $automatic_insertion = $obj->get_automatic_insertion () != AI_AUTOMATIC_INSERTION_DISABLED; $manual_widget = $obj->get_enable_widget() == AI_ENABLED; $manual_shortcode = $obj->get_enable_manual() == AI_ENABLED; $manual_php_function = $obj->get_enable_php_call() == AI_ENABLED; $disabled = $obj->get_disable_insertion (); $block_used = !$disabled && ($automatic_insertion || $manual_php_function || $manual_shortcode || $manual_widget && !empty ($sidebars_with_widget [$block])); if (!$show_all_blocks && !$block_used) continue; $block_text = $block . ' '. $obj->wp_options [AI_OPTION_BLOCK_NAME] . ' ' . $obj->get_automatic_insertion_text() . ' ' . $obj->get_alignment_type_text () . ' ' . implode (', ', $sidebars_with_widget [$block]); if (!empty ($sidebars_with_widget [$block])) $block_text .= ' widget'; if ($manual_shortcode) $block_text .= ' shortcode'; if ($manual_php_function) $block_text .= ' php'; foreach ($search_array as $search_item) { if (stripos ($block_text, trim ($search_item)) === false) continue 2; } $blocks []= $block; $row_counter ++; $row_color = $row_counter % 2 == 0 ? '#eee' : '#fff'; if (function_exists ('ai_settings_url_parameters')) $url_parameters = ai_settings_url_parameters ($block); else $url_parameters = ""; $edit_url = admin_url ('options-general.php?page=ad-inserter.php') . $url_parameters . '&tab=' . $block; $visible_tab = $block >= $start && $block <= $end; ?> wp_options [AI_OPTION_BLOCK_NAME]; ?> wp_options [AI_OPTION_BLOCK_NAME]; ?> get_automatic_insertion_text(); ?> get_alignment_type_text (); ?> ● ● ●
Block Name Automatic Insertion Alignment P S W Widget Positions
No active code block"; else echo "
No code block matches search keywords
"; } } if (defined ('AI_ADSENSE_API')) { function ai_adsense_data (&$error) { require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php'; $error = 'AdSense not authorized'; $ad_data = false; if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) { $error = ''; $update_ad_units = isset ($_GET ["update_ad_units"]) ? $_GET ["update_ad_units"] == 1 : false; $adsense = new adsense_api(); $ad_data = get_transient (AI_TRANSIENT_ADSENSE_ADS); if ($ad_data === false || $update_ad_units) { $ad_units = $adsense->getAdUnits(); $error = $adsense->getError (); if ($error == '' && is_array ($ad_units)) { $ad_data = array ($adsense->getAdSensePublisherID (), $ad_units); set_transient (AI_TRANSIENT_ADSENSE_ADS, $ad_data, AI_TRANSIENT_ADSENSE_ADS_EXPIRATION); } } } return $ad_data; } function adsense_list () { require_once AD_INSERTER_PLUGIN_DIR.'includes/adsense-api.php'; if (defined ('AI_ADSENSE_AUTHORIZATION_CODE')) { $publisher_id = ''; $ad_units = array (); $error = ''; $ad_data = ai_adsense_data ($error); if ($error == '') { $publisher_id = $ad_data [0]; $ad_units = $ad_data [1]; $show_all_ad_units = isset ($_GET ["all"]) && $_GET ["all"]; ?>
Ad unit Name Slot ID Type Size
$error"; if (strpos ($error, 'unauthorized_client') !== false) { echo "
Please clear authorization with the button ", '', " above and once again authorize access to your AdSense account.
"; } } } elseif (defined ('AI_ADSENSE_CLIENT_ID')) { $adsense = new adsense_api(); $adsense_ids = defined ('AI_CI_STRING') && get_option (AI_ADSENSE_OWN_IDS) === false; ?>

AdSense Integration

AdSense Integration - Step 2

Authorize to access your AdSense account. Click on the Get Authorization Code button to open a new window where you can allow access. When you get the code copy it to the field below and click on the button Authorize.

If you get error, can't access ad units or would like to use own Google API IDs click on the button Use own API IDs to enter Client ID and Client Secret.

Now you can authorize to access your AdSense account. Click on the Get Authorization Code button to open a new window where you can allow access. When you get the code copy it to the field below and click on the button Authorize.

If you get error invalid client click on the button Clear and return to Step 1 to re-enter Client ID and Client Secret.

   

AdSense Integration - Step 1

Here can list configured AdSense ad units and get code for AdSense ads. To do this you need to authorize to access your AdSense account. The first step is to create a Google API project in order to get Client ID and Client Secret.

  1. Go to Google APIs and Services console
  2. Create Ad Inserter project - if the project and IDs are already created click on the Credentials in the sidebar and go to step 16
  3. Click on Select a project selection and then click on the + button to create a new project
  4. Enter Ad Inserter for project name and click on the Create button
  5. Click on project selection, wait for the project to be created and then and select Ad Inserter as the current project
  6. Click on ENABLE APIS AND SERVICES
  7. Search for adsense and enable AdSense Management API
  8. Click on Create credentials
  9. For Where will you be calling the API from? select Other UI
  10. For What data will you be accessing? select User data
  11. Click on What credentials do I need?
  12. Create an OAuth 2.0 client ID: For OAuth 2.0 client ID name enter Ad Inserter client
  13. Set up the OAuth 2.0 consent screen: For Product name shown to users enter Ad Inserter
  14. Click on Continue
  15. Click on Done
  16. Click on Ad Inserter client to get Client ID and Client secret
  17. Copy them to the appropriate fields below
Client ID
Client secret
   
getAdCode ($ad_slot_id); echo json_encode (array ('code' => $code, 'error-message' => $adsense->getError ())); } } } function adsense_ad_name ($adsense_data) { if (defined ('AI_ADSENSE_API')) { $publisher_id = ''; $ad_units = array (); $error = ''; $ad_data = ai_adsense_data ($error); if ($error == '') { $publisher_id = $ad_data [0]; $ad_units = $ad_data [1]; $ad_slot_names = array ('publisher_id' => $publisher_id); foreach ($ad_units as $ad_unit) { if ($ad_unit ['active']) $ad_slot_names [$ad_unit ['code']] = $ad_unit ['name']; } echo json_encode ($ad_slot_names); } } } function generate_list_options ($options) { $max_items = 2000; switch ($options) { case 'category': $args = array("hide_empty" => 0); $category_data = get_categories ($args); $category_data = array_slice ($category_data, 0, $max_items); foreach ($category_data as $category) { echo " \n"; } break; case 'tag': $tag_data = get_tags (); $tag_data = array_slice ($tag_data, 0, $max_items); foreach ($tag_data as $tag) { echo " \n"; } break; case 'taxonomy': $term_data = get_terms (); $taxonomies = array (); foreach ($term_data as $term) { if ($term->taxonomy == 'category') continue; if ($term->taxonomy == 'post_tag') continue; $taxonomies [strtolower ($term->taxonomy) . ':' . strtolower ($term->slug)] = $term->name; if (count ($taxonomies) >= $max_items) break; } $args = array ( 'public' => true, // '_builtin' => false, ); $custom_post_types = get_post_types ($args, 'objects', 'and'); foreach ($custom_post_types as $custom_post_type => $custom_post_data) { $taxonomies ['post-type:' . strtolower ($custom_post_type)] = $custom_post_data->labels->singular_name; } $editable_roles = get_editable_roles (); foreach ($editable_roles as $editable_role_slug => $editable_role) { $taxonomies ['user-role:' . strtolower ($editable_role_slug)] = $editable_role ['name']; } $users = get_users (); foreach ($users as $user) { $taxonomies ['user:' . strtolower ($user->data->user_login)] = $user->data->display_name; $taxonomies ['author:' . strtolower ($user->data->user_login)] = $user->data->display_name; if (count ($taxonomies) >= $max_items) break; } ksort ($taxonomies); foreach ($taxonomies as $taxonomy => $taxonomy_name) { if ($taxonomy_name != '') echo " \n"; else echo " \n"; } break; case 'id': $args = array ( 'public' => true, '_builtin' => false ); $custom_post_types = get_post_types ($args, 'names', 'and'); $screens = array_values (array_merge (array ('post', 'page'), $custom_post_types)); $args = array ( 'posts_per_page' => 3 * $max_items, 'offset' => 0, 'category' => '', 'category_name' => '', 'orderby' => 'ID', 'order' => 'ASC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => $screens, 'post_mime_type' => '', 'post_parent' => '', 'author' => '', 'author_name' => '', 'post_status' => '', 'suppress_filters' => true, ); $posts_pages = get_posts ($args); $counter = 0; foreach ($posts_pages as $post_page) { if ($post_page->post_title == '') continue; echo " \n"; $counter ++; if ($counter >= $max_items) break; } break; default: if (function_exists ('ai_generate_list_options')) ai_generate_list_options ($options); break; } } function sidebar_addense_alternative () { ?>

Blank Ad Blocks? Looking for AdSense alternative?

Blank Ad Blocks? Looking for AdSense alternative?

Blank Ad Blocks? Looking for AdSense alternative?

Try Infolinks Ads with Adsense or Media.net

Support plugin development


You've been using Ad Inserter for a while now, and I hope you're happy with it. Positive reviews are a great way to show your appreciation for my work. Besides being an incredible boost to my morale, they are also a great incentive to fix bugs and to add new features for better monetization of your website. happy Thank you! Igor

Support plugin development

Ad Inserter on Twitter Ad Inserter on Facebook

Follow Ad Inserter

Need help with settings? Check Quick Start, Code Editing and Common Settings pages

New to AdSense? Connect your site - Advanced AdSense code: In-feed ads, Auto ads, AMP ads

Ads are not showing? Check troubleshooting guide to find out how to diagnose and fix the problem.
If you need any kind of help or support, please do not hesitate to open a thread on the support forum.

Looking for Pro Ad Management plugin?

To Optimally Monetize your WordPress website?

Ad Inserter Pro is a complete all-in-one ad management plugin for WordPress website with many advertising features to automatically insert adverts on posts and pages. With Ad Inserter Pro you also get one year of free updates and support via email. If you find Ad Inserter useful and need more code blocks, ad statistics for impressions and clicks, A/B testing, sticky ads, slider ads, pop-up ads, geotargeting or geolocation to serve country-specific ads, to protect content from users using ad blockers, to serve different ads for users using ad blockers, multisite options to limit settings for ads, to block some IP addresses, to schedule ads, then you can simply upgrade to Ad Inserter Pro (existing settings will be preserved).

Looking for Pro Ad Management plugin?


  • Ads between posts
  • Ads between comments
  • Support via email
generate_alignment_class ($block_class_name); if ($block_class_name != '' && $block_number_class) $classes []= $block_class_name . '-n'; $class = count ($classes) ? ' class="' . implode (' ', $classes) . '"' : ''; $style = $inline_styles || !defined ('AI_NORMAL_HEADER_STYLES') ? ' style="' . AI_ALIGNMENT_CSS_DEFAULT . '"' : ''; echo "<div$class$style>"; }