if ( is_numeric( $cap ) ) $cap = $this->translate_level_to_cap( $cap ); $args = array_slice( func_get_args(), 1 ); $args = array_merge( array( $cap, $this->ID ), $args ); $caps = call_user_func_array( 'map_meta_cap', $args ); // Must have ALL requested caps $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args ); foreach ( (array) $caps as $cap ) { //echo "Checking cap $cap
"; if ( empty( $capabilities[$cap] ) || !$capabilities[$cap] ) return false; } return true; } /** * Convert numeric level to level capability name. * * Prepends 'level_' to level number. * * @since 2.0.0 * @access public * * @param int $level Level number, 1 to 10. * @return string */ function translate_level_to_cap( $level ) { return 'level_' . $level; } } /** * Map meta capabilities to primitive capabilities. * * This does not actually compare whether the user ID has the actual capability, * just what the capability or capabilities are. Meta capability list value can * be 'delete_user', 'edit_user', 'delete_post', 'delete_page', 'edit_post', * 'edit_page', 'read_post', or 'read_page'. * * @since 2.0.0 * * @param string $cap Capability name. * @param int $user_id User ID. * @return array Actual capabilities for meta capability. */ function map_meta_cap( $cap, $user_id ) { $args = array_slice( func_get_args(), 2 ); $caps = array(); switch ( $cap ) { case 'delete_user': $caps[] = 'delete_users'; break; case 'edit_user': if ( !isset( $args[0] ) || $user_id != $args[0] ) { $caps[] = 'edit_users'; } break; case 'delete_post': $author_data = get_userdata( $user_id ); //echo "post ID: {$args[0]}
"; $post = get_post( $args[0] ); if ( 'page' == $post->post_type ) { $args = array_merge( array( 'delete_page', $user_id ), $args ); return call_user_func_array( 'map_meta_cap', $args ); } if ('' != $post->post_author) { $post_author_data = get_userdata( $post->post_author ); } else { //No author set yet so default to current user for cap checks $post_author_data = $author_data; } // If the user is the author... if ( $user_id == $post_author_data->ID ) { // If the post is published... if ( 'publish' == $post->post_status ) { $caps[] = 'delete_published_posts'; } elseif ( 'trash' == $post->post_status ) { if ('publish' == get_post_meta($post->ID, '_wp_trash_meta_status', true) ) $caps[] = 'delete_published_posts'; } else { // If the post is draft... $caps[] = 'delete_posts'; } } else { // The user is trying to edit someone else's post. $caps[] = 'delete_others_posts'; // The post is published, extra cap required. if ( 'publish' == $post->post_status ) $caps[] = 'delete_published_posts'; elseif ( 'private' == $post->post_status ) $caps[] = 'delete_private_posts'; } break; case 'delete_page': $author_data = get_userdata( $user_id ); //echo "post ID: {$args[0]}
"; $page = get_page( $args[0] ); $page_author_data = get_userdata( $page->post_author ); //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "
"; // If the user is the author... if ('' != $page->post_author) { $page_author_data = get_userdata( $page->post_author ); } else { //No author set yet so default to current user for cap checks $page_author_data = $author_data; } if ( $user_id == $page_author_data->ID ) { // If the page is published... if ( $page->post_status == 'publish' ) { $caps[] = 'delete_published_pages'; } elseif ( 'trash' == $page->post_status ) { if ('publish' == get_post_meta($page->ID, '_wp_trash_meta_status', true) ) $caps[] = 'delete_published_pages'; } else { // If the page is draft... $caps[] = 'delete_pages'; } } else { // The user is trying to edit someone else's page. $caps[] = 'delete_others_pages'; // The page is published, extra cap required. if ( $page->post_status == 'publish' ) $caps[] = 'delete_published_pages'; elseif ( $page->post_status == 'private' ) $caps[] = 'delete_private_pages'; } break; // edit_post breaks down to edit_posts, edit_published_posts, or // edit_others_posts case 'edit_post': $author_data = get_userdata( $user_id ); //echo "post ID: {$args[0]}
"; $post = get_post( $args[0] ); if ( 'page' == $post->post_type ) { $args = array_merge( array( 'edit_page', $user_id ), $args ); return call_user_func_array( 'map_meta_cap', $args ); } $post_author_data = get_userdata( $post->post_author ); //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
"; // If the user is the author... if ( $user_id == $post_author_data->ID ) { // If the post is published... if ( 'publish' == $post->post_status ) { $caps[] = 'edit_published_posts'; } elseif ( 'trash' == $post->post_status ) { if ('publish' == get_post_meta($post->ID, '_wp_trash_meta_status', true) ) $caps[] = 'edit_published_posts'; } else { // If the post is draft... $caps[] = 'edit_posts'; } } else { // The user is trying to edit someone else's post. $caps[] = 'edit_others_posts'; // The post is published, extra cap required. if ( 'publish' == $post->post_status ) $caps[] = 'edit_published_posts'; elseif ( 'private' == $post->post_status ) $caps[] = 'edit_private_posts'; } break; case 'edit_page': $author_data = get_userdata( $user_id ); //echo "post ID: {$args[0]}
"; $page = get_page( $args[0] ); $page_author_data = get_userdata( $page->post_author ); //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "
"; // If the user is the author... if ( $user_id == $page_author_data->ID ) { // If the page is published... if ( 'publish' == $page->post_status ) { $caps[] = 'edit_published_pages'; } elseif ( 'trash' == $page->post_status ) { if ('publish' == get_post_meta($page->ID, '_wp_trash_meta_status', true) ) $caps[] = 'edit_published_pages'; } else { // If the page is draft... $caps[] = 'edit_pages'; } } else { // The user is trying to edit someone else's page. $caps[] = 'edit_others_pages'; // The page is published, extra cap required. if ( 'publish' == $page->post_status ) $caps[] = 'edit_published_pages'; elseif ( 'private' == $page->post_status ) $caps[] = 'edit_private_pages'; } break; case 'read_post': $post = get_post( $args[0] ); if ( 'page' == $post->post_type ) { $args = array_merge( array( 'read_page', $user_id ), $args ); return call_user_func_array( 'map_meta_cap', $args ); } if ( 'private' != $post->post_status ) { $caps[] = 'read'; break; } $author_data = get_userdata( $user_id ); $post_author_data = get_userdata( $post->post_author ); if ( $user_id == $post_author_data->ID ) $caps[] = 'read'; else $caps[] = 'read_private_posts'; break; case 'read_page': $page = get_page( $args[0] ); if ( 'private' != $page->post_status ) { $caps[] = 'read'; break; } $author_data = get_userdata( $user_id ); $page_author_data = get_userdata( $page->post_author ); if ( $user_id == $page_author_data->ID ) $caps[] = 'read'; else $caps[] = 'read_private_pages'; break; case 'unfiltered_upload': if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS == true ) $caps[] = $cap; else $caps[] = 'do_not_allow'; break; default: // If no meta caps match, return the original cap. $caps[] = $cap; } return apply_filters('map_meta_cap', $caps, $cap, $user_id, $args); } /** * Whether current user has capability or role. * * @since 2.0.0 * * @param string $capability Capability or role name. * @return bool */ function current_user_can( $capability ) { $current_user = wp_get_current_user(); if ( empty( $current_user ) ) return false; $args = array_slice( func_get_args(), 1 ); $args = array_merge( array( $capability ), $args ); return call_user_func_array( array( &$current_user, 'has_cap' ), $args ); } /** * Whether author of supplied post has capability or role. * * @since 2.9.0 * * @param int|object $post Post ID or post object. * @param string $capability Capability or role name. * @return bool */ function author_can( $post, $capability ) { if ( !$post = get_post($post) ) return false; $author = new WP_User( $post->post_author ); if ( empty( $author ) ) return false; $args = array_slice( func_get_args(), 2 ); $args = array_merge( array( $capability ), $args ); return call_user_func_array( array( &$author, 'has_cap' ), $args ); } /** * Retrieve role object. * * @see WP_Roles::get_role() Uses method to retrieve role object. * @since 2.0.0 * * @param string $role Role name. * @return object */ function get_role( $role ) { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); return $wp_roles->get_role( $role ); } /** * Add role, if it does not exist. * * @see WP_Roles::add_role() Uses method to add role. * @since 2.0.0 * * @param string $role Role name. * @param string $display_name Display name for role. * @param array $capabilities List of capabilities. * @return null|WP_Role WP_Role object if role is added, null if already exists. */ function add_role( $role, $display_name, $capabilities = array() ) { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); return $wp_roles->add_role( $role, $display_name, $capabilities ); } /** * Remove role, if it exists. * * @see WP_Roles::remove_role() Uses method to remove role. * @since 2.0.0 * * @param string $role Role name. * @return null */ function remove_role( $role ) { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); return $wp_roles->remove_role( $role ); } ?>
Parse error: syntax error, unexpected $end in /mounted-storage/home117a/sub008/sc47939-MTYY/spa-for-you.com/wp-includes/general-template.php on line 1959