示例#1
0
 static function getOptions($optionset = "", $provider = "AdSense")
 {
     $allOptions = self::getAllOptions();
     global $wpdb;
     $table = $wpdb->prefix . "ez_adsense_options";
     if (empty($optionset)) {
         if (is_admin()) {
             $optionset = self::getGenOption('editing');
         } else {
             $optionset = self::getGenOption('optionset');
         }
     }
     if (empty($optionset)) {
         $optionset = "Default";
         self::setOptionset($optionset);
     }
     $plugin_slug = self::getSlug();
     $lookup = array('google-adsense' => 'Google AdSense', 'easy-adsense' => 'Easy AdSense', 'adsense-now' => 'AdSense Now!');
     $plugin = $lookup[$plugin_slug];
     $theme = get_option('stylesheet');
     self::putGenOption('theme', $theme);
     $sql = "SELECT name,value FROM {$table} WHERE plugin_slug='{$plugin_slug}' AND theme='{$theme}' AND provider='{$provider}' AND optionset='{$optionset}'";
     $rows = $wpdb->get_results($sql);
     $defaultText = 'Please generate and paste your ad code here. If left empty, the ad location will be highlighted on your blog pages with a reminder to enter your code.';
     $options = compact('plugin', 'theme', 'provider', 'optionset', 'plugin_slug', 'defaultText');
     foreach ($rows as $row) {
         $options[$row->name] = $row->value;
     }
     self::$options = $options = array_merge($allOptions, $options);
     require "admin/{$plugin_slug}-options.php";
     $defaults = EzGA::getDefaults($ezOptions);
     self::$options = $options = array_merge($defaults, $options);
     return $options;
 }