class-ad-type-adsense.php
8 years ago
class-gadsense-data.php
8 years ago
class-mapi.php
8 years ago
class-gadsense-data.php
79 lines
| 1 | <?php |
| 2 | |
| 3 | class Advanced_Ads_AdSense_Data { |
| 4 | |
| 5 | private static $instance; |
| 6 | private $options; |
| 7 | private $resizing; |
| 8 | |
| 9 | private function __construct() { |
| 10 | |
| 11 | $options = get_option(GADSENSE_OPT_NAME, array()); |
| 12 | |
| 13 | // set defaults |
| 14 | if (!isset($options['adsense-id'])) { |
| 15 | |
| 16 | $options['adsense-id'] = ''; |
| 17 | // starting version 1.7.9, the default limit setting was changed from true to false due to AdSense policy change |
| 18 | $options['limit-per-page'] = false; |
| 19 | |
| 20 | update_option(GADSENSE_OPT_NAME, $options); |
| 21 | } |
| 22 | |
| 23 | if (!isset($options['limit-per-page'])) { |
| 24 | // starting version 1.7.9, the default limit setting was changed from true to false due to AdSense policy change |
| 25 | $options['limit-per-page'] = false; |
| 26 | } |
| 27 | |
| 28 | if (!isset($options['page-level-enabled'])) { |
| 29 | $options['page-level-enabled'] = false; |
| 30 | |
| 31 | } |
| 32 | if ( ! isset( $options['background'] ) ) { |
| 33 | $options['background'] = false; |
| 34 | } |
| 35 | |
| 36 | $this->options = $options; |
| 37 | |
| 38 | // Resizing method for responsive ads |
| 39 | $this->resizing = array( |
| 40 | 'auto' => __('Auto', 'advanced-ads'), |
| 41 | ); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * GETTERS |
| 46 | */ |
| 47 | public function get_options() { |
| 48 | return $this->options; |
| 49 | } |
| 50 | |
| 51 | public function get_adsense_id() { |
| 52 | return trim($this->options['adsense-id']); |
| 53 | } |
| 54 | |
| 55 | public function get_limit_per_page() { |
| 56 | return $this->options['limit-per-page']; |
| 57 | } |
| 58 | |
| 59 | public function get_responsive_sizing() { |
| 60 | $resizing = $this->resizing; |
| 61 | $this->resizing = apply_filters('advanced-ads-gadsense-responsive-sizing', $resizing); |
| 62 | return $this->resizing; |
| 63 | } |
| 64 | |
| 65 | public static function get_instance() { |
| 66 | if (null == self::$instance) { |
| 67 | self::$instance = new self; |
| 68 | } |
| 69 | return self::$instance; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * ISSERS/HASSERS |
| 74 | */ |
| 75 | public function is_page_level_enabled() { |
| 76 | return $this->options['page-level-enabled']; |
| 77 | } |
| 78 | } |
| 79 |