PodsAdmin::admin_capabilities PHP Méthode

admin_capabilities() public méthode

Add pods specific capabilities.
public admin_capabilities ( $capabilities ) : array
$capabilities List of extra capabilities to add
Résultat array
    public function admin_capabilities($capabilities)
    {
        $pods = pods_api()->load_pods(array('type' => array('settings', 'post_type', 'taxonomy'), 'fields' => false, 'table_info' => false));
        $other_pods = pods_api()->load_pods(array('type' => array('pod', 'table'), 'table_info' => false));
        $pods = array_merge($pods, $other_pods);
        $capabilities[] = 'pods';
        $capabilities[] = 'pods_content';
        $capabilities[] = 'pods_settings';
        $capabilities[] = 'pods_components';
        foreach ($pods as $pod) {
            if ('settings' == $pod['type']) {
                $capabilities[] = 'pods_edit_' . $pod['name'];
            } elseif ('post_type' == $pod['type']) {
                $capability_type = pods_var('capability_type_custom', $pod['options'], pods_var_raw('name', $pod));
                if ('custom' == pods_var('capability_type', $pod['options']) && 0 < strlen($capability_type)) {
                    $capabilities[] = 'read_' . $capability_type;
                    $capabilities[] = 'edit_' . $capability_type;
                    $capabilities[] = 'delete_' . $capability_type;
                    if (1 == pods_var('capability_type_extra', $pod['options'], 1)) {
                        $capabilities[] = 'read_private_' . $capability_type . 's';
                        $capabilities[] = 'edit_' . $capability_type . 's';
                        $capabilities[] = 'edit_others_' . $capability_type . 's';
                        $capabilities[] = 'edit_private_' . $capability_type . 's';
                        $capabilities[] = 'edit_published_' . $capability_type . 's';
                        $capabilities[] = 'publish_' . $capability_type . 's';
                        $capabilities[] = 'delete_' . $capability_type . 's';
                        $capabilities[] = 'delete_private_' . $capability_type . 's';
                        $capabilities[] = 'delete_published_' . $capability_type . 's';
                        $capabilities[] = 'delete_others_' . $capability_type . 's';
                    }
                }
            } elseif ('taxonomy' == $pod['type']) {
                if ('custom' == pods_var('capability_type', $pod['options'], 'terms')) {
                    $capability_type = pods_var('capability_type_custom', $pod['options'], pods_var_raw('name', $pod) . 's');
                    $capability_type .= '_terms';
                    $capabilities[] = 'manage_' . $capability_type;
                    $capabilities[] = 'edit_' . $capability_type;
                    $capabilities[] = 'delete_' . $capability_type;
                    $capabilities[] = 'assign_' . $capability_type;
                }
            } else {
                $capabilities[] = 'pods_add_' . $pod['name'];
                $capabilities[] = 'pods_edit_' . $pod['name'];
                if (isset($pod['fields']['author']) && 'pick' == $pod['fields']['author']['type'] && 'user' == $pod['fields']['author']['pick_object']) {
                    $capabilities[] = 'pods_edit_others_' . $pod['name'];
                }
                $capabilities[] = 'pods_delete_' . $pod['name'];
                if (isset($pod['fields']['author']) && 'pick' == $pod['fields']['author']['type'] && 'user' == $pod['fields']['author']['pick_object']) {
                    $capabilities[] = 'pods_delete_others_' . $pod['name'];
                }
                $actions_enabled = pods_var_raw('ui_actions_enabled', $pod['options']);
                if (!empty($actions_enabled)) {
                    $actions_enabled = (array) $actions_enabled;
                } else {
                    $actions_enabled = array();
                }
                $available_actions = array('add', 'edit', 'duplicate', 'delete', 'reorder', 'export');
                if (!empty($actions_enabled)) {
                    $actions_disabled = array('view' => 'view');
                    foreach ($available_actions as $action) {
                        if (!in_array($action, $actions_enabled)) {
                            $actions_disabled[$action] = $action;
                        }
                    }
                    if (!in_array('export', $actions_disabled)) {
                        $capabilities[] = 'pods_export_' . $pod['name'];
                    }
                    if (!in_array('reorder', $actions_disabled)) {
                        $capabilities[] = 'pods_reorder_' . $pod['name'];
                    }
                } elseif (1 == pods_var('ui_export', $pod['options'], 0)) {
                    $capabilities[] = 'pods_export_' . $pod['name'];
                }
            }
        }
        return $capabilities;
    }