mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Move WP_Query and its wrapper functions to query.php. #2525
git-svn-id: https://develop.svn.wordpress.org/trunk@3639 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1470,11 +1470,6 @@ function get_posts($args) {
|
||||
return $posts;
|
||||
}
|
||||
|
||||
function &query_posts($query) {
|
||||
global $wp_query;
|
||||
return $wp_query->query($query);
|
||||
}
|
||||
|
||||
function update_post_cache(&$posts) {
|
||||
global $post_cache;
|
||||
|
||||
@@ -1583,216 +1578,6 @@ function wp_footer() {
|
||||
do_action('wp_footer');
|
||||
}
|
||||
|
||||
function is_single ($post = '') {
|
||||
global $wp_query;
|
||||
|
||||
if ( !$wp_query->is_single )
|
||||
return false;
|
||||
|
||||
if ( empty( $post) )
|
||||
return true;
|
||||
|
||||
$post_obj = $wp_query->get_queried_object();
|
||||
|
||||
if ( $post == $post_obj->ID )
|
||||
return true;
|
||||
elseif ( $post == $post_obj->post_title )
|
||||
return true;
|
||||
elseif ( $post == $post_obj->post_name )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_page ($page = '') {
|
||||
global $wp_query;
|
||||
|
||||
if ( !$wp_query->is_page )
|
||||
return false;
|
||||
|
||||
if ( empty($page) )
|
||||
return true;
|
||||
|
||||
$page_obj = $wp_query->get_queried_object();
|
||||
|
||||
if ( $page == $page_obj->ID )
|
||||
return true;
|
||||
elseif ( $page == $page_obj->post_title )
|
||||
return true;
|
||||
else if ( $page == $page_obj->post_name )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_attachment () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_attachment;
|
||||
}
|
||||
|
||||
function is_preview() {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_preview;
|
||||
}
|
||||
|
||||
function is_archive () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_archive;
|
||||
}
|
||||
|
||||
function is_date () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_date;
|
||||
}
|
||||
|
||||
function is_year () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_year;
|
||||
}
|
||||
|
||||
function is_month () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_month;
|
||||
}
|
||||
|
||||
function is_day () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_day;
|
||||
}
|
||||
|
||||
function is_time () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_time;
|
||||
}
|
||||
|
||||
function is_author ($author = '') {
|
||||
global $wp_query;
|
||||
|
||||
if ( !$wp_query->is_author )
|
||||
return false;
|
||||
|
||||
if ( empty($author) )
|
||||
return true;
|
||||
|
||||
$author_obj = $wp_query->get_queried_object();
|
||||
|
||||
if ( $author == $author_obj->ID )
|
||||
return true;
|
||||
elseif ( $author == $author_obj->nickname )
|
||||
return true;
|
||||
elseif ( $author == $author_obj->user_nicename )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_category ($category = '') {
|
||||
global $wp_query;
|
||||
|
||||
if ( !$wp_query->is_category )
|
||||
return false;
|
||||
|
||||
if ( empty($category) )
|
||||
return true;
|
||||
|
||||
$cat_obj = $wp_query->get_queried_object();
|
||||
|
||||
if ( $category == $cat_obj->cat_ID )
|
||||
return true;
|
||||
else if ( $category == $cat_obj->cat_name )
|
||||
return true;
|
||||
elseif ( $category == $cat_obj->category_nicename )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_search () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_search;
|
||||
}
|
||||
|
||||
function is_feed () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_feed;
|
||||
}
|
||||
|
||||
function is_trackback () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_trackback;
|
||||
}
|
||||
|
||||
function is_admin () {
|
||||
global $wp_query;
|
||||
|
||||
return ( $wp_query->is_admin || strstr($_SERVER['REQUEST_URI'], 'wp-admin/') );
|
||||
}
|
||||
|
||||
function is_home () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_home;
|
||||
}
|
||||
|
||||
function is_404 () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_404;
|
||||
}
|
||||
|
||||
function is_comments_popup () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_comments_popup;
|
||||
}
|
||||
|
||||
function is_paged () {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->is_paged;
|
||||
}
|
||||
|
||||
function in_the_loop() {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->in_the_loop;
|
||||
}
|
||||
|
||||
function get_query_var($var) {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->get($var);
|
||||
}
|
||||
|
||||
function have_posts() {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->have_posts();
|
||||
}
|
||||
|
||||
function rewind_posts() {
|
||||
global $wp_query;
|
||||
|
||||
return $wp_query->rewind_posts();
|
||||
}
|
||||
|
||||
function the_post() {
|
||||
global $wp_query;
|
||||
|
||||
$wp_query->the_post();
|
||||
}
|
||||
|
||||
function get_theme_root() {
|
||||
return apply_filters('theme_root', ABSPATH . "wp-content/themes");
|
||||
}
|
||||
@@ -2163,16 +1948,6 @@ function htmlentities2($myHTML) {
|
||||
return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($myHTML, $translation_table));
|
||||
}
|
||||
|
||||
|
||||
function is_plugin_page() {
|
||||
global $plugin_page;
|
||||
|
||||
if ( isset($plugin_page) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
add_query_arg: Returns a modified querystring by adding
|
||||
a single key & value or an associative array.
|
||||
|
||||
Reference in New Issue
Block a user