mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
Fix syntax for single- and multi-line comments in wp-admin-directory files.
See #28931. Built from https://develop.svn.wordpress.org/trunk@29206 git-svn-id: http://core.svn.wordpress.org/trunk@28990 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e731028303
commit
097dc8ee15
@ -151,7 +151,8 @@ if ( isset($plugin_page) ) {
|
||||
$the_parent = $pagenow;
|
||||
if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
|
||||
$page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
|
||||
// backwards compatibility for plugins using add_management_page
|
||||
|
||||
// Backwards compatibility for plugins using add_management_page().
|
||||
if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) {
|
||||
// There could be plugin specific params on the URL, so we need the whole query string
|
||||
if ( !empty($_SERVER[ 'QUERY_STRING' ]) )
|
||||
|
@ -94,10 +94,10 @@ if ( is_wp_error($id) ) {
|
||||
}
|
||||
|
||||
if ( $_REQUEST['short'] ) {
|
||||
// short form response - attachment ID only
|
||||
// Short form response - attachment ID only.
|
||||
echo $id;
|
||||
} else {
|
||||
// long form response - big chunk o html
|
||||
// Long form response - big chunk o html.
|
||||
$type = $_REQUEST['type'];
|
||||
|
||||
/**
|
||||
|
@ -256,7 +256,8 @@ class Custom_Background {
|
||||
|
||||
if ( get_background_image() ) {
|
||||
$background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', get_background_image() ) ) ) );
|
||||
// background-image URL must be single quote, see below
|
||||
|
||||
// Background-image URL must be single quote, see below.
|
||||
$background_styles .= ' background-image: url(\'' . $background_image_thumb . '\');'
|
||||
. ' background-repeat: ' . get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ) . ';'
|
||||
. ' background-position: top ' . get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
|
||||
|
@ -934,7 +934,7 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
||||
$url = $object['guid'];
|
||||
$this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) );
|
||||
|
||||
// cleanup
|
||||
// Cleanup.
|
||||
$medium = str_replace( basename( $original ), 'midsize-' . basename( $original ), $original );
|
||||
if ( file_exists( $medium ) ) {
|
||||
/**
|
||||
|
@ -189,12 +189,14 @@ do_action( 'customize_controls_print_scripts' );
|
||||
*/
|
||||
do_action( 'customize_controls_print_footer_scripts' );
|
||||
|
||||
// If the frontend and the admin are served from the same domain, load the
|
||||
// preview over ssl if the customizer is being loaded over ssl. This avoids
|
||||
// insecure content warnings. This is not attempted if the admin and frontend
|
||||
// are on different domains to avoid the case where the frontend doesn't have
|
||||
// ssl certs. Domain mapping plugins can allow other urls in these conditions
|
||||
// using the customize_allowed_urls filter.
|
||||
/*
|
||||
* If the frontend and the admin are served from the same domain, load the
|
||||
* preview over ssl if the customizer is being loaded over ssl. This avoids
|
||||
* insecure content warnings. This is not attempted if the admin and frontend
|
||||
* are on different domains to avoid the case where the frontend doesn't have
|
||||
* ssl certs. Domain mapping plugins can allow other urls in these conditions
|
||||
* using the customize_allowed_urls filter.
|
||||
*/
|
||||
|
||||
$allowed_urls = array( home_url('/') );
|
||||
$admin_origin = parse_url( admin_url() );
|
||||
|
@ -7,9 +7,11 @@
|
||||
*/
|
||||
|
||||
if ( ! defined('WP_ADMIN') ) {
|
||||
// This file is being included from a file other than wp-admin/admin.php, so
|
||||
// some setup was skipped. Make sure the admin message catalog is loaded since
|
||||
// load_default_textdomain() will not have done so in this context.
|
||||
/*
|
||||
* This file is being included from a file other than wp-admin/admin.php, so
|
||||
* some setup was skipped. Make sure the admin message catalog is loaded since
|
||||
* load_default_textdomain() will not have done so in this context.
|
||||
*/
|
||||
load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' );
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
function wp_ajax_nopriv_heartbeat() {
|
||||
$response = array();
|
||||
|
||||
// screen_id is the same as $current_screen->id and the JS global 'pagenow'
|
||||
// screen_id is the same as $current_screen->id and the JS global 'pagenow'.
|
||||
if ( ! empty($_POST['screen_id']) )
|
||||
$screen_id = sanitize_key($_POST['screen_id']);
|
||||
else
|
||||
@ -64,7 +64,7 @@ function wp_ajax_nopriv_heartbeat() {
|
||||
*/
|
||||
do_action( 'heartbeat_nopriv_tick', $response, $screen_id );
|
||||
|
||||
// send the current time according to the server
|
||||
// Send the current time according to the server.
|
||||
$response['server_time'] = time();
|
||||
|
||||
wp_send_json($response);
|
||||
@ -362,16 +362,19 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
|
||||
|
||||
$comment_count = wp_count_comments($post_id);
|
||||
|
||||
if ( isset( $comment_count->$status ) ) // We're looking for a known type of comment count
|
||||
// We're looking for a known type of comment count.
|
||||
if ( isset( $comment_count->$status ) )
|
||||
$total = $comment_count->$status;
|
||||
// else use the decremented value from above
|
||||
// Else use the decremented value from above.
|
||||
}
|
||||
|
||||
$time = time(); // The time since the last comment count
|
||||
// The time since the last comment count.
|
||||
$time = time();
|
||||
|
||||
$x = new WP_Ajax_Response( array(
|
||||
'what' => 'comment',
|
||||
'id' => $comment_id, // here for completeness - not used
|
||||
// Here for completeness - not used.
|
||||
'id' => $comment_id,
|
||||
'supplemental' => array(
|
||||
'total_items_i18n' => sprintf( _n( '1 item', '%s items', $total ), number_format_i18n( $total ) ),
|
||||
'total_pages' => ceil( $total / $per_page ),
|
||||
@ -955,7 +958,7 @@ function wp_ajax_replyto_comment( $action ) {
|
||||
$comment_auto_approved = false;
|
||||
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
|
||||
|
||||
// automatically approve parent comment
|
||||
// Automatically approve parent comment.
|
||||
if ( !empty($_POST['approve_parent']) ) {
|
||||
$parent = get_comment( $comment_parent );
|
||||
|
||||
@ -1512,18 +1515,20 @@ function wp_ajax_inline_save() {
|
||||
$data = &$_POST;
|
||||
|
||||
$post = get_post( $post_ID, ARRAY_A );
|
||||
$post = wp_slash($post); //since it is from db
|
||||
|
||||
// Since it's coming from the database.
|
||||
$post = wp_slash($post);
|
||||
|
||||
$data['content'] = $post['post_content'];
|
||||
$data['excerpt'] = $post['post_excerpt'];
|
||||
|
||||
// rename
|
||||
// Rename.
|
||||
$data['user_ID'] = get_current_user_id();
|
||||
|
||||
if ( isset($data['post_parent']) )
|
||||
$data['parent_id'] = $data['post_parent'];
|
||||
|
||||
// status
|
||||
// Status.
|
||||
if ( isset($data['keep_private']) && 'private' == $data['keep_private'] )
|
||||
$data['post_status'] = 'private';
|
||||
else
|
||||
@ -1540,7 +1545,7 @@ function wp_ajax_inline_save() {
|
||||
$data['post_name'] = wp_unique_post_slug( $data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent'] );
|
||||
}
|
||||
|
||||
// update the post
|
||||
// Update the post.
|
||||
edit_post();
|
||||
|
||||
$wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) );
|
||||
@ -1686,7 +1691,7 @@ function wp_ajax_widgets_order() {
|
||||
|
||||
unset( $_POST['savewidgets'], $_POST['action'] );
|
||||
|
||||
// save widgets order for all sidebars
|
||||
// Save widgets order for all sidebars.
|
||||
if ( is_array($_POST['sidebars']) ) {
|
||||
$sidebars = array();
|
||||
foreach ( $_POST['sidebars'] as $key => $val ) {
|
||||
@ -1751,7 +1756,7 @@ function wp_ajax_save_widget() {
|
||||
$sidebars = wp_get_sidebars_widgets();
|
||||
$sidebar = isset($sidebars[$sidebar_id]) ? $sidebars[$sidebar_id] : array();
|
||||
|
||||
// delete
|
||||
// Delete.
|
||||
if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
|
||||
|
||||
if ( !isset($wp_registered_widgets[$widget_id]) )
|
||||
@ -2411,9 +2416,11 @@ function wp_ajax_send_link_to_editor() {
|
||||
$title = wp_basename( $src );
|
||||
|
||||
$post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 );
|
||||
// ping WordPress for an embed
|
||||
|
||||
// Ping WordPress for an embed.
|
||||
$check_embed = $wp_embed->run_shortcode( '[embed]'. $src .'[/embed]' );
|
||||
// fallback that WordPress creates when no oEmbed was found
|
||||
|
||||
// Fallback that WordPress creates when no oEmbed was found.
|
||||
$fallback = $wp_embed->maybe_make_link( $src );
|
||||
|
||||
if ( $check_embed !== $fallback ) {
|
||||
@ -2456,7 +2463,7 @@ function wp_ajax_heartbeat() {
|
||||
wp_send_json($response);
|
||||
}
|
||||
|
||||
// screen_id is the same as $current_screen->id and the JS global 'pagenow'
|
||||
// screen_id is the same as $current_screen->id and the JS global 'pagenow'.
|
||||
if ( ! empty($_POST['screen_id']) )
|
||||
$screen_id = sanitize_key($_POST['screen_id']);
|
||||
else
|
||||
|
@ -424,7 +424,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
if ( $user_can ) {
|
||||
// preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
|
||||
// Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash.
|
||||
$actions = array(
|
||||
'approve' => '', 'unapprove' => '',
|
||||
'reply' => '',
|
||||
@ -434,7 +434,8 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
'trash' => '', 'untrash' => '', 'delete' => ''
|
||||
);
|
||||
|
||||
if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
|
||||
// Not looking at all comments.
|
||||
if ( $comment_status && 'all' != $comment_status ) {
|
||||
if ( 'approved' == $the_comment_status )
|
||||
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved' class='vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
else if ( 'unapproved' == $the_comment_status )
|
||||
|
@ -308,16 +308,21 @@ class WP_Filesystem_Base {
|
||||
if ( $index == $last_index )
|
||||
continue; // We want this to be caught by the next code block.
|
||||
|
||||
// Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
|
||||
// If it's found, change into it and follow through looking for it.
|
||||
// If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on.
|
||||
// If it reaches the end, and still cant find it, it'll return false for the entire function.
|
||||
/*
|
||||
* Working from /home/ to /user/ to /wordpress/ see if that file exists within
|
||||
* the current folder, If it's found, change into it and follow through looking
|
||||
* for it. If it cant find WordPress down that route, it'll continue onto the next
|
||||
* folder level, and see if that matches, and so on. If it reaches the end, and still
|
||||
* cant find it, it'll return false for the entire function.
|
||||
*/
|
||||
if ( isset($files[ $key ]) ){
|
||||
|
||||
// Lets try that folder:
|
||||
$newdir = trailingslashit(path_join($base, $key));
|
||||
if ( $this->verbose )
|
||||
printf( "\n" . __('Changing to %s') . "<br/>\n", $newdir );
|
||||
// only search for the remaining path tokens in the directory, not the full path again
|
||||
|
||||
// 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) )
|
||||
return $ret;
|
||||
|
@ -224,7 +224,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
if ( ! $overwrite && $this->exists($destination) )
|
||||
return false;
|
||||
|
||||
// try using rename first. if that fails (for example, source is read only) try copy
|
||||
// Try using rename first. if that fails (for example, source is read only) try copy.
|
||||
if ( @rename($source, $destination) )
|
||||
return true;
|
||||
|
||||
@ -305,7 +305,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
}
|
||||
|
||||
public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
|
||||
// safe mode fails with a trailing slash under certain PHP versions.
|
||||
// Safe mode fails with a trailing slash under certain PHP versions.
|
||||
$path = untrailingslashit($path);
|
||||
if ( empty($path) )
|
||||
return false;
|
||||
|
@ -232,7 +232,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
public function exists( $file ) {
|
||||
$list = $this->ftp->nlist( $file );
|
||||
return !empty( $list ); //empty list = no file, so invert.
|
||||
// return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server
|
||||
// Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
|
||||
}
|
||||
|
||||
public function is_file($file) {
|
||||
|
@ -85,7 +85,8 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
$this->options['username'] = $opt['username'];
|
||||
|
||||
if ( empty ($opt['password']) ) {
|
||||
if ( !$this->keys ) //password can be blank if we are using keys
|
||||
// Password can be blank if we are using keys.
|
||||
if ( !$this->keys )
|
||||
$this->errors->add('empty_password', __('SSH2 password is required'));
|
||||
} else {
|
||||
$this->options['password'] = $opt['password'];
|
||||
|
@ -41,7 +41,7 @@ class WP_Importer {
|
||||
}
|
||||
} while ( count( $results ) == $limit );
|
||||
|
||||
// unset to save memory
|
||||
// Unset to save memory.
|
||||
unset( $results, $r );
|
||||
|
||||
return $hashtable;
|
||||
@ -67,7 +67,7 @@ class WP_Importer {
|
||||
if ( !empty( $result ) )
|
||||
$count = intval( $result[0]->cnt );
|
||||
|
||||
// unset to save memory
|
||||
// Unset to save memory.
|
||||
unset( $results );
|
||||
|
||||
return $count;
|
||||
@ -109,7 +109,7 @@ class WP_Importer {
|
||||
}
|
||||
} while ( count( $results ) == $limit );
|
||||
|
||||
// unset to save memory
|
||||
// Unset to save memory.
|
||||
unset( $results, $r );
|
||||
|
||||
return $hashtable;
|
||||
|
@ -201,7 +201,7 @@ class WP_List_Table {
|
||||
if ( !$args['total_pages'] && $args['per_page'] > 0 )
|
||||
$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
|
||||
|
||||
// redirect if page number is invalid and headers are not already sent
|
||||
// Redirect if page number is invalid and headers are not already sent.
|
||||
if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
|
||||
wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
|
||||
exit;
|
||||
|
@ -38,8 +38,10 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
$s = trim($s, '*');
|
||||
}
|
||||
|
||||
// If the network is large and a search is not being performed, show only the latest blogs with no paging in order
|
||||
// to avoid expensive count queries.
|
||||
/*
|
||||
* If the network is large and a search is not being performed, show only
|
||||
* the latest blogs with no paging in order to avoid expensive count queries.
|
||||
*/
|
||||
if ( !$s && wp_is_large_network() ) {
|
||||
if ( !isset($_REQUEST['orderby']) )
|
||||
$_GET['orderby'] = $_REQUEST['orderby'] = '';
|
||||
|
@ -33,7 +33,8 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
protected function get_table_classes() {
|
||||
return array( 'widefat', 'plugins' ); // todo: remove and add CSS for .themes
|
||||
// todo: remove and add CSS for .themes
|
||||
return array( 'widefat', 'plugins' );
|
||||
}
|
||||
|
||||
public function ajax_user_can() {
|
||||
@ -268,7 +269,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
$allowed = $theme->is_allowed( 'network' );
|
||||
}
|
||||
|
||||
// preorder
|
||||
// Pre-order.
|
||||
$actions = array(
|
||||
'enable' => '',
|
||||
'disable' => '',
|
||||
|
@ -40,8 +40,11 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
||||
$args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
|
||||
}
|
||||
|
||||
// If the network is large and a search is not being performed, show only the latest users with no paging in order
|
||||
// to avoid expensive count queries.
|
||||
/*
|
||||
* If the network is large and a search is not being performed,
|
||||
* show only the latest users with no paging in order to avoid
|
||||
* expensive count queries.
|
||||
*/
|
||||
if ( !$usersearch && wp_is_large_network( 'users' ) ) {
|
||||
if ( !isset($_REQUEST['orderby']) )
|
||||
$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
|
||||
|
@ -340,7 +340,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
$context = $status;
|
||||
$screen = $this->screen;
|
||||
|
||||
// preorder
|
||||
// Pre-order.
|
||||
$actions = array(
|
||||
'deactivate' => '',
|
||||
'activate' => '',
|
||||
|
@ -414,7 +414,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
|
||||
foreach ( $pages as $page ) {
|
||||
|
||||
// catch and repair bad pages
|
||||
// Catch and repair bad pages.
|
||||
if ( $page->post_parent == $page->ID ) {
|
||||
$page->post_parent = 0;
|
||||
$wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
|
||||
@ -449,7 +449,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
|
||||
}
|
||||
|
||||
// if it is the last pagenum and there are orphaned pages, display them with paging as well
|
||||
// If it is the last pagenum and there are orphaned pages, display them with paging as well.
|
||||
if ( isset( $children_pages ) && $count < $end ){
|
||||
foreach ( $children_pages as $orphans ){
|
||||
foreach ( $orphans as $op ) {
|
||||
@ -591,7 +591,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
$attributes = 'class="post-title page-title column-title"' . $style;
|
||||
if ( $this->hierarchical_display ) {
|
||||
if ( 0 == $level && (int) $post->post_parent > 0 ) {
|
||||
//sent level 0 by accident, by default, or because we don't know the actual level
|
||||
// Sent level 0 by accident, by default, or because we don't know the actual level.
|
||||
$find_main_page = (int) $post->post_parent;
|
||||
while ( $find_main_page > 0 ) {
|
||||
$parent = get_post( $find_main_page );
|
||||
|
@ -155,12 +155,13 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
) );
|
||||
|
||||
$page = $args['page'];
|
||||
// set variable because $args['number'] can be subsequently overridden
|
||||
|
||||
// Set variable because $args['number'] can be subsequently overridden.
|
||||
$number = $args['number'];
|
||||
|
||||
$args['offset'] = $offset = ( $page - 1 ) * $number;
|
||||
|
||||
// convert it to table rows
|
||||
// Convert it to table rows.
|
||||
$count = 0;
|
||||
|
||||
if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) {
|
||||
|
@ -92,7 +92,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
||||
break;
|
||||
|
||||
case 'featured':
|
||||
//case 'popular':
|
||||
// case 'popular':
|
||||
case 'new':
|
||||
case 'updated':
|
||||
$args['browse'] = $tab;
|
||||
|
@ -73,7 +73,7 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||
|
||||
return;
|
||||
}
|
||||
// else, fallthrough. install_themes doesn't help if you can't enable it.
|
||||
// Else, fallthrough. install_themes doesn't help if you can't enable it.
|
||||
} else {
|
||||
if ( current_user_can( 'install_themes' ) ) {
|
||||
printf( __( 'You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress.org Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.' ), admin_url( 'theme-install.php' ) );
|
||||
|
@ -190,7 +190,8 @@ class WP_Upgrader {
|
||||
);
|
||||
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
// these were previously extract()'d
|
||||
|
||||
// These were previously extract()'d.
|
||||
$source = $args['source'];
|
||||
$destination = $args['destination'];
|
||||
$clear_destination = $args['clear_destination'];
|
||||
@ -249,14 +250,19 @@ class WP_Upgrader {
|
||||
return $source;
|
||||
}
|
||||
|
||||
//Has the source location changed? If so, we need a new source_files list.
|
||||
// Has the source location changed? If so, we need a new source_files list.
|
||||
if ( $source !== $remote_source ) {
|
||||
$source_files = array_keys( $wp_filesystem->dirlist( $source ) );
|
||||
}
|
||||
// Protection against deleting files in any important base directories.
|
||||
// Theme_Upgrader & Plugin_Upgrader also trigger this, as they pass the destination directory (WP_PLUGIN_DIR / wp-content/themes)
|
||||
// intending to copy the directory into the directory, whilst they pass the source as the actual files to copy.
|
||||
/*
|
||||
* Protection against deleting files in any important base directories.
|
||||
* Theme_Upgrader & Plugin_Upgrader also trigger this, as they pass the
|
||||
* destination directory (WP_PLUGIN_DIR / wp-content/themes) intending
|
||||
* to copy the directory into the directory, whilst they pass the source
|
||||
* as the actual files to copy.
|
||||
*/
|
||||
$protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' );
|
||||
|
||||
if ( is_array( $wp_theme_directories ) ) {
|
||||
$protected_directories = array_merge( $protected_directories, $wp_theme_directories );
|
||||
}
|
||||
@ -716,7 +722,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
return $source;
|
||||
}
|
||||
|
||||
//return plugin info.
|
||||
// Return plugin info.
|
||||
public function plugin_info() {
|
||||
if ( ! is_array($this->result) )
|
||||
return false;
|
||||
@ -1266,8 +1272,10 @@ class Language_Pack_Upgrader extends WP_Upgrader {
|
||||
$this->update_count = count( $language_updates );
|
||||
$this->update_current = 0;
|
||||
|
||||
// The filesystem's mkdir() is not recursive. Make sure WP_LANG_DIR exists,
|
||||
// as we then may need to create a /plugins or /themes directory inside of it.
|
||||
/*
|
||||
* The filesystem's mkdir() is not recursive. Make sure WP_LANG_DIR exists,
|
||||
* as we then may need to create a /plugins or /themes directory inside of it.
|
||||
*/
|
||||
$remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR );
|
||||
if ( ! $wp_filesystem->exists( $remote_destination ) )
|
||||
if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) )
|
||||
@ -1469,9 +1477,11 @@ class Core_Upgrader extends WP_Upgrader {
|
||||
$try_rollback = false;
|
||||
if ( is_wp_error( $result ) ) {
|
||||
$error_code = $result->get_error_code();
|
||||
// Not all errors are equal. These codes are critical: copy_failed__copy_dir,
|
||||
// mkdir_failed__copy_dir, copy_failed__copy_dir_retry, and disk_full.
|
||||
// do_rollback allows for update_core() to trigger a rollback if needed.
|
||||
/*
|
||||
* Not all errors are equal. These codes are critical: copy_failed__copy_dir,
|
||||
* mkdir_failed__copy_dir, copy_failed__copy_dir_retry, and disk_full.
|
||||
* do_rollback allows for update_core() to trigger a rollback if needed.
|
||||
*/
|
||||
if ( false !== strpos( $error_code, 'do_rollback' ) )
|
||||
$try_rollback = true;
|
||||
elseif ( false !== strpos( $error_code, '__copy_dir' ) )
|
||||
@ -1601,7 +1611,7 @@ class Core_Upgrader extends WP_Upgrader {
|
||||
*/
|
||||
if ( ! apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ) )
|
||||
return false;
|
||||
// else fall through to minor + major branches below
|
||||
// Else fall through to minor + major branches below.
|
||||
}
|
||||
|
||||
// 4: Minor In-branch updates (3.7.0 -> 3.7.1 -> 3.7.2 -> 3.7.4)
|
||||
@ -1692,10 +1702,10 @@ class File_Upload_Upgrader {
|
||||
'post_status' => 'private'
|
||||
);
|
||||
|
||||
// Save the data
|
||||
// Save the data.
|
||||
$this->id = wp_insert_attachment( $object, $file['file'] );
|
||||
|
||||
// schedule a cleanup for 2 hours from now in case of failed install
|
||||
// Schedule a cleanup for 2 hours from now in case of failed install.
|
||||
wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) );
|
||||
|
||||
} elseif ( is_numeric( $_GET[$urlholder] ) ) {
|
||||
@ -2018,16 +2028,18 @@ class WP_Automatic_Updater {
|
||||
// Boom, This sites about to get a whole new splash of paint!
|
||||
$upgrade_result = $upgrader->upgrade( $upgrader_item, array(
|
||||
'clear_update_cache' => false,
|
||||
'pre_check_md5' => false, /* always use partial builds if possible for core updates */
|
||||
'attempt_rollback' => true, /* only available for core updates */
|
||||
// Always use partial builds if possible for core updates.
|
||||
'pre_check_md5' => false,
|
||||
// Only available for core updates.
|
||||
'attempt_rollback' => true,
|
||||
) );
|
||||
|
||||
// if the filesystem is unavailable, false is returned.
|
||||
// If the filesystem is unavailable, false is returned.
|
||||
if ( false === $upgrade_result ) {
|
||||
$upgrade_result = new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
|
||||
}
|
||||
|
||||
// Core doesn't output this, so lets append it so we don't get confused
|
||||
// Core doesn't output this, so lets append it so we don't get confused.
|
||||
if ( 'core' == $type ) {
|
||||
if ( is_wp_error( $upgrade_result ) ) {
|
||||
$skin->error( __( 'Installation Failed' ), $upgrade_result );
|
||||
|
@ -531,7 +531,7 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
|
||||
|
||||
$actions_string = '';
|
||||
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
|
||||
// preorder it: Approve | Reply | Edit | Spam | Trash
|
||||
// Pre-order it: Approve | Reply | Edit | Spam | Trash.
|
||||
$actions = array(
|
||||
'approve' => '', 'unapprove' => '',
|
||||
'reply' => '',
|
||||
@ -898,7 +898,8 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
|
||||
$_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] );
|
||||
$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
|
||||
$widget_options[$widget_id]['number'] = $number;
|
||||
// title is optional. If black, fill it if possible
|
||||
|
||||
// Title is optional. If black, fill it if possible.
|
||||
if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
|
||||
$rss = fetch_feed($widget_options[$widget_id]['url']);
|
||||
if ( is_wp_error($rss) ) {
|
||||
|
@ -83,10 +83,13 @@ function export_wp( $args = array() ) {
|
||||
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime('+1 month', strtotime($args['end_date'])) ) );
|
||||
}
|
||||
|
||||
// grab a snapshot of post IDs, just in case it changes during the export
|
||||
// Grab a snapshot of post IDs, just in case it changes during the export.
|
||||
$post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" );
|
||||
|
||||
// get the requested terms ready, empty unless posts filtered by category or all content
|
||||
/*
|
||||
* Get the requested terms ready, empty unless posts filtered by category
|
||||
* or all content.
|
||||
*/
|
||||
$cats = $tags = $terms = array();
|
||||
if ( isset( $term ) && $term ) {
|
||||
$cat = get_term( $term['term_id'], 'category' );
|
||||
@ -99,7 +102,7 @@ function export_wp( $args = array() ) {
|
||||
$custom_taxonomies = get_taxonomies( array( '_builtin' => false ) );
|
||||
$custom_terms = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) );
|
||||
|
||||
// put categories in order with no child going before its parent
|
||||
// Put categories in order with no child going before its parent.
|
||||
while ( $cat = array_shift( $categories ) ) {
|
||||
if ( $cat->parent == 0 || isset( $cats[$cat->parent] ) )
|
||||
$cats[$cat->term_id] = $cat;
|
||||
@ -107,7 +110,7 @@ function export_wp( $args = array() ) {
|
||||
$categories[] = $cat;
|
||||
}
|
||||
|
||||
// put terms in order with no child going before its parent
|
||||
// Put terms in order with no child going before its parent.
|
||||
while ( $t = array_shift( $custom_terms ) ) {
|
||||
if ( $t->parent == 0 || isset( $terms[$t->parent] ) )
|
||||
$terms[$t->term_id] = $t;
|
||||
@ -144,10 +147,10 @@ function export_wp( $args = array() ) {
|
||||
* @return string Site URL.
|
||||
*/
|
||||
function wxr_site_url() {
|
||||
// ms: the base url
|
||||
// Multisite: the base URL.
|
||||
if ( is_multisite() )
|
||||
return network_home_url();
|
||||
// wp: the blog url
|
||||
// WordPress (single site): the blog URL.
|
||||
else
|
||||
return get_bloginfo_rss( 'url' );
|
||||
}
|
||||
@ -373,14 +376,16 @@ function export_wp( $args = array() ) {
|
||||
|
||||
<?php if ( $post_ids ) {
|
||||
global $wp_query;
|
||||
$wp_query->in_the_loop = true; // Fake being in the loop.
|
||||
|
||||
// fetch 20 posts at a time rather than loading the entire table into memory
|
||||
// Fake being in the loop.
|
||||
$wp_query->in_the_loop = true;
|
||||
|
||||
// Fetch 20 posts at a time rather than loading the entire table into memory.
|
||||
while ( $next_posts = array_splice( $post_ids, 0, 20 ) ) {
|
||||
$where = 'WHERE ID IN (' . join( ',', $next_posts ) . ')';
|
||||
$posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" );
|
||||
|
||||
// Begin Loop
|
||||
// Begin Loop.
|
||||
foreach ( $posts as $post ) {
|
||||
setup_postdata( $post );
|
||||
$is_sticky = is_sticky( $post->ID ) ? 1 : 0;
|
||||
|
@ -179,8 +179,8 @@ function validate_file_to_edit( $file, $allowed_files = '' ) {
|
||||
case 1 :
|
||||
wp_die( __( 'Sorry, that file cannot be edited.' ) );
|
||||
|
||||
//case 2 :
|
||||
// wp_die( __('Sorry, can’t call files with their real path.' ));
|
||||
// case 2 :
|
||||
// wp_die( __('Sorry, can’t call files with their real path.' ));
|
||||
|
||||
case 3 :
|
||||
wp_die( __( 'Sorry, that file cannot be edited.' ) );
|
||||
@ -257,7 +257,10 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) {
|
||||
__( "Failed to write file to disk." ),
|
||||
__( "File upload stopped by extension." ));
|
||||
|
||||
// this may not have orignially been intended to be overrideable, but historically has been
|
||||
/*
|
||||
* This may not have orignially been intended to be overrideable,
|
||||
* but historically has been.
|
||||
*/
|
||||
if ( isset( $overrides['upload_error_strings'] ) ) {
|
||||
$upload_error_strings = $overrides['upload_error_strings'];
|
||||
}
|
||||
@ -267,7 +270,7 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) {
|
||||
$test_size = isset( $overrides['test_size'] ) ? $overrides['test_size'] : true;
|
||||
$test_upload = isset( $overrides['test_upload'] ) ? $overrides['test_upload'] : true;
|
||||
|
||||
// If you override this, you must provide $ext and $type!!!!
|
||||
// If you override this, you must provide $ext and $type!!
|
||||
$test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true;
|
||||
$mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false;
|
||||
|
||||
@ -314,13 +317,16 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) {
|
||||
$type = '';
|
||||
}
|
||||
|
||||
// A writable uploads dir will pass this test. Again, there's no point overriding this one.
|
||||
/*
|
||||
* A writable uploads dir will pass this test. Again, there's no point
|
||||
* overriding this one.
|
||||
*/
|
||||
if ( ! ( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] ) )
|
||||
return call_user_func($upload_error_handler, $file, $uploads['error'] );
|
||||
|
||||
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
|
||||
|
||||
// Move the file to the uploads dir
|
||||
// Move the file to the uploads dir.
|
||||
$new_file = $uploads['path'] . "/$filename";
|
||||
if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) {
|
||||
if ( 0 === strpos( $uploads['basedir'], ABSPATH ) )
|
||||
@ -331,12 +337,12 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) {
|
||||
return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $error_path ) );
|
||||
}
|
||||
|
||||
// Set correct file permissions
|
||||
// Set correct file permissions.
|
||||
$stat = stat( dirname( $new_file ));
|
||||
$perms = $stat['mode'] & 0000666;
|
||||
@ chmod( $new_file, $perms );
|
||||
|
||||
// Compute the URL
|
||||
// Compute the URL.
|
||||
$url = $uploads['url'] . "/$filename";
|
||||
|
||||
if ( is_multisite() )
|
||||
@ -1051,7 +1057,7 @@ function request_filesystem_credentials($form_post, $type = '', $error = false,
|
||||
$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? wp_unslash( $_POST['public_key'] ) : '');
|
||||
$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? wp_unslash( $_POST['private_key'] ) : '');
|
||||
|
||||
//sanitize the hostname, Some people might pass in odd-data:
|
||||
// Sanitize the hostname, Some people might pass in odd-data:
|
||||
$credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off
|
||||
|
||||
if ( strpos($credentials['hostname'], ':') ) {
|
||||
|
@ -411,7 +411,7 @@ function image_edit_apply_changes( $image, $changes ) {
|
||||
if ( !is_array($changes) )
|
||||
return $image;
|
||||
|
||||
// expand change operations
|
||||
// Expand change operations.
|
||||
foreach ( $changes as $key => $obj ) {
|
||||
if ( isset($obj->r) ) {
|
||||
$obj->type = 'rotate';
|
||||
@ -429,7 +429,7 @@ function image_edit_apply_changes( $image, $changes ) {
|
||||
$changes[$key] = $obj;
|
||||
}
|
||||
|
||||
// combine operations
|
||||
// Combine operations.
|
||||
if ( count($changes) > 1 ) {
|
||||
$filtered = array($changes[0]);
|
||||
for ( $i = 0, $j = 1; $j < count($changes); $j++ ) {
|
||||
@ -453,7 +453,7 @@ function image_edit_apply_changes( $image, $changes ) {
|
||||
unset($filtered);
|
||||
}
|
||||
|
||||
// image resource before applying the changes
|
||||
// Image resource before applying the changes.
|
||||
if ( $image instanceof WP_Image_Editor ) {
|
||||
|
||||
/**
|
||||
@ -540,7 +540,7 @@ function stream_preview_image( $post_id ) {
|
||||
if ( $changes )
|
||||
$img = image_edit_apply_changes( $img, $changes );
|
||||
|
||||
// scale the image
|
||||
// Scale the image.
|
||||
$size = $img->get_size();
|
||||
$w = $size['width'];
|
||||
$h = $size['height'];
|
||||
@ -576,7 +576,8 @@ function wp_restore_image($post_id) {
|
||||
|
||||
if ( $parts['basename'] != $data['file'] ) {
|
||||
if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {
|
||||
// delete only if it's edited image
|
||||
|
||||
// Delete only if it's edited image.
|
||||
if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) {
|
||||
|
||||
/** This filter is documented in wp-admin/custom-header.php */
|
||||
@ -601,7 +602,8 @@ function wp_restore_image($post_id) {
|
||||
$data = $backup_sizes["$default_size-orig"];
|
||||
if ( isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file'] ) {
|
||||
if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {
|
||||
// delete only if it's edited image
|
||||
|
||||
// Delete only if it's edited image
|
||||
if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) {
|
||||
/** This filter is documented in wp-admin/custom-header.php */
|
||||
$delpath = apply_filters( 'wp_delete_file', path_join($parts['dirname'], $meta['sizes'][$default_size]['file']) );
|
||||
@ -661,10 +663,10 @@ function wp_save_image( $post_id ) {
|
||||
$sX = $size['width'];
|
||||
$sY = $size['height'];
|
||||
|
||||
// check if it has roughly the same w / h ratio
|
||||
// Check if it has roughly the same w / h ratio.
|
||||
$diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2);
|
||||
if ( -0.1 < $diff && $diff < 0.1 ) {
|
||||
// scale the full size image
|
||||
// Scale the full size image.
|
||||
if ( $img->resize( $fwidth, $fheight ) )
|
||||
$scaled = true;
|
||||
}
|
||||
@ -693,7 +695,7 @@ function wp_save_image( $post_id ) {
|
||||
if ( !is_array($backup_sizes) )
|
||||
$backup_sizes = array();
|
||||
|
||||
// generate new filename
|
||||
// Generate new filename.
|
||||
$path = get_attached_file($post_id);
|
||||
$path_parts = pathinfo( $path );
|
||||
$filename = $path_parts['filename'];
|
||||
@ -719,7 +721,7 @@ function wp_save_image( $post_id ) {
|
||||
}
|
||||
}
|
||||
|
||||
// save the full-size file, also needed to create sub-sizes
|
||||
// Save the full-size file, also needed to create sub-sizes.
|
||||
if ( !wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id) ) {
|
||||
$return->error = esc_js( __('Unable to save the image.') );
|
||||
return $return;
|
||||
|
@ -47,8 +47,10 @@ function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $s
|
||||
if ( ! $dst_file )
|
||||
$dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file );
|
||||
|
||||
// The directory containing the original file may no longer exist when
|
||||
// using a replication plugin.
|
||||
/*
|
||||
* The directory containing the original file may no longer exist when
|
||||
* using a replication plugin.
|
||||
*/
|
||||
wp_mkdir_p( dirname( $dst_file ) );
|
||||
|
||||
$dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) );
|
||||
@ -79,10 +81,10 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
||||
$metadata['width'] = $imagesize[0];
|
||||
$metadata['height'] = $imagesize[1];
|
||||
|
||||
// Make the file path relative to the upload dir
|
||||
// Make the file path relative to the upload dir.
|
||||
$metadata['file'] = _wp_relative_upload_path($file);
|
||||
|
||||
// make thumbnails and other intermediate sizes
|
||||
// Make thumbnails and other intermediate sizes.
|
||||
global $_wp_additional_image_sizes;
|
||||
|
||||
$sizes = array();
|
||||
@ -120,7 +122,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
||||
$metadata['sizes'] = array();
|
||||
}
|
||||
|
||||
// fetch additional metadata from exif/iptc
|
||||
// Fetch additional metadata from EXIF/IPTC.
|
||||
$image_meta = wp_read_image_metadata( $file );
|
||||
if ( $image_meta )
|
||||
$metadata['image_meta'] = $image_meta;
|
||||
@ -134,7 +136,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
||||
}
|
||||
|
||||
if ( $support && ! empty( $metadata['image']['data'] ) ) {
|
||||
// check for existing cover
|
||||
// Check for existing cover.
|
||||
$hash = md5( $metadata['image']['data'] );
|
||||
$posts = get_posts( array(
|
||||
'fields' => 'ids',
|
||||
@ -187,7 +189,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
||||
}
|
||||
}
|
||||
|
||||
// remove the blob of binary data from the array
|
||||
// Remove the blob of binary data from the array.
|
||||
if ( isset( $metadata['image']['data'] ) )
|
||||
unset( $metadata['image']['data'] );
|
||||
|
||||
@ -254,10 +256,12 @@ function wp_read_image_metadata( $file ) {
|
||||
|
||||
list( , , $sourceImageType ) = getimagesize( $file );
|
||||
|
||||
// exif contains a bunch of data we'll probably never need formatted in ways
|
||||
// that are difficult to use. We'll normalize it and just extract the fields
|
||||
// that are likely to be useful. Fractions and numbers are converted to
|
||||
// floats, dates to unix timestamps, and everything else to strings.
|
||||
/*
|
||||
* EXIF contains a bunch of data we'll probably never need formatted in ways
|
||||
* that are difficult to use. We'll normalize it and just extract the fields
|
||||
* that are likely to be useful. Fractions and numbers are converted to
|
||||
* floats, dates to unix timestamps, and everything else to strings.
|
||||
*/
|
||||
$meta = array(
|
||||
'aperture' => 0,
|
||||
'credit' => '',
|
||||
@ -271,20 +275,26 @@ function wp_read_image_metadata( $file ) {
|
||||
'title' => '',
|
||||
);
|
||||
|
||||
// read iptc first, since it might contain data not available in exif such
|
||||
// as caption, description etc
|
||||
/*
|
||||
* Read IPTC first, since it might contain data not available in exif such
|
||||
* as caption, description etc.
|
||||
*/
|
||||
if ( is_callable( 'iptcparse' ) ) {
|
||||
getimagesize( $file, $info );
|
||||
|
||||
if ( ! empty( $info['APP13'] ) ) {
|
||||
$iptc = iptcparse( $info['APP13'] );
|
||||
|
||||
// headline, "A brief synopsis of the caption."
|
||||
if ( ! empty( $iptc['2#105'][0] ) )
|
||||
// Headline, "A brief synopsis of the caption."
|
||||
if ( ! empty( $iptc['2#105'][0] ) ) {
|
||||
$meta['title'] = trim( $iptc['2#105'][0] );
|
||||
// title, "Many use the Title field to store the filename of the image, though the field may be used in many ways."
|
||||
elseif ( ! empty( $iptc['2#005'][0] ) )
|
||||
/*
|
||||
* Title, "Many use the Title field to store the filename of the image,
|
||||
* though the field may be used in many ways."
|
||||
*/
|
||||
} elseif ( ! empty( $iptc['2#005'][0] ) ) {
|
||||
$meta['title'] = trim( $iptc['2#005'][0] );
|
||||
}
|
||||
|
||||
if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption
|
||||
$caption = trim( $iptc['2#120'][0] );
|
||||
@ -568,8 +578,10 @@ function _copy_image_file( $attachment_id ) {
|
||||
$dst_file = str_replace( basename( $dst_file ), 'copy-' . basename( $dst_file ), $dst_file );
|
||||
$dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) );
|
||||
|
||||
// The directory containing the original file may no longer exist when
|
||||
// using a replication plugin.
|
||||
/*
|
||||
* The directory containing the original file may no longer
|
||||
* exist when using a replication plugin.
|
||||
*/
|
||||
wp_mkdir_p( dirname( $dst_file ) );
|
||||
|
||||
if ( ! @copy( $src_file, $dst_file ) )
|
||||
|
@ -105,7 +105,10 @@ function wp_import_handle_upload() {
|
||||
// Save the data
|
||||
$id = wp_insert_attachment( $object, $file );
|
||||
|
||||
// schedule a cleanup for one day from now in case of failed import or missing wp_import_cleanup() call
|
||||
/*
|
||||
* Schedule a cleanup for one day from now in case of failed
|
||||
* import or missing wp_import_cleanup() call.
|
||||
*/
|
||||
wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) );
|
||||
|
||||
return array( 'file' => $file, 'id' => $id );
|
||||
|
@ -180,7 +180,8 @@ function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $
|
||||
|
||||
$caption = str_replace( array("\r\n", "\r"), "\n", $caption);
|
||||
$caption = preg_replace_callback( '/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption );
|
||||
// convert any remaining line breaks to <br>
|
||||
|
||||
// Convert any remaining line breaks to <br>.
|
||||
$caption = preg_replace( '/[ \n\t]*\n[ \t]*/', '<br />', $caption );
|
||||
|
||||
$html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html );
|
||||
@ -208,7 +209,7 @@ add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 );
|
||||
* @since 3.4.0
|
||||
*/
|
||||
function _cleanup_image_add_caption( $matches ) {
|
||||
// remove any line breaks from inside the tags
|
||||
// Remove any line breaks from inside the tags.
|
||||
return preg_replace( '/[\r\n\t]+/', ' ', $matches[0] );
|
||||
}
|
||||
|
||||
@ -317,7 +318,7 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override
|
||||
if ( ! empty( $meta['genre'] ) )
|
||||
$content .= ' ' . sprintf( __( 'Genre: %s.' ), $meta['genre'] );
|
||||
|
||||
// use image exif/iptc data for title and caption defaults if possible
|
||||
// Use image exif/iptc data for title and caption defaults if possible.
|
||||
} elseif ( $image_meta = @wp_read_image_metadata( $file ) ) {
|
||||
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
|
||||
$title = $image_meta['title'];
|
||||
@ -378,7 +379,7 @@ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data =
|
||||
$title = preg_replace('/\.[^.]+$/', '', basename($file));
|
||||
$content = '';
|
||||
|
||||
// use image exif/iptc data for title and caption defaults if possible
|
||||
// Use image exif/iptc data for title and caption defaults if possible.
|
||||
if ( $image_meta = @wp_read_image_metadata($file) ) {
|
||||
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
|
||||
$title = $image_meta['title'];
|
||||
@ -389,7 +390,7 @@ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data =
|
||||
if ( isset( $desc ) )
|
||||
$title = $desc;
|
||||
|
||||
// Construct the attachment array
|
||||
// Construct the attachment array.
|
||||
$attachment = array_merge( array(
|
||||
'post_mime_type' => $type,
|
||||
'guid' => $url,
|
||||
@ -634,7 +635,8 @@ function media_upload_form_handler() {
|
||||
$image_alt = wp_unslash( $attachment['image_alt'] );
|
||||
if ( $image_alt != get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ) {
|
||||
$image_alt = wp_strip_all_tags( $image_alt, true );
|
||||
// update_meta expects slashed
|
||||
|
||||
// Update_meta expects slashed.
|
||||
update_post_meta( $attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
|
||||
}
|
||||
}
|
||||
@ -807,11 +809,11 @@ function wp_media_upload_handler() {
|
||||
*/
|
||||
function media_sideload_image( $file, $post_id, $desc = null ) {
|
||||
if ( ! empty( $file ) ) {
|
||||
// Set variables for storage
|
||||
// fix file filename for query strings
|
||||
// Set variables for storage, fix file filename for query strings.
|
||||
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
|
||||
$file_array['name'] = basename( $matches[0] );
|
||||
// Download file to temp location
|
||||
|
||||
// Download file to temp location.
|
||||
$file_array['tmp_name'] = download_url( $file );
|
||||
|
||||
// If error storing temporarily, return the error.
|
||||
@ -819,9 +821,10 @@ function media_sideload_image( $file, $post_id, $desc = null ) {
|
||||
return $file_array['tmp_name'];
|
||||
}
|
||||
|
||||
// do the validation and storage stuff
|
||||
// Do the validation and storage stuff.
|
||||
$id = media_handle_sideload( $file_array, $post_id, $desc );
|
||||
// If error storing permanently, unlink
|
||||
|
||||
// If error storing permanently, unlink.
|
||||
if ( is_wp_error( $id ) ) {
|
||||
@unlink( $file_array['tmp_name'] );
|
||||
return $id;
|
||||
@ -830,7 +833,7 @@ function media_sideload_image( $file, $post_id, $desc = null ) {
|
||||
$src = wp_get_attachment_url( $id );
|
||||
}
|
||||
|
||||
// Finally check to make sure the file has been saved, then return the html
|
||||
// Finally check to make sure the file has been saved, then return the HTML.
|
||||
if ( ! empty( $src ) ) {
|
||||
$alt = isset( $desc ) ? esc_attr( $desc ) : '';
|
||||
$html = "<img src='$src' alt='$alt' />";
|
||||
@ -943,17 +946,21 @@ function image_size_input_fields( $post, $check = '' ) {
|
||||
$downsize = image_downsize($post->ID, $size);
|
||||
$checked = '';
|
||||
|
||||
// is this size selectable?
|
||||
// Is this size selectable?
|
||||
$enabled = ( $downsize[3] || 'full' == $size );
|
||||
$css_id = "image-size-{$size}-{$post->ID}";
|
||||
// if this size is the default but that's not available, don't select it
|
||||
|
||||
// If this size is the default but that's not available, don't select it.
|
||||
if ( $size == $check ) {
|
||||
if ( $enabled )
|
||||
$checked = " checked='checked'";
|
||||
else
|
||||
$check = '';
|
||||
} elseif ( !$check && $enabled && 'thumbnail' != $size ) {
|
||||
// if $check is not enabled, default to the first available size that's bigger than a thumbnail
|
||||
/*
|
||||
* If $check is not enabled, default to the first available size
|
||||
* that's bigger than a thumbnail.
|
||||
*/
|
||||
$check = $size;
|
||||
$checked = " checked='checked'";
|
||||
}
|
||||
@ -961,7 +968,8 @@ function image_size_input_fields( $post, $check = '' ) {
|
||||
$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
|
||||
|
||||
$html .= "<label for='{$css_id}'>$label</label>";
|
||||
// only show the dimensions if that choice is available
|
||||
|
||||
// Only show the dimensions if that choice is available.
|
||||
if ( $enabled )
|
||||
$html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d × %d)", $downsize[1], $downsize[2] ). "</label>";
|
||||
|
||||
@ -1009,7 +1017,7 @@ function image_link_input_fields($post, $url_type = '') {
|
||||
}
|
||||
|
||||
function wp_caption_input_textarea($edit_post) {
|
||||
// post data is already escaped
|
||||
// Post data is already escaped.
|
||||
$name = "attachments[{$edit_post->ID}][post_excerpt]";
|
||||
|
||||
return '<textarea name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea>';
|
||||
@ -1472,10 +1480,10 @@ function get_media_item( $attachment_id, $args = null ) {
|
||||
$item .= $field[ $field['input'] ];
|
||||
elseif ( $field['input'] == 'textarea' ) {
|
||||
if ( 'post_content' == $id && user_can_richedit() ) {
|
||||
// sanitize_post() skips the post_content when user_can_richedit
|
||||
// Sanitize_post() skips the post_content when user_can_richedit.
|
||||
$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
|
||||
}
|
||||
// post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit()
|
||||
// Post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit().
|
||||
$item .= "<textarea id='$name' name='$name' $aria_required>" . $field['value'] . '</textarea>';
|
||||
} else {
|
||||
$item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "' $aria_required />";
|
||||
@ -1621,7 +1629,7 @@ function get_compat_media_markup( $attachment_id, $args = null ) {
|
||||
$item .= $field[ $field['input'] ];
|
||||
elseif ( $field['input'] == 'textarea' ) {
|
||||
if ( 'post_content' == $id && user_can_richedit() ) {
|
||||
// sanitize_post() skips the post_content when user_can_richedit
|
||||
// sanitize_post() skips the post_content when user_can_richedit.
|
||||
$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
|
||||
}
|
||||
$item .= "<textarea id='$id_attr' name='$name' $aria_required>" . $field['value'] . '</textarea>';
|
||||
@ -2852,7 +2860,7 @@ function wp_add_id3_tag_data( &$metadata, $data ) {
|
||||
foreach ( $data[$version]['comments'] as $key => $list ) {
|
||||
if ( ! empty( $list ) ) {
|
||||
$metadata[$key] = reset( $list );
|
||||
// fix bug in byte stream analysis
|
||||
// Fix bug in byte stream analysis.
|
||||
if ( 'terms_of_use' === $key && 0 === strpos( $metadata[$key], 'yright notice.' ) )
|
||||
$metadata[$key] = 'Cop' . $metadata[$key];
|
||||
}
|
||||
|
@ -97,8 +97,10 @@ foreach ( $menu as $id => $data ) {
|
||||
$first_sub = array_shift($subs);
|
||||
$old_parent = $data[2];
|
||||
$new_parent = $first_sub[2];
|
||||
// If the first submenu is not the same as the assigned parent,
|
||||
// make the first submenu the new parent.
|
||||
/*
|
||||
* If the first submenu is not the same as the assigned parent,
|
||||
* make the first submenu the new parent.
|
||||
*/
|
||||
if ( $new_parent != $old_parent ) {
|
||||
$_wp_real_parent_file[$old_parent] = $new_parent;
|
||||
$menu[$id][2] = $new_parent;
|
||||
|
@ -163,8 +163,10 @@ function save_mod_rewrite_rules() {
|
||||
$home_path = get_home_path();
|
||||
$htaccess_file = $home_path.'.htaccess';
|
||||
|
||||
// If the file doesn't already exist check for write access to the directory and whether we have some rules.
|
||||
// else check for write access to the file.
|
||||
/*
|
||||
* If the file doesn't already exist check for write access to the directory
|
||||
* and whether we have some rules. Else check for write access to the file.
|
||||
*/
|
||||
if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
|
||||
if ( got_mod_rewrite() ) {
|
||||
$rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
function wpmu_menu() {
|
||||
_deprecated_function(__FUNCTION__, '3.0' );
|
||||
// deprecated. See #11763
|
||||
// Deprecated. See #11763.
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -516,7 +516,7 @@ function wp_nav_menu_post_type_meta_boxes() {
|
||||
$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );
|
||||
if ( $post_type ) {
|
||||
$id = $post_type->name;
|
||||
// give pages a higher priority
|
||||
// Give pages a higher priority.
|
||||
$priority = ( 'page' == $post_type->name ? 'core' : 'default' );
|
||||
add_meta_box( "add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type );
|
||||
}
|
||||
@ -615,7 +615,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
|
||||
|
||||
$post_type_name = $post_type['args']->name;
|
||||
|
||||
// paginate browsing for large numbers of post objects
|
||||
// Paginate browsing for large numbers of post objects.
|
||||
$per_page = 50;
|
||||
$pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
|
||||
$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
|
||||
@ -762,7 +762,10 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
|
||||
<?php
|
||||
$args['walker'] = $walker;
|
||||
|
||||
// if we're dealing with pages, let's put a checkbox for the front page at the top of the list
|
||||
/*
|
||||
* If we're dealing with pages, let's put a checkbox for the front
|
||||
* page at the top of the list.
|
||||
*/
|
||||
if ( 'page' == $post_type_name ) {
|
||||
$front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0;
|
||||
if ( ! empty( $front_page ) ) {
|
||||
@ -854,7 +857,7 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) {
|
||||
global $nav_menu_selected_id;
|
||||
$taxonomy_name = $taxonomy['args']->name;
|
||||
|
||||
// paginate browsing for large numbers of objects
|
||||
// Paginate browsing for large numbers of objects.
|
||||
$per_page = 50;
|
||||
$pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
|
||||
$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
|
||||
@ -1045,21 +1048,26 @@ function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
|
||||
|
||||
if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
|
||||
|
||||
// Loop through all the menu items' POST values
|
||||
// Loop through all the menu items' POST values.
|
||||
foreach( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
|
||||
if (
|
||||
empty( $_item_object_data['menu-item-object-id'] ) && // checkbox is not checked
|
||||
// Checkbox is not checked.
|
||||
empty( $_item_object_data['menu-item-object-id'] ) &&
|
||||
(
|
||||
! isset( $_item_object_data['menu-item-type'] ) || // and item type either isn't set
|
||||
in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) || // or URL is the default
|
||||
// And item type either isn't set.
|
||||
! isset( $_item_object_data['menu-item-type'] ) ||
|
||||
// Or URL is the default.
|
||||
in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) ||
|
||||
! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page)
|
||||
! empty( $_item_object_data['menu-item-db-id'] ) // or it *is* a custom menu item that already exists
|
||||
// Or it *is* a custom menu item that already exists.
|
||||
! empty( $_item_object_data['menu-item-db-id'] )
|
||||
)
|
||||
) {
|
||||
continue; // then this potential menu item is not getting added to this menu
|
||||
// Then this potential menu item is not getting added to this menu.
|
||||
continue;
|
||||
}
|
||||
|
||||
// if this possible menu item doesn't actually have a menu database ID yet
|
||||
// If this possible menu item doesn't actually have a menu database ID yet.
|
||||
if (
|
||||
empty( $_item_object_data['menu-item-db-id'] ) ||
|
||||
( 0 > $_possible_db_id ) ||
|
||||
@ -1112,20 +1120,20 @@ function _wp_nav_menu_meta_box_object( $object = null ) {
|
||||
'post_status' => 'publish',
|
||||
);
|
||||
|
||||
// posts should show only published items
|
||||
// Posts should show only published items.
|
||||
} elseif ( 'post' == $object->name ) {
|
||||
$object->_default_query = array(
|
||||
'post_status' => 'publish',
|
||||
);
|
||||
|
||||
// cats should be in reverse chronological order
|
||||
// Categories should be in reverse chronological order.
|
||||
} elseif ( 'category' == $object->name ) {
|
||||
$object->_default_query = array(
|
||||
'orderby' => 'id',
|
||||
'order' => 'DESC',
|
||||
);
|
||||
|
||||
// custom post types should show only published items
|
||||
// Custom post types should show only published items.
|
||||
} else {
|
||||
$object->_default_query = array(
|
||||
'post_status' => 'publish',
|
||||
@ -1226,7 +1234,7 @@ function _wp_delete_orphaned_draft_menu_items() {
|
||||
global $wpdb;
|
||||
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
|
||||
|
||||
// delete orphaned draft menu items
|
||||
// Delete orphaned draft menu items.
|
||||
$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
|
||||
|
||||
foreach( (array) $menu_items_to_delete as $menu_item_id )
|
||||
|
@ -245,15 +245,18 @@ add_action( 'install_plugins_favorites', 'display_plugins_table' );
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function install_plugin_install_status($api, $loop = false) {
|
||||
// this function is called recursively, $loop prevents further loops.
|
||||
// This function is called recursively, $loop prevents further loops.
|
||||
if ( is_array($api) )
|
||||
$api = (object) $api;
|
||||
|
||||
//Default to a "new" plugin
|
||||
// Default to a "new" plugin
|
||||
$status = 'install';
|
||||
$url = false;
|
||||
|
||||
//Check to see if this plugin is known to be installed, and has an update awaiting it.
|
||||
/*
|
||||
* Check to see if this plugin is known to be installed,
|
||||
* and has an update awaiting it.
|
||||
*/
|
||||
$update_plugins = get_site_transient('update_plugins');
|
||||
if ( isset( $update_plugins->response ) ) {
|
||||
foreach ( (array)$update_plugins->response as $file => $plugin ) {
|
||||
@ -438,7 +441,7 @@ function install_plugin_information() {
|
||||
|
||||
if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) {
|
||||
foreach( $api->ratings as $key => $ratecount ) {
|
||||
// avoid div-by-zero
|
||||
// Avoid div-by-zero.
|
||||
$_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0;
|
||||
?>
|
||||
<div class="counter-container">
|
||||
|
@ -851,7 +851,7 @@ function delete_plugins( $plugins, $deprecated = '' ) {
|
||||
*/
|
||||
function validate_active_plugins() {
|
||||
$plugins = get_option( 'active_plugins', array() );
|
||||
// validate vartype: array
|
||||
// Validate vartype: array.
|
||||
if ( ! is_array( $plugins ) ) {
|
||||
update_option( 'active_plugins', array() );
|
||||
$plugins = array();
|
||||
@ -867,7 +867,7 @@ function validate_active_plugins() {
|
||||
|
||||
$invalid = array();
|
||||
|
||||
// invalid plugins get deactivated
|
||||
// Invalid plugins get deactivated.
|
||||
foreach ( $plugins as $plugin ) {
|
||||
$result = validate_plugin( $plugin );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
@ -1119,10 +1119,12 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the parent doesn't already have a submenu, add a link to the parent
|
||||
// as the first item in the submenu. If the submenu file is the same as the
|
||||
// parent file someone is trying to link back to the parent manually. In
|
||||
// this case, don't automatically add a link back to avoid duplication.
|
||||
/*
|
||||
* If the parent doesn't already have a submenu, add a link to the parent
|
||||
* as the first item in the submenu. If the submenu file is the same as the
|
||||
* parent file someone is trying to link back to the parent manually. In
|
||||
* this case, don't automatically add a link back to avoid duplication.
|
||||
*/
|
||||
if (!isset( $submenu[$parent_slug] ) && $menu_slug != $parent_slug ) {
|
||||
foreach ( (array)$menu as $parent_menu ) {
|
||||
if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) )
|
||||
@ -1137,11 +1139,15 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
|
||||
add_action( $hookname, $function );
|
||||
|
||||
$_registered_pages[$hookname] = true;
|
||||
// backwards-compatibility for plugins using add_management page. See wp-admin/admin.php for redirect from edit.php to tools.php
|
||||
|
||||
/*
|
||||
* Backward-compatibility for plugins using add_management page.
|
||||
* See wp-admin/admin.php for redirect from edit.php to tools.php
|
||||
*/
|
||||
if ( 'tools.php' == $parent_slug )
|
||||
$_registered_pages[get_plugin_page_hookname( $menu_slug, 'edit.php')] = true;
|
||||
|
||||
// No parent as top level
|
||||
// No parent as top level.
|
||||
$_parent_pages[$menu_slug] = $parent_slug;
|
||||
|
||||
return $hookname;
|
||||
|
@ -302,7 +302,7 @@ function edit_post( $post_data = null ) {
|
||||
$image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] );
|
||||
if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) {
|
||||
$image_alt = wp_strip_all_tags( $image_alt, true );
|
||||
// update_meta expects slashed
|
||||
// update_meta expects slashed.
|
||||
update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
|
||||
}
|
||||
}
|
||||
@ -740,9 +740,10 @@ function add_meta( $post_ID ) {
|
||||
$metavalue = trim( $metavalue );
|
||||
|
||||
if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) {
|
||||
// We have a key/value pair. If both the select and the
|
||||
// input for the key have data, the input takes precedence:
|
||||
|
||||
/*
|
||||
* We have a key/value pair. If both the select and the input
|
||||
* for the key have data, the input takes precedence.
|
||||
*/
|
||||
if ( '#NONE#' != $metakeyselect )
|
||||
$metakey = $metakeyselect;
|
||||
|
||||
|
@ -177,8 +177,11 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
|
||||
);
|
||||
}
|
||||
|
||||
// If a post has been saved since the last revision (no revisioned fields were changed)
|
||||
// we may not have a "current" revision. Mark the latest revision as "current".
|
||||
/*
|
||||
* If a post has been saved since the last revision (no revisioned fields
|
||||
* were changed), we may not have a "current" revision. Mark the latest
|
||||
* revision as "current".
|
||||
*/
|
||||
if ( empty( $current_id ) ) {
|
||||
if ( $revisions[ $revision->ID ]['autosave'] ) {
|
||||
$revision = end( $revisions );
|
||||
@ -192,7 +195,7 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
|
||||
$revisions[ $current_id ]['current'] = true;
|
||||
}
|
||||
|
||||
// Now, grab the initial diff
|
||||
// Now, grab the initial diff.
|
||||
$compare_two_mode = is_numeric( $from );
|
||||
if ( ! $compare_two_mode ) {
|
||||
$found = array_search( $selected_revision_id, array_keys( $revisions ) );
|
||||
|
@ -205,7 +205,7 @@ CREATE TABLE $wpdb->posts (
|
||||
KEY user_nicename (user_nicename)
|
||||
) $charset_collate;\n";
|
||||
|
||||
// usermeta
|
||||
// Usermeta.
|
||||
$usermeta_table = "CREATE TABLE $wpdb->usermeta (
|
||||
umeta_id bigint(20) unsigned NOT NULL auto_increment,
|
||||
user_id bigint(20) unsigned NOT NULL default '0',
|
||||
@ -522,10 +522,10 @@ function populate_options() {
|
||||
if ( !empty($insert) )
|
||||
$wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert);
|
||||
|
||||
// in case it is set, but blank, update "home"
|
||||
// In case it is set, but blank, update "home".
|
||||
if ( !__get_option('home') ) update_option('home', $guessurl);
|
||||
|
||||
// Delete unused options
|
||||
// Delete unused options.
|
||||
$unusedoptions = array(
|
||||
'blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory',
|
||||
'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping',
|
||||
@ -547,12 +547,14 @@ function populate_options() {
|
||||
foreach ( $unusedoptions as $option )
|
||||
delete_option($option);
|
||||
|
||||
// delete obsolete magpie stuff
|
||||
// Delete obsolete magpie stuff.
|
||||
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
|
||||
|
||||
// Deletes all expired transients.
|
||||
// The multi-table delete syntax is used to delete the transient record from table a,
|
||||
// and the corresponding transient_timeout record from table b.
|
||||
/*
|
||||
* Deletes all expired transients. The multi-table delete syntax is used
|
||||
* to delete the transient record from table a, and the corresponding
|
||||
* transient_timeout record from table b.
|
||||
*/
|
||||
$time = time();
|
||||
$sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b
|
||||
WHERE a.option_name LIKE %s
|
||||
@ -819,8 +821,10 @@ function populate_roles_300() {
|
||||
$role->add_cap( 'list_users' );
|
||||
$role->add_cap( 'remove_users' );
|
||||
|
||||
// Never used, will be removed. create_users or
|
||||
// promote_users is the capability you're looking for.
|
||||
/*
|
||||
* Never used, will be removed. create_users or promote_users
|
||||
* is the capability you're looking for.
|
||||
*/
|
||||
$role->add_cap( 'add_users' );
|
||||
|
||||
$role->add_cap( 'promote_users' );
|
||||
@ -863,7 +867,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
||||
if ( '' == $site_name )
|
||||
$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );
|
||||
|
||||
// check for network collision
|
||||
// Check for network collision.
|
||||
if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) )
|
||||
$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
|
||||
|
||||
@ -874,7 +878,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
||||
if ( $errors->get_error_code() )
|
||||
return $errors;
|
||||
|
||||
// set up site tables
|
||||
// Set up site tables.
|
||||
$template = get_option( 'template' );
|
||||
$stylesheet = get_option( 'stylesheet' );
|
||||
$allowed_themes = array( $stylesheet => true );
|
||||
@ -920,13 +924,13 @@ We hope you enjoy your new site. Thanks!
|
||||
--The Team @ SITE_NAME' );
|
||||
|
||||
$misc_exts = array(
|
||||
// images
|
||||
// Images.
|
||||
'jpg', 'jpeg', 'png', 'gif',
|
||||
// video
|
||||
// Video.
|
||||
'mov', 'avi', 'mpg', '3gp', '3g2',
|
||||
// "audio"
|
||||
// "audio".
|
||||
'midi', 'mid',
|
||||
// misc
|
||||
// Miscellaneous.
|
||||
'pdf', 'doc', 'ppt', 'odt', 'pptx', 'docx', 'pps', 'ppsx', 'xls', 'xlsx', 'key',
|
||||
);
|
||||
$audio_exts = wp_get_audio_extensions();
|
||||
@ -981,9 +985,13 @@ We hope you enjoy your new site. Thanks!
|
||||
}
|
||||
$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
|
||||
|
||||
// When upgrading from single to multisite, assume the current site will become the main site of the network.
|
||||
// When using populate_network() to create another network in an existing multisite environment,
|
||||
// skip these steps since the main site of the new network has not yet been created.
|
||||
/*
|
||||
* When upgrading from single to multisite, assume the current site will
|
||||
* become the main site of the network. When using populate_network()
|
||||
* to create another network in an existing multisite environment, skip
|
||||
* these steps since the main site of the new network has not yet been
|
||||
* created.
|
||||
*/
|
||||
if ( ! is_multisite() ) {
|
||||
$current_site = new stdClass;
|
||||
$current_site->domain = $domain;
|
||||
|
@ -583,10 +583,10 @@ function _list_meta_row( $entry, &$count ) {
|
||||
|
||||
if ( is_serialized( $entry['meta_value'] ) ) {
|
||||
if ( is_serialized_string( $entry['meta_value'] ) ) {
|
||||
// this is a serialized string, so we should display it
|
||||
// This is a serialized string, so we should display it.
|
||||
$entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
|
||||
} else {
|
||||
// this is a serialized array/object so we should NOT display it
|
||||
// This is a serialized array/object so we should NOT display it.
|
||||
--$count;
|
||||
return;
|
||||
}
|
||||
@ -716,6 +716,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
|
||||
if ( (int) $tab_index > 0 )
|
||||
$tab_index_attribute = " tabindex=\"$tab_index\"";
|
||||
|
||||
// todo: Remove this?
|
||||
// echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
|
||||
|
||||
$time_adj = current_time('timestamp');
|
||||
@ -940,23 +941,30 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
|
||||
// If core box previously deleted, don't add
|
||||
if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
|
||||
return;
|
||||
// If box was added with default priority, give it core priority to maintain sort order
|
||||
|
||||
/*
|
||||
* If box was added with default priority, give it core priority to
|
||||
* maintain sort order.
|
||||
*/
|
||||
if ( 'default' == $a_priority ) {
|
||||
$wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
|
||||
unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// If no priority given and id already present, use existing priority
|
||||
// If no priority given and id already present, use existing priority.
|
||||
if ( empty($priority) ) {
|
||||
$priority = $a_priority;
|
||||
// else if we're adding to the sorted priority, we don't know the title or callback. Grab them from the previously added context/priority.
|
||||
/*
|
||||
* Else, if we're adding to the sorted priority, we don't know the title
|
||||
* or callback. Grab them from the previously added context/priority.
|
||||
*/
|
||||
} elseif ( 'sorted' == $priority ) {
|
||||
$title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
|
||||
$callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
|
||||
$callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
|
||||
}
|
||||
// An id can be in only one priority and one context
|
||||
// An id can be in only one priority and one context.
|
||||
if ( $priority != $a_priority || $context != $a_context )
|
||||
unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
|
||||
}
|
||||
@ -1340,23 +1348,25 @@ function add_settings_error( $setting, $code, $message, $type = 'error' ) {
|
||||
function get_settings_errors( $setting = '', $sanitize = false ) {
|
||||
global $wp_settings_errors;
|
||||
|
||||
// If $sanitize is true, manually re-run the sanitization for this option
|
||||
// This allows the $sanitize_callback from register_setting() to run, adding
|
||||
// any settings errors you want to show by default.
|
||||
/*
|
||||
* If $sanitize is true, manually re-run the sanitization for this option
|
||||
* This allows the $sanitize_callback from register_setting() to run, adding
|
||||
* any settings errors you want to show by default.
|
||||
*/
|
||||
if ( $sanitize )
|
||||
sanitize_option( $setting, get_option( $setting ) );
|
||||
|
||||
// If settings were passed back from options.php then use them
|
||||
// If settings were passed back from options.php then use them.
|
||||
if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
|
||||
$wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
|
||||
delete_transient( 'settings_errors' );
|
||||
}
|
||||
|
||||
// Check global in case errors have been added on this pageload
|
||||
// Check global in case errors have been added on this pageload.
|
||||
if ( ! count( $wp_settings_errors ) )
|
||||
return array();
|
||||
|
||||
// Filter the results to those of a specific setting if one was set
|
||||
// Filter the results to those of a specific setting if one was set.
|
||||
if ( $setting ) {
|
||||
$setting_errors = array();
|
||||
foreach ( (array) $wp_settings_errors as $key => $details ) {
|
||||
|
@ -1089,7 +1089,10 @@ function _copy_dir($from, $to, $skip_list = array() ) {
|
||||
return new WP_Error( 'mkdir_failed__copy_dir', __( 'Could not create directory.' ), $to . $filename );
|
||||
}
|
||||
|
||||
// generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list
|
||||
/*
|
||||
* Generate the $sub_skip_list for the subdirectory as a sub-set
|
||||
* of the existing $skip_list.
|
||||
*/
|
||||
$sub_skip_list = array();
|
||||
foreach ( $skip_list as $skip_item ) {
|
||||
if ( 0 === strpos( $skip_item, $filename . '/' ) )
|
||||
@ -1125,7 +1128,7 @@ function _redirect_to_about_wordpress( $new_version ) {
|
||||
if ( 'do-core-upgrade' != $action && 'do-core-reinstall' != $action )
|
||||
return;
|
||||
|
||||
// Load the updated default text localization domain for new strings
|
||||
// Load the updated default text localization domain for new strings.
|
||||
load_default_textdomain();
|
||||
|
||||
// See do_core_upgrade()
|
||||
@ -1141,7 +1144,7 @@ window.location = 'about.php?updated';
|
||||
</script>
|
||||
<?php
|
||||
|
||||
// Include admin-footer.php and exit
|
||||
// Include admin-footer.php and exit.
|
||||
include(ABSPATH . 'wp-admin/admin-footer.php');
|
||||
exit();
|
||||
}
|
||||
|
@ -61,8 +61,10 @@ function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated
|
||||
if ( ! $public )
|
||||
update_option('default_pingback_flag', 0);
|
||||
|
||||
// Create default user. If the user already exists, the user tables are
|
||||
// being shared among blogs. Just set the role in that case.
|
||||
/*
|
||||
* Create default user. If the user already exists, the user tables are
|
||||
* being shared among blogs. Just set the role in that case.
|
||||
*/
|
||||
$user_id = username_exists($user_name);
|
||||
$user_password = trim($user_password);
|
||||
$email_password = false;
|
||||
@ -625,8 +627,10 @@ function upgrade_130() {
|
||||
|
||||
$active_plugins = __get_option('active_plugins');
|
||||
|
||||
// If plugins are not stored in an array, they're stored in the old
|
||||
// newline separated format. Convert to new format.
|
||||
/*
|
||||
* If plugins are not stored in an array, they're stored in the old
|
||||
* newline separated format. Convert to new format.
|
||||
*/
|
||||
if ( !is_array( $active_plugins ) ) {
|
||||
$active_plugins = explode("\n", trim($active_plugins));
|
||||
update_option('active_plugins', $active_plugins);
|
||||
@ -716,14 +720,16 @@ function upgrade_160() {
|
||||
$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
|
||||
$wpdb->show_errors();
|
||||
|
||||
// populate comment_count field of posts table
|
||||
// Populate comment_count field of posts table.
|
||||
$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
|
||||
if ( is_array( $comments ) )
|
||||
foreach ($comments as $comment)
|
||||
$wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
|
||||
|
||||
// Some alpha versions used a post status of object instead of attachment and put
|
||||
// the mime type in post_type instead of post_mime_type.
|
||||
/*
|
||||
* Some alpha versions used a post status of object instead of attachment
|
||||
* and put the mime type in post_type instead of post_mime_type.
|
||||
*/
|
||||
if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
|
||||
$objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
|
||||
foreach ($objects as $object) {
|
||||
@ -880,8 +886,10 @@ function upgrade_230() {
|
||||
|
||||
// < 3570 we used linkcategories. >= 3570 we used categories and link2cat.
|
||||
if ( $wp_current_db_version < 3570 ) {
|
||||
// Create link_category terms for link categories. Create a map of link cat IDs
|
||||
// to link_category terms.
|
||||
/*
|
||||
* Create link_category terms for link categories. Create a map of link
|
||||
* cat IDs to link_category terms.
|
||||
*/
|
||||
$link_cat_id_map = array();
|
||||
$default_link_cat = 0;
|
||||
$tt_ids = array();
|
||||
@ -989,7 +997,7 @@ function upgrade_230_old_tables() {
|
||||
* @since 2.2.0
|
||||
*/
|
||||
function upgrade_old_slugs() {
|
||||
// upgrade people who were using the Redirect Old Slugs plugin
|
||||
// Upgrade people who were using the Redirect Old Slugs plugin.
|
||||
global $wpdb;
|
||||
$wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'");
|
||||
}
|
||||
@ -1304,11 +1312,13 @@ function upgrade_380() {
|
||||
function upgrade_network() {
|
||||
global $wp_current_db_version, $wpdb;
|
||||
|
||||
// Always
|
||||
// Always.
|
||||
if ( is_main_network() ) {
|
||||
// Deletes all expired transients.
|
||||
// The multi-table delete syntax is used to delete the transient record from table a,
|
||||
// and the corresponding transient_timeout record from table b.
|
||||
/*
|
||||
* Deletes all expired transients. The multi-table delete syntax is used
|
||||
* to delete the transient record from table a, and the corresponding
|
||||
* transient_timeout record from table b.
|
||||
*/
|
||||
$time = time();
|
||||
$sql = "DELETE a, b FROM $wpdb->sitemeta a, $wpdb->sitemeta b
|
||||
WHERE a.meta_key LIKE %s
|
||||
@ -1318,7 +1328,7 @@ function upgrade_network() {
|
||||
$wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like ( '_site_transient_timeout_' ) . '%', $time ) );
|
||||
}
|
||||
|
||||
// 2.8
|
||||
// 2.8.
|
||||
if ( $wp_current_db_version < 11549 ) {
|
||||
$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
|
||||
$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
|
||||
@ -1415,9 +1425,11 @@ function maybe_create_table($table_name, $create_ddl) {
|
||||
if ( $wpdb->get_var( $query ) == $table_name ) {
|
||||
return true;
|
||||
}
|
||||
//didn't find it try to create it.
|
||||
|
||||
// Didn't find it try to create it..
|
||||
$wpdb->query($create_ddl);
|
||||
// we cannot directly tell that whether this succeeded!
|
||||
|
||||
// We cannot directly tell that whether this succeeded!
|
||||
if ( $wpdb->get_var( $query ) == $table_name ) {
|
||||
return true;
|
||||
}
|
||||
@ -1478,9 +1490,11 @@ function maybe_add_column($table_name, $column_name, $create_ddl) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//didn't find it try to create it.
|
||||
|
||||
// Didn't find it try to create it.
|
||||
$wpdb->query($create_ddl);
|
||||
// we cannot directly tell that whether this succeeded!
|
||||
|
||||
// We cannot directly tell that whether this succeeded!
|
||||
foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
|
||||
if ($column == $column_name) {
|
||||
return true;
|
||||
@ -1551,12 +1565,16 @@ function __get_option($setting) {
|
||||
function deslash($content) {
|
||||
// Note: \\\ inside a regex denotes a single backslash.
|
||||
|
||||
// Replace one or more backslashes followed by a single quote with
|
||||
// a single quote.
|
||||
/*
|
||||
* Replace one or more backslashes followed by a single quote with
|
||||
* a single quote.
|
||||
*/
|
||||
$content = preg_replace("/\\\+'/", "'", $content);
|
||||
|
||||
// Replace one or more backslashes followed by a double quote with
|
||||
// a double quote.
|
||||
/*
|
||||
* Replace one or more backslashes followed by a double quote with
|
||||
* a double quote.
|
||||
*/
|
||||
$content = preg_replace('/\\\+"/', '"', $content);
|
||||
|
||||
// Replace one or more backslashes with one backslash.
|
||||
@ -1655,24 +1673,27 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
if ( ! $tablefields )
|
||||
continue;
|
||||
|
||||
// Clear the field and index arrays
|
||||
// Clear the field and index arrays.
|
||||
$cfields = $indices = array();
|
||||
// Get all of the field names in the query from between the parens
|
||||
|
||||
// Get all of the field names in the query from between the parentheses.
|
||||
preg_match("|\((.*)\)|ms", $qry, $match2);
|
||||
$qryline = trim($match2[1]);
|
||||
|
||||
// Separate field lines into an array
|
||||
// Separate field lines into an array.
|
||||
$flds = explode("\n", $qryline);
|
||||
|
||||
// todo: Remove this?
|
||||
//echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
|
||||
|
||||
// For every field line specified in the query
|
||||
// For every field line specified in the query.
|
||||
foreach ($flds as $fld) {
|
||||
// Extract the field name
|
||||
|
||||
// Extract the field name.
|
||||
preg_match("|^([^ ]*)|", trim($fld), $fvals);
|
||||
$fieldname = trim( $fvals[1], '`' );
|
||||
|
||||
// Verify the found field name
|
||||
// Verify the found field name.
|
||||
$validfield = true;
|
||||
switch (strtolower($fieldname)) {
|
||||
case '':
|
||||
@ -1687,17 +1708,19 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
}
|
||||
$fld = trim($fld);
|
||||
|
||||
// If it's a valid field, add it to the field array
|
||||
// If it's a valid field, add it to the field array.
|
||||
if ($validfield) {
|
||||
$cfields[strtolower($fieldname)] = trim($fld, ", \n");
|
||||
}
|
||||
}
|
||||
|
||||
// For every field in the table
|
||||
// For every field in the table.
|
||||
foreach ($tablefields as $tablefield) {
|
||||
// If the table field exists in the field array...
|
||||
|
||||
// If the table field exists in the field array ...
|
||||
if (array_key_exists(strtolower($tablefield->Field), $cfields)) {
|
||||
// Get the field type from the query
|
||||
|
||||
// Get the field type from the query.
|
||||
preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
|
||||
$fieldtype = $matches[1];
|
||||
|
||||
@ -1709,6 +1732,7 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
}
|
||||
|
||||
// Get the default value from the array
|
||||
// todo: Remove this?
|
||||
//echo "{$cfields[strtolower($tablefield->Field)]}<br>";
|
||||
if (preg_match("| DEFAULT '(.*?)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
|
||||
$default_value = $matches[1];
|
||||
@ -1719,39 +1743,40 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the field from the array (so it's not added)
|
||||
// Remove the field from the array (so it's not added).
|
||||
unset($cfields[strtolower($tablefield->Field)]);
|
||||
} else {
|
||||
// This field exists in the table, but not in the creation queries?
|
||||
}
|
||||
}
|
||||
|
||||
// For every remaining field specified for the table
|
||||
// For every remaining field specified for the table.
|
||||
foreach ($cfields as $fieldname => $fielddef) {
|
||||
// Push a query line into $cqueries that adds the field to that table
|
||||
// Push a query line into $cqueries that adds the field to that table.
|
||||
$cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
|
||||
$for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
|
||||
}
|
||||
|
||||
// Index stuff goes here
|
||||
// Fetch the table index structure from the database
|
||||
// Index stuff goes here. Fetch the table index structure from the database.
|
||||
$tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
|
||||
|
||||
if ($tableindices) {
|
||||
// Clear the index array
|
||||
// Clear the index array.
|
||||
unset($index_ary);
|
||||
|
||||
// For every index in the table
|
||||
// For every index in the table.
|
||||
foreach ($tableindices as $tableindex) {
|
||||
// Add the index to the index data array
|
||||
|
||||
// Add the index to the index data array.
|
||||
$keyname = $tableindex->Key_name;
|
||||
$index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
|
||||
$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
|
||||
}
|
||||
|
||||
// For each actual index in the index array
|
||||
// For each actual index in the index array.
|
||||
foreach ($index_ary as $index_name => $index_data) {
|
||||
// Build a create string to compare to the query
|
||||
|
||||
// Build a create string to compare to the query.
|
||||
$index_string = '';
|
||||
if ($index_name == 'PRIMARY') {
|
||||
$index_string .= 'PRIMARY ';
|
||||
@ -1763,39 +1788,44 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
$index_string .= $index_name;
|
||||
}
|
||||
$index_columns = '';
|
||||
// For each column in the index
|
||||
|
||||
// For each column in the index.
|
||||
foreach ($index_data['columns'] as $column_data) {
|
||||
if ($index_columns != '') $index_columns .= ',';
|
||||
// Add the field to the column list string
|
||||
|
||||
// Add the field to the column list string.
|
||||
$index_columns .= $column_data['fieldname'];
|
||||
if ($column_data['subpart'] != '') {
|
||||
$index_columns .= '('.$column_data['subpart'].')';
|
||||
}
|
||||
}
|
||||
// Add the column list to the index create string
|
||||
// Add the column list to the index create string.
|
||||
$index_string .= ' ('.$index_columns.')';
|
||||
if (!(($aindex = array_search($index_string, $indices)) === false)) {
|
||||
unset($indices[$aindex]);
|
||||
// todo: Remove this?
|
||||
//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
|
||||
}
|
||||
// todo: Remove this?
|
||||
//else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br /><b>Did not find index:</b>".$index_string."<br />".print_r($indices, true)."</pre>\n";
|
||||
}
|
||||
}
|
||||
|
||||
// For every remaining index specified for the table
|
||||
// For every remaining index specified for the table.
|
||||
foreach ( (array) $indices as $index ) {
|
||||
// Push a query line into $cqueries that adds the index to that table
|
||||
// Push a query line into $cqueries that adds the index to that table.
|
||||
$cqueries[] = "ALTER TABLE {$table} ADD $index";
|
||||
$for_update[] = 'Added index ' . $table . ' ' . $index;
|
||||
}
|
||||
|
||||
// Remove the original table creation query from processing
|
||||
// Remove the original table creation query from processing.
|
||||
unset( $cqueries[ $table ], $for_update[ $table ] );
|
||||
}
|
||||
|
||||
$allqueries = array_merge($cqueries, $iqueries);
|
||||
if ($execute) {
|
||||
foreach ($allqueries as $query) {
|
||||
// todo: Remove this?
|
||||
//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
|
||||
$wpdb->query($query);
|
||||
}
|
||||
@ -1847,9 +1877,10 @@ function make_site_theme_from_oldschool($theme_name, $template) {
|
||||
if (! file_exists("$home_path/index.php"))
|
||||
return false;
|
||||
|
||||
// Copy files from the old locations to the site theme.
|
||||
// TODO: This does not copy arbitrary include dependencies. Only the
|
||||
// standard WP files are copied.
|
||||
/*
|
||||
* Copy files from the old locations to the site theme.
|
||||
* TODO: This does not copy arbitrary include dependencies. Only the standard WP files are copied.
|
||||
*/
|
||||
$files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
|
||||
|
||||
foreach ($files as $oldfile => $newfile) {
|
||||
@ -1858,12 +1889,15 @@ function make_site_theme_from_oldschool($theme_name, $template) {
|
||||
else
|
||||
$oldpath = ABSPATH;
|
||||
|
||||
if ($oldfile == 'index.php') { // Check to make sure it's not a new index
|
||||
// Check to make sure it's not a new index.
|
||||
if ($oldfile == 'index.php') {
|
||||
$index = implode('', file("$oldpath/$oldfile"));
|
||||
if (strpos($index, 'WP_USE_THEMES') !== false) {
|
||||
if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile"))
|
||||
return false;
|
||||
continue; // Don't copy anything
|
||||
|
||||
// Don't copy anything.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,10 +390,11 @@ add_action('admin_init', 'default_password_nag_handler');
|
||||
*/
|
||||
function default_password_nag_handler($errors = false) {
|
||||
global $user_ID;
|
||||
if ( ! get_user_option('default_password_nag') ) //Short circuit it.
|
||||
// Short-circuit it.
|
||||
if ( ! get_user_option('default_password_nag') )
|
||||
return;
|
||||
|
||||
//get_user_setting = JS saved UI setting. else no-js-fallback code.
|
||||
// get_user_setting = JS saved UI setting. else no-js-fallback code.
|
||||
if ( 'hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag'] ) {
|
||||
delete_user_setting('default_password_nag');
|
||||
update_user_option($user_ID, 'default_password_nag', false, true);
|
||||
@ -401,28 +402,33 @@ function default_password_nag_handler($errors = false) {
|
||||
}
|
||||
|
||||
add_action('profile_update', 'default_password_nag_edit_user', 10, 2);
|
||||
|
||||
/**
|
||||
* @since 2.8.0
|
||||
*/
|
||||
function default_password_nag_edit_user($user_ID, $old_data) {
|
||||
if ( ! get_user_option('default_password_nag', $user_ID) ) //Short circuit it.
|
||||
// Short-circuit it.
|
||||
if ( ! get_user_option('default_password_nag', $user_ID) )
|
||||
return;
|
||||
|
||||
$new_data = get_userdata($user_ID);
|
||||
|
||||
if ( $new_data->user_pass != $old_data->user_pass ) { //Remove the nag if the password has been changed.
|
||||
// Remove the nag if the password has been changed.
|
||||
if ( $new_data->user_pass != $old_data->user_pass ) {
|
||||
delete_user_setting('default_password_nag');
|
||||
update_user_option($user_ID, 'default_password_nag', false, true);
|
||||
}
|
||||
}
|
||||
|
||||
add_action('admin_notices', 'default_password_nag');
|
||||
|
||||
/**
|
||||
* @since 2.8.0
|
||||
*/
|
||||
function default_password_nag() {
|
||||
global $pagenow;
|
||||
if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') ) //Short circuit it.
|
||||
// Short-circuit it.
|
||||
if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') )
|
||||
return;
|
||||
|
||||
echo '<div class="error default-password-nag">';
|
||||
|
@ -173,11 +173,14 @@ function wp_widget_control( $sidebar_args ) {
|
||||
$query_arg['key'] = $key;
|
||||
}
|
||||
|
||||
// We aren't showing a widget control, we're outputting a template for a multi-widget control
|
||||
/*
|
||||
* We aren't showing a widget control, we're outputting a template
|
||||
* for a multi-widget control.
|
||||
*/
|
||||
if ( isset($sidebar_args['_display']) && 'template' == $sidebar_args['_display'] && $widget_number ) {
|
||||
// number == -1 implies a template where id numbers are replaced by a generic '__i__'
|
||||
$control['params'][0]['number'] = -1;
|
||||
// with id_base widget id's are constructed like {$id_base}-{$id_number}
|
||||
// With id_base widget id's are constructed like {$id_base}-{$id_number}.
|
||||
if ( isset($control['id_base']) )
|
||||
$id_format = $control['id_base'] . '-__i__';
|
||||
}
|
||||
|
@ -57,9 +57,10 @@ function maybe_create_table($table_name, $create_ddl) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//didn't find it try to create it.
|
||||
// Didn't find it, so try to create it.
|
||||
$wpdb->query($create_ddl);
|
||||
// we cannot directly tell that whether this succeeded!
|
||||
|
||||
// We cannot directly tell that whether this succeeded!
|
||||
foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
|
||||
if ($table == $table_name) {
|
||||
return true;
|
||||
@ -90,9 +91,11 @@ function maybe_add_column($table_name, $column_name, $create_ddl) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//didn't find it try to create it.
|
||||
|
||||
// Didn't find it, so try to create it.
|
||||
$wpdb->query($create_ddl);
|
||||
// we cannot directly tell that whether this succeeded!
|
||||
|
||||
// We cannot directly tell that whether this succeeded!
|
||||
foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
|
||||
if ($column == $column_name) {
|
||||
return true;
|
||||
@ -118,9 +121,11 @@ function maybe_drop_column($table_name, $column_name, $drop_ddl) {
|
||||
global $wpdb;
|
||||
foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
|
||||
if ($column == $column_name) {
|
||||
//found it try to drop it.
|
||||
|
||||
// Found it, so try to drop it.
|
||||
$wpdb->query($drop_ddl);
|
||||
// we cannot directly tell that whether this succeeded!
|
||||
|
||||
// We cannot directly tell that whether this succeeded!
|
||||
foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
|
||||
if ($column == $column_name) {
|
||||
return false;
|
||||
@ -128,7 +133,7 @@ function maybe_drop_column($table_name, $column_name, $drop_ddl) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// else didn't find it
|
||||
// Else didn't find it.
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -167,7 +172,8 @@ function check_column($table_name, $col_name, $col_type, $is_null = null, $key =
|
||||
foreach ($results as $row ) {
|
||||
|
||||
if ($row->Field == $col_name) {
|
||||
// got our column, check the params
|
||||
|
||||
// Got our column, check the params.
|
||||
if (($col_type != null) && ($row->Type != $col_type)) {
|
||||
++$diffs;
|
||||
}
|
||||
|
@ -222,7 +222,8 @@ switch($step) {
|
||||
$admin_password_check = isset($_POST['admin_password2']) ? wp_unslash( $_POST['admin_password2'] ) : '';
|
||||
$admin_email = isset( $_POST['admin_email'] ) ?trim( wp_unslash( $_POST['admin_email'] ) ) : '';
|
||||
$public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : 0;
|
||||
// check e-mail address
|
||||
|
||||
// Check e-mail address.
|
||||
$error = false;
|
||||
if ( empty( $user_name ) ) {
|
||||
// TODO: poka-yoke
|
||||
|
@ -45,13 +45,14 @@ function startElement($parser, $tagName, $attrs) {
|
||||
if ( isset( $attrs['HTMLURL'] ) ) {
|
||||
$url = $attrs['HTMLURL'];
|
||||
}
|
||||
// save the data away.
|
||||
|
||||
// Save the data away.
|
||||
$names[] = $name;
|
||||
$urls[] = $url;
|
||||
$targets[] = isset( $attrs['TARGET'] ) ? $attrs['TARGET'] : '';
|
||||
$feeds[] = isset( $attrs['XMLURL'] ) ? $attrs['XMLURL'] : '';
|
||||
$descriptions[] = isset( $attrs['DESCRIPTION'] ) ? $attrs['DESCRIPTION'] : '';
|
||||
} // end if outline
|
||||
} // End if outline.
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +65,7 @@ function startElement($parser, $tagName, $attrs) {
|
||||
* @param string $tagName XML tag name.
|
||||
*/
|
||||
function endElement($parser, $tagName) {
|
||||
// nothing to do.
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
// Create an XML parser
|
||||
|
@ -30,7 +30,7 @@ switch ($action) {
|
||||
case 'deletebookmarks' :
|
||||
check_admin_referer('bulk-bookmarks');
|
||||
|
||||
//for each link id (in $linkcheck[]) change category to selected value
|
||||
// For each link id (in $linkcheck[]) change category to selected value.
|
||||
if (count($linkcheck) == 0) {
|
||||
wp_redirect($this_file);
|
||||
exit;
|
||||
@ -50,14 +50,16 @@ switch ($action) {
|
||||
case 'move' :
|
||||
check_admin_referer('bulk-bookmarks');
|
||||
|
||||
//for each link id (in $linkcheck[]) change category to selected value
|
||||
// For each link id (in $linkcheck[]) change category to selected value.
|
||||
if (count($linkcheck) == 0) {
|
||||
wp_redirect($this_file);
|
||||
exit;
|
||||
}
|
||||
$all_links = join(',', $linkcheck);
|
||||
// should now have an array of links we can change
|
||||
//$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
|
||||
/*
|
||||
* Should now have an array of links we can change:
|
||||
* $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
|
||||
*/
|
||||
|
||||
wp_redirect($this_file);
|
||||
exit;
|
||||
|
@ -30,14 +30,14 @@ wp_enqueue_script( 'media-gallery' );
|
||||
$ID = isset($ID) ? (int) $ID : 0;
|
||||
$post_id = isset($post_id)? (int) $post_id : 0;
|
||||
|
||||
// Require an ID for the edit screen
|
||||
// Require an ID for the edit screen.
|
||||
if ( isset($action) && $action == 'edit' && !$ID )
|
||||
wp_die( __( 'Cheatin’ uh?' ) );
|
||||
|
||||
if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) )
|
||||
wp_die( __( 'Cheatin’ uh?' ) );
|
||||
|
||||
// upload type: image, video, file, ..?
|
||||
// Upload type: image, video, file, ..?
|
||||
if ( isset($_GET['type']) ) {
|
||||
$type = strval($_GET['type']);
|
||||
} else {
|
||||
@ -52,7 +52,7 @@ if ( isset($action) && $action == 'edit' && !$ID )
|
||||
$type = apply_filters( 'media_upload_default_type', 'file' );
|
||||
}
|
||||
|
||||
// tab: gallery, library, or type-specific
|
||||
// Tab: gallery, library, or type-specific.
|
||||
if ( isset($_GET['tab']) ) {
|
||||
$tab = strval($_GET['tab']);
|
||||
} else {
|
||||
@ -68,7 +68,7 @@ if ( isset($action) && $action == 'edit' && !$ID )
|
||||
|
||||
$body_id = 'media-upload';
|
||||
|
||||
// let the action code decide how to handle the request
|
||||
// Let the action code decide how to handle the request.
|
||||
if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_upload_tabs() ) ) {
|
||||
/**
|
||||
* Fires inside specific upload-type views in the legacy (pre-3.5.0)
|
||||
|
@ -40,7 +40,7 @@ case 'editattachment' :
|
||||
exit;
|
||||
}
|
||||
|
||||
// no break
|
||||
// No break.
|
||||
case 'edit' :
|
||||
$title = __('Edit Media');
|
||||
|
||||
|
@ -80,9 +80,12 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
||||
$img = $img_style = '';
|
||||
$img_class = ' dashicons-before';
|
||||
|
||||
// if the string 'none' (previously 'div') is passed instead of an URL, don't output the default menu image
|
||||
// so an icon can be added to div.wp-menu-image as background with CSS.
|
||||
// Dashicons and base64-encoded data:image/svg_xml URIs are also handled as special cases.
|
||||
/*
|
||||
* If the string 'none' (previously 'div') is passed instead of an URL, don't output
|
||||
* the default menu image so an icon can be added to div.wp-menu-image as background
|
||||
* with CSS. Dashicons and base64-encoded data:image/svg_xml URIs are also handled
|
||||
* as special cases.
|
||||
*/
|
||||
if ( ! empty( $item[6] ) ) {
|
||||
$img = '<img src="' . $item[6] . '" alt="" />';
|
||||
|
||||
|
@ -121,7 +121,10 @@ foreach ( (array) get_post_types( array('show_ui' => true, '_builtin' => false,
|
||||
$ptype_class = 'post';
|
||||
}
|
||||
|
||||
// if $ptype_menu_position is already populated or will be populated by a hard-coded value below, increment the position.
|
||||
/*
|
||||
* If $ptype_menu_position is already populated or will be populated
|
||||
* by a hard-coded value below, increment the position.
|
||||
*/
|
||||
$core_menu_positions = array(59, 60, 65, 70, 75, 80, 85, 99);
|
||||
while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) )
|
||||
$ptype_menu_position++;
|
||||
|
@ -53,7 +53,8 @@ switch ( $action ) {
|
||||
wp_save_nav_menu_items( $nav_menu_selected_id, $_REQUEST['menu-item'] );
|
||||
break;
|
||||
case 'move-down-menu-item' :
|
||||
// moving down a menu item is the same as moving up the next in order
|
||||
|
||||
// Moving down a menu item is the same as moving up the next in order.
|
||||
check_admin_referer( 'move-menu_item' );
|
||||
$menu_item_id = isset( $_REQUEST['menu-item'] ) ? (int) $_REQUEST['menu-item'] : 0;
|
||||
if ( is_nav_menu_item( $menu_item_id ) ) {
|
||||
@ -63,7 +64,7 @@ switch ( $action ) {
|
||||
$ordered_menu_items = wp_get_nav_menu_items( $menu_id );
|
||||
$menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) );
|
||||
|
||||
// set up the data we need in one pass through the array of menu items
|
||||
// Set up the data we need in one pass through the array of menu items.
|
||||
$dbids_to_orders = array();
|
||||
$orders_to_dbids = array();
|
||||
foreach( (array) $ordered_menu_items as $ordered_menu_item_object ) {
|
||||
@ -75,14 +76,14 @@ switch ( $action ) {
|
||||
}
|
||||
}
|
||||
|
||||
// get next in order
|
||||
// Get next in order.
|
||||
if (
|
||||
isset( $orders_to_dbids[$dbids_to_orders[$menu_item_id] + 1] )
|
||||
) {
|
||||
$next_item_id = $orders_to_dbids[$dbids_to_orders[$menu_item_id] + 1];
|
||||
$next_item_data = (array) wp_setup_nav_menu_item( get_post( $next_item_id ) );
|
||||
|
||||
// if not siblings of same parent, bubble menu item up but keep order
|
||||
// If not siblings of same parent, bubble menu item up but keep order.
|
||||
if (
|
||||
! empty( $menu_item_data['menu_item_parent'] ) &&
|
||||
(
|
||||
@ -102,7 +103,7 @@ switch ( $action ) {
|
||||
|
||||
}
|
||||
|
||||
// make menu item a child of its next sibling
|
||||
// Make menu item a child of its next sibling.
|
||||
} else {
|
||||
$next_item_data['menu_order'] = $next_item_data['menu_order'] - 1;
|
||||
$menu_item_data['menu_order'] = $menu_item_data['menu_order'] + 1;
|
||||
@ -114,7 +115,7 @@ switch ( $action ) {
|
||||
wp_update_post($next_item_data);
|
||||
}
|
||||
|
||||
// the item is last but still has a parent, so bubble up
|
||||
// The item is last but still has a parent, so bubble up.
|
||||
} elseif (
|
||||
! empty( $menu_item_data['menu_item_parent'] ) &&
|
||||
in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids )
|
||||
@ -136,7 +137,7 @@ switch ( $action ) {
|
||||
$ordered_menu_items = wp_get_nav_menu_items( $menu_id );
|
||||
$menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) );
|
||||
|
||||
// set up the data we need in one pass through the array of menu items
|
||||
// Set up the data we need in one pass through the array of menu items.
|
||||
$dbids_to_orders = array();
|
||||
$orders_to_dbids = array();
|
||||
foreach( (array) $ordered_menu_items as $ordered_menu_item_object ) {
|
||||
@ -148,10 +149,10 @@ switch ( $action ) {
|
||||
}
|
||||
}
|
||||
|
||||
// if this menu item is not first
|
||||
// If this menu item is not first.
|
||||
if ( ! empty( $dbids_to_orders[$menu_item_id] ) && ! empty( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) ) {
|
||||
|
||||
// if this menu item is a child of the previous
|
||||
// If this menu item is a child of the previous.
|
||||
if (
|
||||
! empty( $menu_item_data['menu_item_parent'] ) &&
|
||||
in_array( $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ) ) &&
|
||||
@ -164,7 +165,10 @@ switch ( $action ) {
|
||||
if ( ! is_wp_error( $parent_object ) ) {
|
||||
$parent_data = (array) $parent_object;
|
||||
|
||||
// if there is something before the parent and parent a child of it, make menu item a child also of it
|
||||
/*
|
||||
* If there is something before the parent and parent a child of it,
|
||||
* make menu item a child also of it.
|
||||
*/
|
||||
if (
|
||||
! empty( $dbids_to_orders[$parent_db_id] ) &&
|
||||
! empty( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1] ) &&
|
||||
@ -172,7 +176,10 @@ switch ( $action ) {
|
||||
) {
|
||||
$menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent'];
|
||||
|
||||
// else if there is something before parent and parent not a child of it, make menu item a child of that something's parent
|
||||
/*
|
||||
* Else if there is something before parent and parent not a child of it,
|
||||
* make menu item a child of that something's parent
|
||||
*/
|
||||
} elseif (
|
||||
! empty( $dbids_to_orders[$parent_db_id] ) &&
|
||||
! empty( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1] )
|
||||
@ -183,24 +190,24 @@ switch ( $action ) {
|
||||
else
|
||||
$menu_item_data['menu_item_parent'] = 0;
|
||||
|
||||
// else there isn't something before the parent
|
||||
// Else there isn't something before the parent.
|
||||
} else {
|
||||
$menu_item_data['menu_item_parent'] = 0;
|
||||
}
|
||||
|
||||
// set former parent's [menu_order] to that of menu-item's
|
||||
// Set former parent's [menu_order] to that of menu-item's.
|
||||
$parent_data['menu_order'] = $parent_data['menu_order'] + 1;
|
||||
|
||||
// set menu-item's [menu_order] to that of former parent
|
||||
// Set menu-item's [menu_order] to that of former parent.
|
||||
$menu_item_data['menu_order'] = $menu_item_data['menu_order'] - 1;
|
||||
|
||||
// save changes
|
||||
// Save changes.
|
||||
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
|
||||
wp_update_post($menu_item_data);
|
||||
wp_update_post($parent_data);
|
||||
}
|
||||
|
||||
// else this menu item is not a child of the previous
|
||||
// Else this menu item is not a child of the previous.
|
||||
} elseif (
|
||||
empty( $menu_item_data['menu_order'] ) ||
|
||||
empty( $menu_item_data['menu_item_parent'] ) ||
|
||||
@ -208,7 +215,7 @@ switch ( $action ) {
|
||||
empty( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) ||
|
||||
$orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] != $menu_item_data['menu_item_parent']
|
||||
) {
|
||||
// just make it a child of the previous; keep the order
|
||||
// Just make it a child of the previous; keep the order.
|
||||
$menu_item_data['menu_item_parent'] = (int) $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1];
|
||||
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
|
||||
wp_update_post($menu_item_data);
|
||||
@ -232,7 +239,7 @@ switch ( $action ) {
|
||||
if ( is_nav_menu( $nav_menu_selected_id ) ) {
|
||||
$deletion = wp_delete_nav_menu( $nav_menu_selected_id );
|
||||
} else {
|
||||
// Reset the selected menu
|
||||
// Reset the selected menu.
|
||||
$nav_menu_selected_id = 0;
|
||||
unset( $_REQUEST['menu'] );
|
||||
}
|
||||
@ -266,22 +273,22 @@ switch ( $action ) {
|
||||
case 'update':
|
||||
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
|
||||
|
||||
// Remove menu locations that have been unchecked
|
||||
// Remove menu locations that have been unchecked.
|
||||
foreach ( $locations as $location => $description ) {
|
||||
if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id )
|
||||
unset( $menu_locations[ $location ] );
|
||||
}
|
||||
|
||||
// Merge new and existing menu locations if any new ones are set
|
||||
// Merge new and existing menu locations if any new ones are set.
|
||||
if ( isset( $_POST['menu-locations'] ) ) {
|
||||
$new_menu_locations = array_map( 'absint', $_POST['menu-locations'] );
|
||||
$menu_locations = array_merge( $menu_locations, $new_menu_locations );
|
||||
}
|
||||
|
||||
// Set menu locations
|
||||
// Set menu locations.
|
||||
set_theme_mod( 'nav_menu_locations', $menu_locations );
|
||||
|
||||
// Add Menu
|
||||
// Add Menu.
|
||||
if ( 0 == $nav_menu_selected_id ) {
|
||||
$new_menu_title = trim( esc_html( $_POST['menu-name'] ) );
|
||||
|
||||
@ -314,6 +321,7 @@ switch ( $action ) {
|
||||
$menu_locations[ $_REQUEST['use-location'] ] = $nav_menu_selected_id;
|
||||
set_theme_mod( 'nav_menu_locations', $menu_locations );
|
||||
}
|
||||
|
||||
// $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%s</strong> has been created.' ), $nav_menu_selected_title ) . '</p></div>';
|
||||
wp_redirect( admin_url( 'nav-menus.php?menu=' . $_nav_menu_selected_id ) );
|
||||
exit();
|
||||
@ -322,7 +330,7 @@ switch ( $action ) {
|
||||
$messages[] = '<div id="message" class="error"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>';
|
||||
}
|
||||
|
||||
// Update existing menu
|
||||
// Update existing menu.
|
||||
} else {
|
||||
|
||||
$_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id );
|
||||
@ -344,7 +352,7 @@ switch ( $action ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Update menu items
|
||||
// Update menu items.
|
||||
if ( ! is_wp_error( $_menu_object ) ) {
|
||||
$messages = array_merge( $messages, wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ) );
|
||||
}
|
||||
@ -371,7 +379,7 @@ switch ( $action ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Get all nav menus
|
||||
// Get all nav menus.
|
||||
$nav_menus = wp_get_nav_menus( array('orderby' => 'name') );
|
||||
$menu_count = count( $nav_menus );
|
||||
|
||||
@ -380,7 +388,10 @@ $add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : fals
|
||||
|
||||
$locations_screen = ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) ? true : false;
|
||||
|
||||
// If we have one theme location, and zero menus, we take them right into editing their first menu
|
||||
/*
|
||||
* If we have one theme location, and zero menus, we take them right
|
||||
* into editing their first menu.
|
||||
*/
|
||||
$page_count = wp_count_posts( 'page' );
|
||||
$one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
|
||||
|
||||
@ -404,32 +415,35 @@ $nav_menus_l10n = array(
|
||||
);
|
||||
wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n );
|
||||
|
||||
// Redirect to add screen if there are no menus and this users has either zero, or more than 1 theme locations
|
||||
/*
|
||||
* Redirect to add screen if there are no menus and this users has either zero,
|
||||
* or more than 1 theme locations.
|
||||
*/
|
||||
if ( 0 == $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus )
|
||||
wp_redirect( admin_url( 'nav-menus.php?action=edit&menu=0' ) );
|
||||
|
||||
// Get recently edited nav menu
|
||||
// Get recently edited nav menu.
|
||||
$recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) );
|
||||
if ( empty( $recently_edited ) && is_nav_menu( $nav_menu_selected_id ) )
|
||||
$recently_edited = $nav_menu_selected_id;
|
||||
|
||||
// Use $recently_edited if none are selected
|
||||
// Use $recently_edited if none are selected.
|
||||
if ( empty( $nav_menu_selected_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) )
|
||||
$nav_menu_selected_id = $recently_edited;
|
||||
|
||||
// On deletion of menu, if another menu exists, show it
|
||||
// On deletion of menu, if another menu exists, show it.
|
||||
if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] )
|
||||
$nav_menu_selected_id = $nav_menus[0]->term_id;
|
||||
|
||||
// Set $nav_menu_selected_id to 0 if no menus
|
||||
// Set $nav_menu_selected_id to 0 if no menus.
|
||||
if ( $one_theme_location_no_menus ) {
|
||||
$nav_menu_selected_id = 0;
|
||||
} elseif ( empty( $nav_menu_selected_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) {
|
||||
// if we have no selection yet, and we have menus, set to the first one in the list
|
||||
// if we have no selection yet, and we have menus, set to the first one in the list.
|
||||
$nav_menu_selected_id = $nav_menus[0]->term_id;
|
||||
}
|
||||
|
||||
// Update the user's setting
|
||||
// Update the user's setting.
|
||||
if ( $nav_menu_selected_id != $recently_edited && is_nav_menu( $nav_menu_selected_id ) )
|
||||
update_user_meta( $current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id );
|
||||
|
||||
@ -439,23 +453,25 @@ if ( ! $nav_menu_selected_title && is_nav_menu( $nav_menu_selected_id ) ) {
|
||||
$nav_menu_selected_title = ! is_wp_error( $_menu_object ) ? $_menu_object->name : '';
|
||||
}
|
||||
|
||||
// Generate truncated menu names
|
||||
// Generate truncated menu names.
|
||||
foreach( (array) $nav_menus as $key => $_nav_menu ) {
|
||||
$nav_menus[$key]->truncated_name = wp_html_excerpt( $_nav_menu->name, 40, '…' );
|
||||
}
|
||||
|
||||
// Retrieve menu locations
|
||||
// Retrieve menu locations.
|
||||
if ( current_theme_supports( 'menus' ) ) {
|
||||
$locations = get_registered_nav_menus();
|
||||
$menu_locations = get_nav_menu_locations();
|
||||
}
|
||||
|
||||
// Ensure the user will be able to scroll horizontally
|
||||
// by adding a class for the max menu depth.
|
||||
/*
|
||||
* Ensure the user will be able to scroll horizontally
|
||||
* by adding a class for the max menu depth.
|
||||
*/
|
||||
global $_wp_nav_menu_max_depth;
|
||||
$_wp_nav_menu_max_depth = 0;
|
||||
|
||||
// Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth
|
||||
// Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth.
|
||||
if ( is_nav_menu( $nav_menu_selected_id ) ) {
|
||||
$menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'post_status' => 'any' ) );
|
||||
$edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id );
|
||||
@ -510,7 +526,7 @@ if ( ! $locations_screen ) : // Main tab
|
||||
'title' => __( 'Editing Menus' ),
|
||||
'content' => $editing_menus
|
||||
) );
|
||||
else : // Locations Tab
|
||||
else : // Locations Tab.
|
||||
$locations_overview = '<p>' . __( 'This screen is used for globally assigning menus to locations defined by your theme.' ) . '</p>';
|
||||
$locations_overview .= '<ul><li>' . __( 'To assign menus to one or more theme locations, <strong>select a menu from each location’s drop down.</strong> When you’re finished, <strong>click Save Changes</strong>' ) . '</li>';
|
||||
$locations_overview .= '<li>' . __( 'To edit a menu currently assigned to a theme location, <strong>click the adjacent ’Edit’ link</strong>' ) . '</li>';
|
||||
@ -529,7 +545,7 @@ get_current_screen()->set_help_sidebar(
|
||||
'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
|
||||
);
|
||||
|
||||
// Get the admin header
|
||||
// Get the admin header.
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
?>
|
||||
<div class="wrap">
|
||||
@ -644,7 +660,7 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
*/
|
||||
$assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ) );
|
||||
|
||||
// Adds ellipses following the number of locations defined in $assigned_locations
|
||||
// Adds ellipses following the number of locations defined in $assigned_locations.
|
||||
if ( ! empty( $assigned_locations ) ) {
|
||||
printf( ' (%1$s%2$s)',
|
||||
implode( ', ', $assigned_locations ),
|
||||
|
@ -533,7 +533,7 @@ if ( $_POST ) {
|
||||
check_admin_referer( 'install-network-1' );
|
||||
|
||||
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
||||
// create network tables
|
||||
// Create network tables.
|
||||
install_network();
|
||||
$base = parse_url( trailingslashit( get_option( 'home' ) ), PHP_URL_PATH );
|
||||
$subdomain_install = allow_subdomain_install() ? !empty( $_POST['subdomain_install'] ) : false;
|
||||
|
@ -59,10 +59,10 @@ if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) {
|
||||
update_option( 'home', $blog_address );
|
||||
}
|
||||
|
||||
// rewrite rules can't be flushed during switch to blog
|
||||
// Rewrite rules can't be flushed during switch to blog.
|
||||
delete_option( 'rewrite_rules' );
|
||||
|
||||
// update blogs table
|
||||
// Update blogs table.
|
||||
$blog_data = wp_unslash( $_POST['blog'] );
|
||||
$existing_details = get_blog_details( $id, false );
|
||||
$blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
|
||||
|
@ -216,7 +216,7 @@ foreach ( (array) $options as $option ) :
|
||||
continue;
|
||||
if ( is_serialized( $option->option_value ) ) {
|
||||
if ( is_serialized_string( $option->option_value ) ) {
|
||||
// this is a serialized string, so we should display it
|
||||
// This is a serialized string, so we should display it.
|
||||
$value = maybe_unserialize( $option->option_value );
|
||||
$options_to_update[] = $option->option_name;
|
||||
$class = 'all-options';
|
||||
|
@ -40,7 +40,7 @@ function press_it() {
|
||||
$upload = false;
|
||||
if ( !empty($_POST['photo_src']) && current_user_can('upload_files') ) {
|
||||
foreach( (array) $_POST['photo_src'] as $key => $image) {
|
||||
// see if files exist in content - we don't want to upload non-used selected files.
|
||||
// See if files exist in content - we don't want to upload non-used selected files.
|
||||
if ( strpos($_POST['content'], htmlspecialchars($image)) !== false ) {
|
||||
$desc = isset($_POST['photo_description'][$key]) ? $_POST['photo_description'][$key] : '';
|
||||
$upload = media_sideload_image($image, $post_ID, $desc);
|
||||
@ -51,7 +51,7 @@ function press_it() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// set the post_content and status
|
||||
// Set the post_content and status.
|
||||
$post['post_content'] = $content;
|
||||
if ( isset( $_POST['publish'] ) && current_user_can( 'publish_posts' ) )
|
||||
$post['post_status'] = 'publish';
|
||||
@ -60,12 +60,12 @@ function press_it() {
|
||||
else
|
||||
$post['post_status'] = 'draft';
|
||||
|
||||
// error handling for media_sideload
|
||||
// Error handling for media_sideload.
|
||||
if ( is_wp_error($upload) ) {
|
||||
wp_delete_post($post_ID);
|
||||
wp_die($upload);
|
||||
} else {
|
||||
// Post formats
|
||||
// Post formats.
|
||||
if ( isset( $_POST['post_format'] ) ) {
|
||||
if ( current_theme_supports( 'post-formats', $_POST['post_format'] ) )
|
||||
set_post_format( $post_ID, $_POST['post_format'] );
|
||||
@ -181,9 +181,10 @@ if ( !empty($_REQUEST['ajax']) ) {
|
||||
return '';
|
||||
$sources = array();
|
||||
foreach ($matches[3] as $src) {
|
||||
// if no http in url
|
||||
|
||||
// If no http in URL.
|
||||
if (strpos($src, 'http') === false)
|
||||
// if it doesn't have a relative uri
|
||||
// If it doesn't have a relative URI.
|
||||
if ( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
|
||||
$src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
|
||||
else
|
||||
@ -197,7 +198,7 @@ if ( !empty($_REQUEST['ajax']) ) {
|
||||
break;
|
||||
|
||||
case 'photo_js': ?>
|
||||
// gather images and load some default JS
|
||||
// Gather images and load some default JS.
|
||||
var last = null
|
||||
var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
|
||||
if(photostorage == false) {
|
||||
@ -438,12 +439,14 @@ var photostorage = false;
|
||||
}
|
||||
}
|
||||
jQuery(document).ready(function($) {
|
||||
//resize screen
|
||||
// Resize screen.
|
||||
window.resizeTo(760,580);
|
||||
// set button actions
|
||||
|
||||
// Set button actions.
|
||||
jQuery('#photo_button').click(function() { show('photo'); return false; });
|
||||
jQuery('#video_button').click(function() { show('video'); return false; });
|
||||
// auto select
|
||||
|
||||
// Auto select.
|
||||
<?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
|
||||
show('video');
|
||||
<?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
|
||||
|
@ -300,8 +300,10 @@ el.select();
|
||||
</script>
|
||||
<?php
|
||||
else :
|
||||
// If this file doesn't exist, then we are using the wp-config-sample.php
|
||||
// file one level up, which is for the develop repo.
|
||||
/*
|
||||
* If this file doesn't exist, then we are using the wp-config-sample.php
|
||||
* file one level up, which is for the develop repo.
|
||||
*/
|
||||
if ( file_exists( ABSPATH . 'wp-config-sample.php' ) )
|
||||
$path_to_wp_config = ABSPATH . 'wp-config.php';
|
||||
else
|
||||
|
@ -81,7 +81,7 @@ case 'update':
|
||||
$newcontent = wp_unslash( $_POST['newcontent'] );
|
||||
$location = 'theme-editor.php?file=' . urlencode( $relative_file ) . '&theme=' . urlencode( $stylesheet ) . '&scrollto=' . $scrollto;
|
||||
if ( is_writeable( $file ) ) {
|
||||
//is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
|
||||
// is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
|
||||
$f = fopen( $file, 'w+' );
|
||||
if ( $f !== false ) {
|
||||
fwrite( $f, $newcontent );
|
||||
|
@ -540,8 +540,7 @@ if ( 'upgrade-core' == $action ) {
|
||||
|
||||
check_admin_referer('upgrade-core');
|
||||
|
||||
// do the (un)dismiss actions before headers,
|
||||
// so that they can redirect
|
||||
// Do the (un)dismiss actions before headers, so that they can redirect.
|
||||
if ( isset( $_POST['dismiss'] ) )
|
||||
do_dismiss_core_update();
|
||||
elseif ( isset( $_POST['undismiss'] ) )
|
||||
|
@ -141,7 +141,7 @@ if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) {
|
||||
$id_base = $_POST['id_base'];
|
||||
$sidebar = isset($sidebars_widgets[$sidebar_id]) ? $sidebars_widgets[$sidebar_id] : array();
|
||||
|
||||
// delete
|
||||
// Delete.
|
||||
if ( isset($_POST['removewidget']) && $_POST['removewidget'] ) {
|
||||
|
||||
if ( !in_array($widget_id, $sidebar, true) ) {
|
||||
@ -168,7 +168,7 @@ if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) {
|
||||
|
||||
$sidebars_widgets[$sidebar_id] = $sidebar;
|
||||
|
||||
// remove old position
|
||||
// Remove old position.
|
||||
if ( !isset($_POST['delete_widget']) ) {
|
||||
foreach ( $sidebars_widgets as $key => $sb ) {
|
||||
if ( is_array($sb) )
|
||||
@ -224,7 +224,7 @@ if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) {
|
||||
|
||||
$id_base = isset($control['id_base']) ? $control['id_base'] : $control['id'];
|
||||
|
||||
// show the widget form
|
||||
// Show the widget form.
|
||||
$width = ' style="width:' . max($control['width'], 350) . 'px"';
|
||||
$key = isset($_GET['key']) ? (int) $_GET['key'] : 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user