Jetpack::jetpack_custom_caps PHP Method

jetpack_custom_caps() public method

public jetpack_custom_caps ( $caps, $cap, $user_id, $args )
    function jetpack_custom_caps($caps, $cap, $user_id, $args)
    {
        switch ($cap) {
            case 'jetpack_connect':
            case 'jetpack_reconnect':
                if (Jetpack::is_development_mode()) {
                    $caps = array('do_not_allow');
                    break;
                }
                /**
                 * Pass through. If it's not development mode, these should match disconnect.
                 * Let users disconnect if it's development mode, just in case things glitch.
                 */
            /**
             * Pass through. If it's not development mode, these should match disconnect.
             * Let users disconnect if it's development mode, just in case things glitch.
             */
            case 'jetpack_disconnect':
                /**
                 * In multisite, can individual site admins manage their own connection?
                 *
                 * Ideally, this should be extracted out to a separate filter in the Jetpack_Network class.
                 */
                if (is_multisite() && !is_super_admin() && is_plugin_active_for_network('jetpack/jetpack.php')) {
                    if (!Jetpack_Network::init()->get_option('sub-site-connection-override')) {
                        /**
                         * We need to update the option name -- it's terribly unclear which
                         * direction the override goes.
                         *
                         * @todo: Update the option name to `sub-sites-can-manage-own-connections`
                         */
                        $caps = array('do_not_allow');
                        break;
                    }
                }
                $caps = array('manage_options');
                break;
            case 'jetpack_manage_modules':
            case 'jetpack_activate_modules':
            case 'jetpack_deactivate_modules':
                $caps = array('manage_options');
                break;
            case 'jetpack_configure_modules':
                $caps = array('manage_options');
                break;
            case 'jetpack_network_admin_page':
            case 'jetpack_network_settings_page':
                $caps = array('manage_network_plugins');
                break;
            case 'jetpack_network_sites_page':
                $caps = array('manage_sites');
                break;
            case 'jetpack_admin_page':
                if (Jetpack::is_development_mode()) {
                    $caps = array('manage_options');
                    break;
                } else {
                    $caps = array('read');
                }
                break;
            case 'jetpack_connect_user':
                if (Jetpack::is_development_mode()) {
                    $caps = array('do_not_allow');
                    break;
                }
                $caps = array('read');
                break;
        }
        return $caps;
    }
Jetpack