From 550763988b72ae061f241edf3bc8cca0946efc16 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 27 Jun 2015 01:11:45 +0000 Subject: [PATCH] `ob_get_contents()` followed by `ob_end_clean()` can be replaced by `ob_get_clean()`. See #32444. git-svn-id: https://develop.svn.wordpress.org/trunk@32965 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/ajax-actions.php | 34 +++++++++++-------- .../includes/class-wp-upgrader-skins.php | 3 +- src/wp-admin/includes/plugin.php | 8 ++--- src/wp-admin/includes/theme.php | 8 ++--- .../class-wp-customize-control.php | 4 +-- src/wp-includes/class-wp-customize-panel.php | 4 +-- .../class-wp-customize-section.php | 4 +-- 7 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index f183d0cb01..ba62b66d4d 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -434,10 +434,13 @@ function _wp_ajax_add_hierarchical_term() { $checked_categories[] = $cat_id; if ( $parent ) // Do these all at once in a second continue; + ob_start(); - wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids )); - $data = ob_get_contents(); - ob_end_clean(); + + wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids )); + + $data = ob_get_clean(); + $add = array( 'what' => $taxonomy->name, 'id' => $cat_id, @@ -458,9 +461,11 @@ function _wp_ajax_add_hierarchical_term() { } ob_start(); - wp_terms_checklist( 0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids)); - $data = ob_get_contents(); - ob_end_clean(); + + wp_terms_checklist( 0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids)); + + $data = ob_get_clean(); + $add = array( 'what' => $taxonomy->name, 'id' => $term_id, @@ -470,12 +475,14 @@ function _wp_ajax_add_hierarchical_term() { } ob_start(); - wp_dropdown_categories( array( - 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name', - 'hierarchical' => 1, 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —' - ) ); - $sup = ob_get_contents(); - ob_end_clean(); + + wp_dropdown_categories( array( + 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name', + 'hierarchical' => 1, 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —' + ) ); + + $sup = ob_get_clean(); + $add['supplemental'] = array( 'newcat_parent' => $sup ); $x = new WP_Ajax_Response( $add ); @@ -914,8 +921,7 @@ function wp_ajax_get_comments( $action ) { get_comment( $comment ); $wp_list_table->single_row( $comment ); } - $comment_list_item = ob_get_contents(); - ob_end_clean(); + $comment_list_item = ob_get_clean(); $x->add( array( 'what' => 'comments', diff --git a/src/wp-admin/includes/class-wp-upgrader-skins.php b/src/wp-admin/includes/class-wp-upgrader-skins.php index 89c901174b..bb7325e420 100644 --- a/src/wp-admin/includes/class-wp-upgrader-skins.php +++ b/src/wp-admin/includes/class-wp-upgrader-skins.php @@ -947,9 +947,8 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin { * @access public */ public function footer() { - $output = ob_get_contents(); + $output = ob_get_clean(); if ( ! empty( $output ) ) $this->feedback( $output ); - ob_end_clean(); } } diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index fc434246f0..233d990818 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -771,8 +771,8 @@ function delete_plugins( $plugins, $deprecated = '' ) { ob_start(); $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins'); if ( false === ($credentials = request_filesystem_credentials($url)) ) { - $data = ob_get_contents(); - ob_end_clean(); + $data = ob_get_clean(); + if ( ! empty($data) ){ include_once( ABSPATH . 'wp-admin/admin-header.php'); echo $data; @@ -784,8 +784,8 @@ function delete_plugins( $plugins, $deprecated = '' ) { if ( ! WP_Filesystem($credentials) ) { request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again - $data = ob_get_contents(); - ob_end_clean(); + $data = ob_get_clean(); + if ( ! empty($data) ){ include_once( ABSPATH . 'wp-admin/admin-header.php'); echo $data; diff --git a/src/wp-admin/includes/theme.php b/src/wp-admin/includes/theme.php index 133130305a..80a14b6114 100644 --- a/src/wp-admin/includes/theme.php +++ b/src/wp-admin/includes/theme.php @@ -27,8 +27,8 @@ function delete_theme($stylesheet, $redirect = '') { if ( empty( $redirect ) ) $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet); if ( false === ($credentials = request_filesystem_credentials($redirect)) ) { - $data = ob_get_contents(); - ob_end_clean(); + $data = ob_get_clean(); + if ( ! empty($data) ){ include_once( ABSPATH . 'wp-admin/admin-header.php'); echo $data; @@ -40,8 +40,8 @@ function delete_theme($stylesheet, $redirect = '') { if ( ! WP_Filesystem($credentials) ) { request_filesystem_credentials($redirect, '', true); // Failed to connect, Error and request again - $data = ob_get_contents(); - ob_end_clean(); + $data = ob_get_clean(); + if ( ! empty($data) ) { include_once( ABSPATH . 'wp-admin/admin-header.php'); echo $data; diff --git a/src/wp-includes/class-wp-customize-control.php b/src/wp-includes/class-wp-customize-control.php index 29ddae08af..f972b1d27c 100644 --- a/src/wp-includes/class-wp-customize-control.php +++ b/src/wp-includes/class-wp-customize-control.php @@ -301,9 +301,7 @@ class WP_Customize_Control { final public function get_content() { ob_start(); $this->maybe_render(); - $template = trim( ob_get_contents() ); - ob_end_clean(); - return $template; + return trim( ob_get_clean() ); } /** diff --git a/src/wp-includes/class-wp-customize-panel.php b/src/wp-includes/class-wp-customize-panel.php index c96fd97e2d..72ab1281e1 100644 --- a/src/wp-includes/class-wp-customize-panel.php +++ b/src/wp-includes/class-wp-customize-panel.php @@ -252,9 +252,7 @@ class WP_Customize_Panel { final public function get_content() { ob_start(); $this->maybe_render(); - $template = trim( ob_get_contents() ); - ob_end_clean(); - return $template; + return trim( ob_get_clean() ); } /** diff --git a/src/wp-includes/class-wp-customize-section.php b/src/wp-includes/class-wp-customize-section.php index 7af62189e6..e7befe7bfd 100644 --- a/src/wp-includes/class-wp-customize-section.php +++ b/src/wp-includes/class-wp-customize-section.php @@ -269,9 +269,7 @@ class WP_Customize_Section { final public function get_content() { ob_start(); $this->maybe_render(); - $template = trim( ob_get_contents() ); - ob_end_clean(); - return $template; + return trim( ob_get_clean() ); } /**