コード例 #1
0
ファイル: class-fscf-util.php プロジェクト: kipraske/site2014
 static function update_options_version()
 {
     // Updates the global and form options table entries if necessary
     // Called on plugin activation if global options exist
     if (version_compare(FSCF_VERSION, self::$global_options['fscf_version'], '>')) {
         // Update the global options
         // Unset any removed global options here:
         //
         if (version_compare(self::$global_options['fscf_version'], '4.0', '<')) {
             // this is where you can run code on a specific version increase specified above
         }
         // Merge in global defaults in case there are new global options entries
         if (!isset(self::$global_defaults)) {
             self::set_defaults();
         }
         self::$global_options = array_merge(self::$global_defaults, self::$global_options);
         self::$global_options['fscf_version'] = FSCF_VERSION;
         update_option('fs_contact_global', self::$global_options);
         // Update the form options
         foreach (self::$global_options['form_list'] as $key => $form) {
             self::$form_options = get_option('fs_contact_form' . $key);
             if (self::$form_options) {
                 self::$form_options = array_merge(self::$form_defaults, self::$form_options);
                 // Note: any deleted form options will be removed the next time the form is saved
                 // Update the field arrays
                 foreach (self::$form_options['fields'] as $k => $fld) {
                     self::$form_options['fields'][$k] = array_merge(self::$field_defaults, $fld);
                 }
                 update_option('fs_contact_form' . $key, self::$form_options);
             }
         }
         // end outer foreach
     }
 }