mirror of
git://develop.git.wordpress.org/
synced 2025-04-12 16:15:07 +02:00
Coding Standards: Improve formatting of some SQL queries for better readability.
This corrects the placement of double quotes around the query and makes sure the alignment is consistent. Props umeshmcakadi, mukesh27, krupalpanchal, dhrumilk, SergeyBiryukov. Fixes #58372. git-svn-id: https://develop.svn.wordpress.org/trunk@55857 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
69718b2612
commit
febce4a482
@ -141,12 +141,10 @@ function export_date_options( $post_type = 'post' ) {
|
||||
|
||||
$months = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = %s AND post_status != 'auto-draft'
|
||||
ORDER BY post_date DESC
|
||||
",
|
||||
"SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = %s AND post_status != 'auto-draft'
|
||||
ORDER BY post_date DESC",
|
||||
$post_type
|
||||
)
|
||||
);
|
||||
|
@ -698,13 +698,11 @@ class WP_List_Table {
|
||||
|
||||
$months = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = %s
|
||||
$extra_checks
|
||||
ORDER BY post_date DESC
|
||||
",
|
||||
"SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = %s
|
||||
$extra_checks
|
||||
ORDER BY post_date DESC",
|
||||
$post_type
|
||||
)
|
||||
);
|
||||
|
@ -1010,11 +1010,10 @@ function get_meta_keys() {
|
||||
global $wpdb;
|
||||
|
||||
$keys = $wpdb->get_col(
|
||||
"
|
||||
SELECT meta_key
|
||||
FROM $wpdb->postmeta
|
||||
GROUP BY meta_key
|
||||
ORDER BY meta_key"
|
||||
"SELECT meta_key
|
||||
FROM $wpdb->postmeta
|
||||
GROUP BY meta_key
|
||||
ORDER BY meta_key"
|
||||
);
|
||||
|
||||
return $keys;
|
||||
|
@ -466,13 +466,13 @@ class WP_Tax_Query {
|
||||
|
||||
$where = $wpdb->prepare(
|
||||
"$operator (
|
||||
SELECT 1
|
||||
FROM $wpdb->term_relationships
|
||||
INNER JOIN $wpdb->term_taxonomy
|
||||
ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id
|
||||
WHERE $wpdb->term_taxonomy.taxonomy = %s
|
||||
AND $wpdb->term_relationships.object_id = $this->primary_table.$this->primary_id_column
|
||||
)",
|
||||
SELECT 1
|
||||
FROM $wpdb->term_relationships
|
||||
INNER JOIN $wpdb->term_taxonomy
|
||||
ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id
|
||||
WHERE $wpdb->term_taxonomy.taxonomy = %s
|
||||
AND $wpdb->term_relationships.object_id = $this->primary_table.$this->primary_id_column
|
||||
)",
|
||||
$clause['taxonomy']
|
||||
);
|
||||
|
||||
|
@ -1009,8 +1009,7 @@ class WP_User_Query {
|
||||
FROM $wpdb->posts
|
||||
$where
|
||||
GROUP BY post_author
|
||||
) p ON ({$wpdb->users}.ID = p.post_author)
|
||||
";
|
||||
) p ON ({$wpdb->users}.ID = p.post_author)";
|
||||
$_orderby = 'post_count';
|
||||
} elseif ( 'ID' === $orderby || 'id' === $orderby ) {
|
||||
$_orderby = 'ID';
|
||||
|
@ -4562,22 +4562,18 @@ function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' )
|
||||
$post_type = esc_sql( $post_type );
|
||||
$post_type_in_string = "'" . implode( "','", $post_type ) . "'";
|
||||
$sql = $wpdb->prepare(
|
||||
"
|
||||
SELECT ID
|
||||
"SELECT ID
|
||||
FROM $wpdb->posts
|
||||
WHERE post_title = %s
|
||||
AND post_type IN ($post_type_in_string)
|
||||
",
|
||||
AND post_type IN ($post_type_in_string)",
|
||||
$page_title
|
||||
);
|
||||
} else {
|
||||
$sql = $wpdb->prepare(
|
||||
"
|
||||
SELECT ID
|
||||
"SELECT ID
|
||||
FROM $wpdb->posts
|
||||
WHERE post_title = %s
|
||||
AND post_type = %s
|
||||
",
|
||||
AND post_type = %s",
|
||||
$page_title,
|
||||
$post_type
|
||||
);
|
||||
|
@ -2298,16 +2298,16 @@ function get_calendar( $initial = true, $display = true ) {
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date < '$thisyear-$thismonth-01'
|
||||
AND post_type = 'post' AND post_status = 'publish'
|
||||
ORDER BY post_date DESC
|
||||
LIMIT 1"
|
||||
ORDER BY post_date DESC
|
||||
LIMIT 1"
|
||||
);
|
||||
$next = $wpdb->get_row(
|
||||
"SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
|
||||
AND post_type = 'post' AND post_status = 'publish'
|
||||
ORDER BY post_date ASC
|
||||
LIMIT 1"
|
||||
ORDER BY post_date ASC
|
||||
LIMIT 1"
|
||||
);
|
||||
|
||||
/* translators: Calendar caption: 1: Month name, 2: 4-digit year. */
|
||||
|
@ -4484,13 +4484,11 @@ function wp_enqueue_media( $args = array() ) {
|
||||
$show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', true );
|
||||
if ( null === $show_audio_playlist ) {
|
||||
$show_audio_playlist = $wpdb->get_var(
|
||||
"
|
||||
SELECT ID
|
||||
"SELECT ID
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = 'attachment'
|
||||
AND post_mime_type LIKE 'audio%'
|
||||
LIMIT 1
|
||||
"
|
||||
LIMIT 1"
|
||||
);
|
||||
}
|
||||
|
||||
@ -4514,13 +4512,11 @@ function wp_enqueue_media( $args = array() ) {
|
||||
$show_video_playlist = apply_filters( 'media_library_show_video_playlist', true );
|
||||
if ( null === $show_video_playlist ) {
|
||||
$show_video_playlist = $wpdb->get_var(
|
||||
"
|
||||
SELECT ID
|
||||
"SELECT ID
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = 'attachment'
|
||||
AND post_mime_type LIKE 'video%'
|
||||
LIMIT 1
|
||||
"
|
||||
LIMIT 1"
|
||||
);
|
||||
}
|
||||
|
||||
@ -4543,12 +4539,10 @@ function wp_enqueue_media( $args = array() ) {
|
||||
if ( ! is_array( $months ) ) {
|
||||
$months = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = %s
|
||||
ORDER BY post_date DESC
|
||||
",
|
||||
"SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = %s
|
||||
ORDER BY post_date DESC",
|
||||
'attachment'
|
||||
)
|
||||
);
|
||||
|
@ -3545,12 +3545,10 @@ function wp_get_users_with_no_role( $site_id = null ) {
|
||||
$regex = preg_replace( '/[^a-zA-Z_\|-]/', '', $regex );
|
||||
$users = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
SELECT user_id
|
||||
FROM $wpdb->usermeta
|
||||
WHERE meta_key = '{$prefix}capabilities'
|
||||
AND meta_value NOT REGEXP %s
|
||||
",
|
||||
"SELECT user_id
|
||||
FROM $wpdb->usermeta
|
||||
WHERE meta_key = '{$prefix}capabilities'
|
||||
AND meta_value NOT REGEXP %s",
|
||||
$regex
|
||||
)
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user