EDD_SL_Plugin_Updater.php
9 years ago
ad-ajax.php
9 years ago
ad-debug.php
9 years ago
ad-model.php
9 years ago
ad-select.php
9 years ago
ad.php
9 years ago
ad_ajax_callbacks.php
9 years ago
ad_group.php
9 years ago
ad_placements.php
9 years ago
ad_type_abstract.php
11 years ago
ad_type_content.php
9 years ago
ad_type_group.php
10 years ago
ad_type_image.php
9 years ago
ad_type_plain.php
9 years ago
checks.php
9 years ago
display-conditions.php
9 years ago
frontend_checks.php
9 years ago
plugin.php
9 years ago
upgrades.php
10 years ago
visitor-conditions.php
9 years ago
widget.php
9 years ago
plugin.php
595 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Wordpress integration and definitions: |
| 5 | * |
| 6 | * - posttypes |
| 7 | * - taxonomy |
| 8 | * - textdomain |
| 9 | * |
| 10 | * @since 1.5.0 |
| 11 | */ |
| 12 | class Advanced_Ads_Plugin { |
| 13 | /** |
| 14 | * |
| 15 | * @var Advanced_Ads_Plugin |
| 16 | */ |
| 17 | protected static $instance; |
| 18 | |
| 19 | /** |
| 20 | * |
| 21 | * @var Advanced_Ads_Model |
| 22 | */ |
| 23 | protected $model; |
| 24 | |
| 25 | /** |
| 26 | * plugin options |
| 27 | * |
| 28 | * @since 1.0.1 |
| 29 | * @var array (if loaded) |
| 30 | */ |
| 31 | protected $options; |
| 32 | |
| 33 | /** |
| 34 | * interal plugin options – set by the plugin |
| 35 | * |
| 36 | * @since 1.4.5 |
| 37 | * @var array (if loaded) |
| 38 | */ |
| 39 | protected $internal_options; |
| 40 | |
| 41 | /** |
| 42 | * default prefix of selectors (id, class) in the frontend |
| 43 | * can be changed by options |
| 44 | * |
| 45 | * @var Advanced_Ads_Plugin |
| 46 | */ |
| 47 | const DEFAULT_FRONTEND_PREFIX = 'advads-'; |
| 48 | |
| 49 | /** |
| 50 | * |
| 51 | * @var frontend prefix for classes and IDs |
| 52 | */ |
| 53 | private $frontend_prefix; |
| 54 | |
| 55 | |
| 56 | private function __construct() { |
| 57 | register_activation_hook( ADVADS_BASE, array( $this, 'activate' ) ); |
| 58 | register_deactivation_hook( ADVADS_BASE, array( $this, 'deactivate' ) ); |
| 59 | register_uninstall_hook( ADVADS_BASE, array( 'Advanced_Ads_Plugin', 'uninstall' ) ); |
| 60 | |
| 61 | add_action( 'plugins_loaded', array( $this, 'wp_plugins_loaded' ), 10 ); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * |
| 66 | * @return Advanced_Ads_Plugin |
| 67 | */ |
| 68 | public static function get_instance() { |
| 69 | // If the single instance hasn't been set, set it now. |
| 70 | if ( null === self::$instance ) { |
| 71 | self::$instance = new self; |
| 72 | } |
| 73 | |
| 74 | return self::$instance; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * |
| 79 | * @param Advanced_Ads_Model $model |
| 80 | */ |
| 81 | public function set_model(Advanced_Ads_Model $model) { |
| 82 | $this->model = $model; |
| 83 | } |
| 84 | |
| 85 | public function wp_plugins_loaded() { |
| 86 | // Load plugin text domain |
| 87 | $this->load_plugin_textdomain(); |
| 88 | |
| 89 | $internal_options = $this->internal_options(); |
| 90 | |
| 91 | /** |
| 92 | * run upgrades, if this is a new version or version does not exist |
| 93 | */ |
| 94 | if ( ! defined( 'DOING_AJAX' ) && ( ! isset( $internal_options['version'] ) || version_compare( $internal_options['version'], ADVADS_VERSION, '<' ) ) ) { |
| 95 | new Advanced_Ads_Upgrades(); |
| 96 | } |
| 97 | |
| 98 | // activate plugin when new blog is added on multisites // -TODO this is admin-only |
| 99 | add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) ); |
| 100 | |
| 101 | // Load public-facing style sheet and JavaScript. |
| 102 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); |
| 103 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| 104 | |
| 105 | // add short codes |
| 106 | add_shortcode( 'the_ad', array( $this, 'shortcode_display_ad' ) ); |
| 107 | add_shortcode( 'the_ad_group', array( $this, 'shortcode_display_ad_group' ) ); |
| 108 | add_shortcode( 'the_ad_placement', array( $this, 'shortcode_display_ad_placement' ) ); |
| 109 | |
| 110 | // remove default ad group menu item // -TODO only for admin |
| 111 | add_action( 'admin_menu', array( $this, 'remove_taxonomy_menu_item' ) ); |
| 112 | // load widgets |
| 113 | add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
| 114 | |
| 115 | // load display conditions |
| 116 | Advanced_Ads_Display_Conditions::get_instance(); |
| 117 | new Advanced_Ads_Frontend_Checks; |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Register and enqueue public-facing style sheet. |
| 122 | * |
| 123 | * @since 1.0.0 |
| 124 | */ |
| 125 | public function enqueue_styles() { |
| 126 | // wp_enqueue_style( $this->get_plugin_slug() . '-plugin-styles', plugins_url('assets/css/public.css', __FILE__), array(), ADVADS_VERSION); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Return the plugin slug. |
| 131 | * |
| 132 | * @since 1.0.0 |
| 133 | * @return Plugin slug variable. |
| 134 | */ |
| 135 | public function get_plugin_slug() { |
| 136 | return ADVADS_SLUG; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Register and enqueues public-facing JavaScript files. |
| 141 | * |
| 142 | * @since 1.0.0 |
| 143 | */ |
| 144 | public function enqueue_scripts() { |
| 145 | // wp_enqueue_script( $this->get_plugin_slug() . '-plugin-script', plugins_url('assets/js/public.js', __FILE__), array('jquery'), ADVADS_VERSION); |
| 146 | $options = $this->options(); |
| 147 | $activated_js = apply_filters( 'advanced-ads-activate-advanced-js', isset( $options['advanced-js'] ) ); |
| 148 | if ( $activated_js ){ |
| 149 | wp_enqueue_script( $this->get_plugin_slug() . '-advanced-js', ADVADS_BASE_URL . 'public/assets/js/advanced.js', array( 'jquery' ), ADVADS_VERSION ); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | public function widget_init() { |
| 154 | register_widget( 'Advanced_Ads_Widget' ); |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Fired when a new site is activated with a WPMU environment. |
| 159 | * |
| 160 | * @since 1.0.0 |
| 161 | * @param int $blog_id ID of the new blog. |
| 162 | */ |
| 163 | public function activate_new_site($blog_id) { |
| 164 | |
| 165 | if ( 1 !== did_action( 'wpmu_new_blog' ) ) { |
| 166 | return; |
| 167 | } |
| 168 | |
| 169 | switch_to_blog( $blog_id ); |
| 170 | $this->single_activate(); |
| 171 | restore_current_blog(); |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Fired for each blog when the plugin is activated. |
| 176 | * |
| 177 | * @since 1.0.0 |
| 178 | */ |
| 179 | protected function single_activate() { |
| 180 | // $this->post_types_rewrite_flush(); |
| 181 | // -TODO inform modules |
| 182 | $this->create_capabilities(); |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * Fired for each blog when the plugin is deactivated. |
| 187 | * |
| 188 | * @since 1.0.0 |
| 189 | */ |
| 190 | protected function single_deactivate() { |
| 191 | // -TODO inform modules |
| 192 | $this->remove_capabilities(); |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Load the plugin text domain for translation. |
| 197 | * |
| 198 | * @since 1.0.0 |
| 199 | */ |
| 200 | public function load_plugin_textdomain() { |
| 201 | // $locale = apply_filters('advanced-ads-plugin-locale', get_locale(), $domain); |
| 202 | load_plugin_textdomain( ADVADS_SLUG, false, ADVADS_BASE_DIR . '/languages' ); |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Fired when the plugin is activated. |
| 207 | * |
| 208 | * @since 1.0.0 |
| 209 | * @param boolean $network_wide True if WPMU superadmin uses |
| 210 | * "Network Activate" action, false if |
| 211 | * WPMU is disabled or plugin is |
| 212 | * activated on an individual blog. |
| 213 | */ |
| 214 | public function activate($network_wide) { |
| 215 | if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
| 216 | |
| 217 | if ( $network_wide ) { |
| 218 | // Get all blog ids |
| 219 | global $wpdb; |
| 220 | $blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" ); |
| 221 | $original_blog_id = $wpdb->blogid; |
| 222 | |
| 223 | foreach ( $blog_ids as $blog_id ) { |
| 224 | switch_to_blog( $blog_id ); |
| 225 | $this->single_activate(); |
| 226 | } |
| 227 | |
| 228 | switch_to_blog( $original_blog_id ); |
| 229 | } else { |
| 230 | $this->single_activate(); |
| 231 | } |
| 232 | } else { |
| 233 | $this->single_activate(); |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Fired when the plugin is deactivated. |
| 239 | * |
| 240 | * @since 1.0.0 |
| 241 | * @param boolean $network_wide |
| 242 | * |
| 243 | * True if WPMU superadmin uses |
| 244 | * "Network Deactivate" action, false if |
| 245 | * WPMU is disabled or plugin is |
| 246 | * deactivated on an individual blog. |
| 247 | */ |
| 248 | public function deactivate($network_wide) { |
| 249 | if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
| 250 | |
| 251 | if ( $network_wide ) { |
| 252 | // Get all blog ids |
| 253 | global $wpdb; |
| 254 | $blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" ); |
| 255 | $original_blog_id = $wpdb->blogid; |
| 256 | |
| 257 | foreach ( $blog_ids as $blog_id ) { |
| 258 | switch_to_blog( $blog_id ); |
| 259 | $this->single_deactivate(); |
| 260 | } |
| 261 | |
| 262 | switch_to_blog( $original_blog_id ); |
| 263 | } else { |
| 264 | $this->single_deactivate(); |
| 265 | } |
| 266 | } else { |
| 267 | $this->single_deactivate(); |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | /** |
| 272 | * flush rewrites on plugin activation so permalinks for them work from the beginning on |
| 273 | * |
| 274 | * @since 1.0.0 |
| 275 | * @link http://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation |
| 276 | */ |
| 277 | /*public function post_types_rewrite_flush(){ |
| 278 | // load custom post type |
| 279 | Advanced_Ads::get_instance()->create_post_types(); |
| 280 | // flush rewrite rules |
| 281 | flush_rewrite_rules(); |
| 282 | }*/ |
| 283 | |
| 284 | /** |
| 285 | * remove WP tag edit page for the ad group taxonomy |
| 286 | * needed, because we can’t remove it with `show_ui` without also removing the meta box |
| 287 | * |
| 288 | * @since 1.0.0 |
| 289 | */ |
| 290 | public function remove_taxonomy_menu_item() { |
| 291 | remove_submenu_page( 'edit.php?post_type=advanced_ads', 'edit-tags.php?taxonomy=advanced_ads_groups&post_type=advanced_ads' ); |
| 292 | } |
| 293 | |
| 294 | /** |
| 295 | * shortcode to include ad in frontend |
| 296 | * |
| 297 | * @since 1.0.0 |
| 298 | * @param arr $atts |
| 299 | */ |
| 300 | public function shortcode_display_ad($atts){ |
| 301 | $id = isset($atts['id']) ? (int) $atts['id'] : 0; |
| 302 | |
| 303 | // use the public available function here |
| 304 | return get_ad( $id ); |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * shortcode to include ad from an ad group in frontend |
| 309 | * |
| 310 | * @since 1.0.0 |
| 311 | * @param arr $atts |
| 312 | */ |
| 313 | public function shortcode_display_ad_group($atts){ |
| 314 | $id = isset($atts['id']) ? (int) $atts['id'] : 0; |
| 315 | |
| 316 | // use the public available function here |
| 317 | return get_ad_group( $id ); |
| 318 | } |
| 319 | |
| 320 | /** |
| 321 | * shortcode to display content of an ad placement in frontend |
| 322 | * |
| 323 | * @since 1.1.0 |
| 324 | * @param arr $atts |
| 325 | */ |
| 326 | public function shortcode_display_ad_placement($atts){ |
| 327 | $id = isset($atts['id']) ? (string) $atts['id'] : ''; |
| 328 | |
| 329 | // use the public available function here |
| 330 | return get_ad_placement( $id ); |
| 331 | } |
| 332 | |
| 333 | /** |
| 334 | * return plugin options |
| 335 | * these are the options updated by the user |
| 336 | * |
| 337 | * @since 1.0.1 |
| 338 | * @return array $options |
| 339 | * @todo parse default options |
| 340 | */ |
| 341 | public function options() { |
| 342 | if ( ! isset( $this->options ) ) { |
| 343 | $this->options = get_option( ADVADS_SLUG, array() ); |
| 344 | } |
| 345 | |
| 346 | return $this->options; |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * update plugin options (not for settings page, but if automatic options are needed) |
| 351 | * |
| 352 | * @since 1.5.1 |
| 353 | * @param array $options new options |
| 354 | */ |
| 355 | public function update_options( array $options ) { |
| 356 | // do not allow to clear options |
| 357 | if ( $options === array() ) { |
| 358 | return; |
| 359 | } |
| 360 | |
| 361 | $this->options = $options; |
| 362 | update_option( ADVADS_SLUG, $options ); |
| 363 | } |
| 364 | |
| 365 | /** |
| 366 | * return internal plugin options |
| 367 | * these are options set by the plugin |
| 368 | * |
| 369 | * @since 1.0.1 |
| 370 | * @return array $options |
| 371 | * @todo parse default options |
| 372 | */ |
| 373 | public function internal_options() { |
| 374 | if ( ! isset( $this->internal_options ) ) { |
| 375 | $defaults = array( |
| 376 | 'version' => ADVADS_VERSION, |
| 377 | 'installed' => time(), // when was this installed |
| 378 | ); |
| 379 | $this->internal_options = get_option( ADVADS_SLUG . '-internal', array() ); |
| 380 | |
| 381 | // save defaults |
| 382 | if($this->internal_options === array()){ |
| 383 | $this->internal_options = $defaults; |
| 384 | $this->update_internal_options($this->internal_options); |
| 385 | } |
| 386 | |
| 387 | // for versions installed prior to 1.5.3 set installed date for now |
| 388 | if( ! isset( $this->internal_options['installed'] )){ |
| 389 | $this->internal_options['installed'] = time(); |
| 390 | $this->update_internal_options($this->internal_options); |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | return $this->internal_options; |
| 395 | } |
| 396 | |
| 397 | /** |
| 398 | * update internal plugin options |
| 399 | * |
| 400 | * @since 1.5.1 |
| 401 | * @param array $options new internal options |
| 402 | */ |
| 403 | public function update_internal_options( array $options ) { |
| 404 | // do not allow to clear options |
| 405 | if ( $options === array() ) { |
| 406 | return; |
| 407 | } |
| 408 | |
| 409 | $this->internal_options = $options; |
| 410 | update_option( ADVADS_SLUG . '-internal', $options ); |
| 411 | } |
| 412 | |
| 413 | /** |
| 414 | * get prefix used for frontend elements |
| 415 | * |
| 416 | * @since 1.6.8.2 |
| 417 | */ |
| 418 | public function get_frontend_prefix(){ |
| 419 | if ( ! $this->frontend_prefix ) { |
| 420 | $options = $this->options(); |
| 421 | |
| 422 | if ( ! isset( $options['front-prefix'] ) ) { |
| 423 | if ( isset( $options['id-prefix'] ) ) { |
| 424 | // deprecated: keeps widgets working that previously received an id based on the front-prefix |
| 425 | $this->frontend_prefix = esc_attr( $options['id-prefix'] ); |
| 426 | } else { |
| 427 | $host = parse_url( get_home_url(), PHP_URL_HOST ); |
| 428 | $this->frontend_prefix = preg_match( '/[A-Za-z][A-Za-z0-9_]{4}/', $host, $result ) ? $result[0] . '-' : Advanced_Ads_Plugin::DEFAULT_FRONTEND_PREFIX; |
| 429 | } |
| 430 | } else { |
| 431 | $this->frontend_prefix = $options['front-prefix']; |
| 432 | } |
| 433 | } |
| 434 | return $this->frontend_prefix; |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * get priority used for injection inside content |
| 439 | * |
| 440 | * @since 1.6.10.2 |
| 441 | */ |
| 442 | public function get_content_injection_priority(){ |
| 443 | $options = $this->options(); |
| 444 | |
| 445 | return isset( $options['content-injection-priority'] ) ? intval( $options['content-injection-priority'] ) : 100; |
| 446 | } |
| 447 | |
| 448 | /** |
| 449 | * returns the capability needed to perform an action |
| 450 | * |
| 451 | * @since 1.6.14 |
| 452 | * @param str $capability a capability to check, can be internal to Advanced Ads |
| 453 | * @return str $capability a valid WordPress capability |
| 454 | */ |
| 455 | public static function user_cap( $capability = 'manage_options' ){ |
| 456 | |
| 457 | global $advanced_ads_capabilities; |
| 458 | |
| 459 | // admins can do everything |
| 460 | // is also a fallback if no option or more specific capability is given |
| 461 | if( current_user_can( 'manage_options' ) ){ |
| 462 | return 'manage_options'; |
| 463 | } |
| 464 | |
| 465 | return apply_filters( 'advanced-ads-capability', $capability ); |
| 466 | |
| 467 | // check, if capability is mapped to an existing WP capability |
| 468 | /*if( isset( $advanced_ads_capabilities[ $capability ] ) ){ |
| 469 | return apply_filters( 'advanced-ads-capability', $advanced_ads_capabilities[ $capability ], $capability ); |
| 470 | } else { |
| 471 | // if not, use 'manage_posts' capability |
| 472 | return apply_filters( 'advanced-ads-capability', 'manage_options', $capability ); |
| 473 | }*/ |
| 474 | |
| 475 | } |
| 476 | |
| 477 | /** |
| 478 | * Create roles and capabilities |
| 479 | * |
| 480 | */ |
| 481 | public function create_capabilities() { |
| 482 | if ( $role = get_role( 'administrator' ) ) { |
| 483 | $role->add_cap( 'advanced_ads_manage_options' ); |
| 484 | $role->add_cap( 'advanced_ads_see_interface' ); |
| 485 | $role->add_cap( 'advanced_ads_edit_ads' ); |
| 486 | $role->add_cap( 'advanced_ads_manage_placements' ); |
| 487 | $role->add_cap( 'advanced_ads_place_ads' ); |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | /** |
| 492 | * Remove roles and capabilities |
| 493 | * |
| 494 | */ |
| 495 | public function remove_capabilities() { |
| 496 | if ( $role = get_role( 'administrator' ) ) { |
| 497 | $role->remove_cap( 'advanced_ads_manage_options' ); |
| 498 | $role->remove_cap( 'advanced_ads_see_interface' ); |
| 499 | $role->remove_cap( 'advanced_ads_edit_ads' ); |
| 500 | $role->remove_cap( 'advanced_ads_manage_placements' ); |
| 501 | $role->remove_cap( 'advanced_ads_place_ads' ); |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | /** |
| 506 | * Fired when the plugin is uninstalled. |
| 507 | */ |
| 508 | public static function uninstall() { |
| 509 | $advads_options = Advanced_Ads::get_instance()->options(); |
| 510 | |
| 511 | if ( ! empty( $advads_options['uninstall-delete-data'] ) ) { |
| 512 | global $wpdb; |
| 513 | $main_blog_id = $wpdb->blogid; |
| 514 | |
| 515 | Advanced_Ads::get_instance()->create_post_types(); |
| 516 | |
| 517 | if ( ! is_multisite() ) { |
| 518 | Advanced_Ads_Plugin::get_instance()->uninstall_single(); |
| 519 | } else { |
| 520 | $blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" ); |
| 521 | |
| 522 | foreach ( $blog_ids as $blog_id ) { |
| 523 | switch_to_blog( $blog_id ); |
| 524 | Advanced_Ads_Plugin::get_instance()->uninstall_single(); |
| 525 | } |
| 526 | switch_to_blog( $main_blog_id ); |
| 527 | } |
| 528 | |
| 529 | // Delete assets (main blog). |
| 530 | Advanced_Ads_Ad_Blocker_Admin::get_instance()->clear_assets(); |
| 531 | delete_option( ADVADS_AB_SLUG ); |
| 532 | } |
| 533 | |
| 534 | } |
| 535 | |
| 536 | /** |
| 537 | * Fired for each blog when the plugin is uninstalled. |
| 538 | * |
| 539 | */ |
| 540 | protected function uninstall_single() { |
| 541 | global $wpdb; |
| 542 | |
| 543 | // Ads. |
| 544 | $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s", Advanced_Ads::POST_TYPE_SLUG ) ); |
| 545 | |
| 546 | if ( $post_ids ) { |
| 547 | $wpdb->delete( |
| 548 | $wpdb->posts, |
| 549 | array( 'post_type' => Advanced_Ads::POST_TYPE_SLUG ), |
| 550 | array( '%s' ) |
| 551 | ); |
| 552 | |
| 553 | $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE post_id IN( " . implode( ',', $post_ids ) . " )" ); |
| 554 | } |
| 555 | |
| 556 | // Groups. |
| 557 | $term_ids = $wpdb->get_col( $wpdb->prepare( "SELECT t.term_id FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s", Advanced_Ads::AD_GROUP_TAXONOMY ) ); |
| 558 | |
| 559 | foreach ( $term_ids as $term_id ) { |
| 560 | wp_delete_term( $term_id, Advanced_Ads::AD_GROUP_TAXONOMY ); |
| 561 | } |
| 562 | |
| 563 | delete_option( 'advads-ad-groups' ); |
| 564 | delete_option( Advanced_Ads::AD_GROUP_TAXONOMY . '_children' ); |
| 565 | delete_option( 'advads-ad-weights' ); |
| 566 | |
| 567 | // Placements. |
| 568 | delete_option( 'advads-ads-placements' ); |
| 569 | |
| 570 | // User metadata. |
| 571 | delete_metadata( 'user', null, 'advanced-ads-hide-wizard', '', true ); |
| 572 | delete_metadata( 'user', null, 'advanced-ads-subscribed', '', true ); |
| 573 | |
| 574 | // Post metadata. |
| 575 | delete_metadata( 'post', null, '_advads_ad_settings', '', true ); |
| 576 | |
| 577 | // Transients. |
| 578 | delete_transient( ADVADS_SLUG . '_add-on-updates-checked' ); |
| 579 | |
| 580 | delete_option( GADSENSE_OPT_NAME ); |
| 581 | delete_option( ADVADS_SLUG ); |
| 582 | delete_option( ADVADS_SLUG . '-internal' ); |
| 583 | delete_option( ADVADS_SLUG . '-notices' ); |
| 584 | |
| 585 | // Widget. |
| 586 | $base_widget_id = Advanced_Ads_Widget::get_base_id(); |
| 587 | delete_option( 'widget_' . $base_widget_id ); |
| 588 | |
| 589 | do_action( 'advanced-ads-uninstall' ); |
| 590 | |
| 591 | wp_cache_flush(); |
| 592 | } |
| 593 | |
| 594 | } |
| 595 |