本文整理汇总了PHP中GFCommon::all_caps方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::all_caps方法的具体用法?PHP GFCommon::all_caps怎么用?PHP GFCommon::all_caps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFCommon
的用法示例。
在下文中一共展示了GFCommon::all_caps方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_parent_menu
public static function get_parent_menu($addon_menus)
{
if (GFCommon::current_user_can_any("gravityforms_edit_forms")) {
$parent = array("name" => "gf_edit_forms", "callback" => array("RGForms", "forms"));
} else {
if (GFCommon::current_user_can_any("gravityforms_create_form")) {
$parent = array("name" => "gf_new_form", "callback" => array("RGForms", "new_form"));
} else {
if (GFCommon::current_user_can_any("gravityforms_view_entries")) {
$parent = array("name" => "gf_entries", "callback" => array("RGForms", "all_leads_page"));
} else {
if (is_array($addon_menus) && sizeof($addon_menus) > 0) {
foreach ($addon_menus as $addon_menu) {
if (GFCommon::current_user_can_any($addon_menu["permission"])) {
$parent = array("name" => $addon_menu["name"], "callback" => $addon_menu["callback"]);
break;
}
}
} else {
if (GFCommon::current_user_can_any("gravityforms_view_settings")) {
$parent = array("name" => "gf_settings", "callback" => array("RGForms", "settings_page"));
} else {
if (GFCommon::current_user_can_any("gravityforms_export_entries")) {
$parent = array("name" => "gf_export", "callback" => array("RGForms", "export_page"));
} else {
if (GFCommon::current_user_can_any("gravityforms_view_updates")) {
$parent = array("name" => "gf_update", "callback" => array("RGForms", "update_page"));
} else {
if (GFCommon::current_user_can_any("gravityforms_view_addons")) {
$parent = array("name" => "gf_addons", "callback" => array("RGForms", "addons_page"));
} else {
if (GFCommon::current_user_can_any(GFCommon::all_caps())) {
$parent = array("name" => "gf_help", "callback" => array("RGForms", "help_page"));
}
}
}
}
}
}
}
}
}
return $parent;
}
示例2: maybe_add_full_access_caps
/**
* Add Gravity Forms and GravityView's "full access" caps when any other caps are checked against.
*
* @since 1.15
* @param array $caps_to_check
*
* @return array
*/
public static function maybe_add_full_access_caps($caps_to_check = array())
{
$caps_to_check = (array) $caps_to_check;
$all_gravityview_caps = self::all_caps();
// Are there any $caps_to_check that are from GravityView?
if ($has_gravityview_caps = array_intersect($caps_to_check, $all_gravityview_caps)) {
$caps_to_check[] = 'gravityview_full_access';
}
$all_gravity_forms_caps = class_exists('GFCommon') ? GFCommon::all_caps() : array();
// Are there any $caps_to_check that are from Gravity Forms?
if ($all_gravity_forms_caps = array_intersect($caps_to_check, $all_gravity_forms_caps)) {
$caps_to_check[] = 'gform_full_access';
}
return array_unique($caps_to_check);
}
示例3: add_gravity_forms_caps
/**
* Add Gravity Forms plugin capabilities, if available
*
*/
protected function add_gravity_forms_caps()
{
if (class_exists('GFCommon')) {
$gf_caps = GFCommon::all_caps();
foreach ($gf_caps as $gf_cap) {
$this->add_capability_to_full_caps_list($gf_cap);
}
}
}
示例4: init_full_capabilities
protected function init_full_capabilities()
{
$this->built_in_wp_caps = $this->get_built_in_wp_caps();
$this->full_capabilities = array();
foreach ($this->roles as $role) {
// validate if capabilities is an array
if (isset($role['capabilities']) && is_array($role['capabilities'])) {
foreach ($role['capabilities'] as $key => $value) {
$this->add_capability_to_full_caps_list($key);
}
}
}
// Get Gravity Forms plugin capabilities, if available
if ($this->integrate_with_gravity_forms) {
$gf_caps = GFCommon::all_caps();
foreach ($gf_caps as $gf_cap) {
$this->add_capability_to_full_caps_list($gf_cap);
}
}
if ($this->ure_object == 'user') {
foreach ($this->user_to_edit->caps as $key => $value) {
if (!isset($this->roles[$key])) {
// it is the user capability, not role
$this->add_capability_to_full_caps_list($key);
}
}
}
foreach ($this->built_in_wp_caps as $cap => $val) {
if (!isset($this->full_capabilities[$cap])) {
$this->add_capability_to_full_caps_list($cap);
}
}
unset($this->built_in_wp_caps);
asort($this->full_capabilities);
}
示例5: prohibited_links_redirect
public function prohibited_links_redirect()
{
global $current_user;
$min_cap = $this->lib->user_can_which($current_user, GFCommon::all_caps());
if (empty($min_cap)) {
return;
}
$this->check_import_link();
$result = false;
$links_to_block = array('admin.php?page=gf_edit_forms&id=', 'admin.php?page=gf_edit_forms&view=settings', 'admin.php?page=gf_entries&id=', 'admin.php?page=gf_entries&view=entries&id=');
foreach ($links_to_block as $link) {
$result = stripos($_SERVER['REQUEST_URI'], $link);
if ($result !== false) {
break;
}
}
if ($result === false) {
// other URL, no need to block
return;
}
$id = 0;
// extract form id
$args = wp_parse_args($_SERVER['REQUEST_URI'], array());
if (isset($args['id'])) {
$id = (int) $args['id'];
} elseif (isset($_POST['action_argument'])) {
// delete, duplicate
$id = (int) $_POST['action_argument'];
} elseif (isset($_POST['form'])) {
// bulk actions
$allowed_forms_list = $this->get_allowed_forms();
foreach ($_POST['form'] as $form_id) {
if (!in_array($form_id, $allowed_forms_list)) {
$id = $form_id;
break;
}
}
}
if (!isset($allowed_forms_list)) {
$allowed_forms_list = $this->get_allowed_forms();
}
if ($id > 0) {
if (count($allowed_forms_list) == 0) {
// no limits
return;
}
if (!in_array($id, $allowed_forms_list)) {
// access to this form is prohibited - redirect user back to the forms list
// its late to user wp_redirect() ad WP sent some headers already, so use this method for redirection
?>
<script>
document.location.href = '<?php
echo get_option('siteurl') . '/wp-admin/admin.php?page=gf_edit_forms';
?>
';
</script>
<?php
die;
}
}
}
示例6: init_full_capabilities
protected function init_full_capabilities()
{
$this->built_in_wp_caps = $this->get_built_in_wp_caps();
$this->full_capabilities = array();
foreach ($this->roles as $role) {
// validate if capabilities is an array
if (isset($role['capabilities']) && is_array($role['capabilities'])) {
foreach ($role['capabilities'] as $key => $value) {
$this->add_capability_to_full_caps_list($key);
}
}
}
// Get Gravity Forms plugin capabilities, if available
if (class_exists('GFCommon')) {
$gf_caps = GFCommon::all_caps();
foreach ($gf_caps as $gf_cap) {
$this->add_capability_to_full_caps_list($gf_cap);
}
}
// provide compatibility with plugins and themes which use 'members_get_capabilities' filter from Members plugin to define their capabilities
$custom_caps = array();
$custom_caps = apply_filters('members_get_capabilities', $custom_caps);
foreach ($custom_caps as $cap) {
$this->add_capability_to_full_caps_list($cap);
}
if ($this->ure_object == 'user') {
foreach ($this->user_to_edit->caps as $key => $value) {
if (!isset($this->roles[$key])) {
// it is the user capability, not role
$this->add_capability_to_full_caps_list($key);
}
}
}
foreach ($this->built_in_wp_caps as $cap => $val) {
if (!isset($this->full_capabilities[$cap])) {
$this->add_capability_to_full_caps_list($cap);
}
}
unset($this->built_in_wp_caps);
asort($this->full_capabilities);
}
示例7: update_gravity_forms_menu
/**
* Update Gravity Forms menu permissions as it may has gf_full_access got for the superadmin user under WP multisite
* @param array $current_menu
* @param array $current_submenu
*/
protected function update_gravity_forms_menu(&$current_menu, &$current_submenu, $allowed_caps)
{
$min_cap = $this->min_cap($allowed_caps, GFCommon::all_caps());
$gf_caps_map = array('gf_edit_forms' => 'gravityforms_edit_forms', 'gf_new_form' => 'gravityforms_create_form', 'gf_entries' => 'gravityforms_view_entries', 'gf_settings' => 'gravityforms_view_settings', 'gf_export' => 'gravityforms_export_entries', 'gf_update' => 'gravityforms_view_updates', 'gf_addons' => 'gravityforms_view_addons', 'gf_help' => $min_cap);
$addon_menus = array();
$addon_menus = apply_filters("gform_addon_navigation", $addon_menus);
if (count($addon_menus) > 0) {
foreach ($addon_menus as $addon_menu) {
$gf_caps_map[esc_html($addon_menu['name'])] = $addon_menu['permission'];
}
}
$current_menu['16.9'][1] = $min_cap;
foreach ($current_submenu['gf_edit_forms'] as $key => $item) {
$current_submenu['gf_edit_forms'][$key][1] = $gf_caps_map[$item[2]];
}
}
示例8: init_full_capabilities
private function init_full_capabilities()
{
$this->built_in_wp_caps = $this->get_built_in_wp_caps();
$this->full_capabilities = array();
foreach ($this->roles as $role) {
// validate if capabilities is an array
if (isset($role['capabilities']) && is_array($role['capabilities'])) {
foreach ($role['capabilities'] as $key => $value) {
$this->add_capability_to_full_caps_list($key);
}
}
}
// Get Gravity Forms plugin capabilities, if available
if ($this->integrate_with_gravity_forms) {
$gf_caps = GFCommon::all_caps();
foreach ($gf_caps as $gf_cap) {
$this->add_capability_to_full_caps_list($gf_cap);
}
}
unset($this->built_in_wp_caps);
asort($this->full_capabilities);
}