__('Watch a short ad to unlock', 'adghost-lite'), 'message' => __('This content is free — unlock it by watching a short ad.', 'adghost-lite'), ], $atts, 'adghost_rewarded'); $inner = do_shortcode((string) $content); $has_reward = false; foreach (AdGhost_Helper::units() as $unit) { if (($unit['type'] ?? '') === 'reward') { $has_reward = true; break; } } if (!$has_reward || !get_option('adghost_is_active', false) || is_feed() || (class_exists('AdGhost_AMP') && AdGhost_AMP::is_amp()) || (class_exists('AdGhost_Targeting') && AdGhost_Targeting::page_exclusion_reason() !== null) || (class_exists('AdGhost_IVT_Manager') && !AdGhost_IVT_Manager::ads_allowed())) { return $inner; } $id = 'adghost-reward-' . (++self::$reward_counter); $fallback = wp_get_inline_script_tag('(function(){function o(){var g=document.querySelector(\'[data-adghost-reward="#' . esc_js($id) . '"]\');' . 'if(!g||g.getAttribute("data-agh-rg"))return;var c=document.getElementById(' . wp_json_encode($id) . ');' . 'if(c){c.hidden=false;}g.style.display="none";}' . 'function w(){setTimeout(o,6000);}document.readyState==="complete"?w():window.addEventListener("load",w);})();'); return $fallback . sprintf( '
[AdGhost] Missing required "id" attribute
'; } return ''; } $network_code = get_option('adghost_network_code', ''); if (empty($network_code)) { if (current_user_can('manage_options')) { return '[AdGhost] Network Code not configured
'; } return ''; } if (!AdGhost_Helper::ads_live() || is_feed()) { return ''; } if (class_exists('AdGhost_Targeting') && AdGhost_Targeting::page_exclusion_reason() !== null) { return ''; } if (class_exists('AdGhost_IVT_Manager') && !AdGhost_IVT_Manager::ads_allowed()) { return ''; } if ($unit) { if (class_exists('AdGhost_Targeting') && AdGhost_Targeting::unit_exclusion_reason($unit) !== null) { return ''; } if ($atts['class'] === '' && $atts['sizes'] === str_replace(';', ',', (string) ($unit['sizes'] ?? '300x250'))) { return AdGhost_Ad_Container::render($unit, 'shortcode', self::$slot_counter++); } } if (class_exists('AdGhost_AMP') && AdGhost_AMP::is_amp()) { $amp_unit = $unit ?: ['id' => $atts['slot'], 'name' => $atts['slot']]; $amp_unit['sizes'] = $atts['sizes']; return AdGhost_AMP::ad(AdGhost_Helper::normalize_unit($amp_unit), 'shortcode', $atts['sizes']); } self::$slot_counter++; $slot_id = 'adghost-manual-' . self::$slot_counter . '-' . sanitize_title($atts['slot']); $gam_code = $unit ? AdGhost_Helper::gam_code($unit) : AdGhost_Helper::sanitize_gam_code($atts['slot']); if (class_exists('AdGhost_Placement_State')) { if (AdGhost_Placement_State::is_block_inserted($slot_id, 'shortcode')) { return ''; } AdGhost_Placement_State::mark_block_inserted($slot_id, 'shortcode', [ 'slot' => $atts['slot'], 'sizes' => $atts['sizes'], ]); } $sizes_array = array_map('trim', explode(',', $atts['sizes'])); $data_sizes = esc_attr(implode(',', $sizes_array)); $classes = ['adghost-ad-container', 'adghost-shortcode', 'adghost-' . sanitize_html_class($atts['position'])]; if (!empty($atts['class'])) { $classes[] = $atts['class']; } $min_height = AdGhost_Ad_Container::reserved_height($atts['sizes']); $output = sprintf( '', esc_attr(implode(' ', $classes)), esc_attr($slot_id), esc_attr($slot_id), esc_attr($gam_code), $data_sizes, $min_height > 0 ? ' style="min-height:' . (int) $min_height . 'px;"' : '' ); return $output; } public static function get_usage_instructions() { return 'Use the [adghost] shortcode to manually place ads anywhere in your content.
[adghost id="your_gam_ad_unit_code"]\n' . '
[adghost id="sidebar_1" sizes="300x250,336x280"]\n' . '
[adghost id="header_1" sizes="728x90" class="my-custom-class"]\n' . '
slot also works)