Bunch of whitespace and coding standardization.
git-svn-id: http://svn.automattic.com/wordpress/trunk@4626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
010379dd52
commit
0aa19529f9
|
@ -3,12 +3,13 @@
|
|||
function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
|
||||
global $wpdb;
|
||||
|
||||
if (1 == get_option('comment_moderation')) return false; // If moderation is set to manual
|
||||
if ( 1 == get_option('comment_moderation') )
|
||||
return false; // If moderation is set to manual
|
||||
|
||||
if ( preg_match_all("|(href\t*?=\t*?['\"]?)?(https?:)?//|i", $comment, $out) >= get_option('comment_max_links') )
|
||||
return false; // Check # of external links
|
||||
|
||||
$mod_keys = trim( get_option('moderation_keys') );
|
||||
$mod_keys = trim(get_option('moderation_keys'));
|
||||
if ( !empty($mod_keys) ) {
|
||||
$words = explode("\n", $mod_keys );
|
||||
|
||||
|
@ -16,7 +17,8 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
|
|||
$word = trim($word);
|
||||
|
||||
// Skip empty lines
|
||||
if (empty($word)) { continue; }
|
||||
if ( empty($word) )
|
||||
continue;
|
||||
|
||||
// Do some escaping magic so that '#' chars in the
|
||||
// spam words don't break things:
|
||||
|
@ -43,7 +45,7 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
|
|||
return true;
|
||||
else
|
||||
return false;
|
||||
} elseif( $author != '' && $email != '' ) {
|
||||
} elseif ( $author != '' && $email != '' ) {
|
||||
$ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1");
|
||||
if ( ( 1 == $ok_to_comment ) &&
|
||||
( empty($mod_keys) || false === strpos( $email, $mod_keys) ) )
|
||||
|
@ -54,10 +56,10 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function get_approved_comments($post_id) {
|
||||
global $wpdb;
|
||||
|
||||
|
@ -65,6 +67,7 @@ function get_approved_comments($post_id) {
|
|||
return $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1' ORDER BY comment_date");
|
||||
}
|
||||
|
||||
|
||||
// Retrieves comment data given a comment ID or comment object.
|
||||
// Handles comment caching.
|
||||
function &get_comment(&$comment, $output = OBJECT) {
|
||||
|
@ -97,14 +100,14 @@ 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;
|
||||
if ($no_cache) {
|
||||
if ( $no_cache ) {
|
||||
$query = "SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_ID'";
|
||||
if (false == $include_unapproved) {
|
||||
if ( false == $include_unapproved )
|
||||
$query .= " AND comment_approved = '1'";
|
||||
}
|
||||
$myrow = $wpdb->get_row($query, ARRAY_A);
|
||||
} else {
|
||||
$myrow['comment_ID'] = $postc->comment_ID;
|
||||
|
@ -122,13 +125,14 @@ function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = fals
|
|||
return $myrow;
|
||||
}
|
||||
|
||||
|
||||
function get_lastcommentmodified($timezone = 'server') {
|
||||
global $cache_lastcommentmodified, $pagenow, $wpdb;
|
||||
$add_seconds_blog = get_option('gmt_offset') * 3600;
|
||||
$add_seconds_server = date('Z');
|
||||
$now = current_time('mysql', 1);
|
||||
if ( !isset($cache_lastcommentmodified[$timezone]) ) {
|
||||
switch(strtolower($timezone)) {
|
||||
switch ( strtolower($timezone)) {
|
||||
case 'gmt':
|
||||
$lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
|
||||
break;
|
||||
|
@ -146,6 +150,7 @@ function get_lastcommentmodified($timezone = 'server') {
|
|||
return $lastcommentmodified;
|
||||
}
|
||||
|
||||
|
||||
function sanitize_comment_cookies() {
|
||||
if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
|
||||
$comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
|
||||
|
@ -169,6 +174,7 @@ function sanitize_comment_cookies() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function wp_allow_comment($commentdata) {
|
||||
global $wpdb;
|
||||
extract($commentdata);
|
||||
|
@ -198,13 +204,11 @@ function wp_allow_comment($commentdata) {
|
|||
$post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1");
|
||||
}
|
||||
|
||||
// The author and the admins get respect.
|
||||
if ( $userdata && ( $user_id == $post_author || $user->has_cap('level_9') ) ) {
|
||||
// The author and the admins get respect.
|
||||
$approved = 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Everyone else's comments will be checked.
|
||||
else {
|
||||
if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) )
|
||||
$approved = 1;
|
||||
else
|
||||
|
@ -217,27 +221,28 @@ function wp_allow_comment($commentdata) {
|
|||
return $approved;
|
||||
}
|
||||
|
||||
|
||||
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) ) {
|
||||
foreach ($chars[1] as $char) {
|
||||
foreach ( (array) $chars[1] as $char ) {
|
||||
// If it's an encoded char in the normal ASCII set, reject
|
||||
if ( 38 == $char )
|
||||
continue; // Unless it's &
|
||||
if ($char < 128)
|
||||
if ( $char < 128 )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$mod_keys = trim( get_option('blacklist_keys') );
|
||||
if ('' == $mod_keys )
|
||||
if ( '' == $mod_keys )
|
||||
return false; // If moderation keys are empty
|
||||
$words = explode("\n", $mod_keys );
|
||||
|
||||
foreach ($words as $word) {
|
||||
foreach ( (array) $words as $word ) {
|
||||
$word = trim($word);
|
||||
|
||||
// Skip empty lines
|
||||
|
@ -248,17 +253,20 @@ function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_age
|
|||
$word = preg_quote($word, '#');
|
||||
|
||||
$pattern = "#$word#i";
|
||||
if ( preg_match($pattern, $author ) ) return true;
|
||||
if ( preg_match($pattern, $email ) ) return true;
|
||||
if ( preg_match($pattern, $url ) ) return true;
|
||||
if ( preg_match($pattern, $comment ) ) return true;
|
||||
if ( preg_match($pattern, $user_ip ) ) return true;
|
||||
if ( preg_match($pattern, $user_agent) ) return true;
|
||||
if (
|
||||
preg_match($pattern, $author)
|
||||
|| preg_match($pattern, $email)
|
||||
|| preg_match($pattern, $url)
|
||||
|| preg_match($pattern, $comment)
|
||||
|| preg_match($pattern, $user_ip)
|
||||
|| preg_match($pattern, $user_agent)
|
||||
)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function wp_delete_comment($comment_id) {
|
||||
global $wpdb;
|
||||
do_action('delete_comment', $comment_id);
|
||||
|
@ -276,23 +284,25 @@ function wp_delete_comment($comment_id) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
function wp_get_comment_status($comment_id) {
|
||||
global $wpdb;
|
||||
|
||||
$result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
|
||||
if ($result == NULL) {
|
||||
|
||||
if ( $result == NULL )
|
||||
return 'deleted';
|
||||
} else if ($result == '1') {
|
||||
elseif ( $result == '1' )
|
||||
return 'approved';
|
||||
} else if ($result == '0') {
|
||||
elseif ( $result == '0' )
|
||||
return 'unapproved';
|
||||
} else if ($result == 'spam') {
|
||||
elseif ( $result == 'spam' )
|
||||
return 'spam';
|
||||
} else {
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function wp_get_current_commenter() {
|
||||
// Cookies should already be sanitized.
|
||||
|
||||
|
@ -311,6 +321,7 @@ function wp_get_current_commenter() {
|
|||
return compact('comment_author', 'comment_author_email', 'comment_author_url');
|
||||
}
|
||||
|
||||
|
||||
function wp_insert_comment($commentdata) {
|
||||
global $wpdb;
|
||||
extract($commentdata);
|
||||
|
@ -342,6 +353,7 @@ function wp_insert_comment($commentdata) {
|
|||
return $id;
|
||||
}
|
||||
|
||||
|
||||
function wp_filter_comment($commentdata) {
|
||||
$commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']);
|
||||
$commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', $commentdata['comment_agent']);
|
||||
|
@ -354,6 +366,7 @@ function wp_filter_comment($commentdata) {
|
|||
return $commentdata;
|
||||
}
|
||||
|
||||
|
||||
function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) {
|
||||
if ( $block ) // a plugin has already blocked... we'll let that decision stand
|
||||
return $block;
|
||||
|
@ -362,6 +375,7 @@ function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
function wp_new_comment( $commentdata ) {
|
||||
$commentdata = apply_filters('preprocess_comment', $commentdata);
|
||||
|
||||
|
@ -374,7 +388,6 @@ function wp_new_comment( $commentdata ) {
|
|||
$commentdata['comment_date'] = current_time('mysql');
|
||||
$commentdata['comment_date_gmt'] = current_time('mysql', 1);
|
||||
|
||||
|
||||
$commentdata = wp_filter_comment($commentdata);
|
||||
|
||||
$commentdata['comment_approved'] = wp_allow_comment($commentdata);
|
||||
|
@ -396,10 +409,11 @@ function wp_new_comment( $commentdata ) {
|
|||
return $comment_ID;
|
||||
}
|
||||
|
||||
|
||||
function wp_set_comment_status($comment_id, $comment_status) {
|
||||
global $wpdb;
|
||||
|
||||
switch($comment_status) {
|
||||
switch ( $comment_status ) {
|
||||
case 'hold':
|
||||
$query = "UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1";
|
||||
break;
|
||||
|
@ -416,20 +430,21 @@ function wp_set_comment_status($comment_id, $comment_status) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($wpdb->query($query)) {
|
||||
if ( $wpdb->query($query) ) {
|
||||
do_action('wp_set_comment_status', $comment_id, $comment_status);
|
||||
|
||||
$comment = get_comment($comment_id);
|
||||
$comment_post_ID = $comment->comment_post_ID;
|
||||
$c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" );
|
||||
if( is_object( $c ) )
|
||||
$wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" );
|
||||
$c = $wpdb->get_row("SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'");
|
||||
if ( is_object($c) )
|
||||
$wpdb->query("UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'");
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function wp_update_comment($commentarr) {
|
||||
global $wpdb;
|
||||
|
||||
|
@ -437,7 +452,7 @@ function wp_update_comment($commentarr) {
|
|||
$comment = get_comment($commentarr['comment_ID'], ARRAY_A);
|
||||
|
||||
// Escape data pulled from DB.
|
||||
foreach ($comment as $key => $value)
|
||||
foreach ( (array) $comment as $key => $value )
|
||||
$comment[$key] = $wpdb->escape($value);
|
||||
|
||||
// Merge old and new fields with new fields overwriting old ones.
|
||||
|
@ -461,14 +476,12 @@ function wp_update_comment($commentarr) {
|
|||
WHERE comment_ID = $comment_ID" );
|
||||
|
||||
$rval = $wpdb->rows_affected;
|
||||
|
||||
wp_update_comment_count($comment_post_ID);
|
||||
|
||||
do_action('edit_comment', $comment_ID);
|
||||
|
||||
return $rval;
|
||||
}
|
||||
|
||||
|
||||
function wp_update_comment_count($post_id) {
|
||||
global $wpdb, $comment_count_cache;
|
||||
$post_id = (int) $post_id;
|
||||
|
@ -480,6 +493,7 @@ function wp_update_comment_count($post_id) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Ping and trackback functions.
|
||||
//
|
||||
|
@ -497,58 +511,51 @@ function discover_pingback_server_uri($url, $timeout_bytes = 2048) {
|
|||
|
||||
extract(parse_url($url));
|
||||
|
||||
if (!isset($host)) {
|
||||
// Not an URL. This should never happen.
|
||||
if ( !isset($host) ) // Not an URL. This should never happen.
|
||||
return false;
|
||||
}
|
||||
|
||||
$path = (!isset($path)) ? '/' : $path;
|
||||
$path .= (isset($query)) ? '?'.$query : '';
|
||||
$port = (isset($port)) ? $port : 80;
|
||||
$path = ( !isset($path) ) ? '/' : $path;
|
||||
$path .= ( isset($query) ) ? '?' . $query : '';
|
||||
$port = ( isset($port) ) ? $port : 80;
|
||||
|
||||
// Try to connect to the server at $host
|
||||
$fp = @fsockopen($host, $port, $errno, $errstr, 2);
|
||||
if (!$fp) {
|
||||
// Couldn't open a connection to $host;
|
||||
if ( !$fp ) // Couldn't open a connection to $host
|
||||
return false;
|
||||
}
|
||||
|
||||
// Send the GET request
|
||||
$request = "GET $path HTTP/1.1\r\nHost: $host\r\nUser-Agent: WordPress/$wp_version \r\n\r\n";
|
||||
// ob_end_flush();
|
||||
// ob_end_flush();
|
||||
fputs($fp, $request);
|
||||
|
||||
// Let's check for an X-Pingback header first
|
||||
while (!feof($fp)) {
|
||||
while ( !feof($fp) ) {
|
||||
$line = fgets($fp, 512);
|
||||
if (trim($line) == '') {
|
||||
if ( trim($line) == '' )
|
||||
break;
|
||||
}
|
||||
$headers .= trim($line)."\n";
|
||||
$x_pingback_header_offset = strpos(strtolower($headers), $x_pingback_str);
|
||||
if ($x_pingback_header_offset) {
|
||||
if ( $x_pingback_header_offset ) {
|
||||
// We got it!
|
||||
preg_match('#x-pingback: (.+)#is', $headers, $matches);
|
||||
$pingback_server_url = trim($matches[1]);
|
||||
return $pingback_server_url;
|
||||
}
|
||||
if(strpos(strtolower($headers), 'content-type: ')) {
|
||||
if ( strpos(strtolower($headers), 'content-type: ') ) {
|
||||
preg_match('#content-type: (.+)#is', $headers, $matches);
|
||||
$content_type = trim($matches[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('#(image|audio|video|model)/#is', $content_type)) {
|
||||
// Not an (x)html, sgml, or xml page, no use going further
|
||||
if ( preg_match('#(image|audio|video|model)/#is', $content_type) ) // Not an (x)html, sgml, or xml page, no use going further
|
||||
return false;
|
||||
}
|
||||
|
||||
while (!feof($fp)) {
|
||||
while ( !feof($fp) ) {
|
||||
$line = fgets($fp, 1024);
|
||||
$contents .= trim($line);
|
||||
$pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
|
||||
$pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
|
||||
if ($pingback_link_offset_dquote || $pingback_link_offset_squote) {
|
||||
if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) {
|
||||
$quote = ($pingback_link_offset_dquote) ? '"' : '\'';
|
||||
$pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
|
||||
$pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset);
|
||||
|
@ -557,13 +564,11 @@ function discover_pingback_server_uri($url, $timeout_bytes = 2048) {
|
|||
$pingback_server_url_len = $pingback_href_end - $pingback_href_start;
|
||||
$pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len);
|
||||
// We may find rel="pingback" but an incomplete pingback URL
|
||||
if ($pingback_server_url_len > 0) {
|
||||
// We got it!
|
||||
if ( $pingback_server_url_len > 0 ) // We got it!
|
||||
return $pingback_server_url;
|
||||
}
|
||||
}
|
||||
$byte_count += strlen($line);
|
||||
if ($byte_count > $timeout_bytes) {
|
||||
if ( $byte_count > $timeout_bytes ) {
|
||||
// It's no use going further, there probably isn't any pingback
|
||||
// server to find in this file. (Prevents loading large files.)
|
||||
return false;
|
||||
|
@ -574,6 +579,7 @@ function discover_pingback_server_uri($url, $timeout_bytes = 2048) {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
function do_all_pings() {
|
||||
global $wpdb;
|
||||
|
||||
|
@ -592,10 +598,9 @@ function do_all_pings() {
|
|||
// Do Trackbacks
|
||||
$trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'");
|
||||
if ( is_array($trackbacks) ) {
|
||||
foreach ( $trackbacks as $trackback ) {
|
||||
foreach ( $trackbacks as $trackback )
|
||||
do_trackbacks($trackback->ID);
|
||||
}
|
||||
}
|
||||
|
||||
//Do Update Services/Generic Pings
|
||||
generic_ping();
|
||||
|
@ -612,7 +617,7 @@ function do_trackbacks($post_id) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (empty($post->post_excerpt))
|
||||
if ( empty($post->post_excerpt) )
|
||||
$excerpt = apply_filters('the_content', $post->post_content);
|
||||
else
|
||||
$excerpt = apply_filters('the_excerpt', $post->post_excerpt);
|
||||
|
@ -626,7 +631,8 @@ function do_trackbacks($post_id) {
|
|||
$post_title = apply_filters('the_title', $post->post_title);
|
||||
$post_title = strip_tags($post_title);
|
||||
|
||||
if ($to_ping) : foreach ($to_ping as $tb_ping) :
|
||||
if ( $to_ping ) {
|
||||
foreach ( (array) $to_ping as $tb_ping ) {
|
||||
$tb_ping = trim($tb_ping);
|
||||
if ( !in_array($tb_ping, $pinged) ) {
|
||||
trackback($tb_ping, $post_title, $excerpt, $post_id);
|
||||
|
@ -634,31 +640,33 @@ function do_trackbacks($post_id) {
|
|||
} else {
|
||||
$wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_ping', '')) WHERE ID = '$post_id'");
|
||||
}
|
||||
endforeach; endif;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function generic_ping($post_id = 0) {
|
||||
$services = get_option('ping_sites');
|
||||
$services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines
|
||||
$services = trim($services);
|
||||
if ( '' != $services ) {
|
||||
$services = explode("\n", $services);
|
||||
foreach ($services as $service) {
|
||||
foreach ( (array) $services as $service )
|
||||
weblog_ping($service);
|
||||
}
|
||||
}
|
||||
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
|
||||
function pingback($content, $post_ID) {
|
||||
global $wp_version, $wpdb;
|
||||
include_once (ABSPATH . WPINC . '/class-IXR.php');
|
||||
include_once(ABSPATH . WPINC . '/class-IXR.php');
|
||||
|
||||
// original code by Mort (http://mort.mine.nu:8080)
|
||||
$log = debug_fopen(ABSPATH . '/pingback.log', 'a');
|
||||
$post_links = array();
|
||||
debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n");
|
||||
debug_fwrite($log, 'BEGIN ' . date('YmdHis', time()) . "\n");
|
||||
|
||||
$pung = get_pung($post_ID);
|
||||
|
||||
|
@ -687,24 +695,24 @@ function pingback($content, $post_ID) {
|
|||
// http://dummy-weblog.org/post.php
|
||||
// We don't wanna ping first and second types, even if they have a valid <link/>
|
||||
|
||||
foreach($post_links_temp[0] as $link_test) :
|
||||
foreach ( $post_links_temp[0] as $link_test ) :
|
||||
if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
|
||||
&& !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
|
||||
$test = parse_url($link_test);
|
||||
if (isset($test['query']))
|
||||
if ( isset($test['query']) )
|
||||
$post_links[] = $link_test;
|
||||
elseif(($test['path'] != '/') && ($test['path'] != ''))
|
||||
elseif ( ($test['path'] != '/') && ($test['path'] != '') )
|
||||
$post_links[] = $link_test;
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
do_action_ref_array('pre_ping', array(&$post_links, &$pung));
|
||||
|
||||
foreach ($post_links as $pagelinkedto){
|
||||
foreach ( (array) $post_links as $pagelinkedto ) {
|
||||
debug_fwrite($log, "Processing -- $pagelinkedto\n");
|
||||
$pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
|
||||
|
||||
if ($pingback_server_url) {
|
||||
if ( $pingback_server_url ) {
|
||||
@ set_time_limit( 60 );
|
||||
// Now, the RPC call
|
||||
debug_fwrite($log, "Page Linked To: $pagelinkedto \n");
|
||||
|
@ -731,7 +739,8 @@ function pingback($content, $post_ID) {
|
|||
debug_fclose($log);
|
||||
}
|
||||
|
||||
function privacy_ping_filter( $sites ) {
|
||||
|
||||
function privacy_ping_filter($sites) {
|
||||
if ( '0' != get_option('blog_public') )
|
||||
return $sites;
|
||||
else
|
||||
|
@ -780,9 +789,10 @@ function trackback($trackback_url, $title, $excerpt, $ID) {
|
|||
return $wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_url', '')) WHERE ID = '$ID'");
|
||||
}
|
||||
|
||||
|
||||
function weblog_ping($server = '', $path = '') {
|
||||
global $wp_version;
|
||||
include_once (ABSPATH . WPINC . '/class-IXR.php');
|
||||
include_once(ABSPATH . WPINC . '/class-IXR.php');
|
||||
|
||||
// using a timeout of 3 seconds should be enough to cover slow servers
|
||||
$client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
|
||||
|
|
|
@ -5,10 +5,12 @@ function get_bloginfo_rss($show = '') {
|
|||
return apply_filters('bloginfo_rss', convert_chars($info));
|
||||
}
|
||||
|
||||
|
||||
function bloginfo_rss($show = '') {
|
||||
echo get_bloginfo_rss($show);
|
||||
}
|
||||
|
||||
|
||||
function get_the_title_rss() {
|
||||
$title = get_the_title();
|
||||
$title = apply_filters('the_title', $title);
|
||||
|
@ -16,10 +18,12 @@ function get_the_title_rss() {
|
|||
return $title;
|
||||
}
|
||||
|
||||
|
||||
function the_title_rss() {
|
||||
echo get_the_title_rss();
|
||||
}
|
||||
|
||||
|
||||
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
|
||||
$content = get_the_content($more_link_text, $stripteaser, $more_file);
|
||||
$content = apply_filters('the_content_rss', $content);
|
||||
|
@ -42,9 +46,8 @@ function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file
|
|||
$k = count($blah);
|
||||
$use_dotdotdot = 0;
|
||||
}
|
||||
for ( $i=0; $i<$k; $i++ ) {
|
||||
for ( $i=0; $i<$k; $i++ )
|
||||
$excerpt .= $blah[$i].' ';
|
||||
}
|
||||
$excerpt .= ($use_dotdotdot) ? '...' : '';
|
||||
$content = $excerpt;
|
||||
}
|
||||
|
@ -52,37 +55,46 @@ function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file
|
|||
echo $content;
|
||||
}
|
||||
|
||||
|
||||
function the_excerpt_rss() {
|
||||
$output = get_the_excerpt(true);
|
||||
echo apply_filters('the_excerpt_rss', $output);
|
||||
}
|
||||
|
||||
|
||||
function permalink_single_rss($file = '') {
|
||||
echo get_permalink();
|
||||
}
|
||||
|
||||
|
||||
function comment_link() {
|
||||
echo get_comment_link();
|
||||
}
|
||||
|
||||
|
||||
function get_comment_author_rss() {
|
||||
return apply_filters('comment_author_rss', get_comment_author() );
|
||||
}
|
||||
|
||||
|
||||
function comment_author_rss() {
|
||||
echo get_comment_author_rss();
|
||||
}
|
||||
|
||||
|
||||
function comment_text_rss() {
|
||||
$comment_text = get_comment_text();
|
||||
$comment_text = apply_filters('comment_text_rss', $comment_text);
|
||||
echo $comment_text;
|
||||
}
|
||||
|
||||
|
||||
function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = '') {
|
||||
$url = comments_rss($commentsrssfilename);
|
||||
echo "<a href='$url'>$link_text</a>";
|
||||
}
|
||||
|
||||
|
||||
function comments_rss($commentsrssfilename = '') {
|
||||
global $id;
|
||||
|
||||
|
@ -94,6 +106,7 @@ function comments_rss($commentsrssfilename = '') {
|
|||
return apply_filters('post_comments_feed_link', $url);
|
||||
}
|
||||
|
||||
|
||||
function get_author_rss_link($echo = false, $author_id, $author_nicename) {
|
||||
$auth_ID = $author_id;
|
||||
$permalink_structure = get_option('permalink_structure');
|
||||
|
@ -112,6 +125,7 @@ function get_author_rss_link($echo = false, $author_id, $author_nicename) {
|
|||
return $link;
|
||||
}
|
||||
|
||||
|
||||
function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
|
||||
$permalink_structure = get_option('permalink_structure');
|
||||
|
||||
|
@ -129,6 +143,7 @@ function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
|
|||
return $link;
|
||||
}
|
||||
|
||||
|
||||
function get_the_category_rss($type = 'rss') {
|
||||
$categories = get_the_category();
|
||||
$the_list = '';
|
||||
|
@ -142,10 +157,12 @@ function get_the_category_rss($type = 'rss') {
|
|||
return apply_filters('the_category_rss', $the_list, $type);
|
||||
}
|
||||
|
||||
|
||||
function the_category_rss($type = 'rss') {
|
||||
echo get_the_category_rss($type);
|
||||
}
|
||||
|
||||
|
||||
function rss_enclosure() {
|
||||
global $id, $post;
|
||||
if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
|
||||
|
|
|
@ -9,7 +9,7 @@ function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1)
|
|||
|
||||
// check that we don't already have the same filter at the same priority
|
||||
if ( isset($wp_filter[$tag]["$priority"]) ) {
|
||||
foreach($wp_filter[$tag]["$priority"] as $filter) {
|
||||
foreach ( $wp_filter[$tag]["$priority"] as $filter ) {
|
||||
// uncomment if we want to match function AND accepted_args
|
||||
// if ( $filter == array($function, $accepted_args) ) {
|
||||
if ( $filter['function'] == $function_to_add )
|
||||
|
@ -135,7 +135,7 @@ function do_action_ref_array($tag, $args) {
|
|||
|
||||
foreach ( (array) $wp_filter[$tag] as $priority => $functions ) {
|
||||
if ( !is_null($functions) ) {
|
||||
foreach( (array) $functions as $function ) {
|
||||
foreach ( (array) $functions as $function ) {
|
||||
$function_name = $function['function'];
|
||||
$accepted_args = $function['accepted_args'];
|
||||
if ( $accepted_args > 0 )
|
||||
|
|
|
@ -10,12 +10,14 @@ function username_exists( $username ) {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
function email_exists( $email ) {
|
||||
global $wpdb;
|
||||
$email = addslashes( $email );
|
||||
return $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '$email'");
|
||||
}
|
||||
|
||||
|
||||
function validate_username( $username ) {
|
||||
$name = sanitize_user($username, true);
|
||||
$valid = true;
|
||||
|
@ -26,6 +28,7 @@ function validate_username( $username ) {
|
|||
return apply_filters('validate_username', $valid, $username);
|
||||
}
|
||||
|
||||
|
||||
function wp_insert_user($userdata) {
|
||||
global $wpdb;
|
||||
|
||||
|
@ -123,6 +126,7 @@ function wp_insert_user($userdata) {
|
|||
return $user_id;
|
||||
}
|
||||
|
||||
|
||||
function wp_update_user($userdata) {
|
||||
global $wpdb;
|
||||
|
||||
|
@ -146,7 +150,7 @@ function wp_update_user($userdata) {
|
|||
|
||||
// Update the cookies if the password changed.
|
||||
$current_user = wp_get_current_user();
|
||||
if( $current_user->id == $ID ) {
|
||||
if ( $current_user->id == $ID ) {
|
||||
if ( isset($plaintext_pass) ) {
|
||||
wp_clearcookie();
|
||||
wp_setcookie($userdata['user_login'], $plaintext_pass);
|
||||
|
@ -156,11 +160,12 @@ function wp_update_user($userdata) {
|
|||
return $user_id;
|
||||
}
|
||||
|
||||
function wp_create_user( $username, $password, $email = '') {
|
||||
|
||||
function wp_create_user($username, $password, $email = '') {
|
||||
global $wpdb;
|
||||
|
||||
$user_login = $wpdb->escape( $username );
|
||||
$user_email = $wpdb->escape( $email );
|
||||
$user_login = $wpdb->escape($username);
|
||||
$user_email = $wpdb->escape($email);
|
||||
$user_pass = $password;
|
||||
|
||||
$userdata = compact('user_login', 'user_email', 'user_pass');
|
||||
|
@ -168,9 +173,8 @@ function wp_create_user( $username, $password, $email = '') {
|
|||
}
|
||||
|
||||
|
||||
function create_user( $username, $password, $email ) {
|
||||
return wp_create_user( $username, $password, $email );
|
||||
function create_user($username, $password, $email) {
|
||||
return wp_create_user($username, $password, $email);
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
// On which page are we ?
|
||||
if (preg_match('#([^/]+\.php)$#', $PHP_SELF, $self_matches)) {
|
||||
if ( preg_match('#([^/]+\.php)$#', $PHP_SELF, $self_matches) ) {
|
||||
$pagenow = $self_matches[1];
|
||||
} else if (strstr($PHP_SELF, '?')) {
|
||||
} elseif ( strpos($PHP_SELF, '?') !== false ) {
|
||||
$pagenow = explode('/', $PHP_SELF);
|
||||
$pagenow = trim($pagenow[(sizeof($pagenow)-1)]);
|
||||
$pagenow = explode('?', $pagenow);
|
||||
|
@ -13,22 +13,23 @@ if (preg_match('#([^/]+\.php)$#', $PHP_SELF, $self_matches)) {
|
|||
}
|
||||
|
||||
// Simple browser detection
|
||||
// We should probably be doing true/false instead of 1/0 here ~ Mark
|
||||
$is_lynx = 0; $is_gecko = 0; $is_winIE = 0; $is_macIE = 0; $is_opera = 0; $is_NS4 = 0;
|
||||
|
||||
if (preg_match('/Lynx/', $_SERVER['HTTP_USER_AGENT'])) {
|
||||
if ( preg_match('/Lynx/', $_SERVER['HTTP_USER_AGENT']) )
|
||||
$is_lynx = 1;
|
||||
} elseif (preg_match('/Gecko/', $_SERVER['HTTP_USER_AGENT'])) {
|
||||
elseif ( preg_match('/Gecko/', $_SERVER['HTTP_USER_AGENT']) )
|
||||
$is_gecko = 1;
|
||||
} elseif ((preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) && (preg_match('/Win/', $_SERVER['HTTP_USER_AGENT']))) {
|
||||
elseif ( preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']) && preg_match('/Win/', $_SERVER['HTTP_USER_AGENT']) )
|
||||
$is_winIE = 1;
|
||||
} elseif ((preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) && (preg_match('/Mac/', $_SERVER['HTTP_USER_AGENT']))) {
|
||||
elseif ( preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']) && preg_match('/Mac/', $_SERVER['HTTP_USER_AGENT']) )
|
||||
$is_macIE = 1;
|
||||
} elseif (preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT'])) {
|
||||
elseif ( preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT']) )
|
||||
$is_opera = 1;
|
||||
} elseif ((preg_match('/Nav/', $_SERVER['HTTP_USER_AGENT']) ) || (preg_match('/Mozilla\/4\./', $_SERVER['HTTP_USER_AGENT']))) {
|
||||
elseif ( preg_match('/Nav/', $_SERVER['HTTP_USER_AGENT']) || preg_match('/Mozilla\/4\./', $_SERVER['HTTP_USER_AGENT']) )
|
||||
$is_NS4 = 1;
|
||||
}
|
||||
$is_IE = (($is_macIE) || ($is_winIE));
|
||||
|
||||
$is_IE = ( $is_macIE || $is_winIE );
|
||||
|
||||
// Server detection
|
||||
$is_apache = ( strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') || strstr($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') ) ? 1 : 0;
|
||||
|
@ -84,11 +85,10 @@ if (!isset($wpsmiliestrans)) {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
// generates smilies' search & replace arrays
|
||||
foreach($wpsmiliestrans as $smiley => $img) {
|
||||
foreach ( (array) $wpsmiliestrans as $smiley => $img ) {
|
||||
$wp_smiliessearch[] = '/(\s|^)'.preg_quote($smiley, '/').'(\s|$)/';
|
||||
$smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES);
|
||||
$smiley_masked = htmlspecialchars(trim($smiley), ENT_QUOTES);
|
||||
$wp_smiliesreplace[] = " <img src='" . get_option('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue