/** * Unique access to instance of YITH_Vendors class * * @return YITH_Vendors|YITH_Vendors_Premium * @since 1.0.0 */ function YITH_Vendors() { // Load required classes and functions require_once YITH_WPV_PATH . 'includes/class.yith-vendors.php'; if (defined('YITH_WPV_PREMIUM') && file_exists(YITH_WPV_PATH . 'includes/class.yith-vendors-premium.php')) { require_once YITH_WPV_PATH . 'includes/class.yith-vendors-premium.php'; return YITH_Vendors_Premium::instance(); } return YITH_Vendors::instance(); }
/** * Set up array of vendor admin capabilities * * @author Andrea Grillo <*****@*****.**> * * @return array Vendor capabilities * @since 1.0 */ public function vendor_enabled_capabilities() { $caps = parent::vendor_enabled_capabilities(); $live_chat_caps = $membership_caps = $size_charts_caps = $subscription_caps = $surveys_caps = array(); /* === View Report Capability === */ $caps['view_woocommerce_reports'] = true; /* === Coupon Capabilities === */ if ('yes' == get_option('yith_wpv_vendors_option_coupon_management', 'no')) { $caps['edit_shop_coupons'] = true; $caps['read_shop_coupons'] = true; $caps['delete_shop_coupons'] = true; $caps['publish_shop_coupons'] = true; $caps['edit_published_shop_coupons'] = true; $caps['delete_published_shop_coupons'] = true; $caps['edit_others_shop_coupons'] = true; $caps['delete_others_shop_coupons'] = true; } /* === Product reviews === */ if ('yes' == get_option('yith_wpv_vendors_option_review_management', 'no')) { $caps['moderate_comments'] = true; $caps['edit_posts'] = true; } /* === YITH Live Chat === */ if (YITH_Vendors()->addons->has_plugin('live-chat') && 'yes' == get_option('yith_wpv_vendors_option_live_chat_management', 'no')) { $live_chat_caps = apply_filters('yith_wcmv_live_chat_caps', array()); } /* === Surveys === */ if (YITH_Vendors()->addons->has_plugin('surveys') && 'yes' == get_option('yith_wpv_vendors_option_surveys_management', 'no')) { $surveys_caps = apply_filters('yith_wcmv_surveys_caps', array()); } /* === Add-Ons capabilities === */ $addons_caps = array(); if (YITH_Vendors()->addons->compatibility) { foreach (YITH_Vendors()->addons->compatibility->plugin_with_capabilities as $plugin_name => $plugin_options) { $slug = YITH_Vendors()->addons->compatibility->get_slug($plugin_name); if (YITH_Vendors()->addons->has_plugin($plugin_name) && 'yes' == get_option('yith_wpv_vendors_option_' . $slug . '_management', 'no')) { $addons_caps = array_merge($addons_caps, (array) $plugin_options['capabilities']); } } } return apply_filters('yith_wcmv_vendor_capabilities', array_merge($caps, $live_chat_caps, $membership_caps, $size_charts_caps, $subscription_caps, $surveys_caps, $addons_caps)); }
/** * Regenerate Vendor Role Capabilities fter update by FTP */ function yith_vendors_plugin_update() { $plugin_version = get_option('yith_wcmv_version', '1.0.0'); if (version_compare($plugin_version, YITH_Vendors()->version, '<')) { /* Check if Vendor Role Exists */ YITH_Vendors::add_vendor_role(); /* Add Vendor Role to vendor owner and admins */ YITH_Vendors::setup('add_role'); update_option('yith_wcmv_version', YITH_Vendors()->version); } }