mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
Remove unused vars. Props DD32. see #5418
git-svn-id: http://svn.automattic.com/wordpress/trunk@6364 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2283075a92
commit
028a159440
49
wp-app.php
49
wp-app.php
@ -215,7 +215,7 @@ EOD;
|
||||
* Create Post (No arguments)
|
||||
*/
|
||||
function create_post() {
|
||||
global $blog_id, $wpdb;
|
||||
global $blog_id, $user_ID;
|
||||
$this->get_accepted_content_type($this->atom_content_types);
|
||||
|
||||
$parser = new AtomParser();
|
||||
@ -249,7 +249,7 @@ EOD;
|
||||
|
||||
$blog_ID = (int ) $blog_id;
|
||||
$post_status = ($publish) ? 'publish' : 'draft';
|
||||
$post_author = (int) $user->ID;
|
||||
$post_author = (int) $user_ID;
|
||||
$post_title = $entry->title[1];
|
||||
$post_content = $entry->content[1];
|
||||
$post_excerpt = $entry->summary[1];
|
||||
@ -269,9 +269,8 @@ EOD;
|
||||
if ( is_wp_error( $postID ) )
|
||||
$this->internal_error($postID->get_error_message());
|
||||
|
||||
if (!$postID) {
|
||||
if (!$postID)
|
||||
$this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
|
||||
}
|
||||
|
||||
// getting warning here about unable to set headers
|
||||
// because something in the cache is printing to the buffer
|
||||
@ -296,8 +295,6 @@ EOD;
|
||||
}
|
||||
|
||||
function put_post($postID) {
|
||||
global $wpdb;
|
||||
|
||||
// checked for valid content-types (atom+xml)
|
||||
// quick check and exit
|
||||
$this->get_accepted_content_type($this->atom_content_types);
|
||||
@ -313,7 +310,6 @@ EOD;
|
||||
|
||||
// check for not found
|
||||
global $entry;
|
||||
$entry = $GLOBALS['entry'];
|
||||
$this->set_current_entry($postID);
|
||||
|
||||
if(!current_user_can('edit_post', $entry['ID']))
|
||||
@ -376,8 +372,6 @@ EOD;
|
||||
}
|
||||
|
||||
function get_attachment($postID = NULL) {
|
||||
|
||||
global $entry;
|
||||
if (!isset($postID)) {
|
||||
$this->get_attachments();
|
||||
} else {
|
||||
@ -389,7 +383,6 @@ EOD;
|
||||
}
|
||||
|
||||
function create_attachment() {
|
||||
global $wp, $wpdb, $wp_query, $blog_id;
|
||||
|
||||
$type = $this->get_accepted_content_type();
|
||||
|
||||
@ -418,9 +411,8 @@ EOD;
|
||||
|
||||
$url = $file['url'];
|
||||
$file = $file['file'];
|
||||
$filename = basename($file);
|
||||
|
||||
$header = apply_filters('wp_create_file_in_uploads', $file); // replicate
|
||||
apply_filters('wp_create_file_in_uploads', $file); // replicate
|
||||
|
||||
// Construct the attachment array
|
||||
$attachment = array(
|
||||
@ -433,11 +425,10 @@ EOD;
|
||||
);
|
||||
|
||||
// Save the data
|
||||
$postID = wp_insert_attachment($attachment, $file, $post);
|
||||
$postID = wp_insert_attachment($attachment, $file);
|
||||
|
||||
if (!$postID) {
|
||||
if (!$postID)
|
||||
$this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
|
||||
}
|
||||
|
||||
$output = $this->get_entry($postID, 'attachment');
|
||||
|
||||
@ -446,8 +437,6 @@ EOD;
|
||||
}
|
||||
|
||||
function put_attachment($postID) {
|
||||
global $wpdb;
|
||||
|
||||
// checked for valid content-types (atom+xml)
|
||||
// quick check and exit
|
||||
$this->get_accepted_content_type($this->atom_content_types);
|
||||
@ -466,8 +455,6 @@ EOD;
|
||||
if(!current_user_can('edit_post', $entry['ID']))
|
||||
$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
|
||||
|
||||
$publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true;
|
||||
|
||||
extract($entry);
|
||||
|
||||
$post_title = $parsed->title[1];
|
||||
@ -546,8 +533,6 @@ EOD;
|
||||
|
||||
function put_file($postID) {
|
||||
|
||||
$type = $this->get_accepted_content_type();
|
||||
|
||||
// first check if user can upload
|
||||
if(!current_user_can('upload_files'))
|
||||
$this->auth_required(__('You do not have permission to upload files.'));
|
||||
@ -605,17 +590,15 @@ EOD;
|
||||
}
|
||||
|
||||
function the_entries_url($page = NULL) {
|
||||
$url = $this->get_entries_url($page);
|
||||
echo $url;
|
||||
echo $this->get_entries_url($page);
|
||||
}
|
||||
|
||||
function get_categories_url($page = NULL) {
|
||||
function get_categories_url($deprecated = '') {
|
||||
return $this->app_base . $this->CATEGORIES_PATH;
|
||||
}
|
||||
|
||||
function the_categories_url() {
|
||||
$url = $this->get_categories_url();
|
||||
echo $url;
|
||||
echo $this->get_categories_url();
|
||||
}
|
||||
|
||||
function get_attachments_url($page = NULL) {
|
||||
@ -627,8 +610,7 @@ EOD;
|
||||
}
|
||||
|
||||
function the_attachments_url($page = NULL) {
|
||||
$url = $this->get_attachments_url($page);
|
||||
echo $url;
|
||||
echo $this->get_attachments_url($page);
|
||||
}
|
||||
|
||||
function get_service_url() {
|
||||
@ -638,7 +620,7 @@ EOD;
|
||||
function get_entry_url($postID = NULL) {
|
||||
if(!isset($postID)) {
|
||||
global $post;
|
||||
$postID = (int) $GLOBALS['post']->ID;
|
||||
$postID = (int) $post->ID;
|
||||
}
|
||||
|
||||
$url = $this->app_base . $this->ENTRY_PATH . "/$postID";
|
||||
@ -648,14 +630,13 @@ EOD;
|
||||
}
|
||||
|
||||
function the_entry_url($postID = NULL) {
|
||||
$url = $this->get_entry_url($postID);
|
||||
echo $url;
|
||||
echo $this->get_entry_url($postID);
|
||||
}
|
||||
|
||||
function get_media_url($postID = NULL) {
|
||||
if(!isset($postID)) {
|
||||
global $post;
|
||||
$postID = (int) $GLOBALS['post']->ID;
|
||||
$postID = (int) $post->ID;
|
||||
}
|
||||
|
||||
$url = $this->app_base . $this->MEDIA_SINGLE_PATH ."/file/$postID";
|
||||
@ -665,8 +646,7 @@ EOD;
|
||||
}
|
||||
|
||||
function the_media_url($postID = NULL) {
|
||||
$url = $this->get_media_url($postID);
|
||||
echo $url;
|
||||
echo $this->get_media_url($postID);
|
||||
}
|
||||
|
||||
function set_current_entry($postID) {
|
||||
@ -759,7 +739,6 @@ EOD;
|
||||
function get_entry($postID, $post_type = 'post') {
|
||||
log_app('function',"get_entry($postID, '$post_type')");
|
||||
ob_start();
|
||||
global $posts, $post, $wp_query, $wp, $wpdb, $blog_id;
|
||||
switch($post_type) {
|
||||
case 'post':
|
||||
$varname = 'p';
|
||||
|
@ -316,7 +316,7 @@ function the_author_posts_link($deprecated = '') {
|
||||
* @return string The URL to the author's page.
|
||||
*/
|
||||
function get_author_posts_url($author_id, $author_nicename = '') {
|
||||
global $wpdb, $wp_rewrite, $post;
|
||||
global $wp_rewrite;
|
||||
$auth_ID = (int) $author_id;
|
||||
$link = $wp_rewrite->get_author_permastruct();
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference" by Mark Jaquith
|
||||
|
||||
function redirect_canonical($requested_url=NULL, $do_redirect=true) {
|
||||
global $wp_rewrite, $posts, $is_IIS;
|
||||
global $wp_rewrite, $is_IIS;
|
||||
|
||||
if ( is_feed() || is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() )
|
||||
return;
|
||||
@ -176,7 +176,7 @@ function redirect_canonical($requested_url=NULL, $do_redirect=true) {
|
||||
}
|
||||
|
||||
function redirect_guess_404_permalink() {
|
||||
global $wp_query, $wpdb;
|
||||
global $wpdb;
|
||||
if ( !get_query_var('name') )
|
||||
return false;
|
||||
|
||||
|
@ -138,7 +138,6 @@ class WP_User {
|
||||
var $allcaps = array();
|
||||
|
||||
function WP_User($id, $name = '') {
|
||||
global $wpdb;
|
||||
|
||||
if ( empty($id) && empty($name) )
|
||||
return;
|
||||
|
@ -66,7 +66,7 @@ function get_category_parents($id, $link = FALSE, $separator = '/', $nicename =
|
||||
}
|
||||
|
||||
function get_the_category($id = false) {
|
||||
global $post, $term_cache, $blog_id;
|
||||
global $post, $term_cache;
|
||||
|
||||
$id = (int) $id;
|
||||
if ( !$id )
|
||||
@ -168,7 +168,7 @@ function get_the_category_list($separator = '', $parents='') {
|
||||
}
|
||||
|
||||
function in_category( $category ) { // Check if the current post is in the given category
|
||||
global $post, $blog_id;
|
||||
global $post;
|
||||
|
||||
$categories = get_object_term_cache($post->ID, 'category');
|
||||
if ( false === $categories )
|
||||
|
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
function get_all_category_ids() {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) {
|
||||
$cat_ids = get_terms('category', 'fields=ids&get=all');
|
||||
wp_cache_add('all_category_ids', $cat_ids, 'category');
|
||||
@ -39,7 +37,6 @@ function &get_category($category, $output = OBJECT, $filter = 'raw') {
|
||||
}
|
||||
|
||||
function get_category_by_path($category_path, $full_match = true, $output = OBJECT) {
|
||||
global $wpdb;
|
||||
$category_path = rawurlencode(urldecode($category_path));
|
||||
$category_path = str_replace('%2F', '/', $category_path);
|
||||
$category_path = str_replace('%20', ' ', $category_path);
|
||||
@ -86,8 +83,6 @@ function get_category_by_slug( $slug ) {
|
||||
|
||||
// Get the ID of a category from its name
|
||||
function get_cat_ID($cat_name='General') {
|
||||
global $wpdb;
|
||||
|
||||
$cat = get_term_by('name', $cat_name, 'category');
|
||||
if ($cat)
|
||||
return $cat->term_id;
|
||||
@ -132,8 +127,6 @@ function sanitize_category_field($field, $value, $cat_id, $context) {
|
||||
// Tags
|
||||
|
||||
function &get_tags($args = '') {
|
||||
global $wpdb, $category_links;
|
||||
|
||||
$key = md5( serialize( $args ) );
|
||||
if ( $cache = wp_cache_get( 'get_tags', 'category' ) )
|
||||
if ( isset( $cache[ $key ] ) )
|
||||
|
@ -38,7 +38,6 @@ function comment_author_email_link($linktext='', $before='', $after='') {
|
||||
}
|
||||
|
||||
function get_comment_author_link() {
|
||||
global $comment;
|
||||
$url = get_comment_author_url();
|
||||
$author = get_comment_author();
|
||||
|
||||
@ -72,7 +71,6 @@ function comment_author_url() {
|
||||
}
|
||||
|
||||
function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
|
||||
global $comment;
|
||||
$url = get_comment_author_url();
|
||||
$display = ($linktext != '') ? $linktext : $url;
|
||||
$display = str_replace( 'http://www.', '', $display );
|
||||
@ -146,7 +144,6 @@ function comments_link( $file = '', $echo = true ) {
|
||||
}
|
||||
|
||||
function get_comments_number( $post_id = 0 ) {
|
||||
global $wpdb, $id;
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
if ( !$post_id )
|
||||
@ -237,7 +234,6 @@ function trackback_url($deprecated = true) { // remove backwards compat in 2.4
|
||||
}
|
||||
|
||||
function trackback_rdf($timezone = 0) {
|
||||
global $id;
|
||||
if (stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') === false) {
|
||||
echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
@ -309,7 +305,7 @@ function comments_template( $file = '/comments.php' ) {
|
||||
}
|
||||
|
||||
function comments_popup_script($width=400, $height=400, $file='') {
|
||||
global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;
|
||||
global $wpcommentspopupfile, $wpcommentsjavascript;
|
||||
|
||||
if (empty ($file)) {
|
||||
$wpcommentspopupfile = ''; // Use the index.
|
||||
@ -323,7 +319,7 @@ function comments_popup_script($width=400, $height=400, $file='') {
|
||||
}
|
||||
|
||||
function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
|
||||
global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb;
|
||||
global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post;
|
||||
|
||||
if ( is_single() || is_page() )
|
||||
return;
|
||||
|
@ -105,7 +105,7 @@ function &get_comment(&$comment, $output = OBJECT) {
|
||||
|
||||
// Deprecate in favor of get_comment()?
|
||||
function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { // less flexible, but saves DB queries
|
||||
global $postc, $id, $commentdata, $wpdb;
|
||||
global $postc, $id, $wpdb;
|
||||
if ( $no_cache ) {
|
||||
$query = $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d", $comment_ID);
|
||||
if ( false == $include_unapproved )
|
||||
@ -129,7 +129,7 @@ function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = fals
|
||||
|
||||
|
||||
function get_lastcommentmodified($timezone = 'server') {
|
||||
global $cache_lastcommentmodified, $pagenow, $wpdb;
|
||||
global $cache_lastcommentmodified, $wpdb;
|
||||
$add_seconds_blog = get_option('gmt_offset') * 3600;
|
||||
$add_seconds_server = date('Z');
|
||||
$now = current_time('mysql', 1);
|
||||
@ -228,8 +228,6 @@ function check_comment_flood_db( $ip, $email, $date ) {
|
||||
}
|
||||
|
||||
function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {
|
||||
global $wpdb;
|
||||
|
||||
do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent);
|
||||
|
||||
if ( preg_match_all('/&#(\d+);/', $comment . $author . $url, $chars) ) {
|
||||
@ -293,8 +291,6 @@ function wp_delete_comment($comment_id) {
|
||||
|
||||
|
||||
function wp_get_comment_status($comment_id) {
|
||||
global $wpdb;
|
||||
|
||||
$comment = get_comment($comment_id);
|
||||
if ( !$comment )
|
||||
return false;
|
||||
@ -686,7 +682,7 @@ function generic_ping($post_id = 0) {
|
||||
|
||||
|
||||
function pingback($content, $post_ID) {
|
||||
global $wp_version, $wpdb;
|
||||
global $wp_version;
|
||||
include_once(ABSPATH . WPINC . '/class-IXR.php');
|
||||
|
||||
// original code by Mort (http://mort.mine.nu:8080)
|
||||
|
@ -98,19 +98,19 @@ function comment_text_rss() {
|
||||
}
|
||||
|
||||
|
||||
function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = 'nolongerused') {
|
||||
function comments_rss_link($link_text = 'Comments RSS', $deprecated = '') {
|
||||
$url = get_post_comments_feed_link();
|
||||
echo "<a href='$url'>$link_text</a>";
|
||||
}
|
||||
|
||||
|
||||
function comments_rss($commentsrssfilename = 'nolongerused') {
|
||||
function comments_rss($deprecated = '') {
|
||||
return get_post_comments_feed_link();
|
||||
}
|
||||
|
||||
|
||||
function get_author_rss_link($echo = false, $author_id, $author_nicename) {
|
||||
$auth_ID = (int) $author_id;
|
||||
$author_id = (int) $author_id;
|
||||
$permalink_structure = get_option('permalink_structure');
|
||||
|
||||
if ( '' == $permalink_structure ) {
|
||||
@ -168,8 +168,8 @@ function get_category_feed_link($cat_id, $feed = 'rss2') {
|
||||
}
|
||||
|
||||
|
||||
function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
|
||||
$link = get_category_feed_link($cat_ID, $feed = 'rss2');
|
||||
function get_category_rss_link($echo = false, $cat_ID, $deprecated = '') {
|
||||
$link = get_category_feed_link($cat_ID, 'rss2');
|
||||
|
||||
if ( $echo )
|
||||
echo $link;
|
||||
@ -180,7 +180,6 @@ function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
|
||||
function get_the_category_rss($type = 'rss') {
|
||||
$categories = get_the_category();
|
||||
$tags = get_the_tags();
|
||||
$home = get_bloginfo_rss('home');
|
||||
$the_list = '';
|
||||
$cat_names = array();
|
||||
|
||||
@ -252,7 +251,7 @@ function html_type_rss() {
|
||||
|
||||
|
||||
function rss_enclosure() {
|
||||
global $id, $post;
|
||||
global $post;
|
||||
if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
|
||||
return;
|
||||
|
||||
@ -267,7 +266,7 @@ function rss_enclosure() {
|
||||
}
|
||||
|
||||
function atom_enclosure() {
|
||||
global $id, $post;
|
||||
global $post;
|
||||
if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
|
||||
return;
|
||||
|
||||
|
@ -363,7 +363,7 @@ function sanitize_title_with_dashes($title) {
|
||||
return $title;
|
||||
}
|
||||
|
||||
function convert_chars($content, $flag = 'obsolete') {
|
||||
function convert_chars($content, $deprecated = '') {
|
||||
// Translation of invalid Unicode references range to valid range
|
||||
$wp_htmltranswinuni = array(
|
||||
'€' => '€', // the Euro sign
|
||||
@ -560,7 +560,6 @@ function format_to_edit($content, $richedit = false) {
|
||||
}
|
||||
|
||||
function format_to_post($content) {
|
||||
global $wpdb;
|
||||
$content = apply_filters('format_to_post', $content);
|
||||
return $content;
|
||||
}
|
||||
@ -783,7 +782,7 @@ function human_time_diff( $from, $to = '' ) {
|
||||
} else if (($diff <= 86400) && ($diff > 3600)) {
|
||||
$hours = round($diff / 3600);
|
||||
if ($hours <= 1) {
|
||||
$hour = 1;
|
||||
$hours = 1;
|
||||
}
|
||||
$since = sprintf(__ngettext('%s hour', '%s hours', $hours), $hours);
|
||||
} elseif ($diff >= 86400) {
|
||||
@ -797,7 +796,6 @@ function human_time_diff( $from, $to = '' ) {
|
||||
}
|
||||
|
||||
function wp_trim_excerpt($text) { // Fakes an excerpt if needed
|
||||
global $post;
|
||||
if ( '' == $text ) {
|
||||
$text = get_the_content('');
|
||||
$text = apply_filters('the_content', $text);
|
||||
|
@ -108,23 +108,25 @@ function size_format( $bytes, $decimals = null ) {
|
||||
}
|
||||
|
||||
|
||||
function get_weekstartend( $mysqlstring, $start_of_week ) {
|
||||
function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
|
||||
$my = substr( $mysqlstring, 0, 4 );
|
||||
$mm = substr( $mysqlstring, 8, 2 );
|
||||
$md = substr( $mysqlstring, 5, 2 );
|
||||
$day = mktime( 0, 0, 0, $md, $mm, $my );
|
||||
$weekday = date( 'w', $day );
|
||||
$i = 86400;
|
||||
if( !is_numeric($a) )
|
||||
$start_of_week = get_option( 'start_of_week' );
|
||||
|
||||
if ( $weekday < get_option( 'start_of_week' ) )
|
||||
$weekday = 7 - ( get_option( 'start_of_week' ) - $weekday );
|
||||
if ( $weekday < $start_of_week )
|
||||
$weekday = 7 - $start_of_week - $weekday;
|
||||
|
||||
while ( $weekday > get_option( 'start_of_week' ) ) {
|
||||
while ( $weekday > $start_of_week ) {
|
||||
$weekday = date( 'w', $day );
|
||||
if ( $weekday < get_option( 'start_of_week' ) )
|
||||
$weekday = 7 - ( get_option( 'start_of_week' ) - $weekday );
|
||||
if ( $weekday < $start_of_week )
|
||||
$weekday = 7 - $start_of_week - $weekday;
|
||||
|
||||
$day = $day - 86400;
|
||||
$day -= 86400;
|
||||
$i = 0;
|
||||
}
|
||||
$week['start'] = $day + 86400 - $i;
|
||||
@ -488,7 +490,7 @@ function debug_fclose( $fp ) {
|
||||
}
|
||||
|
||||
function do_enclose( $content, $post_ID ) {
|
||||
global $wp_version, $wpdb;
|
||||
global $wpdb;
|
||||
include_once( ABSPATH . WPINC . '/class-IXR.php' );
|
||||
|
||||
$log = debug_fopen( ABSPATH . 'enclosures.log', 'a' );
|
||||
@ -1028,7 +1030,7 @@ function wp_upload_dir() {
|
||||
return apply_filters( 'upload_dir', $uploads );
|
||||
}
|
||||
|
||||
function wp_upload_bits( $name, $type, $bits ) {
|
||||
function wp_upload_bits( $name, $deprecated, $bits ) {
|
||||
if ( empty( $name ) )
|
||||
return array( 'error' => __( "Empty filename" ) );
|
||||
|
||||
@ -1066,7 +1068,7 @@ function wp_upload_bits( $name, $type, $bits ) {
|
||||
if ( ! $ifp )
|
||||
return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
|
||||
|
||||
$success = @fwrite( $ifp, $bits );
|
||||
@fwrite( $ifp, $bits );
|
||||
fclose( $ifp );
|
||||
// Set correct file permissions
|
||||
$stat = @ stat( dirname( $new_file ) );
|
||||
@ -1211,7 +1213,7 @@ function wp_explain_nonce( $action ) {
|
||||
|
||||
|
||||
function wp_nonce_ays( $action ) {
|
||||
global $pagenow, $menu, $submenu, $parent_file, $submenu_file;
|
||||
global $pagenow;
|
||||
|
||||
$adminurl = get_option( 'siteurl' ) . '/wp-admin';
|
||||
if ( wp_get_referer() )
|
||||
@ -1499,7 +1501,7 @@ function url_is_accessable_via_ssl($url)
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
|
||||
$data = curl_exec ($ch);
|
||||
curl_exec($ch);
|
||||
|
||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close ($ch);
|
||||
|
@ -164,8 +164,6 @@ function wp_title($sep = '»', $display = true) {
|
||||
|
||||
$cat = get_query_var('cat');
|
||||
$tag = get_query_var('tag_id');
|
||||
$p = get_query_var('p');
|
||||
$name = get_query_var('name');
|
||||
$category_name = get_query_var('category_name');
|
||||
$author = get_query_var('author');
|
||||
$author_name = get_query_var('author_name');
|
||||
@ -386,9 +384,6 @@ function wp_get_archives($args = '') {
|
||||
$archive_week_end_date_format = get_option('date_format');
|
||||
}
|
||||
|
||||
$add_hours = intval(get_option('gmt_offset'));
|
||||
$add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));
|
||||
|
||||
//filters
|
||||
$where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
|
||||
$join = apply_filters('getarchives_join', "", $r);
|
||||
@ -524,7 +519,7 @@ function calendar_week_mod($num) {
|
||||
|
||||
|
||||
function get_calendar($initial = true) {
|
||||
global $wpdb, $m, $monthnum, $year, $timedifference, $wp_locale, $posts;
|
||||
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
||||
|
||||
$key = md5( $m . $monthnum . $year );
|
||||
if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
|
||||
@ -547,8 +542,6 @@ function get_calendar($initial = true) {
|
||||
|
||||
// week_begins = 0 stands for Sunday
|
||||
$week_begins = intval(get_option('start_of_week'));
|
||||
$add_hours = intval(get_option('gmt_offset'));
|
||||
$add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));
|
||||
|
||||
// Let's figure out when we are
|
||||
if ( !empty($monthnum) && !empty($year) ) {
|
||||
@ -560,7 +553,6 @@ function get_calendar($initial = true) {
|
||||
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
||||
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
||||
} elseif ( !empty($m) ) {
|
||||
$calendar = substr($m, 0, 6);
|
||||
$thisyear = ''.intval(substr($m, 0, 4));
|
||||
if ( strlen($m) < 6 )
|
||||
$thismonth = '01';
|
||||
@ -755,7 +747,7 @@ function the_date_xml() {
|
||||
|
||||
|
||||
function the_date($d='', $before='', $after='', $echo = true) {
|
||||
global $id, $post, $day, $previousday;
|
||||
global $post, $day, $previousday;
|
||||
$the_date = '';
|
||||
if ( $day != $previousday ) {
|
||||
$the_date .= $before;
|
||||
@ -842,7 +834,7 @@ function get_post_modified_time( $d = 'U', $gmt = false ) { // returns timestamp
|
||||
|
||||
|
||||
function the_weekday() {
|
||||
global $wp_locale, $id, $post;
|
||||
global $wp_locale, $post;
|
||||
$the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date));
|
||||
$the_weekday = apply_filters('the_weekday', $the_weekday);
|
||||
echo $the_weekday;
|
||||
@ -850,7 +842,7 @@ function the_weekday() {
|
||||
|
||||
|
||||
function the_weekday_date($before='',$after='') {
|
||||
global $wp_locale, $id, $post, $day, $previousweekday;
|
||||
global $wp_locale, $post, $day, $previousweekday;
|
||||
$the_weekday_date = '';
|
||||
if ( $day != $previousweekday ) {
|
||||
$the_weekday_date .= $before;
|
||||
|
@ -75,8 +75,6 @@ function load_textdomain($domain, $mofile) {
|
||||
}
|
||||
|
||||
function load_default_textdomain() {
|
||||
global $l10n;
|
||||
|
||||
$locale = get_locale();
|
||||
if ( empty($locale) )
|
||||
$locale = 'en_US';
|
||||
|
@ -232,9 +232,6 @@ function get_day_link($year, $month, $day) {
|
||||
|
||||
function get_feed_link($feed='rss2') {
|
||||
global $wp_rewrite;
|
||||
$do_perma = 0;
|
||||
$feed_url = get_option('siteurl');
|
||||
$comment_feed_url = $feed_url;
|
||||
|
||||
$permalink = $wp_rewrite->get_feed_permastruct();
|
||||
if ( '' != $permalink ) {
|
||||
@ -494,7 +491,7 @@ function get_pagenum_link($pagenum = 1) {
|
||||
}
|
||||
|
||||
function get_next_posts_page_link($max_page = 0) {
|
||||
global $paged, $pagenow;
|
||||
global $paged;
|
||||
|
||||
if ( !is_single() ) {
|
||||
if ( !$paged )
|
||||
@ -510,7 +507,7 @@ function next_posts($max_page = 0) {
|
||||
}
|
||||
|
||||
function next_posts_link($label='Next Page »', $max_page=0) {
|
||||
global $paged, $wpdb, $wp_query;
|
||||
global $paged, $wp_query;
|
||||
if ( !$max_page ) {
|
||||
$max_page = $wp_query->max_num_pages;
|
||||
}
|
||||
@ -525,7 +522,7 @@ function next_posts_link($label='Next Page »', $max_page=0) {
|
||||
}
|
||||
|
||||
function get_previous_posts_page_link() {
|
||||
global $paged, $pagenow;
|
||||
global $paged;
|
||||
|
||||
if ( !is_single() ) {
|
||||
$nextpage = intval($paged) - 1;
|
||||
|
@ -528,8 +528,6 @@ endif;
|
||||
|
||||
if ( ! function_exists('wp_notify_postauthor') ) :
|
||||
function wp_notify_postauthor($comment_id, $comment_type='') {
|
||||
global $wpdb;
|
||||
|
||||
$comment = get_comment($comment_id);
|
||||
$post = get_post($comment->comment_post_ID);
|
||||
$user = get_userdata( $post->post_author );
|
||||
|
@ -81,9 +81,8 @@ function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file
|
||||
|
||||
|
||||
function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
|
||||
global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages;
|
||||
global $preview;
|
||||
global $pagenow;
|
||||
global $id, $post, $more, $page, $pages, $multipage, $preview, $pagenow;
|
||||
|
||||
$output = '';
|
||||
|
||||
if ( !empty($post->post_password) ) { // if there's a password
|
||||
@ -137,8 +136,8 @@ function the_excerpt() {
|
||||
}
|
||||
|
||||
|
||||
function get_the_excerpt($deprecated = true) {
|
||||
global $id, $post;
|
||||
function get_the_excerpt($deprecated = '') {
|
||||
global $post;
|
||||
$output = '';
|
||||
$output = $post->post_excerpt;
|
||||
if ( !empty($post->post_password) ) { // if there's a password
|
||||
@ -167,7 +166,7 @@ function wp_link_pages($args = '') {
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
extract( $r, EXTR_SKIP );
|
||||
|
||||
global $post, $id, $page, $numpages, $multipage, $more, $pagenow;
|
||||
global $post, $page, $numpages, $multipage, $more, $pagenow;
|
||||
if ( $more_file != '' )
|
||||
$file = $more_file;
|
||||
else
|
||||
@ -249,8 +248,6 @@ function post_custom( $key = '' ) {
|
||||
|
||||
// this will probably change at some point...
|
||||
function the_meta() {
|
||||
global $id;
|
||||
|
||||
if ( $keys = get_post_custom_keys() ) {
|
||||
echo "<ul class='post-meta'>\n";
|
||||
foreach ( $keys as $key ) {
|
||||
@ -386,8 +383,6 @@ function get_attachment_icon_src( $id = 0, $fullsize = false ) {
|
||||
if ( !$post = & get_post($id) )
|
||||
return false;
|
||||
|
||||
$imagedata = wp_get_attachment_metadata( $post->ID );
|
||||
|
||||
$file = get_attached_file( $post->ID );
|
||||
|
||||
if ( !$fullsize && $thumbfile = wp_get_attachment_thumb_file( $post->ID ) ) {
|
||||
|
@ -26,8 +26,6 @@ function update_attached_file( $attachment_id, $file ) {
|
||||
}
|
||||
|
||||
function &get_children($args = '', $output = OBJECT) {
|
||||
global $wpdb;
|
||||
|
||||
if ( empty( $args ) ) {
|
||||
if ( isset( $GLOBALS['post'] ) ) {
|
||||
$args = 'post_parent=' . (int) $GLOBALS['post']->post_parent;
|
||||
@ -163,7 +161,7 @@ function get_post_status($ID = '') {
|
||||
}
|
||||
|
||||
function get_post_type($post = false) {
|
||||
global $wpdb, $posts;
|
||||
global $posts;
|
||||
|
||||
if ( false === $post )
|
||||
$post = $posts[0];
|
||||
@ -310,8 +308,6 @@ function delete_post_meta($post_id, $key, $value = '') {
|
||||
}
|
||||
|
||||
function get_post_meta($post_id, $key, $single = false) {
|
||||
global $wpdb;
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
$meta_cache = wp_cache_get($post_id, 'post_meta');
|
||||
@ -342,10 +338,7 @@ function get_post_meta($post_id, $key, $single = false) {
|
||||
function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') {
|
||||
global $wpdb;
|
||||
|
||||
$original_value = $meta_value;
|
||||
$meta_value = maybe_serialize($meta_value);
|
||||
|
||||
$original_prev = $prev_value;
|
||||
$prev_value = maybe_serialize($prev_value);
|
||||
|
||||
// expected_slashed ($meta_key)
|
||||
@ -378,7 +371,7 @@ function delete_post_meta_by_key($post_meta_key) {
|
||||
|
||||
|
||||
function get_post_custom($post_id = 0) {
|
||||
global $id, $wpdb;
|
||||
global $id;
|
||||
|
||||
if ( !$post_id )
|
||||
$post_id = (int) $id;
|
||||
@ -577,8 +570,6 @@ function wp_get_recent_posts($num = 10) {
|
||||
}
|
||||
|
||||
function wp_get_single_post($postid = 0, $mode = OBJECT) {
|
||||
global $wpdb;
|
||||
|
||||
$postid = (int) $postid;
|
||||
|
||||
$post = get_post($postid, $mode);
|
||||
@ -597,7 +588,7 @@ function wp_get_single_post($postid = 0, $mode = OBJECT) {
|
||||
}
|
||||
|
||||
function wp_insert_post($postarr = array()) {
|
||||
global $wpdb, $wp_rewrite, $allowedtags, $user_ID;
|
||||
global $wpdb, $wp_rewrite, $user_ID;
|
||||
|
||||
$defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
|
||||
'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
|
||||
@ -768,8 +759,6 @@ function wp_insert_post($postarr = array()) {
|
||||
}
|
||||
|
||||
function wp_update_post($postarr = array()) {
|
||||
global $wpdb;
|
||||
|
||||
if ( is_object($postarr) )
|
||||
$postarr = get_object_vars($postarr);
|
||||
|
||||
@ -835,7 +824,6 @@ function wp_add_post_tags($post_id = 0, $tags = '') {
|
||||
|
||||
function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
|
||||
/* $append - true = don't delete existing tags, just add on, false = replace the tags with the new tags */
|
||||
global $wpdb;
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
@ -849,8 +837,6 @@ function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
|
||||
}
|
||||
|
||||
function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
|
||||
global $wpdb;
|
||||
|
||||
$post_ID = (int) $post_ID;
|
||||
// If $post_categories isn't already an array, make it one:
|
||||
if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories))
|
||||
@ -890,7 +876,6 @@ function add_ping($post_id, $uri) { // Add a URL to those already pung
|
||||
}
|
||||
|
||||
function get_enclosed($post_id) { // Get enclosures already enclosed for a post
|
||||
global $wpdb;
|
||||
$custom_fields = get_post_custom( $post_id );
|
||||
$pung = array();
|
||||
if ( !is_array( $custom_fields ) )
|
||||
@ -1226,8 +1211,7 @@ function wp_insert_attachment($object, $file = false, $parent = 0) {
|
||||
$post_name = sanitize_title($post_name);
|
||||
|
||||
// expected_slashed ($post_name)
|
||||
$post_name_check =
|
||||
$wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'inherit' AND ID != %d LIMIT 1", $post_ID));
|
||||
$post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'inherit' AND ID != %d LIMIT 1", $post_ID));
|
||||
|
||||
if ($post_name_check) {
|
||||
$suffix = 2;
|
||||
@ -1547,8 +1531,7 @@ function get_private_posts_cap_sql($post_type) {
|
||||
}
|
||||
|
||||
function get_lastpostdate($timezone = 'server') {
|
||||
global $cache_lastpostdate, $pagenow, $wpdb, $blog_id;
|
||||
$add_seconds_blog = get_option('gmt_offset') * 3600;
|
||||
global $cache_lastpostdate, $wpdb, $blog_id;
|
||||
$add_seconds_server = date('Z');
|
||||
if ( !isset($cache_lastpostdate[$blog_id][$timezone]) ) {
|
||||
switch(strtolower($timezone)) {
|
||||
@ -1570,8 +1553,7 @@ function get_lastpostdate($timezone = 'server') {
|
||||
}
|
||||
|
||||
function get_lastpostmodified($timezone = 'server') {
|
||||
global $cache_lastpostmodified, $pagenow, $wpdb, $blog_id;
|
||||
$add_seconds_blog = get_option('gmt_offset') * 3600;
|
||||
global $cache_lastpostmodified, $wpdb, $blog_id;
|
||||
$add_seconds_server = date('Z');
|
||||
if ( !isset($cache_lastpostmodified[$blog_id][$timezone]) ) {
|
||||
switch(strtolower($timezone)) {
|
||||
@ -1633,8 +1615,6 @@ function clean_page_cache($id) {
|
||||
}
|
||||
|
||||
function update_post_caches(&$posts) {
|
||||
global $wpdb;
|
||||
|
||||
// No point in doing all this work if we didn't match any posts.
|
||||
if ( !$posts )
|
||||
return;
|
||||
@ -1738,8 +1718,6 @@ function _publish_post_hook($post_id) {
|
||||
if ( defined('WP_IMPORTING') )
|
||||
return;
|
||||
|
||||
$post = get_post($post_id);
|
||||
|
||||
$data = array( 'post_id' => $post_id, 'meta_value' => '1' );
|
||||
if ( get_option('default_pingback_flag') )
|
||||
$wpdb->insert( $wpdb->postmeta, $data + array( 'meta_key' => '_pingme' ) );
|
||||
|
@ -728,7 +728,7 @@ class WP_Query {
|
||||
}
|
||||
|
||||
function &get_posts() {
|
||||
global $wpdb, $pagenow, $user_ID;
|
||||
global $wpdb, $user_ID;
|
||||
|
||||
do_action_ref_array('pre_get_posts', array(&$this));
|
||||
|
||||
@ -741,8 +741,6 @@ class WP_Query {
|
||||
$distinct = '';
|
||||
$whichcat = '';
|
||||
$whichauthor = '';
|
||||
$whichpage = '';
|
||||
$result = '';
|
||||
$where = '';
|
||||
$limits = '';
|
||||
$join = '';
|
||||
@ -789,10 +787,6 @@ class WP_Query {
|
||||
$q['page'] = abs($q['page']);
|
||||
}
|
||||
|
||||
$add_hours = intval(get_option('gmt_offset'));
|
||||
$add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));
|
||||
$wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
|
||||
|
||||
// If a month is specified in the querystring, load that month
|
||||
if ( $q['m'] ) {
|
||||
$q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']);
|
||||
@ -1495,8 +1489,7 @@ function wp_old_slug_redirect () {
|
||||
|
||||
// Setup global post data.
|
||||
function setup_postdata($post) {
|
||||
global $id, $postdata, $authordata, $day, $currentmonth, $page, $pages, $multipage, $more, $numpages, $wp_query;
|
||||
global $pagenow;
|
||||
global $id, $authordata, $day, $currentmonth, $page, $pages, $multipage, $more, $numpages;
|
||||
|
||||
$id = (int) $post->ID;
|
||||
|
||||
|
@ -311,8 +311,6 @@ class WP_Rewrite {
|
||||
}
|
||||
|
||||
function page_rewrite_rules() {
|
||||
global $wpdb;
|
||||
|
||||
$rewrite_rules = array();
|
||||
$page_structure = $this->get_page_permastruct();
|
||||
|
||||
|
@ -773,8 +773,7 @@ function sanitize_term($term, $taxonomy, $context = 'display') {
|
||||
* @return mixed sanitized field
|
||||
*/
|
||||
function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {
|
||||
if ( 'parent' == $field || 'term_id' == $field || 'count' == $field
|
||||
|| 'term_group' == $field )
|
||||
if ( 'parent' == $field || 'term_id' == $field || 'count' == $field || 'term_group' == $field )
|
||||
$value = (int) $value;
|
||||
|
||||
if ( 'raw' == $context )
|
||||
@ -1209,7 +1208,7 @@ function wp_unique_term_slug($slug, $term) {
|
||||
if ( !empty($args['term_id']) )
|
||||
$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $args['term_id'] );
|
||||
else
|
||||
$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s $where", $slug );
|
||||
$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug );
|
||||
|
||||
if ( $wpdb->get_var( $query ) ) {
|
||||
$num = 2;
|
||||
@ -1471,8 +1470,6 @@ function &get_object_term_cache($id, $taxonomy) {
|
||||
* @return null|array Null value is given with empty $object_ids.
|
||||
*/
|
||||
function update_object_term_cache($object_ids, $object_type) {
|
||||
global $wpdb;
|
||||
|
||||
if ( empty($object_ids) )
|
||||
return;
|
||||
|
||||
|
@ -436,8 +436,7 @@ function get_comments_popup_template() {
|
||||
}
|
||||
|
||||
function load_template($_template_file) {
|
||||
global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query,
|
||||
$wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
|
||||
global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
|
||||
|
||||
if ( is_array($wp_query->query_vars) )
|
||||
extract($wp_query->query_vars, EXTR_SKIP);
|
||||
|
@ -75,7 +75,6 @@ function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) {
|
||||
else
|
||||
$wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
|
||||
|
||||
$user = get_userdata($user_id);
|
||||
wp_cache_delete($user_id, 'users');
|
||||
|
||||
return true;
|
||||
@ -138,7 +137,6 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = get_userdata($user_id);
|
||||
wp_cache_delete($user_id, 'users');
|
||||
|
||||
return true;
|
||||
|
@ -227,7 +227,7 @@ function is_active_widget($callback) {
|
||||
|
||||
$sidebars_widgets = wp_get_sidebars_widgets(false);
|
||||
|
||||
if ( is_array($sidebars_widgets) ) foreach ( $sidebars_widgets as $sidebar => $widgets )
|
||||
if ( is_array($sidebars_widgets) ) foreach ( $sidebars_widgets as $widgets )
|
||||
if ( is_array($widgets) ) foreach ( $widgets as $widget )
|
||||
if ( $wp_registered_widgets[$widget]['callback'] == $callback )
|
||||
return true;
|
||||
@ -572,7 +572,7 @@ function wp_widget_text_setup() {
|
||||
}
|
||||
|
||||
function wp_widget_text_page() {
|
||||
$options = $newoptions = get_option('widget_text');
|
||||
$options = get_option('widget_text');
|
||||
?>
|
||||
<div class="wrap">
|
||||
<form method="POST">
|
||||
@ -1005,7 +1005,6 @@ function wp_widget_rss_control($number) {
|
||||
} else {
|
||||
$newoptions[$number]['error'] = true;
|
||||
$newoptions[$number]['url'] = wp_specialchars(__('Error: could not find an RSS or ATOM feed at that URL.'), 1);
|
||||
$error = sprintf(__('Error in RSS %1$d: %2$s'), $number, $newoptions[$number]['error']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1023,7 +1022,7 @@ function wp_widget_rss_control($number) {
|
||||
<p style="text-align:center;"><?php _e('Give the feed a title (optional):'); ?></p>
|
||||
<input style="width: 400px;" id="rss-title-<?php echo "$number"; ?>" name="rss-title-<?php echo "$number"; ?>" type="text" value="<?php echo $title; ?>" />
|
||||
<p style="text-align:center; line-height: 30px;"><?php _e('How many items would you like to display?'); ?> <select id="rss-items-<?php echo $number; ?>" name="rss-items-<?php echo $number; ?>"><?php for ( $i = 1; $i <= 10; ++$i ) echo "<option value='$i' ".($items==$i ? "selected='selected'" : '').">$i</option>"; ?></select></p>
|
||||
<input type="hidden" id="rss-submit-<?php echo "$number"; ?>" name="rss-submit-<?php echo "$number"; ?>" value="1" />
|
||||
<input type="hidden" id="rss-submit-<?php echo "$number"; ?>" name="rss-submit-<?php echo $number; ?>" value="1" />
|
||||
<?php
|
||||
}
|
||||
|
||||
@ -1043,7 +1042,7 @@ function wp_widget_rss_setup() {
|
||||
}
|
||||
|
||||
function wp_widget_rss_page() {
|
||||
$options = $newoptions = get_option('widget_rss');
|
||||
$options = get_option('widget_rss');
|
||||
?>
|
||||
<div class="wrap">
|
||||
<form method="POST">
|
||||
|
@ -27,7 +27,7 @@ if ( SITECOOKIEPATH != COOKIEPATH )
|
||||
|
||||
// Rather than duplicating this HTML all over the place, we'll stick it in function
|
||||
function login_header($title = 'Login', $message = '') {
|
||||
global $errors, $error, $wp_locale;
|
||||
global $errors, $error;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
618
xmlrpc.php
618
xmlrpc.php
@ -459,7 +459,6 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
* wp_getAuthors
|
||||
*/
|
||||
function wp_getAuthors($args) {
|
||||
global $wpdb;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
@ -533,8 +532,6 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
* wp_suggestCategories
|
||||
*/
|
||||
function wp_suggestCategories($args) {
|
||||
global $wpdb;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
$blog_id = (int) $args[0];
|
||||
@ -625,7 +622,6 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$user_data = get_userdatabylogin($user_login);
|
||||
$post_data = wp_get_single_post($post_ID, ARRAY_A);
|
||||
|
||||
$categories = implode(',', wp_get_post_categories($post_ID));
|
||||
@ -648,8 +644,6 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
/* blogger.getRecentPosts ...gets recent posts */
|
||||
function blogger_getRecentPosts($args) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
$blog_ID = (int) $args[1]; /* though we don't use it yet */
|
||||
@ -767,137 +761,129 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
/* blogger.newPost ...creates a new post */
|
||||
function blogger_newPost($args) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
$blog_ID = (int) $args[1]; /* though we don't use it yet */
|
||||
$user_login = $args[2];
|
||||
$user_pass = $args[3];
|
||||
$content = $args[4];
|
||||
$publish = $args[5];
|
||||
$blog_ID = (int) $args[1]; /* though we don't use it yet */
|
||||
$user_login = $args[2];
|
||||
$user_pass = $args[3];
|
||||
$content = $args[4];
|
||||
$publish = $args[5];
|
||||
|
||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
||||
$user = set_current_user(0, $user_login);
|
||||
if ( !current_user_can($cap) )
|
||||
return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.'));
|
||||
|
||||
$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 (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
if (!$post_ID)
|
||||
return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
|
||||
|
||||
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
||||
$user = set_current_user(0, $user_login);
|
||||
if ( !current_user_can($cap) )
|
||||
return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.'));
|
||||
$this->attach_uploads( $post_ID, $post_content );
|
||||
|
||||
$post_status = ($publish) ? 'publish' : 'draft';
|
||||
logIO('O', "Posted ! ID: $post_ID");
|
||||
|
||||
$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;
|
||||
return $post_ID;
|
||||
}
|
||||
|
||||
|
||||
/* blogger.editPost ...edits a post */
|
||||
function blogger_editPost($args) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
$post_ID = (int) $args[1];
|
||||
$user_login = $args[2];
|
||||
$user_pass = $args[3];
|
||||
$content = $args[4];
|
||||
$publish = $args[5];
|
||||
|
||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$actual_post = wp_get_single_post($post_ID,ARRAY_A);
|
||||
|
||||
if (!$actual_post) {
|
||||
return new IXR_Error(404, __('Sorry, no such post.'));
|
||||
}
|
||||
|
||||
|
||||
$post_ID = (int) $args[1];
|
||||
$user_login = $args[2];
|
||||
$user_pass = $args[3];
|
||||
$content = $args[4];
|
||||
$publish = $args[5];
|
||||
|
||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$actual_post = wp_get_single_post($post_ID,ARRAY_A);
|
||||
|
||||
if (!$actual_post) {
|
||||
return new IXR_Error(404, __('Sorry, no such post.'));
|
||||
}
|
||||
|
||||
$this->escape($actual_post);
|
||||
|
||||
set_current_user(0, $user_login);
|
||||
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;
|
||||
|
||||
set_current_user(0, $user_login);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/* blogger.deletePost ...deletes a post */
|
||||
function blogger_deletePost($args) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
$post_ID = (int) $args[1];
|
||||
$user_login = $args[2];
|
||||
$user_pass = $args[3];
|
||||
$publish = $args[4];
|
||||
|
||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$actual_post = wp_get_single_post($post_ID,ARRAY_A);
|
||||
|
||||
if (!$actual_post) {
|
||||
return new IXR_Error(404, __('Sorry, no such post.'));
|
||||
}
|
||||
|
||||
set_current_user(0, $user_login);
|
||||
if ( !current_user_can('edit_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;
|
||||
|
||||
$post_ID = (int) $args[1];
|
||||
$user_login = $args[2];
|
||||
$user_pass = $args[3];
|
||||
$publish = $args[4];
|
||||
|
||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$actual_post = wp_get_single_post($post_ID,ARRAY_A);
|
||||
|
||||
if (!$actual_post) {
|
||||
return new IXR_Error(404, __('Sorry, no such post.'));
|
||||
}
|
||||
|
||||
set_current_user(0, $user_login);
|
||||
if ( !current_user_can('edit_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;
|
||||
}
|
||||
|
||||
|
||||
@ -908,25 +894,22 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
/* metaweblog.newPost creates a post */
|
||||
function mw_newPost($args) {
|
||||
|
||||
global $wpdb, $post_default_category;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
$blog_ID = (int) $args[0]; // we will support this in the near future
|
||||
$user_login = $args[1];
|
||||
$user_pass = $args[2];
|
||||
$content_struct = $args[3];
|
||||
$publish = $args[4];
|
||||
|
||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
||||
$user = set_current_user(0, $user_login);
|
||||
if ( !current_user_can($cap) )
|
||||
return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.'));
|
||||
$blog_ID = (int) $args[0]; // we will support this in the near future
|
||||
$user_login = $args[1];
|
||||
$user_pass = $args[2];
|
||||
$content_struct = $args[3];
|
||||
$publish = $args[4];
|
||||
|
||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
|
||||
$user = set_current_user(0, $user_login);
|
||||
if ( !current_user_can($cap) )
|
||||
return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.'));
|
||||
|
||||
// The post_type defaults to post, but could also be page.
|
||||
$post_type = "post";
|
||||
@ -959,7 +942,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$menu_order = $content_struct["wp_page_order"];
|
||||
}
|
||||
|
||||
$post_author = $user->ID;
|
||||
$post_author = $user->ID;
|
||||
|
||||
// If an author id was provided then use it instead.
|
||||
if(
|
||||
@ -984,12 +967,12 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$post_author = $content_struct["wp_author_id"];
|
||||
}
|
||||
|
||||
$post_title = $content_struct['title'];
|
||||
$post_content = apply_filters( 'content_save_pre', $content_struct['description'] );
|
||||
$post_status = $publish ? 'publish' : 'draft';
|
||||
|
||||
$post_excerpt = $content_struct['mt_excerpt'];
|
||||
$post_more = $content_struct['mt_text_more'];
|
||||
$post_title = $content_struct['title'];
|
||||
$post_content = apply_filters( 'content_save_pre', $content_struct['description'] );
|
||||
$post_status = $publish ? 'publish' : 'draft';
|
||||
|
||||
$post_excerpt = $content_struct['mt_excerpt'];
|
||||
$post_more = $content_struct['mt_text_more'];
|
||||
|
||||
$tags_input = $content_struct['mt_keywords'];
|
||||
|
||||
@ -1058,13 +1041,13 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$ping_status = get_option("default_ping_status");
|
||||
}
|
||||
|
||||
if ($post_more) {
|
||||
$post_content = $post_content . "\n<!--more-->\n" . $post_more;
|
||||
}
|
||||
|
||||
$to_ping = $content_struct['mt_tb_ping_urls'];
|
||||
if ( is_array($to_ping) )
|
||||
$to_ping = implode(' ', $to_ping);
|
||||
if ($post_more) {
|
||||
$post_content = $post_content . "\n<!--more-->\n" . $post_more;
|
||||
}
|
||||
|
||||
$to_ping = $content_struct['mt_tb_ping_urls'];
|
||||
if ( is_array($to_ping) )
|
||||
$to_ping = implode(' ', $to_ping);
|
||||
|
||||
// Do some timestamp voodoo
|
||||
$dateCreatedd = $content_struct['dateCreated'];
|
||||
@ -1077,32 +1060,32 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$post_date_gmt = current_time('mysql', 1);
|
||||
}
|
||||
|
||||
$catnames = $content_struct['categories'];
|
||||
logIO('O', 'Post cats: ' . printr($catnames,true));
|
||||
$post_category = array();
|
||||
$catnames = $content_struct['categories'];
|
||||
logIO('O', 'Post cats: ' . printr($catnames,true));
|
||||
$post_category = array();
|
||||
|
||||
if (is_array($catnames)) {
|
||||
foreach ($catnames as $cat) {
|
||||
$post_category[] = get_cat_ID($cat);
|
||||
}
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
$post_ID = wp_insert_post($postdata);
|
||||
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 strval($post_ID);
|
||||
// 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');
|
||||
|
||||
$post_ID = wp_insert_post($postdata);
|
||||
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 strval($post_ID);
|
||||
}
|
||||
|
||||
function attach_uploads( $post_ID, $post_content ) {
|
||||
@ -1122,19 +1105,17 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
/* metaweblog.editPost ...edits a post */
|
||||
function mw_editPost($args) {
|
||||
|
||||
global $wpdb, $post_default_category;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
$post_ID = (int) $args[0];
|
||||
$user_login = $args[1];
|
||||
$user_pass = $args[2];
|
||||
$content_struct = $args[3];
|
||||
$publish = $args[4];
|
||||
|
||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
$post_ID = (int) $args[0];
|
||||
$user_login = $args[1];
|
||||
$user_pass = $args[2];
|
||||
$content_struct = $args[3];
|
||||
$publish = $args[4];
|
||||
|
||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$user = set_current_user(0, $user_login);
|
||||
|
||||
@ -1147,11 +1128,11 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$post_type = "page";
|
||||
}
|
||||
|
||||
// Edit page caps are checked in editPage. Just check post here.
|
||||
if ( ( 'post' == $post_type ) && !current_user_can('edit_post', $post_ID) )
|
||||
return new IXR_Error(401, __('Sorry, you can not edit this post.'));
|
||||
// Edit page caps are checked in editPage. Just check post here.
|
||||
if ( ( 'post' == $post_type ) && !current_user_can('edit_post', $post_ID) )
|
||||
return new IXR_Error(401, __('Sorry, you can not edit this post.'));
|
||||
|
||||
$postdata = wp_get_single_post($post_ID, ARRAY_A);
|
||||
$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
|
||||
@ -1268,141 +1249,136 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
}
|
||||
}
|
||||
|
||||
$post_title = $content_struct['title'];
|
||||
$post_content = apply_filters( 'content_save_pre', $content_struct['description'] );
|
||||
$catnames = $content_struct['categories'];
|
||||
$post_title = $content_struct['title'];
|
||||
$post_content = apply_filters( 'content_save_pre', $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';
|
||||
|
||||
$tags_input = $content_struct['mt_keywords'];
|
||||
|
||||
$post_category = array();
|
||||
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 . "\n<!--more-->\n" . $post_more;
|
||||
}
|
||||
|
||||
if (is_array($catnames)) {
|
||||
foreach ($catnames as $cat) {
|
||||
$post_category[] = get_cat_ID($cat);
|
||||
}
|
||||
}
|
||||
$to_ping = $content_struct['mt_tb_ping_urls'];
|
||||
if ( is_array($to_ping) )
|
||||
$to_ping = implode(' ', $to_ping);
|
||||
|
||||
// Do some timestamp voodoo
|
||||
$dateCreatedd = $content_struct['dateCreated'];
|
||||
if (!empty($dateCreatedd)) {
|
||||
$dateCreated = $dateCreatedd->getIso();
|
||||
$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
|
||||
$post_date_gmt = iso8601_to_datetime($dateCreated . "Z", GMT);
|
||||
} else {
|
||||
$post_date = $postdata['post_date'];
|
||||
$post_date_gmt = $postdata['post_date_gmt'];
|
||||
}
|
||||
|
||||
$post_excerpt = $content_struct['mt_excerpt'];
|
||||
$post_more = $content_struct['mt_text_more'];
|
||||
$post_status = $publish ? 'publish' : 'draft';
|
||||
|
||||
$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 . "\n<!--more-->\n" . $post_more;
|
||||
}
|
||||
|
||||
$to_ping = $content_struct['mt_tb_ping_urls'];
|
||||
if ( is_array($to_ping) )
|
||||
$to_ping = implode(' ', $to_ping);
|
||||
|
||||
// Do some timestamp voodoo
|
||||
$dateCreatedd = $content_struct['dateCreated'];
|
||||
if (!empty($dateCreatedd)) {
|
||||
$dateCreated = $dateCreatedd->getIso();
|
||||
$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
|
||||
$post_date_gmt = iso8601_to_datetime($dateCreated . "Z", 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');
|
||||
|
||||
$result = wp_update_post($newpost);
|
||||
if (!$result) {
|
||||
return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.'));
|
||||
}
|
||||
$this->attach_uploads( $ID, $post_content );
|
||||
|
||||
logIO('O',"(MW) Edited ! ID: $post_ID");
|
||||
|
||||
return true;
|
||||
// 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');
|
||||
|
||||
$result = wp_update_post($newpost);
|
||||
if (!$result) {
|
||||
return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.'));
|
||||
}
|
||||
$this->attach_uploads( $ID, $post_content );
|
||||
|
||||
logIO('O',"(MW) Edited ! ID: $post_ID");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* metaweblog.getPost ...returns a post */
|
||||
function mw_getPost($args) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
$post_ID = (int) $args[0];
|
||||
$user_login = $args[1];
|
||||
$user_pass = $args[2];
|
||||
|
||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$postdata = wp_get_single_post($post_ID, ARRAY_A);
|
||||
|
||||
if ($postdata['post_date'] != '') {
|
||||
|
||||
$post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']);
|
||||
$post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']);
|
||||
|
||||
$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_ID = (int) $args[0];
|
||||
$user_login = $args[1];
|
||||
$user_pass = $args[2];
|
||||
|
||||
if (!$this->login_pass_ok($user_login, $user_pass)) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
$postdata = wp_get_single_post($post_ID, ARRAY_A);
|
||||
|
||||
if ($postdata['post_date'] != '') {
|
||||
$post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']);
|
||||
$post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']);
|
||||
|
||||
$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;
|
||||
|
||||
$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']
|
||||
);
|
||||
|
||||
return $resp;
|
||||
} else {
|
||||
return new IXR_Error(404, __('Sorry, no such post.'));
|
||||
}
|
||||
|
||||
$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;
|
||||
|
||||
$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']
|
||||
);
|
||||
|
||||
return $resp;
|
||||
} else {
|
||||
return new IXR_Error(404, __('Sorry, no such post.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1496,8 +1472,6 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
/* metaweblog.getCategories ...returns the list of categories on a given blog */
|
||||
function mw_getCategories($args) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
$blog_ID = (int) $args[0];
|
||||
@ -1576,7 +1550,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$name = "wpid{$old_file->ID}-{$filename}";
|
||||
}
|
||||
|
||||
$upload = wp_upload_bits($name, $type, $bits, $overwrite);
|
||||
$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);
|
||||
@ -1654,8 +1628,6 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
/* mt.getCategoryList ...returns the list of categories on a given blog */
|
||||
function mt_getCategoryList($args) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
$blog_ID = (int) $args[0];
|
||||
@ -1834,7 +1806,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
/* pingback.ping gets a pingback and registers it */
|
||||
function pingback_ping($args) {
|
||||
global $wpdb, $wp_version;
|
||||
global $wpdb;
|
||||
|
||||
$this->escape($args);
|
||||
|
||||
@ -1847,12 +1819,10 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$pagelinkedto = str_replace('&', '&', $pagelinkedto);
|
||||
$pagelinkedto = str_replace('&', '&', $pagelinkedto);
|
||||
|
||||
$error_code = -1;
|
||||
|
||||
// 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?'));
|
||||
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?
|
||||
@ -1912,7 +1882,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
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
|
||||
$result = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_ID' AND comment_author_url = '$pagelinkedfrom'");
|
||||
$wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_ID' AND comment_author_url = '$pagelinkedfrom'");
|
||||
|
||||
if ( $wpdb->num_rows ) // We already have a Pingback from this URL
|
||||
return new IXR_Error(48, __('The pingback has already been registered.'));
|
||||
@ -1974,9 +1944,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom);
|
||||
|
||||
$context = '[...] ' . wp_specialchars( $excerpt ) . ' [...]';
|
||||
$original_pagelinkedfrom = $pagelinkedfrom;
|
||||
$pagelinkedfrom = $wpdb->escape( $pagelinkedfrom );
|
||||
$original_title = $title;
|
||||
|
||||
$comment_post_ID = (int) $post_ID;
|
||||
$comment_author = $title;
|
||||
|
Loading…
Reference in New Issue
Block a user