protected function api_request($_action, $_data) { $time_key = $this->slug . '-plugin_updater_api_request_last_checked'; $api_key = $this->slug . '-plugin_updater_api_request'; $entity = new WPFront_User_Role_Editor_Entity_Options(); $time = $entity->get_option($time_key); if ($time === NULL || $time < time() - 6 * 3600) { $api = NULL; } else { $api = $entity->get_option($api_key); } if ($api === NULL) { $api = parent::api_request($_action, $_data); if ($api) { $entity->update_option($api_key, serialize($api)); $entity->update_option($time_key, time()); } } else { $api = unserialize($api); } return $api; }
public function admin_init() { $option_key = 'attachment_capabilities_processed'; $entity = new WPFront_User_Role_Editor_Entity_Options(); $processed = $entity->get_option($option_key); if (!empty($processed)) { return; } global $wp_roles; foreach ($wp_roles->role_objects as $key => $role) { if ($role->has_cap('upload_files')) { foreach (self::$attachment_capabilities as $cap) { $role->add_cap($cap); } } } $entity->update_option($option_key, TRUE); }
public function edd_plugin_update() { $entity = new WPFront_User_Role_Editor_Entity_Options(); $this->plugin_updater = new WPFront_User_Role_Editor_Plugin_Updater(self::$store_url, WPFRONT_USER_ROLE_EDITOR_PLUGIN_FILE, array('version' => WPFront_User_Role_Editor::VERSION, 'license' => $entity->get_option($this->license_key_k), 'item_name' => $this->product, 'author' => 'Syam Mohan'), $this->slug); }
private function get_option($key, $ms = FALSE) { $prefix = ''; if ($ms) { $prefix = 'ms_'; switch_to_blog($this->ms_options_blog_id()); } $entity = new WPFront_User_Role_Editor_Entity_Options(); $value = $entity->get_option($prefix . $key); if ($value === NULL) { if ($ms === FALSE && is_multisite()) { return $this->get_option($key, TRUE); } } if ($ms) { restore_current_blog(); } return $value; }
private function add_role_permissions($post_type) { $settings_key = "add_role_permissions_{$post_type}_processed"; $caps = $this->get_post_type_capabilities($post_type); $cap_key = $caps->edit_posts . '_role_permissions'; new WPFront_User_Role_Editor_Custom_Post_Permissions($post_type, $this->main, $cap_key, $caps); if (!is_admin()) { return; } $this->main->add_role_capability($cap_key); $entity = new WPFront_User_Role_Editor_Entity_Options(); if ($entity->get_option($settings_key) === '1') { return; } $role = get_role(self::ADMINISTRATOR_ROLE_KEY); if ($role->has_cap($cap_key)) { $entity->update_option($settings_key, '1'); return; } $role->add_cap($cap_key); global $wp_roles; foreach ($wp_roles->role_objects as $role) { if ($role->has_cap($caps->edit_posts)) { $role->add_cap($cap_key); } } $entity->update_option($settings_key, '1'); }
private function get_disable_for_secondary_role($role) { $entity = new WPFront_User_Role_Editor_Entity_Options(); $value = $entity->get_option(self::$disable_for_secondary_role_option_name . $role->name); if ($value === NULL) { return FALSE; } return (bool) $value; }