/** * Filters a list of objects, based on a set of key => value arguments. * * @since 3.0.0 * * @param array $list An array of objects to filter * @param array $args An array of key => value arguments to match against each object * @param string $operator The logical operation to perform. 'or' means only one element * from the array needs to match; 'and' means all elements must match. The default is 'and'. * @param bool|string $field A field from the object to place instead of the entire object * @return array A list of objects or object fields */ function nxt_filter_object_list($list, $args = array(), $operator = 'and', $field = false) { if (!is_array($list)) { return array(); } $list = nxt_list_filter($list, $args, $operator); if ($field) { $list = nxt_list_pluck($list, $field); } return $list; }
function _access_denied_splash() { if (!is_user_logged_in() || is_network_admin()) { return; } $blogs = get_blogs_of_user(get_current_user_id()); if (nxt_list_filter($blogs, array('userblog_id' => get_current_blog_id()))) { return; } $blog_name = get_bloginfo('name'); if (empty($blogs)) { nxt_die(sprintf(__('You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.'), $blog_name)); } $output = '<p>' . sprintf(__('You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.'), $blog_name) . '</p>'; $output .= '<p>' . __('If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.') . '</p>'; $output .= '<h3>' . __('Your Sites') . '</h3>'; $output .= '<table>'; foreach ($blogs as $blog) { $output .= "<tr>"; $output .= "<td valign='top'>"; $output .= "{$blog->blogname}"; $output .= "</td>"; $output .= "<td valign='top'>"; $output .= "<a href='" . esc_url(get_admin_url($blog->userblog_id)) . "'>" . __('Visit Dashboard') . "</a> | <a href='" . esc_url(get_home_url($blog->userblog_id)) . "'>" . __('View Site') . "</a>"; $output .= "</td>"; $output .= "</tr>"; } $output .= '</table>'; nxt_die($output); }
/** * Retrieve queried object. * * If queried object is not set, then the queried object will be set from * the category, tag, taxonomy, posts page, single post, page, or author * query variable. After it is set up, it will be returned. * * @since 1.5.0 * @access public * * @return object */ function get_queried_object() { if (isset($this->queried_object)) { return $this->queried_object; } $this->queried_object = NULL; $this->queried_object_id = 0; if ($this->is_category || $this->is_tag || $this->is_tax) { $tax_query_in_and = nxt_list_filter($this->tax_query->queries, array('operator' => 'NOT IN'), 'NOT'); $query = reset($tax_query_in_and); if ('term_id' == $query['field']) { $term = get_term(reset($query['terms']), $query['taxonomy']); } else { $term = get_term_by($query['field'], reset($query['terms']), $query['taxonomy']); } if ($term && !is_nxt_error($term)) { $this->queried_object = $term; $this->queried_object_id = (int) $term->term_id; if ($this->is_category) { _make_cat_compat($this->queried_object); } } } elseif ($this->is_post_type_archive) { $this->queried_object = get_post_type_object($this->get('post_type')); } elseif ($this->is_posts_page) { $page_for_posts = get_option('page_for_posts'); $this->queried_object =& get_page($page_for_posts); $this->queried_object_id = (int) $this->queried_object->ID; } elseif ($this->is_singular && !is_null($this->post)) { $this->queried_object = $this->post; $this->queried_object_id = (int) $this->post->ID; } elseif ($this->is_author) { $this->queried_object_id = (int) $this->get('author'); $this->queried_object = get_userdata($this->queried_object_id); } return $this->queried_object; }