From: Edward Z. Yang
Date: Sun, 22 May 2011 10:11:40 +0000 (+0100)
Subject: Wordpress 3.1
X-Git-Tag: wordpress-3.1
X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/commitdiff_plain/refs/tags/wordpress-3.1
Wordpress 3.1
Signed-off-by: Edward Z. Yang
---
diff --git a/license.txt b/license.txt
index d31195ab..eda6b00a 100644
--- a/license.txt
+++ b/license.txt
@@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -279,3 +279,10 @@ POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
+
+WRITTEN OFFER
+
+The source code for any program binaries or compressed scripts that are
+included with WordPress can be freely obtained at the following URL:
+
+ http://wordpress.org/download/source/
diff --git a/readme.html b/readme.html
index 7dc2540c..bd56eb59 100644
--- a/readme.html
+++ b/readme.html
@@ -8,7 +8,7 @@
- Version 3.0.6
+ Version 3.1
Semantic Personal Publishing Platform
@@ -31,17 +31,17 @@
The installer should then send you to the login page. Sign in with the username and password you chose during the installation. If a password was generated for you, you can then click on 'Profile' to change the password.
-
Upgrading
-
Using the Automatic Upgrader
-
If you are upgrading from version 2.7 or higher, you can use the automatic upgrader:
+
Updating
+
Using the Automatic Updater
+
If you are updating from version 2.7 or higher, you can use the automatic updater:
WordPress is the official continuation of b2/cafélog, which came from Michel V. The work has been continued by the WordPress developers. If you would like to support WordPress, please consider donating.
-
Copyright
+
License
WordPress is free software, and is released under the terms of the GPL version 2 or (at your option) any later version. See license.txt.
diff --git a/wp-activate.php b/wp-activate.php
index b9e77070..6bc019c7 100644
--- a/wp-activate.php
+++ b/wp-activate.php
@@ -7,12 +7,10 @@ require( dirname(__FILE__) . '/wp-load.php' );
require( './wp-blog-header.php' );
if ( !is_multisite() ) {
- wp_redirect( get_option( 'siteurl' ) . "/wp-login.php?action=register" );
+ wp_redirect( site_url( '/wp-login.php?action=register' ) );
die();
}
-require_once( ABSPATH . WPINC . '/registration.php');
-
if ( is_object( $wp_object_cache ) )
$wp_object_cache->cache_enabled = false;
@@ -30,7 +28,7 @@ function wpmu_activate_stylesheet() {
#submit, #key { width: 90%; font-size: 24px; }
#language { margin-top: .5em; }
.error { background: #f66; }
- span.h3 { padding:0 8px; font-size:1.3em; font-family:'Trebuchet MS','Lucida Grande',Verdana,Arial,Sans-Serif; font-weight:700; color:#333333; }
+ span.h3 { padding: 0 8px; font-size: 1.3em; font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; font-weight: bold; color: #333; }
';
if ( $signup->domain . $signup->path == '' ) {
- printf( __('Your account has been activated. You may now login to the site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.'), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword', 'login' ) );
+ printf( __('Your account has been activated. You may now log in to the site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.'), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword', 'login' ) );
} else {
printf( __('Your site at %2$s is active. You may now log in to your site using your chosen username of “%3$s”. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword' ) );
}
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index df64921b..d2a8d4d2 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -9,16 +9,16 @@
/**
* Executing AJAX process.
*
- * @since unknown
+ * @since 2.1.0
*/
define('DOING_AJAX', true);
define('WP_ADMIN', true);
-require_once('../wp-load.php');
-
if ( ! isset( $_REQUEST['action'] ) )
die('-1');
+require_once('../wp-load.php');
+
require_once('./includes/admin.php');
@header('Content-Type: text/html; charset=' . get_option('blog_charset'));
send_nosniff_header();
@@ -50,16 +50,43 @@ if ( ! is_user_logged_in() ) {
if ( isset( $_GET['action'] ) ) :
switch ( $action = $_GET['action'] ) :
-case 'ajax-tag-search' :
- if ( !current_user_can( 'edit_posts' ) )
- die('-1');
+case 'fetch-list' :
- $s = $_GET['q']; // is this slashed already?
+ $list_class = $_GET['list_args']['class'];
+ check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );
- if ( isset($_GET['tax']) )
- $taxonomy = sanitize_title($_GET['tax']);
- else
+ $current_screen = (object) $_GET['list_args']['screen'];
+ //TODO fix this in a better way see #15336
+ $current_screen->is_network = 'false' === $current_screen->is_network ? false : true;
+ $current_screen->is_user = 'false' === $current_screen->is_user ? false : true;
+
+ define( 'WP_NETWORK_ADMIN', $current_screen->is_network );
+ define( 'WP_USER_ADMIN', $current_screen->is_user );
+
+ $wp_list_table = _get_list_table( $list_class );
+ if ( ! $wp_list_table )
+ die( '0' );
+
+ if ( ! $wp_list_table->ajax_user_can() )
+ die( '-1' );
+
+ $wp_list_table->ajax_response();
+
+ die( '0' );
+ break;
+case 'ajax-tag-search' :
+ if ( isset( $_GET['tax'] ) ) {
+ $taxonomy = sanitize_key( $_GET['tax'] );
+ $tax = get_taxonomy( $taxonomy );
+ if ( ! $tax )
+ die( '0' );
+ if ( ! current_user_can( $tax->cap->assign_terms ) )
+ die( '-1' );
+ } else {
die('0');
+ }
+
+ $s = stripslashes( $_GET['q'] );
if ( false !== strpos( $s, ',' ) ) {
$s = explode( ',', $s );
@@ -69,7 +96,7 @@ case 'ajax-tag-search' :
if ( strlen( $s ) < 2 )
die; // require 2 chars for matching
- $results = $wpdb->get_col( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = '$taxonomy' AND t.name LIKE ('%" . $s . "%')" );
+ $results = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, '%' . like_escape( $s ) . '%' ) );
echo join( $results, "\n" );
die;
@@ -162,7 +189,7 @@ endif;
* @param int $comment_id
* @return die
*/
-function _wp_ajax_delete_comment_response( $comment_id ) {
+function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
$total = (int) @$_POST['_total'];
$per_page = (int) @$_POST['_per_page'];
$page = (int) @$_POST['_page'];
@@ -171,43 +198,39 @@ function _wp_ajax_delete_comment_response( $comment_id ) {
if ( !$total || !$per_page || !$page || !$url )
die( (string) time() );
- if ( --$total < 0 ) // Take the total from POST and decrement it (since we just deleted one)
+ $total += $delta;
+ if ( $total < 0 )
$total = 0;
- if ( 0 != $total % $per_page && 1 != mt_rand( 1, $per_page ) ) // Only do the expensive stuff on a page-break, and about 1 other time per page
- die( (string) time() );
+ // Only do the expensive stuff on a page-break, and about 1 other time per page
+ if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
+ $post_id = 0;
+ $status = 'total_comments'; // What type of comment count are we looking for?
+ $parsed = parse_url( $url );
+ if ( isset( $parsed['query'] ) ) {
+ parse_str( $parsed['query'], $query_vars );
+ if ( !empty( $query_vars['comment_status'] ) )
+ $status = $query_vars['comment_status'];
+ if ( !empty( $query_vars['p'] ) )
+ $post_id = (int) $query_vars['p'];
+ }
+
+ $comment_count = wp_count_comments($post_id);
- $post_id = 0;
- $status = 'total_comments'; // What type of comment count are we looking for?
- $parsed = parse_url( $url );
- if ( isset( $parsed['query'] ) ) {
- parse_str( $parsed['query'], $query_vars );
- if ( !empty( $query_vars['comment_status'] ) )
- $status = $query_vars['comment_status'];
- if ( !empty( $query_vars['p'] ) )
- $post_id = (int) $query_vars['p'];
+ if ( isset( $comment_count->$status ) ) // We're looking for a known type of comment count
+ $total = $comment_count->$status;
+ // else use the decremented value from above
}
- $comment_count = wp_count_comments($post_id);
$time = time(); // The time since the last comment count
- if ( isset( $comment_count->$status ) ) // We're looking for a known type of comment count
- $total = $comment_count->$status;
- // else use the decremented value from above
-
- $page_links = paginate_links( array(
- 'base' => add_query_arg( 'apage', '%#%', $url ),
- 'format' => '',
- 'prev_text' => __('«'),
- 'next_text' => __('»'),
- 'total' => ceil($total / $per_page),
- 'current' => $page
- ) );
$x = new WP_Ajax_Response( array(
'what' => 'comment',
'id' => $comment_id, // here for completeness - not used
'supplemental' => array(
- 'pageLinks' => $page_links,
+ 'total_items_i18n' => sprintf( _n( '1 item', '%s items', $total ), number_format_i18n( $total ) ),
+ 'total_pages' => ceil( $total / $per_page ),
+ 'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ),
'total' => $total,
'time' => $time
)
@@ -304,6 +327,7 @@ case 'delete-comment' : // On success, die with time() instead of 1
check_ajax_referer( "delete-comment_$id" );
$status = wp_get_comment_status( $comment->comment_ID );
+ $delta = -1;
if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
if ( 'trash' == $status )
die( (string) time() );
@@ -312,6 +336,8 @@ case 'delete-comment' : // On success, die with time() instead of 1
if ( 'trash' != $status )
die( (string) time() );
$r = wp_untrash_comment( $comment->comment_ID );
+ if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
+ $delta = 1;
} elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
if ( 'spam' == $status )
die( (string) time() );
@@ -320,6 +346,8 @@ case 'delete-comment' : // On success, die with time() instead of 1
if ( 'spam' != $status )
die( (string) time() );
$r = wp_unspam_comment( $comment->comment_ID );
+ if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
+ $delta = 1;
} elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
$r = wp_delete_comment( $comment->comment_ID );
} else {
@@ -327,7 +355,7 @@ case 'delete-comment' : // On success, die with time() instead of 1
}
if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
- _wp_ajax_delete_comment_response( $comment->comment_ID );
+ _wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
die( '0' );
break;
case 'delete-tag' :
@@ -349,42 +377,6 @@ case 'delete-tag' :
else
die('0');
break;
-case 'delete-link-cat' :
- check_ajax_referer( "delete-link-category_$id" );
- if ( !current_user_can( 'manage_categories' ) )
- die('-1');
-
- $cat = get_term( $id, 'link_category' );
- if ( !$cat || is_wp_error( $cat ) )
- die('1');
-
- $cat_name = get_term_field('name', $id, 'link_category');
-
- $default = get_option('default_link_category');
-
- // Don't delete the default cats.
- if ( $id == $default ) {
- $x = new WP_AJAX_Response( array(
- 'what' => 'link-cat',
- 'id' => $id,
- 'data' => new WP_Error( 'default-link-cat', sprintf(__("Can’t delete the %s category: this is the default one"), $cat_name) )
- ) );
- $x->send();
- }
-
- $r = wp_delete_term($id, 'link_category', array('default' => $default));
- if ( !$r )
- die('0');
- if ( is_wp_error($r) ) {
- $x = new WP_AJAX_Response( array(
- 'what' => 'link-cat',
- 'id' => $id,
- 'data' => $r
- ) );
- $x->send();
- }
- die('1');
- break;
case 'delete-link' :
check_ajax_referer( "delete-bookmark_$id" );
if ( !current_user_can( 'manage_links' ) )
@@ -515,56 +507,21 @@ case 'add-link-category' : // On the Fly
}
$x->send();
break;
-case 'add-link-cat' : // From Blogroll -> Categories
- check_ajax_referer( 'add-link-category' );
- if ( !current_user_can( 'manage_categories' ) )
- die('-1');
-
- if ( '' === trim($_POST['name']) ) {
- $x = new WP_Ajax_Response( array(
- 'what' => 'link-cat',
- 'id' => new WP_Error( 'name', __('You did not enter a category name.') )
- ) );
- $x->send();
- }
-
- $r = wp_insert_term($_POST['name'], 'link_category', $_POST );
- if ( is_wp_error( $r ) ) {
- $x = new WP_AJAX_Response( array(
- 'what' => 'link-cat',
- 'id' => $r
- ) );
- $x->send();
- }
-
- extract($r, EXTR_SKIP);
-
- if ( !$link_cat = link_cat_row( $term_id ) )
- die('0');
-
- $x = new WP_Ajax_Response( array(
- 'what' => 'link-cat',
- 'id' => $term_id,
- 'position' => -1,
- 'data' => $link_cat
- ) );
- $x->send();
- break;
-case 'add-tag' : // From Manage->Tags
+case 'add-tag' :
check_ajax_referer( 'add-tag' );
$post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';
$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
$tax = get_taxonomy($taxonomy);
- $x = new WP_Ajax_Response();
-
if ( !current_user_can( $tax->cap->edit_terms ) )
die('-1');
+ $x = new WP_Ajax_Response();
+
$tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST );
if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
- $message = __('An error has occured. Please reload the page and try again.');
+ $message = __('An error has occurred. Please reload the page and try again.');
if ( is_wp_error($tag) && $tag->get_error_message() )
$message = $tag->get_error_message();
@@ -575,23 +532,21 @@ case 'add-tag' : // From Manage->Tags
$x->send();
}
- if ( isset($_POST['screen']) )
- set_current_screen($_POST['screen']);
+ set_current_screen( $_POST['screen'] );
+
+ $wp_list_table = _get_list_table('WP_Terms_List_Table');
$level = 0;
- $tag_full_name = false;
- $tag_full_name = $tag->name;
if ( is_taxonomy_hierarchical($taxonomy) ) {
- $_tag = $tag;
- while ( $_tag->parent ) {
- $_tag = get_term( $_tag->parent, $taxonomy );
- $tag_full_name = $_tag->name . ' — ' . $tag_full_name;
- $level++;
- }
- $noparents = _tag_row( $tag, $level, $taxonomy );
+ $level = count( get_ancestors( $tag->term_id, $taxonomy ) );
+ ob_start();
+ $wp_list_table->single_row( $tag, $level );
+ $noparents = ob_get_clean();
}
- $tag->name = $tag_full_name;
- $parents = _tag_row( $tag, 0, $taxonomy);
+
+ ob_start();
+ $wp_list_table->single_row( $tag );
+ $parents = ob_get_clean();
$x->add( array(
'what' => 'taxonomy',
@@ -600,28 +555,29 @@ case 'add-tag' : // From Manage->Tags
$x->add( array(
'what' => 'term',
'position' => $level,
- 'supplemental' => get_term( $tag->term_id, $taxonomy, ARRAY_A ) //Refetch as $tag has been contaminated by the full name.
+ 'supplemental' => (array) $tag
) );
$x->send();
break;
case 'get-tagcloud' :
- if ( !current_user_can( 'edit_posts' ) )
- die('-1');
-
- if ( isset($_POST['tax']) )
- $taxonomy = sanitize_title($_POST['tax']);
- else
+ if ( isset( $_POST['tax'] ) ) {
+ $taxonomy = sanitize_key( $_POST['tax'] );
+ $tax = get_taxonomy( $taxonomy );
+ if ( ! $tax )
+ die( '0' );
+ if ( ! current_user_can( $tax->cap->assign_terms ) )
+ die( '-1' );
+ } else {
die('0');
+ }
$tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
- if ( empty( $tags ) ) {
- $tax = get_taxonomy( $taxonomy );
+ if ( empty( $tags ) )
die( isset( $tax->no_tagcloud ) ? $tax->no_tagcloud : __('No tags found!') );
- }
- if ( is_wp_error($tags) )
- die($tags->get_error_message());
+ if ( is_wp_error( $tags ) )
+ die( $tags->get_error_message() );
foreach ( $tags as $key => $tag ) {
$tags[ $key ]->link = '#';
@@ -638,63 +594,27 @@ case 'get-tagcloud' :
exit;
break;
-case 'add-comment' :
- check_ajax_referer( $action );
- if ( !current_user_can( 'edit_posts' ) )
- die('-1');
- $search = isset($_POST['s']) ? $_POST['s'] : false;
- $status = isset($_POST['comment_status']) ? $_POST['comment_status'] : 'all';
- $per_page = isset($_POST['per_page']) ? (int) $_POST['per_page'] + 8 : 28;
- $start = isset($_POST['page']) ? ( intval($_POST['page']) * $per_page ) -1 : $per_page - 1;
- if ( 1 > $start )
- $start = 27;
-
- $mode = isset($_POST['mode']) ? $_POST['mode'] : 'detail';
- $p = isset($_POST['p']) ? $_POST['p'] : 0;
- $comment_type = isset($_POST['comment_type']) ? $_POST['comment_type'] : '';
- list($comments, $total) = _wp_get_comment_list( $status, $search, $start, 1, $p, $comment_type );
-
- if ( get_option('show_avatars') )
- add_filter( 'comment_author', 'floated_admin_avatar' );
-
- if ( !$comments )
- die('1');
- $x = new WP_Ajax_Response();
- foreach ( (array) $comments as $comment ) {
- get_comment( $comment );
- ob_start();
- _wp_comment_row( $comment->comment_ID, $mode, $status, true, true );
- $comment_list_item = ob_get_contents();
- ob_end_clean();
- $x->add( array(
- 'what' => 'comment',
- 'id' => $comment->comment_ID,
- 'data' => $comment_list_item
- ) );
- }
- $x->send();
- break;
case 'get-comments' :
check_ajax_referer( $action );
- $post_ID = (int) $_POST['post_ID'];
- if ( !current_user_can( 'edit_post', $post_ID ) )
- die('-1');
+ set_current_screen( 'edit-comments' );
- $start = isset($_POST['start']) ? intval($_POST['start']) : 0;
- $num = isset($_POST['num']) ? intval($_POST['num']) : 10;
+ $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
- list($comments, $total) = _wp_get_comment_list( false, false, $start, $num, $post_ID );
+ if ( !current_user_can( 'edit_post', $post_id ) )
+ die('-1');
- if ( !$comments )
+ $wp_list_table->prepare_items();
+
+ if ( !$wp_list_table->has_items() )
die('1');
$comment_list_item = '';
$x = new WP_Ajax_Response();
- foreach ( (array) $comments as $comment ) {
+ foreach ( $wp_list_table->items as $comment ) {
get_comment( $comment );
ob_start();
- _wp_comment_row( $comment->comment_ID, 'single', false, false );
+ $wp_list_table->single_row( $comment );
$comment_list_item .= ob_get_contents();
ob_end_clean();
}
@@ -707,6 +627,8 @@ case 'get-comments' :
case 'replyto-comment' :
check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
+ set_current_screen( 'edit-comments' );
+
$comment_post_ID = (int) $_POST['comment_post_ID'];
if ( !current_user_can( 'edit_post', $comment_post_ID ) )
die('-1');
@@ -744,22 +666,21 @@ case 'replyto-comment' :
$comment = get_comment($comment_id);
if ( ! $comment ) die('1');
- $modes = array( 'single', 'detail', 'dashboard' );
- $mode = isset($_POST['mode']) && in_array( $_POST['mode'], $modes ) ? $_POST['mode'] : 'detail';
$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
- $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
-
- if ( get_option('show_avatars') && 'single' != $mode )
- add_filter( 'comment_author', 'floated_admin_avatar' );
$x = new WP_Ajax_Response();
ob_start();
- if ( 'dashboard' == $mode ) {
+ if ( 'dashboard' == $_REQUEST['mode'] ) {
require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
- _wp_dashboard_recent_comments_row( $comment, false );
+ _wp_dashboard_recent_comments_row( $comment );
} else {
- _wp_comment_row( $comment->comment_ID, $mode, false, $checkbox );
+ if ( 'single' == $_REQUEST['mode'] ) {
+ $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
+ } else {
+ $wp_list_table = _get_list_table('WP_Comments_List_Table');
+ }
+ $wp_list_table->single_row( $comment );
}
$comment_list_item = ob_get_contents();
ob_end_clean();
@@ -776,6 +697,8 @@ case 'replyto-comment' :
case 'edit-comment' :
check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );
+ set_current_screen( 'edit-comments' );
+
$comment_post_ID = (int) $_POST['comment_post_ID'];
if ( ! current_user_can( 'edit_post', $comment_post_ID ) )
die('-1');
@@ -787,21 +710,19 @@ case 'edit-comment' :
$_POST['comment_status'] = $_POST['status'];
edit_comment();
- $mode = ( isset($_POST['mode']) && 'single' == $_POST['mode'] ) ? 'single' : 'detail';
$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
- $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
- $comments_listing = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : '';
-
- if ( get_option('show_avatars') && 'single' != $mode )
- add_filter( 'comment_author', 'floated_admin_avatar' );
+ $comments_status = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : '';
- $x = new WP_Ajax_Response();
+ $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
+ $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table' );
ob_start();
- _wp_comment_row( $comment_id, $mode, $comments_listing, $checkbox );
+ $wp_list_table->single_row( get_comment( $comment_id ) );
$comment_list_item = ob_get_contents();
ob_end_clean();
+ $x = new WP_Ajax_Response();
+
$x->add( array(
'what' => 'edit_comment',
'id' => $comment->comment_ID,
@@ -819,7 +740,37 @@ case 'add-menu-item' :
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
- $item_ids = wp_save_nav_menu_items( 0, $_POST['menu-item'] );
+ // For performance reasons, we omit some object properties from the checklist.
+ // The following is a hacky way to restore them when adding non-custom items.
+
+ $menu_items_data = array();
+ foreach ( (array) $_POST['menu-item'] as $menu_item_data ) {
+ if (
+ ! empty( $menu_item_data['menu-item-type'] ) &&
+ 'custom' != $menu_item_data['menu-item-type'] &&
+ ! empty( $menu_item_data['menu-item-object-id'] )
+ ) {
+ switch( $menu_item_data['menu-item-type'] ) {
+ case 'post_type' :
+ $_object = get_post( $menu_item_data['menu-item-object-id'] );
+ break;
+
+ case 'taxonomy' :
+ $_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] );
+ break;
+ }
+
+ $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) );
+ $_menu_item = array_shift( $_menu_items );
+
+ // Restore the missing menu item properties
+ $menu_item_data['menu-item-description'] = $_menu_item->description;
+ }
+
+ $menu_items_data[] = $menu_item_data;
+ }
+
+ $item_ids = wp_save_nav_menu_items( 0, $menu_items_data );
if ( is_wp_error( $item_ids ) )
die('-1');
@@ -929,7 +880,6 @@ case 'add-user' :
check_ajax_referer( $action );
if ( !current_user_can('create_users') )
die('-1');
- require_once(ABSPATH . WPINC . '/registration.php');
if ( !$user_id = add_user() )
die('0');
elseif ( is_wp_error( $user_id ) ) {
@@ -941,10 +891,12 @@ case 'add-user' :
}
$user_object = new WP_User( $user_id );
+ $wp_list_table = _get_list_table('WP_Users_List_Table');
+
$x = new WP_Ajax_Response( array(
'what' => 'user',
'id' => $user_id,
- 'data' => user_row( $user_object, '', $user_object->roles[0] ),
+ 'data' => $wp_list_table->single_row( $user_object, '', $user_object->roles[0] ),
'supplemental' => array(
'show-link' => sprintf(__( 'User %s added' ), "user-$user_id", $user_object->user_login),
'role' => $user_object->roles[0]
@@ -1136,6 +1088,27 @@ case 'menu-quick-search':
_wp_ajax_menu_quick_search( $_REQUEST );
+ exit;
+ break;
+case 'wp-link-ajax':
+ require_once ABSPATH . 'wp-admin/includes/internal-linking.php';
+
+ check_ajax_referer( 'internal-linking', '_ajax_linking_nonce' );
+
+ $args = array();
+
+ if ( isset( $_POST['search'] ) )
+ $args['s'] = stripslashes( $_POST['search'] );
+ $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
+
+ $results = wp_link_query( $args );
+
+ if ( ! isset( $results ) )
+ die( '0' );
+
+ echo json_encode( $results );
+ echo "\n";
+
exit;
break;
case 'menu-locations-save':
@@ -1193,8 +1166,7 @@ case 'inline-save':
die( __('You are not allowed to edit this post.') );
}
- if ( isset($_POST['screen']) )
- set_current_screen($_POST['screen']);
+ set_current_screen( $_POST['screen'] );
if ( $last = wp_check_post_lock( $post_ID ) ) {
$last_user = get_userdata( $last );
@@ -1231,68 +1203,48 @@ case 'inline-save':
// update the post
edit_post();
- if ( in_array( $_POST['post_type'], get_post_types( array( 'show_ui' => true ) ) ) ) {
- $post = array();
- $post[] = get_post($_POST['post_ID']);
- if ( is_post_type_hierarchical( $_POST['post_type'] ) ) {
- page_rows( $post );
- } else {
- $mode = $_POST['post_view'];
- post_rows( $post );
- }
- }
+ $wp_list_table = _get_list_table('WP_Posts_List_Table');
+
+ $mode = $_POST['post_view'];
+ $wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ) );
exit;
break;
case 'inline-save-tax':
check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
- $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : false;
- if ( ! $taxonomy )
- die( __('Cheatin’ uh?') );
- $tax = get_taxonomy($taxonomy);
+ $taxonomy = sanitize_key( $_POST['taxonomy'] );
+ $tax = get_taxonomy( $taxonomy );
+ if ( ! $tax )
+ die( '0' );
if ( ! current_user_can( $tax->cap->edit_terms ) )
- die( __('Cheatin’ uh?') );
-
- if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
- die(-1);
+ die( '-1' );
- switch ($_POST['tax_type']) {
- case 'link-cat' :
- $updated = wp_update_term($id, 'link_category', $_POST);
+ set_current_screen( 'edit-' . $taxonomy );
- if ( $updated && !is_wp_error($updated) )
- echo link_cat_row($updated['term_id']);
- else
- die( __('Category not updated.') );
+ $wp_list_table = _get_list_table('WP_Terms_List_Table');
- break;
- case 'tag' :
- $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
-
- $tag = get_term( $id, $taxonomy );
- $_POST['description'] = $tag->description;
-
- $updated = wp_update_term($id, $taxonomy, $_POST);
- if ( $updated && !is_wp_error($updated) ) {
- $tag = get_term( $updated['term_id'], $taxonomy );
- if ( !$tag || is_wp_error( $tag ) ) {
- if ( is_wp_error($tag) && $tag->get_error_message() )
- die( $tag->get_error_message() );
- die( __('Item not updated.') );
- }
+ if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
+ die(-1);
- set_current_screen( 'edit-' . $taxonomy );
+ $tag = get_term( $id, $taxonomy );
+ $_POST['description'] = $tag->description;
- echo _tag_row($tag, 0, $taxonomy);
- } else {
- if ( is_wp_error($updated) && $updated->get_error_message() )
- die( $updated->get_error_message() );
- die( __('Item not updated.') );
- }
+ $updated = wp_update_term($id, $taxonomy, $_POST);
+ if ( $updated && !is_wp_error($updated) ) {
+ $tag = get_term( $updated['term_id'], $taxonomy );
+ if ( !$tag || is_wp_error( $tag ) ) {
+ if ( is_wp_error($tag) && $tag->get_error_message() )
+ die( $tag->get_error_message() );
+ die( __('Item not updated.') );
+ }
- break;
+ echo $wp_list_table->single_row( $tag );
+ } else {
+ if ( is_wp_error($updated) && $updated->get_error_message() )
+ die( $updated->get_error_message() );
+ die( __('Item not updated.') );
}
exit;
@@ -1314,11 +1266,11 @@ case 'find_posts':
$searchand = $search = '';
foreach ( (array) $search_terms as $term ) {
- $term = addslashes_gpc($term);
+ $term = esc_sql( like_escape( $term ) );
$search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))";
$searchand = ' AND ';
}
- $term = $wpdb->escape($s);
+ $term = esc_sql( like_escape( $s ) );
if ( count($search_terms) > 1 && $search_terms[0] != $s )
$search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')";
@@ -1367,19 +1319,6 @@ case 'find_posts':
));
$x->send();
- break;
-case 'lj-importer' :
- check_ajax_referer( 'lj-api-import' );
- if ( !current_user_can( 'publish_posts' ) )
- die('-1');
- if ( empty( $_POST['step'] ) )
- die( '-1' );
- define('WP_IMPORTING', true);
- include( ABSPATH . 'wp-admin/import/livejournal.php' );
- $result = $lj_api_import->{ 'step' . ( (int) $_POST['step'] ) }();
- if ( is_wp_error( $result ) )
- echo $result->get_error_message();
- die;
break;
case 'widgets-order' :
check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
@@ -1428,7 +1367,7 @@ case 'save-widget' :
$sidebar_id = $_POST['sidebar'];
$multi_number = !empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0;
$settings = isset($_POST['widget-' . $id_base]) && is_array($_POST['widget-' . $id_base]) ? $_POST['widget-' . $id_base] : false;
- $error = '
' . __('An error has occured. Please reload the page and try again.') . '
';
+ $error = '
' . __('An error has occurred. Please reload the page and try again.') . '
parent_base = str_replace('.php', '', $current_screen->parent_b
' . __( 'You can edit the information left in a comment if needed. This is often useful when you notice that a commenter has made a typographical error.' ) . '' .
'
' . __( 'You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.' ) . '
'
);
@@ -60,8 +60,8 @@ case 'editcomment' :
if ( !$comment = get_comment( $comment_id ) )
comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' '.__('Go back').'!', 'javascript:history.go(-1)') );
- if ( !current_user_can('edit_post', $comment->comment_post_ID) )
- comment_footer_die( __('You are not allowed to edit comments on this post.') );
+ if ( !current_user_can( 'edit_comment', $comment_id ) )
+ comment_footer_die( __('You are not allowed to edit this comment.') );
if ( 'trash' == $comment->comment_approved )
comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') );
@@ -77,6 +77,8 @@ case 'approve' :
case 'trash' :
case 'spam' :
+ $title = __('Moderate Comment');
+
$comment_id = absint( $_GET['c'] );
if ( !$comment = get_comment_to_edit( $comment_id ) ) {
@@ -84,7 +86,7 @@ case 'spam' :
die();
}
- if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
+ if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) {
wp_redirect( admin_url('edit-comments.php?error=2') );
die();
}
@@ -107,7 +109,7 @@ case 'spam' :
-
+
comment_approved != '0' ) { // if not unapproved
' . __('You can manage comments made on your site similar to the way you manage Posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.') . '
' .
- '
' . __('A yellow row means the comment is waiting for you to moderate it.') . '
' .
- '
' . __('In the Author column, in addition to the author’s name, email address, and blog URL, the commenter’s IP address is shown. Clicking on this link will show you all the comments made from this IP address.') . '
' .
- '
' . __('In the Comment column, above each comment it says “Submitted on,” followed by the date and time the comment was left on your site. Clicking on the date/time link will take you to that comment on your live site.') . '
' .
- '
' . __('In the In Response To column, there are three elements. The text is the name of the post that inspired the comment, and links to the post editor for that entry. The “#” permalink symbol below leads to that post on your live site. The small bubble with the number in it shows how many comments that post has received. If the bubble is gray, you have moderated all comments for that post. If it is blue, there are pending comments. Clicking the bubble will filter the comments screen to show only comments on that post.') . '
' .
- '
' . __('Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link below to learn more.') . '
' . __( 'You can manage comments made on your site similar to the way you manage Posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '
' .
+ '
' . __( 'A yellow row means the comment is waiting for you to moderate it.' ) . '
' .
+ '
' . __( 'In the Author column, in addition to the author’s name, email address, and blog URL, the commenter’s IP address is shown. Clicking on this link will show you all the comments made from this IP address.' ) . '
' .
+ '
' . __( 'In the Comment column, above each comment it says “Submitted on,” followed by the date and time the comment was left on your site. Clicking on the date/time link will take you to that comment on your live site.' ) . '
' .
+ '
' . __( 'In the In Response To column, there are three elements. The text is the name of the post that inspired the comment, and links to the post editor for that entry. The “#” permalink symbol below leads to that post on your live site. The small bubble with the number in it shows how many comments that post has received. If the bubble is gray, you have moderated all comments for that post. If it is blue, there are pending comments. Clicking the bubble will filter the comments screen to show only comments on that post.' ) . '
' .
+ '
' . __( 'Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link below to learn more.' ) . '
' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes that allow you to add metadata to your post using drag and drop, and can minimize or expand them by clicking the title bar of the box. You can also hide any of the boxes by using the Screen Options tab, where you can also choose a 1- or 2-column layout for this screen.') . '
' .
+ '
' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of the box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.') . '
' .
'
' . __('Title - Enter a title for your post. After you enter a title, you’ll see the permalink below, which you can edit.') . '
' .
- '
' . __('Post editor - Enter the text for your post. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The HTML mode allows you to enter raw HTML along with your post text. You can insert media files by clicking the icons above the post editor and following the directions.') . '
' .
+ '
' . __('Post editor - Enter the text for your post. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The screen icon just before that allows you to expand the edit box to full screen. The HTML mode allows you to enter raw HTML along with your post text. You can insert media files by clicking the icons above the post editor and following the directions.') . '
' .
'
' . __('Publish - You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.') . '
' . __( 'Post Format - This designates how your theme will display a specific post. For example, you could have a standard blog post with a title and paragraphs, or a short aside that omits the title and contains a short text blurb. Please refer to the Codex for descriptions of each post format.' ) . '
' : '' ) .
'
' . __('Featured Image - This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the featured image as a post thumbnail on the home page, a custom header, etc.') . '
' .
'
' . __('Send Trackbacks - Trackbacks are a way to notify legacy blog systems that you’ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they’ll be notified automatically using pingbacks, and this field is unnecessary.') . '
' .
'
' . __('Discussion - You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.') . '
' .
'
' . sprintf(__('You can also create posts with the Press This bookmarklet.'), 'options-writing.php') . '
' . __('Template - Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them in this dropdown menu.') . '
' .
'
' . __('Order - Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.') . '
' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link’s web address and name (the text you want to display on your site as the link) are required fields.' ) . '
' .
'
' . __( 'The boxes for link name, web address, and description have fixed positions, while the others may be repositioned using drag and drop. You can also hide boxes you don’t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '
' . sprintf(__('You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your writing settings.'), 'options-writing.php') . '
';
+ $help = '
' . sprintf(__( 'You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your writing settings.' ) , 'options-writing.php' ) . '
' . __( 'You can create groups of links by using link categories. Link category names must be unique and link categories are separate from the categories you use for posts.' ) . '
';
else
- $help = '
' . __('You can assign keywords to your posts using Post Tags. Unlike categories, tags have no hierarchy, meaning there’s no relationship from one tag to another.') . '
';
+ $help = '
' . __( 'You can assign keywords to your posts using Post Tags. Unlike categories, tags have no hierarchy, meaning there’s no relationship from one tag to another.' ) . '
';
- $help .='
' . __('What’s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.') . '
' . __( 'You can delete link categories in the Bulk Action pulldown, but that action does not delete the links within the category. Instead, it moves them to the default link category.' ) . '
';
+ else
+ $help .='
' . __( 'What’s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.' ) . '
';
if ( 'category' == $taxonomy )
- $help .= '
' . __('When adding a new category on this screen, you’ll fill in the following fields:') . '
';
- else
- $help .= '
' . __('When adding a new tag on this screen, you’ll fill in the following fields:') . '
';
+ $help .= '
' . __( 'When adding a new category on this screen, you’ll fill in the following fields:' ) . '
' . __( 'Slug - The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '
';
if ( 'category' == $taxonomy )
- $help .= '
' . __('Parent - Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.') . '
';
+ $help .= '
' . __( 'Parent - Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '
';
- $help .= '
' . __('Description - The description is not prominent by default; however, some themes may display it.') . '
' . __( 'Description - The description is not prominent by default; however, some themes may display it.' ) . '
' .
'
' .
- '
' . __('You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.') . '
' .
- '
' . __('For more information:') . '
';
+ '
' . __( 'You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.' ) . '
' . __('You can also edit multiple posts at once. Select the posts you want to edit using the checkboxes, select Edit from the Bulk Actions menu and click Apply. You will be able to change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.') . '
' . __('Pages are similar to to Posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest Pages under other Pages by making one the “Parent” of the other, creating a group of Pages.') . '
' .
+ '
' . __('Pages are similar to Posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest Pages under other Pages by making one the “Parent” of the other, creating a group of Pages.') . '
' .
'
' . __('Managing Pages is very similar to managing Posts, and the screens can be customized in the same way.') . '
' .
'
' . __('You can also perform the same types of actions, including narrowing the list by using the filters, acting on a Page using the action links that appear when you hover over a row, or using the Bulk Actions menu to edit the metadata for multiple Pages at once.') . '
' . __('You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can set filters to have the WXR file only include a certain date, author, category, tag, all posts or all pages, certain publishing statuses.') . '
' .
+function add_js() {
+?>
+
+' . __('You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.') . '
' .
'
' . __('Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.') . '
+ false, 'can_export' => true ), 'objects' ) as $post_type ) : ?>
+
+
-include ('admin-footer.php');
-?>
+
+
+
+
+
diff --git a/wp-admin/images/blue-grad.png b/wp-admin/images/blue-grad.png
index 36e0f6bc..868a657c 100644
Binary files a/wp-admin/images/blue-grad.png and b/wp-admin/images/blue-grad.png differ
diff --git a/wp-admin/images/button-grad-active-vs.png b/wp-admin/images/button-grad-active-vs.png
deleted file mode 100644
index dc641725..00000000
Binary files a/wp-admin/images/button-grad-active-vs.png and /dev/null differ
diff --git a/wp-admin/images/button-grad-vs.png b/wp-admin/images/button-grad-vs.png
deleted file mode 100644
index 51c55a3d..00000000
Binary files a/wp-admin/images/button-grad-vs.png and /dev/null differ
diff --git a/wp-admin/images/ed-bg-vs.gif b/wp-admin/images/ed-bg-vs.gif
index 0b3d2bac..be41c6c8 100644
Binary files a/wp-admin/images/ed-bg-vs.gif and b/wp-admin/images/ed-bg-vs.gif differ
diff --git a/wp-admin/images/fav-arrow-vs-rtl.gif b/wp-admin/images/fav-arrow-vs-rtl.gif
deleted file mode 100644
index a9c0721c..00000000
Binary files a/wp-admin/images/fav-arrow-vs-rtl.gif and /dev/null differ
diff --git a/wp-admin/images/fav-arrow-vs.gif b/wp-admin/images/fav-arrow-vs.gif
deleted file mode 100644
index 73d59fde..00000000
Binary files a/wp-admin/images/fav-arrow-vs.gif and /dev/null differ
diff --git a/wp-admin/images/fav-top-vs.gif b/wp-admin/images/fav-top-vs.gif
deleted file mode 100644
index b9aa3d39..00000000
Binary files a/wp-admin/images/fav-top-vs.gif and /dev/null differ
diff --git a/wp-admin/images/list-vs.png b/wp-admin/images/list-vs.png
deleted file mode 100644
index 85faa8ac..00000000
Binary files a/wp-admin/images/list-vs.png and /dev/null differ
diff --git a/wp-admin/images/menu-bits-rtl-vs.gif b/wp-admin/images/menu-bits-rtl-vs.gif
index 15bca807..422cc8df 100644
Binary files a/wp-admin/images/menu-bits-rtl-vs.gif and b/wp-admin/images/menu-bits-rtl-vs.gif differ
diff --git a/wp-admin/images/menu-bits-vs.gif b/wp-admin/images/menu-bits-vs.gif
index c6ad9310..30f0bc83 100644
Binary files a/wp-admin/images/menu-bits-vs.gif and b/wp-admin/images/menu-bits-vs.gif differ
diff --git a/wp-admin/images/menu-dark-rtl-vs.gif b/wp-admin/images/menu-dark-rtl-vs.gif
new file mode 100644
index 00000000..14ed2ab4
Binary files /dev/null and b/wp-admin/images/menu-dark-rtl-vs.gif differ
diff --git a/wp-admin/images/menu-dark-vs.gif b/wp-admin/images/menu-dark-vs.gif
new file mode 100644
index 00000000..0b448aa4
Binary files /dev/null and b/wp-admin/images/menu-dark-vs.gif differ
diff --git a/wp-admin/images/screen-options-right-up.gif b/wp-admin/images/screen-options-right-up.gif
deleted file mode 100644
index 6556aeed..00000000
Binary files a/wp-admin/images/screen-options-right-up.gif and /dev/null differ
diff --git a/wp-admin/images/screen-options-right.gif b/wp-admin/images/screen-options-right.gif
deleted file mode 100644
index 8fcf2548..00000000
Binary files a/wp-admin/images/screen-options-right.gif and /dev/null differ
diff --git a/wp-admin/images/screen-options-toggle-vs.gif b/wp-admin/images/screen-options-toggle-vs.gif
new file mode 100644
index 00000000..3b9b8af3
Binary files /dev/null and b/wp-admin/images/screen-options-toggle-vs.gif differ
diff --git a/wp-admin/images/screen-options-toggle.gif b/wp-admin/images/screen-options-toggle.gif
new file mode 100644
index 00000000..ed0a5fd3
Binary files /dev/null and b/wp-admin/images/screen-options-toggle.gif differ
diff --git a/wp-admin/images/sort.gif b/wp-admin/images/sort.gif
new file mode 100644
index 00000000..2a5a6e8c
Binary files /dev/null and b/wp-admin/images/sort.gif differ
diff --git a/wp-admin/images/upload-classic.png b/wp-admin/images/upload-classic.png
new file mode 100644
index 00000000..beda3e43
Binary files /dev/null and b/wp-admin/images/upload-classic.png differ
diff --git a/wp-admin/images/upload-fresh.png b/wp-admin/images/upload-fresh.png
new file mode 100644
index 00000000..92fd355c
Binary files /dev/null and b/wp-admin/images/upload-fresh.png differ
diff --git a/wp-admin/images/visit-site-button-grad-vs.gif b/wp-admin/images/visit-site-button-grad-vs.gif
deleted file mode 100644
index 34eb8148..00000000
Binary files a/wp-admin/images/visit-site-button-grad-vs.gif and /dev/null differ
diff --git a/wp-admin/images/visit-site-button-grad.gif b/wp-admin/images/visit-site-button-grad.gif
deleted file mode 100644
index a7b703e5..00000000
Binary files a/wp-admin/images/visit-site-button-grad.gif and /dev/null differ
diff --git a/wp-admin/images/widgets-arrow-vs.gif b/wp-admin/images/widgets-arrow-vs.gif
new file mode 100644
index 00000000..c6398e67
Binary files /dev/null and b/wp-admin/images/widgets-arrow-vs.gif differ
diff --git a/wp-admin/images/wp-logo-vs.png b/wp-admin/images/wp-logo-vs.png
index 793f54cd..f364b266 100644
Binary files a/wp-admin/images/wp-logo-vs.png and b/wp-admin/images/wp-logo-vs.png differ
diff --git a/wp-admin/import.php b/wp-admin/import.php
index 08c5daf0..f94f7047 100644
--- a/wp-admin/import.php
+++ b/wp-admin/import.php
@@ -20,7 +20,7 @@ add_contextual_help($current_screen,
'
' . __('This screen lists links to plugins to import data from blogging/content management platforms. Choose the platform you want to import from, and click Install Now when you are prompted in the popup window. If your platform is not listed, click the link to search the plugin directory for other importer plugins to see if there is one for your platform.') . '
' .
'
' . __('In previous versions of WordPress, all the importers were built-in, but they have been turned into plugins as of version 3.0 since most people only use them once or infrequently.') . '
' . sprintf( __('If the importer you need is not listed, search the plugins directory to see if an importer is available.'), esc_url(admin_url('plugin-install.php?tab=search&type=tag&s=importer')) ) . '
';
+ echo '
' . sprintf( __('If the importer you need is not listed, search the plugins directory to see if an importer is available.'), esc_url( network_admin_url( 'plugin-install.php?tab=search&type=tag&s=importer' ) ) ) . '
';
?>
diff --git a/wp-admin/includes/admin.php b/wp-admin/includes/admin.php
index 23c9ee2b..37f5c8ec 100644
--- a/wp-admin/includes/admin.php
+++ b/wp-admin/includes/admin.php
@@ -39,6 +39,10 @@ require_once(ABSPATH . 'wp-admin/includes/taxonomy.php');
/** WordPress Template Administration API */
require_once(ABSPATH . 'wp-admin/includes/template.php');
+/** WordPress List Table Administration API and base class */
+require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
+require_once(ABSPATH . 'wp-admin/includes/list-table.php');
+
/** WordPress Theme Administration API */
require_once(ABSPATH . 'wp-admin/includes/theme.php');
@@ -48,9 +52,6 @@ require_once(ABSPATH . 'wp-admin/includes/user.php');
/** WordPress Update Administration API */
require_once(ABSPATH . 'wp-admin/includes/update.php');
-/** WordPress Registration API */
-require_once(ABSPATH . WPINC . '/registration.php');
-
/** WordPress Deprecated Administration API */
require_once(ABSPATH . 'wp-admin/includes/deprecated.php');
diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php
index 09e5411e..0ed560c1 100644
--- a/wp-admin/includes/bookmark.php
+++ b/wp-admin/includes/bookmark.php
@@ -7,27 +7,27 @@
*/
/**
- * {@internal Missing Short Description}}
+ * Add a link to using values provided in $_POST.
*
- * @since unknown
+ * @since 2.0.0
*
- * @return unknown
+ * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
*/
function add_link() {
return edit_link();
}
/**
- * {@internal Missing Short Description}}
+ * Update or insert a link using values provided in $_POST.
*
- * @since unknown
+ * @since 2.0.0
*
- * @param unknown_type $link_id
- * @return unknown
+ * @param int $link_id Optional. ID of the link to edit.
+ * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
*/
-function edit_link( $link_id = '' ) {
- if (!current_user_can( 'manage_links' ))
- wp_die( __( 'Cheatin’ uh?' ));
+function edit_link( $link_id = 0 ) {
+ if ( !current_user_can( 'manage_links' ) )
+ wp_die( __( 'Cheatin’ uh?' ) );
$_POST['link_url'] = esc_html( $_POST['link_url'] );
$_POST['link_url'] = esc_url($_POST['link_url']);
@@ -39,27 +39,27 @@ function edit_link( $link_id = '' ) {
if ( !empty( $link_id ) ) {
$_POST['link_id'] = $link_id;
- return wp_update_link( $_POST);
+ return wp_update_link( $_POST );
} else {
- return wp_insert_link( $_POST);
+ return wp_insert_link( $_POST );
}
}
/**
- * {@internal Missing Short Description}}
+ * Retrieve the default link for editing.
*
- * @since unknown
+ * @since 2.0.0
*
- * @return unknown
+ * @return object Default link
*/
function get_default_link_to_edit() {
if ( isset( $_GET['linkurl'] ) )
- $link->link_url = esc_url( $_GET['linkurl']);
+ $link->link_url = esc_url( $_GET['linkurl'] );
else
$link->link_url = '';
if ( isset( $_GET['name'] ) )
- $link->link_name = esc_attr( $_GET['name']);
+ $link->link_name = esc_attr( $_GET['name'] );
else
$link->link_name = '';
@@ -69,12 +69,12 @@ function get_default_link_to_edit() {
}
/**
- * {@internal Missing Short Description}}
+ * Delete link specified from database
*
- * @since unknown
+ * @since 2.0.0
*
- * @param unknown_type $link_id
- * @return unknown
+ * @param int $link_id ID of the link to delete
+ * @return bool True
*/
function wp_delete_link( $link_id ) {
global $wpdb;
@@ -93,12 +93,12 @@ function wp_delete_link( $link_id ) {
}
/**
- * {@internal Missing Short Description}}
+ * Retrieves the link categories associated with the link specified.
*
- * @since unknown
+ * @since 2.1.0
*
- * @param unknown_type $link_id
- * @return unknown
+ * @param int $link_id Link ID to look up
+ * @return array The requested link's categories
*/
function wp_get_link_cats( $link_id = 0 ) {
@@ -108,24 +108,25 @@ function wp_get_link_cats( $link_id = 0 ) {
}
/**
- * {@internal Missing Short Description}}
+ * Retrieve link data based on ID.
*
- * @since unknown
+ * @since 2.0.0
*
- * @param unknown_type $link_id
- * @return unknown
+ * @param int $link_id ID of link to retrieve
+ * @return object Link for editing
*/
function get_link_to_edit( $link_id ) {
return get_bookmark( $link_id, OBJECT, 'edit' );
}
/**
- * {@internal Missing Short Description}}
+ * This function inserts/updates links into/in the database.
*
- * @since unknown
+ * @since 2.0.0
*
- * @param unknown_type $linkdata
- * @return unknown
+ * @param array $linkdata Elements that make up the link to insert.
+ * @param bool $wp_error Optional. If true return WP_Error object on failure.
+ * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
*/
function wp_insert_link( $linkdata, $wp_error = false ) {
global $wpdb;
@@ -181,7 +182,7 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
$link_rel = '';
// Make sure we set a valid category
- if ( ! isset( $link_category ) ||0 == count( $link_category ) || !is_array( $link_category ) ) {
+ if ( ! isset( $link_category ) || 0 == count( $link_category ) || !is_array( $link_category ) ) {
$link_category = array( get_option( 'default_link_category' ) );
}
@@ -215,12 +216,12 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
}
/**
- * {@internal Missing Short Description}}
+ * Update link with the specified link categories.
*
- * @since unknown
+ * @since 2.1.0
*
- * @param unknown_type $link_id
- * @param unknown_type $link_categories
+ * @param int $link_id ID of link to update
+ * @param array $link_categories Array of categories to
*/
function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
// If $link_categories isn't already an array, make it one:
@@ -233,15 +234,15 @@ function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
wp_set_object_terms( $link_id, $link_categories, 'link_category' );
clean_bookmark_cache( $link_id );
-} // wp_set_link_cats()
+}
/**
- * {@internal Missing Short Description}}
+ * Update a link in the database.
*
- * @since unknown
+ * @since 2.0.0
*
- * @param unknown_type $linkdata
- * @return unknown
+ * @param array $linkdata Link data to update.
+ * @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success.
*/
function wp_update_link( $linkdata ) {
$link_id = (int) $linkdata['link_id'];
diff --git a/wp-admin/includes/class-wp-comments-list-table.php b/wp-admin/includes/class-wp-comments-list-table.php
new file mode 100644
index 00000000..90c158fe
--- /dev/null
+++ b/wp-admin/includes/class-wp-comments-list-table.php
@@ -0,0 +1,557 @@
+ 'comments',
+ 'singular' => 'comment',
+ 'ajax' => true,
+ ) );
+ }
+
+ function ajax_user_can() {
+ return current_user_can('edit_posts');
+ }
+
+ function prepare_items() {
+ global $post_id, $comment_status, $search, $comment_type;
+
+ $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
+ if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) )
+ $comment_status = 'all';
+
+ $comment_type = !empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
+
+ $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : '';
+
+ $user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : '';
+
+ $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : '';
+ $order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : '';
+
+ $comments_per_page = $this->get_per_page( $comment_status );
+
+ $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
+
+ if ( isset( $_REQUEST['number'] ) ) {
+ $number = (int) $_REQUEST['number'];
+ }
+ else {
+ $number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra
+ }
+
+ $page = $this->get_pagenum();
+
+ if ( isset( $_REQUEST['start'] ) ) {
+ $start = $_REQUEST['start'];
+ } else {
+ $start = ( $page - 1 ) * $comments_per_page;
+ }
+
+ if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) {
+ $start += $_REQUEST['offset'];
+ }
+
+ $status_map = array(
+ 'moderated' => 'hold',
+ 'approved' => 'approve'
+ );
+
+ $args = array(
+ 'status' => isset( $status_map[$comment_status] ) ? $status_map[$comment_status] : $comment_status,
+ 'search' => $search,
+ 'user_id' => $user_id,
+ 'offset' => $start,
+ 'number' => $number,
+ 'post_id' => $post_id,
+ 'type' => $comment_type,
+ 'orderby' => $orderby,
+ 'order' => $order,
+ );
+
+ $_comments = get_comments( $args );
+
+ update_comment_cache( $_comments );
+
+ $this->items = array_slice( $_comments, 0, $comments_per_page );
+ $this->extra_items = array_slice( $_comments, $comments_per_page );
+
+ $total_comments = get_comments( array_merge( $args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
+
+ $_comment_post_ids = array();
+ foreach ( $_comments as $_c ) {
+ $_comment_post_ids[] = $_c->comment_post_ID;
+ }
+
+ $this->pending_count = get_pending_comments_num( $_comment_post_ids );
+
+ $this->set_pagination_args( array(
+ 'total_items' => $total_comments,
+ 'per_page' => $comments_per_page,
+ ) );
+ }
+
+ function get_per_page( $comment_status = 'all' ) {
+ $comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' );
+ $comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
+ return $comments_per_page;
+ }
+
+ function no_items() {
+ global $comment_status;
+
+ if ( 'moderated' == $comment_status )
+ _e( 'No comments awaiting moderation… yet.' );
+ else
+ _e( 'No comments found.' );
+ }
+
+ function get_views() {
+ global $post_id, $comment_status;
+
+ $status_links = array();
+ $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
+ //, number_format_i18n($num_comments->moderated) ), "" . number_format_i18n($num_comments->moderated) . ""),
+ //, number_format_i18n($num_comments->spam) ), "" . number_format_i18n($num_comments->spam) . "")
+ $stati = array(
+ 'all' => _nx_noop('All', 'All', 'comments'), // singular not used
+ 'moderated' => _n_noop('Pending (%s)', 'Pending (%s)'),
+ 'approved' => _n_noop('Approved', 'Approved'), // singular not used
+ 'spam' => _n_noop('Spam (%s)', 'Spam (%s)'),
+ 'trash' => _n_noop('Trash (%s)', 'Trash (%s)')
+ );
+
+ if ( !EMPTY_TRASH_DAYS )
+ unset($stati['trash']);
+
+ $link = 'edit-comments.php';
+ if ( !empty($comment_type) && 'all' != $comment_type )
+ $link = add_query_arg( 'comment_type', $comment_type, $link );
+
+ foreach ( $stati as $status => $label ) {
+ $class = ( $status == $comment_status ) ? ' class="current"' : '';
+
+ if ( !isset( $num_comments->$status ) )
+ $num_comments->$status = 10;
+ $link = add_query_arg( 'comment_status', $status, $link );
+ if ( $post_id )
+ $link = add_query_arg( 'p', absint( $post_id ), $link );
+ /*
+ // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
+ if ( !empty( $_REQUEST['s'] ) )
+ $link = add_query_arg( 's', esc_attr( stripslashes( $_REQUEST['s'] ) ), $link );
+ */
+ $status_links[$status] = "" . sprintf(
+ translate_nooped_plural( $label, $num_comments->$status ),
+ number_format_i18n( $num_comments->$status )
+ ) . '';
+ }
+
+ $status_links = apply_filters( 'comment_status_links', $status_links );
+ return $status_links;
+ }
+
+ function get_bulk_actions() {
+ global $comment_status;
+
+ $actions = array();
+ if ( in_array( $comment_status, array( 'all', 'approved' ) ) )
+ $actions['unapprove'] = __( 'Unapprove' );
+ if ( in_array( $comment_status, array( 'all', 'moderated', 'spam' ) ) )
+ $actions['approve'] = __( 'Approve' );
+ if ( in_array( $comment_status, array( 'all', 'moderated', 'approved' ) ) )
+ $actions['spam'] = _x( 'Mark as Spam', 'comment' );
+
+ if ( 'trash' == $comment_status )
+ $actions['untrash'] = __( 'Restore' );
+ elseif ( 'spam' == $comment_status )
+ $actions['unspam'] = _x( 'Not Spam', 'comment' );
+
+ if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || !EMPTY_TRASH_DAYS )
+ $actions['delete'] = __( 'Delete Permanently' );
+ else
+ $actions['trash'] = __( 'Move to Trash' );
+
+ return $actions;
+ }
+
+ function extra_tablenav( $which ) {
+ global $comment_status, $comment_type;
+?>
+
%2$s. The stylesheet files are located in %3$s. %4$s uses templates from %5$s. Changes made to the templates will affect both themes.' ), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ), $title, $parent_theme ); ?>
', esc_html( $url ) );
- }
-}
-add_action( 'admin_notices', 'admin_notice_feed' );
+add_action( 'network_admin_notices', 'secret_salt_warning' );
function site_admin_notice() {
global $wp_db_version;
if ( !is_super_admin() )
return false;
if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version )
- echo "
" . sprintf( __( 'Thank you for Updating! Please visit the Update Network page to update all your sites.' ), esc_url( admin_url( 'ms-upgrade-network.php' ) ) ) . "
";
+ echo "
" . sprintf( __( 'Thank you for Updating! Please visit the Update Network page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "
";
}
add_action( 'admin_notices', 'site_admin_notice' );
+add_action( 'network_admin_notices', 'site_admin_notice' );
function avoid_blog_page_permalink_collision( $data, $postarr ) {
if ( is_subdomain_install() )
@@ -805,16 +657,6 @@ function choose_primary_blog() {
" . sprintf( __( "Warning! The current theme supports Featured Images. You must enable image uploads on the options page for it to work." ), esc_url( admin_url( 'ms-options.php' ) ) ) . "";
- }
-}
-add_action( 'admin_notices', 'show_post_thumbnail_warning' );
-
function ms_deprecated_blogs_file() {
if ( ! is_super_admin() )
return;
@@ -822,24 +664,13 @@ function ms_deprecated_blogs_file() {
return;
echo '
' . sprintf( __( 'The %1$s file is deprecated. Please remove it and update your server rewrite rules to use %2$s instead.' ), 'wp-content/blogs.php', 'wp-includes/ms-files.php' ) . '
';
}
-add_action( 'admin_notices', 'ms_deprecated_blogs_file' );
-
-/**
- * Outputs the notice message for multisite regarding activation of plugin page.
- *
- * @since 3.0.0
- * @return none
- */
-function _admin_notice_multisite_activate_plugins_page() {
- $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '' . __( 'Activate' ) . '' );
- echo "
$message
";
-}
+add_action( 'network_admin_notices', 'ms_deprecated_blogs_file' );
/**
* Grants super admin privileges.
*
* @since 3.0.0
- * @param $user_id
+ * @param int $user_id
*/
function grant_super_admin( $user_id ) {
global $super_admins;
@@ -867,7 +698,7 @@ function grant_super_admin( $user_id ) {
* Revokes super admin privileges.
*
* @since 3.0.0
- * @param $user_id
+ * @param int $user_id
*/
function revoke_super_admin( $user_id ) {
global $super_admins;
@@ -892,4 +723,41 @@ function revoke_super_admin( $user_id ) {
}
return false;
}
+
+/**
+ * Whether or not we can edit this network from this page
+ *
+ * By default editing of network is restricted to the Network Admin for that site_id this allows for this to be overridden
+ *
+ * @since 3.1.0
+ * @param integer $site_id The network/site id to check.
+ */
+function can_edit_network( $site_id ) {
+ global $wpdb;
+
+ if ($site_id == $wpdb->siteid )
+ $result = true;
+ else
+ $result = false;
+
+ return apply_filters( 'can_edit_network', $result, $site_id );
+}
+
+/**
+ * Thickbox image paths for Network Admin.
+ *
+ * @since 3.1.0
+ * @access private
+ */
+function _thickbox_path_admin_subfolder() {
+?>
+
+
diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php
index 8c8e9697..6e929286 100644
--- a/wp-admin/includes/nav-menu.php
+++ b/wp-admin/includes/nav-menu.php
@@ -13,7 +13,6 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
* @since 3.0.0
*
* @param string $output Passed by reference.
- * @param int $depth Depth of page.
*/
function start_lvl(&$output) {}
@@ -22,7 +21,6 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
* @since 3.0.0
*
* @param string $output Passed by reference.
- * @param int $depth Depth of page.
*/
function end_lvl(&$output) {
}
@@ -34,7 +32,6 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
* @param string $output Passed by reference. Used to append additional content.
* @param object $item Menu item data object.
* @param int $depth Depth of menu item. Used for padding.
- * @param int $current_page Menu item ID.
* @param object $args
*/
function start_el(&$output, $item, $depth, $args) {
@@ -164,7 +161,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
@@ -218,7 +215,6 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
* @param string $output Passed by reference. Used to append additional content.
* @param object $item Menu item data object.
* @param int $depth Depth of menu item. Used for padding.
- * @param int $current_page Menu item ID.
* @param object $args
*/
function start_el(&$output, $item, $depth, $args) {
@@ -249,7 +245,6 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
$output .= '';
$output .= '';
$output .= '';
- $output .= '';
$output .= '';
$output .= '';
}
@@ -499,7 +494,7 @@ function wp_nav_menu_locations_meta_box() {
?>
@@ -2648,14 +752,11 @@ function the_attachment_links( $id = false ) {
/**
- * Print out ";
else
$r .= "\n\t";
@@ -2676,7 +777,7 @@ function wp_dropdown_roles( $selected = false ) {
/**
* {@internal Missing Short Description}}
*
- * @since unknown
+ * @since 2.3.0
*
* @param unknown_type $size
* @return unknown
@@ -2696,7 +797,7 @@ function wp_convert_hr_to_bytes( $size ) {
/**
* {@internal Missing Short Description}}
*
- * @since unknown
+ * @since 2.3.0
*
* @param unknown_type $bytes
* @return unknown
@@ -2712,7 +813,7 @@ function wp_convert_bytes_to_hr( $bytes ) {
/**
* {@internal Missing Short Description}}
*
- * @since unknown
+ * @since 2.5.0
*
* @return unknown
*/
@@ -2726,7 +827,7 @@ function wp_max_upload_size() {
/**
* Outputs the form used by the importers to accept the data to be imported
*
- * @since 2.0
+ * @since 2.0.0
*
* @param string $action The action attribute for the form.
*/
@@ -2746,9 +847,7 @@ function wp_import_upload_form( $action ) {
-
-
-
+
' . "\n";
- echo '
';
+ echo '
';
echo "
{$box['title']}
\n";
echo '
' . "\n";
call_user_func($box['callback'], $object, $box);
@@ -2901,7 +1000,7 @@ function remove_meta_box($id, $page, $context) {
/**
* {@internal Missing Short Description}}
*
- * @since unknown
+ * @since 2.7.0
*
* @param unknown_type $screen
*/
@@ -2936,7 +1035,7 @@ function meta_box_prefs($screen) {
/**
* Get Hidden Meta Boxes
*
- * @since 2.7
+ * @since 2.7.0
*
* @param string|object $screen Screen identifier
* @return array Hidden Meta Boxes
@@ -2948,8 +1047,13 @@ function get_hidden_meta_boxes( $screen ) {
$hidden = get_user_option( "metaboxhidden_{$screen->id}" );
// Hide slug boxes by default
- if ( !is_array( $hidden ) )
- $hidden = array('slugdiv');
+ if ( !is_array( $hidden ) ) {
+ if ( 'post' == $screen->base || 'page' == $screen->base )
+ $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
+ else
+ $hidden = array( 'slugdiv' );
+ $hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen);
+ }
return $hidden;
}
@@ -3041,7 +1145,7 @@ function add_settings_field($id, $title, $callback, $page, $section = 'default',
*
* @global $wp_settings_sections Storage array of all settings sections added to admin pages
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
- * @since unknown
+ * @since 2.7.0
*
* @param string $page The slug name of the page whos settings sections you want to output
*/
@@ -3071,7 +1175,7 @@ function do_settings_sections($page) {
*
* @global $wp_settings_fields Storage array of settings fields and their pages/sections
*
- * @since unknown
+ * @since 2.7.0
*
* @param string $page Slug title of the admin page who's settings fields you want to show.
* @param section $section Slug title of the settings section who's fields you want to show.
@@ -3108,6 +1212,8 @@ function do_settings_fields($page, $section) {
* Additional calls to settings_errors() can be used to show errors even when the settings
* page is first accessed.
*
+ * @since 3.0.0
+ *
* @global array $wp_settings_errors Storage array of errors registered during this pageload
*
* @param string $setting Slug title of the setting to which this error applies
@@ -3136,7 +1242,7 @@ function add_settings_error( $setting, $code, $message, $type = 'error' ) {
* Checks the $wp_settings_errors array for any errors declared during the current
* pageload and returns them.
*
- * If changes were just submitted ($_GET['updated']) and settings errors were saved
+ * If changes were just submitted ($_GET['settings-updated']) and settings errors were saved
* to the 'settings_errors' transient then those errors will be returned instead. This
* is used to pass errors back across pageloads.
*
@@ -3144,6 +1250,8 @@ function add_settings_error( $setting, $code, $message, $type = 'error' ) {
* This is useful if you have errors or notices you want to show even when the user
* hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook)
*
+ * @since 3.0.0
+ *
* @global array $wp_settings_errors Storage array of errors registered during this pageload
*
* @param string $setting Optional slug title of a specific setting who's errors you want.
@@ -3161,7 +1269,7 @@ function get_settings_errors( $setting = '', $sanitize = FALSE ) {
// If settings were passed back from options.php then use them
// Ignore transients if $sanitize is true, we dont' want the old values anyway
- if ( isset($_GET['updated']) && $_GET['updated'] && get_transient('settings_errors') ) {
+ if ( isset($_GET['settings-updated']) && $_GET['settings-updated'] && get_transient('settings_errors') ) {
$settings_errors = get_transient('settings_errors');
delete_transient('settings_errors');
// Otherwise check global in case validation has been run on this pageload
@@ -3196,14 +1304,15 @@ function get_settings_errors( $setting = '', $sanitize = FALSE ) {
* shown in the default error reporting after submission. This is useful to show general errors like missing
* settings when the user arrives at the settings page.
*
+ * @since 3.0.0
+ *
* @param string $setting Optional slug title of a specific setting who's errors you want.
* @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
* @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted.
- * @return
*/
-function settings_errors ( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) {
+function settings_errors( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) {
- if ($hide_on_update AND $_GET['updated']) return;
+ if ($hide_on_update AND $_GET['settings-updated']) return;
$settings_errors = get_settings_errors( $setting, $sanitize );
@@ -3223,35 +1332,7 @@ function settings_errors ( $setting = '', $sanitize = FALSE, $hide_on_update = F
/**
* {@internal Missing Short Description}}
*
- * @since unknown
- *
- * @param unknown_type $page
- */
-function manage_columns_prefs( $page ) {
- $columns = get_column_headers( $page );
- $hidden = get_hidden_columns( $page );
- $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username');
-
- foreach ( $columns as $column => $title ) {
- // Can't hide these or they are special
- if ( in_array( $column, $special ) )
- continue;
- if ( empty( $title ) )
- continue;
-
- if ( 'comments' == $column )
- $title = __( 'Comments' );
- $id = "$column-hide";
- echo '\n";
- }
-}
-
-/**
- * {@internal Missing Short Description}}
- *
- * @since unknown
+ * @since 2.7.0
*
* @param unknown_type $found_action
*/
@@ -3269,7 +1350,7 @@ function find_posts_div($found_action = '') {
-
+
true), 'objects' );
@@ -3285,8 +1366,8 @@ function find_posts_div($found_action = '') {
' . __('Most of the modules on this screen can be moved. If you hover your mouse over the title bar of a module you’ll notice the 4 arrow cursor appears to let you know it is movable. Click on it, hold down the mouse button and start dragging the module to a new location. As you drag the module, notice the dotted gray box that also moves. This box indicates where the module will be placed when you release the mouse button.') . '
-
' . __('The same modules can be expanded and collapsed by clicking once on their title bar and also completely hidden from the Screen Options tab.') . '
' . __('You may search based on 3 criteria:') . ' ' .
- __('Term: Searches theme names and descriptions for the specified term.') . ' ' .
- __('Tag: Searches for themes tagged as such.') . ' ' .
- __('Author: Searches for themes created by the Author, or which the Author contributed to.') . '
-';
-}
-
function screen_layout($screen) {
- global $screen_layout_columns;
+ global $screen_layout_columns, $wp_current_screen_options;
if ( is_string($screen) )
$screen = convert_to_screen($screen);
- $columns = array('dashboard' => 4, 'link' => 2);
-
- // Add custom post types
- foreach ( get_post_types( array('show_ui' => true) ) as $post_type )
- $columns[$post_type] = 2;
-
- $columns = apply_filters('screen_layout_columns', $columns, $screen->id, $screen);
+ // Back compat for plugins using the filter instead of add_screen_option()
+ $columns = apply_filters('screen_layout_columns', array(), $screen->id, $screen);
+ if ( !empty($columns) && isset($columns[$screen->id]) )
+ add_screen_option('layout_columns', array('max' => $columns[$screen->id]) );
- if ( !isset($columns[$screen->id]) ) {
+ if ( !isset($wp_current_screen_options['layout_columns']) ) {
$screen_layout_columns = 0;
return '';
- }
+ }
$screen_layout_columns = get_user_option("screen_layout_$screen->id");
- $num = $columns[$screen->id];
+ $num = $wp_current_screen_options['layout_columns']['max'];
- if ( ! $screen_layout_columns )
+ if ( ! $screen_layout_columns ) {
+ if ( isset($wp_current_screen_options['layout_columns']['default']) )
+ $screen_layout_columns = $wp_current_screen_options['layout_columns']['default'];
+ else
$screen_layout_columns = 2;
+ }
$i = 1;
$return = '
taxonomy = $taxnow;
}
+ $current_screen->is_network = is_network_admin();
+ $current_screen->is_user = is_user_admin();
+
+ if ( $current_screen->is_network ) {
+ $current_screen->base .= '-network';
+ $current_screen->id .= '-network';
+ } elseif ( $current_screen->is_user ) {
+ $current_screen->base .= '-user';
+ $current_screen->id .= '-user';
+ }
+
$current_screen = apply_filters('current_screen', $current_screen);
}
-?>
+/**
+ * Echos a submit button, with provided text and appropriate class
+ *
+ * @since 3.1.0
+ *
+ * @param string $text The text of the button (defaults to 'Save Changes')
+ * @param string $type The type of button. One of: primary, secondary, delete
+ * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
+ * is given in $other_attributes below, $name will be used as the button's id.
+ * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
+ * false otherwise. Defaults to true
+ * @param array|string $other_attributes Other attributes that should be output with the button,
+ * mapping attributes to their values, such as array( 'tabindex' => '1' ).
+ * These attributes will be ouput as attribute="value", such as tabindex="1".
+ * Defaults to no other attributes. Other attributes can also be provided as a
+ * string such as 'tabindex="1"', though the array format is typically cleaner.
+ */
+function submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) {
+ echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
+}
+
+/**
+ * Returns a submit button, with provided text and appropriate class
+ *
+ * @since 3.1.0
+ *
+ * @param string $text The text of the button (defaults to 'Save Changes')
+ * @param string $type The type of button. One of: primary, secondary, delete
+ * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
+ * is given in $other_attributes below, $name will be used as the button's id.
+ * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
+ * false otherwise. Defaults to true
+ * @param array|string $other_attributes Other attributes that should be output with the button,
+ * mapping attributes to their values, such as array( 'tabindex' => '1' ).
+ * These attributes will be ouput as attribute="value", such as tabindex="1".
+ * Defaults to no other attributes. Other attributes can also be provided as a
+ * string such as 'tabindex="1"', though the array format is typically cleaner.
+ */
+function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) {
+ switch ( $type ) :
+ case 'primary' :
+ case 'secondary' :
+ $class = 'button-' . $type;
+ break;
+ case 'delete' :
+ $class = 'button-secondary delete';
+ break;
+ default :
+ $class = $type; // Custom cases can just pass in the classes they want to be used
+ endswitch;
+ $text = ( NULL == $text ) ? __( 'Save Changes' ) : $text;
+
+ // Default the id attribute to $name unless an id was specifically provided in $other_attributes
+ $id = $name;
+ if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
+ $id = $other_attributes['id'];
+ unset( $other_attributes['id'] );
+ }
+
+ $attributes = '';
+ if ( is_array( $other_attributes ) ) {
+ foreach ( $other_attributes as $attribute => $value ) {
+ $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
+ }
+ } else if ( !empty( $other_attributes ) ) { // Attributes provided as a string
+ $attributes = $other_attributes;
+ }
+
+ $button = '';
+
+ if ( $wrap ) {
+ $button = '
' . $button . '
';
+ }
+
+ return $button;
+}
+
diff --git a/wp-admin/includes/theme-install.php b/wp-admin/includes/theme-install.php
index ea96ef8b..da7c069e 100644
--- a/wp-admin/includes/theme-install.php
+++ b/wp-admin/includes/theme-install.php
@@ -19,57 +19,13 @@ $theme_field_defaults = array( 'description' => true, 'sections' => false, 'test
'tags' => true, 'num_ratings' => true
);
-
-/**
- * Retrieve theme installer pages from WordPress Themes API.
- *
- * It is possible for a theme to override the Themes API result with three
- * filters. Assume this is for themes, which can extend on the Theme Info to
- * offer more choices. This is very powerful and must be used with care, when
- * overridding the filters.
- *
- * The first filter, 'themes_api_args', is for the args and gives the action as
- * the second parameter. The hook for 'themes_api_args' must ensure that an
- * object is returned.
- *
- * The second filter, 'themes_api', is the result that would be returned.
- *
- * @since 2.8.0
- *
- * @param string $action
- * @param array|object $args Optional. Arguments to serialize for the Theme Info API.
- * @return mixed
- */
-function themes_api($action, $args = null) {
-
- if ( is_array($args) )
- $args = (object)$args;
-
- if ( !isset($args->per_page) )
- $args->per_page = 24;
-
- $args = apply_filters('themes_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter.
- $res = apply_filters('themes_api', false, $action, $args); //NOTE: Allows a theme to completely override the builtin WordPress.org API.
-
- if ( ! $res ) {
- $request = wp_remote_post('http://api.wordpress.org/themes/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) );
- if ( is_wp_error($request) ) {
- $res = new WP_Error('themes_api_failed', __('An Unexpected HTTP Error occured during the API request.
';
- if ( ! current_user_can('update_plugins') )
- printf( __('There is a new version of %1$s available. View version %4$s Details.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
- else if ( empty($r->package) )
- printf( __('There is a new version of %1$s available. View version %4$s Detailsautomatic upgrade unavailable for this plugin.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
- else
- printf( __('There is a new version of %1$s available. View version %4$s Details or upgrade automatically.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $file, 'upgrade-plugin_' . $file) );
+ $wp_list_table = _get_list_table('WP_Plugins_List_Table');
+
+ if ( is_network_admin() || !is_multisite() ) {
+ echo '
';
+ if ( ! current_user_can('update_plugins') )
+ printf( __('There is a new version of %1$s available. View version %4$s details.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
+ else if ( empty($r->package) )
+ printf( __('There is a new version of %1$s available. View version %4$s details. Automatic update is unavailable for this plugin.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
+ else
+ printf( __('There is a new version of %1$s available. View version %4$s details or update automatically.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) );
+ }
do_action( "in_plugin_update_message-$file", $plugin_data, $r );
@@ -239,6 +245,45 @@ function wp_update_theme($theme, $feedback = '') {
return $upgrader->upgrade($theme);
}
+function wp_theme_update_rows() {
+ if ( !current_user_can('update_themes' ) )
+ return;
+
+ $themes = get_site_transient( 'update_themes' );
+ if ( isset($themes->response) && is_array($themes->response) ) {
+ $themes = array_keys( $themes->response );
+
+ foreach( $themes as $theme ) {
+ add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 );
+ }
+ }
+}
+add_action( 'admin_init', 'wp_theme_update_rows' );
+
+function wp_theme_update_row( $theme_key, $theme ) {
+ $current = get_site_transient( 'update_themes' );
+ if ( !isset( $current->response[ $theme_key ] ) )
+ return false;
+ $r = $current->response[ $theme_key ];
+ $themes_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
+ $theme_name = wp_kses( $theme['Name'], $themes_allowedtags );
+
+ $details_url = self_admin_url("theme-install.php?tab=theme-information&theme=$theme_key&TB_iframe=true&width=600&height=400");
+
+ $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
+
+ echo '
';
+ if ( ! current_user_can('update_themes') )
+ printf( __('There is a new version of %1$s available. View version %4$s details.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version );
+ else if ( empty( $r['package'] ) )
+ printf( __('There is a new version of %1$s available. View version %4$s details. Automatic update is unavailable for this plugin.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'] );
+ else
+ printf( __('There is a new version of %1$s available. View version %4$s details or update automatically.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key) );
+
+ do_action( "in_theme_update_message-$theme_key", $theme, $r );
+
+ echo '
';
+}
function wp_update_core($current, $feedback = '') {
if ( !empty($feedback) )
diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php
index 7ae2384e..f29f594e 100644
--- a/wp-admin/includes/upgrade.php
+++ b/wp-admin/includes/upgrade.php
@@ -24,7 +24,7 @@ if ( !function_exists('wp_install') ) :
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 2.1.0
*
* @param string $blog_title Blog title.
* @param string $user_name User's username.
@@ -64,7 +64,7 @@ function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated
$user_password = trim($user_password);
$email_password = false;
if ( !$user_id && empty($user_password) ) {
- $user_password = wp_generate_password();
+ $user_password = wp_generate_password( 12, false );
$message = __('Note that password carefully! It is a random password that was generated just for you.');
$user_id = wp_create_user($user_name, $user_password, $user_email);
update_user_option($user_id, 'default_password_nag', true, true);
@@ -98,7 +98,7 @@ if ( !function_exists('wp_install_defaults') ) :
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 2.1.0
*
* @param int $user_id User ID.
*/
@@ -243,7 +243,15 @@ function wp_install_defaults($user_id) {
));
// First Page
- $first_page = __('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.');
+ $first_page = sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
+
+
Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)
+
+...or something like this:
+
+
The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickies to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.
+
+As a new WordPress user, you should go to your dashboard to delete this page and create new pages for your content. Have fun!" ), admin_url() );
if ( is_multisite() )
$first_page = get_site_option( 'first_page', $first_page );
$first_post_guid = get_option('home') . '/?page_id=2';
@@ -253,9 +261,9 @@ function wp_install_defaults($user_id) {
'post_date_gmt' => $now_gmt,
'post_content' => $first_page,
'post_excerpt' => '',
- 'post_title' => __('About'),
+ 'post_title' => __( 'Sample Page' ),
/* translators: Default page slug */
- 'post_name' => _x('about', 'Default page slug'),
+ 'post_name' => __( 'sample-page' ),
'post_modified' => $now,
'post_modified_gmt' => $now_gmt,
'guid' => $first_post_guid,
@@ -266,7 +274,7 @@ function wp_install_defaults($user_id) {
));
$wpdb->insert( $wpdb->postmeta, array( 'post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default' ) );
- // Setup default widgets for default theme.
+ // Set up default widgets for default theme.
update_option( 'widget_search', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
@@ -300,7 +308,7 @@ if ( !function_exists('wp_new_blog_notification') ) :
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 2.1.0
*
* @param string $blog_title Blog title.
* @param string $blog_url Blog url.
@@ -336,7 +344,7 @@ if ( !function_exists('wp_upgrade') ) :
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 2.1.0
*
* @return null
*/
@@ -375,7 +383,7 @@ endif;
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 1.0.1
*/
function upgrade_all() {
global $wp_current_db_version, $wp_db_version, $wp_rewrite;
@@ -1187,7 +1195,7 @@ function upgrade_network() {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 1.0.0
*
* @param string $table_name Database table name to create.
* @param string $create_ddl SQL statement to create table.
@@ -1210,7 +1218,7 @@ function maybe_create_table($table_name, $create_ddl) {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 1.0.1
*
* @param string $table Database table name.
* @param string $index Index name to drop.
@@ -1233,7 +1241,7 @@ function drop_index($table, $index) {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 1.0.1
*
* @param string $table Database table name.
* @param string $index Database table index column.
@@ -1296,7 +1304,7 @@ function get_alloptions_110() {
/**
* Version of get_option that is private to install/upgrade.
*
- * @since unknown
+ * @since 1.5.1
* @access private
*
* @param string $setting Option name.
@@ -1333,7 +1341,7 @@ function __get_option($setting) {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 1.5.0
*
* @param string $content
* @return string
@@ -1360,7 +1368,7 @@ function deslash($content) {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 1.5.0
*
* @param unknown_type $queries
* @param unknown_type $execute
@@ -1567,7 +1575,7 @@ function dbDelta($queries, $execute = true) {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 1.5.0
*/
function make_db_current() {
global $wp_queries;
@@ -1583,7 +1591,7 @@ function make_db_current() {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 1.5.0
*/
function make_db_current_silent() {
global $wp_queries;
@@ -1596,7 +1604,7 @@ function make_db_current_silent() {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 1.5.0
*
* @param unknown_type $theme_name
* @param unknown_type $template
@@ -1656,7 +1664,7 @@ function make_site_theme_from_oldschool($theme_name, $template) {
}
// Add a theme header.
- $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the upgrade.\nVersion: 1.0\nAuthor: Moi\n*/\n";
+ $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n";
$stylelines = file_get_contents("$site_dir/style.css");
if ($stylelines) {
@@ -1675,7 +1683,7 @@ function make_site_theme_from_oldschool($theme_name, $template) {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 1.5.0
*
* @param unknown_type $theme_name
* @param unknown_type $template
@@ -1741,7 +1749,7 @@ function make_site_theme_from_default($theme_name, $template) {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 1.5.0
*
* @return unknown
*/
@@ -1789,7 +1797,7 @@ function make_site_theme() {
/**
* Translate user level to user role name.
*
- * @since unknown
+ * @since 2.0.0
*
* @param int $level User level.
* @return string User role name.
@@ -1820,7 +1828,7 @@ function translate_level_to_role($level) {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 2.1.0
*/
function wp_check_mysql_version() {
global $wpdb;
@@ -1834,7 +1842,7 @@ function wp_check_mysql_version() {
*
* {@internal Missing Long Description}}
*
- * @since unknown
+ * @since 2.2.0
*/
function maybe_disable_automattic_widgets() {
$plugins = __get_option( 'active_plugins' );
@@ -1850,6 +1858,8 @@ function maybe_disable_automattic_widgets() {
/**
* Runs before the schema is upgraded.
+ *
+ * @since 2.9.0
*/
function pre_schema_upgrade() {
global $wp_current_db_version, $wp_db_version, $wpdb;
diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php
index b31c38bd..758c065a 100644
--- a/wp-admin/includes/user.php
+++ b/wp-admin/includes/user.php
@@ -55,14 +55,14 @@ function add_user() {
*/
function edit_user( $user_id = 0 ) {
global $wp_roles, $wpdb;
- if ( $user_id != 0 ) {
+ $user = new stdClass;
+ if ( $user_id ) {
$update = true;
$user->ID = (int) $user_id;
$userdata = get_userdata( $user_id );
$user->user_login = $wpdb->escape( $userdata->user_login );
} else {
$update = false;
- $user = '';
}
if ( !$update && isset( $_POST['user_login'] ) )
@@ -110,7 +110,7 @@ function edit_user( $user_id = 0 ) {
if ( isset( $_POST['description'] ) )
$user->description = trim( $_POST['description'] );
- foreach ( _wp_get_user_contactmethods() as $method => $name ) {
+ foreach ( _wp_get_user_contactmethods( $user ) as $method => $name ) {
if ( isset( $_POST[$method] ))
$user->$method = sanitize_text_field( $_POST[$method] );
}
@@ -118,6 +118,8 @@ function edit_user( $user_id = 0 ) {
if ( $update ) {
$user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true';
$user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
+ $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
+ $user->show_admin_bar_admin = isset( $_POST['admin_bar_admin'] ) ? 'true' : 'false';
}
$user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
@@ -169,7 +171,7 @@ function edit_user( $user_id = 0 ) {
$errors->add( 'empty_email', __( 'ERROR: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) );
} elseif ( !is_email( $user->user_email ) ) {
$errors->add( 'invalid_email', __( 'ERROR: The e-mail address isn’t correct.' ), array( 'form-field' => 'email' ) );
- } elseif ( ( $owner_id = email_exists($user->user_email) ) && $owner_id != $user->ID ) {
+ } elseif ( ( $owner_id = email_exists($user->user_email) ) && ( !$update || ( $owner_id != $user->ID ) ) ) {
$errors->add( 'email_exists', __('ERROR: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) );
}
@@ -188,86 +190,6 @@ function edit_user( $user_id = 0 ) {
return $user_id;
}
-/**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
- *
- * @since unknown
- *
- * @return array List of user IDs.
- */
-function get_author_user_ids() {
- global $wpdb;
- if ( !is_multisite() )
- $level_key = $wpdb->get_blog_prefix() . 'user_level';
- else
- $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
-
- return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
-}
-
-/**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
- *
- * @since unknown
- *
- * @param int $user_id User ID.
- * @return array|bool List of editable authors. False if no editable users.
- */
-function get_editable_authors( $user_id ) {
- global $wpdb;
-
- $editable = get_editable_user_ids( $user_id );
-
- if ( !$editable ) {
- return false;
- } else {
- $editable = join(',', $editable);
- $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
- }
-
- return apply_filters('get_editable_authors', $authors);
-}
-
-/**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
- *
- * @since unknown
- *
- * @param int $user_id User ID.
- * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros.
- * @return unknown
- */
-function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
- global $wpdb;
-
- $user = new WP_User( $user_id );
- $post_type_obj = get_post_type_object($post_type);
-
- if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
- if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
- return array($user->id);
- else
- return array();
- }
-
- if ( !is_multisite() )
- $level_key = $wpdb->get_blog_prefix() . 'user_level';
- else
- $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
-
- $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
- if ( $exclude_zeros )
- $query .= " AND meta_value != '0'";
-
- return $wpdb->get_col( $query );
-}
-
/**
* Fetch a filtered list of user roles that the current user is
* allowed to edit.
@@ -293,85 +215,10 @@ function get_editable_roles() {
return $editable_roles;
}
-/**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
- *
- * @since unknown
- *
- * @return unknown
- */
-function get_nonauthor_user_ids() {
- global $wpdb;
-
- if ( !is_multisite() )
- $level_key = $wpdb->get_blog_prefix() . 'user_level';
- else
- $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
-
- return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
-}
-
-/**
- * Retrieve editable posts from other users.
- *
- * @since unknown
- *
- * @param int $user_id User ID to not retrieve posts from.
- * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
- * @return array List of posts from others.
- */
-function get_others_unpublished_posts($user_id, $type='any') {
- global $wpdb;
-
- $editable = get_editable_user_ids( $user_id );
-
- if ( in_array($type, array('draft', 'pending')) )
- $type_sql = " post_status = '$type' ";
- else
- $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
-
- $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
-
- if ( !$editable ) {
- $other_unpubs = '';
- } else {
- $editable = join(',', $editable);
- $other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
- }
-
- return apply_filters('get_others_drafts', $other_unpubs);
-}
-
-/**
- * Retrieve drafts from other users.
- *
- * @since unknown
- *
- * @param int $user_id User ID.
- * @return array List of drafts from other users.
- */
-function get_others_drafts($user_id) {
- return get_others_unpublished_posts($user_id, 'draft');
-}
-
-/**
- * Retrieve pending review posts from other users.
- *
- * @since unknown
- *
- * @param int $user_id User ID.
- * @return array List of posts with pending review post type from other users.
- */
-function get_others_pending($user_id) {
- return get_others_unpublished_posts($user_id, 'pending');
-}
-
/**
* Retrieve user data and filter it.
*
- * @since unknown
+ * @since 2.0.5
*
* @param int $user_id User ID.
* @return object WP_User object with user data.
@@ -379,7 +226,7 @@ function get_others_pending($user_id) {
function get_user_to_edit( $user_id ) {
$user = new WP_User( $user_id );
- $user_contactmethods = _wp_get_user_contactmethods();
+ $user_contactmethods = _wp_get_user_contactmethods( $user );
foreach ($user_contactmethods as $method => $name) {
if ( empty( $user->{$method} ) )
$user->{$method} = '';
@@ -396,7 +243,7 @@ function get_user_to_edit( $user_id ) {
/**
* Retrieve the user's drafts.
*
- * @since unknown
+ * @since 2.0.0
*
* @param int $user_id User ID.
* @return array
@@ -416,7 +263,7 @@ function get_users_drafts( $user_id ) {
* being deleted will be run after the posts are either reassigned or deleted.
* The user meta will also be deleted that are for that User ID.
*
- * @since unknown
+ * @since 2.0.0
*
* @param int $id User ID.
* @param int $reassign Optional. Reassign posts and links to new User ID.
@@ -471,7 +318,7 @@ function wp_delete_user( $id, $reassign = 'novalue' ) {
/**
* Remove all capabilities from user.
*
- * @since unknown
+ * @since 2.1.0
*
* @param int $id User ID.
*/
@@ -482,344 +329,10 @@ function wp_revoke_user($id) {
$user->remove_all_caps();
}
-if ( !class_exists('WP_User_Search') ) :
+add_action('admin_init', 'default_password_nag_handler');
/**
- * WordPress User Search class.
- *
- * @since unknown
+ * @since 2.8.0
*/
-class WP_User_Search {
-
- /**
- * {@internal Missing Description}}
- *
- * @since unknown
- * @access private
- * @var unknown_type
- */
- var $results;
-
- /**
- * {@internal Missing Description}}
- *
- * @since unknown
- * @access private
- * @var unknown_type
- */
- var $search_term;
-
- /**
- * Page number.
- *
- * @since unknown
- * @access private
- * @var int
- */
- var $page;
-
- /**
- * Role name that users have.
- *
- * @since unknown
- * @access private
- * @var string
- */
- var $role;
-
- /**
- * Raw page number.
- *
- * @since unknown
- * @access private
- * @var int|bool
- */
- var $raw_page;
-
- /**
- * Amount of users to display per page.
- *
- * @since unknown
- * @access public
- * @var int
- */
- var $users_per_page = 50;
-
- /**
- * {@internal Missing Description}}
- *
- * @since unknown
- * @access private
- * @var unknown_type
- */
- var $first_user;
-
- /**
- * {@internal Missing Description}}
- *
- * @since unknown
- * @access private
- * @var int
- */
- var $last_user;
-
- /**
- * {@internal Missing Description}}
- *
- * @since unknown
- * @access private
- * @var string
- */
- var $query_limit;
-
- /**
- * {@internal Missing Description}}
- *
- * @since 3.0.0
- * @access private
- * @var string
- */
- var $query_orderby;
-
- /**
- * {@internal Missing Description}}
- *
- * @since 3.0.0
- * @access private
- * @var string
- */
- var $query_from;
-
- /**
- * {@internal Missing Description}}
- *
- * @since 3.0.0
- * @access private
- * @var string
- */
- var $query_where;
-
- /**
- * {@internal Missing Description}}
- *
- * @since unknown
- * @access private
- * @var int
- */
- var $total_users_for_query = 0;
-
- /**
- * {@internal Missing Description}}
- *
- * @since unknown
- * @access private
- * @var bool
- */
- var $too_many_total_users = false;
-
- /**
- * {@internal Missing Description}}
- *
- * @since unknown
- * @access private
- * @var unknown_type
- */
- var $search_errors;
-
- /**
- * {@internal Missing Description}}
- *
- * @since unknown
- * @access private
- * @var unknown_type
- */
- var $paging_text;
-
- /**
- * PHP4 Constructor - Sets up the object properties.
- *
- * @since unknown
- *
- * @param string $search_term Search terms string.
- * @param int $page Optional. Page ID.
- * @param string $role Role name.
- * @return WP_User_Search
- */
- function WP_User_Search ($search_term = '', $page = '', $role = '') {
- $this->search_term = $search_term;
- $this->raw_page = ( '' == $page ) ? false : (int) $page;
- $this->page = (int) ( '' == $page ) ? 1 : $page;
- $this->role = $role;
-
- $this->prepare_query();
- $this->query();
- $this->prepare_vars_for_template_usage();
- $this->do_paging();
- }
-
- /**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
- *
- * @since unknown
- * @access public
- */
- function prepare_query() {
- global $wpdb;
- $this->first_user = ($this->page - 1) * $this->users_per_page;
-
- $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
- $this->query_orderby = ' ORDER BY user_login';
-
- $search_sql = '';
- if ( $this->search_term ) {
- $searches = array();
- $search_sql = 'AND (';
- foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
- $searches[] = $col . " LIKE '%$this->search_term%'";
- $search_sql .= implode(' OR ', $searches);
- $search_sql .= ')';
- }
-
- $this->query_from = " FROM $wpdb->users";
- $this->query_where = " WHERE 1=1 $search_sql";
-
- if ( $this->role ) {
- $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
- $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
- } elseif ( is_multisite() ) {
- $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
- $this->query_from .= ", $wpdb->usermeta";
- $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
- }
-
- do_action_ref_array( 'pre_user_search', array( &$this ) );
- }
-
- /**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
- *
- * @since unknown
- * @access public
- */
- function query() {
- global $wpdb;
-
- $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
-
- if ( $this->results )
- $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
- else
- $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
- }
-
- /**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
- *
- * @since unknown
- * @access public
- */
- function prepare_vars_for_template_usage() {
- $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
- }
-
- /**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
- *
- * @since unknown
- * @access public
- */
- function do_paging() {
- if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
- $args = array();
- if( ! empty($this->search_term) )
- $args['usersearch'] = urlencode($this->search_term);
- if( ! empty($this->role) )
- $args['role'] = urlencode($this->role);
-
- $this->paging_text = paginate_links( array(
- 'total' => ceil($this->total_users_for_query / $this->users_per_page),
- 'current' => $this->page,
- 'base' => 'users.php?%_%',
- 'format' => 'userspage=%#%',
- 'add_args' => $args
- ) );
- if ( $this->paging_text ) {
- $this->paging_text = sprintf( '' . __( 'Displaying %s–%s of %s' ) . '%s',
- number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
- number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
- number_format_i18n( $this->total_users_for_query ),
- $this->paging_text
- );
- }
- }
- }
-
- /**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
- *
- * @since unknown
- * @access public
- *
- * @return unknown
- */
- function get_results() {
- return (array) $this->results;
- }
-
- /**
- * Displaying paging text.
- *
- * @see do_paging() Builds paging text.
- *
- * @since unknown
- * @access public
- */
- function page_links() {
- echo $this->paging_text;
- }
-
- /**
- * Whether paging is enabled.
- *
- * @see do_paging() Builds paging text.
- *
- * @since unknown
- * @access public
- *
- * @return bool
- */
- function results_are_paged() {
- if ( $this->paging_text )
- return true;
- return false;
- }
-
- /**
- * Whether there are search terms.
- *
- * @since unknown
- * @access public
- *
- * @return bool
- */
- function is_search() {
- if ( $this->search_term )
- return true;
- return false;
- }
-}
-endif;
-
-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.
@@ -833,6 +346,9 @@ 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.
return;
@@ -846,14 +362,18 @@ function default_password_nag_edit_user($user_ID, $old_data) {
}
add_action('admin_notices', 'default_password_nag');
+/**
+ * @since 2.8.0
+ */
function default_password_nag() {
- if ( ! get_user_option('default_password_nag') ) //Short circuit it.
+ global $pagenow;
+ if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') ) //Short circuit it.
return;
echo '
';
echo '
';
echo '' . __('Notice:') . ' ';
- _e('You’re using the auto-generated password for your account. Would you like to change it to something you’ll remember easier?');
+ _e('You’re using the auto-generated password for your account. Would you like to change it to something easier to remember?');
echo '
';
printf( '' . __('Yes, take me to my profile page') . ' | ', admin_url('profile.php') . '#password' );
printf( '' . __('No thanks, do not remind me again') . '', '?default_password_nag=0' );
diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php
index aef0dbaf..a591c60d 100644
--- a/wp-admin/includes/widgets.php
+++ b/wp-admin/includes/widgets.php
@@ -7,20 +7,15 @@
*/
/**
- * Display list of the available widgets, either all or matching search.
+ * Display list of the available widgets.
*
- * The search parameter are search terms separated by spaces.
- *
- * @since unknown
- *
- * @param string $show Optional, default is all. What to display, can be 'all', 'unused', or 'used'.
- * @param string $_search Optional. Search for widgets. Should be unsanitized.
+ * @since 2.5.0
*/
function wp_list_widgets() {
global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
$sort = $wp_registered_widgets;
- usort( $sort, create_function( '$a, $b', 'return strnatcasecmp( $a["name"], $b["name"] );' ) );
+ usort( $sort, '_sort_name_callback' );
$done = array();
foreach ( $sort as $widget ) {
@@ -51,11 +46,21 @@ function wp_list_widgets() {
}
}
+/**
+ * Callback to sort array by a 'name' key.
+ *
+ * @since 3.1.0
+ * @access private
+ */
+function _sort_name_callback( $a, $b ) {
+ return strnatcasecmp( $a['name'], $b['name'] );
+}
+
/**
* Show the widgets and their settings for a sidebar.
* Used in the the admin widget config screen.
*
- * @since unknown
+ * @since 2.5.0
*
* @param string $sidebar id slug of the sidebar
*/
@@ -79,7 +84,7 @@ function wp_list_widget_controls( $sidebar ) {
/**
* {@internal Missing Short Description}}
*
- * @since unknown
+ * @since 2.5.0
*
* @param array $params
* @return array
@@ -93,7 +98,7 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) {
$id = isset($params[0]['_temp_id']) ? $params[0]['_temp_id'] : $widget_id;
$hidden = isset($params[0]['_hide']) ? ' style="display:none;"' : '';
- $params[0]['before_widget'] = "
' . __('Welcome to your WordPress Dashboard! You will find helpful tips in the Help tab of each screen to assist you as you get to know the application.') . '
' .
- '
' . __('The left-hand navigation menu provides links to the administration screens in your WordPress application. You can expand or collapse navigation sections by clicking on the arrow that appears on the right side of each navigation item when you hover over it. You can also minimize the navigation menu to a narrow icon strip by clicking on the separator lines between navigation sections that end in double arrowheads; when minimized, the submenu items will be displayed on hover.') . '
' .
- '
' . __('You can configure your dashboard by choosing which modules to display, how many columns to display them in, and where each module should be placed. You can hide/show modules and select the number of columns in the Screen Options tab. To rearrange the modules, drag and drop by clicking on the title bar of the selected module and releasing when you see a gray dotted-line box appear in the location you want to place the module. You can also expand or collapse each module by clicking once on the the module’s title bar. In addition, some modules are configurable, and will show a “Configure” link in the title bar when you hover over it.') . '
' .
- '
' . __('The modules on your Dashboard screen are:') . '
' .
- '
' . __('Right Now - Displays a summary of the content on your site and identifies which theme and version of WordPress you are using.') . '
' .
- '
' . __('Recent Comments - Shows the most recent comments on your posts (configurable, up to 30) and allows you to moderate them.') . '
' .
- '
' . __('Incoming Links - Shows links to your site found by Google Blog Search.') . '
' .
- '
' . __('QuickPress - Allows you to create a new post and either publish it or save it as a draft.') . '
' .
- '
' . __('Recent Drafts - Displays links to the 5 most recent draft posts you’ve started.') . '
' .
- '
' . __('Other WordPress News - Shows the feed from WordPress Planet. You can configure it to show a different feed of your choosing.') . '
' .
- '
' . __('Plugins - Features the most popular, newest, and recently updated plugins from the WordPress.org Plugin Directory.') . '
' . __( 'Welcome to your WordPress Dashboard! You will find helpful tips in the Help tab of each screen to assist you as you get to know the application.' ) . '
' .
+ '
' . __( 'The Admin Bar at the top, new in 3.1, provides quick access to common tasks when you are viewing your site.' ) . '
' .
+ '
' . __( 'The left-hand navigation menu provides links to the administration screens in your WordPress application. You can expand or collapse navigation sections by clicking on the arrow that appears on the right side of each navigation item when you hover over it. You can also minimize the navigation menu to a narrow icon strip by clicking on the faint separator lines between the Dashboard and Posts sections, or between Comments and Appearance; when minimized, the submenu items will be displayed on hover.' ) . '
' .
+ '
' . __( 'You can configure your dashboard by choosing which boxes, or modules, to display in the work area, how many columns to display them in, and where each box should be placed. You can hide/show boxes and select the number of columns in the Screen Options tab. To rearrange the boxes, drag and drop by clicking on the title bar of the selected box and releasing when you see a gray dotted-line rectangle appear in the location you want to place the box. You can also expand or collapse each box by clicking once on the title bar of the box. In addition, some boxes are configurable, and will show a “Configure” link in the title bar when you hover over it.' ) . '
' .
+ '
' . __( 'The boxes on your Dashboard screen are:' ) . '
' .
+ '
' . __( 'Right Now - Displays a summary of the content on your site and identifies which theme and version of WordPress you are using.' ) . '
' .
+ '
' . __( 'Recent Comments - Shows the most recent comments on your posts (configurable, up to 30) and allows you to moderate them.' ) . '
' .
+ '
' . __( 'Incoming Links - Shows links to your site found by Google Blog Search.' ) . '
' .
+ '
' . __( 'QuickPress - Allows you to create a new post and either publish it or save it as a draft.' ) . '
' .
+ '
' . __( 'Recent Drafts - Displays links to the 5 most recent draft posts you’ve started.' ) . '
' .
+ '
' . __( 'WordPress Development Blog - Come here for the latest scoop.' ) . '
' .
+ '
' . __( 'Other WordPress News - Shows the feed from WordPress Planet. You can configure it to show a different feed of your choosing.' ) . '
' .
+ '
' . __( 'Plugins - Features the most popular, newest, and recently updated plugins from the WordPress.org Plugin Directory.' ) . '
-
-
diff --git a/wp-admin/ms-users.php b/wp-admin/ms-users.php
index 594406ac..5b4f1c52 100644
--- a/wp-admin/ms-users.php
+++ b/wp-admin/ms-users.php
@@ -9,370 +9,6 @@
require_once( './admin.php' );
-if ( !is_multisite() )
- wp_die( __( 'Multisite support is not enabled.' ) );
-
-if ( ! current_user_can( 'manage_network_users' ) )
- wp_die( __( 'You do not have permission to access this page.' ) );
-
-$title = __( 'Users' );
-$parent_file = 'ms-admin.php';
-
-add_contextual_help($current_screen,
- '
' . __('This table shows all users across the network and the sites to which they are assigned.') . '
' .
- '
' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to his or her Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '
' .
- '
' . __('You can also go to the user’s profile page by clicking on the individual username.') . '
' .
- '
' . __('You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.') . '
' .
- '
' . __('The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.') . '
' .
- '
' . __('Add User will add that person to this table and send them an email.') . '
' .
- '
' . __('Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.') . '
' .
- '
' . __('You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.') . '
' . __('This screen shows an individual user all of their sites in this network, and also allows that user to set a primary site. He or she can use the links under each site to visit either the frontend or the dashboard for that site.') . '
' .
'
' . __('Up until WordPress version 3.0, what is now called a Multi-site Network had to be installed separately as WordPress MU (multi-user).') . '
' . __('The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.') . '
';
-$help = '
' . __('This feature is new in version 3.0; to use a custom menu in place of your theme’s default menus, support for this feature must be registered in the theme’s functions.php file. If your theme does not support the custom menus feature yet (the new default theme, Twenty Ten, does), you can learn about adding support yourself by following the below link.') . '
';
+$help = '
' . __('This feature, introduced in version 3.0, allows you to use a custom menu in place of your theme’s default menus. If your theme does not support the custom menus feature yet (the default theme, Twenty Ten, does), you can learn about adding this support by following the Documentation link in this tab. You can still use the “Custom Menu” widget to add menus to a sidebar.') . '
';
$help .= '
' . __('You can create custom menus for your site. These menus may contain links to pages, categories, custom links or other content types (use the Screen Options tab to decide which ones to show on the screen). You can specify a different navigation label for a menu item as well as other attributes. You can create multiple menus. If your theme includes more than one menu, you can choose which custom menu to associate with each. You can also use custom menus in conjunction with the Custom Menus widget.') . '
';
-$help .= '
' . __('To create a new custom menu, click on the + tab, give the menu a name, and click Create Menu. Next, add menu items from the appropriate boxes. You’ll be able to edit the information for each menu item, and can drag and drop to put them in order. You can also drag a menu item a little to the right to make it a submenu, to create menus with hierarchy. You’ll see when the position of the drop target shifts over to create the nested placement. Don’t forget to click Save when you’re finished.') . '
';
+$help .= '
' . __('To create a new custom menu, click on the + tab, give the menu a name, and click Create Menu. Next, add menu items from the appropriate boxes. You’ll be able to edit the information for each menu item, and can drag and drop to put them in order. You can also drag a menu item a little to the right to make it a submenu, to create menus with hierarchy. Drop the item into its new nested placement when the dotted rectangle target shifts over, also a little to the right. Don’t forget to click Save when you’re finished.') . '
+
@@ -598,4 +605,4 @@ require_once( 'admin-header.php' );
-
+
diff --git a/wp-admin/network.php b/wp-admin/network.php
index a2951641..6a9aca33 100644
--- a/wp-admin/network.php
+++ b/wp-admin/network.php
@@ -18,8 +18,14 @@ require_once( './admin.php' );
if ( ! is_super_admin() )
wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
-if ( is_multisite() && ! defined( 'MULTISITE' ) )
- wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) );
+if ( is_multisite() ) {
+ if ( ! is_network_admin() ) {
+ wp_redirect( network_admin_url( 'setup.php' ) );
+ exit;
+ }
+ if ( ! defined( 'MULTISITE' ) )
+ wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) );
+}
// We need to create references to ms global tables to enable Network.
foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table )
@@ -89,8 +95,13 @@ function get_clean_basedomain() {
if ( ! network_domain_check() && ( ! defined( 'WP_ALLOW_MULTISITE' ) || ! WP_ALLOW_MULTISITE ) )
wp_die( __( 'You must define the WP_ALLOW_MULTISITE constant as true in your wp-config.php file to allow creation of a Network.' ) );
-$title = __( 'Create a Network of WordPress Sites' );
-$parent_file = 'tools.php';
+if ( is_network_admin() ) {
+ $title = __( 'Network Setup' );
+ $parent_file = 'settings.php';
+} else {
+ $title = __( 'Create a Network of WordPress Sites' );
+ $parent_file = 'tools.php';
+}
add_contextual_help($current_screen,
'
' . __('This screen allows you to configure a network as having subdomains (site1.example.com) or subdirectories (example.com/site1). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '
' . __('Refreshing your browser will take you to a screen with an archive of those added lines of code. A set of six links under Super Admin will appear at the top of the main left navigation menu. The multisite network is now enabled.') . '
' .
'
' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with “/blog/” from the main site. This disabling will be addressed soon in a future version.') . '
' . __('Error:') . ' ' . sprintf( __( 'Your WordPress address must match your Site address before creating a Network. See General Settings.' ), esc_url( admin_url( 'options-general.php' ) ) ) . '
';
echo '';
- include ('./admin-footer.php' );
+ include ( ABSPATH . 'wp-admin/admin-footer.php' );
+ die();
+ }
+
+ if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
+ echo '
' . __('Error:') . ' ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '
Caution: We recommend you back up your existing wp-config.php file.' );
+ if ( file_exists( ABSPATH . '.htaccess' ) )
+ printf( __( 'Caution: We recommend you back up your existing wp-config.php and %s files.' ), '.htaccess' );
+ elseif ( file_exists( ABSPATH . 'web.config' ) )
+ printf( __( 'Caution: We recommend you back up your existing wp-config.php and %s files.' ), 'web.config' );
else
- _e( 'Caution: We recommend you back up your existing wp-config.php and .htaccess files.' );
+ _e( 'Caution: We recommend you back up your existing wp-config.php file.' );
?>
blogs.dir directory in %s. This directory is used to stored uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR );
+ printf( __( 'Create a blogs.dir directory at %s/blogs.dir. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR );
if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
echo ' ' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '
';
+ require_once( '../admin-footer.php' );
+ exit();
+ break;
+
+ case 'spam':
+ $user = new WP_User( $val );
+ if ( in_array( $user->user_login, get_super_admins() ) )
+ wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) );
+
+ $userfunction = 'all_spam';
+ $blogs = get_blogs_of_user( $val, true );
+ foreach ( (array) $blogs as $key => $details ) {
+ if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam !
+ update_blog_status( $details->userblog_id, 'spam', '1' );
+ }
+ update_user_status( $val, 'spam', '1' );
+ break;
+
+ case 'notspam':
+ $userfunction = 'all_notspam';
+ $blogs = get_blogs_of_user( $val, true );
+ foreach ( (array) $blogs as $key => $details )
+ update_blog_status( $details->userblog_id, 'spam', '0' );
+
+ update_user_status( $val, 'spam', '0' );
+ break;
+ }
+ }
+ }
+
+ wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
+ } else {
+ $location = network_admin_url( 'users.php' );
+
+ if ( ! empty( $_REQUEST['paged'] ) )
+ $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
+ wp_redirect( $location );
+ }
+ exit();
+ break;
+
+ case 'dodelete':
+ check_admin_referer( 'ms-users-delete' );
+ if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) )
+ wp_die( __( 'You do not have permission to access this page.' ) );
+
+ if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) {
+ foreach ( $_POST['blog'] as $id => $users ) {
+ foreach ( $users as $blogid => $user_id ) {
+ if ( ! current_user_can( 'delete_user', $id ) )
+ continue;
+
+ if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] )
+ remove_user_from_blog( $id, $blogid, $user_id );
+ else
+ remove_user_from_blog( $id, $blogid );
+ }
+ }
+ }
+ $i = 0;
+ if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) )
+ foreach( $_POST['user'] as $id ) {
+ if ( ! current_user_can( 'delete_user', $id ) )
+ continue;
+ wpmu_delete_user( $id );
+ $i++;
+ }
+
+ if ( $i == 1 )
+ $deletefunction = 'delete';
+ else
+ $deletefunction = 'all_delete';
+
+ wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), network_admin_url( 'users.php' ) ) );
+ exit();
+ break;
+
+ default:
+ // Let plugins use us as a post handler easily
+ do_action( 'network_admin_edit_' . $_GET['action'] );
+ wp_redirect( network_admin_url( 'index.php' ) );
+ exit();
+ break;
+}
+?>
diff --git a/wp-admin/network/index-extra.php b/wp-admin/network/index-extra.php
new file mode 100644
index 00000000..17ead786
--- /dev/null
+++ b/wp-admin/network/index-extra.php
@@ -0,0 +1,13 @@
+' . __('Until WordPress 3.0, running multiple sites required using WordPress MU instead of regular WordPress. In version 3.0, these applications have merged. If you are a former MU user, you should be aware of the following changes:') . '' .
+ '
' . __('Site Admin is now Super Admin (we highly encourage you to get yourself a cape!).') . '
' .
+ '
' . __('Blogs are now called Sites; Site is now called Network.') . '
' .
+ '
' . __('This screen provides the network administrator with links to the screens for Sites and Users to either create a new site or user, or to search existing users and sites, as well as Dashboard widgets. Those screens are also accessible through the left-hand navigation in the Network Admin section.') . '
' . __('Operational settings has fields for the network’s name and admin email.') . '
' .
+ '
' . __('Dashboard Site is an option to give a site to users who do not have a site on the system. Their default role is Subscriber, but that default can be changed. The Admin Notice Feed can provide a notice on all dashboards of the latest post via RSS or Atom, or provide no such notice if left blank.') . '
' .
+ '
' . __('Registration settings can disable/enable public signups. If you let others sign up for a site, install spam plugins. Spaces, not commas, should separate names banned as sites for this network.') . '
' .
+ '
' . __('New site settings are defaults applied when a new site is created in the network. These include welcome email for when a new site or user account is registered, and what᾿s put in the first post, page, comment, comment author, and comment URL.') . '
' .
+ '
' . __('Upload settings control the size of the uploaded files and the amount of available upload space for each site. You can change the default value for specific sites when you edit a particular site. Allowed file types are also listed (space separated only).') . '
' .
+ '
' . __('Checkboxes for media upload buttons set which are shown in the visual editor. If unchecked, a generic upload button is still visible; other media types can still be uploaded if on the allowed file types list.') . '
' .
+ '
' . __('Menu setting enables/disables the plugin menus from appearing for non super admins, so that only super admins, not site admins, have access to activate plugins.') . '
' .
+ '
' . __('Super admins can no longer be added on the Options screen. You must now go to the list of existing users on Super Admin > Users and click on Username or the Edit action link below that name. This goes to an Edit User page where you can check a box to grant super admin privileges.') . '
+
+
diff --git a/wp-admin/network/setup.php b/wp-admin/network/setup.php
new file mode 100644
index 00000000..e5d5880f
--- /dev/null
+++ b/wp-admin/network/setup.php
@@ -0,0 +1,16 @@
+' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '' .
+ '
' . __('Info - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '
' .
+ '
' . __('Users - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '
' .
+ '
' . sprintf( __('Themes - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . '
' .
+ '
' . __('Settings - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '
+
+
diff --git a/wp-admin/network/site-settings.php b/wp-admin/network/site-settings.php
new file mode 100644
index 00000000..b90bb76d
--- /dev/null
+++ b/wp-admin/network/site-settings.php
@@ -0,0 +1,150 @@
+' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '' .
+ '
' . __('Info - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '
' .
+ '
' . __('Users - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '
' .
+ '
' . sprintf( __('Themes - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . '
' .
+ '
' . __('Settings - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '
+
+
+' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '' .
+ '
' . __('Info - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '
' .
+ '
' . __('Users - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '
' .
+ '
' . sprintf( __('Themes - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . '
' .
+ '
' . __('Settings - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '
' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '
' .
+ '
' . __('Info - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '
' .
+ '
' . __('Users - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '
' .
+ '
' . sprintf( __('Themes - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . '
' .
+ '
' . __('Settings - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '
' . __('Add New takes you to the Add New Site screen. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '
' .
+ '
' . __('This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.') . '
' .
+ '
' . __('Hovering over each site reveals seven options (three for the primary site):') . '
' .
+ '
' . __('An Edit link to a separate Edit Site screen.') . '
' .
+ '
' . __('Dashboard leads to the Dashboard for that site.') . '
' .
+ '
' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '
' .
+ '
' . __('Delete which is a permanent action after the confirmation screens.') . '
' .
+ '
' . __('Visit to go to the frontend site live.') . '
' .
+ '
' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '
' .
+ '
' . __('Clicking on bold settings can re-sort this table. The upper right icons switch between list and excerpt views.') . '
' . __('This screen enables and disables the inclusion of themes available to choose in the Appearance menu for each site. It does not activate or deactivate which theme a site is currently using.') . '
' .
+ '
' . __('If the network admin disables a theme that is in use, it can still remain selected on that site. If another theme is chosen, the disabled theme will not appear in the site’s Appearance > Themes screen.') . '
' .
+ '
' . __('Themes can be enabled on a site by site basis by the network admin on the Edit Site screen you go to via the Edit action link on the Sites screen. Only network admins are able to install or edit themes.') . '
+
+
+
+' . __('Only use this screen once you have updated to a new version of WordPress through Dashboard > Updates. Clicking the Update Network button will step through each site in the network, five at a time, and make sure any database updates are applied.') . '' .
+ '
' . __('If a version update to core has not happened, clicking this button won’t affect anything.') . '
' .
+ '
' . __('If this process fails for any reason, users logging in to their sites will force the same update.') . '
";
+ $response = wp_remote_get( trailingslashit( $siteurl ) . "wp-admin/upgrade.php?step=upgrade_db", array( 'timeout' => 120, 'httpversion' => '1.1' ) );
+ if ( is_wp_error( $response ) )
+ wp_die( sprintf( __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: %2$s' ), $siteurl, $response->get_error_message() ) );
+ do_action( 'after_mu_upgrade', $response );
+ do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] );
+ }
+ echo "
";
+ ?>
+
+
+
+
+
diff --git a/wp-admin/network/user-edit.php b/wp-admin/network/user-edit.php
new file mode 100644
index 00000000..0b2cfd26
--- /dev/null
+++ b/wp-admin/network/user-edit.php
@@ -0,0 +1,16 @@
+' . __('Add User will set up a new user account on the network and send them an email with their username and password.') . '' .
+ '
' . __('Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.') . '
' . __('This table shows all users across the network and the sites to which they are assigned.') . '
' .
+ '
' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to his or her Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '
' .
+ '
' . __('You can also go to the user’s profile page by clicking on the individual username.') . '
' .
+ '
' . __('You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.') . '
' .
+ '
' . __('The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.') . '
' .
+ '
' . __('You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.') . '
' . __('This screen provides many options for controlling the management and display of comments and links to your posts/pages. So many, in fact, they won’t all fit here! :) Use the documentation link below to get information on what each discussion setting does.') . '
' .
'
' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '
'
);
@@ -60,7 +60,7 @@ include('./admin-header.php');
/>
-
+
@@ -141,7 +141,7 @@ printf( __('Comments should be displayed with the %s comments at the top of each
moderation queue. One word or IP per line. It will match inside words, so “press” will match “WordPress”.') ?>
-
+
@@ -150,7 +150,7 @@ printf( __('Comments should be displayed with the %s comments at the top of each
+
diff --git a/wp-admin/options-head.php b/wp-admin/options-head.php
index 965615fd..7f2cc74d 100644
--- a/wp-admin/options-head.php
+++ b/wp-admin/options-head.php
@@ -11,6 +11,11 @@
wp_reset_vars(array('action', 'standalone', 'option_group_id'));
+if ( isset( $_GET['updated'] ) && isset( $_GET['page'] ) ) {
+ // For backwards compat with plugins that don't use the Settings API and just set updated=1 in the redirect
+ add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
+}
+
settings_errors();
?>
\ No newline at end of file
diff --git a/wp-admin/options-media.php b/wp-admin/options-media.php
index 2e5d10d0..67c30ad4 100644
--- a/wp-admin/options-media.php
+++ b/wp-admin/options-media.php
@@ -18,7 +18,7 @@ $parent_file = 'options-general.php';
add_contextual_help($current_screen,
'
' . __('You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.') . '
' .
'
' . __('The Embed option allows you embed a video, image, or other media content into your content automatically by typing the URL (of the web page where the file lives) on its own line when you create your content.') . '
' .
- '
' . __('Uploading Options gives you folder and path choices for storing your files in your installation’s directory.') . '
' .
+ ( is_multisite() ? '' : '
' . __('Uploading Options gives you folder and path choices for storing your files in your installation’s directory.') . '
' ) .
'
' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '
' . __('The Optional fields let you customize the “category” and “tag” base names that will appear in archive URLs. For example, the page listing all posts in the “Uncategorized” category could be /topics/uncategorized instead of /category/uncategorized.') . '
' .
'
' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '
+
web.config file were writable, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your web.config file. Click in the field and press CTRL + a to select all. Then insert this rule inside of the /<configuration>/<system.webServer>/<rewrite>/<rules> element in web.config file.') ?>
-
+
web.config file writable for us to generate rewrite rules automatically, do not forget to revert the permissions after rule has been saved.') ?>
writable, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your web.config file. Create a new file, called web.config in the root directory of your site. Click in the field and press CTRL + a to select all. Then insert this code into the web.config file.') ?>
-
+
web.config file automatically, do not forget to revert the permissions after the file has been created.') ?>
@@ -278,7 +249,7 @@ $structures = array(
.htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.') ?>
' . __('When this setting is in effect a reminder is shown in the header of these administration screens that says, “Search Engines Blocked,” to remind you that your site is not being crawled.') . '
' .
'
' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '
+
diff --git a/wp-admin/options-reading.php b/wp-admin/options-reading.php
index 7cd4c463..7c8e1545 100644
--- a/wp-admin/options-reading.php
+++ b/wp-admin/options-reading.php
@@ -15,13 +15,39 @@ if ( ! current_user_can( 'manage_options' ) )
$title = __( 'Reading Settings' );
$parent_file = 'options-general.php';
+/**
+ * Display JavaScript on the page.
+ *
+ * @package WordPress
+ * @subpackage Reading_Settings_Screen
+ */
+function add_js() {
+?>
+
+' . __('This screen contains the settings that affect the display of your content.') . '' .
'
' . sprintf(__('You can choose what’s displayed on the front page of your site. It can be posts in reverse chronological order (classic blog), or a fixed/static page. To set a static home page, you first need to create two Pages. One will become the front page, and the other will be where your posts are displayed.'), 'post-new.php?post_type=page') . '
' .
'
' . __('You can also control the display of your content in RSS feeds, including the maximum numbers of posts to display, whether to show full text or a summary, and the character set encoding.') . '
' .
'
' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '
' . __('You can submit content in several different ways; this screen holds the settings for all of them. The top section controls the editor within these administration screens, while the rest control external publishing methods. For more information on any of these methods, use the documentation links below.') . '
' .
'
' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '
-
+
+
+
+
+
diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php
index 47437079..7efcecd3 100644
--- a/wp-admin/plugin-editor.php
+++ b/wp-admin/plugin-editor.php
@@ -9,6 +9,11 @@
/** WordPress Administration Bootstrap */
require_once('./admin.php');
+if ( is_multisite() && ! is_network_admin() ) {
+ wp_redirect( network_admin_url( 'plugin-editor.php' ) );
+ exit();
+}
+
if ( !current_user_can('edit_plugins') )
wp_die( __('You do not have sufficient permissions to edit plugins for this site.') );
@@ -67,9 +72,9 @@ case 'update':
wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide));
exit;
}
- wp_redirect("plugin-editor.php?file=$file&a=te&scrollto=$scrollto");
+ wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") );
} else {
- wp_redirect("plugin-editor.php?file=$file&scrollto=$scrollto");
+ wp_redirect( self_admin_url("plugin-editor.php?file=$file&scrollto=$scrollto") );
}
exit;
@@ -84,10 +89,10 @@ default:
if ( is_wp_error($error) )
wp_die( $error );
- if ( ! is_plugin_active($file) )
+ if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network($file) ) || ! is_plugin_active($file) )
activate_plugin($file, "plugin-editor.php?file=$file&phperror=1", ! empty( $_GET['networkwide'] ) ); // we'll override this later if the plugin can be included without fatal error
- wp_redirect("plugin-editor.php?file=$file&a=te&scrollto=$scrollto");
+ wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") );
exit;
}
@@ -111,13 +116,15 @@ default:
'
' . __('You can use the editor to make changes to any of your plugins’ individual PHP files. Be aware that if you make changes, plugins updates will overwrite your customizations.') . '
' .
'
' . __('Choose a plugin to edit from the menu in the upper right and click the Select button. Click once on any file name to load it in the editor, and make your changes. Don’t forget to save your changes (Update File) when you’re finished.') . '
' .
'
' . __('The Documentation menu below the editor lists the PHP functions recognized in the plugin file. Clicking Lookup takes you to a web page about that particular function.') . '
' .
- '
' . __('If you want to make changes but don’t want them to be overwritten when the plugin is updated, you may be ready to think about writing your own plugin. For information on how to edit a plugin or start from scratch, check out the links below.') . '
' .
+ '
' . __('If you want to make changes but don’t want them to be overwritten when the plugin is updated, you may be ready to think about writing your own plugin. For information on how to edit plugins, write your own from scratch, or just better understand their anatomy, check out the links below.') . '
' .
+ ( is_network_admin() ? '
' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '
' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '
' .
'
' . sprintf(__('You can find additional plugins for your site by using the Plugin Browser/Installer functionality or by browsing the WordPress Plugin Directory directly and installing new plugins manually. To manually install a plugin you generally just need to upload the plugin file into your /wp-content/plugins directory. Once a plugin has been installed, you can activate it here.'), 'plugin-install.php', 'http://wordpress.org/extend/plugins/') . '
' .
@@ -324,8 +338,9 @@ add_contextual_help($current_screen,
);
$title = __('Plugins');
+$parent_file = 'plugins.php';
-require_once('./admin-header.php');
+require_once(ABSPATH . 'wp-admin/admin-header.php');
$invalid = validate_active_plugins();
if ( !empty($invalid) )
@@ -335,15 +350,17 @@ if ( !empty($invalid) )
unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
else
$errmsg = __('Plugin could not be activated because it triggered a fatal error.');
?>
edit_posts capability to your user, in order to be authorized to post.
-You can also e-mail the admin to ask for a promotion.
-When you’re promoted, just reload this page and you’ll be able to blog. :)'), get_option('admin_email')); ?>
-
' . __('To add a new user to your site, fill in the form on this screen. If you’re not sure which role to assign, you can use the link below to review the different roles and their capabilities. Here is a basic overview of roles:') . '
' .
'
' .
@@ -127,7 +152,6 @@ add_contextual_help($current_screen,
wp_enqueue_script('wp-ajax-response');
wp_enqueue_script('user-profile');
-wp_enqueue_script('password-strength-meter');
require_once ('admin-header.php');
@@ -147,6 +171,12 @@ if ( isset($_GET['update']) ) {
case "addexisting":
$messages[] = __('That user is already a member of this site.');
break;
+ case "does_not_exist":
+ $messages[] = __('The requested user does not exist.');
+ break;
+ case "does_not_exist":
+ $messages[] = __('Please enter a valid email address.');
+ break;
}
} else {
if ( 'add' == $_GET['update'] )
@@ -156,7 +186,13 @@ if ( isset($_GET['update']) ) {
?>
-
+
+
@@ -185,32 +221,70 @@ if ( ! empty( $messages ) ) {
' . sprintf(__('Users can register themselves or you can manually create users here.'), site_url('wp-register.php')) . '';
- else
- echo '
' . sprintf(__('Users cannot currently register themselves, but you can manually create users here.'), admin_url('options-general.php#users_can_register')) . '
';
-} else {
- echo '
' . __( 'You can add new users to your site in two ways:' ) . '
' . __( 'Enter the username and email address of an existing user on this site.' ) . '
' . __( 'Enter the username and the email address of a person who is not already a member of this site. Choose the username carefully, it cannot be changed.' ) . '
';
- echo '
' . __( 'That person will be sent an email asking them to click a link confirming the invite. New users will then be sent an email with a randomly generated password and a login link.' ) . '
';
+ if ( !is_super_admin() ) {
+ _e( 'Enter the email address of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' );
+ $label = __('E-mail');
+ } else {
+ _e( 'Enter the email address or username of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' );
+ $label = __('E-mail or Username');
+ }
?>
-
diff --git a/wp-admin/user/index-extra.php b/wp-admin/user/index-extra.php
new file mode 100644
index 00000000..48812635
--- /dev/null
+++ b/wp-admin/user/index-extra.php
@@ -0,0 +1,12 @@
+
\ No newline at end of file
diff --git a/wp-admin/user/profile.php b/wp-admin/user/profile.php
new file mode 100644
index 00000000..4857a508
--- /dev/null
+++ b/wp-admin/user/profile.php
@@ -0,0 +1,12 @@
+get_pagenum();
$title = __('Users');
$parent_file = 'users.php';
+add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
+
// contextual help - choose Help on the top right of admin panel to preview this.
add_contextual_help($current_screen,
- '
' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options when they are logged in, based on their role.') . '
' .
+ '
' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.') . '
' .
'
' . __('You can customize the display of information on this screen as you can on other screens, by using the Screen Options tab and the on-screen filters.') . '
' .
'
' . __('To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.') . '
' . __('Widgets are independent sections of content that can be placed into any widgetized area provided by your theme (commonly called sidebars). To populate your sidebars/widget areas with individual widgets, drag and drop the title bars into the desired area. By default, only the first widget area is expanded. To populate additional widget areas, click on their title bars to expand them.') . '
-
' . __('Available Widgets section contains all the widgets you can choose from. Once you drag a widget into a sidebar, it will open to allow you to configure its settings. When you are happy with the widget settings, click the Save button and the widget will go live on your site. If you click Delete, it will remove the widget.') . '
+
' . __('The Available Widgets section contains all the widgets you can choose from. Once you drag a widget into a sidebar, it will open to allow you to configure its settings. When you are happy with the widget settings, click the Save button and the widget will go live on your site. If you click Delete, it will remove the widget.') . '
' . __('If you want to remove the widget but save its setting for possible future use, just drag it into the Inactive Widgets area. You can add them back anytime from there. This is especially helpful when you switch to a theme with fewer or different widget areas.') . '
' . __('Widgets may be used multiple times. You can give each widget a title, to display on your site, but it’s not required.') . '
' . __('Enabling Accessibility Mode, via Screen Options, allows you to use Add and Edit buttons instead of using drag and drop.') . '
' . __('Many themes show some sidebar widgets by default until you edit your sidebars, but they are not automatically displayed in your sidebar management tool. After you make your first widget change, you can re-add the default widgets by adding them from the Available Widgets area.') . '
-
+
-
-
-
-
+
diff --git a/wp-app.php b/wp-app.php
index f21c3c06..6de52882 100644
--- a/wp-app.php
+++ b/wp-app.php
@@ -387,7 +387,7 @@ EOD;
* @since 2.2.0
*/
function create_post() {
- global $blog_id, $user_ID;
+ global $user_ID;
$this->get_accepted_content_type($this->atom_content_types);
$parser = new AtomParser();
@@ -419,7 +419,7 @@ EOD;
if ( !current_user_can($cap) )
$this->auth_required(__('Sorry, you do not have the right to edit/publish new posts.'));
- $blog_ID = (int ) $blog_id;
+ $blog_ID = get_current_blog_id();
$post_status = ($publish) ? 'publish' : 'draft';
$post_author = (int) $user_ID;
$post_title = $entry->title[1];
@@ -712,7 +712,7 @@ EOD;
$filetype = wp_check_filetype($location);
if ( !isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']) )
- $this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
+ $this->internal_error(__('Error occurred while accessing post metadata for file location.'));
// delete file
@unlink($location);
@@ -749,7 +749,7 @@ EOD;
$filetype = wp_check_filetype($location);
if ( !isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']) )
- $this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
+ $this->internal_error(__('Error occurred while accessing post metadata for file location.'));
status_header('200');
header('Content-Type: ' . $entry['post_mime_type']);
@@ -801,7 +801,7 @@ EOD;
$location = "{$upload_dir['basedir']}/{$location}";
if (!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']))
- $this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
+ $this->internal_error(__('Error occurred while accessing post metadata for file location.'));
$fp = fopen("php://input", "rb");
$localfp = fopen($location, "w+");
diff --git a/wp-atom.php b/wp-atom.php
index f7221f3f..a83ac7db 100644
--- a/wp-atom.php
+++ b/wp-atom.php
@@ -8,5 +8,5 @@
require( './wp-load.php' );
wp_redirect( get_bloginfo( 'atom_url' ), 301 );
-
-?>
\ No newline at end of file
+exit;
+?>
diff --git a/wp-comments-post.php b/wp-comments-post.php
index e2e12f76..9c17a355 100644
--- a/wp-comments-post.php
+++ b/wp-comments-post.php
@@ -101,5 +101,5 @@ $location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POS
$location = apply_filters('comment_post_redirect', $location, $comment);
wp_redirect($location);
-
+exit;
?>
diff --git a/wp-commentsrss2.php b/wp-commentsrss2.php
index 1c146b14..280766ed 100644
--- a/wp-commentsrss2.php
+++ b/wp-commentsrss2.php
@@ -8,5 +8,5 @@
require( './wp-load.php' );
wp_redirect( get_bloginfo( 'comments_rss2_url' ), 301 );
-
-?>
\ No newline at end of file
+exit;
+?>
diff --git a/wp-config-sample.php b/wp-config-sample.php
index 69cd75e5..e47e1b5a 100644
--- a/wp-config-sample.php
+++ b/wp-config-sample.php
@@ -64,12 +64,12 @@ $table_prefix = 'wp_';
/**
* WordPress Localized Language, defaults to English.
*
- * Change this to localize WordPress. A corresponding MO file for the chosen
+ * Change this to localize WordPress. A corresponding MO file for the chosen
* language must be installed to wp-content/languages. For example, install
- * de.mo to wp-content/languages and set WPLANG to 'de' to enable German
+ * de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
* language support.
*/
-define ('WPLANG', '');
+define('WPLANG', '');
/**
* For developers: WordPress debugging mode.
diff --git a/wp-content/plugins/akismet/admin.php b/wp-content/plugins/akismet/admin.php
index a1954039..91cedb29 100644
--- a/wp-content/plugins/akismet/admin.php
+++ b/wp-content/plugins/akismet/admin.php
@@ -7,11 +7,11 @@ function akismet_admin_init() {
global $wp_version;
// all admin functions are disabled in old versions
- if ( version_compare( $wp_version, '3.0', '<' ) ) {
+ if ( !function_exists('is_multisite') && version_compare( $wp_version, '3.0', '<' ) ) {
function akismet_version_warning() {
echo "
-
".sprintf(__('Akismet %s required WordPress 3.0 or higher.'), AKISMET_VERSION) ." ".sprintf(__('Please upgrade WordPress to a current version, or downgrade to version 2.4 of the Akismet plugin.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/'). "
+
".sprintf(__('Akismet %s requires WordPress 3.0 or higher.'), AKISMET_VERSION) ." ".sprintf(__('Please upgrade WordPress to a current version, or downgrade to version 2.4 of the Akismet plugin.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/'). "
";
}
add_action('admin_notices', 'akismet_version_warning');
@@ -24,7 +24,11 @@ function akismet_admin_init() {
else
$hook = 'dashboard_page_akismet-stats-display';
add_action('admin_head-'.$hook, 'akismet_stats_script');
- add_meta_box('akismet-status', __('Akismet Status'), 'akismet_comment_status_meta_box', 'comment', 'normal');
+ add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal');
+ wp_register_style('akismet.css', AKISMET_PLUGIN_URL . 'akismet.css');
+ wp_enqueue_style('akismet.css');
+ wp_register_script('akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'));
+ wp_enqueue_script('akismet.js');
}
add_action('admin_init', 'akismet_admin_init');
@@ -34,9 +38,18 @@ $akismet_nonce = 'akismet-update-key';
function akismet_config_page() {
if ( function_exists('add_submenu_page') )
add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
+}
+
+function akismet_plugin_action_links( $links, $file ) {
+ if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) {
+ $links[] = ''.__('Settings').'';
+ }
+ return $links;
}
+add_filter( 'plugin_action_links', 'akismet_plugin_action_links', 10, 2 );
+
function akismet_conf() {
global $akismet_nonce, $wpcom_api_key;
@@ -46,11 +59,15 @@ function akismet_conf() {
check_admin_referer( $akismet_nonce );
$key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] );
+ $home_url = parse_url( get_bloginfo('url') );
if ( empty($key) ) {
$key_status = 'empty';
$ms[] = 'new_key_empty';
delete_option('wordpress_api_key');
+ } elseif ( empty($home_url['host']) ) {
+ $key_status = 'empty';
+ $ms[] = 'bad_home_url';
} else {
$key_status = akismet_verify_key( $key );
}
@@ -68,6 +85,12 @@ function akismet_conf() {
update_option( 'akismet_discard_month', 'true' );
else
update_option( 'akismet_discard_month', 'false' );
+
+ if ( isset( $_POST['akismet_show_user_comments_approved'] ) )
+ update_option( 'akismet_show_user_comments_approved', 'true' );
+ else
+ update_option( 'akismet_show_user_comments_approved', 'false' );
+
} elseif ( isset($_POST['check']) ) {
akismet_get_server_connectivity(0);
}
@@ -97,19 +120,24 @@ function akismet_conf() {
$messages = array(
'new_key_empty' => array('color' => 'aa0', 'text' => __('Your key has been cleared.')),
- 'new_key_valid' => array('color' => '2d2', 'text' => __('Your key has been verified. Happy blogging!')),
- 'new_key_invalid' => array('color' => 'd22', 'text' => __('The key you entered is invalid. Please double-check it.')),
- 'new_key_failed' => array('color' => 'd22', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')),
- 'no_connection' => array('color' => 'd22', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
+ 'new_key_valid' => array('color' => '4AB915', 'text' => __('Your key has been verified. Happy blogging!')),
+ 'new_key_invalid' => array('color' => '888', 'text' => __('The key you entered is invalid. Please double-check it.')),
+ 'new_key_failed' => array('color' => '888', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')),
+ 'no_connection' => array('color' => '888', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (Get your key.)'), 'http://akismet.com/get/')),
- 'key_valid' => array('color' => '2d2', 'text' => __('This key is valid.')),
- 'key_failed' => array('color' => 'aa0', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.')));
+ 'key_valid' => array('color' => '4AB915', 'text' => __('This key is valid.')),
+ 'key_failed' => array('color' => 'aa0', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.')),
+ 'bad_home_url' => array('color' => '888', 'text' => sprintf( __('Your WordPress home URL %s is invalid. Please fix the home option.'), esc_html( get_bloginfo('url') ), admin_url('options.php#home') ) ),
+ );
?>
+
+
Sign up success! Please check your email for your Akismet API Key and enter it below.' ); ?>
+
@@ -126,7 +154,8 @@ function akismet_conf() {
-
/>
+
/>
+
/>
@@ -136,7 +165,7 @@ function akismet_conf() {
-
+
fsockopen or gethostbynamel functions. Akismet cannot work correctly until this is fixed. Please contact your web host or firewall administrator and give them this information about Akismet\'s system requirements.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?>
0 ) { ?>
-
+
Akismet cannot work correctly until this is fixed. Please contact your web host or firewall administrator and give them this information about Akismet and firewalls.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?>
-
+
-
+
Akismet cannot work correctly until this is fixed. Please contact your web host or firewall administrator and give them this information about Akismet and firewalls.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?>
Click here to confirm that Akismet.com is up.'), 'http://status.automattic.com/9931/136079/Akismet-API', 'http://status.automattic.com/9931/136079/Akismet-API' ); ?>
@@ -206,11 +236,8 @@ function akismet_stats_script() {
?>
-
'.sprintf(__('Akismet has protected your site from %3$s spam comments.'), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'
';
-}
-add_action('activity_box_end', 'akismet_stats');
-
function akismet_get_key() {
global $wpcom_api_key;
if ( !empty($wpcom_api_key) )
@@ -316,104 +81,11 @@ function akismet_verify_key( $key, $ip = null ) {
return $response[1];
}
-// Check connectivity between the WordPress blog and Akismet's servers.
-// Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect).
-function akismet_check_server_connectivity() {
- global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
-
- $test_host = 'rest.akismet.com';
-
- // Some web hosts may disable one or both functions
- if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') )
- return array();
-
- $ips = gethostbynamel($test_host);
- if ( !$ips || !is_array($ips) || !count($ips) )
- return array();
-
- $servers = array();
- foreach ( $ips as $ip ) {
- $response = akismet_verify_key( akismet_get_key(), $ip );
- // even if the key is invalid, at least we know we have connectivity
- if ( $response == 'valid' || $response == 'invalid' )
- $servers[$ip] = true;
- else
- $servers[$ip] = false;
- }
-
- return $servers;
-}
-
-// Check the server connectivity and store the results in an option.
-// Cached results will be used if not older than the specified timeout in seconds; use $cache_timeout = 0 to force an update.
-// Returns the same associative array as akismet_check_server_connectivity()
-function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
- $servers = get_option('akismet_available_servers');
- if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false )
- return $servers;
-
- // There's a race condition here but the effect is harmless.
- $servers = akismet_check_server_connectivity();
- update_option('akismet_available_servers', $servers);
- update_option('akismet_connectivity_time', time());
- return $servers;
-}
-
-// Returns true if server connectivity was OK at the last check, false if there was a problem that needs to be fixed.
-function akismet_server_connectivity_ok() {
- // skip the check on WPMU because the status page is hidden
- global $wpcom_api_key;
- if ( $wpcom_api_key )
+// if we're in debug or test modes, use a reduced service level so as not to polute training or stats data
+function akismet_test_mode() {
+ if ( defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE )
return true;
- $servers = akismet_get_server_connectivity();
- return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
-}
-
-function akismet_admin_warnings() {
- global $wpcom_api_key;
- if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) {
- function akismet_warning() {
- echo "
-
".__('Akismet is almost ready.')." ".sprintf(__('You must enter your Akismet API key for it to work.'), "plugins.php?page=akismet-key-config")."
".__('Akismet has detected a problem.')." ".sprintf(__('A server or network problem is preventing Akismet from working correctly. Click here for more information about how to fix the problem.'), "plugins.php?page=akismet-key-config")."
- ";
- }
- add_action('admin_notices', 'akismet_warning');
- return;
- }
-}
-
-function akismet_get_host($host) {
- // if all servers are accessible, just return the host name.
- // if not, return an IP that was known to be accessible at the last check.
- if ( akismet_server_connectivity_ok() ) {
- return $host;
- } else {
- $ips = akismet_get_server_connectivity();
- // a firewall may be blocking access to some Akismet IPs
- if ( count($ips) > 0 && count(array_filter($ips)) < count($ips) ) {
- // use DNS to get current IPs, but exclude any known to be unreachable
- $dns = (array)gethostbynamel( rtrim($host, '.') . '.' );
- $dns = array_filter($dns);
- foreach ( $dns as $ip ) {
- if ( array_key_exists( $ip, $ips ) && empty( $ips[$ip] ) )
- unset($dns[$ip]);
- }
- // return a random IP from those available
- if ( count($dns) )
- return $dns[ array_rand($dns) ];
-
- }
- }
- // if all else fails try the host name
- return $host;
+ return false;
}
// return a comma-separated list of role names for the given user
@@ -428,42 +100,76 @@ function akismet_get_user_roles($user_id ) {
if ( isset($comment_user->roles) )
$roles = join(',', $comment_user->roles);
}
-
+
+ if ( is_multisite() && is_super_admin( $user_id ) ) {
+ if ( empty( $roles ) ) {
+ $roles = 'super_admin';
+ } else {
+ $comment_user->roles[] = 'super_admin';
+ $roles = join( ',', $comment_user->roles );
+ }
+ }
+
return $roles;
}
// Returns array with headers in $response[0] and body in $response[1]
function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
global $wp_version;
-
- $akismet_version = constant('AKISMET_VERSION');
-
- $http_request = "POST $path HTTP/1.0\r\n";
- $http_request .= "Host: $host\r\n";
- $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n";
- $http_request .= "Content-Length: " . strlen($request) . "\r\n";
- $http_request .= "User-Agent: WordPress/$wp_version | Akismet/$akismet_version\r\n";
- $http_request .= "\r\n";
- $http_request .= $request;
-
+
+ $akismet_ua = "WordPress/{$wp_version} | ";
+ $akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' );
+
+ $content_length = strlen( $request );
+
$http_host = $host;
- // use a specific IP if provided - needed by akismet_check_server_connectivity()
- if ( $ip && long2ip(ip2long($ip)) ) {
+ // use a specific IP if provided
+ // needed by akismet_check_server_connectivity()
+ if ( $ip && long2ip( ip2long( $ip ) ) ) {
$http_host = $ip;
} else {
- $http_host = akismet_get_host($host);
+ $http_host = $host;
}
-
- $response = '';
- if( false != ( $fs = @fsockopen($http_host, $port, $errno, $errstr, 10) ) ) {
- fwrite($fs, $http_request);
-
- while ( !feof($fs) )
- $response .= fgets($fs, 1160); // One TCP-IP packet
- fclose($fs);
- $response = explode("\r\n\r\n", $response, 2);
+
+ // use the WP HTTP class if it is available
+ if ( function_exists( 'wp_remote_post' ) ) {
+ $http_args = array(
+ 'body' => $request,
+ 'headers' => array(
+ 'Content-Type' => 'application/x-www-form-urlencoded; ' .
+ 'charset=' . get_option( 'blog_charset' ),
+ 'Host' => $host,
+ 'User-Agent' => $akismet_ua
+ ),
+ 'httpversion' => '1.0',
+ 'timeout' => 15
+ );
+ $akismet_url = "http://{$http_host}{$path}";
+ $response = wp_remote_post( $akismet_url, $http_args );
+ if ( is_wp_error( $response ) )
+ return '';
+
+ return array( $response['headers'], $response['body'] );
+ } else {
+ $http_request = "POST $path HTTP/1.0\r\n";
+ $http_request .= "Host: $host\r\n";
+ $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
+ $http_request .= "Content-Length: {$content_length}\r\n";
+ $http_request .= "User-Agent: {$akismet_ua}\r\n";
+ $http_request .= "\r\n";
+ $http_request .= $request;
+
+ $response = '';
+ if( false != ( $fs = @fsockopen( $http_host, $port, $errno, $errstr, 10 ) ) ) {
+ fwrite( $fs, $http_request );
+
+ while ( !feof( $fs ) )
+ $response .= fgets( $fs, 1160 ); // One TCP-IP packet
+ fclose( $fs );
+ $response = explode( "\r\n\r\n", $response, 2 );
+ }
+ return $response;
}
- return $response;
}
// filter handler used to return a spam result to pre_comment_approved
@@ -471,11 +177,122 @@ function akismet_result_spam( $approved ) {
// bump the counter here instead of when the filter is added to reduce the possibility of overcounting
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
+ // this is a one-shot deal
+ remove_filter( 'pre_comment_approved', 'akismet_result_spam' );
return 'spam';
}
+function akismet_result_hold( $approved ) {
+ // once only
+ remove_filter( 'pre_comment_approved', 'akismet_result_hold' );
+ return '0';
+}
+
+// how many approved comments does this author have?
+function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
+ global $wpdb;
+
+ if ( !empty($user_id) )
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = 1", $user_id ) );
+
+ if ( !empty($comment_author_email) )
+ return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_author_email = %s AND comment_author = %s AND comment_author_url = %s AND comment_approved = 1", $comment_author_email, $comment_author, $comment_author_url ) );
+
+ return 0;
+}
+
+function akismet_microtime() {
+ $mtime = explode( ' ', microtime() );
+ return $mtime[1] + $mtime[0];
+}
+
+// log an event for a given comment, storing it in comment_meta
+function akismet_update_comment_history( $comment_id, $message, $event=null ) {
+ global $current_user;
+
+ // failsafe for old WP versions
+ if ( !function_exists('add_comment_meta') )
+ return false;
+
+ $user = '';
+ if ( is_object($current_user) && isset($current_user->user_login) )
+ $user = $current_user->user_login;
+
+ $event = array(
+ 'time' => akismet_microtime(),
+ 'message' => $message,
+ 'event' => $event,
+ 'user' => $user,
+ );
+
+ // $unique = false so as to allow multiple values per comment
+ $r = add_comment_meta( $comment_id, 'akismet_history', $event, false );
+}
+
+// get the full comment history for a given comment, as an array in reverse chronological order
+function akismet_get_comment_history( $comment_id ) {
+
+ // failsafe for old WP versions
+ if ( !function_exists('add_comment_meta') )
+ return false;
+
+ $history = get_comment_meta( $comment_id, 'akismet_history', false );
+ usort( $history, 'akismet_cmp_time' );
+ return $history;
+}
+
+function akismet_cmp_time( $a, $b ) {
+ return $a['time'] > $b['time'] ? -1 : 1;
+}
+
+// this fires on wp_insert_comment. we can't update comment_meta when akismet_auto_check_comment() runs
+// because we don't know the comment ID at that point.
+function akismet_auto_check_update_meta( $id, $comment ) {
+ global $akismet_last_comment;
+
+ // failsafe for old WP versions
+ if ( !function_exists('add_comment_meta') )
+ return false;
+
+ // wp_insert_comment() might be called in other contexts, so make sure this is the same comment
+ // as was checked by akismet_auto_check_comment
+ if ( is_object($comment) && !empty($akismet_last_comment) && is_array($akismet_last_comment) ) {
+ if ( intval($akismet_last_comment['comment_post_ID']) == intval($comment->comment_post_ID)
+ && $akismet_last_comment['comment_author'] == $comment->comment_author
+ && $akismet_last_comment['comment_author_email'] == $comment->comment_author_email ) {
+ // normal result: true or false
+ if ( $akismet_last_comment['akismet_result'] == 'true' ) {
+ update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' );
+ akismet_update_comment_history( $comment->comment_ID, __('Akismet caught this comment as spam'), 'check-spam' );
+ if ( $comment->comment_approved != 'spam' )
+ akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed'.$comment->comment_approved );
+ } elseif ( $akismet_last_comment['akismet_result'] == 'false' ) {
+ update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
+ akismet_update_comment_history( $comment->comment_ID, __('Akismet cleared this comment'), 'check-ham' );
+ if ( $comment->comment_approved == 'spam' ) {
+ if ( wp_blacklist_check($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent) )
+ akismet_update_comment_history( $comment->comment_ID, __('Comment was caught by wp_blacklist_check'), 'wp-blacklisted' );
+ else
+ akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed-'.$comment->comment_approved );
+ }
+ // abnormal result: error
+ } else {
+ update_comment_meta( $comment->comment_ID, 'akismet_error', time() );
+ akismet_update_comment_history( $comment->comment_ID, sprintf( __('Akismet was unable to check this comment (response: %s), will automatically retry again later.'), $akismet_last_comment['akismet_result']), 'check-error' );
+ }
+
+ // record the complete original data as submitted for checking
+ if ( isset($akismet_last_comment['comment_as_submitted']) )
+ update_comment_meta( $comment->comment_ID, 'akismet_as_submitted', $akismet_last_comment['comment_as_submitted'] );
+ }
+ }
+}
+
+add_action( 'wp_insert_comment', 'akismet_auto_check_update_meta', 10, 2 );
+
+
function akismet_auto_check_comment( $commentdata ) {
- global $akismet_api_host, $akismet_api_port;
+ global $akismet_api_host, $akismet_api_port, $akismet_last_comment;
$comment = $commentdata;
$comment['user_ip'] = $_SERVER['REMOTE_ADDR'];
@@ -488,17 +305,41 @@ function akismet_auto_check_comment( $commentdata ) {
$comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
+ $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
+ $comment['akismet_comment_nonce'] = 'inactive';
+ if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
+ $comment['akismet_comment_nonce'] = 'failed';
+ if ( isset( $_POST['akismet_comment_nonce'] ) && wp_verify_nonce( $_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'] ) )
+ $comment['akismet_comment_nonce'] = 'passed';
+
+ // comment reply in wp-admin
+ if ( isset( $_POST['_ajax_nonce-replyto-comment'] ) && check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ) )
+ $comment['akismet_comment_nonce'] = 'passed';
+
+ }
+
+ if ( akismet_test_mode() )
+ $comment['is_test'] = 'true';
+
+ foreach ($_POST as $key => $value ) {
+ if ( is_string($value) )
+ $comment["POST_{$key}"] = $value;
+ }
+
$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
- foreach ( $_SERVER as $key => $value )
+ foreach ( $_SERVER as $key => $value ) {
if ( !in_array( $key, $ignore ) && is_string($value) )
$comment["$key"] = $value;
else
$comment["$key"] = '';
+ }
$query_string = '';
foreach ( $comment as $key => $data )
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
+
+ $commentdata['comment_as_submitted'] = $comment;
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
$commentdata['akismet_result'] = $response[1];
@@ -517,10 +358,17 @@ function akismet_auto_check_comment( $commentdata ) {
// akismet_result_spam() won't be called so bump the counter here
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
- die;
+ wp_redirect( $_SERVER['HTTP_REFERER'] );
+ die();
}
}
+ // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
+ if ( 'true' != $response[1] && 'false' != $response[1] ) {
+ add_filter('pre_comment_approved', 'akismet_result_hold');
+ wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
+ }
+
if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
// WP 2.1+: delete old comments daily
if ( !wp_next_scheduled('akismet_scheduled_delete') )
@@ -529,18 +377,25 @@ function akismet_auto_check_comment( $commentdata ) {
// WP 2.0: run this one time in ten
akismet_delete_old();
}
+ $akismet_last_comment = $commentdata;
return $commentdata;
}
+add_action('preprocess_comment', 'akismet_auto_check_comment', 1);
+
function akismet_delete_old() {
global $wpdb;
$now_gmt = current_time('mysql', 1);
$comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");
if ( empty( $comment_ids ) )
return;
+
+ $comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );
do_action( 'delete_comment', $comment_ids );
- $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( " . implode( ', ', $comment_ids ) . " )");
+ $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( $comma_comment_ids )");
+ $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id IN ( $comma_comment_ids )");
+ clean_comment_cache( $comment_ids );
$n = mt_rand(1, 5000);
if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number
$wpdb->query("OPTIMIZE TABLE $wpdb->comments");
@@ -549,341 +404,109 @@ function akismet_delete_old() {
add_action('akismet_scheduled_delete', 'akismet_delete_old');
-function akismet_submit_nonspam_comment ( $comment_id ) {
- global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
- $comment_id = (int) $comment_id;
+function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
+ global $wpdb, $akismet_api_host, $akismet_api_port;
- $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
- if ( !$comment ) // it was deleted
- return;
- $comment->blog = get_option('home');
- $comment->blog_lang = get_locale();
- $comment->blog_charset = get_option('blog_charset');
- $comment->permalink = get_permalink($comment->comment_post_ID);
- if ( is_object($current_user) ) {
- $comment->reporter = $current_user->user_login;
- }
- if ( is_object($current_site) ) {
- $comment->site_domain = $current_site->domain;
- }
-
- $comment->user_role = '';
- if ( isset( $comment->user_ID ) )
- $comment->user_role = akismet_get_user_roles($comment->user_ID);
-
- $query_string = '';
- foreach ( $comment as $key => $data )
- $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
-
- $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-ham", $akismet_api_port);
- do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
-}
-
-function akismet_submit_spam_comment ( $comment_id ) {
- global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
- $comment_id = (int) $comment_id;
-
- $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
- if ( !$comment ) // it was deleted
- return;
- if ( 'spam' != $comment->comment_approved )
- return;
- $comment->blog = get_option('home');
- $comment->blog_lang = get_locale();
- $comment->blog_charset = get_option('blog_charset');
- $comment->permalink = get_permalink($comment->comment_post_ID);
- if ( is_object($current_user) ) {
- $comment->reporter = $current_user->user_login;
- }
- if ( is_object($current_site) ) {
- $comment->site_domain = $current_site->domain;
- }
-
- $comment->user_role = '';
- if ( !isset( $comment->user_id ) )
- $comment->user_role = akismet_get_user_roles($comment->user_ID);
+ $id = (int) $id;
+ $c = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID = '$id'", ARRAY_A );
+ if ( !$c )
+ return;
- $query_string = '';
- foreach ( $comment as $key => $data )
- $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
-
- $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port);
- do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
-}
+ $c['user_ip'] = $c['comment_author_IP'];
+ $c['user_agent'] = $c['comment_agent'];
+ $c['referrer'] = '';
+ $c['blog'] = get_option('home');
+ $c['blog_lang'] = get_locale();
+ $c['blog_charset'] = get_option('blog_charset');
+ $c['permalink'] = get_permalink($c['comment_post_ID']);
+ $id = $c['comment_ID'];
+ if ( akismet_test_mode() )
+ $c['is_test'] = 'true';
+ $c['recheck_reason'] = $recheck_reason;
-add_action('preprocess_comment', 'akismet_auto_check_comment', 1);
+ $query_string = '';
+ foreach ( $c as $key => $data )
+ $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
-// For old versions of WP only
-function akismet_set_comment_status( $comment_id, $status ) {
- if ( $status == 'spam' ) {
- akismet_submit_spam_comment( $comment_id );
- } elseif ( $status == 'approve' ) {
- akismet_submit_nonspam_comment( $comment_id );
- }
+ $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
+ return $response[1];
}
-// For WP 2.7+
-function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
- if ( $new_status == $old_status )
- return;
-
- if ( $new_status == 'spam' ) {
- akismet_submit_spam_comment( $comment->comment_ID );
- } elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
- akismet_submit_nonspam_comment( $comment->comment_ID );
- }
-}
-
-function akismet_spamtoham( $comment ) { akismet_submit_nonspam_comment( $comment->comment_ID ); }
-
-if ( function_exists( 'wp_transition_comment_status' ) ) {
- add_action( 'transition_comment_status', 'akismet_transition_comment_status', 10, 3 );
-} else {
- add_action('wp_set_comment_status', 'akismet_set_comment_status', 10, 2);
- add_action('edit_comment', 'akismet_submit_spam_comment');
- add_filter( 'comment_spam_to_approved', 'akismet_spamtoham' );
- add_filter( 'comment_spam_to_unapproved', 'akismet_spamtoham' );
-}
-// Total spam in queue
-// get_option( 'akismet_spam_count' ) is the total caught ever
-function akismet_spam_count( $type = false ) {
+function akismet_cron_recheck() {
global $wpdb;
- if ( !$type ) { // total
- $count = wp_cache_get( 'akismet_spam_count', 'widget' );
- if ( false === $count ) {
- if ( function_exists('wp_count_comments') ) {
- $count = wp_count_comments();
- $count = $count->spam;
- } else {
- $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'");
+ delete_option('akismet_available_servers');
+
+ $comment_errors = $wpdb->get_col( "
+ SELECT comment_id
+ FROM {$wpdb->prefix}commentmeta
+ WHERE meta_key = 'akismet_error'
+ LIMIT 100
+ " );
+
+ foreach ( (array) $comment_errors as $comment_id ) {
+ // if the comment no longer exists, remove the meta entry from the queue to avoid getting stuck
+ if ( !get_comment( $comment_id ) ) {
+ delete_comment_meta( $comment_id, 'akismet_error' );
+ continue;
+ }
+
+ add_comment_meta( $comment_id, 'akismet_rechecking', true );
+ $status = akismet_check_db_comment( $comment_id, 'retry' );
+
+ $msg = '';
+ if ( $status == 'true' ) {
+ $msg = __( 'Akismet caught this comment as spam during an automatic retry.' );
+ } elseif ( $status == 'false' ) {
+ $msg = __( 'Akismet cleared this comment during an automatic retry.' );
+ }
+
+ // If we got back a legit response then update the comment history
+ // other wise just bail now and try again later. No point in
+ // re-trying all the comments once we hit one failure.
+ if ( !empty( $msg ) ) {
+ delete_comment_meta( $comment_id, 'akismet_error' );
+ akismet_update_comment_history( $comment_id, $msg, 'cron-retry' );
+ update_comment_meta( $comment_id, 'akismet_result', $status );
+ // make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.
+ $comment = get_comment( $comment_id );
+ if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
+ if ( $status == 'true' ) {
+ wp_spam_comment( $comment_id );
+ } elseif ( $status == 'false' ) {
+ // comment is good, but it's still in the pending queue. depending on the moderation settings
+ // we may need to change it to approved.
+ if ( check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type) )
+ wp_set_comment_status( $comment_id, 1 );
+ }
}
- wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );
+ } else {
+ delete_comment_meta( $comment_id, 'akismet_rechecking' );
+ wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
+ return;
}
- return $count;
- } elseif ( 'comments' == $type || 'comment' == $type ) { // comments
- $type = '';
- } else { // pingback, trackback, ...
- $type = $wpdb->escape( $type );
- }
-
- return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'");
-}
-
-
-// WP 2.5+
-function akismet_rightnow() {
- global $submenu, $wp_db_version;
-
- // clean_url was deprecated in WP 3.0
- $esc_url = 'clean_url';
- if ( function_exists( 'esc_url' ) )
- $esc_url = 'esc_url';
-
- if ( 8645 < $wp_db_version ) // 2.7
- $link = 'edit-comments.php?comment_status=spam';
- elseif ( isset( $submenu['edit-comments.php'] ) )
- $link = 'edit-comments.php?page=akismet-admin';
- else
- $link = 'edit.php?page=akismet-admin';
-
- if ( $count = get_option('akismet_spam_count') ) {
- $intro = sprintf( __ngettext(
- 'Akismet has protected your site from %2$s spam comment already,',
- 'Akismet has protected your site from %2$s spam comments already,',
- $count
- ), 'http://akismet.com/', number_format_i18n( $count ) );
- } else {
- $intro = sprintf( __('Akismet blocks spam from getting to your blog,'), 'http://akismet.com/' );
}
-
- if ( $queue_count = akismet_spam_count() ) {
- $queue_text = sprintf( __ngettext(
- 'and there\'s %1$s comment in your spam queue right now.',
- 'and there are %1$s comments in your spam queue right now.',
- $queue_count
- ), number_format_i18n( $queue_count ), clean_url($link) );
- } else {
- $queue_text = sprintf( __( "but there's nothing in your spam queue at the moment." ), $esc_url($link) );
- }
-
- // _c was deprecated in WP 2.9.0
- if ( function_exists( '_x' ) )
- $text = sprintf( _x( '%1$s %2$s', 'akismet_rightnow' ), $intro, $queue_text );
- else
- $text = sprintf( _c( '%1$s %2$s|akismet_rightnow' ), $intro, $queue_text );
-
- echo "
-
diff --git a/wp-content/plugins/akismet/readme.txt b/wp-content/plugins/akismet/readme.txt
index db8234fc..fbd3513b 100644
--- a/wp-content/plugins/akismet/readme.txt
+++ b/wp-content/plugins/akismet/readme.txt
@@ -1,10 +1,10 @@
=== Akismet ===
-Contributors: matt, ryan, andy, mdawaffe, tellyworth, automattic
+Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, automattic
Tags: akismet, comments, spam
-Requires at least: 2.0
-Tested up to: 3.0
-Stable tag: 2.4.0
-License: GPLv2
+Requires at least: 3.0
+Tested up to: 3.1
+Stable tag: 2.5.3
+License: GPLv2 or later
Akismet checks your comments against the Akismet web service to see if they look like spam or not.
@@ -13,11 +13,15 @@ Akismet checks your comments against the Akismet web service to see if they look
Akismet checks your comments against the Akismet web service to see if they look like spam or not and lets you
review the spam it catches under your blog's "Comments" admin screen.
-Want to show off how much spam Akismet has caught for you? Just put `` in your template.
+Major new features in Akismet 2.5 include:
-See also: [WP Stats plugin](http://wordpress.org/extend/plugins/stats/).
+* A comment status history, so you can easily see which comments were caught or cleared by Akismet, and which were spammed or unspammed by a moderator
+* Links are highlighted in the comment body, to reveal hidden or misleading links
+* If your web host is unable to reach Akismet's servers, the plugin will automatically retry when your connection is back up
+* Moderators can see the number of approved comments for each user
+* Spam and Unspam reports now include more information, to help improve accuracy
-PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it.
+PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. Keys are free for personal blogs, with paid subscriptions available for businesses and commercial sites.
== Installation ==
@@ -27,6 +31,53 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
== Changelog ==
+= 2.5.3 =
+* Specify the license is GPL v2 or later
+* Fix a bug that could result in orphaned commentmeta entries
+* Include hotfix for WordPress 3.0.5 filter issue
+
+= 2.5.2 =
+
+* Properly format the comment count for author counts
+* Look for super admins on multisite installs when looking up user roles
+* Increase the HTTP request timeout
+* Removed padding for author approved count
+* Fix typo in function name
+* Set Akismet stats iframe height to fixed 2500px. Better to have one tall scroll bar than two side by side.
+
+= 2.5.1 =
+
+* Fix a bug that caused the "Auto delete" option to fail to discard comments correctly
+* Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce
+* Fixed padding bug in "author" column of posts screen
+* Added margin-top to "cleared by ..." badges on dashboard
+* Fix possible error when calling akismet_cron_recheck()
+* Fix more PHP warnings
+* Clean up XHTML warnings for comment nonce
+* Fix for possible condition where scheduled comment re-checks could get stuck
+* Clean up the comment meta details after deleting a comment
+* Only show the status badge if the comment status has been changed by someone/something other than Akismet
+* Show a 'History' link in the row-actions
+* Translation fixes
+* Reduced font-size on author name
+* Moved "flagged by..." notification to top right corner of comment container and removed heavy styling
+* Hid "flagged by..." notification while on dashboard
+
+= 2.5.0 =
+
+* Track comment actions under 'Akismet Status' on the edit comment screen
+* Fix a few remaining deprecated function calls ( props Mike Glendinning )
+* Use HTTPS for the stats IFRAME when wp-admin is using HTTPS
+* Use the WordPress HTTP class if available
+* Move the admin UI code to a separate file, only loaded when needed
+* Add cron retry feature, to replace the old connectivity check
+* Display Akismet status badge beside each comment
+* Record history for each comment, and display it on the edit page
+* Record the complete comment as originally submitted in comment_meta, to use when reporting spam and ham
+* Highlight links in comment content
+* New option, "Show the number of comments you've approved beside each comment author."
+* New option, "Use a nonce on the comment form."
+
= 2.4.0 =
* Spell out that the license is GPLv2
diff --git a/wp-content/plugins/akismet/widget.php b/wp-content/plugins/akismet/widget.php
new file mode 100644
index 00000000..e9a3f626
--- /dev/null
+++ b/wp-content/plugins/akismet/widget.php
@@ -0,0 +1,90 @@
+
+
+
+
', $count ), number_format_i18n( $count ) );
+}
diff --git a/wp-content/plugins/hello.php b/wp-content/plugins/hello.php
index 2877f083..d2287e24 100644
--- a/wp-content/plugins/hello.php
+++ b/wp-content/plugins/hello.php
@@ -1,14 +1,14 @@
Hello, Dolly in the upper right of your admin screen on every page.
Author: Matt Mullenweg
-Version: 1.5.1
+Version: 1.6
Author URI: http://ma.tt/
*/
@@ -44,10 +44,10 @@ Dolly'll never go away
Dolly'll never go away again";
// Here we split it into lines
- $lyrics = explode("\n", $lyrics);
+ $lyrics = explode( "\n", $lyrics );
// And then randomly choose a line
- return wptexturize( $lyrics[ mt_rand(0, count($lyrics) - 1) ] );
+ return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
}
// This just echoes the chosen line, we'll position it later
@@ -56,28 +56,27 @@ function hello_dolly() {
echo "
$chosen
";
}
-// Now we set that function up to execute when the admin_footer action is called
-add_action('admin_footer', 'hello_dolly');
+// Now we set that function up to execute when the admin_notices action is called
+add_action( 'admin_notices', 'hello_dolly' );
// We need some CSS to position the paragraph
function dolly_css() {
- // This makes sure that the posinioning is also good for right-to-left languages
- $x = ( is_rtl() ) ? 'left' : 'right';
+ // This makes sure that the positioning is also good for right-to-left languages
+ $x = is_rtl() ? 'left' : 'right';
echo "
";
}
-add_action('admin_head', 'dolly_css');
+add_action( 'admin_head', 'dolly_css' );
?>
diff --git a/wp-content/themes/twentyten/archive.php b/wp-content/themes/twentyten/archive.php
index 52baaa70..0707e186 100644
--- a/wp-content/themes/twentyten/archive.php
+++ b/wp-content/themes/twentyten/archive.php
@@ -32,9 +32,9 @@ get_header(); ?>
%s', 'twentyten' ), get_the_date() ); ?>
- %s', 'twentyten' ), get_the_date('F Y') ); ?>
+ %s', 'twentyten' ), get_the_date( 'F Y' ) ); ?>
- %s', 'twentyten' ), get_the_date('Y') ); ?>
+ %s', 'twentyten' ), get_the_date( 'Y' ) ); ?>
@@ -49,7 +49,7 @@ get_header(); ?>
/* Run the loop for the archives page to output the posts.
* If you want to overload this in a child theme then include a file
- * called loop-archives.php and that will be used instead.
+ * called loop-archive.php and that will be used instead.
*/
get_template_part( 'loop', 'archive' );
?>
diff --git a/wp-content/themes/twentyten/attachment.php b/wp-content/themes/twentyten/attachment.php
index f805bcdb..5b35936e 100644
--- a/wp-content/themes/twentyten/attachment.php
+++ b/wp-content/themes/twentyten/attachment.php
@@ -12,105 +12,13 @@ get_header(); ?>
diff --git a/wp-content/themes/twentyten/functions.php b/wp-content/themes/twentyten/functions.php
index d7a127a2..36f55066 100644
--- a/wp-content/themes/twentyten/functions.php
+++ b/wp-content/themes/twentyten/functions.php
@@ -77,6 +77,9 @@ function twentyten_setup() {
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
+ // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
+ add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
+
// This theme uses post thumbnails
add_theme_support( 'post-thumbnails' );
@@ -101,9 +104,12 @@ function twentyten_setup() {
add_custom_background();
// Your changeable header business starts here
- define( 'HEADER_TEXTCOLOR', '' );
+ if ( ! defined( 'HEADER_TEXTCOLOR' ) )
+ define( 'HEADER_TEXTCOLOR', '' );
+
// No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
- define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
+ if ( ! defined( 'HEADER_IMAGE' ) )
+ define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
// The height and width of your custom header. You can hook into the theme's own filters to change these values.
// Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
@@ -116,7 +122,8 @@ function twentyten_setup() {
set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
// Don't support text inside the header image.
- define( 'NO_HEADER_TEXT', true );
+ if ( ! defined( 'NO_HEADER_TEXT' ) )
+ define( 'NO_HEADER_TEXT', true );
// Add a way for the custom header to be styled in the admin panel that controls
// custom headers. See twentyten_admin_header_style(), below.
@@ -275,15 +282,30 @@ add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
/**
* Remove inline styles printed when the gallery shortcode is used.
*
- * Galleries are styled by the theme in Twenty Ten's style.css.
+ * Galleries are styled by the theme in Twenty Ten's style.css. This is just
+ * a simple filter call that tells WordPress to not use the default styles.
+ *
+ * @since Twenty Ten 1.2
+ */
+add_filter( 'use_default_gallery_style', '__return_false' );
+
+/**
+ * Deprecated way to remove inline styles printed when the gallery shortcode is used.
+ *
+ * This function is no longer needed or used. Use the use_default_gallery_style
+ * filter instead, as seen above.
*
* @since Twenty Ten 1.0
+ * @deprecated Deprecated in Twenty Ten 1.2 for WordPress 3.1
+ *
* @return string The gallery style filter, with the styles themselves removed.
*/
function twentyten_remove_gallery_css( $css ) {
return preg_replace( "##s", '', $css );
}
-add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
+// Backwards compatibility with WordPress 3.0.
+if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) )
+ add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
if ( ! function_exists( 'twentyten_comment' ) ) :
/**
@@ -308,7 +330,7 @@ function twentyten_comment( $comment, $args, $depth ) {
says:', 'twentyten' ), sprintf( '%s', get_comment_author_link() ) ); ?>
comment_approved == '0' ) : ?>
-
+
@@ -332,7 +354,7 @@ function twentyten_comment( $comment, $args, $depth ) {
case 'trackback' :
?>
-
+
widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
+ add_filter( 'show_recent_comments_widget_style', '__return_false' );
}
add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
if ( ! function_exists( 'twentyten_posted_on' ) ) :
/**
- * Prints HTML with meta information for the current post—date/time and author.
+ * Prints HTML with meta information for the current post-date/time and author.
*
* @since Twenty Ten 1.0
*/
diff --git a/wp-content/themes/twentyten/header.php b/wp-content/themes/twentyten/header.php
index fa4b7279..54971c93 100644
--- a/wp-content/themes/twentyten/header.php
+++ b/wp-content/themes/twentyten/header.php
@@ -67,13 +67,13 @@
ID ) &&
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
$image[1] >= HEADER_IMAGE_WIDTH ) :
// Houston, we have a new header image!
- echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
- else : ?>
+ echo get_the_post_thumbnail( $post->ID );
+ elseif ( get_header_image() ) : ?>
diff --git a/wp-content/themes/twentyten/index.php b/wp-content/themes/twentyten/index.php
index 9f7d240c..7bc3fd46 100644
--- a/wp-content/themes/twentyten/index.php
+++ b/wp-content/themes/twentyten/index.php
@@ -4,7 +4,7 @@
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
- * It is used to display a page when nothing more specific matches a query.
+ * It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
diff --git a/wp-content/themes/twentyten/languages/twentyten.pot b/wp-content/themes/twentyten/languages/twentyten.pot
index 1febb300..403d43e4 100644
--- a/wp-content/themes/twentyten/languages/twentyten.pot
+++ b/wp-content/themes/twentyten/languages/twentyten.pot
@@ -2,9 +2,9 @@
# This file is distributed under the same license as the Twenty Ten package.
msgid ""
msgstr ""
-"Project-Id-Version: Twenty Ten 1.1\n"
+"Project-Id-Version: Twenty Ten 1.2\n"
"Report-Msgid-Bugs-To: http://wordpress.org/tag/twentyten\n"
-"POT-Creation-Date: 2011-01-01 21:26:51+00:00\n"
+"POT-Creation-Date: 2011-02-22 08:27:25+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -12,17 +12,58 @@ msgstr ""
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
-#. #-#-#-#-# twentyten.pot (Twenty Ten 1.1) #-#-#-#-#
+#: loop-attachment.php:21
+msgid "Return to %s"
+msgstr ""
+
+#: loop-attachment.php:23
+msgid "← %s"
+msgstr ""
+
+#: loop-attachment.php:32
+msgid "By %2$s"
+msgstr ""
+
+#: loop-attachment.php:36 functions.php:476
+msgid "View all posts by %s"
+msgstr ""
+
+#: loop-attachment.php:43
+msgid "Published %2$s"
+msgstr ""
+
+#: loop-attachment.php:53
+msgid "Full size is %s pixels"
+msgstr ""
+
+#: loop-attachment.php:56
+msgid "Link to full-size image"
+msgstr ""
+
+#: loop-attachment.php:63 loop-attachment.php:111 loop.php:100 loop.php:123
+#: loop.php:165 loop-page.php:30 loop-single.php:56
+msgid "Edit"
+msgstr ""
+
+#: loop-attachment.php:104 loop.php:115 loop.php:143 functions.php:248
+msgid "Continue reading →"
+msgstr ""
+
+#: loop-attachment.php:105 loop.php:144 loop-page.php:29 loop-single.php:34
+msgid "Pages:"
+msgstr ""
+
+#. #-#-#-#-# twentyten.pot (Twenty Ten 1.2) #-#-#-#-#
#. Theme URI of the plugin/theme
#: footer.php:33
msgid "http://wordpress.org/"
msgstr ""
-#: footer.php:34
+#: footer.php:33
msgid "Semantic Personal Publishing Platform"
msgstr ""
-#: footer.php:35
+#: footer.php:33
msgid "Proudly powered by %s."
msgstr ""
@@ -75,11 +116,11 @@ msgid ""
"will help."
msgstr ""
-#: loop.php:25 loop.php:173
+#: loop.php:25 loop.php:178
msgid "← Older posts"
msgstr ""
-#: loop.php:26 loop.php:174
+#: loop.php:26 loop.php:179
msgid "Newer posts →"
msgstr ""
@@ -89,193 +130,181 @@ msgid ""
"searching will help find a related post."
msgstr ""
-#: loop.php:60 loop.php:92
+#: loop.php:60 loop.php:95 loop.php:96
msgctxt "gallery category slug"
msgid "gallery"
msgstr ""
-#: loop.php:62 loop.php:83 loop.php:126
+#: loop.php:62 loop.php:83 loop.php:131
msgid "Permalink to %s"
msgstr ""
#: loop.php:82
-msgid "This gallery contains %2$s photos."
-msgstr ""
+msgid "This gallery contains %2$s photo."
+msgid_plural "This gallery contains %2$s photos."
+msgstr[0] ""
+msgstr[1] ""
-#: loop.php:92
-msgid "View posts in the Gallery category"
+#: loop.php:93
+msgid "View Galleries"
msgstr ""
-#: loop.php:92
+#: loop.php:93 loop.php:96
msgid "More Galleries"
msgstr ""
-#: loop.php:94 loop.php:117 loop.php:159
+#: loop.php:96
+msgid "View posts in the Gallery category"
+msgstr ""
+
+#: loop.php:99 loop.php:122 loop.php:164
msgid "Leave a comment"
msgstr ""
-#: loop.php:94 loop.php:117 loop.php:159
+#: loop.php:99 loop.php:122 loop.php:164
msgid "1 Comment"
msgstr ""
-#: loop.php:94 loop.php:117 loop.php:159
+#: loop.php:99 loop.php:122 loop.php:164
msgid "% Comments"
msgstr ""
-#: loop.php:95 loop.php:118 loop.php:160 page.php:32 attachment.php:60
-#: attachment.php:107 onecolumn-page.php:27 single.php:53
-msgid "Edit"
-msgstr ""
-
-#: loop.php:101
+#: loop.php:106
msgctxt "asides category slug"
msgid "asides"
msgstr ""
-#: loop.php:110 loop.php:138 functions.php:241 attachment.php:100
-msgid "Continue reading →"
-msgstr ""
-
-#: loop.php:139 page.php:31 attachment.php:101 onecolumn-page.php:26
-#: single.php:31
-msgid "Pages:"
-msgstr ""
-
-#: loop.php:146
+#: loop.php:151
msgid "Posted in %2$s"
msgstr ""
-#: loop.php:155
+#: loop.php:160
msgid "Tagged %2$s"
msgstr ""
-#: functions.php:97
+#: functions.php:100
msgid "Primary Navigation"
msgstr ""
-#: functions.php:133
+#: functions.php:140
msgid "Berries"
msgstr ""
-#: functions.php:139
+#: functions.php:146
msgid "Cherry Blossoms"
msgstr ""
-#: functions.php:145
+#: functions.php:152
msgid "Concave"
msgstr ""
-#: functions.php:151
+#: functions.php:158
msgid "Fern"
msgstr ""
-#: functions.php:157
+#: functions.php:164
msgid "Forest Floor"
msgstr ""
-#: functions.php:163
+#: functions.php:170
msgid "Inkwell"
msgstr ""
-#: functions.php:169
+#: functions.php:176
msgid "Path"
msgstr ""
-#: functions.php:175
+#: functions.php:182
msgid "Sunset"
msgstr ""
-#: functions.php:308
+#: functions.php:330
msgid "%s says:"
msgstr ""
-#: functions.php:311
+#: functions.php:333
msgid "Your comment is awaiting moderation."
msgstr ""
-#: functions.php:318
+#: functions.php:340
msgid "%1$s at %2$s"
msgstr ""
-#: functions.php:318 functions.php:335
+#: functions.php:340 functions.php:357
msgid "(Edit)"
msgstr ""
-#: functions.php:335
+#: functions.php:357
msgid "Pingback:"
msgstr ""
-#: functions.php:354
+#: functions.php:376
msgid "Primary Widget Area"
msgstr ""
-#: functions.php:356
+#: functions.php:378
msgid "The primary widget area"
msgstr ""
-#: functions.php:365
+#: functions.php:387
msgid "Secondary Widget Area"
msgstr ""
-#: functions.php:367
+#: functions.php:389
msgid "The secondary widget area"
msgstr ""
-#: functions.php:376
+#: functions.php:398
msgid "First Footer Widget Area"
msgstr ""
-#: functions.php:378
+#: functions.php:400
msgid "The first footer widget area"
msgstr ""
-#: functions.php:387
+#: functions.php:409
msgid "Second Footer Widget Area"
msgstr ""
-#: functions.php:389
+#: functions.php:411
msgid "The second footer widget area"
msgstr ""
-#: functions.php:398
+#: functions.php:420
msgid "Third Footer Widget Area"
msgstr ""
-#: functions.php:400
+#: functions.php:422
msgid "The third footer widget area"
msgstr ""
-#: functions.php:409
+#: functions.php:431
msgid "Fourth Footer Widget Area"
msgstr ""
-#: functions.php:411
+#: functions.php:433
msgid "The fourth footer widget area"
msgstr ""
-#: functions.php:442
+#: functions.php:467
msgid ""
"Posted on %2$s by"
"span> %3$s"
msgstr ""
-#: functions.php:451 attachment.php:33
-msgid "View all posts by %s"
-msgstr ""
-
-#: functions.php:468
+#: functions.php:493
msgid ""
"This entry was posted in %1$s and tagged %2$s. Bookmark the permalink."
msgstr ""
-#: functions.php:470
+#: functions.php:495
msgid ""
"This entry was posted in %1$s. Bookmark the permalink."
msgstr ""
-#: functions.php:472
+#: functions.php:497
msgid ""
"Bookmark the permalink."
@@ -293,34 +322,10 @@ msgstr ""
msgid "Author Archives: %s"
msgstr ""
-#: author.php:37 single.php:40
+#: author.php:37 loop-single.php:43
msgid "About %s"
msgstr ""
-#: attachment.php:18
-msgid "Return to %s"
-msgstr ""
-
-#: attachment.php:20
-msgid "← %s"
-msgstr ""
-
-#: attachment.php:29
-msgid "By %2$s"
-msgstr ""
-
-#: attachment.php:40
-msgid "Published %2$s"
-msgstr ""
-
-#: attachment.php:50
-msgid "Full size is %s pixels"
-msgstr ""
-
-#: attachment.php:53
-msgid "Link to full-size image"
-msgstr ""
-
#: search.php:16
msgid "Search Results for: %s"
msgstr ""
@@ -335,6 +340,20 @@ msgid ""
"different keywords."
msgstr ""
+#: loop-single.php:21 loop-single.php:61
+msgctxt "Previous post link"
+msgid "←"
+msgstr ""
+
+#: loop-single.php:22 loop-single.php:62
+msgctxt "Next post link"
+msgid "→"
+msgstr ""
+
+#: loop-single.php:47
+msgid "View all posts by %s →"
+msgstr ""
+
#: archive.php:33
msgid "Daily Archives: %s"
msgstr ""
@@ -351,20 +370,6 @@ msgstr ""
msgid "Blog Archives"
msgstr ""
-#: single.php:18 single.php:58
-msgctxt "Previous post link"
-msgid "←"
-msgstr ""
-
-#: single.php:19 single.php:59
-msgctxt "Next post link"
-msgid "→"
-msgstr ""
-
-#: single.php:44
-msgid "View all posts by %s →"
-msgstr ""
-
#. Theme Name of the plugin/theme
msgid "Twenty Ten"
msgstr ""
@@ -389,5 +394,5 @@ msgstr ""
msgid ""
"black, blue, white, two-columns, fixed-width, custom-header, custom-"
"background, threaded-comments, sticky-post, translation-ready, microformats, "
-"rtl-language-support, editor-style"
+"rtl-language-support, editor-style, custom-menu"
msgstr ""
diff --git a/wp-content/themes/twentyten/loop-attachment.php b/wp-content/themes/twentyten/loop-attachment.php
new file mode 100644
index 00000000..20794fba
--- /dev/null
+++ b/wp-content/themes/twentyten/loop-attachment.php
@@ -0,0 +1,117 @@
+
+
+
+
+ post_parent ) ) : ?>
+
' : ', ' );
+ if ( $optioncount )
+ $link .= ' ('. $posts . ')';
+
+ $return .= $link;
+ $return .= ( 'list' == $style ) ? '' : ', ';
}
- $return = trim($return, ', ');
+ $return = rtrim($return, ', ');
- if ( ! $echo )
+ if ( !$echo )
return $return;
+
echo $return;
}
diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php
index 641ae3b4..8b0fe487 100644
--- a/wp-includes/bookmark.php
+++ b/wp-includes/bookmark.php
@@ -7,12 +7,12 @@
*/
/**
- * Retrieve Bookmark data based on ID
+ * Retrieve Bookmark data
*
* @since 2.1.0
* @uses $wpdb Database Object
*
- * @param int $bookmark_id
+ * @param mixed $bookmark
* @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant
* @param string $filter Optional, default is 'raw'.
* @return array|object Type returned depends on $output value.
@@ -334,11 +334,10 @@ function sanitize_bookmark_field($field, $value, $bookmark_id, $context) {
return $value;
if ( 'edit' == $context ) {
- $format_to_edit = array('link_notes');
$value = apply_filters("edit_$field", $value, $bookmark_id);
- if ( in_array($field, $format_to_edit) ) {
- $value = format_to_edit($value);
+ if ( 'link_notes' == $field ) {
+ $value = esc_html( $value ); // textarea_escaped
} else {
$value = esc_attr($value);
}
diff --git a/wp-includes/cache.php b/wp-includes/cache.php
index 62438662..895c4316 100644
--- a/wp-includes/cache.php
+++ b/wp-includes/cache.php
@@ -110,7 +110,7 @@ function wp_cache_init() {
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::replace()
*
- * @param int|string $id What to call the contents in the cache
+ * @param int|string $key What to call the contents in the cache
* @param mixed $data The contents to store in the cache
* @param string $flag Where to group the cache contents
* @param int $expire When to expire the cache contents
@@ -129,7 +129,7 @@ function wp_cache_replace($key, $data, $flag = '', $expire = 0) {
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::set()
*
- * @param int|string $id What to call the contents in the cache
+ * @param int|string $key What to call the contents in the cache
* @param mixed $data The contents to store in the cache
* @param string $flag Where to group the cache contents
* @param int $expire When to expire the cache contents
@@ -171,8 +171,6 @@ function wp_cache_add_non_persistent_groups( $groups ) {
* this function instructs the backend to reset those keys and perform any cleanup since blog or site IDs have changed since cache init.
*
* @since 2.6.0
- *
- * @param string|array $groups A group or an array of groups to add
*/
function wp_cache_reset() {
global $wp_object_cache;
@@ -451,15 +449,11 @@ class WP_Object_Cache {
echo "Cache Hits: {$this->cache_hits} ";
echo "Cache Misses: {$this->cache_misses} ";
echo "";
-
+ echo '
term_id;
+ if ( !empty($current_category) ) {
+ $_current_category = get_term( $current_category, $category->taxonomy );
+ if ( $category->term_id == $current_category )
+ $class .= ' current-cat';
+ elseif ( $category->term_id == $_current_category->parent )
+ $class .= ' current-cat-parent';
+ }
+ $output .= ' class="' . $class . '"';
+ $output .= ">$link\n";
+ } else {
+ $output .= "\t$link \n";
+ }
+ }
+
+ /**
+ * @see Walker::end_el()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $page Not used.
+ * @param int $depth Depth of category. Not used.
+ * @param array $args Only uses 'list' for whether should append to output.
+ */
+ function end_el(&$output, $page, $depth, $args) {
+ if ( 'list' != $args['style'] )
+ return;
+
+ $output .= "
\n";
+ }
+
+}
+
+/**
+ * Create HTML dropdown list of Categories.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ * @uses Walker
+ */
+class Walker_CategoryDropdown extends Walker {
+ /**
+ * @see Walker::$tree_type
+ * @since 2.1.0
+ * @var string
+ */
+ var $tree_type = 'category';
+
+ /**
+ * @see Walker::$db_fields
+ * @since 2.1.0
+ * @todo Decouple this
+ * @var array
+ */
+ var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
+
+ /**
+ * @see Walker::start_el()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $category Category data object.
+ * @param int $depth Depth of category. Used for padding.
+ * @param array $args Uses 'selected', 'show_count', and 'show_last_update' keys, if they exist.
+ */
+ function start_el(&$output, $category, $depth, $args) {
+ $pad = str_repeat(' ', $depth * 3);
+
+ $cat_name = apply_filters('list_cats', $category->name, $category);
+ $output .= "\t\n";
+ }
+}
+
//
// Tags
//
@@ -785,28 +970,21 @@ function walk_category_dropdown_tree() {
* Retrieve the link to the tag.
*
* @since 2.3.0
- * @uses apply_filters() Calls 'tag_link' with tag link and tag ID as parameters.
+ * @see get_term_link()
*
- * @param int $tag_id Tag (term) ID.
- * @return string
+ * @param int|object $tag Tag ID or object.
+ * @return string Link on success, empty string if tag does not exist.
*/
-function get_tag_link( $tag_id ) {
- global $wp_rewrite;
- $taglink = $wp_rewrite->get_tag_permastruct();
+function get_tag_link( $tag ) {
+ if ( ! is_object( $tag ) )
+ $tag = (int) $tag;
+
+ $tag = get_term_link( $tag, 'post_tag' );
- $tag = &get_term( $tag_id, 'post_tag' );
if ( is_wp_error( $tag ) )
- return $tag;
- $slug = $tag->slug;
+ return '';
- if ( empty( $taglink ) ) {
- $file = get_option( 'home' ) . '/';
- $taglink = $file . '?tag=' . $slug;
- } else {
- $taglink = str_replace( '%tag%', $slug, $taglink );
- $taglink = get_option( 'home' ) . user_trailingslashit( $taglink, 'category' );
- }
- return apply_filters( 'tag_link', $taglink, $tag_id );
+ return $tag;
}
/**
@@ -875,8 +1053,7 @@ function tag_description( $tag = 0 ) {
*/
function term_description( $term = 0, $taxonomy = 'post_tag' ) {
if ( !$term && ( is_tax() || is_tag() || is_category() ) ) {
- global $wp_query;
- $term = $wp_query->get_queried_object();
+ $term = get_queried_object();
$taxonomy = $term->taxonomy;
$term = $term->term_id;
}
@@ -908,8 +1085,12 @@ function get_the_terms( $id = 0, $taxonomy ) {
}
$terms = get_object_term_cache( $id, $taxonomy );
- if ( false === $terms )
+ if ( false === $terms ) {
$terms = wp_get_object_terms( $id, $taxonomy );
+ wp_cache_add($id, $terms, $taxonomy . '_relationships');
+ }
+
+ $terms = apply_filters( 'get_the_terms', $terms, $id, $taxonomy );
if ( empty( $terms ) )
return false;
@@ -955,14 +1136,14 @@ function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after
*
* @since 2.5.0
*
- * @param int $id Term ID.
+ * @param int $id Post ID.
* @param string $taxonomy Taxonomy name.
* @param string $before Optional. Before list.
* @param string $sep Optional. Separate items using this.
* @param string $after Optional. After list.
* @return null|bool False on WordPress error. Returns null when displaying.
*/
-function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
+function the_terms( $id = 0, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
$term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
if ( is_wp_error( $term_list ) )
@@ -971,6 +1152,20 @@ function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
echo apply_filters('the_terms', $term_list, $taxonomy, $before, $sep, $after);
}
+
+/**
+ * Check if the current post has any of given category.
+ *
+ * @since 3.1.0
+ *
+ * @param string|int|array $tag Optional. The category name/term_id/slug or array of them to check for.
+ * @param int|object $post Optional. Post to check instead of the current post.
+ * @return bool True if the current post has any of the given categories (or any category, if no category specified).
+ */
+function has_category( $category = '', $post = null ) {
+ return has_term( $category, 'category', $post );
+}
+
/**
* Check if the current post has any of given tags.
*
@@ -984,26 +1179,39 @@ function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
*
* @since 2.6.0
*
- * @uses is_object_in_term()
- *
* @param string|int|array $tag Optional. The tag name/term_id/slug or array of them to check for.
- * @param int|post object Optional. Post to check instead of the current post. @since 2.7.0
- * @return bool True if the current post has any of the the given tags (or any tag, if no tag specified).
+ * @param int|object $post Optional. Post to check instead of the current post. (since 2.7.0)
+ * @return bool True if the current post has any of the given tags (or any tag, if no tag specified).
*/
-function has_tag( $tag = '', $_post = null ) {
- if ( $_post ) {
- $_post = get_post( $_post );
- } else {
- $_post =& $GLOBALS['post'];
- }
+function has_tag( $tag = '', $post = null ) {
+ return has_term( $tag, 'post_tag', $post );
+}
- if ( !$_post )
+/**
+ * Check if the current post has any of given terms.
+ *
+ * The given terms are checked against the post's terms' term_ids, names and slugs.
+ * Terms given as integers will only be checked against the post's terms' term_ids.
+ * If no terms are given, determines if post has any terms.
+ *
+ * @since 3.1.0
+ *
+ * @param string|int|array $term Optional. The term name/term_id/slug or array of them to check for.
+ * @param string $taxonomy Taxonomy name
+ * @param int|object $post Optional. Post to check instead of the current post.
+ * @return bool True if the current post has any of the given tags (or any tag, if no tag specified).
+ */
+function has_term( $term = '', $taxonomy = '', $post = null ) {
+ $post = get_post($post);
+
+ if ( !$post )
return false;
- $r = is_object_in_term( $_post->ID, 'post_tag', $tag );
+ $r = is_object_in_term( $post->ID, $taxonomy, $term );
if ( is_wp_error( $r ) )
return false;
+
return $r;
}
-?>
\ No newline at end of file
+?>
diff --git a/wp-includes/category.php b/wp-includes/category.php
index 1f665185..4d022774 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -305,22 +305,6 @@ function &get_tag( $tag, $output = OBJECT, $filter = 'raw' ) {
/* Cache */
-/**
- * Update the categories cache.
- *
- * This function does not appear to be used anymore or does not appear to be
- * needed. It might be a legacy function left over from when there was a need
- * for updating the category cache.
- *
- * @since 1.5.0
- *
- * @return bool Always return True
- */
-function update_category_cache() {
- return true;
-}
-
-
/**
* Remove the category cache data based on ID.
*
diff --git a/wp-includes/class-IXR.php b/wp-includes/class-IXR.php
index 49f80b0c..9d89f0c5 100644
--- a/wp-includes/class-IXR.php
+++ b/wp-includes/class-IXR.php
@@ -1,16 +1,42 @@
data = $data;
if (!$type) {
$type = $this->calculateType();
}
$this->type = $type;
if ($type == 'struct') {
- /* Turn all the values in the array in to new IXR_Value objects */
+ // Turn all the values in the array in to new IXR_Value objects
foreach ($this->data as $key => $value) {
$this->data[$key] = new IXR_Value($value);
}
@@ -42,7 +69,8 @@ class IXR_Value {
}
}
- function calculateType() {
+ function calculateType()
+ {
if ($this->data === true || $this->data === false) {
return 'boolean';
}
@@ -52,6 +80,7 @@ class IXR_Value {
if (is_double($this->data)) {
return 'double';
}
+
// Deal with IXR object types base64 and date
if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
return 'date';
@@ -59,16 +88,17 @@ class IXR_Value {
if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
return 'base64';
}
+
// If it is a normal PHP object convert it in to a struct
if (is_object($this->data)) {
-
$this->data = get_object_vars($this->data);
return 'struct';
}
if (!is_array($this->data)) {
return 'string';
}
- /* We have an array - is it an array or a struct ? */
+
+ // We have an array - is it an array or a struct?
if ($this->isStruct($this->data)) {
return 'struct';
} else {
@@ -76,8 +106,9 @@ class IXR_Value {
}
}
- function getXml() {
- /* Return XML for this value */
+ function getXml()
+ {
+ // Return XML for this value
switch ($this->type) {
case 'boolean':
return ''.(($this->data) ? '1' : '0').'';
@@ -117,8 +148,14 @@ class IXR_Value {
return false;
}
- function isStruct($array) {
- /* Nasty function to check if an array is a struct or not */
+ /**
+ * Checks whether or not the supplied array is a struct or not
+ *
+ * @param unknown_type $array
+ * @return boolean
+ */
+ function isStruct($array)
+ {
$expected = 0;
foreach ($array as $key => $value) {
if ((string)$key != (string)$expected) {
@@ -131,18 +168,21 @@ class IXR_Value {
}
/**
- * IXR_Message
+ * IXR_MESSAGE
*
* @package IXR
* @since 1.5
+ *
*/
-class IXR_Message {
+class IXR_Message
+{
var $message;
var $messageType; // methodCall / methodResponse / fault
var $faultCode;
var $faultString;
var $methodName;
var $params;
+
// Current variable stacks
var $_arraystructs = array(); // The stack used to keep track of the current array/struct
var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
@@ -153,44 +193,55 @@ class IXR_Message {
var $_currentTagContents;
// The XML parser
var $_parser;
- function IXR_Message (&$message) {
- $this->message = &$message;
- }
- function parse() {
- // first remove the XML declaration
- // this method avoids the RAM usage of preg_replace on very large messages
- $header = preg_replace( '/<\?xml.*?\?'.'>/', '', substr( $this->message, 0, 100 ), 1 );
- $this->message = substr_replace($this->message, $header, 0, 100);
+
+ function IXR_Message($message)
+ {
+ $this->message =& $message;
+ }
+
+ function parse()
+ {
+ // first remove the XML declaration
+ // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
+ $header = preg_replace( '/<\?xml.*?\?'.'>/', '', substr($this->message, 0, 100), 1);
+ $this->message = substr_replace($this->message, $header, 0, 100);
if (trim($this->message) == '') {
return false;
- }
+ }
$this->_parser = xml_parser_create();
// Set XML parser to take the case of tags in to account
xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
// Set XML parser callback functions
xml_set_object($this->_parser, $this);
xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
- xml_set_character_data_handler($this->_parser, 'cdata');
- $chunk_size = 262144; // 256Kb, parse in chunks to avoid the RAM usage on very large messages
- do {
- if ( strlen($this->message) <= $chunk_size )
- $final=true;
- $part = substr( $this->message, 0, $chunk_size );
- $this->message = substr( $this->message, $chunk_size );
- if ( !xml_parse( $this->_parser, $part, $final ) )
- return false;
- if ( $final )
- break;
- } while ( true );
- xml_parser_free($this->_parser);
+ xml_set_character_data_handler($this->_parser, 'cdata');
+ $chunk_size = 262144; // 256Kb, parse in chunks to avoid the RAM usage on very large messages
+ $final = false;
+ do {
+ if (strlen($this->message) <= $chunk_size) {
+ $final = true;
+ }
+ $part = substr($this->message, 0, $chunk_size);
+ $this->message = substr($this->message, $chunk_size);
+ if (!xml_parse($this->_parser, $part, $final)) {
+ return false;
+ }
+ if ($final) {
+ break;
+ }
+ } while (true);
+ xml_parser_free($this->_parser);
+
// Grab the error messages, if any
if ($this->messageType == 'fault') {
$this->faultCode = $this->params[0]['faultCode'];
$this->faultString = $this->params[0]['faultString'];
- }
+ }
return true;
}
- function tag_open($parser, $tag, $attr) {
+
+ function tag_open($parser, $tag, $attr)
+ {
$this->_currentTagContents = '';
$this->currentTag = $tag;
switch($tag) {
@@ -199,7 +250,7 @@ class IXR_Message {
case 'fault':
$this->messageType = $tag;
break;
- /* Deal with stacks of arrays and structs */
+ /* Deal with stacks of arrays and structs */
case 'data': // data is to all intents and puposes more interesting than array
$this->_arraystructstypes[] = 'array';
$this->_arraystructs[] = array();
@@ -210,28 +261,31 @@ class IXR_Message {
break;
}
}
- function cdata($parser, $cdata) {
+
+ function cdata($parser, $cdata)
+ {
$this->_currentTagContents .= $cdata;
}
- function tag_close($parser, $tag) {
+
+ function tag_close($parser, $tag)
+ {
$valueFlag = false;
switch($tag) {
case 'int':
case 'i4':
- $value = (int) trim($this->_currentTagContents);
+ $value = (int)trim($this->_currentTagContents);
$valueFlag = true;
break;
case 'double':
- $value = (double) trim($this->_currentTagContents);
+ $value = (double)trim($this->_currentTagContents);
$valueFlag = true;
break;
case 'string':
- $value = $this->_currentTagContents;
+ $value = (string)trim($this->_currentTagContents);
$valueFlag = true;
break;
case 'dateTime.iso8601':
$value = new IXR_Date(trim($this->_currentTagContents));
- // $value = $iso->getTimestamp();
$valueFlag = true;
break;
case 'value':
@@ -242,14 +296,14 @@ class IXR_Message {
}
break;
case 'boolean':
- $value = (boolean) trim($this->_currentTagContents);
+ $value = (boolean)trim($this->_currentTagContents);
$valueFlag = true;
break;
case 'base64':
- $value = base64_decode( trim( $this->_currentTagContents ) );
+ $value = base64_decode($this->_currentTagContents);
$valueFlag = true;
break;
- /* Deal with stacks of arrays and structs */
+ /* Deal with stacks of arrays and structs */
case 'data':
case 'struct':
$value = array_pop($this->_arraystructs);
@@ -266,6 +320,7 @@ class IXR_Message {
$this->methodName = trim($this->_currentTagContents);
break;
}
+
if ($valueFlag) {
if (count($this->_arraystructs) > 0) {
// Add value to struct or array
@@ -291,27 +346,40 @@ class IXR_Message {
* @package IXR
* @since 1.5
*/
-class IXR_Server {
+class IXR_Server
+{
var $data;
var $callbacks = array();
var $message;
var $capabilities;
- function IXR_Server($callbacks = false, $data = false) {
+
+ function IXR_Server($callbacks = false, $data = false, $wait = false)
+ {
$this->setCapabilities();
if ($callbacks) {
$this->callbacks = $callbacks;
}
$this->setCallbacks();
- $this->serve($data);
+ if (!$wait) {
+ $this->serve($data);
+ }
}
- function serve($data = false) {
+
+ function serve($data = false)
+ {
if (!$data) {
+ if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
+ header('Content-Type: text/plain'); // merged from WP #9093
+ die('XML-RPC server accepts POST requests only.');
+ }
+
global $HTTP_RAW_POST_DATA;
- if (!$HTTP_RAW_POST_DATA) {
- header( 'Content-Type: text/plain' );
- die('XML-RPC server accepts POST requests only.');
+ if (empty($HTTP_RAW_POST_DATA)) {
+ // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
+ $data = file_get_contents('php://input');
+ } else {
+ $data =& $HTTP_RAW_POST_DATA;
}
- $data = &$HTTP_RAW_POST_DATA;
}
$this->message = new IXR_Message($data);
if (!$this->message->parse()) {
@@ -321,75 +389,83 @@ class IXR_Server {
$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
}
$result = $this->call($this->message->methodName, $this->message->params);
+
// Is the result an error?
if (is_a($result, 'IXR_Error')) {
$this->error($result);
}
+
// Encode the result
$r = new IXR_Value($result);
$resultxml = $r->getXml();
+
// Create the XML
$xml = <<
- $resultxml
+ $resultxml
EOD;
- // Send it
- $this->output($xml);
+ // Send it
+ $this->output($xml);
}
- function call($methodname, $args) {
+
+ function call($methodname, $args)
+ {
if (!$this->hasMethod($methodname)) {
- return new IXR_Error(-32601, 'server error. requested method '.
- $methodname.' does not exist.');
+ return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
}
$method = $this->callbacks[$methodname];
+
// Perform the callback and send the response
if (count($args) == 1) {
// If only one paramater just send that instead of the whole array
$args = $args[0];
}
+
// Are we dealing with a function or a method?
- if ( is_string( $method ) && substr($method, 0, 5) == 'this:' ) {
+ if (is_string($method) && substr($method, 0, 5) == 'this:') {
// It's a class method - check it exists
$method = substr($method, 5);
if (!method_exists($this, $method)) {
- return new IXR_Error(-32601, 'server error. requested class method "'.
- $method.'" does not exist.');
+ return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
}
- // Call the method
+
+ //Call the method
$result = $this->$method($args);
} else {
// It's a function - does it exist?
if (is_array($method)) {
- if (!method_exists($method[0], $method[1])) {
- return new IXR_Error(-32601, 'server error. requested object method "'.
- $method[1].'" does not exist.');
+ if (!is_callable(array($method[0], $method[1]))) {
+ return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
}
} else if (!function_exists($method)) {
- return new IXR_Error(-32601, 'server error. requested function "'.
- $method.'" does not exist.');
+ return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
}
+
// Call the function
$result = call_user_func($method, $args);
}
return $result;
}
- function error($error, $message = false) {
+ function error($error, $message = false)
+ {
// Accepts either an error object or an error code and message
if ($message && !is_object($error)) {
$error = new IXR_Error($error, $message);
}
$this->output($error->getXml());
}
- function output($xml) {
+
+ function output($xml)
+ {
$xml = ''."\n".$xml;
$length = strlen($xml);
header('Connection: close');
@@ -399,40 +475,52 @@ EOD;
echo $xml;
exit;
}
- function hasMethod($method) {
+
+ function hasMethod($method)
+ {
return in_array($method, array_keys($this->callbacks));
}
- function setCapabilities() {
+
+ function setCapabilities()
+ {
// Initialises capabilities array
$this->capabilities = array(
'xmlrpc' => array(
'specUrl' => 'http://www.xmlrpc.com/spec',
'specVersion' => 1
- ),
+ ),
'faults_interop' => array(
'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
'specVersion' => 20010516
- ),
+ ),
'system.multicall' => array(
'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
'specVersion' => 1
- ),
+ ),
);
}
- function getCapabilities($args) {
+
+ function getCapabilities($args)
+ {
return $this->capabilities;
}
- function setCallbacks() {
+
+ function setCallbacks()
+ {
$this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
$this->callbacks['system.listMethods'] = 'this:listMethods';
$this->callbacks['system.multicall'] = 'this:multiCall';
}
- function listMethods($args) {
+
+ function listMethods($args)
+ {
// Returns a list of methods - uses array_reverse to ensure user defined
// methods are listed before server defined methods
return array_reverse(array_keys($this->callbacks));
}
- function multiCall($methodcalls) {
+
+ function multiCall($methodcalls)
+ {
// See http://www.xmlrpc.com/discuss/msgReader$1208
$return = array();
foreach ($methodcalls as $call) {
@@ -462,11 +550,14 @@ EOD;
* @package IXR
* @since 1.5
*/
-class IXR_Request {
+class IXR_Request
+{
var $method;
var $args;
var $xml;
- function IXR_Request($method, $args) {
+
+ function IXR_Request($method, $args)
+ {
$this->method = $method;
$this->args = $args;
$this->xml = <<xml .= '';
}
- function getLength() {
+
+ function getLength()
+ {
return strlen($this->xml);
}
- function getXml() {
+
+ function getXml()
+ {
return $this->xml;
}
}
@@ -497,26 +592,32 @@ EOD;
*
* @package IXR
* @since 1.5
+ *
*/
-class IXR_Client {
+class IXR_Client
+{
var $server;
var $port;
var $path;
var $useragent;
- var $headers;
var $response;
var $message = false;
var $debug = false;
var $timeout;
+ var $headers = array();
+
// Storage place for an error message
var $error = false;
- function IXR_Client($server, $path = false, $port = 80, $timeout = false) {
+
+ function IXR_Client($server, $path = false, $port = 80, $timeout = 15)
+ {
if (!$path) {
// Assume we have been given a URL instead
$bits = parse_url($server);
$this->server = $bits['host'];
$this->port = isset($bits['port']) ? $bits['port'] : 80;
$this->path = isset($bits['path']) ? $bits['path'] : '/';
+
// Make absolutely sure we have a path
if (!$this->path) {
$this->path = '/';
@@ -529,7 +630,9 @@ class IXR_Client {
$this->useragent = 'The Incutio XML-RPC PHP Library';
$this->timeout = $timeout;
}
- function query() {
+
+ function query()
+ {
$args = func_get_args();
$method = array_shift($args);
$request = new IXR_Request($method, $args);
@@ -538,33 +641,36 @@ class IXR_Client {
$r = "\r\n";
$request = "POST {$this->path} HTTP/1.0$r";
- $this->headers['Host'] = $this->server;
- $this->headers['Content-Type'] = 'text/xml';
- $this->headers['User-Agent'] = $this->useragent;
- $this->headers['Content-Length']= $length;
+ // Merged from WP #8145 - allow custom headers
+ $this->headers['Host'] = $this->server;
+ $this->headers['Content-Type'] = 'text/xml';
+ $this->headers['User-Agent'] = $this->useragent;
+ $this->headers['Content-Length']= $length;
- foreach( $this->headers as $header => $value ) {
- $request .= "{$header}: {$value}{$r}";
- }
- $request .= $r;
+ foreach( $this->headers as $header => $value ) {
+ $request .= "{$header}: {$value}{$r}";
+ }
+ $request .= $r;
$request .= $xml;
+
// Now send the request
if ($this->debug) {
echo '
'.htmlspecialchars($request)."\n
\n\n";
}
+
if ($this->timeout) {
$fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
} else {
$fp = @fsockopen($this->server, $this->port, $errno, $errstr);
}
if (!$fp) {
- $this->error = new IXR_Error(-32300, "transport error - could not open socket: $errno $errstr");
+ $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
return false;
}
fputs($fp, $request);
$contents = '';
- $debug_contents = '';
+ $debugContents = '';
$gotFirstLine = false;
$gettingHeaders = true;
while (!feof($fp)) {
@@ -572,7 +678,7 @@ class IXR_Client {
if (!$gotFirstLine) {
// Check line for '200'
if (strstr($line, '200') === false) {
- $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200');
+ $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
return false;
}
$gotFirstLine = true;
@@ -581,16 +687,17 @@ class IXR_Client {
$gettingHeaders = false;
}
if (!$gettingHeaders) {
- // WP#12559 remove trim so as to not strip newlines from received response.
+ // merged from WP #12559 - remove trim
$contents .= $line;
}
if ($this->debug) {
- $debug_contents .= $line;
+ $debugContents .= $line;
}
}
if ($this->debug) {
- echo '
'.htmlspecialchars($debug_contents)."\n
\n\n";
+ echo '
'.htmlspecialchars($debugContents)."\n
\n\n";
}
+
// Now parse what we've got back
$this->message = new IXR_Message($contents);
if (!$this->message->parse()) {
@@ -598,44 +705,59 @@ class IXR_Client {
$this->error = new IXR_Error(-32700, 'parse error. not well formed');
return false;
}
+
// Is the message a fault?
if ($this->message->messageType == 'fault') {
$this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
return false;
}
+
// Message must be OK
return true;
}
- function getResponse() {
+
+ function getResponse()
+ {
// methodResponses can only have one param - return that
return $this->message->params[0];
}
- function isError() {
+
+ function isError()
+ {
return (is_object($this->error));
}
- function getErrorCode() {
+
+ function getErrorCode()
+ {
return $this->error->code;
}
- function getErrorMessage() {
+
+ function getErrorMessage()
+ {
return $this->error->message;
}
}
+
/**
* IXR_Error
*
* @package IXR
* @since 1.5
*/
-class IXR_Error {
+class IXR_Error
+{
var $code;
var $message;
- function IXR_Error($code, $message) {
+
+ function IXR_Error($code, $message)
+ {
$this->code = $code;
- // WP adds htmlspecialchars(). See #5666
$this->message = htmlspecialchars($message);
}
- function getXml() {
+
+ function getXml()
+ {
$xml = <<
@@ -673,7 +795,9 @@ class IXR_Date {
var $minute;
var $second;
var $timezone;
- function IXR_Date($time) {
+
+ function IXR_Date($time)
+ {
// $time can be a PHP timestamp or an ISO one
if (is_numeric($time)) {
$this->parseTimestamp($time);
@@ -681,34 +805,41 @@ class IXR_Date {
$this->parseIso($time);
}
}
- function parseTimestamp($timestamp) {
+
+ function parseTimestamp($timestamp)
+ {
$this->year = date('Y', $timestamp);
$this->month = date('m', $timestamp);
$this->day = date('d', $timestamp);
$this->hour = date('H', $timestamp);
$this->minute = date('i', $timestamp);
$this->second = date('s', $timestamp);
- // WP adds timezone. See #2036
$this->timezone = '';
}
- function parseIso($iso) {
+
+ function parseIso($iso)
+ {
$this->year = substr($iso, 0, 4);
$this->month = substr($iso, 4, 2);
$this->day = substr($iso, 6, 2);
$this->hour = substr($iso, 9, 2);
$this->minute = substr($iso, 12, 2);
$this->second = substr($iso, 15, 2);
- // WP adds timezone. See #2036
$this->timezone = substr($iso, 17);
}
- function getIso() {
- // WP adds timezone. See #2036
+
+ function getIso()
+ {
return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
}
- function getXml() {
+
+ function getXml()
+ {
return ''.$this->getIso().'';
}
- function getTimestamp() {
+
+ function getTimestamp()
+ {
return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
}
}
@@ -719,12 +850,17 @@ class IXR_Date {
* @package IXR
* @since 1.5
*/
-class IXR_Base64 {
+class IXR_Base64
+{
var $data;
- function IXR_Base64($data) {
+
+ function IXR_Base64($data)
+ {
$this->data = $data;
}
- function getXml() {
+
+ function getXml()
+ {
return ''.base64_encode($this->data).'';
}
}
@@ -735,10 +871,13 @@ class IXR_Base64 {
* @package IXR
* @since 1.5
*/
-class IXR_IntrospectionServer extends IXR_Server {
+class IXR_IntrospectionServer extends IXR_Server
+{
var $signatures;
var $help;
- function IXR_IntrospectionServer() {
+
+ function IXR_IntrospectionServer()
+ {
$this->setCallbacks();
$this->setCapabilities();
$this->capabilities['introspection'] = array(
@@ -770,16 +909,21 @@ class IXR_IntrospectionServer extends IXR_Server {
'Returns a documentation string for the specified method'
);
}
- function addCallback($method, $callback, $args, $help) {
+
+ function addCallback($method, $callback, $args, $help)
+ {
$this->callbacks[$method] = $callback;
$this->signatures[$method] = $args;
$this->help[$method] = $help;
}
- function call($methodname, $args) {
+
+ function call($methodname, $args)
+ {
// Make sure it's in an array
if ($args && !is_array($args)) {
$args = array($args);
}
+
// Over-rides default call method, adds signature check
if (!$this->hasMethod($methodname)) {
return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
@@ -787,10 +931,12 @@ class IXR_IntrospectionServer extends IXR_Server {
$method = $this->callbacks[$methodname];
$signature = $this->signatures[$methodname];
$returnType = array_shift($signature);
+
// Check the number of arguments
if (count($args) != count($signature)) {
return new IXR_Error(-32602, 'server error. wrong number of method parameters');
}
+
// Check the argument types
$ok = true;
$argsbackup = $args;
@@ -835,7 +981,9 @@ class IXR_IntrospectionServer extends IXR_Server {
// It passed the test - run the "real" method call
return parent::call($methodname, $argsbackup);
}
- function methodSignature($method) {
+
+ function methodSignature($method)
+ {
if (!$this->hasMethod($method)) {
return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
}
@@ -873,7 +1021,9 @@ class IXR_IntrospectionServer extends IXR_Server {
}
return $return;
}
- function methodHelp($method) {
+
+ function methodHelp($method)
+ {
return $this->help[$method];
}
}
@@ -884,13 +1034,18 @@ class IXR_IntrospectionServer extends IXR_Server {
* @package IXR
* @since 1.5
*/
-class IXR_ClientMulticall extends IXR_Client {
+class IXR_ClientMulticall extends IXR_Client
+{
var $calls = array();
- function IXR_ClientMulticall($server, $path = false, $port = 80) {
+
+ function IXR_ClientMulticall($server, $path = false, $port = 80)
+ {
parent::IXR_Client($server, $path, $port);
$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
}
- function addCall() {
+
+ function addCall()
+ {
$args = func_get_args();
$methodName = array_shift($args);
$struct = array(
@@ -899,7 +1054,9 @@ class IXR_ClientMulticall extends IXR_Client {
);
$this->calls[] = $struct;
}
- function query() {
+
+ function query()
+ {
// Prepare multicall, then call the parent::query() method
return parent::query('system.multicall', $this->calls);
}
diff --git a/wp-includes/class-http.php b/wp-includes/class-http.php
index 3e808692..5d7f83d8 100644
--- a/wp-includes/class-http.php
+++ b/wp-includes/class-http.php
@@ -238,39 +238,39 @@ class WP_Http {
if ( false !== $pre )
return $pre;
- $arrURL = parse_url($url);
+ $arrURL = parse_url( $url );
if ( empty( $url ) || empty( $arrURL['scheme'] ) )
return new WP_Error('http_request_failed', __('A valid URL was not provided.'));
if ( $this->block_request( $url ) )
- return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.'));
+ return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ) );
// Determine if this is a https call and pass that on to the transport functions
// so that we can blacklist the transports that do not support ssl verification
$r['ssl'] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl';
// Determine if this request is to OUR install of WordPress
- $homeURL = parse_url( get_bloginfo('url') );
+ $homeURL = parse_url( get_bloginfo( 'url' ) );
$r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host'];
- unset($homeURL);
+ unset( $homeURL );
if ( is_null( $r['headers'] ) )
$r['headers'] = array();
- if ( ! is_array($r['headers']) ) {
- $processedHeaders = WP_Http::processHeaders($r['headers']);
+ if ( ! is_array( $r['headers'] ) ) {
+ $processedHeaders = WP_Http::processHeaders( $r['headers'] );
$r['headers'] = $processedHeaders['headers'];
}
- if ( isset($r['headers']['User-Agent']) ) {
+ if ( isset( $r['headers']['User-Agent'] ) ) {
$r['user-agent'] = $r['headers']['User-Agent'];
- unset($r['headers']['User-Agent']);
+ unset( $r['headers']['User-Agent'] );
}
- if ( isset($r['headers']['user-agent']) ) {
+ if ( isset( $r['headers']['user-agent'] ) ) {
$r['user-agent'] = $r['headers']['user-agent'];
- unset($r['headers']['user-agent']);
+ unset( $r['headers']['user-agent'] );
}
// Construct Cookie: header if any cookies are set
@@ -280,45 +280,46 @@ class WP_Http {
$r['headers']['Accept-Encoding'] = WP_Http_Encoding::accept_encoding();
if ( empty($r['body']) ) {
+ $r['body'] = null;
// Some servers fail when sending content without the content-length header being set.
// Also, to fix another bug, we only send when doing POST and PUT and the content-length
// header isn't already set.
- if( ($r['method'] == 'POST' || $r['method'] == 'PUT') && ! isset($r['headers']['Content-Length']) )
+ if ( ($r['method'] == 'POST' || $r['method'] == 'PUT') && ! isset( $r['headers']['Content-Length'] ) )
$r['headers']['Content-Length'] = 0;
// The method is ambiguous, because we aren't talking about HTTP methods, the "get" in
// this case is simply that we aren't sending any bodies and to get the transports that
// don't support sending bodies along with those which do.
- $transports = WP_Http::_getTransport($r);
+ $transports = WP_Http::_getTransport( $r );
} else {
if ( is_array( $r['body'] ) || is_object( $r['body'] ) ) {
if ( ! version_compare(phpversion(), '5.1.2', '>=') )
- $r['body'] = _http_build_query($r['body'], null, '&');
+ $r['body'] = _http_build_query( $r['body'], null, '&' );
else
- $r['body'] = http_build_query($r['body'], null, '&');
- $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset');
- $r['headers']['Content-Length'] = strlen($r['body']);
+ $r['body'] = http_build_query( $r['body'], null, '&' );
+ $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' );
+ $r['headers']['Content-Length'] = strlen( $r['body'] );
}
if ( ! isset( $r['headers']['Content-Length'] ) && ! isset( $r['headers']['content-length'] ) )
- $r['headers']['Content-Length'] = strlen($r['body']);
+ $r['headers']['Content-Length'] = strlen( $r['body'] );
// The method is ambiguous, because we aren't talking about HTTP methods, the "post" in
// this case is simply that we are sending HTTP body and to get the transports that do
// support sending the body. Not all do, depending on the limitations of the PHP core
// limitations.
- $transports = WP_Http::_postTransport($r);
+ $transports = WP_Http::_postTransport( $r );
}
do_action( 'http_api_debug', $transports, 'transports_list' );
$response = array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
foreach ( (array) $transports as $transport ) {
- $response = $transport->request($url, $r);
+ $response = $transport->request( $url, $r );
- do_action( 'http_api_debug', $response, 'response', get_class($transport) );
+ do_action( 'http_api_debug', $response, 'response', get_class( $transport ) );
- if ( ! is_wp_error($response) )
+ if ( ! is_wp_error( $response ) )
return apply_filters( 'http_response', $response, $r, $url );
}
@@ -453,7 +454,7 @@ class WP_Http {
} else {
$newheaders[$key] = trim( $value );
}
- if ( 'set-cookie' == strtolower( $key ) )
+ if ( 'set-cookie' == $key )
$cookies[] = new WP_Http_Cookie( $value );
}
}
@@ -540,10 +541,12 @@ class WP_Http {
* You block external URL requests by defining WP_HTTP_BLOCK_EXTERNAL as true in your wp-config.php
* file and this will only allow localhost and your blog to make requests. The constant
* WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests. The format of the
- * WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow.
+ * WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow, wildcard domains
+ * are supported, eg *.wordpress.org will allow for all subdomains of wordpress.org to be contacted.
*
* @since 2.8.0
* @link http://core.trac.wordpress.org/ticket/8927 Allow preventing external requests.
+ * @link http://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_ACCESSIBLE_HOSTS
*
* @param string $uri URI of url.
* @return bool True to block, false to allow.
@@ -577,10 +580,25 @@ class WP_Http {
return true;
static $accessible_hosts;
- if ( null == $accessible_hosts )
+ static $wildcard_regex = false;
+ if ( null == $accessible_hosts ) {
$accessible_hosts = preg_split('|,\s*|', WP_ACCESSIBLE_HOSTS);
- return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If its in the array, then we can't access it.
+ if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) {
+ $wildcard_regex = array();
+ foreach ( $accessible_hosts as $host )
+ $wildcard_regex[] = str_replace('\*', '[\w.]+?', preg_quote($host, '/'));
+ $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i';
+ }
+ }
+
+ if ( !empty($wildcard_regex) )
+ return !preg_match($wildcard_regex, $check['host']);
+ else
+ return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If its in the array, then we can't access it.
+
+
+
}
}
@@ -621,7 +639,7 @@ class WP_Http_Fsockopen {
if ( isset($r['headers']['User-Agent']) ) {
$r['user-agent'] = $r['headers']['User-Agent'];
unset($r['headers']['User-Agent']);
- } else if( isset($r['headers']['user-agent']) ) {
+ } else if ( isset($r['headers']['user-agent']) ) {
$r['user-agent'] = $r['headers']['user-agent'];
unset($r['headers']['user-agent']);
}
@@ -973,7 +991,7 @@ class WP_Http_Streams {
if ( isset($r['headers']['User-Agent']) ) {
$r['user-agent'] = $r['headers']['User-Agent'];
unset($r['headers']['User-Agent']);
- } else if( isset($r['headers']['user-agent']) ) {
+ } else if ( isset($r['headers']['user-agent']) ) {
$r['user-agent'] = $r['headers']['user-agent'];
unset($r['headers']['user-agent']);
}
@@ -1120,7 +1138,7 @@ class WP_Http_Streams {
* @subpackage HTTP
* @since 2.7.0
*/
-class WP_Http_ExtHTTP {
+class WP_Http_ExtHttp {
/**
* Send a HTTP request to a URI using HTTP extension.
*
@@ -1146,7 +1164,7 @@ class WP_Http_ExtHTTP {
if ( isset($r['headers']['User-Agent']) ) {
$r['user-agent'] = $r['headers']['User-Agent'];
unset($r['headers']['User-Agent']);
- } else if( isset($r['headers']['user-agent']) ) {
+ } else if ( isset($r['headers']['user-agent']) ) {
$r['user-agent'] = $r['headers']['user-agent'];
unset($r['headers']['user-agent']);
}
@@ -1296,7 +1314,7 @@ class WP_Http_Curl {
if ( isset($r['headers']['User-Agent']) ) {
$r['user-agent'] = $r['headers']['User-Agent'];
unset($r['headers']['User-Agent']);
- } else if( isset($r['headers']['user-agent']) ) {
+ } else if ( isset($r['headers']['user-agent']) ) {
$r['user-agent'] = $r['headers']['user-agent'];
unset($r['headers']['user-agent']);
}
@@ -1408,7 +1426,7 @@ class WP_Http_Curl {
$theBody = substr( $theResponse, $headerLength );
else
$theBody = '';
- if ( false !== strrpos($theHeaders, "\r\n\r\n") ) {
+ if ( false !== strpos($theHeaders, "\r\n\r\n") ) {
$headerParts = explode("\r\n\r\n", $theHeaders);
$theHeaders = $headerParts[ count($headerParts) -1 ];
}
@@ -1478,17 +1496,18 @@ class WP_Http_Curl {
*
WP_PROXY_PASSWORD - Proxy password, if it requires authentication.
*
WP_PROXY_BYPASS_HOSTS - Will prevent the hosts in this list from going through the proxy.
* You do not need to have localhost and the blog host in this list, because they will not be passed
- * through the proxy. The list should be presented in a comma separated list
+ * through the proxy. The list should be presented in a comma separated list, wildcards using * are supported, eg. *.wordpress.org
*
*
* An example can be as seen below.
*
* define('WP_PROXY_HOST', '192.168.84.101');
* define('WP_PROXY_PORT', '8080');
- * define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com');
+ * define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com, *.wordpress.org');
*
*
* @link http://core.trac.wordpress.org/ticket/4011 Proxy support ticket in WordPress.
+ * @link http://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_PROXY_BYPASS_HOSTS
* @since 2.8
*/
class WP_HTTP_Proxy {
@@ -1605,7 +1624,7 @@ class WP_HTTP_Proxy {
* hosts that won't be sent through the proxy.
*
* @uses WP_PROXY_BYPASS_HOSTS
- * @since unknown
+ * @since 2.8.0
*
* @param string $uri URI to check.
* @return bool True, to send through the proxy and false if, the proxy should not be used.
@@ -1628,10 +1647,22 @@ class WP_HTTP_Proxy {
return true;
static $bypass_hosts;
- if ( null == $bypass_hosts )
+ static $wildcard_regex = false;
+ if ( null == $bypass_hosts ) {
$bypass_hosts = preg_split('|,\s*|', WP_PROXY_BYPASS_HOSTS);
- return !in_array( $check['host'], $bypass_hosts );
+ if ( false !== strpos(WP_PROXY_BYPASS_HOSTS, '*') ) {
+ $wildcard_regex = array();
+ foreach ( $bypass_hosts as $host )
+ $wildcard_regex[] = str_replace('\*', '[\w.]+?', preg_quote($host, '/'));
+ $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i';
+ }
+ }
+
+ if ( !empty($wildcard_regex) )
+ return !preg_match($wildcard_regex, $check['host']);
+ else
+ return !in_array( $check['host'], $bypass_hosts );
}
}
/**
diff --git a/wp-includes/class-json.php b/wp-includes/class-json.php
index 7582609a..75010df2 100644
--- a/wp-includes/class-json.php
+++ b/wp-includes/class-json.php
@@ -153,7 +153,7 @@ class Services_JSON
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
- $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
+ $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
switch(true) {
case ((0x7F & $bytes) == $bytes):
@@ -206,17 +206,17 @@ class Services_JSON
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0x07 & (ord($utf8{0}) >> 2))
- . chr((0xC0 & (ord($utf8{0}) << 6))
- | (0x3F & ord($utf8{1})));
+ return chr(0x07 & (ord($utf8[0]) >> 2))
+ . chr((0xC0 & (ord($utf8[0]) << 6))
+ | (0x3F & ord($utf8[1])));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr((0xF0 & (ord($utf8{0}) << 4))
- | (0x0F & (ord($utf8{1}) >> 2)))
- . chr((0xC0 & (ord($utf8{1}) << 6))
- | (0x7F & ord($utf8{2})));
+ return chr((0xF0 & (ord($utf8[0]) << 4))
+ | (0x0F & (ord($utf8[1]) >> 2)))
+ . chr((0xC0 & (ord($utf8[1]) << 6))
+ | (0x7F & ord($utf8[2])));
}
// ignoring UTF-32 for now, sorry
@@ -293,7 +293,7 @@ class Services_JSON
*/
for ($c = 0; $c < $strlen_var; ++$c) {
- $ord_var_c = ord($var{$c});
+ $ord_var_c = ord($var[$c]);
switch (true) {
case $ord_var_c == 0x08:
@@ -316,12 +316,12 @@ class Services_JSON
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
- $ascii .= '\\'.$var{$c};
+ $ascii .= '\\'.$var[$c];
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
- $ascii .= $var{$c};
+ $ascii .= $var[$c];
break;
case (($ord_var_c & 0xE0) == 0xC0):
@@ -333,7 +333,7 @@ class Services_JSON
break;
}
- $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
+ $char = pack('C*', $ord_var_c, ord($var[$c + 1]));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -348,8 +348,8 @@ class Services_JSON
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
- @ord($var{$c + 1}),
- @ord($var{$c + 2}));
+ @ord($var[$c + 1]),
+ @ord($var[$c + 2]));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -364,9 +364,9 @@ class Services_JSON
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}));
+ ord($var[$c + 1]),
+ ord($var[$c + 2]),
+ ord($var[$c + 3]));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -381,10 +381,10 @@ class Services_JSON
break;
}
$char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}));
+ ord($var[$c + 1]),
+ ord($var[$c + 2]),
+ ord($var[$c + 3]),
+ ord($var[$c + 4]));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -399,11 +399,11 @@ class Services_JSON
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}),
- ord($var{$c + 5}));
+ ord($var[$c + 1]),
+ ord($var[$c + 2]),
+ ord($var[$c + 3]),
+ ord($var[$c + 4]),
+ ord($var[$c + 5]));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -577,7 +577,7 @@ class Services_JSON
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
- $ord_chrs_c = ord($chrs{$c});
+ $ord_chrs_c = ord($chrs[$c]);
switch (true) {
case $substr_chrs_c_2 == '\b':
@@ -607,7 +607,7 @@ class Services_JSON
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
- $utf8 .= $chrs{++$c};
+ $utf8 .= $chrs[++$c];
}
break;
@@ -620,7 +620,7 @@ class Services_JSON
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
- $utf8 .= $chrs{$c};
+ $utf8 .= $chrs[$c];
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
@@ -667,7 +667,7 @@ class Services_JSON
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
- if ($str{0} == '[') {
+ if ($str[0] == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
@@ -706,7 +706,7 @@ class Services_JSON
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
- if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
+ if (($c == $strlen_chrs) || (($chrs[$c] == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
@@ -748,12 +748,12 @@ class Services_JSON
}
- } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
+ } elseif ((($chrs[$c] == '"') || ($chrs[$c] == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
- array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
+ array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c]));
//print("Found start of string at {$c}\n");
- } elseif (($chrs{$c} == $top['delim']) &&
+ } elseif (($chrs[$c] == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
@@ -762,24 +762,24 @@ class Services_JSON
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
- } elseif (($chrs{$c} == '[') &&
+ } elseif (($chrs[$c] == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
- } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
+ } elseif (($chrs[$c] == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
- } elseif (($chrs{$c} == '{') &&
+ } elseif (($chrs[$c] == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
- } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
+ } elseif (($chrs[$c] == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
diff --git a/wp-includes/class-oembed.php b/wp-includes/class-oembed.php
index a09b3167..87e59a69 100644
--- a/wp-includes/class-oembed.php
+++ b/wp-includes/class-oembed.php
@@ -242,7 +242,7 @@ class WP_oEmbed {
return false;
$title = ( !empty($data->title) ) ? $data->title : '';
- $return = '';
+ $return = '';
break;
case 'video':
diff --git a/wp-includes/class-pop3.php b/wp-includes/class-pop3.php
index c11676c4..2bf442f8 100644
--- a/wp-includes/class-pop3.php
+++ b/wp-includes/class-pop3.php
@@ -11,10 +11,11 @@
* An RFC 1939 compliant wrapper class for the POP3 protocol.
*
* Licensed under the GNU GPL. For full terms see the file COPYING.
+ * @license http://opensource.org/licenses/gpl-license.php GNU General Public License
*
* pop3 class
*
- * $Id: class-pop3.php 9503 2008-11-03 23:25:11Z ryan $
+ * $Id: class-pop3.php 17435 2011-02-09 17:35:36Z ryan $
*/
class POP3 {
@@ -367,7 +368,7 @@ class POP3 {
$line = fgets($fp,$buffer);
while ( !ereg("^\.\r\n",$line))
{
- if ( $line{0} == '.' ) { $line = substr($line,1); }
+ if ( $line[0] == '.' ) { $line = substr($line,1); }
$MsgArray[$count] = $line;
$count++;
$line = fgets($fp,$buffer);
diff --git a/wp-includes/class-simplepie.php b/wp-includes/class-simplepie.php
index 98843f03..275033a8 100644
--- a/wp-includes/class-simplepie.php
+++ b/wp-includes/class-simplepie.php
@@ -1831,7 +1831,7 @@ class SimplePie
}
/**
- * Return the error message for the occured error
+ * Return the error message for the occurred error
*
* @access public
* @return string Error message
diff --git a/wp-includes/class-snoopy.php b/wp-includes/class-snoopy.php
index da3d824e..66ff71fc 100644
--- a/wp-includes/class-snoopy.php
+++ b/wp-includes/class-snoopy.php
@@ -719,13 +719,13 @@ class Snoopy
chr(176),
chr(39),
chr(128),
- "ä",
- "ö",
- "ü",
- "Ä",
- "Ö",
- "Ü",
- "ß",
+ chr(0xE4), // ANSI ä
+ chr(0xF6), // ANSI ö
+ chr(0xFC), // ANSI ü
+ chr(0xC4), // ANSI Ä
+ chr(0xD6), // ANSI Ö
+ chr(0xDC), // ANSI Ü
+ chr(0xDF), // ANSI ß
);
$text = preg_replace($search,$replace,$document);
diff --git a/wp-includes/class-wp-admin-bar.php b/wp-includes/class-wp-admin-bar.php
new file mode 100644
index 00000000..549d5ecf
--- /dev/null
+++ b/wp-includes/class-wp-admin-bar.php
@@ -0,0 +1,236 @@
+proto = 'https://';
+
+ $this->user = new stdClass;
+ $this->menu = new stdClass;
+
+ /* Populate settings we need for the menu based on the current user. */
+ $this->user->blogs = get_blogs_of_user( get_current_user_id() );
+ if ( is_multisite() ) {
+ $this->user->active_blog = get_active_blog_for_user( get_current_user_id() );
+ $this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
+ $this->user->account_domain = $this->user->domain;
+ } else {
+ $this->user->active_blog = $this->user->blogs[get_current_blog_id()];
+ $this->user->domain = trailingslashit( home_url() );
+ $this->user->account_domain = $this->user->domain;
+ }
+ $this->user->locale = get_locale();
+
+ add_action( 'wp_head', 'wp_admin_bar_header' );
+
+ add_action( 'admin_head', 'wp_admin_bar_header' );
+
+ if ( current_theme_supports( 'admin-bar' ) ) {
+ $admin_bar_args = get_theme_support( 'admin-bar' ); // add_theme_support( 'admin-bar', array( 'callback' => '__return_false') );
+ $header_callback = $admin_bar_args[0]['callback'];
+ }
+
+ if ( empty($header_callback) )
+ $header_callback = '_admin_bar_bump_cb';
+
+ add_action('wp_head', $header_callback);
+
+ wp_enqueue_script( 'admin-bar' );
+ wp_enqueue_style( 'admin-bar' );
+
+ do_action( 'admin_bar_init' );
+ }
+
+ function add_menu( $args = array() ) {
+ $defaults = array(
+ 'title' => false,
+ 'href' => false,
+ 'parent' => false, // false for a root menu, pass the ID value for a submenu of that menu.
+ 'id' => false, // defaults to a sanitized title value.
+ 'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ extract( $r, EXTR_SKIP );
+
+ if ( empty( $title ) )
+ return false;
+
+ /* Make sure we have a valid ID */
+ if ( empty( $id ) )
+ $id = esc_attr( sanitize_title( trim( $title ) ) );
+
+ if ( ! empty( $parent ) ) {
+ /* Add the menu to the parent item */
+ $child = array( 'id' => $id, 'title' => $title, 'href' => $href );
+
+ if ( ! empty( $meta ) )
+ $child['meta'] = $meta;
+
+ $this->add_node( $parent, $this->menu, $child );
+ } else {
+ /* Add the menu item */
+ $this->menu->{$id} = array( 'title' => $title, 'href' => $href );
+
+ if ( ! empty( $meta ) )
+ $this->menu->{$id}['meta'] = $meta;
+ }
+ }
+
+ function remove_menu( $id ) {
+ return $this->remove_node( $id, $this->menu );
+ }
+
+ function render() {
+ ?>
+
+
+
+ menu as $id => $menu_item ) : ?>
+ recursive_render( $id, $menu_item ) ?>
+
+
-
-
-
-
has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) )
- $redirect_to = admin_url('profile.php');
+
+ if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) {
+ // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
+ if ( is_multisite() && !get_active_blog_for_user($user->id) )
+ $redirect_to = user_admin_url();
+ elseif ( is_multisite() && !$user->has_cap('read') )
+ $redirect_to = get_dashboard_url( $user->id );
+ elseif ( !$user->has_cap('edit_posts') )
+ $redirect_to = admin_url('profile.php');
+ }
wp_safe_redirect($redirect_to);
exit();
}
@@ -619,7 +664,7 @@ default:
-
+
@@ -629,11 +674,17 @@ function wp_attempt_focus(){
setTimeout( function(){ try{
d = document.getElementById('user_pass');
+d.value = '';
d = document.getElementById('user_login');
-
+get_error_code() ) { ?>
+if( d.value != '' )
d.value = '';
+
d.focus();
+d.select();
} catch(e){}
}, 200);
}
@@ -643,6 +694,7 @@ wp_attempt_focus();
if(typeof wpOnload=='function')wpOnload();
+
\ No newline at end of file
+exit;
+?>
diff --git a/wp-rdf.php b/wp-rdf.php
index 3c8f005f..cc94ad06 100644
--- a/wp-rdf.php
+++ b/wp-rdf.php
@@ -8,5 +8,5 @@
require( './wp-load.php' );
wp_redirect( get_bloginfo( 'rdf_url' ), 301 );
-
-?>
\ No newline at end of file
+exit;
+?>
diff --git a/wp-register.php b/wp-register.php
index caad4f2b..0b1a7697 100644
--- a/wp-register.php
+++ b/wp-register.php
@@ -10,6 +10,6 @@
*/
require('./wp-load.php');
-wp_redirect('wp-login.php?action=register');
-
-?>
\ No newline at end of file
+wp_redirect( site_url('wp-login.php?action=register') );
+exit;
+?>
diff --git a/wp-rss.php b/wp-rss.php
index 0ae63a23..af2427ad 100644
--- a/wp-rss.php
+++ b/wp-rss.php
@@ -8,5 +8,5 @@
require( './wp-load.php' );
wp_redirect( get_bloginfo( 'rss_url' ), 301 );
-
-?>
\ No newline at end of file
+exit;
+?>
diff --git a/wp-rss2.php b/wp-rss2.php
index 78daa6d2..de75c239 100644
--- a/wp-rss2.php
+++ b/wp-rss2.php
@@ -8,5 +8,5 @@
require( './wp-load.php' );
wp_redirect( get_bloginfo( 'rss2_url' ), 301 );
-
-?>
\ No newline at end of file
+exit;
+?>
diff --git a/wp-settings.php b/wp-settings.php
index 473f2c6c..2cd12c1c 100644
--- a/wp-settings.php
+++ b/wp-settings.php
@@ -35,7 +35,7 @@ if ( function_exists( 'date_default_timezone_set' ) )
wp_unregister_GLOBALS();
// Ensure these global variables do not exist so they do not interfere with WordPress.
-unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate );
+unset( $wp_filter, $cache_lastcommentmodified );
// Standardize $_SERVER variables across setups.
wp_fix_server_vars();
@@ -65,9 +65,11 @@ wp_set_lang_dir();
// Load early WordPress files.
require( ABSPATH . WPINC . '/compat.php' );
require( ABSPATH . WPINC . '/functions.php' );
-require( ABSPATH . WPINC . '/classes.php' );
+require( ABSPATH . WPINC . '/class-wp.php' );
+require( ABSPATH . WPINC . '/class-wp-error.php' );
+require( ABSPATH . WPINC . '/plugin.php' );
-// Include the wpdb class, or a db.php database drop-in if present.
+// Include the wpdb class and, if present, a db.php database drop-in.
require_wp_db();
// Set the database table prefix and the format specifiers for database table columns.
@@ -77,7 +79,6 @@ wp_set_wpdb_vars();
wp_start_object_cache();
// Load early WordPress files.
-require( ABSPATH . WPINC . '/plugin.php' );
require( ABSPATH . WPINC . '/default-filters.php' );
require( ABSPATH . WPINC . '/pomo/mo.php' );
@@ -100,6 +101,8 @@ require( ABSPATH . WPINC . '/l10n.php' );
wp_not_installed();
// Load most of WordPress.
+require( ABSPATH . WPINC . '/class-wp-walker.php' );
+require( ABSPATH . WPINC . '/class-wp-ajax-response.php' );
require( ABSPATH . WPINC . '/formatting.php' );
require( ABSPATH . WPINC . '/capabilities.php' );
require( ABSPATH . WPINC . '/query.php' );
@@ -133,6 +136,7 @@ require( ABSPATH . WPINC . '/class-http.php' );
require( ABSPATH . WPINC . '/widgets.php' );
require( ABSPATH . WPINC . '/nav-menu.php' );
require( ABSPATH . WPINC . '/nav-menu-template.php' );
+require( ABSPATH . WPINC . '/admin-bar.php' );
// Load multisite-specific files.
if ( is_multisite() ) {
@@ -151,6 +155,14 @@ foreach ( wp_get_mu_plugins() as $mu_plugin ) {
}
unset( $mu_plugin );
+// Load network activated plugins.
+if ( is_multisite() ) {
+ foreach( wp_get_active_network_plugins() as $network_plugin ) {
+ include_once( $network_plugin );
+ }
+ unset( $network_plugin );
+}
+
do_action( 'muplugins_loaded' );
if ( is_multisite() )
@@ -170,6 +182,9 @@ require( ABSPATH . WPINC . '/vars.php' );
create_initial_taxonomies();
create_initial_post_types();
+// Register the default theme directory root
+register_theme_directory( get_theme_root() );
+
// Load active plugins.
foreach ( wp_get_active_and_valid_plugins() as $plugin )
include_once( $plugin );
diff --git a/wp-signup.php b/wp-signup.php
index 28b561a9..c2ab566b 100644
--- a/wp-signup.php
+++ b/wp-signup.php
@@ -6,7 +6,6 @@ require( dirname(__FILE__) . '/wp-load.php' );
add_action( 'wp_head', 'signuppageheaders' ) ;
require( './wp-blog-header.php' );
-require_once( ABSPATH . WPINC . '/registration.php' );
if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) == true ) {
wp_redirect( network_home_url() );
@@ -23,7 +22,7 @@ function signuppageheaders() {
}
if ( !is_multisite() ) {
- wp_redirect( get_option( 'siteurl' ) . "/wp-login.php?action=register" );
+ wp_redirect( site_url('wp-login.php?action=register') );
die();
}
@@ -81,12 +80,11 @@ function show_blog_form($blogname = '', $blog_title = '', $errors = '') {
echo '.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . ' ';
if ( !is_user_logged_in() ) {
- print '(' . __( 'Your address will be ' );
if ( !is_subdomain_install() )
- print $current_site->domain . $current_site->path . __( 'sitename' );
+ $site = $current_site->domain . $current_site->path . __( 'sitename' );
else
- print __( 'domain.' ) . $site_domain . $current_site->path;
- echo '.) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '';
+ $site = __( 'domain' ) . '.' . $site_domain . $current_site->path;
+ echo '
(' . sprintf( __('Your address will be %s.'), $site ) . ') ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '
';
}
// Blog Title
@@ -393,7 +391,7 @@ $i18n_signup['blog'] = _x('blog', 'Multisite active signup type');
$i18n_signup['user'] = _x('user', 'Multisite active signup type');
if ( is_super_admin() )
- echo '
' . sprintf( __( 'Greetings Site Administrator! You are currently allowing “%s” registrations. To change or disable registration go to your Options page.' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'ms-options.php' ) ) ) . '
';
+ echo '
' . sprintf( __( 'Greetings Site Administrator! You are currently allowing “%s” registrations. To change or disable registration go to your Options page.' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'settings.php' ) ) ) . '
';
$newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
diff --git a/xmlrpc.php b/xmlrpc.php
index 5ec072b0..85171776 100644
--- a/xmlrpc.php
+++ b/xmlrpc.php
@@ -2,7 +2,6 @@
/**
* XML-RPC protocol support for WordPress
*
- * @license GPL v2 <./license.txt>
* @package WordPress
*/
@@ -53,6 +52,7 @@ exit;
include_once(ABSPATH . 'wp-admin/includes/admin.php');
include_once(ABSPATH . WPINC . '/class-IXR.php');
+include_once(ABSPATH . WPINC . '/class-wp-xmlrpc-server.php');
// Turn off all warnings and errors.
// error_reporting(0);
@@ -98,3278 +98,10 @@ function logIO($io,$msg) {
if ( isset($HTTP_RAW_POST_DATA) )
logIO("I", $HTTP_RAW_POST_DATA);
-/**
- * WordPress XMLRPC server implementation.
- *
- * Implements compatability for Blogger API, MetaWeblog API, MovableType, and
- * pingback. Additional WordPress API for managing comments, pages, posts,
- * options, etc.
- *
- * Since WordPress 2.6.0, WordPress XMLRPC server can be disabled in the
- * administration panels.
- *
- * @package WordPress
- * @subpackage Publishing
- * @since 1.5.0
- */
-class wp_xmlrpc_server extends IXR_Server {
-
- /**
- * Register all of the XMLRPC methods that XMLRPC server understands.
- *
- * PHP4 constructor and sets up server and method property. Passes XMLRPC
- * methods through the 'xmlrpc_methods' filter to allow plugins to extend
- * or replace XMLRPC methods.
- *
- * @since 1.5.0
- *
- * @return wp_xmlrpc_server
- */
- function wp_xmlrpc_server() {
- $this->methods = array(
- // WordPress API
- 'wp.getUsersBlogs' => 'this:wp_getUsersBlogs',
- 'wp.getPage' => 'this:wp_getPage',
- 'wp.getPages' => 'this:wp_getPages',
- 'wp.newPage' => 'this:wp_newPage',
- 'wp.deletePage' => 'this:wp_deletePage',
- 'wp.editPage' => 'this:wp_editPage',
- 'wp.getPageList' => 'this:wp_getPageList',
- 'wp.getAuthors' => 'this:wp_getAuthors',
- 'wp.getCategories' => 'this:mw_getCategories', // Alias
- 'wp.getTags' => 'this:wp_getTags',
- 'wp.newCategory' => 'this:wp_newCategory',
- 'wp.deleteCategory' => 'this:wp_deleteCategory',
- 'wp.suggestCategories' => 'this:wp_suggestCategories',
- 'wp.uploadFile' => 'this:mw_newMediaObject', // Alias
- 'wp.getCommentCount' => 'this:wp_getCommentCount',
- 'wp.getPostStatusList' => 'this:wp_getPostStatusList',
- 'wp.getPageStatusList' => 'this:wp_getPageStatusList',
- 'wp.getPageTemplates' => 'this:wp_getPageTemplates',
- 'wp.getOptions' => 'this:wp_getOptions',
- 'wp.setOptions' => 'this:wp_setOptions',
- 'wp.getComment' => 'this:wp_getComment',
- 'wp.getComments' => 'this:wp_getComments',
- 'wp.deleteComment' => 'this:wp_deleteComment',
- 'wp.editComment' => 'this:wp_editComment',
- 'wp.newComment' => 'this:wp_newComment',
- 'wp.getCommentStatusList' => 'this:wp_getCommentStatusList',
-
- // Blogger API
- 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
- 'blogger.getUserInfo' => 'this:blogger_getUserInfo',
- 'blogger.getPost' => 'this:blogger_getPost',
- 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts',
- 'blogger.getTemplate' => 'this:blogger_getTemplate',
- 'blogger.setTemplate' => 'this:blogger_setTemplate',
- 'blogger.newPost' => 'this:blogger_newPost',
- 'blogger.editPost' => 'this:blogger_editPost',
- 'blogger.deletePost' => 'this:blogger_deletePost',
-
- // MetaWeblog API (with MT extensions to structs)
- 'metaWeblog.newPost' => 'this:mw_newPost',
- 'metaWeblog.editPost' => 'this:mw_editPost',
- 'metaWeblog.getPost' => 'this:mw_getPost',
- 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts',
- 'metaWeblog.getCategories' => 'this:mw_getCategories',
- 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject',
-
- // MetaWeblog API aliases for Blogger API
- // see http://www.xmlrpc.com/stories/storyReader$2460
- 'metaWeblog.deletePost' => 'this:blogger_deletePost',
- 'metaWeblog.getTemplate' => 'this:blogger_getTemplate',
- 'metaWeblog.setTemplate' => 'this:blogger_setTemplate',
- 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs',
-
- // MovableType API
- 'mt.getCategoryList' => 'this:mt_getCategoryList',
- 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles',
- 'mt.getPostCategories' => 'this:mt_getPostCategories',
- 'mt.setPostCategories' => 'this:mt_setPostCategories',
- 'mt.supportedMethods' => 'this:mt_supportedMethods',
- 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters',
- 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings',
- 'mt.publishPost' => 'this:mt_publishPost',
-
- // PingBack
- 'pingback.ping' => 'this:pingback_ping',
- 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',
-
- 'demo.sayHello' => 'this:sayHello',
- 'demo.addTwoNumbers' => 'this:addTwoNumbers'
- );
-
- $this->initialise_blog_option_info( );
- $this->methods = apply_filters('xmlrpc_methods', $this->methods);
- }
-
- function serve_request() {
- $this->IXR_Server($this->methods);
- }
-
- /**
- * Test XMLRPC API by saying, "Hello!" to client.
- *
- * @since 1.5.0
- *
- * @param array $args Method Parameters.
- * @return string
- */
- function sayHello($args) {
- return 'Hello!';
- }
-
- /**
- * Test XMLRPC API by adding two numbers for client.
- *
- * @since 1.5.0
- *
- * @param array $args Method Parameters.
- * @return int
- */
- function addTwoNumbers($args) {
- $number1 = $args[0];
- $number2 = $args[1];
- return $number1 + $number2;
- }
-
- /**
- * Check user's credentials.
- *
- * @since 1.5.0
- *
- * @param string $user_login User's username.
- * @param string $user_pass User's password.
- * @return bool Whether authentication passed.
- * @deprecated use wp_xmlrpc_server::login
- * @see wp_xmlrpc_server::login
- */
- function login_pass_ok($user_login, $user_pass) {
- if ( !get_option( 'enable_xmlrpc' ) ) {
- $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site. An admin user can enable them at %s'), admin_url('options-writing.php') ) );
- return false;
- }
-
- if (!user_pass_ok($user_login, $user_pass)) {
- $this->error = new IXR_Error(403, __('Bad login/pass combination.'));
- return false;
- }
- return true;
- }
-
- /**
- * Log user in.
- *
- * @since 2.8
- *
- * @param string $username User's username.
- * @param string $password User's password.
- * @return mixed WP_User object if authentication passed, false otherwise
- */
- function login($username, $password) {
- if ( !get_option( 'enable_xmlrpc' ) ) {
- $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site. An admin user can enable them at %s'), admin_url('options-writing.php') ) );
- return false;
- }
-
- $user = wp_authenticate($username, $password);
-
- if (is_wp_error($user)) {
- $this->error = new IXR_Error(403, __('Bad login/pass combination.'));
- return false;
- }
-
- wp_set_current_user( $user->ID );
- return $user;
- }
-
- /**
- * Sanitize string or array of strings for database.
- *
- * @since 1.5.2
- *
- * @param string|array $array Sanitize single string or array of strings.
- * @return string|array Type matches $array and sanitized for the database.
- */
- function escape(&$array) {
- global $wpdb;
-
- if (!is_array($array)) {
- return($wpdb->escape($array));
- } else {
- foreach ( (array) $array as $k => $v ) {
- if ( is_array($v) ) {
- $this->escape($array[$k]);
- } else if ( is_object($v) ) {
- //skip
- } else {
- $array[$k] = $wpdb->escape($v);
- }
- }
- }
- }
-
- /**
- * Retrieve custom fields for post.
- *
- * @since 2.5.0
- *
- * @param int $post_id Post ID.
- * @return array Custom fields, if exist.
- */
- function get_custom_fields($post_id) {
- $post_id = (int) $post_id;
-
- $custom_fields = array();
-
- foreach ( (array) has_meta($post_id) as $meta ) {
- // Don't expose protected fields.
- if ( strpos($meta['meta_key'], '_wp_') === 0 ) {
- continue;
- }
-
- $custom_fields[] = array(
- "id" => $meta['meta_id'],
- "key" => $meta['meta_key'],
- "value" => $meta['meta_value']
- );
- }
-
- return $custom_fields;
- }
-
- /**
- * Set custom fields for post.
- *
- * @since 2.5.0
- *
- * @param int $post_id Post ID.
- * @param array $fields Custom fields.
- */
- function set_custom_fields($post_id, $fields) {
- $post_id = (int) $post_id;
-
- foreach ( (array) $fields as $meta ) {
- if ( isset($meta['id']) ) {
- $meta['id'] = (int) $meta['id'];
-
- if ( isset($meta['key']) ) {
- update_meta($meta['id'], $meta['key'], $meta['value']);
- }
- else {
- delete_meta($meta['id']);
- }
- }
- else {
- $_POST['metakeyinput'] = $meta['key'];
- $_POST['metavalue'] = $meta['value'];
- add_meta($post_id);
- }
- }
- }
-
- /**
- * Set up blog options property.
- *
- * Passes property through 'xmlrpc_blog_options' filter.
- *
- * @since 2.6.0
- */
- function initialise_blog_option_info( ) {
- global $wp_version;
-
- $this->blog_options = array(
- // Read only options
- 'software_name' => array(
- 'desc' => __( 'Software Name' ),
- 'readonly' => true,
- 'value' => 'WordPress'
- ),
- 'software_version' => array(
- 'desc' => __( 'Software Version' ),
- 'readonly' => true,
- 'value' => $wp_version
- ),
- 'blog_url' => array(
- 'desc' => __( 'Site URL' ),
- 'readonly' => true,
- 'option' => 'siteurl'
- ),
-
- // Updatable options
- 'time_zone' => array(
- 'desc' => __( 'Time Zone' ),
- 'readonly' => false,
- 'option' => 'gmt_offset'
- ),
- 'blog_title' => array(
- 'desc' => __( 'Site Title' ),
- 'readonly' => false,
- 'option' => 'blogname'
- ),
- 'blog_tagline' => array(
- 'desc' => __( 'Site Tagline' ),
- 'readonly' => false,
- 'option' => 'blogdescription'
- ),
- 'date_format' => array(
- 'desc' => __( 'Date Format' ),
- 'readonly' => false,
- 'option' => 'date_format'
- ),
- 'time_format' => array(
- 'desc' => __( 'Time Format' ),
- 'readonly' => false,
- 'option' => 'time_format'
- ),
- 'users_can_register' => array(
- 'desc' => __( 'Allow new users to sign up' ),
- 'readonly' => false,
- 'option' => 'users_can_register'
- )
- );
-
- $this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options );
- }
-
- /**
- * Retrieve the blogs of the user.
- *
- * @since 2.6.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getUsersBlogs( $args ) {
- global $current_site;
- // If this isn't on WPMU then just use blogger_getUsersBlogs
- if ( !is_multisite() ) {
- array_unshift( $args, 1 );
- return $this->blogger_getUsersBlogs( $args );
- }
-
- $this->escape( $args );
-
- $username = $args[0];
- $password = $args[1];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
-
- do_action( 'xmlrpc_call', 'wp.getUsersBlogs' );
-
- $blogs = (array) get_blogs_of_user( $user->ID );
- $struct = array( );
-
- foreach ( $blogs as $blog ) {
- // Don't include blogs that aren't hosted at this site
- if ( $blog->site_id != $current_site->id )
- continue;
-
- $blog_id = $blog->userblog_id;
- switch_to_blog($blog_id);
- $is_admin = current_user_can('manage_options');
-
- $struct[] = array(
- 'isAdmin' => $is_admin,
- 'url' => get_option( 'home' ) . '/',
- 'blogid' => $blog_id,
- 'blogName' => get_option( 'blogname' ),
- 'xmlrpc' => site_url( 'xmlrpc.php' )
- );
-
- restore_current_blog( );
- }
-
- return $struct;
- }
-
- /**
- * Retrieve page.
- *
- * @since 2.2.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getPage($args) {
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $page_id = (int) $args[1];
- $username = $args[2];
- $password = $args[3];
-
- if ( !$user = $this->login($username, $password) ) {
- return $this->error;
- }
-
- if ( !current_user_can( 'edit_page', $page_id ) )
- return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) );
-
- do_action('xmlrpc_call', 'wp.getPage');
-
- // Lookup page info.
- $page = get_page($page_id);
-
- // If we found the page then format the data.
- if ( $page->ID && ($page->post_type == "page") ) {
- // Get all of the page content and link.
- $full_page = get_extended($page->post_content);
- $link = post_permalink($page->ID);
-
- // Get info the page parent if there is one.
- $parent_title = "";
- if ( !empty($page->post_parent) ) {
- $parent = get_page($page->post_parent);
- $parent_title = $parent->post_title;
- }
-
- // Determine comment and ping settings.
- $allow_comments = comments_open($page->ID) ? 1 : 0;
- $allow_pings = pings_open($page->ID) ? 1 : 0;
-
- // Format page date.
- $page_date = mysql2date("Ymd\TH:i:s", $page->post_date, false);
- $page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false);
-
- // For drafts use the GMT version of the date
- if ( $page->post_status == 'draft' )
- $page_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page->post_date ), 'Ymd\TH:i:s' );
-
- // Pull the categories info together.
- $categories = array();
- foreach ( wp_get_post_categories($page->ID) as $cat_id ) {
- $categories[] = get_cat_name($cat_id);
- }
-
- // Get the author info.
- $author = get_userdata($page->post_author);
-
- $page_template = get_post_meta( $page->ID, '_wp_page_template', true );
- if ( empty( $page_template ) )
- $page_template = 'default';
-
- $page_struct = array(
- "dateCreated" => new IXR_Date($page_date),
- "userid" => $page->post_author,
- "page_id" => $page->ID,
- "page_status" => $page->post_status,
- "description" => $full_page["main"],
- "title" => $page->post_title,
- "link" => $link,
- "permaLink" => $link,
- "categories" => $categories,
- "excerpt" => $page->post_excerpt,
- "text_more" => $full_page["extended"],
- "mt_allow_comments" => $allow_comments,
- "mt_allow_pings" => $allow_pings,
- "wp_slug" => $page->post_name,
- "wp_password" => $page->post_password,
- "wp_author" => $author->display_name,
- "wp_page_parent_id" => $page->post_parent,
- "wp_page_parent_title" => $parent_title,
- "wp_page_order" => $page->menu_order,
- "wp_author_id" => $author->ID,
- "wp_author_display_name" => $author->display_name,
- "date_created_gmt" => new IXR_Date($page_date_gmt),
- "custom_fields" => $this->get_custom_fields($page_id),
- "wp_page_template" => $page_template
- );
-
- return($page_struct);
- }
- // If the page doesn't exist indicate that.
- else {
- return(new IXR_Error(404, __("Sorry, no such page.")));
- }
- }
-
- /**
- * Retrieve Pages.
- *
- * @since 2.2.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getPages($args) {
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $num_pages = isset($args[3]) ? (int) $args[3] : 10;
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_pages' ) )
- return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) );
-
- do_action('xmlrpc_call', 'wp.getPages');
-
- $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) );
- $num_pages = count($pages);
-
- // If we have pages, put together their info.
- if ( $num_pages >= 1 ) {
- $pages_struct = array();
-
- for ( $i = 0; $i < $num_pages; $i++ ) {
- $page = wp_xmlrpc_server::wp_getPage(array(
- $blog_id, $pages[$i]->ID, $username, $password
- ));
- $pages_struct[] = $page;
- }
-
- return($pages_struct);
- }
- // If no pages were found return an error.
- else {
- return(array());
- }
- }
-
- /**
- * Create new page.
- *
- * @since 2.2.0
- *
- * @param array $args Method parameters.
- * @return unknown
- */
- function wp_newPage($args) {
- // Items not escaped here will be escaped in newPost.
- $username = $this->escape($args[1]);
- $password = $this->escape($args[2]);
- $page = $args[3];
- $publish = $args[4];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'wp.newPage');
-
- // Make sure the user is allowed to add new pages.
- if ( !current_user_can("publish_pages") )
- return(new IXR_Error(401, __("Sorry, you cannot add new pages.")));
-
- // Mark this as content for a page.
- $args[3]["post_type"] = "page";
-
- // Let mw_newPost do all of the heavy lifting.
- return($this->mw_newPost($args));
- }
-
- /**
- * Delete page.
- *
- * @since 2.2.0
- *
- * @param array $args Method parameters.
- * @return bool True, if success.
- */
- function wp_deletePage($args) {
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $page_id = (int) $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'wp.deletePage');
-
- // Get the current page based on the page_id and
- // make sure it is a page and not a post.
- $actual_page = wp_get_single_post($page_id, ARRAY_A);
- if ( !$actual_page || ($actual_page["post_type"] != "page") )
- return(new IXR_Error(404, __("Sorry, no such page.")));
-
- // Make sure the user can delete pages.
- if ( !current_user_can("delete_page", $page_id) )
- return(new IXR_Error(401, __("Sorry, you do not have the right to delete this page.")));
-
- // Attempt to delete the page.
- $result = wp_delete_post($page_id);
- if ( !$result )
- return(new IXR_Error(500, __("Failed to delete the page.")));
-
- return(true);
- }
-
- /**
- * Edit page.
- *
- * @since 2.2.0
- *
- * @param array $args Method parameters.
- * @return unknown
- */
- function wp_editPage($args) {
- // Items not escaped here will be escaped in editPost.
- $blog_id = (int) $args[0];
- $page_id = (int) $this->escape($args[1]);
- $username = $this->escape($args[2]);
- $password = $this->escape($args[3]);
- $content = $args[4];
- $publish = $args[5];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'wp.editPage');
-
- // Get the page data and make sure it is a page.
- $actual_page = wp_get_single_post($page_id, ARRAY_A);
- if ( !$actual_page || ($actual_page["post_type"] != "page") )
- return(new IXR_Error(404, __("Sorry, no such page.")));
-
- // Make sure the user is allowed to edit pages.
- if ( !current_user_can("edit_page", $page_id) )
- return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page.")));
-
- // Mark this as content for a page.
- $content["post_type"] = "page";
-
- // Arrange args in the way mw_editPost understands.
- $args = array(
- $page_id,
- $username,
- $password,
- $content,
- $publish
- );
-
- // Let mw_editPost do all of the heavy lifting.
- return($this->mw_editPost($args));
- }
-
- /**
- * Retrieve page list.
- *
- * @since 2.2.0
- *
- * @param array $args Method parameters.
- * @return unknown
- */
- function wp_getPageList($args) {
- global $wpdb;
-
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_pages' ) )
- return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) );
-
- do_action('xmlrpc_call', 'wp.getPageList');
-
- // Get list of pages ids and titles
- $page_list = $wpdb->get_results("
- SELECT ID page_id,
- post_title page_title,
- post_parent page_parent_id,
- post_date_gmt,
- post_date,
- post_status
- FROM {$wpdb->posts}
- WHERE post_type = 'page'
- ORDER BY ID
- ");
-
- // The date needs to be formated properly.
- $num_pages = count($page_list);
- for ( $i = 0; $i < $num_pages; $i++ ) {
- $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date, false);
- $post_date_gmt = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt, false);
-
- $page_list[$i]->dateCreated = new IXR_Date($post_date);
- $page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt);
-
- // For drafts use the GMT version of the date
- if ( $page_list[$i]->post_status == 'draft' ) {
- $page_list[$i]->date_created_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page_list[$i]->post_date ), 'Ymd\TH:i:s' );
- $page_list[$i]->date_created_gmt = new IXR_Date( $page_list[$i]->date_created_gmt );
- }
-
- unset($page_list[$i]->post_date_gmt);
- unset($page_list[$i]->post_date);
- unset($page_list[$i]->post_status);
- }
-
- return($page_list);
- }
-
- /**
- * Retrieve authors list.
- *
- * @since 2.2.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getAuthors($args) {
-
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can("edit_posts") )
- return(new IXR_Error(401, __("Sorry, you cannot edit posts on this site.")));
-
- do_action('xmlrpc_call', 'wp.getAuthors');
-
- $authors = array();
- foreach ( (array) get_users_of_blog() as $row ) {
- $authors[] = array(
- "user_id" => $row->user_id,
- "user_login" => $row->user_login,
- "display_name" => $row->display_name
- );
- }
-
- return($authors);
- }
-
- /**
- * Get list of all tags
- *
- * @since 2.7
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getTags( $args ) {
- $this->escape( $args );
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_posts' ) )
- return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) );
-
- do_action( 'xmlrpc_call', 'wp.getKeywords' );
-
- $tags = array( );
-
- if ( $all_tags = get_tags() ) {
- foreach( (array) $all_tags as $tag ) {
- $struct['tag_id'] = $tag->term_id;
- $struct['name'] = $tag->name;
- $struct['count'] = $tag->count;
- $struct['slug'] = $tag->slug;
- $struct['html_url'] = esc_html( get_tag_link( $tag->term_id ) );
- $struct['rss_url'] = esc_html( get_tag_feed_link( $tag->term_id ) );
-
- $tags[] = $struct;
- }
- }
-
- return $tags;
- }
-
- /**
- * Create new category.
- *
- * @since 2.2.0
- *
- * @param array $args Method parameters.
- * @return int Category ID.
- */
- function wp_newCategory($args) {
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $category = $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'wp.newCategory');
-
- // Make sure the user is allowed to add a category.
- if ( !current_user_can("manage_categories") )
- return(new IXR_Error(401, __("Sorry, you do not have the right to add a category.")));
-
- // If no slug was provided make it empty so that
- // WordPress will generate one.
- if ( empty($category["slug"]) )
- $category["slug"] = "";
-
- // If no parent_id was provided make it empty
- // so that it will be a top level page (no parent).
- if ( !isset($category["parent_id"]) )
- $category["parent_id"] = "";
-
- // If no description was provided make it empty.
- if ( empty($category["description"]) )
- $category["description"] = "";
-
- $new_category = array(
- "cat_name" => $category["name"],
- "category_nicename" => $category["slug"],
- "category_parent" => $category["parent_id"],
- "category_description" => $category["description"]
- );
-
- $cat_id = wp_insert_category($new_category, true);
- if ( is_wp_error( $cat_id ) ) {
- if ( 'term_exists' == $cat_id->get_error_code() )
- return (int) $cat_id->get_error_data();
- else
- return(new IXR_Error(500, __("Sorry, the new category failed.")));
- } elseif ( ! $cat_id ) {
- return(new IXR_Error(500, __("Sorry, the new category failed.")));
- }
-
- return($cat_id);
- }
-
- /**
- * Remove category.
- *
- * @since 2.5.0
- *
- * @param array $args Method parameters.
- * @return mixed See {@link wp_delete_category()} for return info.
- */
- function wp_deleteCategory($args) {
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $category_id = (int) $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'wp.deleteCategory');
-
- if ( !current_user_can("manage_categories") )
- return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) );
-
- return wp_delete_category( $category_id );
- }
-
- /**
- * Retrieve category list.
- *
- * @since 2.2.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_suggestCategories($args) {
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $category = $args[3];
- $max_results = (int) $args[4];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_posts' ) )
- return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) );
-
- do_action('xmlrpc_call', 'wp.suggestCategories');
-
- $category_suggestions = array();
- $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category);
- foreach ( (array) get_categories($args) as $cat ) {
- $category_suggestions[] = array(
- "category_id" => $cat->cat_ID,
- "category_name" => $cat->cat_name
- );
- }
-
- return($category_suggestions);
- }
-
- /**
- * Retrieve comment.
- *
- * @since 2.7.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getComment($args) {
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $comment_id = (int) $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'moderate_comments' ) )
- return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
-
- do_action('xmlrpc_call', 'wp.getComment');
-
- if ( ! $comment = get_comment($comment_id) )
- return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
-
- // Format page date.
- $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false);
- $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false);
-
- if ( '0' == $comment->comment_approved )
- $comment_status = 'hold';
- else if ( 'spam' == $comment->comment_approved )
- $comment_status = 'spam';
- else if ( '1' == $comment->comment_approved )
- $comment_status = 'approve';
- else
- $comment_status = $comment->comment_approved;
-
- $link = get_comment_link($comment);
-
- $comment_struct = array(
- "date_created_gmt" => new IXR_Date($comment_date_gmt),
- "user_id" => $comment->user_id,
- "comment_id" => $comment->comment_ID,
- "parent" => $comment->comment_parent,
- "status" => $comment_status,
- "content" => $comment->comment_content,
- "link" => $link,
- "post_id" => $comment->comment_post_ID,
- "post_title" => get_the_title($comment->comment_post_ID),
- "author" => $comment->comment_author,
- "author_url" => $comment->comment_author_url,
- "author_email" => $comment->comment_author_email,
- "author_ip" => $comment->comment_author_IP,
- "type" => $comment->comment_type,
- );
-
- return $comment_struct;
- }
-
- /**
- * Retrieve comments.
- *
- * @since 2.7.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getComments($args) {
- $raw_args = $args;
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $struct = $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'moderate_comments' ) )
- return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) );
-
- do_action('xmlrpc_call', 'wp.getComments');
-
- if ( isset($struct['status']) )
- $status = $struct['status'];
- else
- $status = '';
-
- $post_id = '';
- if ( isset($struct['post_id']) )
- $post_id = absint($struct['post_id']);
-
- $offset = 0;
- if ( isset($struct['offset']) )
- $offset = absint($struct['offset']);
-
- $number = 10;
- if ( isset($struct['number']) )
- $number = absint($struct['number']);
-
- $comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
- $num_comments = count($comments);
-
- if ( ! $num_comments )
- return array();
-
- $comments_struct = array();
-
- for ( $i = 0; $i < $num_comments; $i++ ) {
- $comment = wp_xmlrpc_server::wp_getComment(array(
- $raw_args[0], $raw_args[1], $raw_args[2], $comments[$i]->comment_ID,
- ));
- $comments_struct[] = $comment;
- }
-
- return $comments_struct;
- }
-
- /**
- * Remove comment.
- *
- * @since 2.7.0
- *
- * @param array $args Method parameters.
- * @return mixed {@link wp_delete_comment()}
- */
- function wp_deleteComment($args) {
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $comment_ID = (int) $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'moderate_comments' ) )
- return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
-
- do_action('xmlrpc_call', 'wp.deleteComment');
-
- if ( !$comment = get_comment( $comment_ID ) )
- return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
-
- if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
- return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
-
- return wp_delete_comment($comment_ID);
- }
-
- /**
- * Edit comment.
- *
- * @since 2.7.0
- *
- * @param array $args Method parameters.
- * @return bool True, on success.
- */
- function wp_editComment($args) {
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $comment_ID = (int) $args[3];
- $content_struct = $args[4];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'moderate_comments' ) )
- return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
-
- if ( !$comment = get_comment( $comment_ID ) )
- return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
-
- if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
- return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
-
- do_action('xmlrpc_call', 'wp.editComment');
-
- if ( isset($content_struct['status']) ) {
- $statuses = get_comment_statuses();
- $statuses = array_keys($statuses);
-
- if ( ! in_array($content_struct['status'], $statuses) )
- return new IXR_Error( 401, __( 'Invalid comment status.' ) );
- $comment_approved = $content_struct['status'];
- }
-
- // Do some timestamp voodoo
- if ( !empty( $content_struct['date_created_gmt'] ) ) {
- $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force
- $comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
- $comment_date_gmt = iso8601_to_datetime($dateCreated, GMT);
- }
-
- if ( isset($content_struct['content']) )
- $comment_content = $content_struct['content'];
-
- if ( isset($content_struct['author']) )
- $comment_author = $content_struct['author'];
-
- if ( isset($content_struct['author_url']) )
- $comment_author_url = $content_struct['author_url'];
-
- if ( isset($content_struct['author_email']) )
- $comment_author_email = $content_struct['author_email'];
-
- // We've got all the data -- post it:
- $comment = compact('comment_ID', 'comment_content', 'comment_approved', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url');
-
- $result = wp_update_comment($comment);
- if ( is_wp_error( $result ) )
- return new IXR_Error(500, $result->get_error_message());
-
- if ( !$result )
- return new IXR_Error(500, __('Sorry, the comment could not be edited. Something wrong happened.'));
-
- return true;
- }
-
- /**
- * Create new comment.
- *
- * @since 2.7.0
- *
- * @param array $args Method parameters.
- * @return mixed {@link wp_new_comment()}
- */
- function wp_newComment($args) {
- global $wpdb;
-
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $post = $args[3];
- $content_struct = $args[4];
-
- $allow_anon = apply_filters('xmlrpc_allow_anonymous_comments', false);
-
- $user = $this->login($username, $password);
-
- if ( !$user ) {
- $logged_in = false;
- if ( $allow_anon && get_option('comment_registration') )
- return new IXR_Error( 403, __( 'You must be registered to comment' ) );
- else if ( !$allow_anon )
- return $this->error;
- } else {
- $logged_in = true;
- }
-
- if ( is_numeric($post) )
- $post_id = absint($post);
- else
- $post_id = url_to_postid($post);
-
- if ( ! $post_id )
- return new IXR_Error( 404, __( 'Invalid post ID.' ) );
-
- if ( ! get_post($post_id) )
- return new IXR_Error( 404, __( 'Invalid post ID.' ) );
-
- $comment['comment_post_ID'] = $post_id;
-
- if ( $logged_in ) {
- $comment['comment_author'] = $wpdb->escape( $user->display_name );
- $comment['comment_author_email'] = $wpdb->escape( $user->user_email );
- $comment['comment_author_url'] = $wpdb->escape( $user->user_url );
- $comment['user_ID'] = $user->ID;
- } else {
- $comment['comment_author'] = '';
- if ( isset($content_struct['author']) )
- $comment['comment_author'] = $content_struct['author'];
-
- $comment['comment_author_email'] = '';
- if ( isset($content_struct['author_email']) )
- $comment['comment_author_email'] = $content_struct['author_email'];
-
- $comment['comment_author_url'] = '';
- if ( isset($content_struct['author_url']) )
- $comment['comment_author_url'] = $content_struct['author_url'];
-
- $comment['user_ID'] = 0;
-
- if ( get_option('require_name_email') ) {
- if ( 6 > strlen($comment['comment_author_email']) || '' == $comment['comment_author'] )
- return new IXR_Error( 403, __( 'Comment author name and email are required' ) );
- elseif ( !is_email($comment['comment_author_email']) )
- return new IXR_Error( 403, __( 'A valid email address is required' ) );
- }
- }
-
- $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0;
-
- $comment['comment_content'] = $content_struct['content'];
-
- do_action('xmlrpc_call', 'wp.newComment');
-
- return wp_new_comment($comment);
- }
-
- /**
- * Retrieve all of the comment status.
- *
- * @since 2.7.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getCommentStatusList($args) {
- $this->escape( $args );
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'moderate_comments' ) )
- return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
-
- do_action('xmlrpc_call', 'wp.getCommentStatusList');
-
- return get_comment_statuses( );
- }
-
- /**
- * Retrieve comment count.
- *
- * @since 2.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getCommentCount( $args ) {
- $this->escape($args);
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $post_id = (int) $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_posts' ) )
- return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) );
-
- do_action('xmlrpc_call', 'wp.getCommentCount');
-
- $count = wp_count_comments( $post_id );
- return array(
- "approved" => $count->approved,
- "awaiting_moderation" => $count->moderated,
- "spam" => $count->spam,
- "total_comments" => $count->total_comments
- );
- }
-
- /**
- * Retrieve post statuses.
- *
- * @since 2.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getPostStatusList( $args ) {
- $this->escape( $args );
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_posts' ) )
- return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
-
- do_action('xmlrpc_call', 'wp.getPostStatusList');
-
- return get_post_statuses( );
- }
-
- /**
- * Retrieve page statuses.
- *
- * @since 2.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getPageStatusList( $args ) {
- $this->escape( $args );
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_pages' ) )
- return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
-
- do_action('xmlrpc_call', 'wp.getPageStatusList');
-
- return get_page_statuses( );
- }
-
- /**
- * Retrieve page templates.
- *
- * @since 2.6.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getPageTemplates( $args ) {
- $this->escape( $args );
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_pages' ) )
- return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
-
- $templates = get_page_templates( );
- $templates['Default'] = 'default';
-
- return $templates;
- }
-
- /**
- * Retrieve blog options.
- *
- * @since 2.6.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function wp_getOptions( $args ) {
- $this->escape( $args );
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $options = (array) $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- // If no specific options where asked for, return all of them
- if ( count( $options ) == 0 )
- $options = array_keys($this->blog_options);
-
- return $this->_getOptions($options);
- }
-
- /**
- * Retrieve blog options value from list.
- *
- * @since 2.6.0
- *
- * @param array $options Options to retrieve.
- * @return array
- */
- function _getOptions($options) {
- $data = array( );
- foreach ( $options as $option ) {
- if ( array_key_exists( $option, $this->blog_options ) ) {
- $data[$option] = $this->blog_options[$option];
- //Is the value static or dynamic?
- if ( isset( $data[$option]['option'] ) ) {
- $data[$option]['value'] = get_option( $data[$option]['option'] );
- unset($data[$option]['option']);
- }
- }
- }
-
- return $data;
- }
-
- /**
- * Update blog options.
- *
- * @since 2.6.0
- *
- * @param array $args Method parameters.
- * @return unknown
- */
- function wp_setOptions( $args ) {
- $this->escape( $args );
-
- $blog_id = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $options = (array) $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'manage_options' ) )
- return new IXR_Error( 403, __( 'You are not allowed to update options.' ) );
-
- foreach ( $options as $o_name => $o_value ) {
- $option_names[] = $o_name;
- if ( !array_key_exists( $o_name, $this->blog_options ) )
- continue;
-
- if ( $this->blog_options[$o_name]['readonly'] == true )
- continue;
-
- update_option( $this->blog_options[$o_name]['option'], $o_value );
- }
-
- //Now return the updated values
- return $this->_getOptions($option_names);
- }
-
- /* Blogger API functions.
- * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
- */
-
- /**
- * Retrieve blogs that user owns.
- *
- * Will make more sense once we support multiple blogs.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function blogger_getUsersBlogs($args) {
- if ( is_multisite() )
- return $this->_multisite_getUsersBlogs($args);
-
- $this->escape($args);
-
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'blogger.getUsersBlogs');
-
- $is_admin = current_user_can('manage_options');
-
- $struct = array(
- 'isAdmin' => $is_admin,
- 'url' => get_option('home') . '/',
- 'blogid' => '1',
- 'blogName' => get_option('blogname'),
- 'xmlrpc' => site_url( 'xmlrpc.php' )
- );
-
- return array($struct);
- }
-
- /**
- * Private function for retrieving a users blogs for multisite setups
- *
- * @access protected
- */
- function _multisite_getUsersBlogs($args) {
- global $current_blog;
- $domain = $current_blog->domain;
- $path = $current_blog->path . 'xmlrpc.php';
- $protocol = is_ssl() ? 'https' : 'http';
-
- $rpc = new IXR_Client("$protocol://{$domain}{$path}");
- $rpc->query('wp.getUsersBlogs', $args[1], $args[2]);
- $blogs = $rpc->getResponse();
-
- if ( isset($blogs['faultCode']) )
- return new IXR_Error($blogs['faultCode'], $blogs['faultString']);
-
- if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) {
- return $blogs;
- } else {
- foreach ( (array) $blogs as $blog ) {
- if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) )
- return array($blog);
- }
- return array();
- }
- }
-
- /**
- * Retrieve user's data.
- *
- * Gives your client some info about you, so you don't have to.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function blogger_getUserInfo($args) {
-
- $this->escape($args);
-
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_posts' ) )
- return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) );
-
- do_action('xmlrpc_call', 'blogger.getUserInfo');
-
- $struct = array(
- 'nickname' => $user->nickname,
- 'userid' => $user->ID,
- 'url' => $user->user_url,
- 'lastname' => $user->last_name,
- 'firstname' => $user->first_name
- );
-
- return $struct;
- }
-
- /**
- * Retrieve post.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function blogger_getPost($args) {
-
- $this->escape($args);
-
- $post_ID = (int) $args[1];
- $username = $args[2];
- $password = $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_post', $post_ID ) )
- return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
-
- do_action('xmlrpc_call', 'blogger.getPost');
-
- $post_data = wp_get_single_post($post_ID, ARRAY_A);
-
- $categories = implode(',', wp_get_post_categories($post_ID));
-
- $content = ''.stripslashes($post_data['post_title']).'';
- $content .= ''.$categories.'';
- $content .= stripslashes($post_data['post_content']);
-
- $struct = array(
- 'userid' => $post_data['post_author'],
- 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'], false)),
- 'content' => $content,
- 'postid' => $post_data['ID']
- );
-
- return $struct;
- }
-
- /**
- * Retrieve list of recent posts.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function blogger_getRecentPosts($args) {
-
- $this->escape($args);
-
- $blog_ID = (int) $args[1]; /* though we don't use it yet */
- $username = $args[2];
- $password = $args[3];
- $num_posts = $args[4];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'blogger.getRecentPosts');
-
- $posts_list = wp_get_recent_posts($num_posts);
-
- if ( !$posts_list ) {
- $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.'));
- return $this->error;
- }
-
- foreach ($posts_list as $entry) {
- if ( !current_user_can( 'edit_post', $entry['ID'] ) )
- continue;
-
- $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
- $categories = implode(',', wp_get_post_categories($entry['ID']));
-
- $content = ''.stripslashes($entry['post_title']).'';
- $content .= ''.$categories.'';
- $content .= stripslashes($entry['post_content']);
-
- $struct[] = array(
- 'userid' => $entry['post_author'],
- 'dateCreated' => new IXR_Date($post_date),
- 'content' => $content,
- 'postid' => $entry['ID'],
- );
-
- }
-
- $recent_posts = array();
- for ( $j=0; $jescape($args);
-
- $blog_ID = (int) $args[1];
- $username = $args[2];
- $password = $args[3];
- $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'blogger.getTemplate');
-
- if ( !current_user_can('edit_themes') )
- return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
-
- /* warning: here we make the assumption that the blog's URL is on the same server */
- $filename = get_option('home') . '/';
- $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
-
- $f = fopen($filename, 'r');
- $content = fread($f, filesize($filename));
- fclose($f);
-
- /* so it is actually editable with a windows/mac client */
- // FIXME: (or delete me) do we really want to cater to bad clients at the expense of good ones by BEEPing up their line breaks? commented. $content = str_replace("\n", "\r\n", $content);
-
- return $content;
- }
-
- /**
- * Updates the content of blog_filename.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return bool True when done.
- */
- function blogger_setTemplate($args) {
-
- $this->escape($args);
-
- $blog_ID = (int) $args[1];
- $username = $args[2];
- $password = $args[3];
- $content = $args[4];
- $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'blogger.setTemplate');
-
- if ( !current_user_can('edit_themes') )
- return new IXR_Error(401, __('Sorry, this user cannot edit the template.'));
-
- /* warning: here we make the assumption that the blog's URL is on the same server */
- $filename = get_option('home') . '/';
- $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
-
- if ($f = fopen($filename, 'w+')) {
- fwrite($f, $content);
- fclose($f);
- } else {
- return new IXR_Error(500, __('Either the file is not writable, or something wrong happened. The file has not been updated.'));
- }
-
- return true;
- }
-
- /**
- * Create new post.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return int
- */
- function blogger_newPost($args) {
-
- $this->escape($args);
-
- $blog_ID = (int) $args[1]; /* though we don't use it yet */
- $username = $args[2];
- $password = $args[3];
- $content = $args[4];
- $publish = $args[5];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'blogger.newPost');
-
- $cap = ($publish) ? 'publish_posts' : 'edit_posts';
- if ( !current_user_can($cap) )
- return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.'));
-
- $post_status = ($publish) ? 'publish' : 'draft';
-
- $post_author = $user->ID;
-
- $post_title = xmlrpc_getposttitle($content);
- $post_category = xmlrpc_getpostcategory($content);
- $post_content = xmlrpc_removepostdata($content);
-
- $post_date = current_time('mysql');
- $post_date_gmt = current_time('mysql', 1);
-
- $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status');
-
- $post_ID = wp_insert_post($post_data);
- if ( is_wp_error( $post_ID ) )
- return new IXR_Error(500, $post_ID->get_error_message());
-
- if ( !$post_ID )
- return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
-
- $this->attach_uploads( $post_ID, $post_content );
-
- logIO('O', "Posted ! ID: $post_ID");
-
- return $post_ID;
- }
-
- /**
- * Edit a post.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return bool true when done.
- */
- function blogger_editPost($args) {
-
- $this->escape($args);
-
- $post_ID = (int) $args[1];
- $username = $args[2];
- $password = $args[3];
- $content = $args[4];
- $publish = $args[5];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'blogger.editPost');
-
- $actual_post = wp_get_single_post($post_ID,ARRAY_A);
-
- if ( !$actual_post || $actual_post['post_type'] != 'post' )
- return new IXR_Error(404, __('Sorry, no such post.'));
-
- $this->escape($actual_post);
-
- if ( !current_user_can('edit_post', $post_ID) )
- return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.'));
-
- extract($actual_post, EXTR_SKIP);
-
- if ( ('publish' == $post_status) && !current_user_can('publish_posts') )
- return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.'));
-
- $post_title = xmlrpc_getposttitle($content);
- $post_category = xmlrpc_getpostcategory($content);
- $post_content = xmlrpc_removepostdata($content);
-
- $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt');
-
- $result = wp_update_post($postdata);
-
- if ( !$result )
- return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be edited.'));
-
- $this->attach_uploads( $ID, $post_content );
-
- return true;
- }
-
- /**
- * Remove a post.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return bool True when post is deleted.
- */
- function blogger_deletePost($args) {
- $this->escape($args);
-
- $post_ID = (int) $args[1];
- $username = $args[2];
- $password = $args[3];
- $publish = $args[4];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'blogger.deletePost');
-
- $actual_post = wp_get_single_post($post_ID,ARRAY_A);
-
- if ( !$actual_post || $actual_post['post_type'] != 'post' )
- return new IXR_Error(404, __('Sorry, no such post.'));
-
- if ( !current_user_can('delete_post', $post_ID) )
- return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.'));
-
- $result = wp_delete_post($post_ID);
-
- if ( !$result )
- return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be deleted.'));
-
- return true;
- }
-
- /* MetaWeblog API functions
- * specs on wherever Dave Winer wants them to be
- */
-
- /**
- * Create a new post.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return int
- */
- function mw_newPost($args) {
- $this->escape($args);
-
- $blog_ID = (int) $args[0]; // we will support this in the near future
- $username = $args[1];
- $password = $args[2];
- $content_struct = $args[3];
- $publish = isset( $args[4] ) ? $args[4] : 0;
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'metaWeblog.newPost');
-
- $page_template = '';
- if ( !empty( $content_struct['post_type'] ) ) {
- if ( $content_struct['post_type'] == 'page' ) {
- if ( $publish || 'publish' == $content_struct['page_status'])
- $cap = 'publish_pages';
- else
- $cap = 'edit_pages';
- $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );
- $post_type = 'page';
- if ( !empty( $content_struct['wp_page_template'] ) )
- $page_template = $content_struct['wp_page_template'];
- } elseif ( $content_struct['post_type'] == 'post' ) {
- if ( $publish || 'publish' == $content_struct['post_status'])
- $cap = 'publish_posts';
- else
- $cap = 'edit_posts';
- $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
- $post_type = 'post';
- } else {
- // No other post_type values are allowed here
- return new IXR_Error( 401, __( 'Invalid post type.' ) );
- }
- } else {
- if ( $publish || 'publish' == $content_struct['post_status'])
- $cap = 'publish_posts';
- else
- $cap = 'edit_posts';
- $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
- $post_type = 'post';
- }
-
- if ( !current_user_can( $cap ) )
- return new IXR_Error( 401, $error_message );
-
- // Let WordPress generate the post_name (slug) unless
- // one has been provided.
- $post_name = "";
- if ( isset($content_struct["wp_slug"]) )
- $post_name = $content_struct["wp_slug"];
-
- // Only use a password if one was given.
- if ( isset($content_struct["wp_password"]) )
- $post_password = $content_struct["wp_password"];
-
- // Only set a post parent if one was provided.
- if ( isset($content_struct["wp_page_parent_id"]) )
- $post_parent = $content_struct["wp_page_parent_id"];
-
- // Only set the menu_order if it was provided.
- if ( isset($content_struct["wp_page_order"]) )
- $menu_order = $content_struct["wp_page_order"];
-
- $post_author = $user->ID;
-
- // If an author id was provided then use it instead.
- if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) {
- switch ( $post_type ) {
- case "post":
- if ( !current_user_can("edit_others_posts") )
- return(new IXR_Error(401, __("You are not allowed to post as this user")));
- break;
- case "page":
- if ( !current_user_can("edit_others_pages") )
- return(new IXR_Error(401, __("You are not allowed to create pages as this user")));
- break;
- default:
- return(new IXR_Error(401, __("Invalid post type.")));
- break;
- }
- $post_author = $content_struct["wp_author_id"];
- }
-
- $post_title = $content_struct['title'];
- $post_content = $content_struct['description'];
-
- $post_status = $publish ? 'publish' : 'draft';
-
- if ( isset( $content_struct["{$post_type}_status"] ) ) {
- switch ( $content_struct["{$post_type}_status"] ) {
- case 'draft':
- case 'private':
- case 'publish':
- $post_status = $content_struct["{$post_type}_status"];
- break;
- case 'pending':
- // Pending is only valid for posts, not pages.
- if ( $post_type === 'post' )
- $post_status = $content_struct["{$post_type}_status"];
- break;
- default:
- $post_status = $publish ? 'publish' : 'draft';
- break;
- }
- }
-
- $post_excerpt = $content_struct['mt_excerpt'];
- $post_more = $content_struct['mt_text_more'];
-
- $tags_input = $content_struct['mt_keywords'];
-
- if ( isset($content_struct["mt_allow_comments"]) ) {
- if ( !is_numeric($content_struct["mt_allow_comments"]) ) {
- switch ( $content_struct["mt_allow_comments"] ) {
- case "closed":
- $comment_status = "closed";
- break;
- case "open":
- $comment_status = "open";
- break;
- default:
- $comment_status = get_option("default_comment_status");
- break;
- }
- } else {
- switch ( (int) $content_struct["mt_allow_comments"] ) {
- case 0:
- case 2:
- $comment_status = "closed";
- break;
- case 1:
- $comment_status = "open";
- break;
- default:
- $comment_status = get_option("default_comment_status");
- break;
- }
- }
- } else {
- $comment_status = get_option("default_comment_status");
- }
-
- if ( isset($content_struct["mt_allow_pings"]) ) {
- if ( !is_numeric($content_struct["mt_allow_pings"]) ) {
- switch ( $content_struct['mt_allow_pings'] ) {
- case "closed":
- $ping_status = "closed";
- break;
- case "open":
- $ping_status = "open";
- break;
- default:
- $ping_status = get_option("default_ping_status");
- break;
- }
- } else {
- switch ( (int) $content_struct["mt_allow_pings"] ) {
- case 0:
- $ping_status = "closed";
- break;
- case 1:
- $ping_status = "open";
- break;
- default:
- $ping_status = get_option("default_ping_status");
- break;
- }
- }
- } else {
- $ping_status = get_option("default_ping_status");
- }
-
- if ( $post_more )
- $post_content = $post_content . "" . $post_more;
-
- $to_ping = $content_struct['mt_tb_ping_urls'];
- if ( is_array($to_ping) )
- $to_ping = implode(' ', $to_ping);
-
- // Do some timestamp voodoo
- if ( !empty( $content_struct['date_created_gmt'] ) )
- $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force
- elseif ( !empty( $content_struct['dateCreated']) )
- $dateCreated = $content_struct['dateCreated']->getIso();
-
- if ( !empty( $dateCreated ) ) {
- $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
- $post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
- } else {
- $post_date = current_time('mysql');
- $post_date_gmt = current_time('mysql', 1);
- }
-
- $catnames = $content_struct['categories'];
- logIO('O', 'Post cats: ' . var_export($catnames,true));
- $post_category = array();
-
- if ( is_array($catnames) ) {
- foreach ($catnames as $cat) {
- $post_category[] = get_cat_ID($cat);
- }
- }
-
- // We've got all the data -- post it:
- $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template');
-
- $post_ID = wp_insert_post($postdata, true);
- if ( is_wp_error( $post_ID ) )
- return new IXR_Error(500, $post_ID->get_error_message());
-
- if ( !$post_ID )
- return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
-
- // Only posts can be sticky
- if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
- if ( $content_struct['sticky'] == true )
- stick_post( $post_ID );
- elseif ( $content_struct['sticky'] == false )
- unstick_post( $post_ID );
- }
-
- if ( isset($content_struct['custom_fields']) )
- $this->set_custom_fields($post_ID, $content_struct['custom_fields']);
-
- // Handle enclosures
- $this->add_enclosure_if_new($post_ID, $content_struct['enclosure']);
-
- $this->attach_uploads( $post_ID, $post_content );
-
- logIO('O', "Posted ! ID: $post_ID");
-
- return strval($post_ID);
- }
-
- function add_enclosure_if_new($post_ID, $enclosure) {
- if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
-
- $encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'];
- $found = false;
- foreach ( (array) get_post_custom($post_ID) as $key => $val) {
- if ($key == 'enclosure') {
- foreach ( (array) $val as $enc ) {
- if ($enc == $encstring) {
- $found = true;
- break 2;
- }
- }
- }
- }
- if (!$found)
- add_post_meta( $post_ID, 'enclosure', $encstring );
- }
- }
-
- /**
- * Attach upload to a post.
- *
- * @since 2.1.0
- *
- * @param int $post_ID Post ID.
- * @param string $post_content Post Content for attachment.
- */
- function attach_uploads( $post_ID, $post_content ) {
- global $wpdb;
-
- // find any unattached files
- $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );
- if ( is_array( $attachments ) ) {
- foreach ( $attachments as $file ) {
- if ( strpos( $post_content, $file->guid ) !== false )
- $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) );
- }
- }
- }
-
- /**
- * Edit a post.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return bool True on success.
- */
- function mw_editPost($args) {
-
- $this->escape($args);
-
- $post_ID = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $content_struct = $args[3];
- $publish = $args[4];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'metaWeblog.editPost');
-
- $cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
- $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
- $post_type = 'post';
- $page_template = '';
- if ( !empty( $content_struct['post_type'] ) ) {
- if ( $content_struct['post_type'] == 'page' ) {
- if ( $publish || 'publish' == $content_struct['page_status'] )
- $cap = 'publish_pages';
- else
- $cap = 'edit_pages';
- $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );
- $post_type = 'page';
- if ( !empty( $content_struct['wp_page_template'] ) )
- $page_template = $content_struct['wp_page_template'];
- } elseif ( $content_struct['post_type'] == 'post' ) {
- if ( $publish || 'publish' == $content_struct['post_status'] )
- $cap = 'publish_posts';
- else
- $cap = 'edit_posts';
- $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
- $post_type = 'post';
- } else {
- // No other post_type values are allowed here
- return new IXR_Error( 401, __( 'Invalid post type.' ) );
- }
- } else {
- if ( $publish || 'publish' == $content_struct['post_status'] )
- $cap = 'publish_posts';
- else
- $cap = 'edit_posts';
- $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
- $post_type = 'post';
- }
-
- if ( !current_user_can( $cap ) )
- return new IXR_Error( 401, $error_message );
-
- $postdata = wp_get_single_post($post_ID, ARRAY_A);
-
- // If there is no post data for the give post id, stop
- // now and return an error. Other wise a new post will be
- // created (which was the old behavior).
- if ( empty($postdata["ID"]) )
- return(new IXR_Error(404, __("Invalid post ID.")));
-
- $this->escape($postdata);
- extract($postdata, EXTR_SKIP);
-
- // Let WordPress manage slug if none was provided.
- $post_name = "";
- if ( isset($content_struct["wp_slug"]) )
- $post_name = $content_struct["wp_slug"];
-
- // Only use a password if one was given.
- if ( isset($content_struct["wp_password"]) )
- $post_password = $content_struct["wp_password"];
-
- // Only set a post parent if one was given.
- if ( isset($content_struct["wp_page_parent_id"]) )
- $post_parent = $content_struct["wp_page_parent_id"];
-
- // Only set the menu_order if it was given.
- if ( isset($content_struct["wp_page_order"]) )
- $menu_order = $content_struct["wp_page_order"];
-
- $post_author = $postdata["post_author"];
-
- // Only set the post_author if one is set.
- if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) {
- switch ( $post_type ) {
- case "post":
- if ( !current_user_can("edit_others_posts") )
- return(new IXR_Error(401, __("You are not allowed to change the post author as this user.")));
- break;
- case "page":
- if ( !current_user_can("edit_others_pages") )
- return(new IXR_Error(401, __("You are not allowed to change the page author as this user.")));
- break;
- default:
- return(new IXR_Error(401, __("Invalid post type.")));
- break;
- }
- $post_author = $content_struct["wp_author_id"];
- }
-
- if ( isset($content_struct["mt_allow_comments"]) ) {
- if ( !is_numeric($content_struct["mt_allow_comments"]) ) {
- switch ( $content_struct["mt_allow_comments"] ) {
- case "closed":
- $comment_status = "closed";
- break;
- case "open":
- $comment_status = "open";
- break;
- default:
- $comment_status = get_option("default_comment_status");
- break;
- }
- } else {
- switch ( (int) $content_struct["mt_allow_comments"] ) {
- case 0:
- case 2:
- $comment_status = "closed";
- break;
- case 1:
- $comment_status = "open";
- break;
- default:
- $comment_status = get_option("default_comment_status");
- break;
- }
- }
- }
-
- if ( isset($content_struct["mt_allow_pings"]) ) {
- if ( !is_numeric($content_struct["mt_allow_pings"]) ) {
- switch ( $content_struct["mt_allow_pings"] ) {
- case "closed":
- $ping_status = "closed";
- break;
- case "open":
- $ping_status = "open";
- break;
- default:
- $ping_status = get_option("default_ping_status");
- break;
- }
- } else {
- switch ( (int) $content_struct["mt_allow_pings"] ) {
- case 0:
- $ping_status = "closed";
- break;
- case 1:
- $ping_status = "open";
- break;
- default:
- $ping_status = get_option("default_ping_status");
- break;
- }
- }
- }
-
- $post_title = $content_struct['title'];
- $post_content = $content_struct['description'];
- $catnames = $content_struct['categories'];
-
- $post_category = array();
-
- if ( is_array($catnames) ) {
- foreach ($catnames as $cat) {
- $post_category[] = get_cat_ID($cat);
- }
- }
-
- $post_excerpt = $content_struct['mt_excerpt'];
- $post_more = $content_struct['mt_text_more'];
-
- $post_status = $publish ? 'publish' : 'draft';
- if ( isset( $content_struct["{$post_type}_status"] ) ) {
- switch( $content_struct["{$post_type}_status"] ) {
- case 'draft':
- case 'private':
- case 'publish':
- $post_status = $content_struct["{$post_type}_status"];
- break;
- case 'pending':
- // Pending is only valid for posts, not pages.
- if ( $post_type === 'post' )
- $post_status = $content_struct["{$post_type}_status"];
- break;
- default:
- $post_status = $publish ? 'publish' : 'draft';
- break;
- }
- }
-
- $tags_input = $content_struct['mt_keywords'];
-
- if ( ('publish' == $post_status) ) {
- if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') )
- return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.'));
- else if ( !current_user_can('publish_posts') )
- return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.'));
- }
-
- if ( $post_more )
- $post_content = $post_content . "" . $post_more;
-
- $to_ping = $content_struct['mt_tb_ping_urls'];
- if ( is_array($to_ping) )
- $to_ping = implode(' ', $to_ping);
-
- // Do some timestamp voodoo
- if ( !empty( $content_struct['date_created_gmt'] ) )
- $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force
- elseif ( !empty( $content_struct['dateCreated']) )
- $dateCreated = $content_struct['dateCreated']->getIso();
-
- if ( !empty( $dateCreated ) ) {
- $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
- $post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
- } else {
- $post_date = $postdata['post_date'];
- $post_date_gmt = $postdata['post_date_gmt'];
- }
-
- // We've got all the data -- post it:
- $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template');
-
- $result = wp_update_post($newpost, true);
- if ( is_wp_error( $result ) )
- return new IXR_Error(500, $result->get_error_message());
-
- if ( !$result )
- return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.'));
-
- // Only posts can be sticky
- if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
- if ( $content_struct['sticky'] == true )
- stick_post( $post_ID );
- elseif ( $content_struct['sticky'] == false )
- unstick_post( $post_ID );
- }
-
- if ( isset($content_struct['custom_fields']) )
- $this->set_custom_fields($post_ID, $content_struct['custom_fields']);
-
- // Handle enclosures
- $this->add_enclosure_if_new($post_ID, $content_struct['enclosure']);
-
- $this->attach_uploads( $ID, $post_content );
-
- logIO('O',"(MW) Edited ! ID: $post_ID");
-
- return true;
- }
-
- /**
- * Retrieve post.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function mw_getPost($args) {
-
- $this->escape($args);
-
- $post_ID = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_post', $post_ID ) )
- return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
-
- do_action('xmlrpc_call', 'metaWeblog.getPost');
-
- $postdata = wp_get_single_post($post_ID, ARRAY_A);
-
- if ($postdata['post_date'] != '') {
- $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false);
- $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false);
-
- // For drafts use the GMT version of the post date
- if ( $postdata['post_status'] == 'draft' )
- $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ), 'Ymd\TH:i:s' );
-
- $categories = array();
- $catids = wp_get_post_categories($post_ID);
- foreach($catids as $catid)
- $categories[] = get_cat_name($catid);
-
- $tagnames = array();
- $tags = wp_get_post_tags( $post_ID );
- if ( !empty( $tags ) ) {
- foreach ( $tags as $tag )
- $tagnames[] = $tag->name;
- $tagnames = implode( ', ', $tagnames );
- } else {
- $tagnames = '';
- }
-
- $post = get_extended($postdata['post_content']);
- $link = post_permalink($postdata['ID']);
-
- // Get the author info.
- $author = get_userdata($postdata['post_author']);
-
- $allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0;
- $allow_pings = ('open' == $postdata['ping_status']) ? 1 : 0;
-
- // Consider future posts as published
- if ( $postdata['post_status'] === 'future' )
- $postdata['post_status'] = 'publish';
-
- $sticky = false;
- if ( is_sticky( $post_ID ) )
- $sticky = true;
-
- $enclosure = array();
- foreach ( (array) get_post_custom($post_ID) as $key => $val) {
- if ($key == 'enclosure') {
- foreach ( (array) $val as $enc ) {
- $encdata = split("\n", $enc);
- $enclosure['url'] = trim(htmlspecialchars($encdata[0]));
- $enclosure['length'] = (int) trim($encdata[1]);
- $enclosure['type'] = trim($encdata[2]);
- break 2;
- }
- }
- }
-
- $resp = array(
- 'dateCreated' => new IXR_Date($post_date),
- 'userid' => $postdata['post_author'],
- 'postid' => $postdata['ID'],
- 'description' => $post['main'],
- 'title' => $postdata['post_title'],
- 'link' => $link,
- 'permaLink' => $link,
- // commented out because no other tool seems to use this
- // 'content' => $entry['post_content'],
- 'categories' => $categories,
- 'mt_excerpt' => $postdata['post_excerpt'],
- 'mt_text_more' => $post['extended'],
- 'mt_allow_comments' => $allow_comments,
- 'mt_allow_pings' => $allow_pings,
- 'mt_keywords' => $tagnames,
- 'wp_slug' => $postdata['post_name'],
- 'wp_password' => $postdata['post_password'],
- 'wp_author_id' => $author->ID,
- 'wp_author_display_name' => $author->display_name,
- 'date_created_gmt' => new IXR_Date($post_date_gmt),
- 'post_status' => $postdata['post_status'],
- 'custom_fields' => $this->get_custom_fields($post_ID),
- 'sticky' => $sticky
- );
-
- if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure;
-
- return $resp;
- } else {
- return new IXR_Error(404, __('Sorry, no such post.'));
- }
- }
-
- /**
- * Retrieve list of recent posts.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function mw_getRecentPosts($args) {
-
- $this->escape($args);
-
- $blog_ID = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $num_posts = (int) $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'metaWeblog.getRecentPosts');
-
- $posts_list = wp_get_recent_posts($num_posts);
-
- if ( !$posts_list )
- return array( );
-
- foreach ($posts_list as $entry) {
- if ( !current_user_can( 'edit_post', $entry['ID'] ) )
- continue;
-
- $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
- $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
-
- // For drafts use the GMT version of the date
- if ( $entry['post_status'] == 'draft' )
- $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' );
-
- $categories = array();
- $catids = wp_get_post_categories($entry['ID']);
- foreach( $catids as $catid )
- $categories[] = get_cat_name($catid);
-
- $tagnames = array();
- $tags = wp_get_post_tags( $entry['ID'] );
- if ( !empty( $tags ) ) {
- foreach ( $tags as $tag ) {
- $tagnames[] = $tag->name;
- }
- $tagnames = implode( ', ', $tagnames );
- } else {
- $tagnames = '';
- }
-
- $post = get_extended($entry['post_content']);
- $link = post_permalink($entry['ID']);
-
- // Get the post author info.
- $author = get_userdata($entry['post_author']);
-
- $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0;
- $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0;
-
- // Consider future posts as published
- if ( $entry['post_status'] === 'future' )
- $entry['post_status'] = 'publish';
-
- $struct[] = array(
- 'dateCreated' => new IXR_Date($post_date),
- 'userid' => $entry['post_author'],
- 'postid' => $entry['ID'],
- 'description' => $post['main'],
- 'title' => $entry['post_title'],
- 'link' => $link,
- 'permaLink' => $link,
- // commented out because no other tool seems to use this
- // 'content' => $entry['post_content'],
- 'categories' => $categories,
- 'mt_excerpt' => $entry['post_excerpt'],
- 'mt_text_more' => $post['extended'],
- 'mt_allow_comments' => $allow_comments,
- 'mt_allow_pings' => $allow_pings,
- 'mt_keywords' => $tagnames,
- 'wp_slug' => $entry['post_name'],
- 'wp_password' => $entry['post_password'],
- 'wp_author_id' => $author->ID,
- 'wp_author_display_name' => $author->display_name,
- 'date_created_gmt' => new IXR_Date($post_date_gmt),
- 'post_status' => $entry['post_status'],
- 'custom_fields' => $this->get_custom_fields($entry['ID'])
- );
-
- }
-
- $recent_posts = array();
- for ( $j=0; $jescape($args);
-
- $blog_ID = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_posts' ) )
- return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
-
- do_action('xmlrpc_call', 'metaWeblog.getCategories');
-
- $categories_struct = array();
-
- if ( $cats = get_categories(array('get' => 'all')) ) {
- foreach ( $cats as $cat ) {
- $struct['categoryId'] = $cat->term_id;
- $struct['parentId'] = $cat->parent;
- $struct['description'] = $cat->name;
- $struct['categoryDescription'] = $cat->description;
- $struct['categoryName'] = $cat->name;
- $struct['htmlUrl'] = esc_html(get_category_link($cat->term_id));
- $struct['rssUrl'] = esc_html(get_category_feed_link($cat->term_id, 'rss2'));
-
- $categories_struct[] = $struct;
- }
- }
-
- return $categories_struct;
- }
-
- /**
- * Uploads a file, following your settings.
- *
- * Adapted from a patch by Johann Richard.
- *
- * @link http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function mw_newMediaObject($args) {
- global $wpdb;
-
- $blog_ID = (int) $args[0];
- $username = $wpdb->escape($args[1]);
- $password = $wpdb->escape($args[2]);
- $data = $args[3];
-
- $name = sanitize_file_name( $data['name'] );
- $type = $data['type'];
- $bits = $data['bits'];
-
- logIO('O', '(MW) Received '.strlen($bits).' bytes');
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'metaWeblog.newMediaObject');
-
- if ( !current_user_can('upload_files') ) {
- logIO('O', '(MW) User does not have upload_files capability');
- $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.'));
- return $this->error;
- }
-
- if ( $upload_err = apply_filters( "pre_upload_error", false ) )
- return new IXR_Error(500, $upload_err);
-
- if ( !empty($data["overwrite"]) && ($data["overwrite"] == true) ) {
- // Get postmeta info on the object.
- $old_file = $wpdb->get_row("
- SELECT ID
- FROM {$wpdb->posts}
- WHERE post_title = '{$name}'
- AND post_type = 'attachment'
- ");
-
- // Delete previous file.
- wp_delete_attachment($old_file->ID);
-
- // Make sure the new name is different by pre-pending the
- // previous post id.
- $filename = preg_replace("/^wpid\d+-/", "", $name);
- $name = "wpid{$old_file->ID}-{$filename}";
- }
-
- $upload = wp_upload_bits($name, $type, $bits);
- if ( ! empty($upload['error']) ) {
- $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']);
- logIO('O', '(MW) ' . $errorString);
- return new IXR_Error(500, $errorString);
- }
- // Construct the attachment array
- // attach to post_id 0
- $post_id = 0;
- $attachment = array(
- 'post_title' => $name,
- 'post_content' => '',
- 'post_type' => 'attachment',
- 'post_parent' => $post_id,
- 'post_mime_type' => $type,
- 'guid' => $upload[ 'url' ]
- );
-
- // Save the data
- $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id );
- wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
-
- return apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type ), 'upload' );
- }
-
- /* MovableType API functions
- * specs on http://www.movabletype.org/docs/mtmanual_programmatic.html
- */
-
- /**
- * Retrieve the post titles of recent posts.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function mt_getRecentPostTitles($args) {
-
- $this->escape($args);
-
- $blog_ID = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $num_posts = (int) $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'mt.getRecentPostTitles');
-
- $posts_list = wp_get_recent_posts($num_posts);
-
- if ( !$posts_list ) {
- $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.'));
- return $this->error;
- }
-
- foreach ($posts_list as $entry) {
- if ( !current_user_can( 'edit_post', $entry['ID'] ) )
- continue;
-
- $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
- $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
-
- // For drafts use the GMT version of the date
- if ( $entry['post_status'] == 'draft' )
- $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' );
-
- $struct[] = array(
- 'dateCreated' => new IXR_Date($post_date),
- 'userid' => $entry['post_author'],
- 'postid' => $entry['ID'],
- 'title' => $entry['post_title'],
- 'date_created_gmt' => new IXR_Date($post_date_gmt)
- );
-
- }
-
- $recent_posts = array();
- for ( $j=0; $jescape($args);
-
- $blog_ID = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_posts' ) )
- return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
-
- do_action('xmlrpc_call', 'mt.getCategoryList');
-
- $categories_struct = array();
-
- if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) {
- foreach ( $cats as $cat ) {
- $struct['categoryId'] = $cat->term_id;
- $struct['categoryName'] = $cat->name;
-
- $categories_struct[] = $struct;
- }
- }
-
- return $categories_struct;
- }
-
- /**
- * Retrieve post categories.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function mt_getPostCategories($args) {
-
- $this->escape($args);
-
- $post_ID = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- if ( !current_user_can( 'edit_post', $post_ID ) )
- return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) );
-
- do_action('xmlrpc_call', 'mt.getPostCategories');
-
- $categories = array();
- $catids = wp_get_post_categories(intval($post_ID));
- // first listed category will be the primary category
- $isPrimary = true;
- foreach ( $catids as $catid ) {
- $categories[] = array(
- 'categoryName' => get_cat_name($catid),
- 'categoryId' => (string) $catid,
- 'isPrimary' => $isPrimary
- );
- $isPrimary = false;
- }
-
- return $categories;
- }
-
- /**
- * Sets categories for a post.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return bool True on success.
- */
- function mt_setPostCategories($args) {
-
- $this->escape($args);
-
- $post_ID = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
- $categories = $args[3];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'mt.setPostCategories');
-
- if ( !current_user_can('edit_post', $post_ID) )
- return new IXR_Error(401, __('Sorry, you cannot edit this post.'));
-
- foreach ( $categories as $cat ) {
- $catids[] = $cat['categoryId'];
- }
-
- wp_set_post_categories($post_ID, $catids);
-
- return true;
- }
-
- /**
- * Retrieve an array of methods supported by this server.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function mt_supportedMethods($args) {
-
- do_action('xmlrpc_call', 'mt.supportedMethods');
-
- $supported_methods = array();
- foreach ( $this->methods as $key => $value ) {
- $supported_methods[] = $key;
- }
-
- return $supported_methods;
- }
-
- /**
- * Retrieve an empty array because we don't support per-post text filters.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- */
- function mt_supportedTextFilters($args) {
- do_action('xmlrpc_call', 'mt.supportedTextFilters');
- return apply_filters('xmlrpc_text_filters', array());
- }
-
- /**
- * Retrieve trackbacks sent to a given post.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return mixed
- */
- function mt_getTrackbackPings($args) {
-
- global $wpdb;
-
- $post_ID = intval($args);
-
- do_action('xmlrpc_call', 'mt.getTrackbackPings');
-
- $actual_post = wp_get_single_post($post_ID, ARRAY_A);
-
- if ( !$actual_post )
- return new IXR_Error(404, __('Sorry, no such post.'));
-
- $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) );
-
- if ( !$comments )
- return array();
-
- $trackback_pings = array();
- foreach ( $comments as $comment ) {
- if ( 'trackback' == $comment->comment_type ) {
- $content = $comment->comment_content;
- $title = substr($content, 8, (strpos($content, '') - 8));
- $trackback_pings[] = array(
- 'pingTitle' => $title,
- 'pingURL' => $comment->comment_author_url,
- 'pingIP' => $comment->comment_author_IP
- );
- }
- }
-
- return $trackback_pings;
- }
-
- /**
- * Sets a post's publish status to 'publish'.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return int
- */
- function mt_publishPost($args) {
-
- $this->escape($args);
-
- $post_ID = (int) $args[0];
- $username = $args[1];
- $password = $args[2];
-
- if ( !$user = $this->login($username, $password) )
- return $this->error;
-
- do_action('xmlrpc_call', 'mt.publishPost');
-
- if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) )
- return new IXR_Error(401, __('Sorry, you cannot edit this post.'));
-
- $postdata = wp_get_single_post($post_ID,ARRAY_A);
-
- $postdata['post_status'] = 'publish';
-
- // retain old cats
- $cats = wp_get_post_categories($post_ID);
- $postdata['post_category'] = $cats;
- $this->escape($postdata);
-
- $result = wp_update_post($postdata);
-
- return $result;
- }
-
- /* PingBack functions
- * specs on www.hixie.ch/specs/pingback/pingback
- */
-
- /**
- * Retrieves a pingback and registers it.
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function pingback_ping($args) {
- global $wpdb;
-
- do_action('xmlrpc_call', 'pingback.ping');
-
- $this->escape($args);
-
- $pagelinkedfrom = $args[0];
- $pagelinkedto = $args[1];
-
- $title = '';
-
- $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom);
- $pagelinkedto = str_replace('&', '&', $pagelinkedto);
- $pagelinkedto = str_replace('&', '&', $pagelinkedto);
-
- // Check if the page linked to is in our site
- $pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home')));
- if ( !$pos1 )
- return new IXR_Error(0, __('Is there no link to us?'));
-
- // let's find which post is linked to
- // FIXME: does url_to_postid() cover all these cases already?
- // if so, then let's use it and drop the old code.
- $urltest = parse_url($pagelinkedto);
- if ( $post_ID = url_to_postid($pagelinkedto) ) {
- $way = 'url_to_postid()';
- } elseif ( preg_match('#p/[0-9]{1,}#', $urltest['path'], $match) ) {
- // the path defines the post_ID (archives/p/XXXX)
- $blah = explode('/', $match[0]);
- $post_ID = (int) $blah[1];
- $way = 'from the path';
- } elseif ( preg_match('#p=[0-9]{1,}#', $urltest['query'], $match) ) {
- // the querystring defines the post_ID (?p=XXXX)
- $blah = explode('=', $match[0]);
- $post_ID = (int) $blah[1];
- $way = 'from the querystring';
- } elseif ( isset($urltest['fragment']) ) {
- // an #anchor is there, it's either...
- if ( intval($urltest['fragment']) ) {
- // ...an integer #XXXX (simpliest case)
- $post_ID = (int) $urltest['fragment'];
- $way = 'from the fragment (numeric)';
- } elseif ( preg_match('/post-[0-9]+/',$urltest['fragment']) ) {
- // ...a post id in the form 'post-###'
- $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']);
- $way = 'from the fragment (post-###)';
- } elseif ( is_string($urltest['fragment']) ) {
- // ...or a string #title, a little more complicated
- $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']);
- $sql = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title);
- if (! ($post_ID = $wpdb->get_var($sql)) ) {
- // returning unknown error '0' is better than die()ing
- return new IXR_Error(0, '');
- }
- $way = 'from the fragment (title)';
- }
- } else {
- // TODO: Attempt to extract a post ID from the given URL
- return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.'));
- }
- $post_ID = (int) $post_ID;
-
-
- logIO("O","(PB) URL='$pagelinkedto' ID='$post_ID' Found='$way'");
-
- $post = get_post($post_ID);
-
- if ( !$post ) // Post_ID not found
- return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.'));
-
- if ( $post_ID == url_to_postid($pagelinkedfrom) )
- return new IXR_Error(0, __('The source URL and the target URL cannot both point to the same resource.'));
-
- // Check if pings are on
- if ( !pings_open($post) )
- return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.'));
-
- // Let's check that the remote site didn't already pingback this entry
- if ( $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) )
- return new IXR_Error( 48, __( 'The pingback has already been registered.' ) );
-
- // very stupid, but gives time to the 'from' server to publish !
- sleep(1);
-
- // Let's check the remote site
- $linea = wp_remote_fopen( $pagelinkedfrom );
- if ( !$linea )
- return new IXR_Error(16, __('The source URL does not exist.'));
-
- $linea = apply_filters('pre_remote_source', $linea, $pagelinkedto);
-
- // Work around bug in strip_tags():
- $linea = str_replace(']*>/", "\n\n", $linea );
-
- preg_match('|([^<]*?)|is', $linea, $matchtitle);
- $title = $matchtitle[1];
- if ( empty( $title ) )
- return new IXR_Error(32, __('We cannot find a title on that page.'));
-
- $linea = strip_tags( $linea, '' ); // just keep the tag we need
-
- $p = explode( "\n\n", $linea );
-
- $preg_target = preg_quote($pagelinkedto, '|');
-
- foreach ( $p as $para ) {
- if ( strpos($para, $pagelinkedto) !== false ) { // it exists, but is it a link?
- preg_match("|]+?".$preg_target."[^>]*>([^>]+?)|", $para, $context);
-
- // If the URL isn't in a link context, keep looking
- if ( empty($context) )
- continue;
-
- // We're going to use this fake tag to mark the context in a bit
- // the marker is needed in case the link text appears more than once in the paragraph
- $excerpt = preg_replace('|\?wpcontext\>|', '', $para);
-
- // prevent really long link text
- if ( strlen($context[1]) > 100 )
- $context[1] = substr($context[1], 0, 100) . '...';
-
- $marker = ''.$context[1].''; // set up our marker
- $excerpt= str_replace($context[0], $marker, $excerpt); // swap out the link for our marker
- $excerpt = strip_tags($excerpt, ''); // strip all tags but our context marker
- $excerpt = trim($excerpt);
- $preg_marker = preg_quote($marker, '|');
- $excerpt = preg_replace("|.*?\s(.{0,100}$preg_marker.{0,100})\s.*|s", '$1', $excerpt);
- $excerpt = strip_tags($excerpt); // YES, again, to remove the marker wrapper
- break;
- }
- }
-
- if ( empty($context) ) // Link to target not found
- return new IXR_Error(17, __('The source URL does not contain a link to the target URL, and so cannot be used as a source.'));
-
- $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom);
-
- $context = '[...] ' . esc_html( $excerpt ) . ' [...]';
- $pagelinkedfrom = $wpdb->escape( $pagelinkedfrom );
-
- $comment_post_ID = (int) $post_ID;
- $comment_author = $title;
- $this->escape($comment_author);
- $comment_author_url = $pagelinkedfrom;
- $comment_content = $context;
- $this->escape($comment_content);
- $comment_type = 'pingback';
-
- $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_content', 'comment_type');
-
- $comment_ID = wp_new_comment($commentdata);
- do_action('pingback_post', $comment_ID);
-
- return sprintf(__('Pingback from %1$s to %2$s registered. Keep the web talking! :-)'), $pagelinkedfrom, $pagelinkedto);
- }
-
- /**
- * Retrieve array of URLs that pingbacked the given URL.
- *
- * Specs on http://www.aquarionics.com/misc/archives/blogite/0198.html
- *
- * @since 1.5.0
- *
- * @param array $args Method parameters.
- * @return array
- */
- function pingback_extensions_getPingbacks($args) {
-
- global $wpdb;
-
- do_action('xmlrpc_call', 'pingback.extensions.getPingbacks');
-
- $this->escape($args);
-
- $url = $args;
-
- $post_ID = url_to_postid($url);
- if ( !$post_ID ) {
- // We aren't sure that the resource is available and/or pingback enabled
- return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.'));
- }
-
- $actual_post = wp_get_single_post($post_ID, ARRAY_A);
-
- if ( !$actual_post ) {
- // No such post = resource not found
- return new IXR_Error(32, __('The specified target URL does not exist.'));
- }
-
- $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) );
-
- if ( !$comments )
- return array();
-
- $pingbacks = array();
- foreach ( $comments as $comment ) {
- if ( 'pingback' == $comment->comment_type )
- $pingbacks[] = $comment->comment_author_url;
- }
-
- return $pingbacks;
- }
-}
+// Allow for a plugin to insert a different class to handle requests.
+$wp_xmlrpc_server_class = apply_filters('wp_xmlrpc_server_class', 'wp_xmlrpc_server');
+$wp_xmlrpc_server = new $wp_xmlrpc_server_class;
-$wp_xmlrpc_server = new wp_xmlrpc_server();
+// Fire off the request
$wp_xmlrpc_server->serve_request();
?>
\ No newline at end of file