/** * Add plugin options to Cherry options page * * @since 1.0.0 * @param array $sections existing section array. * @return array */ public function add_options($sections) { if (!defined('PARENT_URI')) { return $sections; } $menus = wp_get_nav_menus(array('orderby' => 'name')); $options_menus = array('0' => __('Select menu', 'cherry-woocommerce-package')); foreach ($menus as $menu) { $options_menus[$menu->term_id] = $menu->name; } $shop_options = array('shop-per-page' => array('type' => 'stepper', 'title' => __('Products per page', 'cherry-woocommerce-package'), 'label' => '', 'description' => __('Set a number of products per shop page.', 'cherry-woocommerce-package'), 'value' => '8', 'step_value' => '1', 'max_value' => '40', 'min_value' => '1'), 'shop-per-cat-page' => array('type' => 'stepper', 'title' => __('Products per category page', 'cherry-woocommerce-package'), 'label' => '', 'description' => __('Set a number of products per category page.', 'cherry-woocommerce-package'), 'value' => '9', 'step_value' => '1', 'max_value' => '40', 'min_value' => '1'), 'shop-show-acc' => array('type' => 'switcher', 'title' => __('Show account dropdown', 'cherry-woocommerce-package'), 'label' => '', 'hint' => array('type' => 'text', 'content' => __('Show/hide account dropdown static content', 'cherry-woocommerce-package')), 'value' => 'true'), 'shop-not-logged-label' => array('type' => 'text', 'title' => __('Guests account menu label', 'cherry-woocommerce-package'), 'label' => '', 'hint' => array('type' => 'text', 'content' => __('Set label for account drop down for not logged in users', 'cherry-woocommerce-package')), 'value' => __('My Account', 'cherry-woocommerce-package')), 'shop-logged-label' => array('type' => 'text', 'title' => __('Members account menu label', 'cherry-woocommerce-package'), 'label' => '', 'hint' => array('type' => 'text', 'content' => __('Set label for account drop down for logged in users', 'cherry-woocommerce-package')), 'value' => __('My Account', 'cherry-woocommerce-package')), 'shop-acc-menu' => array('type' => 'select', 'title' => __('Menu to show in account dropdown', 'cherry'), 'label' => '', 'hint' => array('type' => 'text', 'content' => __('Select navigation menu to show it in account dropdown', 'cherry-woocommerce-package')), 'value' => '', 'options' => $options_menus), 'shop-show-auth' => array('type' => 'switcher', 'title' => __('Login/out links in account menu', 'cherry-woocommerce-package'), 'label' => '', 'hint' => array('type' => 'text', 'content' => __('Show/hide authentication links in account dropdown', 'cherry-woocommerce-package')), 'value' => 'true'), 'shop-login-label' => array('type' => 'text', 'title' => __('Log in link label', 'cherry-woocommerce-package'), 'label' => '', 'hint' => array('type' => 'text', 'content' => __('Set label for log in/register link in account drop down', 'cherry-woocommerce-package')), 'value' => __('Log In/Register', 'cherry-woocommerce-package')), 'shop-logout-label' => array('type' => 'text', 'title' => __('Logout link label', 'cherry-woocommerce-package'), 'label' => '', 'hint' => array('type' => 'text', 'content' => __('Set label for log out link in account drop down', 'cherry-woocommerce-package')), 'value' => __('Logout', 'cherry-woocommerce-package'))); $sidebars = $this->get_sidebars(); $frontend_hooks = Cherry_WC_Frontend_Hooks::get_instance(); $default_sidebar = $frontend_hooks->shop_sidebar_id; $shop_layout = array('shop-loop-layout' => array('type' => 'radio', 'title' => __('Main shop page layout', 'cherry-woocommerce-package'), 'hint' => array('type' => 'text', 'content' => __('You can choose if you want to display sidebars and how you want to display them.', 'cherry-woocommerce-package')), 'value' => 'no-sidebar', 'display_input' => false, 'options' => array('sidebar-content' => array('label' => __('Left sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-left-sidebar.svg'), 'content-sidebar' => array('label' => __('Right sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-right-sidebar.svg'), 'sidebar-content-sidebar' => array('label' => __('Left and right sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-both-sidebar.svg'), 'sidebar-sidebar-content' => array('label' => __('Two sidebars on the left', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-sameside-left-sidebar.svg'), 'content-sidebar-sidebar' => array('label' => __('Two sidebars on the right', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-sameside-right-sidebar.svg'), 'no-sidebar' => array('label' => __('No sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-fullwidth.svg'))), 'shop-category-layout' => array('type' => 'radio', 'title' => __('Product categories and tags layout', 'cherry-woocommerce-package'), 'hint' => array('type' => 'text', 'content' => __('You can choose if you want to display sidebars and how you want to display them.', 'cherry-woocommerce-package')), 'value' => 'sidebar-content', 'display_input' => false, 'options' => array('sidebar-content' => array('label' => __('Left sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-left-sidebar.svg'), 'content-sidebar' => array('label' => __('Right sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-right-sidebar.svg'), 'sidebar-content-sidebar' => array('label' => __('Left and right sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-both-sidebar.svg'), 'sidebar-sidebar-content' => array('label' => __('Two sidebars on the left', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-sameside-left-sidebar.svg'), 'content-sidebar-sidebar' => array('label' => __('Two sidebars on the right', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-sameside-right-sidebar.svg'), 'no-sidebar' => array('label' => __('No sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-fullwidth.svg'))), 'shop-single-layout' => array('type' => 'radio', 'title' => __('Single page layout', 'cherry-woocommerce-package'), 'hint' => array('type' => 'text', 'content' => __('You can choose if you want to display sidebars and how you want to display them.', 'cherry-woocommerce-package')), 'value' => 'no-sidebar', 'display_input' => false, 'options' => array('sidebar-content' => array('label' => __('Left sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-left-sidebar.svg'), 'content-sidebar' => array('label' => __('Right sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-right-sidebar.svg'), 'sidebar-content-sidebar' => array('label' => __('Left and right sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-both-sidebar.svg'), 'sidebar-sidebar-content' => array('label' => __('Two sidebars on the left', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-sameside-left-sidebar.svg'), 'content-sidebar-sidebar' => array('label' => __('Two sidebars on the right', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-sameside-right-sidebar.svg'), 'no-sidebar' => array('label' => __('No sidebar', 'cherry-woocommerce-package'), 'img_src' => PARENT_URI . '/lib/admin/assets/images/svg/page-layout-fullwidth.svg'))), 'shop-loop-sidebar' => array('type' => 'select', 'title' => __('Main sidebar for shop page', 'cherry-woocommerce-package'), 'label' => '', 'hint' => array('type' => 'text', 'content' => __('Select main sidebar to show on shop page', 'cherry-woocommerce-package')), 'value' => $default_sidebar, 'options' => $sidebars), 'shop-category-sidebar' => array('type' => 'select', 'title' => __('Main sidebar for shop category and tags pages', 'cherry-woocommerce-package'), 'label' => '', 'hint' => array('type' => 'text', 'content' => __('Select main sidebar to show it on category and tags pages', 'cherry-woocommerce-package')), 'value' => $default_sidebar, 'options' => $sidebars), 'shop-single-sidebar' => array('type' => 'select', 'title' => __('Main sidebar for single product page', 'cherry-woocommerce-package'), 'label' => '', 'hint' => array('type' => 'text', 'content' => __('Select main sidebar to show it on single product page', 'cherry-woocommerce-package')), 'value' => $default_sidebar, 'options' => $sidebars)); $sections['shop-section'] = array('name' => __('Shop', 'cherry-woocommerce-package'), 'icon' => 'dashicons dashicons-cart', 'priority' => 105, 'options-list' => apply_filters('cherry_wc_package_shop_options_list', $shop_options)); $sections['shop-layout-subsection'] = array('name' => __('Layout', 'cherry-woocommerce-package'), 'parent' => 'shop-section', 'icon' => 'dashicons dashicons-arrow-right', 'priority' => 110, 'options-list' => apply_filters('cherry_wc_package_shop_layout_options_list', $shop_layout)); return $sections; }
* @param string $layout layout type. * @return string */ public function shop_page_layouts($layout) { if (is_shop()) { $layout = cherry_wc_options()->get_option('shop-loop-layout', 'no-sidebar'); } elseif (is_product_taxonomy()) { $layout = cherry_wc_options()->get_option('shop-category-layout', 'no-sidebar'); } elseif (is_singular('product')) { $layout = cherry_wc_options()->get_option('shop-single-layout', 'no-sidebar'); } return $layout; } /** * Returns the instance. * * @since 1.0.0 * @return object */ public static function get_instance() { // If the single instance hasn't been set, set it now. if (null == self::$instance) { self::$instance = new self(); } return self::$instance; } } Cherry_WC_Frontend_Hooks::get_instance(); }