Avoid PHP notices in get_sample_permalink() and get_sample_permalink_html(). Remove unused global reference. props ocean90. fixes #25005.

Built from https://develop.svn.wordpress.org/trunk@25028


git-svn-id: http://core.svn.wordpress.org/trunk@25015 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2013-08-15 16:25:12 +00:00
parent a872d95778
commit aadd546d48
8 changed files with 37 additions and 22 deletions

View File

@ -241,10 +241,11 @@ function wp_ajax_logged_in() {
* @return die
*/
function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
$total = (int) @$_POST['_total'];
$per_page = (int) @$_POST['_per_page'];
$page = (int) @$_POST['_page'];
$url = esc_url_raw( @$_POST['_url'] );
$total = isset( $_POST['_total'] ) ? (int) $_POST['_total'] : 0;
$per_page = isset( $_POST['_per_page'] ) ? (int) $_POST['_per_page'] : 0;
$page = isset( $_POST['_page'] ) ? (int) $_POST['_page'] : 0;
$url = isset( $_POST['_url'] ) ? esc_url_raw( $_POST['_url'] ) : '';
// JS didn't send us everything we need to know. Just die with success message
if ( !$total || !$per_page || !$page || !$url )
wp_die( time() );

View File

@ -192,8 +192,12 @@ class WP_Filesystem_Base {
$folder = untrailingslashit($folder);
if ( $this->verbose )
printf( "\n" . __('Looking for %1$s in %2$s') . "<br/>\n", $folder, $base );
$folder_parts = explode('/', $folder);
$last_index = array_pop( array_keys( $folder_parts ) );
$folder_part_keys = array_keys( $folder_parts );
$last_index = array_pop( $folder_part_keys );
$last_path = $folder_parts[ $last_index ];
$files = $this->dirlist( $base );
@ -210,7 +214,7 @@ class WP_Filesystem_Base {
//Lets try that folder:
$newdir = trailingslashit(path_join($base, $key));
if ( $this->verbose )
printf( __('Changing to %s') . '<br/>', $newdir );
printf( "\n" . __('Changing to %s') . "<br/>\n", $newdir );
// only search for the remaining path tokens in the directory, not the full path again
$newfolder = implode( '/', array_slice( $folder_parts, $index + 1 ) );
if ( $ret = $this->search_for_folder( $newfolder, $newdir, $loop) )
@ -221,13 +225,18 @@ class WP_Filesystem_Base {
//Only check this as a last resort, to prevent locating the incorrect install. All above procedures will fail quickly if this is the right branch to take.
if (isset( $files[ $last_path ] ) ) {
if ( $this->verbose )
printf( __('Found %s') . '<br/>', $base . $last_path );
printf( "\n" . __('Found %s') . "<br/>\n", $base . $last_path );
return trailingslashit($base . $last_path);
}
if ( $loop )
return false; //Prevent this function from looping again.
//As an extra last resort, Change back to / if the folder wasn't found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups.
return $this->search_for_folder($folder, '/', true);
// Prevent this function from looping again.
// No need to proceed if we've just searched in /
if ( $loop || '/' == $base )
return false;
// As an extra last resort, Change back to / if the folder wasn't found.
// This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
return $this->search_for_folder( $folder, '/', true );
}

View File

@ -2077,17 +2077,18 @@ $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmon
$arc_result = $wpdb->get_results( $arc_query );
$month_count = count($arc_result);
$selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0;
if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?>
<select name='m'>
<option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
<option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
<?php
foreach ($arc_result as $arc_row) {
if ( $arc_row->yyear == 0 )
continue;
$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
if ( isset($_GET['m']) && ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) )
if ( $arc_row->yyear . $arc_row->mmonth == $selected_month )
$default = ' selected="selected"';
else
$default = '';

View File

@ -996,9 +996,9 @@ function postbox_classes( $id, $page ) {
* @return array With two entries of type string
*/
function get_sample_permalink($id, $title = null, $name = null) {
$post = get_post($id);
if ( !$post->ID )
return array('', '');
$post = get_post( $id );
if ( ! $post )
return array( '', '' );
$ptype = get_post_type_object($post->post_type);
@ -1058,8 +1058,9 @@ function get_sample_permalink($id, $title = null, $name = null) {
* @return string The HTML of the sample permalink slug editor.
*/
function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
global $wpdb;
$post = get_post($id);
$post = get_post( $id );
if ( ! $post )
return '';
list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);

View File

@ -862,7 +862,7 @@
if ( 9 === event.which ) // tab
return;
if ( 13 === event.which ) // enter
parent.send( 'close' );
this.click();
event.preventDefault();
});

File diff suppressed because one or more lines are too long

View File

@ -875,7 +875,7 @@ function wp_list_pages($args = '') {
*
* <ul>
* <li><strong>sort_column</strong> - How to sort the list of pages. Defaults
* to page title. Use column for posts table.</li>
* to 'menu_order, post_title'. Use column for posts table.</li>
* <li><strong>menu_class</strong> - Class to use for the div ID which contains
* the page list. Defaults to 'menu'.</li>
* <li><strong>echo</strong> - Whether to echo list or return it. Defaults to

View File

@ -647,7 +647,10 @@ function preview_theme_ob_filter_callback( $matches ) {
)
return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4];
$link = add_query_arg( array( 'preview' => 1, 'template' => $_GET['template'], 'stylesheet' => @$_GET['stylesheet'], 'preview_iframe' => 1 ), $matches[3] );
$stylesheet = isset( $_GET['stylesheet'] ) ? $_GET['stylesheet'] : '';
$template = isset( $_GET['template'] ) ? $_GET['template'] : '';
$link = add_query_arg( array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1 ), $matches[3] );
if ( 0 === strpos($link, 'preview=1') )
$link = "?$link";
return $matches[1] . esc_attr( $link ) . $matches[4];