theladder/readme.html 0000644 0041054 0041055 00000016732 11231104122 015344 0 ustar lacunaus lacunaus
Semantic Personal Publishing Platform
Welcome. WordPress is a very special project to me. Every developer and contributor adds something unique to the mix, and together we create something beautiful that I'm proud to be a part of. Thousands of hours have gone into WordPress, and we're dedicated to making it better every day. Thank you for making it part of your world.
— Matt Mullenweg
wp-config-sample.php
with a text editor like WordPad or similar and fill in your database connection details.wp-config.php
admin
and the password generated during the installation. You can then click on 'Profile' to change the password.Before you upgrade anything, make sure you have backup copies of any files you may have modified such as index.php
.
If you have customized your templates you will probably have to make some changes to them. If you're converting your 1.2 or earlier templates, we've created a special guide for you.
If you have any questions that aren't addressed in this document, please take advantage of WordPress' numerous online resources:
WordPress is the official continuation of b2/cafélog, which came from Michel V. The work has been continued by the WordPress developers. If you would like to support WordPress, please consider donating.
WordPress can import from a number of systems. First you need to get WordPress installed and working as described above.
You can now post to your WordPress blog with tools like Windows Live Writer, Ecto, Bloggar, Radio Userland (which means you can use Radio's email-to-blog feature), NewzCrawler, and other tools that support the Blogging APIs! :) You can read more about XML-RPC support on the Codex.
You can post from an email client! To set this up go to your "Writing" options screen and fill in the connection details for your secret POP3 account. Then you need to set up wp-mail.php
to execute periodically to check the mailbox for new posts. You can do it with Cron-jobs, or if your host doesn't support it you can look into the various website-monitoring services, and make them check your wp-mail.php
URL.
Posting is easy: Any email sent to the address you specify will be posted, with the subject as the title. It is best to keep the address discrete. The script will delete emails that are successfully posted.
We've eliminated user levels in order to make way for the much more flexible roles system introduced in 2.0. You can read more about Roles and Capabilities on the Codex.
WordPress has no multi-million dollar marketing campaign or celebrity sponsors, but we do have something even better—you. If you enjoy WordPress please consider telling a friend, setting it up for someone less knowledgable than yourself, or writing the author of a media article that overlooks us.
WordPress is released under the GPL (see license.txt).
theladder/wp-admin/includes/comment.php 0000644 0041054 0041055 00000010455 11231104122 020712 0 ustar lacunaus lacunaus get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_author = %s AND comment_date = %s", $comment_author, $comment_date) ); } /** * {@internal Missing Short Description}} * * @since unknown */ function edit_comment() { $comment_post_ID = (int) $_POST['comment_post_ID']; if (!current_user_can( 'edit_post', $comment_post_ID )) wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' )); $_POST['comment_author'] = $_POST['newcomment_author']; $_POST['comment_author_email'] = $_POST['newcomment_author_email']; $_POST['comment_author_url'] = $_POST['newcomment_author_url']; $_POST['comment_approved'] = $_POST['comment_status']; $_POST['comment_content'] = $_POST['content']; $_POST['comment_ID'] = (int) $_POST['comment_ID']; foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { $_POST['edit_date'] = '1'; break; } } if (!empty ( $_POST['edit_date'] ) ) { $aa = $_POST['aa']; $mm = $_POST['mm']; $jj = $_POST['jj']; $hh = $_POST['hh']; $mn = $_POST['mn']; $ss = $_POST['ss']; $jj = ($jj > 31 ) ? 31 : $jj; $hh = ($hh > 23 ) ? $hh -24 : $hh; $mn = ($mn > 59 ) ? $mn -60 : $mn; $ss = ($ss > 59 ) ? $ss -60 : $ss; $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; } wp_update_comment( $_POST); } /** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $id * @return unknown */ function get_comment_to_edit( $id ) { if ( !$comment = get_comment($id) ) return false; $comment->comment_ID = (int) $comment->comment_ID; $comment->comment_post_ID = (int) $comment->comment_post_ID; $comment->comment_content = format_to_edit( $comment->comment_content ); $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content); $comment->comment_author = format_to_edit( $comment->comment_author ); $comment->comment_author_email = format_to_edit( $comment->comment_author_email ); $comment->comment_author_url = format_to_edit( $comment->comment_author_url ); $comment->comment_author_url = esc_url($comment->comment_author_url); return $comment; } /** * {@internal Missing Short Description}} * * @since unknown * @uses $wpdb * * @param int $post_id Post ID * @return unknown */ function get_pending_comments_num( $post_id ) { global $wpdb; $single = false; if ( !is_array($post_id) ) { $post_id = (array) $post_id; $single = true; } $post_id = array_map('intval', $post_id); $post_id = "'" . implode("', '", $post_id) . "'"; $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_N ); if ( empty($pending) ) return 0; if ( $single ) return $pending[0][1]; $pending_keyed = array(); foreach ( $pending as $pend ) $pending_keyed[$pend[0]] = $pend[1]; return $pending_keyed; } /** * Add avatars to relevant places in admin, or try to. * * @since unknown * @uses $comment * * @param string $name User name. * @return string Avatar with Admin name. */ function floated_admin_avatar( $name ) { global $comment; $id = $avatar = false; if ( $comment->comment_author_email ) $id = $comment->comment_author_email; if ( $comment->user_id ) $id = $comment->user_id; if ( $id ) $avatar = get_avatar( $id, 32 ); return "$avatar $name"; } function enqueue_comment_hotkeys_js() { if ( 'true' == get_user_option( 'comment_shortcuts' ) ) wp_enqueue_script( 'jquery-table-hotkeys' ); } if ( is_admin() && isset($pagenow) && ('edit-comments.php' == $pagenow || 'edit.php' == $pagenow) ) { if ( get_option('show_avatars') ) add_filter( 'comment_author', 'floated_admin_avatar' ); } ?> theladder/wp-admin/includes/template.php 0000644 0041054 0041055 00000367430 11231104122 021073 0 ustar lacunaus lacunaus 0); if ( !empty($_GET['s']) ) $args['search'] = $_GET['s']; $categories = get_categories( $args ); if ( empty($categories) ) return false; } $children = _get_term_hierarchy('category'); _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count ); } /** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $categories * @param unknown_type $count * @param unknown_type $parent * @param unknown_type $level * @param unknown_type $page * @param unknown_type $per_page * @return unknown */ function _cat_rows( $parent = 0, $level = 0, $categories, &$children, $page = 1, $per_page = 20, &$count ) { $start = ($page - 1) * $per_page; $end = $start + $per_page; ob_start(); foreach ( $categories as $key => $category ) { if ( $count >= $end ) break; if ( $category->parent != $parent && empty($_GET['s']) ) continue; // If the page starts in a subtree, print the parents. if ( $count == $start && $category->parent > 0 ) { $my_parents = array(); $p = $category->parent; while ( $p ) { $my_parent = get_category( $p ); $my_parents[] = $my_parent; if ( $my_parent->parent == 0 ) break; $p = $my_parent->parent; } $num_parents = count($my_parents); while( $my_parent = array_pop($my_parents) ) { echo "\t" . _cat_row( $my_parent, $level - $num_parents ); $num_parents--; } } if ( $count >= $start ) echo "\t" . _cat_row( $category, $level ); unset( $categories[ $key ] ); $count++; if ( isset($children[$category->term_id]) ) _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count ); } $output = ob_get_contents(); ob_end_clean(); echo $output; } /** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $category * @param unknown_type $level * @param unknown_type $name_override * @return unknown */ function _cat_row( $category, $level, $name_override = false ) { static $row_class = ''; $category = get_category( $category, OBJECT, 'display' ); $default_cat_id = (int) get_option( 'default_category' ); $pad = str_repeat( '— ', max(0, $level) ); $name = ( $name_override ? $name_override : $pad . ' ' . $category->name ); $edit_link = "categories.php?action=edit&cat_ID=$category->term_id"; if ( current_user_can( 'manage_categories' ) ) { $edit = "name)) . "'>" . esc_attr( $name ) . '
$template"; endforeach; } /** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $default * @param unknown_type $parent * @param unknown_type $level * @return unknown */ function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { global $wpdb, $post_ID; $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) ); if ( $items ) { foreach ( $items as $item ) { // A page cannot be its own parent. if (!empty ( $post_ID ) ) { if ( $item->ID == $post_ID ) { continue; } } $pad = str_repeat( ' ', $level * 3 ); if ( $item->ID == $default) $current = ' selected="selected"'; else $current = ''; echo "\n\t"; parent_dropdown( $default, $item->ID, $level +1 ); } } else { return false; } } /** * {@internal Missing Short Description}} * * @since unknown */ function browse_happy() { $getit = __( 'WordPress recommends a better browser' ); echo ' '; } /** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $id * @return unknown */ function the_attachment_links( $id = false ) { $id = (int) $id; $post = & get_post( $id ); if ( $post->post_type != 'attachment' ) return false; $icon = get_attachment_icon( $post->ID ); $attachment_data = wp_get_attachment_metadata( $id ); $thumb = isset( $attachment_data['thumb'] ); ?> html elements for role selectors based on $wp_roles * * @package WordPress * @subpackage Administration * @since 2.1 * * @uses $wp_roles * @param string $default slug for the role that should be already selected */ function wp_dropdown_roles( $selected = false ) { global $wp_roles; $p = ''; $r = ''; $editable_roles = get_editable_roles(); foreach( $editable_roles as $role => $details ) { $name = translate_user_role($details['name'] ); if ( $selected == $role ) // Make default first in list $p = "\n\t"; else $r .= "\n\t"; } echo $p . $r; } /** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $size * @return unknown */ function wp_convert_hr_to_bytes( $size ) { $size = strtolower($size); $bytes = (int) $size; if ( strpos($size, 'k') !== false ) $bytes = intval($size) * 1024; elseif ( strpos($size, 'm') !== false ) $bytes = intval($size) * 1024 * 1024; elseif ( strpos($size, 'g') !== false ) $bytes = intval($size) * 1024 * 1024 * 1024; return $bytes; } /** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $bytes * @return unknown */ function wp_convert_bytes_to_hr( $bytes ) { $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' ); $log = log( $bytes, 1024 ); $power = (int) $log; $size = pow(1024, $log - $power); return $size . $units[$power]; } /** * {@internal Missing Short Description}} * * @since unknown * * @return unknown */ function wp_max_upload_size() { $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); return $bytes; } /** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $action */ function wp_import_upload_form( $action ) { $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); $size = wp_convert_bytes_to_hr( $bytes ); $upload_dir = wp_upload_dir(); if ( ! empty( $upload_dir['error'] ) ) : ?>
' . __('Writing Posts') . '
'; $_wp_contextual_help['post'] = $help; } break; case 'page': if ( !isset($_wp_contextual_help['page']) ) { $help = drag_drop_help(); $_wp_contextual_help['page'] = $help; } break; case 'dashboard': if ( !isset($_wp_contextual_help['dashboard']) ) { $help = '' . __('The modules on this screen can be arranged in several columns. You can select the number of columns from the Screen Options tab.') . "
\n"; $help .= drag_drop_help(); $_wp_contextual_help['dashboard'] = $help; } break; case 'link': if ( !isset($_wp_contextual_help['link']) ) { $help = drag_drop_help(); $_wp_contextual_help['link'] = $help; } break; case 'options-general': if ( !isset($_wp_contextual_help['options-general']) ) $_wp_contextual_help['options-general'] = __('General Settings'); break; case 'theme-install': case 'plugin-install': if ( ( !isset($_GET['tab']) || 'dashboard' == $_GET['tab'] ) && !isset($_wp_contextual_help[$screen]) ) { $help = plugins_search_help(); $_wp_contextual_help[$screen] = $help; } break; case 'widgets': if ( !isset($_wp_contextual_help['widgets']) ) { $help = widgets_help(); $_wp_contextual_help['widgets'] = $help; } $settings = '' . __('Enable accessibility mode') . '' . __('Disable accessibility mode') . "
\n"; $show_screen = true; break; } ?>' . __('The same modules can be expanded and collapsed by clicking once on their title bar and also completely hidden from the Screen Options tab.') . '
'; } function plugins_search_help() { return '' . __('Search help') . '
' . '' . __('You may search based on 3 criteria:') . '
' .
__('Term: Searches theme names and descriptions for the specified term.') . '
' .
__('Tag: Searches for themes tagged as such.') . '
' .
__('Author: Searches for themes created by the Author, or which the Author contributed to.') . '
' . __('Widgets are added and arranged by simple drag ’n’ drop. If you hover your mouse over the titlebar of a widget, you’ll see a 4-arrow cursor which indicates that the widget is movable. Click on the titlebar, hold down the mouse button and drag the widget to a sidebar. As you drag, you’ll see a dotted box that also moves. This box shows where the widget will go once you drop it.') . '
' . __('To remove a widget from a sidebar, drag it back to Available Widgets or click on the arrow on its titlebar to reveal its settings, and then click Remove.') . '
' . __('To remove a widget from a sidebar and keep its configuration, drag it to Inactive Widgets.') . '
' . __('The Inactive Widgets area stores widgets that are configured but not curently used. If you change themes and the new theme has fewer sidebars than the old, all extra widgets will be stored to Inactive Widgets automatically.') . '
'; } function screen_layout($screen) { global $screen_layout_columns; $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2); $columns = apply_filters('screen_layout_columns', $columns, $screen); if ( !isset($columns[$screen]) ) { $screen_layout_columns = 0; return ''; } $screen_layout_columns = get_user_option("screen_layout_$screen"); $num = $columns[$screen]; if ( ! $screen_layout_columns ) $screen_layout_columns = 2; $i = 1; $return = '$msg
"; include('admin-footer.php'); die; } switch( $action ) { case 'editcomment' : $title = __('Edit Comment'); wp_enqueue_script('comment'); require_once('admin-header.php'); $comment_id = absint( $_GET['c'] ); if ( !$comment = get_comment( $comment_id ) ) comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' '.__('Go back').'!', 'javascript:history.go(-1)') ); if ( !current_user_can('edit_post', $comment->comment_post_ID) ) comment_footer_die( __('You are not allowed to edit comments on this post.') ); $comment = get_comment_to_edit( $comment_id ); include('edit-form-comment.php'); break; case 'cdc' : case 'mac' : require_once('admin-header.php'); $comment_id = absint( $_GET['c'] ); $formaction = 'cdc' == $action ? 'deletecomment' : 'approvecomment'; $nonce_action = 'cdc' == $action ? 'delete-comment_' : 'approve-comment_'; $nonce_action .= $comment_id; if ( !$comment = get_comment_to_edit( $comment_id ) ) comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' '.__('Go back').'!', 'edit.php') ); if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) comment_footer_die( 'cdc' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') ); ?>
comment_author; ?> | |
comment_author_email; ?> | |
comment_author_url; ?> | |
comment_content; ?> |
<?php akismet_counter(); ?>
in your template. See also: WP Stats plugin.
Version: 2.2.6
Author: Matt Mullenweg
Author URI: http://ma.tt/
*/
// If you hardcode a WP.com API key here, all key config screens will be hidden
if ( defined('WPCOM_API_KEY') )
$wpcom_api_key = constant('WPCOM_API_KEY');
else
$wpcom_api_key = '';
function akismet_init() {
global $wpcom_api_key, $akismet_api_host, $akismet_api_port;
if ( $wpcom_api_key )
$akismet_api_host = $wpcom_api_key . '.rest.akismet.com';
else
$akismet_api_host = get_option('wordpress_api_key') . '.rest.akismet.com';
$akismet_api_port = 80;
add_action('admin_menu', 'akismet_config_page');
add_action('admin_menu', 'akismet_stats_page');
akismet_admin_warnings();
}
add_action('init', 'akismet_init');
function akismet_admin_init() {
if ( function_exists( 'get_plugin_page_hook' ) )
$hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' );
else
$hook = 'dashboard_page_akismet-stats-display';
add_action('admin_head-'.$hook, 'akismet_stats_script');
}
add_action('admin_init', 'akismet_admin_init');
if ( !function_exists('wp_nonce_field') ) {
function akismet_nonce_field($action = -1) { return; }
$akismet_nonce = -1;
} else {
function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
$akismet_nonce = 'akismet-update-key';
}
if ( !function_exists('number_format_i18n') ) {
function number_format_i18n( $number, $decimals = null ) { return number_format( $number, $decimals ); }
}
function akismet_config_page() {
if ( function_exists('add_submenu_page') )
add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
}
function akismet_conf() {
global $akismet_nonce, $wpcom_api_key;
if ( isset($_POST['submit']) ) {
if ( function_exists('current_user_can') && !current_user_can('manage_options') )
die(__('Cheatin’ uh?'));
check_admin_referer( $akismet_nonce );
$key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] );
if ( empty($key) ) {
$key_status = 'empty';
$ms[] = 'new_key_empty';
delete_option('wordpress_api_key');
} else {
$key_status = akismet_verify_key( $key );
}
if ( $key_status == 'valid' ) {
update_option('wordpress_api_key', $key);
$ms[] = 'new_key_valid';
} else if ( $key_status == 'invalid' ) {
$ms[] = 'new_key_invalid';
} else if ( $key_status == 'failed' ) {
$ms[] = 'new_key_failed';
}
if ( isset( $_POST['akismet_discard_month'] ) )
update_option( 'akismet_discard_month', 'true' );
else
update_option( 'akismet_discard_month', 'false' );
} elseif ( isset($_POST['check']) ) {
akismet_get_server_connectivity(0);
}
if ( $key_status != 'valid' ) {
$key = get_option('wordpress_api_key');
if ( empty( $key ) ) {
if ( $key_status != 'failed' ) {
if ( akismet_verify_key( '1234567890ab' ) == 'failed' )
$ms[] = 'no_connection';
else
$ms[] = 'key_empty';
}
$key_status = 'empty';
} else {
$key_status = akismet_verify_key( $key );
}
if ( $key_status == 'valid' ) {
$ms[] = 'key_valid';
} else if ( $key_status == 'invalid' ) {
delete_option('wordpress_api_key');
$ms[] = 'key_empty';
} else if ( !empty($key) && $key_status == 'failed' ) {
$ms[] = 'key_failed';
}
}
$messages = array(
'new_key_empty' => array('color' => 'aa0', 'text' => __('Your key has been cleared.')),
'new_key_valid' => array('color' => '2d2', 'text' => __('Your key has been verified. Happy blogging!')),
'new_key_invalid' => array('color' => 'd22', 'text' => __('The key you entered is invalid. Please double-check it.')),
'new_key_failed' => array('color' => 'd22', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')),
'no_connection' => array('color' => 'd22', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (Get your key.)'), 'http://wordpress.com/profile/')),
'key_valid' => array('color' => '2d2', 'text' => __('This key is valid.')),
'key_failed' => array('color' => 'aa0', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.')));
?>
".__('Akismet is almost ready.')." ".sprintf(__('You must enter your WordPress.com API key for it to work.'), "plugins.php?page=akismet-key-config")."
"; } add_action('admin_notices', 'akismet_warning'); return; } elseif ( get_option('akismet_connectivity_time') && empty($_POST) && is_admin() && !akismet_server_connectivity_ok() ) { function akismet_warning() { echo " "; } add_action('admin_notices', 'akismet_warning'); return; } } function akismet_get_host($host) { // if all servers are accessible, just return the host name. // if not, return an IP that was known to be accessible at the last check. if ( akismet_server_connectivity_ok() ) { return $host; } else { $ips = akismet_get_server_connectivity(); // a firewall may be blocking access to some Akismet IPs if ( count($ips) > 0 && count(array_filter($ips)) < count($ips) ) { // use DNS to get current IPs, but exclude any known to be unreachable $dns = (array)gethostbynamel( rtrim($host, '.') . '.' ); $dns = array_filter($dns); foreach ( $dns as $ip ) { if ( array_key_exists( $ip, $ips ) && empty( $ips[$ip] ) ) unset($dns[$ip]); } // return a random IP from those available if ( count($dns) ) return $dns[ array_rand($dns) ]; } } // if all else fails try the host name return $host; } // Returns array with headers in $response[0] and body in $response[1] function akismet_http_post($request, $host, $path, $port = 80, $ip=null) { global $wp_version; $http_request = "POST $path HTTP/1.0\r\n"; $http_request .= "Host: $host\r\n"; $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n"; $http_request .= "Content-Length: " . strlen($request) . "\r\n"; $http_request .= "User-Agent: WordPress/$wp_version | Akismet/2.0\r\n"; $http_request .= "\r\n"; $http_request .= $request; $http_host = $host; // use a specific IP if provided - needed by akismet_check_server_connectivity() if ( $ip && long2ip(ip2long($ip)) ) { $http_host = $ip; } else { $http_host = akismet_get_host($host); } $response = ''; if( false != ( $fs = @fsockopen($http_host, $port, $errno, $errstr, 10) ) ) { fwrite($fs, $http_request); while ( !feof($fs) ) $response .= fgets($fs, 1160); // One TCP-IP packet fclose($fs); $response = explode("\r\n\r\n", $response, 2); } return $response; } function akismet_auto_check_comment( $comment ) { global $akismet_api_host, $akismet_api_port; $comment['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] ); $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT']; $comment['referrer'] = $_SERVER['HTTP_REFERER']; $comment['blog'] = get_option('home'); $comment['blog_lang'] = get_locale(); $comment['blog_charset'] = get_option('blog_charset'); $comment['permalink'] = get_permalink($comment['comment_post_ID']); $ignore = array( 'HTTP_COOKIE' ); foreach ( $_SERVER as $key => $value ) if ( !in_array( $key, $ignore ) && is_string($value) ) $comment["$key"] = $value; $query_string = ''; foreach ( $comment as $key => $data ) $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); if ( 'true' == $response[1] ) { add_filter('pre_comment_approved', create_function('$a', 'return \'spam\';')); update_option( 'akismet_spam_count', get_option('akismet_spam_count') + 1 ); do_action( 'akismet_spam_caught' ); $post = get_post( $comment['comment_post_ID'] ); $last_updated = strtotime( $post->post_modified_gmt ); $diff = time() - $last_updated; $diff = $diff / 86400; if ( $post->post_type == 'post' && $diff > 30 && get_option( 'akismet_discard_month' ) == 'true' ) die; } akismet_delete_old(); return $comment; } function akismet_delete_old() { global $wpdb; $now_gmt = current_time('mysql', 1); $wpdb->query("DELETE FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'"); $n = mt_rand(1, 5000); if ( $n == 11 ) // lucky number $wpdb->query("OPTIMIZE TABLE $wpdb->comments"); } function akismet_submit_nonspam_comment ( $comment_id ) { global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site; $comment_id = (int) $comment_id; $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'"); if ( !$comment ) // it was deleted return; $comment->blog = get_option('home'); $comment->blog_lang = get_locale(); $comment->blog_charset = get_option('blog_charset'); $comment->permalink = get_permalink($comment->comment_post_ID); if ( is_object($current_user) ) { $comment->reporter = $current_user->user_login; } if ( is_object($current_site) ) { $comment->site_domain = $current_site->domain; } $query_string = ''; foreach ( $comment as $key => $data ) $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-ham", $akismet_api_port); } function akismet_submit_spam_comment ( $comment_id ) { global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site; $comment_id = (int) $comment_id; $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'"); if ( !$comment ) // it was deleted return; if ( 'spam' != $comment->comment_approved ) return; $comment->blog = get_option('home'); $comment->blog_lang = get_locale(); $comment->blog_charset = get_option('blog_charset'); $comment->permalink = get_permalink($comment->comment_post_ID); if ( is_object($current_user) ) { $comment->reporter = $current_user->user_login; } if ( is_object($current_site) ) { $comment->site_domain = $current_site->domain; } $query_string = ''; foreach ( $comment as $key => $data ) $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port); } add_action('wp_set_comment_status', 'akismet_submit_spam_comment'); add_action('edit_comment', 'akismet_submit_spam_comment'); add_action('preprocess_comment', 'akismet_auto_check_comment', 1); function akismet_spamtoham( $comment ) { akismet_submit_nonspam_comment( $comment->comment_ID ); } add_filter( 'comment_spam_to_approved', 'akismet_spamtoham' ); // Total spam in queue // get_option( 'akismet_spam_count' ) is the total caught ever function akismet_spam_count( $type = false ) { global $wpdb; if ( !$type ) { // total $count = wp_cache_get( 'akismet_spam_count', 'widget' ); if ( false === $count ) { if ( function_exists('wp_count_comments') ) { $count = wp_count_comments(); $count = $count->spam; } else { $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'"); } wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 ); } return $count; } elseif ( 'comments' == $type || 'comment' == $type ) { // comments $type = ''; } else { // pingback, trackback, ... $type = $wpdb->escape( $type ); } return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'"); } function akismet_spam_comments( $type = false, $page = 1, $per_page = 50 ) { global $wpdb; $page = (int) $page; if ( $page < 2 ) $page = 1; $per_page = (int) $per_page; if ( $per_page < 1 ) $per_page = 50; $start = ( $page - 1 ) * $per_page; $end = $start + $per_page; if ( $type ) { if ( 'comments' == $type || 'comment' == $type ) $type = ''; else $type = $wpdb->escape( $type ); return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type' ORDER BY comment_date DESC LIMIT $start, $end"); } // All return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT $start, $end"); } // Totals for each comment type // returns array( type => count, ... ) function akismet_spam_totals() { global $wpdb; $totals = $wpdb->get_results( "SELECT comment_type, COUNT(*) AS cc FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_type" ); $return = array(); foreach ( $totals as $total ) $return[$total->comment_type ? $total->comment_type : 'comment'] = $total->cc; return $return; } function akismet_manage_page() { global $wpdb, $submenu, $wp_db_version; // WP 2.7 has its own spam management page if ( 8645 <= $wp_db_version ) return; $count = sprintf(__('Akismet Spam (%s)'), akismet_spam_count()); if ( isset( $submenu['edit-comments.php'] ) ) add_submenu_page('edit-comments.php', __('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught' ); elseif ( function_exists('add_management_page') ) add_management_page(__('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught'); } function akismet_caught() { global $wpdb, $comment, $akismet_caught, $akismet_nonce; akismet_recheck_queue(); if (isset($_POST['submit']) && 'recover' == $_POST['action'] && ! empty($_POST['not_spam'])) { check_admin_referer( $akismet_nonce ); if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) die(__('You do not have sufficient permission to moderate comments.')); $i = 0; foreach ($_POST['not_spam'] as $comment): $comment = (int) $comment; if ( function_exists('wp_set_comment_status') ) wp_set_comment_status($comment, 'approve'); else $wpdb->query("UPDATE $wpdb->comments SET comment_approved = '1' WHERE comment_ID = '$comment'"); akismet_submit_nonspam_comment($comment); ++$i; endforeach; $to = add_query_arg( 'recovered', $i, $_SERVER['HTTP_REFERER'] ); wp_redirect( $to ); exit; } if ('delete' == $_POST['action']) { check_admin_referer( $akismet_nonce ); if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) die(__('You do not have sufficient permission to moderate comments.')); $delete_time = $wpdb->escape( $_POST['display_time'] ); $nuked = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" ); wp_cache_delete( 'akismet_spam_count', 'widget' ); $to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] ); wp_redirect( $to ); exit; } if ( isset( $_GET['recovered'] ) ) { $i = (int) $_GET['recovered']; echo '' . sprintf(__('%1$s comments recovered.'), $i) . "
' . __('All spam deleted.') . '
%1$s spam for you since you first installed it.'), number_format_i18n($count) ); ?>
'.__('You have no spam currently in the queue. Must be your lucky day. :)').''; echo ''.__('You can delete all of the spam from your database with a single click. This operation cannot be undone, so you may wish to check to ensure that no legitimate comments got through first. Spam is automatically deleted after 15 days, so don’t sweat it.').'
'; ?>$r
"; ?>'.sprintf(__('Akismet has protected your site from %3$s spam comments.'), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'
'; } add_action('activity_box_end', 'akismet_stats'); // WP 2.5+ function akismet_rightnow() { global $submenu, $wp_db_version; if ( 8645 < $wp_db_version ) // 2.7 $link = 'edit-comments.php?comment_status=spam'; elseif ( isset( $submenu['edit-comments.php'] ) ) $link = 'edit-comments.php?page=akismet-admin'; else $link = 'edit.php?page=akismet-admin'; if ( $count = get_option('akismet_spam_count') ) { $intro = sprintf( __ngettext( 'Akismet has protected your site from %2$s spam comment already,', 'Akismet has protected your site from %2$s spam comments already,', $count ), 'http://akismet.com/', number_format_i18n( $count ) ); } else { $intro = sprintf( __('Akismet blocks spam from getting to your blog,'), 'http://akismet.com/' ); } if ( $queue_count = akismet_spam_count() ) { $queue_text = sprintf( __ngettext( 'and there\'s %1$s comment in your spam queue right now.', 'and there are %1$s comments in your spam queue right now.', $queue_count ), number_format_i18n( $queue_count ), clean_url($link) ); } else { $queue_text = sprintf( __( "but there's nothing in your spam queue at the moment." ), clean_url($link) ); } $text = sprintf( _c( '%1$s %2$s|akismet_rightnow' ), $intro, $queue_text ); echo " \n"; } add_action('rightnow_end', 'akismet_rightnow'); // For WP <= 2.3.x if ( 'moderation.php' == $pagenow ) { function akismet_recheck_button( $page ) { global $submenu; if ( isset( $submenu['edit-comments.php'] ) ) $link = 'edit-comments.php'; else $link = 'edit.php'; $button = "" . __('Recheck Queue for Spam') . ""; $page = str_replace( '
id="get_field_id('images'); ?>" name="get_field_name('images'); ?>" />
id="get_field_id('name'); ?>" name="get_field_name('name'); ?>" />
id="get_field_id('description'); ?>" name="get_field_name('description'); ?>" />
id="get_field_id('rating'); ?>" name="get_field_name('rating'); ?>" />
id="get_field_id('count'); ?>" name="get_field_name('count'); ?>" />
id="get_field_id('dropdown'); ?>" name="get_field_name('dropdown'); ?>" />
'widget_calendar', 'description' => __( 'A calendar of your blog’s posts') ); $this->WP_Widget('calendar', __('Calendar'), $widget_ops); } function widget( $args, $instance ) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title']); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; echo '
'widget_text', 'description' => __('Arbitrary text or HTML')); $control_ops = array('width' => 400, 'height' => 350); $this->WP_Widget('text', __('Text'), $widget_ops, $control_ops); } function widget( $args, $instance ) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']); $text = apply_filters( 'widget_text', $instance['text'] ); echo $before_widget; if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?> '', 'text' => '' ) ); $title = strip_tags($instance['title']); $text = format_to_edit($instance['text']); ?>
/>
'widget_categories', 'description' => __( "A list or dropdown of categories" ) ); $this->WP_Widget('categories', __('Categories'), $widget_ops); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title']); $c = $instance['count'] ? '1' : '0'; $h = $instance['hierarchical'] ? '1' : '0'; $d = $instance['dropdown'] ? '1' : '0'; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); if ( $d ) { $cat_args['show_option_none'] = __('Select Category'); wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args)); ?>
/>
/>
/>
' . sprintf( __('RSS Error: %s'), $rss->get_error_message() ) . '
'; return; } $default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0 ); $args = wp_parse_args( $args, $default_args ); extract( $args, EXTR_SKIP ); $items = (int) $items; if ( $items < 1 || 20 < $items ) $items = 10; $show_summary = (int) $show_summary; $show_author = (int) $show_author; $show_date = (int) $show_date; if ( !$rss->get_item_quantity() ) { echo '
/>
/>
/>
get_error_message(); } else { $link = esc_url(strip_tags($rss->get_permalink())); while ( stristr($link, 'http') != $link ) $link = substr($link, 1); } } return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' ); } /** * Tag cloud widget class * * @since 2.8.0 */ class WP_Widget_Tag_Cloud extends WP_Widget { function WP_Widget_Tag_Cloud() { $widget_ops = array( 'description' => __( "Your most used tags in cloud format") ); $this->WP_Widget('tag_cloud', __('Tag Cloud'), $widget_ops); } function widget( $args, $instance ) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Tags') : $instance['title']); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; echo 'comment_author) ) { if (!empty($comment->user_id)){ $user=get_userdata($comment->user_id); $author=$user->user_login; } else { $author = __('Anonymous'); } } else { $author = $comment->comment_author; } return apply_filters('get_comment_author', $author); } /** * Displays the author of the current comment. * * @since 0.71 * @uses apply_filters() Calls 'comment_author' on comment author before displaying */ function comment_author() { $author = apply_filters('comment_author', get_comment_author() ); echo $author; } /** * Retrieve the email of the author of the current comment. * * @since 1.5.0 * @uses apply_filters() Calls the 'get_comment_author_email' hook on the comment author email * @uses $comment * * @return string The current comment author's email */ function get_comment_author_email() { global $comment; return apply_filters('get_comment_author_email', $comment->comment_author_email); } /** * Display the email of the author of the current global $comment. * * Care should be taken to protect the email address and assure that email * harvesters do not capture your commentors' email address. Most assume that * their email address will not appear in raw form on the blog. Doing so will * enable anyone, including those that people don't want to get the email * address and use it for their own means good and bad. * * @since 0.71 * @uses apply_filters() Calls 'author_email' hook on the author email */ function comment_author_email() { echo apply_filters('author_email', get_comment_author_email() ); } /** * Display the html email link to the author of the current comment. * * Care should be taken to protect the email address and assure that email * harvesters do not capture your commentors' email address. Most assume that * their email address will not appear in raw form on the blog. Doing so will * enable anyone, including those that people don't want to get the email * address and use it for their own means good and bad. * * @since 0.71 * @uses apply_filters() Calls 'comment_email' hook for the display of the comment author's email * @uses get_comment_author_email_link() For generating the link * @global object $comment The current Comment row object * * @param string $linktext The text to display instead of the comment author's email address * @param string $before The text or HTML to display before the email link. * @param string $after The text or HTML to display after the email link. */ function comment_author_email_link($linktext='', $before='', $after='') { if ( $link = get_comment_author_email_link( $linktext, $before, $after ) ) echo $link; } /** * Return the html email link to the author of the current comment. * * Care should be taken to protect the email address and assure that email * harvesters do not capture your commentors' email address. Most assume that * their email address will not appear in raw form on the blog. Doing so will * enable anyone, including those that people don't want to get the email * address and use it for their own means good and bad. * * @since 2.7 * @uses apply_filters() Calls 'comment_email' hook for the display of the comment author's email * @global object $comment The current Comment row object * * @param string $linktext The text to display instead of the comment author's email address * @param string $before The text or HTML to display before the email link. * @param string $after The text or HTML to display after the email link. */ function get_comment_author_email_link($linktext='', $before='', $after='') { global $comment; $email = apply_filters('comment_email', $comment->comment_author_email); if ((!empty($email)) && ($email != '@')) { $display = ($linktext != '') ? $linktext : $email; $return = $before; $return .= "$display"; $return .= $after; return $return; } else { return ''; } } /** * Retrieve the html link to the url of the author of the current comment. * * @since 1.5.0 * @uses apply_filters() Calls 'get_comment_author_link' hook on the complete link HTML or author * * @return string Comment Author name or HTML link for author's URL */ function get_comment_author_link() { /** @todo Only call these functions when they are needed. Include in if... else blocks */ $url = get_comment_author_url(); $author = get_comment_author(); if ( empty( $url ) || 'http://' == $url ) $return = $author; else $return = "$author"; return apply_filters('get_comment_author_link', $return); } /** * Display the html link to the url of the author of the current comment. * * @since 0.71 * @see get_comment_author_link() Echos result */ function comment_author_link() { echo get_comment_author_link(); } /** * Retrieve the IP address of the author of the current comment. * * @since 1.5.0 * @uses $comment * @uses apply_filters() * * @return unknown */ function get_comment_author_IP() { global $comment; return apply_filters('get_comment_author_IP', $comment->comment_author_IP); } /** * Display the IP address of the author of the current comment. * * @since 0.71 * @see get_comment_author_IP() Echos Result */ function comment_author_IP() { echo get_comment_author_IP(); } /** * Retrieve the url of the author of the current comment. * * @since 1.5.0 * @uses apply_filters() Calls 'get_comment_author_url' hook on the comment author's URL * * @return string */ function get_comment_author_url() { global $comment; $url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url; $url = esc_url( $url, array('http', 'https') ); return apply_filters('get_comment_author_url', $url); } /** * Display the url of the author of the current comment. * * @since 0.71 * @uses apply_filters() * @uses get_comment_author_url() Retrieves the comment author's URL */ function comment_author_url() { echo apply_filters('comment_url', get_comment_author_url()); } /** * Retrieves the HTML link of the url of the author of the current comment. * * $linktext parameter is only used if the URL does not exist for the comment * author. If the URL does exist then the URL will be used and the $linktext * will be ignored. * * Encapsulate the HTML link between the $before and $after. So it will appear * in the order of $before, link, and finally $after. * * @since 1.5.0 * @uses apply_filters() Calls the 'get_comment_author_url_link' on the complete HTML before returning. * * @param string $linktext The text to display instead of the comment author's email address * @param string $before The text or HTML to display before the email link. * @param string $after The text or HTML to display after the email link. * @return string The HTML link between the $before and $after parameters */ function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) { $url = get_comment_author_url(); $display = ($linktext != '') ? $linktext : $url; $display = str_replace( 'http://www.', '', $display ); $display = str_replace( 'http://', '', $display ); if ( '/' == substr($display, -1) ) $display = substr($display, 0, -1); $return = "$before$display$after"; return apply_filters('get_comment_author_url_link', $return); } /** * Displays the HTML link of the url of the author of the current comment. * * @since 0.71 * @see get_comment_author_url_link() Echos result * * @param string $linktext The text to display instead of the comment author's email address * @param string $before The text or HTML to display before the email link. * @param string $after The text or HTML to display after the email link. */ function comment_author_url_link( $linktext = '', $before = '', $after = '' ) { echo get_comment_author_url_link( $linktext, $before, $after ); } /** * Generates semantic classes for each comment element * * @since 2.7.0 * * @param string|array $class One or more classes to add to the class list * @param int $comment_id An optional comment ID * @param int $post_id An optional post ID * @param bool $echo Whether comment_class should echo or return */ function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) { // Separates classes with a single space, collates classes for comment DIV $class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"'; if ( $echo) echo $class; else return $class; } /** * Returns the classes for the comment div as an array * * @since 2.7.0 * * @param string|array $class One or more classes to add to the class list * @param int $comment_id An optional comment ID * @param int $post_id An optional post ID * @return array Array of classes */ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { global $comment_alt, $comment_depth, $comment_thread_alt; $comment = get_comment($comment_id); $classes = array(); // Get the comment type (comment, trackback), $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type; // If the comment author has an id (registered), then print the log in name if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) { // For all registered users, 'byuser' $classes[] = 'byuser'; $classes[] = 'comment-author-' . sanitize_html_class($user->user_nicename, $comment->user_id); // For comment authors who are the author of the post if ( $post = get_post($post_id) ) { if ( $comment->user_id === $post->post_author ) $classes[] = 'bypostauthor'; } } if ( empty($comment_alt) ) $comment_alt = 0; if ( empty($comment_depth) ) $comment_depth = 1; if ( empty($comment_thread_alt) ) $comment_thread_alt = 0; if ( $comment_alt % 2 ) { $classes[] = 'odd'; $classes[] = 'alt'; } else { $classes[] = 'even'; } $comment_alt++; // Alt for top-level comments if ( 1 == $comment_depth ) { if ( $comment_thread_alt % 2 ) { $classes[] = 'thread-odd'; $classes[] = 'thread-alt'; } else { $classes[] = 'thread-even'; } $comment_thread_alt++; } $classes[] = "depth-$comment_depth"; if ( !empty($class) ) { if ( !is_array( $class ) ) $class = preg_split('#\s+#', $class); $classes = array_merge($classes, $class); } return apply_filters('comment_class', $classes, $class, $comment_id, $post_id); } /** * Retrieve the comment date of the current comment. * * @since 1.5.0 * @uses apply_filters() Calls 'get_comment_date' hook with the formated date and the $d parameter respectively * @uses $comment * * @param string $d The format of the date (defaults to user's config) * @return string The comment's date */ function get_comment_date( $d = '' ) { global $comment; if ( '' == $d ) $date = mysql2date(get_option('date_format'), $comment->comment_date); else $date = mysql2date($d, $comment->comment_date); return apply_filters('get_comment_date', $date, $d); } /** * Display the comment date of the current comment. * * @since 0.71 * * @param string $d The format of the date (defaults to user's config) */ function comment_date( $d = '' ) { echo get_comment_date( $d ); } /** * Retrieve the excerpt of the current comment. * * Will cut each word and only output the first 20 words with '...' at the end. * If the word count is less than 20, then no truncating is done and no '...' * will appear. * * @since 1.5.0 * @uses $comment * @uses apply_filters() Calls 'get_comment_excerpt' on truncated comment * * @return string The maybe truncated comment with 20 words or less */ function get_comment_excerpt() { global $comment; $comment_text = strip_tags($comment->comment_content); $blah = explode(' ', $comment_text); if (count($blah) > 20) { $k = 20; $use_dotdotdot = 1; } else { $k = count($blah); $use_dotdotdot = 0; } $excerpt = ''; for ($i=0; $i<$k; $i++) { $excerpt .= $blah[$i] . ' '; } $excerpt .= ($use_dotdotdot) ? '...' : ''; return apply_filters('get_comment_excerpt', $excerpt); } /** * Display the excerpt of the current comment. * * @since 1.2.0 * @uses apply_filters() Calls 'comment_excerpt' hook before displaying excerpt */ function comment_excerpt() { echo apply_filters('comment_excerpt', get_comment_excerpt() ); } /** * Retrieve the comment id of the current comment. * * @since 1.5.0 * @uses $comment * @uses apply_filters() Calls the 'get_comment_ID' hook for the comment ID * * @return int The comment ID */ function get_comment_ID() { global $comment; return apply_filters('get_comment_ID', $comment->comment_ID); } /** * Displays the comment id of the current comment. * * @since 0.71 * @see get_comment_ID() Echos Result */ function comment_ID() { echo get_comment_ID(); } /** * Retrieve the link to a given comment. * * @since 1.5.0 * @uses $comment * * @param object|string|int $comment Comment to retrieve. * @param array $args Optional args. * @return string The permalink to the given comment. */ function get_comment_link( $comment = null, $args = array() ) { global $wp_rewrite, $in_comment_loop; $comment = get_comment($comment); // Backwards compat if ( !is_array($args) ) { $page = $args; $args = array(); $args['page'] = $page; } $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); $args = wp_parse_args( $args, $defaults ); if ( '' === $args['per_page'] && get_option('page_comments') ) $args['per_page'] = get_option('comments_per_page'); if ( empty($args['per_page']) ) { $args['per_page'] = 0; $args['page'] = 0; } if ( $args['per_page'] ) { if ( '' == $args['page'] ) $args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args ); if ( $wp_rewrite->using_permalinks() ) $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' ); else $link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ); } else { $link = get_permalink( $comment->comment_post_ID ); } return apply_filters( 'get_comment_link', $link . '#comment-' . $comment->comment_ID, $comment, $args ); } /** * Retrieves the link to the current post comments. * * @since 1.5.0 * * @return string The link to the comments */ function get_comments_link() { return get_permalink() . '#comments'; } /** * Displays the link to the current post comments. * * @since 0.71 * * @param string $deprecated Not Used * @param bool $deprecated Not Used */ function comments_link( $deprecated = '', $deprecated = '' ) { echo get_comments_link(); } /** * Retrieve the amount of comments a post has. * * @since 1.5.0 * @uses apply_filters() Calls the 'get_comments_number' hook on the number of comments * * @param int $post_id The Post ID * @return int The number of comments a post has */ function get_comments_number( $post_id = 0 ) { global $id; $post_id = (int) $post_id; if ( !$post_id ) $post_id = (int) $id; $post = get_post($post_id); if ( ! isset($post->comment_count) ) $count = 0; else $count = $post->comment_count; return apply_filters('get_comments_number', $count); } /** * Display the language string for the number of comments the current post has. * * @since 0.71 * @uses $id * @uses apply_filters() Calls the 'comments_number' hook on the output and number of comments respectively. * * @param string $zero Text for no comments * @param string $one Text for one comment * @param string $more Text for more than one comment * @param string $deprecated Not used. */ function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { global $id; $number = get_comments_number($id); if ( $number > 1 ) $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more); elseif ( $number == 0 ) $output = ( false === $zero ) ? __('No Comments') : $zero; else // must be one $output = ( false === $one ) ? __('1 Comment') : $one; echo apply_filters('comments_number', $output, $number); } /** * Retrieve the text of the current comment. * * @since 1.5.0 * @uses $comment * * @return string The comment content */ function get_comment_text() { global $comment; return apply_filters('get_comment_text', $comment->comment_content); } /** * Displays the text of the current comment. * * @since 0.71 * @uses apply_filters() Passes the comment content through the 'comment_text' hook before display * @uses get_comment_text() Gets the comment content */ function comment_text() { echo apply_filters('comment_text', get_comment_text() ); } /** * Retrieve the comment time of the current comment. * * @since 1.5.0 * @uses $comment * @uses apply_filter() Calls 'get_comment_time' hook with the formatted time, the $d parameter, and $gmt parameter passed. * * @param string $d Optional. The format of the time (defaults to user's config) * @param bool $gmt Whether to use the GMT date * @param bool $translate Whether to translate the time (for use in feeds) * @return string The formatted time */ function get_comment_time( $d = '', $gmt = false, $translate = true ) { global $comment; $comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date; if ( '' == $d ) $date = mysql2date(get_option('time_format'), $comment_date, $translate); else $date = mysql2date($d, $comment_date, $translate); return apply_filters('get_comment_time', $date, $d, $gmt); } /** * Display the comment time of the current comment. * * @since 0.71 * * @param string $d Optional. The format of the time (defaults to user's config) */ function comment_time( $d = '' ) { echo get_comment_time($d); } /** * Retrieve the comment type of the current comment. * * @since 1.5.0 * @uses $comment * @uses apply_filters() Calls the 'get_comment_type' hook on the comment type * * @return string The comment type */ function get_comment_type() { global $comment; if ( '' == $comment->comment_type ) $comment->comment_type = 'comment'; return apply_filters('get_comment_type', $comment->comment_type); } /** * Display the comment type of the current comment. * * @since 0.71 * * @param string $commenttxt The string to display for comment type * @param string $trackbacktxt The string to display for trackback type * @param string $pingbacktxt The string to display for pingback type */ function comment_type($commenttxt = false, $trackbacktxt = false, $pingbacktxt = false) { if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); $type = get_comment_type(); switch( $type ) { case 'trackback' : echo $trackbacktxt; break; case 'pingback' : echo $pingbacktxt; break; default : echo $commenttxt; } } /** * Retrieve The current post's trackback URL. * * There is a check to see if permalink's have been enabled and if so, will * retrieve the pretty path. If permalinks weren't enabled, the ID of the * current post is used and appended to the correct page to go to. * * @since 1.5.0 * @uses apply_filters() Calls 'trackback_url' on the resulting trackback URL * @uses $id * * @return string The trackback URL after being filtered */ function get_trackback_url() { global $id; if ( '' != get_option('permalink_structure') ) { $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); } else { $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . $id; } return apply_filters('trackback_url', $tb_url); } /** * Displays the current post's trackback URL. * * @since 0.71 * @uses get_trackback_url() Gets the trackback url for the current post * * @param bool $deprecated Remove backwards compat in 2.5 * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() for the result instead. */ function trackback_url($deprecated = true) { if ($deprecated) echo get_trackback_url(); else return get_trackback_url(); } /** * Generates and displays the RDF for the trackback information of current post. * * @since 0.71 * * @param int $deprecated Not used (Was $timezone = 0) */ function trackback_rdf($deprecated = '') { if (stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') === false) { echo '