public $pluginDirName;
public $wpdb;
+ static public function activate_plugin()
+ {
+ glm_coupon_admin::add_capability();
+ }
+
+ static public function add_capability()
+ {
+ $roles = get_editable_roles();
+ foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) {
+ if (isset($roles[$key]) && $role->has_cap(GLM_COUPON_BUILTIN_CAPABILITIES)) {
+ $role->add_cap(GLM_COUPON_TERM_CAPABILITIES);
+ }
+ }
+ }
+
public function __construct($path, $wpdb)
{
/**
* Plugin Name: Gaslight Media Coupons
* Description: Coupon Application for Gaslight Media Clients.
- * Version: 0.1.2 Beta
+ * Version: 0.1.3 Beta
* Author: Steve Sutton
* Author URI: http://www.gaslightmedia.com
* License: All right reserved
define('GLM_COUPON_VERSION_OPTION_NAME', 'glm_coupons_db_version');
define('GLM_COUPON_POST_TYPE', 'glm_coupons');
define('GLM_COUPON_TAX_CATEGORIES', 'glm_couponscategory');
+define('GLM_COUPON_BUILTIN_CAPABILITIES', 'edit_posts');
+define('GLM_COUPON_TERM_CAPABILITIES', 'manage_glmcouponterms');
+
+/* Register Activation or Deactivation hooks
+ */
+register_activation_hook(__FILE__, array('glm_coupon_admin', 'activate_plugin'));
+
/**
* Required class files
*/
'show_admin_column' => true,
'_builtin' => true,
'capabilities' => array(
- 'manage_terms' => 'manage_glmcouponterms',
- 'edit_terms' => 'manage_glmcouponterms',
- 'delete_terms' => 'manage_glmcouponterms',
- 'assign_terms' => 'manage_glmcouponterms'
+ 'manage_terms' => GLM_COUPON_TERM_CAPABILITIES,
+ 'edit_terms' => GLM_COUPON_TERM_CAPABILITIES,
+ 'delete_terms' => GLM_COUPON_TERM_CAPABILITIES,
+ 'assign_terms' => GLM_COUPON_TERM_CAPABILITIES
)
));
}