Ejemplo n.º 1
0
 /**
  * Sets the default options.
  *
  * @since 3.0.0
  */
 public static function create_options()
 {
     $default = '';
     $page = 'settings';
     $settings_pages = new Pages($page);
     $plugin_settings = $settings_pages->get_settings();
     if ($plugin_settings && is_array($plugin_settings)) {
         foreach ($plugin_settings as $id => $settings) {
             $group = 'simple-calendar_' . $page . '_' . $id;
             if (isset($settings['sections'])) {
                 if ($settings['sections'] && is_array($settings['sections'])) {
                     foreach ($settings['sections'] as $section_id => $section) {
                         if (isset($section['fields'])) {
                             if ($section['fields'] && is_array($section['fields'])) {
                                 foreach ($section['fields'] as $key => $field) {
                                     if (isset($field['type'])) {
                                         // Maybe an associative array.
                                         if (is_int($key)) {
                                             $default[$section_id] = self::get_field_default_value($field);
                                         } else {
                                             $default[$section_id][$key] = self::get_field_default_value($field);
                                         }
                                     }
                                 }
                                 // Loop fields.
                             }
                             // Are fields non empty?
                         }
                         // Are there fields?
                     }
                     // Loop fields sections.
                 }
                 // Are sections non empty?
             }
             // Are there sections?
             add_option($group, $default, '', true);
             // Reset before looping next settings page.
             $default = '';
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Register plugin settings.
  *
  * @since 3.0.0
  */
 public function register_settings()
 {
     if (is_admin() && !defined('DOING_AJAX')) {
         $settings = new Admin\Pages();
         $settings->register_settings($settings->get_settings());
     }
 }