Exemple #1
0
 /**
  * Enqueue registered admin JS scripts and CSS styles.
  */
 public function enqueue_admin_scripts($hook)
 {
     if (!$this->condition()) {
         return;
     }
     wp_enqueue_script($this->args['page_slug'], _appthemes_get_addons_mp_args('url') . '/js/scripts.js', array('jquery'), '1.0');
     wp_enqueue_style($this->args['page_slug'], _appthemes_get_addons_mp_args('url') . '/css/styles.css', array(), '1.0');
 }
Exemple #2
0
 /**
  * Retrieves the requested user selected filters values, if any.
  * Otherwise, assigns default selected filter values for each filter that contains only a single value.
  *
  * e.g:
  *	 - categories => array( 'plugins' ); // in this case, since the categories filter
  *										    only has one possible value, select it by default
  *
  * @return array An associative array of selected filter/values.
  */
 public function get_filter_by()
 {
     $active_theme = _appthemes_get_addons_mp_args('theme');
     $active_theme = array_pop($active_theme);
     $filters = $this->get_filter_list();
     $filter_by = wp_parse_args($_GET, $filters);
     // make sure the 'filter_by' only contains valid filter keys
     $filter_by = array_intersect_key($filter_by, $filters);
     // iterate through the valid filters and try assign a default value if none selected
     foreach ($filter_by as $filter => $values) {
         if (!$values) {
             // user selected 'All' - show all results for this filter
             unset($filter_by[$filter]);
         } elseif (!is_array($values)) {
             // user selected a value for this filter
             continue;
         } else {
             // user didn't select a value - find a possible default value or default to 'All'
             // get rid of the empty array keys to have a real count of this filter values
             $values = array_filter(array_keys($values), 'strlen');
             if (count($values) > 1) {
                 // default to the active theme if available on the filter list of values
                 if ('theme' == $filter && $active_theme && isset($filters[$filter][$active_theme])) {
                     $filter_by[$filter] = $active_theme;
                 } else {
                     // default to 'All' - show all results for this filter
                     unset($filter_by[$filter]);
                 }
             } else {
                 // one value only filter (use it as the default value if none other requested in '$_GET')
                 $filter_by[$filter] = reset($values);
             }
         }
     }
     return $filter_by;
 }
Exemple #3
0
/**
 * Retrieves the marketplace page options for a given menu page slug.
 *
 * @param string $page_slug The mp page slug.
 * @param string $option (optional) The mp option to retrieve values from.
 * @return mixed A single value if an option is given, or a list of options/values.
 *               False, if the option is invalid.
 */
function _appthemes_get_addons_mp_page_args($page_slug, $option = '')
{
    $marketplace = _appthemes_get_addons_mp_args('mp');
    if (empty($marketplace[$page_slug])) {
        return false;
    }
    if (empty($option)) {
        return $marketplace[$page_slug];
    } elseif (isset($marketplace[$page_slug][$option])) {
        return $marketplace[$page_slug][$option];
    } else {
        return false;
    }
}