Initiate an instance of this class if one doesn't
exist already. Return the VipSupportRole instance.
public static init ( ) : WPCOM_VIP_Support_Role | ||
리턴 | WPCOM_VIP_Support_Role | object The instance of WPCOM_VIP_Support_Role |
function test_role_order() { // Arrange // Trigger the update method call on admin_init, // this sets up the role WPCOM_VIP_Support_Role::init()->action_admin_init(); // Act $roles = get_editable_roles(); $role_names = array_keys($roles); // Assert // To show up last, the VIP Support role will be // the first index in the array $first_role = array_shift($role_names); $this->assertTrue(WPCOM_VIP_Support_Role::VIP_SUPPORT_ROLE === $first_role); }
if (function_exists('wpcom_vip_add_role')) { wpcom_vip_add_role(self::VIP_SUPPORT_ROLE, __('VIP Support', 'a8c_vip_support'), array('read' => true)); wpcom_vip_add_role(self::VIP_SUPPORT_INACTIVE_ROLE, __('VIP Support (inactive)', 'a8c_vip_support'), array('read' => true)); } else { add_role(self::VIP_SUPPORT_ROLE, __('VIP Support', 'a8c_vip_support'), array('read' => true)); add_role(self::VIP_SUPPORT_INACTIVE_ROLE, __('VIP Support (inactive)', 'a8c_vip_support'), array('read' => true)); } } /** * Checks the version option value against the version * property value, and runs update routines as appropriate. * */ protected function update() { $option_name = 'vipsupportrole_version'; $version = absint(get_option($option_name, 0)); if ($version == self::VERSION) { return; } if ($version < 1 && function_exists('wpcom_vip_add_role')) { self::add_role(); self::error_log("VIP Support Role: Added VIP Support role "); } // N.B. Remember to increment self::VERSION above when you add a new IF update_option($option_name, self::VERSION); $this->error_log("VIP Support Role: Done upgrade, now at version " . self::VERSION); } } WPCOM_VIP_Support_Role::init();