/** * Add new menu items to the WordPress Toolbar / Admin Bar. * * @since 1.0.0 * * @uses ddw_wcaba_woocommerce_current() To detect current WooCommerce version branch. * * @global mixed $wp_admin_bar */ function ddw_woocommerce_aba_admin_bar_menu() { global $wp_admin_bar; /** * Allows for filtering the general user capability to see main & sub-level items * * Default capability: 'manage_woocommerce' (set by WooCommerce plugin itself!) */ $wcaba_filter_capability = apply_filters('wcaba_filter_capability_all', 'manage_woocommerce'); /** * Required WooCommerce/ WordPress cabability to display new admin bar entry * Only showing items if toolbar / admin bar is activated and user is logged in! */ if (!is_user_logged_in() || !is_admin_bar_showing() || !current_user_can($wcaba_filter_capability) || defined('WCABA_DISPLAY') && !WCABA_DISPLAY) { return; } // end if /** Set unique prefix */ $prefix = 'ddw-woocommerce-'; /** Create parent menu item references */ $woocommercebar = $prefix . 'admin-bar'; // root level $support = $prefix . 'wcsupport'; // sub level: support $wcdocs = $prefix . 'wcdocs'; // sub level: wc docs $woocommercesites = $prefix . 'woocommercesites'; // sub level: wc sites $settings = $prefix . 'settings'; // sub level: settings $sgeneralsettings = $prefix . 'sgeneralsettings'; // third level: general settings / wc status $semails = $prefix . 'semails'; // third level: general settings / emails $settingsintegration = $prefix . 'settingsintegration'; // third level: integration(s) $s_dynpricing = $prefix . 's_dynpricing'; // third level settings: dynamic pricing $s_commissionking = $prefix . 's_commissionking'; // third level settings: comission king $products = $prefix . 'products'; // sub level: products $p_compareproductslite = $prefix . 'p_compareproductslite'; // third level products: compare products lite $p_compareproductspro = $prefix . 'p_compareproductspro'; // third level products: compare products pro $p_csvimportsuite = $prefix . 'p_csvimportsuite'; // third level products: csv import suite $coupons = $prefix . 'coupons'; // sub level: coupons $orders = $prefix . 'orders'; // sub level: orders $reports = $prefix . 'reports'; // sub level: reports $reportssales = $prefix . 'reportssales'; // third level: reports sales $reportsproducts = $prefix . 'reportsproducts'; // third level: reports products $reportscategories = $prefix . 'reportscategories'; // third level: reports categories $reportscoupons = $prefix . 'reportscoupons'; // third level: reports coupons $reportscustomers = $prefix . 'reportscustomers'; // third level: reports customers $reportsstock = $prefix . 'reportsstock'; // third level: reports stock $shoplink = $prefix . 'shoplink'; // sub level: shop link $shoplinkcheckout = $prefix . 'shoplinkcheckout'; // third level: shop link checkout $shoplinkmyaccount = $prefix . 'shoplinkmyaccount'; // third level: shop link my account $shoplinkde = $prefix . 'shoplinkde'; // third level: shop link german extension $extensions = $prefix . 'extensions'; // sub level: extensions $extpideal = $prefix . 'extpideal'; // third level plugin ext.: pronamic ideal $extwtsoftwareaddon = $prefix . 'extwtsoftwareaddon'; // third level plugin ext.: software add-on $extwtdynpricing = $prefix . 'extwtdynpricing'; // third level plugin ext.: dynamic pricing $extwtcommissionking = $prefix . 'extwtcommissionking'; // third level plugin ext.: comission king $extwtclickatellsms = $prefix . 'extwtclickatellsms'; // third level plugin ext.: clickatell sms $extwtquickbooks = $prefix . 'extwtquickbooks'; // third level plugin ext.: quickbooks $extwccplite = $prefix . 'extwccplite'; // third level plugin ext.: compare products lite $extwccppro = $prefix . 'extwccppro'; // third level plugin ext.: compare products pro $extwtcsvimportsuite = $prefix . 'extwtcsvimportsuite'; // third level plugin ext.: csv import suite $wcgroup = $prefix . 'wcgroup'; // sub level: wc group (resources) /** Make the "WooCommerce" name filterable within menu items */ $wcaba_woocommerce_name = apply_filters('wcaba_filter_woocommerce_name', __('WooCommerce', 'woocommerce-admin-bar-addition')); /** Make the "WooCommerce" name's tooltip filterable within menu items */ $wcaba_woocommerce_name_tooltip = apply_filters('wcaba_filter_woocommerce_name_tooltip', _x('WooCommerce', 'Translators: For the tooltip', 'woocommerce-admin-bar-addition')); /** Display the following items also when WooCommerce plugin is not installed */ if (defined('WCABA_RESOURCES_DISPLAY') && WCABA_RESOURCES_DISPLAY) { /** Include plugin file with resources links */ require_once WCABA_PLUGIN_DIR . 'includes/wcaba-resources.php'; } // end if /** Include plugin file with language specific items/ links */ if (!ddw_wcaba_detect_locales('en_US', 'en_GB', 'en_CA', 'en_NZ', 'en_AU')) { require_once WCABA_PLUGIN_DIR . 'includes/wcaba-languages.php'; } // end if /** * Show these items only if WooCommerce plugin is actually installed * Check for classes "WooCommerce" (v2.1.0+) or "Woocommerce" (2.0.x) */ if (class_exists('WooCommerce') || class_exists('Woocommerce')) { /** Display "Orders" section only for users with the capability 'edit_shop_order' */ if (current_user_can('edit_shop_orders')) { $menu_items['orders'] = array('parent' => $woocommercebar, 'title' => __('Orders', 'woocommerce-admin-bar-addition'), 'href' => admin_url('edit.php?post_type=shop_order'), 'meta' => array('target' => '', 'title' => __('Orders', 'woocommerce-admin-bar-addition'))); /** Display order status links if theme support is added */ if (current_theme_supports('wcaba-order-status')) { require_once WCABA_PLUGIN_DIR . 'includes/wcaba-orderstatus.php'; } // end if theme support check $menu_items['o-add-order'] = array('parent' => $orders, 'title' => __('Add new order', 'woocommerce-admin-bar-addition'), 'href' => admin_url('post-new.php?post_type=shop_order'), 'meta' => array('target' => '', 'title' => __('Add new order', 'woocommerce-admin-bar-addition'))); $menu_items['o-customers'] = array('parent' => $orders, 'title' => __('Current Customers', 'woocommerce-admin-bar-addition'), 'href' => admin_url('users.php?role=customer'), 'meta' => array('target' => '', 'title' => __('Current Customers', 'woocommerce-admin-bar-addition'))); } // end if orders cap check /** Display "Reports" section only for users with the capability 'view_woocommerce_reports' */ if (defined('WCABA_REPORTS_DISPLAY') && WCABA_REPORTS_DISPLAY && current_user_can('view_woocommerce_reports')) { /** Include reports links per version branch */ if (ddw_wcaba_woocommerce_current()) { require_once WCABA_PLUGIN_DIR . 'includes/wcaba-reports-v21x.php'; } else { require_once WCABA_PLUGIN_DIR . 'includes/wcaba-reports-v20x.php'; } // end if } // end if reports cap check /** Display "Products" section only for users with the capability 'edit_products' */ if (current_user_can('edit_products')) { $menu_items['products'] = array('parent' => $woocommercebar, 'title' => __('Products', 'woocommerce-admin-bar-addition'), 'href' => admin_url('edit.php?post_type=product'), 'meta' => array('target' => '', 'title' => __('Products', 'woocommerce-admin-bar-addition'))); $menu_items['p-add-product'] = array('parent' => $products, 'title' => __('Add new product', 'woocommerce-admin-bar-addition'), 'href' => admin_url('post-new.php?post_type=product'), 'meta' => array('target' => '', 'title' => __('Add new product', 'woocommerce-admin-bar-addition'))); /** Various 'product' taxonomies */ if (current_user_can('manage_product_terms')) { $menu_items['p-product-categories'] = array('parent' => $products, 'title' => __('Product Categories', 'woocommerce-admin-bar-addition'), 'href' => admin_url('edit-tags.php?taxonomy=product_cat&post_type=product'), 'meta' => array('target' => '', 'title' => __('Product Categories', 'woocommerce-admin-bar-addition'))); $menu_items['p-product-tags'] = array('parent' => $products, 'title' => __('Product Tags', 'woocommerce-admin-bar-addition'), 'href' => admin_url('edit-tags.php?taxonomy=product_tag&post_type=product'), 'meta' => array('target' => '', 'title' => __('Product Tags', 'woocommerce-admin-bar-addition'))); $menu_items['p-product-shippingclasses'] = array('parent' => $products, 'title' => __('Products - Shipping Classes', 'woocommerce-admin-bar-addition'), 'href' => admin_url('edit-tags.php?taxonomy=product_shipping_class&post_type=product'), 'meta' => array('target' => '', 'title' => __('Products - Shipping Classes', 'woocommerce-admin-bar-addition'))); $menu_items['p-product-variants'] = array('parent' => $products, 'title' => __('Product Variants (Attributes)', 'woocommerce-admin-bar-addition'), 'href' => admin_url('edit.php?post_type=product&page=woocommerce_attributes'), 'meta' => array('target' => '', 'title' => __('Product Variants (Attributes)', 'woocommerce-admin-bar-addition'))); } // end if } // end if products cap check /** Display "Coupons" section only for users with the capability 'edit_shop_coupon' */ if (current_user_can('edit_shop_coupons')) { $menu_items['coupons'] = array('parent' => $woocommercebar, 'title' => __('Coupons', 'woocommerce-admin-bar-addition'), 'href' => admin_url('edit.php?post_type=shop_coupon'), 'meta' => array('target' => '', 'title' => __('Coupons', 'woocommerce-admin-bar-addition'))); $menu_items['c-add-coupon'] = array('parent' => $coupons, 'title' => __('Add new coupon', 'woocommerce-admin-bar-addition'), 'href' => admin_url('post-new.php?post_type=shop_coupon'), 'meta' => array('target' => '', 'title' => __('Add new coupon', 'woocommerce-admin-bar-addition'))); } // end if /** Settings links */ if (current_user_can('manage_woocommerce')) { /** Include settings links per version branch */ if (ddw_wcaba_woocommerce_current()) { require_once WCABA_PLUGIN_DIR . 'includes/wcaba-settings-v21x.php'; } else { require_once WCABA_PLUGIN_DIR . 'includes/wcaba-settings-v20x.php'; } // end if /** Setting links continued once again... */ if (current_user_can('edit_theme_options')) { $menu_items['s-widgets'] = array('parent' => $settings, 'title' => esc_attr__($wcaba_woocommerce_name) . ' ' . __('Widgets', 'woocommerce-admin-bar-addition'), 'href' => admin_url('widgets.php'), 'meta' => array('target' => '', 'title' => esc_attr__($wcaba_woocommerce_name_tooltip) . ' ' . __('Widgets', 'woocommerce-admin-bar-addition'))); $menu_items['s-menus'] = array('parent' => $settings, 'title' => esc_attr__($wcaba_woocommerce_name) . ' ' . __('Menus', 'woocommerce-admin-bar-addition'), 'href' => admin_url('nav-menus.php'), 'meta' => array('target' => '', 'title' => esc_attr__($wcaba_woocommerce_name_tooltip) . ' ' . __('Menus', 'woocommerce-admin-bar-addition'))); } // end if cap check } // end if WC (main/ settings) cap check /** Display shop links if theme support is added */ if (current_theme_supports('wcaba-shop-links') && current_user_can('edit_pages')) { require_once WCABA_PLUGIN_DIR . 'includes/wcaba-shoplinks.php'; } // end if theme support check /** * Display last main item in the menu for active extensions/plugins * ATTENTION: This is where plugins/extensions hook in on the sub-level hierarchy * * @since 1.0.0 */ if (defined('WCABA_EXTENSIONS_DISPLAY') && WCABA_EXTENSIONS_DISPLAY && current_user_can('activate_plugins')) { $menu_items['extensions'] = array('parent' => $woocommercebar, 'title' => __('Active Extensions', 'woocommerce-admin-bar-addition'), 'href' => is_network_admin() ? network_admin_url('plugins.php') : admin_url('plugins.php'), 'meta' => array('target' => '', 'title' => __('Active Extensions', 'woocommerce-admin-bar-addition'))); /** Add-Ons admin page link */ if (ddw_wcaba_woocommerce_current()) { $menu_items['extensions-browser'] = array('parent' => $extensions, 'title' => __('Add-On Browser', 'woocommerce-admin-bar-addition'), 'href' => admin_url('admin.php?page=wc-addons'), 'meta' => array('target' => '', 'title' => __('Add-On Browser', 'woocommerce-admin-bar-addition'))); } // end if /** * Action Hook 'wcaba_custom_extension_items' * allows for hooking other extension-related items in */ do_action('wcaba_custom_extension_items'); } // end if } // end if WooCommerce conditional for settings items /** * Display links to active WooCommerce specific themes settings' pages. */ /** Include plugin file with theme support links */ if (defined('WCABA_THEMES_DISPLAY') && WCABA_THEMES_DISPLAY) { require_once WCABA_PLUGIN_DIR . 'includes/wcaba-themes.php'; /** * Action Hook 'wcaba_custom_theme_items' * allows for hooking other theme-related items in */ do_action('wcaba_custom_theme_items'); } // end if constant check /** * Display links to active WooCommerce plugins/extensions settings' pages. */ /** Include plugin file with plugin support links */ require_once WCABA_PLUGIN_DIR . 'includes/wcaba-plugins.php'; /** Allow menu items to be filtered, but pass in parent menu item IDs */ $menu_items = (array) apply_filters('wcaba_filter_menu_items', $menu_items, $woogroup_menu_items, $prefix, $woocommercebar, $support, $woocommercesites, $settings, $sgeneralsettings, $semails, $settingsintegration, $s_dynpricing, $s_commissionking, $products, $p_compareproductslite, $p_compareproductspro, $p_csvimportsuite, $coupons, $orders, $reports, $reportssales, $reportsproducts, $reportscategories, $reportscoupons, $reportscustomers, $reportsstock, $shoplink, $shoplinkcheckout, $shoplinkmyaccount, $shoplinkde, $extensions, $extpideal, $extwtdynpricing, $extwtcommissionking, $extwtclickatellsms, $extwtquickbooks, $extwccplite, $extwccppro, $extwtcsvimportsuite, $wcgroup); // end of array /** * Add the WooCommerce top-level menu item. */ /** Filter the main item name */ $wcaba_main_item_title = apply_filters('wcaba_filter_main_item', _x('WooCommerce', 'Translators: Main item', 'woocommerce-admin-bar-addition')); /** Filter the main item name's tooltip */ $wcaba_main_item_title_tooltip = apply_filters('wcaba_filter_main_item_tooltip', _x('Current Orders - WooCommerce Shop', 'Translators: Main item - for the tooltip', 'woocommerce-admin-bar-addition')); /** Main item URL helpers */ $wcaba_main_url_orders = current_user_can('edit_shop_orders') ? admin_url('edit.php?post_type=shop_order') : '#'; $wcaba_wc_settings_url = ddw_wcaba_woocommerce_current() ? admin_url('admin.php?page=wc-settings') : admin_url('admin.php?page=woocommerce_settings'); $wcaba_main_url_settings = current_user_can('manage_woocommerce') ? $wcaba_wc_settings_url : '#'; /** Filter the main item icon's url */ $wcaba_main_item_url = apply_filters('wcaba_filter_main_item_url', defined('WP_DEBUG') && WP_DEBUG ? $wcaba_main_url_settings : $wcaba_main_url_orders); /** Filter the main item icon's class/display */ $wcaba_main_item_icon_display = apply_filters('wcaba_filter_main_item_icon_display', 'icon-woocommerce'); /** Add the top-level menu item */ $wp_admin_bar->add_menu(array('id' => $woocommercebar, 'title' => $wcaba_main_item_title, 'href' => esc_url($wcaba_main_item_url), 'meta' => array('class' => $wcaba_main_item_icon_display, 'title' => $wcaba_main_item_title_tooltip))); /** Loop through the menu items */ foreach ($menu_items as $id => $menu_item) { /** Add in the item ID */ $menu_item['id'] = $prefix . $id; /** Add meta target to each item where it's not already set, so links open in new window/tab */ if (!isset($menu_item['meta']['target'])) { $menu_item['meta']['target'] = '_blank'; } // end if /** Add class to links that open up in a new window/tab */ if ('_blank' === $menu_item['meta']['target']) { if (!isset($menu_item['meta']['class'])) { $menu_item['meta']['class'] = ''; } // end if $menu_item['meta']['class'] .= $prefix . 'wcaba-new-tab'; } // end if /** Add menu items */ $wp_admin_bar->add_menu($menu_item); } // end foreach /** * Action Hook 'wcaba_custom_main_items' * allows for hooking other main items in */ do_action('wcaba_custom_main_items'); /** * Check for WordPress version to add resource links group */ $wp_admin_bar->add_group(array('parent' => $woocommercebar, 'id' => $wcgroup, 'meta' => array('class' => 'ab-sub-secondary'))); /** WooCommerce Group: Loop through the group menu items */ foreach ($woogroup_menu_items as $id => $woogroup_menu_item) { /** WooCommerce Group: Add in the item ID */ $woogroup_menu_item['id'] = $prefix . $id; /** WooCommerce Group: Add meta target to each item where it's not already set, so links open in new window/tab */ if (!isset($woogroup_menu_item['meta']['target'])) { $woogroup_menu_item['meta']['target'] = '_blank'; } // end if /** WooCommerce Group: Add class to links that open up in a new window/tab */ if ('_blank' === $woogroup_menu_item['meta']['target']) { if (!isset($woogroup_menu_item['meta']['class'])) { $woogroup_menu_item['meta']['class'] = ''; } // end if $woogroup_menu_item['meta']['class'] .= $prefix . 'wcaba-new-tab'; } // end if /** WooCommerce Group: Add menu items */ $wp_admin_bar->add_menu($woogroup_menu_item); } // end foreach /** * Action Hook 'wcaba_custom_group_items' * allows for hooking other WooCommerce Group items in */ do_action('wcaba_custom_group_items'); }
/** * Setting internal plugin helper values. * * @since 2.6.0 * * @uses ddw_wcaba_detect_locales() */ function ddw_wcaba_info_values() { $wcaba_info = array('url_translate' => 'http://translate.wpautobahn.com/projects/genesis-plugins-deckerweb/woocommerce-admin-bar-addition', 'url_wporg_faq' => 'http://wordpress.org/plugins/woocommerce-admin-bar-addition/faq/', 'url_wporg_forum' => 'http://wordpress.org/support/plugin/woocommerce-admin-bar-addition', 'url_wporg_profile' => 'http://profiles.wordpress.org/daveshine/', 'url_snippets' => 'https://gist.github.com/deckerweb/2173193', 'url_suggestions' => 'https://deckerweb.de/twitter', 'license' => 'GPL-2.0+', 'first_release' => absint('2011'), 'url_donate' => ddw_wcaba_detect_locales('de_DE', 'de_AT', 'de_CH', 'de_LU', 'gsw') ? 'http://genesisthemes.de/spenden/' : 'http://genesisthemes.de/en/donate/', 'url_plugin' => ddw_wcaba_detect_locales('de_DE', 'de_AT', 'de_CH', 'de_LU', 'gsw') ? 'http://genesisthemes.de/plugins/woocommerce-admin-bar-addition/' : 'http://genesisthemes.de/en/wp-plugins/woocommerce-admin-bar-addition/', 'de_plugin' => 'http://wordpress.org/plugins/woocommerce-de/', 'de_files' => 'http://deckerweb.de/sprachdateien/woocommerce-und-extensions/', 'nl_plugin' => 'http://wordpress.org/plugins/woocommerce-nl/', 'es_plugin' => 'http://wordpress.org/plugins/woocommerce-es/', 'cz_plugin' => 'http://wordpress.org/plugins/woocommerce-cestina/', 'is_german' => ddw_wcaba_detect_locales('de_DE', 'de_AT', 'de_CH', 'de_LU', 'gsw') ? TRUE : FALSE, 'is_dutch' => ddw_wcaba_detect_locales('nl', 'nl_NL') ? TRUE : FALSE, 'is_czech' => ddw_wcaba_detect_locales('cs_CZ') ? TRUE : FALSE, 'is_spanish' => ddw_wcaba_detect_locales('es_ES', 'es_PE') ? TRUE : FALSE); // end of array return $wcaba_info; }
if (defined('WCABA_DE_DISPLAY') && WCABA_DE_DISPLAY && ddw_wcaba_detect_locales('de_DE', 'de_AT', 'de_CH', 'de_LU', 'gsw')) { /** WooCommerce German Extension plugin */ if (class_exists('Woocommerce_German_Market')) { $menu_items['wcgermany'] = array('parent' => $settings, 'title' => __('Preferences DE', 'woocommerce-admin-bar-addition'), 'href' => admin_url('admin.php?page=woocommerce_settings&tab=preferences_de'), 'meta' => array('target' => '', 'title' => _x('Preferences DE', 'Translators: For the tooltip', 'woocommerce-admin-bar-addition'))); $menu_items['preferences-de'] = array('parent' => $extensions, 'title' => __('Preferences DE', 'woocommerce-admin-bar-addition'), 'href' => admin_url('admin.php?page=woocommerce_settings&tab=preferences_de'), 'meta' => array('target' => '', 'title' => _x('Preferences DE', 'Translators: For the tooltip', 'woocommerce-admin-bar-addition'))); } // end-if German Extension plugin /** German language plugin - only if DE plugin not active */ if (!defined('WCDE_EXTENSIONS_DIR') || !class_exists('WooCommerce_de_DE')) { $menu_items['wclanguages-de'] = array('parent' => $wcgroup, 'title' => __('German language plugin', 'woocommerce-admin-bar-addition'), 'href' => esc_url($wcaba_info['de_plugin']), 'meta' => array('title' => _x('German language plugin for WooCommerce - with complete translations and formal/informal version support!', 'Translators: For the tooltip', 'woocommerce-admin-bar-addition'))); } // end-if German language plugin /** Downloadable German language packs */ $menu_items['languages-de'] = array('parent' => $wcgroup, 'title' => __('German language files', 'woocommerce-admin-bar-addition'), 'href' => esc_url($wcaba_info['de_files']), 'meta' => array('title' => _x('German language files', 'Translators: For the tooltip', 'woocommerce-admin-bar-addition'))); } // end if German locale /** Display links to language plugin only for this locale: nl, nl_NL - and when NL plugin not active */ if (defined('WCABA_NL_DISPLAY') && WCABA_NL_DISPLAY && (ddw_wcaba_detect_locales('nl', 'nl_NL') && !class_exists('WooCommerceNL'))) { $menu_items['wclanguages-nl'] = array('parent' => $wcgroup, 'title' => __('Dutch language plugin', 'woocommerce-admin-bar-addition'), 'href' => esc_url($wcaba_info['nl_plugin']), 'meta' => array('title' => _x('Dutch language plugin for WooCommerce - with complete translations!', 'Translators: For the tooltip', 'woocommerce-admin-bar-addition'))); } // end if Dutch locale /** Display links to language plugin only for this locale: es_ES, es_PE - and when ES plugin not active */ if (defined('WCABA_ES_DISPLAY') && WCABA_ES_DISPLAY && (ddw_wcaba_detect_locales('es_ES', 'es_PE') && !class_exists('WooCommerceESPlugin'))) { $menu_items['wclanguages-es'] = array('parent' => $wcgroup, 'title' => __('Spanish language plugin', 'woocommerce-admin-bar-addition'), 'href' => esc_url($wcaba_info['es_plugin']), 'meta' => array('title' => _x('Spanish language plugin for WooCommerce - with complete translations!', 'Translators: For the tooltip', 'woocommerce-admin-bar-addition'))); } // end if Spanish locale /** Display links to language plugin only for this locale: cs_CZ - and when CZ plugin not active */ if (defined('WCABA_CZ_DISPLAY') && WCABA_CZ_DISPLAY && (ddw_wcaba_detect_locales('cs_CZ') && !function_exists('wcc_load_textdomain'))) { $menu_items['wclanguages-cz'] = array('parent' => $wcgroup, 'title' => __('Czech language plugin', 'woocommerce-admin-bar-addition'), 'href' => esc_url($wcaba_info['cz_plugin']), 'meta' => array('title' => _x('Czech language plugin for WooCommerce - with complete translations!', 'Translators: For the tooltip', 'woocommerce-admin-bar-addition'))); } // end if Czech locale