Esempio n. 1
0
 function add_setting($args = array())
 {
     $defaults = array('id' => 'default_field', 'title' => 'Default Field', 'desc' => '', 'default' => '', 'placeholder' => '', 'type' => 'text', 'section' => '', 'choices' => array(), 'class' => '', 'tab' => '');
     //only declare up front so no debug warnings are shown
     $title = $type = $id = $desc = $default = $placeholder = $choices = $class = $section = $tab = null;
     extract(wp_parse_args($args, $defaults));
     $field_args = array('type' => $type, 'id' => $id, 'desc' => $desc, 'default' => $default, 'placeholder' => $placeholder, 'choices' => $choices, 'label_for' => $id, 'class' => $class);
     if (count($this->_settings) == 0) {
         //only do this once
         register_setting($this->plugin_slug, $this->plugin_slug, array($this, 'validate'));
     }
     $this->_settings[] = $args;
     $section_id = foo_convert_to_key($section);
     //check we have the tab
     if (!empty($tab)) {
         $tab_id = foo_convert_to_key($tab);
         //add the tab
         $this->add_tab($tab_id, foo_title_case($tab));
         //add the section
         $section_id = $this->add_section_to_tab($tab_id, $section_id, foo_title_case($section));
     } else {
         //just add the section
         $this->add_section($section_id, foo_title_case($section));
     }
     do_action($this->plugin_slug . '_admin_settings_before_setting', $args);
     //add the setting!
     add_settings_field($id, $title, array($this, 'render'), $this->plugin_slug, $section_id, $field_args);
     do_action($this->plugin_slug . '_admin_settings_after_setting', $args);
 }
Esempio n. 2
0
 }
 if ($downloaded && $api->is_active($slug)) {
     $classes .= ' activated';
 }
 if ($api->has_errors($slug)) {
     $classes .= ' has_error';
 }
 $tag_html = '';
 if (isset($extension['tags'])) {
     foreach ($extension['tags'] as $tag) {
         $classes .= ' ' . $tag;
         $tag_html .= '<span class="tag ' . $tag . '">' . $tag . '</span>';
     }
 }
 foreach ($extension['categories'] as $category) {
     $classes .= ' ' . foo_convert_to_key($category);
 }
 if (isset($extension['css_class'])) {
     $classes .= ' ' . $extension['css_class'];
 }
 $thumbnail = $extension['thumbnail'];
 if (foo_starts_with($thumbnail, '/')) {
     $thumbnail = rtrim(FOOGALLERY_URL, '/') . $thumbnail;
 }
 $base_url = add_query_arg('extension', $slug);
 $download_url = add_query_arg('action', 'download', $base_url);
 $activate_url = add_query_arg('action', 'activate', $base_url);
 $deactivate_url = add_query_arg('action', 'deactivate', $base_url);
 $download_button_html = '';
 //check if we want to override the download button
 if (isset($extension['download_button'])) {
Esempio n. 3
0
 /**
  * Returns a distinct array of categories that are used in the extensions
  * @return mixed
  */
 function get_all_categories()
 {
     $categories['all'] = array('name' => __('All', 'foogallery'));
     $categories['activated'] = array('name' => __('Active', 'foogallery'));
     $active = 0;
     foreach ($this->get_all() as $extension) {
         if ($this->is_active($extension['slug'])) {
             $active++;
         }
         $category_names = $extension['categories'];
         foreach ($category_names as $category_name) {
             $category_slug = foo_convert_to_key($category_name);
             if (!array_key_exists($category_slug, $categories)) {
                 $categories[$category_slug] = array('name' => $category_name);
             }
         }
     }
     $categories['build_your_own'] = array('name' => __('Build Your Own', 'foogallery'));
     return apply_filters('foogallery_extension_categories', $categories);
 }