Ejemplo n.º 1
0
 /**
  * Display the options screen
  *
  * @return void
  **/
 function admin_options()
 {
     // Save
     if (isset($_POST['save']) && check_admin_referer('headspace-update_options')) {
         $options = $this->get_options();
         $options['inherit'] = isset($_POST['inherit']) ? true : false;
         $options['debug'] = isset($_POST['debug']) ? true : false;
         $options['excerpt'] = isset($_POST['excerpt']) ? true : false;
         update_option('headspace_options', $options);
         $this->render_message(__('Your options have been updated', 'headspace'));
     } else {
         if (isset($_POST['delete']) && check_admin_referer('headspace-delete_plugin')) {
             include dirname(__FILE__) . '/models/upgrade.php';
             HS_Upgrade::remove(__FILE__);
             $this->render_message(__('HeadSpace has been removed', 'headspace'));
         }
     }
     $this->render_admin('options', array('options' => $this->get_options()));
 }
Ejemplo n.º 2
0
 function upgrade($currentversion, $desiredversion)
 {
     global $wpdb;
     // From HeadSpace 2.X
     if ($currentversion == false) {
         // Convert very old post meta data
         $wpdb->query("UPDATE {$wpdb->postmeta} SET meta_key='_headspace_stylesheets' WHERE meta_key='head_style'");
         $wpdb->query("UPDATE {$wpdb->postmeta} SET meta_key='_headspace_scripts' WHERE meta_key='head_script'");
         $wpdb->query("UPDATE {$wpdb->postmeta} SET meta_key='_headspace_keywords' WHERE meta_key='head_keywords'");
         $wpdb->query("UPDATE {$wpdb->postmeta} SET meta_key='_headspace_description' WHERE meta_key='head_description'");
         $wpdb->query("UPDATE {$wpdb->postmeta} SET meta_key='_headspace_raw' WHERE meta_key='head_raw'");
         delete_option('headspace2');
     } else {
         if ($currentversion == 1) {
             // Convert 3.1 to 3.2
             $options = get_option('headspace_options');
             $main = array('inherit' => $options['inherit'] == 'true' ? true : false, 'updates' => $options['updates'] == 'true' ? true : false);
             update_option('headspace_options', $main);
             // Copy all keywords into dictionary, along with hotwords
             $hot = get_option('headspace_keywords');
             $rows = $wpdb->get_results("SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_headspace_keywords'");
             if ($rows) {
                 foreach ($rows as $row) {
                     $hot .= $row->meta_value . ',';
                 }
             }
             update_option('headspace_dictionary', HS_Upgrade::normalize_tags($hot));
             delete_option('headspace_keywords');
         }
     }
     if ($currentversion < 8) {
         //
         $available = get_declared_classes();
         $files = glob(dirname(__FILE__) . '/../modules/page/*.php');
         if (!empty($files)) {
             foreach ($files as $file) {
                 include_once $file;
             }
         }
         $available = array_diff(get_declared_classes(), $available);
         $options = get_option('headspace_options');
         if (count($options['advanced_modules']) > 0) {
             foreach ($options['advanced_modules'] as $name) {
                 $module = new $name();
                 $newadvanced[$module->file()] = $name;
             }
             $options['advanced_modules'] = $newadvanced;
         }
         if (count($options['simple_modules']) > 0) {
             $newsimple = array();
             foreach ($options['simple_modules'] as $name) {
                 $module = new $name();
                 $newsimple[$module->file()] = $name;
             }
             $options['simple_modules'] = $newsimple;
         }
         if (count($options['site_modules']) > 0) {
             $newsimple = array();
             foreach ($options['site_modules'] as $name) {
                 if (class_exists($name)) {
                     $module = new $name();
                     $newsimple[$module->file()] = $name;
                 }
             }
             $options['site_modules'] = $newsimple;
         }
         update_option('headspace_options', $options);
     }
     if ($currentversion < 10) {
         // Copy posts details to page details
         update_option('headspace_page', get_option('headspace_post'));
     }
     update_option('headspace_version', $desiredversion);
 }