public function screen() { $status = 'available'; if (!is_dir($this->theme_path)) { $status = 'directory'; } else { if (!is_writable($this->theme_path)) { $status = 'permissions'; } else { $builtin = array_filter(scandir($this->template_path), 'filter_dotfiles'); $theme = array_filter(scandir($this->theme_path), 'filter_dotfiles'); if (empty($theme)) { $status = 'ready'; } elseif (array_diff($builtin, $theme)) { $status = 'incomplete'; } } } $category_views = array('grid' => Shopp::__('Grid'), 'list' => Shopp::__('List')); $row_products = array(2, 3, 4, 5, 6, 7); $productOrderOptions = ProductCategory::sortoptions(); $productOrderOptions['custom'] = Shopp::__('Custom'); $orderOptions = array('ASC' => Shopp::__('Order'), 'DESC' => Shopp::__('Reverse Order'), 'RAND' => Shopp::__('Shuffle')); $orderBy = array('sortorder' => Shopp::__('Custom arrangement'), 'created' => Shopp::__('Upload date')); include $this->ui('presentation.php'); }
public function presentation() { if (!current_user_can('shopp_settings_presentation')) { wp_die(__('You do not have sufficient permissions to access this page.')); } $builtin_path = SHOPP_PATH . '/templates'; $theme_path = sanitize_path(STYLESHEETPATH . '/shopp'); $term_recount = false; if (!empty($_POST['save'])) { check_admin_referer('shopp-settings-presentation'); $updated = __('Shopp presentation settings saved.', 'Shopp'); if (isset($_POST['settings']['theme_templates']) && $_POST['settings']['theme_templates'] == 'on' && !is_dir($theme_path)) { $_POST['settings']['theme_templates'] = 'off'; $updated = __('Shopp theme templates can\'t be used because they don\'t exist.', 'Shopp'); } if (empty($_POST['settings']['catalog_pagination'])) { $_POST['settings']['catalog_pagination'] = 0; } // Recount terms when this setting changes if (isset($_POST['settings']['outofstock_catalog']) && $_POST['settings']['outofstock_catalog'] != shopp_setting('outofstock_catalog')) { $term_recount = true; } shopp_set_formsettings(); $this->notice(Shopp::__('Presentation settings saved.'), 'notice', 20); } if ($term_recount) { $taxonomy = ProductCategory::$taxon; $terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids')); if (!empty($terms)) { wp_update_term_count_now($terms, $taxonomy); } } // Copy templates to the current WordPress theme if (!empty($_POST['install'])) { check_admin_referer('shopp-settings-presentation'); copy_shopp_templates($builtin_path, $theme_path); } $status = 'available'; if (!is_dir($theme_path)) { $status = 'directory'; } else { if (!is_writable($theme_path)) { $status = 'permissions'; } else { $builtin = array_filter(scandir($builtin_path), 'filter_dotfiles'); $theme = array_filter(scandir($theme_path), 'filter_dotfiles'); if (empty($theme)) { $status = 'ready'; } else { if (array_diff($builtin, $theme)) { $status = 'incomplete'; } } } } $category_views = array('grid' => __('Grid', 'Shopp'), 'list' => __('List', 'Shopp')); $row_products = array(2, 3, 4, 5, 6, 7); $productOrderOptions = ProductCategory::sortoptions(); $productOrderOptions['custom'] = __('Custom', 'Shopp'); $orderOptions = array('ASC' => __('Order', 'Shopp'), 'DESC' => __('Reverse Order', 'Shopp'), 'RAND' => __('Shuffle', 'Shopp')); $orderBy = array('sortorder' => __('Custom arrangement', 'Shopp'), 'created' => __('Upload date', 'Shopp')); include $this->ui('presentation.php'); }
/** * Provides markup for a category sort order selection widget * * The widget can be a drop-down menu or an unordered list of links * * @api `shopp('storefront.orderby-list')` * @since 1.0 * * @param string $result The output * @param array $options The options * @param ShoppStorefront $O The working object * @return string The order-by markup **/ public static function orderby_list($result, $options, $O) { $Collection = ShoppCollection(); $Storefront = ShoppStorefront(); // Some internals can suppress this control if (isset($Collection->controls)) { return false; } if (isset($Collection->loading['order']) || isset($Collection->loading['sortorder'])) { return false; } $defaultsort = array('title', shopp_setting('default_product_order'), isset($Storefront->browsing['sortorder']) ? $Storefront->browsing['sortorder'] : false); foreach ($defaultsort as $setting) { if (!empty($setting)) { $default = $setting; } } // Setup defaults $options = wp_parse_args($options, array('dropdown' => false, 'default' => $default, 'title' => '', 'class' => '')); extract($options, EXTR_SKIP); // Get the sort option labels $menuoptions = ProductCategory::sortoptions(); // Don't show custom product order for smart categories if ($Collection->smart) { unset($menuoptions['custom']); } $_ = array(); $request = $_SERVER['REQUEST_URI']; if (Shopp::str_true($dropdown)) { $_[] = $title; $_[] = '<form action="' . esc_url($request) . '" method="get" id="shopp-' . $Collection->slug . '-orderby-menu">'; if ('' == get_option('permalink_structure')) { foreach ($_GET as $key => $value) { if ('sort' != $key) { $_[] = '<input type="hidden" name="' . $key . '" value="' . $value . '" />'; } } } $_[] = '<select name="sort" class="shopp-orderby-menu ' . esc_attr($class) . '">'; $_[] = menuoptions($menuoptions, $default, true); $_[] = '</select>'; $_[] = '</form>'; } else { foreach ($menuoptions as $value => $label) { $href = esc_url(add_query_arg(array('sort' => $value), $request)); $class = $default == $value ? ' class="current"' : ''; $_[] = '<li><a href="' . $href . '"' . $class . '>' . $label . '</a></li>'; } } return join('', $_); }