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