$id, 'name' => $name, 'slotName' => 'div-gpt-ad-' . $id, 'sizes' => $sizes, 'label' => $label, 'gamPlacement' => $placement, 'type' => 'standard', 'position' => '', 'devices' => '', 'device' => 'both', 'enabled' => true, 'isDefault' => true, 'isLazy' => true, 'isAnchor' => false, 'floatToCorner' => false, 'spotSticky' => false, 'feature' => 'none', ], $extra); } public static function get_defaults($network_code = '') { return [ self::unit('sticky_footer_anchor', 'Sticky Footer Anchor', '300x50;300x100;320x50;320x100;728x90;970x90;1x1', 'Sticky Anchor', 'ROS_Sticky_Footer', ['position' => 'anchor', 'isAnchor' => true, 'isLazy' => false]), self::unit('bottom_btf', 'Bottom BTF', '300x250;336x280;728x90;728x250;970x90;970x250;1x1', 'Pre-Footer Ad', 'ROS_Pre-Footer_BTF', ['position' => 'footer']), self::unit('incontent', 'Incontent Lazy', '250x250;300x250;336x280', 'In-Content', 'In-Article_All', ['position' => 'incontent', 'insertionRule' => 'auto', 'insertionValue' => 3]), self::unit('interstitial_ad', 'Interstitial', 'out-of-page', 'Interstitial', 'Special_Interstitial', ['type' => 'interstitial', 'isLazy' => false]), self::unit('reward', 'Reward', '1x1', 'Reward', 'Special_Reward', ['type' => 'reward', 'isLazy' => false]), self::unit('sidebar_left_atf', 'Sidebar Left ATF', '160x600;300x600;300x250;336x280;1x1', 'Left Sticky Sidebar', 'ROS_Sticky_Sidebars', ['position' => 'sidebar', 'insertionValue' => 1, 'devices' => 'desktop', 'device' => 'desktop']), self::unit('sidebar_right_atf', 'Sidebar Right ATF', '160x600;300x600;300x250;336x280;1x1', 'Right Sticky Sidebar', 'ROS_Sticky_Sidebars', ['position' => 'sidebar', 'insertionValue' => 2, 'devices' => 'desktop', 'device' => 'desktop']), self::unit('top_leaderboard_atf', 'Top Leaderboard ATF', '300x250;320x50;320x100;336x280;728x90;728x250;970x90;970x250;1x1', 'Top Leaderboard', 'ROS_ATF_Leaderboard', ['position' => 'header', 'isLazy' => false]), ]; } public static function get_pro_defaults($network_code = '') { return [ self::unit('spotsticky', 'Spot Sticky', '250x250;300x250;336x280', 'Spot Sticky', 'In-Article_All', ['position' => 'incontent', 'feature' => 'sticky', 'spotSticky' => true, 'devices' => 'desktop', 'device' => 'desktop', 'insertionRule' => 'after_n', 'insertionValue' => 2]), self::unit('float_to_corner', 'Float to Corner', '250x250;300x250;336x280', 'Float to Corner', 'In-Article_All', ['position' => 'incontent', 'feature' => 'float', 'floatToCorner' => true, 'devices' => 'desktop', 'device' => 'desktop', 'insertionRule' => 'after_n', 'insertionValue' => 5]), ]; } public static function fill_from_default(array $unit) { static $by_code = null; if ($by_code === null) { $by_code = []; foreach (array_merge(self::get_defaults(), self::get_pro_defaults()) as $default) { $by_code[$default['id']] = $default; } } $default = $by_code[$unit['id'] ?? ''] ?? null; if ($default === null) { return $unit; } $explicit = !empty($unit['position']) || !empty($unit['isAnchor']) || !empty($unit['floatToCorner']) || (($unit['placementMode'] ?? 'auto') === 'manual') || !empty($unit['positionChosen']) || in_array($unit['type'] ?? 'standard', ['interstitial', 'reward'], true); if (!$explicit && ($default['type'] ?? 'standard') === 'standard' && ($unit['type'] ?? 'standard') === 'standard') { $unit['position'] = $default['position']; if (!isset($unit['insertionValue']) && isset($default['insertionValue'])) { $unit['insertionValue'] = $default['insertionValue']; } } foreach (['label', 'gamPlacement'] as $key) { if (empty($unit[$key])) { $unit[$key] = $default[$key]; } } return $unit; } public static function get_all_defaults($network_code = '') { return self::get_defaults($network_code); } public static function units_saved() { return (bool) get_option('adghost_units_saved', false) || !empty(get_option('adghost_ad_units', [])); } public static function maybe_initialize_defaults($network_code) { if (self::units_saved()) { return false; } update_option('adghost_ad_units', self::get_all_defaults($network_code)); AdGhost_Helper::flush_units_cache(); return true; } }