public function include_required_scripts()
 {
     $screen_id = foo_current_screen_id();
     //only include scripts if we on the foogallery add/edit page
     if (FOOGALLERY_CPT_GALLERY === $screen_id || 'edit-' . FOOGALLERY_CPT_GALLERY === $screen_id) {
         //spectrum needed for the colorpicker field
         $url = FOOGALLERY_URL . 'lib/spectrum/spectrum.js';
         wp_enqueue_script('foogallery-spectrum', $url, array('jquery'), FOOGALLERY_VERSION);
         $url = FOOGALLERY_URL . 'lib/spectrum/spectrum.css';
         wp_enqueue_style('foogallery-spectrum', $url, array(), FOOGALLERY_VERSION);
         //include any admin js required for the templates
         foreach (foogallery_gallery_templates() as $template) {
             $admin_js = foo_safe_get($template, 'admin_js');
             if ($admin_js) {
                 wp_enqueue_script('foogallery-gallery-admin-' . $template['slug'], $admin_js, array('jquery', 'media-upload', 'jquery-ui-sortable'), FOOGALLERY_VERSION);
             }
         }
     }
 }
 public function include_required_scripts()
 {
     //only include scripts if we on the foogallery page
     if (FOOGALLERY_CPT_GALLERY === foo_current_screen_post_type()) {
         //zeroclipboard needed for copy to clipboard functionality
         $url = FOOGALLERY_URL . 'lib/zeroclipboard/ZeroClipboard.min.js';
         wp_enqueue_script('foogallery-zeroclipboard', $url, array('jquery'), FOOGALLERY_VERSION);
         //spectrum needed for the colorpicker field
         $url = FOOGALLERY_URL . 'lib/spectrum/spectrum.js';
         wp_enqueue_script('foogallery-spectrum', $url, array('jquery'), FOOGALLERY_VERSION);
         $url = FOOGALLERY_URL . 'lib/spectrum/spectrum.css';
         wp_enqueue_style('foogallery-spectrum', $url, array(), FOOGALLERY_VERSION);
         //include any admin js required for the templates
         foreach (foogallery_gallery_templates() as $template) {
             $admin_js = foo_safe_get($template, 'admin_js');
             if ($admin_js) {
                 wp_enqueue_script('foogallery-gallery-admin-' . $template['slug'], $admin_js, array('jquery'), FOOGALLERY_VERSION);
             }
         }
     }
 }
Esempio n. 3
0
 /**
  * @TODO
  */
 public function auto_activate_extensions()
 {
     foreach ($this->get_all() as $extension) {
         if (true === foo_safe_get($extension, 'activated_by_default')) {
             //check to see if the extension is downloaded
             if ($this->is_downloaded($extension)) {
                 $this->add_to_activated_extensions($extension);
             }
         }
     }
 }
Esempio n. 4
0
 function add_settings($settings = false)
 {
     if (!is_array($settings) || !array_key_exists('settings', $settings)) {
         return;
     }
     foreach ($settings['settings'] as $setting) {
         //add a tab if needed
         $tab_id = foo_safe_get($setting, 'tab', false);
         if ($tab_id !== false && !$this->has_tab($tab_id) && array_key_exists('tabs', $settings) && array_key_exists($tab_id, $settings['tabs'])) {
             $tab = $settings['tabs'][$tab_id];
             $this->add_tab($tab_id, $tab);
         }
         //add a section if needed
         $section_id = foo_safe_get($setting, 'section', false);
         if ($section_id !== false && !$this->has_section($section_id) && array_key_exists('sections', $settings) && array_key_exists($section_id, $settings['sections'])) {
             $section = $settings['sections'][$section_id];
             $this->add_section_to_tab($tab_id, $section_id, $section['name']);
         }
         $this->add_setting($setting);
     }
 }
Esempio n. 5
0
 /**
  * Safely get a value from the global $_REQUEST array
  *
  * @param string $key     The key of the item within the array.
  * @param mixed  $default The default value toi return if the value is not found in the array.
  *
  * @return mixed
  */
 function safe_get_from_request($key, $default = null)
 {
     return foo_safe_get($_REQUEST, $key, $default);
 }