GNU GENERAL PUBLIC LICENSE\r
Version 2, June 1991\r
\r
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.\r
- 675 Mass Ave, Cambridge, MA 02139, USA\r
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc. \r
+ 51 Franklin St, Fifth Floor, Boston, MA 02110, USA\r
+\r
Everyone is permitted to copy and distribute verbatim copies\r
of this license document, but changing it is not allowed.\r
\r
<body>
<h1 id="logo" style="text-align: center">
<img alt="WordPress" src="wp-admin/images/wordpress-logo.png" />
- <br /> Version 2.6.1
+ <br /> Version 2.7
</h1>
<p style="text-align: center">Semantic Personal Publishing Platform</p>
<h1>Upgrading</h1>
<p>Before you upgrade anything, make sure you have backup copies of any files you may have modified such as <code>index.php</code>.</p>
-<h2>Upgrading from any previous WordPress to 2.6.1:</h2>
+<h2>Upgrading from any previous WordPress to 2.7:</h2>
<ol>
<li>Delete your old WP files, saving ones you've modified.</li>
<li>Upload the new files.</li>
<?php
+/**
+ * WordPress AJAX Process Execution.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Executing AJAX process.
+ *
+ * @since unknown
+ */
define('DOING_AJAX', true);
+define('WP_ADMIN', true);
require_once('../wp-load.php');
require_once('includes/admin.php');
-if ( !is_user_logged_in() )
+if ( ! is_user_logged_in() ) {
+
+ if ( $_POST['action'] == 'autosave' ) {
+ $id = isset($_POST['post_ID'])? (int) $_POST['post_ID'] : 0;
+
+ if ( ! $id )
+ die('-1');
+
+ $message = sprintf( __('<strong>ALERT: You are logged out!</strong> Could not save draft. <a href="%s" target="blank">Please log in again.</a>'), wp_login_url() );
+ $x = new WP_Ajax_Response( array(
+ 'what' => 'autosave',
+ 'id' => $id,
+ 'data' => $message
+ ) );
+ $x->send();
+ }
+
die('-1');
+}
-if ( isset($_GET['action']) && 'ajax-tag-search' == $_GET['action'] ) {
+if ( isset( $_GET['action'] ) ) :
+switch ( $action = $_GET['action'] ) :
+case 'ajax-tag-search' :
if ( !current_user_can( 'manage_categories' ) )
die('-1');
$s = $_GET['q']; // is this slashed already?
- if ( strstr( $s, ',' ) ) {
- $s = explode( ',', $s );
- $s = $s[count( $s ) - 1];
+ if ( false !== strpos( $s, ',' ) ) {
+ $s = explode( ',', $s );
+ $s = $s[count( $s ) - 1];
}
$s = trim( $s );
if ( strlen( $s ) < 2 )
- die; // require 2 chars for matching
- $results = $wpdb->get_col( "SELECT name FROM $wpdb->terms WHERE name LIKE ('%". $s . "%')" );
+ die; // require 2 chars for matching
+ $results = $wpdb->get_col( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = 'post_tag' AND t.name LIKE ('%". $s . "%')" );
echo join( $results, "\n" );
die;
-}
+ break;
+default :
+ do_action( 'wp_ajax_' . $_GET['action'] );
+ die('0');
+ break;
+endswitch;
+endif;
$id = isset($_POST['id'])? (int) $_POST['id'] : 0;
switch ( $action = $_POST['action'] ) :
if ( $_POST['new'] == $current )
die('1');
- if ( 'unapproved' == $current ) {
+ if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) {
check_ajax_referer( "approve-comment_$id" );
if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) )
die('1');
) );
$x->send();
}
-
+
$cat = wp_insert_category( $_POST, true );
if ( is_wp_error($cat) ) {
$x = new WP_Ajax_Response( array(
'what' => 'cat',
'id' => $cat->term_id,
+ 'position' => -1,
'data' => _cat_row( $cat, $level, $cat_full_name ),
'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->term_id", $cat_full_name))
) );
$x = new WP_Ajax_Response( array(
'what' => 'link-cat',
'id' => $term_id,
+ 'position' => -1,
'data' => $link_cat
) );
$x->send();
$x = new WP_Ajax_Response( array(
'what' => 'tag',
'id' => $tag->term_id,
+ 'position' => '-1',
'data' => _tag_row( $tag ),
'supplemental' => array('name' => $tag_full_name, 'show-link' => sprintf(__( 'Tag <a href="#%s">%s</a> added' ), "tag-$tag->term_id", $tag_full_name))
) );
$x->send();
break;
+case 'get-tagcloud' :
+ if ( !current_user_can( 'manage_categories' ) )
+ die('-1');
+
+ $tags = get_tags( array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
+
+ if ( empty( $tags ) )
+ die( __('No tags found!') );
+
+ if ( is_wp_error($tags) )
+ die($tags->get_error_message());
+
+ foreach ( $tags as $key => $tag ) {
+ $tags[ $key ]->link = '#';
+ $tags[ $key ]->id = $tag->term_id;
+ }
+
+ $return = wp_generate_tag_cloud( $tags );
+
+ if ( empty($return) )
+ die('0');
+
+ echo $return;
+
+ exit;
+ break;
case 'add-comment' :
check_ajax_referer( $action );
if ( !current_user_can( 'edit_post', $id ) )
$start = isset($_POST['page']) ? intval($_POST['page']) * 25 - 1: 24;
$status = isset($_POST['comment_status']) ? $_POST['comment_status'] : false;
$mode = isset($_POST['mode']) ? $_POST['mode'] : 'detail';
-
- list($comments, $total) = _wp_get_comment_list( $status, $search, $start, 1 );
+ $p = isset($_POST['p']) ? $_POST['p'] : 0;
+ $comment_type = isset($_POST['comment_type']) ? $_POST['comment_type'] : '';
+ list($comments, $total) = _wp_get_comment_list( $status, $search, $start, 1, $p, $comment_type );
if ( get_option('show_avatars') )
add_filter( 'comment_author', 'floated_admin_avatar' );
foreach ( (array) $comments as $comment ) {
get_comment( $comment );
ob_start();
- _wp_comment_row( $comment->comment_ID, $mode, $status );
+ _wp_comment_row( $comment->comment_ID, $mode, $status, true, true );
$comment_list_item = ob_get_contents();
ob_end_clean();
$x->add( array(
'data' => $comment_list_item
) );
}
+ $x->send();
+ break;
+case 'get-comments' :
+ check_ajax_referer( $action );
+
+ $post_ID = (int) $_POST['post_ID'];
+ if ( !current_user_can( 'edit_post', $post_ID ) )
+ die('-1');
+
+ $start = isset($_POST['start']) ? intval($_POST['start']) : 0;
+ $num = isset($_POST['num']) ? intval($_POST['num']) : 10;
+
+ list($comments, $total) = _wp_get_comment_list( false, false, $start, $num, $post_ID );
+
+ if ( !$comments )
+ die('1');
+
+ $comment_list_item = '';
+ $x = new WP_Ajax_Response();
+ foreach ( (array) $comments as $comment ) {
+ get_comment( $comment );
+ ob_start();
+ _wp_comment_row( $comment->comment_ID, 'single', false, false );
+ $comment_list_item .= ob_get_contents();
+ ob_end_clean();
+ }
+ $x->add( array(
+ 'what' => 'comments',
+ 'data' => $comment_list_item
+ ) );
+ $x->send();
+ break;
+case 'replyto-comment' :
+ check_ajax_referer( $action );
+
+ $comment_post_ID = (int) $_POST['comment_post_ID'];
+ if ( !current_user_can( 'edit_post', $comment_post_ID ) )
+ die('-1');
+
+ $status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );
+
+ if ( empty($status) )
+ die('1');
+ elseif ( in_array($status, array('draft', 'pending') ) )
+ die( __('Error: you are replying to a comment on a draft post.') );
+
+ $user = wp_get_current_user();
+ if ( $user->ID ) {
+ $comment_author = $wpdb->escape($user->display_name);
+ $comment_author_email = $wpdb->escape($user->user_email);
+ $comment_author_url = $wpdb->escape($user->user_url);
+ $comment_content = trim($_POST['content']);
+ if ( current_user_can('unfiltered_html') ) {
+ if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) {
+ kses_remove_filters(); // start with a clean slate
+ kses_init_filters(); // set up the filters
+ }
+ }
+ } else {
+ die( __('Sorry, you must be logged in to reply to a comment.') );
+ }
+
+ if ( '' == $comment_content )
+ die( __('Error: please type a comment.') );
+
+ $comment_parent = absint($_POST['comment_ID']);
+ $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
+
+ $comment_id = wp_new_comment( $commentdata );
+ $comment = get_comment($comment_id);
+ if ( ! $comment ) die('1');
+
+ $modes = array( 'single', 'detail', 'dashboard' );
+ $mode = isset($_POST['mode']) && in_array( $_POST['mode'], $modes ) ? $_POST['mode'] : 'detail';
+ $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
+ $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
+
+ if ( get_option('show_avatars') && 'single' != $mode )
+ add_filter( 'comment_author', 'floated_admin_avatar' );
+
+ $x = new WP_Ajax_Response();
+
+ ob_start();
+ if ( 'dashboard' == $mode ) {
+ require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
+ _wp_dashboard_recent_comments_row( $comment, false );
+ } else {
+ _wp_comment_row( $comment->comment_ID, $mode, false, $checkbox );
+ }
+ $comment_list_item = ob_get_contents();
+ ob_end_clean();
+
+ $x->add( array(
+ 'what' => 'comment',
+ 'id' => $comment->comment_ID,
+ 'data' => $comment_list_item,
+ 'position' => $position
+ ));
+
+ $x->send();
+ break;
+case 'edit-comment' :
+ check_ajax_referer( 'replyto-comment' );
+
+ $comment_post_ID = (int) $_POST['comment_post_ID'];
+ if ( ! current_user_can( 'edit_post', $comment_post_ID ) )
+ die('-1');
+
+ if ( '' == $_POST['content'] )
+ die( __('Error: please type a comment.') );
+
+ $comment_id = (int) $_POST['comment_ID'];
+ $_POST['comment_status'] = $_POST['status'];
+ edit_comment();
+
+ $mode = ( isset($_POST['mode']) && 'single' == $_POST['mode'] ) ? 'single' : 'detail';
+ $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
+ $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
+
+ if ( get_option('show_avatars') && 'single' != $mode )
+ add_filter( 'comment_author', 'floated_admin_avatar' );
+
+ $x = new WP_Ajax_Response();
+
+ ob_start();
+ _wp_comment_row( $comment_id, $mode, true, $checkbox );
+ $comment_list_item = ob_get_contents();
+ ob_end_clean();
+
+ $x->add( array(
+ 'what' => 'edit_comment',
+ 'id' => $comment->comment_ID,
+ 'data' => $comment_list_item,
+ 'position' => $position
+ ));
+
$x->send();
break;
case 'add-meta' :
$do_lock = true;
$data = '';
- $message = sprintf( __('Draft Saved at %s.'), date( __('g:i:s a'), current_time( 'timestamp', true ) ) );
+ $message = sprintf( __('Draft Saved at %s.'), date_i18n( __('g:i:s a') ) );
$supplemental = array();
check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' );
$closed = isset( $_POST['closed'] )? $_POST['closed'] : '';
$closed = explode( ',', $_POST['closed'] );
+ $hidden = isset( $_POST['hidden'] )? $_POST['hidden'] : '';
+ $hidden = explode( ',', $_POST['hidden'] );
+ $page = isset( $_POST['page'] )? $_POST['page'] : '';
+ if ( !preg_match( '/^[a-z-_]+$/', $page ) ) {
+ die(-1);
+ }
+ $current_user = wp_get_current_user();
+ if ( is_array($closed) )
+ update_usermeta($current_user->ID, 'closedpostboxes_'.$page, $closed);
+ if ( is_array($hidden) )
+ update_usermeta($current_user->ID, 'meta-box-hidden_'.$page, $hidden);
+break;
+case 'hidden-columns' :
+ check_ajax_referer( 'hiddencolumns', 'hiddencolumnsnonce' );
+ $hidden = isset( $_POST['hidden'] )? $_POST['hidden'] : '';
+ $hidden = explode( ',', $_POST['hidden'] );
$page = isset( $_POST['page'] )? $_POST['page'] : '';
- if ( !preg_match( '/^[a-z-]+$/', $page ) ) {
+ if ( !preg_match( '/^[a-z-_]+$/', $page ) ) {
die(-1);
}
- if (!is_array($closed)) break;
$current_user = wp_get_current_user();
- update_usermeta($current_user->ID, 'closedpostboxes_'.$page, $closed);
+ if ( is_array($hidden) )
+ update_usermeta($current_user->ID, "manage-$page-columns-hidden", $hidden);
break;
case 'get-permalink':
check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
$slug = isset($_POST['new_slug'])? $_POST['new_slug'] : '';
die(get_sample_permalink_html($post_id, $title, $slug));
break;
+case 'inline-save':
+ check_ajax_referer( 'inlineeditnonce', '_inline_edit' );
+
+ if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) )
+ exit;
+
+ if ( 'page' == $_POST['post_type'] ) {
+ if ( ! current_user_can( 'edit_page', $post_ID ) )
+ die( __('You are not allowed to edit this page.') );
+ } else {
+ if ( ! current_user_can( 'edit_post', $post_ID ) )
+ die( __('You are not allowed to edit this post.') );
+ }
+
+ if ( $last = wp_check_post_lock( $post_ID ) ) {
+ $last_user = get_userdata( $last );
+ $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
+ printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), wp_specialchars( $last_user_name ) );
+ exit;
+ }
+
+ $data = &$_POST;
+ $post = get_post( $post_ID, ARRAY_A );
+ $data['content'] = $post['post_content'];
+ $data['excerpt'] = $post['post_excerpt'];
+
+ // rename
+ $data['user_ID'] = $GLOBALS['user_ID'];
+
+ if ( isset($data['post_parent']) )
+ $data['parent_id'] = $data['post_parent'];
+
+ // status
+ if ( isset($data['keep_private']) && 'private' == $data['keep_private'] )
+ $data['post_status'] = 'private';
+ else
+ $data['post_status'] = $data['_status'];
+
+ if ( empty($data['comment_status']) )
+ $data['comment_status'] = 'closed';
+ if ( empty($data['ping_status']) )
+ $data['ping_status'] = 'closed';
+
+ // update the post
+ $_POST = $data;
+ edit_post();
+
+ $post = array();
+ if ( 'page' == $_POST['post_type'] ) {
+ $post[] = get_post($_POST['post_ID']);
+ page_rows($post);
+ } elseif ( 'post' == $_POST['post_type'] ) {
+ $mode = $_POST['post_view'];
+ $post[] = get_post($_POST['post_ID']);
+ post_rows($post);
+ }
+
+ exit;
+ break;
+case 'inline-save-tax':
+ check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
+
+ if ( ! current_user_can('manage_categories') )
+ die( __('Cheatin’ uh?') );
+
+ if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
+ die(-1);
+
+ switch ($_POST['tax_type']) {
+ case 'cat' :
+ $data = array();
+ $data['cat_ID'] = $id;
+ $data['cat_name'] = $_POST['name'];
+ $data['category_nicename'] = $_POST['slug'];
+ if ( isset($_POST['parent']) && (int) $_POST['parent'] > 0 )
+ $data['category_parent'] = $_POST['parent'];
+
+ $cat = get_category($id, ARRAY_A);
+ $data['category_description'] = $cat['category_description'];
+
+ $updated = wp_update_category($data);
+
+ if ( $updated && !is_wp_error($updated) )
+ echo _cat_row( $updated, 0 );
+ else
+ die( __('Category not updated.') );
+
+ break;
+ case 'link-cat' :
+ $updated = wp_update_term($id, 'link_category', $_POST);
+
+ if ( $updated && !is_wp_error($updated) )
+ echo link_cat_row($updated['term_id']);
+ else
+ die( __('Category not updated.') );
+
+ break;
+ case 'tag' :
+ $updated = wp_update_term($id, 'post_tag', $_POST);
+ if ( $updated && !is_wp_error($updated) ) {
+ $tag = get_term( $updated['term_id'], 'post_tag' );
+ if ( !$tag || is_wp_error( $tag ) )
+ die( __('Tag not updated.') );
+
+ echo _tag_row($tag);
+ } else {
+ die( __('Tag not updated.') );
+ }
+
+ break;
+ }
+
+ exit;
+ break;
+case 'meta-box-order':
+ check_ajax_referer( 'meta-box-order' );
+ update_user_option( $GLOBALS['current_user']->ID, "meta-box-order_$_POST[page]", $_POST['order'] );
+ die('1');
+ break;
+case 'find_posts':
+ check_ajax_referer( 'find-posts' );
+
+ if ( empty($_POST['ps']) )
+ exit;
+
+ $what = isset($_POST['pages']) ? 'page' : 'post';
+ $s = stripslashes($_POST['ps']);
+ preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
+ $search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
+
+ $searchand = $search = '';
+ foreach( (array) $search_terms as $term) {
+ $term = addslashes_gpc($term);
+ $search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))";
+ $searchand = ' AND ';
+ }
+ $term = $wpdb->escape($s);
+ if ( count($search_terms) > 1 && $search_terms[0] != $s )
+ $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')";
+
+ $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND $search ORDER BY post_date_gmt DESC LIMIT 50" );
+
+ if ( ! $posts )
+ exit( __('No posts found.') );
+
+ $html = '<table class="widefat"><thead><tr><th class="found-radio"><br /></th><th>'.__('Title').'</th><th>'.__('Time').'</th><th>'.__('Status').'</th></tr></thead><tbody>';
+ foreach ( $posts as $post ) {
+
+ switch ( $post->post_status ) {
+ case 'publish' :
+ case 'private' :
+ $stat = __('Published');
+ break;
+ case 'future' :
+ $stat = __('Scheduled');
+ break;
+ case 'pending' :
+ $stat = __('Pending Review');
+ break;
+ case 'draft' :
+ $stat = __('Unpublished');
+ break;
+ }
+
+ if ( '0000-00-00 00:00:00' == $post->post_date ) {
+ $time = '';
+ } else {
+ $time = mysql2date(__('Y/m/d'), $post->post_date);
+ }
+
+ $html .= '<tr class="found-posts"><td class="found-radio"><input type="radio" id="found-'.$post->ID.'" name="found_post_id" value="'.$post->ID.'"></td>';
+ $html .= '<td><label for="found-'.$post->ID.'">'.wp_specialchars($post->post_title, true).'</label></td><td>'.wp_specialchars($time, true).'</td><td>'.wp_specialchars($stat, true).'</td></tr>'."\n\n";
+ }
+ $html .= '</tbody></table>';
+
+ $x = new WP_Ajax_Response();
+ $x->add( array(
+ 'what' => $what,
+ 'data' => $html
+ ));
+ $x->send();
+
+ break;
default :
do_action( 'wp_ajax_' . $_POST['action'] );
die('0');
-</div><!-- wpbody -->
-</div><!-- wpcontent -->
+<?php
+/**
+ * WordPress Administration Template Footer
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+?>
+
+<div class="clear"></div></div><!-- wpbody-content -->
+<div class="clear"></div></div><!-- wpbody -->
+<div class="clear"></div></div><!-- wpcontent -->
</div><!-- wpwrap -->
+
<div id="footer">
-<p><?php
-do_action('in_admin_footer', '');
+<p id="footer-left" class="alignleft"><?php
+do_action( 'in_admin_footer' );
$upgrade = apply_filters( 'update_footer', '' );
-echo __('Thank you for creating with <a href="http://wordpress.org/">WordPress</a>').' | '.__('<a href="http://codex.wordpress.org/">Documentation</a>').' | '.__('<a href="http://wordpress.org/support/forum/4">Feedback</a>').' '.$upgrade;
-?></p>
+echo '<span id="footer-thankyou">' . __('Thank you for creating with <a href="http://wordpress.org/">WordPress</a>.').'</span> | '.__('<a href="http://codex.wordpress.org/">Documentation</a>').' | '.__('<a href="http://wordpress.org/support/forum/4">Feedback</a>'); ?>
+</p>
+<?php // if ( $is_IE ) browse_happy(); ?>
+<p id="footer-upgrade" class="alignright"><?php echo $upgrade; ?></p>
+<div class="clear"></div>
</div>
<?php do_action('admin_footer', ''); ?>
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
</body>
-</html>
+</html>
\ No newline at end of file
<?php
-// Deprecated. Use includes/admin.php.
+/**
+ * Administration Functions
+ *
+ * This file is deprecated, use 'wp-admin/includes/admin.php' instead.
+ *
+ * @deprecated 2.5
+ * @package WordPress
+ * @subpackage Administration
+ */
+
_deprecated_file( basename(__FILE__), '2.5', 'wp-admin/includes/admin.php' );
+
+/** WordPress Administration API: Includes all Administration functions. */
require_once(ABSPATH . 'wp-admin/includes/admin.php');
-?>
+?>
\ No newline at end of file
<?php
+/**
+ * WordPress Administration Template Header
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
if (!isset($_GET["page"])) require_once('admin.php');
-if ( $editing ) {
- if ( user_can_richedit() )
- wp_enqueue_script( 'wp_tiny_mce' );
-}
-wp_enqueue_script( 'wp-gears' );
-
-$min_width_pages = array( 'post.php', 'post-new.php', 'page.php', 'page-new.php', 'widgets.php', 'comment.php', 'link.php' );
-$the_current_page = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
-$ie6_no_scrollbar = true;
-
-function add_minwidth($c) {
- return $c . 'minwidth ';
-}
-
-if ( in_array( $the_current_page, $min_width_pages ) ) {
- $ie6_no_scrollbar = false;
- add_filter( 'admin_body_class', 'add_minwidth' );
-}
get_admin_page_title();
-
+$title = wp_specialchars( strip_tags( $title ) );
+wp_user_settings();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
-<title><?php bloginfo('name') ?> › <?php echo wp_specialchars( strip_tags( $title ) ); ?> — WordPress</title>
+<title><?php bloginfo('name') ?> › <?php echo $title; ?> — WordPress</title>
<?php
wp_admin_css( 'css/global' );
<script type="text/javascript">
//<![CDATA[
addLoadEvent = function(func) {if (typeof jQuery != "undefined") jQuery(document).ready(func); else if (typeof wpOnload!='function'){wpOnload=func;} else {var oldonload=wpOnload; wpOnload=function(){oldonload();func();}}};
+
+function convertEntities(o) {
+ var c = function(s) {
+ if (/&[^;]+;/.test(s)) {
+ var e = document.createElement("div");
+ e.innerHTML = s;
+ return !e.firstChild ? s : e.firstChild.nodeValue;
+ }
+ return s;
+ }
+
+ if ( typeof o === 'string' )
+ return c(o);
+ else if ( typeof o === 'object' )
+ for (var v in o) {
+ if ( typeof o[v] === 'string' )
+ o[v] = c(o[v]);
+ }
+ return o;
+};
//]]>
</script>
-<?php if ( ($parent_file != 'link-manager.php') && ($parent_file != 'options-general.php') && $ie6_no_scrollbar ) : ?>
-<style type="text/css">* html { overflow-x: hidden; }</style>
-<?php endif;
+<?php
-$hook_suffixes = array();
+if ( in_array( $pagenow, array('post.php', 'post-new.php', 'page.php', 'page-new.php') ) ) {
+ add_action( 'admin_head', 'wp_tiny_mce' );
+}
+$hook_suffix = '';
if ( isset($page_hook) )
- $hook_suffixes[] = "-$page_hook";
+ $hook_suffix = "$page_hook";
else if ( isset($plugin_page) )
- $hook_suffixes[] = "-$plugin_page";
+ $hook_suffix = "$plugin_page";
else if ( isset($pagenow) )
- $hook_suffixes[] = "-$pagenow";
-
-$hook_suffixes[] = '';
+ $hook_suffix = "$pagenow";
-foreach ( $hook_suffixes as $hook_suffix )
- do_action("admin_print_styles$hook_suffix"); // do_action( 'admin_print_styles-XXX' ); do_action( 'admin_print_styles' );
-foreach ( $hook_suffixes as $hook_suffix )
- do_action("admin_print_scripts$hook_suffix"); // do_action( 'admin_print_scripts-XXX' ); do_action( 'admin_print_scripts' );
-foreach ( $hook_suffixes as $hook_suffix )
- do_action("admin_head$hook_suffix"); // do_action( 'admin_head-XXX' ); do_action( 'admin_head' );
-unset($hook_suffixes, $hook_suffix);
+do_action("admin_print_styles-$hook_suffix");
+do_action('admin_print_styles');
+do_action("admin_print_scripts-$hook_suffix");
+do_action('admin_print_scripts');
+do_action("admin_head-$hook_suffix");
+do_action('admin_head');
-?>
+if ( $is_iphone ) { ?>
+<style type="text/css">.row-actions{visibility:visible;}</style>
+<?php } ?>
</head>
<body class="wp-admin <?php echo apply_filters( 'admin_body_class', '' ); ?>">
+
<div id="wpwrap">
<div id="wpcontent">
<div id="wphead">
-<h1><?php if ( '' == get_bloginfo('name', 'display') ) echo ' '; else echo get_bloginfo('name', 'display'); ?><span id="viewsite"><a href="<?php echo trailingslashit( get_option('home') ); ?>"><?php _e('Visit Site') ?></a></span></h1>
-</div>
-
<?php
-if ( ! $is_opera ) {
+$blog_name = get_bloginfo('name', 'display');
+if ( '' == $blog_name ) {
+ $blog_name = ' ';
+} else {
+ $blog_name_excerpt = wp_html_excerpt($blog_name, 40);
+ if ( $blog_name != $blog_name_excerpt )
+ $blog_name_excerpt = trim($blog_name_excerpt) . '…';
+ $blog_name = $blog_name_excerpt;
+}
+$title_class = '';
+if ( function_exists('mb_strlen') ) {
+ if ( mb_strlen($blog_name, 'UTF-8') > 30 )
+ $title_class = 'class="long-title"';
+} else {
+ if ( strlen($blog_name) > 30 )
+ $title_class = 'class="long-title"';
+}
?>
- <div id="gears-info-box" class="info-box" style="display:none;">
- <img src="images/gear.png" title="Gear" alt="" class="gears-img" />
- <div id="gears-msg1">
- <h3 class="info-box-title"><?php _e('Speed up WordPress'); ?></h3>
- <p><?php _e('WordPress now has support for Gears, which adds new features to your web browser.'); ?><br />
- <a href="http://gears.google.com/" target="_blank" style="font-weight:normal;"><?php _e('More information...'); ?></a></p>
- <p><?php _e('After you install and enable Gears most of WordPress’ images, scripts, and CSS files will be stored locally on your computer. This speeds up page load time.'); ?></p>
- <p><strong><?php _e('Don’t install on a public or shared computer.'); ?></strong></p> <div class="submit"><button onclick="window.location = 'http://gears.google.com/?action=install&return=<?php echo urlencode( admin_url() ); ?>';" class="button"><?php _e('Install Now'); ?></button>
- <button class="button" style="margin-left:10px;" onclick="document.getElementById('gears-info-box').style.display='none';"><?php _e('Cancel'); ?></button></div>
- </div>
-
- <div id="gears-msg2" style="display:none;">
- <h3 class="info-box-title"><?php _e('Gears Status'); ?></h3>
- <p><?php _e('Gears is installed on this computer but is not enabled for use with WordPress.'); ?></p>
- <p><?php
-
- if ( $is_safari )
- _e('To enable it, make sure this web site is not on the denied list in Gears Settings under the Safari menu, then click the button below.');
- else
- _e('To enable it, make sure this web site is not on the denied list in Gears Settings under your browser Tools menu, then click the button below.');
-
- ?></p>
- <p><strong><?php _e('However if this is a public or shared computer, Gears should not be enabled.'); ?></strong></p>
- <div class="submit"><button class="button" onclick="wpGears.getPermission();"><?php _e('Enable Gears'); ?></button>
- <button class="button" style="margin-left:10px;" onclick="document.getElementById('gears-info-box').style.display='none';"><?php _e('Cancel'); ?></button></div>
- </div>
-
- <div id="gears-msg3" style="display:none;">
- <h3 class="info-box-title"><?php _e('Gears Status'); ?></h3>
- <p><?php
-
- if ( $is_safari )
- _e('Gears is installed and enabled on this computer. You can disable it from the Safari menu.');
- else
- _e('Gears is installed and enabled on this computer. You can disable it from your browser Tools menu.');
-
- ?></p>
- <p><?php _e('If there are any errors, try disabling Gears, then reload the page and enable it again.'); ?></p>
- <p><?php _e('Local storage status:'); ?> <span id="gears-wait"><span style="color:#f00;"><?php _e('Please wait! Updating files:'); ?></span> <span id="gears-upd-number"></span></span></p>
- <div class="submit"><button class="button" onclick="document.getElementById('gears-info-box').style.display='none';"><?php _e('Close'); ?></button></div>
- </div>
- </div>
+
+<img id="header-logo" src="../wp-includes/images/blank.gif" alt="" width="32" height="32" /> <h1 <?php echo $title_class ?>><a href="<?php echo trailingslashit( get_bloginfo('url') ); ?>" title="<?php _e('Visit site') ?>"><?php echo $blog_name ?> <span>← <?php _e('Visit site') ?></span></a></h1>
+
+<div id="wphead-info">
+<div id="user_info">
+<p><?php printf(__('Howdy, <a href="%1$s" title="Edit your profile">%2$s</a>'), 'profile.php', $user_identity) ?>
+<?php if ( ! $is_opera ) { ?><span class="turbo-nag hidden"> | <a href="tools.php"><?php _e('Turbo') ?></a></span><?php } ?> |
+<a href="<?php echo wp_logout_url() ?>" title="<?php _e('Log Out') ?>"><?php _e('Log Out'); ?></a></p>
+</div>
+
+<?php favorite_actions(); ?>
+</div>
+</div>
+
+<?php if ( get_user_setting('mfold') == 'f' ) { ?>
+<script type="text/javascript">jQuery('#wpcontent').addClass('folded');</script>
<?php } ?>
-<div id="user_info"><p><?php printf(__('Howdy, <a href="%1$s">%2$s</a>!'), 'profile.php', $user_identity) ?> | <a href="<?php echo site_url('wp-login.php?action=logout', 'login') ?>" title="<?php _e('Log Out') ?>"><?php _e('Log Out'); ?></a> | <?php _e('<a href="http://codex.wordpress.org/">Help</a>') ?> | <?php _e('<a href="http://wordpress.org/support/">Forums</a>'); if ( ! $is_opera ) { ?> | <span id="gears-menu"><a href="#" onclick="wpGears.message(1);return false;"><?php _e('Turbo') ?></a></span><?php } ?></p></div>
+<div id="wpbody">
+<?php require(ABSPATH . 'wp-admin/menu-header.php'); ?>
+<div id="wpbody-content">
<?php
-require(ABSPATH . 'wp-admin/menu-header.php');
+screen_meta($hook_suffix);
+
+do_action('admin_notices');
if ( $parent_file == 'options-general.php' ) {
require(ABSPATH . 'wp-admin/options-head.php');
}
-?>
-<div id="wpbody">
<?php
-define('WP_ADMIN', TRUE);
+/**
+ * WordPress Administration Generic POST Handler.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** We are located in WordPress Administration Panels */
+define('WP_ADMIN', true);
if ( defined('ABSPATH') )
require_once(ABSPATH . 'wp-load.php');
<?php
+/**
+ * WordPress Administration Bootstrap
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * In WordPress Administration Panels
+ *
+ * @since unknown
+ */
define('WP_ADMIN', TRUE);
if ( defined('ABSPATH') )
wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback'));
-wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"), array('#07273E', '#14568A', '#D54E21', '#2683AE'));
-wp_admin_css_color('fresh', __('Fresh'), admin_url("css/colors-fresh.css"), array('#464646', '#CEE1EF', '#D54E21', '#2683AE'));
+wp_admin_css_color('classic', __('Blue'), admin_url("css/colors-classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7'));
+wp_admin_css_color('fresh', __('Gray'), admin_url("css/colors-fresh.css"), array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF'));
wp_enqueue_script( 'common' );
wp_enqueue_script( 'jquery-color' );
// Handle plugin admin pages.
if (isset($plugin_page)) {
- $page_hook = get_plugin_page_hook($plugin_page, $pagenow);
+ if( ! $page_hook = get_plugin_page_hook($plugin_page, $pagenow) ) {
+ $page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
+ // backwards compatibility for plugins using add_management_page
+ if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) {
+ // There could be plugin specific params on the URL, so we need the whole query string
+ if ( !empty($_SERVER[ 'QUERY_STRING' ]) )
+ $query_string = $_SERVER[ 'QUERY_STRING' ];
+ else
+ $query_string = 'page=' . $plugin_page;
+ wp_redirect( 'tools.php?' . $query_string );
+ exit;
+ }
+ }
if ( $page_hook ) {
do_action('load-' . $page_hook);
}
// Allow plugins to define importers as well
- if (! is_callable($wp_importers[$importer][2]))
+ if ( !isset($wp_importers) || !isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2]))
{
if (! file_exists(ABSPATH . "wp-admin/import/$importer.php"))
{
include(ABSPATH . "wp-admin/import/$importer.php");
}
- $parent_file = 'edit.php';
+ $parent_file = 'tools.php';
$submenu_file = 'import.php';
$title = __('Import');
include(ABSPATH . 'wp-admin/admin-footer.php');
+ // Make sure rules are flushed
+ global $wp_rewrite;
+ $wp_rewrite->flush_rules();
+
exit();
} else {
do_action("load-$pagenow");
<?php
-
-/* This accepts file uploads from swfupload or other asynchronous upload methods.
-
-*/
+/**
+ * Accepts file uploads from swfupload or other asynchronous upload methods.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
if ( defined('ABSPATH') )
require_once(ABSPATH . 'wp-load.php');
if ( !current_user_can('upload_files') )
wp_die(__('You do not have permission to upload files.'));
-// just fetch the detail form for that attachment
-if ( ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) {
- echo get_media_item($id);
+// just fetch the detail form for that attachment
+if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) {
+ if ( 2 == $_REQUEST['fetch'] ) {
+ add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
+ echo get_media_item($id, array( 'send' => false, 'delete' => false ));
+ } else {
+ echo get_media_item($id);
+ }
exit;
}
echo apply_filters("async_upload_{$type}", $id);
}
-?>
+?>
\ No newline at end of file
<?php
+/**
+ * Categories Management Panel
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
require_once('admin.php');
$title = __('Categories');
-$parent_file = 'edit.php';
-wp_reset_vars(array('action', 'cat'));
+wp_reset_vars( array('action', 'cat') );
-if ( isset($_GET['deleteit']) && isset($_GET['delete']) )
+if ( isset( $_GET['action'] ) && isset($_GET['delete']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) )
$action = 'bulk-delete';
switch($action) {
}
$sendback = wp_get_referer();
- $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
wp_redirect($sendback);
exit();
break;
case 'edit':
+ $title = __('Edit Category');
+
require_once ('admin-header.php');
$cat_ID = (int) $_GET['cat_ID'];
$category = get_category_to_edit($cat_ID);
if ( !current_user_can('manage_categories') )
wp_die(__('Cheatin’ uh?'));
+ $location = 'categories.php';
+ if ( $referer = wp_get_original_referer() ) {
+ if ( false !== strpos($referer, 'categories.php') )
+ $location = $referer;
+ }
+
if ( wp_update_category($_POST) )
- wp_redirect('categories.php?message=3');
+ $location = add_query_arg('message', 3, $location);
else
- wp_redirect('categories.php?message=5');
+ $location = add_query_arg('message', 5, $location);
+
+ wp_redirect($location);
exit;
break;
default:
-if ( !empty($_GET['_wp_http_referer']) ) {
- wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
+if ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
+ wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
exit;
}
-wp_enqueue_script( 'admin-categories' );
-wp_enqueue_script('admin-forms');
+wp_enqueue_script('admin-categories');
+if ( current_user_can('manage_categories') )
+ wp_enqueue_script('inline-edit-tax');
require_once ('admin-header.php');
$messages[5] = __('Category not updated.');
?>
-<?php if (isset($_GET['message'])) : ?>
-<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<div class="wrap nosubsub">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title );
+if ( isset($_GET['s']) && $_GET['s'] )
+ printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
+</h2>
+
+<?php
+if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
+<div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
endif; ?>
-<div class="wrap">
-<form id="posts-filter" action="" method="get">
-<?php if ( current_user_can('manage_categories') ) : ?>
- <h2><?php printf(__('Manage Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
-<?php else : ?>
- <h2><?php _e('Manage Categories') ?> </h2>
-<?php endif; ?>
-
-<p id="post-search">
- <label class="hidden" for="post-search-input"><?php _e('Search Categories'); ?>:</label>
- <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
+<form class="search-form topmargin" action="" method="get">
+<p class="search-box">
+ <label class="hidden" for="category-search-input"><?php _e('Search Categories'); ?>:</label>
+ <input type="text" class="search-input" id="category-search-input" name="s" value="<?php _admin_search_query(); ?>" />
<input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" />
</p>
-
+</form>
<br class="clear" />
+<div id="col-container">
+
+<div id="col-right">
+<div class="col-wrap">
+<form id="posts-filter" action="" method="get">
<div class="tablenav">
<?php
-$pagenum = absint( $_GET['pagenum'] );
+$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
if ( empty($pagenum) )
$pagenum = 1;
-if( !$catsperpage || $catsperpage < 0 )
+if( ! isset( $catsperpage ) || $catsperpage < 0 )
$catsperpage = 20;
$page_links = paginate_links( array(
'base' => add_query_arg( 'pagenum', '%#%' ),
'format' => '',
+ 'prev_text' => __('«'),
+ 'next_text' => __('»'),
'total' => ceil(wp_count_terms('category') / $catsperpage),
'current' => $pagenum
));
echo "<div class='tablenav-pages'>$page_links</div>";
?>
-<div class="alignleft">
-<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
+<div class="alignleft actions">
+<select name="action">
+<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-categories'); ?>
</div>
<br class="clear" />
</div>
-<br class="clear" />
+<div class="clear"></div>
-<table class="widefat">
+<table class="widefat fixed" cellspacing="0">
<thead>
<tr>
- <th scope="col" class="check-column"><input type="checkbox" /></th>
- <th scope="col"><?php _e('Name') ?></th>
- <th scope="col"><?php _e('Description') ?></th>
- <th scope="col" class="num"><?php _e('Posts') ?></th>
+<?php print_column_headers('categories'); ?>
</tr>
</thead>
+
+ <tfoot>
+ <tr>
+<?php print_column_headers('categories', false); ?>
+ </tr>
+ </tfoot>
+
<tbody id="the-list" class="list:cat">
<?php
cat_rows(0, 0, 0, $pagenum, $catsperpage);
?>
</tbody>
</table>
-</form>
<div class="tablenav">
-
<?php
if ( $page_links )
echo "<div class='tablenav-pages'>$page_links</div>";
?>
-<br class="clear" />
+
+<div class="alignleft actions">
+<select name="action2">
+<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
+<?php wp_nonce_field('bulk-categories'); ?>
</div>
-<br class="clear" />
+<br class="clear" />
</div>
-<?php if ( current_user_can('manage_categories') ) : ?>
-<div class="wrap">
+</form>
+
+<div class="form-wrap">
<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), apply_filters('the_category', get_catname(get_option('default_category')))) ?></p>
<p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), 'admin.php?import=wp-cat2tag') ?></p>
</div>
-<?php include('edit-category-form.php'); ?>
+</div>
+</div><!-- /col-right -->
+
+<div id="col-left">
+<div class="col-wrap">
+
+<?php if ( current_user_can('manage_categories') ) { ?>
+<?php $category = (object) array(); $category->parent = 0; do_action('add_category_form_pre', $category); ?>
+
+<div class="form-wrap">
+<h3><?php _e('Add Category'); ?></h3>
+<div id="ajax-response"></div>
+<form name="addcat" id="addcat" method="post" action="categories.php" class="add:the-list: validate">
+<input type="hidden" name="action" value="addcat" />
+<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-category'); ?>
+
+<div class="form-field form-required">
+ <label for="cat_name"><?php _e('Category Name') ?></label>
+ <input name="cat_name" id="cat_name" type="text" value="" size="40" aria-required="true" />
+ <p><?php _e('The name is used to identify the category almost everywhere, for example under the post or in the category widget.'); ?></p>
+</div>
+
+<div class="form-field">
+ <label for="category_nicename"><?php _e('Category Slug') ?></label>
+ <input name="category_nicename" id="category_nicename" type="text" value="" size="40" />
+ <p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
+</div>
+
+<div class="form-field">
+ <label for="category_parent"><?php _e('Category Parent') ?></label>
+ <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'category_parent', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
+ <p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p>
+</div>
+
+<div class="form-field">
+ <label for="category_description"><?php _e('Description') ?></label>
+ <textarea name="category_description" id="category_description" rows="5" cols="40"></textarea>
+ <p><?php _e('The description is not prominent by default, however some themes may show it.'); ?></p>
+</div>
+
+<p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Category'); ?>" /></p>
+<?php do_action('edit_category_form', $category); ?>
+</form></div>
-<?php endif; ?>
+<?php } ?>
+
+</div>
+</div><!-- /col-left -->
+
+</div><!-- /col-container -->
+</div><!-- /wrap -->
+
+<script type="text/javascript">
+/* <![CDATA[ */
+(function($){
+ $(document).ready(function(){
+ $('#doaction, #doaction2').click(function(){
+ if ( $('select[name^="action"]').val() == 'delete' ) {
+ var m = '<?php echo js_escape(__("You are about to delete the selected categories.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
+ return showNotice.warn(m);
+ }
+ });
+ });
+})(jQuery);
+/* ]]> */
+</script>
<?php
+inline_edit_term_row('categories');
+
break;
}
<?php
+/**
+ * Comment Management Panel
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
require_once('admin.php');
$parent_file = 'edit-comments.php';
if ( isset( $_POST['deletecomment'] ) )
$action = 'deletecomment';
-function comment_footer_die( $msg ) { // $msg is assumed to contain HTML and be sanitized
+/**
+ * Display error message at bottom of comments.
+ *
+ * @param string $msg Error Message. Assumed to contain HTML and be sanitized.
+ */
+function comment_footer_die( $msg ) { //
echo "<div class='wrap'><p>$msg</p></div>";
include('admin-footer.php');
die;
$title = __('Edit Comment');
wp_enqueue_script('comment');
-
require_once('admin-header.php');
$comment_id = absint( $_GET['c'] );
</tr>
<?php } ?>
<tr>
-<th scope="row" valign="top"><?php _e('Comment'); ?></th>
+<th scope="row" valign="top"><?php echo _c('Comment|noun'); ?></th>
<td><?php echo $comment->comment_content; ?></td>
</tr>
</table>
if ( '' != wp_get_referer() && false == $noredir )
wp_redirect( wp_get_referer() );
else
- wp_redirect( admin_url('edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
+ wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
exit();
break;
if ( '' != wp_get_referer() && false == $noredir )
wp_redirect( wp_get_referer() );
else
- wp_redirect( admin_url('edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
+ wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
exit();
break;
edit_comment();
- $location = ( empty( $_POST['referredby'] ) ? "edit.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
+ $location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
$location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
wp_redirect( $location );
include('admin-footer.php');
-?>
+?>
\ No newline at end of file
-.post-com-count {
-}
-#adminmenu li a #awaiting-mod, #sidemenu li a #update-plugins {
- background-image: url(../images/comment-stalk-rtl.gif);
- background-position:right bottom;
-}
-#footer {
- background-position:99% 10px;
-}
-#poststuff .closed .togbox, #poststuff .togbox {
- background-image: url(../images/toggle-arrow-rtl.gif) !important;
-}
.bar {
border-right-color: transparent;
border-left-color: #99d;
}
+
.plugins .togl {
border-right-color: transparent;
border-left-color: #ccc;
}
+
+.post-com-count {
+ background-image: url(../images/bubble_bg-rtl.gif);
+}
+.tablenav .tablenav-pages a {
+ background: #eee url('../images/menu-bits-rtl.gif') repeat-x scroll right -379px;
+}
#upload-menu li.current {
border-right-color: transparent;
border-left-color: #448abd;
}
+
+#adminmenu .wp-submenu .current a.current {
+ background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -289px;
+}
+
+#adminmenu li.wp-menu-separator {
+ background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;
+}
+
+.folded #adminmenu li.wp-menu-separator {
+ background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;
+}
+
+#adminmenu li.wp-has-current-submenu .wp-menu-toggle,
+#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+ background: transparent url(../images/menu-bits-rtl.gif) repeat-x scroll right -207px;
+}
+
+#adminmenu .wp-has-current-submenu ul li a.current {
+ background: url(../images/menu-dark-rtl.gif) top right no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
+#adminmenu .menu-top .current {
+ background: url(../images/menu-bits-rtl.gif) top right repeat-x;
+}
+
+#adminmenu li.wp-has-current-submenu ul li a {
+ background: url(../images/menu-dark-rtl.gif) bottom right no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle, #adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+ background: transparent url(../images/menu-bits-rtl.gif) no-repeat right -207px;
+}
+
+#adminmenu .wp-has-submenu:hover .wp-menu-toggle,
+#adminmenu .wp-menu-open .wp-menu-toggle {
+ background: transparent url(../images/menu-bits-rtl.gif) repeat-x scroll right -109px;
+}
+
+#adminmenu a.wp-has-submenu {
+ background: #f1f1f1 url(../images/menu-bits-rtl.gif) repeat-x scroll right -379px;
+}
+
+#adminmenu .wp-submenu a {
+ background: #FFFFFF url(../images/menu-bits-rtl.gif) no-repeat scroll right -310px;
+}
+
+#adminmenu li.current a,
+#adminmenu .wp-submenu a:hover {
+ background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -289px;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-submenu {
+ background: #b5b5b5 url(../images/menu-bits-rtl.gif) repeat-x scroll right top;
+}
+
+.meta-box-sortables .postbox:hover .handlediv {
+ background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -111px;
+}
+html {
+ background-color: #F5FCFD;
+}
+
+.find-box-search {
+ border-color: #dfdfdf;
+ background-color: #f1f1f1;
+}
+
+.find-box {
+ background-color: #f1f1f1;
+}
+
+.find-box-inside {
+ background-color: #fff;
+}
+
a.page-numbers:hover {
border-color: #999;
}
-body, .form-table .pre {
- background-color: #fff;
+body,
+#wpbody,
+.form-table .pre {
color: #333;
}
border-bottom-color: #fff;
}
-div#current-widgets, #postcustomstuff table, #your-profile fieldset, a.page-numbers, #rightnow, div.dashboard-widget, .widefat {
+kbd, code {
+ background: #eaeaea;
+}
+
+div#current-widgets,
+#postcustomstuff table,
+#your-profile fieldset,
+#rightnow,
+div.dashboard-widget,
+#dashboard-widgets p.dashboard-widget-links,
+#replyrow #ed_reply_toolbar input {
border-color: #ccc;
}
+#poststuff .inside label.spam {
+ color: red;
+}
+
+#poststuff .inside label.waiting {
+ color: orange;
+}
+
+#poststuff .inside label.approved {
+ color: green;
+}
+
+#postcustomstuff table {
+ border-color: #dfdfdf;
+ background-color: #F9F9F9;
+}
+
+#postcustomstuff thead th {
+ background-color: #F1F1F1;
+}
+
+#postcustomstuff table input,
+#postcustomstuff table textarea {
+ border-color: #dfdfdf;
+ background-color: #fff;
+}
+
+.widefat {
+ border-color: #BBD8E7;
+ background-color: #fff;
+}
+
div.dashboard-widget-error {
background-color: #c43;
}
div.dashboard-widget-notice {
- background-color: #F0F6FB;
+ background-color: #cfe1ef;
}
-div.dashboard-widget-submit, ul.widget-control-list div.widget-control-actions {
+div.dashboard-widget-submit,
+ul.widget-control-list div.widget-control-actions {
border-top-color: #ccc;
}
-input.disabled, textarea.disabled {
- background-color: #ccc;
+div.ui-tabs-panel {
+ border-color: #f1f1f1;
+}
+
+ul#category-tabs li.ui-tabs-selected {
+ background-color: #f1f1f1;
}
-#user_info a:hover, li.widget-list-control-item h4.widget-title a:hover, .submit a, #dashmenu a:hover, #footer a, #upload-menu li a.upload-tab-link, li.widget-list-control-item h4.widget-title a,
+input.disabled,
+textarea.disabled {
+ background-color: #ccc;
+}
+/* #upload-menu li a.upload-tab-link, */
+li.widget-list-control-item h4.widget-title a:hover,
+li.widget-list-control-item h4.widget-title a,
#dragHelper li.widget-list-control-item h4.widget-title a,
-#draghelper li.widget-list-control-item h4.widget-title a:visited, .login #backtoblog a:hover {
+#draghelper li.widget-list-control-item h4.widget-title a:visited,
+.login #backtoblog a:hover,
+#plugin-information .action-button a,
+#plugin-information .action-button a:hover,
+#plugin-information .action-button a:visited {
color: #fff;
}
-ul#category-tabs li.ui-tabs-selected, li.widget-list-control-item, div.nav, .tablenav, .submitbox, h3.dashboard-widget-title, h3.dashboard-widget-title span, h3.dashboard-widget-title small, ul.view-switch li.current, .form-table tr, #poststuff h3, .login form, h3.info-box-title {
- background-color: #cfebf7;
+li.widget-list-control-item div.widget-control {
+ background-color: #fff;
+ border-color: #dfdfdf;
}
-div.ui-tabs-panel {
- border-color: #cfebf7;
+.metabox-holder .postbox h3,
+#poststuff .postbox h3,
+#poststuff .stuffbox h3 {
+ background: #dfdfdf url("../images/blue-grad.png") repeat-x left top;
+ text-shadow: #fff 0 1px 0;
+}
+
+.form-table th,
+.form-wrap label {
+ color: #222;
+ text-shadow: #fff 0 1px 0;
+}
+
+.setting-description, .form-wrap p {
+ color: #666;
}
select {
background-color: #fff;
- border-color: #ddd;
+ border-color: #8CBDD5;
}
strong .post-com-count span {
- background-color: #2583ad;
-}
-
-.button-secondary, #login form .submit input {
- background-color: #8ebddc !important;
+ background-color: #21759b;
}
ul#widget-list li.widget-list-item h4.widget-title {
background-color: #ccf3fa;
}
-.ac_match, .subsubsub a.current, h2 {
+.ac_match, .subsubsub a.current {
color: #000;
}
+.wrap h2 {
+ color: #093E56;
+}
+
.ac_over {
background-color: #f0f0b8;
}
color: #101010;
}
-.alternate {
- background-color: #f9f9f9;
+.alternate, .alt {
+ background-color: #EDFBFC;
}
.available-theme a.screenshot {
background-color: #f1f1f1;
- border-color: #ccc;
+ border-color: #ddd;
}
.bar {
border-right-color: #99d;
}
-.describe {
- border-top-color: #d0d0d0;
+#media-upload {
+ background: #fff;
+}
+#media-upload .slidetoggle {
+ border-top-color: #dfdfdf;
}
.error, #login #login_error {
border-color: #c00 !important;
}
-.form-table input, .form-table textarea {
- border-color: #c6d9e9;
-}
-
-.form-table td, .form-table th {
- border-bottom-color: #fff;
+.form-table input,
+.form-table textarea,
+.search-input,
+.form-field input,
+.form-field textarea,
+.submit {
+ border-color: #8CBDD5;
}
.highlight {
- background-color: #cfebf7;
+ background-color: #e4f2fd;
color: #d54e21;
}
-.howto, .nonessential, #sidemenu, #edit-slug-box, .form-input-tip, #dashboard_primary span.rss-date, .subsubsub, #dashboard_secondary div.dashboard-widget-content ul li a cite {
- color: #999;
-}
-
-#dashmenu a, #user_info a {
- color: #88b4d7;
+.howto,
+.nonessential,
+#edit-slug-box,
+.form-input-tip,
+.rss-widget span.rss-date,
+.subsubsub {
+ color: #666;
}
.media-item {
- border-bottom-color: #d0d0d0;
+ border-bottom-color: #dfdfdf;
}
-.media-upload-form label.form-help, td.help {
- color: #9a9a9a;
+#wpbody-content #media-items .describe {
+ border-top-color: #dfdfdf;
}
-.page-numbers {
- background-color: #fff;
- border-color: #fff;
+.describe input[type="text"],
+.describe textarea {
+ border-color: #dfdfdf;
}
-.page-numbers.current {
- background-color: #328ab2;
- border-color: #328ab2;
- color: #fff;
+.media-upload-form label.form-help,
+td.help {
+ color: #9a9a9a;
}
.post-com-count {
color: #666;
}
-.submit input, .button, .button-secondary, #login form .submit input, div.dashboard-widget-submit input, #edit-slug-buttons a.save {
- background-color: #e5e5e5;
- color: #07273e;
- border-color: #a3a3a3;
+.button,
+.button-secondary,
+.submit input,
+input[type=button],
+input[type=submit] {
+ border-color: #8CBDD5;
+ color: #093E56;
}
-.button[disabled], .button:disabled {
- background-color: #999;
+.button:hover,
+.button-secondary:hover,
+.submit input:hover,
+input[type=button]:hover,
+input[type=submit]:hover {
+ color: #000;
+ border-color: #21759B;
}
-.tablenav .button-secondary {
- border-color: #5396c5;
+.button,
+.submit input,
+.button-secondary {
+ background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;
}
-.submit input:hover, .button:hover, #edit-slug-buttons a.save:hover {
- border-color: #535353;
+.button:active,
+.submit input:active,
+.button-secondary:active {
+ background: #eee url(../images/white-grad-active.png) repeat-x scroll left top;
}
-.submit input:hover, .button:hover, .button-secondary:hover, #wphead #viewsite a:hover, #submenu a.current, #submenu a:hover, .submitbox #previewview a:hover, #the-comment-list .comment a:hover, #rightnow a:hover, a:hover, .subsubsub a:hover, .subsubsub a.current:hover, #login form .submit input:hover, div.dashboard-widget-submit input:hover, #edit-slug-buttons a.save:hover, #media-upload a.del-link:hover {
+.button-primary,
+.submit .button-primary,
+#login form .submit input {
+ border-color: #298cba !important;
+ font-weight: bold;
+ color: #FFF !important;
+ background: #21759B url(../images/button-grad.png) repeat-x scroll left top;
+}
+
+.button-primary:active,
+#login form .submit input:active {
+ background: #21759b url(../images/button-grad-active.png) repeat-x scroll left top !important;
+}
+
+.button[disabled],
+.button:disabled,
+.button-secondary[disabled],
+.button-secondary:disabled,
+a.button.disabled {
+ color: #ccc !important;
+ border-color: #ccc;
+}
+
+.button-primary[disabled],
+.button-primary:disabled {
+ color: #2fa0d5 !important;
+}
+
+a:active,
+a:focus {
color: #d54e21;
}
-#adminmenu a:hover, #sidemenu a:hover, .ui-tabs-nav a:hover {
- color: #97c4d8;
+a:hover,
+#wphead #viewsite a:hover,
+#adminmenu a:hover,
+#adminmenu ul.wp-submenu a:hover,
+#the-comment-list .comment a:hover,
+#rightnow a:hover,
+.subsubsub a:hover,
+.subsubsub a.current:hover,
+#login form .submit input:hover,
+div.dashboard-widget-submit input:hover,
+#media-upload a.del-link:hover,
+.ui-tabs-nav a:hover {
+ color: #d54e21;
}
-.button-secondary:hover, #login form .submit input:hover {
- border-color: #328ab2;
- background-color: #a6d2e5 !important;
+#the-comment-list .comment-item,
+#dashboard-widgets #dashboard_quick_press form p.submit {
+ border-color: #dfdfdf;
}
-.submitbox #autosave .error, ul.view-switch li.current a {
- color: #333;
+.button-primary:hover,
+#login form .submit input:hover {
+ border-color: #13455b !important;
+ color: #EAF2FA !important;
}
-.submitbox #previewview {
- background-color: #5488af;
+#side-info-column #category-tabs .ui-tabs-selected a {
+ color: #333;
}
-.submitbox #previewview a, #rightnow .rbutton {
+#rightnow .rbutton {
background-color: #ebebeb;
color: #264761;
}
color: #ccc;
}
-.submitbox .submitdelete {
- border-bottom-color: #999;
+.submitbox .submitdelete, a.delete {
+ color: #f00;
+ border-bottom-color: #f00;
}
.submitbox .submitdelete:hover,
border-bottom-color: #f00;
}
+#normal-sortables .submitbox .submitdelete:hover {
+ color: #000;
+ background-color: #f00;
+ border-bottom-color: #f00;
+}
+
.tablenav .dots {
- background-color: #cfebf7;
- border-color: #cfebf7;
+ border-color: transparent;
}
-.tablenav .next, .tablenav .prev{
- background-color: #cfebf7;
- border-bottom-color: #cfebf7;
- border-color: #cfebf7;
- color: #2583ad;
+.tablenav .next,
+.tablenav .prev {
+ border-color: transparent;
+ color: #21759b;
}
-.tablenav .next:hover, .tablenav .prev:hover {
- border-bottom-color: #d54e21;
- border-color: #cfebf7;
+.tablenav .next:hover,
+.tablenav .prev:hover {
+ border-color: transparent;
color: #d54e21;
}
-.updated, .login #login_error, .login .message {
+.updated,
+.login #login_error,
+.login .message {
background-color: #ffffe0;
border-color: #e6db55;
}
-.updated a {
- border-bottom-color: #2583ad;
+a.page-numbers {
+ border-bottom-color: #B8D3E2;
}
-.widefat td, .widefat th, div#available-widgets-filter, ul#widget-list li.widget-list-item, .commentlist li {
+div#available-widgets-filter,
+ul#widget-list li.widget-list-item,
+.commentlist li {
border-bottom-color: #ccc;
}
-.widefat thead, .thead {
- background-color: #464646;
- color: #d7d7d7;
+.widefat td,
+.widefat th {
+ border-bottom-color: #BBD8E7;
}
-.widget-control-save, .widget-control-remove {
- background-color: #83b4d5;
- color: #246;
+.widefat th {
+ text-shadow: rgba(255,255,255,0.8) 0 1px 0;
}
-.wrap h2 {
- border-bottom-color: #dadada;
- color: #5a5a5a;
+.widefat thead tr th,
+.widefat tfoot tr th,
+h3.dashboard-widget-title,
+h3.dashboard-widget-title span,
+h3.dashboard-widget-title small,
+.find-box-head {
+ color: #333;
+ background: #dfdfdf url(../images/blue-grad.png) repeat-x scroll left top;
}
-#poststuff #edButtonPreview, #poststuff #edButtonHTML, #the-comment-list p.comment-author strong a, #media-upload a.del-link, #media-upload a.delete, a {
- color: #2e7ca0;
+h3.dashboard-widget-title small a {
+ color: #d7d7d7;
}
-#adminmenu a, .ui-tabs-nav a {
- color: #cfebf6;
+h3.dashboard-widget-title small a:hover {
+ color: #fff;
}
-#submenu a {
- color: #2782af
+#adminmenu a,
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML,
+#the-comment-list p.comment-author strong a,
+#media-upload a.del-link,
+#media-upload a.delete,
+.ui-tabs-nav a, a {
+ color: #1C6280;
}
+
/* Because we don't want visited on these links */
-#adminmenu a.current, #sidemenu a.current, body.press-this .ui-tabs-selected a, body.press-this .ui-tabs-selected a:hover {
+body.press-this .ui-tabs-selected a,
+body.press-this .ui-tabs-selected a:hover {
background-color: #fff;
- border-color: #07273e;
+ border-color: #c6d9e9;
border-bottom-color: #fff;
color: #d54e21;
- font-weight: bold;
}
-#adminmenu li a #awaiting-mod, #sidemenu li a #update-plugins {
- background-image: url(../images/comment-stalk-classic.gif);
-}
-
-#adminmenu li a #awaiting-mod span, #sidemenu li a #update-plugins span {
+#adminmenu #awaiting-mod,
+#adminmenu .update-plugins,
+#sidemenu a .update-plugins,
+#rightnow .reallynow,
+#plugin-information .action-button {
background-color: #d54e21;
color: #fff;
}
-#rightnow .reallynow {
- background-color: #114973;
+#adminmenu li a:hover #awaiting-mod,
+#adminmenu li a:hover .update-plugins,
+#sidemenu li a:hover .update-plugins {
+ background-color: #264761;
color: #fff;
}
+#adminmenu li.current a #awaiting-mod,
+#adminmenu li.current a .update-plugins,
+#adminmenu li.wp-has-current-submenu a .update-plugins,
+#adminmenu li.wp-has-current-submenu a .update-plugins {
+ background-color: #ddd;
+ color: #000;
+ text-shadow: none;
+ -moz-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px;
+ -khtml-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px;
+ -webkit-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px;
+ box-shadow: rgba(0,0,0,0.2) 0px -1px 0px;
+}
+
+#adminmenu li.current a:hover #awaiting-mod,
+#adminmenu li.current a:hover .update-plugins,
+#adminmenu li.wp-has-current-submenu a:hover #awaiting-mod,
+#adminmenu li.wp-has-current-submenu a:hover .update-plugins {
+ background-color: #264761;
+ color: #fff;
+}
-#adminmenu li a:hover #awaiting-mod span, #sidemenu li a:hover #update-plugins span {
- background-color: #07273E;
+div#media-upload-header {
+ background-color: #f9f9f9;
+ border-bottom-color: #dfdfdf;
}
-#adminmenu, div#media-upload-header {
- background-color: #14568a;
- border-bottom-color: #07273e;
+div#plugin-information-header {
+ background-color: #e4f2fd;
+ border-bottom-color: #c6d9e9;
}
#currenttheme img {
background-color: #f9f9f9;
}
-input.readonly {
+input.readonly, textarea.readonly {
background-color: #ddd;
}
-#dashmenu a.current {
- background-color: #14568a;
- color: #cfebf6;
-}
-
-#dragHelper h4.widget-title, li.widget-list-control-item h4, #dragHelper li.widget-list-control-item h4 {
+#dragHelper h4.widget-title,
+li.widget-list-control-item h4,
+#dragHelper li.widget-list-control-item h4 {
background-color: #2683ae;
color: #fff;
}
-#ed_toolbar input {
- background: url( ../images/fade-butt.png ) #fff repeat-x 0 -2px;
+#ed_toolbar input,
+#ed_reply_toolbar input {
+ background: #fff url("../images/fade-butt.png") repeat-x 0 -2px;
}
#editable-post-name {
background-color: #fffbcc;
}
-#edit-slug-box strong, .login #nav a {
+#edit-slug-box strong,
+.tablenav .displaying-num,
+#submitted-on {
color: #777;
}
-#edit-slug-buttons a.save {
- background-color: #ebebeb;
+.login #nav a {
+ color: #21759b !important;
+}
+
+.login #nav a:hover {
+ color: #d54e21 !important;
}
-#footer {
- background: url(../images/logo-ghost.png) #464646 no-repeat 20px 10px;
+#footer,
+#footer-upgrade {
+ background: #073447;
color: #999;
}
#media-items {
- border-color: #c0c0c0;
+ border-color: #dfdfdf;
}
#pass-strength-result {
- background-color: #e3e3e3;
- border-color: #000;
+ background-color: #eee;
+ border-color: #ddd !important;
}
#pass-strength-result.bad {
- background-color: #ffeff7;
- border-color: #c69;
+ background-color: #ffb78c;
+ border-color: #ff853c !important;
}
#pass-strength-result.good {
- background-color: #effff4;
- border-color: #66cc87;
+ background-color: #ffec8b;
+ border-color: #fc0 !important;
}
#pass-strength-result.short {
- background-color: #e3e3e3;
+ background-color: #ffa0a0;
+ border-color: #f04040 !important;
}
#pass-strength-result.strong {
- background-color: #59ef86;
- border-color: #319f52;
+ background-color: #c3ff88;
+ border-color: #8dff1c !important;
}
-.checkbox, .side-info, #your-profile #rich_editing {
+.checkbox,
+.side-info,
+#your-profile #rich_editing {
background-color: #fff;
}
-.plugins .active {
- background-color: #BBEEBB;
+.plugins .active,
+.plugins .active th,
+.plugins .active td {
+ background-color: #e7f7d3;
}
-.plugins .togl {
- border-right-color: #ccc;
+#the-comment-list .unapproved,
+#the-comment-list .unapproved th,
+#the-comment-list .unapproved td {
+ background-color: #ffffe0;
}
-#the-comment-list .unapproved {
- background-color: #ffffe0;
+#the-comment-list .approve a {
+ color: #006505;
+}
+
+#the-comment-list .unapprove a {
+ color: #d98500;
+}
+
+#the-comment-list .delete a {
+ color: #bc0b0b;
}
.plugins tr {
background-color: #fff;
}
-#poststuff #editor-toolbar .active {
- background-color: #83b4d5;
- color: #333;
+.metabox-holder .postbox,
+#poststuff .postbox,
+#titlediv,
+#poststuff .postarea,
+#poststuff .stuffbox,
+.postbox input[type="text"],
+.postbox textarea,
+.stuffbox input[type="text"],
+.stuffbox textarea {
+ border-color: #BBD8E7;
}
-#poststuff .closed .togbox {
- background-color: #2583ad;
- background-image: url(../images/toggle-arrow.gif);
+.metabox-holder .postbox,
+#poststuff .postbox {
+ background-color: #FFF;
}
-#poststuff .postbox, #titlediv, #poststuff .postarea, #poststuff .stuffbox {
- border-color: #ebebeb;
- border-right-color: #ccc;
- border-bottom-color: #ccc;
+.ui-sortable .postbox h3 {
+ color: #093E56;
+}
+
+.ui-sortable .postbox h3:hover {
+ color: #000;
}
-#poststuff .togbox {
- background-color: #b2b2b2;
- background-image: url(../images/toggle-arrow.gif);
+.curtime #timestamp {
+ background-image: url(../images/date-button.gif);
}
#quicktags #ed_link {
color: #448abd;
}
-#sidemenu a {
- background-color: #14568a;
- border-bottom-color: #07273e;
- border-top-color: #14568a;
- color: #cfebf6;
-}
-
-#tagchecklist span a {
+#tagchecklist span a,
+#bulk-titles div a {
background: url(../images/xit.gif) no-repeat;
}
-#tagchecklist span a:hover {
+#tagchecklist span a:hover,
+#bulk-titles div a:hover {
background: url(../images/xit.gif) no-repeat -10px 0;
}
-#the-comment-list .comment a {
- border-bottom-color: #ababab;
- color: #666;
-}
-
#update-nag, .plugin-update {
background-color: #fffeeb;
border-bottom-color: #ccc;
color: #555;
}
-#upload-files a.file-link {
- background-color: #d1e2ef;
+.login #backtoblog a {
+ color: #ccc;
}
-#upload-file-view a img {
- border-bottom-color: #69c;
+#wphead {
+ background-color: #073447;
}
-#upload-menu li #current-tab-nav, #upload-file {
- background-color: #f9fcfe;
+body.login {
+ border-top-color: #093E56;
}
-#upload-menu li span a.page-numbers {
- color: #00019b;
+#wphead h1 a {
+ color: #fff;
}
-#upload-menu li.current {
- border-right-color: #448abd;
- color: #000;
+#login form input {
+ color: #555;
}
-#upload-menu li.current a.upload-tab-link, #upload-menu li a:hover {
- background-color: #f9fcfe;
- color: #000;
+#wphead h1 a:hover {
+ text-decoration: underline;
}
-#upload-menu, #upload-menu li {
- border-top-color: #247fab;
+#user_info {
+ color: #999;
}
-#user_info, .login #backtoblog a {
+#user_info a:link, #user_info a:visited, #footer a:link, #footer a:visited {
color: #ccc;
+ text-decoration: none;
}
-#wphead {
- background-color: #14568a;
+#user_info a:hover, #footer a:hover {
+ color: #fff;
+ text-decoration: underline !important;
}
-#wphead, body.login {
- border-top-color: #07273e;
+#user_info a:active, #footer a:active {
+ color: #ccc !important;
}
-#wphead #viewsite a {
- background-color: #5488af;
- color: #cfebf7;
- border-color: #0b3d64;
+div#media-upload-error,
+.file-error,
+abbr.required,
+.widget-control-remove:hover,
+.delete a:hover {
+ color: #f00;
}
-#wphead #viewsite a:hover {
- color: #07273e;
+#media-upload a.delete {
+ color: #888;
}
-#wphead h1, #dashmenu a.current:hover {
- color: #cfebf6;
+/* editors */
+#quicktags {
+ border-color: #dfdfdf;
+ background-color: #dfdfdf;
}
-div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover, .delete:hover {
- color: #f00;
+#ed_toolbar input {
+ border-color: #C3C3C3;
+}
+
+#ed_toolbar input:hover {
+ border-color: #aaa;
+ background: #ddd;
+}
+
+#poststuff .wp_themeSkin .mceStatusbar {
+ border-color: #EDEDED;
+}
+
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML {
+ background-color: #f1f1f1;
+ border-color: #dfdfdf;
+ color: #999;
+}
+
+#poststuff #editor-toolbar .active {
+ border-bottom-color: #e9e9e9;
+ background-color: #e9e9e9;
+ color: #333;
}
/* TinyMCE */
+#post-status-info {
+ background-color: #EDEDED;
+}
+
.wp_themeSkin *,
-.wp_themeSkin a:hover,
-.wp_themeSkin a:link,
-.wp_themeSkin a:visited,
+.wp_themeSkin a:hover,
+.wp_themeSkin a:link,
+.wp_themeSkin a:visited,
.wp_themeSkin a:active {
color: #000;
}
/* Containers */
-.wp_themeSkin table, #wp_editbtns {
- background: #83B4D5;
-}
-
.wp_themeSkin iframe {
background: #fff;
}
/* Layout */
.wp_themeSkin .mceStatusbar {
- color:#000;
- background-color: #eaf3fa;
+ color: #000;
+ background-color: #f5f5f5;
}
/* Button */
-.wp_themeSkin .mceButton {
+.wp_themeSkin .mceButton {
background-color: #e9e8e8;
- border-color: #83B4D5;
+ border-color: #B2B2B2;
}
.wp_themeSkin a.mceButtonEnabled:hover,
-.wp_themeSkin a.mceButtonActive,
+.wp_themeSkin a.mceButtonActive,
.wp_themeSkin a.mceButtonSelected {
- background-color: #d6d8da;
- border-color: #7789ba !important;
+ background-color: #d5d5d5;
+ border-color: #777 !important;
}
.wp_themeSkin .mceButtonDisabled {
- border-color: #83B4D5 !important;
+ border-color: #ccc !important;
}
/* ListBox */
.wp_themeSkin .mceListBox .mceText,
.wp_themeSkin .mceListBox .mceOpen {
- border-color: #83B4D5;
- background-color: #e9e8e8;
+ border-color: #B2B2B2;
+ background-color: #d5d5d5;
}
-.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen,
+.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen,
.wp_themeSkin .mceListBoxHover .mceOpen,
.wp_themeSkin .mceListBoxSelected .mceOpen,
.wp_themeSkin .mceListBoxSelected .mceText {
- border-color: #7789ba !important;
- background-color: #d6d8da;
+ border-color: #777 !important;
+ background-color: #d5d5d5;
}
-.wp_themeSkin table.mceListBoxEnabled:hover .mceText,
+.wp_themeSkin table.mceListBoxEnabled:hover .mceText,
.wp_themeSkin .mceListBoxHover .mceText {
- border-color: #7789ba !important;
+ border-color: #777 !important;
}
.wp_themeSkin select.mceListBox {
- border-color: #b3c7e1;
+ border-color: #B2B2B2;
background-color: #fff;
}
/* SplitButton */
-.wp_themeSkin .mceSplitButton a.mceAction,
+.wp_themeSkin .mceSplitButton a.mceAction,
.wp_themeSkin .mceSplitButton a.mceOpen {
- background-color: #e9e8e8;
- border-color: #83B4D5;
+ background-color: #e8e8e8;
+ border-color: #B2B2B2;
}
.wp_themeSkin .mceSplitButton a.mceOpen:hover,
.wp_themeSkin .mceSplitButtonSelected a.mceOpen,
.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction,
.wp_themeSkin .mceSplitButton a.mceAction:hover {
- background-color: #d6d8da;
- border-color: #7789ba !important;
-}
+ background-color: #d5d5d5;
+ border-color: #777 !important;
+}
.wp_themeSkin .mceSplitButtonActive {
- background-color: #d6d8da;
+ background-color: #B2B2B2;
}
/* ColorSplitButton */
.wp_themeSkin div.mceColorSplitMenu table {
- background-color: #ebeaeb;
- border-color: #808080;
+ background-color: #ebebeb;
+ border-color: #B2B2B2;
}
.wp_themeSkin .mceColorSplitMenu a {
- border-color: #808080;
+ border-color: #B2B2B2;
}
.wp_themeSkin .mceColorSplitMenu a.mceMoreColors {
}
.wp_themeSkin .mceMenu .mceText {
- color: #000;
+ color: #000;
}
.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover,
-.wp_themeSkin .mceMenu .mceMenuItemActive, #quicktags {
- background-color: #83B4D5;
+.wp_themeSkin .mceMenu .mceMenuItemActive {
+ background-color: #f5f5f5;
}
.wp_themeSkin td.mceMenuItemSeparator {
background-color: #aaa;
}
.wp_themeSkin .mceMenuItemTitle a {
- background-color: #ccc;
+ background-color: #ccc;
border-bottom-color: #aaa;
}
.wp_themeSkin .mceMenuItemTitle span.mceText {
color: #888;
}
-/* pop-up */
-.clearlooks2 .mceTop .mceLeft, .clearlooks2 .mceTop .mceRight {
- background-color: #cee1ef;
- border-color: #c6d9e9;
+.wp_themeSkin tr.mceFirst td.mceToolbar {
+ background-color: #dfdfdf;
+ border-color: #dfdfdf;
}
-.clearlooks2 .mceFocus .mceTop .mceLeft, .clearlooks2 .mceFocus .mceTop .mceRight {
- background-color: #5488AF;
- border-color: #464646;
+.wp-admin #mceModalBlocker {
+ background: #000;
}
-#editorcontainer {
- border-color: #ccc;
+.wp-admin .clearlooks2 .mceFocus .mceTop .mceLeft {
+ background: #444444;
+ border-left: 1px solid #999;
+ border-top: 1px solid #999;
+ -moz-border-radius: 4px 0 0 0;
+ -webkit-border-top-left-radius: 4px;
+ -khtml-border-top-left-radius: 4px;
+ border-top-left-radius: 4px;
}
-#poststuff #titlewrap {
- border-color: #ccc;
+.wp-admin .clearlooks2 .mceFocus .mceTop .mceRight {
+ background: #444444;
+ border-right: 1px solid #999;
+ border-top: 1px solid #999;
+ border-top-right-radius: 4px;
+ -khtml-border-top-right-radius: 4px;
+ -webkit-border-top-right-radius: 4px;
+ -moz-border-radius: 0 4px 0 0;
+}
+
+.wp-admin .clearlooks2 .mceMiddle .mceLeft {
+ background: #f1f1f1;
+ border-left: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceMiddle .mceRight {
+ background: #f1f1f1;
+ border-right: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom {
+ background: #f1f1f1;
+ border-bottom: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceLeft {
+ background: #f1f1f1;
+ border-bottom: 1px solid #999;
+ border-left: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceCenter {
+ background: #f1f1f1;
+ border-bottom: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceRight {
+ background: #f1f1f1;
+ border-bottom: 1px solid #999;
+ border-right: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceFocus .mceTop span {
+ color: #e5e5e5;
+}
+/* end TinyMCE */
+
+#editorcontainer,
+#post-status-info,
+#titlediv #title {
+ border-color: #dfdfdf;
+}
+
+#titlediv #title {
+ background-color: #fff;
}
#tTips p#tTips_inside {
color: #333;
}
-/* Diff */
+#timestampdiv input,
+#namediv input,
+#tagsdiv #the-tagcloud {
+ border-color: #ddd;
+}
+
+/* menu */
+#adminmenu * {
+ border-color: #BBD8E7;
+}
+
+#adminmenu li.wp-menu-separator {
+ background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;
+}
+
+.folded #adminmenu li.wp-menu-separator {
+ background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;
+}
+
+#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,
+#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+ background: transparent url(../images/menu-bits.gif) no-repeat scroll left -207px;
+}
+
+#adminmenu .wp-has-submenu:hover .wp-menu-toggle,
+#adminmenu .wp-menu-open .wp-menu-toggle {
+ background: transparent url(../images/menu-bits.gif) no-repeat scroll left -109px;
+}
+
+#adminmenu a.menu-top {
+ background: #EAF3FA url(../images/menu-bits.gif) repeat-x scroll left -379px;
+}
+
+#adminmenu .wp-submenu a {
+ background: #FFFFFF url(../images/menu-bits.gif) no-repeat scroll 0 -310px;
+}
+
+#adminmenu .wp-has-current-submenu ul li a {
+ background: none;
+}
+
+#adminmenu .wp-has-current-submenu ul li a.current {
+ background: url(../images/menu-dark.gif) top left no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
+#adminmenu .menu-top .current {
+ background: #6d6d6d url(../images/menu-bits.gif) top left repeat-x;
+ border-color: #6d6d6d;
+ color: #fff;
+ text-shadow: rgba(0,0,0,0.4) 0px -1px 0px;
+}
+
+#adminmenu li.wp-has-current-submenu .wp-submenu,
+#adminmenu li.wp-has-current-submenu ul li a {
+ border-color: #aaa !important;
+}
+
+#adminmenu li.wp-has-current-submenu ul li a {
+ background: url(../images/menu-dark.gif) bottom left no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu ul {
+ border-bottom-color: #aaa;
+}
+
+#adminmenu li.menu-top .current:hover {
+ border-color: #B5B5B5;
+}
+
+#adminmenu .wp-submenu .current a.current {
+ background: transparent url(../images/menu-bits.gif) no-repeat scroll 0 -289px;
+}
+
+#adminmenu .wp-submenu a:hover {
+ background-color: #EAF2FA !important;
+ color: #333 !important;
+}
+
+#adminmenu .wp-submenu li.current,
+#adminmenu .wp-submenu li.current a,
+#adminmenu .wp-submenu li.current a:hover {
+ color: #333;
+ background-color: #f5f5f5;
+ background-image: none;
+ border-color: #e3e3e3;
+ text-shadow: rgba(255,255,255,1) 0px 1px 0px;
+}
+
+#adminmenu .wp-submenu ul {
+ background-color: #fff;
+}
+
+.folded #adminmenu li.menu-top,
+#adminmenu .wp-submenu .wp-submenu-head {
+ background-color: #EAF2FA;
+}
+
+.folded #adminmenu li.wp-has-current-submenu,
+.folded #adminmenu li.menu-top.current {
+ background-color: #BBD8E7;
+}
+
+#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head {
+ background-color: #BBD8E7;
+ border-color: #8CBDD5;
+}
+
+#adminmenu div.wp-submenu {
+ background-color: transparent;
+}
+
+/* menu icons */
+#adminmenu #menu-dashboard div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -61px -33px;
+}
+
+#adminmenu #menu-dashboard:hover div.wp-menu-image,
+#adminmenu #menu-dashboard.wp-has-current-submenu div.wp-menu-image,
+#adminmenu #menu-dashboard.current div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -61px -1px;
+}
+
+#adminmenu #menu-posts div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -272px -33px;
+}
+
+#adminmenu #menu-posts:hover div.wp-menu-image,
+#adminmenu #menu-posts.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -272px -1px;
+}
+
+#adminmenu #menu-media div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -121px -33px;
+}
+
+#adminmenu #menu-media:hover div.wp-menu-image,
+#adminmenu #menu-media.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -121px -1px;
+}
+
+#adminmenu #menu-links div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -91px -33px;
+}
+
+#adminmenu #menu-links:hover div.wp-menu-image,
+#adminmenu #menu-links.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -91px -1px;
+}
+
+#adminmenu #menu-pages div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -151px -33px;
+}
+
+#adminmenu #menu-pages:hover div.wp-menu-image,
+#adminmenu #menu-pages.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -151px -1px;
+}
+
+#adminmenu #menu-comments div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -31px -33px;
+}
+
+#adminmenu #menu-comments:hover div.wp-menu-image,
+#adminmenu #menu-comments.wp-has-current-submenu div.wp-menu-image,
+#adminmenu #menu-comments.current div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -31px -1px;
+}
+
+#adminmenu #menu-appearance div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -1px -33px;
+}
+
+#adminmenu #menu-appearance:hover div.wp-menu-image,
+#adminmenu #menu-appearance.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -1px -1px;
+}
+
+#adminmenu #menu-plugins div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -181px -33px;
+}
+
+#adminmenu #menu-plugins:hover div.wp-menu-image,
+#adminmenu #menu-plugins.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -181px -1px;
+}
+
+#adminmenu #menu-users div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -301px -33px;
+}
+
+#adminmenu #menu-users:hover div.wp-menu-image,
+#adminmenu #menu-users.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -301px -1px;
+}
+
+#adminmenu #menu-tools div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -211px -33px;
+}
+
+#adminmenu #menu-tools:hover div.wp-menu-image,
+#adminmenu #menu-tools.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -211px -1px;
+}
+
+#adminmenu #menu-settings div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -241px -33px;
+}
+
+#adminmenu #menu-settings:hover div.wp-menu-image,
+#adminmenu #menu-settings.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu-vs.png") no-repeat scroll -241px -1px;
+}
+/* end menu */
+
+/* Diff */
table.diff .diff-deletedline {
background-color: #ffdddd;
}
table.diff .diff-addedline ins {
background-color: #99ff99;
}
+
+#att-info {
+ background-color: #E4F2FD;
+}
+
+/* edit image */
+#sidemenu a {
+ background-color: #f9f9f9;
+ border-color: #f9f9f9;
+ border-bottom-color: #dfdfdf;
+}
+
+#sidemenu a.current {
+ background-color: #fff;
+ border-color: #dfdfdf #dfdfdf #fff;
+ color: #D54E21;
+}
+
+
+#screen-options-wrap,
+#contextual-help-wrap {
+ background-color: #f1f1f1;
+ border-color: #dfdfdf;
+}
+
+#screen-meta-links a.show-settings {
+ color: #606060;
+}
+
+#screen-meta-links a.show-settings:hover {
+ color: #000;
+}
+
+#replysubmit {
+ background-color: #f1f1f1;
+ border-top-color: #ddd;
+}
+
+#replyerror {
+ border-color: #ddd;
+ background-color: #f9f9f9;
+}
+
+#edithead,
+#replyhead {
+ background-color: #f1f1f1;
+}
+
+#ed_reply_toolbar {
+ background-color: #e9e9e9;
+}
+
+/* table vim shortcuts */
+.vim-current {
+ background-color: #E4F2FD !important;
+}
+
+/* Install Plugins */
+.star-average,
+.star.star-rating {
+ background-color: #fc0;
+}
+
+div.star.select:hover {
+ background-color: #d00;
+}
+
+#plugin-information .fyi ul {
+ background-color: #eaf3fa;
+}
+
+#plugin-information .fyi h2.mainheader {
+ background-color: #cee1ef;
+}
+
+#plugin-information pre,
+#plugin-information code {
+ background-color: #ededff;
+}
+
+#plugin-information pre {
+ border: 1px solid #ccc;
+}
+
+/* inline editor */
+.inline-edit-row fieldset input[type="text"],
+.inline-edit-row fieldset textarea,
+#bulk-titles,
+#replyrow input {
+ border-color: #ddd;
+}
+
+.inline-editor div.title {
+ background-color: #EAF3FA;
+}
+
+.inline-editor ul.cat-checklist {
+ background-color: #FFFFFF;
+ border-color: #ddd;
+}
+
+.inline-edit-row p.submit {
+ background-color: #f1f1f1;
+}
+
+.inline-editor .categories .catshow,
+.inline-editor .categories .cathide {
+ color: #21759b;
+}
+
+.inline-editor .quick-edit-save {
+ background-color: #f1f1f1;
+}
+
+#replyrow #ed_reply_toolbar input:hover {
+ border-color: #aaa;
+ background: #ddd;
+}
+
+fieldset.inline-edit-col-right .inline-edit-col {
+ border-color: #dfdfdf;
+}
+
+.attention {
+ color: #D54E21;
+}
+
+.meta-box-sortables .postbox:hover .handlediv {
+ background: transparent url(../images/menu-bits.gif) no-repeat scroll left -111px;
+}
+
+#major-publishing-actions {
+ background: #eaf2fa;
+}
+
+.tablenav .tablenav-pages {
+ color: #555;
+}
+
+.tablenav .tablenav-pages a {
+ border-color: #e3e3e3;
+ background: #eee url('../images/menu-bits.gif') repeat-x scroll left -379px;
+}
+
+.tablenav .tablenav-pages a:hover {
+ color: #d54e21;
+ border-color: #d54321;
+}
+
+.tablenav .tablenav-pages a:active {
+ color: #fff !important;
+}
+
+.tablenav .tablenav-pages .current {
+ background: #dfdfdf;
+ border-color: #d3d3d3;
+}
+
+#availablethemes,
+#availablethemes td {
+ border-color: #ddd;
+}
+
+#current-theme img {
+ border-color: #999;
+}
+
+#TB_window #TB_title a.tb-theme-preview-link,
+#TB_window #TB_title a.tb-theme-preview-link:visited {
+ color: #999;
+}
+
+#TB_window #TB_title a.tb-theme-preview-link:hover,
+#TB_window #TB_title a.tb-theme-preview-link:focus {
+ color: #ccc;
+}
+
+.misc-pub-section {
+ border-bottom-color: #eee;
+}
+
+#minor-publishing {
+ border-bottom-color: #ddd;
+}
+
+#post-body .misc-pub-section {
+ border-right-color: #eee;
+}
+
+.post-com-count span {
+ background-color: #bbb;
+}
+
+.form-table .color-palette td {
+ border-color: #fff;
+}
+
+.sortable-placeholder {
+ border-color: #bbb;
+ background-color: #f5f5f5;
+}
+
+#post-body ul#category-tabs li.ui-tabs-selected a {
+ color: #333;
+}
+
+#wp_editimgbtn,
+#wp_delimgbtn,
+#wp_editgallery,
+#wp_delgallery {
+ border-color: #999;
+ background-color: #eee;
+}
+
+#wp_editimgbtn:hover,
+#wp_delimgbtn:hover,
+#wp_editgallery:hover,
+#wp_delgallery:hover {
+ border-color: #555;
+ background-color: #ccc;
+}
+
+#favorite-first {
+ background: #797979 url(../images/fav.png) repeat-x 0 center;
+ border-color: #777 !important;
+ border-bottom-color: #666 !important;
+}
+
+#favorite-inside {
+ border-color: #797979;
+ background-color: #797979;
+}
+
+#favorite-toggle {
+ background: transparent url(../images/fav-arrow.gif) no-repeat 0 -4px;
+}
+
+#favorite-actions a {
+ color: #ddd;
+}
+
+#favorite-actions a:hover {
+ color: #fff;
+}
+
+#favorite-inside a:hover {
+ text-decoration: underline;
+}
+
+#favorite-actions .slide-down {
+ border-bottom-color: #626262;
+}
+
+.submit input,
+.button,
+.button-primary,
+.button-secondary,
+.button-highlighted,
+#postcustomstuff .submit input {
+ text-shadow: rgba(255,255,255,1) 0 1px 0;
+}
+
+.button-primary,
+.submit .button-primary {
+ text-shadow: rgba(0,0,0,0.3) 0 -1px 0;
+}
+
+#screen-meta a.show-settings {
+ background-color: transparent;
+ text-shadow: rgba(255,255,255,0.7) 0 1px 0;
+}
+
+#icon-edit,
+#icon-post {
+ background: transparent url(../images/icons32-vs.png) no-repeat -552px -5px;
+}
+
+#icon-index {
+ background: transparent url(../images/icons32-vs.png) no-repeat -137px -5px;
+}
+
+#icon-upload {
+ background: transparent url(../images/icons32-vs.png) no-repeat -251px -5px;
+}
+
+#icon-link-manager,
+#icon-link,
+#icon-link-category {
+ background: transparent url(../images/icons32-vs.png) no-repeat -190px -5px;
+}
+
+#icon-edit-pages,
+#icon-page {
+ background: transparent url(../images/icons32-vs.png) no-repeat -312px -5px;
+}
+
+#icon-edit-comments {
+ background: transparent url(../images/icons32-vs.png) no-repeat -72px -5px;
+}
+
+#icon-themes {
+ background: transparent url(../images/icons32-vs.png) no-repeat -11px -5px;
+}
+
+#icon-plugins {
+ background: transparent url(../images/icons32-vs.png) no-repeat -370px -5px;
+}
+
+#icon-users,
+#icon-user-edit {
+ background: transparent url(../images/icons32-vs.png) no-repeat -600px -5px;
+}
+
+#icon-tools,
+#icon-admin {
+ background: transparent url(../images/icons32-vs.png) no-repeat -432px -5px;
+}
+
+#icon-options-general {
+ background: transparent url(../images/icons32-vs.png) no-repeat -492px -5px;
+}
+
+.view-switch #view-switch-list {
+ background: transparent url(../images/list-vs.png) no-repeat 0 0;
+}
+
+.view-switch #view-switch-list.current {
+ background: transparent url(../images/list-vs.png) no-repeat -40px 0;
+}
+
+.view-switch #view-switch-excerpt {
+ background: transparent url(../images/list-vs.png) no-repeat -20px 0;
+}
+
+.view-switch #view-switch-excerpt.current {
+ background: transparent url(../images/list-vs.png) no-repeat -60px 0;
+}
+
+#header-logo {
+ background: transparent url(../images/wp-logo.gif) no-repeat scroll center center;
+}
border-right-color: transparent;
border-left-color: #99d;
}
-.post-com-count {
-}
-#adminmenu li a #awaiting-mod, #sidemenu li a #update-plugins {
- background-image: url(../images/comment-stalk-rtl.gif);
- background-position:right bottom;
-}
-#footer {
- background-position:99% 10px;
-}
+
.plugins .togl {
border-right-color: transparent;
border-left-color: #ccc;
}
-#poststuff .closed .togbox, #poststuff .togbox {
- background-image: url(../images/toggle-arrow-rtl.gif);
+
+.post-com-count {
+ background-image: url(../images/bubble_bg-rtl.gif);
+}
+.tablenav .tablenav-pages a {
+ background: #eee url('../images/menu-bits-rtl.gif') repeat-x scroll right -379px;
}
#upload-menu li.current {
- border-right-color:transparent;
+ border-right-color: transparent;
border-left-color: #448abd;
}
+
+#adminmenu .wp-submenu .current a.current {
+ background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -289px;
+}
+
+#adminmenu li.wp-menu-separator {
+ background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;
+}
+
+.folded #adminmenu li.wp-menu-separator {
+ background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;
+}
+
+#adminmenu li.wp-has-current-submenu .wp-menu-toggle,
+#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+ background: transparent url(../images/menu-bits-rtl.gif) repeat-x scroll right -207px;
+}
+
+#adminmenu .wp-has-current-submenu ul li a.current {
+ background: url(../images/menu-dark-rtl.gif) top right no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
+#adminmenu .menu-top .current {
+ background: url(../images/menu-bits-rtl.gif) top right repeat-x;
+}
+
+#adminmenu li.wp-has-current-submenu ul li a {
+ background: url(../images/menu-dark-rtl.gif) bottom right no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle, #adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+ background: transparent url(../images/menu-bits-rtl.gif) no-repeat right -207px;
+}
+
+#adminmenu .wp-has-submenu:hover .wp-menu-toggle,
+#adminmenu .wp-menu-open .wp-menu-toggle {
+ background: transparent url(../images/menu-bits-rtl.gif) repeat-x scroll right -109px;
+}
+
+#adminmenu a.wp-has-submenu {
+ background: #f1f1f1 url(../images/menu-bits-rtl.gif) repeat-x scroll right -379px;
+}
+
+#adminmenu .wp-submenu a {
+ background: #FFFFFF url(../images/menu-bits-rtl.gif) no-repeat scroll right -310px;
+}
+
+#adminmenu li.current a,
+#adminmenu .wp-submenu a:hover {
+ background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -289px;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-submenu {
+ background: #b5b5b5 url(../images/menu-bits-rtl.gif) repeat-x scroll right top;
+}
+
+.meta-box-sortables .postbox:hover .handlediv {
+ background: transparent url(../images/menu-bits-rtl.gif) no-repeat scroll right -111px;
+}
+#favorite-toggle {
+ background: transparent url(../images/fav-arrow-rtl.gif) no-repeat right -4px;
+}
+html {
+ background-color: #f9f9f9;
+}
+
+.find-box-search {
+ border-color: #dfdfdf;
+ background-color: #f1f1f1;
+}
+
+.find-box {
+ background-color: #f1f1f1;
+}
+
+.find-box-inside {
+ background-color: #fff;
+}
+
a.page-numbers:hover {
border-color: #999;
}
-body, .form-table .pre {
- background-color: #fff;
+body,
+#wpbody,
+.form-table .pre {
color: #333;
}
border-bottom-color: #fff;
}
-div#current-widgets, #postcustomstuff table, #your-profile fieldset, a.page-numbers, #rightnow, div.dashboard-widget, .widefat {
+kbd, code {
+ background: #eaeaea;
+}
+
+div#current-widgets,
+#postcustomstuff table,
+#your-profile fieldset,
+#rightnow,
+div.dashboard-widget,
+#dashboard-widgets p.dashboard-widget-links,
+#replyrow #ed_reply_toolbar input {
border-color: #ccc;
}
+#poststuff .inside label.spam {
+ color: red;
+}
+
+#poststuff .inside label.waiting {
+ color: orange;
+}
+
+#poststuff .inside label.approved {
+ color: green;
+}
+
+#postcustomstuff table {
+ border-color: #dfdfdf;
+ background-color: #F9F9F9;
+}
+
+#postcustomstuff thead th {
+ background-color: #F1F1F1;
+}
+
+#postcustomstuff table input,
+#postcustomstuff table textarea {
+ border-color: #dfdfdf;
+ background-color: #fff;
+}
+
+.widefat {
+ border-color: #dfdfdf;
+ background-color: #fff;
+}
+
div.dashboard-widget-error {
background-color: #c43;
}
background-color: #cfe1ef;
}
-div.dashboard-widget-submit, ul.widget-control-list div.widget-control-actions {
+div.dashboard-widget-submit,
+ul.widget-control-list div.widget-control-actions {
border-top-color: #ccc;
}
div.ui-tabs-panel {
- border-color: #cee1ef;
+ border-color: #f1f1f1;
}
-input.disabled, textarea.disabled {
- background-color: #ccc;
+ul#category-tabs li.ui-tabs-selected {
+ background-color: #f1f1f1;
}
-#user_info a:hover, li.widget-list-control-item h4.widget-title a:hover, .submit a, #dashmenu a:hover, #footer a, #upload-menu li a.upload-tab-link, li.widget-list-control-item h4.widget-title a,
+input.disabled,
+textarea.disabled {
+ background-color: #ccc;
+}
+/* #upload-menu li a.upload-tab-link, */
+li.widget-list-control-item h4.widget-title a:hover,
+li.widget-list-control-item h4.widget-title a,
#dragHelper li.widget-list-control-item h4.widget-title a,
-#draghelper li.widget-list-control-item h4.widget-title a:visited, .login #backtoblog a:hover {
+#draghelper li.widget-list-control-item h4.widget-title a:visited,
+.login #backtoblog a:hover,
+#plugin-information .action-button a,
+#plugin-information .action-button a:hover,
+#plugin-information .action-button a:visited {
color: #fff;
}
-li.widget-list-control-item, div.nav, .tablenav, .submitbox, h3.dashboard-widget-title, h3.dashboard-widget-title span, h3.dashboard-widget-title small, ul.view-switch li.current, .form-table tr, #poststuff h3, .login form, h3.info-box-title {
- background-color: #eaf3fa;
+li.widget-list-control-item div.widget-control {
+ background-color: #fff;
+ border-color: #dfdfdf;
+}
+
+.metabox-holder .postbox h3,
+#poststuff .postbox h3,
+#poststuff .stuffbox h3 {
+ background: #dfdfdf url("../images/gray-grad.png") repeat-x left top;
+ text-shadow: #fff 0 1px 0;
+}
+
+.form-table th,
+.form-wrap label {
+ color: #222;
+ text-shadow: #fff 0 1px 0;
+}
+
+.setting-description, .form-wrap p {
+ color: #666;
}
select {
}
strong .post-com-count span {
- background-color: #2583ad;
-}
-
-ul#category-tabs li.ui-tabs-selected, .button-secondary, #quicktags, #login form .submit input {
- background-color: #cee1ef !important;
+ background-color: #21759b;
}
ul#widget-list li.widget-list-item h4.widget-title {
background-color: #ccf3fa;
}
-.ac_match, .subsubsub a.current, h2 {
+.ac_match, .subsubsub a.current {
color: #000;
}
+.wrap h2 {
+ color: #464646;
+}
+
.ac_over {
background-color: #f0f0b8;
}
color: #101010;
}
-.alternate {
+.alternate, .alt {
background-color: #f9f9f9;
}
.available-theme a.screenshot {
background-color: #f1f1f1;
- border-color: #ccc;
+ border-color: #ddd;
}
.bar {
border-right-color: #99d;
}
-.describe {
- border-top-color: #d0d0d0;
+#media-upload {
+ background: #fff;
+}
+#media-upload .slidetoggle {
+ border-top-color: #dfdfdf;
}
.error, #login #login_error {
border-color: #c00 !important;
}
-.form-table input, .form-table textarea {
- border-color: #c6d9e9;
-}
-
-.form-table td, .form-table th {
- border-bottom-color: #fff;
+.form-table input,
+.form-table textarea,
+.search-input,
+.form-field input,
+.form-field textarea,
+.submit {
+ border-color: #DFDFDF;
}
.highlight {
color: #d54e21;
}
-#user_info, .howto, .nonessential, #dashmenu a, #sidemenu, #edit-slug-box, .form-input-tip, #dashboard_primary span.rss-date, .subsubsub, #dashboard_secondary div.dashboard-widget-content ul li a cite {
- color: #999;
+.howto,
+.nonessential,
+#edit-slug-box,
+.form-input-tip,
+.rss-widget span.rss-date,
+.subsubsub {
+ color: #666;
}
.media-item {
- border-bottom-color: #d0d0d0;
+ border-bottom-color: #dfdfdf;
}
-.media-upload-form label.form-help, td.help {
- color: #9a9a9a;
+#wpbody-content #media-items .describe {
+ border-top-color: #dfdfdf;
}
-.page-numbers {
- background-color: #fff;
- border-color: #fff;
+.describe input[type="text"],
+.describe textarea {
+ border-color: #dfdfdf;
}
-.page-numbers.current {
- background-color: #328ab2;
- border-color: #328ab2;
- color: #fff;
+.media-upload-form label.form-help,
+td.help {
+ color: #9a9a9a;
}
.post-com-count {
color: #666;
}
-.submit input, .button, .button-secondary, #login form .submit input, div.dashboard-widget-submit input, #edit-slug-buttons a.save {
- background-color: #e5e5e5;
- color: #246;
- border-color: #80b5d0;
+.button,
+.button-secondary,
+.submit input,
+input[type=button],
+input[type=submit] {
+ border-color: #bbb;
+ color: #464646;
+}
+
+.button:hover,
+.button-secondary:hover,
+.submit input:hover,
+input[type=button]:hover,
+input[type=submit]:hover {
+ color: #000;
+ border-color: #666;
+}
+
+.button,
+.submit input,
+.button-secondary {
+ background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;
+}
+
+.button:active,
+.submit input:active,
+.button-secondary:active {
+ background: #eee url(../images/white-grad-active.png) repeat-x scroll left top;
+}
+
+.button-primary,
+.submit .button-primary,
+#login form .submit input {
+ border-color: #298cba !important;
+ font-weight: bold;
+ color: #FFF !important;
+ background: #21759B url(../images/button-grad.png) repeat-x scroll left top;
+}
+
+.button-primary:active,
+#login form .submit input:active {
+ background: #21759b url(../images/button-grad-active.png) repeat-x scroll left top !important;
}
-.button[disabled], .button:disabled {
- background-color: #999;
+.button[disabled],
+.button:disabled,
+.button-secondary[disabled],
+.button-secondary:disabled,
+a.button.disabled {
+ color: #ccc !important;
+ border-color: #ccc;
}
-.submit input:hover, .button:hover, #edit-slug-buttons a.save:hover {
- border-color: #535353;
+.button-primary[disabled],
+.button-primary:disabled {
+ color: #2fa0d5 !important;
}
-.submit input:hover, .button:hover, .button-secondary:hover, #wphead #viewsite a:hover, #adminmenu a:hover, #sidemenu a:hover, #submenu a.current, #submenu a:hover, .submitbox #previewview a:hover, #the-comment-list .comment a:hover, #rightnow a:hover, a:hover, .subsubsub a:hover, .subsubsub a.current:hover, #login form .submit input:hover, div.dashboard-widget-submit input:hover, #edit-slug-buttons a.save:hover, #media-upload a.delete:hover, #media-upload a.del-link:hover, .ui-tabs-nav a:hover {
+a:active,
+a:focus {
color: #d54e21;
}
-.button-secondary:hover, #login form .submit input:hover {
- border-color: #328ab2;
+a:hover,
+#wphead #viewsite a:hover,
+#adminmenu a:hover,
+#adminmenu ul.wp-submenu a:hover,
+#the-comment-list .comment a:hover,
+#rightnow a:hover,
+.subsubsub a:hover,
+.subsubsub a.current:hover,
+#login form .submit input:hover,
+div.dashboard-widget-submit input:hover,
+#media-upload a.del-link:hover,
+.ui-tabs-nav a:hover {
+ color: #d54e21;
}
-.submitbox #autosave .error, ul.view-switch li.current a {
- color: #333;
+#the-comment-list .comment-item,
+#dashboard-widgets #dashboard_quick_press form p.submit {
+ border-color: #dfdfdf;
}
-.submitbox #previewview {
- background-color: #2683ae;
+.button-primary:hover,
+#login form .submit input:hover {
+ border-color: #13455b !important;
+ color: #EAF2FA !important;
+}
+
+#side-info-column #category-tabs .ui-tabs-selected a {
+ color: #333;
}
-.submitbox #previewview a, #rightnow .rbutton {
+#rightnow .rbutton {
background-color: #ebebeb;
color: #264761;
}
color: #ccc;
}
-.submitbox .submitdelete {
- border-bottom-color: #999;
+.submitbox .submitdelete, a.delete {
+ color: #f00;
+ border-bottom-color: #f00;
}
.submitbox .submitdelete:hover,
border-bottom-color: #f00;
}
+#normal-sortables .submitbox .submitdelete:hover {
+ color: #000;
+ background-color: #f00;
+ border-bottom-color: #f00;
+}
+
.tablenav .dots {
- background-color: #e4f2fd;
- border-color: #e4f2fd;
+ border-color: transparent;
}
-.tablenav .next, .tablenav .prev{
- background-color: #e4f2fd;
- border-bottom-color: #2583ad;
- border-color: #e4f2fd;
- color: #2583ad;
+.tablenav .next,
+.tablenav .prev {
+ border-color: transparent;
+ color: #21759b;
}
-.tablenav .next:hover, .tablenav .prev:hover {
- border-bottom-color: #d54e21;
- border-color: #e4f2fd;
+.tablenav .next:hover,
+.tablenav .prev:hover {
+ border-color: transparent;
color: #d54e21;
}
-.updated, .login #login_error, .login .message {
+.updated,
+.login #login_error,
+.login .message {
background-color: #ffffe0;
border-color: #e6db55;
}
-.updated a {
- border-bottom-color: #2583ad;
+a.page-numbers {
+ border-bottom-color: #B8D3E2;
}
-.widefat td, .widefat th, div#available-widgets-filter, ul#widget-list li.widget-list-item, .commentlist li {
+div#available-widgets-filter,
+ul#widget-list li.widget-list-item,
+.commentlist li {
border-bottom-color: #ccc;
}
-.widefat thead, .thead {
- background-color: #464646;
- color: #d7d7d7;
+.widefat td,
+.widefat th {
+ border-color: #dfdfdf;
}
-.widget-control-save, .widget-control-remove {
- background-color: #cee1ef;
- color: #246;
+.widefat th {
+ text-shadow: rgba(255,255,255,0.8) 0 1px 0;
}
-.wrap h2 {
- border-bottom-color: #dadada;
- color: #666;
+.widefat thead tr th,
+.widefat tfoot tr th,
+h3.dashboard-widget-title,
+h3.dashboard-widget-title span,
+h3.dashboard-widget-title small,
+.find-box-head {
+ color: #333;
+ background: #dfdfdf url(../images/gray-grad.png) repeat-x scroll left top;
}
-#adminmenu a, #submenu a, #poststuff #edButtonPreview, #poststuff #edButtonHTML, #the-comment-list p.comment-author strong a, #media-upload a.del-link, #media-upload a.delete, .ui-tabs-nav a, a {
- color: #2583ad;
+h3.dashboard-widget-title small a {
+ color: #d7d7d7;
+}
+
+h3.dashboard-widget-title small a:hover {
+ color: #fff;
+}
+
+#adminmenu a,
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML,
+#the-comment-list p.comment-author strong a,
+#media-upload a.del-link,
+#media-upload a.delete,
+.ui-tabs-nav a, a {
+ color: #21759b;
}
/* Because we don't want visited on these links */
-#adminmenu a.current, #sidemenu a.current, body.press-this .ui-tabs-selected a, body.press-this .ui-tabs-selected a:hover {
+body.press-this .ui-tabs-selected a,
+body.press-this .ui-tabs-selected a:hover {
background-color: #fff;
border-color: #c6d9e9;
border-bottom-color: #fff;
color: #d54e21;
}
-#adminmenu li a #awaiting-mod, #sidemenu li a #update-plugins {
- background-image: url(../images/comment-stalk-fresh.gif);
+#adminmenu #awaiting-mod,
+#adminmenu .update-plugins,
+#sidemenu a .update-plugins,
+#rightnow .reallynow,
+#plugin-information .action-button {
+ background-color: #d54e21;
+ color: #fff;
}
-#adminmenu li a #awaiting-mod span, #sidemenu li a #update-plugins span, #rightnow .reallynow {
- background-color: #d54e21;
+#adminmenu li a:hover #awaiting-mod,
+#adminmenu li a:hover .update-plugins,
+#sidemenu li a:hover .update-plugins {
+ background-color: #264761;
color: #fff;
}
-#adminmenu li a:hover #awaiting-mod span, #sidemenu li a:hover #update-plugins span {
+#adminmenu li.current a #awaiting-mod,
+#adminmenu li.current a .update-plugins,
+#adminmenu li.wp-has-current-submenu a .update-plugins,
+#adminmenu li.wp-has-current-submenu a .update-plugins {
+ background-color: #ddd;
+ color: #000;
+ text-shadow: none;
+ -moz-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px;
+ -khtml-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px;
+ -webkit-box-shadow: rgba(0,0,0,0.2) 0px -1px 0px;
+ box-shadow: rgba(0,0,0,0.2) 0px -1px 0px;
+}
+
+#adminmenu li.current a:hover #awaiting-mod,
+#adminmenu li.current a:hover .update-plugins,
+#adminmenu li.wp-has-current-submenu a:hover #awaiting-mod,
+#adminmenu li.wp-has-current-submenu a:hover .update-plugins {
background-color: #264761;
+ color: #fff;
}
-#adminmenu, div#media-upload-header {
+div#media-upload-header {
+ background-color: #f9f9f9;
+ border-bottom-color: #dfdfdf;
+}
+
+div#plugin-information-header {
background-color: #e4f2fd;
border-bottom-color: #c6d9e9;
}
background-color: #f9f9f9;
}
-input.readonly {
+input.readonly, textarea.readonly {
background-color: #ddd;
}
-#dashmenu a.current {
- background-color: #e4f2fd;
- color: #555;
-}
-
-#dragHelper h4.widget-title, li.widget-list-control-item h4, #dragHelper li.widget-list-control-item h4 {
+#dragHelper h4.widget-title,
+li.widget-list-control-item h4,
+#dragHelper li.widget-list-control-item h4 {
background-color: #2683ae;
color: #fff;
}
-#ed_toolbar input {
- background: url( ../images/fade-butt.png ) #fff repeat-x 0 -2px;
+#ed_toolbar input,
+#ed_reply_toolbar input {
+ background: #fff url("../images/fade-butt.png") repeat-x 0 -2px;
}
#editable-post-name {
background-color: #fffbcc;
}
-#edit-slug-box strong, .login #nav a {
+#edit-slug-box strong,
+.tablenav .displaying-num,
+#submitted-on {
color: #777;
}
-#footer {
- background: url(../images/logo-ghost.png) #464646 no-repeat 20px 10px;
+.login #nav a {
+ color: #21759b !important;
+}
+
+.login #nav a:hover {
+ color: #d54e21 !important;
+}
+
+#footer,
+#footer-upgrade {
+ background: #464646;
color: #999;
}
#media-items {
- border-color: #c0c0c0;
+ border-color: #dfdfdf;
}
#pass-strength-result {
- background-color: #e3e3e3;
- border-color: #000;
+ background-color: #eee;
+ border-color: #ddd !important;
}
#pass-strength-result.bad {
- background-color: #ffeff7;
- border-color: #c69;
+ background-color: #ffb78c;
+ border-color: #ff853c !important;
}
#pass-strength-result.good {
- background-color: #effff4;
- border-color: #66cc87;
+ background-color: #ffec8b;
+ border-color: #fc0 !important;
}
#pass-strength-result.short {
- background-color: #e3e3e3;
+ background-color: #ffa0a0;
+ border-color: #f04040 !important;
}
#pass-strength-result.strong {
- background-color: #59ef86;
- border-color: #319f52;
+ background-color: #c3ff88;
+ border-color: #8dff1c !important;
}
-.checkbox, .side-info, #your-profile #rich_editing {
+.checkbox,
+.side-info,
+#your-profile #rich_editing {
background-color: #fff;
}
-.plugins .active {
+.plugins .active,
+.plugins .active th,
+.plugins .active td {
background-color: #e7f7d3;
}
-.plugins .togl {
- border-right-color: #ccc;
+#the-comment-list .unapproved,
+#the-comment-list .unapproved th,
+#the-comment-list .unapproved td {
+ background-color: #ffffe0;
}
-#the-comment-list .unapproved {
- background-color: #ffffe0;
+#the-comment-list .approve a {
+ color: #006505;
+}
+
+#the-comment-list .unapprove a {
+ color: #d98500;
+}
+
+#the-comment-list .delete a {
+ color: #bc0b0b;
}
.plugins tr {
background-color: #fff;
}
-#poststuff #editor-toolbar .active {
- background-color: #cee1ef;
- color: #333;
+.metabox-holder .postbox,
+#poststuff .postbox,
+#titlediv,
+#poststuff .postarea,
+#poststuff .stuffbox,
+.postbox input[type="text"],
+.postbox textarea,
+.stuffbox input[type="text"],
+.stuffbox textarea {
+ border-color: #dfdfdf;
}
-#poststuff .closed .togbox {
- background-color: #2583ad;
- background-image: url(../images/toggle-arrow.gif);
+.metabox-holder .postbox,
+#poststuff .postbox {
+ background-color: #FFF;
}
-#poststuff .postbox, #titlediv, #poststuff .postarea, #poststuff .stuffbox {
- border-color: #ebebeb;
- border-right-color: #ccc;
- border-bottom-color: #ccc;
+.ui-sortable .postbox h3 {
+ color: #464646;
}
-#poststuff .togbox {
- background-color: #b2b2b2;
- background-image: url(../images/toggle-arrow.gif);
+.ui-sortable .postbox h3:hover {
+ color: #000;
+}
+
+.curtime #timestamp {
+ background-image: url(../images/date-button.gif);
}
#quicktags #ed_link {
color: #448abd;
}
-#sidemenu a {
- background-color: #e4f2fd;
- border-bottom-color: #c6d9e9;
- border-top-color: #e4f2fd;
-}
-
-#tagchecklist span a {
+#tagchecklist span a,
+#bulk-titles div a {
background: url(../images/xit.gif) no-repeat;
}
-#tagchecklist span a:hover {
+#tagchecklist span a:hover,
+#bulk-titles div a:hover {
background: url(../images/xit.gif) no-repeat -10px 0;
}
-#the-comment-list .comment a {
- border-bottom-color: #ababab;
- color: #666;
-}
-
#update-nag, .plugin-update {
background-color: #fffeeb;
border-bottom-color: #ccc;
color: #555;
}
-#upload-files a.file-link {
- background-color: #d1e2ef;
+.login #backtoblog a {
+ color: #ccc;
}
-#upload-file-view a img {
- border-bottom-color: #69c;
+#wphead {
+ background-color: #464646;
}
-#upload-menu li #current-tab-nav, #upload-file {
- background-color: #f9fcfe;
+body.login {
+ border-top-color: #464646;
}
-#upload-menu li span a.page-numbers {
- color: #00019b;
+#wphead h1 a {
+ color: #fff;
}
-#upload-menu li.current {
- border-right-color: #448abd;
- color: #000;
+#login form input {
+ color: #555;
}
-#upload-menu li.current a.upload-tab-link, #upload-menu li a:hover {
- background-color: #f9fcfe;
- color: #000;
+#wphead h1 a:hover {
+ text-decoration: underline;
}
-#upload-menu, #upload-menu li {
- border-top-color: #247fab;
+#user_info {
+ color: #999;
}
-.login #backtoblog a, .curtime, #user_info a {
+#user_info a:link, #user_info a:visited, #footer a:link, #footer a:visited {
color: #ccc;
+ text-decoration: none;
}
-#wphead {
- background-color: #e4f2fd;
+#user_info a:hover, #footer a:hover {
+ color: #fff;
+ text-decoration: underline !important;
}
-#wphead, body.login {
- border-top-color: #464646;
+#user_info a:active, #footer a:active {
+ color: #ccc !important;
}
-#wphead #viewsite a {
- background-color: #c6d9e9;
- color: #246;
- border-color: #80b5d0;
+div#media-upload-error,
+.file-error,
+abbr.required,
+.widget-control-remove:hover,
+.delete a:hover {
+ color: #f00;
}
-#wphead #viewsite a:hover {
- border-color: #328ab2;
+#media-upload a.delete {
+ color: #888;
}
-#wphead h1, #dashmenu a.current:hover, #login form input {
- color: #555;
+/* editors */
+#quicktags {
+ border-color: #dfdfdf;
+ background-color: #dfdfdf;
}
-div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover, .delete:hover {
- color: #f00;
+#ed_toolbar input {
+ border-color: #C3C3C3;
}
-#media-upload a.delete {
- color: #888;
+#ed_toolbar input:hover {
+ border-color: #aaa;
+ background: #ddd;
+}
+
+#poststuff .wp_themeSkin .mceStatusbar {
+ border-color: #EDEDED;
+}
+
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML {
+ background-color: #f1f1f1;
+ border-color: #dfdfdf;
+ color: #999;
+}
+
+#poststuff #editor-toolbar .active {
+ border-bottom-color: #e9e9e9;
+ background-color: #e9e9e9;
+ color: #333;
}
/* TinyMCE */
+#post-status-info {
+ background-color: #EDEDED;
+}
+
.wp_themeSkin *,
-.wp_themeSkin a:hover,
-.wp_themeSkin a:link,
-.wp_themeSkin a:visited,
+.wp_themeSkin a:hover,
+.wp_themeSkin a:link,
+.wp_themeSkin a:visited,
.wp_themeSkin a:active {
color: #000;
}
/* Containers */
-.wp_themeSkin table, #wp_editbtns {
- background: #cee1ef;
-}
-
.wp_themeSkin iframe {
background: #fff;
}
/* Layout */
.wp_themeSkin .mceStatusbar {
- color:#000;
- background-color: #eaf3fa;
+ color: #000;
+ background-color: #f5f5f5;
}
/* Button */
-.wp_themeSkin .mceButton {
+.wp_themeSkin .mceButton {
background-color: #e9e8e8;
- border-color: #abc0fb;
+ border-color: #B2B2B2;
}
.wp_themeSkin a.mceButtonEnabled:hover,
-.wp_themeSkin a.mceButtonActive,
+.wp_themeSkin a.mceButtonActive,
.wp_themeSkin a.mceButtonSelected {
- background-color: #d6d8da;
- border-color: #7789ba !important;
+ background-color: #d5d5d5;
+ border-color: #777 !important;
}
.wp_themeSkin .mceButtonDisabled {
- border-color: #bdd !important;
+ border-color: #ccc !important;
}
/* ListBox */
.wp_themeSkin .mceListBox .mceText,
.wp_themeSkin .mceListBox .mceOpen {
- border-color: #abc0fb;
- background-color: #e9e8e8;
+ border-color: #B2B2B2;
+ background-color: #d5d5d5;
}
-.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen,
+.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen,
.wp_themeSkin .mceListBoxHover .mceOpen,
.wp_themeSkin .mceListBoxSelected .mceOpen,
.wp_themeSkin .mceListBoxSelected .mceText {
- border-color: #7789ba !important;
- background-color: #d6d8da;
+ border-color: #777 !important;
+ background-color: #d5d5d5;
}
-.wp_themeSkin table.mceListBoxEnabled:hover .mceText,
+.wp_themeSkin table.mceListBoxEnabled:hover .mceText,
.wp_themeSkin .mceListBoxHover .mceText {
- border-color: #7789ba !important;
+ border-color: #777 !important;
}
.wp_themeSkin select.mceListBox {
- border-color: #b3c7e1;
+ border-color: #B2B2B2;
background-color: #fff;
}
/* SplitButton */
-.wp_themeSkin .mceSplitButton a.mceAction,
+.wp_themeSkin .mceSplitButton a.mceAction,
.wp_themeSkin .mceSplitButton a.mceOpen {
- background-color: #e9e8e8;
- border-color: #abc0fb;
+ background-color: #e8e8e8;
+ border-color: #B2B2B2;
}
.wp_themeSkin .mceSplitButton a.mceOpen:hover,
.wp_themeSkin .mceSplitButtonSelected a.mceOpen,
.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction,
.wp_themeSkin .mceSplitButton a.mceAction:hover {
- background-color: #d6d8da;
- border-color: #7789ba !important;
-}
+ background-color: #d5d5d5;
+ border-color: #777 !important;
+}
.wp_themeSkin .mceSplitButtonActive {
- background-color: #d6d8da;
+ background-color: #B2B2B2;
}
/* ColorSplitButton */
.wp_themeSkin div.mceColorSplitMenu table {
- background-color: #ebeaeb;
- border-color: #808080;
+ background-color: #ebebeb;
+ border-color: #B2B2B2;
}
.wp_themeSkin .mceColorSplitMenu a {
- border-color: #808080;
+ border-color: #B2B2B2;
}
.wp_themeSkin .mceColorSplitMenu a.mceMoreColors {
}
.wp_themeSkin .mceMenu .mceText {
- color: #000;
+ color: #000;
}
.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover,
.wp_themeSkin .mceMenu .mceMenuItemActive {
- background-color: #CEE1EF;
+ background-color: #f5f5f5;
}
.wp_themeSkin td.mceMenuItemSeparator {
background-color: #aaa;
}
.wp_themeSkin .mceMenuItemTitle a {
- background-color: #ccc;
+ background-color: #ccc;
border-bottom-color: #aaa;
}
.wp_themeSkin .mceMenuItemTitle span.mceText {
color: #888;
}
-/* pop-up */
-.clearlooks2 .mceTop .mceLeft, .clearlooks2 .mceTop .mceRight {
- background-color: #cee1ef;
- border-color: #c6d9e9;
+.wp_themeSkin tr.mceFirst td.mceToolbar {
+ background-color: #dfdfdf;
+ border-color: #dfdfdf;
}
-.clearlooks2 .mceFocus .mceTop .mceLeft, .clearlooks2 .mceFocus .mceTop .mceRight {
- background-color: #2683ae;
- border-color: #464646;
+.wp-admin #mceModalBlocker {
+ background: #000;
}
-#editorcontainer {
- border-color: #ccc;
+.wp-admin .clearlooks2 .mceFocus .mceTop .mceLeft {
+ background: #444444;
+ border-left: 1px solid #999;
+ border-top: 1px solid #999;
+ -moz-border-radius: 4px 0 0 0;
+ -webkit-border-top-left-radius: 4px;
+ -khtml-border-top-left-radius: 4px;
+ border-top-left-radius: 4px;
}
-#poststuff #titlewrap {
- border-color: #ccc;
+.wp-admin .clearlooks2 .mceFocus .mceTop .mceRight {
+ background: #444444;
+ border-right: 1px solid #999;
+ border-top: 1px solid #999;
+ border-top-right-radius: 4px;
+ -khtml-border-top-right-radius: 4px;
+ -webkit-border-top-right-radius: 4px;
+ -moz-border-radius: 0 4px 0 0;
}
-.curtime {
- color: #666;
+.wp-admin .clearlooks2 .mceMiddle .mceLeft {
+ background: #f1f1f1;
+ border-left: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceMiddle .mceRight {
+ background: #f1f1f1;
+ border-right: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom {
+ background: #f1f1f1;
+ border-bottom: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceLeft {
+ background: #f1f1f1;
+ border-bottom: 1px solid #999;
+ border-left: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceCenter {
+ background: #f1f1f1;
+ border-bottom: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceRight {
+ background: #f1f1f1;
+ border-bottom: 1px solid #999;
+ border-right: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceFocus .mceTop span {
+ color: #e5e5e5;
+}
+/* end TinyMCE */
+
+#editorcontainer,
+#post-status-info,
+#titlediv #title {
+ border-color: #dfdfdf;
+}
+
+#titlediv #title {
+ background-color: #fff;
}
#tTips p#tTips_inside {
color: #333;
}
-/* Diff */
+#timestampdiv input,
+#namediv input,
+#tagsdiv #the-tagcloud {
+ border-color: #ddd;
+}
+
+/* menu */
+#adminmenu * {
+ border-color: #e3e3e3;
+}
+
+#adminmenu li.wp-menu-separator {
+ background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;
+}
+
+.folded #adminmenu li.wp-menu-separator {
+ background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;
+}
+
+#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,
+#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+ background: transparent url(../images/menu-bits.gif) no-repeat scroll left -207px;
+}
+
+#adminmenu .wp-has-submenu:hover .wp-menu-toggle,
+#adminmenu .wp-menu-open .wp-menu-toggle {
+ background: transparent url(../images/menu-bits.gif) no-repeat scroll left -109px;
+}
+
+#adminmenu a.menu-top {
+ background: #f1f1f1 url(../images/menu-bits.gif) repeat-x scroll left -379px;
+}
+
+#adminmenu .wp-submenu a {
+ background: #FFFFFF url(../images/menu-bits.gif) no-repeat scroll 0 -310px;
+}
+
+#adminmenu .wp-has-current-submenu ul li a {
+ background: none;
+}
+
+#adminmenu .wp-has-current-submenu ul li a.current {
+ background: url(../images/menu-dark.gif) top left no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
+#adminmenu .menu-top .current {
+ background: #6d6d6d url(../images/menu-bits.gif) top left repeat-x;
+ border-color: #6d6d6d;
+ color: #fff;
+ text-shadow: rgba(0,0,0,0.4) 0px -1px 0px;
+}
+
+#adminmenu li.wp-has-current-submenu .wp-submenu,
+#adminmenu li.wp-has-current-submenu ul li a {
+ border-color: #aaa !important;
+}
+
+#adminmenu li.wp-has-current-submenu ul li a {
+ background: url(../images/menu-dark.gif) bottom left no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu ul {
+ border-bottom-color: #aaa;
+}
+
+#adminmenu li.menu-top .current:hover {
+ border-color: #B5B5B5;
+}
+
+#adminmenu .wp-submenu .current a.current {
+ background: transparent url(../images/menu-bits.gif) no-repeat scroll 0 -289px;
+}
+
+#adminmenu .wp-submenu a:hover {
+ background-color: #EAF2FA !important;
+ color: #333 !important;
+}
+
+#adminmenu .wp-submenu li.current,
+#adminmenu .wp-submenu li.current a,
+#adminmenu .wp-submenu li.current a:hover {
+ color: #333;
+ background-color: #f5f5f5;
+ background-image: none;
+ border-color: #e3e3e3;
+ text-shadow: rgba(255,255,255,1) 0px 1px 0px;
+}
+
+#adminmenu .wp-submenu ul {
+ background-color: #fff;
+}
+
+.folded #adminmenu li.menu-top,
+#adminmenu .wp-submenu .wp-submenu-head {
+ background-color: #F1F1F1;
+}
+
+.folded #adminmenu li.wp-has-current-submenu,
+.folded #adminmenu li.menu-top.current {
+ background-color: #e6e6e6;
+}
+
+#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head {
+ background-color: #EAEAEA;
+ border-color: #aaa;
+}
+
+#adminmenu div.wp-submenu {
+ background-color: transparent;
+}
+
+/* menu icons */
+#adminmenu #menu-dashboard div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -61px -33px;
+}
+
+#adminmenu #menu-dashboard:hover div.wp-menu-image,
+#adminmenu #menu-dashboard.wp-has-current-submenu div.wp-menu-image,
+#adminmenu #menu-dashboard.current div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -61px -1px;
+}
+
+#adminmenu #menu-posts div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -272px -33px;
+}
+
+#adminmenu #menu-posts:hover div.wp-menu-image,
+#adminmenu #menu-posts.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -272px -1px;
+}
+
+#adminmenu #menu-media div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -121px -33px;
+}
+
+#adminmenu #menu-media:hover div.wp-menu-image,
+#adminmenu #menu-media.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -121px -1px;
+}
+
+#adminmenu #menu-links div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -91px -33px;
+}
+
+#adminmenu #menu-links:hover div.wp-menu-image,
+#adminmenu #menu-links.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -91px -1px;
+}
+
+#adminmenu #menu-pages div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -151px -33px;
+}
+
+#adminmenu #menu-pages:hover div.wp-menu-image,
+#adminmenu #menu-pages.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -151px -1px;
+}
+
+#adminmenu #menu-comments div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -31px -33px;
+}
+
+#adminmenu #menu-comments:hover div.wp-menu-image,
+#adminmenu #menu-comments.wp-has-current-submenu div.wp-menu-image,
+#adminmenu #menu-comments.current div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -31px -1px;
+}
+
+#adminmenu #menu-appearance div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -1px -33px;
+}
+
+#adminmenu #menu-appearance:hover div.wp-menu-image,
+#adminmenu #menu-appearance.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -1px -1px;
+}
+
+#adminmenu #menu-plugins div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -181px -33px;
+}
+
+#adminmenu #menu-plugins:hover div.wp-menu-image,
+#adminmenu #menu-plugins.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -181px -1px;
+}
+
+#adminmenu #menu-users div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -301px -33px;
+}
+
+#adminmenu #menu-users:hover div.wp-menu-image,
+#adminmenu #menu-users.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -301px -1px;
+}
+
+#adminmenu #menu-tools div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -211px -33px;
+}
+
+#adminmenu #menu-tools:hover div.wp-menu-image,
+#adminmenu #menu-tools.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -211px -1px;
+}
+
+#adminmenu #menu-settings div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -241px -33px;
+}
+
+#adminmenu #menu-settings:hover div.wp-menu-image,
+#adminmenu #menu-settings.wp-has-current-submenu div.wp-menu-image {
+ background: transparent url("../images/menu.png") no-repeat scroll -241px -1px;
+}
+/* end menu */
+
+/* Diff */
table.diff .diff-deletedline {
background-color: #ffdddd;
}
table.diff .diff-addedline ins {
background-color: #99ff99;
}
+
+#att-info {
+ background-color: #E4F2FD;
+}
+
+/* edit image */
+#sidemenu a {
+ background-color: #f9f9f9;
+ border-color: #f9f9f9;
+ border-bottom-color: #dfdfdf;
+}
+
+#sidemenu a.current {
+ background-color: #fff;
+ border-color: #dfdfdf #dfdfdf #fff;
+ color: #D54E21;
+}
+
+
+#screen-options-wrap,
+#contextual-help-wrap {
+ background-color: #f1f1f1;
+ border-color: #dfdfdf;
+}
+
+#screen-meta-links a.show-settings {
+ color: #606060;
+}
+
+#screen-meta-links a.show-settings:hover {
+ color: #000;
+}
+
+#replysubmit {
+ background-color: #f1f1f1;
+ border-top-color: #ddd;
+}
+
+#replyerror {
+ border-color: #ddd;
+ background-color: #f9f9f9;
+}
+
+#edithead,
+#replyhead {
+ background-color: #f1f1f1;
+}
+
+#ed_reply_toolbar {
+ background-color: #e9e9e9;
+}
+
+/* table vim shortcuts */
+.vim-current {
+ background-color: #E4F2FD !important;
+}
+
+/* Install Plugins */
+.star-average,
+.star.star-rating {
+ background-color: #fc0;
+}
+
+div.star.select:hover {
+ background-color: #d00;
+}
+
+#plugin-information .fyi ul {
+ background-color: #eaf3fa;
+}
+
+#plugin-information .fyi h2.mainheader {
+ background-color: #cee1ef;
+}
+
+#plugin-information pre,
+#plugin-information code {
+ background-color: #ededff;
+}
+
+#plugin-information pre {
+ border: 1px solid #ccc;
+}
+
+/* inline editor */
+.inline-edit-row fieldset input[type="text"],
+.inline-edit-row fieldset textarea,
+#bulk-titles,
+#replyrow input {
+ border-color: #ddd;
+}
+
+.inline-editor div.title {
+ background-color: #EAF3FA;
+}
+
+.inline-editor ul.cat-checklist {
+ background-color: #FFFFFF;
+ border-color: #ddd;
+}
+
+.inline-edit-row p.submit {
+ background-color: #f1f1f1;
+}
+
+.inline-editor .categories .catshow,
+.inline-editor .categories .cathide {
+ color: #21759b;
+}
+
+.inline-editor .quick-edit-save {
+ background-color: #f1f1f1;
+}
+
+#replyrow #ed_reply_toolbar input:hover {
+ border-color: #aaa;
+ background: #ddd;
+}
+
+fieldset.inline-edit-col-right .inline-edit-col {
+ border-color: #dfdfdf;
+}
+
+.attention {
+ color: #D54E21;
+}
+
+.meta-box-sortables .postbox:hover .handlediv {
+ background: transparent url(../images/menu-bits.gif) no-repeat scroll left -111px;
+}
+
+#major-publishing-actions {
+ background: #eaf2fa;
+}
+
+.tablenav .tablenav-pages {
+ color: #555;
+}
+
+.tablenav .tablenav-pages a {
+ border-color: #e3e3e3;
+ background: #eee url('../images/menu-bits.gif') repeat-x scroll left -379px;
+}
+
+.tablenav .tablenav-pages a:hover {
+ color: #d54e21;
+ border-color: #d54321;
+}
+
+.tablenav .tablenav-pages a:active {
+ color: #fff !important;
+}
+
+.tablenav .tablenav-pages .current {
+ background: #dfdfdf;
+ border-color: #d3d3d3;
+}
+
+#availablethemes,
+#availablethemes td {
+ border-color: #ddd;
+}
+
+#current-theme img {
+ border-color: #999;
+}
+
+#TB_window #TB_title a.tb-theme-preview-link,
+#TB_window #TB_title a.tb-theme-preview-link:visited {
+ color: #999;
+}
+
+#TB_window #TB_title a.tb-theme-preview-link:hover,
+#TB_window #TB_title a.tb-theme-preview-link:focus {
+ color: #ccc;
+}
+
+.misc-pub-section {
+ border-bottom-color: #eee;
+}
+
+#minor-publishing {
+ border-bottom-color: #ddd;
+}
+
+#post-body .misc-pub-section {
+ border-right-color: #eee;
+}
+
+.post-com-count span {
+ background-color: #bbb;
+}
+
+.form-table .color-palette td {
+ border-color: #fff;
+}
+
+.sortable-placeholder {
+ border-color: #bbb;
+ background-color: #f5f5f5;
+}
+
+#post-body ul#category-tabs li.ui-tabs-selected a {
+ color: #333;
+}
+
+#wp_editimgbtn,
+#wp_delimgbtn,
+#wp_editgallery,
+#wp_delgallery {
+ border-color: #999;
+ background-color: #eee;
+}
+
+#wp_editimgbtn:hover,
+#wp_delimgbtn:hover,
+#wp_editgallery:hover,
+#wp_delgallery:hover {
+ border-color: #555;
+ background-color: #ccc;
+}
+
+#favorite-first {
+ background: #797979 url(../images/fav.png) repeat-x left center;
+ border-color: #777 !important;
+ border-bottom-color: #666 !important;
+}
+
+#favorite-inside {
+ border-color: #797979;
+ background-color: #797979;
+}
+
+#favorite-toggle {
+ background: transparent url(../images/fav-arrow.gif) no-repeat 0 -4px;
+}
+
+#favorite-actions a {
+ color: #ddd;
+}
+
+#favorite-actions a:hover {
+ color: #fff;
+}
+
+#favorite-inside a:hover {
+ text-decoration: underline;
+}
+
+#favorite-actions .slide-down {
+ border-bottom-color: #626262;
+}
+
+.submit input,
+.button,
+.button-primary,
+.button-secondary,
+.button-highlighted,
+#postcustomstuff .submit input {
+ text-shadow: rgba(255,255,255,1) 0 1px 0;
+}
+
+.button-primary,
+.submit .button-primary {
+ text-shadow: rgba(0,0,0,0.3) 0 -1px 0;
+}
+
+#screen-meta a.show-settings {
+ background-color: transparent;
+ text-shadow: rgba(255,255,255,0.7) 0 1px 0;
+}
+
+#icon-edit,
+#icon-post {
+ background: transparent url(../images/icons32.png) no-repeat -552px -5px;
+}
+
+#icon-index {
+ background: transparent url(../images/icons32.png) no-repeat -137px -5px;
+}
+
+#icon-upload {
+ background: transparent url(../images/icons32.png) no-repeat -251px -5px;
+}
+
+#icon-link-manager,
+#icon-link,
+#icon-link-category {
+ background: transparent url(../images/icons32.png) no-repeat -190px -5px;
+}
+
+#icon-edit-pages,
+#icon-page {
+ background: transparent url(../images/icons32.png) no-repeat -312px -5px;
+}
+
+#icon-edit-comments {
+ background: transparent url(../images/icons32.png) no-repeat -72px -5px;
+}
+
+#icon-themes {
+ background: transparent url(../images/icons32.png) no-repeat -11px -5px;
+}
+
+#icon-plugins {
+ background: transparent url(../images/icons32.png) no-repeat -370px -5px;
+}
+
+#icon-users,
+#icon-user-edit {
+ background: transparent url(../images/icons32.png) no-repeat -600px -5px;
+}
+
+#icon-tools,
+#icon-admin {
+ background: transparent url(../images/icons32.png) no-repeat -432px -5px;
+}
+
+#icon-options-general {
+ background: transparent url(../images/icons32.png) no-repeat -492px -5px;
+}
+
+.view-switch #view-switch-list {
+ background: transparent url(../images/list.png) no-repeat 0 0;
+}
+
+.view-switch #view-switch-list.current {
+ background: transparent url(../images/list.png) no-repeat -40px 0;
+}
+
+.view-switch #view-switch-excerpt {
+ background: transparent url(../images/list.png) no-repeat -20px 0;
+}
+
+.view-switch #view-switch-excerpt.current {
+ background: transparent url(../images/list.png) no-repeat -60px 0;
+}
+
+#header-logo {
+ background: transparent url(../images/wp-logo.gif) no-repeat scroll center center;
+}
-/* Right Now */
-#rightnow {
- margin-right:0;
- margin-left: 7px;
+#dashboard-widgets-wrap .has-sidebar {
+ margin-right: 0;
+ margin-left: -51%;
}
-#rightnow .reallynow span {
- text-align: right;
- float: right;
+#dashboard-widgets-wrap .has-sidebar .has-sidebar-content {
+ margin-right: 0;
+ margin-left: 51%;
+}
+.view-all {
+ right: auto;
+ left: 0;
}
-#rightnow .reallynow a {
+#dashboard_right_now p.sub, #dashboard-widgets h4, #dashboard_quick_press h4, a.rsswidget, #dashboard_plugins h4, #dashboard_plugins h5, #dashboard_recent_comments .comment-meta .approve {
+ font-family: Tahoma, Arial;
+}
+#dashboard_right_now td.b {
+ padding-right: 0;
+ padding-left: 6px;
text-align: left;
+ font-family: Tahoma, Arial;
+}
+#dashboard_right_now .t {
+ padding-right: 0;
+ padding-left: 12px;
+}
+#dashboard_right_now .versions a {
+ font-family: Tahoma, Arial;
+}
+#dashboard_right_now a.button {
float: left;
- margin: 1px 0 0 6px;
+ clear: left;
}
-/* Widgets */
-div#dashboard-widgets-wrap {
- margin-right:0;
- margin-left:-13px;
+#dashboard-widgets h3 .postbox-title-action {
+ right: auto;
+ left: 30px;
}
-div.dashboard-widget-holder {
- float:right;
+#the-comment-list .pingback {
+ padding-left: 0 !important;
+ padding-right: 9px !important;
}
-div.dashboard-widget {
- margin-right:0;
- margin-left: 20px;
+/* Recent Comments */
+#the-comment-list .comment-item {
+ padding: 1em 70px 1em 10px;
}
-h3.dashboard-widget-title span {
- text-align: right;
+#the-comment-list .comment-item .avatar {
float: right;
+ margin-left: 0;
+ margin-right: -60px;
}
-h3.dashboard-widget-title small {
+/* Feeds */
+.rss-widget cite {
text-align: left;
- float:left;
-}
-div.dashboard-widget-submit input {
- font-family: Tahoma;
}
-div.dashboard-widget-content ul, div.dashboard-widget-content ol, div.dashboard-widget-content dl {
- padding-left:0;
- padding-right:15px;
+.rss-widget span.rss-date {
+ font-family: Tahoma, Arial;
+ margin-left: 0;
+ margin-right: 3px;
}
-#dashboard_secondary div.dashboard-widget-content ul li {
- float:right;
+/* QuickPress */
+#dashboard_quick_press h4 {
+ float: right;
+ text-align: left;
}
-#dashboard_secondary div.dashboard-widget-content ul li .post {
- font-family:arial;
+#dashboard_quick_press h4 label {
+ margin-right: 0;
+ margin-left: 10px;
}
-#dashboard_secondary div.dashboard-widget-content ul li a {
- border-right:0 none;
- border-left: 1px solid #dadada;
- height:110px;
+#dashboard_quick_press .input-text-wrap, #dashboard_quick_press .textarea-wrap {
+ margin: 0 5em 1em 0;
}
-#dashboard_secondary div.dashboard-widget-content ul li a cite {
- font-family: Tahoma;
+#dashboard_quick_press #media-buttons {
+ margin: 0 5em .5em 0;
+ padding: 0 10px 0 0;
}
-#dashboard-widgets .widget_rss ul li span.rss-date {
- float:right;
+#dashboard-widgets #dashboard_quick_press form p.submit {
+ margin-left: 0;
+ margin-right: 4.6em;
}
-#dashboard-widgets .widget_rss ul li a {
+#dashboard-widgets #dashboard_quick_press form p.submit input {
float: right;
- margin: 0 0 .2em .5em;
+}
+#dashboard-widgets #dashboard_quick_press form p.submit #save-post {
+ margin: 0 10px 0 1em;
+}
+#dashboard-widgets #dashboard_quick_press form p.submit #publish {
+ float: left;
+}
+/* Recent Drafts */
+#dashboard_recent_drafts h4 abbr {
+ font-family: Tahoma, Arial;
+ margin-left:0;
+ margin-right: 3px;
}
-/* Right Now */
+.postbox p, .postbox ul, .postbox ol, .postbox blockquote, #wp-version-message { font-size: 11px; }
+
+.edit-box {
+ display: none;
+}
+
+h3:hover .edit-box {
+ display: inline;
+}
-#rightnow {
+form .input-text-wrap {
+ border-style: solid;
border-width: 1px;
+ padding: 2px 3px;
+ border-color: #ccc;
+}
+
+#dashboard-widgets form .input-text-wrap input {
+ border: 0 none;
+ outline: none;
+ margin: 0;
+ padding: 0;
+ width: 99%;
+ color: #333;
+}
+
+form .textarea-wrap {
border-style: solid;
+ border-width: 1px;
padding: 2px;
- margin-top: 10px;
- margin-right: 7px;
+ border-color: #ccc;
}
-#rightnow .reallynow {
- padding: 6px;
- font-size: 15px;
- line-height: 2;
+#dashboard-widgets form .textarea-wrap textarea {
+ border: 0 none;
+ padding: 0;
+ outline: none;
+ width: 99%;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+#dashboard-widgets .postbox form .submit {
+ float: none;
+ margin: .5em 0 0;
+ padding: 0;
+ border: none;
+}
+
+#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit input {
margin: 0;
}
-#rightnow .rbutton {
- font-weight: normal;
- padding: 6px;
- border-bottom: none;
- -moz-border-radius: 2px;
- -khtml-border-radius: 2px;
- -webkit-border-radius: 2px;
- border-radius: 2px;
- text-decoration: none;
+#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit #publish {
+ min-width: 0;
}
-#rightnow .reallynow span {
- display: block;
- text-align: left;
- float: left;
- padding: 0 6px;
+#dashboard-widgets-wrap .has-sidebar {
+ margin-right: -51%;
}
-#rightnow .reallynow a {
- display: block;
- text-align: right;
- float: right;
- padding: 0 6px;
- font-size: 14px;
- margin: 1px 6px 0 0;
+#dashboard-widgets-wrap .inner-sidebar {
+ width: 49%;
}
-#rightnow .youhave {
- font-size: 14px;
- padding: 10px;
+#dashboard-widgets-wrap .has-sidebar .has-sidebar-content {
+ margin-right: 51%;
}
-#rightnow h3, #rightnow p {
- padding: 0 10px;
+div.postbox div.inside {
+ margin: 10px;
+ position: relative;
}
-#rightnow a {
- font-weight: bold;
+#dashboard-widgets a {
+ text-decoration: none;
}
-/* Widgets */
+#dashboard-widgets h3 a {
+ text-decoration: underline;
+}
-div#dashboard-widgets-wrap {
- margin-top: -20px;
- margin-right: -13px; /* 20 (div.dashboard-widget margin-right) - 7 (#rightnow margin-right) */
+#dashboard-widgets h3 .postbox-title-action {
+ position: absolute;
+ right: 30px;
+ padding: 0;
}
-div#dashboard-widgets {
- width: 100%;
+#dashboard-widgets h4 {
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+ font-size: 13px;
+ margin: 0 0 .2em;
+ padding: 0;
}
-div.dashboard-widget-holder {
- margin-top: 20px;
- width: 50%;
- float: left;
+/* Right Now */
+
+#dashboard_right_now p.sub,
+#dashboard_right_now .table, #dashboard_right_now .versions {
+ margin: -12px;
+}
+
+#dashboard_right_now .inside {
+ font-size: 12px;
}
-div.dashboard-widget-holder.third {
- width: 33.3%;
+#dashboard_right_now p.sub {
+ font-style: italic;
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+ padding: 5px 10px 15px;
+ color: #777;
+ font-size: 13px;
}
-div.dashboard-widget-holder.fourth {
- width: 25%;
+#dashboard_right_now .table {
+ background: #f9f9f9;
+ border-top: #ececec 1px solid;
+ border-bottom: #ececec 1px solid;
+ margin: 0 -9px 10px;
+ padding: 0 10px;
}
-div.dashboard-widget-holder.full {
+#dashboard_right_now table {
width: 100%;
}
-div.dashboard-widget-holder.double div.dashboard-widget {
- height: 54em;
- padding-bottom: 28px /* lame */
+#dashboard_right_now table td {
+ border-top: #ececec 1px solid;
+ padding: 3px 0;
+ white-space: nowrap;
}
-div.dashboard-widget {
- position: relative;
- margin-right: 20px;
- border-width: 1px;
- border-style: solid;
- padding: 2px;
- height: 27em;
- overflow: auto;
- font-size: 11px;
+#dashboard_right_now table tr.first td {
+ border-top: none;
}
-h3.dashboard-widget-title {
- margin: 0;
- padding: 0 7px;
+#dashboard_right_now td.b {
+ padding-right: 6px;
+ text-align: right;
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
font-size: 14px;
- line-height: 2;
}
-h3.dashboard-widget-title span {
- display: block;
- text-align: left;
- float: left;
+#dashboard_right_now td.b a {
+ font-size: 18px;
}
-h3.dashboard-widget-title small {
- display: block;
- text-align: right;
- float: right;
- font-size: 75%;
- line-height: 2.67; /* math: it works, bitches */
+#dashboard_right_now td.b a:hover {
+ color: #d54e21;
}
-h3.dashboard-widget-title img.rss-icon {
- vertical-align: middle;
- margin: .5em 0;
+#dashboard_right_now .t {
+ font-size: 12px;
+ padding-right: 12px;
+ padding-top: 6px;
+ color: #777;
}
-div.dashboard-widget-notice {
- padding: 0 14px;
- font-size: 1.2em;
- line-height: 2;
+#dashboard_right_now td.first,
+#dashboard_right_now td.last {
+ width: 1px;
}
-div.dashboard-widget-error {
- padding: 0 20px;
- font-size: 1.2em;
- line-height: 2;
+#dashboard_right_now .spam {
+ color: red;
}
-div.dashboard-widget-content {
- padding: 10px 15px;
+#dashboard_right_now .waiting {
+ color: orange;
}
-div.dashboard-widget-submit {
- border-top: 1px solid #ccc;
- padding: 1em 0 0 0;
- margin: 10px 0 0 0;
+#dashboard_right_now .approved {
+ color: green;
}
-div.dashboard-widget-submit input {
- font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
- padding: 4px 6px;
- border: none;
- font-size: 13px;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
- cursor: pointer;
- text-decoration: none;
+
+#dashboard_right_now .versions {
+ padding: 6px 10px 12px;
}
-div.dashboard-widget-content ul, div.dashboard-widget-content ol, div.dashboard-widget-content dl {
- margin: 0;
- text-indent: 0;
- padding-left: 15px;
+#dashboard_right_now .versions .b {
+ font-weight: bold;
+}
+
+#dashboard_right_now a.button {
+ float: right;
+ clear: right;
+ position: relative;
+ top: -5px;
}
-div.dashboard-widget-content li {
- margin: .5em 0 1em;
+
+/* Recent Comments */
+
+#dashboard_recent_comments h3 {
+ margin-bottom: 0;
}
-div.dashboard-widget-content blockquote {
- margin: -1em 0;
+#dashboard_recent_comments .inside {
+ margin-top: 0;
}
-div#dashboard_recent_comments p {
- font-size: 14px;
+#dashboard_recent_comments .comment-meta .approve {
+ font-style: italic;
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+ font-size: 10px;
}
-div.dashboard-widget-content p.comment-meta {
- font-size: 11px !important;
+#the-comment-list {
+ position: relative;
}
-#dashboard_secondary div.dashboard-widget {
- height: auto;
+#the-comment-list .comment-item {
+ padding: 1em 10px 1em 70px;
+ border-top: 1px solid;
}
-#dashboard_secondary div.dashboard-widget-content ul {
- list-style: none;
- padding: 0;
+#the-comment-list .pingback {
+ padding-left: 9px !important;
}
-#dashboard_secondary div.dashboard-widget-content ul li {
- display: block;
- width: 19.95%;
- padding-bottom: 10px;
- margin: 0;
+#the-comment-list .comment-item,
+#the-comment-list #replyrow {
+ margin: 0 -10px;
+}
+
+#the-comment-list .comment-item:first-child {
+ border-top: none;
+}
+
+#the-comment-list .comment-item .avatar {
float: left;
- font-size: 95%;
+ margin-left: -60px;
}
-#dashboard_secondary div.dashboard-widget-content {
- margin: 10px 5px;
- padding: 0;
+#the-comment-list .comment-item h4 {
+ line-height: 1.4;
+ margin-top: -.2em;
+ font-weight: normal;
+ color: #999;
}
-#dashboard_secondary div.dashboard-widget-content ul li .post {
- display:block;
- font-family:Georgia,"Times New Roman",Times,serif;
- font-size:18px;
- line-height: 1.2em;
- height:90px;
- overflow:hidden;
+#the-comment-list .comment-item h4 cite {
+ font-style: normal;
+ font-weight: normal;
}
-#dashboard_secondary div.dashboard-widget-content ul li a {
- display: block;
- height:100%;
- overflow:hidden;
- margin: 5px 10px;
- text-decoration: none;
- padding: .5em;
- border-right: 1px solid #dadada;
- border-bottom: 1px solid #dadada;
+#the-comment-list .comment-item blockquote,
+#the-comment-list .comment-item blockquote p {
+ margin: 0;
+ padding: 0;
+ display: inline;
}
-#dashboard_secondary div.dashboard-widget-content ul li a cite {
+#dashboard_recent_comments #the-comment-list .trackback blockquote,
+#dashboard_recent_comments #the-comment-list .pingback blockquote {
display: block;
- font-family: "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
}
-#dashboard-widgets .widget_rss ul {
- list-style: none;
+#the-comment-list .comment-item p.row-actions {
+ margin: 3px 0 0;
padding: 0;
+ font-size: 10px;
}
-#dashboard-widgets .widget_rss ul li {
+/* QuickPress */
+
+#dashboard_quick_press h4 {
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+ float: left;
+ width: 5.5em;
clear: both;
+ font-weight: normal;
+ text-align: right;
+ padding-top: 5px;
+ font-size: 12px;
+}
+
+#dashboard_quick_press h4 label {
+ margin-right: 10px;
}
-#dashboard-widgets .widget_rss ul li span.rss-date {
+#dashboard_quick_press .input-text-wrap,
+#dashboard_quick_press .textarea-wrap {
+ margin: 0 0 1em 5em;
+}
+
+#dashboard_quick_press #media-buttons {
+ margin: 0 0 .5em 5em;
+ padding: 0 0 0 10px;
+ font-size: 11px;
+}
+
+#dashboard_quick_press #media-buttons a {
+ vertical-align: bottom;
+}
+
+#dashboard-widgets #dashboard_quick_press form p.submit {
+ margin-left: 4.6em;
+}
+
+#dashboard-widgets #dashboard_quick_press form p.submit input {
float: left;
+}
+
+#dashboard-widgets #dashboard_quick_press form p.submit #save-post {
+ margin: 0 1em 0 10px;
+}
+
+#dashboard-widgets #dashboard_quick_press form p.submit #publish {
+ float: right;
+}
+
+/* Recent Drafts */
+#dashboard_recent_drafts ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+
+#dashboard_recent_drafts ul li {
+ margin-bottom: 0.6em;
+}
+
+#dashboard_recent_drafts h4 {
+ font-weight: normal;
+}
+
+#dashboard_recent_drafts h4 abbr {
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+ font-size: 11px;
+ color: #999;
+ margin-left: 3px;
+}
+
+#dashboard_recent_drafts p {
margin: 0;
+ padding: 0;
}
-#dashboard-widgets .widget_rss ul li a {
- float: left;
- margin: 0 .5em .2em 0;
- font-weight: bold;
+/* Feeds */
+
+.rss-widget ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
}
-#dashboard-widgets .widget_rss ul li div {
- clear: both;
+a.rsswidget {
+ font-size: 13px;
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+ line-height: 1.7em;
+}
+
+.rss-widget ul li {
line-height: 1.5em;
+ margin-bottom: 12px;
}
-#dashboard_primary a.rsswidget, #dashboard_plugins h5 {
- font-size: 14px;
+.rss-widget span.rss-date {
+ margin-left: 3px;
}
-#dashboard_primary span.rss-date {
- font-size: 14px;
+.rss-widget cite {
+ display: block;
+ text-align: right;
+ margin: 0 0 1em;
+ padding: 0;
}
+.rss-widget cite:before {
+ content: '\2014';
+}
+
+/* Plugins */
+
#dashboard_plugins h4 {
- font-size: 1em;
- margin: 0 0 .1em;
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
}
#dashboard_plugins h5 {
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+ font-size: 13px !important;
margin: 0;
display: inline;
line-height: 1.4em;
}
-#dashboard_plugins p {
- margin: 0 0 1em;
- line-height: 1.5em;
+#dashboard_plugins h5 a {
+ font-weight: normal;
+ line-height: 1.7em;
}
-.widget-loading {
+#dashboard_plugins p {
+ margin: 0 0 1.4em;
+ line-height: 1.4em;
}
--- /dev/null
+.farbtastic .color, .farbtastic .overlay {\r
+ left: 0;\r
+ right: 47px;\r
+}\r
+.farbtastic .marker {\r
+ margin: -8px -8px 0 0;\r
+}\r
--- /dev/null
+.farbtastic {
+ position: relative;
+}
+.farbtastic * {
+ position: absolute;
+ cursor: crosshair;
+}
+.farbtastic, .farbtastic .wheel {
+ width: 195px;
+ height: 195px;
+}
+.farbtastic .color, .farbtastic .overlay {
+ top: 47px;
+ left: 47px;
+ width: 101px;
+ height: 101px;
+}
+.farbtastic .wheel {
+ background: url(../images/wheel.png) no-repeat;
+ width: 195px;
+ height: 195px;
+}
+.farbtastic .overlay {
+ background: url(../images/mask.png) no-repeat;
+}
+.farbtastic .marker {
+ width: 17px;
+ height: 17px;
+ margin: -8px 0 0 -8px;
+ overflow: hidden;
+ background: url(../images/marker.png) no-repeat;
+}
\ No newline at end of file
-body, td {
- font-family: Tahoma;
+/* 2 column liquid layout */
+#adminmenu {
+ float: right;
+ clear: right;
+ margin-right:-160px;
+ margin-left: 5px;
}
-textarea, input, select {
- font-family: Tahoma;
+div.folded #adminmenu {
+ margin-left: 0;
+ margin-right: -45px;
}
-h1, h2, h3 {
- font-family:arial;
+/* inner 2 column liquid layout */
+.inner-sidebar {
+ float: left;
+ clear: left;
}
-.widefat td {
- padding: 7px 10px 9px 15px;
+.has-sidebar {
+ float: right;
+ clear: right;
+ margin-right: 0;
+ margin-left: -340px;
+}
+.has-sidebar .has-sidebar-content {
+ margin-right: 0;
+ margin-left: 305px;
+}
+#wpbody {
+ margin-left:0;
+ margin-right: 175px;
+}
+.folded #wpbody {
+ margin-left: 0;
+ margin-right: 60px;
+}
+#wpbody-content {
+ float: right;
+}
+/* 2 columns main area */
+#col-right {
+ float: left;
+ clear: left;
+}
+.wrap {
+ margin: 0 5px 0 15px;
+}
+/* styles for use by people extending the WordPress interface */
+body, td, textarea, input, select {
+ font-family: Tahoma, arial;
+}
+.alignleft {
+ float: right;
+}
+.alignright {
+ float: left;
+}
+.subsubsub {
+ float: right;
}
.widefat th {
- padding: 9px 10px 6px 15px;
text-align: right;
}
.widefat th input {
margin: 0 8px 0 0;
}
-.widefat .check-column {
- text-align: left;
-}
.wrap h2 {
- font-family:arial;
- margin: 5px -4px 0 0;
- padding-right:0;
- padding-left: 280px;
+ font-family: arial;
+ padding: 14px 0 3px 15px;
}
.wrap h2.long-header {
padding-left: 0;
}
+.updated, .error {
+ clear: both;
+}
-/* styles for use by people extending the WordPress interface */
+/* http://meyerweb.com/eric/tools/css/reset/ */
+/* v1.0 | 20080212 */
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, font, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ outline: 0;
+/* font-size: 100%;
+ vertical-align: baseline; */
+ background: transparent;
+}
+body {
+ line-height: 1;
+}
+ol, ul {
+ list-style: none;
+}
+blockquote, q {
+ quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+ content: '';
+ content: none;
+}
+/* remember to define focus styles! */
+/*
+:focus {
+ outline: 0;
+}
+*/
+/* remember to highlight inserts somehow! */
+ins {
+ text-decoration: none;
+}
+del {
+ text-decoration: line-through;
+}
-body {
+/* tables still need 'cellspacing="0"' in the markup */
+/*
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+*/
+/* end reset css */
+
+
+/* 2 column liquid layout */
+#wpwrap {
+ height: auto;
+ min-height: 100%;
+ width: 100%;
+}
+
+#wpcontent {
+ height: 100%;
+ padding-bottom: 50px;
+}
+
+#wpbody {
+ clear: both;
+ margin-left: 175px;
+}
+
+.folded #wpbody {
+ margin-left: 60px;
+}
+
+#wpbody-content {
+ float: left;
+ width: 100%;
+}
+
+#adminmenu {
+ float: left;
+ clear: left;
+ width: 145px;
+ margin-top: 15px;
+ margin-right: 5px;
+ margin-bottom: 15px;
+ margin-left: -160px;
+ position: relative;
+ padding: 0;
+ list-style: none;
+}
+
+.folded #adminmenu {
+ margin-left: -45px;
+}
+
+.folded #adminmenu,
+.folded #adminmenu li.menu-top {
+ width: 28px;
+}
+
+#footer {
+ clear: both;
+ position: relative;
+ width: 100%;
+}
+
+/* inner 2 column liquid layout */
+
+.inner-sidebar {
+ float: right;
+ clear: right;
+ width: 280px;
+ position: relative;
+}
+
+.has-sidebar {
+ float: left;
+ clear: left;
+ width: 100%;
+ margin-right: -340px;
+}
+
+.has-sidebar .has-sidebar-content {
+ margin-right: 305px;
+}
+
+/* 2 columns main area */
+
+#col-container {
+ overflow: hidden;
+ padding: 0;
margin: 0;
+}
+
+#col-left {
padding: 0;
+ margin: 0;
+ overflow: hidden;
+ width: 39%;
+}
+
+#col-right {
+ float: right;
+ clear: right;
+ overflow: hidden;
+ padding: 0;
+ margin: 0;
+ width: 59%;
+}
+
+/* utility classes */
+.alignleft {
+ float: left;
+}
+
+.alignright {
+ float: right;
+}
+
+.textleft {
+ text-align: left;
}
-body, td {
- font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
+.textright {
+ text-align: right;
}
-form, label input { margin: 0; padding: 0; }
+.clear {
+ clear: both;
+}
-img { border: 0; }
+.hidden,
+.closed .inside,
+.hide-if-no-js {
+ display: none;
+}
-label { cursor: pointer; }
+/* include margin and padding in the width calculation of input and textarea */
+input[type="text"],
+textarea {
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ -ms-box-sizing: border-box; /* ie8 only */
+ box-sizing: border-box;
+}
+
+input[type="checkbox"],
+input[type="radio"] {
+ vertical-align: text-top;
+}
-li, dd { margin-bottom: 6px; }
+/* styles for use by people extending the WordPress interface */
+html,
+body {
+ height: 100%;
+}
-p, li, dl, dd, dt { line-height: 140%; }
+body,
+td {
+ font: 13px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+}
-textarea, input, select {
- font: 13px Verdana, Arial, Helvetica, sans-serif;
- margin: 1px;
- padding: 3px;
+p {
+ margin: 1em 0;
}
-.alignleft { float: left; }
-.alignright { float: right; }
+blockquote {
+ margin: 1em;
+}
-.textleft { text-align: left; }
-.textright { text-align: right; }
+label {
+ cursor: pointer;
+}
-.clear { clear: both; height: 2px; }
+li,
+dd {
+ margin-bottom: 6px;
+}
-.hidden { display: none; }
+p,
+li,
+dl,
+dd,
+dt {
+ line-height: 140%;
+}
+
+textarea,
+input,
+select {
+ font: 13px/19px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+ margin: 1px;
+ padding: 3px;
+}
h1 {
display: block;
.subsubsub {
list-style: none;
- margin: 14px 0 8px 0;
+ margin: 8px 0 5px;
padding: 0;
white-space: nowrap;
- font-size: 12px;
+ font-size: 11px;
+ float: left;
}
-.subsubsub a { line-height: 200%; padding: 3px; text-decoration: none; }
+.subsubsub a {
+ line-height: 2;
+ padding: .2em;
+ text-decoration: none;
+}
-.subsubsub a.current { font-weight: bold; background: none; border: none;}
+.subsubsub a .count, .subsubsub a.current .count {
+ color: #999;
+ font-weight: normal;
+}
-.subsubsub li { display: inline; margin: 0; padding: 0; }
+.subsubsub a.current {
+ font-weight: bold;
+ background: none;
+ border: none;
+}
+
+.subsubsub li {
+ display: inline;
+ margin: 0;
+ padding: 0;
+}
.widefat {
border-width: 1px;
border-style: solid;
- border-collapse: collapse;
+ border-collapse: separate;
+ border-spacing: 0;
width: 100%;
clear: both;
margin: 0;
+ -moz-border-radius: 4px;
+ -khtml-border-radius: 4px;
+ -webkit-border-radius: 4px;
+ border-radius: 4px;
}
-.widefat a {
- text-decoration: none;
+.widefat * {
+ word-wrap: break-word;
}
-.widefat abbr {
- white-space: nowrap;
+.widefat a {
+ text-decoration: none;
}
-.widefat td, .widefat th {
+.widefat td,
+.widefat th {
border-bottom-width: 1px;
border-bottom-style: solid;
- border-bottom-color: #ccc;
font-size: 11px;
vertical-align: text-top;
}
.widefat td {
- padding: 7px 15px 9px 10px;
+ padding: 7px 7px 5px;
vertical-align: top;
}
+.widefat thead tr th:first {
+ -moz-border-radius-topleft: 4px;
+ -webkit-border-top-left-radius: 4px;
+ -khtml-border-top-left-radius: 4px;
+ border-top-left-radius: 4px;
+}
+
+.widefat thead tr th:last {
+ -moz-border-radius-topright: 4px;
+ -webkit-border-top-right-radius: 4px;
+ -khtml-border-top-right-radius: 4px;
+ border-top-right-radius: 4px;
+}
+
+.widefat tfoot tr th:first {
+ -moz-border-radius-bottomleft: 4px;
+ -webkit-border-bottom-left-radius: 4px;
+ -khtml-border-bottom-left-radius: 4px;
+ border-bottom-left-radius: 4px;
+}
+
+.widefat tfoot tr th:last {
+ -moz-border-radius-bottomright: 4px;
+ -webkit-border-bottom-right-radius: 4px;
+ -khtml-border-bottom-right-radius: 4px;
+ border-bottom-right-radius: 4px;
+}
+
+.widefat td p {
+ font-size: 11px;
+}
+
.widefat th {
- padding: 9px 15px 6px 10px;
+ padding: 7px 7px 8px;
text-align: left;
line-height: 1.3em;
}
.widefat th input {
margin: 0 0 0 8px;
padding: 0;
+ vertical-align: text-top;
}
.widefat .check-column {
- text-align: right;
- width: 1.5em;
+ width: 2.2em;
padding: 0;
}
.widefat tbody th.check-column {
- padding: 8px 0 22px;
-}
-/*
-th.check-column + th, th.check-column + td {
- padding-left: 5px;
+ padding: 7px 0 22px;
}
-*/
-.widefat .num {
+
+.widefat .num,
+.column-comments,
+.column-links,
+.column-posts,
+.column-parent {
text-align: center;
}
-.wrap, .updated, .error {
- margin: 0;
- margin-left: 15px;
- margin-right: 15px;
- padding: 0;
- max-width: 980px;
+.widefat th#comments {
+ vertical-align: middle;
}
-.updated, .error {
+.wrap {
+ margin: 0 15px 0 5px;
+}
+
+.updated,
+.error {
border-width: 1px;
border-style: solid;
padding: 0 0.6em;
- max-width: 950px;
- margin-bottom: 1em;
-}
-
-.updated p, .error p {
- margin: 0.6em 0;
+ margin: 5px 15px 2px;
+ -moz-border-radius: 3px;
+ -khtml-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
}
-.wrap .updated, .wrap .error {
- margin: auto 0 0;
+.updated p,
+.error p {
+ margin: 0.5em 0;
+ line-height: 1;
+ padding: 2px;
}
-.updated a, .error a {
- text-decoration: underline;
-}
-
-.updated a {
- text-decoration: none;
- padding-bottom: 2px;
+.wrap .updated,
+.wrap .error {
+ margin: 5px 0;
}
.wrap h2 {
- border-bottom-width: 1px;
- border-bottom-style: solid;
- clear: both;
- font: 24px Georgia, "Times New Roman", Times, serif;
- margin: 5px 0 0 -4px;
- padding: 0;
- padding-bottom: 7px;
- padding-right: 280px;
+ font: italic normal normal 24px/29px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+ margin: 0;
+ padding: 14px 15px 3px 0;
+ line-height: 35px;
+ text-shadow: rgba(255,255,255,1) 0px 1px 0px;
}
.wrap h2.long-header {
-#poststuff .postbox h3 {
- padding-left:0;
- padding-right: 23px;
+* html #wpcontent #adminmenu .wp-has-submenu .wp-menu-toggle {
+ background: url(../images/menu-bits-rtl.gif) no-repeat scroll right -109px;
}
-* html #poststuff .postarea, * html #poststuff #titlediv {
+
+* html #wpcontent #adminmenu li.wp-has-current-submenu .wp-menu-toggle {
+ background: url(../images/menu-bits-rtl.gif) no-repeat scroll right -206px;
+}
+* html #adminmenu {
margin-left:0;
- margin-right: 3%;
+ margin-right: -80px;
+}
+* html div.folded #adminmenu {
+ margin-left: 0;
+ margin-right: -22px;
+}
+#wpcontent #adminmenu .wp-submenu li.wp-submenu-head {
+ padding: 3px 10px 4px 4px;
+}
+.inline-edit-row fieldset label span.title {
+ float: right;
+}
+.inline-edit-row fieldset label span.input-text-wrap {
+ margin-right: 0;
+}
+p.search-box {
+ float: left;
}
* html #poststuff h2 {
margin-right: 0;
}
#bh {
- padding-right:0;
- padding-left: 15px;
+ margin: 7px 10px 0 0;
+ float: left;
+}
+#user_info + div#favorite-actions {
+ right: auto;
+ left: 15px;
+}
+#wphead-info {
+ float: left;
}
+/* without this dashboard widgets appear in one column for some screen widths */
div#dashboard-widgets {
- padding-right:0;
+ padding-right: 0;
padding-left: 1px;
}
#tagchecklist span a {
margin: 4px -9px 0 0;
}
-#poststuff .togbox {
- margin-left:0;
- margin-right: -19px;
-}
.widefat th input {
margin: 0 5px 0 0;
}
/* ---------- add by navid */
-#dashmenu { /* fix top right bottom in admin */
- direction:ltr;
-}
-#sidemenu a { /* fix left admin buttom ex. plugins, options */
- float:left;
+#TB_window {
+ width: 670px;
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ margin-right: 335px !important;
}
-.wrap h2 {
- margin:5px 4px 0 0;
+#dashboard_plugins {
+ direction: ltr;
}
-#editor-toolbar {/* fix hover in media uploader icon */
- direction:ltr;
+#dashboard_plugins h3.hndle {
+ direction: rtl;
}
-#TB_window { /* fix theme preview */
- left:2%;
+#dashboard_incoming_links ul li,
+#dashboard_secondary ul li,
+#dashboard_primary ul li,
+p.row-actions {
+ width: 100%;
}
-/* fix widget page */
-form#widgets-filter {
- position:static;
+#favorite-inside {
+ position: absolute;
+ right:0;
}
-#widget-search {
- display:none;
+#post-status-info {
+ height: 25px;
}
-/* fix manage comment page */
-ul.view-switch li {
- float:left;
+#screen-meta {
+ position: static;
}
-form#posts-filter {
- position:static;
+p.submit { /* quick edit and reply in edit-comments.php */
+ height:22px;
}
-#post-search {
- display:none;
+.inner-sidebar { /* fix edit single comment */
+ position: static;
}
-#submenu {
- margin-right: 20px;
+form#widgets-filter { /* fix widget page */
+ position: static;
}
-/* Fixes for media-upload window */
-/* Center media-upload panel on screen */
-#TB_window {
- width: 670px;
- position: absolute;
- top: 50%;
- left: 50%;
- margin-right: 335px !important; }
/* Fixes for IE bugs */
-#poststuff .postbox h3 {
- padding-left: 23px;
+input.button,
+input.button-secondary,
+input.button-highlighted {
+ padding: 0;
+}
+
+#minor-publishing-actions input,
+#major-publishing-actions input,
+#minor-publishing-actions .preview {
+ min-width: auto;
+ padding-left: 0;
+ padding-right: 0;
+}
+
+#wpbody-content .postbox {
+ border: 1px solid #dfdfdf;
+}
+
+#wpbody-content .postbox h3 {
+ margin-bottom: -1px;
}
-#submenu li a.current {
- background:none;
- border:none;
+* html #side-info-column {
+ height: auto;
}
+* html #wpbody-content #screen-options-link-wrap {
+ display: inline-block;
+ width: 150px;
+ text-align: center;
+}
+
+* html #wpbody-content #contextual-help-link-wrap {
+ display: inline-block;
+ width: 100px;
+ text-align: center;
+}
+
+/*
* html body.minwidth {
_width: expression(document.documentElement.clientWidth < 810 ? "808px" : "99.9%");
}
* html #wpbody {
_width: expression(document.documentElement.clientWidth > 982 ? "980px" : "99.9%");
}
+*/
-* html #poststuff .postarea, * html #poststuff #titlediv {
- width: 95%;
- margin-left: 3%;
+* html #adminmenu {
+ margin-left: -80px;
+}
+
+* html div.folded #adminmenu {
+ margin-left: -22px;
+}
+
+* html #wpcontent #adminmenu li.menu-top {
+ display: inline;
+ padding: 0;
+ margin: 0;
+}
+
+#wpcontent.folded #adminmenu li.menu-top {
+ display: block;
+}
+
+ul#adminmenu {
+ z-index: 99;
+}
+
+#adminmenu li.menu-top a.menu-top {
+ min-width: auto;
+ width: auto;
+}
+
+#wpcontent #adminmenu li.wp-has-current-submenu a.wp-has-submenu {
+ font-style: normal;
+}
+
+* html #wpcontent #adminmenu .wp-menu-open .wp-menu-toggle {
+ background: none;
+}
+
+* html #wpcontent #adminmenu .wp-has-submenu .wp-menu-toggle {
+ background: url(../images/menu-bits.gif) no-repeat scroll left -109px;
+}
+
+* html #wpcontent #adminmenu li.wp-has-current-submenu .wp-menu-toggle {
+ background: url(../images/menu-bits.gif) no-repeat scroll left -206px;
+}
+
+* html #adminmenu div.wp-menu-image {
+ height: 29px;
+}
+
+#wpcontent #adminmenu .wp-submenu li {
+ padding: 0;
+}
+
+#adminmenu,
+.wp-submenu,
+.wp-submenu li,
+.wp-menu-toggle {
+ zoom: 100%;
+}
+
+#wpcontent.folded #adminmenu li.wp-menu-separator {
+ width: 28px;
+}
+
+#wpcontent #adminmenu .wp-submenu li.wp-submenu-head {
+ padding: 3px 4px 4px 10px;
+ zoom: 100%;
+}
+
+#wpcontent.folded #adminmenu .menu-top {
+ height: 30px;
+}
+
+.folded #adminmenu .wp-submenu {
+ margin: -1px 0 0 0;
+}
+
+#template,
+#template div,
+#editcat,
+#addcat {
+ zoom: 100%;
}
.submitbox {
margin-top: 10px;
}
-* html div.widget-liquid-left-holder, * html div.widget-liquid-right {
+/* Inline Editor */
+#wpbody-content .quick-edit-row-post .inline-edit-col-left {
+ width: 39%;
+}
+
+#wpbody-content .inline-edit-row-post .inline-edit-col-center {
+ width: 19%;
+}
+
+#wpbody-content .quick-edit-row-page .inline-edit-col-left {
+ width: 49%;
+}
+
+#wpbody-content .bulk-edit-row .inline-edit-col-left {
+ width: 29%;
+}
+
+.inline-edit-row p.submit {
+ zoom: 100%;
+}
+
+.inline-edit-row fieldset label span.title {
+ display: block;
+ float: left;
+ width: 5em;
+}
+
+.inline-edit-row fieldset label span.input-text-wrap {
+ margin-left: 0;
+ zoom: 100%;
+}
+
+#wpbody-content .inline-edit-row fieldset label span.input-text-wrap input {
+ line-height: 130%;
+}
+
+#wpbody-content .inline-edit-row .input-text-wrap input {
+ width: 95%;
+}
+
+#wpbody-content .inline-edit-row .input-text-wrap input.inline-edit-password-input {
+ width: 8em;
+}
+/* end Inline Editor */
+
+input {
+ line-height: 1;
+}
+
+* html .row-actions {
+ visibility: visible;
+}
+
+#dashboard-widgets h3 a {
+ height: 20px;
+ line-height: 20px;
+}
+
+#the-comment-list .comment-item,
+ul#widget-list li.widget-list-item {
+ zoom: 100%;
+}
+
+#wphead-info {
+ float: right;
+}
+
+#titlediv #title {
+ width: 98%;
+}
+
+a.button {
+ line-height: 1.4em;
+ margin: 1px;
+}
+
+* html div.widget-liquid-left-holder,
+* html div.widget-liquid-right {
display: block;
position: relative;
}
-#wpwrap, #wpcontent, #post, #wrap, #postdivrich, #postdiv, #poststuff, #titlediv, #post-body, #editorcontainer, .tablenav, .widget-control-list, li.widget-list-control-item, #dragHelper, li.widget-list-control-item h4, .widget-sortable, .widget-control-actions {
+#screen-options-wrap {
+ overflow: hidden;
+}
+
+#favorite-actions {
+ z-index: 12;
+}
+
+#favorite-inside,
+#favorite-inside a,
+.favorite-action {
+ zoom: 100%;
+}
+
+#post-status-info,
+#wpwrap,
+#wpcontent,
+#post,
+#wrap,
+#postdivrich,
+#postdiv,
+#poststuff,
+.metabox-holder,
+#titlediv,
+#post-body,
+#editorcontainer,
+.tablenav,
+.widget-control-list,
+li.widget-list-control-item,
+#dragHelper,
+li.widget-list-control-item h4,
+.widget-sortable,
+.widget-control-actions,
+#tagchecklist,
+#col-container,
+#col-left,
+#col-right {
display: block;
zoom: 100%;
}
+p.search-box {
+ position: static;
+ float: right;
+ margin: -3px 0 4px;
+}
+
* html #editorcontainer {
padding: 0;
}
-* html #editorcontainer #content {
- position: relative;
+#editorcontainer #content {
overflow: auto;
- padding: 6px;
margin: auto;
width: 98%;
}
width: 100%;
}
-#ed_toolbar input {
+#ed_toolbar input,
+#ed_reply_toolbar input {
overflow: visible;
padding: 0 4px;
}
}
#bh {
- padding-right: 15px;
+ margin: 7px 10px 0 0;
+ float: right;
}
/* without this dashboard widgets appear in one column for some screen widths */
padding-right: 1px;
}
-#tagchecklist {
- display: block;
- zoom: 100%;
-}
-
#tagchecklist span, #tagchecklist span a {
display: inline-block;
display: block;
margin: 4px 0 0 -9px;
}
-#poststuff .togbox {
- margin-left: -19px;
-}
-
.tablenav .button-secondary, .nav .button-secondary {
padding: 0 1px;
vertical-align: middle;
margin-top: 2px;
}
-.tablenav-pages .page-numbers {
- display: inline-block;
-}
-
-.tablenav-pages {
- display: block;
- margin-top: -3px;
-}
-
table.ie-fixed {
table-layout: fixed;
}
-#post-search .button, #widget-search .button {
- padding: 1px;
-}
-
.widefat tr, .widefat th {
margin-bottom: 0;
border-spacing: 0;
body {
- font-family: Tahoma;
+ font-family: Tahoma, arial;
}
-/* Half the page disapears on IE6 */
-* html body {
- width: 700px;
- position: absolute;
- left: 50%;
- margin-right: 350px;
-}
-ul, ol {
- padding: 5px 22px 5px 5px;
-}
-.step, th {
- text-align:right;
+h1 {
+ font-family: arial;
+ margin: 5px -4px 0 0;
}
-.submit input, .button, .button-secondary {
- font-family: Tahoma;
+ul, ol { padding: 5px 22px 5px 5px; }
+.step, th { text-align: right; }
+.submit input, .button, .button-secondary {
+ font-family: Tahoma, arial;
margin-right:0;
}
.form-table th {
- text-align:right;
-}
-h1 {
- font-family:arial;
- margin: 5px -4px 0 0;
+ text-align: right;
}
-html { background: #f1f1f1; }
+html { background: #f7f7f7; }
body {
background: #fff;
color: #333;
- font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
margin: 2em auto 0 auto;
width: 700px;
padding: 1em 2em;
- -moz-border-radius: 12px;
- -khtml-border-radius: 12px;
- -webkit-border-radius: 12px;
- border-radius: 12px;
+ -moz-border-radius: 11px;
+ -khtml-border-radius: 11px;
+ -webkit-border-radius: 11px;
+ border-radius: 11px;
+ border: 1px solid #dfdfdf;
}
a { color: #2583ad; text-decoration: none; }
a:hover { color: #d54e21; }
-
h1 {
- font-size: 18px;
- margin-bottom: 0;
+ border-bottom: 1px solid #dadada;
+ clear: both;
+ color: #666;
+ font: 24px Georgia, "Times New Roman", Times, serif;
+ margin: 5px 0 0 -4px;
+ padding: 0;
+ padding-bottom: 7px;
}
h2 { font-size: 16px; }
p, li {
padding-bottom: 2px;
- font-size: 13px;
+ font-size: 12px;
line-height: 18px;
}
-code {
- font-size: 13px;
-}
+code { font-size: 13px; }
ul, ol { padding: 5px 5px 5px 22px; }
-#logo { margin: 6px 0 14px 0px; border-bottom: none;}
+#logo { margin: 6px 0 14px 0; border-bottom: none;}
.step {
margin: 20px 0 15px;
}
-.step input {
- font-size: 18px;
-}
-
-a.button {
- font-size: 18px;
-}
-
.step, th { text-align: left; padding: 0; }
.submit input, .button, .button-secondary {
- font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
- padding: 5px 7px 7px;
- border: 1px solid #a3a3a3;
- margin-left: 0;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
- color: #246;
- background: #e5e5e5;
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+ text-decoration: none;
+ font-size: 14px !important;
+ line-height: 16px;
+ padding: 6px 12px;
+ cursor: pointer;
+ border: 1px solid #bbb;
+ color: #464646;
+ -moz-border-radius: 15px;
+ -khtml-border-radius: 15px;
+ -webkit-border-radius: 15px;
+ border-radius: 15px;
+ -moz-box-sizing: content-box;
+ -webkit-box-sizing: content-box;
+ -khtml-box-sizing: content-box;
+ box-sizing: content-box;
+}
+
+.button:hover, .button-secondary:hover, .submit input:hover {
+ color: #000;
+ border-color: #666;
}
-.button-secondary {
- background: #cee1ef;
+.button, .submit input, .button-secondary {
+ background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;
}
-.submit input:hover, .button:hover, .button-secondary:hover {
- color: #d54e21;
- border-color: #535353;
+.button:active, .submit input:active, .button-secondary:active {
+ background: #eee url(../images/white-grad-active.png) repeat-x scroll left top;
}
.form-table {
}
.form-table tr {
- background: #eaf3fa;
+ background: #f3f3f3;
}
.form-table code {
padding: 2px;
}
-h1 {
- border-bottom: 1px solid #dadada;
- clear: both;
- color: #666666;
- font: 24px Georgia, "Times New Roman", Times, serif;
- margin: 5px 0 0 -4px;
- padding: 0;
- padding-bottom: 7px;
-}
-
-#error-page {
- margin-top: 50px;
-}
+#error-page { margin-top: 50px; }
#error-page p {
- font-size: 14px;
- line-height: 16px;
+ font-size: 12px;
+ line-height: 18px;
margin: 25px 0 20px;
}
-#error-page code {
- font-size: 15px;
-}
\ No newline at end of file
+#error-page code { font-family: Consolas, Monaco, Courier, monospace; }
body {
- font-family: Tahoma;
+ font-family: Tahoma, arial;
}
form {
- margin-left:0;
margin-right: 8px;
+ margin-left: 0;
}
form .forgetmenot {
- float:right;
+ float: right;
}
-#login form .submit input {
- font-family: Tahoma;
-}
-form .submit {
- float:left;
+#login form .submit input {
+ font-family: Tahoma, arial;
}
+form .submit { float: left; }
#backtoblog a {
- left:auto;
- right:15px;
+ left: auto;
+ right: 15px;
}
#login_error, .message {
margin: 0 8px 16px 0;
}
-#nav {
- margin:0 8px 0 0;
-}
+#nav { margin: 0 8px 0 0; }
#user_pass, #user_login, #user_email {
- margin-right:0;
margin-left: 6px;
+ margin-right: 0;
+ direction:ltr;
}
h1 a {
- text-decoration:none;
-}
-/* ltr input */
-#user_login, #user_pass {
- direction:ltr;
+ text-decoration: none;
}
body {
border-top-width: 30px;
border-top-style: solid;
- font: 12px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
+ font: 11px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
}
form {
margin-left: 8px;
padding: 16px 16px 40px 16px;
- font-weight: bold;
- -moz-border-radius: 5px;
- -khtml-border-radius: 5px;
- -webkit-border-radius: 5px;
+ font-weight: normal;
+ -moz-border-radius: 11px;
+ -khtml-border-radius: 11px;
+ -webkit-border-radius: 11px;
border-radius: 5px;
+ background: #fff;
+ border: 1px solid #e5e5e5;
+ -moz-box-shadow: rgba(200,200,200,1) 0 4px 18px;
+ -webkit-box-shadow: rgba(200,200,200,1) 0 4px 18px;
+ -khtml-box-shadow: rgba(200,200,200,1) 0 4px 18px;
+ box-shadow: rgba(200,200,200,1) 0 4px 18px;
}
-form .forgetmenot { font-weight: normal; float: left; margin-bottom: 0;}
+form .forgetmenot { font-weight: normal; float: left; margin-bottom: 0; }
#login form .submit input {
- font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
- padding: 3px 5px;
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+ padding: 3px 10px;
border: none;
- font-size: 13px;
+ font-size: 12px;
border-width: 1px;
border-style: solid;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
- cursor: default;
- text-decoration: none;
- margin-top: -6px;
+ -moz-border-radius: 11px;
+ -khtml-border-radius: 11px;
+ -webkit-border-radius: 11px;
+ border-radius: 11px;
+ cursor: pointer;
+ text-decoration: none;
+ margin-top: -3px;
+ text-shadow: rgba(0,0,0,0.3) 0 -1px 0;
+}
+
+#login form p {
+ margin-bottom: 0;
+}
+
+label {
+ color: #777;
+ font-size: 13px;
+}
+
+form .forgetmenot label {
+ font-size: 11px;
+ line-height: 19px;
}
form .submit { float: right; }
form p { margin-bottom: 24px; }
h1 a {
- background: url(../images/logo-login.gif) no-repeat;
- width: 292px;
- height: 66px;
+ background: url(../images/logo-login.gif) no-repeat top center;
+ width: 326px;
+ height: 67px;
text-indent: -9999px;
overflow: hidden;
padding-bottom: 15px;
display: block;
}
+#nav {
+ text-shadow: rgba(255,255,255,1) 0 1px 0;
+}
+
#backtoblog a {
position: absolute;
top: 7px;
text-decoration: none;
}
-#login { width: 292px; margin: 7em auto; }
+#login { width: 320px; margin: 7em auto; }
#login_error, .message {
margin: 0 0 16px 8px;
border-width: 1px;
border-style: solid;
padding: 12px;
+ -moz-border-radius: 3px;
+ -khtml-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
}
#nav { margin: 0 0 0 8px; padding: 16px; }
#user_pass, #user_login, #user_email {
- font-size: 20px;
+ font-size: 24px;
width: 97%;
padding: 3px;
+ margin-top: 2px;
margin-right: 6px;
-}
\ No newline at end of file
+ margin-bottom: 16px;
+ border: 1px solid #e5e5e5;
+ background: #fbfbfb;
+}
body#media-upload ul#sidemenu {
- left:auto;
- right:0;
- width: 620px;
+ left: auto;
+ right: 0;
}
#search-filter {
- text-align:left;
+ text-align: left;
}
+/* specific to the image upload form */
.align .field label {
padding: 0 28px 0 0;
margin: 0 0 0 1em;
}
.image-align-none-label, .image-align-left-label, .image-align-center-label, .image-align-right-label {
- background-position:center right;
+ background-position: center right;
+}
+tr.image-size div.image-size-item {
+ float: right;
}
tr.image-size label {
- margin: 0 0 0 1em;
+ margin: 0 1em 0 0;
}
.filename.original {
float: right;
}
.crunching {
text-align: left;
- margin-right:0;
+ margin-right: 0;
margin-left: 5px;
}
button.dismiss {
- right:auto;
- left:5px;
+ right: auto;
+ left: 5px;
}
.file-error {
margin: 0 50px 5px 0;
}
.progress {
- left:auto;
- right:0;
+ left: auto;
+ right: 0;
+}
+.describe td {
+ padding: 0 0 0 5px;
}
.bar {
- border-right-width:0;
+ border-right-width: 0;
border-left-width: 3px;
+ border-right-style: none;
border-left-style: solid;
}
.media-item .pinkynail {
- float:right;
+ float: right;
}
-.describe-toggle-on, .describe-toggle-off {
+.describe-toggle-on,
+.describe-toggle-off {
float: left;
- margin-right:0;
+ margin-right: 0;
margin-left: 20px;
}
/* Specific to Uploader */
-
#media-upload .media-upload-form p {
margin: 0 0 1em 1em;
}
.filename {
float: right;
- margin-left:0;
+ margin-left: 0;
margin-right: 10px;
}
#media-upload .describe th.label {
- text-align:right;
+ text-align: right;
}
.menu_order {
- float:left;
+ float: left;
+}
+.media-upload-form label.form-help, td.help, #media-upload p.help, #media-upload label.help {
+ font-family: Tahoma, Arial;
+}
+#gallery-settings #basic th.label {
+ padding: 5px 0 5px 5px;
+}
+#gallery-settings .title, h3.media-title {
+ font-family: Tahoma, Arial;
+}
+#gallery-settings .describe th.label {
+ text-align: right;
+}
+#gallery-settings label,
+#gallery-settings legend {
+ margin-right: 0;
+ margin-left: 15px;
+}
+#gallery-settings .align .field label {
+ margin: 0 0 0 1.5em;
}
text-align: right;
}
-.media-upload-form label, .media-upload-form legend {
- display:block;
+.media-upload-form label,
+.media-upload-form legend {
+ display: block;
font-weight: bold;
font-size: 13px;
margin-bottom: 0.5em;
margin: 0 0 0.5em 0;
}
-th { position: relative; }
+th {
+ position: relative;
+}
.media-upload-form label.form-help, td.help {
+ font-family: "Lucida Grande", "Bitstream Vera Sans", Verdana, Arial, sans-serif;
font-style: italic;
font-weight: normal;
}
padding: 0 0 0 28px;
margin: 0 1em 0 0;
}
+
.image-align-none-label {
background: url(../images/align-none.png) no-repeat center left;
}
background: url(../images/align-right.png) no-repeat center left;
}
-#flash-upload-ui, .insert-gallery {
- display: none;
+tr.image-size td {
+ width: 460px;
+}
+
+tr.image-size div.image-size-item {
+ float: left;
+ width: 25%;
+ margin: 0;
}
tr.image-size label {
display: inline;
- margin: 0 1em 0 0;
+ margin: 0 0 0 1em;
}
+
.pinkynail {
max-width: 40px;
max-height: 40px;
.filename.original {
float: left;
}
+
.crunching {
display: block;
line-height: 32px;
text-align: right;
margin-right: 5px;
}
+
button.dismiss {
position: absolute;
- top: 5px;
+ top: 7px;
right: 5px;
z-index: 4;
+ width: 8em;
}
+
.file-error {
- margin: 0 0 5px 50px;
+ float: left;
font-weight: bold;
+ padding: 10px;
}
.progress {
position: absolute;
- top: 0px;
- left: 0px;
+ top: 0;
+ left: 0;
width: 623px;
height: 36px;
}
+
.bar {
- width: 0px;
+ width: 0;
height: 100%;
border-right-width: 3px;
border-right-style: solid;
}
-#library-form .progress, #gallery-form .progress {
+#library-form .progress,
+#gallery-form .progress,
+#flash-upload-ui,
+.insert-gallery,
+.describe.startopen,
+.describe.startclosed {
display: none;
}
max-width: 128px;
max-height: 128px;
}
+
.media-item .pinkynail {
float: left;
margin: 2px;
thead.media-item-info tr {
background-color: transparent;
}
-thead.media-item-info th, thead.media-item-info td {
+
+thead.media-item-info th,
+thead.media-item-info td {
border: none;
margin: 0;
}
border: 8px solid #fff;
}
-.describe.startopen, .describe.startclosed {
- display: none;
-}
abbr.required {
text-decoration: none;
border: none;
}
+
.describe label {
display: inline;
}
+
.describe td {
vertical-align: middle;
+ padding: 0 5px 0 0;
}
+
.describe td.A1 {
width: 132px;
}
-.describe input[type="text"], .describe textarea {
+
+.describe input[type="text"],
+.describe textarea {
width: 460px;
+ border-width: 1px;
+ border-style: solid;
}
-.describe-toggle-on, .describe-toggle-off {
+
+.describe-toggle-on,
+.describe-toggle-off {
display: block;
line-height: 36px;
float: right;
margin-right: 20px;
}
+
.describe-toggle-off {
display: none;
}
-.clickmask {
-}
-
.hidden {
- height: 0px;
- width: 0px;
+ height: 0;
+ width: 0;
overflow: hidden;
border: none;
}
padding: 1em 0;
}
-#media-upload p.help {
+#media-upload p.help,
+#media-upload label.help {
+ font-family: "Lucida Grande", "Bitstream Vera Sans", Verdana, Arial, sans-serif;
font-style: italic;
font-weight: normal;
}
+
#media-upload tr.image-size td.field {
text-align: center;
}
+
#media-upload #media-items {
border-width: 1px;
border-style: solid;
overflow: hidden;
max-width: 430px;
}
+
#media-upload .describe {
- border-top-width: 1px;
- border-top-style: solid;
padding: 5px;
width: 100%;
clear: both;
cursor: default;
}
+
+#media-upload .slidetoggle {
+ border-top-width: 1px;
+ border-top-style: solid;
+}
+
#media-upload .describe th.label {
padding-top: .5em;
text-align: left;
+ min-width: 120px;
}
+
#media-upload tr.align td.field {
text-align: center;
}
+
#media-upload tr.image-size {
margin-bottom: 1em;
height: 3em;
}
#filter .tablenav select {
- border-style:solid;
- border-width:1px;
- padding:2px;
- vertical-align:top;
+ border-style: solid;
+ border-width: 1px;
+ padding: 2px;
+ vertical-align: top;
+ width: auto;
}
#media-upload a.delete,
}
.menu_order_input {
- border: 1px solid #DDDDDD;
+ border: 1px solid #ddd;
font-size: 10px;
padding: 1px;
width: 23px;
}
#media-upload th.order-head {
- width: 25%;
- text-align: center;
+ width: 25%;
+ text-align: center;
}
#media-upload .widefat {
.sorthelper {
z-index: -1;
}
+
+#gallery-settings th.label {
+ width: 160px;
+}
+
+#gallery-settings #basic th.label {
+ padding: 5px 5px 5px 0;
+}
+
+#gallery-settings .title {
+ clear: both;
+ padding: 0 0 3px;
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ font-family: Georgia,"Times New Roman",Times,serif;
+ font-size: 1.6em;
+ border-bottom-color: #DADADA;
+ color: #5A5A5A;
+}
+
+h3.media-title {
+ color: #5A5A5A;
+ font-family: Georgia,"Times New Roman",Times,serif;
+ font-size: 1.6em;
+ font-weight: normal;
+}
+
+#gallery-settings .describe td {
+ vertical-align: middle;
+ height: 3.5em;
+}
+
+#gallery-settings .describe th.label {
+ padding-top: .5em;
+ text-align: left;
+}
+
+#gallery-settings .describe {
+ padding: 5px;
+ width: 615px;
+ clear: both;
+ cursor: default;
+}
+
+#gallery-settings .describe select {
+ width: 15em;
+ border: 1px solid #dfdfdf;
+}
+
+#gallery-settings label,
+#gallery-settings legend {
+ font-size: 13px;
+ color: #464646;
+ margin-right: 15px;
+}
+
+#gallery-settings .align .field label {
+ margin: 0 1.5em 0 0;
+}
+
+#gallery-settings p.ml-submit {
+ border-top: 1px solid #dfdfdf;
+}
+
+#gallery-settings select#columns {
+ width: 6em;
+}
--- /dev/null
+div.star {
+ left: auto;
+ right: 0;
+ letter-spacing: 0;
+}
+.star img, div.star a, div.star a:hover, div.star a:visited {
+ right: auto;
+ left: 0;
+}
+#plugin-information ul#sidemenu {
+ left: auto;
+ right: 0;
+}
+#plugin-information h2 {
+ margin-right: 0;
+ margin-left: 200px;
+}
+#plugin-information .fyi {
+ margin-left: 5px;
+ margin-right: 20px;
+}
+#plugin-information .fyi h2 {
+ margin-left: 0;
+}
+#plugin-information .fyi ul {
+ padding: 10px 7px 10px 5px;
+}
+#plugin-information #section-screenshots li p {
+ padding-left: 0;
+ padding-right: 20px;
+}
+#plugin-information .updated,
+#plugin-information pre {
+ margin-right: 0;
+ margin-left: 215px;
+}
+#plugin-information .updated, #plugin-information .error {
+ clear: none;
+ direction: rtl;
+}
+#section-description {
+ direction: ltr;
+}
--- /dev/null
+/* NOTE: the following CSS rules(.star*) are taken more or less straight from the bbPress rating plugin. */
+div.star-holder {
+ position: relative;
+ height: 19px;
+ width: 100px;
+ font-size: 19px;
+}
+
+div.star {
+ height: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+ background-color: transparent;
+ letter-spacing: 1ex;
+ border: none;
+}
+
+.star1 { width: 20%; }
+.star2 { width: 40%; }
+.star3 { width: 60%; }
+.star4 { width: 80%; }
+.star5 { width: 100%; }
+
+.star img, div.star a, div.star a:hover, div.star a:visited {
+ display: block;
+ position: absolute;
+ right: 0;
+ border: none;
+ text-decoration: none;
+}
+
+div.star img {
+ width: 19px;
+ height: 19px;
+ border-left: 1px solid #fff;
+ border-right: 1px solid #fff;
+}
+
+/* Start custom CSS */
+/* Header on thickbox */
+#plugin-information-header {
+ margin: 0;
+ padding: 0 5px;
+ font-weight: bold;
+ position: relative;
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
+ height: 2.5em;
+}
+#plugin-information ul#sidemenu {
+ font-weight: normal;
+ margin: 0 5px;
+ position: absolute;
+ left: 0;
+ bottom: -1px;
+}
+
+/* Install sidemenu */
+#plugin-information p.action-button {
+ width: 100%;
+ padding-bottom: 0;
+ margin-bottom: 0;
+ margin-top: 10px;
+ -moz-border-radius: 3px 0 0 3px;
+ -webkit-border-top-left-radius: 3px;
+ -khtml-border-top-left-radius: 3px;
+ border-top-left-radius: 3px;
+ -webkit-border-bottom-left-radius: 3px;
+ -khtml-border-bottom-left-radius: 3px;
+ border-top-bottom-radius: 3px;
+}
+
+#plugin-information .action-button a {
+ text-align: center;
+ font-weight: bold;
+ text-decoration: none;
+ display: block;
+ line-height: 2em;
+}
+
+#plugin-information h2 {
+ clear: none !important;
+ margin-right: 200px;
+}
+
+#plugin-information .fyi {
+ margin-left: 10px;
+ margin-bottom: 50px;
+ width: 210px;
+}
+
+#plugin-information .fyi h2 {
+ font-size: 0.9em;
+ margin-bottom: 0;
+ margin-right: 0;
+}
+
+#plugin-information .fyi h2.mainheader {
+ padding: 5px;
+ -moz-border-radius-topleft: 3px;
+ -webkit-border-top-left-radius: 3px;
+ -khtml-border-top-left-radius: 3px;
+ border-top-left-radius: 3px;
+}
+
+#plugin-information .fyi ul {
+ padding: 10px 5px 10px 7px;
+ margin: 0;
+ list-style: none;
+ -moz-border-radius-bottomleft: 3px;
+ -webkit-border-bottom-left-radius: 3px;
+ -khtml-border-bottom-left-radius: 3px;
+ border-top-bottom-radius: 3px;
+}
+
+#plugin-information .fyi li {
+ margin-right: 0;
+}
+
+#plugin-information #section-holder {
+ padding: 10px;
+}
+
+#plugin-information .section ul,
+#plugin-information .section ol {
+ margin-left: 16px;
+ list-style-type: square;
+ list-style-image: none;
+}
+
+#plugin-information #section-screenshots li img {
+ vertical-align: text-top;
+}
+
+#plugin-information #section-screenshots li p {
+ font-style: italic;
+ padding-left: 20px;
+ padding-bottom: 2em;
+}
+
+#plugin-information .updated,
+#plugin-information pre {
+ margin-right: 215px;
+}
+
+#plugin-information pre {
+ padding: 7px;
+}
\ No newline at end of file
+++ /dev/null
-.ui-tabs-nav {
- margin-right: 0;
-}
+++ /dev/null
-#posting {
- position: static !important;
-}
- .ui-tabs-nav {
- margin-left: 0;
- border: 0 !important;
-}
body {
- font-family: Tahoma;
+ font-family: Tahoma, Arial;
}
-.ui-tabs-nav {
- padding-left:0;
- padding-right:8px;
-}
-.ui-tabs-nav li {
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML {
+ margin: 0px 0 0 5px;
float: right;
}
-.button {
- font-family: Tahoma;
- margin-left:0;
- margin-right: 5px;
+/* Editor/Main Column */
+div#poststuff {
+ padding-left: 0;
+ padding-right: 10px;
}
-#wphead #viewsite {
- margin-left:0;
- margin-right: 10px;
+.posting {
+ margin-right: 0;
+ margin-left: 228px;
+ left:auto;
+ right: 0;
}
-#viewsite {
- right:auto;
- left: 8px;
+#side-info-column {
+ float: left;
+ right: auto;
+ left: 0;
+ margin-right: 0;
+ margin-left: 10px;
}
-#wphead #viewsite a {
- font-family: Tahoma;
+#side-info-column .sleeve {
+ padding-left: 0;
+ padding-right: 10px;
}
-h1 {
- right:auto;
- left:0;
+h3.tb {
+ margin-left: 0;
+ margin-right: 5px;
}
-div#posting {
- padding-left:0;
- padding-right: 16px;
+#actions {
+ float: left;
}
-#photo_directions span {
- right:auto;
- left:3px;
+#extra_fields #actions {
+ right: auto;
+ left: 4px;
}
-#img_container a {
- float:right;
+#actions li {
+ float: right;
+ margin-right: 0;
+ margin-left: 10px;
+}
+#extra_fields .button {
+ margin-right: 0;
+ margin-left: 5px;
}
-#img_container a, #img_container a:link, #img_container a:visited {
- margin:0 0 4px 4px;
+/* Photo Styles */
+#img_container a {
+ float: right;
}
-div#categories {
- right:auto;
- left:16px;
+#category-add input, #category-add select {
+ font-family: Tahoma, Arial;
}
-div#categories h2 {
- margin: .5em 1em .5em 0;
+#categorydiv ul.categorychecklist ul {
+ margin-left: 0;
+ margin-right: 18px;
}
+/* Tags */
#tagsdiv #newtag {
- margin-right:0;
- margin-left: 5px;
-}
-#jaxtag {
- padding-left:0;
- padding-right: 1em;
+ margin-right: 0;
+ margin-left: 5px;
}
-#tagchecklist {
- padding-left:0;
- padding-right: 1em;
+#tagadd {
+ margin-left: 0;
+ margin-right: 3px;
}
#tagchecklist span {
- margin-right: 10px;
margin-left: .5em;
+ margin-right: 10px;
float: right;
}
#tagchecklist span a {
- margin: 6px -9px 0pt 0;
+ margin: 6px -9px 0 0;
float: right;
}
-.submitbox {
- float: left;
-}
-.submitbox .submit input {
- text-align:right;
+#content {
+ margin-left: 0;
+ margin-right: 1%;
}
-.video_split #extra_fields {
- float:right;
-}
-.video_split .editor_area {
- float: left;
+.submit input,
+.button,
+.button-primary,
+.button-secondary,
+.button-highlighted,
+#postcustomstuff .submit input {
+ font-family: tahoma;
}
.ac_results li {
- text-align:right;
+ text-align: right;
}
#TB_ajaxContent #options {
- right:auto;
- left:25px;
+ right: auto;
+ left: 25px;
}
#post_status {
- margin-left:0;
+ margin-left: 0;
margin-right: 10px;
}
+/* Footer */
#footer {
padding: 10px 60px 0 0;
}
body {
- font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
+ font: 13px "Lucida Grande", "Bitstream Vera Sans", Verdana, Arial, sans-serif;
color: #333;
- margin: 0px;
- padding: 0px;
+ margin: 0;
+ padding: 0;
}
-img { border: 0; }
-/* Tabs */
-@media projection , screen {
- .ui-tabs-hide {
- display: none;
- }
+img {
+ border: none;
}
-@media print {
- .ui-tabs-nav {
- display: none;
- }
+/* Header */
+#wphead {
+ border-top: none;
+ padding-top: 4px;
+ background: #444 !important;
}
-.ui-tabs-nav {
- list-style: none;
- border-bottom: 1px solid #C6D9E9;
- padding-left: 8px;
- margin-bottom: .5em;
- margin-top: -2em;
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML {
+ -moz-border-radius-bottomleft: 0;
+ -moz-border-radius-bottomright: 0;
+ -moz-border-radius-topleft: 3px;
+ -moz-border-radius-topright: 3px;
+ -khtml-border-radius-bottomleft: 0;
+ -khtml-border-radius-bottomright: 0;
+ -khtml-border-radius-topleft: 3px;
+ -khtml-border-radius-topright: 3px;
+ -webkit-border-radius-bottomleft: 0;
+ -webkit-border-radius-bottomright: 0;
+ -webkit-border-radius-topleft: 3px;
+ -webkit-border-radius-topright: 3px;
+ border-radius-bottomleft: 0;
+ border-radius-bottomright: 0;
+ border-radius-topleft: 3px;
+ border-radius-topright: 3px;
+ border-style: solid;
+ border-width: 1px;
+ cursor: pointer;
+ display: block;
+ height: 18px;
+ margin: 0px 5px 0 0;
+ padding: 0px 5px 0px;
+ background-color: #E9E9E9;
+ border-bottom-color: #E9E9E9;
+ color: #333333;
+ font-size: 10px;
+ line-height: 18px;
+ float: left;
}
-/* Additional IE specific bug fixes... */
-* html .ui-tabs-nav { /* auto clear, @ IE 6 & IE 7 Quirks Mode */
- display: inline-block;
+.howto {
+ margin-top: 2px;
+ margin-bottom: 3px;
+ font-size: 11px;
+ font-style: italic;
+ display: block;
}
-* :first-child+html .ui-tabs-nav {
- /* @ IE 7 Standards Mode - do not group selectors, otherwise IE 6 will ignore complete rule (because of the unknown + combinator)... */
- display: inline-block;
+input.text {
+ outline-color: -moz-use-text-color;
+ outline-style: none;
+ outline-width: medium;
+ width: 100%;
}
-.ui-tabs-nav:after {
- /* clearing without presentational markup, IE gets extra treatment */
- display: block;
- clear: both;
- content: " ";
+#message {
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
}
-.ui-tabs-nav li {
- float: left;
- margin: 0;
- height: 2em;
- line-height: 2em;
+/* Editor/Main Column */
+div#poststuff {
+ padding-left: 10px;
+ margin-top: 10px;
}
-.ui-tabs-nav a,.ui-tabs-nav a span {
- display: block;
+div.zerosize {
+ border: 0 none;
+ height: 0;
+ margin: 0;
+ overflow: hidden;
+ padding: 0;
+ position: absolute;
+ width: 0;
}
-.ui-tabs-nav a {
- margin: 1px 0 0;
- /* position: relative makes opacity fail for disabled tab in IE */
- padding-left: 0;
- color: #27537a;
- font-weight: bold;
- line-height: 2em;
- text-align: center;
- text-decoration: none;
- white-space: nowrap; /* required in IE 6 */
- outline: 0; /* prevent dotted border in Firefox */
- padding: 0 1em;
+#poststuff #edButtonPreview.active,
+#poststuff #edButtonHTML.active {
+ display: none;
}
-.ui-tabs-nav .ui-tabs-selected a {
+.posting {
+ margin-right: 228px;
position: relative;
- top: 1px;
- z-index: 2;
- margin-top: 0;
- -moz-border-radius-topleft: 4px;
- -moz-border-radius-topright: 4px;
- -webkit-border-top-left-radius: 4px;
- -webkit-border-top-right-radius: 4px;
- border-style: solid;
- border-width: 1px;
- background: white;
- border-bottom-width: 2px;
- margin-top: -2px;
+ left: 0;
}
-.ui-tabs-nav a:hover,.ui-tabs-nav a:focus,.ui-tabs-nav a:active,
-.ui-tabs-nav .ui-tabs-selected a:link,.ui-tabs-nav .ui-tabs-selected a:visited {
- cursor: pointer;
+#side-info-column {
+ float: right;
+ width: 218px;
+ position: absolute;
+ right: 0;
+ margin-right: 10px;
}
-/* Header */
-#wphead {
- border-top: none;
- height: 2em;
- padding-top: 8px;
+#side-info-column .sleeve {
+ padding-left: 10px;
}
-.button {
- font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
- padding: 3px 5px;
- font-size: 12px;
- line-height: 1.5em;
- border-width: 1px;
- border-style: solid;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
- cursor: pointer;
- margin-left: 5px;
- text-decoration: none;
+#poststuff .inside {
+ font-size: 11px;
+ margin: 0 12px 12px;
}
-.howto {
- font-size: 11px;
- font-style: italic;
- display: block;
+#poststuff h2, #poststuff h3 {
+ font-size: 14px;
+ font-weight: bold;
+ padding: 7px;
+ margin: 0 0 10px;
+ background: #dfdfdf url("../images/gray-grad.png") repeat-x left top;
+ font-size: 12px;
+ font-weight: bold;
+ line-height: 1;
+ margin: 0 0 10px;
+ padding: 7px 9px;
+ text-shadow: 0 1px 0 #FFFFFF;
}
-#wphead #viewsite {
- position: absolute;
- margin-top: 12px;
- margin-left: 10px;
+h3.tb {
+ text-shadow: 0 1px 0 #FFFFFF;
+ font-weight: bold;
+ font-size: 12px;
+ margin-left: 5px;
}
-#viewsite {
- position: relative;
- right: 8px;
- top: 6px;
- margin: 0 !important;
+#TB_window {
+ border: 1px solid #333;
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
}
-#wphead #viewsite a {
- font: 12px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
- padding: 3px 4px;
- display: block;
- letter-spacing: normal;
+.metabox-holder .postbox,
+.postbox,
+.stuffbox {
+ margin-bottom: 10px;
border-width: 1px;
border-style: solid;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
- text-decoration: none;
+ line-height: 1;
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+ border-color: #DFDFDF;
}
-#previewview {
- padding-top: 8px !important;
- padding-bottom: 8px !important;
-}
-
-h1 {
- font-size: .75em;
- line-height: 2.666em;
- top: .5em;
- right: 0;
- margin: 0 !important;
- padding: 0 !important;
- width: 236px;
- background: none;
+.titlediv {
+ border-color: #DFDFDF;
}
-input.text {
- border: 0pt none;
- outline-color: -moz-use-text-color;
- outline-style: none;
- outline-width: medium;
- padding: 0pt;
- width: 100%;
+#title, .tbtitle {
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
border-style: solid;
- color: #333333;
-}
-
-/* Editor/Main Column */
-
-div#container {
- margin: 0;
- min-width: 500px;
+ border-width: 1px;
+ font-size: 1.7em;
+ outline: none;
+ padding: 3px 4px;
+ border-color: #DFDFDF;
}
-div#container form {
- margin: 0px;
- padding: 0px;
+.tbtitle {
+ font-size: 12px;
+ padding: 3px;
}
-div#posting {
- padding-left: 16px;
- position: absolute;
- z-index: 1;
- width: 66%;
+#title {
+ width: 98%;
}
-#post_title {
- width: 99%;
+.postbox h2 {
+ background-image: url(../images/postbox-bg.gif);
+ background-position: left top;
+ background-repeat: repeat-x;
+ background-color: #DFDFDF;
}
-.titlewrap {
+.editor-container {
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+ border-collapse: separate;
border-style: solid;
border-width: 1px;
- padding: 2px 3px;
- border-color: #CCCCCC;
+ border-color: #DFDFDF;
}
-div#posting h2 {
- margin: .5em 0 .25em 0;
- font-size: 12px;
- padding: 3px;
- background: ;
+.postdivrich {
+ position: relative;
+ padding-top: 25px;
}
-.editor-container {
- border-width: 1px;
- border-color: #ccc;
- border-style: solid;
- margin-bottom: 1em;
+#actions {
+ clear: both;
+ float: right;
+ margin-top: -19px;
+ position: relative;
+}
+#extra_fields #actions {
+ clear: both;
+ position: absolute;
+ right: 4px;
+ top: 6px;
+ margin: 0;
}
-/* Photo Styles */
-
-#photo_directions {
- margin-top: .25em;
- display: block;
- position: relative;
+#actions li {
+ float: left;
+ list-style: none;
+ margin-right: 10px;
+}
+#extra_fields .button {
+ margin-right: 5px;
}
-#photo_directions span {
- display: block;
- position: absolute;
- top: 0;
- right: 3px;
+/* Photo Styles */
+.photolist {
+ margin-top: -10px;
}
#photo_saving {
#img_container {
background-color: #fff;
+ height: 101px;
+ width: 100%;
+}
+
+#extra_fields {
+ margin-top: 10px;
+ position: relative;
+}
+
+#extra_fields .postbox {
+ margin-bottom: 5px;
+}
+
+#extra_fields .titlewrap {
+ padding: 0;
overflow: auto;
height: 100px;
}
+#img_container {
+ position: relative;
+}
+
#img_container a {
display: block;
- width: 79px;
- height: 79px;
float: left;
+ overflow: hidden;
+ vertical-align: center;
+}
+
+#img_container img, #img_container a {
+ width: 68px;
+ height: 68px;
}
#img_container img {
- width: 75px;
- height: 75px;
- border: 0px;
- padding: 2px;
+ width: 68px;
+ height: 68px;
+ border: none;
background-color: #f4f4f4;
cursor: pointer;
}
-#img_container a, #img_container a:link, #img_container a:visited {
- border: 2px solid #ccc;
- margin: 0 4px 4px 0;
-}
-#img_container a:hover, #img_container a:active {
- border: 2px solid #000;
+
+#img_container a,
+#img_container a:link,
+#img_container a:visited {
+ border: 1px solid #ccc;
+ display: block;
+ position: relative;
+}
+
+#img_container a:hover,
+#img_container a:active {
+ border-color: #000;
+ z-index: 1000;
+ border-width: 2px;
+ margin: -1px;
+}
+
+/* Video */
+#embed-code {
+ width: 100%;
+ height: 98px;
}
/* Submit Column */
+#viewsite {
+ padding: 0;
+ margin: 0 0 20px 0;
+ font-size: 10px;
+ clear: both;
+}
-div#categories {
- font-size: 85%;
- position: absolute;
- top: 50px;
- right: 16px;
- width: 27%;
- z-index: 2;
+#viewsite .button {
+ margin: 0 0 0px 0;
+ display: block;
}
-div#categories h2 {
- color: #333;
+.wp-hidden-children .wp-hidden-child {
+ display: none;
+}
+
+#category-adder {
+ padding: 4px 0;
+}
+
+#category-adder h4 {
+ margin: 0 0 8px;
+}
+
+#category-add input {
+ width: 94%;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 13px;
+ margin: 1px;
+ padding: 3px;
+}
+
+#category-add select {
+ width: 70%;
+ -x-system-font: none;
+ border-style: solid;
+ border-width: 1px;
+ font-family: "Lucida Grande", "Bitstream Vera Sans", Verdana, Arial, sans-serif;
font-size: 12px;
- margin: .5em 0 .5em 1em;
- padding: 0;
+ height: 2em;
+ line-height: 20px;
+ padding: 2px;
+ margin: 1px;
+ vertical-align: top;
}
-#categories-all {
- overflow: auto;
- padding: 0 1em 1em 1em;
- height: 15em;
+#category-add input#category-add-sumbit {
+ width: auto;
}
-#categories ul {
+/* Categories */
+#categorydiv ul, #linkcategorydiv ul {
list-style: none;
padding: 0;
margin: 0;
}
+#categorydiv ul.categorychecklist ul {
+ margin-left: 18px;
+}
+
+#categorydiv div.ui-tabs-panel {
+ height: 150px;
+ overflow: auto;
+}
+
+ul.categorychecklist li {
+ margin: 0;
+ padding: 0;
+ line-height: 19px;
+}
+
+/* Tags */
#tagsdiv #newtag {
padding: 3px;
margin-right: 5px;
- width: 16em;
+ width: 16em;
}
#jaxtag {
clear: both;
- padding-left: 1em;
margin: 0;
}
+#tagadd {
+ margin-left: 3px;
+}
+
#tagchecklist {
- padding-left: 1em;
+ margin-top: 3px;
margin-bottom: 1em;
font-size: 12px;
overflow: auto;
}
#tagchecklist span a {
- margin: 6px 0pt 0pt -9px;
+ margin: 6px 0 0 -9px;
cursor: pointer;
width: 10px;
height: 10px;
overflow: hidden;
position: absolute;
}
-.submit {
- -moz-border-radius-bottomleft: 3px;
- -khtml-border-bottom-left-radius: 3px;
- -webkit-border-bottom-left-radius: 3px;
- border-bottom-left-radius: 3px;
- -moz-border-radius-bottomright: 3px;
- -khtml-border-bottom-right-radius: 3px;
- -webkit-border-bottom-right-radius: 3px;
- border-bottom-right-radius: 3px;
- margin: 0;
- padding: 10px;
-}
-.submitbox {
- width: 100%;
- float: right;
-}
-.submitbox .submit a:hover {
- border-bottom-width: 1px;
- border-bottom-style: solid;
+#content {
+ width: 96% !important;
+ margin-left: 1%;
+ margin-bottom: 10px;
+ border: 1px solid #f1f1f1;
}
-.submitbox .submit input {
- border: none;
- text-align: left;
- padding: 6px 4px;
- font-size: 12px;
- margin: 2px;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
- cursor: pointer;
-}
+/* Submit */
-.submitbox #previewview {
- padding: 15px 10px;
- -moz-border-radius-topleft: 3px;
- -khtml-border-top-left-radius: 3px;
- -webkit-border-top-left-radius: 3px;
- border-top-left-radius: 3px;
- -moz-border-radius-topright: 3px;
- -khtml-border-top-right-radius: 3px;
- -webkit-border-top-right-radius: 3px;
- border-top-right-radius: 3px;
+#saving {
+ display: inline;
}
-/* Video Styles */
-.video_split #extra_fields {
- width: 27%;
- height: 300px;
- float: left;
+.submit input,
+.button,
+.button-primary,
+.button-secondary,
+.button-highlighted,
+#postcustomstuff .submit input {
+ font-family: "Lucida Grande", "Bitstream Vera Sans", Verdana, Arial, sans-serif;
+ text-decoration: none;
+ font-size: 11px !important;
+ line-height: 16px;
+ padding: 2px 8px;
+ cursor: pointer;
+ border-width: 1px;
+ border-style: solid;
+ -moz-border-radius: 11px;
+ -khtml-border-radius: 11px;
+ -webkit-border-radius: 11px;
+ border-radius: 11px;
}
-#embed_code {
- border: 0;
- width: 99%;
- height: 200px;
-}
-.video_split .editor_area {
- width: 70%;
- float: right;
+.button-primary {
+ background: #21759B url(../images/button-grad.png) repeat-x scroll left top;
+ border-color: #21759B;
+ color: #FFFFFF;
}
.ac_results {
text-decoration: underline;
}
-.photolist {
- display: none;
-}
-
-#extra_fields small {
- display: block;
- margin-top: .5em;
- padding-bottom: .25em;
-}
-
#TB_ajaxContent #options {
position: absolute;
top: 20px;
right: 25px;
padding: 5px;
}
+
#TB_ajaxContent h3 {
margin-bottom: .25em;
}
.updated {
- margin: 0;
- margin-left: 15px;
- margin-right: 15px;
+ margin: 10px 0;
padding: 0;
- max-width: 980px;
border-width: 1px;
border-style: solid;
- padding: 0 0.6em;
- max-width: 950px;
- margin-top: 1em;
- margin-bottom: 1em;
+ width: 99%;
}
-.updated p, .error p {
+.updated p,
+.error p {
margin: 0.6em 0;
+ padding: 0 0.6em;
}
-.updated a, .error a {
+.error a {
text-decoration: underline;
}
}
/* Footer */
-
#footer {
height: 65px;
display: block;
#footer p a {
text-decoration: none;
}
-
#footer p a:hover {
text-decoration: underline;
}
-
/* Utility Classes */
.centered {
text-align: center;
.hidden {
display: none;
-}
\ No newline at end of file
+}
-#template textarea {
- font-family:monospace;
-}
#templateside {
- float:left;
+ float: left;
}
#themeselector {
- padding-right:0;
+ padding-right: 0;
padding-left: 5px;
float: left;
}
div.tablenav {
- margin-right:0;
+ margin-right: 0;
margin-left: 210px;
}
#template textarea {
- font-family: 'Courier New', Courier, monospace;
+ font-family: Consolas, Monaco, Courier, monospace;
font-size: 12px;
width: 97%;
}
#templateside {
float: right;
width: 190px;
- margin-top:-3.4em;
}
#templateside h3, #postcustomstuff p.submit {
}
#templateside h4 {
- margin-bottom: 0px;
+ margin-bottom: 0;
}
#templateside ol, #templateside ul {
}
#templateside ol li, #templateside ul li {
- margin: 1px 0px;
+ margin: 1px 0;
}
#themeselector {
float: right;
position: relative;
bottom: 25px;
+ top:20px;
}
#themeselector select {
div.bordertitle h2 {
border: none;
- padding-bottom: 0px;
+ padding-bottom: 0;
}
div.tablenav {
+++ /dev/null
-html {
- direction: ltr;
- }
-#uploadoptions, table {
- direction: rtl;
- }
-td {
- padding: 1px 6px 0;
- }
-.submit {
- text-align: left;
- }
\ No newline at end of file
-/* 2 column liquid layout */
-div.widget-liquid-left-holder {
- float: right;
- clear: right;
- margin-right:0;
- margin-left: -310px;
-}
-div.widget-liquid-left {
- margin-right:0;
- margin-left: 320px;
-}
-div.widget-liquid-right {
- float: left;
- clear: left;
-}
-p#widget-search {
- right:auto;
- left:0;
-}
h4.widget-title span {
float: right;
}
h4.widget-title a {
float: left;
- margin-left:0;
+ margin-left: 0;
margin-right: 1em;
}
ul#widget-list li.widget-list-item h4.widget-title {
- float:right;
+ float: right;
}
ul#widget-list li.widget-list-item div.widget-description {
margin: 0 200px 0 0;
padding: 0 4em 0 0;
}
-.widget-control-save, .widget-control-remove {
- margin-right:0;
+.widget-control-save,
+.widget-control-remove {
+ margin-right: 0;
margin-left: 8px;
float: right;
}
li.widget-list-control-item h4.widget-title a,
#dragHelper li.widget-list-control-item h4.widget-title a,
#draghelper li.widget-list-control-item h4.widget-title a:visited {
- right:auto;
+ right: auto;
left: 1em;
}
border-bottom-style: solid;
}
-p#widget-search {
- position: absolute;
- right: 0;
- top: 0;
- margin: 0;
-}
-
ul#widget-list {
list-style: none;
margin: 0;
border-radius: 3px;
}
-li.widget-list-control-item h4,
-#dragHelper li.widget-list-control-item h4,
+li.widget-list-control-item h4,
+#dragHelper li.widget-list-control-item h4,
li.widget-sortable h4 {
margin: 0;
cursor: move;
border-radius: 3px;
}
-.widget-control-save, .widget-control-remove {
- padding: 3px 5px;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
+.widget-control-save,
+.widget-control-remove {
margin-right: 8px;
float: left;
text-decoration: none;
}
li.widget-list-control-item div.widget-control {
+ border-width: 0 1px 1px;
+ border-style: none solid solid;
display: none;
padding: 15px;
font-size: 11px;
}
ul.widget-control-list div.widget-control-actions {
- border-top-width: 1px;
- border-top-style: solid;
padding: 0.5em 0 0;
}
div#current-widgets {
padding-top: 1em;
- border-width: 1px;
+ border-width: 1px 0 0;
border-style: solid none none;
}
<?php
-
+/**
+ * The custom header image script.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * The custom header image class.
+ *
+ * @since unknown
+ * @package WordPress
+ * @subpackage Administration
+ */
class Custom_Image_Header {
+
+ /**
+ * Callback for administration header.
+ *
+ * @var callback
+ * @since unknown
+ * @access private
+ */
var $admin_header_callback;
+ /**
+ * PHP4 Constructor - Register administration header callback.
+ *
+ * @since unknown
+ * @param callback $admin_header_callback
+ * @return Custom_Image_Header
+ */
function Custom_Image_Header($admin_header_callback) {
$this->admin_header_callback = $admin_header_callback;
}
+ /**
+ * Setup the hooks for the Custom Header admin page.
+ *
+ * @since unknown
+ */
function init() {
$page = add_theme_page(__('Custom Image Header'), __('Custom Image Header'), 'edit_themes', 'custom-header', array(&$this, 'admin_page'));
add_action("admin_print_scripts-$page", array(&$this, 'js_includes'));
+ add_action("admin_print_styles-$page", array(&$this, 'css_includes'));
add_action("admin_head-$page", array(&$this, 'take_action'), 50);
add_action("admin_head-$page", array(&$this, 'js'), 50);
add_action("admin_head-$page", $this->admin_header_callback, 51);
}
+ /**
+ * Get the current step.
+ *
+ * @since unknown
+ *
+ * @return int Current step
+ */
function step() {
- $step = (int) @$_GET['step'];
+ if ( ! isset( $_GET['step'] ) )
+ return 1;
+
+ $step = (int) $_GET['step'];
if ( $step < 1 || 3 < $step )
$step = 1;
+
return $step;
}
+ /**
+ * Setup the enqueue for the JavaScript files.
+ *
+ * @since unknown
+ */
function js_includes() {
$step = $this->step();
+
if ( 1 == $step )
- wp_enqueue_script('colorpicker');
- elseif ( 2 == $step )
+ wp_enqueue_script('farbtastic');
+ elseif ( 2 == $step )
wp_enqueue_script('cropper');
}
+ /**
+ * Setup the enqueue for the CSS files
+ *
+ * @since 2.7
+ */
+ function css_includes() {
+ $step = $this->step();
+
+ if ( 1 == $step ) {
+ wp_enqueue_style('farbtastic');
+ }
+ }
+
+ /**
+ * Execute custom header modification.
+ *
+ * @since unknown
+ */
function take_action() {
if ( isset( $_POST['textcolor'] ) ) {
check_admin_referer('custom-header');
}
}
+ /**
+ * Execute Javascript depending on step.
+ *
+ * @since unknown
+ */
function js() {
$step = $this->step();
if ( 1 == $step )
$this->js_2();
}
+ /**
+ * Display Javascript based on Step 1.
+ *
+ * @since unknown
+ */
function js_1() { ?>
<script type="text/javascript">
- var cp = new ColorPicker();
+ var buttons = ['#name', '#desc', '#pickcolor', '#defaultcolor'];
+ var farbtastic;
function pickColor(color) {
- $('name').style.color = color;
- $('desc').style.color = color;
- $('textcolor').value = color;
- }
- function PopupWindow_hidePopup(magicword) {
- if ( magicword != 'prettyplease' )
- return false;
- if (this.divName != null) {
- if (this.use_gebi) {
- document.getElementById(this.divName).style.visibility = "hidden";
- }
- else if (this.use_css) {
- document.all[this.divName].style.visibility = "hidden";
- }
- else if (this.use_layers) {
- document.layers[this.divName].visibility = "hidden";
- }
- }
- else {
- if (this.popupWindow && !this.popupWindow.closed) {
- this.popupWindow.close();
- this.popupWindow = null;
- }
- }
- return false;
- }
- function colorSelect(t,p) {
- if ( cp.p == p && document.getElementById(cp.divName).style.visibility != "hidden" ) {
- cp.hidePopup('prettyplease');
- } else {
- cp.p = p;
- cp.select(t,p);
- }
+ jQuery('#name').css('color', color);
+ jQuery('#desc').css('color', color);
+ jQuery('#textcolor').val(color);
+ farbtastic.setColor(color);
}
+
+ jQuery(document).ready(function() {
+ jQuery('#pickcolor').click(function() {
+ jQuery('#colorPickerDiv').show();
+ });
+
+ jQuery('#hidetext').click(function() {
+ toggle_text();
+ });
+
+ farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) { pickColor(color); });
+ pickColor('#<?php echo get_theme_mod('header_textcolor', HEADER_TEXTCOLOR); ?>');
+
+ <?php if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) ) { ?>
+ toggle_text();
+ <?php } ?>
+ });
+
+ jQuery(document).mousedown(function(){
+ // Make the picker disappear, since we're using it in an independant div
+ hide_picker();
+ });
+
function colorDefault() {
pickColor('#<?php echo HEADER_TEXTCOLOR; ?>');
}
- function hide_text() {
- $('name').style.display = 'none';
- $('desc').style.display = 'none';
- $('pickcolor').style.display = 'none';
- $('defaultcolor').style.display = 'none';
- $('textcolor').value = 'blank';
- $('hidetext').value = '<?php _e('Show Text'); ?>';
-// $('hidetext').onclick = 'show_text()';
- Event.observe( $('hidetext'), 'click', show_text );
+ function hide_picker(what) {
+ var update = false;
+ jQuery('#colorPickerDiv').each(function(){
+ var id = jQuery(this).attr('id');
+ if (id == what) {
+ return;
+ }
+ var display = jQuery(this).css('display');
+ if (display == 'block') {
+ jQuery(this).fadeOut(2);
+ }
+ });
}
- function show_text() {
- $('name').style.display = 'block';
- $('desc').style.display = 'block';
- $('pickcolor').style.display = 'inline';
- $('defaultcolor').style.display = 'inline';
- $('textcolor').value = '<?php echo HEADER_TEXTCOLOR; ?>';
- $('hidetext').value = '<?php _e('Hide Text'); ?>';
- Event.stopObserving( $('hidetext'), 'click', show_text );
- Event.observe( $('hidetext'), 'click', hide_text );
+ function toggle_text(force) {
+ if(jQuery('#textcolor').val() == 'blank') {
+ //Show text
+ jQuery( buttons.toString() ).show();
+ jQuery('#textcolor').val('<?php echo HEADER_TEXTCOLOR; ?>');
+ jQuery('#hidetext').val('<?php _e('Hide Text'); ?>');
+ }
+ else {
+ //Hide text
+ jQuery( buttons.toString() ).hide();
+ jQuery('#textcolor').val('blank');
+ jQuery('#hidetext').val('<?php _e('Show Text'); ?>');
+ }
}
- <?php if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) ) { ?>
-Event.observe( window, 'load', hide_text );
- <?php } ?>
+
</script>
<?php
}
+ /**
+ * Display Javascript based on Step 2.
+ *
+ * @since unknown
+ */
function js_2() { ?>
<script type="text/javascript">
function onEndCrop( coords, dimensions ) {
- $( 'x1' ).value = coords.x1;
- $( 'y1' ).value = coords.y1;
- $( 'x2' ).value = coords.x2;
- $( 'y2' ).value = coords.y2;
- $( 'width' ).value = dimensions.width;
- $( 'height' ).value = dimensions.height;
+ jQuery( '#x1' ).val(coords.x1);
+ jQuery( '#y1' ).val(coords.y1);
+ jQuery( '#x2' ).val(coords.x2);
+ jQuery( '#y2' ).val(coords.y2);
+ jQuery( '#width' ).val(dimensions.width);
+ jQuery( '#height' ).val(dimensions.height);
}
// with a supplied ratio
- Event.observe(
- window,
- 'load',
- function() {
- var xinit = <?php echo HEADER_IMAGE_WIDTH; ?>;
- var yinit = <?php echo HEADER_IMAGE_HEIGHT; ?>;
- var ratio = xinit / yinit;
- var ximg = $('upload').width;
- var yimg = $('upload').height;
- if ( yimg < yinit || ximg < xinit ) {
- if ( ximg / yimg > ratio ) {
- yinit = yimg;
- xinit = yinit * ratio;
- } else {
- xinit = ximg;
- yinit = xinit / ratio;
- }
+ jQuery(document).ready(function() {
+ var xinit = <?php echo HEADER_IMAGE_WIDTH; ?>;
+ var yinit = <?php echo HEADER_IMAGE_HEIGHT; ?>;
+ var ratio = xinit / yinit;
+ var ximg = jQuery('#upload').width();
+ var yimg = jQuery('#upload').height();
+ if ( yimg < yinit || ximg < xinit ) {
+ if ( ximg / yimg > ratio ) {
+ yinit = yimg;
+ xinit = yinit * ratio;
+ } else {
+ xinit = ximg;
+ yinit = xinit / ratio;
}
- new Cropper.Img(
- 'upload',
- {
- ratioDim: { x: xinit, y: yinit },
- displayOnInit: true,
- onEndCrop: onEndCrop
- }
- )
}
- );
+ new Cropper.Img(
+ 'upload',
+ {
+ ratioDim: { x: xinit, y: yinit },
+ displayOnInit: true,
+ onEndCrop: onEndCrop
+ }
+ )
+ });
</script>
<?php
}
+ /**
+ * Display first step of custom header image page.
+ *
+ * @since unknown
+ */
function step_1() {
if ( $_GET['updated'] ) { ?>
<div id="message" class="updated fade">
<?php } ?>
<div class="wrap">
+<?php screen_icon(); ?>
<h2><?php _e('Your Header Image'); ?></h2>
<p><?php _e('This is your header image. You can change the text color or upload and crop a new image.'); ?></p>
<?php if ( !defined( 'NO_HEADER_TEXT' ) ) { ?>
<form method="post" action="<?php echo admin_url('themes.php?page=custom-header&updated=true') ?>">
<input type="button" value="<?php _e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" />
-<input type="button" value="<?php _e('Select a Text Color'); ?>" onclick="colorSelect($('textcolor'), 'pickcolor')" id="pickcolor" /><input type="button" value="<?php _e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" />
+<input type="button" value="<?php _e('Select a Text Color'); ?>" id="pickcolor" /><input type="button" value="<?php _e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" />
<?php wp_nonce_field('custom-header') ?>
<input type="hidden" name="textcolor" id="textcolor" value="#<?php attribute_escape(header_textcolor()) ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes'); ?>" /></form>
<?php } ?>
-<div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
+<div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"> </div>
</div>
<div class="wrap">
<h2><?php _e('Upload New Header Image'); ?></h2><p><?php _e('Here you can upload a custom header image to be shown at the top of your blog instead of the default one. On the next screen you will be able to crop the image.'); ?></p>
}
+ /**
+ * Display second step of custom header image page.
+ *
+ * @since unknown
+ */
function step_2() {
check_admin_referer('custom-header');
$overrides = array('test_form' => false);
<?php
}
+ /**
+ * Display third step of custom header image page.
+ *
+ * @since unknown
+ */
function step_3() {
check_admin_referer('custom-header');
if ( $_POST['oitar'] > 1 ) {
return $this->finished();
}
+ /**
+ * Display last step of custom header image page.
+ *
+ * @since unknown
+ */
function finished() {
?>
<div class="wrap">
<?php
}
+ /**
+ * Display the page based on the current step.
+ *
+ * @since unknown
+ */
function admin_page() {
$step = $this->step();
if ( 1 == $step )
-<?php if ( ! defined('ABSPATH') ) die(); ?>
-<table class="widefat">
- <thead>
- <tr>
+<?php
+/**
+ * Edit attachments table for inclusion in administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
-<?php $posts_columns = wp_manage_media_columns(); ?>
-<?php foreach($posts_columns as $post_column_key => $column_display_name) {
- if ( 'cb' === $post_column_key )
- $class = ' class="check-column"';
- elseif ( 'comments' === $post_column_key )
- $class = ' class="num"';
- else
- $class = '';
-?>
- <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th>
-<?php } ?>
+if ( ! defined('ABSPATH') ) die();
+if ( have_posts() ) { ?>
+<table class="widefat fixed" cellspacing="0">
+ <thead>
+ <tr>
+<?php print_column_headers('upload'); ?>
</tr>
</thead>
+
+ <tfoot>
+ <tr>
+<?php print_column_headers('upload', false); ?>
+ </tr>
+ </tfoot>
+
<tbody id="the-list" class="list:post">
<?php
-if ( have_posts() ) {
-$bgcolor = '';
add_filter('the_title','wp_specialchars');
+$alt = '';
+$posts_columns = get_column_headers('upload');
+$hidden = get_hidden_columns('upload');
while (have_posts()) : the_post();
-$class = 'alternate' == $class ? '' : 'alternate';
+$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
global $current_user;
$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
-$att_title = get_the_title();
-if ( empty($att_title) )
- $att_title = __('(no title)');
+$att_title = _draft_or_post_title();
?>
- <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
+ <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
<?php
+foreach ($posts_columns as $column_name => $column_display_name ) {
+ $class = "class=\"$column_name column-$column_name\"";
-foreach($posts_columns as $column_name=>$column_display_name) {
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
+
+ $attributes = "$class$style";
switch($column_name) {
case 'cb':
?>
- <th scope="row" class="check-column"><input type="checkbox" name="delete[]" value="<?php the_ID(); ?>" /></th>
+ <th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /></th>
<?php
break;
case 'icon':
+ $attributes = 'class="column-icon media-icon"' . $style;
?>
- <td class="media-icon"><?php echo wp_get_attachment_link($post->ID, array(80, 60), false, true); ?></td>
+ <td <?php echo $attributes ?>><?php
+ if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) {
+?>
+
+ <a href="media.php?action=edit&attachment_id=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>">
+ <?php echo $thumb; ?>
+ </a>
+
+<?php }
+ ?></td>
<?php
// TODO
break;
case 'media':
?>
- <td><strong><a href="media.php?action=edit&attachment_id=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
+ <td <?php echo $attributes ?>><strong><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
<?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
- <?php do_action('manage_media_media_column', $post->ID); ?>
- </td>
+ <p>
+ <?php
+ $actions = array();
+ if ( current_user_can('edit_post', $post->ID) )
+ $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
+ if ( current_user_can('delete_post', $post->ID) )
+ $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
+ $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
+ $action_count = count($actions);
+ $i = 0;
+ echo '<div class="row-actions">';
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ echo "<span class='$action'>$link$sep</span>";
+ }
+ echo '</div>';
+ ?></p></td>
+ <?php
+ break;
+
+ case 'author':
+ ?>
+ <td <?php echo $attributes ?>><?php the_author() ?></td>
+ <?php
+ break;
+
+ case 'tags':
+ ?>
+ <td <?php echo $attributes ?>><?php
+ $tags = get_the_tags();
+ if ( !empty( $tags ) ) {
+ $out = array();
+ foreach ( $tags as $c )
+ $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
+ echo join( ', ', $out );
+ } else {
+ _e('No Tags');
+ }
+ ?></td>
<?php
break;
case 'desc':
?>
- <td><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
+ <td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
<?php
break;
} else {
$t_time = get_the_time(__('Y/m/d g:i:s A'));
$m_time = $post->post_date;
- $time = get_post_time( 'G', true );
+ $time = get_post_time( 'G', true, $post );
if ( ( abs($t_diff = time() - $time) ) < 86400 ) {
if ( $t_diff < 0 )
$h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
}
}
?>
- <td><?php echo $h_time ?></td>
+ <td <?php echo $attributes ?>><?php echo $h_time ?></td>
<?php
break;
case 'parent':
- $title = __('(no title)'); // override below
if ( $post->post_parent > 0 ) {
if ( get_post($post->post_parent) ) {
- $parent_title = get_the_title($post->post_parent);
- if ( !empty($parent_title) )
- $title = $parent_title;
+ $title =_draft_or_post_title($post->post_parent);
}
?>
- <td><strong><a href="post.php?action=edit&post=<?php echo $post->post_parent; ?>"><?php echo $title ?></a></strong></td>
+ <td <?php echo $attributes ?>><strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>, <?php echo get_the_time(__('Y/m/d')); ?></td>
<?php
} else {
?>
- <td> </td>
+ <td <?php echo $attributes ?>> </td>
<?php
}
break;
case 'comments':
+ $attributes = 'class="comments column-comments num"' . $style;
?>
- <td class="num"><div class="post-com-count-wrapper">
+ <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
<?php
$left = get_pending_comments_num( $post->ID );
$pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
if ( $left )
echo '<strong>';
- comments_number("<a href='upload.php?attachment_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='upload.php?attachment_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='upload.php?attachment_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
+ comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
if ( $left )
echo '</strong>';
?>
<?php
break;
- case 'location':
+ case 'actions':
?>
- <td><a href="<?php the_permalink(); ?>"><?php _e('Permalink'); ?></a></td>
+ <td <?php echo $attributes ?>>
+ <a href="media.php?action=edit&attachment_id=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php _e('Edit'); ?></a> |
+ <a href="<?php the_permalink(); ?>"><?php _e('Get permalink'); ?></a>
+ </td>
<?php
break;
default:
?>
- <td><?php do_action('manage_media_custom_column', $column_name, $id); ?></td>
+ <td <?php echo $attributes ?>><?php do_action('manage_media_custom_column', $column_name, $id); ?></td>
<?php
break;
}
}
?>
</tr>
-<?php
-endwhile;
-} else {
-?>
- <tr style='background-color: <?php echo $bgcolor; ?>'>
- <td colspan="8"><?php _e('No posts found.') ?></td>
- </tr>
+<?php endwhile; ?>
+ </tbody>
+</table>
+<?php } else { ?>
+
+<p><?php _e('No posts found.') ?></p>
+
<?php
} // end if ( have_posts() )
?>
- </tbody>
-</table>
+
<?php
-if ( ! empty($cat_ID) ) {
- $heading = __('Edit Category');
- $submit_text = __('Edit Category');
- $form = '<form name="editcat" id="editcat" method="post" action="categories.php" class="validate">';
- $action = 'editedcat';
- $nonce_action = 'update-category_' . $cat_ID;
- do_action('edit_category_form_pre', $category);
-} else {
- $heading = __('Add Category');
- $submit_text = __('Add Category');
- $form = '<form name="addcat" id="addcat" method="post" action="categories.php" class="add:the-list: validate">';
- $action = 'addcat';
- $nonce_action = 'add-category';
- do_action('add_category_form_pre', $category);
+/**
+ * Edit category form for inclusion in administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * @var object
+ */
+if ( ! isset( $category ) )
+ $category = (object) array();
+
+/**
+ * @ignore
+ * @since 2.7
+ * @internal Used to prevent errors in page when no category is being edited.
+ *
+ * @param object $category
+ */
+function _fill_empty_category(&$category) {
+ if ( ! isset( $category->name ) )
+ $category->name = '';
+
+ if ( ! isset( $category->slug ) )
+ $category->slug = '';
+
+ if ( ! isset( $category->parent ) )
+ $category->parent = '';
+
+ if ( ! isset( $category->description ) )
+ $category->description = '';
}
+
+do_action('edit_category_form_pre', $category);
+
+_fill_empty_category($category);
?>
<div class="wrap">
-<h2><?php echo $heading ?></h2>
+<?php screen_icon(); ?>
+<h2><?php _e('Edit Category'); ?></h2>
<div id="ajax-response"></div>
-<?php echo $form ?>
-<input type="hidden" name="action" value="<?php echo $action ?>" />
+<form name="editcat" id="editcat" method="post" action="categories.php" class="validate">
+<input type="hidden" name="action" value="editedcat" />
<input type="hidden" name="cat_ID" value="<?php echo $category->term_id ?>" />
-<?php wp_nonce_field($nonce_action); ?>
+<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-category_' . $cat_ID); ?>
<table class="form-table">
<tr class="form-field form-required">
<th scope="row" valign="top"><label for="cat_name"><?php _e('Category Name') ?></label></th>
<?php _e('The description is not prominent by default, however some themes may show it.'); ?></td>
</tr>
</table>
-<p class="submit"><input type="submit" class="button" name="submit" value="<?php echo $submit_text ?>" /></p>
+<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php _e('Update Category'); ?>" /></p>
<?php do_action('edit_category_form', $category); ?>
</form>
</div>
<?php
+/**
+ * Edit Comments Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
-$title = __('Edit Comments');
-$parent_file = 'edit-comments.php';
-wp_enqueue_script( 'admin-comments' );
-wp_enqueue_script('admin-forms');
+wp_enqueue_script('admin-comments');
+enqueue_comment_hotkeys_js();
-if ( !empty( $_REQUEST['delete_comments'] ) ) {
+$post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
+
+if ( ( isset( $_REQUEST['delete_all_spam'] ) || isset( $_REQUEST['delete_all_spam2'] ) ) && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
+ check_admin_referer('bulk-spam-delete', '_spam_nonce');
+
+ $delete_time = $wpdb->escape( $_REQUEST['pagegen_timestamp'] );
+ if ( current_user_can('moderate_comments')) {
+ $deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
+ } else {
+ $deleted_spam = 0;
+ }
+ $redirect_to = 'edit-comments.php?comment_status=spam&deleted=' . (int) $deleted_spam;
+ if ( $post_id )
+ $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
+ wp_redirect( $redirect_to );
+} elseif ( isset($_REQUEST['delete_comments']) && isset($_REQUEST['action']) && ( -1 != $_REQUEST['action'] || -1 != $_REQUEST['action2'] ) ) {
check_admin_referer('bulk-comments');
+ $doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
+
+ $deleted = $approved = $unapproved = $spammed = 0;
+ foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each
+ $comment_id = (int) $comment_id;
+ $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) );
- $comments_deleted = $comments_approved = $comments_unapproved = $comments_spammed = 0;
- foreach ($_REQUEST['delete_comments'] as $comment) : // Check the permissions on each
- $comment = (int) $comment;
- $post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment) );
- if ( !current_user_can('edit_post', $post_id) )
+ if ( !current_user_can('edit_post', $_post_id) )
continue;
- if ( !empty( $_REQUEST['spamit'] ) ) {
- wp_set_comment_status($comment, 'spam');
- $comments_spammed++;
- } elseif ( !empty( $_REQUEST['deleteit'] ) ) {
- wp_set_comment_status($comment, 'delete');
- $comments_deleted++;
- } elseif ( !empty( $_REQUEST['approveit'] ) ) {
- wp_set_comment_status($comment, 'approve');
- $comments_approved++;
- } elseif ( !empty( $_REQUEST['unapproveit'] ) ) {
- wp_set_comment_status($comment, 'hold');
- $comments_unapproved++;
+
+ switch( $doaction ) {
+ case 'markspam' :
+ wp_set_comment_status($comment_id, 'spam');
+ $spammed++;
+ break;
+ case 'delete' :
+ wp_set_comment_status($comment_id, 'delete');
+ $deleted++;
+ break;
+ case 'approve' :
+ wp_set_comment_status($comment_id, 'approve');
+ $approved++;
+ break;
+ case 'unapprove' :
+ wp_set_comment_status($comment_id, 'hold');
+ $unapproved++;
+ break;
}
endforeach;
- $redirect_to = basename( __FILE__ ) . '?deleted=' . $comments_deleted . '&approved=' . $comments_approved . '&spam=' . $comments_spammed . '&unapproved=' . $comments_unapproved;
+
+ $redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved;
+ if ( $post_id )
+ $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
if ( isset($_REQUEST['apage']) )
$redirect_to = add_query_arg( 'apage', absint($_REQUEST['apage']), $redirect_to );
if ( !empty($_REQUEST['mode']) )
if ( !empty($_REQUEST['s']) )
$redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to);
wp_redirect( $redirect_to );
-} elseif ( !empty($_GET['_wp_http_referer']) ) {
- wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
+} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
+ wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
exit;
}
+if ( $post_id )
+ $title = sprintf(__('Edit Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
+else
+ $title = __('Edit Comments');
+
require_once('admin-header.php');
-if ( empty($_GET['mode']) )
- $mode = 'detail';
-else
- $mode = attribute_escape($_GET['mode']);
+$mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : attribute_escape($_GET['mode']);
-if ( isset($_GET['comment_status']) )
- $comment_status = attribute_escape($_GET['comment_status']);
-else
- $comment_status = '';
+$comment_status = !empty($_GET['comment_status']) ? attribute_escape($_GET['comment_status']) : '';
+
+$comment_type = !empty($_GET['comment_type']) ? attribute_escape($_GET['comment_type']) : '';
+
+$search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : '';
+$search = attribute_escape( $search_dirty ); ?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title );
+if ( isset($_GET['s']) && $_GET['s'] )
+ printf( '<span class="subtitle">' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( wp_specialchars( stripslashes( $_GET['s'] ) ), 50 ) ) . '</span>' ); ?>
+</h2>
-if ( isset($_GET['s']) )
- $search_dirty = $_GET['s'];
-else
- $search_dirty = '';
-$search = attribute_escape( $search_dirty );
-?>
<?php
if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) {
$approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0;
}
}
?>
-<div class="wrap">
-<form id="posts-filter" action="" method="get">
-<h2><?php _e('Manage Comments'); ?></h2>
+<form id="comments-form" action="" method="get">
<ul class="subsubsub">
<?php
$status_links = array();
-$num_comments = wp_count_comments();
-$stati = array('moderated' => sprintf(__ngettext('Awaiting Moderation (%s)', 'Awaiting Moderation (%s)', number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"), 'approved' => _c('Approved|plural'));
+$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
+//, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
+//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
+$stati = array(
+ 'all' => __ngettext_noop('All', 'All'), // singular not used
+ 'moderated' => __ngettext_noop('Pending (<span class="pending-count">%s</span>)', 'Pending (<span class="pending-count">%s</span>)'),
+ 'approved' => __ngettext_noop('Approved', 'Approved'), // singular not used
+ 'spam' => __ngettext_noop('Spam (<span class="spam-count">%s</span>)', 'Spam (<span class="spam-count">%s</span>)')
+ );
$class = ( '' === $comment_status ) ? ' class="current"' : '';
-$status_links[] = "<li><a href=\"edit-comments.php\"$class>".__('Show All Comments')."</a>";
+// $status_links[] = "<li><a href='edit-comments.php'$class>" . __( 'All' ) . '</a>';
+$link = 'edit-comments.php';
+if ( !empty($comment_type) && 'all' != $comment_type )
+ $link = add_query_arg( 'comment_type', $comment_type, $link );
foreach ( $stati as $status => $label ) {
$class = '';
- if ( $status == $comment_status )
+ if ( str_replace( 'all', '', $status ) == $comment_status )
$class = ' class="current"';
-
- $status_links[] = "<li><a href=\"edit-comments.php?comment_status=$status\"$class>" . $label . '</a>';
+ if ( !isset( $num_comments->$status ) )
+ $num_comments->$status = 10;
+ if ( 'all' != $status )
+ $link = add_query_arg( 'comment_status', $status, $link );
+ if ( $post_id )
+ $link = add_query_arg( 'p', absint( $post_id ), $link );
+ /*
+ // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
+ if ( !empty( $_GET['s'] ) )
+ $link = add_query_arg( 's', attribute_escape( stripslashes( $_GET['s'] ) ), $link );
+ */
+ $status_links[] = "<li class='$status'><a href='$link'$class>" . sprintf(
+ __ngettext( $label[0], $label[1], $num_comments->$status ),
+ number_format_i18n( $num_comments->$status )
+ ) . '</a>';
}
$status_links = apply_filters( 'comment_status_links', $status_links );
-echo implode(' | </li>', $status_links) . '</li>';
+echo implode( " |</li>\n", $status_links) . '</li>';
unset($status_links);
?>
</ul>
-<p id="post-search">
- <label class="hidden" for="post-search-input"><?php _e( 'Search Comments' ); ?>:</label>
- <input type="text" id="post-search-input" name="s" value="<?php echo $search; ?>" />
+<p class="search-box">
+ <label class="hidden" for="comment-search-input"><?php _e( 'Search Comments' ); ?>:</label>
+ <input type="text" class="search-input" id="comment-search-input" name="s" value="<?php _admin_search_query(); ?>" />
<input type="submit" value="<?php _e( 'Search Comments' ); ?>" class="button" />
</p>
-<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
-<input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
-</form>
-
-<ul class="view-switch">
- <li <?php if ( 'detail' == $mode ) echo "class='current'" ?>><a href="<?php echo clean_url(add_query_arg('mode', 'detail', $_SERVER['REQUEST_URI'])) ?>"><?php _e('Detail View') ?></a></li>
- <li <?php if ( 'list' == $mode ) echo "class='current'" ?>><a href="<?php echo clean_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>"><?php _e('List View') ?></a></li>
-</ul>
-
<?php
-
$comments_per_page = apply_filters('comments_per_page', 20, $comment_status);
if ( isset( $_GET['apage'] ) )
$start = $offset = ( $page - 1 ) * $comments_per_page;
-list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5 ); // Grab a few extra
+list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5, $post_id, $comment_type ); // Grab a few extra
+
+$_comment_post_ids = array();
+foreach ( $_comments as $_c ) {
+ $_comment_post_ids[] = $_c->comment_post_ID;
+}
+$_comment_pending_count_temp = (array) get_pending_comments_num($_comment_post_ids);
+foreach ( (array) $_comment_post_ids as $_cpid )
+ $_comment_pending_count[$_cpid] = isset( $_comment_pending_count_temp[$_cpid] ) ? $_comment_pending_count_temp[$_cpid] : 0;
+if ( empty($_comment_pending_count) )
+ $_comment_pending_count = array();
$comments = array_slice($_comments, 0, $comments_per_page);
$extra_comments = array_slice($_comments, $comments_per_page);
$page_links = paginate_links( array(
'base' => add_query_arg( 'apage', '%#%' ),
'format' => '',
+ 'prev_text' => __('«'),
+ 'next_text' => __('»'),
'total' => ceil($total / $comments_per_page),
'current' => $page
));
?>
-<form id="comments-form" action="" method="post">
+<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
+<?php if ( $post_id ) : ?>
+<input type="hidden" name="p" value="<?php echo intval( $post_id ); ?>" />
+<?php endif; ?>
+<input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
+<input type="hidden" name="pagegen_timestamp" value="<?php echo current_time('mysql', 1); ?>" />
<div class="tablenav">
-<?php
-if ( $page_links )
- echo "<div class='tablenav-pages'>$page_links</div>";
-?>
+<?php if ( $page_links ) : ?>
+<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
+ number_format_i18n( $start + 1 ),
+ number_format_i18n( min( $page * $comments_per_page, $total ) ),
+ number_format_i18n( $total ),
+ $page_links
+); echo $page_links_text; ?></div>
+<?php endif; ?>
-<div class="alignleft">
-<?php if ( 'approved' != $comment_status ): ?>
-<input type="submit" value="<?php _e('Approve'); ?>" name="approveit" class="button-secondary" />
+<div class="alignleft actions">
+<select name="action">
+<option value="-1" selected="selected"><?php _e('Bulk Actions') ?></option>
+<?php if ( empty($comment_status) || 'approved' == $comment_status ): ?>
+<option value="unapprove"><?php _e('Unapprove'); ?></option>
<?php endif; ?>
-<input type="submit" value="<?php _e('Mark as Spam'); ?>" name="spamit" class="button-secondary" />
-<?php if ( 'moderated' != $comment_status ): ?>
-<input type="submit" value="<?php _e('Unapprove'); ?>" name="unapproveit" class="button-secondary" />
+<?php if ( empty($comment_status) || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
+<option value="approve"><?php _e('Approve'); ?></option>
<?php endif; ?>
-<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
-<?php do_action('manage_comments_nav', $comment_status); ?>
+<?php if ( 'spam' != $comment_status ): ?>
+<option value="markspam"><?php _e('Mark as Spam'); ?></option>
+<?php endif; ?>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" name="doaction" id="doaction" value="<?php _e('Apply'); ?>" class="button-secondary apply" />
<?php wp_nonce_field('bulk-comments'); ?>
+
+<?php if ( $comment_status ) echo "<input type='hidden' name='comment_status' value='$comment_status' />\n"; ?>
+<select name="comment_type">
+ <option value="all"><?php _e('Show all comment types'); ?></option>
+<?php
+ $comment_types = apply_filters( 'admin_comment_types_dropdown', array(
+ 'comment' => __('Comments'),
+ 'pings' => __('Pings'),
+ ) );
+
+ foreach ( $comment_types as $type => $label ) {
+ echo " <option value='$type'";
+ selected( $comment_type, $type );
+ echo ">$label</option>\n";
+ }
+?>
+</select>
+<input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
+
<?php if ( isset($_GET['apage']) ) { ?>
<input type="hidden" name="apage" value="<?php echo absint( $_GET['apage'] ); ?>" />
-<?php } ?>
+<?php }
+
+if ( 'spam' == $comment_status ) {
+ wp_nonce_field('bulk-spam-delete', '_spam_nonce');
+ if ( current_user_can ('moderate_comments')) { ?>
+ <input type="submit" name="delete_all_spam" value="<?php _e('Delete All Spam'); ?>" class="button-secondary apply" />
+<?php }
+} ?>
+<?php do_action('manage_comments_nav', $comment_status); ?>
</div>
<br class="clear" />
</div>
-<br class="clear" />
-<?php
-if ($comments) {
-?>
-<table class="widefat">
+<div class="clear"></div>
+
+<?php if ( $comments ) { ?>
+<table class="widefat comments fixed" cellspacing="0">
<thead>
- <tr>
- <th scope="col" class="check-column"><input type="checkbox" /></th>
- <th scope="col"><?php _e('Comment') ?></th>
- <th scope="col"><?php _e('Date') ?></th>
- <th scope="col" class="action-links"><?php _e('Actions') ?></th>
- </tr>
+ <tr>
+<?php print_column_headers('edit-comments'); ?>
+ </tr>
</thead>
+
+<tfoot>
+ <tr>
+<?php print_column_headers('edit-comments', false); ?>
+ </tr>
+</tfoot>
+
<tbody id="the-comment-list" class="list:comment">
<?php
foreach ($comments as $comment)
</tbody>
</table>
+<div class="tablenav">
+<?php
+if ( $page_links )
+ echo "<div class='tablenav-pages'>$page_links_text</div>";
+?>
+
+<div class="alignleft actions">
+<select name="action2">
+<option value="-1" selected="selected"><?php _e('Bulk Actions') ?></option>
+<?php if ( empty($comment_status) || 'approved' == $comment_status ): ?>
+<option value="unapprove"><?php _e('Unapprove'); ?></option>
+<?php endif; ?>
+<?php if ( empty($comment_status) || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
+<option value="approve"><?php _e('Approve'); ?></option>
+<?php endif; ?>
+<?php if ( 'spam' != $comment_status ): ?>
+<option value="markspam"><?php _e('Mark as Spam'); ?></option>
+<?php endif; ?>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" name="doaction2" id="doaction2" value="<?php _e('Apply'); ?>" class="button-secondary apply" />
+
+<?php if ( 'spam' == $comment_status ) { ?>
+<input type="submit" name="delete_all_spam2" value="<?php _e('Delete All Spam'); ?>" class="button-secondary apply" />
+<?php } ?>
+<?php do_action('manage_comments_nav', $comment_status); ?>
+</div>
+
+<br class="clear" />
+</div>
+
</form>
<form id="get-extra-comments" method="post" action="" class="add:the-extra-comment-list:" style="display: none;">
<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
<input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
<input type="hidden" name="page" value="<?php echo isset($_REQUEST['page']) ? absint( $_REQUEST['page'] ) : 1; ?>" />
+ <input type="hidden" name="p" value="<?php echo attribute_escape( $post_id ); ?>" />
+ <input type="hidden" name="comment_type" value="<?php echo attribute_escape( $comment_type ); ?>" />
<?php wp_nonce_field( 'add-comment', '_ajax_nonce', false ); ?>
</form>
<div id="ajax-response"></div>
-<?php
-} elseif ( 'moderated' == $_GET['comment_status'] ) {
-?>
-<p>
-<?php _e('No comments awaiting moderation… yet.') ?>
-</p>
-<?php
-} else {
-?>
-<p>
-<?php _e('No results found.') ?>
-</p>
-<?php
-}
-?>
-<div class="tablenav">
-<?php
-if ( $page_links )
- echo "<div class='tablenav-pages'>$page_links</div>";
-?>
-<br class="clear" />
-</div>
+<?php } elseif ( 'moderated' == $_GET['comment_status'] ) { ?>
+<p><?php _e('No comments awaiting moderation… yet.') ?></p>
+</form>
+
+<?php } else { ?>
+<p><?php _e('No results found.') ?></p>
+</form>
+
+<?php } ?>
</div>
-<?php include('admin-footer.php'); ?>
+<script type="text/javascript">
+/* <![CDATA[ */
+(function($){
+ $(document).ready(function(){
+ $('#doaction, #doaction2').click(function(){
+ if ( $('select[name^="action"]').val() == 'delete' ) {
+ var m = '<?php echo js_escape(__("You are about to delete the selected comments.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
+ return showNotice.warn(m);
+ }
+ });
+ });
+})(jQuery);
+/* ]]> */
+</script>
+
+<?php
+wp_comment_reply('-1', true, 'detail');
+include('admin-footer.php'); ?>
<?php
+/**
+ * Post advanced form for inclusion in the administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Post ID global
+ * @name $post_ID
+ * @var int
+ */
+if ( ! isset( $post_ID ) )
+ $post_ID = 0;
+else
+ $post_ID = (int) $post_ID;
$action = isset($action) ? $action : '';
if ( isset($_GET['message']) )
$_GET['message'] = absint( $_GET['message'] );
-$messages[1] = sprintf( __( 'Post updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) );
+$messages[1] = sprintf( __( 'Post updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( ( isset( $_GET['_wp_original_http_referer'] ) ? $_GET['_wp_original_http_referer'] : '') ) ) );
$messages[2] = __('Custom field updated.');
$messages[3] = __('Custom field deleted.');
$messages[4] = __('Post updated.');
+$messages[6] = sprintf(__('Post published. <a href="%s">View post</a>'), get_permalink($post_ID));
+$messages[7] = __('Post saved.');
+$messages[8] = sprintf(__('Post submitted. <a href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
if ( isset($_GET['revision']) )
$messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) );
$notice = false;
$notices[1] = __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>.' );
-if ( !isset($post_ID) || 0 == $post_ID ) {
+if ( 0 == $post_ID ) {
$form_action = 'post';
$temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
$form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
$autosave = false;
} else {
- $post_ID = (int) $post_ID;
$form_action = 'editpost';
$form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
- $autosave = wp_get_post_autosave( $post_id );
+ $autosave = wp_get_post_autosave( $post_ID );
// Detect if there exists an autosave newer than the post and if that autosave is different than the post
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) ) {
foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
- if ( wp_text_diff( $autosave->$autosave_field, $post->$autosave_field ) ) {
+ if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
$notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
break;
}
}
}
+// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
+
+/**
+ * Display post submit form fields.
+ *
+ * @since 2.7.0
+ *
+ * @param object $post
+ */
+function post_submit_meta_box($post) {
+ global $action;
+
+ $can_publish = current_user_can('publish_posts');
?>
-<?php if ( $notice ) : ?>
-<div id="notice" class="error"><p><?php echo $notice ?></p></div>
-<?php endif; ?>
-<?php if (isset($_GET['message'])) : ?>
-<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
-<?php endif; ?>
+<div class="submitbox" id="submitpost">
-<form name="post" action="post.php" method="post" id="post">
-<?php if ( (isset($mode) && 'bookmarklet' == $mode) || isset($_GET['popupurl']) ): ?>
-<input type="hidden" name="mode" value="bookmarklet" />
-<?php endif; ?>
+<div id="minor-publishing">
-<div class="wrap">
-<h2><?php _e('Write Post') ?></h2>
-<?php
+<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
+<div style="display:none;">
+<input type="submit" name="save" value="<?php echo attribute_escape( __('Save') ); ?>" />
+</div>
-if ( !isset($post_ID) || 0 == $post_ID)
- wp_nonce_field('add-post');
-else
- wp_nonce_field('update-post_' . $post_ID);
+<div id="minor-publishing-actions">
+<div id="save-action">
+<?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
+<input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save Draft') ); ?>" tabindex="4" class="button button-highlighted" />
+<?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
+<input type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save as Pending') ); ?>" tabindex="4" class="button button-highlighted" />
+<?php } ?>
+</div>
-$form_pingback = '<input type="hidden" name="post_pingback" value="' . (int) get_option('default_pingback_flag') . '" id="post_pingback" />';
+<div id="preview-action">
+<?php $preview_link = 'publish' == $post->post_status ? clean_url(get_permalink($post->ID)) : clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>
-$form_prevstatus = '<input type="hidden" name="prev_status" value="' . attribute_escape( $post->post_status ) . '" />';
+<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php _e('Preview'); ?></a>
+<input type="hidden" name="wp-preview" id="wp-preview" value="" />
+</div>
+
+<div class="clear"></div>
+</div><?php // /minor-publishing-actions ?>
-$saveasdraft = '<input name="save" type="submit" id="save" class="button" tabindex="3" value="' . attribute_escape( __('Save and Continue Editing') ) . '" />';
+<div id="misc-publishing-actions">
+<div class="misc-pub-section<?php if ( !$can_publish ) { echo ' misc-pub-section-last'; } ?>"><label for="post_status"><?php _e('Status:') ?></label>
+<b><span id="post-status-display">
+<?php
+switch ( $post->post_status ) {
+ case 'private':
+ _e('Privately Published');
+ break;
+ case 'publish':
+ _e('Published');
+ break;
+ case 'future':
+ _e('Scheduled');
+ break;
+ case 'pending':
+ _e('Pending Review');
+ break;
+ case 'draft':
+ _e('Draft');
+ break;
+}
?>
+</span></b>
+<?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
+<a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
-<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
-<input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" />
-<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
-<input type="hidden" id="post_author" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />
-<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
-<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" />
-<input name="referredby" type="hidden" id="referredby" value="<?php echo clean_url(stripslashes(wp_get_referer())); ?>" />
-<?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?>
+<div id="post-status-select" class="hide-if-js">
+<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo $post->post_status; ?>" />
+<select name='post_status' id='post_status' tabindex='4'>
+<?php if ( 'publish' == $post->post_status ) : ?>
+<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
+<?php elseif ( 'private' == $post->post_status ) : ?>
+<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
+<?php elseif ( 'future' == $post->post_status ) : ?>
+<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
+<?php endif; ?>
+<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
+<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
+</select>
+ <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
+ <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
+</div>
-<?php echo $form_extra ?>
+<?php } ?>
+</div><?php // /misc-pub-section ?>
+
+<div class="misc-pub-section " id="visibility">
+<?php _e('Visibility:'); ?> <b><span id="post-visibility-display"><?php
+
+if ( 'private' == $post->post_status ) {
+ $post->post_password = '';
+ $visibility = 'private';
+ $visibility_trans = __('Private');
+} elseif ( !empty( $post->post_password ) ) {
+ $visibility = 'password';
+ $visibility_trans = __('Password protected');
+} elseif ( is_sticky( $post->ID ) ) {
+ $visibility = 'public';
+ $visibility_trans = __('Public, Sticky');
+} else {
+ $visibility = 'public';
+ $visibility_trans = __('Public');
+}
-<div id="poststuff">
+?><?php echo wp_specialchars( $visibility_trans ); ?></span></b> <?php if ( $can_publish ) { ?> <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
-<div class="submitbox" id="submitpost">
+<div id="post-visibility-select" class="hide-if-js">
+<input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo attribute_escape($post->post_password); ?>" />
+<input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID), true); ?> />
+<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo attribute_escape( $visibility ); ?>" />
-<div id="previewview">
-<?php if ( 'publish' == $post->post_status ) { ?>
-<a href="<?php echo clean_url(get_permalink($post->ID)); ?>" target="_blank" tabindex="4"><?php _e('View this Post'); ?></a>
-<?php } elseif ( 'edit' == $action ) { ?>
-<a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" target="_blank" tabindex="4"><?php _e('Preview this Post'); ?></a>
-<?php } ?>
-</div>
-<div class="inside">
+<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
+<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID), true); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page') ?></label><br /></span>
+<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
+<span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo attribute_escape($post->post_password); ?>" /><br /></span>
+<input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
-<p><strong><label for='post_status'><?php _e('Publish Status') ?></label></strong></p>
<p>
-<select name='post_status' id='post_status' tabindex='4'>
-<?php
-// only show the publish menu item if they are allowed to publish posts or they are allowed to edit this post (accounts for 'edit_published_posts' capability)
-if ( current_user_can('publish_posts') OR ( $post->post_status == 'publish' AND current_user_can('edit_post', $post->ID) ) ) :
-?>
-<option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option>
-<?php if ( 'future' == $post->post_status ) : ?>
-<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
-<?php endif; ?>
-<?php endif; ?>
-<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
-<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Unpublished') ?></option>
-</select>
+ <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
+ <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
</p>
+</div>
+<?php } ?>
+
+</div><?php // /misc-pub-section ?>
+
-<?php if ( current_user_can( 'publish_posts' ) ) : ?>
-<p id="private-checkbox"><label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> tabindex="4" /> <?php _e('Keep this post private') ?></label></p>
-<?php endif; ?>
<?php
-if ($post_ID) {
+$datef = _c( 'M j, Y @ G:i|Publish box date format');
+if ( 0 != $post->ID ) {
if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
- $stamp = __('Scheduled for:<br />%1$s at %2$s');
- } else if ( 'publish' == $post->post_status ) { // already published
- $stamp = __('Published on:<br />%1$s at %2$s');
- } else if ( '0000-00-00 00:00:00' == $post->post_date ) { // draft, 1 or more saves, no date specified
- $stamp = __('Publish immediately');
+ $stamp = __('Scheduled for: <b>%1$s</b>');
+ } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
+ $stamp = __('Published on: <b>%1$s</b>');
+ } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
+ $stamp = __('Publish <b>immediately</b>');
+ } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
+ $stamp = __('Schedule for: <b>%1$s</b>');
} else { // draft, 1 or more saves, date specified
- $stamp = __('Publish on:<br />%1$s at %2$s');
+ $stamp = __('Publish on: <b>%1$s</b>');
}
- $date = mysql2date(get_option('date_format'), $post->post_date);
- $time = mysql2date(get_option('time_format'), $post->post_date);
+ $date = date_i18n( $datef, strtotime( $post->post_date ) );
} else { // draft (no saves, and thus no date specified)
- $stamp = __('Publish immediately');
- $date = mysql2date(get_option('date_format'), current_time('mysql'));
- $time = mysql2date(get_option('time_format'), current_time('mysql'));
+ $stamp = __('Publish <b>immediately</b>');
+ $date = date_i18n( $datef, strtotime( current_time('mysql') ) );
}
?>
-<?php if ( current_user_can( 'publish_posts' ) ) : // Contributors don't get to choose the date of publish ?>
-<p class="curtime"><?php printf($stamp, $date, $time); ?>
- <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a></p>
-
-<div id='timestampdiv' class='hide-if-js'><?php touch_time(($action == 'edit'),1,4); ?></div>
+<?php if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
+<div class="misc-pub-section curtime misc-pub-section-last">
+ <span id="timestamp">
+ <?php printf($stamp, $date); ?></span>
+ <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
+ <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div>
+</div><?php // /misc-pub-section ?>
<?php endif; ?>
+</div>
+<div class="clear"></div>
</div>
-<p class="submit">
-<input type="submit" name="save" id="save-post" value="<?php _e('Save'); ?>" tabindex="4" class="button button-highlighted" />
+<div id="major-publishing-actions">
+<?php do_action('post_submitbox_start'); ?>
+<div id="delete-action">
<?php
-if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post_ID ) {
-?>
+if ( ( 'edit' == $action ) && current_user_can('delete_post', $post->ID) ) { ?>
+<a class="submitdelete deletion" href="<?php echo wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID); ?>" onclick="if ( confirm('<?php echo js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
+<?php } ?>
+</div>
+
+<div id="publishing-action">
+<?php
+if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { ?>
<?php if ( current_user_can('publish_posts') ) : ?>
- <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
+ <?php if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
+ <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Schedule') ?>" />
+ <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Schedule') ?>" />
+ <?php else : ?>
+ <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Publish') ?>" />
+ <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
+ <?php endif; ?>
<?php else : ?>
- <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
+ <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Submit for Review') ?>" />
+ <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
<?php endif; ?>
-<?php
-}
-
-if ( ( 'edit' == $action) && current_user_can('delete_post', $post_ID) )
- echo "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post_ID", 'delete-post_' . $post_ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete post') . "</a>";
-?>
-<br class="clear" />
-<?php if ($post_ID): ?>
-<?php if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
- $last_user = get_userdata($last_id);
- printf(__('Last edited by %1$s on %2$s at %3$s'), wp_specialchars( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
-} else {
- printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
-}
-?>
-<br class="clear" />
-<?php endif; ?>
-<span id="autosave"></span>
-<span id="wp-word-count"></span>
-</p>
-
-<div class="side-info">
-<h5><?php _e('Related') ?></h5>
-
-<ul>
-<?php if ($post_ID): ?>
-<li><a href="edit.php?p=<?php echo $post_ID ?>"><?php _e('See Comments on this Post') ?></a></li>
-<?php endif; ?>
-<li><a href="edit-comments.php"><?php _e('Manage All Comments') ?></a></li>
-<li><a href="edit.php"><?php _e('Manage All Posts') ?></a></li>
-<li><a href="categories.php"><?php _e('Manage All Categories') ?></a></li>
-<li><a href="edit-tags.php"><?php _e('Manage All Tags') ?></a></li>
-<li><a href="edit.php?post_status=draft"><?php _e('View Drafts'); ?></a></li>
-<?php do_action('post_relatedlinks_list'); ?>
-</ul>
-
-<h5><?php _e('Shortcuts') ?></h5>
-<p><?php _e('Drag-and-drop the following link to your bookmarks bar or right click it and add it to your favorites for a posting shortcut.') ?> <a href="<?php echo get_shortcut_link(); ?>" title="<?php echo attribute_escape(__('Press This')) ?>"><?php _e('Press This') ?></a></p>
-</div>
-
-<?php do_action('submitpost_box'); ?>
-</div>
-
-<div id="post-body">
-<div id="titlediv">
-<h3><label for="title"><?php _e('Title') ?></label></h3>
-<div id="titlewrap">
- <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape($post->post_title); ?>" id="title" autocomplete="off" />
-</div>
-<div class="inside">
-<?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>
- <div id="edit-slug-box">
-<?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
- echo $sample_permalink_html;
-endif; ?>
- </div>
+<?php } else { ?>
+ <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Update Post') ?>" />
+ <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Update Post') ?>" />
+<?php } ?>
</div>
+<div class="clear"></div>
</div>
-
-<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
-<h3><label for="content"><?php _e('Post') ?></label></h3>
-<?php the_editor($post->post_content); ?>
-<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
-<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
-<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
-<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
</div>
-<?php echo $form_pingback ?>
-<?php echo $form_prevstatus ?>
-
<?php
+}
+add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'post', 'side', 'core');
+
+/**
+ * Display post tags form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function post_tags_meta_box($post) {
?>
<p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p>
<div id="tagchecklist"></div>
+<p id="tagcloud-link" class="hide-if-no-js"><a href='#'><?php _e( 'Choose from the most popular tags' ); ?></a></p>
<?php
}
-add_meta_box('tagsdiv', __('Tags'), 'post_tags_meta_box', 'post', 'normal', 'core');
-
+add_meta_box('tagsdiv', __('Tags'), 'post_tags_meta_box', 'post', 'side', 'core');
+
+/**
+ * Display post categories form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function post_categories_meta_box($post) {
?>
-<div id="category-adder" class="wp-hidden-children">
- <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
- <p id="category-add" class="wp-hidden-child">
- <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
- <label class="hidden" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
- <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
- <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
- <span id="category-ajax-response"></span>
- </p>
-</div>
-
<ul id="category-tabs">
<li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li>
- <li class="wp-no-js-hidden"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
+ <li class="hide-if-no-js"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
</ul>
<div id="categories-pop" class="ui-tabs-panel" style="display: none;">
<?php wp_category_checklist($post->ID, false, false, $popular_ids) ?>
</ul>
</div>
+
+<?php if ( current_user_can('manage_categories') ) : ?>
+<div id="category-adder" class="wp-hidden-children">
+ <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
+ <p id="category-add" class="wp-hidden-child">
+ <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
+ <label class="hidden" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
+ <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
+ <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
+ <span id="category-ajax-response"></span>
+ </p>
+</div>
<?php
+endif;
+
}
-add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'normal', 'core');
+add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');
+
+/**
+ * Display post password form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
+function post_password_meta_box($post) {
?>
-
-<?php do_meta_boxes('post', 'normal', $post); ?>
-
-<?php do_action('edit_form_advanced'); ?>
-
-<h2><?php _e('Advanced Options'); ?></h2>
-
+<p>
+ <label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> tabindex="4" /> <?php _e('Keep this post private') ?></label>
+</p>
+<h4><?php _e( 'Post Password' ); ?></h4>
+<p><label class="hidden" for="post_password"><?php _e('Password Protect This Post') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php the_post_password(); ?>" /></p>
+<p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this post and its comments.'); ?></p>
<?php
+}
+// add_meta_box('passworddiv', __('Privacy Options'), 'post_password_meta_box', 'post', 'side', 'core');
+
+/**
+ * Display post excerpt form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function post_excerpt_meta_box($post) {
?>
<label class="hidden" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea>
<p><?php _e('Excerpts are optional hand-crafted summaries of your content. You can <a href="http://codex.wordpress.org/Template_Tags/the_excerpt" target="_blank">use them in your template</a>'); ?></p>
<?php
}
-add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'advanced', 'core');
-
+add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core');
+
+/**
+ * Display trackback links form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function post_trackback_meta_box($post) {
- $form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. attribute_escape( str_replace("\n", ' ', $post->to_ping) ) .'" />';
+ $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" tabindex="7" value="'. attribute_escape( str_replace("\n", ' ', $post->to_ping) ) .'" />';
if ('' != $post->pinged) {
$pings = '<p>'. __('Already pinged:') . '</p><ul>';
$already_pinged = explode("\n", trim($post->pinged));
}
?>
-<p><label for="trackback"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p>
+<p><label for="trackback_url"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p>
<p><?php _e('Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress blogs they’ll be notified automatically using <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">pingbacks</a>, no other action necessary.'); ?></p>
<?php
if ( ! empty($pings) )
echo $pings;
}
-add_meta_box('trackbacksdiv', __('Trackbacks'), 'post_trackback_meta_box', 'post', 'advanced', 'core');
-
+add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core');
+
+/**
+ * Display custom fields for the post form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function post_custom_meta_box($post) {
?>
<div id="postcustomstuff">
-<table cellpadding="3">
+<div id="ajax-response"></div>
<?php
$metadata = has_meta($post->ID);
list_meta($metadata);
+meta_form();
?>
-
-</table>
-<?php
- meta_form();
-?>
-<div id="ajax-response"></div>
</div>
<p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
<?php
}
-add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'advanced', 'core');
+add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'normal', 'core');
do_action('dbx_post_advanced');
+/**
+ * Display comment status for post form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function post_comment_status_meta_box($post) {
+ global $wpdb, $post_ID;
?>
<input name="advanced_view" type="hidden" value="1" />
-<p><label for="comment_status" class="selectit">
-<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
-<?php _e('Allow Comments') ?></label></p>
-<p><label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label></p>
-<p><?php _e('These settings apply to this post only. “Pings” are <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a>.'); ?></p>
+<p class="meta-options">
+ <label for="comment_status" class="selectit"> <input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e('Allow comments on this post') ?></label><br />
+ <label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a> on this post') ?></label>
+</p>
<?php
-}
-add_meta_box('commentstatusdiv', __('Comments & Pings'), 'post_comment_status_meta_box', 'post', 'advanced', 'core');
+ $total = $wpdb->get_var($wpdb->prepare("SELECT count(1) FROM $wpdb->comments WHERE comment_post_ID = '%d' AND ( comment_approved = '0' OR comment_approved = '1')", $post_ID));
-function post_password_meta_box($post) {
+ if ( !$post_ID || $post_ID < 0 || 1 > $total )
+ return;
+
+wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
?>
-<p><label class="hidden" for="post_password"><?php _e('Password Protect This Post') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p>
-<p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this post and its comments.'); ?></p>
+
+<table class="widefat comments-box fixed" cellspacing="0" style="display:none;">
+<thead>
+ <tr>
+ <th scope="col" class="column-author"><?php _e('Author') ?></th>
+ <th scope="col" class="column-comment"><?php echo _c('Comment|noun') ?></th>
+ </tr>
+</thead>
+<tbody id="the-comment-list" class="list:comment">
+</tbody>
+</table>
+<p class="hide-if-no-js"><a href="#commentstatusdiv" id="show-comments" onclick="commentsBox.get(<?php echo $total; ?>);return false;"><?php _e('Show comments'); ?></a> <img class="waiting" style="display:none;" src="images/loading.gif" alt="" /></p>
<?php
+ $hidden = get_hidden_meta_boxes('post');
+ if ( ! in_array('commentstatusdiv', $hidden) ) { ?>
+ <script type="text/javascript">commentsBox.get(<?php echo $total; ?>, 10);</script>
+<?php
+ }
}
-add_meta_box('passworddiv', __('Password Protect This Post'), 'post_password_meta_box', 'post', 'advanced', 'core');
-
+add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core');
+
+/**
+ * Display post slug form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function post_slug_meta_box($post) {
?>
<label class="hidden" for="post_name"><?php _e('Post Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" />
<?php
}
-add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'advanced', 'core');
+if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) )
+ add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core');
$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
if ( $post->post_author && !in_array($post->post_author, $authors) )
$authors[] = $post->post_author;
if ( $authors && count( $authors ) > 1 ) :
+/**
+ * Display form field with list of authors.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function post_author_meta_box($post) {
global $current_user, $user_ID;
$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
<label class="hidden" for="post_author_override"><?php _e('Post Author'); ?></label><?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?>
<?php
}
-add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'advanced', 'core');
+add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'normal', 'core');
endif;
-if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
+if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
+/**
+ * Display list of post revisions.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function post_revisions_meta_box($post) {
wp_list_post_revisions();
}
-add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'advanced', 'core');
+add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core');
endif;
-do_meta_boxes('post', 'advanced', $post);
+do_action('do_meta_boxes', 'post', 'normal', $post);
+do_action('do_meta_boxes', 'post', 'advanced', $post);
+do_action('do_meta_boxes', 'post', 'side', $post);
+
+require_once('admin-header.php');
-do_action('dbx_post_sidebar');
?>
+
+<?php if ( (isset($mode) && 'bookmarklet' == $mode) || isset($_GET['popupurl']) ): ?>
+<input type="hidden" name="mode" value="bookmarklet" />
+<?php endif; ?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+<?php if ( $notice ) : ?>
+<div id="notice" class="error"><p><?php echo $notice ?></p></div>
+<?php endif; ?>
+<?php if (isset($_GET['message'])) : ?>
+<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<?php endif; ?>
+<form name="post" action="post.php" method="post" id="post">
+<?php
+
+if ( 0 == $post_ID)
+ wp_nonce_field('add-post');
+else
+ wp_nonce_field('update-post_' . $post_ID);
+
+?>
+
+<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
+<input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" />
+<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
+<input type="hidden" id="post_author" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />
+<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
+<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" />
+<input name="referredby" type="hidden" id="referredby" value="<?php echo clean_url(stripslashes(wp_get_referer())); ?>" />
+<?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?>
+
+<?php echo $form_extra ?>
+
+<div id="poststuff" class="metabox-holder">
+
+<div id="side-info-column" class="inner-sidebar">
+
+<?php do_action('submitpost_box'); ?>
+
+<?php $side_meta_boxes = do_meta_boxes('post', 'side', $post); ?>
+</div>
+
+<div id="post-body" class="<?php echo $side_meta_boxes ? 'has-sidebar' : ''; ?>">
+<div id="post-body-content" class="has-sidebar-content">
+<div id="titlediv">
+<div id="titlewrap">
+ <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape($post->post_title); ?>" id="title" autocomplete="off" />
+</div>
+<div class="inside">
+<?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>
+<?php if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) ) { ?>
+ <div id="edit-slug-box">
+<?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
+ echo $sample_permalink_html;
+endif; ?>
+ </div>
+<?php } ?>
</div>
</div>
+<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
+
+<?php the_editor($post->post_content); ?>
+
+<div id="post-status-info">
+ <span id="wp-word-count" class="alignleft"></span>
+ <span class="alignright">
+ <span id="autosave"> </span>
+<?php
+ if ( $post_ID ) {
+ echo '<span id="last-edit">';
+ if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
+ $last_user = get_userdata($last_id);
+ printf(__('Last edited by %1$s on %2$s at %3$s'), wp_specialchars( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
+ } else {
+ printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
+ }
+ echo '</span>';
+ }
+?>
+ </span>
+ <br class="clear" />
+</div>
+
+
+<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
+<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
+<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
+<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
+<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
</div>
+<?php
+
+do_meta_boxes('post', 'normal', $post);
+
+do_action('edit_form_advanced');
+
+do_meta_boxes('post', 'advanced', $post);
+
+do_action('dbx_post_sidebar');
+
+?>
+
+</div>
+</div>
+<br class="clear" />
+</div><!-- /poststuff -->
</form>
+</div>
+
+<?php wp_comment_reply(); ?>
<?php if ((isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?>
<script type="text/javascript">
<?php
+/**
+ * Edit comment form for inclusion in another file.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * @var string
+ */
$submitbutton_text = __('Edit Comment');
$toprow_title = sprintf(__('Editing Comment # %s'), $comment->comment_ID);
$form_action = 'editedcomment';
<form name="post" action="comment.php" method="post" id="post">
<?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?>
<div class="wrap">
-<h2><?php echo $toprow_title; ?></h2>
+<?php screen_icon(); ?>
+<h2><?php _e('Edit Comment'); ?></h2>
+
+<div id="poststuff" class="metabox-holder">
<input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" />
<input type="hidden" name="action" value='<?php echo $form_action . $form_extra ?>' />
+<?php
-<div id="poststuff">
+$email = attribute_escape( $comment->comment_author_email );
+$url = attribute_escape( $comment->comment_author_url );
+// add_meta_box('submitdiv', __('Save'), 'comment_submit_meta_box', 'comment', 'side', 'core');
+?>
+<div id="side-info-column" class="inner-sidebar">
+<div id="submitdiv" class="stuffbox" >
+<h3><span class='hndle'><?php _e('Status') ?></span></h3>
+<div class="inside">
<div class="submitbox" id="submitcomment">
+<div id="minor-publishing">
-<div id="previewview">
-<a href="<?php echo get_comment_link(); ?>" target="_blank"><?php _e('View this Comment'); ?></a>
+<div id="minor-publishing-actions">
+<div id="preview-action">
+<a class="preview button" href="<?php echo get_comment_link(); ?>" target="_blank"><?php _e('View Comment'); ?></a>
+</div>
+<div class="clear"></div>
</div>
-<div class="inside">
+<div id="misc-publishing-actions">
-<p><strong><label for='comment_status'><?php _e('Approval Status') ?></label></strong></p>
-<p>
-<select name='comment_status' id='comment_status'>
-<option<?php selected( $comment->comment_approved, '1' ); ?> value='1'><?php _e('Approved') ?></option>
-<option<?php selected( $comment->comment_approved, '0' ); ?> value='0'><?php _e('Moderated') ?></option>
-<option<?php selected( $comment->comment_approved, 'spam' ); ?> value='spam'><?php _e('Spam') ?></option>
-</select>
-</p>
+<div class="misc-pub-section" id="comment-status-radio">
+<label class="approved"><input type="radio"<?php checked( $comment->comment_approved, '1' ); ?> name="comment_status" value="1" /><?php echo _c('Approved|adjective') ?></label><br />
+<label class="waiting"><input type="radio"<?php checked( $comment->comment_approved, '0' ); ?> name="comment_status" value="0" /><?php echo _c('Pending|adjective') ?></label><br />
+<label class="spam"><input type="radio"<?php checked( $comment->comment_approved, 'spam' ); ?> name="comment_status" value="spam" /><?php echo _c('Spam|adjective'); ?></label>
+</div>
+<div class="misc-pub-section curtime misc-pub-section-last">
<?php
-$stamp = __('%1$s at %2$s');
-$date = mysql2date(get_option('date_format'), $comment->comment_date);
-$time = mysql2date(get_option('time_format'), $comment->comment_date);
+$datef = _c( 'M j, Y @ G:i|Publish box date format');
+$stamp = __('Submitted on: <b>%1$s</b>');
+$date = date_i18n( $datef, strtotime( $comment->comment_date ) );
?>
-<p class="curtime"><?php printf($stamp, $date, $time); ?>
- <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><?php _e('Edit') ?></a></p>
-
+<span id="timestamp"><?php printf($stamp, $date); ?></span> <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
<div id='timestampdiv' class='hide-if-js'><?php touch_time(('editcomment' == $action), 0, 5); ?></div>
-
+</div>
+</div> <!-- misc actions -->
+<div class="clear"></div>
</div>
-<p class="submit">
-<input type="submit" name="save" value="<?php _e('Save'); ?>" tabindex="4" class="button button-highlighted" />
-<?php
-echo "<a class='submitdelete' href='" . wp_nonce_url("comment.php?action=deletecomment&c=$comment->comment_ID&_wp_original_http_referer=" . wp_get_referer(), 'delete-comment_' . $comment->comment_ID) . "' onclick=\"if ( confirm('" . js_escape(__("You are about to delete this comment. \n 'Cancel' to stop, 'OK' to delete.")) . "') ) { return true;}return false;\">" . __('Delete comment') . "</a>";
-?>
-</p>
-
-<div class="side-info">
-<h5><?php _e('Related') ?></h5>
-
-<ul>
-<li><a href="edit-comments.php"><?php _e('Manage All Comments') ?></a></li>
-<li><a href="edit-comments.php?comment_status=moderated"><?php _e('Moderate Comments') ?></a></li>
-<?php do_action('comment_relatedlinks_list'); ?>
-</ul>
+<div id="major-publishing-actions">
+<div id="delete-action">
+<a class='submitdelete deletion' href='<?php echo wp_nonce_url("comment.php?action=deletecomment&c=$comment->comment_ID&_wp_original_http_referer=" . wp_get_referer(), 'delete-comment_' . $comment->comment_ID) . "' onclick=\"if ( confirm('" . js_escape(__("You are about to delete this comment. \n 'Cancel' to stop, 'OK' to delete.")) . "') ) { return true;}return false;\">" . __('Delete'); ?></a>
</div>
-<?php do_action('submitcomment_box'); ?>
+<div id="publishing-action">
+<input type="submit" name="save" value="<?php _e('Update Comment'); ?>" tabindex="4" class="button-primary" />
</div>
-
-<div id="post-body">
-<div id="namediv" class="stuffbox">
-<h3><label for="name"><?php _e('Name') ?></label></h3>
-<div class="inside">
-<input type="text" name="newcomment_author" size="30" value="<?php echo attribute_escape( $comment->comment_author ); ?>" tabindex="1" id="name" />
+<div class="clear"></div>
</div>
</div>
-
-<div id="emaildiv" class="stuffbox">
-<h3><label for="email"><?php _e('E-mail') ?></label></h3>
-<div class="inside">
-<input type="text" name="newcomment_author_email" size="30" value="<?php echo attribute_escape( $comment->comment_author_email ); ?>" tabindex="2" id="email" />
</div>
</div>
+</div>
+
+<div id="post-body" class="has-sidebar">
+<div id="post-body-content" class="has-sidebar-content">
-<div id="uridiv" class="stuffbox">
-<h3><label for="newcomment_author_url"><?php _e('URL') ?></label></h3>
+<div id="namediv" class="stuffbox">
+<h3><label for="name"><?php _e( 'Author' ) ?></label></h3>
<div class="inside">
-<input type="text" id="newcomment_author_url" name="newcomment_author_url" size="30" value="<?php echo attribute_escape( $comment->comment_author_url ); ?>" tabindex="3" />
+<table class="form-table">
+<tbody>
+<tr valign="top">
+ <td class="first"><?php _e( 'Name:' ); ?></td>
+ <td><input type="text" name="newcomment_author" size="30" value="<?php echo attribute_escape( $comment->comment_author ); ?>" tabindex="1" id="name" /></td>
+</tr>
+<tr valign="top">
+ <td class="first">
+ <?php
+ if ( $email ) {
+ printf( __( 'E-mail (%s):' ), get_comment_author_email_link( __( 'send e-mail' ), '', '' ) );
+ } else {
+ _e( 'E-mail:' );
+ }
+?></td>
+ <td><input type="text" name="newcomment_author_email" size="30" value="<?php echo $email; ?>" tabindex="2" id="email" /></td>
+</tr>
+<tr valign="top">
+ <td class="first">
+ <?php
+ $url = get_comment_author_url();
+ if ( ! empty( $url ) && 'http://' != $url ) {
+ $link = "<a href='$url' rel='external nofollow' target='_blank'>" . __('visit site') . "</a>";
+ printf( __( 'URL (%s):' ), apply_filters('get_comment_author_link', $link ) );
+ } else {
+ _e( 'URL:' );
+ } ?></td>
+ <td><input type="text" id="newcomment_author_url" name="newcomment_author_url" size="30" value="<?php echo $url; ?>" tabindex="3" /></td>
+</tr>
+</tbody>
+</table>
+<br />
</div>
</div>
<div id="postdiv" class="postarea">
-<h3><label for="content"><?php _e('Comment') ?></label></h3>
<?php the_editor($comment->comment_content, 'content', 'newcomment_author_url', false, 4); ?>
<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
</div>
<input type="hidden" name="c" value="<?php echo $comment->comment_ID ?>" />
<input type="hidden" name="p" value="<?php echo $comment->comment_post_ID ?>" />
-<input name="referredby" type="hidden" id="referredby" value="<?php echo wp_get_referer(); ?>" />
+<input name="referredby" type="hidden" id="referredby" value="<?php echo clean_url(stripslashes(wp_get_referer())); ?>" />
<?php wp_original_referer_field(true, 'previous'); ?>
<input type="hidden" name="noredir" value="1" />
+
+</div>
</div>
</div>
</div>
-
</form>
<script type="text/javascript">
+++ /dev/null
-
-<div class="wrap">
-<h2><?php _e('Write Post'); ?></h2>
-<form name="post" action="post.php" method="post" id="simple">
-
-<?php if (isset($mode) && 'bookmarklet' == $mode) : ?>
-<input type="hidden" name="mode" value="bookmarklet" />
-<?php endif; ?>
-<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
-<input type="hidden" name="action" value='post' />
-
-<div id="poststuff">
- <fieldset id="titlediv">
- <legend><a href="http://wordpress.org/docs/reference/post/#title" title="<?php _e('Help on titles') ?>"><?php _e('Title') ?></a></legend>
- <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" /></div>
- </fieldset>
-
- <fieldset id="categorydiv">
- <legend><a href="http://wordpress.org/docs/reference/post/#category" title="<?php _e('Help on categories') ?>"><?php _e('Categories') ?></a></legend>
- <div><?php dropdown_categories($post->post_category); ?></div>
- </fieldset>
-
-<br />
-<fieldset id="postdiv">
- <legend><a href="http://wordpress.org/docs/reference/post/#post" title="<?php _e('Help with post field') ?>"><?php _e('Post') ?></a></legend>
-<?php
- $rows = get_option('default_post_edit_rows');
- if (($rows < 3) || ($rows > 100)) {
- $rows = 10;
- }
-?>
-<div><textarea rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo $post->post_content ?></textarea></div>
-<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
-</fieldset>
-
-
-<script type="text/javascript">
-<!--
-edCanvas = document.getElementById('content');
-//-->
-</script>
-
-<input type="hidden" name="post_pingback" value="<?php echo (int) get_option('default_pingback_flag') ?>" id="post_pingback" />
-
-<p><label for="trackback"> <?php printf(__('<a href="%s" title="Help on trackbacks"><strong>TrackBack</strong> a <abbr title="Universal Resource Locator">URL</abbr></a>:</label> (Separate multiple <abbr title="Universal Resource Locator">URL</abbr>s with spaces.)'), 'http://wordpress.org/docs/reference/post/#trackback'); echo '<br />'; ?>
- <input type="text" name="trackback_url" style="width: 360px" id="trackback" tabindex="7" /></p>
-
-<p class="submit"><input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="<?php _e('Save as Draft') ?>" />
- <input name="saveasprivate" type="submit" id="saveasprivate" tabindex="10" value="<?php _e('Save as Private') ?>" />
-
- <?php if ( current_user_can('edit_posts') ) : ?>
- <input name="publish" type="submit" id="publish" tabindex="6" value="<?php _e('Publish') ?>" class="button button-highlighted" />
-<?php endif; ?>
-
-<?php if ('bookmarklet' != $mode) {
- echo '<input name="advanced" type="submit" id="advancededit" tabindex="7" value="' . __('Advanced Editing') . '" />';
- } ?>
- <input name="referredby" type="hidden" id="referredby" value="<?php if ( $refby = wp_get_referer() ) echo urlencode($refby); ?>" />
-</p>
-
-<?php do_action('simple_edit_form', ''); ?>
-
-</div>
-</form>
-
-<script type="text/javascript">
-try{document.getElementById('title').focus();}catch(e){}
-</script>
-</div>
<?php
+/**
+ * Edit Link Categories Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
-// Handle bulk deletes
-if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
+// Handle bulk actions
+if ( isset($_GET['action']) && isset($_GET['delete']) ) {
check_admin_referer('bulk-link-categories');
+ $doaction = $_GET['action'] ? $_GET['action'] : $_GET['action2'];
if ( !current_user_can('manage_categories') )
wp_die(__('Cheatin’ uh?'));
- foreach( (array) $_GET['delete'] as $cat_ID ) {
- $cat_name = get_term_field('name', $cat_ID, 'link_category');
- $default_cat_id = get_option('default_link_category');
-
- // Don't delete the default cats.
- if ( $cat_ID == $default_cat_id )
- wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
+ if ( 'delete' == $doaction ) {
+ foreach( (array) $_GET['delete'] as $cat_ID ) {
+ $cat_name = get_term_field('name', $cat_ID, 'link_category');
+ $default_cat_id = get_option('default_link_category');
- wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
- }
+ // Don't delete the default cats.
+ if ( $cat_ID == $default_cat_id )
+ wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
- $location = 'edit-link-categories.php';
- if ( $referer = wp_get_referer() ) {
- if ( false !== strpos($referer, 'edit-link-categories.php') )
- $location = $referer;
- }
+ wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
+ }
+
+ $location = 'edit-link-categories.php';
+ if ( $referer = wp_get_referer() ) {
+ if ( false !== strpos($referer, 'edit-link-categories.php') )
+ $location = $referer;
+ }
- $location = add_query_arg('message', 6, $location);
- wp_redirect($location);
- exit();
-} elseif ( !empty($_GET['_wp_http_referer']) ) {
- wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
+ $location = add_query_arg('message', 6, $location);
+ wp_redirect($location);
+ exit();
+ }
+} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
+ wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
exit;
}
$title = __('Link Categories');
-$parent_file = 'edit.php';
-wp_enqueue_script( 'admin-categories' );
-wp_enqueue_script('admin-forms');
+wp_enqueue_script('admin-categories');
+if ( current_user_can('manage_categories') )
+ wp_enqueue_script('inline-edit-tax');
require_once ('admin-header.php');
$messages[3] = __('Category updated.');
$messages[4] = __('Category not added.');
$messages[5] = __('Category not updated.');
-$messages[6] = __('Categories deleted.');
+$messages[6] = __('Categories deleted.'); ?>
+
+<div class="wrap nosubsub">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title );
+if ( isset($_GET['s']) && $_GET['s'] )
+ printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
+</h2>
-if (isset($_GET['message'])) : ?>
-<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<?php if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
+<div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
endif; ?>
-<div class="wrap">
-
-<form id="posts-filter" action="" method="get">
-<?php if ( current_user_can('manage_categories') ) : ?>
- <h2><?php printf(__('Manage Link Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
-<?php else : ?>
- <h2><?php _e('Manage Link Categories') ?> </h2>
-<?php endif; ?>
-
-<p id="post-search">
- <label class="hidden" for="post-search-input"><?php _e( 'Search Categories' ); ?>:</label>
- <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
+<form class="search-form" action="" method="get">
+<p class="search-box">
+ <label class="hidden" for="link-category-search-input"><?php _e( 'Search Categories' ); ?>:</label>
+ <input type="text" class="search-input" id="link-category-search-input" name="s" value="<?php _admin_search_query(); ?>" />
<input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" />
</p>
-
+</form>
<br class="clear" />
+<div id="col-container">
+
+<div id="col-right">
+<div class="col-wrap">
+<form id="posts-filter" action="" method="get">
<div class="tablenav">
<?php
-$pagenum = absint( $_GET['pagenum'] );
+$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
if ( empty($pagenum) )
$pagenum = 1;
-if( !$catsperpage || $catsperpage < 0 )
+if( ! isset( $catsperpage ) || $catsperpage < 0 )
$catsperpage = 20;
$page_links = paginate_links( array(
'base' => add_query_arg( 'pagenum', '%#%' ),
'format' => '',
+ 'prev_text' => __('«'),
+ 'next_text' => __('»'),
'total' => ceil(wp_count_terms('link_category') / $catsperpage),
'current' => $pagenum
));
echo "<div class='tablenav-pages'>$page_links</div>";
?>
-<div class="alignleft">
-<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
+<div class="alignleft actions">
+<select name="action">
+<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-link-categories'); ?>
</div>
<br class="clear" />
</div>
-<br class="clear" />
+<div class="clear"></div>
-<table class="widefat">
+<table class="widefat fixed" cellspacing="0">
<thead>
<tr>
- <th scope="col" class="check-column"><input type="checkbox" /></th>
- <th scope="col"><?php _e('Name') ?></th>
- <th scope="col"><?php _e('Description') ?></th>
- <th scope="col" class="num" style="width: 90px;"><?php _e('Links') ?></th>
+<?php print_column_headers('edit-link-categories'); ?>
</tr>
</thead>
+
+ <tfoot>
+ <tr>
+<?php print_column_headers('edit-link-categories', false); ?>
+ </tr>
+ </tfoot>
+
<tbody id="the-list" class="list:link-cat">
<?php
$start = ($pagenum - 1) * $catsperpage;
if ( $categories ) {
$output = '';
foreach ( $categories as $category ) {
- $category = sanitize_term($category, 'link_category', 'display');
$output .= link_cat_row($category);
}
- $output = apply_filters('cat_rows', $output);
echo $output;
unset($category);
}
?>
</tbody>
</table>
-</form>
<div class="tablenav">
-
<?php
if ( $page_links )
echo "<div class='tablenav-pages'>$page_links</div>";
?>
+
+<div class="alignleft actions">
+<select name="action2">
+<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
+</div>
+
<br class="clear" />
</div>
<br class="clear" />
+</form>
+<div class="form-wrap">
+<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the links in that category. Instead, links that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), get_term_field('name', get_option('default_link_category'), 'link_category')) ?></p>
</div>
-<?php if ( current_user_can('manage_categories') ) : ?>
-<div class="wrap">
-<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the links in that category. Instead, links that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), get_term_field('name', get_option('default_link_category'), 'link_category')) ?></p>
+
+</div>
+</div><!-- /col-right -->
+
+<div id="col-left">
+<div class="col-wrap">
+
+<?php if ( current_user_can('manage_categories') ) {
+ $category = (object) array(); $category->parent = 0; do_action('add_link_category_form_pre', $category); ?>
+
+<div class="form-wrap">
+<h3><?php _e('Add Category'); ?></h3>
+<div id="ajax-response"></div>
+<form name="addcat" id="addcat" class="add:the-list: validate" method="post" action="link-category.php">
+<input type="hidden" name="action" value="addcat" />
+<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-link-category'); ?>
+
+<div class="form-field form-required">
+ <label for="name"><?php _e('Category name') ?></label>
+ <input name="name" id="name" type="text" value="" size="40" aria-required="true" />
</div>
-<?php include('edit-link-category-form.php'); ?>
+<div class="form-field">
+ <label for="slug"><?php _e('Category slug') ?></label>
+ <input name="slug" id="slug" type="text" value="" size="40" />
+ <p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
+</div>
-<?php endif; ?>
+<div class="form-field">
+ <label for="description"><?php _e('Description (optional)') ?></label>
+ <textarea name="description" id="description" rows="5" cols="40"></textarea>
+</div>
+<p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Category'); ?>" /></p>
+<?php do_action('edit_link_category_form', $category); ?>
+</form>
+</div>
+
+<?php } ?>
+
+</div>
+</div><!-- /col-left -->
+
+</div><!-- /col-container -->
+</div><!-- /wrap -->
+
+<script type="text/javascript">
+/* <![CDATA[ */
+(function($){
+ $(document).ready(function(){
+ $('#doaction, #doaction2').click(function(){
+ if ( $('select[name^="action"]').val() == 'delete' ) {
+ var m = '<?php echo js_escape(__("You are about to delete the selected link categories.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
+ return showNotice.warn(m);
+ }
+ });
+ });
+})(jQuery);
+/* ]]> */
+</script>
+
+<?php inline_edit_term_row('edit-link-categories'); ?>
<?php include('admin-footer.php'); ?>
<?php
+/**
+ * Edit link category form for inclusion in administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * @var object
+ */
+if ( ! isset( $category ) )
+ $category = (object) array();
+
if ( ! empty($cat_ID) ) {
- $heading = __('Edit Category');
- $submit_text = __('Edit Category');
+ /**
+ * @var string
+ */
+ $heading = '<h2>' . __('Edit Link Category') . '</h2>';
+ $submit_text = __('Update Category');
$form = '<form name="editcat" id="editcat" method="post" action="link-category.php" class="validate">';
$action = 'editedcat';
$nonce_action = 'update-link-category_' . $cat_ID;
do_action('edit_link_category_form_pre', $category);
} else {
- $heading = __('Add Category');
+ $heading = '<h2>' . __('Add Link Category') . '</h2>';
$submit_text = __('Add Category');
$form = '<form name="addcat" id="addcat" class="add:the-list: validate" method="post" action="link-category.php">';
$action = 'addcat';
$nonce_action = 'add-link-category';
do_action('add_link_category_form_pre', $category);
}
+
+/**
+ * @ignore
+ * @since 2.7
+ * @internal Used to prevent errors in page when no category is being edited.
+ *
+ * @param object $category
+ */
+function _fill_empty_link_category(&$category) {
+ if ( ! isset( $category->name ) )
+ $category->name = '';
+
+ if ( ! isset( $category->slug ) )
+ $category->slug = '';
+
+ if ( ! isset( $category->description ) )
+ $category->description = '';
+}
+
+_fill_empty_link_category($category);
?>
<div class="wrap">
-<h2><?php echo $heading ?></h2>
+<?php screen_icon(); ?>
+<?php echo $heading ?>
<div id="ajax-response"></div>
<?php echo $form ?>
<input type="hidden" name="action" value="<?php echo $action ?>" />
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="slug"><?php _e('Category slug') ?></label></th>
- <td><input name="slug" id="slug" type="text" value="<?php echo attribute_escape(apply_filters('editable_slug', $category->slug)); ?>" size="40" />
+ <td><input name="slug" id="slug" type="text" value="<?php echo attribute_escape(apply_filters('editable_slug', $category->slug)); ?>" size="40" /><br />
<?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></td>
</tr>
<tr class="form-field">
<td><textarea name="description" id="description" rows="5" cols="50" style="width: 97%;"><?php echo $category->description; ?></textarea></td>
</tr>
</table>
-<p class="submit"><input type="submit" class="button" name="submit" value="<?php echo $submit_text ?>" /></p>
+<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php echo $submit_text ?>" /></p>
<?php do_action('edit_link_category_form', $category); ?>
</form>
</div>
<?php
+/**
+ * Edit links form for inclusion in administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
if ( ! empty($link_id) ) {
- $heading = __('Edit Link');
- $submit_text = __('Save Changes');
+ $heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' );
+ $submit_text = __('Update Link');
$form = '<form name="editlink" id="editlink" method="post" action="link.php">';
$nonce_action = 'update-bookmark_' . $link_id;
} else {
- $heading = __('Add Link');
+ $heading = sprintf( __( '<a href="%s">Links</a> / Add New Link' ), 'link-manager.php' );
$submit_text = __('Add Link');
$form = '<form name="addlink" id="addlink" method="post" action="link.php">';
$nonce_action = 'add-bookmark';
}
+/**
+ * Display checked checkboxes attribute for xfn microformat options.
+ *
+ * @since 1.0.1
+ *
+ * @param string $class
+ * @param string $value
+ * @param mixed $deprecated Not used.
+ */
function xfn_check($class, $value = '', $deprecated = '') {
global $link;
- $link_rel = $link->link_rel;
+ $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
$rels = preg_split('/\s+/', $link_rel);
if ('' != $value && in_array($value, $rels) ) {
if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
}
}
-?>
-
-<?php echo $form ?>
-<?php wp_nonce_field($nonce_action); ?>
-<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
-
-<div class="wrap">
-<h2><?php echo $heading; ?></h2>
-
-<div id="poststuff">
+/**
+ * Display link create form fields.
+ *
+ * @since 2.7.0
+ *
+ * @param object $link
+ */
+function link_submit_meta_box($link) {
+?>
<div class="submitbox" id="submitlink">
-<div id="previewview">
-<?php if ( !empty($link_id) ) { ?>
-<a href="<?php echo $link->link_url; ?>" target="_blank"><?php _e('Visit Link'); ?></a>
-<?php } ?>
-</div>
+<div id="minor-publishing">
-<div class="inside">
-<p><label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked($link->link_visible, 'N'); ?> /> <?php _e('Keep this link private') ?></label></p>
+<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
+<div style="display:none;">
+<input type="submit" name="save" value="<?php echo attribute_escape( __('Save') ); ?>" />
</div>
-<p class="submit">
-<input type="submit" class="button button-highlighted" name="save" value="<?php _e('Save'); ?>" tabindex="4" />
-<?php
-if ( ( 'edit' == $action) && current_user_can('manage_links') )
- echo "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&link_id=$link_id", 'delete-bookmark_' . $link_id) . "' onclick=\"if ( confirm('" . js_escape( sprintf( __("You are about to delete this link '%s'\n'Cancel' to stop, 'OK' to delete."), $link->link_name )) . "') ) { return true;}return false;\">" . __('Delete link') . "</a>";
-?>
-</p>
-
-<div class="side-info">
-<h5><?php _e('Related') ?></h5>
-
-<ul>
-<li><a href="link-manager.php"><?php _e('Manage All Links') ?></a></li>
-<li><a href="edit-link-categories.php"><?php _e('Manage All Link Categories') ?></a></li>
-<li><a href="link-import.php"><?php _e('Import Links') ?></a></li>
-<?php do_action('link_relatedlinks_list'); ?>
-</ul>
+<div id="minor-publishing-actions">
+<div id="preview-action">
+<?php if ( !empty($link->link_id) ) { ?>
+ <a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank" tabindex="4"><?php _e('Visit Link'); ?></a>
+<?php } ?>
</div>
-<?php do_action('submitlink_box'); ?>
+<div class="clear"></div>
</div>
-<div id="post-body">
-<div id="namediv" class="stuffbox">
-<h3><label for="link_name"><?php _e('Name') ?></label></h3>
-<div class="inside">
- <input type="text" name="link_name" size="30" tabindex="1" value="<?php echo $link->link_name; ?>" id="link_name" /><br />
- <?php _e('Example: Nifty blogging software'); ?>
+<div id="misc-publishing-actions">
+<div class="misc-pub-section misc-pub-section-last">
+ <label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked($link->link_visible, 'N'); ?> /> <?php _e('Keep this link private') ?></label>
</div>
</div>
-<div id="addressdiv" class="stuffbox">
-<h3><label for="link_url"><?php _e('Web Address') ?></label></h3>
-<div class="inside">
- <input type="text" name="link_url" size="30" tabindex="1" value="<?php echo $link->link_url; ?>" id="link_url" /><br />
- <?php _e('Example: <code>http://wordpress.org/</code> — don’t forget the <code>http://</code>'); ?>
</div>
+
+<div id="major-publishing-actions">
+<?php do_action('post_submitbox_start'); ?>
+<div id="delete-action">
+<?php
+if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?>
+ <a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id); ?>" onclick="if ( confirm('<?php echo js_escape(sprintf(__("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
+<?php } ?>
</div>
-<div id="descriptiondiv" class="stuffbox">
-<h3><label for="link_description"><?php _e('Description') ?></label></h3>
-<div class="inside">
- <input type="text" name="link_description" size="30" tabindex="1" value="<?php echo $link->link_description; ?>" id="link_description" /><br />
- <?php _e('This will be shown when someone hovers over the link in the blogroll, or optionally below the link.'); ?>
+<div id="publishing-action">
+<?php if ( !empty($link->link_id) ) { ?>
+ <input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php _e('Update Link') ?>" />
+<?php } else { ?>
+ <input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php _e('Add Link') ?>" />
+<?php } ?>
</div>
+<div class="clear"></div>
</div>
+<?php do_action('submitlink_box'); ?>
+<div class="clear"></div>
+</div>
+<?php
+}
+add_meta_box('linksubmitdiv', __('Save'), 'link_submit_meta_box', 'link', 'side', 'core');
-<?php function link_categories_meta_box($link) { ?>
+/**
+ * Display link categories form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $link
+ */
+function link_categories_meta_box($link) { ?>
<div id="category-adder" class="wp-hidden-children">
<h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4>
<p id="link-category-add" class="wp-hidden-child">
<label class="hidden" for="newcat"><?php _e( '+ Add New Category' ); ?></label>
<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" aria-required="true" />
- <input type="button" id="category-add-sumbit" class="add:categorychecklist:linkcategorydiv button" value="<?php _e( 'Add' ); ?>" />
+ <input type="button" id="category-add-submit" class="add:categorychecklist:linkcategorydiv button" value="<?php _e( 'Add' ); ?>" />
<?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?>
<span id="category-ajax-response"></span>
</p>
<ul id="category-tabs">
<li class="ui-tabs-selected"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
- <li class="wp-no-js-hidden"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
+ <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
</ul>
<div id="categories-all" class="ui-tabs-panel">
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
- <?php wp_link_category_checklist($link->link_id); ?>
+ <?php
+ if ( isset($link->link_id) )
+ wp_link_category_checklist($link->link_id);
+ else
+ wp_link_category_checklist();
+ ?>
</ul>
</div>
<?php
}
add_meta_box('linkcategorydiv', __('Categories'), 'link_categories_meta_box', 'link', 'normal', 'core');
-?>
-
-<?php do_meta_boxes('link', 'normal', $link); ?>
-
-<h2><?php _e('Advanced Options'); ?></h2>
-<?php function link_target_meta_box($link) { ?>
+/**
+ * Display form fields for changing link target.
+ *
+ * @since 2.6.0
+ *
+ * @param object $link
+ */
+function link_target_meta_box($link) { ?>
<fieldset><legend class="hidden"><?php _e('Target') ?></legend>
<label for="link_target_blank" class="selectit">
-<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
+<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
<code>_blank</code></label><br />
<label for="link_target_top" class="selectit">
-<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
+<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
<code>_top</code></label><br />
<label for="link_target_none" class="selectit">
-<input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
+<input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> />
<?php _e('none') ?></label>
</fieldset>
<p><?php _e('Choose the frame your link targets. Essentially this means if you choose <code>_blank</code> your link will open in a new window.'); ?></p>
<?php
}
-add_meta_box('linktargetdiv', __('Target'), 'link_target_meta_box', 'link', 'advanced', 'core');
+add_meta_box('linktargetdiv', __('Target'), 'link_target_meta_box', 'link', 'normal', 'core');
+/**
+ * Display xfn form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $link
+ */
function link_xfn_meta_box($link) {
?>
<table class="editform" style="width: 100%;" cellspacing="2" cellpadding="5">
<tr>
<th style="width: 20%;" scope="row"><label for="link_rel"><?php _e('rel:') ?></label></th>
- <td style="width: 80%;"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
+ <td style="width: 80%;"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo ( isset( $link->link_rel ) ? $link->link_rel : ''); ?>" /></td>
</tr>
<tr>
<td colspan="2">
<p><?php _e('If the link is to a person, you can specify your relationship with them using the above form. If you would like to learn more about the idea check out <a href="http://gmpg.org/xfn/">XFN</a>.'); ?></p>
<?php
}
-add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', 'link', 'advanced', 'core');
+add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', 'link', 'normal', 'core');
+/**
+ * Display advanced link options form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $link
+ */
function link_advanced_meta_box($link) {
?>
<table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
<tr class="form-field">
<th valign="top" scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th>
- <td><input type="text" name="link_image" id="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
+ <td><input type="text" name="link_image" id="link_image" size="50" value="<?php echo ( isset( $link->link_image ) ? $link->link_image : ''); ?>" style="width: 95%" /></td>
</tr>
<tr class="form-field">
<th valign="top" scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>
- <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
+ <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo ( isset( $link->link_rss ) ? $link->link_rss : ''); ?>" size="50" style="width: 95%" /></td>
</tr>
<tr class="form-field">
<th valign="top" scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>
- <td><textarea name="link_notes" id="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
+ <td><textarea name="link_notes" id="link_notes" cols="50" rows="10" style="width: 95%"><?php echo ( isset( $link->link_notes ) ? $link->link_notes : ''); ?></textarea></td>
</tr>
<tr class="form-field">
<th valign="top" scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th>
<?php
for ($r = 0; $r < 10; $r++) {
echo(' <option value="'.$r.'" ');
- if ($link->link_rating == $r)
+ if ( isset($link->link_rating) && $link->link_rating == $r)
echo 'selected="selected"';
echo('>'.$r.'</option>');
}
</table>
<?php
}
-add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', 'link', 'advanced', 'core');
+add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', 'link', 'normal', 'core');
+
+do_action('do_meta_boxes', 'link', 'normal', $link);
+do_action('do_meta_boxes', 'link', 'advanced', $link);
+do_action('do_meta_boxes', 'link', 'side', $link);
+
+require_once ('admin-header.php');
+
+?>
+
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
+<?php if ( isset( $_GET['added'] ) ) : ?>
+<div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div>
+<?php endif; ?>
+
+<?php
+if ( !empty($form) )
+ echo $form;
+if ( !empty($link_added) )
+ echo $link_added;
+
+wp_nonce_field( $nonce_action );
+wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
+wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
+
+<div id="poststuff" class="metabox-holder">
+
+<div id="side-info-column" class="inner-sidebar">
+<?php
+
+do_action('submitlink_box');
+$side_meta_boxes = do_meta_boxes( 'link', 'side', $link );
+
+?>
+</div>
+
+<div id="post-body" class="<?php echo $side_meta_boxes ? 'has-sidebar' : ''; ?>">
+<div id="post-body-content" class="has-sidebar-content">
+<div id="namediv" class="stuffbox">
+<h3><label for="link_name"><?php _e('Name') ?></label></h3>
+<div class="inside">
+ <input type="text" name="link_name" size="30" tabindex="1" value="<?php echo $link->link_name; ?>" id="link_name" />
+ <p><?php _e('Example: Nifty blogging software'); ?></p>
+</div>
+</div>
+
+<div id="addressdiv" class="stuffbox">
+<h3><label for="link_url"><?php _e('Web Address') ?></label></h3>
+<div class="inside">
+ <input type="text" name="link_url" size="30" tabindex="1" value="<?php echo $link->link_url; ?>" id="link_url" />
+ <p><?php _e('Example: <code>http://wordpress.org/</code> — don’t forget the <code>http://</code>'); ?></p>
+</div>
+</div>
+
+<div id="descriptiondiv" class="stuffbox">
+<h3><label for="link_description"><?php _e('Description') ?></label></h3>
+<div class="inside">
+ <input type="text" name="link_description" size="30" tabindex="1" value="<?php echo isset($link->link_description) ? $link->link_description : ''; ?>" id="link_description" />
+ <p><?php _e('This will be shown when someone hovers over the link in the blogroll, or optionally below the link.'); ?></p>
+</div>
+</div>
+
+<?php
+
+do_meta_boxes('link', 'normal', $link);
do_meta_boxes('link', 'advanced', $link);
</div>
</div>
-
</div>
</form>
+</div>
<?php
+/**
+ * Edit page form for inclusion in the administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Post ID global.
+ * @name $post_ID
+ * @var int
+ */
+if ( ! isset( $post_ID ) )
+ $post_ID = 0;
+if ( ! isset( $temp_ID ) )
+ $temp_ID = 0;
+
if ( isset($_GET['message']) )
$_GET['message'] = absint( $_GET['message'] );
-$messages[1] = sprintf( __( 'Page updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) );
+$messages[1] = sprintf( __( 'Page updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( ( isset( $_GET['_wp_original_http_referer'] ) ? $_GET['_wp_original_http_referer'] : '') ) ) );
$messages[2] = __('Custom field updated.');
$messages[3] = __('Custom field deleted.');
$messages[4] = __('Page updated.');
+$messages[5] = sprintf(__('Page published. <a href="%s">View page</a>'), get_permalink($post_ID));
+$messages[6] = sprintf(__('Page submitted. <a href="%s">Preview page</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
if ( isset($_GET['revision']) )
$messages[5] = sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) );
$notice = false;
$notices[1] = __( 'There is an autosave of this page that is more recent than the version below. <a href="%s">View the autosave</a>.' );
-if (!isset($post_ID) || 0 == $post_ID) {
+if ( 0 == $post_ID) {
$form_action = 'post';
$nonce_action = 'add-page';
$temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
$form_action = 'editpost';
$nonce_action = 'update-page_' . $post_ID;
$form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
- $autosave = wp_get_post_autosave( $post_id );
+ $autosave = wp_get_post_autosave( $post_ID );
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) )
$notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
}
$temp_ID = (int) $temp_ID;
$user_ID = (int) $user_ID;
+/**
+ * Display submit form fields.
+ *
+ * @since 2.7.0
+ *
+ * @param object $post
+ */
+function page_submit_meta_box($post) {
+ global $action;
+
+ $can_publish = current_user_can('publish_pages');
?>
+<div class="submitbox" id="submitpage">
-<?php if ( $notice ) : ?>
-<div id="notice" class="error"><p><?php echo $notice ?></p></div>
-<?php endif; ?>
-<?php if (isset($_GET['message'])) : ?>
-<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
-<?php endif; ?>
+<div id="minor-publishing">
-<form name="post" action="page.php" method="post" id="post">
-<div class="wrap">
-<h2><?php _e('Write Page') ?></h2>
+<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
+<div style="display:none;">
+<input type="submit" name="save" value="<?php echo attribute_escape( __('Save') ); ?>" />
+</div>
-<?php
-wp_nonce_field($nonce_action);
+<div id="minor-publishing-actions">
+<div id="save-action">
+<?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
+<input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save Draft') ); ?>" tabindex="4" class="button button-highlighted" />
+<?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
+<input type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save as Pending') ); ?>" tabindex="4" class="button button-highlighted" />
+<?php } ?>
+</div>
-if (isset($mode) && 'bookmarklet' == $mode)
- echo '<input type="hidden" name="mode" value="bookmarklet" />';
-?>
-<input type="hidden" id="user-id" name="user_ID" value="<?php echo $user_ID ?>" />
-<input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' />
-<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
-<input type="hidden" id="post_author" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />
-<?php echo $form_extra ?>
-<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
-<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" />
-<input name="referredby" type="hidden" id="referredby" value="<?php echo clean_url(stripslashes(wp_get_referer())); ?>" />
-<?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?>
+<div id="preview-action">
+<?php $preview_link = 'publish' == $post->post_status ? clean_url(get_permalink($post->ID)) : clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>
-<div id="poststuff">
+<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php _e('Preview'); ?></a>
+<input type="hidden" name="wp-preview" id="wp-preview" value="" />
+</div>
-<div class="submitbox" id="submitpage">
+<div class="clear"></div>
+</div><?php // /minor-publishing-actions ?>
-<div id="previewview">
-<?php if ( 'publish' == $post->post_status ) { ?>
-<a href="<?php echo clean_url(get_permalink($post->ID)); ?>" target="_blank" tabindex="4"><?php _e('View this Page'); ?></a>
-<?php } elseif ( 'edit' == $action ) { ?>
-<a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" target="_blank" tabindex="4"><?php _e('Preview this Page'); ?></a>
-<?php } ?>
-</div>
+<div id="misc-publishing-actions">
-<div class="inside">
-<p><strong><label for='post_status'><?php _e('Publish Status') ?></label></strong></p>
-<p>
-<select name='post_status' tabindex='4' id='post_status'>
-<?php // Show publish in dropdown if user can publish or if they can re-publish this page ('edit_published_pages')
-// 'publish' option will be selected for published AND private posts (checkbox overrides dropdown)
-if ( current_user_can('publish_pages') OR ( $post->post_status == 'publish' AND current_user_can('edit_page', $post->ID) ) ) :
+<div class="misc-pub-section<?php if ( !$can_publish ) { echo ' misc-pub-section-last'; } ?>"><label for="post_status"><?php _e('Status:') ?></label>
+<b><span id="post-status-display">
+<?php
+switch ( $post->post_status ) {
+ case 'private':
+ _e('Privately Published');
+ break;
+ case 'publish':
+ _e('Published');
+ break;
+ case 'future':
+ _e('Scheduled');
+ break;
+ case 'pending':
+ _e('Pending Review');
+ break;
+ case 'draft':
+ _e('Draft');
+ break;
+}
?>
-<option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option>
-<?php endif; ?>
-<?php if ( 'future' == $post->post_status ) : ?>
-<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Pending') ?></option>
+</span></b>
+<?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
+<a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
+
+<div id="post-status-select" class="hide-if-js">
+<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo $post->post_status; ?>" />
+<select name='post_status' id='post_status' tabindex='4'>
+<?php if ( 'publish' == $post->post_status ) : ?>
+<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
+<?php elseif ( 'private' == $post->post_status ) : ?>
+<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
+<?php elseif ( 'future' == $post->post_status ) : ?>
+<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
<?php endif; ?>
<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
-<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Unpublished') ?></option>
+<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
</select>
+
+ <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
+ <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
+</div>
+
+<?php } ?>
+</div><?php // /misc-pub-section ?>
+
+<div class="misc-pub-section " id="visibility">
+<?php _e('Visibility:'); ?> <b><span id="post-visibility-display"><?php
+
+if ( 'private' == $post->post_status ) {
+ $post->post_password = '';
+ $visibility = 'private';
+ $visibility_trans = __('Private');
+} elseif ( !empty( $post->post_password ) ) {
+ $visibility = 'password';
+ $visibility_trans = __('Password protected');
+} else {
+ $visibility = 'public';
+ $visibility_trans = __('Public');
+}
+
+?><?php echo wp_specialchars( $visibility_trans ); ?></span></b> <?php if ( $can_publish ) { ?> <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
+
+<div id="post-visibility-select" class="hide-if-js">
+<input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo attribute_escape($post->post_password); ?>" />
+<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo attribute_escape( $visibility ); ?>" />
+
+
+<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
+<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
+<span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo attribute_escape($post->post_password); ?>" /><br /></span>
+<input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
+
+<p>
+ <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
+ <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
</p>
-<?php if ( current_user_can( 'publish_posts' ) ) : ?>
-<p id="private-checkbox"><label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> tabindex='4' /> <?php _e('Keep this page private') ?></label></p>
-<?php endif; ?>
+</div>
+<?php } ?>
+
+</div><?php // /misc-pub-section ?>
<?php
-if ($post_ID) {
+$datef = _c( 'M j, Y @ G:i|Publish box date format');
+if ( 0 != $post->ID ) {
if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
- $stamp = __('Scheduled for:<br />%1$s at %2$s');
- } else if ( 'publish' == $post->post_status ) { // already published
- $stamp = __('Published on:<br />%1$s at %2$s');
- } else if ( '0000-00-00 00:00:00' == $post->post_date ) { // draft, 1 or more saves, no date specified
- $stamp = __('Publish immediately');
+ $stamp = __('Scheduled for: <b>%1$s</b>');
+ } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
+ $stamp = __('Published on: <b>%1$s</b>');
+ } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
+ $stamp = __('Publish <b>immediately</b>');
+ } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
+ $stamp = __('Schedule for: <b>%1$s</b>');
} else { // draft, 1 or more saves, date specified
- $stamp = __('Publish on:<br />%1$s at %2$s');
+ $stamp = __('Publish on: <b>%1$s</b>');
}
- $date = mysql2date(get_option('date_format'), $post->post_date);
- $time = mysql2date(get_option('time_format'), $post->post_date);
+ $date = date_i18n( $datef, strtotime( $post->post_date ) );
} else { // draft (no saves, and thus no date specified)
- $stamp = __('Publish immediately');
- $date = mysql2date(get_option('date_format'), current_time('mysql'));
- $time = mysql2date(get_option('time_format'), current_time('mysql'));
+ $stamp = __('Publish <b>immediately</b>');
+ $date = date_i18n( $datef, strtotime( current_time('mysql') ) );
}
?>
-<p class="curtime"><?php printf($stamp, $date, $time); ?>
- <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a></p>
+<?php if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
+<div class="misc-pub-section curtime misc-pub-section-last">
+ <span id="timestamp">
+ <?php printf($stamp, $date); ?></span>
+ <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
+ <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div>
+</div><?php // /misc-pub-section ?>
+<?php endif; ?>
-<div id='timestampdiv' class='hide-if-js'><?php touch_time(($action == 'edit'),1,4); ?></div>
+</div>
+<div class="clear"></div>
+</div>
+<div id="major-publishing-actions">
+<?php do_action('post_submitbox_start'); ?>
+<div id="delete-action">
+<?php
+if ( ( 'edit' == $action ) && current_user_can('delete_page', $post->ID) ) { ?>
+<a class="submitdelete deletion" href="<?php echo wp_nonce_url("page.php?action=delete&post=$post->ID", 'delete-page_' . $post->ID); ?>" onclick="if ( confirm('<?php echo js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
+<?php } ?>
</div>
-<p class="submit">
-<input type="submit" name="save" class="button button-highlighted" value="<?php _e('Save'); ?>" tabindex="4" />
+<div id="publishing-action">
<?php
-if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post_ID ) {
-?>
-<?php if ( current_user_can('publish_pages') ) : ?>
- <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
+if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { ?>
+<?php if ( $can_publish ) : ?>
+ <?php if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
+ <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Schedule') ?>" />
+ <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Schedule') ?>" />
+ <?php else : ?>
+ <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Publish') ?>" />
+ <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
+ <?php endif; ?>
<?php else : ?>
- <input name="publish" type="submit" class="button" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
+ <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Submit for Review') ?>" />
+ <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
<?php endif; ?>
+<?php } else { ?>
+ <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Update Page') ?>" />
+ <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Update Page') ?>" />
+<?php } ?>
+</div>
+<div class="clear"></div>
+</div>
+</div>
<?php
}
-
-if ( ('edit' == $action) && current_user_can('delete_page', $post_ID) )
- echo "<a class='submitdelete' href='" . wp_nonce_url("page.php?action=delete&post=$post_ID", 'delete-page_' . $post_ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete page') . "</a>";
+add_meta_box('pagesubmitdiv', __('Publish'), 'page_submit_meta_box', 'page', 'side', 'core');
+
+/**
+ * Display page password form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
+function page_password_meta_box($post){
?>
-<br class="clear" />
-<?php if ($post_ID): ?>
-<?php if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
- $last_user = get_userdata($last_id);
- printf(__('Last edited by %1$s on %2$s at %3$s'), wp_specialchars( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
-} else {
- printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
+<p><label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> tabindex='4' /> <?php _e('Keep this page private') ?></label></p>
+<h4><?php _e( 'Page Password' ); ?></h4>
+<p><label class="hidden" for="post_password"><?php _e('Password Protect This Page') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php the_post_password(); ?>" /></p>
+<p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this page and its comments.'); ?></p>
+<?php
}
+// add_meta_box('pagepassworddiv', __('Privacy Options'), 'page_password_meta_box', 'page', 'side', 'core');
+
+/**
+ * Display page attributes form fields.
+ *
+ * @since 2.7.0
+ *
+ * @param object $post
+ */
+function page_attributes_meta_box($post){
?>
-<br class="clear" />
-<?php endif; ?>
-<span id="autosave"></span>
-<span id="wp-word-count"></span>
-</p>
-
-<div class="side-info">
-<h5><?php _e('Related') ?></h5>
-
-<ul>
-<?php if ($post_ID): ?>
-<li><a href="edit-pages.php?page_id=<?php echo $post_ID ?>"><?php _e('See Comments on this Page') ?></a></li>
-<?php endif; ?>
-<li><a href="edit-comments.php"><?php _e('Manage All Comments') ?></a></li>
-<li><a href="edit-pages.php"><?php _e('Manage All Pages') ?></a></li>
-<?php do_action('page_relatedlinks_list'); ?>
-</ul>
-</div>
-<?php do_action('submitpage_box'); ?>
-</div>
-
-<div id="post-body">
-<div id="titlediv">
-<h3><label for="title"><?php _e('Title') ?></label></h3>
-<div id="titlewrap">
- <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" autocomplete="off" />
-</div>
-<div class="inside">
-<?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>
- <div id="edit-slug-box">
-<?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
- echo $sample_permalink_html;
-endif; ?>
- </div>
-</div>
-</div>
-
-<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
-<h3><label for="content"><?php _e('Page') ?></label></h3>
-<?php the_editor($post->post_content); ?>
-<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
-<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
-<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
-<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
-</div>
-
-<?php do_meta_boxes('page', 'normal', $post); ?>
-
-<?php do_action('edit_page_form'); ?>
-
-<h2><?php _e('Advanced Options'); ?></h2>
-
-
-<?php
+<h5><?php _e('Parent') ?></h5>
+<label class="hidden" for="parent_id"><?php _e('Page Parent') ?></label>
+<?php wp_dropdown_pages(array('exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('Main Page (no parent)'), 'sort_column'=> 'menu_order, post_title')); ?>
+<p><?php _e('You can arrange your pages in hierarchies, for example you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how deeply nested you can make pages.'); ?></p>
+<?php
+ if ( 0 != count( get_page_templates() ) ) {
+?>
+<h5><?php _e('Template') ?></h5>
+<label class="hidden" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
+<option value='default'><?php _e('Default Template'); ?></option>
+<?php page_template_dropdown($post->page_template); ?>
+</select>
+<p><?php _e('Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them above.'); ?></p>
+<?php
+ }
+?>
+<h5><?php _e('Order') ?></h5>
+<p><label class="hidden" for="menu_order"><?php _e('Page Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" /></p>
+<p><?php _e('Pages are usually ordered alphabetically, but you can put a number above to change the order pages appear in. (We know this is a little janky, it’ll be better in future releases.)'); ?></p>
+<?php
+}
+add_meta_box('pageparentdiv', __('Attributes'), 'page_attributes_meta_box', 'page', 'side', 'core');
+
+/**
+ * Display custom field for page form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function page_custom_meta_box($post){
?>
<div id="postcustomstuff">
-<table cellpadding="3">
<?php
$metadata = has_meta($post->ID);
list_meta($metadata);
-?>
-
-</table>
-<?php
- meta_form();
+meta_form();
?>
<div id="ajax-response"></div>
</div>
<p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
<?php
}
-add_meta_box('pagecustomdiv', __('Custom Fields'), 'page_custom_meta_box', 'page', 'advanced', 'core');
-
+add_meta_box('pagecustomdiv', __('Custom Fields'), 'page_custom_meta_box', 'page', 'normal', 'core');
+
+/**
+ * Display comments status form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function page_comments_status_meta_box($post){
?>
<input name="advanced_view" type="hidden" value="1" />
<?php _e('Allow Comments') ?></label></p>
<p><label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label></p>
<p><?php _e('These settings apply to this page only. “Pings” are <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a>.'); ?></p>
-<?php
-}
-add_meta_box('pagecommentstatusdiv', __('Comments & Pings'), 'page_comments_status_meta_box', 'page', 'advanced', 'core');
-
-function page_password_meta_box($post){
-?>
-<p><label class="hidden" for="post_password"><?php _e('Password Protect This Page') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></p>
-<p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this page and its comments.'); ?></p>
<?php
}
-add_meta_box('pagepassworddiv', __('Password Protect This Page'), 'page_password_meta_box', 'page', 'advanced', 'core');
-
+add_meta_box('pagecommentstatusdiv', __('Discussion'), 'page_comments_status_meta_box', 'page', 'normal', 'core');
+
+/**
+ * Display page slug form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function page_slug_meta_box($post){
?>
<label class="hidden" for="post_name"><?php _e('Page Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" />
<?php
}
-add_meta_box('pageslugdiv', __('Page Slug'), 'page_slug_meta_box', 'page', 'advanced', 'core');
-
-function page_parent_meta_box($post){
-?>
-<label class="hidden" for="parent_id"><?php _e('Page Parent') ?></label>
-<select name="parent_id" id="parent_id">
-<option value='0'><?php _e('Main Page (no parent)'); ?></option>
-<?php parent_dropdown($post->post_parent); ?>
-</select>
-<p><?php _e('You can arrange your pages in hierarchies, for example you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how deeply nested you can make pages.'); ?></p>
-<?php
-}
-add_meta_box('pageparentdiv', __('Page Parent'), 'page_parent_meta_box', 'page', 'advanced', 'core');
-
-if ( 0 != count( get_page_templates() ) ) {
- function page_template_meta_box($post){
-?>
-<label class="hidden" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
-<option value='default'><?php _e('Default Template'); ?></option>
-<?php page_template_dropdown($post->page_template); ?>
-</select>
-<p><?php _e('Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them above.'); ?></p>
-<?php
- }
- add_meta_box('pagetemplatediv', __('Page Template'), 'page_template_meta_box', 'page', 'advanced', 'core');
-}
-
-function page_order_meta_box($post){
-?>
-<p><label class="hidden" for="menu_order"><?php _e('Page Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" /></p>
-<p><?php _e('Pages are usually ordered alphabetically, but you can put a number above to change the order pages appear in. (We know this is a little janky, it’ll be better in future releases.)'); ?></p>
-<?php
-}
-add_meta_box('pageorderdiv', __('Page Order'), 'page_order_meta_box', 'page', 'advanced', 'core');
-
+add_meta_box('pageslugdiv', __('Page Slug'), 'page_slug_meta_box', 'page', 'normal', 'core');
-$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
+$authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM
if ( $post->post_author && !in_array($post->post_author, $authors) )
$authors[] = $post->post_author;
if ( $authors && count( $authors ) > 1 ) {
+ /**
+ * Display page author form fields, when more than one author exists.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function page_author_meta_box($post){
global $current_user, $user_ID;
- $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
+ $authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM
if ( $post->post_author && !in_array($post->post_author, $authors) )
$authors[] = $post->post_author;
?>
<label class="hidden" for="post_author_override"><?php _e('Page Author'); ?></label><?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?>
<?php
}
- add_meta_box('pageauthordiv', __('Page Author'), 'page_author_meta_box', 'page', 'advanced', 'core');
+ add_meta_box('pageauthordiv', __('Page Author'), 'page_author_meta_box', 'page', 'normal', 'core');
}
-
-if ( isset($post_ID) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
+if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
+/**
+ * Display list of page revisions.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
function page_revisions_meta_box($post) {
wp_list_post_revisions();
}
-add_meta_box('revisionsdiv', __('Page Revisions'), 'page_revisions_meta_box', 'page', 'advanced', 'core');
+add_meta_box('revisionsdiv', __('Page Revisions'), 'page_revisions_meta_box', 'page', 'normal', 'core');
endif;
-do_meta_boxes('page', 'advanced', $post);
+do_action('do_meta_boxes', 'page', 'normal', $post);
+do_action('do_meta_boxes', 'page', 'advanced', $post);
+do_action('do_meta_boxes', 'page', 'side', $post);
+
+require_once('admin-header.php');
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
+<form name="post" action="page.php" method="post" id="post">
+<?php if ( $notice ) : ?>
+<div id="notice" class="error"><p><?php echo $notice ?></p></div>
+<?php endif; ?>
+<?php if (isset($_GET['message'])) : ?>
+<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<?php endif; ?>
+
+<?php
+wp_nonce_field($nonce_action);
+
+if (isset($mode) && 'bookmarklet' == $mode)
+ echo '<input type="hidden" name="mode" value="bookmarklet" />';
+?>
+<input type="hidden" id="user-id" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' />
+<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
+<input type="hidden" id="post_author" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />
+<?php echo $form_extra ?>
+<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
+<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" />
+<input name="referredby" type="hidden" id="referredby" value="<?php echo clean_url(stripslashes(wp_get_referer())); ?>" />
+<?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?>
+
+<div id="poststuff" class="metabox-holder">
+
+<div id="side-info-column" class="inner-sidebar">
+
+<?php
+
+do_action('submitpage_box');
+$side_meta_boxes = do_meta_boxes('page', 'side', $post);
+
?>
+</div>
+
+<div id="post-body" class="<?php echo $side_meta_boxes ? 'has-sidebar' : ''; ?>">
+<div id="post-body-content" class="has-sidebar-content">
+
+<div id="titlediv">
+<div id="titlewrap">
+ <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" autocomplete="off" />
+</div>
+<div class="inside">
+<?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>
+ <div id="edit-slug-box">
+<?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
+ echo $sample_permalink_html;
+endif; ?>
+ </div>
+</div>
+</div>
+<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
+
+<?php the_editor($post->post_content); ?>
+<div id="post-status-info">
+ <span id="wp-word-count" class="alignleft"></span>
+ <span class="alignright">
+ <span id="autosave"> </span>
+
+<?php
+ if ($post_ID) {
+ if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
+ $last_user = get_userdata($last_id);
+ printf(__('Last edited by %1$s on %2$s at %3$s'), wp_specialchars( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
+ } else {
+ printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
+ }
+ }
+?>
+ </span>
+ <br class="clear" />
</div>
+
+<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
+<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
+<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
+<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
+<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
</div>
+<?php
+
+do_meta_boxes('page', 'normal', $post);
+do_action('edit_page_form');
+do_meta_boxes('page', 'advanced', $post);
+
+?>
+
+</div>
+</div>
</div>
</form>
+</div>
<script type="text/javascript">
try{document.post.title.focus();}catch(e){}
<?php
+/**
+ * Edit Pages Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
-// Handle bulk deletes
-if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
- check_admin_referer('bulk-pages');
- foreach( (array) $_GET['delete'] as $post_id_del ) {
- $post_del = & get_post($post_id_del);
-
- if ( !current_user_can('delete_page', $post_id_del) )
- wp_die( __('You are not allowed to delete this page.') );
-
- if ( $post_del->post_type == 'attachment' ) {
- if ( ! wp_delete_attachment($post_id_del) )
- wp_die( __('Error in deleting...') );
- } else {
- if ( !wp_delete_post($post_id_del) )
- wp_die( __('Error in deleting...') );
- }
+// Handle bulk actions
+if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
+ $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
+
+ switch ( $doaction ) {
+ case 'delete':
+ if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
+ check_admin_referer('bulk-pages');
+ $deleted = 0;
+ foreach( (array) $_GET['post'] as $post_id_del ) {
+ $post_del = & get_post($post_id_del);
+
+ if ( !current_user_can('delete_page', $post_id_del) )
+ wp_die( __('You are not allowed to delete this page.') );
+
+ if ( $post_del->post_type == 'attachment' ) {
+ if ( ! wp_delete_attachment($post_id_del) )
+ wp_die( __('Error in deleting...') );
+ } else {
+ if ( !wp_delete_post($post_id_del) )
+ wp_die( __('Error in deleting...') );
+ }
+ $deleted++;
+ }
+ }
+ break;
+ case 'edit':
+ if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
+ check_admin_referer('bulk-pages');
+
+ if ( -1 == $_GET['_status'] ) {
+ $_GET['post_status'] = null;
+ unset($_GET['_status'], $_GET['post_status']);
+ } else {
+ $_GET['post_status'] = $_GET['_status'];
+ }
+
+ $done = bulk_edit_posts($_GET);
+ }
+ break;
}
$sendback = wp_get_referer();
if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php');
elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
- $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
-
+ if ( isset($done) ) {
+ $done['updated'] = count( $done['updated'] );
+ $done['skipped'] = count( $done['skipped'] );
+ $done['locked'] = count( $done['locked'] );
+ $sendback = add_query_arg( $done, $sendback );
+ }
+ if ( isset($deleted) )
+ $sendback = add_query_arg('deleted', $deleted, $sendback);
wp_redirect($sendback);
exit();
-} elseif ( !empty($_GET['_wp_http_referer']) ) {
- wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
+} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
+ wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
exit;
}
-$title = __('Pages');
-$parent_file = 'edit.php';
-wp_enqueue_script('admin-forms');
+if ( empty($title) )
+ $title = __('Edit Pages');
+$parent_file = 'edit-pages.php';
+wp_enqueue_script('inline-edit-post');
$post_stati = array( // array( adj, noun )
- 'publish' => array(__('Published'), __('Published pages'), __ngettext_noop('Published (%s)', 'Published (%s)')),
- 'future' => array(__('Scheduled'), __('Scheduled pages'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')),
- 'pending' => array(__('Pending Review'), __('Pending pages'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')),
- 'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')),
- 'private' => array(__('Private'), __('Private pages'), __ngettext_noop('Private (%s)', 'Private (%s)'))
+ 'publish' => array(__('Published|page'), __('Published pages'), _n_noop('Published <span class="count">(%s)</span>|page', 'Published <span class="count">(%s)</span>')),
+ 'future' => array(__('Scheduled|page'), __('Scheduled pages'), _n_noop('Scheduled <span class="count">(%s)</span>|page', 'Scheduled <span class="count">(%s)</span>')),
+ 'pending' => array(__('Pending Review|page'), __('Pending pages'), _n_noop('Pending Review <span class="count">(%s)</span>|page', 'Pending Review <span class="count">(%s)</span>')),
+ 'draft' => array(__('Draft|page'), _c('Drafts|manage posts header'), _n_noop('Draft <span class="count">(%s)</span>|page', 'Drafts <span class="count">(%s)</span>')),
+ 'private' => array(__('Private|page'), __('Private pages'), _n_noop('Private <span class="count">(%s)</span>|page', 'Private <span class="count">(%s)</span>'))
);
-$post_status_label = __('Manage Pages');
-$post_status_q = '';
+$query = array('post_type' => 'page', 'orderby' => 'menu_order title', 'what_to_show' => 'posts',
+ 'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc');
+
+$post_status_label = __('Pages');
if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
$post_status_label = $post_stati[$_GET['post_status']][1];
- $post_status_q = '&post_status=' . $_GET['post_status'];
- $post_status_q .= '&perm=readable';
+ $query['post_status'] = $_GET['post_status'];
+ $query['perm'] = 'readable';
}
-$query_str = "post_type=page&orderby=menu_order title&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc";
+$query = apply_filters('manage_pages_query', $query);
+wp($query);
-$query_str = apply_filters('manage_pages_query', $query_str);
-wp($query_str);
-
-if ( is_singular() )
+if ( is_singular() ) {
wp_enqueue_script( 'admin-comments' );
-require_once('admin-header.php');
+ enqueue_comment_hotkeys_js();
+}
+
+require_once('admin-header.php'); ?>
-?>
<div class="wrap">
-<form id="posts-filter" action="" method="get">
-<h2><?php
-// Use $_GET instead of is_ since they can override each other
-$h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : '';
-$h2_author = '';
-if ( isset($_GET['author']) && $_GET['author'] ) {
- $author_user = get_userdata( (int) $_GET['author'] );
- $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title );
+if ( isset($_GET['s']) && $_GET['s'] )
+ printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( get_search_query() ) ); ?>
+</h2>
+
+<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>
+<div id="message" class="updated fade"><p>
+<?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
+ printf( __ngettext( '%s page updated.', '%s pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
+ unset($_GET['updated']);
+}
+
+if ( isset($_GET['skipped']) && (int) $_GET['skipped'] ) {
+ printf( __ngettext( '%s page not updated, invalid parent page specified.', '%s pages not updated, invalid parent page specified.', $_GET['skipped'] ), number_format_i18n( $_GET['skipped'] ) );
+ unset($_GET['skipped']);
+}
+
+if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
+ printf( __ngettext( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['skipped'] ) );
+ unset($_GET['locked']);
+}
+
+if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
+ printf( __ngettext( 'Page deleted.', '%s pages deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
+ unset($_GET['deleted']);
}
-printf( _c( '%1$s%2$s%3$s|You can reorder these: 1: Pages, 2: by {s}, 3: matching {s}' ), $post_status_label, $h2_author, $h2_search );
-?></h2>
+$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
+?>
+</p></div>
+<?php } ?>
+
+<?php if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
+<div id="message" class="updated fade"><p><strong><?php _e('Your page has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View page'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit page'); ?></a></p></div>
+<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
+endif; ?>
+<form id="posts-filter" action="" method="get">
<ul class="subsubsub">
<?php
$avail_post_stati = get_available_post_statuses('page');
-
+if ( empty($locked_post_status) ) :
$status_links = array();
$num_posts = wp_count_posts('page', 'readable');
+$total_posts = array_sum( (array) $num_posts );
$class = empty($_GET['post_status']) ? ' class="current"' : '';
-$status_links[] = "<li><a href=\"edit-pages.php\"$class>".__('All Pages')."</a>";
+$status_links[] = "<li><a href='edit-pages.php'$class>" . sprintf( __ngettext( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts ), number_format_i18n( $total_posts ) ) . '</a>';
foreach ( $post_stati as $status => $label ) {
$class = '';
if ( !in_array($status, $avail_post_stati) )
continue;
- if ( $status == $_GET['post_status'] )
+ if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'] )
$class = ' class="current"';
- $status_links[] = "<li><a href=\"edit-pages.php?post_status=$status\"$class>" .
- sprintf(__ngettext($label[2][0], $label[2][1], $num_posts->$status), number_format_i18n( $num_posts->$status ) ) . '</a>';
+ $status_links[] = "<li><a href='edit-pages.php?post_status=$status'$class>" . sprintf( _nc( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
}
-echo implode(' |</li>', $status_links) . '</li>';
+echo implode( " |</li>\n", $status_links ) . '</li>';
unset($status_links);
+endif;
?>
</ul>
+<p class="search-box">
+ <label class="hidden" for="page-search-input"><?php _e( 'Search Pages' ); ?>:</label>
+ <input type="text" class="search-input" id="page-search-input" name="s" value="<?php _admin_search_query(); ?>" />
+ <input type="submit" value="<?php _e( 'Search Pages' ); ?>" class="button" />
+</p>
+
<?php if ( isset($_GET['post_status'] ) ) : ?>
<input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" />
-<?php
-endif;
-if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
-<div id="message" class="updated fade"><p><strong><?php _e('Your page has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View page'); ?></a> | <a href="page.php?action=edit&post=<?php echo $_GET['posted']; ?>"><?php _e('Edit page'); ?></a></p></div>
-<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
-endif;
-?>
+<?php endif; ?>
-<p id="post-search">
- <label class="hidden" for="post-search-input"><?php _e( 'Search Pages' ); ?>:</label>
- <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
- <input type="submit" value="<?php _e( 'Search Pages' ); ?>" class="button" />
-</p>
+<?php if ($posts) { ?>
<div class="tablenav">
<?php
-$pagenum = absint( $_GET['pagenum'] );
+$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
if ( empty($pagenum) )
$pagenum = 1;
-if( !$per_page || $per_page < 0 )
+if( ! isset( $per_page ) || $per_page < 0 )
$per_page = 20;
-$num_pages = ceil(count($posts) / $per_page);
+$num_pages = ceil($wp_query->post_count / $per_page);
$page_links = paginate_links( array(
'base' => add_query_arg( 'pagenum', '%#%' ),
'format' => '',
+ 'prev_text' => __('«'),
+ 'next_text' => __('»'),
'total' => $num_pages,
'current' => $pagenum
));
-if ( $page_links )
- echo "<div class='tablenav-pages'>$page_links</div>";
-?>
-
-<div class="alignleft">
-<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
+if ( $page_links ) : ?>
+<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
+ number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
+ number_format_i18n( min( $pagenum * $per_page, $wp_query->post_count ) ),
+ number_format_i18n( $wp_query->post_count ),
+ $page_links
+); echo $page_links_text; ?></div>
+<?php endif; ?>
+
+<div class="alignleft actions">
+<select name="action">
+<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="edit"><?php _e('Edit'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-pages'); ?>
</div>
<br class="clear" />
</div>
-<br class="clear" />
+<div class="clear"></div>
-<?php
-
-$all = !( $h2_search || $post_status_q );
-
-if ($posts) {
-?>
-<table class="widefat">
+<table class="widefat page fixed" cellspacing="0">
<thead>
<tr>
-<?php $posts_columns = wp_manage_pages_columns(); ?>
-<?php foreach($posts_columns as $post_column_key => $column_display_name) {
- if ( 'cb' === $post_column_key )
- $class = ' class="check-column"';
- elseif ( 'comments' === $post_column_key )
- $class = ' class="num"';
- else
- $class = '';
-?>
- <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th>
-<?php } ?>
+<?php print_column_headers('edit-pages'); ?>
</tr>
</thead>
+
+ <tfoot>
+ <tr>
+<?php print_column_headers('edit-pages', false); ?>
+ </tr>
+ </tfoot>
+
<tbody>
<?php page_rows($posts, $pagenum, $per_page); ?>
</tbody>
</table>
-</form>
-
-<div id="ajax-response"></div>
-
+<div class="tablenav">
<?php
-} else {
+if ( $page_links )
+ echo "<div class='tablenav-pages'>$page_links_text</div>";
?>
-</form>
+
+<div class="alignleft actions">
+<select name="action2">
+<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="edit"><?php _e('Edit'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
+</div>
+
+<br class="clear" />
+</div>
+
+<?php } else { ?>
+<div class="clear"></div>
<p><?php _e('No pages found.') ?></p>
<?php
} // end if ($posts)
?>
-<div class="tablenav">
-<?php
-if ( $page_links )
- echo "<div class='tablenav-pages'>$page_links</div>";
-?>
-<br class="clear" />
-</div>
+</form>
+
+<?php inline_edit_row( 'page' ) ?>
+
+<div id="ajax-response"></div>
+
<?php
<br class="clear" />
-<table class="widefat" style="margin-top: .5em">
+<table class="widefat" cellspacing="0">
<thead>
<tr>
- <th scope="col"><?php _e('Comment') ?></th>
- <th scope="col"><?php _e('Date') ?></th>
- <th scope="col"><?php _e('Actions') ?></th>
+ <th scope="col" class="column-comment"><?php echo _c('Comment|noun') ?></th>
+ <th scope="col" class="column-author"><?php _e('Author') ?></th>
+ <th scope="col" class="column-date"><?php _e('Submitted') ?></th>
</tr>
</thead>
<tbody id="the-comment-list" class="list:comment">
<?php
foreach ($comments as $comment)
- _wp_comment_row( $comment->comment_ID, 'detail', false, false );
+ _wp_comment_row( $comment->comment_ID, 'single', false, false );
?>
</tbody>
</table>
<?php
-
+wp_comment_reply();
endif; // comments
endif; // posts;
</div>
+<script type="text/javascript">
+/* <![CDATA[ */
+(function($){
+ $(document).ready(function(){
+ $('#doaction, #doaction2').click(function(){
+ if ( $('select[name^="action"]').val() == 'delete' ) {
+ var m = '<?php echo js_escape(__("You are about to delete the selected pages.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
+ return showNotice.warn(m);
+ }
+ });
+ });
+})(jQuery);
+columns.init('edit-pages');
+/* ]]> */
+</script>
+
<?php include('admin-footer.php'); ?>
-<?php if ( ! defined('ABSPATH') ) die(); ?>
-<table class="widefat">
+<?php
+/**
+ * Edit posts rows table for inclusion in administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+if ( ! defined('ABSPATH') ) die();
+?>
+<table class="widefat post fixed" cellspacing="0">
<thead>
<tr>
-
-<?php $posts_columns = wp_manage_posts_columns(); ?>
-<?php foreach($posts_columns as $post_column_key => $column_display_name) {
- if ( 'cb' === $post_column_key )
- $class = ' class="check-column"';
- elseif ( 'comments' === $post_column_key )
- $class = ' class="num"';
- else
- $class = '';
-?>
- <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th>
-<?php } ?>
-
+<?php print_column_headers('edit'); ?>
</tr>
</thead>
- <tbody>
-<?php
-if ( have_posts() ) {
-$bgcolor = '';
-add_filter('the_title','wp_specialchars');
-
-// Create array of post IDs.
-$post_ids = array();
-foreach ( $wp_query->posts as $a_post )
- $post_ids[] = $a_post->ID;
-
-$comment_pending_count = get_pending_comments_num($post_ids);
-
-while (have_posts()) : the_post();
-$class = 'alternate' == $class ? '' : 'alternate';
-global $current_user;
-$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
-$title = get_the_title();
-if ( empty($title) )
- $title = __('(no title)');
-?>
- <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
-
-<?php
-
-foreach($posts_columns as $column_name=>$column_display_name) {
-
- switch($column_name) {
-
- case 'cb':
- ?>
- <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="delete[]" value="<?php the_ID(); ?>" /><?php } ?></th>
- <?php
- break;
- case 'modified':
- case 'date':
- if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
- $t_time = $h_time = __('Unpublished');
- } else {
- if ( 'modified' == $column_name ) {
- $t_time = get_the_modified_time(__('Y/m/d g:i:s A'));
- $m_time = $post->post_modified;
- $time = get_post_modified_time('G', true);
- } else {
- $t_time = get_the_time(__('Y/m/d g:i:s A'));
- $m_time = $post->post_date;
- $time = get_post_time('G', true);
- }
- if ( ( abs(time() - $time) ) < 86400 ) {
- if ( ( 'future' == $post->post_status) )
- $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
- else
- $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
- } else {
- $h_time = mysql2date(__('Y/m/d'), $m_time);
- }
- }
- ?>
- <td><abbr title="<?php echo $t_time ?>"><?php echo apply_filters('post_date_column_time', $h_time, $post, $column_name) ?></abbr></td>
- <?php
- break;
- case 'title':
- ?>
- <td><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="post.php?action=edit&post=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; } ?></strong>
- <?php if ( !empty($post->post_password) ) { _e(' — <strong>Protected</strong>'); } elseif ('private' == $post->post_status) { _e(' — <strong>Private</strong>'); } ?></td>
- <?php
- break;
- case 'categories':
- ?>
- <td><?php
- $categories = get_the_category();
- if ( !empty( $categories ) ) {
- $out = array();
- foreach ( $categories as $c )
- $out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
- echo join( ', ', $out );
- } else {
- _e('Uncategorized');
- }
- ?></td>
- <?php
- break;
-
- case 'tags':
- ?>
- <td><?php
- $tags = get_the_tags();
- if ( !empty( $tags ) ) {
- $out = array();
- foreach ( $tags as $c )
- $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
- echo join( ', ', $out );
- } else {
- _e('No Tags');
- }
- ?></td>
- <?php
- break;
-
- case 'comments':
- ?>
- <td class="num"><div class="post-com-count-wrapper">
- <?php
- $left = isset($comment_pending_count) ? $comment_pending_count[$post->ID] : 0;
- $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
- if ( $left )
- echo '<strong>';
- comments_number("<a href='edit.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
- if ( $left )
- echo '</strong>';
- ?>
- </div></td>
- <?php
- break;
-
- case 'author':
- ?>
- <td><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
- <?php
- break;
-
- case 'status':
- ?>
- <td>
- <a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink">
- <?php
- switch ( $post->post_status ) {
- case 'publish' :
- case 'private' :
- _e('Published');
- break;
- case 'future' :
- _e('Scheduled');
- break;
- case 'pending' :
- _e('Pending Review');
- break;
- case 'draft' :
- _e('Unpublished');
- break;
- }
- ?>
- </a>
- </td>
- <?php
- break;
-
- case 'control_view':
- ?>
- <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
- <?php
- break;
-
- case 'control_edit':
- ?>
- <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
- <?php
- break;
-
- case 'control_delete':
- ?>
- <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
- <?php
- break;
-
- default:
- ?>
- <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
- <?php
- break;
- }
-}
-?>
+ <tfoot>
+ <tr>
+<?php print_column_headers('edit', false); ?>
</tr>
-<?php
-endwhile;
-} else {
-?>
- <tr style='background-color: <?php echo $bgcolor; ?>'>
- <td colspan="8"><?php _e('No posts found.') ?></td>
- </tr>
-<?php
-} // end if ( have_posts() )
-?>
+ </tfoot>
+
+ <tbody>
+<?php post_rows(); ?>
</tbody>
-</table>
+</table>
\ No newline at end of file
<?php
-if ( ! empty($tag_ID) ) {
- $heading = __('Edit Tag');
- $submit_text = __('Edit Tag');
- $form = '<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate">';
- $action = 'editedtag';
- $nonce_action = 'update-tag_' . $tag_ID;
- do_action('edit_tag_form_pre', $tag);
-} else {
- $heading = __('Add Tag');
- $submit_text = __('Add Tag');
- $form = '<form name="addtag" id="addtag" method="post" action="edit-tags.php" class="add:the-list: validate">';
- $action = 'addtag';
- $nonce_action = 'add-tag';
- do_action('add_tag_form_pre', $tag);
+/**
+ * Edit tag form for inclusion in administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+if ( empty($tag_ID) ) { ?>
+ <div id="message" class="updated fade"><p><strong><?php _e('A tag was not selected for editing.'); ?></strong></p></div>
+<?php
+ return;
}
-?>
+
+do_action('edit_tag_form_pre', $tag); ?>
<div class="wrap">
-<h2><?php echo $heading ?></h2>
+<?php screen_icon(); ?>
+<h2><?php _e('Edit Tag'); ?></h2>
<div id="ajax-response"></div>
-<?php echo $form ?>
-<input type="hidden" name="action" value="<?php echo $action ?>" />
+<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate">
+<input type="hidden" name="action" value="editedtag" />
<input type="hidden" name="tag_ID" value="<?php echo $tag->term_id ?>" />
-<?php wp_original_referer_field(true, 'previous'); wp_nonce_field($nonce_action); ?>
+<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-tag_' . $tag_ID); ?>
<table class="form-table">
<tr class="form-field form-required">
<th scope="row" valign="top"><label for="name"><?php _e('Tag name') ?></label></th>
- <td><input name="name" id="name" type="text" value="<?php echo attribute_escape($tag->name); ?>" size="40" aria-required="true" />
+ <td><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo attribute_escape($tag->name); ?>" size="40" aria-required="true" />
<p><?php _e('The name is how the tag appears on your site.'); ?></p></td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="slug"><?php _e('Tag slug') ?></label></th>
- <td><input name="slug" id="slug" type="text" value="<?php echo attribute_escape(apply_filters('editable_slug', $tag->slug)); ?>" size="40" />
+ <td><input name="slug" id="slug" type="text" value="<?php if ( isset( $tag->slug ) ) echo attribute_escape(apply_filters('editable_slug', $tag->slug)); ?>" size="40" />
<p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td>
</tr>
</table>
-<p class="submit"><input type="submit" class="button" name="submit" value="<?php echo $submit_text ?>" /></p>
+<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php _e('Update Tag'); ?>" /></p>
<?php do_action('edit_tag_form', $tag); ?>
</form>
</div>
<?php
+/**
+ * Edit Tags Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
$title = __('Tags');
-$parent_file = 'edit.php';
-wp_reset_vars(array('action', 'tag'));
+wp_reset_vars( array('action', 'tag') );
-if ( isset($_GET['deleteit']) && isset($_GET['delete_tags']) )
+if ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) )
$action = 'bulk-delete';
switch($action) {
break;
case 'edit':
+ $title = __('Edit Tag');
require_once ('admin-header.php');
$tag_ID = (int) $_GET['tag_ID'];
default:
-if ( !empty($_GET['_wp_http_referer']) ) {
- wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
+if ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
+ wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
exit;
}
-wp_enqueue_script( 'admin-tags' );
-wp_enqueue_script('admin-forms');
+$can_manage = current_user_can('manage_categories');
+
+wp_enqueue_script('admin-tags');
+if ( $can_manage )
+ wp_enqueue_script('inline-edit-tax');
require_once ('admin-header.php');
$messages[3] = __('Tag updated.');
$messages[4] = __('Tag not added.');
$messages[5] = __('Tag not updated.');
-$messages[6] = __('Tags deleted.');
-?>
+$messages[6] = __('Tags deleted.'); ?>
+
+<div class="wrap nosubsub">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title );
+if ( isset($_GET['s']) && $_GET['s'] )
+ printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
+</h2>
-<?php if (isset($_GET['message'])) : ?>
-<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<?php if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
+<div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
endif; ?>
-<div class="wrap">
-
-<form id="posts-filter" action="" method="get">
-<?php if ( current_user_can('manage_categories') ) : ?>
- <h2><?php printf(__('Manage Tags (<a href="%s">add new</a>)'), '#addtag') ?> </h2>
-<?php else : ?>
- <h2><?php _e('Manage Tags') ?> </h2>
-<?php endif; ?>
-
-<p id="post-search">
- <label class="hidden" for="post-search-input"><?php _e( 'Search Tags' ); ?>:</label>
- <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
+<form class="search-form" action="" method="get">
+<p class="search-box">
+ <label class="hidden" for="tag-search-input"><?php _e( 'Search Tags' ); ?>:</label>
+ <input type="text" class="search-input" id="tag-search-input" name="s" value="<?php _admin_search_query(); ?>" />
<input type="submit" value="<?php _e( 'Search Tags' ); ?>" class="button" />
</p>
-
+</form>
<br class="clear" />
-<div class="tablenav">
+<div id="col-container">
+<div id="col-right">
+<div class="col-wrap">
+<form id="posts-filter" action="" method="get">
+<div class="tablenav">
<?php
-$pagenum = absint( $_GET['pagenum'] );
+$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
if ( empty($pagenum) )
$pagenum = 1;
-if( !$tagsperpage || $tagsperpage < 0 )
- $tagsperpage = 20;
+
+$tagsperpage = apply_filters("tagsperpage",20);
$page_links = paginate_links( array(
'base' => add_query_arg( 'pagenum', '%#%' ),
'format' => '',
+ 'prev_text' => __('«'),
+ 'next_text' => __('»'),
'total' => ceil(wp_count_terms('post_tag') / $tagsperpage),
'current' => $pagenum
));
echo "<div class='tablenav-pages'>$page_links</div>";
?>
-<div class="alignleft">
-<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
+<div class="alignleft actions">
+<select name="action">
+<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-tags'); ?>
</div>
<br class="clear" />
</div>
-<br class="clear" />
+<div class="clear"></div>
-<table class="widefat">
+<table class="widefat tag fixed" cellspacing="0">
<thead>
<tr>
- <th scope="col" class="check-column"><input type="checkbox" /></th>
- <th scope="col"><?php _e('Name') ?></th>
- <th scope="col" class="num" style="width: 90px"><?php _e('Posts') ?></th>
+<?php print_column_headers('edit-tags'); ?>
</tr>
</thead>
+
+ <tfoot>
+ <tr>
+<?php print_column_headers('edit-tags', false); ?>
+ </tr>
+ </tfoot>
+
<tbody id="the-list" class="list:tag">
<?php
-$searchterms = trim( $_GET['s'] );
+$searchterms = isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '';
$count = tag_rows( $pagenum, $tagsperpage, $searchterms );
?>
</tbody>
</table>
-</form>
<div class="tablenav">
-
<?php
if ( $page_links )
echo "<div class='tablenav-pages'>$page_links</div>";
?>
+
+<div class="alignleft actions">
+<select name="action2">
+<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
+</div>
+
<br class="clear" />
</div>
+
<br class="clear" />
+</form>
+</div>
+</div><!-- /col-right -->
+
+<div id="col-left">
+<div class="col-wrap">
+<div class="tagcloud">
+<h3><?php _e('Popular Tags'); ?></h3>
+<?php
+if ( $can_manage )
+ wp_tag_cloud(array('link' => 'edit'));
+else
+ wp_tag_cloud();
+?>
+</div>
+
+<?php if ( $can_manage ) {
+ do_action('add_tag_form_pre'); ?>
+
+<div class="form-wrap">
+<h3><?php _e('Add a New Tag'); ?></h3>
+<div id="ajax-response"></div>
+<form name="addtag" id="addtag" method="post" action="edit-tags.php" class="add:the-list: validate">
+<input type="hidden" name="action" value="addtag" />
+<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-tag'); ?>
+
+<div class="form-field form-required">
+ <label for="name"><?php _e('Tag name') ?></label>
+ <input name="name" id="name" type="text" value="" size="40" aria-required="true" />
+ <p><?php _e('The name is how the tag appears on your site.'); ?></p>
</div>
-<?php if ( current_user_can('manage_categories') ) : ?>
+<div class="form-field">
+ <label for="slug"><?php _e('Tag slug') ?></label>
+ <input name="slug" id="slug" type="text" value="" size="40" />
+ <p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
+</div>
-<br />
-<?php include('edit-tag-form.php'); ?>
+<p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Tag'); ?>" /></p>
+<?php do_action('add_tag_form'); ?>
+</form></div>
+<?php } ?>
-<?php endif; ?>
+</div>
+</div><!-- /col-left -->
+
+</div><!-- /col-container -->
+</div><!-- /wrap -->
+
+<script type="text/javascript">
+/* <![CDATA[ */
+(function($){
+ $(document).ready(function(){
+ $('#doaction, #doaction2').click(function(){
+ if ( $('select[name^="action"]').val() == 'delete' ) {
+ var m = '<?php echo js_escape(__("You are about to delete the selected tags.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
+ return showNotice.warn(m);
+ }
+ });
+ });
+})(jQuery);
+/* ]]> */
+</script>
+
+<?php inline_edit_term_row('edit-tags'); ?>
<?php
break;
<?php
+/**
+ * Edit Posts Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
-// Handle bulk deletes
-if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
- check_admin_referer('bulk-posts');
- foreach( (array) $_GET['delete'] as $post_id_del ) {
- $post_del = & get_post($post_id_del);
-
- if ( !current_user_can('delete_post', $post_id_del) )
- wp_die( __('You are not allowed to delete this post.') );
-
- if ( $post_del->post_type == 'attachment' ) {
- if ( ! wp_delete_attachment($post_id_del) )
- wp_die( __('Error in deleting...') );
- } else {
- if ( !wp_delete_post($post_id_del) )
- wp_die( __('Error in deleting...') );
- }
+// Back-compat for viewing comments of an entry
+if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['page_id'] ) ) ) {
+ wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) );
+ exit;
+} else {
+ unset( $_redirect );
+}
+
+// Handle bulk actions
+if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
+ $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
+
+ switch ( $doaction ) {
+ case 'delete':
+ if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
+ check_admin_referer('bulk-posts');
+ $deleted = 0;
+ foreach( (array) $_GET['post'] as $post_id_del ) {
+ $post_del = & get_post($post_id_del);
+
+ if ( !current_user_can('delete_post', $post_id_del) )
+ wp_die( __('You are not allowed to delete this post.') );
+
+ if ( $post_del->post_type == 'attachment' ) {
+ if ( ! wp_delete_attachment($post_id_del) )
+ wp_die( __('Error in deleting...') );
+ } else {
+ if ( !wp_delete_post($post_id_del) )
+ wp_die( __('Error in deleting...') );
+ }
+ $deleted++;
+ }
+ }
+ break;
+ case 'edit':
+ if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
+ check_admin_referer('bulk-posts');
+
+ if ( -1 == $_GET['_status'] ) {
+ $_GET['post_status'] = null;
+ unset($_GET['_status'], $_GET['post_status']);
+ } else {
+ $_GET['post_status'] = $_GET['_status'];
+ }
+
+ $done = bulk_edit_posts($_GET);
+ }
+ break;
}
$sendback = wp_get_referer();
- if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('post-new.php');
- elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
- $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
-
+ if ( strpos($sendback, 'post.php') !== false ) $sendback = admin_url('post-new.php');
+ elseif ( strpos($sendback, 'attachments.php') !== false ) $sendback = admin_url('attachments.php');
+ if ( isset($done) ) {
+ $done['updated'] = count( $done['updated'] );
+ $done['skipped'] = count( $done['skipped'] );
+ $done['locked'] = count( $done['locked'] );
+ $sendback = add_query_arg( $done, $sendback );
+ }
+ if ( isset($deleted) )
+ $sendback = add_query_arg('deleted', $deleted, $sendback);
wp_redirect($sendback);
exit();
-} elseif ( !empty($_GET['_wp_http_referer']) ) {
- wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
+} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
+ wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
exit;
}
-$title = __('Posts');
+if ( empty($title) )
+ $title = __('Edit Posts');
$parent_file = 'edit.php';
-wp_enqueue_script('admin-forms');
+wp_enqueue_script('inline-edit-post');
list($post_stati, $avail_post_stati) = wp_edit_posts_query();
-if ( 1 == count($posts) && is_singular() )
- wp_enqueue_script( 'admin-comments' );
require_once('admin-header.php');
if ( !isset( $_GET['paged'] ) )
$_GET['paged'] = 1;
-?>
+if ( empty($_GET['mode']) )
+ $mode = 'list';
+else
+ $mode = attribute_escape($_GET['mode']); ?>
<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title );
+if ( isset($_GET['s']) && $_GET['s'] )
+ printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( get_search_query() ) ); ?>
+</h2>
-<form id="posts-filter" action="" method="get">
-<h2><?php
-if ( is_single() ) {
- printf(__('Comments on %s'), apply_filters( "the_title", $post->post_title));
-} else {
- $post_status_label = _c('Manage Posts|manage posts header');
- if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) )
- $post_status_label = $post_stati[$_GET['post_status']][1];
- if ( $post_listing_pageable && !is_archive() && !is_search() )
- $h2_noun = is_paged() ? sprintf(__( 'Previous %s' ), $post_status_label) : sprintf(__('Latest %s'), $post_status_label);
- else
- $h2_noun = $post_status_label;
- // Use $_GET instead of is_ since they can override each other
- $h2_author = '';
- $_GET['author'] = (int) $_GET['author'];
- if ( $_GET['author'] != 0 ) {
- if ( $_GET['author'] == '-' . $user_ID ) { // author exclusion
- $h2_author = ' ' . __('by other authors');
- } else {
- $author_user = get_userdata( get_query_var( 'author' ) );
- $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
- }
- }
- $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( get_search_query() ) ) : '';
- $h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in “%s”'), single_cat_title('', false) ) : '';
- $h2_tag = isset($_GET['tag']) && $_GET['tag'] ? ' ' . sprintf( __('tagged with “%s”'), single_tag_title('', false) ) : '';
- $h2_month = isset($_GET['m']) && $_GET['m'] ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : '';
- printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: tagged with {s}, 6: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_tag, $h2_month );
+<?php
+if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
+<div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div>
+<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
+endif; ?>
+
+<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>
+<div id="message" class="updated fade"><p>
+<?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
+ printf( __ngettext( '%s post updated.', '%s posts updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
+ unset($_GET['updated']);
+}
+
+if ( isset($_GET['skipped']) && (int) $_GET['skipped'] )
+ unset($_GET['skipped']);
+
+if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
+ printf( __ngettext( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) );
+ unset($_GET['locked']);
+}
+
+if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
+ printf( __ngettext( 'Post deleted.', '%s posts deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
+ unset($_GET['deleted']);
}
-?></h2>
+
+$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
+?>
+</p></div>
+<?php } ?>
+
+<form id="posts-filter" action="" method="get">
<ul class="subsubsub">
<?php
+if ( empty($locked_post_status) ) :
$status_links = array();
$num_posts = wp_count_posts( 'post', 'readable' );
+$total_posts = array_sum( (array) $num_posts );
$class = empty( $_GET['post_status'] ) ? ' class="current"' : '';
-$status_links[] = "<li><a href='edit.php' $class>" . __('All Posts') . '</a>';
+$status_links[] = "<li><a href='edit.php' $class>" . sprintf( __ngettext( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts ), number_format_i18n( $total_posts ) ) . '</a>';
+
+
foreach ( $post_stati as $status => $label ) {
$class = '';
if ( empty( $num_posts->$status ) )
continue;
- if ( $status == $_GET['post_status'] )
+ if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )
$class = ' class="current"';
- $status_links[] = "<li><a href='edit.php?post_status=$status' $class>" .
- sprintf( __ngettext( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
+ $status_links[] = "<li><a href='edit.php?post_status=$status' $class>" . sprintf( __ngettext( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
}
-echo implode( ' |</li>', $status_links ) . '</li>';
+echo implode( " |</li>\n", $status_links ) . '</li>';
unset( $status_links );
-?>
-</ul>
-
-<?php if ( isset($_GET['post_status'] ) ) : ?>
-<input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" />
-<?php
-endif;
-
-if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
-<div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&post=<?php echo $_GET['posted']; ?>"><?php _e('Edit post'); ?></a></p></div>
-<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
endif;
?>
+</ul>
-<p id="post-search">
+<p class="search-box">
<label class="hidden" for="post-search-input"><?php _e( 'Search Posts' ); ?>:</label>
- <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
+ <input type="text" class="search-input" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
<input type="submit" value="<?php _e( 'Search Posts' ); ?>" class="button" />
</p>
-<div class="tablenav">
+<?php if ( isset($_GET['post_status'] ) ) : ?>
+<input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" />
+<?php endif; ?>
+<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
+<?php if ( have_posts() ) { ?>
+
+<div class="tablenav">
<?php
$page_links = paginate_links( array(
'base' => add_query_arg( 'paged', '%#%' ),
'format' => '',
+ 'prev_text' => __('«'),
+ 'next_text' => __('»'),
'total' => $wp_query->max_num_pages,
'current' => $_GET['paged']
));
-if ( $page_links )
- echo "<div class='tablenav-pages'>$page_links</div>";
?>
-<div class="alignleft">
-<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
+<div class="alignleft actions">
+<select name="action">
+<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="edit"><?php _e('Edit'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-posts'); ?>
-<?php
+
+<?php // view filters
if ( !is_singular() ) {
$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC";
$month_count = count($arc_result);
-if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?>
+if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
+$m = isset($_GET['m']) ? (int)$_GET['m'] : 0;
+?>
<select name='m'>
-<option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
+<option<?php selected( $m, 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
<?php
foreach ($arc_result as $arc_row) {
if ( $arc_row->yyear == 0 )
continue;
$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
- if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] )
+ if ( $arc_row->yyear . $arc_row->mmonth == $m )
$default = ' selected="selected"';
else
$default = '';
<?php } ?>
</div>
-<br class="clear" />
-</div>
+<?php if ( $page_links ) { ?>
+<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
+ number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ),
+ number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ),
+ number_format_i18n( $wp_query->found_posts ),
+ $page_links
+); echo $page_links_text; ?></div>
+<?php } ?>
-<br class="clear" />
+<div class="view-switch">
+ <a href="<?php echo clean_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('List View') ?>" alt="<?php _e('List View') ?>" /></a>
+ <a href="<?php echo clean_url(add_query_arg('mode', 'excerpt', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('Excerpt View') ?>" alt="<?php _e('Excerpt View') ?>" /></a>
+</div>
-<?php include( 'edit-post-rows.php' ); ?>
+<div class="clear"></div>
+</div>
-</form>
+<div class="clear"></div>
-<div id="ajax-response"></div>
+<?php include( 'edit-post-rows.php' ); ?>
<div class="tablenav">
<?php
if ( $page_links )
- echo "<div class='tablenav-pages'>$page_links</div>";
+ echo "<div class='tablenav-pages'>$page_links_text</div>";
?>
+<div class="alignleft actions">
+<select name="action2">
+<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="edit"><?php _e('Edit'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
<br class="clear" />
</div>
-
<br class="clear" />
+</div>
-<?php
-
-if ( 1 == count($posts) && is_singular() ) :
-
- $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) );
- if ( $comments ) :
- // Make sure comments, post, and post_author are cached
- update_comment_cache($comments);
- $post = get_post($id);
- $authordata = get_userdata($post->post_author);
- ?>
-
-<br class="clear" />
+<?php } else { // have_posts() ?>
+<div class="clear"></div>
+<p><?php _e('No posts found') ?></p>
+<?php } ?>
-<table class="widefat" style="margin-top: .5em">
-<thead>
- <tr>
- <th scope="col"><?php _e('Comment') ?></th>
- <th scope="col"><?php _e('Date') ?></th>
- <th scope="col"><?php _e('Actions') ?></th>
- </tr>
-</thead>
-<tbody id="the-comment-list" class="list:comment">
-<?php
- foreach ($comments as $comment)
- _wp_comment_row( $comment->comment_ID, 'detail', false, false );
-?>
-</tbody>
-</table>
+</form>
-<?php
+<?php inline_edit_row( 'post' ); ?>
-endif; // comments
-endif; // posts;
+<div id="ajax-response"></div>
-?>
+<br class="clear" />
</div>
+<script type="text/javascript">
+/* <![CDATA[ */
+(function($){
+ $(document).ready(function(){
+ $('#doaction, #doaction2').click(function(){
+ if ( $('select[name^="action"]').val() == 'delete' ) {
+ var m = '<?php echo js_escape(__("You are about to delete the selected posts.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
+ return showNotice.warn(m);
+ }
+ });
+ });
+})(jQuery);
+columns.init('edit');
+/* ]]> */
+</script>
+
<?php include('admin-footer.php'); ?>
<?php
+/**
+ * WordPress Export Administration Panel
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
require_once ('admin.php');
+
+/** Load WordPress export API */
require_once('includes/export.php');
$title = __('Export');
-$parent_file = 'edit.php';
if ( isset( $_GET['download'] ) ) {
- export_wp( $_GET['author'] );
+ $author = isset($_GET['author']) ? $_GET['author'] : 'all';
+ export_wp( $author );
die();
}
?>
<div class="wrap">
-<h2><?php _e('Export'); ?></h2>
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
<p><?php _e('When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p>
<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.'); ?></p>
<p><?php _e('Once you’ve saved the download file, you can use the Import function on another WordPress blog to import this blog.'); ?></p>
</td>
</tr>
</table>
-<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?>" />
+<p class="submit"><input type="submit" name="submit" class="button" value="<?php _e('Download Export File'); ?>" />
<input type="hidden" name="download" value="true" />
</p>
</form>
<?php
+/**
+ * Defines the Gears manifest file for Google Gears offline storage.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+/** Set ABSPATH for execution */
define( 'ABSPATH', dirname(dirname(__FILE__)) );
define( 'WPINC', '/wp-includes' );
+/**
+ * @ignore
+ */
function __() {}
+
+/**
+ * @ignore
+ */
+function _c() {}
+
+/**
+ * @ignore
+ */
function add_filter() {}
+
+/**
+ * @ignore
+ */
function attribute_escape() {}
+
+/**
+ * @ignore
+ */
function apply_filters() {}
+
+/**
+ * @ignore
+ */
function get_option() {}
+
+/**
+ * @ignore
+ */
function is_lighttpd_before_150() {}
+
+/**
+ * @ignore
+ */
function add_action() {}
+
+/**
+ * @ignore
+ */
function do_action_ref_array() {}
+
+/**
+ * @ignore
+ */
function get_bloginfo() {}
+
+/**
+ * @ignore
+ */
function is_admin() {return true;}
+
+/**
+ * @ignore
+ */
function site_url() {}
+
+/**
+ * @ignore
+ */
function admin_url() {}
+
+/**
+ * @ignore
+ */
function wp_guess_url() {}
require(ABSPATH . '/wp-includes/script-loader.php');
$defaults = $man_version = '';
foreach ( $wp_scripts->registered as $script ) {
- if ( empty($script->src) || strpos($script->src, 'tiny_mce_config.php') ) continue;
+ if ( empty($script->src) ) continue;
$ver = empty($script->ver) ? $wp_version : $script->ver;
+ if ( 'editor' == $script->handle ) $mce_ver = $script->ver;
$src = str_replace( array( '/wp-admin/', '/wp-includes/' ), array( '', '../wp-includes/' ), $script->src );
$defaults .= '{ "url" : "' . $src . '?ver=' . $ver . '" },' . "\n";
$man_version .= $ver;
if ( isset($style->extra['rtl']) && $style->extra['rtl'] ) {
if ( is_bool( $style->extra['rtl'] ) )
$rtl_href = str_replace( '.css', '-rtl.css', $src );
- else
+ else
$rtl_href = str_replace( array( '/wp-admin/', '/wp-includes/' ), array( '', '../wp-includes/' ), $style->extra['rtl'] );
$defaults .= '{ "url" : "' . $rtl_href . '?ver=' . $ver . '" },' . "\n";
?>
{
"betaManifestVersion" : 1,
-"version" : "<?php echo $man_version; ?>_20080810",
+"version" : "<?php echo $man_version; ?>_20081201",
"entries" : [
<?php echo $defaults; ?>
{ "url" : "images/align-left.png" },
{ "url" : "images/align-none.png" },
{ "url" : "images/align-right.png" },
+{ "url" : "images/archive-link.png" },
+{ "url" : "images/blue-grad.png" },
{ "url" : "images/browse-happy.gif" },
{ "url" : "images/bubble_bg.gif" },
+{ "url" : "images/bubble_bg-rtl.gif" },
+{ "url" : "images/button-grad.png" },
+{ "url" : "images/button-grad-active.png" },
{ "url" : "images/comment-grey-bubble.png" },
-{ "url" : "images/comment-pill.gif" },
-{ "url" : "images/comment-stalk-classic.gif" },
-{ "url" : "images/comment-stalk-fresh.gif" },
-{ "url" : "images/comment-stalk-rtl.gif" },
{ "url" : "images/date-button.gif" },
+{ "url" : "images/ed-bg.gif" },
{ "url" : "images/fade-butt.png" },
-{ "url" : "images/gear.png" },
+{ "url" : "images/fav.png" },
+{ "url" : "images/fav-arrow.gif" },
+{ "url" : "images/fav-arrow-rtl.gif" },
+{ "url" : "images/fav-top.png" },
+{ "url" : "images/generic.png" },
+{ "url" : "images/gray-grad.png" },
+{ "url" : "images/icons32.png" },
+{ "url" : "images/icons32-vs.png" },
+{ "url" : "images/list.png" },
+{ "url" : "images/list-vs.png" },
+{ "url" : "images/loading.gif" },
+{ "url" : "images/loading-publish.gif" },
+{ "url" : "images/logo.gif" },
{ "url" : "images/logo-ghost.png" },
{ "url" : "images/logo-login.gif" },
-{ "url" : "images/logo.gif" },
-{ "url" : "images/media-button-gallery.gif" },
{ "url" : "images/media-button-image.gif" },
{ "url" : "images/media-button-music.gif" },
{ "url" : "images/media-button-other.gif" },
{ "url" : "images/media-button-video.gif" },
-{ "url" : "images/media-buttons.gif" },
-{ "url" : "images/tab.png" },
-{ "url" : "images/tail.gif" },
-{ "url" : "images/toggle-arrow-rtl.gif" },
+{ "url" : "images/menu.png" },
+{ "url" : "images/menu-vs.png" },
+{ "url" : "images/menu-arrows.gif" },
+{ "url" : "images/menu-bits.gif" },
+{ "url" : "images/menu-bits-rtl.gif" },
+{ "url" : "images/menu-dark.gif" },
+{ "url" : "images/menu-dark-rtl.gif" },
+{ "url" : "images/no.png" },
+{ "url" : "images/required.gif" },
+{ "url" : "images/resize.gif" },
+{ "url" : "images/screen-options-left.gif" },
+{ "url" : "images/screen-options-right.gif" },
+{ "url" : "images/screen-options-right-up.gif" },
+{ "url" : "images/se.png" },
+{ "url" : "images/star.gif" },
{ "url" : "images/toggle-arrow.gif" },
+{ "url" : "images/toggle-arrow-rtl.gif" },
+{ "url" : "images/white-grad.png" },
+{ "url" : "images/white-grad-active.png" },
{ "url" : "images/wordpress-logo.png" },
+{ "url" : "images/wp-logo.gif" },
{ "url" : "images/xit.gif" },
-{ "url" : "images/loading-publish.gif" },
-{ "url" : "images/loading.gif" },
-{ "url" : "images/required.gif" },
-{ "url" : "images/no.png" },
{ "url" : "images/yes.png" },
-<?php if ( is_file(ABSPATH.'/wp-includes/js/tinymce/tiny_mce.js') ) { ?>
-{ "url" : "../wp-includes/js/tinymce/tiny_mce_popup.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/utils/mctabs.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/utils/validate.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/utils/form_utils.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/utils/editable_selects.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/paste/js/pasteword.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/paste/js/pastetext.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/media/js/media.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/color_picker.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/charmap.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/image.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/link.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/source_editor.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/anchor.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js?ver=311g" },
-{ "url" : "../wp-includes/js/tinymce/tiny_mce.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/editor_template.js?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js?ver=311" },
-
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/source_editor.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/anchor.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/image.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/link.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/color_picker.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/charmap.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/media/media.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/paste/pasteword.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/paste/blank.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/paste/pastetext.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/template.htm?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html?ver=311g" },
-{ "url" : "../wp-includes/js/tinymce/wp-mce-help.php?ver=311" },
-
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/spellchecker/css/content.css?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/css/content.css?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/media/css/content.css?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/media/css/media.css?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/pasteword.css?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/blank.css?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css?ver=311g" },
-{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css?ver=311" },
-{ "url" : "../wp-includes/js/tinymce/wordpress.css?ver=311" },
+<?php if ( is_file('../wp-includes/js/tinymce/tiny_mce.js') ) { ?>
+{ "url" : "../wp-includes/js/tinymce/tiny_mce.js", "src" : "../wp-includes/js/tinymce/tiny_mce.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/langs/wp-langs-en.js", "src" : "../wp-includes/js/tinymce/langs/wp-langs-en.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/wordpress.css", "src" : "../wp-includes/js/tinymce/wordpress.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/utils/mctabs.js", "src" : "../wp-includes/js/tinymce/utils/mctabs.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/utils/validate.js", "src" : "../wp-includes/js/tinymce/utils/validate.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/utils/form_utils.js", "src" : "../wp-includes/js/tinymce/utils/form_utils.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/utils/editable_selects.js", "src" : "../wp-includes/js/tinymce/utils/editable_selects.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/tiny_mce_popup.js", "src" : "../wp-includes/js/tinymce/tiny_mce_popup.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/editor_template.js", "src" : "../wp-includes/js/tinymce/themes/advanced/editor_template.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/source_editor.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/source_editor.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/anchor.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/anchor.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/image.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/image.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/link.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/link.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/color_picker.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/color_picker.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/charmap.htm", "src" : "../wp-includes/js/tinymce/themes/advanced/charmap.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/color_picker.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/color_picker.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/charmap.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/charmap.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/image.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/image.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/link.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/link.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/source_editor.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/source_editor.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/anchor.js", "src" : "../wp-includes/js/tinymce/themes/advanced/js/anchor.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css", "src" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css", "src" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css", "src" : "../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+
+{ "url" : "../wp-includes/js/tinymce/plugins/autosave/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/autosave/editor_plugin.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+
+{ "url" : "../wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm", "src" : "../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+
+{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/template.htm", "src" : "../wp-includes/js/tinymce/plugins/inlinepopups/template.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css", "src" : "../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+
+{ "url" : "../wp-includes/js/tinymce/plugins/media/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/media/editor_plugin.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/media/js/media.js", "src" : "../wp-includes/js/tinymce/plugins/media/js/media.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/media/media.htm", "src" : "../wp-includes/js/tinymce/plugins/media/media.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/media/css/content.css", "src" : "../wp-includes/js/tinymce/plugins/media/css/content.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/media/css/media.css", "src" : "../wp-includes/js/tinymce/plugins/media/css/media.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+
+{ "url" : "../wp-includes/js/tinymce/plugins/paste/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/paste/editor_plugin.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/paste/js/pasteword.js", "src" : "../wp-includes/js/tinymce/plugins/paste/js/pasteword.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/paste/js/pastetext.js", "src" : "../wp-includes/js/tinymce/plugins/paste/js/pastetext.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/paste/pasteword.htm", "src" : "../wp-includes/js/tinymce/plugins/paste/pasteword.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/paste/blank.htm", "src" : "../wp-includes/js/tinymce/plugins/paste/blank.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/paste/pastetext.htm", "src" : "../wp-includes/js/tinymce/plugins/paste/pastetext.htm?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/pasteword.css", "src" : "../wp-includes/js/tinymce/plugins/paste/css/pasteword.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/paste/css/blank.css", "src" : "../wp-includes/js/tinymce/plugins/paste/css/blank.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+
+{ "url" : "../wp-includes/js/tinymce/plugins/safari/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/safari/editor_plugin.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+
+{ "url" : "../wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/spellchecker/css/content.css", "src" : "../wp-includes/js/tinymce/plugins/spellchecker/css/content.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+
+{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/css/content.css", "src" : "../wp-includes/js/tinymce/plugins/wordpress/css/content.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+
+{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html", "src" : "../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js", "src" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css", "src" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css", "src" : "../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
+
+{ "url" : "../wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js", "src" : "../wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js?ver=<?php echo $mce_ver; ?>", "ignoreQuery" : true },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/icons.gif" },
{ "url" : "../wp-includes/js/tinymce/themes/advanced/img/colorpicker.jpg" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/img/shockwave.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/media/img/trans.gif" },
+{ "url" : "../wp-includes/js/tinymce/plugins/spellchecker/img/wline.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/more.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/page.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif" },
-{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/img/image.png" },
-{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/img/delete.png" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/help.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/image.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/media.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/video.gif" },
{ "url" : "../wp-includes/js/tinymce/plugins/wordpress/img/audio.gif" },
+{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/img/image.png" },
+{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/img/delete.png" },
+{ "url" : "../wp-includes/js/tinymce/plugins/wpgallery/img/delete.png" },
+{ "url" : "../wp-includes/js/tinymce/plugins/wpgallery/img/edit.png" },
+{ "url" : "../wp-includes/js/tinymce/plugins/wpgallery/img/gallery.png" },
<?php } ?>
{ "url" : "../wp-includes/images/crystal/archive.png" },
{ "url" : "../wp-includes/images/crystal/spreadsheet.png" },
{ "url" : "../wp-includes/images/rss.png" },
{ "url" : "../wp-includes/js/thickbox/loadingAnimation.gif" },
-{ "url" : "../wp-includes/js/thickbox/tb-close.png" },
-{ "url" : "../wp-includes/js/swfupload/swfupload_f9.swf" }
+{ "url" : "../wp-includes/js/thickbox/tb-close.png" }
]}
<?php
+/**
+ * Import WordPress Administration Panel
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
require_once ('admin.php');
$title = __('Import');
-$parent_file = 'edit.php';
require_once ('admin-header.php');
+$parent_file = 'tools.php';
?>
<div class="wrap">
-<h2><?php _e('Import'); ?></h2>
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
<p><?php _e('If you have posts or comments in another system, WordPress can import those into this blog. To get started, choose a system to import from below:'); ?></p>
<?php
echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful
} else {
?>
-<table class="widefat">
+<table class="widefat" cellspacing="0">
<?php
$style = '';
<?php
-
-define( 'MAX_RESULTS', 50 ); // How many records per GData query
-define( 'MAX_EXECUTION_TIME', 20 ); // How many seconds to let the script run
-define( 'STATUS_INTERVAL', 3 ); // How many seconds between status bar updates
-
+/**
+ * Blogger Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * How many records per GData query
+ *
+ * @package WordPress
+ * @subpackage Blogger_Import
+ * @var int
+ * @since unknown
+ */
+define( 'MAX_RESULTS', 50 );
+
+/**
+ * How many seconds to let the script run
+ *
+ * @package WordPress
+ * @subpackage Blogger_Import
+ * @var int
+ * @since unknown
+ */
+define( 'MAX_EXECUTION_TIME', 20 );
+
+/**
+ * How many seconds between status bar updates
+ *
+ * @package WordPress
+ * @subpackage Blogger_Import
+ * @var int
+ * @since unknown
+ */
+define( 'STATUS_INTERVAL', 3 );
+
+/**
+ * Blogger Importer class
+ *
+ * @since unknown
+ */
class Blogger_Import {
// Shows the welcome screen and the magic auth link.
function greet() {
- $next_url = get_option('siteurl') . '/wp-admin/index.php?import=blogger&noheader=true';
+ $next_url = get_option('siteurl') . '/wp-admin/index.php?import=blogger&noheader=true';
$auth_url = "https://www.google.com/accounts/AuthSubRequest";
$title = __('Import Blogger');
$welcome = __('Howdy! This importer allows you to import posts and comments from your Blogger account into your WordPress blog.');
$auth = __('Authorize');
echo "
- <div class='wrap'><h2>$title</h2><p>$welcome</p><p>$prereqs</p><p>$stepone</p>
+ <div class='wrap'>
+ ".screen_icon()."
+ <h2>$title</h2>
+ <p>$welcome</p><p>$prereqs</p><p>$stepone</p>
<form action='$auth_url' method='get'>
<p class='submit' style='text-align:left;'>
<input type='submit' class='button' value='$auth' />
}
function uh_oh($title, $message, $info) {
- echo "<div class='wrap'><h2>$title</h2><p>$message</p><pre>$info</pre></div>";
+ echo "<div class='wrap'>";
+ screen_icon();
+ echo "<h2>$title</h2><p>$message</p><pre>$info</pre></div>";
}
function auth() {
$rows .= "<tr id='blog$i'><td class='blogtitle'>$blogtitle</td><td class='bloghost'>{$blog['host']}</td><td class='bar'>$pstat</td><td class='bar'>$cstat</td><td class='submit'><input type='submit' class='button' id='submit$i' value='$value' /><input type='hidden' name='blog' value='$i' /></td></tr>\n";
}
- echo "<div class='wrap'><h2>$title</h2><noscript>$noscript</noscript><table cellpadding='5px'><thead><td>$name</td><td>$url</td><td>$posts</td><td>$comments</td><td>$action</td></thead>\n$rows</table></form></div>";
+ echo "<div class='wrap'><h2>$title</h2><noscript>$noscript</noscript><table cellpadding='5px'><thead><tr><td>$name</td><td>$url</td><td>$posts</td><td>$comments</td><td>$action</td></tr></thead>\n$rows</table></div>";
echo "
<script type='text/javascript'>
+ /* <![CDATA[ */
var strings = {cont:'$continue',stop:'$stop',stopping:'$stopping',authors:'$authors',nothing:'$nothing'};
var blogs = {};
function blog(i, title, mode, status){
};
$init
jQuery.each(blogs, function(i, me){me.init();});
+ /* ]]> */
</script>\n";
}
}
function import_post( $entry ) {
- global $wpdb, $importing_blog;
+ global $importing_blog;
// The old permalink is all Blogger gives us to link comments to their posts.
if ( isset( $entry->draft ) )
$post_status = isset( $entry->draft ) ? 'draft' : 'publish';
// Clean up content
- $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
+ $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
$comment_content = addslashes( $this->no_apos( html_entity_decode( $entry->content ) ) );
// Clean up content
- $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
+ $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content);
$comment_content = str_replace('<br>', '<br />', $comment_content);
$comment_content = str_replace('<hr>', '<hr />', $comment_content);
foreach ( $blog['authors'] as $i => $author )
$rows .= "<tr><td><label for='authors[$i]'>{$author[0]}</label></td><td><select name='authors[$i]' id='authors[$i]'>" . $this->get_user_options($author[1]) . "</select></td></tr>";
- return "<div class='wrap'><h2>$heading</h2><h3>$blogtitle</h3><p>$directions</p><form action='index.php?import=blogger&noheader=true&saveauthors=1' method='post'><input type='hidden' name='blog' value='$importing_blog' /><table cellpadding='5'><thead><td>$mapthis</td><td>$tothis</td></thead>$rows<tr><td></td><td class='submit'><input type='submit' class='button authorsubmit' value='$submit' /></td></tr></table></form></div>";
+ return "<div class='wrap'><h2>$heading</h2><h3>$blogtitle</h3><p>$directions</p><form action='index.php?import=blogger&noheader=true&saveauthors=1' method='post'><input type='hidden' name='blog' value='$importing_blog' /><table cellpadding='5'><thead><td>$mapthis</td><td>$tothis</td></thead>$rows<tr><td></td><td class='submit'><input type='submit' class='button authorsubmit' value='$submit' /></td></tr></table></form></div>";
}
function get_user_options($current) {
- global $wpdb, $importer_users;
+ global $importer_users;
if ( ! isset( $importer_users ) )
$importer_users = (array) get_users_of_blog();
echo $result->get_error_message();
} elseif ( isset($_GET['token']) )
$this->auth();
- elseif ( $this->token && $this->token_is_valid() )
+ elseif ( isset($this->token) && $this->token_is_valid() )
$this->show_blogs();
else
$this->greet();
$restart = __('Restart');
$message = __('We have saved some information about your Blogger account in your WordPress database. Clearing this information will allow you to start over. Restarting will not affect any posts you have already imported. If you attempt to re-import a blog, duplicate posts and comments will be skipped.');
$submit = __('Clear account information');
- echo "<div class='wrap'><h2>$restart</h2><p>$message</p><form method='post' action='?import=blogger&noheader=true'><p class='submit' style='text-align:left;'><input type='submit' class='button' value='$submit' name='restart' /></p></form></div>";
+ echo "<div class='wrap'><h2>$restart</h2><p>$message</p><form method='post' action='?import=blogger&noheader=true'><p class='submit' style='text-align:left;'><input type='submit' class='button' value='$submit' name='restart' /></p></form></div>";
}
}
<?php
-
-/* By Shayne Sweeney - http://www.theshayne.com/ */
-
+/**
+ * Blogware XML Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ * @author Shayne Sweeney
+ * @link http://www.theshayne.com/
+ */
+
+/**
+ * Blogware XML Importer class
+ *
+ * Extract posts from Blogware XML export file into your blog.
+ *
+ * @since unknown
+ */
class BW_Import {
var $file;
function header() {
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import Blogware').'</h2>';
}
}
// Clean up content
- $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
+ $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
$post_content = $wpdb->escape($post_content);
$comment_content = $this->unhtmlentities($comment_content);
// Clean up content
- $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
+ $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content);
$comment_content = str_replace('<br>', '<br />', $comment_content);
$comment_content = str_replace('<hr>', '<hr />', $comment_content);
$comment_content = $wpdb->escape($comment_content);
<?php
-
+/**
+ * BunnyTags Plugin Tag Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * BunnyTags Plugin tag converter
+ *
+ * This will process the BunnyTags plugin tags and convert them to the WordPress
+ * 2.3 taxonomy.
+ *
+ * @since unknown
+ */
class BunnyTags_Import {
function header() {
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import Bunny’s Technorati Tags').'</h2>';
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
}
echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>';
echo '<form action="admin.php?import=btt&step=1" method="post">';
wp_nonce_field('import-btt');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Tags').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Import Tags').'" /></p>';
echo '</form>';
echo '</div>';
}
echo '<form action="admin.php?import=btt&step='.($precheck? 2:3).'" method="post">';
wp_nonce_field('import-btt');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Next').'" /></p>';
echo '</form>';
echo '</div>';
}
<?php
-/*
- * DotClear import plugin
- * by Thomas Quinot - http://thomas.quinot.org/
+/**
+ * DotClear Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ * @author Thomas Quinot
+ * @link http://thomas.quinot.org/
*/
/**
if(!function_exists('get_comment_count'))
{
+ /**
+ * Get the comment count for posts.
+ *
+ * @package WordPress
+ * @subpackage Dotclear_Import
+ *
+ * @param int $post_ID Post ID
+ * @return int
+ */
function get_comment_count($post_ID)
{
global $wpdb;
if(!function_exists('link_exists'))
{
+ /**
+ * Check whether link already exists.
+ *
+ * @package WordPress
+ * @subpackage Dotclear_Import
+ *
+ * @param string $linkname
+ * @return int
+ */
function link_exists($linkname)
{
global $wpdb;
// This cries out for a C-implementation to be included in PHP core
//
+/**
+ * @package WordPress
+ * @subpackage Dotclear_Import
+ *
+ * @param string $char
+ * @return string
+ */
function valid_1byte($char) {
if(!is_int($char)) return false;
return ($char & 0x80) == 0x00;
}
+/**
+ * @package WordPress
+ * @subpackage Dotclear_Import
+ *
+ * @param string $char
+ * @return string
+ */
function valid_2byte($char) {
if(!is_int($char)) return false;
return ($char & 0xE0) == 0xC0;
}
+/**
+ * @package WordPress
+ * @subpackage Dotclear_Import
+ *
+ * @param string $char
+ * @return string
+ */
function valid_3byte($char) {
if(!is_int($char)) return false;
return ($char & 0xF0) == 0xE0;
}
+/**
+ * @package WordPress
+ * @subpackage Dotclear_Import
+ *
+ * @param string $char
+ * @return string
+ */
function valid_4byte($char) {
if(!is_int($char)) return false;
return ($char & 0xF8) == 0xF0;
}
+/**
+ * @package WordPress
+ * @subpackage Dotclear_Import
+ *
+ * @param string $char
+ * @return string
+ */
function valid_nextbyte($char) {
if(!is_int($char)) return false;
return ($char & 0xC0) == 0x80;
}
+/**
+ * @package WordPress
+ * @subpackage Dotclear_Import
+ *
+ * @param string $string
+ * @return string
+ */
function valid_utf8($string) {
$len = strlen($string);
$i = 0;
return true; // done
}
+/**
+ * @package WordPress
+ * @subpackage Dotclear_Import
+ *
+ * @param string $s
+ * @return string
+ */
function csc ($s) {
if (valid_utf8 ($s)) {
return $s;
}
}
+/**
+ * @package WordPress
+ * @subpackage Dotclear_Import
+ *
+ * @param string $s
+ * @return string
+ */
function textconv ($s) {
return csc (preg_replace ('|(?<!<br />)\s*\n|', ' ', $s));
}
/**
- The Main Importer Class
-**/
+ * Dotclear Importer class
+ *
+ * Will process the WordPress eXtended RSS files that you upload from the export
+ * file.
+ *
+ * @package WordPress
+ * @subpackage Importer
+ *
+ * @since unknown
+ */
class Dotclear_Import {
function header()
{
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import DotClear').'</h2>';
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
}
echo '<form action="admin.php?import=dotclear&step=1" method="post">';
wp_nonce_field('import-dotclear');
$this->db_form();
- echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories')).'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.attribute_escape(__('Import Categories')).'" /></p>';
echo '</form></div>';
}
echo '<form action="admin.php?import=dotclear&step=2" method="post">';
wp_nonce_field('import-dotclear');
- printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users')));
+ printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Users')));
echo '</form>';
}
echo '<form action="admin.php?import=dotclear&step=3" method="post">';
wp_nonce_field('import-dotclear');
- printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts')));
+ printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Posts')));
echo '</form>';
}
echo '<form action="admin.php?import=dotclear&step=4" method="post">';
wp_nonce_field('import-dotclear');
- printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments')));
+ printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Comments')));
echo '</form>';
}
echo '<form action="admin.php?import=dotclear&step=5" method="post">';
wp_nonce_field('import-dotclear');
- printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links')));
+ printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Links')));
echo '</form>';
}
echo '<form action="admin.php?import=dotclear&step=6" method="post">';
wp_nonce_field('import-dotclear');
- printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish')));
+ printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Finish')));
echo '</form>';
}
printf('<tr><th><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('DotClear Database User:'));
printf('<tr><th><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('DotClear Database Password:'));
printf('<tr><th><label for="dbname">%s</label></th><td><input type="text" name="dbname" id="dbname" /></td></tr>', __('DotClear Database Name:'));
- printf('<tr><th><label for="dbhost">%s</label></th><td><input type="text" name="dbhost" nameid="dbhost" value="localhost" /></td></tr>', __('DotClear Database Host:'));
+ printf('<tr><th><label for="dbhost">%s</label></th><td><input type="text" name="dbhost" id="dbhost" value="localhost" /></td></tr>', __('DotClear Database Host:'));
printf('<tr><th><label for="dbprefix">%s</label></th><td><input type="text" name="dbprefix" id="dbprefix" value="dc_"/></td></tr>', __('DotClear Table prefix:'));
printf('<tr><th><label for="dccharset">%s</label></th><td><input type="text" name="dccharset" id="dccharset" value="ISO-8859-15"/></td></tr>', __('Originating character set:'));
echo '</table>';
}
$dc_import = new Dotclear_Import();
+
register_importer('dotclear', __('DotClear'), __('Import categories, users, posts, comments, and links from a DotClear blog.'), array ($dc_import, 'dispatch'));
+
?>
<?php
-
+/**
+ * GreyMatter Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * GreyMatter Importer class
+ *
+ * Basic GreyMatter to WordPress importer, will import posts, comments, and
+ * posts karma.
+ *
+ * @since unknown
+ */
class GM_Import {
var $gmnames = array ();
function header() {
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import GreyMatter').'</h2>';
}
</ul>
<p> </p>
-<form name="stepOne" method="get">
+<form name="stepOne" method="get" action="">
<input type="hidden" name="import" value="greymatter" />
<input type="hidden" name="step" value="1" />
<?php wp_nonce_field('import-greymatter'); ?>
<?php _e("This importer will search for files 00000001.cgi to 000-whatever.cgi,<br />so you need to enter the number of the last GM post here.<br />(if you don't know that number, just log into your FTP and look it out<br />in the entries' folder)") ?></td>
</tr>
</table>
-</p>
-<p><input type="submit" name="submit" value="<?php _e('Start Importing') ?>" class="button" /></p>
+<p class="submit"><input type="submit" name="submit" class="button" value="<?php _e('Start Importing') ?>" /></p>
</form>
<?php
$this->footer();
<?php
-
+/**
+ * Jeromes Keyword Plugin Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * Jeromes Keyword Plugin Importer class
+ *
+ * Will convert Jeromes Keyword Plugin tags to WordPress taxonomy tags.
+ *
+ * @since 2.3
+ */
class JeromesKeyword_Import {
function header() {
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import Jerome’s Keywords').'</h2>';
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
}
echo '<form action="admin.php?import=jkw&step='.($precheck? 2:6).'" method="post">';
wp_nonce_field('import-jkw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Next').'" /></p>';
echo '</form>';
echo '</div>';
}
}
echo '<form action="admin.php?import=jkw&step='.($precheck? 4:5).'" method="post">';
wp_nonce_field('import-jkw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Next').'" /></p>';
echo '</form>';
echo '</div>';
}
<?php
-
+/**
+ * LiveJournal Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * LiveJournal Importer class
+ *
+ * Imports your LiveJournal XML exported file into WordPress.
+ *
+ * @since unknown
+ */
class LJ_Import {
var $file;
function header() {
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import LiveJournal').'</h2>';
}
$post_content = $this->unhtmlentities($post_content);
// Clean up content
- $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
+ $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
$post_content = $wpdb->escape($post_content);
$comment_content = $this->unhtmlentities($comment_content);
// Clean up content
- $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
+ $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content);
$comment_content = str_replace('<br>', '<br />', $comment_content);
$comment_content = str_replace('<hr>', '<hr />', $comment_content);
$comment_content = $wpdb->escape($comment_content);
<?php
-
+/**
+ * Movable Type and Typepad Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * Moveable Type and Typepad Importer class
+ *
+ * Upload your exported Movable Type or Typepad entries into WordPress.
+ *
+ * @since unknown
+ */
class MT_Import {
var $posts = array ();
function header() {
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import Movable Type or TypePad').'</h2>';
}
<input type="hidden" name="upload_type" value="ftp" />
<?php _e('Or use <code>mt-export.txt</code> in your <code>/wp-content/</code> directory'); ?></p>
<p class="submit">
-<input type="submit" value="<?php echo attribute_escape(__('Import mt-export.txt')); ?>" />
+<input type="submit" class="button" value="<?php echo attribute_escape(__('Import mt-export.txt')); ?>" />
</p>
</form>
<p><?php _e('The importer is smart enough not to import duplicates, so you can run this multiple times without worry if—for whatever reason—it doesn\'t finish. If you get an <strong>out of memory</strong> error try splitting up the import file into pieces.'); ?> </p>
}
function users_form($n) {
- global $wpdb, $testing;
+ global $wpdb;
$users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID");
?><select name="userselect[<?php echo $n; ?>]">
<option value="#NONE#"><?php _e('- Select -') ?></option>
</select>
<?php
+ }
+
+ function has_gzip() {
+ return is_callable('gzopen');
+ }
+
+ function fopen($filename, $mode='r') {
+ if ( $this->has_gzip() )
+ return gzopen($filename, $mode);
+ return fopen($filename, $mode);
+ }
+
+ function feof($fp) {
+ if ( $this->has_gzip() )
+ return gzeof($fp);
+ return feof($fp);
+ }
+ function fgets($fp, $len=8192) {
+ if ( $this->has_gzip() )
+ return gzgets($fp, $len);
+ return fgets($fp, $len);
}
+ function fclose($fp) {
+ if ( $this->has_gzip() )
+ return gzclose($fp);
+ return fclose($fp);
+ }
+
//function to check the authorname and do the mapping
function checkauthor($author) {
- global $wpdb;
//mtnames is an array with the names in the mt import file
$pass = wp_generate_password();
if (!(in_array($author, $this->mtnames))) { //a new mt author name is found
$this->mtnames[$this->j] = $author; //add that new mt author name to an array
$user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user
if (!$user_id) { //banging my head against the desk now.
- if ($newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname
+ if ($this->newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname
$user_id = wp_create_user($author, $pass);
$this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank.
} else {
$temp = array();
$authors = array();
- $handle = fopen($this->file, 'r');
+ $handle = $this->fopen($this->file, 'r');
if ( $handle == null )
return false;
$in_comment = false;
- while ( $line = fgets($handle) ) {
+ while ( $line = $this->fgets($handle) ) {
$line = trim($line);
if ( 'COMMENT:' == $line )
array_push($authors, "$next");
}
- fclose($handle);
+ $this->fclose($handle);
return $authors;
}
function mt_authors_form() {
?>
<div class="wrap">
+<?php screen_icon(); ?>
<h2><?php _e('Assign Authors'); ?></h2>
<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as admin\'s entries.'); ?></p>
<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <em>italics</em>. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?></p>
echo '</label></li>';
}
- echo '<input type="submit" value="'.__('Submit').'">'.'<br />';
+ echo '<p class="submit"><input type="submit" class="button" value="'.__('Submit').'"></p>'.'<br />';
echo '</form>';
echo '</ol></div>';
if ( 0 != count($post->categories) ) {
wp_create_categories($post->categories, $post_id);
}
-
+
// Add tags or keywords
if ( 1 < strlen($post->post_keywords) ) {
- // Keywords exist.
+ // Keywords exist.
printf(__('<br />Adding tags <i>%s</i>...'), stripslashes($post->post_keywords));
wp_add_post_tags($post_id, $post->post_keywords);
}
function process_posts() {
global $wpdb;
- $handle = fopen($this->file, 'r');
+ $handle = $this->fopen($this->file, 'r');
if ( $handle == null )
return false;
echo "<div class='wrap'><ol>";
- while ( $line = fgets($handle) ) {
+ while ( $line = $this->fgets($handle) ) {
$line = trim($line);
if ( '-----' == $line ) {
$ping->comment_author = $blog;
} else {
// Processing multi-line field, check context.
-
- $line .= "\n";
+
+ if( !empty($line) )
+ $line .= "\n";
+
if ( 'body' == $context ) {
$post->post_content .= $line;
} else if ( 'extended' == $context ) {
}
}
+ $this->fclose($handle);
+
echo '</ol>';
wp_import_cleanup($this->id);
<?php
-// Links
-// Copyright (C) 2002 Mike Little -- mike@zed1.com
-
-require_once('admin.php');
-$parent_file = 'edit.php';
+/**
+ * Links Import Administration Panel.
+ *
+ * @copyright 2002 Mike Little <mike@zed1.com>
+ * @author Mike Little <mike@zed1.com>
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
+$parent_file = 'tools.php';
+$submenu_file = 'import.php';
$title = __('Import Blogroll');
+class OPML_Import {
+
+ function dispatch() {
+ global $wpdb, $user_ID;
$step = $_POST['step'];
if (!$step) $step = 0;
?>
?>
<div class="wrap">
-
+<?php screen_icon(); ?>
<h2><?php _e('Import your blogroll from another system') ?> </h2>
-<form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
+<form enctype="multipart/form-data" action="admin.php?import=opml" method="post" name="blogroll">
<?php wp_nonce_field('import-bookmarks') ?>
<p><?php _e('If a program or website you use allows you to export your links or subscriptions as OPML you may import them here.'); ?></p>
$blogrolling = false;
}
+ global $opml, $updated_timestamp, $all_links, $map, $names, $urls, $targets, $descriptions, $feeds;
if ( isset($opml_url) && $opml_url != '' ) {
if ( $blogrolling === true ) {
$opml = wp_remote_fopen($opml_url);
$opml = file_get_contents($opml_url);
}
+ /** Load OPML Parser */
include_once('link-parse-opml.php');
$link_count = count($names);
break;
} // end case 1
} // end switch
+ }
-include('admin-footer.php');
+ function OPML_Import() {}
+}
-?>
\ No newline at end of file
+$opml_importer = new OPML_Import();
+
+register_importer('opml', __('Blogroll'), __('Import links in OPML format.'), array(&$opml_importer, 'dispatch'));
+
+?>
<?php
-
+/**
+ * RSS Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * RSS Importer
+ *
+ * Will process a RSS feed for importing posts into WordPress. This is a very
+ * limited importer and should only be used as the last resort, when no other
+ * importer is available.
+ *
+ * @since unknown
+ */
class RSS_Import {
var $posts = array ();
function header() {
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import RSS').'</h2>';
}
}
// Clean up content
- $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
+ $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
<?php
+/**
+ * Simple Tags Plugin Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * Simple Tags Plugin Tags converter class.
+ *
+ * Will convert Simple Tags Plugin tags over to the WordPress 2.3 taxonomy.
+ *
+ * @since unknown
+ */
class STP_Import {
function header() {
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import Simple Tagging').'</h2>';
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
}
echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>';
echo '<form action="admin.php?import=stp&step=1" method="post">';
wp_nonce_field('import-stp');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Step 1').'" /></p>';
echo '</form>';
echo '</div>';
}
echo '<form action="admin.php?import=stp&step=2" method="post">';
wp_nonce_field('import-stp');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Step 2').'" /></p>';
echo '</form>';
echo '</div>';
}
echo '<p>' . sprintf( __ngettext('Done! <strong>%s</strong> tag was added!', 'Done! <strong>%s</strong> tags were added!', $tags_added), $tags_added ) . '<br /></p>';
echo '<form action="admin.php?import=stp&step=3" method="post">';
wp_nonce_field('import-stp');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Step 3').'" /></p>';
echo '</form>';
echo '</div>';
}
<?php
/**
- Add These Functions to make our lives easier
-**/
+ * TextPattern Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
if(!function_exists('get_comment_count'))
{
+ /**
+ * Get the comment count for posts.
+ *
+ * @package WordPress
+ * @subpackage Textpattern_Import
+ *
+ * @param int $post_ID Post ID
+ * @return int
+ */
function get_comment_count($post_ID)
{
global $wpdb;
if(!function_exists('link_exists'))
{
+ /**
+ * Check whether link already exists.
+ *
+ * @package WordPress
+ * @subpackage Textpattern_Import
+ *
+ * @param string $linkname
+ * @return int
+ */
function link_exists($linkname)
{
global $wpdb;
}
/**
- The Main Importer Class
-**/
+ * TextPattern Importer Class
+ *
+ * @since unknown
+ */
class Textpattern_Import {
function header()
{
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import Textpattern').'</h2>';
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
}
echo '<form action="admin.php?import=textpattern&step=1" method="post">';
wp_nonce_field('import-textpattern');
$this->db_form();
- echo '<p class="submit"><input type="submit" class="button" name="submit" value="'.attribute_escape(__('Import')).'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.attribute_escape(__('Import')).'" /></p>';
echo '</form>';
echo '</div>';
}
echo '<form action="admin.php?import=textpattern&step=2" method="post">';
wp_nonce_field('import-textpattern');
- printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Users')));
+ printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Users')));
echo '</form>';
}
echo '<form action="admin.php?import=textpattern&step=3" method="post">';
wp_nonce_field('import-textpattern');
- printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Posts')));
+ printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Posts')));
echo '</form>';
}
echo '<form action="admin.php?import=textpattern&step=4" method="post">';
wp_nonce_field('import-textpattern');
- printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Comments')));
+ printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Comments')));
echo '</form>';
}
echo '<form action="admin.php?import=textpattern&step=5" method="post">';
wp_nonce_field('import-textpattern');
- printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Import Links')));
+ printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Links')));
echo '</form>';
}
echo '<form action="admin.php?import=textpattern&step=6" method="post">';
wp_nonce_field('import-textpattern');
- printf('<input type="submit" class="button" name="submit" value="%s" />', attribute_escape(__('Finish')));
+ printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Finish')));
echo '</form>';
}
}
$txp_import = new Textpattern_Import();
+
register_importer('textpattern', __('Textpattern'), __('Import categories, users, posts, comments, and links from a Textpattern blog.'), array ($txp_import, 'dispatch'));
+
?>
<?php
-
+/**
+ * The Ultimate Tag Warrior Importer.
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * Ultimate Tag Warrior Converter to 2.3 taxonomy.
+ *
+ * This converts the Ultimate Tag Warrior tags to the 2.3 WordPress taxonomy.
+ *
+ * @since 2.3.0
+ */
class UTW_Import {
function header() {
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import Ultimate Tag Warrior').'</h2>';
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
}
echo '<p>'.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 5-step program to help you kick that nasty UTW habit. Just keep clicking along and we will let you know when you are in the clear!').'</p>';
echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>';
echo '<form action="admin.php?import=utw&step=1" method="post">';
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Step 1').'" /></p>';
echo '</form>';
echo '</div>';
}
echo '<form action="admin.php?import=utw&step=2" method="post">';
wp_nonce_field('import-utw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Step 2').'" /></p>';
echo '</form>';
echo '</div>';
}
echo '<form action="admin.php?import=utw&step=3" method="post">';
wp_nonce_field('import-utw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Step 3').'" /></p>';
echo '</form>';
echo '</div>';
echo '<form action="admin.php?import=utw&step=4" method="post">';
wp_nonce_field('import-utw');
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 4').'" /></p>';
+ echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.__('Step 4').'" /></p>';
echo '</form>';
echo '</div>';
<?php
-
+/**
+ * WordPress Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * WordPress Importer
+ *
+ * Will process the WordPress eXtended RSS files that you upload from the export
+ * file.
+ *
+ * @since unknown
+ */
class WP_Import {
var $post_ids_processed = array ();
function header() {
echo '<div class="wrap">';
+ screen_icon();
echo '<h2>'.__('Import WordPress').'</h2>';
}
function greet() {
echo '<div class="narrow">';
- echo '<p>'.__('Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, comments, custom fields, and categories into this blog.').'</p>';
+ echo '<p>'.__('Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, pages, comments, custom fields, categories, and tags into this blog.').'</p>';
echo '<p>'.__('Choose a WordPress WXR file to upload, then click Upload file and import.').'</p>';
wp_import_upload_form("admin.php?import=wordpress&step=1");
echo '</div>';
if ( !$is_wxr_file && preg_match('|xmlns:wp="http://wordpress[.]org/export/\d+[.]\d+/"|', $importline) )
$is_wxr_file = true;
+ if ( false !== strpos($importline, '<wp:base_site_url>') ) {
+ preg_match('|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url);
+ $this->base_url = $url[1];
+ continue;
+ }
if ( false !== strpos($importline, '<wp:category>') ) {
preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category);
$this->categories[] = $category[1];
function wp_authors_form() {
?>
+<?php screen_icon(); ?>
<h2><?php _e('Assign Authors'); ?></h2>
<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
<?php
$authors = $this->get_wp_authors();
- echo '<ol id="authors">';
echo '<form action="?import=wordpress&step=2&id=' . $this->id . '" method="post">';
wp_nonce_field('import-wordpress');
+ echo '<ol id="authors">';
$j = -1;
foreach ($authors as $author) {
++ $j;
if ( $this->allow_fetch_attachments() ) {
?>
</ol>
+<?php screen_icon(); ?>
<h2><?php _e('Import Attachments'); ?></h2>
<p>
<input type="checkbox" value="1" name="attachments" id="import-attachments" />
<?php
}
- echo '<input type="submit" value="'.attribute_escape( __('Submit') ).'">'.'<br />';
+ echo '<p class="submit">';
+ echo '<input type="submit" class="button" value="'.attribute_escape( __('Submit') ).'" />'.'<br />';
+ echo '</p>';
echo '</form>';
}
function users_form($n, $author) {
if ( $this->allow_create_users() ) {
- printf('<label>'.__('Create user %1$s or map to existing'), ' <input type="text" value="'.$author.'" name="'.'user_create['.intval($n).']'.'" maxlength="30"></label> <br />');
+ printf('<label>'.__('Create user %1$s or map to existing'), ' <input type="text" value="'.$author.'" name="'.'user_create['.intval($n).']'.'" maxlength="30" /></label> <br />');
}
else {
echo __('Map to existing').'<br />';
}
function process_posts() {
- $i = -1;
echo '<ol>';
$this->get_entries(array(&$this, 'process_post'));
$post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
if ( $post_ID && !empty($this->post_ids_processed[$post_ID]) ) // Processed already
return 0;
-
+
set_time_limit( 60 );
// There are only ever one of these
$post_author = $this->get_tag( $post, 'dc:creator' );
$post_excerpt = $this->get_tag( $post, 'excerpt:encoded' );
- $post_excerpt = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_excerpt);
+ $post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_excerpt);
$post_excerpt = str_replace('<br>', '<br />', $post_excerpt);
$post_excerpt = str_replace('<hr>', '<hr />', $post_excerpt);
$post_content = $this->get_tag( $post, 'content:encoded' );
- $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
+ $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
if ( $post_exists ) {
echo '<li>';
printf(__('Post <em>%s</em> already exists.'), stripslashes($post_title));
+ $comment_post_ID = $post_id = $post_exists;
} else {
// If it has parent, process parent first.
$post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor
$postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt', 'post_title', 'post_status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent', 'menu_order', 'post_type', 'post_password');
+ $postdata['import_id'] = $post_ID;
if ($post_type == 'attachment') {
$remote_url = $this->get_tag( $post, 'wp:attachment_url' );
if ( !$remote_url )
if (count($categories) > 0) {
$post_cats = array();
foreach ($categories as $category) {
+ if ( '' == $category )
+ continue;
$slug = sanitize_term_field('slug', $category, 0, 'category', 'db');
$cat = get_term_by('slug', $slug, 'category');
$cat_ID = 0;
if ($cat_ID == 0) {
$category = $wpdb->escape($category);
$cat_ID = wp_insert_category(array('cat_name' => $category));
+ if ( is_wp_error($cat_ID) )
+ continue;
}
$post_cats[] = $cat_ID;
}
if (count($tags) > 0) {
$post_tags = array();
foreach ($tags as $tag) {
+ if ( '' == $tag )
+ continue;
$slug = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
$tag_obj = get_term_by('slug', $slug, 'post_tag');
$tag_id = 0;
if ( $tag_id == 0 ) {
$tag = $wpdb->escape($tag);
$tag_id = wp_insert_term($tag, 'post_tag');
+ if ( is_wp_error($tag_id) )
+ continue;
$tag_id = $tag_id['term_id'];
}
$post_tags[] = intval($tag_id);
function process_attachment($postdata, $remote_url) {
if ($this->fetch_attachments and $remote_url) {
printf( __('Importing attachment <em>%s</em>... '), htmlspecialchars($remote_url) );
+
+ // If the URL is absolute, but does not contain http, upload it assuming the base_site_url variable
+ if ( preg_match('/^\/[\w\W]+$/', $remote_url) )
+ $remote_url = rtrim($this->base_url,'/').$remote_url;
+
$upload = $this->fetch_remote_file($postdata, $remote_url);
if ( is_wp_error($upload) ) {
printf( __('Remote file error: %s'), htmlspecialchars($upload->get_error_message()) );
// fetch the remote url and write it to the placeholder file
$headers = wp_get_http($url, $upload['file']);
+ //Request failed
+ if ( ! $headers ) {
+ @unlink($upload['file']);
+ return new WP_Error( 'import_file_error', __('Remote server did not respond') );
+ }
+
// make sure the fetch was successful
if ( $headers['response'] != '200' ) {
@unlink($upload['file']);
- return new WP_Error( 'import_file_error', sprintf(__('Remote file returned error response %d'), intval($headers['response'])) );
+ return new WP_Error( 'import_file_error', sprintf(__('Remote file returned error response %1$d %2$s'), $headers['response'], get_status_header_desc($headers['response']) ) );
}
elseif ( isset($headers['content-length']) && filesize($upload['file']) != $headers['content-length'] ) {
@unlink($upload['file']);
$this->import_start();
$this->get_authors_from_post();
+ wp_suspend_cache_invalidation(true);
$this->get_entries();
$this->process_categories();
$this->process_tags();
$result = $this->process_posts();
+ wp_suspend_cache_invalidation(false);
$this->backfill_parents();
$this->backfill_attachment_urls();
$this->import_end();
}
}
+/**
+ * Register WordPress Importer
+ *
+ * @since unknown
+ * @var WP_Import
+ * @name $wp_import
+ */
$wp_import = new WP_Import();
-register_importer('wordpress', 'WordPress', __('Import <strong>posts, comments, custom fields, pages, and categories</strong> from a WordPress export file.'), array ($wp_import, 'dispatch'));
+register_importer('wordpress', 'WordPress', __('Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file.'), array ($wp_import, 'dispatch'));
?>
<?php
-
+/**
+ * WordPress Categories to Tags Converter.
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * WordPress categories to tags converter class.
+ *
+ * Will convert WordPress categories to tags, removing the category after the
+ * process is complete and updating all posts to switch to the tag.
+ *
+ * @since unknown
+ */
class WP_Categories_to_Tags {
var $categories_to_convert = array();
var $all_categories = array();
echo '<br class="clear" />';
if ( $cat_num > 0 ) {
+ screen_icon();
echo '<h2>' . sprintf( __ngettext( 'Convert Category to Tag.', 'Convert Categories (%d) to Tags.', $cat_num ), $cat_num ) . '</h2>';
echo '<div class="narrow">';
echo '<p>' . __('Hey there. Here you can selectively convert existing categories to tags. To get started, check the categories you wish to be converted, then click the Convert button.') . '</p>';
if ( in_array( intval($category->term_id), $this->hybrids_ids ) )
echo ' <a href="#note"> * </a>';
-
+
if ( isset($hier[$category->term_id]) )
$this->_category_children($category, $hier); ?></li>
<?php }
echo '<br class="clear" />';
if ( $tags_num > 0 ) {
+ screen_icon();
echo '<h2>' . sprintf( __ngettext( 'Convert Tag to Category.', 'Convert Tags (%d) to Categories.', $tags_num ), $tags_num ) . '</h2>';
echo '<div class="narrow">';
echo '<p>' . __('Here you can selectively converts existing tags to categories. To get started, check the tags you wish to be converted, then click the Convert button.') . '</p>';
if ( ! ($id = is_term( $category->slug, 'post_tag' ) ) )
$id = wp_insert_term($category->name, 'post_tag', array('slug' => $category->slug));
-
+
$id = $id['term_taxonomy_id'];
$posts = get_objects_in_term($category->term_id, 'category');
$term_order = 0;
$values[] = $wpdb->prepare( "(%d, %d, %d)", $post, $id, $term_order);
clean_post_cache($post);
}
-
+
if ( $values ) {
$wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)");
echo __('Converted successfully.') . "</li>\n";
continue;
}
-
+
// if tag already exists, add it to all posts in the category
if ( $tag_ttid = $wpdb->get_var( $wpdb->prepare("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id = %d AND taxonomy = 'post_tag'", $category->term_id) ) ) {
$objects_ids = get_objects_in_term($category->term_id, 'category');
<?php
+/**
+ * Includes all of the WordPress Administration API files.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+/** WordPress Bookmark Administration API */
require_once(ABSPATH . 'wp-admin/includes/bookmark.php');
+
+/** WordPress Comment Administration API */
require_once(ABSPATH . 'wp-admin/includes/comment.php');
+
+/** WordPress Administration File API */
require_once(ABSPATH . 'wp-admin/includes/file.php');
+
+/** WordPress Image Administration API */
require_once(ABSPATH . 'wp-admin/includes/image.php');
+
+/** WordPress Media Administration API */
require_once(ABSPATH . 'wp-admin/includes/media.php');
+
+/** WordPress Import Administration API */
require_once(ABSPATH . 'wp-admin/includes/import.php');
+
+/** WordPress Misc Administration API */
require_once(ABSPATH . 'wp-admin/includes/misc.php');
+
+/** WordPress Plugin Administration API */
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
+
+/** WordPress Post Administration API */
require_once(ABSPATH . 'wp-admin/includes/post.php');
+
+/** WordPress Taxonomy Administration API */
require_once(ABSPATH . 'wp-admin/includes/taxonomy.php');
+
+/** WordPress Template Administration API */
require_once(ABSPATH . 'wp-admin/includes/template.php');
+
+/** WordPress Theme Administration API */
require_once(ABSPATH . 'wp-admin/includes/theme.php');
+
+/** WordPress User Administration API */
require_once(ABSPATH . 'wp-admin/includes/user.php');
+
+/** WordPress Update Administration API */
require_once(ABSPATH . 'wp-admin/includes/update.php');
+/** WordPress Registration API */
require_once(ABSPATH . WPINC . '/registration.php');
-?>
+?>
\ No newline at end of file
<?php
-
+/**
+ * WordPress Bookmark Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function add_link() {
return edit_link();
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $link_id
+ * @return unknown
+ */
function edit_link( $link_id = '' ) {
if (!current_user_can( 'manage_links' ))
wp_die( __( 'Cheatin’ uh?' ));
$_POST['link_name'] = wp_specialchars( $_POST['link_name'] );
$_POST['link_image'] = wp_specialchars( $_POST['link_image'] );
$_POST['link_rss'] = clean_url($_POST['link_rss']);
- if ( 'N' != $_POST['link_visible'] )
+ if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] )
$_POST['link_visible'] = 'Y';
if ( !empty( $link_id ) ) {
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function get_default_link_to_edit() {
if ( isset( $_GET['linkurl'] ) )
$link->link_url = clean_url( $_GET['linkurl']);
return $link;
}
-function wp_delete_link($link_id) {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $link_id
+ * @return unknown
+ */
+function wp_delete_link( $link_id ) {
global $wpdb;
- do_action('delete_link', $link_id);
+ do_action( 'delete_link', $link_id );
+
+ wp_delete_object_term_relationships( $link_id, 'link_category' );
- wp_delete_object_term_relationships($link_id, 'link_category');
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->links WHERE link_id = %d", $link_id ) );
- $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->links WHERE link_id = %d", $link_id) );
+ do_action( 'deleted_link', $link_id );
- do_action('deleted_link', $link_id);
+ clean_bookmark_cache( $link_id );
return true;
}
-function wp_get_link_cats($link_id = 0) {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $link_id
+ * @return unknown
+ */
+function wp_get_link_cats( $link_id = 0 ) {
- $cats = wp_get_object_terms($link_id, 'link_category', 'fields=ids');
+ $cats = wp_get_object_terms( $link_id, 'link_category', 'fields=ids' );
- return array_unique($cats);
+ return array_unique( $cats );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $link_id
+ * @return unknown
+ */
function get_link_to_edit( $link_id ) {
return get_bookmark( $link_id, OBJECT, 'edit' );
}
-function wp_insert_link($linkdata) {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $linkdata
+ * @return unknown
+ */
+function wp_insert_link( $linkdata, $wp_error = false ) {
global $wpdb, $current_user;
- $defaults = array('link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
+ $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
- $linkdata = wp_parse_args($linkdata, $defaults);
- $linkdata = sanitize_bookmark($linkdata, 'db');
+ $linkdata = wp_parse_args( $linkdata, $defaults );
+ $linkdata = sanitize_bookmark( $linkdata, 'db' );
- extract(stripslashes_deep($linkdata), EXTR_SKIP);
+ extract( stripslashes_deep( $linkdata ), EXTR_SKIP );
$update = false;
- if ( !empty($link_id) )
+ if ( !empty( $link_id ) )
$update = true;
- if ( trim( $link_name ) == '' )
- return 0;
+ if ( trim( $link_name ) == '' ) {
+ if ( trim( $link_url ) != '' ) {
+ $link_name = $link_url;
+ } else {
+ return 0;
+ }
+ }
if ( trim( $link_url ) == '' )
return 0;
- if ( empty($link_rating) )
+ if ( empty( $link_rating ) )
$link_rating = 0;
- if ( empty($link_image) )
+ if ( empty( $link_image ) )
$link_image = '';
- if ( empty($link_target) )
+ if ( empty( $link_target ) )
$link_target = '';
- if ( empty($link_visible) )
+ if ( empty( $link_visible ) )
$link_visible = 'Y';
- if ( empty($link_owner) )
+ if ( empty( $link_owner ) )
$link_owner = $current_user->id;
- if ( empty($link_notes) )
+ if ( empty( $link_notes ) )
$link_notes = '';
- if ( empty($link_description) )
+ if ( empty( $link_description ) )
$link_description = '';
- if ( empty($link_rss) )
+ if ( empty( $link_rss ) )
$link_rss = '';
- if ( empty($link_rel) )
+ if ( empty( $link_rel ) )
$link_rel = '';
// Make sure we set a valid category
- if (0 == count($link_category) || !is_array($link_category)) {
- $link_category = array(get_option('default_link_category'));
+ if ( ! isset( $link_category ) ||0 == count( $link_category ) || !is_array( $link_category ) ) {
+ $link_category = array( get_option( 'default_link_category' ) );
}
if ( $update ) {
- $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_url = %s,
- link_name = %s, link_image = %s, link_target = %s,
- link_visible = %s, link_description = %s, link_rating = %s,
+ if ( false === $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_url = %s,
+ link_name = %s, link_image = %s, link_target = %s,
+ link_visible = %s, link_description = %s, link_rating = %s,
link_rel = %s, link_notes = %s, link_rss = %s
- WHERE link_id = %s", $link_url, $link_name, $link_image, $link_target, $link_visible, $link_description, $link_rating, $link_rel, $link_notes, $link_rss, $link_id) );
+ WHERE link_id = %s", $link_url, $link_name, $link_image, $link_target, $link_visible, $link_description, $link_rating, $link_rel, $link_notes, $link_rss, $link_id ) ) ) {
+ if ( $wp_error )
+ return new WP_Error( 'db_update_error', __( 'Could not update link in the database' ), $wpdb->last_error );
+ else
+ return 0;
+ }
} else {
- $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
- $link_url,$link_name, $link_image, $link_target, $link_description, $link_visible, $link_owner, $link_rating, $link_rel, $link_notes, $link_rss) );
+ if ( false === $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
+ $link_url,$link_name, $link_image, $link_target, $link_description, $link_visible, $link_owner, $link_rating, $link_rel, $link_notes, $link_rss ) ) ) {
+ if ( $wp_error )
+ return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database' ), $wpdb->last_error );
+ else
+ return 0;
+ }
$link_id = (int) $wpdb->insert_id;
}
- wp_set_link_cats($link_id, $link_category);
+ wp_set_link_cats( $link_id, $link_category );
if ( $update )
- do_action('edit_link', $link_id);
+ do_action( 'edit_link', $link_id );
else
- do_action('add_link', $link_id);
+ do_action( 'add_link', $link_id );
+
+ clean_bookmark_cache( $link_id );
return $link_id;
}
-function wp_set_link_cats($link_id = 0, $link_categories = array()) {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $link_id
+ * @param unknown_type $link_categories
+ */
+function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
// If $link_categories isn't already an array, make it one:
- if (!is_array($link_categories) || 0 == count($link_categories))
- $link_categories = array(get_option('default_link_category'));
+ if ( !is_array( $link_categories ) || 0 == count( $link_categories ) )
+ $link_categories = array( get_option( 'default_link_category' ) );
+
+ $link_categories = array_map( 'intval', $link_categories );
+ $link_categories = array_unique( $link_categories );
- $link_categories = array_map('intval', $link_categories);
- $link_categories = array_unique($link_categories);
+ wp_set_object_terms( $link_id, $link_categories, 'link_category' );
- wp_set_object_terms($link_id, $link_categories, 'link_category');
+ clean_bookmark_cache( $link_id );
} // wp_set_link_cats()
-function wp_update_link($linkdata) {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $linkdata
+ * @return unknown
+ */
+function wp_update_link( $linkdata ) {
$link_id = (int) $linkdata['link_id'];
- $link = get_link($link_id, ARRAY_A);
+ $link = get_link( $link_id, ARRAY_A );
// Escape data pulled from DB.
- $link = add_magic_quotes($link);
+ $link = add_magic_quotes( $link );
// Passed link category list overwrites existing category list if not empty.
- if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])
- && 0 != count($linkdata['link_category']) )
+ if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )
+ && 0 != count( $linkdata['link_category'] ) )
$link_cats = $linkdata['link_category'];
else
$link_cats = $link['link_category'];
// Merge old and new fields with new fields overwriting old ones.
- $linkdata = array_merge($link, $linkdata);
+ $linkdata = array_merge( $link, $linkdata );
$linkdata['link_category'] = $link_cats;
- return wp_insert_link($linkdata);
+ return wp_insert_link( $linkdata );
}
-?>
\ No newline at end of file
+?>
* @link http://www.phpclasses.org/browse/package/1743.html Site
* @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
*/
+
+/**
+ * FTP implementation using fsockopen to connect.
+ *
+ * @package PemFTP
+ * @subpackage Pure
+ * @since 2.5
+ *
+ * @version 1.0
+ * @copyright Alexey Dotsenko
+ * @author Alexey Dotsenko
+ * @link http://www.phpclasses.org/browse/package/1743.html Site
+ * @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
+ */
class ftp extends ftp_base {
function ftp($verb=FALSE, $le=FALSE) {
}
}
}
+
?>
* @link http://www.phpclasses.org/browse/package/1743.html Site
* @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
*/
+
+/**
+ * Socket Based FTP implementation
+ *
+ * @package PemFTP
+ * @subpackage Socket
+ * @since 2.5
+ *
+ * @version 1.0
+ * @copyright Alexey Dotsenko
+ * @author Alexey Dotsenko
+ * @link http://www.phpclasses.org/browse/package/1743.html Site
+ * @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
+ */
class ftp extends ftp_base {
function ftp($verb=FALSE, $le=FALSE) {
* @link http://www.phpclasses.org/browse/package/1743.html Site
* @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
*/
+
+/**
+ * Defines the newline characters, if not defined already.
+ *
+ * This can be redefined.
+ *
+ * @since 2.5
+ * @var string
+ */
if(!defined('CRLF')) define('CRLF',"\r\n");
+
+/**
+ * Sets whatever to autodetect ASCII mode.
+ *
+ * This can be redefined.
+ *
+ * @since 2.5
+ * @var int
+ */
if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1);
+
+/**
+ *
+ * This can be redefined.
+ * @since 2.5
+ * @var int
+ */
if(!defined("FTP_BINARY")) define("FTP_BINARY", 1);
+
+/**
+ *
+ * This can be redefined.
+ * @since 2.5
+ * @var int
+ */
if(!defined("FTP_ASCII")) define("FTP_ASCII", 0);
-if(!defined('FTP_FORCE')) define('FTP_FORCE', TRUE);
+
+/**
+ * Whether to force FTP.
+ *
+ * This can be redefined.
+ *
+ * @since 2.5
+ * @var bool
+ */
+if(!defined('FTP_FORCE')) define('FTP_FORCE', true);
+
+/**
+ * @since 2.5
+ * @var string
+ */
define('FTP_OS_Unix','u');
+
+/**
+ * @since 2.5
+ * @var string
+ */
define('FTP_OS_Windows','w');
+
+/**
+ * @since 2.5
+ * @var string
+ */
define('FTP_OS_Mac','m');
+/**
+ * PemFTP base class
+ *
+ */
class ftp_base {
/* Public variables */
var $LocalEcho;
$prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : '';
if(!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE;
}
+
require_once "class-ftp-".($mod_sockets?"sockets":"pure").".php";
?>
<?php
-// --------------------------------------------------------------------------------
-// PhpConcept Library - Zip Module 2.5
-// --------------------------------------------------------------------------------
-// License GNU/LGPL - Vincent Blavet - March 2006
-// http://www.phpconcept.net
-// --------------------------------------------------------------------------------
-//
-// Presentation :
-// PclZip is a PHP library that manage ZIP archives.
-// So far tests show that archives generated by PclZip are readable by
-// WinZip application and other tools.
-//
-// Description :
-// See readme.txt and http://www.phpconcept.net
-//
-// Warning :
-// This library and the associated files are non commercial, non professional
-// work.
-// It should not have unexpected results. However if any damage is caused by
-// this software the author can not be responsible.
-// The use of this software is at the risk of the user.
-//
-// --------------------------------------------------------------------------------
-// $Id: pclzip.lib.php,v 1.44 2006/03/08 21:23:59 vblavet Exp $
-// --------------------------------------------------------------------------------
-
- // ----- Constants
- define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
-
- // ----- File list separator
- // In version 1.x of PclZip, the separator for file list is a space
- // (which is not a very smart choice, specifically for windows paths !).
- // A better separator should be a comma (,). This constant gives you the
- // abilty to change that.
- // However notice that changing this value, may have impact on existing
- // scripts, using space separated filenames.
- // Recommanded values for compatibility with older versions :
- //define( 'PCLZIP_SEPARATOR', ' ' );
- // Recommanded values for smart separation of filenames.
- define( 'PCLZIP_SEPARATOR', ',' );
-
- // ----- Error configuration
- // 0 : PclZip Class integrated error handling
- // 1 : PclError external library error handling. By enabling this
- // you must ensure that you have included PclError library.
- // [2,...] : reserved for futur use
- define( 'PCLZIP_ERROR_EXTERNAL', 0 );
+/**
+ * PhpConcept Library - Zip Module 2.5
+ *
+ * Presentation :
+ * PclZip is a PHP library that manage ZIP archives.
+ * So far tests show that archives generated by PclZip are readable by
+ * WinZip application and other tools.
+ *
+ * Warning :
+ * This library and the associated files are non commercial, non professional
+ * work.
+ * It should not have unexpected results. However if any damage is caused by
+ * this software the author can not be responsible.
+ * The use of this software is at the risk of the user.
+ *
+ * @package External
+ * @subpackage PclZip
+ *
+ * @license License GNU/LGPL
+ * @copyright March 2006 Vincent Blavet
+ * @author Vincent Blavet
+ * @link http://www.phpconcept.net
+ * @version $Id: pclzip.lib.php,v 1.44 2006/03/08 21:23:59 vblavet Exp $
+ */
+
+/**
+ * The read block size for reading zip files.
+ *
+ * @since 2.5
+ */
+define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
+
+/**
+ * File list separator
+ *
+ * In version 1.x of PclZip, the separator for file list is a space(which is not
+ * a very smart choice, specifically for windows paths !). A better separator
+ * should be a comma (,). This constant gives you the abilty to change that.
+ *
+ * However notice that changing this value, may have impact on existing scripts,
+ * using space separated filenames. Recommanded values for compatibility with
+ * older versions :
+ * <code>define( 'PCLZIP_SEPARATOR', ' ' );</code>
+ * Recommanded values for smart separation of filenames.
+ */
+define( 'PCLZIP_SEPARATOR', ',' );
+
+/**
+ * Error configuration
+ *
+ * 0 : PclZip Class integrated error handling
+ * 1 : PclError external library error handling. By enabling this you must
+ * ensure that you have included PclError library.
+ * [2,...] : reserved for future use
+ */
+define( 'PCLZIP_ERROR_EXTERNAL', 0 );
// ----- Optional static temporary directory
// By default temporary files are generated in the script current
define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
define( 'PCLZIP_CB_PRE_ADD', 78003 );
define( 'PCLZIP_CB_POST_ADD', 78004 );
- /* For futur use
+ /* For future use
define( 'PCLZIP_CB_PRE_LIST', 78005 );
define( 'PCLZIP_CB_POST_LIST', 78006 );
define( 'PCLZIP_CB_PRE_DELETE', 78007 );
<?php
-class WP_Filesystem_Base{
+/**
+ * Base WordPress Filesystem.
+ *
+ * @package WordPress
+ * @subpackage Filesystem
+ */
+
+/**
+ * Base WordPress Filesystem class for which Filesystem implementations extend
+ *
+ * @since 2.5
+ */
+class WP_Filesystem_Base {
+ /**
+ * Whether to display debug data for the connection or not.
+ *
+ * @since 2.5
+ * @access public
+ * @var bool
+ */
var $verbose = false;
+ /**
+ * Cached list of local filepaths to maped remote filepaths.
+ *
+ * @since 2.7
+ * @access private
+ * @var array
+ */
var $cache = array();
-
+
+ /**
+ * The Access method of the current connection, Set automatically.
+ *
+ * @since 2.5
+ * @access public
+ * @var string
+ */
var $method = '';
-
+
+ /**
+ * Returns the path on the remote filesystem of ABSPATH
+ *
+ * @since 2.7
+ * @access public
+ * @return string The location of the remote path.
+ */
function abspath() {
- if ( defined('FTP_BASE') && strpos($this->method, 'ftp') !== false )
+ if ( defined('FTP_BASE') && strpos($this->method, 'ftp') !== false )
return FTP_BASE;
- return $this->find_folder(ABSPATH);
+ $folder = $this->find_folder(ABSPATH);
+ //Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
+ if ( ! $folder && $this->is_dir('/wp-includes') )
+ $folder = '/';
+ return $folder;
}
+ /**
+ * Returns the path on the remote filesystem of WP_CONTENT_DIR
+ *
+ * @since 2.7
+ * @access public
+ * @return string The location of the remote path.
+ */
function wp_content_dir() {
- if ( defined('FTP_CONTENT_DIR') && strpos($this->method, 'ftp') !== false )
+ if ( defined('FTP_CONTENT_DIR') && strpos($this->method, 'ftp') !== false )
return FTP_CONTENT_DIR;
return $this->find_folder(WP_CONTENT_DIR);
}
+ /**
+ * Returns the path on the remote filesystem of WP_PLUGIN_DIR
+ *
+ * @since 2.7
+ * @access public
+ *
+ * @return string The location of the remote path.
+ */
function wp_plugins_dir() {
- if ( defined('FTP_PLUGIN_DIR') && strpos($this->method, 'ftp') !== false )
+ if ( defined('FTP_PLUGIN_DIR') && strpos($this->method, 'ftp') !== false )
return FTP_PLUGIN_DIR;
return $this->find_folder(WP_PLUGIN_DIR);
}
+ /**
+ * Returns the path on the remote filesystem of the Themes Directory
+ *
+ * @since 2.7
+ * @access public
+ *
+ * @return string The location of the remote path.
+ */
function wp_themes_dir() {
return $this->wp_content_dir() . '/themes';
}
- //Back compat: use abspath() or wp_*_dir
+
+ /**
+ * Locates a folder on the remote filesystem.
+ *
+ * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
+ *
+ * @since 2.5
+ * @deprecated 2.7
+ * @access public
+ *
+ * @param string $base The folder to start searching from
+ * @param bool $echo True to display debug information
+ * @return string The location of the remote path.
+ */
function find_base_dir($base = '.', $echo = false) {
+ _deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
$this->verbose = $echo;
return $this->abspath();
}
- //Back compat: use ::abspath() or ::wp_*_dir
+ /**
+ * Locates a folder on the remote filesystem.
+ *
+ * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
+ *
+ * @since 2.5
+ * @deprecated 2.7
+ * @access public
+ *
+ * @param string $base The folder to start searching from
+ * @param bool $echo True to display debug information
+ * @return string The location of the remote path.
+ */
function get_base_dir($base = '.', $echo = false) {
+ _deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
$this->verbose = $echo;
return $this->abspath();
}
-
+
+ /**
+ * Locates a folder on the remote filesystem.
+ *
+ * Assumes that on Windows systems, Stripping off the Drive letter is OK
+ * Sanitizes \\ to / in windows filepaths.
+ *
+ * @since 2.7
+ * @access public
+ *
+ * @param string $folder the folder to locate
+ * @return string The location of the remote path.
+ */
function find_folder($folder) {
- $folder = str_replace('\\', '/', $folder); //Windows Sanitiation
+
+ $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); //Strip out windows driveletter if its there.
+ $folder = str_replace('\\', '/', $folder); //Windows path sanitiation
+
if ( isset($this->cache[ $folder ] ) )
return $this->cache[ $folder ];
$this->cache[ $folder ] = $return;
return $return;
}
-
- // Assumes $folder is windows sanitized;
- // Assumes that the drive letter is safe to be stripped off, Should not be a problem for windows servers.
+
+ /**
+ * Locates a folder on the remote filesystem.
+ *
+ * Expects Windows sanitized path
+ *
+ * @since 2.7
+ * @access private
+ *
+ * @param string $folder the folder to locate
+ * @param string $base the folder to start searching from
+ * @param bool $loop if the function has recursed, Internal use only
+ * @return string The location of the remote path.
+ */
function search_for_folder($folder, $base = '.', $loop = false ) {
if ( empty( $base ) || '.' == $base )
$base = trailingslashit($this->cwd());
-
- $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); //Strip out windows driveletter if its there.
-
+
+ $folder = untrailingslashit($folder);
+
$folder_parts = explode('/', $folder);
$last_path = $folder_parts[ count($folder_parts) - 1 ];
-
+
$files = $this->dirlist( $base );
-
+
foreach ( $folder_parts as $key ) {
if ( $key == $last_path )
continue; //We want this to be caught by the next code block.
- //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
- // If its found, change into it and follow through looking for it.
+ //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
+ // If its found, change into it and follow through looking for it.
// If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on.
// If it reaches the end, and still cant find it, it'll return false for the entire function.
if( isset($files[ $key ]) ){
return $ret;
}
}
-
+
//Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take.
if(isset( $files[ $last_path ] ) ) {
if( $this->verbose )
if( $loop )
return false;//Prevent tihs function looping again.
//As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups.
- return $this->search_for_folder($folder, '/', true);
-
+ return $this->search_for_folder($folder, '/', true);
+
}
-
- //Common Helper functions.
+
+ /**
+ * Returns the *nix style file permissions for a file
+ *
+ * From the PHP documentation page for fileperms()
+ *
+ * @link http://docs.php.net/fileperms
+ * @since 2.5
+ * @access public
+ *
+ * @param string $file string filename
+ * @return int octal representation of permissions
+ */
function gethchmod($file){
- //From the PHP.net page for ...?
$perms = $this->getchmod($file);
if (($perms & 0xC000) == 0xC000) // Socket
$info = 's';
(($perms & 0x0200) ? 'T' : '-'));
return $info;
}
+
+ /**
+ * Converts *nix style file permissions to a octal number.
+ *
+ * Converts '-rw-r--r--' to 0644
+ * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
+ *
+ * @link http://docs.php.net/manual/en/function.chmod.php#49614
+ * @since 2.5
+ * @access public
+ *
+ * @param string $mode string *nix style file permission
+ * @return int octal representation
+ */
function getnumchmodfromh($mode) {
- $realmode = "";
- $legal = array("", "w", "r", "x", "-");
- $attarray = preg_split("//", $mode);
+ $realmode = '';
+ $legal = array('', 'w', 'r', 'x', '-');
+ $attarray = preg_split('//', $mode);
for($i=0; $i < count($attarray); $i++)
if($key = array_search($attarray[$i], $legal))
$realmode .= $legal[$key];
-
+
$mode = str_pad($realmode, 9, '-');
$trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1');
$mode = strtr($mode,$trans);
-
+
$newmode = '';
$newmode .= $mode[0] + $mode[1] + $mode[2];
$newmode .= $mode[3] + $mode[4] + $mode[5];
$newmode .= $mode[6] + $mode[7] + $mode[8];
return $newmode;
}
+
+ /**
+ * Determines if the string provided contains binary characters.
+ *
+ * @since 2.7
+ * @access private
+ *
+ * @param string $text String to test against
+ * @return bool true if string is binary, false otherwise
+ */
+ function is_binary( $text ) {
+ return (bool) preg_match('|[^\x20-\x7E]|', $text); //chr(32)..chr(127)
+ }
}
+
?>
<?php
+/**
+ * WordPress Direct Filesystem.
+ *
+ * @package WordPress
+ * @subpackage Filesystem
+ */
+/**
+ * WordPress Filesystem Class for direct PHP file and folder manipulation.
+ *
+ * @since 2.5
+ * @package WordPress
+ * @subpackage Filesystem
+ * @uses WP_Filesystem_Base Extends class
+ */
class WP_Filesystem_Direct extends WP_Filesystem_Base {
var $permission = null;
var $errors = array();
return false;
$ret = array();
- $dir = dir($path);
+ $dir = @dir($path);
+ if ( ! $dir )
+ return false;
while (false !== ($entry = $dir->read()) ) {
$struc = array();
$struc['name'] = $entry;
<?php
-class WP_Filesystem_FTPext extends WP_Filesystem_Base{
+/**
+ * WordPress FTP Filesystem.
+ *
+ * @package WordPress
+ * @subpackage Filesystem
+ */
+
+/**
+ * WordPress Filesystem Class for implementing FTP.
+ *
+ * @since 2.5
+ * @package WordPress
+ * @subpackage Filesystem
+ * @uses WP_Filesystem_Base Extends class
+ */
+class WP_Filesystem_FTPext extends WP_Filesystem_Base {
var $link;
var $timeout = 5;
var $errors = array();
var $permission = null;
- var $filetypes = array(
- 'php'=>FTP_ASCII,
- 'css'=>FTP_ASCII,
- 'txt'=>FTP_ASCII,
- 'js'=>FTP_ASCII,
- 'html'=>FTP_ASCII,
- 'htm'=>FTP_ASCII,
- 'xml'=>FTP_ASCII,
-
- 'jpg'=>FTP_BINARY,
- 'png'=>FTP_BINARY,
- 'gif'=>FTP_BINARY,
- 'bmp'=>FTP_BINARY
- );
-
function WP_Filesystem_FTPext($opt='') {
$this->method = 'ftpext';
$this->errors = new WP_Error();
else
$this->options['password'] = $opt['password'];
- $this->options['ssl'] = ( !empty($opt['ssl']) );
+ $this->options['ssl'] = false;
+ if ( isset($opt['ssl']) )
+ $this->options['ssl'] = ( !empty($opt['ssl']) );
+ elseif ( isset( $opt['connection_type']) )
+ $this->options['ssl'] = ( 'ftps' == $opt['connection_type'] );
}
function connect() {
return false;
}
+ //Set the Connection to use Passive FTP
+ @ftp_pasv( $this->link, true );
+
return true;
}
function setDefaultPermissions($perm) {
$this->permission = $perm;
}
-
+
function get_contents($file, $type = '', $resumepos = 0 ){
- if( empty($type) ){
- $extension = substr(strrchr($file, "."), 1);
- $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII;
- }
+ if( empty($type) )
+ $type = FTP_BINARY;
+
$temp = tmpfile();
if ( ! $temp )
return false;
+
if( ! @ftp_fget($this->link, $temp, $file, $type, $resumepos) )
return false;
+
fseek($temp, 0); //Skip back to the start of the file being written to
$contents = '';
- while (!feof($temp)) {
+
+ while ( ! feof($temp) )
$contents .= fread($temp, 8192);
- }
+
fclose($temp);
return $contents;
}
return explode("\n", $this->get_contents($file));
}
function put_contents($file, $contents, $type = '' ) {
- if( empty($type) ) {
- $extension = substr(strrchr($file, "."), 1);
- $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII;
- }
+ if( empty($type) )
+ $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII;
+
$temp = tmpfile();
if ( ! $temp )
return false;
+
fwrite($temp, $contents);
fseek($temp, 0); //Skip back to the start of the file being written to
+
$ret = @ftp_fput($this->link, $file, $temp, $type);
+
fclose($temp);
return $ret;
}
function cwd() {
- $cwd = ftp_pwd($this->link);
+ $cwd = @ftp_pwd($this->link);
if( $cwd )
$cwd = trailingslashit($cwd);
return $cwd;
<?php
+/**
+ * WordPress FTP Sockets Filesystem.
+ *
+ * @package WordPress
+ * @subpackage Filesystem
+ */
+
+/**
+ * WordPress Filesystem Class for implementing FTP Sockets.
+ *
+ * @since 2.5
+ * @package WordPress
+ * @subpackage Filesystem
+ * @uses WP_Filesystem_Base Extends class
+ */
class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
var $ftp = false;
var $timeout = 5;
var $permission = null;
- var $filetypes = array(
- 'php' => FTP_ASCII,
- 'css' => FTP_ASCII,
- 'txt' => FTP_ASCII,
- 'js' => FTP_ASCII,
- 'html'=> FTP_ASCII,
- 'htm' => FTP_ASCII,
- 'xml' => FTP_ASCII,
-
- 'jpg' => FTP_BINARY,
- 'png' => FTP_BINARY,
- 'gif' => FTP_BINARY,
- 'bmp' => FTP_BINARY
- );
-
- function WP_Filesystem_ftpsockets($opt='') {
+ function WP_Filesystem_ftpsockets($opt = '') {
$this->method = 'ftpsockets';
$this->errors = new WP_Error();
$this->permission = $perm;
}
- function get_contents($file, $type = '', $resumepos = 0){
+ function get_contents($file, $type = '', $resumepos = 0) {
if( ! $this->exists($file) )
return false;
- if( empty($type) ){
- $extension = substr(strrchr($file, '.'), 1);
- $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_AUTOASCII;
- }
+ if( empty($type) )
+ $type = FTP_AUTOASCII;
$this->ftp->SetType($type);
+
$temp = wp_tempnam( $file );
+
if ( ! $temphandle = fopen($temp, 'w+') )
return false;
+
if ( ! $this->ftp->fget($temphandle, $file) ) {
fclose($temphandle);
unlink($temp);
return ''; //Blank document, File does exist, Its just blank.
}
+
fseek($temphandle, 0); //Skip back to the start of the file being written to
$contents = '';
+
while ( ! feof($temphandle) )
$contents .= fread($temphandle, 8192);
+
fclose($temphandle);
unlink($temp);
return $contents;
}
- function get_contents_array($file){
+ function get_contents_array($file) {
return explode("\n", $this->get_contents($file) );
}
function put_contents($file, $contents, $type = '' ) {
- if( empty($type) ){
- $extension = substr(strrchr($file, '.'), 1);
- $type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_AUTOASCII;
- }
+ if( empty($type) )
+ $type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII;
+
$this->ftp->SetType($type);
$temp = wp_tempnam( $file );
if ( ! $temphandle = fopen($temp, 'w+') ){
- unlink($temp);
+ unlink($temp);
return false;
}
+
fwrite($temphandle, $contents);
fseek($temphandle, 0); //Skip back to the start of the file being written to
+
$ret = $this->ftp->fput($file, $temphandle);
+
fclose($temphandle);
unlink($temp);
return $ret;
function chdir($file) {
return $this->ftp->chdir($file);
}
-
+
function chgrp($file, $group, $recursive = false ) {
return false;
}
- function chmod($file, $mode = false, $recursive = false ){
+ function chmod($file, $mode = false, $recursive = false ) {
if( ! $mode )
$mode = $this->permission;
if( ! $mode )
return $this->ftp->filesize($file);
}
- function touch($file, $time = 0, $atime = 0 ){
+ function touch($file, $time = 0, $atime = 0 ) {
return false;
}
return $ret;
}
- function __destruct(){
+ function __destruct() {
$this->ftp->quit();
}
}
+
?>
--- /dev/null
+<?php
+/**
+ * WordPress SSH2 Filesystem.
+ *
+ * @package WordPress
+ * @subpackage Filesystem
+ */
+
+/**
+ * WordPress Filesystem Class for implementing SSH2.
+ *
+ * To use this class you must follow these steps for PHP 5.2.6+
+ *
+ * @contrib http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/ - Installation Notes
+ *
+ * Complie libssh2 (Note: Only 0.14 is officaly working with PHP 5.2.6+ right now.)
+ *
+ * cd /usr/src
+ * wget http://surfnet.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.14.tar.gz
+ * tar -zxvf libssh2-0.14.tar.gz
+ * cd libssh2-0.14/
+ * ./configure
+ * make all install
+ *
+ * Note: No not leave the directory yet!
+ *
+ * Enter: pecl install -f ssh2
+ *
+ * Copy the ssh.so file it creates to your PHP Module Directory.
+ * Open up your PHP.INI file and look for where extensions are placed.
+ * Add in your PHP.ini file: extension=ssh2.so
+ *
+ * Restart Apache!
+ * Check phpinfo() streams to confirm that: ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp exist.
+ *
+ *
+ * @since 2.7
+ * @package WordPress
+ * @subpackage Filesystem
+ * @uses WP_Filesystem_Base Extends class
+ */
+class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
+
+ var $debugtest = false; // set this to true only if your a debuging your connection
+
+ var $link = null;
+ var $sftp_link = null;
+ var $keys = false;
+ /*
+ * This is the timeout value for ssh results to comeback.
+ * Slower servers might need this incressed, but this number otherwise should not change.
+ *
+ * @parm $timeout int
+ *
+ */
+ var $timeout = 15;
+ var $errors = array();
+ var $options = array();
+
+ var $permission = 0644;
+
+ function WP_Filesystem_SSH2($opt='') {
+ $this->method = 'ssh2';
+ $this->errors = new WP_Error();
+
+ //Check if possible to use ssh2 functions.
+ if ( ! extension_loaded('ssh2') ) {
+ $this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available'));
+ return false;
+ }
+
+ // Set defaults:
+ if ( empty($opt['port']) )
+ $this->options['port'] = 22;
+ else
+ $this->options['port'] = $opt['port'];
+
+ if ( empty($opt['hostname']) )
+ $this->errors->add('empty_hostname', __('SSH2 hostname is required'));
+ else
+ $this->options['hostname'] = $opt['hostname'];
+
+ if ( isset($opt['base']) && ! empty($opt['base']) )
+ $this->wp_base = $opt['base'];
+
+ // Check if the options provided are OK.
+ if ( empty ($opt['username']) )
+ $this->errors->add('empty_username', __('SSH2 username is required'));
+ else
+ $this->options['username'] = $opt['username'];
+
+ if ( ( !empty ($opt['public_key']) ) && ( !empty ($opt['private_key']) ) ) {
+ $this->options['public_key'] = $opt['public_key'];
+ $this->options['private_key'] = $opt['private_key'];
+
+ $this->options['hostkey'] = array("hostkey" => "ssh-rsa");
+
+ $this->keys = true;
+ }
+
+
+ if ( empty ($opt['password']) ) {
+ if ( !$this->keys ) // password can be blank if we are using keys
+ $this->errors->add('empty_password', __('SSH2 password is required'));
+ } else {
+ $this->options['password'] = $opt['password'];
+ }
+
+ }
+
+ function connect() {
+ $this->debug("connect();");
+
+ if ( ! $this->keys ) {
+ $this->link = @ssh2_connect($this->options['hostname'], $this->options['port']);
+ } else {
+ $this->link = @ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']);
+ }
+
+ if ( ! $this->link ) {
+ $this->errors->add('connect', sprintf(__('Failed to connect to SSH2 Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
+ return false;
+ }
+
+ if ( !$this->keys ) {
+ if ( ! @ssh2_auth_password($this->link, $this->options['username'], $this->options['password']) ) {
+ $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
+ return false;
+ }
+ } else {
+ if ( ! @ssh2_auth_pubkey_file($this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'], $this->options['password'] ) ) {
+ $this->errors->add('auth', sprintf(__('Public and Private keys incorrent for %s'), $this->options['username']));
+ return false;
+ }
+ }
+
+ $this->sftp_link = ssh2_sftp($this->link);
+
+ return true;
+ }
+
+ function run_command($link, $command, $returnbool = false) {
+ $this->debug("run_command();");
+ if(!($stream = @ssh2_exec( $link, $command . "; echo \"__COMMAND_FINISHED__\";"))) {
+ $this->errors->add('command', sprintf(__('Unable to perform command: %s'), $command));
+ } else {
+ stream_set_blocking( $stream, true );
+ $time_start = time();
+ $data = null;
+ while( true ) {
+ if (strpos($data,"__COMMAND_FINISHED__") !== false){
+ break; // the command has finshed!
+ }
+ if( (time()-$time_start) > $this->timeout ){
+ $this->errors->add('command', sprintf(__('Connection to the server has timeout after %s seconds.'), $this->timeout));
+ unset($this->link);
+ unset($this->sftp_link); // close connections
+ return false;
+ }
+ while( $buf = fread( $stream, strlen($stream) ) )
+ $data .= $buf;
+ }
+ fclose($stream);
+ $data = trim(str_replace("__COMMAND_FINISHED__", "", $data));
+ if (($returnbool) && ( (int) $data )) {
+ return true;
+ } elseif (($returnbool) && (! (int) $data )) {
+ return false;
+ } else {
+ return $data;
+ }
+ }
+ return false;
+ }
+
+ function debug($text)
+ {
+ if ($this->debugtest)
+ {
+ echo "<br/>" . $text . "<br/>";
+ }
+ }
+
+ function setDefaultPermissions($perm) {
+ $this->debug("setDefaultPermissions();");
+ if ( $perm )
+ $this->permission = $perm;
+ }
+
+ function get_contents($file, $type = '', $resumepos = 0 ) {
+ $this->debug("get_contents();");
+ $tempfile = wp_tempnam( $file );
+ if ( ! $tempfile )
+ return false;
+ if( ! ssh2_scp_recv($this->link, $file, $tempfile) )
+ return false;
+ $contents = file_get_contents($tempfile);
+ unlink($tempfile);
+ return $contents;
+ }
+
+ function get_contents_array($file) {
+ $this->debug("get_contents_array();");
+ return explode("\n", $this->get_contents($file));
+ }
+
+ function put_contents($file, $contents, $type = '' ) {
+ $this->debug("put_contents($file);");
+ $tempfile = wp_tempnam( $file );
+ $temp = fopen($tempfile, 'w');
+ if ( ! $temp )
+ return false;
+ fwrite($temp, $contents);
+ fclose($temp);
+ $ret = ssh2_scp_send($this->link, $tempfile, $file, $this->permission);
+ unlink($tempfile);
+ return $ret;
+ }
+
+ function cwd() {
+ $this->debug("cwd();");
+ $cwd = $this->run_command($this->link, 'pwd');
+ if( $cwd )
+ $cwd = trailingslashit($cwd);
+ return $cwd;
+ }
+
+ function chdir($dir) {
+ $this->debug("chdir();");
+ return $this->run_command($this->link, 'cd ' . $dir, true);
+ }
+
+ function chgrp($file, $group, $recursive = false ) {
+ $this->debug("chgrp();");
+ if ( ! $this->exists($file) )
+ return false;
+ if ( ! $recursive || ! $this->is_dir($file) )
+ return $this->run_command($this->link, sprintf('chgrp %o %s', $mode, $file), true);
+ return $this->run_command($this->link, sprintf('chgrp -R %o %s', $mode, $file), true);
+ }
+
+ function chmod($file, $mode = false, $recursive = false) {
+ $this->debug("chmod();");
+ if( ! $mode )
+ $mode = $this->permission;
+ if( ! $mode )
+ return false;
+ if ( ! $this->exists($file) )
+ return false;
+ if ( ! $recursive || ! $this->is_dir($file) )
+ return $this->run_command($this->link, sprintf('chmod %o %s', $mode, $file), true);
+ return $this->run_command($this->link, sprintf('chmod -R %o %s', $mode, $file), true);
+ }
+
+ function chown($file, $owner, $recursive = false ) {
+ $this->debug("chown();");
+ if ( ! $this->exists($file) )
+ return false;
+ if ( ! $recursive || ! $this->is_dir($file) )
+ return $this->run_command($this->link, sprintf('chown %o %s', $mode, $file), true);
+ return $this->run_command($this->link, sprintf('chown -R %o %s', $mode, $file), true);
+ }
+
+ function owner($file) {
+ $this->debug("owner();");
+ $dir = $this->dirlist($file);
+ return $dir[$file]['owner'];
+ }
+
+ function getchmod($file) {
+ $this->debug("getchmod();");
+ $dir = $this->dirlist($file);
+ return $dir[$file]['permsn'];
+ }
+
+ function group($file) {
+ $this->debug("group();");
+ $dir = $this->dirlist($file);
+ return $dir[$file]['group'];
+ }
+
+ function copy($source, $destination, $overwrite = false ) {
+ $this->debug("copy();");
+ if( ! $overwrite && $this->exists($destination) )
+ return false;
+ $content = $this->get_contents($source);
+ if( false === $content)
+ return false;
+ return $this->put_contents($destination, $content);
+ }
+
+ function move($source, $destination, $overwrite = false) {
+ $this->debug("move();");
+ return @ssh2_sftp_rename($this->link, $source, $destination);
+ }
+
+ function delete($file, $recursive = false) {
+ $this->debug("delete();");
+ if ( $this->is_file($file) )
+ return ssh2_sftp_unlink($this->sftp_link, $file);
+ if ( ! $recursive )
+ return ssh2_sftp_rmdir($this->sftp_link, $file);
+ $filelist = $this->dirlist($file);
+ if ( is_array($filelist) ) {
+ foreach ( $filelist as $filename => $fileinfo) {
+ $this->delete($file . '/' . $filename, $recursive);
+ }
+ }
+ return ssh2_sftp_rmdir($this->sftp_link, $file);
+ }
+
+ function exists($file) {
+ $this->debug("exists();");
+ return $this->run_command($this->link, sprintf('ls -lad %s', $file), true);
+ }
+
+ function is_file($file) {
+ $this->debug("is_file();");
+ //DO NOT RELY ON dirlist()!
+ $list = $this->run_command($this->link, sprintf('ls -lad %s', $file));
+ $list = $this->parselisting($list);
+ if ( ! $list )
+ return false;
+ else
+ return ( !$list['isdir'] && !$list['islink'] ); //ie. not a file or link, yet exists, must be file.
+ }
+
+ function is_dir($path) {
+ $this->debug("is_dir();");
+ //DO NOT RELY ON dirlist()!
+ $list = $this->parselisting($this->run_command($this->link, sprintf('ls -lad %s', untrailingslashit($path))));
+ if ( ! $list )
+ return false;
+ else
+ return $list['isdir'];
+ }
+
+ function is_readable($file) {
+ //Not implmented.
+ }
+
+ function is_writable($file) {
+ //Not implmented.
+ }
+
+ function atime($file) {
+ //Not implmented.
+ }
+
+ function mtime($file) {
+ //Not implmented.
+ }
+
+ function size($file) {
+ //Not implmented.
+ }
+
+ function touch($file, $time = 0, $atime = 0) {
+ //Not implmented.
+ }
+
+ function mkdir($path, $chmod = null, $chown = false, $chgrp = false) {
+ $this->debug("mkdir();");
+ $path = untrailingslashit($path);
+ if( ! ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true) )
+ return false;
+ if( $chown )
+ $this->chown($path, $chown);
+ if( $chgrp )
+ $this->chgrp($path, $chgrp);
+ return true;
+ }
+
+ function rmdir($path, $recursive = false) {
+ $this->debug("rmdir();");
+ return $this->delete($path, $recursive);
+ }
+
+ function parselisting($line) {
+ $this->debug("parselisting();");
+ $is_windows = ($this->OS_remote == FTP_OS_Windows);
+ if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/", $line, $lucifer)) {
+ $b = array();
+ if ($lucifer[3]<70) { $lucifer[3] +=2000; } else { $lucifer[3]+=1900; } // 4digit year fix
+ $b['isdir'] = ($lucifer[7]=="<DIR>");
+ if ( $b['isdir'] )
+ $b['type'] = 'd';
+ else
+ $b['type'] = 'f';
+ $b['size'] = $lucifer[7];
+ $b['month'] = $lucifer[1];
+ $b['day'] = $lucifer[2];
+ $b['year'] = $lucifer[3];
+ $b['hour'] = $lucifer[4];
+ $b['minute'] = $lucifer[5];
+ $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]);
+ $b['am/pm'] = $lucifer[6];
+ $b['name'] = $lucifer[8];
+ } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) {
+ //echo $line."\n";
+ $lcount=count($lucifer);
+ if ($lcount<8) return '';
+ $b = array();
+ $b['isdir'] = $lucifer[0]{0} === "d";
+ $b['islink'] = $lucifer[0]{0} === "l";
+ if ( $b['isdir'] )
+ $b['type'] = 'd';
+ elseif ( $b['islink'] )
+ $b['type'] = 'l';
+ else
+ $b['type'] = 'f';
+ $b['perms'] = $lucifer[0];
+ $b['number'] = $lucifer[1];
+ $b['owner'] = $lucifer[2];
+ $b['group'] = $lucifer[3];
+ $b['size'] = $lucifer[4];
+ if ($lcount==8) {
+ sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']);
+ sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']);
+ $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']);
+ $b['name'] = $lucifer[7];
+ } else {
+ $b['month'] = $lucifer[5];
+ $b['day'] = $lucifer[6];
+ if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) {
+ $b['year'] = date("Y");
+ $b['hour'] = $l2[1];
+ $b['minute'] = $l2[2];
+ } else {
+ $b['year'] = $lucifer[7];
+ $b['hour'] = 0;
+ $b['minute'] = 0;
+ }
+ $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute']));
+ $b['name'] = $lucifer[8];
+ }
+ }
+
+ return $b;
+ }
+
+ function dirlist($path = '.', $incdot = false, $recursive = false) {
+ $this->debug("dirlist();");
+ if( $this->is_file($path) ) {
+ $limitFile = basename($path);
+ $path = trailingslashit(dirname($path));
+ } else {
+ $limitFile = false;
+ }
+
+ $list = $this->run_command($this->link, sprintf('ls -la %s', $path));
+
+ if ( $list === false )
+ return false;
+
+ $list = explode("\n", $list);
+
+ $dirlist = array();
+ foreach ( (array)$list as $k => $v ) {
+ $entry = $this->parselisting($v);
+ if ( empty($entry) )
+ continue;
+
+ if ( '.' == $entry['name'] || '..' == $entry['name'] )
+ continue;
+
+ $dirlist[ $entry['name'] ] = $entry;
+ }
+
+ if ( ! $dirlist )
+ return false;
+
+ if ( empty($dirlist) )
+ return array();
+
+ $ret = array();
+ foreach ( $dirlist as $struc ) {
+
+ if ( 'd' == $struc['type'] ) {
+ $struc['files'] = array();
+
+ if ( $incdot ){
+ //We're including the doted starts
+ if( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder
+ if ($recursive)
+ $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive);
+ }
+ } else { //No dots
+ if ( $recursive )
+ $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive);
+ }
+ }
+ //File
+ $ret[$struc['name']] = $struc;
+ }
+ return $ret;
+ }
+ function __destruct() {
+ $this->debug("__destruct();");
+ if ( $this->link )
+ unset($this->link);
+ if ( $this->sftp_link )
+ unset($this->sftp_link);
+ }
+}
+
+?>
<?php
-
+/**
+ * WordPress Comment Administration API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ * @uses $wpdb
+ *
+ * @param string $comment_author
+ * @param string $comment_date
+ * @return mixed Comment ID on success.
+ */
function comment_exists($comment_author, $comment_date) {
global $wpdb;
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 (!empty ( $_POST['edit_date'] ) ) {
$aa = $_POST['aa'];
$mm = $_POST['mm'];
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;
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;
return $pending_keyed;
}
-// Add avatars to relevant places in admin, or try to
-
+/**
+ * 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;
return "$avatar $name";
}
+function enqueue_comment_hotkeys_js() {
+ if ( 'true' == get_user_option( 'comment_shortcuts' ) )
+ wp_enqueue_script( 'jquery-table-hotkeys' );
+}
+
if ( is_admin() && ('edit-comments.php' == $pagenow || 'edit.php' == $pagenow) ) {
if ( get_option('show_avatars') )
add_filter( 'comment_author', 'floated_admin_avatar' );
<?php
-
-// Registers dashboard widgets, handles POST data, sets up filters
+/**
+ * WordPress Dashboard Widget Administration Panel API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Registers dashboard widgets.
+ *
+ * handles POST data, sets up filters.
+ *
+ * @since unknown
+ */
function wp_dashboard_setup() {
- global $wpdb, $wp_dashboard_sidebars;
+ global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
+ $wp_dashboard_control_callbacks = array();
+
$update = false;
$widget_options = get_option( 'dashboard_widget_options' );
if ( !$widget_options || !is_array($widget_options) )
$widget_options = array();
-
- /* Register WP Dashboard Dynamic Sidebar */
- register_sidebar( array(
- 'name' => 'WordPress Dashboard',
- 'id' => 'wp_dashboard',
- 'before_widget' => "\t<div class='dashboard-widget-holder %2\$s' id='%1\$s'>\n\n\t\t<div class='dashboard-widget'>\n\n",
- 'after_widget' => "\t\t</div>\n\n\t</div>\n\n",
- 'before_title' => "\t\t\t<h3 class='dashboard-widget-title'>",
- 'after_title' => "</h3>\n\n"
- ) );
-
-
/* Register Widgets and Controls */
+ // Right Now
+ wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
+
// Recent Comments Widget
- $mod_comments = wp_count_comments();
- $mod_comments = $mod_comments->moderated;
- if ( current_user_can( 'moderate_comments' ) && $mod_comments ) {
- $notice = sprintf( __ngettext( '%d comment awaiting moderation', '%d comments awaiting moderation', $mod_comments ), $mod_comments );
- $notice = "<a href='edit-comments.php?comment_status=moderated'>$notice</a>";
- } else {
- $notice = '';
- }
- wp_register_sidebar_widget( 'dashboard_recent_comments', __( 'Recent Comments' ), 'wp_dashboard_recent_comments',
- array( 'all_link' => 'edit-comments.php', 'notice' => $notice, 'width' => 'half' )
- );
+ $recent_comments_title = __( 'Recent Comments' );
+ wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments' );
// Incoming Links Widget
if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
'home' => get_option('home'),
'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
'url' => apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&ie=utf-8&num=10&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
- 'items' => 5,
- 'show_date' => 0
+ 'items' => isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10,
+ 'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false
);
}
- wp_register_sidebar_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_empty',
- array( 'all_link' => $widget_options['dashboard_incoming_links']['link'], 'feed_link' => $widget_options['dashboard_incoming_links']['url'], 'width' => 'half' ),
- 'wp_dashboard_cached_rss_widget', 'wp_dashboard_incoming_links_output'
- );
- wp_register_widget_control( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_rss_control', array(),
- array( 'widget_id' => 'dashboard_incoming_links', 'form_inputs' => array( 'title' => false, 'show_summary' => false, 'show_author' => false ) )
- );
-
+ wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
// WP Plugins Widget
- wp_register_sidebar_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_empty',
- array( 'all_link' => 'http://wordpress.org/extend/plugins/', 'feed_link' => 'http://wordpress.org/extend/plugins/rss/topics/', 'width' => 'half' ),
- 'wp_dashboard_cached_rss_widget', 'wp_dashboard_plugins_output',
- array( 'http://wordpress.org/extend/plugins/rss/browse/popular/', 'http://wordpress.org/extend/plugins/rss/browse/new/', 'http://wordpress.org/extend/plugins/rss/browse/updated/' )
- );
+ if ( current_user_can( 'activate_plugins' ) )
+ wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
+
+ // QuickPress Widget
+ if ( current_user_can('edit_posts') )
+ wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' );
+
+ // Recent Drafts
+ if ( current_user_can('edit_posts') )
+ wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
// Primary feed (Dev Blog) Widget
if ( !isset( $widget_options['dashboard_primary'] ) ) {
'show_date' => 1
);
}
- wp_register_sidebar_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_empty',
- array( 'all_link' => $widget_options['dashboard_primary']['link'], 'feed_link' => $widget_options['dashboard_primary']['url'], 'width' => 'half', 'class' => 'widget_rss' ),
- 'wp_dashboard_cached_rss_widget', 'wp_dashboard_rss_output'
- );
- wp_register_widget_control( 'dashboard_primary', __( 'Primary Feed' ), 'wp_dashboard_rss_control', array(),
- array( 'widget_id' => 'dashboard_primary' )
- );
-
+ wp_add_dashboard_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_primary', 'wp_dashboard_primary_control' );
// Secondary Feed (Planet) Widget
if ( !isset( $widget_options['dashboard_secondary'] ) ) {
'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ),
'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ),
'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
- 'items' => 15
+ 'items' => 5
);
}
- wp_register_sidebar_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_empty',
- array( 'all_link' => $widget_options['dashboard_secondary']['link'], 'feed_link' => $widget_options['dashboard_secondary']['url'], 'width' => 'full' ),
- 'wp_dashboard_cached_rss_widget', 'wp_dashboard_secondary_output'
- );
- wp_register_widget_control( 'dashboard_secondary', __( 'Secondary Feed' ), 'wp_dashboard_rss_control', array(),
- array( 'widget_id' => 'dashboard_secondary', 'form_inputs' => array( 'show_summary' => false, 'show_author' => false, 'show_date' => false ) )
- );
-
-
- /* Dashboard Widget Template
- wp_register_sidebar_widget( $widget_id (unique slug) , $widget_title, $output_callback,
- array(
- 'all_link' => full url for "See All" link,
- 'feed_link' => full url for "RSS" link,
- 'width' => 'fourth', 'third', 'half', 'full' (defaults to 'half'),
- 'height' => 'single', 'double' (defaults to 'single'),
- ),
- $wp_dashboard_empty_callback (only needed if using 'wp_dashboard_empty' as your $output_callback),
- $arg, $arg, $arg... (further args passed to callbacks)
- );
-
- // optional: if you want users to be able to edit the settings of your widget, you need to register a widget_control
- wp_register_widget_control( $widget_id, $widget_control_title, $control_output_callback,
- array(), // leave an empty array here: oddity in widget code
- array(
- 'widget_id' => $widget_id, // Yes - again. This is required: oddity in widget code
- 'arg' => an arg to pass to the $control_output_callback,
- 'another' => another arg to pass to the $control_output_callback,
- ...
- )
- );
- */
+ wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' );
// Hook to register new widgets
do_action( 'wp_dashboard_setup' );
- // Hard code the sidebar's widgets and order
- $dashboard_widgets = array();
- $dashboard_widgets[] = 'dashboard_recent_comments';
- $dashboard_widgets[] = 'dashboard_incoming_links';
- $dashboard_widgets[] = 'dashboard_primary';
- if ( current_user_can( 'activate_plugins' ) )
- $dashboard_widgets[] = 'dashboard_plugins';
- $dashboard_widgets[] = 'dashboard_secondary';
-
// Filter widget order
- $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', $dashboard_widgets );
-
- $wp_dashboard_sidebars = array( 'wp_dashboard' => $dashboard_widgets, 'array_version' => 3.5 );
+ $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
- add_filter( 'dynamic_sidebar_params', 'wp_dashboard_dynamic_sidebar_params' );
+ foreach ( $dashboard_widgets as $widget_id ) {
+ $name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>';
+ wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
+ }
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) {
ob_start(); // hack - but the same hack wp-admin/widgets.php uses
if ( $update )
update_option( 'dashboard_widget_options', $widget_options );
+
+ do_action('do_meta_boxes', 'dashboard', 'normal', '');
+ do_action('do_meta_boxes', 'dashboard', 'side', '');
}
-// Echoes out the dashboard
-function wp_dashboard() {
- echo "<div id='dashboard-widgets'>\n\n";
+function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) {
+ global $wp_dashboard_control_callbacks;
+ if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
+ $wp_dashboard_control_callbacks[$widget_id] = $control_callback;
+ if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
+ list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
+ $widget_name .= ' <span class="postbox-title-action"><a href="' . clean_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
+ add_meta_box( $widget_id, $widget_name, '_wp_dashboard_control_callback', 'dashboard', 'normal', 'core' );
+ return;
+ }
+ list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
+ $widget_name .= ' <span class="postbox-title-action"><a href="' . clean_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
+ }
+ $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
+ $location = 'normal';
+ if ( in_array($widget_id, $side_widgets) )
+ $location = 'side';
+ add_meta_box( $widget_id, $widget_name , $callback, 'dashboard', $location, 'core' );
+}
- // We're already filtering dynamic_sidebar_params obove
- add_filter( 'option_sidebars_widgets', 'wp_dashboard_sidebars_widgets' ); // here there be hackery
- dynamic_sidebar( 'wp_dashboard' );
- remove_filter( 'option_sidebars_widgets', 'wp_dashboard_sidebars_widgets' );
+function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
+ echo '<form action="" method="post" class="dashboard-widget-control-form">';
+ wp_dashboard_trigger_widget_control( $meta_box['id'] );
+ echo "<p class='submit'><input type='hidden' name='widget_id' value='$meta_box[id]' /><input type='submit' value='" . __( 'Submit' ) . "' /></p>";
- echo "<br class='clear' />\n</div>\n\n\n";
+ echo '</form>';
}
-// Makes sidebar_widgets option reflect the dashboard settings
-function wp_dashboard_sidebars_widgets() { // hackery
- return $GLOBALS['wp_dashboard_sidebars'];
+/**
+ * Displays the dashboard.
+ *
+ * @since unknown
+ */
+function wp_dashboard() {
+ echo "<div id='dashboard-widgets' class='metabox-holder'>\n\n";
+
+ echo "<div id='side-info-column' class='inner-sidebar'>\n\n";
+ $class = do_meta_boxes( 'dashboard', 'side', '' ) ? ' class="has-sidebar"' : '';
+ echo "</div>\n\n";
+
+ echo "<div id='post-body'$class>\n\n";
+ echo "<div id='dashboard-widgets-main-content' class='has-sidebar-content'>\n\n";
+ do_meta_boxes( 'dashboard', 'normal', '' );
+ echo "</div>\n\n";
+ echo "</div>\n\n";
+
+ echo "<form style='display: none' method='get' action=''>\n<p>\n";
+ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
+ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
+ echo "</p>\n</form>\n";
+
+ echo "</div>";
}
-// Modifies sidbar params on the fly to set up ids, class names, titles for each widget (called once per widget)
-// Switches widget to edit mode if $_GET['edit']
-function wp_dashboard_dynamic_sidebar_params( $params ) {
- global $wp_registered_widgets, $wp_registered_widget_controls;
-
- $sidebar_defaults = array('widget_id' => 0, 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '');
- extract( $sidebar_defaults, EXTR_PREFIX_ALL, 'sidebar' );
- extract( $params[0], EXTR_PREFIX_ALL, 'sidebar' );
-
- if ( !isset($wp_registered_widgets[$sidebar_widget_id]) || !is_array($wp_registered_widgets[$sidebar_widget_id]) ) {
- return $params;
- }
- $widget_defaults = array('id' => '', 'width' => '', 'height' => '', 'class' => '', 'feed_link' => '', 'all_link' => '', 'notice' => false, 'error' => false);
- extract( $widget_defaults, EXTR_PREFIX_ALL, 'widget' );
- extract( $wp_registered_widgets[$sidebar_widget_id], EXTR_PREFIX_ALL, 'widget' );
-
- $the_classes = array();
- if ( in_array($widget_width, array( 'third', 'fourth', 'full' ) ) )
- $the_classes[] = $widget_width;
-
- if ( 'double' == $widget_height )
- $the_classes[] = 'double';
-
- if ( $widget_class )
- $the_classes[] = $widget_class;
-
- // Add classes to the widget holder
- if ( $the_classes )
- $sidebar_before_widget = str_replace( "<div class='dashboard-widget-holder ", "<div class='dashboard-widget-holder " . join( ' ', $the_classes ) . ' ', $sidebar_before_widget );
-
- $links = array();
- if ( $widget_all_link )
- $links[] = '<a href="' . clean_url( $widget_all_link ) . '">' . __( 'See All' ) . '</a>';
-
- $content_class = 'dashboard-widget-content';
- if ( current_user_can( 'edit_dashboard' ) && isset($wp_registered_widget_controls[$widget_id]) && is_callable($wp_registered_widget_controls[$widget_id]['callback']) ) {
- // Switch this widget to edit mode
- if ( isset($_GET['edit']) && $_GET['edit'] == $widget_id ) {
- $content_class .= ' dashboard-widget-control';
- $wp_registered_widgets[$widget_id]['callback'] = 'wp_dashboard_empty';
- $sidebar_widget_name = $wp_registered_widget_controls[$widget_id]['name'];
- $params[1] = 'wp_dashboard_trigger_widget_control';
- $sidebar_before_widget .= '<form action="' . clean_url(remove_query_arg( 'edit' )) . '" method="post">';
- $sidebar_after_widget = "<div class='dashboard-widget-submit'><input type='hidden' name='sidebar' value='wp_dashboard' /><input type='hidden' name='widget_id' value='$widget_id' /><input type='submit' value='" . __( 'Save' ) . "' /></div></form>$sidebar_after_widget";
- $links[] = '<a href="' . clean_url(remove_query_arg( 'edit' )) . '">' . __( 'Cancel' ) . '</a>';
- } else {
- $links[] = '<a href="' . clean_url(add_query_arg( 'edit', $widget_id )) . "#$widget_id" . '">' . __( 'Edit' ) . '</a>';
- }
- }
+/* Dashboard Widgets */
- if ( $widget_feed_link )
- $links[] = '<img class="rss-icon" src="' . includes_url('images/rss.png') . '" alt="' . __( 'rss icon' ) . '" /> <a href="' . clean_url( $widget_feed_link ) . '">' . __( 'RSS' ) . '</a>';
+function wp_dashboard_right_now() {
+ $num_posts = wp_count_posts( 'post' );
+ $num_pages = wp_count_posts( 'page' );
- $links = apply_filters( "wp_dashboard_widget_links_$widget_id", $links );
+ $num_cats = wp_count_terms('category');
- // Add links to widget's title bar
- if ( $links ) {
- $sidebar_before_title .= '<span>';
- $sidebar_after_title = '</span><small>' . join( ' | ', $links ) . "</small><br class='clear' />$sidebar_after_title";
- }
+ $num_tags = wp_count_terms('post_tag');
- // Could have put this in widget-content. Doesn't really matter
- if ( $widget_notice )
- $sidebar_after_title .= "\t\t\t<div class='dashboard-widget-notice'>$widget_notice</div>\n\n";
+ $num_comm = wp_count_comments( );
- if ( $widget_error )
- $sidebar_after_title .= "\t\t\t<div class='dashboard-widget-error'>$widget_error</div>\n\n";
+ echo "\n\t".'<p class="sub">' . __('At a Glance') . '</p>';
+ echo "\n\t".'<div class="table">'."\n\t".'<table>';
+ echo "\n\t".'<tr class="first">';
- $sidebar_after_title .= "\t\t\t<div class='$content_class'>\n\n";
+ // Posts
+ $num = number_format_i18n( $num_posts->publish );
+ $text = __ngettext( 'Post', 'Posts', intval($num_posts->publish) );
+ if ( current_user_can( 'edit_posts' ) ) {
+ $num = "<a href='edit.php'>$num</a>";
+ $text = "<a href='edit.php'>$text</a>";
+ }
+ echo '<td class="first b b-posts">' . $num . '</td>';
+ echo '<td class="t posts">' . $text . '</td>';
+ /* TODO: Show status breakdown on hover
+ if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds. Don't show if !current_user_can
+ $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
+ }
+ if ( $can_edit_posts && !empty($num_posts->draft) ) {
+ $post_type_texts[] = '<a href="edit.php?post_status=draft">'.sprintf( __ngettext( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).'</a>';
+ }
+ if ( $can_edit_posts && !empty($num_posts->future) ) {
+ $post_type_texts[] = '<a href="edit.php?post_status=future">'.sprintf( __ngettext( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).'</a>';
+ }
+ if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {
+ $pending_text = sprintf( __ngettext( 'There is <a href="%1$s">%2$s post</a> pending your review.', 'There are <a href="%1$s">%2$s posts</a> pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) );
+ } else {
+ $pending_text = '';
+ }
+ */
+
+ // Total Comments
+ $num = number_format_i18n($num_comm->total_comments);
+ $text = __ngettext( 'Comment', 'Comments', $num_comm->total_comments );
+ if ( current_user_can( 'moderate_comments' ) ) {
+ $num = "<a href='edit-comments.php'>$num</a>";
+ $text = "<a href='edit-comments.php'>$text</a>";
+ }
+ echo '<td class="b b-comments">' . $num . '</td>';
+ echo '<td class="last t comments">' . $text . '</td>';
- $sidebar_after_widget .= "\t\t\t</div>\n\n";
+ echo '</tr><tr>';
- foreach( array_keys( $params[0] ) as $key )
- $$key = ${'sidebar_' . $key};
+ // Pages
+ $num = number_format_i18n( $num_pages->publish );
+ $text = __ngettext( 'Page', 'Pages', $num_pages->publish );
+ if ( current_user_can( 'edit_pages' ) ) {
+ $num = "<a href='edit-pages.php'>$num</a>";
+ $text = "<a href='edit-pages.php'>$text</a>";
+ }
+ echo '<td class="first b b_pages">' . $num . '</td>';
+ echo '<td class="t pages">' . $text . '</td>';
+
+ // Approved Comments
+ $num = number_format_i18n($num_comm->approved);
+ $text = __ngettext( 'Approved', 'Approved', $num_comm->approved );
+ if ( current_user_can( 'moderate_comments' ) ) {
+ $num = "<a href='edit-comments.php?comment_status=approved'>$num</a>";
+ $text = "<a class='approved' href='edit-comments.php?comment_status=approved'>$text</a>";
+ }
+ echo '<td class="b b_approved">' . $num . '</td>';
+ echo '<td class="last t">' . $text . '</td>';
- $params[0] = compact( array_keys( $params[0] ) );
+ echo "</tr>\n\t<tr>";
- return $params;
-}
+ // Categories
+ $num = number_format_i18n( $num_cats );
+ $text = __ngettext( 'Category', 'Categories', $num_cats );
+ if ( current_user_can( 'manage_categories' ) ) {
+ $num = "<a href='categories.php'>$num</a>";
+ $text = "<a href='categories.php'>$text</a>";
+ }
+ echo '<td class="first b b-cats">' . $num . '</td>';
+ echo '<td class="t cats">' . $text . '</td>';
+
+ // Pending Comments
+ $num = number_format_i18n($num_comm->moderated);
+ $text = __ngettext( 'Pending', 'Pending', $num_comm->moderated );
+ if ( current_user_can( 'moderate_comments' ) ) {
+ $num = "<a href='edit-comments.php?comment_status=moderated'><span class='pending-count'>$num</span></a>";
+ $text = "<a class='waiting' href='edit-comments.php?comment_status=moderated'>$text</a>";
+ }
+ echo '<td class="b b-waiting">' . $num . '</td>';
+ echo '<td class="last t">' . $text . '</td>';
+ echo "</tr>\n\t<tr>";
-/* Dashboard Widgets */
+ // Tags
+ $num = number_format_i18n( $num_tags );
+ $text = __ngettext( 'Tag', 'Tags', $num_tags );
+ if ( current_user_can( 'manage_categories' ) ) {
+ $num = "<a href='edit-tags.php'>$num</a>";
+ $text = "<a href='edit-tags.php'>$text</a>";
+ }
+ echo '<td class="first b b-tags">' . $num . '</td>';
+ echo '<td class="t tags">' . $text . '</td>';
+
+ // Spam Comments
+ $num = number_format_i18n($num_comm->spam);
+ $text = __ngettext( 'Spam', 'Spam', $num_comm->spam );
+ if ( current_user_can( 'moderate_comments' ) ) {
+ $num = "<a href='edit-comments.php?comment_status=spam'><span class='spam-count'>$num</span></a>";
+ $text = "<a class='spam' href='edit-comments.php?comment_status=spam'>$text</a>";
+ }
+ echo '<td class="b b-spam">' . $num . '</td>';
+ echo '<td class="last t">' . $text . '</td>';
+
+ echo "</tr>";
+ do_action('right_now_table_end');
+ echo "\n\t</table>\n\t</div>";
+
+ echo "\n\t".'<div class="versions">';
+ $ct = current_theme_info();
+ $sidebars_widgets = wp_get_sidebars_widgets();
+ $num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ), 0 );
+ $num = number_format_i18n( $num_widgets );
+
+ echo "\n\t<p>";
+ if ( current_user_can( 'switch_themes' ) ) {
+ echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
+ printf(__ngettext('Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $ct->title, $num);
+ } else {
+ printf(__ngettext('Theme <span class="b">%1$s</span> with <span class="b">%2$s Widget</span>', 'Theme <span class="b">%1$s</span> with <span class="b">%2$s Widgets</span>', $num_widgets), $ct->title, $num);
+ }
+
+ echo '</p>';
-function wp_dashboard_recent_comments( $sidebar_args ) {
- global $comment;
- extract( $sidebar_args, EXTR_SKIP );
+ update_right_now_message();
- echo $before_widget;
+ echo "\n\t".'<br class="clear" /></div>';
+ do_action( 'rightnow_end' );
+ do_action( 'activity_box_end' );
+}
- echo $before_title;
- echo $widget_name;
- echo $after_title;
+function wp_dashboard_quick_press() {
+ $drafts = false;
+ if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) {
+ $view = get_permalink( $_POST['post_ID'] );
+ $edit = clean_url( get_edit_post_link( $_POST['post_ID'] ) );
+ if ( 'post-quickpress-publish' == $_POST['action'] ) {
+ if ( current_user_can('publish_posts') )
+ printf( '<div class="message"><p>' . __( 'Post Published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', clean_url( $view ), $edit );
+ else
+ printf( '<div class="message"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', clean_url( add_query_arg( 'preview', 1, $view ) ), $edit );
+ } else {
+ printf( '<div class="message"><p>' . __( 'Draft Saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', clean_url( add_query_arg( 'preview', 1, $view ) ), $edit );
+ $drafts_query = new WP_Query( array(
+ 'post_type' => 'post',
+ 'what_to_show' => 'posts',
+ 'post_status' => 'draft',
+ 'author' => $GLOBALS['current_user']->ID,
+ 'posts_per_page' => 1,
+ 'orderby' => 'modified',
+ 'order' => 'DESC'
+ ) );
+
+ if ( $drafts_query->posts )
+ $drafts =& $drafts_query->posts;
+ }
+ printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="tools.php">' . __('Press This') . '</a>' );
+ $_REQUEST = array(); // hack for get_default_post_to_edit()
+ }
- $lambda = create_function( '', 'return 5;' );
- add_filter( 'option_posts_per_rss', $lambda ); // hack - comments query doesn't accept per_page parameter
- $comments_query = new WP_Query(array('feed' => 'rss2', 'withcomments' => 1));
- remove_filter( 'option_posts_per_rss', $lambda );
+ $post = get_default_post_to_edit();
+?>
- $is_first = true;
+ <form name="post" action="<?php echo clean_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press">
+ <h4 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h4>
+ <div class="input-text-wrap">
+ <input type="text" name="post_title" id="title" tabindex="1" autocomplete="off" value="<?php echo attribute_escape( $post->post_title ); ?>" />
+ </div>
+
+ <?php if ( current_user_can( 'upload_files' ) ) : ?>
+ <div id="media-buttons" class="hide-if-no-js">
+ <?php do_action( 'media_buttons' ); ?>
+ </div>
+ <?php endif; ?>
+
+ <h4 id="content-label"><label for="content"><?php _e('Content') ?></label></h4>
+ <div class="textarea-wrap">
+ <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" tabindex="2"><?php echo $post->post_content; ?></textarea>
+ </div>
+
+ <script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script>
+
+ <h4><label for="tags-input"><?php _e('Tags') ?></label></h4>
+ <div class="input-text-wrap">
+ <input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
+ </div>
+
+ <p class="submit">
+ <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
+ <input type="hidden" name="quickpress_post_ID" value="<?php echo (int) $post->ID; ?>" />
+ <?php wp_nonce_field('add-post'); ?>
+ <input type="submit" name="save" id="save-post" class="button" tabindex="4" value="<?php _e('Save Draft'); ?>" />
+ <input type="reset" value="<?php _e( 'Cancel' ); ?>" class="cancel" />
+ <?php if ( current_user_can('publish_posts') ) { ?>
+ <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php _e('Publish'); ?>" />
+ <?php } else { ?>
+ <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php _e('Submit for Review'); ?>" />
+ <?php } ?>
+ <br class="clear" />
+ </p>
+
+ </form>
- if ( $comments_query->have_comments() ) {
- while ( $comments_query->have_comments() ) { $comments_query->the_comment();
+<?php
+ if ( $drafts )
+ wp_dashboard_recent_drafts( $drafts );
+}
- $comment_post_url = get_permalink( $comment->comment_post_ID );
- $comment_post_title = get_the_title( $comment->comment_post_ID );
- $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
- $comment_link = '<a class="comment-link" href="' . get_comment_link() . '">#</a>';
- $comment_meta = sprintf( __( 'From <strong>%1$s</strong> on %2$s %3$s' ), get_comment_author(), $comment_post_link, $comment_link );
+function wp_dashboard_recent_drafts( $drafts = false ) {
+ if ( !$drafts ) {
+ $drafts_query = new WP_Query( array(
+ 'post_type' => 'post',
+ 'what_to_show' => 'posts',
+ 'post_status' => 'draft',
+ 'author' => $GLOBALS['current_user']->ID,
+ 'posts_per_page' => 5,
+ 'orderby' => 'modified',
+ 'order' => 'DESC'
+ ) );
+ $drafts =& $drafts_query->posts;
+ }
- if ( $is_first ) : $is_first = false;
+ if ( $drafts && is_array( $drafts ) ) {
+ $list = array();
+ foreach ( $drafts as $draft ) {
+ $url = get_edit_post_link( $draft->ID );
+ $title = _draft_or_post_title( $draft->ID );
+ $item = "<h4><a href='$url' title='" . sprintf( __( 'Edit "%s"' ), attribute_escape( $title ) ) . "'>$title</a> <abbr title='" . get_the_time(__('Y/m/d g:i:s A'), $draft) . "'>" . get_the_time( get_option( 'date_format' ), $draft ) . '</abbr></h4>';
+ if ( $the_content = preg_split( '#\s#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) )
+ $item .= '<p>' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '…' : '' ) . '</p>';
+ $list[] = $item;
+ }
?>
- <blockquote><p>“<?php comment_excerpt(); ?>”</p></blockquote>
- <p class='comment-meta'><?php echo $comment_meta; ?></p>
+ <ul>
+ <li><?php echo join( "</li>\n<li>", $list ); ?></li>
+ </ul>
+ <p class="textright"><a href="edit.php?post_status=draft" class="button"><?php _e('View all'); ?></a></p>
<?php
- if ( $comments_query->comment_count > 1 ) : ?>
- <ul id="dashboard-comments-list">
+ } else {
+ _e('There are no drafts at the moment');
+ }
+}
+
+/**
+ * Display recent comments dashboard widget content.
+ *
+ * @since unknown
+ */
+function wp_dashboard_recent_comments() {
+ global $wpdb;
+
+ if ( current_user_can('edit_posts') )
+ $allowed_states = array('0', '1');
+ else
+ $allowed_states = array('1');
+
+ // Select all comment types and filter out spam later for better query performance.
+ $comments = array();
+ $start = 0;
+
+ while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT $start, 50" ) ) {
+
+ foreach ( $possible as $comment ) {
+ if ( count( $comments ) >= 5 )
+ break;
+ if ( in_array( $comment->comment_approved, $allowed_states ) )
+ $comments[] = $comment;
+ }
+
+ $start = $start + 50;
+ }
+
+ if ( $comments ) :
+?>
+
+ <div id="the-comment-list" class="list:comment">
<?php
- endif; // comment_count
- else : // is_first
+ foreach ( $comments as $comment )
+ _wp_dashboard_recent_comments_row( $comment );
?>
- <li class='comment-meta'><?php echo $comment_meta; ?></li>
+ </div>
+
<?php
- endif; // is_first
- }
+ if ( current_user_can('edit_posts') ) { ?>
+ <p class="textright"><a href="edit-comments.php" class="button"><?php _e('View all'); ?></a></p>
+<?php }
+
+ wp_comment_reply( -1, false, 'dashboard', false );
+
+ else :
+?>
+
+ <p><?php _e( 'No comments yet.' ); ?></p>
- if ( $comments_query->comment_count > 1 ) : ?>
- </ul>
<?php
- endif; // comment_count;
+ endif; // $comments;
+}
+
+function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
+ $GLOBALS['comment'] =& $comment;
+
+ $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
+ $comment_post_title = get_the_title( $comment->comment_post_ID );
+ $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
+ $comment_link = '<a class="comment-link" href="' . get_comment_link() . '">#</a>';
+
+ $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
+ $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
+ $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
+ $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
+
+ $actions = array();
+
+ $actions_string = '';
+ if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
+ $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
+ $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
+ $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
+ //$actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
+ $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
+ $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . _c( 'Spam|verb' ) . '</a>';
+ $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
+
+ $actions = apply_filters( 'comment_row_actions', $actions, $comment );
+
+ $i = 0;
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
+ // Reply and quickedit need a hide-if-no-js span
+ if ( 'reply' == $action || 'quickedit' == $action )
+ $action .= ' hide-if-no-js';
+
+ $actions_string .= "<span class='$action'>$sep$link</span>";
+ }
}
- echo $after_widget;
+?>
+
+ <div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status($comment->comment_ID) ) ); ?>>
+ <?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
+
+ <?php echo get_avatar( $comment, 50 ); ?>
+ <h4 class="comment-meta"><?php printf( __( 'From %1$s on %2$s%3$s' ), '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link." ".$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?></h4>
+
+ <?php
+ else :
+ switch ( $comment->comment_type ) :
+ case 'pingback' :
+ $type = __( 'Pingback' );
+ break;
+ case 'trackback' :
+ $type = __( 'Trackback' );
+ break;
+ default :
+ $type = ucwords( $comment->comment_type );
+ endswitch;
+ $type = wp_specialchars( $type );
+ ?>
+
+ <h4 class="comment-meta"><?php printf( __( '%1$s on %2$s' ), "<strong>$type</strong>", $comment_post_link ); ?></h4>
+ <p class="comment-author"><?php comment_author_link(); ?></p>
+
+ <?php endif; // comment_type ?>
+ <blockquote><p><?php comment_excerpt(); ?></p></blockquote>
+ <p class="row-actions"><?php echo $actions_string; ?></p>
+
+ <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
+ <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea>
+ <div class="author-email"><?php echo attribute_escape( $comment->comment_author_email ); ?></div>
+ <div class="author"><?php echo attribute_escape( $comment->comment_author ); ?></div>
+ <div class="author-url"><?php echo attribute_escape( $comment->comment_author_url ); ?></div>
+ <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
+ </div>
+
+ </div>
+<?php
+}
+
+function wp_dashboard_incoming_links() {
+ wp_dashboard_cached_rss_widget( 'dashboard_incoming_links', 'wp_dashboard_incoming_links_output' );
}
-// $sidebar_args are handled by wp_dashboard_empty()
+/**
+ * Display incoming links dashboard widget content.
+ *
+ * @since unknown
+ */
function wp_dashboard_incoming_links_output() {
$widgets = get_option( 'dashboard_widget_options' );
@extract( @$widgets['dashboard_incoming_links'], EXTR_SKIP );
}
}
-// $sidebar_args are handled by wp_dashboard_empty()
+function wp_dashboard_incoming_links_control() {
+ wp_dashboard_rss_control( 'dashboard_incoming_links', array( 'title' => false, 'show_summary' => false, 'show_author' => false ) );
+}
+
+function wp_dashboard_primary() {
+ wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' );
+}
+
+function wp_dashboard_primary_control() {
+ wp_dashboard_rss_control( 'dashboard_primary' );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param int $widget_id
+ */
function wp_dashboard_rss_output( $widget_id ) {
$widgets = get_option( 'dashboard_widget_options' );
+ echo "<div class='rss-widget'>";
wp_widget_rss_output( $widgets[$widget_id] );
+ echo "</div>";
+}
+
+function wp_dashboard_secondary() {
+ wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' );
+}
+
+function wp_dashboard_secondary_control() {
+ wp_dashboard_rss_control( 'dashboard_secondary' );
}
-// $sidebar_args are handled by wp_dashboard_empty()
+/**
+ * Display secondary dashboard RSS widget feed.
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function wp_dashboard_secondary_output() {
$widgets = get_option( 'dashboard_widget_options' );
@extract( @$widgets['dashboard_secondary'], EXTR_SKIP );
$rss = @fetch_rss( $url );
+
if ( !isset($rss->items) || 0 == count($rss->items) )
return false;
- echo "<ul id='planetnews'>\n";
-
$rss->items = array_slice($rss->items, 0, $items);
- foreach ($rss->items as $item ) {
- $title = wp_specialchars($item['title']);
- list($author,$post) = explode( ':', $title, 2 );
- $link = clean_url($item['link']);
- echo "\t<li><a href='$link'><span class='post'>$post</span><span class='hidden'> - </span><cite>$author</cite></a></li>\n";
+ if ( 'http://planet.wordpress.org/' == $rss->channel['link'] ) {
+ foreach ( array_keys($rss->items) as $i ) {
+ list($site, $description) = explode( ':', wp_specialchars($rss->items[$i]['title']), 2 );
+ $rss->items[$i]['dc']['creator'] = trim($site);
+ $rss->items[$i]['title'] = trim($description);
+ }
}
- echo "</ul>\n<br class='clear' />\n";
+ echo "<div class='rss-widget'>";
+ wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
+ echo "</div>";
}
-// $sidebar_args are handled by wp_dashboard_empty()
+function wp_dashboard_plugins() {
+ wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array(
+ 'http://wordpress.org/extend/plugins/rss/browse/popular/',
+ 'http://wordpress.org/extend/plugins/rss/browse/new/',
+ 'http://wordpress.org/extend/plugins/rss/browse/updated/'
+ ) );
+}
+
+/**
+ * Display plugins most popular, newest plugins, and recently updated widget text.
+ *
+ * @since unknown
+ */
function wp_dashboard_plugins_output() {
$popular = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/popular/' );
$new = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
list($link, $frag) = explode( '#', $item['link'] );
$link = clean_url($link);
- $dlink = rtrim($link, '/') . '/download/';
+ if( preg_match('|/([^/]+?)/?$|', $link, $matches) )
+ $slug = $matches[1];
+ else
+ $slug = '';
+
+ $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) .
+ '&TB_iframe=true&width=600&height=800';
echo "<h4>$label</h4>\n";
- echo "<h5><a href='$link'>$title</a></h5> <span>(<a href='$dlink'>" . __( 'Download' ) . "</a>)</span>\n";
+ echo "<h5><a href='$link'>$title</a></h5> <span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span>\n";
echo "<p>$description</p>\n";
}
}
-// Checks to see if all of the feed url in $check_urls are cached.
-// If $check_urls is empty, look for the rss feed url found in the dashboard widget optios of $widget_id.
-// If cached, call $callback, a function that echoes out output for this widget.
-// If not cache, echo a "Loading..." stub which is later replaced by AJAX call (see top of /wp-admin/index.php)
+/**
+ * Checks to see if all of the feed url in $check_urls are cached.
+ *
+ * If $check_urls is empty, look for the rss feed url found in the dashboard
+ * widget optios of $widget_id. If cached, call $callback, a function that
+ * echoes out output for this widget. If not cache, echo a "Loading..." stub
+ * which is later replaced by AJAX call (see top of /wp-admin/index.php)
+ *
+ * @since unknown
+ *
+ * @param int $widget_id
+ * @param callback $callback
+ * @param array $check_urls RSS feeds
+ * @return bool False on failure. True on success.
+ */
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
$loading = '<p class="widget-loading">' . __( 'Loading…' ) . '</p>';
return true;
}
-// Empty widget used for JS/AJAX created output.
-// Callback inserts content between before_widget and after_widget. Used when widget is in edit mode. Can also be used for custom widgets.
-function wp_dashboard_empty( $sidebar_args, $callback = false ) {
- extract( $sidebar_args, EXTR_SKIP );
-
- echo $before_widget;
-
- echo $before_title;
- echo $widget_name;
- echo $after_title;
-
- // When in edit mode, the callback passed to this function is the widget_control callback
- if ( $callback && is_callable( $callback ) ) {
- $args = array_slice( func_get_args(), 2 );
- array_unshift( $args, $widget_id );
- call_user_func_array( $callback, $args );
- }
-
- echo $after_widget;
-}
-
-/* Dashboard Widgets Controls. Ssee also wp_dashboard_empty() */
+/* Dashboard Widgets Controls */
// Calls widget_control callback
+/**
+ * Calls widget control callback.
+ *
+ * @since unknown
+ *
+ * @param int $widget_control_id Registered Widget ID.
+ */
function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
- global $wp_registered_widget_controls;
- if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_registered_widget_controls[$widget_control_id]) && is_callable($wp_registered_widget_controls[$widget_control_id]['callback']) )
- call_user_func_array( $wp_registered_widget_controls[$widget_control_id]['callback'], $wp_registered_widget_controls[$widget_control_id]['params'] );
-}
+ global $wp_dashboard_control_callbacks;
-// Sets up $args to be used as input to wp_widget_rss_form(), handles POST data from RSS-type widgets
-function wp_dashboard_rss_control( $args ) {
- extract( $args );
- if ( !$widget_id )
- return false;
+ if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) {
+ call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) );
+ }
+}
+/**
+ * The RSS dashboard widget control.
+ *
+ * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
+ * from RSS-type widgets.
+ *
+ * @since unknown
+ *
+ * @param string widget_id
+ * @param array form_inputs
+ */
+function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
$widget_options = array();
wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
}
+/**
+ * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
+ */
+function wp_dashboard_empty() {}
+
?>
<?php
-
-// version number for the export format. bump this when something changes that might affect compatibility.
+/**
+ * WordPress Export Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Version number for the export format.
+ *
+ * Bump this when something changes that might affect compatibility.
+ *
+ * @since unknown
+ * @var string
+ */
define('WXR_VERSION', '1.0');
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $author
+ */
function export_wp($author='') {
global $wpdb, $post_ids, $post;
$categories = (array) get_categories('get=all');
$tags = (array) get_tags('get=all');
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $categories
+ */
function wxr_missing_parents($categories) {
if ( !is_array($categories) || empty($categories) )
return array();
}
unset($categories);
+/**
+ * Place string in CDATA tag.
+ *
+ * @since unknown
+ *
+ * @param string $str String to place in XML CDATA tag.
+ */
function wxr_cdata($str) {
if ( seems_utf8($str) == false )
$str = utf8_encode($str);
return $str;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return string Site URL.
+ */
function wxr_site_url() {
global $current_site;
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param object $c Category Object
+ */
function wxr_cat_name($c) {
if ( empty($c->name) )
return;
echo '<wp:cat_name>' . wxr_cdata($c->name) . '</wp:cat_name>';
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param object $c Category Object
+ */
function wxr_category_description($c) {
if ( empty($c->description) )
return;
echo '<wp:category_description>' . wxr_cdata($c->description) . '</wp:category_description>';
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param object $t Tag Object
+ */
function wxr_tag_name($t) {
if ( empty($t->name) )
return;
echo '<wp:tag_name>' . wxr_cdata($t->name) . '</wp:tag_name>';
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param object $t Tag Object
+ */
function wxr_tag_description($t) {
if ( empty($t->description) )
return;
echo '<wp:tag_description>' . wxr_cdata($t->description) . '</wp:tag_description>';
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
function wxr_post_taxonomy() {
$categories = get_the_category();
$tags = get_the_tags();
<!-- To import this information into a WordPress blog follow these steps. -->
<!-- 1. Log into that blog as an administrator. -->
-<!-- 2. Go to Manage: Import in the blog's admin panels. -->
+<!-- 2. Go to Tools: Import in the blog's admin panels (or Manage: Import in older versions of WordPress). -->
<!-- 3. Choose "WordPress" from the list. -->
<!-- 4. Upload this file using the form provided on that page. -->
<!-- 5. You will first be asked to map the authors in this export file to users -->
<?php the_generator('export');?>
<rss version="2.0"
+ xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
$where = "WHERE ID IN (".join(',', $next_posts).")";
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");
foreach ($posts as $post) {
+ // Don't export revisions. They bloat the export.
+ if ( 'revision' == $post->post_type )
+ continue;
setup_postdata($post); ?>
<item>
<title><?php echo apply_filters('the_title_rss', $post->post_title); ?></title>
<?php
-
-$wp_file_descriptions = array ('index.php' => __( 'Main Index Template' ), 'style.css' => __( 'Stylesheet' ), 'rtl.css' => __( 'RTL Stylesheet' ), 'comments.php' => __( 'Comments' ), 'comments-popup.php' => __( 'Popup Comments' ), 'footer.php' => __( 'Footer' ), 'header.php' => __( 'Header' ), 'sidebar.php' => __( 'Sidebar' ), 'archive.php' => __( 'Archives' ), 'category.php' => __( 'Category Template' ), 'page.php' => __( 'Page Template' ), 'search.php' => __( 'Search Results' ), 'searchform.php' => __( 'Search Form' ), 'single.php' => __( 'Single Post' ), '404.php' => __( '404 Template' ), 'link.php' => __( 'Links Template' ), 'functions.php' => __( 'Theme Functions' ), 'attachment.php' => __( 'Attachment Template' ), 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), '.htaccess' => __( '.htaccess (for rewrite rules )' ),
+/**
+ * File contains all the administration image manipulation functions.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** The descriptions for theme files. */
+$wp_file_descriptions = array (
+ 'index.php' => __( 'Main Index Template' ),
+ 'style.css' => __( 'Stylesheet' ),
+ 'rtl.css' => __( 'RTL Stylesheet' ),
+ 'comments.php' => __( 'Comments' ),
+ 'comments-popup.php' => __( 'Popup Comments' ),
+ 'footer.php' => __( 'Footer' ),
+ 'header.php' => __( 'Header' ),
+ 'sidebar.php' => __( 'Sidebar' ),
+ 'archive.php' => __( 'Archives' ),
+ 'category.php' => __( 'Category Template' ),
+ 'page.php' => __( 'Page Template' ),
+ 'search.php' => __( 'Search Results' ),
+ 'searchform.php' => __( 'Search Form' ),
+ 'single.php' => __( 'Single Post' ),
+ '404.php' => __( '404 Template' ),
+ 'link.php' => __( 'Links Template' ),
+ 'functions.php' => __( 'Theme Functions' ),
+ 'attachment.php' => __( 'Attachment Template' ),
+ 'image.php' => __('Image Attachment Template'),
+ 'video.php' => __('Video Attachment Template'),
+ 'audio.php' => __('Audio Attachment Template'),
+ 'application.php' => __('Application Attachment Template'),
+ 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ),
+ '.htaccess' => __( '.htaccess (for rewrite rules )' ),
// Deprecated files
'wp-layout.css' => __( 'Stylesheet' ), 'wp-comments.php' => __( 'Comments Template' ), 'wp-comments-popup.php' => __( 'Popup Comments Template' ));
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $file
+ * @return unknown
+ */
function get_file_description( $file ) {
global $wp_file_descriptions;
if ( isset( $wp_file_descriptions[basename( $file )] ) ) {
return $wp_file_descriptions[basename( $file )];
}
- elseif ( file_exists( ABSPATH . $file ) && is_file( ABSPATH . $file ) ) {
- $template_data = implode( '', file( ABSPATH . $file ) );
- if ( preg_match( "|Template Name:(.*)|i", $template_data, $name ))
- return $name[1];
+ elseif ( file_exists( WP_CONTENT_DIR . $file ) && is_file( WP_CONTENT_DIR . $file ) ) {
+ $template_data = implode( '', file( WP_CONTENT_DIR . $file ) );
+ if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ))
+ return $name[1] . ' Page Template';
}
return basename( $file );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function get_home_path() {
$home = get_option( 'home' );
if ( $home != '' && $home != get_option( 'siteurl' ) ) {
return $home_path;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $file
+ * @return unknown
+ */
function get_real_file_to_edit( $file ) {
if ('index.php' == $file || '.htaccess' == $file ) {
$real_file = get_home_path() . $file;
return $real_file;
}
-//$folder = Full path to folder
-//$levels = Levels of folders to follow, Default: 100 (PHP Loop limit)
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param string $folder Optional. Full path to folder
+ * @param int $levels Optional. Levels of folders to follow, Default: 100 (PHP Loop limit).
+ * @return bool|array
+ */
function list_files( $folder = '', $levels = 100 ) {
if( empty($folder) )
return false;
return $files;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function get_temp_dir() {
if ( defined('WP_TEMP_DIR') )
return trailingslashit(WP_TEMP_DIR);
return '/tmp/';
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $filename
+ * @param unknown_type $dir
+ * @return unknown
+ */
function wp_tempnam($filename = '', $dir = ''){
if ( empty($dir) )
$dir = get_temp_dir();
return $filename;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $file
+ * @param unknown_type $allowed_files
+ * @return unknown
+ */
function validate_file_to_edit( $file, $allowed_files = '' ) {
$file = stripslashes( $file );
}
}
-// array wp_handle_upload ( array &file [, array overrides] )
-// file: reference to a single element of $_FILES. Call the function once for each uploaded file.
-// overrides: an associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
-// On success, returns an associative array of file attributes.
-// On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
-function wp_handle_upload( &$file, $overrides = false ) {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param array $file Reference to a single element of $_FILES. Call the function once for each uploaded file.
+ * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
+ * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
+ */
+function wp_handle_upload( &$file, $overrides = false, $time = null ) {
// The default error handler.
if (! function_exists( 'wp_handle_upload_error' ) ) {
function wp_handle_upload_error( &$file, $message ) {
// You may define your own function and pass the name in $overrides['upload_error_handler']
$upload_error_handler = 'wp_handle_upload_error';
+ // You may define your own function and pass the name in $overrides['unique_filename_callback']
+ $unique_filename_callback = null;
+
// $_POST['action'] must be set and its value must equal $overrides['action'] or this:
$action = 'wp_handle_upload';
__( "The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form." ),
__( "The uploaded file was only partially uploaded." ),
__( "No file was uploaded." ),
+ '',
__( "Missing a temporary folder." ),
__( "Failed to write file to disk." ));
}
// A writable uploads dir will pass this test. Again, there's no point overriding this one.
- if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
+ if ( ! ( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] ) )
return $upload_error_handler( $file, $uploads['error'] );
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
return $return;
}
-// Pass this function an array similar to that of a $_FILES POST array.
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Pass this function an array similar to that of a $_FILES POST array.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $file
+ * @param unknown_type $overrides
+ * @return unknown
+ */
function wp_handle_sideload( &$file, $overrides = false ) {
// The default error handler.
if (! function_exists( 'wp_handle_upload_error' ) ) {
// You may define your own function and pass the name in $overrides['upload_error_handler']
$upload_error_handler = 'wp_handle_upload_error';
+ // You may define your own function and pass the name in $overrides['unique_filename_callback']
+ $unique_filename_callback = null;
+
// $_POST['action'] must be set and its value must equal $overrides['action'] or this:
$action = 'wp_handle_sideload';
return $upload_error_handler( $file, $uploads['error'] );
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
-
+
// Strip the query strings.
$filename = str_replace('?','-', $filename);
$filename = str_replace('&','-', $filename);
-
+
// Move the file to the uploads dir
$new_file = $uploads['path'] . "/$filename";
if ( false === @ rename( $file['tmp_name'], $new_file ) ) {
}
/**
-* Downloads a url to a local file using the Snoopy HTTP Class
-*
-* @param string $url the URL of the file to download
-* @return mixed WP_Error on failure, string Filename on success.
-*/
+ * Downloads a url to a local file using the Snoopy HTTP Class.
+ *
+ * @since unknown
+ * @todo Transition over to using the new HTTP Request API (jacob).
+ *
+ * @param string $url the URL of the file to download
+ * @return mixed WP_Error on failure, string Filename on success.
+ */
function download_url( $url ) {
//WARNING: The file is not automatically deleted, The script must unlink() the file.
- if( ! $url )
+ if ( ! $url )
return new WP_Error('http_no_url', __('Invalid URL Provided'));
$tmpfname = wp_tempnam($url);
- if( ! $tmpfname )
+ if ( ! $tmpfname )
return new WP_Error('http_no_file', __('Could not create Temporary file'));
- $handle = @fopen($tmpfname, 'w');
- if( ! $handle )
+ $handle = @fopen($tmpfname, 'wb');
+ if ( ! $handle )
return new WP_Error('http_no_file', __('Could not create Temporary file'));
- require_once( ABSPATH . 'wp-includes/class-snoopy.php' );
- $snoopy = new Snoopy();
- $snoopy->fetch($url);
+ $response = wp_remote_get($url, array('timeout' => 30));
+
+ if ( is_wp_error($response) ) {
+ fclose($handle);
+ unlink($tmpfname);
+ return $response;
+ }
- if( $snoopy->status != '200' ){
+ if ( $response['response']['code'] != '200' ){
fclose($handle);
unlink($tmpfname);
- return new WP_Error('http_404', trim($snoopy->response_code));
+ return new WP_Error('http_404', trim($response['response']['message']));
}
- fwrite($handle, $snoopy->results);
+
+ fwrite($handle, $response['body']);
fclose($handle);
return $tmpfname;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $file
+ * @param unknown_type $to
+ * @return unknown
+ */
function unzip_file($file, $to) {
global $wp_filesystem;
if ( ! $wp_filesystem || !is_object($wp_filesystem) )
return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
+ // Unzip uses a lot of memory
+ @ini_set('memory_limit', '256M');
+
$fs =& $wp_filesystem;
require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php');
if ( 0 == count($archive_files) )
return new WP_Error('empty_archive', __('Empty archive'));
- $to = trailingslashit($to);
- $path = explode('/', $to);
- $tmppath = '';
- for ( $j = 0; $j < count($path) - 1; $j++ ) {
- $tmppath .= $path[$j] . '/';
- if ( ! $fs->is_dir($tmppath) )
- $fs->mkdir($tmppath, 0755);
+ $path = explode('/', untrailingslashit($to));
+ for ( $i = count($path); $i > 0; $i-- ) { //>0 = first element is empty allways for paths starting with '/'
+ $tmppath = implode('/', array_slice($path, 0, $i) );
+ if ( $fs->is_dir($tmppath) ) { //Found the highest folder that exists, Create from here(ie +1)
+ for ( $i = $i + 1; $i <= count($path); $i++ ) {
+ $tmppath = implode('/', array_slice($path, 0, $i) );
+ if ( ! $fs->mkdir($tmppath, FS_CHMOD_DIR) )
+ return new WP_Error('mkdir_failed', __('Could not create directory'), $tmppath);
+ }
+ break; //Exit main for loop
+ }
}
+ $to = trailingslashit($to);
foreach ($archive_files as $file) {
- $path = explode('/', $file['filename']);
- $tmppath = '';
-
- // Loop through each of the items and check that the folder exists.
- for ( $j = 0; $j < count($path) - 1; $j++ ) {
- $tmppath .= $path[$j] . '/';
- if ( ! $fs->is_dir($to . $tmppath) )
- if ( !$fs->mkdir($to . $tmppath, 0755) )
- return new WP_Error('mkdir_failed', __('Could not create directory'), $to . $tmppath);
+ $path = $file['folder'] ? $file['filename'] : dirname($file['filename']);
+ $path = explode('/', $path);
+ for ( $i = count($path); $i >= 0; $i-- ) { //>=0 as the first element contains data
+ if ( empty($path[$i]) )
+ continue;
+ $tmppath = $to . implode('/', array_slice($path, 0, $i) );
+ if ( $fs->is_dir($tmppath) ) {//Found the highest folder that exists, Create from here
+ for ( $i = $i + 1; $i <= count($path); $i++ ) { //< count() no file component please.
+ $tmppath = $to . implode('/', array_slice($path, 0, $i) );
+ if ( ! $fs->is_dir($tmppath) && ! $fs->mkdir($tmppath, FS_CHMOD_DIR) )
+ return new WP_Error('mkdir_failed', __('Could not create directory'), $tmppath);
+ }
+ break; //Exit main for loop
+ }
}
// We've made sure the folders are there, so let's extract the file now:
- if ( ! $file['folder'] )
+ if ( ! $file['folder'] ) {
if ( !$fs->put_contents( $to . $file['filename'], $file['content']) )
return new WP_Error('copy_failed', __('Could not copy file'), $to . $file['filename']);
- $fs->chmod($to . $file['filename'], 0644);
+ $fs->chmod($to . $file['filename'], FS_CHMOD_FILE);
+ }
}
-
return true;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $from
+ * @param unknown_type $to
+ * @return unknown
+ */
function copy_dir($from, $to) {
global $wp_filesystem;
foreach ( (array) $dirlist as $filename => $fileinfo ) {
if ( 'f' == $fileinfo['type'] ) {
- if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true) )
- return new WP_Error('copy_failed', __('Could not copy file'), $to . $filename);
- $wp_filesystem->chmod($to . $filename, 0644);
+ if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true) ) {
+ // If copy failed, chmod file to 0644 and try again.
+ $wp_filesystem->chmod($to . $filename, 0644);
+ if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true) )
+ return new WP_Error('copy_failed', __('Could not copy file'), $to . $filename);
+ }
+ $wp_filesystem->chmod($to . $filename, FS_CHMOD_FILE);
} elseif ( 'd' == $fileinfo['type'] ) {
- if ( !$wp_filesystem->mkdir($to . $filename, 0755) )
- return new WP_Error('mkdir_failed', __('Could not create directory'), $to . $filename);
+ if ( !$wp_filesystem->is_dir($to . $filename) ) {
+ if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
+ return new WP_Error('mkdir_failed', __('Could not create directory'), $to . $filename);
+ }
$result = copy_dir($from . $filename, $to . $filename);
if ( is_wp_error($result) )
return $result;
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $args
+ * @return unknown
+ */
function WP_Filesystem( $args = false ) {
global $wp_filesystem;
require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
- $method = get_filesystem_method();
+ $method = get_filesystem_method($args);
if ( ! $method )
return false;
- $abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method);
+ $abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method);
if( ! file_exists($abstraction_file) )
return;
if ( !$wp_filesystem->connect() )
return false; //There was an erorr connecting to the server.
+ // Set the permission constants if not already set.
+ if ( ! defined('FS_CHMOD_DIR') )
+ define('FS_CHMOD_DIR', 0755 );
+ if ( ! defined('FS_CHMOD_FILE') )
+ define('FS_CHMOD_FILE', 0644 );
+
return true;
}
-function get_filesystem_method() {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $args
+ * @return unknown
+ */
+function get_filesystem_method($args = array()) {
$method = false;
if( function_exists('getmyuid') && function_exists('fileowner') ){
$temp_file = wp_tempnam();
unlink($temp_file);
}
+ if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') ) $method = 'ssh2';
if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
return apply_filters('filesystem_method', $method);
}
-?>
\ No newline at end of file
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $form_post
+ * @param unknown_type $type
+ * @param unknown_type $error
+ * @return unknown
+ */
+function request_filesystem_credentials($form_post, $type = '', $error = false) {
+ $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error);
+ if ( '' !== $req_cred )
+ return $req_cred;
+
+ if ( empty($type) )
+ $type = get_filesystem_method();
+
+ if ( 'direct' == $type )
+ return true;
+
+ $credentials = get_option('ftp_credentials', array());
+ // If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option)
+ $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']);
+ $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']);
+ $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']);
+
+ // Check to see if we are setting the public/private keys for ssh
+ $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? $_POST['public_key'] : $credentials['public_key']);
+ $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? $_POST['private_key'] : $credentials['private_key']);
+
+ //sanitize the hostname, Some people might pass in odd-data:
+ $credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off
+
+ if ( strpos($credentials['hostname'], ':') )
+ list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2);
+ else
+ unset($credentials['port']);
+
+ if ( defined('FTP_SSH') || (isset($_POST['connection_type']) && 'ssh' == $_POST['connection_type']) )
+ $credentials['connection_type'] = 'ssh';
+ else if ( defined('FTP_SSL') || (isset($_POST['connection_type']) && 'ftps' == $_POST['connection_type']) )
+ $credentials['connection_type'] = 'ftps';
+ else if ( !isset($credentials['connection_type']) || (isset($_POST['connection_type']) && 'ftp' == $_POST['connection_type']) )
+ $credentials['connection_type'] = 'ftp';
+
+ if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) {
+ $stored_credentials = $credentials;
+ if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code.
+ $stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
+
+ unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']);
+ update_option('ftp_credentials', $stored_credentials);
+ return $credentials;
+ }
+ $hostname = '';
+ $username = '';
+ $password = '';
+ $connection_type = '';
+ if ( !empty($credentials) )
+ extract($credentials, EXTR_OVERWRITE);
+ if ( $error ) {
+ $error_string = __('<strong>Error:</strong> There was an error connecting to the server, Please verify the settings are correct.');
+ if ( is_wp_error($error) )
+ $error_string = $error->get_error_message();
+ echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
+ }
+?>
+<script type="text/javascript">
+<!--
+jQuery(function($){
+ jQuery("#ssh").click(function () {
+ jQuery("#ssh_keys").show();
+ });
+ jQuery("#ftp, #ftps").click(function () {
+ jQuery("#ssh_keys").hide();
+ });
+});
+-->
+</script>
+<form action="<?php echo $form_post ?>" method="post">
+<div class="wrap">
+<h2><?php _e('Connection Information') ?></h2>
+<p><?php _e('To perform the requested action, connection information is required.') ?></p>
+
+<table class="form-table">
+<tr valign="top">
+<th scope="row"><label for="hostname"><?php _e('Hostname') ?></label></th>
+<td><input name="hostname" type="text" id="hostname" value="<?php echo attribute_escape($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php if( defined('FTP_HOST') ) echo ' disabled="disabled"' ?> size="40" /></td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><label for="username"><?php _e('Username') ?></label></th>
+<td><input name="username" type="text" id="username" value="<?php echo attribute_escape($username) ?>"<?php if( defined('FTP_USER') ) echo ' disabled="disabled"' ?> size="40" /></td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><label for="password"><?php _e('Password') ?></label></th>
+<td><input name="password" type="password" id="password" value=""<?php if( defined('FTP_PASS') ) echo ' disabled="disabled"' ?> size="40" /><?php if( defined('FTP_PASS') && !empty($password) ) echo '<em>'.__('(Password not shown)').'</em>'; ?></td>
+</tr>
+
+<tr id="ssh_keys" valign="top" style="<?php if ( 'ssh' != $connection_type ) echo 'display:none' ?>">
+<th scope="row"><?php _e('Authentication Keys') ?>
+<div class="key-labels textright">
+<label for="public_key"><?php _e('Public Key:') ?></label ><br />
+<label for="private_key"><?php _e('Private Key:') ?></label>
+</div></th>
+<td><br /><input name="public_key" type="text" id="public_key" value=""<?php if( defined('FTP_PUBKEY') ) echo ' disabled="disabled"' ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value=""<?php if( defined('FTP_PRIKEY') ) echo ' disabled="disabled"' ?> size="40" />
+<div><?php _e('Enter the location on the server where the keys are located. If a passphrase is needed, enter that in the password field above.') ?></div></td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><?php _e('Connection Type') ?></th>
+<td>
+<fieldset><legend class="hidden"><?php _e('Connection Type') ?></legend>
+<label><input id="ftp" name="connection_type" type="radio" value="ftp" <?php checked('ftp', $connection_type); if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"'; ?>/> <?php _e('FTP') ?></label><br />
+<label><input id="ftps" name="connection_type" type="radio" value="ftps" <?php checked('ftps', $connection_type); if ( defined('FTP_SSH') || defined('FTP_SSH') ) echo ' disabled="disabled"'; ?>/> <?php _e('FTPS (SSL)') ?></label><br />
+<?php if ( extension_loaded('ssh2') ) { ?><label><input id="ssh" name="connection_type" type="radio" value="ssh" <?php checked('ssh', $connection_type); if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"'; ?>/> <?php _e('SSH') ?></label><?php } ?>
+</fieldset>
+</td>
+</tr>
+</table>
+
+<?php if ( isset( $_POST['version'] ) ) : ?>
+<input type="hidden" name="version" value="<?php echo attribute_escape($_POST['version']) ?>" />
+<?php endif; ?>
+<?php if ( isset( $_POST['locale'] ) ) : ?>
+<input type="hidden" name="locale" value="<?php echo attribute_escape($_POST['locale']) ?>" />
+<?php endif; ?>
+<p class="submit">
+<input id="upgrade" name="upgrade" type="submit" class="button" value="<?php _e('Proceed'); ?>" />
+</p>
+</div>
+</form>
+<?php
+ return false;
+}
+
+?>
* File contains all the administration image manipulation functions.
*
* @package WordPress
+ * @subpackage Administration
*/
/**
- * wp_create_thumbnail() - Create a thumbnail from an Image given a maximum side size.
+ * Create a thumbnail from an Image given a maximum side size.
*
- * @package WordPress
- * @param mixed $file Filename of the original image, Or attachment id
- * @param int $max_side Maximum length of a single side for the thumbnail
- * @return string Thumbnail path on success, Error string on failure
+ * This function can handle most image file formats which PHP supports. If PHP
+ * does not have the functionality to save in a file of the same format, the
+ * thumbnail will be created as a jpeg.
+ *
+ * @since 1.2.0
*
- * This function can handle most image file formats which PHP supports.
- * If PHP does not have the functionality to save in a file of the same format, the thumbnail will be created as a jpeg.
+ * @param mixed $file Filename of the original image, Or attachment id.
+ * @param int $max_side Maximum length of a single side for the thumbnail.
+ * @return string Thumbnail path on success, Error string on failure.
*/
function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
-
$thumbpath = image_resize( $file, $max_side, $max_side );
return apply_filters( 'wp_create_thumbnail', $thumbpath );
}
/**
- * wp_crop_image() - Crop an Image to a given size.
+ * Crop an Image to a given size.
*
- * @package WordPress
- * @internal Missing Long Description
- * @param int $src_file The source file
- * @param int $src_x The start x position to crop from
- * @param int $src_y The start y position to crop from
- * @param int $src_w The width to crop
- * @param int $src_h The height to crop
- * @param int $dst_w The destination width
- * @param int $dst_h The destination height
- * @param int $src_abs If the source crop points are absolute
- * @param int $dst_file The destination file to write to
- * @return string New filepath on success, String error message on failure
+ * @since 2.1.0
*
+ * @param string|int $src_file The source file or Attachment ID.
+ * @param int $src_x The start x position to crop from.
+ * @param int $src_y The start y position to crop from.
+ * @param int $src_w The width to crop.
+ * @param int $src_h The height to crop.
+ * @param int $dst_w The destination width.
+ * @param int $dst_h The destination height.
+ * @param int $src_abs Optional. If the source crop points are absolute.
+ * @param string $dst_file Optional. The destination file to write to.
+ * @return string New filepath on success, String error message on failure.
*/
function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
if ( is_numeric( $src_file ) ) // Handle int as attachment ID
}
/**
- * wp_generate_attachment_metadata() - Generate post Image attachment Metadata
+ * Generate post image attachment meta data.
*
- * @package WordPress
- * @internal Missing Long Description
- * @param int $attachment_id Attachment Id to process
- * @param string $file Filepath of the Attached image
- * @return mixed Metadata for attachment
+ * @since 2.1.0
*
+ * @param int $attachment_id Attachment Id to process.
+ * @param string $file Filepath of the Attached image.
+ * @return mixed Metadata for attachment.
*/
function wp_generate_attachment_metadata( $attachment_id, $file ) {
$attachment = get_post( $attachment_id );
$metadata = array();
if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) {
- $imagesize = getimagesize( $file );
+ $full_path_file = $file;
+ $imagesize = getimagesize( $full_path_file );
$metadata['width'] = $imagesize[0];
$metadata['height'] = $imagesize[1];
list($uwidth, $uheight) = wp_shrink_dimensions($metadata['width'], $metadata['height']);
$metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
+
+ // Make the file path relative to the upload dir
+ if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { // Get upload directory
+ if ( 0 === strpos($file, $uploads['basedir']) ) {// Check that the upload base exists in the file path
+ $file = str_replace($uploads['basedir'], '', $file); // Remove upload dir from the file path
+ $file = ltrim($file, '/');
+ }
+ }
$metadata['file'] = $file;
// make thumbnails and other intermediate sizes
- $sizes = array('thumbnail', 'medium');
+ $sizes = array('thumbnail', 'medium', 'large');
$sizes = apply_filters('intermediate_image_sizes', $sizes);
-
+
foreach ($sizes as $size) {
- $resized = image_make_intermediate_size( $file, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop") );
+ $resized = image_make_intermediate_size( $full_path_file, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop") );
if ( $resized )
$metadata['sizes'][$size] = $resized;
}
-
+
// fetch additional metadata from exif/iptc
- $image_meta = wp_read_image_metadata( $file );
+ $image_meta = wp_read_image_metadata( $full_path_file );
if ($image_meta)
$metadata['image_meta'] = $image_meta;
}
+
return apply_filters( 'wp_generate_attachment_metadata', $metadata );
}
/**
- * wp_load_image() - Load an image which PHP Supports.
+ * Load an image from a string, if PHP supports it.
*
- * @package WordPress
- * @internal Missing Long Description
- * @param string $file Filename of the image to load
- * @return resource The resulting image resource on success, Error string on failure.
+ * @since 2.1.0
*
+ * @param string $file Filename of the image to load.
+ * @return resource The resulting image resource on success, Error string on failure.
*/
function wp_load_image( $file ) {
if ( is_numeric( $file ) )
}
/**
- * get_udims() - Calculated the new dimentions for downsampled images
+ * Calculated the new dimentions for a downsampled image.
*
- * @package WordPress
- * @internal Missing Description
+ * @since 2.0.0
* @see wp_shrink_dimensions()
- * @param int $width Current width of the image
- * @param int $height Current height of the image
- * @return mixed Array(height,width) of shrunk dimensions.
*
+ * @param int $width Current width of the image
+ * @param int $height Current height of the image
+ * @return mixed Array(height,width) of shrunk dimensions.
*/
function get_udims( $width, $height) {
return wp_shrink_dimensions( $width, $height );
}
+
/**
- * wp_shrink_dimensions() - Calculates the new dimentions for a downsampled image.
+ * Calculates the new dimentions for a downsampled image.
*
- * @package WordPress
- * @internal Missing Long Description
- * @param int $width Current width of the image
- * @param int $height Current height of the image
- * @param int $wmax Maximum wanted width
- * @param int $hmax Maximum wanted height
- * @return mixed Array(height,width) of shrunk dimensions.
+ * @since 2.0.0
+ * @see wp_constrain_dimensions()
*
+ * @param int $width Current width of the image
+ * @param int $height Current height of the image
+ * @param int $wmax Maximum wanted width
+ * @param int $hmax Maximum wanted height
+ * @return mixed Array(height,width) of shrunk dimensions.
*/
function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
}
-// convert a fraction string to a decimal
+/**
+ * Convert a fraction string to a decimal.
+ *
+ * @since 2.5.0
+ *
+ * @param string $str
+ * @return int|float
+ */
function wp_exif_frac2dec($str) {
@list( $n, $d ) = explode( '/', $str );
if ( !empty($d) )
return $str;
}
-// convert the exif date format to a unix timestamp
+/**
+ * Convert the exif date format to a unix timestamp.
+ *
+ * @since 2.5.0
+ *
+ * @param string $str
+ * @return int
+ */
function wp_exif_date2ts($str) {
- // seriously, who formats a date like 'YYYY:MM:DD hh:mm:ss'?
@list( $date, $time ) = explode( ' ', trim($str) );
@list( $y, $m, $d ) = explode( ':', $date );
return strtotime( "{$y}-{$m}-{$d} {$time}" );
}
-// get extended image metadata, exif or iptc as available
+/**
+ * Get extended image metadata, exif or iptc as available.
+ *
+ * Retrieves the EXIF metadata aperture, credit, camera, caption, copyright, iso
+ * created_timestamp, focal_length, shutter_speed, and title.
+ *
+ * The IPTC metadata that is retrieved is APP13, credit, byline, created date
+ * and time, caption, copyright, and title. Also includes FNumber, Model,
+ * DateTimeDigitized, FocalLength, ISOSpeedRatings, and ExposureTime.
+ *
+ * @todo Try other exif libraries if available.
+ * @since 2.5.0
+ *
+ * @param string $file
+ * @return bool|array False on failure. Image metadata array on success.
+ */
function wp_read_image_metadata( $file ) {
if ( !file_exists( $file ) )
return false;
list(,,$sourceImageType) = getimagesize( $file );
- // exif contains a bunch of data we'll probably never need formatted in ways that are difficult to use.
- // We'll normalize it and just extract the fields that are likely to be useful. Fractions and numbers
- // are converted to floats, dates to unix timestamps, and everything else to strings.
+ // exif contains a bunch of data we'll probably never need formatted in ways
+ // that are difficult to use. We'll normalize it and just extract the fields
+ // that are likely to be useful. Fractions and numbers are converted to
+ // floats, dates to unix timestamps, and everything else to strings.
$meta = array(
'aperture' => 0,
'credit' => '',
'title' => '',
);
- // read iptc first, since it might contain data not available in exif such as caption, description etc
+ // read iptc first, since it might contain data not available in exif such
+ // as caption, description etc
if ( is_callable('iptcparse') ) {
getimagesize($file, $info);
if ( !empty($info['APP13']) ) {
$meta['credit'] = utf8_encode(trim($iptc['2#110'][0]));
elseif ( !empty($iptc['2#080'][0]) ) // byline
$meta['credit'] = utf8_encode(trim($iptc['2#080'][0]));
- if ( !empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0]) ) // created datee and time
+ if ( !empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0]) ) // created date and time
$meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]);
if ( !empty($iptc['2#120'][0]) ) // caption
$meta['caption'] = utf8_encode(trim($iptc['2#120'][0]));
if (!empty($exif['ExposureTime']))
$meta['shutter_speed'] = wp_exif_frac2dec( $exif['ExposureTime'] );
}
- // FIXME: try other exif libraries if available
return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType );
}
-// is the file a real image file?
+/**
+ * Validate that file is an image.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path File path to test if valid image.
+ * @return bool True if valid image, false if not valid image.
+ */
function file_is_valid_image($path) {
$size = @getimagesize($path);
return !empty($size);
}
-// is the file an image suitable for displaying within a web page?
+/**
+ * Validate that file is suitable for displaying within a web page.
+ *
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'file_is_displayable_image' on $result and $path.
+ *
+ * @param string $path File path to test.
+ * @return bool True if suitable, false if not suitable.
+ */
function file_is_displayable_image($path) {
$info = @getimagesize($path);
if ( empty($info) )
$result = false;
- elseif ( !in_array($info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) )
- // only gif, jpeg and png images can reliably be displayed
- $result = false;
- elseif ( $info['channels'] > 0 && $info['channels'] != 3 ) {
- // some web browsers can't display cmyk or grayscale jpegs
+ elseif ( !in_array($info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) ) // only gif, jpeg and png images can reliably be displayed
$result = false;
- }
else
$result = true;
-
+
return apply_filters('file_is_displayable_image', $result, $path);
}
<?php
+/**
+ * WordPress Administration Importer API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+/**
+ * Retrieve list of importers.
+ *
+ * @since 2.0.0
+ *
+ * @return array
+ */
function get_importers() {
global $wp_importers;
if ( is_array($wp_importers) )
return $wp_importers;
}
+/**
+ * Register importer for WordPress.
+ *
+ * @since 2.0.0
+ *
+ * @param string $id Importer tag. Used to uniquely identify importer.
+ * @param string $name Importer name and title.
+ * @param string $description Importer description.
+ * @param callback $callback Callback to run.
+ * @return WP_Error Returns WP_Error when $callback is WP_Error.
+ */
function register_importer( $id, $name, $description, $callback ) {
global $wp_importers;
if ( is_wp_error( $callback ) )
$wp_importers[$id] = array ( $name, $description, $callback );
}
+/**
+ * Cleanup importer.
+ *
+ * Removes attachment based on ID.
+ *
+ * @since 2.0.0
+ *
+ * @param string $id Importer ID.
+ */
function wp_import_cleanup( $id ) {
wp_delete_attachment( $id );
}
+/**
+ * Handle importer uploading and add attachment.
+ *
+ * @since 2.0.0
+ *
+ * @return array
+ */
function wp_import_handle_upload() {
$overrides = array( 'test_form' => false, 'test_type' => false );
$_FILES['import']['name'] .= '.import';
<?php
-
+/**
+ * WordPress Administration Media API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function media_upload_tabs() {
$_default_tabs = array(
- 'type' => __('Choose File'), // handler action suffix => tab text
+ 'type' => __('From Computer'), // handler action suffix => tab text
+ 'type_url' => __('From URL'),
'gallery' => __('Gallery'),
- 'library' => __('Media Library'),
+ 'library' => __('Media Library')
);
return apply_filters('media_upload_tabs', $_default_tabs);
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $tabs
+ * @return unknown
+ */
function update_gallery_tab($tabs) {
global $wpdb;
+
if ( !isset($_REQUEST['post_id']) ) {
unset($tabs['gallery']);
return $tabs;
}
+
if ( intval($_REQUEST['post_id']) )
$attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id'])));
+ if ( empty($attachments) ) {
+ unset($tabs['gallery']);
+ return $tabs;
+ }
+
$tabs['gallery'] = sprintf(__('Gallery (%s)'), "<span id='attachments-count'>$attachments</span>");
return $tabs;
}
add_filter('media_upload_tabs', 'update_gallery_tab');
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
function the_media_upload_tabs() {
global $redir_tab;
$tabs = media_upload_tabs();
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $id
+ * @param unknown_type $alt
+ * @param unknown_type $title
+ * @param unknown_type $align
+ * @param unknown_type $url
+ * @param unknown_type $rel
+ * @param unknown_type $size
+ * @return unknown
+ */
function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') {
- $html = get_image_tag($id, $alt, $title, $align, $size);
+ $htmlalt = ( empty($alt) ) ? $title : $alt;
+
+ $html = get_image_tag($id, $htmlalt, $title, $align, $size);
$rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : '';
return $html;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $html
+ * @param unknown_type $id
+ * @param unknown_type $alt
+ * @param unknown_type $title
+ * @param unknown_type $align
+ * @param unknown_type $url
+ * @param unknown_type $size
+ * @return unknown
+ */
function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) {
if ( empty($alt) || apply_filters( 'disable_captions', '' ) ) return $html;
$html = preg_replace( '/align[^\s\'"]+\s?/', '', $html );
if ( empty($align) ) $align = 'none';
+ $alt = ! empty($alt) ? addslashes($alt) : '';
+
$shcode = '[caption id="' . $id . '" align="align' . $align
. '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/caption]';
}
add_filter( 'image_send_to_editor', 'image_add_caption', 20, 7 );
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $html
+ */
function media_send_to_editor($html) {
- ?>
+?>
<script type="text/javascript">
/* <![CDATA[ */
var win = window.dialogArguments || opener || parent || top;
exit;
}
-// this handles the file upload POST itself, creating the attachment post
+/**
+ * {@internal Missing Short Description}}
+ *
+ * This handles the file upload POST itself, creating the attachment post.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $file_id
+ * @param unknown_type $post_id
+ * @param unknown_type $post_data
+ * @return unknown
+ */
function media_handle_upload($file_id, $post_id, $post_data = array()) {
$overrides = array('test_form'=>false);
- $file = wp_handle_upload($_FILES[$file_id], $overrides);
+
+ $time = current_time('mysql');
+ if ( $post = get_post($post_id) ) {
+ if ( substr( $post->post_date, 0, 4 ) > 0 )
+ $time = $post->post_date;
+ }
+
+ $file = wp_handle_upload($_FILES[$file_id], $overrides, $time);
if ( isset($file['error']) )
return new WP_Error( 'upload_error', $file['error'] );
), $post_data );
// Save the data
- $id = wp_insert_attachment($attachment, $file, $post_parent);
+ $id = wp_insert_attachment($attachment, $file, $post_id);
if ( !is_wp_error($id) ) {
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $file_array
+ * @param unknown_type $post_id
+ * @param unknown_type $desc
+ * @param unknown_type $post_data
+ * @return unknown
+ */
function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) {
$overrides = array('test_form'=>false);
$file = wp_handle_sideload($file_array, $overrides);
), $post_data );
// Save the data
- $id = wp_insert_attachment($attachment, $file, $post_parent);
+ $id = wp_insert_attachment($attachment, $file, $post_id);
if ( !is_wp_error($id) ) {
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
return $url;
return $id;
}
-
-// wrap iframe content (produced by $content_func) in a doctype, html head/body etc
-// any additional function args will be passed to content_func
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Wrap iframe content (produced by $content_func) in a doctype, html head/body
+ * etc any additional function args will be passed to content_func.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $content_func
+ */
function wp_iframe($content_func /* ... */) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
function media_buttons() {
global $post_ID, $temp_ID;
$uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
- $context = apply_filters('media_buttons_context', __('Add media: %s'));
+ $context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
$media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
$media_title = __('Add Media');
$image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image");
add_action( 'media_buttons', 'media_buttons' );
add_action('media_upload_media', 'media_upload_handler');
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function media_upload_form_handler() {
check_admin_referer('media-form');
+ if ( isset($_POST['send']) ) {
+ $keys = array_keys($_POST['send']);
+ $send_id = (int) array_shift($keys);
+ }
+
if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
$post = $_post = get_post($attachment_id, ARRAY_A);
if ( isset($attachment['post_content']) )
$post['post_excerpt'] = $attachment['post_excerpt'];
if ( isset($attachment['menu_order']) )
$post['menu_order'] = $attachment['menu_order'];
+ if ( isset($send_id) && $attachment_id == $send_id ) {
+ if ( isset($attachment['post_parent']) )
+ $post['post_parent'] = $attachment['post_parent'];
+ }
$post = apply_filters('attachment_fields_to_save', $post, $attachment);
wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
}
- if ( isset($_POST['insert-gallery']) )
- return media_send_to_editor('[gallery]');
+ if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ var win = window.dialogArguments || opener || parent || top;
+ win.tb_remove();
+ /* ]]> */
+ </script>
+ <?php
+ exit;
+ }
- if ( isset($_POST['send']) ) {
- $keys = array_keys($_POST['send']);
- $send_id = (int) array_shift($keys);
+ if ( isset($send_id) ) {
$attachment = stripslashes_deep( $_POST['attachments'][$send_id] );
$html = $attachment['post_title'];
if ( !empty($attachment['url']) ) {
return $errors;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function media_upload_image() {
+ $errors = array();
+ $id = 0;
+
if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
// Upload File button was clicked
$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
return media_upload_gallery();
}
+ if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
+ return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );
+
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $file
+ * @param unknown_type $post_id
+ * @param unknown_type $desc
+ * @return unknown
+ */
function media_sideload_image($file, $post_id, $desc = null) {
if (!empty($file) ) {
$file_array['name'] = basename($file);
- $file_array['tmp_name'] = download_url($file);
+ $tmp = download_url($file);
+ $file_array['tmp_name'] = $tmp;
$desc = @$desc;
+ if ( is_wp_error($tmp) ) {
+ @unlink($file_array['tmp_name']);
+ $file_array['tmp_name'] = '';
+ }
+
$id = media_handle_sideload($file_array, $post_id, $desc);
$src = $id;
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function media_upload_audio() {
+ $errors = array();
+ $id = 0;
+
if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
// Upload File button was clicked
$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
return media_upload_gallery();
}
+ if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
+ return wp_iframe( 'media_upload_type_url_form', 'audio', $errors, $id );
+
return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function media_upload_video() {
+ $errors = array();
+ $id = 0;
+
if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
// Upload File button was clicked
$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
return media_upload_gallery();
}
+ if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
+ return wp_iframe( 'media_upload_type_url_form', 'video', $errors, $id );
+
return wp_iframe( 'media_upload_type_form', 'video', $errors, $id );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function media_upload_file() {
+ $errors = array();
+ $id = 0;
+
if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
// Upload File button was clicked
$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
return media_upload_gallery();
}
+ if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
+ return wp_iframe( 'media_upload_type_url_form', 'file', $errors, $id );
+
return wp_iframe( 'media_upload_type_form', 'file', $errors, $id );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function media_upload_gallery() {
+ $errors = array();
+
if ( !empty($_POST) ) {
$return = media_upload_form_handler();
return wp_iframe( 'media_upload_gallery_form', $errors );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function media_upload_library() {
+ $errors = array();
if ( !empty($_POST) ) {
$return = media_upload_form_handler();
return wp_iframe( 'media_upload_library_form', $errors );
}
+/**
+ * Retrieve HTML for the image alignment radio buttons with the specified one checked.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $post
+ * @param unknown_type $checked
+ * @return unknown
+ */
+function image_align_input_fields($post, $checked='') {
+
+ $alignments = array('none' => 'None', 'left' => 'Left', 'center' => 'Center', 'right' => 'Right');
+ if ( !array_key_exists($checked, $alignments) )
+ $checked = 'none';
+
+ $out = array();
+ foreach ($alignments as $name => $label) {
+
+ $out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'".
+ ( $checked == $name ? " checked='checked'" : "" ) .
+ " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>" . __($label) . "</label>";
+ }
+ return join("\n", $out);
+}
+
+/**
+ * Retrieve HTML for the size radio buttons with the specified one checked.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $post
+ * @param unknown_type $checked
+ * @return unknown
+ */
+function image_size_input_fields($post, $checked='') {
+
+ // get a list of the actual pixel dimensions of each possible intermediate version of this image
+ $size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full size'));
+
+ foreach ( $size_names as $size => $name) {
+ $downsize = image_downsize($post->ID, $size);
+
+ // is this size selectable?
+ $enabled = ( $downsize[3] || 'full' == $size );
+ $css_id = "image-size-{$size}-{$post->ID}";
+ // if this size is the default but that's not available, don't select it
+ if ( $checked && !$enabled )
+ $checked = '';
+ // if $checked was not specified, default to the first available size that's bigger than a thumbnail
+ if ( !$checked && $enabled && 'thumbnail' != $size )
+ $checked = $size;
+
+ $html = "<div class='image-size-item'><input type='radio' ".( $enabled ? '' : "disabled='disabled'")."name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'".( $checked == $size ? " checked='checked'" : '') ." />";
+
+ $html .= "<label for='{$css_id}'>" . __($name). "</label>";
+ // only show the dimensions if that choice is available
+ if ( $enabled )
+ $html .= " <label for='{$css_id}' class='help'>" . sprintf( __("(%d × %d)"), $downsize[1], $downsize[2] ). "</label>";
+
+ $html .= '</div>';
+
+ $out[] = $html;
+ }
+
+ return array(
+ 'label' => __('Size'),
+ 'input' => 'html',
+ 'html' => join("\n", $out),
+ );
+}
+
+/**
+ * Retrieve HTML for the Link URL buttons with the default link type as specified.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $post
+ * @param unknown_type $url_type
+ * @return unknown
+ */
+function image_link_input_fields($post, $url_type='') {
+
+ $file = wp_get_attachment_url($post->ID);
+ $link = get_attachment_link($post->ID);
+
+ $url = '';
+ if ( $url_type == 'file' )
+ $url = $file;
+ elseif ( $url_type == 'post' )
+ $url = $link;
+
+ return "<input type='text' class='urlfield' name='attachments[$post->ID][url]' value='" . attribute_escape($url) . "' /><br />
+ <button type='button' class='button urlnone' title=''>" . __('None') . "</button>
+ <button type='button' class='button urlfile' title='" . attribute_escape($file) . "'>" . __('File URL') . "</button>
+ <button type='button' class='button urlpost' title='" . attribute_escape($link) . "'>" . __('Post URL') . "</button>
+";
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $form_fields
+ * @param unknown_type $post
+ * @return unknown
+ */
function image_attachment_fields_to_edit($form_fields, $post) {
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
$form_fields['post_title']['required'] = true;
$form_fields['post_content']['label'] = __('Description');
- $thumb = wp_get_attachment_thumb_url($post->ID);
-
$form_fields['align'] = array(
'label' => __('Alignment'),
'input' => 'html',
- 'html' => "
- <input type='radio' name='attachments[$post->ID][align]' id='image-align-none-$post->ID' value='none' checked='checked' />
- <label for='image-align-none-$post->ID' class='align image-align-none-label'>" . __('None') . "</label>
- <input type='radio' name='attachments[$post->ID][align]' id='image-align-left-$post->ID' value='left' />
- <label for='image-align-left-$post->ID' class='align image-align-left-label'>" . __('Left') . "</label>
- <input type='radio' name='attachments[$post->ID][align]' id='image-align-center-$post->ID' value='center' />
- <label for='image-align-center-$post->ID' class='align image-align-center-label'>" . __('Center') . "</label>
- <input type='radio' name='attachments[$post->ID][align]' id='image-align-right-$post->ID' value='right' />
- <label for='image-align-right-$post->ID' class='align image-align-right-label'>" . __('Right') . "</label>\n",
- );
- $form_fields['image-size'] = array(
- 'label' => __('Size'),
- 'input' => 'html',
- 'html' => "
- " . ( $thumb ? "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-thumb-$post->ID' value='thumbnail' />
- <label for='image-size-thumb-$post->ID'>" . __('Thumbnail') . "</label>
- " : '' ) . "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-medium-$post->ID' value='medium' checked='checked' />
- <label for='image-size-medium-$post->ID'>" . __('Medium') . "</label>
- <input type='radio' name='attachments[$post->ID][image-size]' id='image-size-full-$post->ID' value='full' />
- <label for='image-size-full-$post->ID'>" . __('Full size') . "</label>",
+ 'html' => image_align_input_fields($post, get_option('image_default_align')),
);
+
+ $form_fields['image-size'] = image_size_input_fields($post, get_option('image_default_size'));
}
return $form_fields;
}
add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2);
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $form_fields
+ * @param unknown_type $post
+ * @return unknown
+ */
function media_single_attachment_fields_to_edit( $form_fields, $post ) {
unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']);
return $form_fields;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $post
+ * @param unknown_type $attachment
+ * @return unknown
+ */
function image_attachment_fields_to_save($post, $attachment) {
if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {
if ( strlen(trim($post['post_title'])) == 0 ) {
add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2);
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $html
+ * @param unknown_type $attachment_id
+ * @param unknown_type $attachment
+ * @return unknown
+ */
function image_media_send_to_editor($html, $attachment_id, $attachment) {
$post =& get_post($attachment_id);
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3);
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $post
+ * @param unknown_type $errors
+ * @return unknown
+ */
function get_attachment_fields_to_edit($post, $errors = null) {
if ( is_int($post) )
$post =& get_post($post);
$post = (object) $post;
$edit_post = sanitize_post($post, 'edit');
- $file = wp_get_attachment_url($post->ID);
- $link = get_attachment_link($post->ID);
$form_fields = array(
'post_title' => array(
'url' => array(
'label' => __('Link URL'),
'input' => 'html',
- 'html' => "
- <input type='text' name='attachments[$post->ID][url]' value='" . attribute_escape($file) . "' /><br />
- <button type='button' class='button url-$post->ID' value=''>" . __('None') . "</button>
- <button type='button' class='button url-$post->ID' value='" . attribute_escape($file) . "'>" . __('File URL') . "</button>
- <button type='button' class='button url-$post->ID' value='" . attribute_escape($link) . "'>" . __('Post URL') . "</button>
- <script type='text/javascript'>
- jQuery('button.url-$post->ID').bind('click', function(){jQuery(this).siblings('input').val(this.value);});
- </script>\n",
+ 'html' => image_link_input_fields($post, get_option('image_default_link_type')),
'helps' => __('Enter a link URL or click above for presets.'),
),
- 'menu_order' => array(
+ 'menu_order' => array(
'label' => __('Order'),
'value' => $edit_post->menu_order
),
return $form_fields;
}
+/**
+ * Retrieve HTML for media items of post gallery.
+ *
+ * The HTML markup retrieved will be created for the progress of SWF Upload
+ * component. Will also create link for showing and hiding the form to modify
+ * the image attachment.
+ *
+ * @since unknown
+ *
+ * @param int $post_id Optional. Post ID.
+ * @param array $errors Errors for attachment, if any.
+ * @return string
+ */
function get_media_items( $post_id, $errors ) {
if ( $post_id ) {
$post = get_post($post_id);
$attachments[$attachment->ID] = $attachment;
}
- if ( empty($attachments) )
- return '';
-
- foreach ( $attachments as $id => $attachment )
+ $output = '';
+ foreach ( (array) $attachments as $id => $attachment )
if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress'><div class='bar'></div></div><div id='media-upload-error-$id'></div><div class='filename'></div>$item\n</div>";
return $output;
}
+/**
+ * Retrieve HTML form for modifying the image attachment.
+ *
+ * @since unknown
+ *
+ * @param int $attachment_id Attachment ID for modification.
+ * @param string|array $args Optional. Override defaults.
+ * @return string HTML form for attachment.
+ */
function get_media_item( $attachment_id, $args = null ) {
global $redir_tab;
- $default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true );
+ $default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true, 'show_title' => true );
$args = wp_parse_args( $args, $default_args );
extract( $args, EXTR_SKIP );
else
return false;
- $title_label = __('Title');
- $description_label = __('Description');
- $tags_label = __('Tags');
-
$toggle_on = __('Show');
$toggle_off = __('Hide');
$filename = basename($post->guid);
$title = attribute_escape($post->post_title);
- $description = attribute_escape($post->post_content);
+
if ( $_tags = get_the_tags($attachment_id) ) {
foreach ( $_tags as $tag )
$tags[] = $tag->name;
$tags = attribute_escape(join(', ', $tags));
}
+ $type = '';
if ( isset($post_mime_types) ) {
$keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
$type = array_shift($keys);
}
$display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
- $display_title = wp_html_excerpt($display_title, 60);
+ $display_title = $show_title ? "<div class='filename new'>" . wp_html_excerpt($display_title, 60) . "</div>" : '';
$gallery = ( (isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab']) || (isset($redir_tab) && 'gallery' == $redir_tab) ) ? true : false;
$order = '';
$type
$toggle_links
$order
- <div class='filename new'>$display_title</div>
+ $display_title
<table class='slidetoggle describe $class'>
<thead class='media-item-info'>
<tr>
if ( !empty($field[$field['input']]) )
$item .= $field[$field['input']];
elseif ( $field['input'] == 'textarea' ) {
- $item .= "<textarea type='text' id='$name' name='$name'>" . attribute_escape( $field['value'] ) . $aria_required . "</textarea>";
+ $item .= "<textarea type='text' id='$name' name='$name'" . $aria_required . ">" . htmlspecialchars( $field['value'] ) . "</textarea>";
} else {
$item .= "<input type='text' id='$name' name='$name' value='" . attribute_escape( $field['value'] ) . "'" . $aria_required . "/>";
}
foreach ( $hidden_fields as $name => $value )
$item .= "\t<input type='hidden' name='$name' id='$name' value='" . attribute_escape( $value ) . "' />\n";
+ if ( $post->post_parent < 1 && (int) $_REQUEST['post_id'] ) {
+ $parent = (int) $_REQUEST['post_id'];
+ $parent_name = "attachments[$attachment_id][post_parent]";
+
+ $item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='" . $parent . "' />\n";
+ }
+
return $item;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
function media_upload_header() {
?>
<script type="text/javascript">post_id = <?php echo intval($_REQUEST['post_id']); ?>;</script>
<?php
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $errors
+ */
function media_upload_form( $errors = null ) {
global $type, $tab;
$flash = false;
$flash = apply_filters('flash_uploader', $flash);
- $post_id = intval($_REQUEST['post_id']);
+ $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
?>
<div id="media-upload-notice">
<?php if ( $flash ) : ?>
<script type="text/javascript">
<!--
-jQuery(function($){
+SWFUpload.onload = function() {
swfu = new SWFUpload({
+ button_text: '<span class="button"><?php _e('Select Files'); ?></span>',
+ button_text_style: '.button { text-align: center; font-weight: bold; font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif; }',
+ button_height: "24",
+ button_width: "132",
+ button_image_url: '<?php echo includes_url('images/upload.png'); ?>',
+ button_placeholder_id: "flash-browse-button",
upload_url : "<?php echo attribute_escape( $flash_action_url ); ?>",
- flash_url : "<?php echo includes_url('js/swfupload/swfupload_f9.swf'); ?>",
+ flash_url : "<?php echo includes_url('js/swfupload/swfupload.swf'); ?>",
file_post_name: "async-upload",
file_types: "<?php echo apply_filters('upload_file_glob', '*.*'); ?>",
post_params : {
"short" : "1"
},
file_size_limit : "<?php echo wp_max_upload_size(); ?>b",
- swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available
- degraded_element_id : "html-upload-ui", // when swfupload is unavailable
file_dialog_start_handler : fileDialogStart,
file_queued_handler : fileQueued,
upload_start_handler : uploadStart,
upload_complete_handler : uploadComplete,
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
-
+ swfupload_pre_load_handler: swfuploadPreLoad,
+ swfupload_load_failed_handler: swfuploadLoadFailed,
+ custom_settings : {
+ degraded_element_id : "html-upload-ui", // id of the element displayed when swfupload is unavailable
+ swfupload_element_id : "flash-upload-ui" // id of the element displayed when swfupload is available
+ },
debug: false
});
- $("#flash-browse-button").bind( "click", function(){swfu.selectFiles();});
-});
+};
//-->
</script>
<div id="flash-upload-ui">
<?php do_action('pre-flash-upload-ui'); ?>
- <p><input id="flash-browse-button" type="button" value="<?php echo attribute_escape( __( 'Choose files to upload' ) ); ?>" class="button" /></p>
+
+ <div><?php _e( 'Choose files to upload' ); ?> <div id="flash-browse-button"></div></div>
<?php do_action('post-flash-upload-ui'); ?>
<p class="howto"><?php _e('After a file has been uploaded, you can add titles and descriptions.'); ?></p>
</div>
<div id="html-upload-ui">
<?php do_action('pre-html-upload-ui'); ?>
- <p>
+ <p id="async-upload-wrap">
<input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" name="html-upload" value="<?php echo attribute_escape(__('Upload')); ?>" /> <a href="#" onclick="return top.tb_remove();"><?php _e('Cancel'); ?></a>
</p>
+
<br class="clear" />
<?php if ( is_lighttpd_before_150() ): ?>
<p><?php _e('If you want to use all capabilities of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.'); ?></p>
<?php
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $type
+ * @param unknown_type $errors
+ * @param unknown_type $id
+ */
function media_upload_type_form($type = 'file', $errors = null, $id = null) {
media_upload_header();
$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
-
- $callback = "type_form_$type";
?>
<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form type-form validate" id="<?php echo $type; ?>-form">
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
<?php wp_nonce_field('media-form'); ?>
-<h3><?php _e('From Computer'); ?></h3>
+
+<h3 class="media-title"><?php _e('Add media files from your computer'); ?></h3>
+
<?php media_upload_form( $errors ); ?>
<script type="text/javascript">
});
-->
</script>
-<?php if ( $id && !is_wp_error($id) ) : ?>
<div id="media-items">
-<?php echo get_media_items( $id, $errors ); ?>
+<?php
+if ( $id ) {
+ if ( !is_wp_error($id) ) {
+ echo get_media_items( $id, $errors );
+ } else {
+ echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
+ exit;
+ }
+}
+?>
</div>
<input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
+<?php
+}
-<?php elseif ( is_callable($callback) ) : ?>
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $type
+ * @param unknown_type $errors
+ * @param unknown_type $id
+ */
+function media_upload_type_url_form($type = 'file', $errors = null, $id = null) {
+ media_upload_header();
-<div class="media-blank">
-<p style="text-align:center"><?php _e('— OR —'); ?></p>
-<h3><?php _e('From URL'); ?></h3>
-</div>
+ $post_id = intval($_REQUEST['post_id']);
+
+ $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
+ $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
+
+ $callback = "type_url_form_$type";
+?>
+
+<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form type-form validate" id="<?php echo $type; ?>-form">
+<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
+<?php wp_nonce_field('media-form'); ?>
+
+<?php if ( is_callable($callback) ) { ?>
+
+<h3 class="media-title"><?php _e('Add media file from URL'); ?></h3>
<script type="text/javascript">
//<![CDATA[
<?php echo call_user_func($callback); ?>
</div>
</div>
-<input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
</form>
<?php
- endif;
+ } else {
+ wp_die( __('Unknown action.') );
+ }
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $errors
+ */
function media_upload_gallery_form($errors) {
global $redir_tab;
<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="gallery-form">
<?php wp_nonce_field('media-form'); ?>
<?php //media_upload_form( $errors ); ?>
-<table class="widefat">
+<table class="widefat" cellspacing="0">
<thead><tr>
<th><?php _e('Media'); ?></th>
<th class="order-head"><?php _e('Order'); ?></th>
<div id="media-items">
<?php echo get_media_items($post_id, $errors); ?>
</div>
+
<p class="ml-submit">
-<input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
-<input type="submit" class="button insert-gallery" name="insert-gallery" value="<?php echo attribute_escape( __( 'Insert gallery into post' ) ); ?>" />
+<input type="submit" class="button savebutton" style="display:none;" name="save" id="save-all" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
<input type="hidden" name="type" value="<?php echo attribute_escape( $GLOBALS['type'] ); ?>" />
<input type="hidden" name="tab" value="<?php echo attribute_escape( $GLOBALS['tab'] ); ?>" />
</p>
+
+<div id="gallery-settings" style="display:none;">
+<div class="title"><?php _e('Gallery Settings'); ?></div>
+<table id="basic" class="describe"><tbody>
+ <tr>
+ <th scope="row" class="label">
+ <label>
+ <span class="alignleft"><?php _e('Link thumbnails to:'); ?></span>
+ </label>
+ </th>
+ <td class="field">
+ <input type="radio" name="linkto" id="linkto-file" value="file" />
+ <label for="linkto-file" class="radio"><?php _e('Image File'); ?></label>
+
+ <input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" />
+ <label for="linkto-post" class="radio"><?php _e('Attachment Page'); ?></label>
+ </td>
+ </tr>
+
+ <tr>
+ <th scope="row" class="label">
+ <label>
+ <span class="alignleft"><?php _e('Order images by:'); ?></span>
+ </label>
+ </th>
+ <td class="field">
+ <select id="orderby" name="orderby">
+ <option value="menu_order" selected="selected"><?php _e('Menu order'); ?></option>
+ <option value="post_name"><?php _e('Name'); ?></option>
+ <option value="ID"><?php _e('Date/Time'); ?></option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <th scope="row" class="label">
+ <label>
+ <span class="alignleft"><?php _e('Order:'); ?></span>
+ </label>
+ </th>
+ <td class="field">
+ <input type="radio" checked="checked" name="order" id="order-asc" value="asc" />
+ <label for="order-asc" class="radio"><?php _e('Ascending'); ?></label>
+
+ <input type="radio" name="order" id="order-desc" value="desc" />
+ <label for="order-desc" class="radio"><?php _e('Descending'); ?></label>
+ </td>
+ </tr>
+
+ <tr>
+ <th scope="row" class="label">
+ <label>
+ <span class="alignleft"><?php _e('Gallery columns:'); ?></span>
+ </label>
+ </th>
+ <td class="field">
+ <select id="columns" name="columns">
+ <option value="2"><?php _e('2'); ?></option>
+ <option value="3" selected="selected"><?php _e('3'); ?></option>
+ <option value="4"><?php _e('4'); ?></option>
+ <option value="5"><?php _e('5'); ?></option>
+ <option value="6"><?php _e('6'); ?></option>
+ <option value="7"><?php _e('7'); ?></option>
+ <option value="8"><?php _e('8'); ?></option>
+ <option value="9"><?php _e('9'); ?></option>
+ </select>
+ </td>
+ </tr>
+</tbody></table>
+
+<p class="ml-submit">
+<input type="button" class="button" style="display:none;" onmousedown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php echo attribute_escape( __( 'Insert gallery' ) ); ?>" />
+<input type="button" class="button" style="display:none;" onmousedown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php echo attribute_escape( __( 'Update gallery settings' ) ); ?>" />
+</p>
+</div>
</form>
<?php
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $errors
+ */
function media_upload_library_form($errors) {
global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types;
$form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=library&post_id=$post_id");
- $_GET['paged'] = intval($_GET['paged']);
+ $_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0;
if ( $_GET['paged'] < 1 )
$_GET['paged'] = 1;
$start = ( $_GET['paged'] - 1 ) * 10;
<input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
<input type="hidden" name="post_mime_type" value="<?php echo attribute_escape( $_GET['post_mime_type'] ); ?>" />
-<div id="search-filter">
- <label class="hidden" for="post-search-input"><?php _e('Search Media');?>:</label>
- <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
+<p id="media-search" class="search-box">
+ <label class="hidden" for="media-search-input"><?php _e('Search Media');?>:</label>
+ <input type="text" id="media-search-input" class="search-input" name="s" value="<?php the_search_query(); ?>" />
<input type="submit" value="<?php echo attribute_escape( __( 'Search Media' ) ); ?>" class="button" />
-</div>
+</p>
<ul class="subsubsub">
<?php
$page_links = paginate_links( array(
'base' => add_query_arg( 'paged', '%#%' ),
'format' => '',
+ 'prev_text' => __('«'),
+ 'next_text' => __('»'),
'total' => ceil($wp_query->found_posts / 10),
'current' => $_GET['paged']
));
echo "<div class='tablenav-pages'>$page_links</div>";
?>
-<div class="alignleft">
+<div class="alignleft actions">
<?php
$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
<?php
}
-function type_form_image() {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
+function type_url_form_image() {
if ( apply_filters( 'disable_captions', '' ) ) {
$alt = __('Alternate Text');
$alt_help = __('Also used as alternate text for the image');
}
+ $default_align = get_option('image_default_align');
+ if ( empty($default_align) )
+ $default_align = 'none';
+
return '
<table class="describe"><tbody>
<tr>
<th valign="top" scope="row" class="label" style="width:120px;">
- <span class="alignleft"><label for="src">' . __('Source') . '</label></span>
+ <span class="alignleft"><label for="src">' . __('Image URL') . '</label></span>
<span class="alignright"><img id="status_img" src="images/required.gif" title="required" alt="required" /></span>
</th>
<td class="field"><input id="src" name="src" value="" type="text" aria-required="true" onblur="addExtImage.getImageData()" /></td>
<tr class="align">
<th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
<td class="field">
- <input name="align" id="align-none" value="alignnone" onclick="addExtImage.align=this.value" type="radio" checked="checked" />
+ <input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' />
<label for="align-none" class="align image-align-none-label">' . __('None') . '</label>
- <input name="align" id="align-left" value="alignleft" onclick="addExtImage.align=this.value" type="radio" />
+ <input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'left' ? ' checked="checked"' : '').' />
<label for="align-left" class="align image-align-left-label">' . __('Left') . '</label>
- <input name="align" id="align-center" value="aligncenter" onclick="addExtImage.align=this.value" type="radio" />
+ <input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'center' ? ' checked="checked"' : '').' />
<label for="align-center" class="align image-align-center-label">' . __('Center') . '</label>
- <input name="align" id="align-right" value="alignright" onclick="addExtImage.align=this.value" type="radio" />
+ <input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'right' ? ' checked="checked"' : '').' />
<label for="align-right" class="align image-align-right-label">' . __('Right') . '</label>
</td>
</tr>
<tr>
<th valign="top" scope="row" class="label">
- <span class="alignleft"><label for="url">' . __('Link URL') . '</label></span>
+ <span class="alignleft"><label for="url">' . __('Link Image To:') . '</label></span>
</th>
<td class="field"><input id="url" name="url" value="" type="text" /><br />
}
-function type_form_audio() {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
+function type_url_form_audio() {
return '
<table class="describe"><tbody>
<tr>
';
}
-function type_form_video() {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
+function type_url_form_video() {
return '
<table class="describe"><tbody>
<tr>
';
}
-function type_form_file() {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
+function type_url_form_file() {
return '
<table class="describe"><tbody>
<tr>
';
}
-// support a GET parameter for disabling the flash uploader
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Support a GET parameter for disabling the flash uploader.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $flash
+ * @return unknown
+ */
function media_upload_use_flash($flash) {
- if ( array_key_exists('flash', $_REQUEST) )
- $flash = !empty($_REQUEST['flash']);
- return $flash;
+ if ( array_key_exists('flash', $_REQUEST) )
+ $flash = !empty($_REQUEST['flash']);
+ return $flash;
}
add_filter('flash_uploader', 'media_upload_use_flash');
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
function media_upload_flash_bypass() {
- echo '<p class="upload-flash-bypass">';
- printf( __('You are using the Flash uploader. Problems? Try the <a href="%s">Browser uploader</a> instead.'), clean_url(add_query_arg('flash', 0)) );
- echo '</p>';
+ echo '<p class="upload-flash-bypass">';
+ printf( __('You are using the Flash uploader. Problems? Try the <a href="%s">Browser uploader</a> instead.'), clean_url(add_query_arg('flash', 0)) );
+ echo '</p>';
}
-add_action('post-flash-upload-ui', 'media_upload_flash_bypass');
-
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
function media_upload_html_bypass() {
- echo '<p class="upload-html-bypass">';
- if ( array_key_exists('flash', $_REQUEST) )
- // the user manually selected the browser uploader, so let them switch back to Flash
- printf( __('You are using the Browser uploader. Try the <a href="%s">Flash uploader</a> instead.'), clean_url(add_query_arg('flash', 1)) );
- else
- // the user probably doesn't have Flash
- printf( __('You are using the Browser uploader.') );
-
- echo '</p>';
+ echo '<p class="upload-html-bypass">';
+ if ( array_key_exists('flash', $_REQUEST) )
+ // the user manually selected the browser uploader, so let them switch back to Flash
+ printf( __('You are using the Browser uploader. Try the <a href="%s">Flash uploader</a> instead.'), clean_url(add_query_arg('flash', 1)) );
+ else
+ // the user probably doesn't have Flash
+ printf( __('You are using the Browser uploader.') );
+
+ echo '</p>';
}
add_action('post-flash-upload-ui', 'media_upload_flash_bypass');
add_action('post-html-upload-ui', 'media_upload_html_bypass');
-// make sure the GET parameter sticks when we submit a form
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Make sure the GET parameter sticks when we submit a form.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $url
+ * @return unknown
+ */
function media_upload_bypass_url($url) {
- if ( array_key_exists('flash', $_REQUEST) )
- $url = add_query_arg('flash', intval($_REQUEST['flash']));
- return $url;
+ if ( array_key_exists('flash', $_REQUEST) )
+ $url = add_query_arg('flash', intval($_REQUEST['flash']));
+ return $url;
}
add_filter('media_upload_form_url', 'media_upload_bypass_url');
<?php
+/**
+ * Misc WordPress Administration API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function got_mod_rewrite() {
$got_rewrite = apache_mod_loaded('mod_rewrite', true);
return apply_filters('got_rewrite', $got_rewrite);
}
-// Returns an array of strings from a file (.htaccess ) from between BEGIN
-// and END markers.
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $filename
+ * @param unknown_type $marker
+ * @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
+ */
function extract_from_markers( $filename, $marker ) {
$result = array ();
return $result;
}
-// Inserts an array of strings into a file (.htaccess ), placing it between
-// BEGIN and END markers. Replaces existing marked info. Retains surrounding
-// data. Creates file if none exists.
-// Returns true on write success, false on failure.
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Inserts an array of strings into a file (.htaccess ), placing it between
+ * BEGIN and END markers. Replaces existing marked info. Retains surrounding
+ * data. Creates file if none exists.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $filename
+ * @param unknown_type $marker
+ * @param unknown_type $insertion
+ * @return bool True on write success, false on failure.
+ */
function insert_with_markers( $filename, $marker, $insertion ) {
if (!file_exists( $filename ) || is_writeable( $filename ) ) {
if (!file_exists( $filename ) ) {
/**
* Updates the htaccess file with the current rules if it is writable.
*
- * Always writes to the file if it exists and is writable to ensure that we blank out old rules.
+ * Always writes to the file if it exists and is writable to ensure that we
+ * blank out old rules.
+ *
+ * @since unknown
*/
-
function save_mod_rewrite_rules() {
global $wp_rewrite;
return false;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $file
+ */
function update_recently_edited( $file ) {
$oldfiles = (array ) get_option( 'recently_edited' );
if ( $oldfiles ) {
update_option( 'recently_edited', $oldfiles );
}
-// If siteurl or home changed, flush rewrite rules.
+/**
+ * If siteurl or home changed, flush rewrite rules.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $old_value
+ * @param unknown_type $value
+ */
function update_home_siteurl( $old_value, $value ) {
global $wp_rewrite;
add_action( 'update_option_home', 'update_home_siteurl', 10, 2 );
add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 );
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $url
+ * @return unknown
+ */
function url_shorten( $url ) {
$short_url = str_replace( 'http://', '', stripslashes( $url ));
$short_url = str_replace( 'www.', '', $short_url );
return $short_url;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $vars
+ */
function wp_reset_vars( $vars ) {
for ( $i=0; $i<count( $vars ); $i += 1 ) {
$var = $vars[$i];
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $message
+ */
+function show_message($message) {
+ if( is_wp_error($message) ){
+ if( $message->get_error_data() )
+ $message = $message->get_error_message() . ': ' . $message->get_error_data();
+ else
+ $message = $message->get_error_message();
+ }
+ echo "<p>$message</p>\n";
+}
+
?>
--- /dev/null
+<?php
+/**
+ * WordPress Plugin Install Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Retrieve plugin installer pages from WordPress Plugins API.
+ *
+ * It is possible for a plugin to override the Plugin API result with three
+ * filters. Assume this is for plugins, which can extend on the Plugin Info to
+ * offer more choices. This is very powerful and must be used with care, when
+ * overridding the filters.
+ *
+ * The first filter, 'plugins_api_args', is for the args and gives the action as
+ * the second parameter. The hook for 'plugins_api_args' must ensure that an
+ * object is returned.
+ *
+ * The second filter, 'plugins_api', is the result that would be returned.
+ *
+ * @since 2.7.0
+ *
+ * @param string $action
+ * @param array|object $args Optional. Arguments to serialize for the Plugin Info API.
+ * @return mixed
+ */
+function plugins_api($action, $args = null) {
+
+ if( is_array($args) )
+ $args = (object)$args;
+
+ if ( !isset($args->per_page) )
+ $args->per_page = 24;
+
+ $args = apply_filters('plugins_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter.
+ $res = apply_filters('plugins_api', false, $action, $args); //NOTE: Allows a plugin to completely override the builtin WordPress.org API.
+
+ if ( ! $res ) {
+ $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) );
+ if ( is_wp_error($request) ) {
+ $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occured during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message() );
+ } else {
+ $res = unserialize($request['body']);
+ if ( ! $res )
+ $res = new WP_Error('plugins_api_failed', __('An unknown error occured'), $request['body']);
+ }
+ }
+
+ return apply_filters('plugins_api_result', $res, $action, $args);
+}
+
+/**
+ * Retrieve popular WordPress plugin tags.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args
+ * @return array
+ */
+function install_popular_tags( $args = array() ) {
+ if ( ! ($cache = wp_cache_get('popular_tags', 'api')) && ! ($cache = get_option('wporg_popular_tags')) )
+ add_option('wporg_popular_tags', array(), '', 'no'); ///No autoload.
+
+ if ( $cache && $cache->timeout + 3 * 60 * 60 > time() )
+ return $cache->cached;
+
+ $tags = plugins_api('hot_tags', $args);
+
+ if ( is_wp_error($tags) )
+ return $tags;
+
+ $cache = (object) array('timeout' => time(), 'cached' => $tags);
+
+ update_option('wporg_popular_tags', $cache);
+ wp_cache_set('popular_tags', $cache, 'api');
+
+ return $tags;
+}
+add_action('install_plugins_search', 'install_search', 10, 1);
+
+/**
+ * Display search results and display as tag cloud.
+ *
+ * @since 2.7.0
+ *
+ * @param string $page
+ */
+function install_search($page) {
+ $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
+ $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
+
+ $args = array();
+
+ switch( $type ){
+ case 'tag':
+ $args['tag'] = sanitize_title_with_dashes($term);
+ break;
+ case 'term':
+ $args['search'] = $term;
+ break;
+ case 'author':
+ $args['author'] = $term;
+ break;
+ }
+
+ $args['page'] = $page;
+
+ $api = plugins_api('query_plugins', $args);
+
+ if ( is_wp_error($api) )
+ wp_die($api);
+
+ add_action('install_plugins_table_header', 'install_search_form');
+
+ display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
+
+ return;
+}
+
+add_action('install_plugins_dashboard', 'install_dashboard');
+function install_dashboard() {
+ ?>
+ <p><?php _e('Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> or upload a plugin in .zip format via this page.') ?></p>
+
+ <h4><?php _e('Search') ?></h4>
+ <?php install_search_form('<a href="' . add_query_arg('show-help', !isset($_REQUEST['show-help'])) .'" onclick="jQuery(\'#search-help\').toggle(); return false;">' . __('[need help?]') . '</a>') ?>
+ <div id="search-help" style="display: <?php echo isset($_REQUEST['show-help']) ? 'block' : 'none'; ?>;">
+ <p> <?php _e('You may search based on 3 criteria:') ?><br />
+ <?php _e('<strong>Term:</strong> Searches plugins names and descriptions for the specified term') ?><br />
+ <?php _e('<strong>Tag:</strong> Searches for plugins tagged as such') ?><br />
+ <?php _e('<strong>Author:</strong> Searches for plugins created by the Author, or which the Author contributed to.') ?></p>
+ </div>
+
+ <h4><?php _e('Install a plugin in .zip format') ?></h4>
+ <p><?php _e('If you have a plugin in a .zip format, You may install it by uploading it here.') ?></p>
+ <form method="post" enctype="multipart/form-data" action="<?php echo admin_url('plugin-install.php?tab=upload') ?>">
+ <?php wp_nonce_field( 'plugin-upload') ?>
+ <input type="file" name="pluginzip" />
+ <input type="submit" class="button" value="<?php _e('Install Now') ?>" />
+ </form>
+
+ <h4><?php _e('Popular tags') ?></h4>
+ <p><?php _e('You may also browse based on the most popular tags in the Plugin Directory:') ?></p>
+ <?php
+
+ $api_tags = install_popular_tags();
+
+ //Set up the tags in a way which can be interprated by wp_generate_tag_cloud()
+ $tags = array();
+ foreach ( (array)$api_tags as $tag )
+ $tags[ $tag['name'] ] = (object) array(
+ 'link' => clean_url( admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ),
+ 'name' => $tag['name'],
+ 'id' => sanitize_title_with_dashes($tag['name']),
+ 'count' => $tag['count'] );
+ echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%d plugin'), 'multiple_text' => __('%d plugins') ) );
+}
+
+/**
+ * Display search form for searching plugins.
+ *
+ * @since 2.7.0
+ */
+function install_search_form(){
+ $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
+ $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
+
+ ?><form id="search-plugins" method="post" action="<?php echo admin_url('plugin-install.php?tab=search') ?>">
+ <select name="type" id="typeselector">
+ <option value="term"<?php selected('term', $type) ?>><?php _e('Term') ?></option>
+ <option value="author"<?php selected('author', $type) ?>><?php _e('Author') ?></option>
+ <option value="tag"<?php selected('tag', $type) ?>><?php _e('Tag') ?></option>
+ </select>
+ <input type="text" name="s" id="search-field" value="<?php echo attribute_escape($term) ?>" />
+ <input type="submit" name="search" value="<?php echo attribute_escape(__('Search')) ?>" class="button" />
+ </form><?php
+}
+
+add_action('install_plugins_featured', 'install_featured', 10, 1);
+/**
+ * Display featured plugins.
+ *
+ * @since 2.7.0
+ *
+ * @param string $page
+ */
+function install_featured($page = 1) {
+ $args = array('browse' => 'featured', 'page' => $page);
+ $api = plugins_api('query_plugins', $args);
+ if ( is_wp_error($api) )
+ wp_die($api);
+ display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
+}
+
+add_action('install_plugins_popular', 'install_popular', 10, 1);
+/**
+ * Display popular plugins.
+ *
+ * @since 2.7.0
+ *
+ * @param string $page
+ */
+function install_popular($page = 1) {
+ $args = array('browse' => 'popular', 'page' => $page);
+ $api = plugins_api('query_plugins', $args);
+ display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
+}
+
+add_action('install_plugins_new', 'install_new', 10, 1);
+/**
+ * Display new plugins.
+ *
+ * @since 2.7.0
+ *
+ * @param string $page
+ */
+function install_new($page = 1) {
+ $args = array('browse' => 'new', 'page' => $page);
+ $api = plugins_api('query_plugins', $args);
+ if ( is_wp_error($api) )
+ wp_die($api);
+ display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
+}
+add_action('install_plugins_updated', 'install_updated', 10, 1);
+
+
+/**
+ * Display recently updated plugins.
+ *
+ * @since 2.7.0
+ *
+ * @param string $page
+ */
+function install_updated($page = 1) {
+ $args = array('browse' => 'updated', 'page' => $page);
+ $api = plugins_api('query_plugins', $args);
+ display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
+}
+
+/**
+ * Display plugin content based on plugin list.
+ *
+ * @since 2.7.0
+ *
+ * @param array $plugins List of plugins.
+ * @param string $page
+ * @param int $totalpages Number of pages.
+ */
+function display_plugins_table($plugins, $page = 1, $totalpages = 1){
+ $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
+ $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
+
+ $plugins_allowedtags = array('a' => array('href' => array(),'title' => array(), 'target' => array()),
+ 'abbr' => array('title' => array()),'acronym' => array('title' => array()),
+ 'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array());
+
+?>
+ <div class="tablenav">
+ <div class="alignleft actions">
+ <?php do_action('install_plugins_table_header'); ?>
+ </div>
+ <?php
+ $url = clean_url($_SERVER['REQUEST_URI']);
+ if ( ! empty($term) )
+ $url = add_query_arg('s', $term, $url);
+ if ( ! empty($type) )
+ $url = add_query_arg('type', $type, $url);
+
+ $page_links = paginate_links( array(
+ 'base' => add_query_arg('paged', '%#%', $url),
+ 'format' => '',
+ 'prev_text' => __('«'),
+ 'next_text' => __('»'),
+ 'total' => $totalpages,
+ 'current' => $page
+ ));
+
+ if ( $page_links )
+ echo "\t\t<div class='tablenav-pages'>$page_links</div>";
+?>
+ <br class="clear" />
+ </div>
+ <table class="widefat" id="install-plugins" cellspacing="0">
+ <thead>
+ <tr>
+ <th scope="col" class="name"><?php _e('Name'); ?></th>
+ <th scope="col" class="num"><?php _e('Version'); ?></th>
+ <th scope="col" class="num"><?php _e('Rating'); ?></th>
+ <th scope="col" class="desc"><?php _e('Description'); ?></th>
+ <th scope="col" class="action-links"><?php _e('Actions'); ?></th>
+ </tr>
+ </thead>
+
+ <tfoot>
+ <tr>
+ <th scope="col" class="name"><?php _e('Name'); ?></th>
+ <th scope="col" class="num"><?php _e('Version'); ?></th>
+ <th scope="col" class="num"><?php _e('Rating'); ?></th>
+ <th scope="col" class="desc"><?php _e('Description'); ?></th>
+ <th scope="col" class="action-links"><?php _e('Actions'); ?></th>
+ </tr>
+ </tfoot>
+
+ <tbody class="plugins">
+ <?php
+ if( empty($plugins) )
+ echo '<tr><td colspan="5">', __('No plugins match your request.'), '</td></tr>';
+
+ foreach( (array) $plugins as $plugin ){
+ if ( is_object($plugin) )
+ $plugin = (array) $plugin;
+
+ $title = wp_kses($plugin['name'], $plugins_allowedtags);
+ $description = wp_kses($plugin['description'], $plugins_allowedtags);
+ $version = wp_kses($plugin['version'], $plugins_allowedtags);
+
+ $name = strip_tags($title . ' ' . $version);
+
+ $author = $plugin['author'];
+ if( ! empty($plugin['author']) )
+ $author = ' <cite>' . sprintf( __('By %s'), $author ) . '.</cite>';
+
+ $author = wp_kses($author, $plugins_allowedtags);
+
+ if( isset($plugin['homepage']) )
+ $title = '<a target="_blank" href="' . attribute_escape($plugin['homepage']) . '">' . $title . '</a>';
+
+ $action_links = array();
+ $action_links[] = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] .
+ '&TB_iframe=true&width=600&height=800') . '" class="thickbox onclick" title="' .
+ attribute_escape($name) . '">' . __('Install') . '</a>';
+
+ $action_links = apply_filters('plugin_install_action_links', $action_links, $plugin);
+ ?>
+ <tr>
+ <td class="name"><?php echo $title; ?></td>
+ <td class="vers"><?php echo $version; ?></td>
+ <td class="vers">
+ <div class="star-holder" title="<?php printf(__ngettext('(based on %s rating)', '(based on %s ratings)', $plugin['num_ratings']), number_format_i18n($plugin['num_ratings'])) ?>">
+ <div class="star star-rating" style="width: <?php echo attribute_escape($plugin['rating']) ?>px"></div>
+ <div class="star star5"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('5 stars') ?>" /></div>
+ <div class="star star4"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('4 stars') ?>" /></div>
+ <div class="star star3"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('3 stars') ?>" /></div>
+ <div class="star star2"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('2 stars') ?>" /></div>
+ <div class="star star1"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('1 star') ?>" /></div>
+ </div>
+ </td>
+ <td class="desc"><p><?php echo $description, $author; ?></p></td>
+ <td class="action-links"><?php if ( !empty($action_links) ) echo implode(' | ', $action_links); ?></td>
+ </tr>
+ <?php
+ }
+ ?>
+ </tbody>
+ </table>
+
+ <div class="tablenav">
+ <?php if ( $page_links )
+ echo "\t\t<div class='tablenav-pages'>$page_links</div>"; ?>
+ <br class="clear" />
+ </div>
+
+<?php
+}
+
+add_action('install_plugins_pre_plugin-information', 'install_plugin_information');
+
+/**
+ * Display plugin information in dialog box form.
+ *
+ * @since 2.7.0
+ */
+function install_plugin_information() {
+ global $tab;
+
+ $api = plugins_api('plugin_information', array('slug' => stripslashes( $_REQUEST['plugin'] ) ));
+
+ if ( is_wp_error($api) )
+ wp_die($api);
+
+ $plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
+ 'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
+ 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
+ 'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
+ 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
+ 'img' => array('src' => array(), 'class' => array(), 'alt' => array()));
+ //Sanitize HTML
+ foreach ( (array)$api->sections as $section_name => $content )
+ $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags);
+ foreach ( array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key )
+ $api->$key = wp_kses($api->$key, $plugins_allowedtags);
+
+ $section = isset($_REQUEST['section']) ? stripslashes( $_REQUEST['section'] ) : 'description'; //Default to the Description tab, Do not translate, API returns English.
+ if( empty($section) || ! isset($api->sections[ $section ]) )
+ $section = array_shift( $section_titles = array_keys((array)$api->sections) );
+
+ iframe_header( __('Plugin Install') );
+ echo "<div id='$tab-header'>\n";
+ echo "<ul id='sidemenu'>\n";
+ foreach ( (array)$api->sections as $section_name => $content ) {
+
+ $title = $section_name;
+ $title = ucwords(str_replace('_', ' ', $title));
+
+ $class = ( $section_name == $section ) ? ' class="current"' : '';
+ $href = add_query_arg( array('tab' => $tab, 'section' => $section_name) );
+ $href = clean_url($href);
+ $san_title = attribute_escape(sanitize_title_with_dashes($title));
+ echo "\t<li><a name='$san_title' target='' href='$href'$class>$title</a></li>\n";
+ }
+ echo "</ul>\n";
+ echo "</div>\n";
+ ?>
+ <div class="alignright fyi">
+ <?php if ( ! empty($api->download_link) ) : ?>
+ <p class="action-button">
+ <?php
+ //Default to a "new" plugin
+ $type = 'install';
+ //Check to see if this plugin is known to be installed, and has an update awaiting it.
+ $update_plugins = get_option('update_plugins');
+ foreach ( (array)$update_plugins->response as $file => $plugin ) {
+ if ( $plugin->slug === $api->slug ) {
+ $type = 'update_available';
+ $update_file = $file;
+ break;
+ }
+ }
+ if ( 'install' == $type && is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) {
+ $installed_plugin = get_plugins('/' . $api->slug);
+ if ( ! empty($installed_plugin) ) {
+ $key = array_shift( $key = array_keys($installed_plugin) ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
+ if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '>') ){
+ $type = 'latest_installed';
+ } elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) {
+ $type = 'newer_installed';
+ $newer_version = $installed_plugin[ $key ]['Version'];
+ } else {
+ //If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
+ delete_option('update_plugins');
+ $update_file = $api->slug . '/' . $key; //This code branch only deals with a plugin which is in a folder the same name as its slug, Doesnt support plugins which have 'non-standard' names
+ $type = 'update_available';
+ }
+ }
+ }
+
+ switch ( $type ) :
+ default:
+ case 'install':
+ if ( current_user_can('install_plugins') ) :
+ ?><a href="<?php echo wp_nonce_url(admin_url('plugin-install.php?tab=install&plugin=' . $api->slug), 'install-plugin_' . $api->slug) ?>" target="_parent"><?php _e('Install Now') ?></a><?php
+ endif;
+ break;
+ case 'update_available':
+ if ( current_user_can('update_plugins') ) :
+ ?><a href="<?php echo wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file) ?>" target="_parent"><?php _e('Install Update Now') ?></a><?php
+ endif;
+ break;
+ case 'newer_installed':
+ if ( current_user_can('install_plugins') || current_user_can('update_plugins') ) :
+ ?><a><?php printf(__('Newer Version (%s) Installed'), $newer_version) ?></a><?php
+ endif;
+ break;
+ case 'latest_installed':
+ if ( current_user_can('install_plugins') || current_user_can('update_plugins') ) :
+ ?><a><?php _e('Latest Version Installed') ?></a><?php
+ endif;
+ break;
+ endswitch; ?>
+ </p>
+ <?php endif; ?>
+ <h2 class="mainheader"><?php _e('FYI') ?></h2>
+ <ul>
+<?php if ( ! empty($api->version) ) : ?>
+ <li><strong><?php _e('Version:') ?></strong> <?php echo $api->version ?></li>
+<?php endif; if ( ! empty($api->author) ) : ?>
+ <li><strong><?php _e('Author:') ?></strong> <?php echo links_add_target($api->author, '_blank') ?></li>
+<?php endif; if ( ! empty($api->last_updated) ) : ?>
+ <li><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php
+ printf( __('%s ago'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li>
+<?php endif; if ( ! empty($api->requires) ) : ?>
+ <li><strong><?php _e('Requires WordPress Version:') ?></strong> <?php printf(__('%s or higher'), $api->requires) ?></li>
+<?php endif; if ( ! empty($api->tested) ) : ?>
+ <li><strong><?php _e('Compatible up to:') ?></strong> <?php echo $api->tested ?></li>
+<?php endif; if ( ! empty($api->downloaded) ) : ?>
+ <li><strong><?php _e('Downloaded:') ?></strong> <?php printf(__ngettext('%s time', '%s times', $api->downloaded), number_format_i18n($api->downloaded)) ?></li>
+<?php endif; if ( ! empty($api->slug) ) : ?>
+ <li><a target="_blank" href="http://wordpress.org/extend/plugins/<?php echo $api->slug ?>/"><?php _e('WordPress.org Plugin Page »') ?></a></li>
+<?php endif; if ( ! empty($api->homepage) ) : ?>
+ <li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage »') ?></a></li>
+<?php endif; ?>
+ </ul>
+ <h2><?php _e('Average Rating') ?></h2>
+ <div class="star-holder" title="<?php printf(__ngettext('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?>">
+ <div class="star star-rating" style="width: <?php echo attribute_escape($api->rating) ?>px"></div>
+ <div class="star star5"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('5 stars') ?>" /></div>
+ <div class="star star4"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('4 stars') ?>" /></div>
+ <div class="star star3"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('3 stars') ?>" /></div>
+ <div class="star star2"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('2 stars') ?>" /></div>
+ <div class="star star1"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('1 star') ?>" /></div>
+ </div>
+ <small><?php printf(__ngettext('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?></small>
+ </div>
+ <div id="section-holder" class="wrap">
+ <?php
+ if ( version_compare($GLOBALS['wp_version'], $api->tested, '>') )
+ echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';
+ else if ( version_compare($GLOBALS['wp_version'], $api->requires, '<') )
+ echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has not been marked as <strong>compatible</strong> with your version of WordPress.') . '</p></div>';
+ foreach ( (array)$api->sections as $section_name => $content ) {
+ $title = $section_name;
+ $title[0] = strtoupper($title[0]);
+ $title = str_replace('_', ' ', $title);
+
+ $content = links_add_base_url($content, 'http://wordpress.org/extend/plugins/' . $api->slug . '/');
+ $content = links_add_target($content, '_blank');
+
+ $san_title = attribute_escape(sanitize_title_with_dashes($title));
+
+ $display = ( $section_name == $section ) ? 'block' : 'none';
+
+ echo "\t<div id='section-{$san_title}' class='section' style='display: {$display};'>\n";
+ echo "\t\t<h2 class='long-header'>$title</h2>";
+ echo $content;
+ echo "\t</div>\n";
+ }
+ echo "</div>\n";
+
+ iframe_footer();
+ exit;
+}
+
+
+add_action('install_plugins_upload', 'upload_plugin');
+function upload_plugin() {
+
+ if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
+ wp_die($uploads['error']);
+
+ if ( !empty($_FILES) )
+ $filename = $_FILES['pluginzip']['name'];
+ else if ( isset($_GET['package']) )
+ $filename = $_GET['package'];
+
+ check_admin_referer('plugin-upload');
+
+ echo '<div class="wrap">';
+ echo '<h2>', sprintf( __('Installing Plugin from file: %s'), basename($filename) ), '</h2>';
+
+ //Handle a newly uploaded file, Else assume it was
+ if ( !empty($_FILES) ) {
+ $filename = wp_unique_filename( $uploads['basedir'], $filename );
+ $local_file = $uploads['basedir'] . '/' . $filename;
+
+ // Move the file to the uploads dir
+ if ( false === @ move_uploaded_file( $_FILES['pluginzip']['tmp_name'], $local_file) )
+ wp_die( sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path']));
+ } else {
+ $local_file = $uploads['basedir'] . '/' . $filename;
+ }
+
+ do_plugin_install_local_package($local_file, $filename);
+ echo '</div>';
+}
+
+add_action('install_plugins_install', 'install_plugin');
+
+/**
+ * Display plugin link and execute install.
+ *
+ * @since 2.7.0
+ */
+function install_plugin() {
+
+ $plugin = isset($_REQUEST['plugin']) ? stripslashes( $_REQUEST['plugin'] ) : '';
+
+ check_admin_referer('install-plugin_' . $plugin);
+ $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
+
+ if ( is_wp_error($api) )
+ wp_die($api);
+
+ echo '<div class="wrap">';
+ echo '<h2>', sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ), '</h2>';
+
+ do_plugin_install($api->download_link, $api);
+ echo '</div>';
+
+}
+
+/**
+ * Retrieve plugin and install.
+ *
+ * @since 2.7.0
+ *
+ * @param string $download_url Download URL.
+ * @param object $plugin_information Optional. Plugin information
+ */
+function do_plugin_install($download_url, $plugin_information = null) {
+ global $wp_filesystem;
+
+ if ( empty($download_url) ) {
+ show_message( __('No plugin Specified') );
+ return;
+ }
+
+ $plugin = isset($_REQUEST['plugin']) ? stripslashes( $_REQUEST['plugin'] ) : '';
+
+ $url = 'plugin-install.php?tab=install';
+ $url = add_query_arg(array('plugin' => $plugin, 'plugin_name' => stripslashes( $_REQUEST['plugin_name'] ), 'download_url' => stripslashes( $_REQUEST['download_url'] ) ), $url);
+
+ $url = wp_nonce_url($url, 'install-plugin_' . $plugin);
+ if ( false === ($credentials = request_filesystem_credentials($url)) )
+ return;
+
+ if ( ! WP_Filesystem($credentials) ) {
+ request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
+ return;
+ }
+
+ if ( $wp_filesystem->errors->get_error_code() ) {
+ foreach ( $wp_filesystem->errors->get_error_messages() as $message )
+ show_message($message);
+ return;
+ }
+
+ $result = wp_install_plugin( $download_url, 'show_message' );
+
+ if ( is_wp_error($result) ) {
+ show_message($result);
+ show_message( __('Installation Failed') );
+ } else {
+ show_message( sprintf(__('Successfully installed the plugin <strong>%s %s</strong>.'), $plugin_information->name, $plugin_information->version) );
+ $plugin_file = $result;
+
+ $install_actions = apply_filters('install_plugin_complete_actions', array(
+ 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . attribute_escape(__('Activate this plugin')) . '" target="_parent">' . __('Activate Plugin') . '</a>',
+ 'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . attribute_escape(__('Goto plugins page')) . '" target="_parent">' . __('Return to Plugins page') . '</a>'
+ ), $plugin_information, $plugin_file);
+ if ( ! empty($install_actions) )
+ show_message('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$install_actions));
+ }
+}
+
+/**
+ * Install a plugin from a local file.
+ *
+ * @since 2.7.0
+ *
+ * @param string $package Local Plugin zip
+ * @param string $filename Optional. Original filename
+ * @param object $plugin_information Optional. Plugin information
+ */
+function do_plugin_install_local_package($package, $filename = '') {
+ global $wp_filesystem;
+
+ if ( empty($package) ) {
+ show_message( __('No plugin Specified') );
+ return;
+ }
+
+ if ( empty($filename) )
+ $filename = basename($package);
+
+ $url = 'plugin-install.php?tab=upload';
+ $url = add_query_arg(array('package' => $filename), $url);
+
+ $url = wp_nonce_url($url, 'plugin-upload');
+ if ( false === ($credentials = request_filesystem_credentials($url)) )
+ return;
+
+ if ( ! WP_Filesystem($credentials) ) {
+ request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
+ return;
+ }
+
+ if ( $wp_filesystem->errors->get_error_code() ) {
+ foreach ( $wp_filesystem->errors->get_error_messages() as $message )
+ show_message($message);
+ return;
+ }
+
+ $result = wp_install_plugin_local_package( $package, 'show_message' );
+
+ if ( is_wp_error($result) ) {
+ show_message($result);
+ show_message( __('Installation Failed') );
+ } else {
+ show_message( __('Successfully installed the plugin.') );
+ $plugin_file = $result;
+
+ $install_actions = apply_filters('install_plugin_complete_actions', array(
+ 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
+ 'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . __('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
+ ), array(), $plugin_file);
+ if ( ! empty($install_actions) )
+ show_message('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$install_actions));
+ }
+}
+
+/**
+ * Install plugin.
+ *
+ * @since 2.7.0
+ *
+ * @param string $package
+ * @param string $feedback Optional.
+ * @return mixed.
+ */
+function wp_install_plugin($package, $feedback = '') {
+ global $wp_filesystem;
+
+ if ( !empty($feedback) )
+ add_filter('install_feedback', $feedback);
+
+ // Is a filesystem accessor setup?
+ if ( ! $wp_filesystem || ! is_object($wp_filesystem) )
+ WP_Filesystem();
+
+ if ( ! is_object($wp_filesystem) )
+ return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
+
+ if ( $wp_filesystem->errors->get_error_code() )
+ return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors);
+
+ //Get the base plugin folder
+ $plugins_dir = $wp_filesystem->wp_plugins_dir();
+ if ( empty($plugins_dir) )
+ return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.'));
+
+ //And the same for the Content directory.
+ $content_dir = $wp_filesystem->wp_content_dir();
+ if( empty($content_dir) )
+ return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).'));
+
+ $plugins_dir = trailingslashit( $plugins_dir );
+ $content_dir = trailingslashit( $content_dir );
+
+ if ( empty($package) )
+ return new WP_Error('no_package', __('Install package not available.'));
+
+ // Download the package
+ apply_filters('install_feedback', sprintf(__('Downloading plugin package from %s'), $package));
+ $download_file = download_url($package);
+
+ if ( is_wp_error($download_file) )
+ return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message());
+
+ $working_dir = $content_dir . 'upgrade/' . basename($package, '.zip');
+
+ // Clean up working directory
+ if ( $wp_filesystem->is_dir($working_dir) )
+ $wp_filesystem->delete($working_dir, true);
+
+ apply_filters('install_feedback', __('Unpacking the plugin package'));
+ // Unzip package to working directory
+ $result = unzip_file($download_file, $working_dir);
+
+ // Once extracted, delete the package
+ @unlink($download_file);
+
+ if ( is_wp_error($result) ) {
+ $wp_filesystem->delete($working_dir, true);
+ return $result;
+ }
+
+ //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
+ $filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
+
+ if( $wp_filesystem->exists( $plugins_dir . $filelist[0] ) ) {
+ $wp_filesystem->delete($working_dir, true);
+ return new WP_Error('install_folder_exists', __('Folder already exists.'), $filelist[0] );
+ }
+
+ apply_filters('install_feedback', __('Installing the plugin'));
+ // Copy new version of plugin into place.
+ $result = copy_dir($working_dir, $plugins_dir);
+ if ( is_wp_error($result) ) {
+ $wp_filesystem->delete($working_dir, true);
+ return $result;
+ }
+
+ //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
+ $filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
+
+ // Remove working directory
+ $wp_filesystem->delete($working_dir, true);
+
+ if( empty($filelist) )
+ return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.
+
+ $folder = $filelist[0];
+ $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
+ $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
+
+ //Return the plugin files name.
+ return $folder . '/' . $pluginfiles[0];
+}
+
+/**
+ * Install plugin from local package
+ *
+ * @since 2.7.0
+ *
+ * @param string $package
+ * @param string $feedback Optional.
+ * @return mixed.
+ */
+function wp_install_plugin_local_package($package, $feedback = '') {
+ global $wp_filesystem;
+
+ if ( !empty($feedback) )
+ add_filter('install_feedback', $feedback);
+
+ // Is a filesystem accessor setup?
+ if ( ! $wp_filesystem || ! is_object($wp_filesystem) )
+ WP_Filesystem();
+
+ if ( ! is_object($wp_filesystem) )
+ return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
+
+ if ( $wp_filesystem->errors->get_error_code() )
+ return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors);
+
+ //Get the base plugin folder
+ $plugins_dir = $wp_filesystem->wp_plugins_dir();
+ if ( empty($plugins_dir) )
+ return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.'));
+
+ //And the same for the Content directory.
+ $content_dir = $wp_filesystem->wp_content_dir();
+ if( empty($content_dir) )
+ return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).'));
+
+ $plugins_dir = trailingslashit( $plugins_dir );
+ $content_dir = trailingslashit( $content_dir );
+
+ if ( empty($package) )
+ return new WP_Error('no_package', __('Install package not available.'));
+
+ $working_dir = $content_dir . 'upgrade/' . basename($package, '.zip');
+
+ // Clean up working directory
+ if ( $wp_filesystem->is_dir($working_dir) )
+ $wp_filesystem->delete($working_dir, true);
+
+ apply_filters('install_feedback', __('Unpacking the plugin package'));
+ // Unzip package to working directory
+ $result = unzip_file($package, $working_dir);
+
+ // Once extracted, delete the package
+ unlink($package);
+
+ if ( is_wp_error($result) ) {
+ $wp_filesystem->delete($working_dir, true);
+ return $result;
+ }
+
+ //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
+ $filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
+
+ if( $wp_filesystem->exists( $plugins_dir . $filelist[0] ) ) {
+ $wp_filesystem->delete($working_dir, true);
+ return new WP_Error('install_folder_exists', __('Folder already exists.'), $filelist[0] );
+ }
+
+ apply_filters('install_feedback', __('Installing the plugin'));
+ // Copy new version of plugin into place.
+ $result = copy_dir($working_dir, $plugins_dir);
+ if ( is_wp_error($result) ) {
+ $wp_filesystem->delete($working_dir, true);
+ return $result;
+ }
+
+ //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
+ $filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
+
+ // Remove working directory
+ $wp_filesystem->delete($working_dir, true);
+
+ if( empty($filelist) )
+ return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.
+
+ $folder = $filelist[0];
+ $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
+ $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
+
+ //Return the plugin files name.
+ return $folder . '/' . $pluginfiles[0];
+}
+
+?>
<?php
-
-function get_plugin_data( $plugin_file ) {
- $plugin_data = implode( '', file( $plugin_file ));
- preg_match( '|Plugin Name:(.*)$|mi', $plugin_data, $plugin_name );
- preg_match( '|Plugin URI:(.*)$|mi', $plugin_data, $plugin_uri );
+/**
+ * WordPress Plugin Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Parse the plugin contents to retrieve plugin's metadata.
+ *
+ * The metadata of the plugin's data searches for the following in the plugin's
+ * header. All plugin data must be on its own line. For plugin description, it
+ * must not have any newlines or only parts of the description will be displayed
+ * and the same goes for the plugin data. The below is formatted for printing.
+ *
+ * <code>
+ * /*
+ * Plugin Name: Name of Plugin
+ * Plugin URI: Link to plugin information
+ * Description: Plugin Description
+ * Author: Plugin author's name
+ * Author URI: Link to the author's web site
+ * Version: Must be set in the plugin for WordPress 2.3+
+ * Text Domain: Optional. Unique identifier, should be same as the one used in
+ * plugin_text_domain()
+ * Domain Path: Optional. Only useful if the translations are located in a
+ * folder above the plugin's base path. For example, if .mo files are
+ * located in the locale folder then Domain Path will be "/locale/" and
+ * must have the first slash. Defaults to the base folder the plugin is
+ * located in.
+ * * / # Remove the space to close comment
+ * </code>
+ *
+ * Plugin data returned array contains the following:
+ * 'Name' - Name of the plugin, must be unique.
+ * 'Title' - Title of the plugin and the link to the plugin's web site.
+ * 'Description' - Description of what the plugin does and/or notes
+ * from the author.
+ * 'Author' - The author's name
+ * 'AuthorURI' - The authors web site address.
+ * 'Version' - The plugin version number.
+ * 'PluginURI' - Plugin web site address.
+ * 'TextDomain' - Plugin's text domain for localization.
+ * 'DomainPath' - Plugin's relative directory path to .mo files.
+ *
+ * Some users have issues with opening large files and manipulating the contents
+ * for want is usually the first 1kiB or 2kiB. This function stops pulling in
+ * the plugin contents when it has all of the required plugin data.
+ *
+ * The first 8kiB of the file will be pulled in and if the plugin data is not
+ * within that first 8kiB, then the plugin author should correct their plugin
+ * and move the plugin data headers to the top.
+ *
+ * The plugin file is assumed to have permissions to allow for scripts to read
+ * the file. This is not checked however and the file is only opened for
+ * reading.
+ *
+ * @link http://trac.wordpress.org/ticket/5651 Previous Optimizations.
+ * @link http://trac.wordpress.org/ticket/7372 Further and better Optimizations.
+ * @since 1.5.0
+ *
+ * @param string $plugin_file Path to the plugin file
+ * @param bool $markup If the returned data should have HTML markup applied
+ * @param bool $translate If the returned data should be translated
+ * @return array See above for description.
+ */
+function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
+ // We don't need to write to the file, so just open for reading.
+ $fp = fopen($plugin_file, 'r');
+
+ // Pull only the first 8kiB of the file in.
+ $plugin_data = fread( $fp, 8192 );
+
+ // PHP will close file handle, but we are good citizens.
+ fclose($fp);
+
+ preg_match( '|Plugin Name:(.*)$|mi', $plugin_data, $name );
+ preg_match( '|Plugin URI:(.*)$|mi', $plugin_data, $uri );
+ preg_match( '|Version:(.*)|i', $plugin_data, $version );
preg_match( '|Description:(.*)$|mi', $plugin_data, $description );
preg_match( '|Author:(.*)$|mi', $plugin_data, $author_name );
preg_match( '|Author URI:(.*)$|mi', $plugin_data, $author_uri );
+ preg_match( '|Text Domain:(.*)$|mi', $plugin_data, $text_domain );
+ preg_match( '|Domain Path:(.*)$|mi', $plugin_data, $domain_path );
- if ( preg_match( "|Version:(.*)|i", $plugin_data, $version ))
- $version = trim( $version[1] );
- else
- $version = '';
+ foreach ( array( 'name', 'uri', 'version', 'description', 'author_name', 'author_uri', 'text_domain', 'domain_path' ) as $field ) {
+ if ( !empty( ${$field} ) )
+ ${$field} = trim(${$field}[1]);
+ else
+ ${$field} = '';
+ }
- $description = wptexturize( trim( $description[1] ));
+ $plugin_data = array(
+ 'Name' => $name, 'Title' => $name, 'PluginURI' => $uri, 'Description' => $description,
+ 'Author' => $author_name, 'AuthorURI' => $author_uri, 'Version' => $version,
+ 'TextDomain' => $text_domain, 'DomainPath' => $domain_path
+ );
+ if ( $markup || $translate )
+ $plugin_data = _get_plugin_data_markup_translate($plugin_data, $markup, $translate);
+ return $plugin_data;
+}
+
+function _get_plugin_data_markup_translate($plugin_data, $markup = true, $translate = true) {
+
+ //Translate fields
+ if( $translate && ! empty($plugin_data['TextDomain']) ) {
+ if( ! empty( $plugin_data['DomainPath'] ) )
+ load_plugin_textdomain($plugin_data['TextDomain'], dirname($plugin_file). $plugin_data['DomainPath']);
+ else
+ load_plugin_textdomain($plugin_data['TextDomain'], dirname($plugin_file));
- $name = $plugin_name[1];
- $name = trim( $name );
- $plugin = $name;
- if ('' != trim($plugin_uri[1]) && '' != $name ) {
- $plugin = '<a href="' . trim( $plugin_uri[1] ) . '" title="'.__( 'Visit plugin homepage' ).'">'.$plugin.'</a>';
+ foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field )
+ $plugin_data[ $field ] = translate($plugin_data[ $field ], $plugin_data['TextDomain']);
}
- if ('' == $author_uri[1] ) {
- $author = trim( $author_name[1] );
- } else {
- $author = '<a href="' . trim( $author_uri[1] ) . '" title="'.__( 'Visit author homepage' ).'">' . trim( $author_name[1] ) . '</a>';
+ //Apply Markup
+ if ( $markup ) {
+ if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']) )
+ $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin homepage' ) . '">' . $plugin_data['Name'] . '</a>';
+ else
+ $plugin_data['Title'] = $plugin_data['Name'];
+
+ if ( ! empty($plugin_data['AuthorURI']) && ! empty($plugin_data['Author']) )
+ $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';
+
+ $plugin_data['Description'] = wptexturize( $plugin_data['Description'] );
+ if( ! empty($plugin_data['Author']) )
+ $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>';
}
- return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version);
+ $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
+
+ // Sanitize all displayed data
+ $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags);
+ $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags);
+ $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags);
+ $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags);
+
+ return $plugin_data;
}
+/**
+ * Check the plugins directory and retrieve all plugin files with plugin data.
+ *
+ * WordPress only supports plugin files in the base plugins directory
+ * (wp-content/plugins) and in one directory above the plugins directory
+ * (wp-content/plugins/my-plugin). The file it looks for has the plugin data and
+ * must be found in those two locations. It is recommended that do keep your
+ * plugin files in directories.
+ *
+ * The file with the plugin data is the file that will be included and therefore
+ * needs to have the main execution for the plugin. This does not mean
+ * everything must be contained in the file and it is recommended that the file
+ * be split for maintainability. Keep everything in one file for extreme
+ * optimization purposes.
+ *
+ * @since unknown
+ *
+ * @param string $plugin_folder Optional. Relative path to single plugin folder.
+ * @return array Key is the plugin file path and the value is an array of the plugin data.
+ */
function get_plugins($plugin_folder = '') {
-
+
if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') )
$cache_plugins = array();
-
+
if ( isset($cache_plugins[ $plugin_folder ]) )
return $cache_plugins[ $plugin_folder ];
-
+
$wp_plugins = array ();
$plugin_root = WP_PLUGIN_DIR;
if( !empty($plugin_folder) )
if ( !is_readable( "$plugin_root/$plugin_file" ) )
continue;
- $plugin_data = get_plugin_data( "$plugin_root/$plugin_file" );
+ $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
if ( empty ( $plugin_data['Name'] ) )
continue;
uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));
- $cache_plugins[ $plugin_folder ] = $wp_plugins;
- wp_cache_set('plugins', $cache_plugins, 'plugins');
+ $cache_plugins[ $plugin_folder ] = $wp_plugins;
+ wp_cache_set('plugins', $cache_plugins, 'plugins');
return $wp_plugins;
}
-function is_plugin_active($plugin){
+/**
+ * Check whether the plugin is active by checking the active_plugins list.
+ *
+ * @since 2.5.0
+ *
+ * @param string $plugin Base plugin path from plugins directory.
+ * @return bool True, if in the active plugins list. False, not in the list.
+ */
+function is_plugin_active($plugin) {
return in_array($plugin, get_option('active_plugins'));
}
+/**
+ * Attempts activation of plugin in a "sandbox" and redirects on success.
+ *
+ * A plugin that is already activated will not attempt to be activated again.
+ *
+ * The way it works is by setting the redirection to the error before trying to
+ * include the plugin file. If the plugin fails, then the redirection will not
+ * be overwritten with the success message. Also, the options will not be
+ * updated and the activation hook will not be called on plugin error.
+ *
+ * It should be noted that in no way the below code will actually prevent errors
+ * within the file. The code should not be used elsewhere to replicate the
+ * "sandbox", which uses redirection to work.
+ * {@source 13 1}
+ *
+ * If any errors are found or text is outputted, then it will be captured to
+ * ensure that the success redirection will update the error redirection.
+ *
+ * @since unknown
+ *
+ * @param string $plugin Plugin path to main plugin file with plugin data.
+ * @param string $redirect Optional. URL to redirect to.
+ * @return WP_Error|null WP_Error on invalid file or null on success.
+ */
function activate_plugin($plugin, $redirect = '') {
- $current = get_option('active_plugins');
- $plugin = trim($plugin);
-
- $valid = validate_plugin($plugin);
- if ( is_wp_error($valid) )
- return $valid;
-
- if ( !in_array($plugin, $current) ) {
- if ( !empty($redirect) )
- wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
- ob_start();
- @include(WP_PLUGIN_DIR . '/' . $plugin);
- $current[] = $plugin;
- sort($current);
- update_option('active_plugins', $current);
- do_action('activate_' . $plugin);
- ob_end_clean();
- }
+ $current = get_option('active_plugins');
+ $plugin = plugin_basename(trim($plugin));
- return null;
+ $valid = validate_plugin($plugin);
+ if ( is_wp_error($valid) )
+ return $valid;
+
+ if ( !in_array($plugin, $current) ) {
+ if ( !empty($redirect) )
+ wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
+ ob_start();
+ @include(WP_PLUGIN_DIR . '/' . $plugin);
+ $current[] = $plugin;
+ sort($current);
+ update_option('active_plugins', $current);
+ do_action('activate_' . $plugin);
+ ob_end_clean();
+ }
+
+ return null;
}
+/**
+ * Deactivate a single plugin or multiple plugins.
+ *
+ * The deactivation hook is disabled by the plugin upgrader by using the $silent
+ * parameter.
+ *
+ * @since unknown
+ *
+ * @param string|array $plugins Single plugin or list of plugins to deactivate.
+ * @param bool $silent Optional, default is false. Prevent calling deactivate hook.
+ */
function deactivate_plugins($plugins, $silent= false) {
$current = get_option('active_plugins');
$plugins = array($plugins);
foreach ( $plugins as $plugin ) {
+ $plugin = plugin_basename($plugin);
if( ! is_plugin_active($plugin) )
continue;
array_splice($current, array_search( $plugin, $current), 1 ); // Fixed Array-fu!
update_option('active_plugins', $current);
}
+/**
+ * Activate multiple plugins.
+ *
+ * When WP_Error is returned, it does not mean that one of the plugins had
+ * errors. It means that one or more of the plugins file path was invalid.
+ *
+ * The execution will be halted as soon as one of the plugins has an error.
+ *
+ * @since unknown
+ *
+ * @param string|array $plugins
+ * @param string $redirect Redirect to page after successful activation.
+ * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation.
+ */
function activate_plugins($plugins, $redirect = '') {
if ( !is_array($plugins) )
$plugins = array($plugins);
return true;
}
+/**
+ * Remove directory and files of a plugin for a single or list of plugin(s).
+ *
+ * If the plugins parameter list is empty, false will be returned. True when
+ * completed.
+ *
+ * @since unknown
+ *
+ * @param array $plugins List of plugin
+ * @param string $redirect Redirect to page when complete.
+ * @return mixed
+ */
function delete_plugins($plugins, $redirect = '' ) {
global $wp_filesystem;
$plugins_dir = $wp_filesystem->wp_plugins_dir();
if ( empty($plugins_dir) )
return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.'));
-
+
$plugins_dir = trailingslashit( $plugins_dir );
$errors = array();
foreach( $plugins as $plugin_file ) {
+ // Run Uninstall hook
+ if ( is_uninstallable_plugin( $plugin_file ) )
+ uninstall_plugin($plugin_file);
+
$this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin_file) );
// If plugin is in its own directory, recursively delete the directory.
if ( strpos($plugin_file, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory seperator AND that its not the root plugin folder
$deleted = $wp_filesystem->delete($this_plugin_dir, true);
else
$deleted = $wp_filesystem->delete($plugins_dir . $plugin_file);
-
+
if ( ! $deleted )
$errors[] = $plugin_file;
}
-
- if( ! empty($errors) )
+
+ if ( ! empty($errors) )
return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s'), implode(', ', $errors)) );
-
+
+ // Force refresh of plugin update information
+ delete_option('update_plugins');
+
return true;
}
}
//Invalid is any plugin that is deactivated due to error.
- $invalid = array();
+ $invalid = array();
// If a plugin file does not exist, remove it from the list of active
// plugins.
return $invalid;
}
+/**
+ * Validate the plugin path.
+ *
+ * Checks that the file exists and {@link validate_file() is valid file}.
+ *
+ * @since unknown
+ *
+ * @param string $plugin Plugin Path
+ * @return WP_Error|int 0 on success, WP_Error on failure.
+ */
function validate_plugin($plugin) {
if ( validate_file($plugin) )
- return new WP_Error('plugin_invalid', __('Invalid plugin.'));
+ return new WP_Error('plugin_invalid', __('Invalid plugin path.'));
if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) )
return new WP_Error('plugin_not_found', __('Plugin file does not exist.'));
return 0;
}
+/**
+ * Whether the plugin can be uninstalled.
+ *
+ * @since 2.7.0
+ *
+ * @param string $plugin Plugin path to check.
+ * @return bool Whether plugin can be uninstalled.
+ */
+function is_uninstallable_plugin($plugin) {
+ $file = plugin_basename($plugin);
+
+ $uninstallable_plugins = (array) get_option('uninstall_plugins');
+ if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) )
+ return true;
+
+ return false;
+}
+
+/**
+ * Uninstall a single plugin.
+ *
+ * Calls the uninstall hook, if it is available.
+ *
+ * @since 2.7.0
+ *
+ * @param string $plugin Relative plugin path from Plugin Directory.
+ */
+function uninstall_plugin($plugin) {
+ $file = plugin_basename($plugin);
+
+ $uninstallable_plugins = (array) get_option('uninstall_plugins');
+ if ( file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) {
+ if ( isset( $uninstallable_plugins[$file] ) ) {
+ unset($uninstallable_plugins[$file]);
+ update_option('uninstall_plugins', $uninstallable_plugins);
+ }
+ unset($uninstallable_plugins);
+
+ define('WP_UNINSTALL_PLUGIN', $file);
+ include WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php';
+
+ return true;
+ }
+
+ if ( isset( $uninstallable_plugins[$file] ) ) {
+ $callable = $uninstallable_plugins[$file];
+ unset($uninstallable_plugins[$file]);
+ update_option('uninstall_plugins', $uninstallable_plugins);
+ unset($uninstallable_plugins);
+
+ include WP_PLUGIN_DIR . '/' . $file;
+
+ add_action( 'uninstall_' . $file, $callable );
+ do_action( 'uninstall_' . $file );
+ }
+}
+
//
// Menu
//
-function add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+function add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '' ) {
global $menu, $admin_page_hooks;
$file = plugin_basename( $file );
- $menu[] = array ( $menu_title, $access_level, $file, $page_title );
+ $admin_page_hooks[$file] = sanitize_title( $menu_title );
+
+ $hookname = get_plugin_page_hookname( $file, '' );
+ if (!empty ( $function ) && !empty ( $hookname ))
+ add_action( $hookname, $function );
+
+ if ( empty($icon_url) )
+ $icon_url = 'images/generic.png';
+
+ $menu[] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
+
+ return $hookname;
+}
+
+function add_object_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '') {
+ global $menu, $admin_page_hooks, $_wp_last_object_menu;
+
+ $file = plugin_basename( $file );
$admin_page_hooks[$file] = sanitize_title( $menu_title );
if (!empty ( $function ) && !empty ( $hookname ))
add_action( $hookname, $function );
+ if ( empty($icon_url) )
+ $icon_url = 'images/generic.png';
+
+ $_wp_last_object_menu++;
+
+ $menu[$_wp_last_object_menu] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
+
+ return $hookname;
+}
+
+function add_utility_page( $page_title, $menu_title, $access_level, $file, $function = '', $icon_url = '') {
+ global $menu, $admin_page_hooks, $_wp_last_utility_menu;
+
+ $file = plugin_basename( $file );
+
+ $admin_page_hooks[$file] = sanitize_title( $menu_title );
+
+ $hookname = get_plugin_page_hookname( $file, '' );
+ if (!empty ( $function ) && !empty ( $hookname ))
+ add_action( $hookname, $function );
+
+ if ( empty($icon_url) )
+ $icon_url = 'images/generic.png';
+
+ $_wp_last_utility_menu++;
+
+ $menu[$_wp_last_utility_menu] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
+
return $hookname;
}
return $hookname;
}
+/**
+ * Add sub menu page to the tools main menu.
+ *
+ * @param string $page_title
+ * @param unknown_type $menu_title
+ * @param unknown_type $access_level
+ * @param unknown_type $file
+ * @param unknown_type $function
+ * @return unknown
+ */
function add_management_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
- return add_submenu_page( 'edit.php', $page_title, $menu_title, $access_level, $file, $function );
+ return add_submenu_page( 'tools.php', $page_title, $menu_title, $access_level, $file, $function );
}
function add_options_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
return add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function );
}
+function add_dashboard_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'index.php', $page_title, $menu_title, $access_level, $file, $function );
+}
+
+function add_posts_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'edit.php', $page_title, $menu_title, $access_level, $file, $function );
+}
+
+function add_media_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'upload.php', $page_title, $menu_title, $access_level, $file, $function );
+}
+
+function add_links_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $access_level, $file, $function );
+}
+
+function add_pages_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'edit-pages.php', $page_title, $menu_title, $access_level, $file, $function );
+}
+
+function add_comments_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $access_level, $file, $function );
+}
+
//
// Pluggable Menu Support -- Private
//
-function get_admin_page_parent() {
+function get_admin_page_parent( $parent = '' ) {
global $parent_file;
global $menu;
global $submenu;
global $_wp_menu_nopriv;
global $_wp_submenu_nopriv;
+ if ( !empty ( $parent ) && 'admin.php' != $parent ) {
+ if ( isset( $_wp_real_parent_file[$parent] ) )
+ $parent = $_wp_real_parent_file[$parent];
+ return $parent;
+ }
+/*
if ( !empty ( $parent_file ) ) {
if ( isset( $_wp_real_parent_file[$parent_file] ) )
$parent_file = $_wp_real_parent_file[$parent_file];
return $parent_file;
}
+*/
if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
foreach ( $menu as $parent_menu ) {
}
}
- $parent_file = '';
+ if ( empty($parent_file) )
+ $parent_file = '';
return '';
}
$hook = get_plugin_page_hook( $plugin_page, $pagenow );
$parent = $parent1 = get_admin_page_parent();
+
if ( empty ( $parent) ) {
foreach ( $menu as $menu_array ) {
if ( isset( $menu_array[3] ) ) {
function get_plugin_page_hookname( $plugin_page, $parent_page ) {
global $admin_page_hooks;
- $parent = get_admin_page_parent();
+ $parent = get_admin_page_parent( $parent_page );
$page_type = 'admin';
- if ( empty ( $parent_page ) || 'admin.php' == $parent_page ) {
- if ( isset( $admin_page_hooks[$plugin_page] ))
+ if ( empty ( $parent_page ) || 'admin.php' == $parent_page || isset( $admin_page_hooks[$plugin_page] ) ) {
+ if ( isset( $admin_page_hooks[$plugin_page] ) )
$page_type = 'toplevel';
else
if ( isset( $admin_page_hooks[$parent] ))
$page_type = $admin_page_hooks[$parent];
- } else if ( isset( $admin_page_hooks[$parent_page] ) ) {
- $page_type = $admin_page_hooks[$parent_page];
+ } else if ( isset( $admin_page_hooks[$parent] ) ) {
+ $page_type = $admin_page_hooks[$parent];
}
$plugin_name = preg_replace( '!\.php!', '', $plugin_page );
$parent = get_admin_page_parent();
- if ( isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
+ if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
return false;
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
return true;
}
+/* Whitelist functions */
+
+/**
+ * Register a setting and its sanitization callback
+ *
+ * @since 2.7.0
+ *
+ * @param string $option_group A settings group name. Can be anything.
+ * @param string $option_name The name of an option to sanitize and save.
+ * @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
+ * @return unknown
+ */
+function register_setting($option_group, $option_name, $sanitize_callback = '') {
+ return add_option_update_handler($option_group, $option_name, $sanitize_callback);
+}
+
+/**
+ * Unregister a setting
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $option_group
+ * @param unknown_type $option_name
+ * @param unknown_type $sanitize_callback
+ * @return unknown
+ */
+function unregister_setting($option_group, $option_name, $sanitize_callback = '') {
+ return remove_option_update_handler($option_group, $option_name, $sanitize_callback);
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $option_group
+ * @param unknown_type $option_name
+ * @param unknown_type $sanitize_callback
+ */
+function add_option_update_handler($option_group, $option_name, $sanitize_callback = '') {
+ global $new_whitelist_options;
+ $new_whitelist_options[ $option_group ][] = $option_name;
+ if ( $sanitize_callback != '' )
+ add_filter( "sanitize_option_{$option_name}", $sanitize_callback );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $option_group
+ * @param unknown_type $option_name
+ * @param unknown_type $sanitize_callback
+ */
+function remove_option_update_handler($option_group, $option_name, $sanitize_callback = '') {
+ global $new_whitelist_options;
+ $pos = array_search( $option_name, $new_whitelist_options );
+ if ( $pos !== false )
+ unset( $new_whitelist_options[ $option_group ][ $pos ] );
+ if ( $sanitize_callback != '' )
+ remove_filter( "sanitize_option_{$option_name}", $sanitize_callback );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $options
+ * @return unknown
+ */
+function option_update_filter( $options ) {
+ global $new_whitelist_options;
+
+ if ( is_array( $new_whitelist_options ) )
+ $options = add_option_whitelist( $new_whitelist_options, $options );
+
+ return $options;
+}
+add_filter( 'whitelist_options', 'option_update_filter' );
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $new_options
+ * @param unknown_type $options
+ * @return unknown
+ */
+function add_option_whitelist( $new_options, $options = '' ) {
+ if( $options == '' ) {
+ global $whitelist_options;
+ } else {
+ $whitelist_options = $options;
+ }
+ foreach( $new_options as $page => $keys ) {
+ foreach( $keys as $key ) {
+ if ( !isset($whitelist_options[ $page ]) || !is_array($whitelist_options[ $page ]) ) {
+ $whitelist_options[ $page ] = array();
+ $whitelist_options[ $page ][] = $key;
+ } else {
+ $pos = array_search( $key, $whitelist_options[ $page ] );
+ if ( $pos === false )
+ $whitelist_options[ $page ][] = $key;
+ }
+ }
+ }
+ return $whitelist_options;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $del_options
+ * @param unknown_type $options
+ * @return unknown
+ */
+function remove_option_whitelist( $del_options, $options = '' ) {
+ if( $options == '' ) {
+ global $whitelist_options;
+ } else {
+ $whitelist_options = $options;
+ }
+ foreach( $del_options as $page => $keys ) {
+ foreach( $keys as $key ) {
+ $pos = array_search( $key, $whitelist_options[ $page ] );
+ if( $pos !== false )
+ unset( $whitelist_options[ $page ][ $pos ] );
+ }
+ }
+ return $whitelist_options;
+}
+
+/**
+ * Output nonce, action, and option_page fields for a settings page.
+ *
+ * @since 2.7.0
+ *
+ * @param string $option_group A settings group name. This should match the group name used in register_setting().
+ */
+function settings_fields($option_group) {
+ echo "<input type='hidden' name='option_page' value='$option_group' />";
+ echo '<input type="hidden" name="action" value="update" />';
+ wp_nonce_field("$option_group-options");
+}
+
?>
<?php
+/**
+ * WordPress Post Administration API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
/**
- * _wp_translate_postdata() - Rename $_POST data from form names to DB post columns.
+ * Rename $_POST data from form names to DB post columns.
*
* Manipulates $_POST directly.
*
* @package WordPress
- * @since 2.6
+ * @since 2.6.0
*
* @param bool $update Are we updating a pre-existing post?
+ * @param post_data array Array of post data. Defaults to the contents of $_POST.
* @return object|bool WP_Error on failure, true on success.
*/
-function _wp_translate_postdata( $update = false ) {
+function _wp_translate_postdata( $update = false, $post_data = null ) {
+
+ if ( empty($post_data) )
+ $post_data = &$_POST;
+
if ( $update )
- $_POST['ID'] = (int) $_POST['post_ID'];
- $_POST['post_content'] = $_POST['content'];
- $_POST['post_excerpt'] = $_POST['excerpt'];
- $_POST['post_parent'] = isset($_POST['parent_id'])? $_POST['parent_id'] : '';
- $_POST['to_ping'] = $_POST['trackback_url'];
-
- if (!empty ( $_POST['post_author_override'] ) ) {
- $_POST['post_author'] = (int) $_POST['post_author_override'];
+ $post_data['ID'] = (int) $post_data['post_ID'];
+ $post_data['post_content'] = isset($post_data['content']) ? $post_data['content'] : '';
+ $post_data['post_excerpt'] = isset($post_data['excerpt']) ? $post_data['excerpt'] : '';
+ $post_data['post_parent'] = isset($post_data['parent_id'])? $post_data['parent_id'] : '';
+ if ( isset($post_data['trackback_url']) )
+ $post_data['to_ping'] = $post_data['trackback_url'];
+
+ if (!empty ( $post_data['post_author_override'] ) ) {
+ $post_data['post_author'] = (int) $post_data['post_author_override'];
} else {
- if (!empty ( $_POST['post_author'] ) ) {
- $_POST['post_author'] = (int) $_POST['post_author'];
+ if (!empty ( $post_data['post_author'] ) ) {
+ $post_data['post_author'] = (int) $post_data['post_author'];
} else {
- $_POST['post_author'] = (int) $_POST['user_ID'];
+ $post_data['post_author'] = (int) $post_data['user_ID'];
}
}
- if ( $_POST['post_author'] != $_POST['user_ID'] ) {
- if ( 'page' == $_POST['post_type'] ) {
+ if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) {
+ if ( 'page' == $post_data['post_type'] ) {
if ( !current_user_can( 'edit_others_pages' ) ) {
return new WP_Error( 'edit_others_pages', $update ?
__( 'You are not allowed to edit pages as this user.' ) :
}
// What to do based on which button they pressed
- if ( isset($_POST['saveasdraft']) && '' != $_POST['saveasdraft'] )
- $_POST['post_status'] = 'draft';
- if ( isset($_POST['saveasprivate']) && '' != $_POST['saveasprivate'] )
- $_POST['post_status'] = 'private';
- if ( isset($_POST['publish']) && ( '' != $_POST['publish'] ) && ( $_POST['post_status'] != 'private' ) )
- $_POST['post_status'] = 'publish';
- if ( isset($_POST['advanced']) && '' != $_POST['advanced'] )
- $_POST['post_status'] = 'draft';
-
- $previous_status = get_post_field('post_status', $_POST['ID']);
-
- // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
+ if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] )
+ $post_data['post_status'] = 'draft';
+ if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] )
+ $post_data['post_status'] = 'private';
+ if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( $post_data['post_status'] != 'private' ) )
+ $post_data['post_status'] = 'publish';
+ if ( isset($post_data['advanced']) && '' != $post_data['advanced'] )
+ $post_data['post_status'] = 'draft';
+ if ( isset($post_data['pending']) && '' != $post_data['pending'] )
+ $post_data['post_status'] = 'pending';
+
+ $previous_status = get_post_field('post_status', isset($post_data['ID']) ? $post_data['ID'] : $post_data['temp_ID']);
+
+ // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
// Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
- if ( 'page' == $_POST['post_type'] ) {
- if ( 'publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) )
- if ( $previous_status != 'publish' OR !current_user_can( 'edit_published_pages') )
- $_POST['post_status'] = 'pending';
+ if ( 'page' == $post_data['post_type'] ) {
+ $publish_cap = 'publish_pages';
+ $edit_cap = 'edit_published_pages';
} else {
- if ( 'publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) ) :
- // Stop attempts to publish new posts, but allow already published posts to be saved if appropriate.
- if ( $previous_status != 'publish' OR !current_user_can( 'edit_published_posts') )
- $_POST['post_status'] = 'pending';
- endif;
+ $publish_cap = 'publish_posts';
+ $edit_cap = 'edit_published_posts';
}
+ if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $publish_cap )) )
+ if ( $previous_status != 'publish' || !current_user_can( $edit_cap ) )
+ $post_data['post_status'] = 'pending';
+
+ if ( ! isset($post_data['post_status']) )
+ $post_data['post_status'] = $previous_status;
- if (!isset( $_POST['comment_status'] ))
- $_POST['comment_status'] = 'closed';
+ if (!isset( $post_data['comment_status'] ))
+ $post_data['comment_status'] = 'closed';
- if (!isset( $_POST['ping_status'] ))
- $_POST['ping_status'] = 'closed';
+ if (!isset( $post_data['ping_status'] ))
+ $post_data['ping_status'] = 'closed';
foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
- if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
- $_POST['edit_date'] = '1';
+ if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) {
+ $post_data['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'];
+ if ( !empty( $post_data['edit_date'] ) ) {
+ $aa = $post_data['aa'];
+ $mm = $post_data['mm'];
+ $jj = $post_data['jj'];
+ $hh = $post_data['hh'];
+ $mn = $post_data['mn'];
+ $ss = $post_data['ss'];
$aa = ($aa <= 0 ) ? date('Y') : $aa;
$mm = ($mm <= 0 ) ? date('n') : $mm;
$jj = ($jj > 31 ) ? 31 : $jj;
$hh = ($hh > 23 ) ? $hh -24 : $hh;
$mn = ($mn > 59 ) ? $mn -60 : $mn;
$ss = ($ss > 59 ) ? $ss -60 : $ss;
- $_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
- $_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date'] );
+ $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
+ $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
}
- return true;
+ return $post_data;
}
+/**
+ * Update an existing post with values provided in $_POST.
+ *
+ * @since unknown
+ *
+ * @param array $post_data Optional.
+ * @return int Post ID.
+ */
+function edit_post( $post_data = null ) {
-// Update an existing post with values provided in $_POST.
-function edit_post() {
+ if ( empty($post_data) )
+ $post_data = &$_POST;
- $post_ID = (int) $_POST['post_ID'];
+ $post_ID = (int) $post_data['post_ID'];
- if ( 'page' == $_POST['post_type'] ) {
+ if ( 'page' == $post_data['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_ID ) )
wp_die( __('You are not allowed to edit this page.' ));
} else {
}
// Autosave shouldn't save too soon after a real save
- if ( 'autosave' == $_POST['action'] ) {
+ if ( 'autosave' == $post_data['action'] ) {
$post =& get_post( $post_ID );
$now = time();
$then = strtotime($post->post_date_gmt . ' +0000');
return $post_ID;
}
- $translated = _wp_translate_postdata( true );
- if ( is_wp_error($translated) )
- wp_die( $translated->get_error_message() );
+ $post_data = _wp_translate_postdata( true, $post_data );
+ if ( is_wp_error($post_data) )
+ wp_die( $post_data->get_error_message() );
+
+ if ( isset($post_data['visibility']) ) {
+ switch ( $post_data['visibility'] ) {
+ case 'public' :
+ $post_data['post_password'] = '';
+ break;
+ case 'password' :
+ unset( $post_data['sticky'] );
+ break;
+ case 'private' :
+ $post_data['post_status'] = 'private';
+ $post_data['post_password'] = '';
+ unset( $post_data['sticky'] );
+ break;
+ }
+ }
// Meta Stuff
- if ( isset($_POST['meta']) && $_POST['meta'] ) {
- foreach ( $_POST['meta'] as $key => $value )
+ if ( isset($post_data['meta']) && $post_data['meta'] ) {
+ foreach ( $post_data['meta'] as $key => $value )
update_meta( $key, $value['key'], $value['value'] );
}
- if ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) {
- foreach ( $_POST['deletemeta'] as $key => $value )
+ if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) {
+ foreach ( $post_data['deletemeta'] as $key => $value )
delete_meta( $key );
}
add_meta( $post_ID );
- wp_update_post( $_POST );
+ wp_update_post( $post_data );
// Reunite any orphaned attachments with their parent
if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID );
+ if ( current_user_can( 'edit_others_posts' ) ) {
+ if ( !empty($post_data['sticky']) )
+ stick_post($post_ID);
+ else
+ unstick_post($post_ID);
+ }
+
return $post_ID;
}
-// Default post information to use when populating the "Write Post" form.
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Updates all bulk edited posts/pages, adding (but not removing) tags and
+ * categories. Skips pages when they would be their own parent or child.
+ *
+ * @since unknown
+ *
+ * @return array
+ */
+function bulk_edit_posts( $post_data = null ) {
+ global $wpdb;
+
+ if ( empty($post_data) )
+ $post_data = &$_POST;
+
+ if ( isset($post_data['post_type']) && 'page' == $post_data['post_type'] ) {
+ if ( ! current_user_can( 'edit_pages' ) )
+ wp_die( __('You are not allowed to edit pages.') );
+ } else {
+ if ( ! current_user_can( 'edit_posts' ) )
+ wp_die( __('You are not allowed to edit posts.') );
+ }
+
+ $post_IDs = array_map( 'intval', (array) $post_data['post'] );
+
+ $reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tags_input', 'post_category', 'sticky' );
+ foreach ( $reset as $field ) {
+ if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) )
+ unset($post_data[$field]);
+ }
+
+ if ( isset($post_data['post_category']) ) {
+ if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) )
+ $new_cats = array_map( absint, $post_data['post_category'] );
+ else
+ unset($post_data['post_category']);
+ }
+
+ if ( isset($post_data['tags_input']) ) {
+ $new_tags = preg_replace( '/\s*,\s*/', ',', rtrim( trim($post_data['tags_input']), ' ,' ) );
+ $new_tags = explode(',', $new_tags);
+ }
+
+ if ( isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent']) ) {
+ $pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'");
+ $children = array();
+
+ for ( $i = 0; $i < 50 && $parent > 0; $i++ ) {
+ $children[] = $parent;
+
+ foreach ( $pages as $page ) {
+ if ( $page->ID == $parent ) {
+ $parent = $page->post_parent;
+ break;
+ }
+ }
+ }
+ }
+
+ $updated = $skipped = $locked = array();
+ foreach ( $post_IDs as $post_ID ) {
+
+ if ( isset($children) && in_array($post_ID, $children) ) {
+ $skipped[] = $post_ID;
+ continue;
+ }
+
+ if ( wp_check_post_lock( $post_ID ) ) {
+ $locked[] = $post_ID;
+ continue;
+ }
+
+ if ( isset($new_cats) ) {
+ $cats = (array) wp_get_post_categories($post_ID);
+ $post_data['post_category'] = array_unique( array_merge($cats, $new_cats) );
+ }
+
+ if ( isset($new_tags) ) {
+ $tags = wp_get_post_tags($post_ID, array('fields' => 'names'));
+ $post_data['tags_input'] = array_unique( array_merge($tags, $new_tags) );
+ }
+
+ $post_data['ID'] = $post_ID;
+ $updated[] = wp_update_post( $post_data );
+
+ if ( current_user_can( 'edit_others_posts' ) && isset( $post_data['sticky'] ) ) {
+ if ( 'sticky' == $post_data['sticky'] )
+ stick_post( $post_ID );
+ else
+ unstick_post( $post_ID );
+ }
+
+ }
+
+ return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked );
+}
+
+/**
+ * Default post information to use when populating the "Write Post" form.
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function get_default_post_to_edit() {
if ( !empty( $_REQUEST['post_title'] ) )
$post_title = wp_specialchars( stripslashes( $_REQUEST['post_title'] ));
$text = wp_specialchars( stripslashes( urldecode( $_REQUEST['text'] ) ) );
$text = funky_javascript_fix( $text);
$popupurl = clean_url($_REQUEST['popupurl']);
- $post_content = '<a href="'.$popupurl.'">'.$post_title.'</a>'."\n$text";
- }
+ $post_content = '<a href="'.$popupurl.'">'.$post_title.'</a>'."\n$text";
+ }
if ( !empty( $_REQUEST['excerpt'] ) )
$post_excerpt = wp_specialchars( stripslashes( $_REQUEST['excerpt'] ));
$post->post_name = '';
$post->post_author = '';
$post->post_date = '';
+ $post->post_password = '';
$post->post_status = 'draft';
$post->post_type = 'post';
$post->to_ping = '';
return $post;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function get_default_page_to_edit() {
- $page = get_default_post_to_edit();
- $page->post_type = 'page';
- return $page;
+ $page = get_default_post_to_edit();
+ $page->post_type = 'page';
+ return $page;
}
-// Get an existing post and format it for editing.
+/**
+ * Get an existing post and format it for editing.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $id
+ * @return unknown
+ */
function get_post_to_edit( $id ) {
$post = get_post( $id, OBJECT, 'edit' );
return $post;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $title
+ * @param unknown_type $content
+ * @param unknown_type $post_date
+ * @return unknown
+ */
function post_exists($title, $content = '', $post_date = '') {
global $wpdb;
+ $title = stripslashes($title);
+ $content = stripslashes($content);
+ $post_date = stripslashes($post_date);
+
if (!empty ($post_date))
$post_date = $wpdb->prepare("AND post_date = %s", $post_date);
return 0;
}
-// Creates a new post from the "Write Post" form using $_POST information.
+/**
+ * Creates a new post from the "Write Post" form using $_POST information.
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function wp_write_post() {
global $user_ID;
if ( is_wp_error($translated) )
return $translated;
+ if ( isset($_POST['visibility']) ) {
+ switch ( $_POST['visibility'] ) {
+ case 'public' :
+ $_POST['post_password'] = '';
+ break;
+ case 'password' :
+ unset( $_POST['sticky'] );
+ break;
+ case 'private' :
+ $_POST['post_status'] = 'private';
+ $_POST['post_password'] = '';
+ unset( $_POST['sticky'] );
+ break;
+ }
+ }
+
// Create the post.
$post_ID = wp_insert_post( $_POST );
if ( is_wp_error( $post_ID ) )
return $post_ID;
}
+/**
+ * Calls wp_write_post() and handles the errors.
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function write_post() {
$result = wp_write_post();
if( is_wp_error( $result ) )
// Post Meta
//
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $post_ID
+ * @return unknown
+ */
function add_meta( $post_ID ) {
global $wpdb;
$post_ID = (int) $post_ID;
$protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
- $metakeyselect = $wpdb->escape( stripslashes( trim( $_POST['metakeyselect'] ) ) );
- $metakeyinput = $wpdb->escape( stripslashes( trim( $_POST['metakeyinput'] ) ) );
- $metavalue = maybe_serialize( stripslashes( (trim( $_POST['metavalue'] ) ) ));
- $metavalue = $wpdb->escape( $metavalue );
+ $metakeyselect = isset($_POST['metakeyselect']) ? stripslashes( trim( $_POST['metakeyselect'] ) ) : '';
+ $metakeyinput = isset($_POST['metakeyinput']) ? stripslashes( trim( $_POST['metakeyinput'] ) ) : '';
+ $metavalue = isset($_POST['metavalue']) ? maybe_serialize( stripslashes( trim( $_POST['metavalue'] ) ) ) : '';
if ( ('0' === $metavalue || !empty ( $metavalue ) ) && ((('#NONE#' != $metakeyselect) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput) ) ) {
// We have a key/value pair. If both the select and the
wp_cache_delete($post_ID, 'post_meta');
- $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->postmeta
- (post_id,meta_key,meta_value ) VALUES (%s, %s, %s)",
- $post_ID, $metakey, $metavalue) );
+ $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value ) VALUES (%s, %s, %s)", $post_ID, $metakey, $metavalue) );
return $wpdb->insert_id;
}
return false;
} // add_meta
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $mid
+ * @return unknown
+ */
function delete_meta( $mid ) {
global $wpdb;
$mid = (int) $mid;
return $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id = %d", $mid) );
}
-// Get a list of previously defined keys
+/**
+ * Get a list of previously defined keys.
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function get_meta_keys() {
global $wpdb;
return $keys;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $mid
+ * @return unknown
+ */
function get_post_meta_by_id( $mid ) {
global $wpdb;
$mid = (int) $mid;
return $meta;
}
-// Some postmeta stuff
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Some postmeta stuff.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $postid
+ * @return unknown
+ */
function has_meta( $postid ) {
global $wpdb;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $meta_id
+ * @param unknown_type $meta_key
+ * @param unknown_type $meta_value
+ * @return unknown
+ */
function update_meta( $meta_id, $meta_key, $meta_value ) {
global $wpdb;
$meta_value = maybe_serialize( stripslashes( $meta_value ));
$meta_id = (int) $meta_id;
-
+
$data = compact( 'meta_key', 'meta_value' );
$where = compact( 'meta_id' );
// Private
//
-// Replace hrefs of attachment anchors with up-to-date permalinks.
+/**
+ * Replace hrefs of attachment anchors with up-to-date permalinks.
+ *
+ * @since unknown
+ * @access private
+ *
+ * @param unknown_type $post_ID
+ * @return unknown
+ */
function _fix_attachment_links( $post_ID ) {
$post = & get_post( $post_ID, ARRAY_A );
return wp_update_post( $post);
}
-// Move child posts to a new parent
+/**
+ * Move child posts to a new parent.
+ *
+ * @since unknown
+ * @access private
+ *
+ * @param unknown_type $old_ID
+ * @param unknown_type $new_ID
+ * @return unknown
+ */
function _relocate_children( $old_ID, $new_ID ) {
global $wpdb;
$old_ID = (int) $old_ID;
return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = %d WHERE post_parent = %d", $new_ID, $old_ID) );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $type
+ * @return unknown
+ */
function get_available_post_statuses($type = 'post') {
$stati = wp_count_posts($type);
return array_keys(get_object_vars($stati));
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $q
+ * @return unknown
+ */
function wp_edit_posts_query( $q = false ) {
- global $wpdb;
if ( false === $q )
$q = $_GET;
- $q['m'] = (int) $q['m'];
- $q['cat'] = (int) $q['cat'];
+ $q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
+ $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
$post_stati = array( // array( adj, noun )
- 'publish' => array(__('Published'), __('Published posts'), __ngettext_noop('Published (%s)', 'Published (%s)')),
- 'future' => array(__('Scheduled'), __('Scheduled posts'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')),
- 'pending' => array(__('Pending Review'), __('Pending posts'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')),
- 'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')),
- 'private' => array(__('Private'), __('Private posts'), __ngettext_noop('Private (%s)', 'Private (%s)')),
+ 'publish' => array(__('Published'), __('Published posts'), __ngettext_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>')),
+ 'future' => array(__('Scheduled'), __('Scheduled posts'), __ngettext_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>')),
+ 'pending' => array(__('Pending Review'), __('Pending posts'), __ngettext_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>')),
+ 'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>')),
+ 'private' => array(__('Private'), __('Private posts'), __ngettext_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>')),
);
$post_stati = apply_filters('post_stati', $post_stati);
$post_status_q .= '&perm=readable';
}
- if ( 'pending' === $q['post_status'] ) {
+ if ( isset($q['post_status']) && 'pending' === $q['post_status'] ) {
$order = 'ASC';
$orderby = 'modified';
- } elseif ( 'draft' === $q['post_status'] ) {
+ } elseif ( isset($q['post_status']) && 'draft' === $q['post_status'] ) {
$order = 'DESC';
$orderby = 'modified';
} else {
return array($post_stati, $avail_post_stati);
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $type
+ * @return unknown
+ */
function get_available_post_mime_types($type = 'attachment') {
global $wpdb;
return $types;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $q
+ * @return unknown
+ */
function wp_edit_attachments_query( $q = false ) {
- global $wpdb;
if ( false === $q )
$q = $_GET;
- $q['m'] = (int) $q['m'];
- $q['cat'] = (int) $q['cat'];
+
+ $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0;
+ $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
$q['post_type'] = 'attachment';
$q['post_status'] = 'any';
$q['posts_per_page'] = 15;
$post_mime_types = array( // array( adj, noun )
- 'image' => array(__('Images'), __('Manage Images'), __ngettext_noop('Image (%s)', 'Images (%s)')),
- 'audio' => array(__('Audio'), __('Manage Audio'), __ngettext_noop('Audio (%s)', 'Audio (%s)')),
- 'video' => array(__('Video'), __('Manage Video'), __ngettext_noop('Video (%s)', 'Video (%s)')),
+ 'image' => array(__('Images'), __('Manage Images'), __ngettext_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>')),
+ 'audio' => array(__('Audio'), __('Manage Audio'), __ngettext_noop('Audio <span class="count">(%s)</span>', 'Audio <span class="count">(%s)</span>')),
+ 'video' => array(__('Video'), __('Manage Video'), __ngettext_noop('Video <span class="count">(%s)</span>', 'Video <span class="count">(%s)</span>')),
);
$post_mime_types = apply_filters('post_mime_types', $post_mime_types);
return array($post_mime_types, $avail_post_mime_types);
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $id
+ * @param unknown_type $page
+ * @return unknown
+ */
function postbox_classes( $id, $page ) {
+ if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id )
+ return '';
$current_user = wp_get_current_user();
- if ( $closed = get_usermeta( $current_user->ID, 'closedpostboxes_'.$page ) ) {
+ if ( $closed = get_user_option('closedpostboxes_'.$page, 0, false ) ) {
if ( !is_array( $closed ) ) return '';
return in_array( $id, $closed )? 'if-js-closed' : '';
} else {
- if ( 'tagsdiv' == $id || 'categorydiv' == $id ) return '';
- else return 'if-js-closed';
+ return '';
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $id
+ * @param unknown_type $title
+ * @param unknown_type $name
+ * @return unknown
+ */
function get_sample_permalink($id, $title=null, $name = null) {
$post = &get_post($id);
if (!$post->ID) {
// drafts, so we will fake, that our post is published
if (in_array($post->post_status, array('draft', 'pending'))) {
$post->post_status = 'publish';
- $post->post_date = date('Y-m-d H:i:s');
- $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID);
+ $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID);
}
// If the user wants to set a new name -- override the current one
$post->post_name = sanitize_title($name? $name : $title, $post->ID);
}
+ $post->filter = 'sample';
+
$permalink = get_permalink($post, true);
// Handle page hierarchy
$post->post_status = $original_status;
$post->post_date = $original_date;
$post->post_name = $original_name;
+ unset($post->filter);
+
return $permalink;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $id
+ * @param unknown_type $new_title
+ * @param unknown_type $new_slug
+ * @return unknown
+ */
function get_sample_permalink_html($id, $new_title=null, $new_slug=null) {
$post = &get_post($id);
list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
return '';
}
$title = __('Click to edit this part of the permalink');
- if (strlen($post_name) > 30) {
- $post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14);
+ if (function_exists('mb_strlen')) {
+ if (mb_strlen($post_name) > 30) {
+ $post_name_abridged = mb_substr($post_name, 0, 14). '…' . mb_substr($post_name, -14);
+ } else {
+ $post_name_abridged = $post_name;
+ }
} else {
- $post_name_abridged = $post_name;
+ if (strlen($post_name) > 30) {
+ $post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14);
+ } else {
+ $post_name_abridged = $post_name;
+ }
}
$post_name_html = '<span id="editable-post-name" title="'.$title.'">'.$post_name_abridged.'</span><span id="editable-post-name-full">'.$post_name.'</span>';
$display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $display_link . "</span>\n";
- $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug" onclick="edit_permalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
+ $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button" onclick="edit_permalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
return $return;
}
-// false: not locked or locked by current user
-// int: user ID of user with lock
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $post_id
+ * @return bool|int False: not locked or locked by current user. Int: user ID of user with lock.
+ */
function wp_check_post_lock( $post_id ) {
global $current_user;
return false;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $post_id
+ * @return unknown
+ */
function wp_set_post_lock( $post_id ) {
global $current_user;
if ( !$post = get_post( $post_id ) )
}
/**
- * wp_create_post_autosave() - creates autosave data for the specified post from $_POST data
+ * Creates autosave data for the specified post from $_POST data.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
* @uses _wp_translate_postdata()
* @uses _wp_post_revision_fields()
// Otherwise create the new autosave as a special post revision
return _wp_put_post_revision( $_POST, true );
}
+
+/**
+ * Save draft or manually autosave for showing preview.
+ *
+ * @package WordPress
+ * @since 2.7
+ *
+ * @uses wp_write_post()
+ * @uses edit_post()
+ * @uses get_post()
+ * @uses current_user_can()
+ * @uses wp_create_post_autosave()
+ *
+ * @return str URL to redirect to show the preview
+ */
+function post_preview() {
+
+ $post_ID = (int) $_POST['post_ID'];
+ if ( $post_ID < 1 )
+ wp_die( __('Preview not available. Please save as a draft first.') );
+
+ if ( isset($_POST['catslist']) )
+ $_POST['post_category'] = explode(",", $_POST['catslist']);
+
+ if ( isset($_POST['tags_input']) )
+ $_POST['tags_input'] = explode(",", $_POST['tags_input']);
+
+ if ( $_POST['post_type'] == 'page' || empty($_POST['post_category']) )
+ unset($_POST['post_category']);
+
+ $_POST['ID'] = $post_ID;
+ $post = get_post($post_ID);
+
+ if ( 'page' == $post->post_type ) {
+ if ( !current_user_can('edit_page', $post_ID) )
+ wp_die(__('You are not allowed to edit this page.'));
+ } else {
+ if ( !current_user_can('edit_post', $post_ID) )
+ wp_die(__('You are not allowed to edit this post.'));
+ }
+
+ if ( 'draft' == $post->post_status ) {
+ $id = edit_post();
+ } else { // Non drafts are not overwritten. The autosave is stored in a special post revision.
+ $id = wp_create_post_autosave( $post->ID );
+ if ( ! is_wp_error($id) )
+ $id = $post->ID;
+ }
+
+ if ( is_wp_error($id) )
+ wp_die( $id->get_error_message() );
+
+ if ( $_POST['post_status'] == 'draft' ) {
+ $url = add_query_arg( 'preview', 'true', get_permalink($id) );
+ } else {
+ $nonce = wp_create_nonce('post_preview_' . $id);
+ $url = add_query_arg( array( 'preview' => 'true', 'preview_id' => $id, 'preview_nonce' => $nonce ), get_permalink($id) );
+ }
+
+ return $url;
+}
+
+/**
+ * Adds the TinyMCE editor used on the Write and Edit screens.
+ *
+ * Has option to output a trimmed down version used in Press This.
+ *
+ * @package WordPress
+ * @since 2.7
+ */
+function wp_tiny_mce( $teeny = false ) {
+ if ( ! user_can_richedit() )
+ return;
+
+ $baseurl = includes_url('js/tinymce');
+
+ $mce_css = $baseurl . '/wordpress.css';
+ $mce_css = apply_filters('mce_css', $mce_css);
+
+ $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1
+
+ /*
+ The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
+ By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
+ The + sign marks the default language. More information:
+ http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
+ */
+ $mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
+
+ if ( $teeny ) {
+ $plugins = apply_filters( 'teeny_mce_plugins', array('safari', 'inlinepopups', 'media', 'autosave', 'fullscreen') );
+ $ext_plugins = '';
+ } else {
+ $plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery' );
+
+ /*
+ The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'.
+ It adds the plugin's name to TinyMCE's plugins init and the call to PluginManager to load the plugin.
+ The url should be absolute and should include the js file name to be loaded. Example:
+ array( 'myplugin' => 'http://my-site.com/wp-content/plugins/myfolder/mce_plugin.js' )
+ If the plugin uses a button, it should be added with one of the "$mce_buttons" filters.
+ */
+ $mce_external_plugins = apply_filters('mce_external_plugins', array());
+
+ $ext_plugins = "\n";
+ if ( ! empty($mce_external_plugins) ) {
+
+ /*
+ The following filter loads external language files for TinyMCE plugins.
+ It takes an associative array 'plugin_name' => 'path', where path is the
+ include path to the file. The language file should follow the same format as
+ /tinymce/langs/wp-langs.php and should define a variable $strings that
+ holds all translated strings.
+ When this filter is not used, the function will try to load {mce_locale}.js.
+ If that is not found, en.js will be tried next.
+ */
+ $mce_external_languages = apply_filters('mce_external_languages', array());
+
+ $loaded_langs = array();
+ $strings = '';
+
+ if ( ! empty($mce_external_languages) ) {
+ foreach ( $mce_external_languages as $name => $path ) {
+ if ( @is_file($path) && @is_readable($path) ) {
+ include_once($path);
+ $ext_plugins .= $strings . "\n";
+ $loaded_langs[] = $name;
+ }
+ }
+ }
+
+ foreach ( $mce_external_plugins as $name => $url ) {
+
+ if ( is_ssl() ) $url = str_replace('http://', 'https://', $url);
+
+ $plugins[] = '-' . $name;
+
+ $plugurl = dirname($url);
+ $strings = $str1 = $str2 = '';
+ if ( ! in_array($name, $loaded_langs) ) {
+ $path = str_replace( WP_PLUGIN_URL, '', $plugurl );
+ $path = WP_PLUGIN_DIR . $path . '/langs/';
+
+ if ( function_exists('realpath') )
+ $path = trailingslashit( realpath($path) );
+
+ if ( @is_file($path . $mce_locale . '.js') )
+ $strings .= @file_get_contents($path . $mce_locale . '.js') . "\n";
+
+ if ( @is_file($path . $mce_locale . '_dlg.js') )
+ $strings .= @file_get_contents($path . $mce_locale . '_dlg.js') . "\n";
+
+ if ( 'en' != $mce_locale && empty($strings) ) {
+ if ( @is_file($path . 'en.js') ) {
+ $str1 = @file_get_contents($path . 'en.js');
+ $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n";
+ }
+
+ if ( @is_file($path . 'en_dlg.js') ) {
+ $str2 = @file_get_contents($path . 'en_dlg.js');
+ $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str2, 1 ) . "\n";
+ }
+ }
+
+ if ( ! empty($strings) )
+ $ext_plugins .= "\n" . $strings . "\n";
+ }
+
+ $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
+ $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
+ }
+ }
+ }
+
+ $plugins = implode($plugins, ',');
+
+ if ( $teeny ) {
+ $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen') );
+ $mce_buttons = implode($mce_buttons, ',');
+ $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = '';
+ } else {
+ $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ));
+ $mce_buttons = implode($mce_buttons, ',');
+
+ $mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' ));
+ $mce_buttons_2 = implode($mce_buttons_2, ',');
+
+ $mce_buttons_3 = apply_filters('mce_buttons_3', array());
+ $mce_buttons_3 = implode($mce_buttons_3, ',');
+
+ $mce_buttons_4 = apply_filters('mce_buttons_4', array());
+ $mce_buttons_4 = implode($mce_buttons_4, ',');
+ }
+ $no_captions = ( apply_filters( 'disable_captions', '' ) ) ? true : false;
+
+ // TinyMCE init settings
+ $initArray = array (
+ 'mode' => 'none',
+ 'onpageload' => 'switchEditors.edInit',
+ 'width' => '100%',
+ 'theme' => 'advanced',
+ 'skin' => 'wp_theme',
+ 'theme_advanced_buttons1' => "$mce_buttons",
+ 'theme_advanced_buttons2' => "$mce_buttons_2",
+ 'theme_advanced_buttons3' => "$mce_buttons_3",
+ 'theme_advanced_buttons4' => "$mce_buttons_4",
+ 'language' => "$mce_locale",
+ 'spellchecker_languages' => "$mce_spellchecker_languages",
+ 'theme_advanced_toolbar_location' => 'top',
+ 'theme_advanced_toolbar_align' => 'left',
+ 'theme_advanced_statusbar_location' => 'bottom',
+ 'theme_advanced_resizing' => true,
+ 'theme_advanced_resize_horizontal' => false,
+ 'dialog_type' => 'modal',
+ 'relative_urls' => false,
+ 'remove_script_host' => false,
+ 'convert_urls' => false,
+ 'apply_source_formatting' => false,
+ 'remove_linebreaks' => true,
+ 'paste_convert_middot_lists' => true,
+ 'paste_remove_spans' => true,
+ 'paste_remove_styles' => true,
+ 'gecko_spellcheck' => true,
+ 'entities' => '38,amp,60,lt,62,gt',
+ 'accessibility_focus' => true,
+ 'tab_focus' => ':prev,:next',
+ 'content_css' => "$mce_css",
+ 'save_callback' => 'switchEditors.saveCallback',
+ 'wpeditimage_disable_captions' => $no_captions,
+ 'plugins' => "$plugins"
+ );
+
+ // For people who really REALLY know what they're doing with TinyMCE
+ // You can modify initArray to add, remove, change elements of the config before tinyMCE.init
+ // Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through "tiny_mce_before_init".
+ // Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0.
+ if ( $teeny ) {
+ $initArray = apply_filters('teeny_mce_before_init', $initArray);
+ } else {
+ $initArray = apply_filters('tiny_mce_before_init', $initArray);
+ }
+
+ $language = $initArray['language'];
+
+ $ver = apply_filters('tiny_mce_version', '3101');
+
+ if ( 'en' != $language )
+ include_once(ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php');
+
+ $mce_options = '';
+ foreach ( $initArray as $k => $v )
+ $mce_options .= $k . ':"' . $v . '", ';
+
+ $mce_options = rtrim( trim($mce_options), '\n\r,' ); ?>
+
+<script type="text/javascript">
+/* <![CDATA[ */
+tinyMCEPreInit = {
+ base : "<?php echo $baseurl; ?>",
+ suffix : "",
+ query : "ver=<?php echo $ver; ?>",
+ mceInit : {<?php echo $mce_options; ?>},
+
+ go : function() {
+ var t = this, sl = tinymce.ScriptLoader, ln = t.mceInit.language, th = t.mceInit.theme, pl = t.mceInit.plugins;
+
+ sl.markDone(t.base + '/langs/' + ln + '.js');
+
+ sl.markDone(t.base + '/themes/' + th + '/langs/' + ln + '.js');
+ sl.markDone(t.base + '/themes/' + th + '/langs/' + ln + '_dlg.js');
+
+ tinymce.each(pl.split(','), function(n) {
+ if (n && n.charAt(0) != '-') {
+ sl.markDone(t.base + '/plugins/' + n + '/langs/' + ln + '.js');
+ sl.markDone(t.base + '/plugins/' + n + '/langs/' + ln + '_dlg.js');
+ }
+ });
+ },
+
+ load_ext : function(url,lang) {
+ var sl = tinymce.ScriptLoader;
+
+ sl.markDone(url + '/langs/' + lang + '.js');
+ sl.markDone(url + '/langs/' + lang + '_dlg.js');
+ }
+};
+/* ]]> */
+</script>
+<script type="text/javascript" src="<?php echo $baseurl; ?>/tiny_mce.js?ver=<?php echo $ver; ?>"></script>
+<?php if ( 'en' != $language && isset($lang) ) { ?>
+<script type="text/javascript">
+<?php echo $lang; ?>
+</script>
+<?php } else { ?>
+<script type="text/javascript" src="<?php echo $baseurl; ?>/langs/wp-langs-en.js?ver=<?php echo $ver; ?>"></script>
+<?php } ?>
+<script type="text/javascript">
+<?php if ( $ext_plugins ) echo $ext_plugins; ?>
+
+// Mark translations as done
+tinyMCEPreInit.go();
+
+// Init
+tinyMCE.init(tinyMCEPreInit.mceInit);
+</script>
+
+<?php
+}
+?>
<?php
-// Here we keep the DB structure and option values
-
+/**
+ * WordPress Administration Scheme API
+ *
+ * Here we keep the DB structure and option values.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * The database character collate.
+ * @var string
+ * @global string
+ * @name $charset_collate
+ */
$charset_collate = '';
// Declare these as global in case schema.php is included from a function.
global $wpdb, $wp_queries;
-if ( $wpdb->supports_collation() ) {
+if ( $wpdb->has_cap( 'collation' ) ) {
if ( ! empty($wpdb->charset) )
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
if ( ! empty($wpdb->collate) )
$charset_collate .= " COLLATE $wpdb->collate";
}
-$wp_queries="CREATE TABLE $wpdb->terms (
+/** Create WordPress database tables SQL */
+$wp_queries = "CREATE TABLE $wpdb->terms (
term_id bigint(20) NOT NULL auto_increment,
name varchar(200) NOT NULL default '',
slug varchar(200) NOT NULL default '',
comment_count bigint(20) NOT NULL default '0',
PRIMARY KEY (ID),
KEY post_name (post_name),
- KEY type_status_date (post_type,post_status,post_date,ID)
+ KEY type_status_date (post_type,post_status,post_date,ID),
+ KEY post_parent (post_parent)
) $charset_collate;
CREATE TABLE $wpdb->users (
ID bigint(20) unsigned NOT NULL auto_increment,
KEY meta_key (meta_key)
) $charset_collate;";
+/**
+ * Create WordPress options and set the default values.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ * @uses $wp_db_version
+ */
function populate_options() {
global $wpdb, $wp_db_version;
-
+
$guessurl = wp_guess_url();
-
+
do_action('populate_options');
-
+
add_option('siteurl', $guessurl);
add_option('blogname', __('My Blog'));
add_option('blogdescription', __('Just another WordPress weblog'));
add_option('avatar_default', 'mystery');
add_option('enable_app', 0);
add_option('enable_xmlrpc', 0);
-
+
+ // 2.7
+ add_option('large_size_w', 1024);
+ add_option('large_size_h', 1024);
+ add_option('image_default_link_type', 'file');
+ add_option('image_default_size', '');
+ add_option('image_default_align', '');
+ add_option('close_comments_for_old_posts', 0);
+ add_option('close_comments_days_old', 14);
+ add_option('thread_comments', 0);
+ add_option('thread_comments_depth', 5);
+ add_option('page_comments', 1);
+ add_option('comments_per_page', 50);
+ add_option('default_comments_page', 'newest');
+ add_option('comment_order', 'asc');
+ add_option('use_ssl', 0);
+ add_option('sticky_posts', array());
+ add_option('widget_categories', array());
+ add_option('widget_text', array());
+ add_option('widget_rss', array());
+ add_option('update_core', array());
+ add_option('dismissed_update_core', array());
+
// Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins');
foreach ($unusedoptions as $option) :
endforeach;
}
+/**
+ * Execute WordPress role creation for the various WordPress versions.
+ *
+ * @since 2.0.0
+ */
function populate_roles() {
populate_roles_160();
populate_roles_210();
populate_roles_230();
populate_roles_250();
populate_roles_260();
+ populate_roles_270();
}
+/**
+ * Create the roles for WordPress 2.0
+ *
+ * @since 2.0.0
+ */
function populate_roles_160() {
// Add roles
add_role('subscriber', 'Subscriber|User role');
// Add caps for Administrator role
- $role = get_role('administrator');
+ $role =& get_role('administrator');
$role->add_cap('switch_themes');
$role->add_cap('edit_themes');
$role->add_cap('activate_plugins');
$role->add_cap('level_0');
// Add caps for Editor role
- $role = get_role('editor');
+ $role =& get_role('editor');
$role->add_cap('moderate_comments');
$role->add_cap('manage_categories');
$role->add_cap('manage_links');
$role->add_cap('level_0');
// Add caps for Author role
- $role = get_role('author');
+ $role =& get_role('author');
$role->add_cap('upload_files');
$role->add_cap('edit_posts');
$role->add_cap('edit_published_posts');
$role->add_cap('level_0');
// Add caps for Contributor role
- $role = get_role('contributor');
+ $role =& get_role('contributor');
$role->add_cap('edit_posts');
$role->add_cap('read');
$role->add_cap('level_1');
$role->add_cap('level_0');
// Add caps for Subscriber role
- $role = get_role('subscriber');
+ $role =& get_role('subscriber');
$role->add_cap('read');
$role->add_cap('level_0');
}
+/**
+ * Create and modify WordPress roles for WordPress 2.1.
+ *
+ * @since 2.1.0
+ */
function populate_roles_210() {
$roles = array('administrator', 'editor');
foreach ($roles as $role) {
- $role = get_role($role);
+ $role =& get_role($role);
if ( empty($role) )
continue;
$role->add_cap('read_private_pages');
}
- $role = get_role('administrator');
+ $role =& get_role('administrator');
if ( ! empty($role) ) {
$role->add_cap('delete_users');
$role->add_cap('create_users');
}
- $role = get_role('author');
+ $role =& get_role('author');
if ( ! empty($role) ) {
$role->add_cap('delete_posts');
$role->add_cap('delete_published_posts');
}
- $role = get_role('contributor');
+ $role =& get_role('contributor');
if ( ! empty($role) ) {
$role->add_cap('delete_posts');
}
}
+/**
+ * Create and modify WordPress roles for WordPress 2.3.
+ *
+ * @since 2.3.0
+ */
function populate_roles_230() {
- $role = get_role( 'administrator' );
+ $role =& get_role( 'administrator' );
if ( !empty( $role ) ) {
$role->add_cap( 'unfiltered_upload' );
}
}
+/**
+ * Create and modify WordPress roles for WordPress 2.5.
+ *
+ * @since 2.5.0
+ */
function populate_roles_250() {
- $role = get_role( 'administrator' );
+ $role =& get_role( 'administrator' );
if ( !empty( $role ) ) {
$role->add_cap( 'edit_dashboard' );
}
}
+/**
+ * Create and modify WordPress roles for WordPress 2.6.
+ *
+ * @since 2.6.0
+ */
function populate_roles_260() {
- $role = get_role( 'administrator' );
+ $role =& get_role( 'administrator' );
if ( !empty( $role ) ) {
$role->add_cap( 'update_plugins' );
}
}
+/**
+ * Create and modify WordPress roles for WordPress 2.7.
+ *
+ * @since 2.7.0
+ */
+function populate_roles_270() {
+ $role =& get_role( 'administrator' );
+
+ if ( !empty( $role ) ) {
+ $role->add_cap( 'install_plugins' );
+ $role->add_cap( 'update_themes' );
+ }
+}
+
?>
<?php
+/**
+ * WordPress Taxonomy Administration API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
//
// Category
//
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $cat_name
+ * @return unknown
+ */
function category_exists($cat_name) {
$id = is_term($cat_name, 'category');
if ( is_array($id) )
return $id;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $id
+ * @return unknown
+ */
function get_category_to_edit( $id ) {
$category = get_category( $id, OBJECT, 'edit' );
return $category;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $cat_name
+ * @param unknown_type $parent
+ * @return unknown
+ */
function wp_create_category( $cat_name, $parent = 0 ) {
if ( $id = category_exists($cat_name) )
return $id;
return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $categories
+ * @param unknown_type $post_id
+ * @return unknown
+ */
function wp_create_categories($categories, $post_id = '') {
$cat_ids = array ();
foreach ($categories as $category) {
return $cat_ids;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $cat_ID
+ * @return unknown
+ */
function wp_delete_category($cat_ID) {
$cat_ID = (int) $cat_ID;
$default = get_option('default_category');
return wp_delete_term($cat_ID, 'category', array('default' => $default));
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $catarr
+ * @param unknown_type $wp_error
+ * @return unknown
+ */
function wp_insert_category($catarr, $wp_error = false) {
$cat_defaults = array('cat_ID' => 0, 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '');
- $cat_arr = wp_parse_args($cat_arr, $cat_defaults);
+ $catarr = wp_parse_args($catarr, $cat_defaults);
extract($catarr, EXTR_SKIP);
if ( trim( $cat_name ) == '' ) {
return $cat_ID['term_id'];
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $catarr
+ * @return unknown
+ */
function wp_update_category($catarr) {
$cat_ID = (int) $catarr['cat_ID'];
- if ( $cat_ID == $catarr['category_parent'] )
+ if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) )
return false;
// First, get all of the original fields
// Tags
//
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $post_id
+ * @return unknown
+ */
function get_tags_to_edit( $post_id ) {
$post_id = (int) $post_id;
if ( !$post_id )
return $tags_to_edit;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $tag_name
+ * @return unknown
+ */
function tag_exists($tag_name) {
return is_term($tag_name, 'post_tag');
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $tag_name
+ * @return unknown
+ */
function wp_create_tag($tag_name) {
if ( $id = tag_exists($tag_name) )
return $id;
<?php
-
-//
-// Big Mess
-//
+/**
+ * Template WordPress Administration API.
+ *
+ * A Big Mess. Also some neat functions that are nicely written.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
// Ugly recursive category stuff.
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $parent
+ * @param unknown_type $level
+ * @param unknown_type $categories
+ * @param unknown_type $page
+ * @param unknown_type $per_page
+ */
function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) {
$count = 0;
_cat_rows($categories, $count, $parent, $level, $page, $per_page);
}
+/**
+ * {@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( $categories, &$count, $parent = 0, $level = 0, $page = 1, $per_page = 20 ) {
if ( empty($categories) ) {
$args = array('hide_empty' => 0);
// If the page starts in a subtree, print the parents.
if ( $count == $start && $category->parent > 0 ) {
$my_parents = array();
- $my_parent = $category->parent;
while ( $my_parent) {
$my_parent = get_category($my_parent);
$my_parents[] = $my_parent;
if ( $count >= $start )
echo "\t" . _cat_row( $category, $level );
- unset($categories[$i]); // Prune the working set
+ unset($categories[$i]); // Prune the working set
$count++;
if ( isset($children[$category->term_id]) )
$output = ob_get_contents();
ob_end_clean();
- $output = apply_filters('cat_rows', $output);
-
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 ) {
- global $class;
+ static $row_class = '';
- $category = get_category( $category );
+ $category = get_category( $category, OBJECT, 'display' );
+ $default_cat_id = (int) get_option( 'default_category' );
$pad = str_repeat( '— ', $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 = "<a class='row-title' href='categories.php?action=edit&cat_ID=$category->term_id' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>$name</a>";
+ $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>" . attribute_escape( $name ) . '</a><br />';
+ $actions = array();
+ $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
+ $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
+ if ( $default_cat_id != $category->term_id )
+ $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
+ $action_count = count($actions);
+ $i = 0;
+ $edit .= '<div class="row-actions">';
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ $edit .= "<span class='$action'>$link$sep</span>";
+ }
+ $edit .= '</div>';
} else {
$edit = $name;
}
- $class = " class='alternate'" == $class ? '' : " class='alternate'";
+ $row_class = 'alternate' == $row_class ? '' : 'alternate';
+ $qe_data = get_category_to_edit($category->term_id);
$category->count = number_format_i18n( $category->count );
$posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;
- $output = "<tr id='cat-$category->term_id'$class>
- <th scope='row' class='check-column'>";
- if ( absint(get_option( 'default_category' ) ) != $category->term_id ) {
- $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
- } else {
- $output .= " ";
+ $output = "<tr id='cat-$category->term_id' class='iedit $row_class'>";
+
+ $columns = get_column_headers('categories');
+ $hidden = get_hidden_columns('categories');
+ foreach ( $columns as $column_name => $column_display_name ) {
+ $class = "class=\"$column_name column-$column_name\"";
+
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
+
+ $attributes = "$class$style";
+
+ switch ($column_name) {
+ case 'cb':
+ $output .= "<th scope='row' class='check-column'>";
+ if ( $default_cat_id != $category->term_id ) {
+ $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
+ } else {
+ $output .= " ";
+ }
+ $output .= '</th>';
+ break;
+ case 'name':
+ $output .= "<td $attributes>$edit";
+ $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
+ $output .= '<div class="name">' . $qe_data->name . '</div>';
+ $output .= '<div class="slug">' . $qe_data->slug . '</div>';
+ $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
+ break;
+ case 'description':
+ $output .= "<td $attributes>$category->description</td>";
+ break;
+ case 'slug':
+ $output .= "<td $attributes>$category->slug</td>";
+ break;
+ case 'posts':
+ $attributes = 'class="posts column-posts num"' . $style;
+ $output .= "<td $attributes>$posts_count</td>\n";
+ }
+ }
+ $output .= '</tr>';
+
+ return $output;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7
+ *
+ * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit.
+ *
+ * @param string $type "tag", "category" or "link-category"
+ * @return
+ */
+function inline_edit_term_row($type) {
+
+ if ( ! current_user_can( 'manage_categories' ) )
+ return;
+
+ $is_tag = $type == 'edit-tags';
+ $columns = get_column_headers($type);
+ $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) );
+ $col_count = count($columns) - count($hidden);
+ ?>
+
+<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
+ <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>">
+
+ <fieldset><div class="inline-edit-col">
+ <h4><?php _e( 'Quick Edit' ); ?></h4>
+
+ <label>
+ <span class="title"><?php _e( 'Name' ); ?></span>
+ <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
+ </label>
+
+ <label>
+ <span class="title"><?php _e( 'Slug' ); ?></span>
+ <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
+ </label>
+
+<?php if ( 'category' == $type ) : ?>
+
+ <label>
+ <span class="title"><?php _e( 'Parent' ); ?></span>
+ <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('None'))); ?>
+ </label>
+
+<?php endif; // $type ?>
+
+ </div></fieldset>
+
+<?php
+
+ $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
+
+ foreach ( $columns as $column_name => $column_display_name ) {
+ if ( isset( $core_columns[$column_name] ) )
+ continue;
+ do_action( 'quick_edit_custom_box', $column_name, $type );
}
- $output .= "</th>
- <td>$edit</td>
- <td>$category->description</td>
- <td class='num'>$posts_count</td>\n\t</tr>\n";
- return apply_filters('cat_row', $output);
+?>
+
+ <p class="inline-edit-save submit">
+ <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a>
+ <?php $update_text = ( $is_tag ) ? __( 'Update Tag' ) : __( 'Update Category' ); ?>
+ <a accesskey="s" href="#inline-edit" title="<?php echo attribute_escape( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>
+ <img class="waiting" style="display:none;" src="images/loading.gif" alt="" />
+ <span class="error" style="display:none;"></span>
+ <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
+ <br class="clear" />
+ </p>
+ </td></tr>
+ </tbody></table></form>
+<?php
}
-function link_cat_row( $category ) {
- global $class;
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $category
+ * @param unknown_type $name_override
+ * @return unknown
+ */
+function link_cat_row( $category, $name_override = false ) {
+ static $row_class = '';
- if ( !$category = get_term( $category, 'link_category' ) )
+ if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) )
return false;
if ( is_wp_error( $category ) )
return $category;
+ $default_cat_id = (int) get_option( 'default_link_category' );
$name = ( $name_override ? $name_override : $category->name );
+ $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id";
if ( current_user_can( 'manage_categories' ) ) {
- $edit = "<a class='row-title' href='link-category.php?action=edit&cat_ID=$category->term_id' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "' class='edit'>$name</a>";
- $default_cat_id = (int) get_option( 'default_link_category' );
+ $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>$name</a><br />";
+ $actions = array();
+ $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
+ $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
+ if ( $default_cat_id != $category->term_id )
+ $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
+ $action_count = count($actions);
+ $i = 0;
+ $edit .= '<div class="row-actions">';
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ $edit .= "<span class='$action'>$link$sep</span>";
+ }
+ $edit .= '</div>';
} else {
$edit = $name;
}
- $class = " class='alternate'" == $class ? '' : " class='alternate'";
+ $row_class = 'alternate' == $row_class ? '' : 'alternate';
+ $qe_data = get_term_to_edit($category->term_id, 'link_category');
$category->count = number_format_i18n( $category->count );
$count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
- $output = "<tr id='link-cat-$category->term_id'$class>
- <th scope='row' class='check-column'>";
- if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {
- $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
- } else {
- $output .= " ";
+ $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>";
+ $columns = get_column_headers('edit-link-categories');
+ $hidden = get_hidden_columns('edit-link-categories');
+ foreach ( $columns as $column_name => $column_display_name ) {
+ $class = "class=\"$column_name column-$column_name\"";
+
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
+
+ $attributes = "$class$style";
+
+ switch ($column_name) {
+ case 'cb':
+ $output .= "<th scope='row' class='check-column'>";
+ if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {
+ $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
+ } else {
+ $output .= " ";
+ }
+ $output .= "</th>";
+ break;
+ case 'name':
+ $output .= "<td $attributes>$edit";
+ $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
+ $output .= '<div class="name">' . $qe_data->name . '</div>';
+ $output .= '<div class="slug">' . $qe_data->slug . '</div>';
+ $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
+ break;
+ case 'description':
+ $output .= "<td $attributes>$category->description</td>";
+ break;
+ case 'slug':
+ $output .= "<td $attributes>$category->slug</td>";
+ break;
+ case 'links':
+ $attributes = 'class="links column-links num"' . $style;
+ $output .= "<td $attributes>$count</td>";
+ }
}
- $output .= "</th>
- <td>$edit</td>
- <td>$category->description</td>
- <td class='num'>$count</td></tr>";
+ $output .= '</tr>';
- return apply_filters( 'link_cat_row', $output );
+ return $output;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $checked
+ * @param unknown_type $current
+ */
function checked( $checked, $current) {
if ( $checked == $current)
echo ' checked="checked"';
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $selected
+ * @param unknown_type $current
+ */
function selected( $selected, $current) {
if ( $selected == $current)
echo ' selected="selected"';
// Category Checklists
//
-// Deprecated. Use wp_link_category_checklist
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ * @deprecated Use {@link wp_link_category_checklist()}
+ * @see wp_link_category_checklist()
+ *
+ * @param unknown_type $default
+ * @param unknown_type $parent
+ * @param unknown_type $popular_ids
+ */
function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
global $post_ID;
wp_category_checklist($post_ID);
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
class Walker_Category_Checklist extends Walker {
var $tree_type = 'category';
var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
extract($args);
$class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
- $output .= "\n<li id='category-$category->term_id'$class>" . '<label for="in-category-' . $category->term_id . '" class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
+ $output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
}
function end_el(&$output, $category, $depth, $args) {
}
}
-function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false ) {
- $walker = new Walker_Category_Checklist;
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $post_id
+ * @param unknown_type $descendants_and_self
+ * @param unknown_type $selected_cats
+ * @param unknown_type $popular_cats
+ */
+function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null ) {
+ if ( empty($walker) || !is_a($walker, 'Walker') )
+ $walker = new Walker_Category_Checklist;
+
$descendants_and_self = (int) $descendants_and_self;
$args = array();
-
+
if ( is_array( $selected_cats ) )
$args['selected_cats'] = $selected_cats;
elseif ( $post_id )
echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $taxonomy
+ * @param unknown_type $default
+ * @param unknown_type $number
+ * @param unknown_type $echo
+ * @return unknown
+ */
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
global $post_ID;
if ( $post_ID )
?>
<li id="<?php echo $id; ?>" class="popular-category">
- <label class="selectit" for="in-<?php echo $id; ?>">
+ <label class="selectit">
<input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
<?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
</label>
return $popular_ids;
}
-// Deprecated. Use wp_link_category_checklist
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ * @deprecated Use {@link wp_link_category_checklist()}
+ * @see wp_link_category_checklist()
+ *
+ * @param unknown_type $default
+ */
function dropdown_link_categories( $default = 0 ) {
global $link_id;
wp_link_category_checklist($link_id);
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $link_id
+ */
function wp_link_category_checklist( $link_id = 0 ) {
+ $default = 1;
+
if ( $link_id ) {
$checked_categories = wp_get_link_cats($link_id);
// Returns a single tag row (see tag_rows below)
// Note: this is also used in admin-ajax.php!
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $tag
+ * @param unknown_type $class
+ * @return unknown
+ */
function _tag_row( $tag, $class = '' ) {
$count = number_format_i18n( $tag->count );
$count = ( $count > 0 ) ? "<a href='edit.php?tag=$tag->slug'>$count</a>" : $count;
$name = apply_filters( 'term_name', $tag->name );
+ $qe_data = get_term($tag->term_id, 'post_tag', object, 'edit');
+ $edit_link = "edit-tags.php?action=edit&tag_ID=$tag->term_id";
$out = '';
$out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>';
- $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
- $out .= '<td><strong><a class="row-title" href="edit-tags.php?action=edit&tag_ID=' . $tag->term_id . '" title="' . attribute_escape(sprintf(__('Edit "%s"'), $name)) . '">' .
- $name . '</a></td>';
+ $columns = get_column_headers('edit-tags');
+ $hidden = get_hidden_columns('edit-tags');
+ foreach ( $columns as $column_name => $column_display_name ) {
+ $class = "class=\"$column_name column-$column_name\"";
+
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
+
+ $attributes = "$class$style";
+
+ switch ($column_name) {
+ case 'cb':
+ $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
+ break;
+ case 'name':
+ $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . attribute_escape(sprintf(__('Edit "%s"'), $name)) . '">' . $name . '</a></strong><br />';
+ $actions = array();
+ $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
+ $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
+ $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this tag '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
+ $action_count = count($actions);
+ $i = 0;
+ $out .= '<div class="row-actions">';
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ $out .= "<span class='$action'>$link$sep</span>";
+ }
+ $out .= '</div>';
+ $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
+ $out .= '<div class="name">' . $qe_data->name . '</div>';
+ $out .= '<div class="slug">' . $qe_data->slug . '</div></div></td>';
+ break;
+ case 'slug':
+ $out .= "<td $attributes>$tag->slug</td>";
+ break;
+ case 'posts':
+ $attributes = 'class="posts column-posts num"' . $style;
+ $out .= "<td $attributes>$count</td>";
+ break;
+ }
+ }
- $out .= "<td class='num'>$count</td>";
$out .= '</tr>';
return $out;
// Outputs appropriate rows for the Nth page of the Tag Management screen,
// assuming M tags displayed at a time on the page
// Returns the number of tags displayed
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ * @param unknown_type $pagesize
+ * @param unknown_type $searchterms
+ * @return unknown
+ */
function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) {
// Get a page worth of tags
// convert it to table rows
$out = '';
- $class = '';
$count = 0;
foreach( $tags as $tag )
- $out .= _tag_row( $tag, ++$count % 2 ? ' class="alternate"' : '' );
+ $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"' );
// filter and send to screen
- $out = apply_filters('tag_rows', $out);
echo $out;
return $count;
}
// define the columns to display, the syntax is 'internal name' => 'display name'
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function wp_manage_posts_columns() {
$posts_columns = array();
$posts_columns['cb'] = '<input type="checkbox" />';
- if ( 'draft' === $_GET['post_status'] )
- $posts_columns['modified'] = __('Modified');
- elseif ( 'pending' === $_GET['post_status'] )
- $posts_columns['modified'] = __('Submitted');
- else
- $posts_columns['date'] = __('Date');
- $posts_columns['title'] = __('Title');
+ $posts_columns['title'] = _c('Post|noun');
$posts_columns['author'] = __('Author');
$posts_columns['categories'] = __('Categories');
$posts_columns['tags'] = __('Tags');
- if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
+ if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
$posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
- $posts_columns['status'] = __('Status');
+ $posts_columns['date'] = __('Date');
$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
return $posts_columns;
}
// define the columns to display, the syntax is 'internal name' => 'display name'
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function wp_manage_media_columns() {
$posts_columns = array();
$posts_columns['cb'] = '<input type="checkbox" />';
$posts_columns['icon'] = '';
- $posts_columns['media'] = _c('Media|media column header');
- $posts_columns['desc'] = _c('Description|media column header');
- $posts_columns['date'] = _c('Date Added|media column header');
- $posts_columns['parent'] = _c('Appears with|media column header');
+ $posts_columns['media'] = _c('File|media column header');
+ $posts_columns['author'] = __('Author');
+ //$posts_columns['tags'] = _c('Tags|media column header');
+ $posts_columns['parent'] = _c('Attached to|media column header');
$posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
- $posts_columns['location'] = _c('Location|media column header');
+ //$posts_columns['comments'] = __('Comments');
+ $posts_columns['date'] = _c('Date|media column header');
$posts_columns = apply_filters('manage_media_columns', $posts_columns);
return $posts_columns;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function wp_manage_pages_columns() {
$posts_columns = array();
$posts_columns['cb'] = '<input type="checkbox" />';
- if ( 'draft' === $_GET['post_status'] )
- $posts_columns['modified'] = __('Modified');
- elseif ( 'pending' === $_GET['post_status'] )
- $posts_columns['modified'] = __('Submitted');
- else
- $posts_columns['date'] = __('Date');
$posts_columns['title'] = __('Title');
$posts_columns['author'] = __('Author');
- if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
+ $post_status = 'all';
+ if ( !empty($_GET['post_status']) )
+ $post_status = $_GET['post_status'];
+ if ( !in_array($post_status, array('pending', 'draft', 'future')) )
$posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>';
- $posts_columns['status'] = __('Status');
+ $posts_columns['date'] = __('Date');
$posts_columns = apply_filters('manage_pages_columns', $posts_columns);
return $posts_columns;
}
-/*
- * display one row if the page doesn't have any children
- * otherwise, display the row and its children in subsequent rows
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ * @return unknown
*/
-function display_page_row( $page, $level = 0 ) {
- global $post;
- static $class;
+function get_column_headers($page) {
+ global $_wp_column_headers;
+
+ if ( !isset($_wp_column_headers) )
+ $_wp_column_headers = array();
+
+ // Store in static to avoid running filters on each call
+ if ( isset($_wp_column_headers[$page]) )
+ return $_wp_column_headers[$page];
+
+ switch ($page) {
+ case 'edit':
+ $_wp_column_headers[$page] = wp_manage_posts_columns();
+ break;
+ case 'edit-pages':
+ $_wp_column_headers[$page] = wp_manage_pages_columns();
+ break;
+ case 'edit-comments':
+ $_wp_column_headers[$page] = array(
+ 'cb' => '<input type="checkbox" />',
+ 'author' => __('Author'),
+ 'comment' => _c('Comment|noun'),
+ //'date' => __('Submitted'),
+ 'response' => __('In Response To')
+ );
- $post = $page;
- setup_postdata($page);
+ break;
+ case 'link-manager':
+ $_wp_column_headers[$page] = array(
+ 'cb' => '<input type="checkbox" />',
+ 'name' => __('Name'),
+ 'url' => __('URL'),
+ 'categories' => __('Categories'),
+ 'rel' => __('rel'),
+ 'visible' => __('Visible')
+ );
- $page->post_title = wp_specialchars( $page->post_title );
- $pad = str_repeat( '— ', $level );
- $id = (int) $page->ID;
- $class = ('alternate' == $class ) ? '' : 'alternate';
- $posts_columns = wp_manage_pages_columns();
- $title = get_the_title();
- if ( empty($title) )
- $title = __('(no title)');
-?>
- <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
+ break;
+ case 'upload':
+ $_wp_column_headers[$page] = wp_manage_media_columns();
+ break;
+ case 'categories':
+ $_wp_column_headers[$page] = array(
+ 'cb' => '<input type="checkbox" />',
+ 'name' => __('Name'),
+ 'description' => __('Description'),
+ 'slug' => __('Slug'),
+ 'posts' => __('Posts')
+ );
+ break;
+ case 'edit-link-categories':
+ $_wp_column_headers[$page] = array(
+ 'cb' => '<input type="checkbox" />',
+ 'name' => __('Name'),
+ 'description' => __('Description'),
+ 'slug' => __('Slug'),
+ 'links' => __('Links')
+ );
- <?php
+ break;
+ case 'edit-tags':
+ $_wp_column_headers[$page] = array(
+ 'cb' => '<input type="checkbox" />',
+ 'name' => __('Name'),
+ 'slug' => __('Slug'),
+ 'posts' => __('Posts')
+ );
-foreach ($posts_columns as $column_name=>$column_display_name) {
+ break;
+ case 'users':
+ $_wp_column_headers[$page] = array(
+ 'cb' => '<input type="checkbox" />',
+ 'username' => __('Username'),
+ 'name' => __('Name'),
+ 'email' => __('E-mail'),
+ 'role' => __('Role'),
+ 'posts' => __('Posts')
+ );
+ break;
+ default :
+ $_wp_column_headers[$page] = array();
+ }
- switch ($column_name) {
+ $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]);
+ return $_wp_column_headers[$page];
+}
- case 'cb':
- ?>
- <th scope="row" class="check-column"><input type="checkbox" name="delete[]" value="<?php the_ID(); ?>" /></th>
- <?php
- break;
- case 'modified':
- case 'date':
- if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) {
- $t_time = $h_time = __('Unpublished');
- } else {
- if ( 'modified' == $column_name ) {
- $t_time = get_the_modified_time(__('Y/m/d g:i:s A'));
- $m_time = $page->post_modified;
- $time = get_post_modified_time('G', true);
- } else {
- $t_time = get_the_time(__('Y/m/d g:i:s A'));
- $m_time = $page->post_date;
- $time = get_post_time('G', true);
- }
- if ( ( abs(time() - $time) ) < 86400 ) {
- if ( ( 'future' == $page->post_status) )
- $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
- else
- $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
- } else {
- $h_time = mysql2date(__('Y/m/d'), $m_time);
- }
- }
- ?>
- <td><abbr title="<?php echo $t_time ?>"><?php echo $h_time ?></abbr></td>
- <?php
- break;
- case 'title':
- ?>
- <td><strong><a class="row-title" href="page.php?action=edit&post=<?php the_ID(); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $pad; echo $title ?></a></strong>
- <?php if ('private' == $page->post_status) _e(' — <strong>Private</strong>'); ?></td>
- <?php
- break;
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $type
+ * @param unknown_type $id
+ */
+function print_column_headers( $type, $id = true ) {
+ $type = str_replace('.php', '', $type);
+ $columns = get_column_headers( $type );
+ $hidden = get_hidden_columns($type);
+ $styles = array();
+// $styles['tag']['posts'] = 'width: 90px;';
+// $styles['link-category']['links'] = 'width: 90px;';
+// $styles['category']['posts'] = 'width: 90px;';
+// $styles['link']['visible'] = 'text-align: center;';
- case 'comments':
- ?>
- <td class="num"><div class="post-com-count-wrapper">
- <?php
- $left = get_pending_comments_num( $page->ID );
- $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
- if ( $left )
- echo '<strong>';
- comments_number("<a href='edit-pages.php?page_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-pages.php?page_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-pages.php?page_id=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
- if ( $left )
- echo '</strong>';
- ?>
- </div></td>
- <?php
- break;
+ foreach ( $columns as $column_key => $column_display_name ) {
+ $class = ' class="manage-column';
- case 'author':
- ?>
- <td><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
- <?php
- break;
+ $class .= " column-$column_key";
- case 'status':
- ?>
- <td>
- <a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink">
- <?php
- switch ( $page->post_status ) {
- case 'publish' :
- case 'private' :
- _e('Published');
- break;
- case 'future' :
- _e('Scheduled');
- break;
- case 'pending' :
- _e('Pending Review');
- break;
- case 'draft' :
- _e('Unpublished');
- break;
- }
- ?>
- </a>
- </td>
- <?php
- break;
+ if ( 'cb' == $column_key )
+ $class .= ' check-column';
+ elseif ( in_array($column_key, array('posts', 'comments', 'links')) )
+ $class .= ' num';
- default:
- ?>
- <td><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td>
- <?php
- break;
- }
-}
- ?>
+ $class .= '"';
- </tr>
+ $style = '';
+ if ( in_array($column_key, $hidden) )
+ $style = 'display:none;';
-<?php
+ if ( isset($styles[$type]) && isset($styles[$type][$column_key]) )
+ $style .= ' ' . $styles[$type][$column_key];
+ $style = ' style="' . $style . '"';
+?>
+ <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
+<?php }
}
-/*
- * displays pages in hierarchical order with paging support
+/**
+ * Register column headers for a particular screen. The header names will be listed in the Screen Options.
+ *
+ * @since 2.7.0
+ *
+ * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
+ * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
+ * @see get_column_headers(), print_column_headers(), get_hidden_columns()
*/
-function page_rows($pages, $pagenum = 1, $per_page = 20) {
- $level = 0;
+function register_column_headers($screen, $columns) {
+ global $_wp_column_headers;
- if ( ! $pages ) {
- $pages = get_pages( array('sort_column' => 'menu_order') );
+ if ( !isset($_wp_column_headers) )
+ $_wp_column_headers = array();
- if ( ! $pages )
- return false;
- }
+ $_wp_column_headers[$screen] = $columns;
+}
- /*
- * arrange pages into two parts: top level pages and children_pages
- * children_pages is two dimensional array, eg.
- * children_pages[10][] contains all sub-pages whose parent is 10.
- * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ */
+function get_hidden_columns($page) {
+ $page = str_replace('.php', '', $page);
+ return (array) get_user_option( 'manage-' . $page . '-columns-hidden', 0, false );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Outputs the quick edit and bulk edit table rows for posts and pages
+ *
+ * @since 2.7
+ *
+ * @param string $type 'post' or 'page'
+ */
+function inline_edit_row( $type ) {
+ global $current_user, $mode;
+
+ $is_page = 'page' == $type;
+ if ( $is_page ) {
+ $screen = 'edit-pages';
+ $post = get_default_page_to_edit();
+ } else {
+ $screen = 'edit';
+ $post = get_default_post_to_edit();
+ }
+
+ $columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns();
+ $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
+ $col_count = count($columns) - count($hidden);
+ $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
+ $can_publish = current_user_can("publish_{$type}s");
+ $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
+
+?>
+
+<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
+ <?php
+ $bulk = 0;
+ while ( $bulk < 2 ) { ?>
+
+ <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type ";
+ echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type";
+ ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
+
+ <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
+ <h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4>
+
+
+<?php if ( $bulk ) : ?>
+ <div id="bulk-title-div">
+ <div id="bulk-titles"></div>
+ </div>
+
+<?php else : // $bulk ?>
+
+ <label>
+ <span class="title"><?php _e( 'Title' ); ?></span>
+ <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
+ </label>
+
+<?php endif; // $bulk ?>
+
+
+<?php if ( !$bulk ) : ?>
+
+ <label>
+ <span class="title"><?php _e( 'Slug' ); ?></span>
+ <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
+ </label>
+
+ <label><span class="title"><?php _e( 'Date' ); ?></span></label>
+ <div class="inline-edit-date">
+ <?php touch_time(1, 1, 4, 1); ?>
+ </div>
+ <br class="clear" />
+
+<?php endif; // $bulk
+
+ ob_start();
+ $authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM
+ if ( $authors && count( $authors ) > 1 ) :
+ $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1);
+ if ( $bulk )
+ $users_opt['show_option_none'] = __('- No Change -');
+?>
+ <label>
+ <span class="title"><?php _e( 'Author' ); ?></span>
+ <?php wp_dropdown_users( $users_opt ); ?>
+ </label>
+
+<?php
+ endif; // authors
+ $authors_dropdown = ob_get_clean();
+?>
+
+<?php if ( !$bulk ) : echo $authors_dropdown; ?>
+
+ <div class="inline-edit-group">
+ <label class="alignleft">
+ <span class="title"><?php _e( 'Password' ); ?></span>
+ <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
+ </label>
+
+ <em style="margin:5px 10px 0 0" class="alignleft"><?php echo _c( '–OR–|Between password field and private checkbox on post quick edit interface' ); ?></em>
+
+ <label class="alignleft inline-edit-private">
+ <input type="checkbox" name="keep_private" value="private" />
+ <span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span>
+ </label>
+ </div>
+
+<?php endif; ?>
+
+ </div></fieldset>
+
+<?php if ( !$is_page && !$bulk ) : ?>
+
+ <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
+ <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?>
+ <span class="catshow"><?php _e('[more]'); ?></span>
+ <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>
+ </span>
+ <ul class="cat-checklist">
+ <?php wp_category_checklist(); ?>
+ </ul>
+ </div></fieldset>
+
+<?php endif; // !$is_page && !$bulk ?>
+
+ <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
+
+<?php
+ if ( $bulk )
+ echo $authors_dropdown;
+?>
+
+<?php if ( $is_page ) : ?>
+
+ <label>
+ <span class="title"><?php _e( 'Parent' ); ?></span>
+<?php
+ $dropdown_args = array('selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title');
+ if ( $bulk )
+ $dropdown_args['show_option_no_change'] = __('- No Change -');
+ $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
+ wp_dropdown_pages($dropdown_args);
+?>
+ </label>
+
+<?php if ( !$bulk ) : ?>
+
+ <label>
+ <span class="title"><?php _e( 'Order' ); ?></span>
+ <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
+ </label>
+
+<?php endif; // !$bulk ?>
+
+ <label>
+ <span class="title"><?php _e( 'Template' ); ?></span>
+ <select name="page_template">
+<?php if ( $bulk ) : ?>
+ <option value="-1"><?php _e('- No Change -'); ?></option>
+<?php endif; // $bulk ?>
+ <option value="default"><?php _e( 'Default Template' ); ?></option>
+ <?php page_template_dropdown() ?>
+ </select>
+ </label>
+
+<?php elseif ( !$bulk ) : // $is_page ?>
+
+ <label class="inline-edit-tags">
+ <span class="title"><?php _e( 'Tags' ); ?></span>
+ <textarea cols="22" rows="1" name="tags_input" class="tags_input"></textarea>
+ </label>
+
+<?php endif; // $is_page ?>
+
+<?php if ( $bulk ) : ?>
+
+ <div class="inline-edit-group">
+ <label class="alignleft">
+ <span class="title"><?php _e( 'Comments' ); ?></span>
+ <select name="comment_status">
+ <option value=""><?php _e('- No Change -'); ?></option>
+ <option value="open"><?php _e('Allow'); ?></option>
+ <option value="closed"><?php _e('Do not allow'); ?></option>
+ </select>
+ </label>
+
+ <label class="alignright">
+ <span class="title"><?php _e( 'Pings' ); ?></span>
+ <select name="ping_status">
+ <option value=""><?php _e('- No Change -'); ?></option>
+ <option value="open"><?php _e('Allow'); ?></option>
+ <option value="closed"><?php _e('Do not allow'); ?></option>
+ </select>
+ </label>
+ </div>
+
+<?php else : // $bulk ?>
+
+ <div class="inline-edit-group">
+ <label class="alignleft">
+ <input type="checkbox" name="comment_status" value="open" />
+ <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
+ </label>
+
+ <label class="alignleft">
+ <input type="checkbox" name="ping_status" value="open" />
+ <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
+ </label>
+ </div>
+
+<?php endif; // $bulk ?>
+
+
+ <div class="inline-edit-group">
+ <label class="inline-edit-status alignleft">
+ <span class="title"><?php _e( 'Status' ); ?></span>
+ <select name="_status">
+<?php if ( $bulk ) : ?>
+ <option value="-1"><?php _e('- No Change -'); ?></option>
+<?php endif; // $bulk ?>
+ <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
+ <option value="publish"><?php _e( 'Published' ); ?></option>
+ <option value="future"><?php _e( 'Scheduled' ); ?></option>
+<?php if ( $bulk ) : ?>
+ <option value="private"><?php _e('Private') ?></option>
+<?php endif; // $bulk ?>
+ <?php endif; ?>
+ <option value="pending"><?php _e( 'Pending Review' ); ?></option>
+ <option value="draft"><?php _e( 'Unpublished' ); ?></option>
+ </select>
+ </label>
+
+<?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?>
+
+<?php if ( $bulk ) : ?>
+
+ <label class="alignright">
+ <span class="title"><?php _e( 'Sticky' ); ?></span>
+ <select name="sticky">
+ <option value="-1"><?php _e( '- No Change -' ); ?></option>
+ <option value="sticky"><?php _e( 'Sticky' ); ?></option>
+ <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
+ </select>
+ </label>
+
+<?php else : // $bulk ?>
+
+ <label class="alignleft">
+ <input type="checkbox" name="sticky" value="sticky" />
+ <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
+ </label>
+
+<?php endif; // $bulk ?>
+
+<?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ?>
+
+ </div>
+
+ </div></fieldset>
+
+<?php
+ foreach ( $columns as $column_name => $column_display_name ) {
+ if ( isset( $core_columns[$column_name] ) )
+ continue;
+ do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $type);
+ }
+?>
+ <p class="submit inline-edit-save">
+ <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>
+ <?php if ( ! $bulk ) {
+ wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
+ $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' );
+ ?>
+ <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo attribute_escape( $update_text ); ?></a>
+ <img class="waiting" style="display:none;" src="images/loading.gif" alt="" />
+ <?php } else {
+ $update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' );
+ ?>
+ <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo attribute_escape( $update_text ); ?>" />
+ <?php } ?>
+ <input type="hidden" name="post_view" value="<?php echo $m; ?>" />
+ <br class="clear" />
+ </p>
+ </td></tr>
+<?php
+ $bulk++;
+ } ?>
+ </tbody></table></form>
+<?php
+}
+
+// adds hidden fields with the data for use in the inline editor for posts and pages
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $post
+ */
+function get_inline_data($post) {
+
+ if ( ! current_user_can('edit_' . $post->post_type, $post->ID) )
+ return;
+
+ $title = attribute_escape($post->post_title);
+
+ echo '
+<div class="hidden" id="inline_' . $post->ID . '">
+ <div class="post_title">' . $title . '</div>
+ <div class="post_name">' . $post->post_name . '</div>
+ <div class="post_author">' . $post->post_author . '</div>
+ <div class="comment_status">' . $post->comment_status . '</div>
+ <div class="ping_status">' . $post->ping_status . '</div>
+ <div class="_status">' . $post->post_status . '</div>
+ <div class="jj">' . mysql2date( 'd', $post->post_date ) . '</div>
+ <div class="mm">' . mysql2date( 'm', $post->post_date ) . '</div>
+ <div class="aa">' . mysql2date( 'Y', $post->post_date ) . '</div>
+ <div class="hh">' . mysql2date( 'H', $post->post_date ) . '</div>
+ <div class="mn">' . mysql2date( 'i', $post->post_date ) . '</div>
+ <div class="ss">' . mysql2date( 's', $post->post_date ) . '</div>
+ <div class="post_password">' . wp_specialchars($post->post_password, 1) . '</div>';
+
+ if( $post->post_type == 'page' )
+ echo '
+ <div class="post_parent">' . $post->post_parent . '</div>
+ <div class="page_template">' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . '</div>
+ <div class="menu_order">' . $post->menu_order . '</div>';
+
+ if( $post->post_type == 'post' )
+ echo '
+ <div class="tags_input">' . wp_specialchars( str_replace( ',', ', ', get_tags_to_edit($post->ID) ), 1) . '</div>
+ <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
+ <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
+
+ echo '</div>';
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $posts
+ */
+function post_rows( $posts = array() ) {
+ global $wp_query, $post, $mode;
+
+ add_filter('the_title','wp_specialchars');
+
+ // Create array of post IDs.
+ $post_ids = array();
+
+ if ( empty($posts) )
+ $posts = &$wp_query->posts;
+
+ foreach ( $posts as $a_post )
+ $post_ids[] = $a_post->ID;
+
+ $comment_pending_count = get_pending_comments_num($post_ids);
+ if ( empty($comment_pending_count) )
+ $comment_pending_count = array();
+
+ foreach ( $posts as $post ) {
+ if ( empty($comment_pending_count[$post->ID]) )
+ $comment_pending_count[$post->ID] = 0;
+
+ _post_row($post, $comment_pending_count[$post->ID], $mode);
+ }
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $a_post
+ * @param unknown_type $pending_comments
+ * @param unknown_type $mode
+ */
+function _post_row($a_post, $pending_comments, $mode) {
+ global $post;
+ static $rowclass;
+
+ $global_post = $post;
+ $post = $a_post;
+ setup_postdata($post);
+
+ $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
+ global $current_user;
+ $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
+ $edit_link = get_edit_post_link( $post->ID );
+ $title = _draft_or_post_title();
+?>
+ <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
+<?php
+ $posts_columns = get_column_headers('edit');
+ $hidden = get_hidden_columns('edit');
+ foreach ( $posts_columns as $column_name=>$column_display_name ) {
+ $class = "class=\"$column_name column-$column_name\"";
+
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
+
+ $attributes = "$class$style";
+
+ switch ($column_name) {
+
+ case 'cb':
+ ?>
+ <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
+ <?php
+ break;
+
+ case 'date':
+ if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
+ $t_time = $h_time = __('Unpublished');
+ } else {
+ $t_time = get_the_time(__('Y/m/d g:i:s A'));
+ $m_time = $post->post_date;
+ $time = get_post_time('G', true, $post);
+
+ $time_diff = time() - $time;
+
+ if ( ( 'future' == $post->post_status) ) {
+ if ( $time_diff <= 0 ) {
+ $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
+ } else {
+ $h_time = $t_time;
+ $missed = true;
+ }
+ } else {
+
+ if ( $time_diff > 0 && $time_diff < 24*60*60 )
+ $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
+ else
+ $h_time = mysql2date(__('Y/m/d'), $m_time);
+ }
+ }
+
+ echo '<td ' . $attributes . '>';
+ if ( 'excerpt' == $mode )
+ echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
+ else
+ echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
+ echo '<br />';
+ if ( 'publish' == $post->post_status ) {
+ _e('Published');
+ } elseif ( 'future' == $post->post_status ) {
+ if ( isset($missed) )
+ echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
+ else
+ _e('Scheduled');
+ } else {
+ _e('Last Modified');
+ }
+ echo '</td>';
+ break;
+
+ case 'title':
+ $attributes = 'class="post-title column-title"' . $style;
+ ?>
+ <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
+ <?php
+ if ( 'excerpt' == $mode )
+ the_excerpt();
+
+ $actions = array();
+ if ( current_user_can('edit_post', $post->ID) ) {
+ $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . attribute_escape(__('Edit this post')) . '">' . __('Edit') . '</a>';
+ $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . attribute_escape(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>';
+ $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this post')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
+ }
+ if ( in_array($post->post_status, array('pending', 'draft')) ) {
+ if ( current_user_can('edit_post', $post->ID) )
+ $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
+ } else {
+ $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
+ }
+ $action_count = count($actions);
+ $i = 0;
+ echo '<div class="row-actions">';
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ echo "<span class='$action'>$link$sep</span>";
+ }
+ echo '</div>';
+
+ get_inline_data($post);
+ ?>
+ </td>
+ <?php
+ break;
+
+ case 'categories':
+ ?>
+ <td <?php echo $attributes ?>><?php
+ $categories = get_the_category();
+ if ( !empty( $categories ) ) {
+ $out = array();
+ foreach ( $categories as $c )
+ $out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
+ echo join( ', ', $out );
+ } else {
+ _e('Uncategorized');
+ }
+ ?></td>
+ <?php
+ break;
+
+ case 'tags':
+ ?>
+ <td <?php echo $attributes ?>><?php
+ $tags = get_the_tags($post->ID);
+ if ( !empty( $tags ) ) {
+ $out = array();
+ foreach ( $tags as $c )
+ $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
+ echo join( ', ', $out );
+ } else {
+ _e('No Tags');
+ }
+ ?></td>
+ <?php
+ break;
+
+ case 'comments':
+ ?>
+ <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
+ <?php
+ $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
+ if ( $pending_comments )
+ echo '<strong>';
+ comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
+ if ( $pending_comments )
+ echo '</strong>';
+ ?>
+ </div></td>
+ <?php
+ break;
+
+ case 'author':
+ ?>
+ <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
+ <?php
+ break;
+
+ case 'control_view':
+ ?>
+ <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
+ <?php
+ break;
+
+ case 'control_edit':
+ ?>
+ <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
+ <?php
+ break;
+
+ case 'control_delete':
+ ?>
+ <td><?php if ( current_user_can('delete_post', $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
+ <?php
+ break;
+
+ default:
+ ?>
+ <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td>
+ <?php
+ break;
+ }
+}
+?>
+ </tr>
+<?php
+ $post = $global_post;
+}
+
+/*
+ * display one row if the page doesn't have any children
+ * otherwise, display the row and its children in subsequent rows
+ */
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ * @param unknown_type $level
+ */
+function display_page_row( $page, $level = 0 ) {
+ global $post;
+ static $rowclass;
+
+ $post = $page;
+ setup_postdata($page);
+
+ $page->post_title = wp_specialchars( $page->post_title );
+ $pad = str_repeat( '— ', $level );
+ $id = (int) $page->ID;
+ $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
+ $posts_columns = get_column_headers('edit-pages');
+ $hidden = get_hidden_columns('edit-pages');
+ $title = _draft_or_post_title();
+?>
+<tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
+<?php
+
+foreach ($posts_columns as $column_name=>$column_display_name) {
+ $class = "class=\"$column_name column-$column_name\"";
+
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
+
+ $attributes = "$class$style";
+
+ switch ($column_name) {
+
+ case 'cb':
+ ?>
+ <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /></th>
+ <?php
+ break;
+ case 'date':
+ if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) {
+ $t_time = $h_time = __('Unpublished');
+ } else {
+ $t_time = get_the_time(__('Y/m/d g:i:s A'));
+ $m_time = $page->post_date;
+ $time = get_post_time('G', true);
+
+ if ( ( abs(time() - $time) ) < 86400 ) {
+ if ( ( 'future' == $page->post_status) )
+ $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
+ else
+ $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
+ } else {
+ $h_time = mysql2date(__('Y/m/d'), $m_time);
+ }
+ }
+ echo '<td ' . $attributes . '>';
+ echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . '</abbr>';
+ echo '<br />';
+ if ( 'publish' == $page->post_status || 'future' == $page->post_status )
+ _e('Published');
+ else
+ _e('Last Modified');
+ echo '</td>';
+ break;
+ case 'title':
+ $attributes = 'class="post-title page-title column-title"' . $style;
+ $edit_link = get_edit_post_link( $page->ID );
+ ?>
+ <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $page->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); ?></strong>
+ <?php
+ $actions = array();
+ if ( current_user_can('edit_page', $page->ID) ) {
+ $actions['edit'] = '<a href="' . $edit_link . '" title="' . attribute_escape(__('Edit this page')) . '">' . __('Edit') . '</a>';
+ $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
+ $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this page')) . "' href='" . wp_nonce_url("page.php?action=delete&post=$page->ID", 'delete-page_' . $page->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
+ }
+ if ( in_array($post->post_status, array('pending', 'draft')) ) {
+ if ( current_user_can('edit_page', $page->ID) )
+ $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
+ } else {
+ $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
+ }
+ $action_count = count($actions);
+
+ $i = 0;
+ echo '<div class="row-actions">';
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ echo "<span class='$action'>$link$sep</span>";
+ }
+ echo '</div>';
+
+ get_inline_data($post);
+ echo '</td>';
+ break;
+
+ case 'comments':
+ ?>
+ <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
+ <?php
+ $left = get_pending_comments_num( $page->ID );
+ $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
+ if ( $left )
+ echo '<strong>';
+ comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
+ if ( $left )
+ echo '</strong>';
+ ?>
+ </div></td>
+ <?php
+ break;
+
+ case 'author':
+ ?>
+ <td <?php echo $attributes ?>><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
+ <?php
+ break;
+
+ default:
+ ?>
+ <td <?php echo $attributes ?>><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td>
+ <?php
+ break;
+ }
+}
+?>
+
+</tr>
+
+<?php
+}
+
+/*
+ * displays pages in hierarchical order with paging support
+ */
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $pages
+ * @param unknown_type $pagenum
+ * @param unknown_type $per_page
+ * @return unknown
+ */
+function page_rows($pages, $pagenum = 1, $per_page = 20) {
+ global $wpdb;
+
+ $level = 0;
+
+ if ( ! $pages ) {
+ $pages = get_pages( array('sort_column' => 'menu_order') );
+
+ if ( ! $pages )
+ return false;
+ }
+
+ /*
+ * arrange pages into two parts: top level pages and children_pages
+ * children_pages is two dimensional array, eg.
+ * children_pages[10][] contains all sub-pages whose parent is 10.
+ * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations
* If searching, ignore hierarchy and treat everything as top level
*/
- if ( empty($_GET['s']) ) {
-
+ if ( empty($_GET['s']) ) {
+
$top_level_pages = array();
- $children_pages = array();
-
+ $children_pages = array();
+
foreach ( $pages as $page ) {
-
+
// catch and repair bad pages
if ( $page->post_parent == $page->ID ) {
$page->post_parent = 0;
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
clean_page_cache( $page->ID );
}
-
+
if ( 0 == $page->post_parent )
$top_level_pages[] = $page;
else
$count = 0;
$start = ($pagenum - 1) * $per_page;
$end = $start + $per_page;
-
+
foreach ( $pages as $page ) {
if ( $count >= $end )
break;
if ( isset($children_pages) )
_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
}
-
+
// if it is the last pagenum and there are orphaned pages, display them with paging as well
if ( isset($children_pages) && $count < $end ){
foreach( $children_pages as $orphans ){
* Given a top level page ID, display the nested hierarchy of sub-pages
* together with paging support
*/
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $children_pages
+ * @param unknown_type $count
+ * @param unknown_type $parent
+ * @param unknown_type $level
+ * @param unknown_type $pagenum
+ * @param unknown_type $per_page
+ */
function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
-
+
if ( ! isset( $children_pages[$parent] ) )
- return;
-
+ return;
+
$start = ($pagenum - 1) * $per_page;
$end = $start + $per_page;
-
+
foreach ( $children_pages[$parent] as $page ) {
-
+
if ( $count >= $end )
break;
-
+
// If the page starts in a subtree, print the parents.
if ( $count == $start && $page->post_parent > 0 ) {
$my_parents = array();
if ( $count >= $start )
echo "\t" . display_page_row( $page, $level );
-
+
$count++;
_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
}
-
+
unset( $children_pages[$parent] ); //required in order to keep track of orphans
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $user_object
+ * @param unknown_type $style
+ * @param unknown_type $role
+ * @return unknown
+ */
function user_row( $user_object, $style = '', $role = '' ) {
global $wp_roles;
$current_user = wp_get_current_user();
-
+
if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
$user_object = new WP_User( (int) $user_object );
$email = $user_object->user_email;
if ('/' == substr( $short_url, -1 ))
$short_url = substr( $short_url, 0, -1 );
if ( strlen( $short_url ) > 35 )
- $short_url = substr( $short_url, 0, 32 ).'...';
+ $short_url = substr( $short_url, 0, 32 ).'...';
$numposts = get_usernumposts( $user_object->ID );
if ( current_user_can( 'edit_user', $user_object->ID ) ) {
if ($current_user->ID == $user_object->ID) {
- $edit = 'profile.php';
+ $edit_link = 'profile.php';
} else {
- $edit = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) );
+ $edit_link = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) );
+ }
+ $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
+ $actions = array();
+ $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
+ if ( $current_user->ID != $user_object->ID )
+ $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>";
+ $action_count = count($actions);
+ $i = 0;
+ $edit .= '<div class="row-actions">';
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ $edit .= "<span class='$action'>$link$sep</span>";
}
- $edit = "<a href=\"$edit\">$user_object->user_login</a>";
+ $edit .= '</div>';
} else {
- $edit = $user_object->user_login;
+ $edit = '<strong>' . $user_object->user_login . '</strong>';
}
- $role_name = $wp_roles->role_names[$role] ? translate_with_context($wp_roles->role_names[$role]) : __('None');
- $r = "<tr id='user-$user_object->ID'$style>
- <th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></th>
- <td><strong>$edit</strong></td>
- <td>$user_object->first_name $user_object->last_name</td>
- <td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>
- <td>$role_name</td>";
- $r .= "\n\t\t<td class='num'>";
- if ( $numposts > 0 ) {
- $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
- $r .= $numposts;
- $r .= '</a>';
- } else {
- $r .= 0;
+ $role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None');
+ $r = "<tr id='user-$user_object->ID'$style>";
+ $columns = get_column_headers('users');
+ $hidden = get_hidden_columns('users');
+ $avatar = get_avatar( $user_object->user_email, 32 );
+ foreach ( $columns as $column_name => $column_display_name ) {
+ $class = "class=\"$column_name column-$column_name\"";
+
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
+
+ $attributes = "$class$style";
+
+ switch ($column_name) {
+ case 'cb':
+ $r .= "<th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></th>";
+ break;
+ case 'username':
+ $r .= "<td $attributes>$avatar $edit</td>";
+ break;
+ case 'name':
+ $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
+ break;
+ case 'email':
+ $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>";
+ break;
+ case 'role':
+ $r .= "<td $attributes>$role_name</td>";
+ break;
+ case 'posts':
+ $attributes = 'class="posts column-posts num"' . $style;
+ $r .= "<td $attributes>";
+ if ( $numposts > 0 ) {
+ $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
+ $r .= $numposts;
+ $r .= '</a>';
+ } else {
+ $r .= 0;
+ }
+ $r .= "</td>";
+ }
}
- $r .= "</td>\n\t</tr>";
+ $r .= '</tr>';
+
return $r;
}
-function _wp_get_comment_list( $status = '', $s = false, $start, $num ) {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $status
+ * @param unknown_type $s
+ * @param unknown_type $start
+ * @param unknown_type $num
+ * @param unknown_type $post
+ * @param unknown_type $type
+ * @return unknown
+ */
+function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
global $wpdb;
$start = abs( (int) $start );
$num = (int) $num;
+ $post = (int) $post;
if ( 'moderated' == $status )
$approved = "comment_approved = '0'";
else
$approved = "( comment_approved = '0' OR comment_approved = '1' )";
+ if ( $post ) {
+ $post = " AND comment_post_ID = '$post'";
+ $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
+ } else {
+ $post = '';
+ $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
+ }
+
+ if ( 'comment' == $type )
+ $typesql = "AND comment_type = ''";
+ elseif ( 'pingback' == $type )
+ $typesql = "AND comment_type = 'pingback'";
+ elseif ( 'trackback' == $type )
+ $typesql = "AND comment_type = 'trackback'";
+ elseif ( 'pings' == $type )
+ $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
+ else
+ $typesql = '';
+
if ( $s ) {
$s = $wpdb->escape($s);
$comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
comment_author_IP LIKE ('%$s%') OR
comment_content LIKE ('%$s%') ) AND
$approved
- ORDER BY comment_date_gmt DESC LIMIT $start, $num");
+ $typesql
+ $orderby");
} else {
- $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved ORDER BY comment_date_gmt DESC LIMIT $start, $num" );
+ $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post $typesql $orderby" );
}
update_comment_cache($comments);
return array($comments, $total);
}
-function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true ) {
- global $comment, $post;
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $comment_id
+ * @param unknown_type $mode
+ * @param unknown_type $comment_status
+ * @param unknown_type $checkbox
+ */
+function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {
+ global $comment, $post, $_comment_pending_count;
$comment = get_comment( $comment_id );
$post = get_post($comment->comment_post_ID);
- $authordata = get_userdata($post->post_author);
$the_comment_status = wp_get_comment_status($comment->comment_ID);
- $class = ('unapproved' == $the_comment_status) ? 'unapproved' : '';
-
- if ( current_user_can( 'edit_post', $post->ID ) ) {
- $post_link = "<a href='" . get_comment_link() . "'>";
- $post_link .= get_the_title($comment->comment_post_ID) . '</a>';
-
- $edit_link_start = "<a class='row-title' href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>";
- $edit_link_end = '</a>';
- } else {
- $post_link = get_the_title($comment->comment_post_ID);
- $edit_link_start = $edit_link_end ='';
- }
-
$author_url = get_comment_author_url();
if ( 'http://' == $author_url )
$author_url = '';
$author_url_display = $author_url;
+ $author_url_display = str_replace('http://www.', '', $author_url_display);
+ $author_url_display = str_replace('http://', '', $author_url_display);
if ( strlen($author_url_display) > 50 )
$author_url_display = substr($author_url_display, 0, 49) . '...';
else
$ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );
- $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
- $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
- $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
- $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
+ $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
+ $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
+ $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
+ $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
-?>
- <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
-<?php if ( $checkbox ) : ?>
- <td class="check-column"><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
-<?php endif; ?>
- <td class="comment">
- <p class="comment-author"><strong><?php echo $edit_link_start; comment_author(); echo $edit_link_end; ?></strong><br />
- <?php if ( !empty($author_url) ) : ?>
- <a href="<?php echo $author_url ?>"><?php echo $author_url_display; ?></a> |
- <?php endif; ?>
- <?php if ( current_user_can( 'edit_post', $post->ID ) ) : ?>
- <?php if ( !empty($comment->comment_author_email) ): ?>
- <?php comment_author_email_link() ?> |
- <?php endif; ?>
- <a href="edit-comments.php?s=<?php comment_author_IP() ?>&mode=detail"><?php comment_author_IP() ?></a>
- <?php endif; //current_user_can?>
- </p>
- <?php if ( 'detail' == $mode ) comment_text(); ?>
- <p><?php printf(__('From %1$s, %2$s'), $post_link, $ptime) ?></p>
- </td>
- <td><?php comment_date(__('Y/m/d')); ?></td>
- <td class="action-links">
-<?php
+ echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
+ $columns = get_column_headers('edit-comments');
+ $hidden = get_hidden_columns('edit-comments');
+ foreach ( $columns as $column_name => $column_display_name ) {
+ $class = "class=\"$column_name column-$column_name\"";
- $actions = array();
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
- if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
- $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | ';
- $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a> | ';
+ $attributes = "$class$style";
- // we're looking at list of only approved or only unapproved comments
- if ( 'moderated' == $comment_status ) {
- $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | ';
- unset($actions['unapprove']);
- } elseif ( 'approved' == $comment_status ) {
- $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a> | ';
- unset($actions['approve']);
+ switch ($column_name) {
+ case 'cb':
+ if ( !$checkbox ) break;
+ echo '<th scope="row" class="check-column">';
+ if ( current_user_can('edit_post', $post->ID) ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
+ echo '</th>';
+ break;
+ case 'comment':
+ echo "<td $attributes>";
+ echo '<div id="submitted-on">';
+ printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>'), get_comment_link($comment->comment_ID), get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia')));
+ echo '</div>';
+ comment_text(); ?>
+ <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
+ <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea>
+ <div class="author-email"><?php echo attribute_escape( $comment->comment_author_email ); ?></div>
+ <div class="author"><?php echo attribute_escape( $comment->comment_author ); ?></div>
+ <div class="author-url"><?php echo attribute_escape( $comment->comment_author_url ); ?></div>
+ <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
+ </div>
+ <?php
+ $actions = array();
+
+ if ( current_user_can('edit_post', $post->ID) ) {
+ $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
+ $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
+ if ( $comment_status ) { // not looking at all comments
+ if ( 'approved' == $the_comment_status ) {
+ $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
+ unset($actions['approve']);
+ } else {
+ $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
+ unset($actions['unapprove']);
+ }
+ }
+ if ( 'spam' != $the_comment_status )
+ $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . _c( 'Spam|verb' ) . '</a>';
+ $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
+ $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
+ $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
+ if ( 'spam' != $the_comment_status )
+ $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
+
+ $actions = apply_filters( 'comment_row_actions', $actions, $comment );
+
+ $i = 0;
+ echo '<div class="row-actions">';
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
+
+ // Reply and quickedit need a hide-if-no-js span when not added with ajax
+ if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
+ $action .= ' hide-if-no-js';
+
+ echo "<span class='$action'>$sep$link</span>";
+ }
+ echo '</div>';
+ }
+
+ echo '</td>';
+ break;
+ case 'author':
+ echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
+ if ( !empty($author_url) )
+ echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
+ if ( current_user_can( 'edit_post', $post->ID ) ) {
+ if ( !empty($comment->comment_author_email) ) {
+ comment_author_email_link();
+ echo '<br />';
+ }
+ echo '<a href="edit-comments.php?s=';
+ comment_author_IP();
+ echo '&mode=detail';
+ if ( 'spam' == $comment_status )
+ echo '&comment_status=spam';
+ echo '">';
+ comment_author_IP();
+ echo '</a>';
+ } //current_user_can
+ echo '</td>';
+ break;
+ case 'date':
+ echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';
+ break;
+ case 'response':
+ if ( 'single' !== $mode ) {
+ if ( isset( $_comment_pending_count[$post->ID] ) ) {
+ $pending_comments = absint( $_comment_pending_count[$post->ID] );
+ } else {
+ $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) );
+ $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
+ }
+ if ( current_user_can( 'edit_post', $post->ID ) ) {
+ $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";
+ $post_link .= get_the_title($post->ID) . '</a>';
+ } else {
+ $post_link = get_the_title($post->ID);
+ }
+ echo "<td $attributes>\n";
+ echo $post_link;
+
+ echo '<div class="response-links"><span class="post-com-count-wrapper">';
+ $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
+ if ( $pending_comments )
+ echo '<strong>';
+ comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
+ if ( $pending_comments )
+ echo '</strong>';
+ echo '</span> ';
+ echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
+ echo '</div></td>';
+ }
}
+ }
+ echo "</tr>\n";
+}
- $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1' title='" . __( 'Mark this comment as spam' ) . "'>" . __( 'Spam' ) . '</a> | ';
- $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete'>" . __('Delete') . '</a>';
- $actions = apply_filters( 'comment_row_actions', $actions, $comment );
- foreach ( $actions as $action => $link )
- echo "<span class='$action'>$link</span>";
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $position
+ * @param unknown_type $checkbox
+ * @param unknown_type $mode
+ */
+function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
+ global $current_user;
+
+ // allow plugin to replace the popup content
+ $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
+
+ if ( ! empty($content) ) {
+ echo $content;
+ return;
}
- ?>
- </td>
- </tr>
- <?php
+
+ $columns = get_column_headers('edit-comments');
+ $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) );
+ $col_count = count($columns) - count($hidden);
+
+?>
+<form method="get" action="">
+<?php if ( $table_row ) : ?>
+<table style="display:none;"><tbody id="com-reply"><tr id="replyrow"><td colspan="<?php echo $col_count; ?>">
+<?php else : ?>
+<div id="com-reply" style="display:none;"><div id="replyrow">
+<?php endif; ?>
+ <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
+
+ <div id="edithead" style="display:none;">
+ <div class="inside">
+ <label for="author"><?php _e('Name') ?></label>
+ <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
+ </div>
+
+ <div class="inside">
+ <label for="author-email"><?php _e('E-mail') ?></label>
+ <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
+ </div>
+
+ <div class="inside">
+ <label for="author-url"><?php _e('URL') ?></label>
+ <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
+ </div>
+ <div style="clear:both;"></div>
+ </div>
+
+ <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
+
+ <p id="replysubmit" class="submit">
+ <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
+ <a href="#comments-form" class="save button-primary alignright" tabindex="104">
+ <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
+ <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
+ <img class="waiting" style="display:none;" src="images/loading.gif" alt="" />
+ <span class="error" style="display:none;"></span>
+ <br class="clear" />
+ </p>
+
+ <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
+ <input type="hidden" name="action" id="action" value="" />
+ <input type="hidden" name="comment_ID" id="comment_ID" value="" />
+ <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
+ <input type="hidden" name="status" id="status" value="" />
+ <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
+ <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
+ <input type="hidden" name="mode" id="mode" value="<?php echo $mode; ?>" />
+ <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?>
+ <?php wp_comment_form_unfiltered_html_nonce(); ?>
+<?php if ( $table_row ) : ?>
+</td></tr></tbody></table>
+<?php else : ?>
+</div></div>
+<?php endif; ?>
+</form>
+<?php
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $currentcat
+ * @param unknown_type $currentparent
+ * @param unknown_type $parent
+ * @param unknown_type $level
+ * @param unknown_type $categories
+ * @return unknown
+ */
function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
if (!$categories )
$categories = get_categories( array('hide_empty' => 0) );
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $meta
+ */
function list_meta( $meta ) {
// Exit if no meta
- if (!$meta ) {
- echo '<tbody id="the-list" class="list:meta"><tr style="display: none;"><td> </td></tr></tbody>'; //TBODY needed for list-manipulation JS
+ if ( ! $meta ) {
+ echo '
+<table id="list-table" style="display: none;">
+ <thead>
+ <tr>
+ <th class="left">' . __( 'Name' ) . '</th>
+ <th>' . __( 'Value' ) . '</th>
+ </tr>
+ </thead>
+ <tbody id="the-list" class="list:meta">
+ <tr><td></td></tr>
+ </tbody>
+</table>'; //TBODY needed for list-manipulation JS
return;
}
$count = 0;
?>
+<table id="list-table">
<thead>
<tr>
- <th><?php _e( 'Key' ) ?></th>
+ <th class="left"><?php _e( 'Name' ) ?></th>
<th><?php _e( 'Value' ) ?></th>
- <th colspan='2'><?php _e( 'Action' ) ?></th>
</tr>
</thead>
<tbody id='the-list' class='list:meta'>
<?php
foreach ( $meta as $entry )
echo _list_meta_row( $entry, $count );
- echo "\n\t</tbody>";
+?>
+ </tbody>
+</table>
+<?php
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $entry
+ * @param unknown_type $count
+ * @return unknown
+ */
function _list_meta_row( $entry, &$count ) {
static $update_nonce = false;
if ( !$update_nonce )
}
}
- $entry['meta_key'] = attribute_escape($entry['meta_key']);
+ $entry['meta_key'] = attribute_escape($entry['meta_key']);
$entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />
$entry['meta_id'] = (int) $entry['meta_id'];
$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
$r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
- $r .= "\n\t\t<td valign='top'><label class='hidden' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>";
- $r .= "\n\t\t<td><label class='hidden' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>";
- $r .= "\n\t\t<td style='text-align: center;'><input name='updatemeta' type='submit' tabindex='6' value='".attribute_escape(__( 'Update' ))."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$update_nonce updatemeta' /><br />";
- $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
+ $r .= "\n\t\t<td class='left'><label class='hidden' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />";
+
+ $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
$r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' />";
+ $r .= "\n\t\t<input name='updatemeta' type='submit' tabindex='6' value='".attribute_escape(__( 'Update' ))."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$update_nonce updatemeta' /></div>";
$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
- $r .= "</td>\n\t</tr>";
+ $r .= "</td>";
+
+ $r .= "\n\t\t<td><label class='hidden' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
return $r;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
function meta_form() {
global $wpdb;
$limit = (int) apply_filters( 'postmeta_form_limit', 30 );
if ( $keys )
natcasesort($keys);
?>
-<p><strong><?php _e( 'Add a new custom field:' ) ?></strong></p>
-<table id="newmeta" cellspacing="3" cellpadding="3">
- <tr>
-<th colspan="2"><label <?php if ( $keys ) : ?> for="metakeyselect" <?php else : ?> for="metakeyinput" <?php endif; ?>><?php _e( 'Key' ) ?></label></th>
+<p><strong><?php _e( 'Add new custom field:' ) ?></strong></p>
+<table id="newmeta">
+<thead>
+<tr>
+<th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
<th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
</tr>
- <tr valign="top">
- <td style="width: 18%;" class="textright">
-<?php if ( $keys ) : ?>
+</thead>
+
+<tbody>
+<tr>
+<td id="newmetaleft" class="left">
+<?php if ( $keys ) { ?>
<select id="metakeyselect" name="metakeyselect" tabindex="7">
<option value="#NONE#"><?php _e( '- Select -' ); ?></option>
<?php
foreach ( $keys as $key ) {
$key = attribute_escape( $key );
- echo "\n\t<option value='$key'>$key</option>";
+ echo "\n<option value='$key'>$key</option>";
}
?>
-</select> <label for="metakeyinput"><?php _e( 'or' ); ?></label>
-<?php endif; ?>
+</select>
+<input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
+<a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
+<span id="enternew"><?php _e('Enter new'); ?></span>
+<span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
+<?php } else { ?>
+<input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
+<?php } ?>
</td>
-<td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td>
- <td><textarea id="metavalue" name="metavalue" rows="3" cols="25" tabindex="8"></textarea></td>
- </tr>
-<tr class="submit"><td colspan="3">
- <?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
- <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php _e( 'Add Custom Field' ) ?>" />
+<td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
+</tr>
+
+<tr><td colspan="2" class="submit">
+<input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php _e( 'Add Custom Field' ) ?>" />
+<?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
</td></tr>
+</tbody>
</table>
<?php
}
-function touch_time( $edit = 1, $for_post = 1, $tab_index = 0 ) {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $edit
+ * @param unknown_type $for_post
+ * @param unknown_type $tab_index
+ * @param unknown_type $multi
+ */
+function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
global $wp_locale, $post, $comment;
if ( $for_post )
- $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
+ $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ) ? false : true;
$tab_index_attribute = '';
if ( (int) $tab_index > 0 )
$mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
$ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
- $month = "<select id=\"mm\" name=\"mm\"$tab_index_attribute>\n";
+ $cur_jj = gmdate( 'd', $time_adj );
+ $cur_mm = gmdate( 'm', $time_adj );
+ $cur_aa = gmdate( 'Y', $time_adj );
+ $cur_hh = gmdate( 'H', $time_adj );
+ $cur_mn = gmdate( 'i', $time_adj );
+
+ $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
for ( $i = 1; $i < 13; $i = $i +1 ) {
$month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
if ( $i == $mm )
$month .= ' selected="selected"';
- $month .= '>' . $wp_locale->get_month( $i ) . "</option>\n";
+ $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
}
$month .= '</select>';
- $day = '<input type="text" id="jj" name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
- $year = '<input type="text" id="aa" name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off" />';
- $hour = '<input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
- $minute = '<input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
- printf(_c('%1$s%2$s, %3$s <br />@ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute);
+ $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+ $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off" />';
+ $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+ $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+ printf(_c('%1$s%2$s, %3$s @ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute);
+
+ echo '<input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
+
+ if ( $multi ) return;
+
echo "\n\n";
- foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit )
+ foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
+ $cur_timeunit = 'cur_' . $timeunit;
+ echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
+ }
?>
<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
+
+<p>
+<a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
+<a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
+</p>
<?php
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $default
+ */
function page_template_dropdown( $default = '' ) {
$templates = get_page_templates();
ksort( $templates );
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) );
else
$current = '';
- echo "\n\t<option value='$item->ID'$current>$pad " . wp_specialchars($item->post_title) . "</option>";
+ echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . wp_specialchars($item->post_title) . "</option>";
parent_dropdown( $default, $item->ID, $level +1 );
}
} else {
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
function browse_happy() {
$getit = __( 'WordPress recommends a better browser' );
echo '
- <span id="bh" class="alignright"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></span>
- ';
+ <div id="bh"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></div>
+';
}
-if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
- add_action( 'in_admin_footer', 'browse_happy' );
-
+/**
+ * {@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 );
<?php else : ?>
<tr>
<th scope="row"><?php _e( 'Link to file' ) ?></th>
- <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td>
</tr>
<tr>
<th scope="row"><?php _e( 'Link to page' ) ?></th>
<?php
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $default
+ */
function wp_dropdown_roles( $default = false ) {
global $wp_roles;
+ $p = '';
$r = '';
foreach( $wp_roles->role_names as $role => $name ) {
$name = translate_with_context($name);
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;
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 );
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' ) );
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 );
<?php
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
function wp_remember_old_slug() {
global $post;
$name = attribute_escape($post->post_name); // just in case
}
/**
- * add_meta_box() - Add a meta box to an edit form
+ * Add a meta box to an edit form.
*
- * @since 2.5
+ * @since 2.5.0
*
* @param string $id String for use in the 'id' attribute of tags.
- * @param string $title Title of the meta box
- * @param string $callback Function that fills the box with the desired content. The function should echo its output.
- * @param string $page The type of edit page on which to show the box (post, page, link)
- * @param string $context The context within the page where the boxes should show ('normal', 'advanced')
- * @param string $priority The priority within the context where the boxes should show ('high', 'low')
+ * @param string $title Title of the meta box.
+ * @param string $callback Function that fills the box with the desired content. The function should echo its output.
+ * @param string $page The type of edit page on which to show the box (post, page, link).
+ * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
+ * @param string $priority The priority within the context where the boxes should show ('high', 'low').
*/
function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default') {
global $wp_meta_boxes;
-
- if ( !isset($wp_meta_boxes) )
+ if ( !isset($wp_meta_boxes) )
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
$wp_meta_boxes[$page] = array();
if ( !isset($wp_meta_boxes[$page][$context]) )
$wp_meta_boxes[$page][$context] = array();
+ foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
- if ( !isset($wp_meta_boxes[$page][$context][$a_priority][$id]) )
+ if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
continue;
+
// If a core box was previously added or removed by a plugin, don't add.
if ( 'core' == $priority ) {
// If core box previously deleted, don't add
- if ( false === $wp_meta_boxes[$page][$context][$a_priority][$id] )
+ if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
return;
// If box was added with default priority, give it core priority to maintain sort order
if ( 'default' == $a_priority ) {
- $wp_meta_boxes[$page][$context]['core'][$id] = $wp_meta_boxes[$page][$context]['default'][$id];
- unset($wp_meta_boxes[$page][$context]['default'][$id]);
+ $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
+ unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
}
return;
}
// If no priority given and id already present, use existing priority
- if ( empty($priority) )
+ if ( empty($priority) ) {
$priority = $a_priority;
- // An id can be in only one priority
- if ( $priority != $a_priority )
- unset($wp_meta_boxes[$page][$context][$a_priority][$id]);
+ // else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority.
+ } elseif ( 'sorted' == $priority ) {
+ $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
+ $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
+ }
+ // An id can be in only one priority and one context
+ if ( $priority != $a_priority || $context != $a_context )
+ unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
+ }
}
if ( empty($priority) )
- $priority = low;
+ $priority = 'low';
if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
$wp_meta_boxes[$page][$context][$priority] = array();
$wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ * @param unknown_type $context
+ * @param unknown_type $object
+ * @return int number of meta_boxes
+ */
function do_meta_boxes($page, $context, $object) {
global $wp_meta_boxes;
+ static $already_sorted = false;
- do_action('do_meta_boxes', $page, $context, $object);
+ //do_action('do_meta_boxes', $page, $context, $object);
- if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
- return;
+ $hidden = get_hidden_meta_boxes($page);
- foreach ( array('high', 'core', 'default', 'low') as $priority ) {
- foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
- if ( false === $box )
- continue;
- echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '">' . "\n";
- echo "<h3>{$box['title']}</h3>\n";
- echo '<div class="inside">' . "\n";
- call_user_func($box['callback'], $object, $box);
- echo "</div>\n";
- echo "</div>\n";
+ echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
+
+ $i = 0;
+ do {
+ // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
+ if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) {
+ foreach ( $sorted as $box_context => $ids )
+ foreach ( explode(',', $ids) as $id )
+ if ( $id )
+ add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
}
- }
+ $already_sorted = true;
+
+ if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
+ break;
+
+ foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
+ if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
+ foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
+ if ( false == $box || ! $box['title'] )
+ continue;
+ $i++;
+ $style = '';
+ if ( in_array($box['id'], $hidden) )
+ $style = 'style="display:none;"';
+ echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
+ echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>';
+ echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
+ echo '<div class="inside">' . "\n";
+ call_user_func($box['callback'], $object, $box);
+ echo "</div>\n";
+ echo "</div>\n";
+ }
+ }
+ }
+ } while(0);
+
+ echo "</div>";
+
+ return $i;
+
}
/**
- * remove_meta_box() - Remove a meta box from an edit form
+ * Remove a meta box from an edit form.
*
- * @since 2.6
+ * @since 2.6.0
*
* @param string $id String for use in the 'id' attribute of tags.
- * @param string $page The type of edit page on which to show the box (post, page, link)
- * @param string $context The context within the page where the boxes should show ('normal', 'advanced')
+ * @param string $page The type of edit page on which to show the box (post, page, link).
+ * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
*/
function remove_meta_box($id, $page, $context) {
global $wp_meta_boxes;
- if ( !isset($wp_meta_boxes) )
+ if ( !isset($wp_meta_boxes) )
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
$wp_meta_boxes[$page] = array();
$wp_meta_boxes[$page][$context][$priority][$id] = false;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ */
+function meta_box_prefs($page) {
+ global $wp_meta_boxes;
+
+ if ( empty($wp_meta_boxes[$page]) )
+ return;
+
+ $hidden = get_hidden_meta_boxes($page);
+
+ foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
+ foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
+ foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
+ if ( false == $box || ! $box['title'] )
+ continue;
+ // Submit box cannot be hidden
+ if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
+ continue;
+ $box_id = $box['id'];
+ echo '<label for="' . $box_id . '-hide">';
+ echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />';
+ echo "{$box['title']}</label>\n";
+ }
+ }
+ }
+}
+
+function get_hidden_meta_boxes($page) {
+ $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
+
+ // Hide slug boxes by default
+ if ( empty($hidden[0]) ) {
+ if ( 'page' == $page )
+ $hidden = array('pageslugdiv');
+ elseif ( 'post' == $page )
+ $hidden = array('slugdiv');
+ }
+
+ return $hidden;
+}
+
+/**
+ * Add a new section to a settings page.
+ *
+ * @since 2.7.0
+ *
+ * @param string $id String for use in the 'id' attribute of tags.
+ * @param string $title Title of the section.
+ * @param string $callback Function that fills the section with the desired content. The function should echo its output.
+ * @param string $page The type of settings page on which to show the section (general, reading, writing, ...).
+ */
+function add_settings_section($id, $title, $callback, $page) {
+ global $wp_settings_sections;
+
+ if ( !isset($wp_settings_sections) )
+ $wp_settings_sections = array();
+ if ( !isset($wp_settings_sections[$page]) )
+ $wp_settings_sections[$page] = array();
+ if ( !isset($wp_settings_sections[$page][$id]) )
+ $wp_settings_sections[$page][$id] = array();
+
+ $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
+}
+
+/**
+ * Add a new field to a settings page.
+ *
+ * @since 2.7.0
+ *
+ * @param string $id String for use in the 'id' attribute of tags.
+ * @param string $title Title of the field.
+ * @param string $callback Function that fills the field with the desired content. The function should echo its output.
+ * @param string $page The type of settings page on which to show the field (general, reading, writing, ...).
+ * @param string $section The section of the settingss page in which to show the box (default, ...).
+ * @param array $args Additional arguments
+ */
+function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
+ global $wp_settings_fields;
+
+ if ( !isset($wp_settings_fields) )
+ $wp_settings_fields = array();
+ if ( !isset($wp_settings_fields[$page]) )
+ $wp_settings_fields[$page] = array();
+ if ( !isset($wp_settings_fields[$page][$section]) )
+ $wp_settings_fields[$page][$section] = array();
+
+ $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ */
+function do_settings_sections($page) {
+ global $wp_settings_sections, $wp_settings_fields;
+
+ if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
+ return;
+
+ foreach ( (array) $wp_settings_sections[$page] as $section ) {
+ echo "<h3>{$section['title']}</h3>\n";
+ call_user_func($section['callback'], $section);
+ if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
+ continue;
+ echo '<table class="form-table">';
+ do_settings_fields($page, $section['id']);
+ echo '</table>';
+ }
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ * @param unknown_type $section
+ */
+function do_settings_fields($page, $section) {
+ global $wp_settings_fields;
+
+ if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
+ return;
+
+ foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
+ echo '<tr valign="top">';
+ if ( !empty($field['args']['label_for']) )
+ echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
+ else
+ echo '<th scope="row">' . $field['title'] . '</th>';
+ echo '<td>';
+ call_user_func($field['callback']);
+ echo '</td>';
+ echo '</tr>';
+ }
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $page
+ */
+function manage_columns_prefs($page) {
+ $columns = get_column_headers($page);
+
+ $hidden = get_hidden_columns($page);
+
+ foreach ( $columns as $column => $title ) {
+ // Can't hide these
+ if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column )
+ continue;
+ if ( empty($title) )
+ continue;
+
+ if ( 'comments' == $column )
+ $title = __('Comments');
+ $id = "$column-hide";
+ echo '<label for="' . $id . '">';
+ echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
+ echo "$title</label>\n";
+ }
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $found_action
+ */
+function find_posts_div($found_action = '') {
+?>
+ <div id="find-posts" class="find-box" style="display:none;">
+ <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
+ <div class="find-box-inside">
+ <div class="find-box-search">
+ <?php if ( $found_action ) { ?>
+ <input type="hidden" name="found_action" value="<?php echo $found_action; ?>" />
+ <?php } ?>
+
+ <input type="hidden" name="affected" id="affected" value="" />
+ <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
+ <label class="hidden" for="find-posts-input"><?php _e( 'Search' ); ?></label>
+ <input type="text" id="find-posts-input" class="search-input" name="ps" value="" />
+ <input type="button" onclick="findPosts.send();" value="<?php _e( 'Search' ); ?>" class="button" /><br />
+
+ <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" />
+ <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label>
+ <input type="radio" name="find-posts-what" id="find-posts-pages" value="pages" />
+ <label for="find-posts-pages"><?php _e( 'Pages' ); ?></label>
+ </div>
+ <div id="find-posts-response"></div>
+ </div>
+ <div class="find-box-buttons">
+ <input type="button" class="button" onclick="findPosts.close();" value="<?php _e('Close'); ?>" />
+ <input id="find-posts-submit" type="submit" class="button" value="<?php _e('Select'); ?>" />
+ </div>
+ </div>
+ <script type="text/javascript">
+ /* <![CDATA[ */
+ (function($){
+ findPosts = {
+ open : function(af_name, af_val) {
+ var st = document.documentElement.scrollTop || $(document).scrollTop();
+
+ if ( af_name && af_val )
+ $('#affected').attr('name', af_name).val(af_val);
+
+ $('#find-posts').show().draggable({
+ handle: '#find-posts-head'
+ }).resizable({
+ handles: 'all',
+ minHeight: 150,
+ minWidth: 280
+ }).css({'top':st+'px','left':'50%','marginLeft':'-200px'});
+
+ $('.ui-resizable-handle').css({
+ 'backgroundColor': '#e5e5e5'
+ });
+
+ $('.ui-resizable-se').css({
+ 'border': '0 none',
+ 'width': '15px',
+ 'height': '16px',
+ 'background': 'transparent url(images/se.png) no-repeat scroll 0 0'
+ });
+
+ $('#find-posts-input').focus().keyup(function(e){
+ if (e.which == 27) findPosts.close(); // close on Escape
+ });
+
+ return false;
+ },
+
+ close : function() {
+ $('#find-posts-response').html('');
+ $('#find-posts').draggable('destroy').resizable('destroy').hide();
+ },
+
+ send : function() {
+ var post = {};
+
+ post['ps'] = $('#find-posts-input').val();
+ post['action'] = 'find_posts';
+ post['_ajax_nonce'] = $('#_ajax_nonce').val();
+
+ if ( $('#find-posts-pages:checked').val() )
+ post['pages'] = 1;
+ else
+ post['posts'] = 1;
+
+ $.ajax({
+ type : 'POST',
+ url : '<?php echo admin_url('admin-ajax.php'); ?>',
+ data : post,
+ success : function(x) { findPosts.show(x); },
+ error : function(r) { findPosts.error(r); }
+ });
+ },
+
+ show : function(x) {
+
+ if ( typeof(x) == 'string' ) {
+ this.error({'responseText': x});
+ return;
+ }
+
+ var r = wpAjax.parseAjaxResponse(x);
+
+ if ( r.errors )
+ this.error({'responseText': wpAjax.broken});
+
+ r = r.responses[0];
+ $('#find-posts-response').html(r.data);
+ },
+
+ error : function(r) {
+ var er = r.statusText;
+
+ if ( r.responseText )
+ er = r.responseText.replace( /<.[^<>]*?>/g, '' );
+
+ if ( er )
+ $('#find-posts-response').html(er);
+ }
+ };
+
+ $(document).ready(function(){
+ $('#find-posts-submit').click(function(e) {
+ if ( '' == $('#find-posts-response').html() )
+ e.preventDefault();
+ });
+ });
+ })(jQuery);
+ /* ]]> */
+ </script>
+<?php
+}
+
+/**
+ * Display the post password.
+ *
+ * The password is passed through {@link attribute_escape()} to ensure that it
+ * is safe for placing in an html attribute.
+ *
+ * @uses attribute_escape
+ * @since 2.7.0
+ */
+function the_post_password() {
+ global $post;
+ if ( isset( $post->post_password ) ) echo attribute_escape( $post->post_password );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
+function favorite_actions() {
+ $actions = array(
+ 'post-new.php' => array(__('New Post'), 'edit_posts'),
+ 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
+ 'page-new.php' => array(__('New Page'), 'edit_pages'),
+ 'media-new.php' => array(__('Upload'), 'upload_files'),
+ 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
+ );
+
+ $actions = apply_filters('favorite_actions', $actions);
+
+ $allowed_actions = array();
+ foreach ( $actions as $action => $data ) {
+ if ( current_user_can($data[1]) )
+ $allowed_actions[$action] = $data[0];
+ }
+
+ if ( empty($allowed_actions) )
+ return;
+
+ $first = array_keys($allowed_actions);
+ $first = $first[0];
+ echo '<div id="favorite-actions">';
+ echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
+ echo '<div id="favorite-inside">';
+
+ array_shift($allowed_actions);
+
+ foreach ( $allowed_actions as $action => $label) {
+ echo "<div class='favorite-action'><a href='$action'>";
+ echo $label;
+ echo "</a></div>\n";
+ }
+ echo "</div></div>\n";
+}
+
+/**
+ * Get the post title.
+ *
+ * The post title is fetched and if it is blank then a default string is
+ * returned.
+ *
+ * @since 2.7.0
+ * @param int $id The post id. If not supplied the global $post is used.
+ *
+ */
+function _draft_or_post_title($post_id = 0)
+{
+ $title = get_the_title($post_id);
+ if ( empty($title) )
+ $title = __('(no title)');
+ return $title;
+}
+
+/**
+ * Display the search query.
+ *
+ * A simple wrapper to display the "s" parameter in a GET URI. This function
+ * should only be used when {@link the_search_query()} cannot.
+ *
+ * @uses attribute_escape
+ * @since 2.7.0
+ *
+ */
+function _admin_search_query() {
+ echo isset($_GET['s']) ? attribute_escape( stripslashes( $_GET['s'] ) ) : '';
+}
+
+/**
+ * Generic Iframe header for use with Thickbox
+ *
+ * @since 2.7.0
+ * @param string $title Title of the Iframe page.
+ * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
+ *
+ */
+function iframe_header( $title = '', $limit_styles = false) {
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
+<head>
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
+<title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title>
+<?php
+wp_enqueue_style( 'global' );
+wp_enqueue_style( 'colors' );
+if ( ! $limit_styles )
+ wp_enqueue_style( 'wp-admin' );
+?>
+<script type="text/javascript">
+//<![CDATA[
+function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
+//]]>
+</script>
+<?php
+do_action('admin_print_styles');
+do_action('admin_print_scripts');
+do_action('admin_head');
+?>
+</head>
+<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
+<?php
+}
+
+/**
+ * Generic Iframe footer for use with Thickbox
+ *
+ * @since 2.7.0
+ *
+ */
+function iframe_footer() {
+ echo '
+ </body>
+</html>';
+}
+
+function _post_states($post) {
+ $post_states = array();
+ if ( isset($_GET['post_status']) )
+ $post_status = $_GET['post_status'];
+ else
+ $post_status = '';
+
+ if ( !empty($post->post_password) )
+ $post_states[] = __('Password protected');
+ if ( 'private' == $post->post_status && 'private' != $post_status )
+ $post_states[] = __('Private');
+ if ( 'draft' == $post->post_status && 'draft' != $post_status )
+ $post_states[] = __('Draft');
+ if ( 'pending' == $post->post_status && 'pending' != $post_status )
+ $post_states[] = __('Pending');
+
+ if ( ! empty($post_states) ) {
+ $state_count = count($post_states);
+ $i = 0;
+ echo ' - ';
+ foreach ( $post_states as $state ) {
+ ++$i;
+ ( $i == $state_count ) ? $sep = '' : $sep = ', ';
+ echo "<span class='post-state'>$state$sep</span>";
+ }
+ }
+}
+
+function screen_meta($screen) {
+ global $wp_meta_boxes, $_wp_contextual_help;
+
+ $screen = str_replace('.php', '', $screen);
+ $screen = str_replace('-new', '', $screen);
+ $screen = str_replace('-add', '', $screen);
+ $screen = apply_filters('screen_meta_screen', $screen);
+
+ $column_screens = get_column_headers($screen);
+ $meta_screens = array('index' => 'dashboard');
+
+ if ( isset($meta_screens[$screen]) )
+ $screen = $meta_screens[$screen];
+ $show_screen = false;
+ if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) )
+ $show_screen = true;
+?>
+<div id="screen-meta">
+<?php
+ if ( $show_screen ) :
+?>
+<div id="screen-options-wrap" class="hidden">
+ <h5><?php _e('Show on screen') ?></h5>
+ <form id="adv-settings" action="" method="get">
+ <div class="metabox-prefs">
+<?php
+ if ( !meta_box_prefs($screen) && isset($column_screens) ) {
+ manage_columns_prefs($screen);
+ wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false );
+ }
+?>
+ <br class="clear" />
+ </div></form>
+</div>
+
+<?php
+ endif;
+
+ global $title;
+
+ if ( !isset($_wp_contextual_help) )
+ $_wp_contextual_help = array();
+
+ if ( !isset($_wp_contextual_help['post']) ) {
+ $help = drag_drop_help();
+ $help .= '<p>' . __('<a href="http://codex.wordpress.org/Writing_Posts" target="_blank">Writing Posts</a>') . '</p>';
+ $_wp_contextual_help['post'] = $help;
+ }
+
+ if ( !isset($_wp_contextual_help['page']) ) {
+ $help = drag_drop_help();
+ $_wp_contextual_help['page'] = $help;
+ }
+
+ if ( !isset($_wp_contextual_help['dashboard']) ) {
+ $help = drag_drop_help();
+ $_wp_contextual_help['dashboard'] = $help;
+ }
+
+ if ( !isset($_wp_contextual_help['link']) ) {
+ $help = drag_drop_help();
+ $_wp_contextual_help['link'] = $help;
+ }
+
+ if ( !isset($_wp_contextual_help['options-general']) )
+ $_wp_contextual_help['options-general'] = __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>');
+
+ $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen);
+ ?>
+ <div id="contextual-help-wrap" class="hidden">
+ <?php
+ $contextual_help = '';
+ if ( isset($_wp_contextual_help[$screen]) ) {
+ if ( !empty($title) )
+ $contextual_help .= '<h5>' . sprintf(__('Get help with "%s"'), $title) . '</h5>';
+ else
+ $contextual_help .= '<h5>' . __('Get help with this page') . '</h5>';
+ $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen] . "</div>\n";
+
+ $contextual_help .= '<h5>' . __('Other Help') . '</h5>';
+ } else {
+ $contextual_help .= '<h5>' . __('Help') . '</h5>';
+ }
+
+ $contextual_help .= '<div class="metabox-prefs">';
+ $contextual_help .= __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>');
+ $contextual_help .= '<br />';
+ $contextual_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>');
+ $contextual_help .= "</div>\n";
+ echo apply_filters('contextual_help', $contextual_help, $screen);
+ ?>
+ </div>
+
+<div id="screen-meta-links">
+<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
+<a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help') ?></a>
+</div>
+<?php if ( $show_screen ) { ?>
+<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
+<a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options') ?></a>
+</div>
+<?php } ?>
+</div>
+</div>
+<?php
+}
+
+/**
+ * Add contextual help text for a page
+ *
+ * @since 2.7.0
+ *
+ * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
+ * @param string $help Arbitrary help text
+ */
+function add_contextual_help($screen, $help) {
+ global $_wp_contextual_help;
+
+ if ( !isset($_wp_contextual_help) )
+ $_wp_contextual_help = array();
+
+ $_wp_contextual_help[$screen] = $help;
+}
+
+function drag_drop_help() {
+ return '
+ <p>' . __('Most of the modules on this screen can be moved. If you hover your mouse over the title bar of a module you’ll notice the 4 arrow cursor appears to let you know it is movable. Click on it, hold down the mouse button and start dragging the module to a new location. As you drag the module, notice the dotted gray box that also moves. This box indicates where the module will be placed when you release the mouse button.') . '</p>
+ <p>' . __('The same modules can be expanded and collapsed by clicking once on their title bar and also completely hidden from the Screen Options tab.') . '</p>
+';
+}
+
+function screen_icon($name = '') {
+ global $parent_file, $hook_suffix;
+
+ if ( empty($name) ) {
+ if ( isset($parent_file) && !empty($parent_file) )
+ $name = substr($parent_file, 0, -4);
+ else
+ $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix);
+ }
+ unset($hook_suffix);
+?>
+ <div id="icon-<?php echo $name; ?>" class="icon32"><br /></div>
+<?php
+}
+
?>
<?php
+/**
+ * WordPress Theme Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function current_theme_info() {
$themes = get_themes();
$current_theme = get_current_theme();
return $ct;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function get_broken_themes() {
global $wp_broken_themes;
return $wp_broken_themes;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function get_page_templates() {
$themes = get_themes();
$theme = get_current_theme();
foreach ( $templates as $template ) {
$template_data = implode( '', file( WP_CONTENT_DIR.$template ));
- preg_match( '|Template Name:(.*)$|mi', $template_data, $name );
- preg_match( '|Description:(.*)$|mi', $template_data, $description );
+ $name = '';
+ if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) )
+ $name = $name[1];
- $name = $name[1];
- $description = $description[1];
+ $description = '';
+ if( preg_match( '|Description:(.*)$|mi', $template_data, $description ) )
+ $description = $description[1];
if ( !empty( $name ) ) {
$page_templates[trim( $name )] = basename( $template );
--- /dev/null
+<?php
+/**
+ * WordPress core upgrade functionality.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 2.7.0
+ */
+
+/**
+ * Stores files to be deleted.
+ *
+ * @since 2.7.0
+ * @global array $_old_files
+ * @var array
+ * @name $_old_files
+ */
+global $_old_files;
+
+$_old_files = array(
+'wp-admin/bookmarklet.php',
+'wp-admin/css/upload.css',
+'wp-admin/css/upload-rtl.css',
+'wp-admin/css/press-this-ie.css',
+'wp-admin/css/press-this-ie-rtl.css',
+'wp-admin/edit-form.php',
+'wp-admin/link-import.php',
+'wp-admin/images/box-bg-left.gif',
+'wp-admin/images/box-bg-right.gif',
+'wp-admin/images/box-bg.gif',
+'wp-admin/images/box-butt-left.gif',
+'wp-admin/images/box-butt-right.gif',
+'wp-admin/images/box-butt.gif',
+'wp-admin/images/box-head-left.gif',
+'wp-admin/images/box-head-right.gif',
+'wp-admin/images/box-head.gif',
+'wp-admin/images/heading-bg.gif',
+'wp-admin/images/login-bkg-bottom.gif',
+'wp-admin/images/login-bkg-tile.gif',
+'wp-admin/images/notice.gif',
+'wp-admin/images/toggle.gif',
+'wp-admin/images/comment-stalk-classic.gif',
+'wp-admin/images/comment-stalk-fresh.gif',
+'wp-admin/images/comment-stalk-rtl.gif',
+'wp-admin/images/comment-pill.gif',
+'wp-admin/images/del.png',
+'wp-admin/images/media-button-gallery.gif',
+'wp-admin/images/media-buttons.gif',
+'wp-admin/images/tail.gif',
+'wp-admin/images/gear.png',
+'wp-admin/images/tab.png',
+'wp-admin/images/postbox-bg.gif',
+'wp-admin/includes/upload.php',
+'wp-admin/js/dbx-admin-key.js',
+'wp-admin/js/link-cat.js',
+'wp-admin/js/forms.js',
+'wp-admin/js/upload.js',
+'wp-admin/profile-update.php',
+'wp-admin/templates.php',
+'wp-includes/images/audio.png',
+'wp-includes/images/css.png',
+'wp-includes/images/default.png',
+'wp-includes/images/doc.png',
+'wp-includes/images/exe.png',
+'wp-includes/images/html.png',
+'wp-includes/images/js.png',
+'wp-includes/images/pdf.png',
+'wp-includes/images/swf.png',
+'wp-includes/images/tar.png',
+'wp-includes/images/text.png',
+'wp-includes/images/video.png',
+'wp-includes/images/zip.png',
+'wp-includes/js/dbx.js',
+'wp-includes/js/fat.js',
+'wp-includes/js/list-manipulation.js',
+'wp-includes/js/jquery/jquery.dimensions.min.js',
+'wp-includes/js/tinymce/langs/en.js',
+'wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js',
+'wp-includes/js/tinymce/plugins/autosave/langs',
+'wp-includes/js/tinymce/plugins/directionality/images',
+'wp-includes/js/tinymce/plugins/directionality/langs',
+'wp-includes/js/tinymce/plugins/inlinepopups/css',
+'wp-includes/js/tinymce/plugins/inlinepopups/images',
+'wp-includes/js/tinymce/plugins/inlinepopups/jscripts',
+'wp-includes/js/tinymce/plugins/paste/images',
+'wp-includes/js/tinymce/plugins/paste/jscripts',
+'wp-includes/js/tinymce/plugins/paste/langs',
+'wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php',
+'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php',
+'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php',
+'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php',
+'wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css',
+'wp-includes/js/tinymce/plugins/spellchecker/images',
+'wp-includes/js/tinymce/plugins/spellchecker/langs',
+'wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php',
+'wp-includes/js/tinymce/plugins/wordpress/images',
+'wp-includes/js/tinymce/plugins/wordpress/langs',
+'wp-includes/js/tinymce/plugins/wordpress/popups.css',
+'wp-includes/js/tinymce/plugins/wordpress/wordpress.css',
+'wp-includes/js/tinymce/plugins/wphelp',
+'wp-includes/js/tinymce/themes/advanced/css',
+'wp-includes/js/tinymce/themes/advanced/images',
+'wp-includes/js/tinymce/themes/advanced/jscripts',
+'wp-includes/js/tinymce/themes/advanced/langs',
+'wp-includes/js/tinymce/tiny_mce_gzip.php',
+'wp-includes/js/wp-ajax.js',
+'wp-admin/admin-db.php',
+'wp-admin/cat.js',
+'wp-admin/categories.js',
+'wp-admin/custom-fields.js',
+'wp-admin/dbx-admin-key.js',
+'wp-admin/edit-comments.js',
+'wp-admin/install-rtl.css',
+'wp-admin/install.css',
+'wp-admin/upgrade-schema.php',
+'wp-admin/upload-functions.php',
+'wp-admin/upload-rtl.css',
+'wp-admin/upload.css',
+'wp-admin/upload.js',
+'wp-admin/users.js',
+'wp-admin/widgets-rtl.css',
+'wp-admin/widgets.css',
+'wp-admin/xfn.js',
+'wp-includes/js/tinymce/license.html',
+'wp-admin/cat-js.php',
+'wp-admin/edit-form-ajax-cat.php',
+'wp-admin/execute-pings.php',
+'wp-admin/import/b2.php',
+'wp-admin/inline-uploading.php',
+'wp-admin/link-categories.php',
+'wp-admin/list-manipulation.js',
+'wp-admin/list-manipulation.php',
+'wp-includes/comment-functions.php',
+'wp-includes/feed-functions.php',
+'wp-includes/functions-compat.php',
+'wp-includes/functions-formatting.php',
+'wp-includes/functions-post.php',
+'wp-includes/js/dbx-key.js',
+'wp-includes/js/tinymce/plugins/autosave/langs/cs.js',
+'wp-includes/js/tinymce/plugins/autosave/langs/sv.js',
+'wp-includes/js/tinymce/themes/advanced/editor_template_src.js',
+'wp-includes/links.php',
+'wp-includes/pluggable-functions.php',
+'wp-includes/template-functions-author.php',
+'wp-includes/template-functions-category.php',
+'wp-includes/template-functions-general.php',
+'wp-includes/template-functions-links.php',
+'wp-includes/template-functions-post.php',
+'wp-includes/wp-l10n.php',
+'wp-admin/import-b2.php',
+'wp-admin/import-blogger.php',
+'wp-admin/import-greymatter.php',
+'wp-admin/import-livejournal.php',
+'wp-admin/import-mt.php',
+'wp-admin/import-rss.php',
+'wp-admin/import-textpattern.php',
+'wp-admin/quicktags.js',
+'wp-images/fade-butt.png',
+'wp-images/get-firefox.png',
+'wp-images/header-shadow.png',
+'wp-images/smilies',
+'wp-images/wp-small.png',
+'wp-images/wpminilogo.png',
+'wp.php',
+'wp-content/themes/default/attachment.php',
+'wp-content/themes/default/images/kubrickbg.jpg',
+'wp-content/plugins/markdown.php',
+'wp-content/plugins/textile1.php',
+);
+
+/**
+ * Upgrade the core of WordPress.
+ *
+ * This will create a .maintenance file at the base of the WordPress directory
+ * to ensure that people can not access the web site, when the files are being
+ * copied to their locations.
+ *
+ * The files in the {@link $_old_files} list will be removed and the new files
+ * copied from the zip file after the database is upgraded.
+ *
+ * The steps for the upgrader for after the new release is downloaded and
+ * unzipped is:
+ * 1. Test unzipped location for select files to ensure that unzipped worked.
+ * 2. Create the .maintenance file in current WordPress base.
+ * 3. Copy new WordPress directory over old WordPress files.
+ * 4. Upgrade WordPress to new version.
+ * 5. Delete new WordPress directory path.
+ * 6. Delete .maintenance file.
+ * 7. Remove old files.
+ * 8. Delete 'update_core' option.
+ *
+ * There are several areas of failure. For instance if PHP times out before step
+ * 6, then you will not be able to access any portion of your site. Also, since
+ * the upgrade will not continue where it left off, you will not be able to
+ * automatically remove old files and remove the 'update_core' option. This
+ * isn't that bad.
+ *
+ * If the copy of the new WordPress over the old fails, then the worse is that
+ * the new WordPress directory will remain.
+ *
+ * If it is assumed that every file will be copied over, including plugins and
+ * themes, then if you edit the default theme, you should rename it, so that
+ * your changes remain.
+ *
+ * @since 2.7.0
+ *
+ * @param string $from New release unzipped path.
+ * @param string $to Path to old WordPress installation.
+ * @return WP_Error|null WP_Error on failure, null on success.
+ */
+function update_core($from, $to) {
+ global $wp_filesystem, $_old_files;
+
+ @set_time_limit( 300 );
+
+ // Sanity check the unzipped distribution
+ apply_filters('update_feedback', __('Verifying the unpacked files'));
+ if ( !$wp_filesystem->exists($from . '/wordpress/wp-settings.php') || !$wp_filesystem->exists($from . '/wordpress/wp-admin/admin.php') ||
+ !$wp_filesystem->exists($from . '/wordpress/wp-includes/functions.php') ) {
+ $wp_filesystem->delete($from, true);
+ return new WP_Error('insane_distro', __('The update could not be unpacked') );
+ }
+
+ apply_filters('update_feedback', __('Installing the latest version'));
+
+ // Create maintenance file to signal that we are upgrading
+ $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
+ $maintenance_file = $to . '.maintenance';
+ $wp_filesystem->delete($maintenance_file);
+ $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE);
+
+ // Copy new versions of WP files into place.
+ $result = copy_dir($from . '/wordpress', $to);
+ if ( is_wp_error($result) ) {
+ $wp_filesystem->delete($maintenance_file);
+ //$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails.
+ return $result;
+ }
+
+ // Remove old files
+ foreach ( $_old_files as $old_file ) {
+ $old_file = $to . $old_file;
+ if ( !$wp_filesystem->exists($old_file) )
+ continue;
+ $wp_filesystem->delete($old_file, true);
+ }
+
+ // Upgrade DB with separate request
+ apply_filters('update_feedback', __('Upgrading database'));
+ $db_upgrade_url = admin_url('upgrade.php?step=upgrade_db');
+ wp_remote_post($db_upgrade_url, array('timeout' => 60));
+
+ // Remove working directory
+ $wp_filesystem->delete($from, true);
+
+ // Force refresh of update information
+ delete_option('update_core');
+
+ // Remove maintenance file, we're done.
+ $wp_filesystem->delete($maintenance_file);
+}
+
+?>
<?php
+/**
+ * WordPress Administration Update API
+ *
+ * @package WordPress
+ * @subpackage Admin
+ */
// The admin side of our 1.1 update system
+/**
+ * Selects the first update version from the update_core option
+ *
+ * @return object the response from the API
+ */
+function get_preferred_from_update_core() {
+ $updates = get_core_updates();
+ if ( !is_array( $updates ) )
+ return false;
+ if ( empty( $updates ) )
+ return (object)array('response' => 'latest');
+ return $updates[0];
+}
+
+/**
+ * Get available core updates
+ *
+ * @param array $options Set $options['dismissed'] to true to show dismissed upgrades too,
+ * set $options['available'] to false to skip not-dimissed updates.
+ * @return array Array of the update objects
+ */
+function get_core_updates( $options = array() ) {
+ $options = array_merge( array('available' => true, 'dismissed' => false ), $options );
+ $dismissed = get_option( 'dismissed_update_core' );
+ if ( !is_array( $dismissed ) ) $dismissed = array();
+ $from_api = get_option( 'update_core' );
+ if ( empty($from_api) )
+ return false;
+ if ( !is_array( $from_api->updates ) ) return false;
+ $updates = $from_api->updates;
+ if ( !is_array( $updates ) ) return false;
+ $result = array();
+ foreach($updates as $update) {
+ if ( array_key_exists( $update->current.'|'.$update->locale, $dismissed ) ) {
+ if ( $options['dismissed'] ) {
+ $update->dismissed = true;
+ $result[]= $update;
+ }
+ } else {
+ if ( $options['available'] ) {
+ $update->dismissed = false;
+ $result[]= $update;
+ }
+ }
+ }
+ return $result;
+}
+
+function dismiss_core_update( $update ) {
+ $dismissed = get_option( 'dismissed_update_core' );
+ $dismissed[ $update->current.'|'.$update->locale ] = true;
+ return update_option( 'dismissed_update_core', $dismissed );
+}
+
+function undismiss_core_update( $version, $locale ) {
+ $dismissed = get_option( 'dismissed_update_core' );
+ $key = $version.'|'.$locale;
+ if ( !isset( $dismissed[$key] ) ) return false;
+ unset( $dismissed[$key] );
+ return update_option( 'dismissed_update_core', $dismissed );
+}
+
+function find_core_update( $version, $locale ) {
+ $from_api = get_option( 'update_core' );
+ if ( !is_array( $from_api->updates ) ) return false;
+ $updates = $from_api->updates;
+ foreach($updates as $update) {
+ if ( $update->current == $version && $update->locale == $locale )
+ return $update;
+ }
+ return false;
+}
+
function core_update_footer( $msg = '' ) {
if ( !current_user_can('manage_options') )
return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'] );
- $cur = get_option( 'update_core' );
+ $cur = get_preferred_from_update_core();
+ if ( ! isset( $cur->current ) )
+ $cur->current = '';
+
+ if ( ! isset( $cur->url ) )
+ $cur->url = '';
+
+ if ( ! isset( $cur->response ) )
+ $cur->response = '';
switch ( $cur->response ) {
case 'development' :
- return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please <a href="%s">stay updated</a>.' ), $GLOBALS['wp_version'], $cur->url, $cur->current );
+ return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), $GLOBALS['wp_version'], 'update-core.php');
break;
case 'upgrade' :
if ( current_user_can('manage_options') ) {
- return sprintf( '| <strong>'.__( '<a href="%2$s">Get Version %3$s</a>' ).'</strong>', $GLOBALS['wp_version'], $cur->url, $cur->current );
+ return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', 'update-core.php', $cur->current);
break;
}
case 'latest' :
default :
- return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'], $cur->url, $cur->current );
+ return sprintf( __( 'Version %s' ), $GLOBALS['wp_version'] );
break;
}
}
add_filter( 'update_footer', 'core_update_footer' );
function update_nag() {
- $cur = get_option( 'update_core' );
+ global $pagenow;
+
+ if ( 'update-core.php' == $pagenow )
+ return;
+
+ $cur = get_preferred_from_update_core();
if ( ! isset( $cur->response ) || $cur->response != 'upgrade' )
return false;
if ( current_user_can('manage_options') )
- $msg = sprintf( __('WordPress %2$s is available! <a href="%1$s">Please update now</a>.'), $cur->url, $cur->current );
+ $msg = sprintf( __('WordPress %1$s is available! <a href="%2$s">Please update now</a>.'), $cur->current, 'update-core.php' );
else
- $msg = sprintf( __('WordPress %2$s is available! Please notify the site administrator.'), $cur->url, $cur->current );
+ $msg = sprintf( __('WordPress %1$s is available! Please notify the site administrator.'), $cur->current );
echo "<div id='update-nag'>$msg</div>";
}
// Called directly from dashboard
function update_right_now_message() {
- $cur = get_option( 'update_core' );
+ $cur = get_preferred_from_update_core();
- $msg = sprintf( __('This is WordPress version %s.'), $GLOBALS['wp_version'] );
+ $msg = sprintf( __('You are using <span class="b">WordPress %s</span>.'), $GLOBALS['wp_version'] );
if ( isset( $cur->response ) && $cur->response == 'upgrade' && current_user_can('manage_options') )
- $msg .= " <a href='$cur->url' class='rbutton'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>';
+ $msg .= " <a href='update-core.php' class='button'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>';
echo "<span id='wp-version-message'>$msg</span>";
}
$r = $current->response[ $file ];
+ $details_url = admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&TB_iframe=true&width=600&height=800');
+
echo '<tr><td colspan="5" class="plugin-update">';
if ( ! current_user_can('update_plugins') )
- printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a>.'), $plugin_data['Name'], $r->url, $r->new_version);
+ printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a>.'), $plugin_data['Name'], $details_url, $r->new_version);
else if ( empty($r->package) )
- printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> <em>automatic upgrade unavailable for this plugin</em>.'), $plugin_data['Name'], $r->url, $r->new_version);
+ printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> <em>automatic upgrade unavailable for this plugin</em>.'), $plugin_data['Name'], $details_url, $r->new_version);
else
- printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> or <a href="%4$s">upgrade automatically</a>.'), $plugin_data['Name'], $r->url, $r->new_version, wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $file, 'upgrade-plugin_' . $file) );
-
+ printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> or <a href="%4$s">upgrade automatically</a>.'), $plugin_data['Name'], $details_url, $r->new_version, wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $file, 'upgrade-plugin_' . $file) );
+
echo '</td></tr>';
}
add_action( 'after_plugin_row', 'wp_plugin_update_row', 10, 2 );
$content_dir = $wp_filesystem->wp_content_dir();
if( empty($content_dir) )
return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).'));
-
+
$plugins_dir = trailingslashit( $plugins_dir );
$content_dir = trailingslashit( $content_dir );
apply_filters('update_feedback', __('Unpacking the update'));
// Unzip package to working directory
$result = unzip_file($download_file, $working_dir);
-
+
// Once extracted, delete the package
unlink($download_file);
-
+
if ( is_wp_error($result) ) {
$wp_filesystem->delete($working_dir, true);
return $result;
// Remove the existing plugin.
apply_filters('update_feedback', __('Removing the old version of the plugin'));
$this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin) );
-
+
// If plugin is in its own directory, recursively delete the directory.
if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory seperator AND that its not the root plugin folder
$deleted = $wp_filesystem->delete($this_plugin_dir, true);
// Copy new version of plugin into place.
$result = copy_dir($working_dir, $plugins_dir);
if ( is_wp_error($result) ) {
- //$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails.
+ $wp_filesystem->delete($working_dir, true);
return $result;
}
// Force refresh of plugin update information
delete_option('update_plugins');
-
+
if( empty($filelist) )
return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.
-
+
$folder = $filelist[0];
$plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
$pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
return $folder . '/' . $pluginfiles[0];
}
+function wp_update_theme($theme, $feedback = '') {
+ global $wp_filesystem;
+
+ if ( !empty($feedback) )
+ add_filter('update_feedback', $feedback);
+
+ // Is an update available?
+ $current = get_option( 'update_themes' );
+ if ( !isset( $current->response[ $theme ] ) )
+ return new WP_Error('up_to_date', __('The theme is at the latest version.'));
+
+ $r = $current->response[ $theme ];
+
+ $themes = get_themes();
+ foreach ( (array) $themes as $this_theme ) {
+ if ( $this_theme['Stylesheet'] == $theme ) {
+ $theme_directory = preg_replace('!^/themes/!i', '', $this_theme['Stylesheet Dir']);
+ break;
+ }
+ }
+ unset($themes);
+
+ if ( empty($theme_directory) )
+ return new WP_Error('theme_non_existant', __('Theme does not exist.'));
+
+ // Is a filesystem accessor setup?
+ if ( ! $wp_filesystem || ! is_object($wp_filesystem) )
+ WP_Filesystem();
+
+ if ( ! is_object($wp_filesystem) )
+ return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
+
+ if ( $wp_filesystem->errors->get_error_code() )
+ return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors);
+
+ //Get the base plugin folder
+ $themes_dir = $wp_filesystem->wp_themes_dir();
+ if ( empty($themes_dir) )
+ return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress Theme directory.'));
+
+ //And the same for the Content directory.
+ $content_dir = $wp_filesystem->wp_content_dir();
+ if( empty($content_dir) )
+ return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).'));
+
+ $themes_dir = trailingslashit( $themes_dir );
+ $content_dir = trailingslashit( $content_dir );
+
+ if ( empty($r->package) )
+ return new WP_Error('no_package', __('Upgrade package not available.'));
+
+ // Download the package
+ apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $r['package']));
+ $download_file = download_url($r['package']);
+
+ if ( is_wp_error($download_file) )
+ return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message());
+
+ $working_dir = $content_dir . 'upgrade/' . basename($theme_directory);
+
+ // Clean up working directory
+ if ( $wp_filesystem->is_dir($working_dir) )
+ $wp_filesystem->delete($working_dir, true);
+
+ apply_filters('update_feedback', __('Unpacking the update'));
+ // Unzip package to working directory
+ $result = unzip_file($download_file, $working_dir);
+
+ // Once extracted, delete the package
+ unlink($download_file);
+
+ if ( is_wp_error($result) ) {
+ $wp_filesystem->delete($working_dir, true);
+ return $result;
+ }
+
+ //TODO: Is theme currently active? If so, set default theme
+ /*
+ if ( is_plugin_active($plugin) ) {
+ //Deactivate the plugin silently, Prevent deactivation hooks from running.
+ apply_filters('update_feedback', __('Deactivating the plugin'));
+ deactivate_plugins($plugin, true);
+ }*/
+
+ // Remove the existing plugin.
+ apply_filters('update_feedback', __('Removing the old version of the theme'));
+ $deleted = $wp_filesystem->delete($themes_dir . $theme_directory, true);
+
+ if ( ! $deleted ) {
+ $wp_filesystem->delete($working_dir, true);
+ return new WP_Error('delete_failed', __('Could not remove the old plugin'));
+ }
+
+ apply_filters('update_feedback', __('Installing the latest version'));
+ // Copy new version of plugin into place.
+ $result = copy_dir($working_dir, $themes_dir);
+ if ( is_wp_error($result) ) {
+ $wp_filesystem->delete($working_dir, true);
+ return $result;
+ }
+
+ //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
+ //$filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
+
+ // Remove working directory
+ $wp_filesystem->delete($working_dir, true);
+
+ // Force refresh of plugin update information
+ delete_option('update_themes');
+
+ /*if( empty($filelist) )
+ return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.
+
+ $folder = $filelist[0];
+ $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
+ $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
+
+ return $folder . '/' . $pluginfiles[0];*/
+}
+
+
+function wp_update_core($current, $feedback = '') {
+ global $wp_filesystem;
+
+ @set_time_limit( 300 );
+
+ if ( !empty($feedback) )
+ add_filter('update_feedback', $feedback);
+
+ // Is an update available?
+ if ( !isset( $current->response ) || $current->response == 'latest' )
+ return new WP_Error('up_to_date', __('WordPress is at the latest version.'));
+
+ // Is a filesystem accessor setup?
+ if ( ! $wp_filesystem || ! is_object($wp_filesystem) )
+ WP_Filesystem();
+
+ if ( ! is_object($wp_filesystem) )
+ return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
+
+ if ( $wp_filesystem->errors->get_error_code() )
+ return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors);
+
+ // Get the base WP folder
+ $wp_dir = $wp_filesystem->abspath();
+ if ( empty($wp_dir) )
+ return new WP_Error('fs_no_wp_dir', __('Unable to locate WordPress directory.'));
+
+ // And the same for the Content directory.
+ $content_dir = $wp_filesystem->wp_content_dir();
+ if( empty($content_dir) )
+ return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).'));
+
+ $wp_dir = trailingslashit( $wp_dir );
+ $content_dir = trailingslashit( $content_dir );
+
+ // Get the URL to the zip file
+ $package = $current->package;
+
+ // Download the package
+ apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $package));
+ $download_file = download_url($package);
+
+ if ( is_wp_error($download_file) )
+ return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message());
+
+ $working_dir = $content_dir . 'upgrade/core';
+ // Clean up working directory
+ if ( $wp_filesystem->is_dir($working_dir) ) {
+ $wp_filesystem->delete($working_dir, true);
+ }
+
+ apply_filters('update_feedback', __('Unpacking the core update'));
+ // Unzip package to working directory
+ $result = unzip_file($download_file, $working_dir);
+ // Once extracted, delete the package
+ unlink($download_file);
+
+ if ( is_wp_error($result) ) {
+ $wp_filesystem->delete($working_dir, true);
+ return $result;
+ }
+
+ // Copy update-core.php from the new version into place.
+ if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) {
+ $wp_filesystem->delete($working_dir, true);
+ return new WP_Error('copy_failed', __('Could not copy files'));
+ }
+ $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
+
+ require(ABSPATH . 'wp-admin/includes/update-core.php');
+
+ return update_core($working_dir, $wp_dir);
+}
+
+function maintenance_nag() {
+ global $upgrading;
+ if ( ! isset( $upgrading ) )
+ return false;
+
+ if ( current_user_can('manage_options') )
+ $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' );
+ else
+ $msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.');
+
+ echo "<div id='update-nag'>$msg</div>";
+}
+add_action( 'admin_notices', 'maintenance_nag' );
+
?>
<?php
+/**
+ * WordPress Upgrade API
+ *
+ * Most of the functions are pluggable and can be overwritten
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+/** Include user install customize script. */
if ( file_exists(WP_CONTENT_DIR . '/install.php') )
require (WP_CONTENT_DIR . '/install.php');
+
+/** WordPress Administration API */
require_once(ABSPATH . 'wp-admin/includes/admin.php');
+
+/** WordPress Schema API */
require_once(ABSPATH . 'wp-admin/includes/schema.php');
if ( !function_exists('wp_install') ) :
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param string $blog_title Blog title.
+ * @param string $user_name User's username.
+ * @param string $user_email User's email.
+ * @param bool $public Whether blog is public.
+ * @param null $deprecated Optional. Not used.
+ * @return array Array keys 'url', 'user_id', 'password'.
+ */
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') {
global $wp_rewrite;
endif;
if ( !function_exists('wp_install_defaults') ) :
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param int $user_id User ID.
+ */
function wp_install_defaults($user_id) {
global $wpdb;
endif;
if ( !function_exists('wp_new_blog_notification') ) :
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param string $blog_title Blog title.
+ * @param string $blog_url Blog url.
+ * @param int $user_id User ID.
+ * @param string $password User's Password.
+ */
function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
$user = new WP_User($user_id);
$email = $user->user_email;
endif;
if ( !function_exists('wp_upgrade') ) :
+/**
+ * Run WordPress Upgrade functions.
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @return null
+ */
function wp_upgrade() {
global $wp_current_db_version, $wp_db_version;
if ( $wp_db_version == $wp_current_db_version )
return;
+ if( ! is_blog_installed() )
+ return;
+
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
}
endif;
-// Functions to be called in install and upgrade scripts
+/**
+ * Functions to be called in install and upgrade scripts.
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ */
function upgrade_all() {
global $wp_current_db_version, $wp_db_version, $wp_rewrite;
$wp_current_db_version = __get_option('db_version');
if ( $wp_current_db_version < 8201 )
upgrade_260();
+ if ( $wp_current_db_version < 8989 )
+ upgrade_270();
+
maybe_disable_automattic_widgets();
$wp_rewrite->flush_rules();
update_option('db_version', $wp_db_version);
}
+/**
+ * Execute changes made in WordPress 1.0.
+ *
+ * @since 1.0.0
+ */
function upgrade_100() {
global $wpdb;
}
}
-
$wpdb->query("UPDATE $wpdb->options SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
WHERE option_name LIKE 'links_rating_image%'
AND option_value LIKE 'wp-links/links-images/%'");
endif;
}
+/**
+ * Execute changes made in WordPress 1.0.1.
+ *
+ * @since 1.0.1
+ */
function upgrade_101() {
global $wpdb;
add_clean_index($wpdb->links , 'link_visible');
}
-
+/**
+ * Execute changes made in WordPress 1.2.
+ *
+ * @since 1.2.0
+ */
function upgrade_110() {
global $wpdb;
}
}
-
// Get the GMT offset, we'll use that later on
$all_options = get_alloptions_110();
}
+/**
+ * Execute changes made in WordPress 1.5.
+ *
+ * @since 1.5.0
+ */
function upgrade_130() {
global $wpdb;
make_site_theme();
}
+/**
+ * Execute changes made in WordPress 2.0.
+ *
+ * @since 2.0.0
+ */
function upgrade_160() {
global $wpdb, $wp_current_db_version;
}
}
+/**
+ * Execute changes made in WordPress 2.1.
+ *
+ * @since 2.1.0
+ */
function upgrade_210() {
global $wpdb, $wp_current_db_version;
}
}
+/**
+ * Execute changes made in WordPress 2.3.
+ *
+ * @since 2.3.0
+ */
function upgrade_230() {
global $wp_current_db_version, $wpdb;
}
}
- $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
+ $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) );
$count = 0;
}
}
+/**
+ * Remove old options from the database.
+ *
+ * @since 2.3.0
+ */
function upgrade_230_options_table() {
global $wpdb;
$old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' );
$wpdb->show_errors();
}
+/**
+ * Remove old categories, link2cat, and post2cat database tables.
+ *
+ * @since 2.3.0
+ */
function upgrade_230_old_tables() {
global $wpdb;
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat');
}
+/**
+ * Upgrade old slugs made in version 2.2.
+ *
+ * @since 2.2.0
+ */
function upgrade_old_slugs() {
// upgrade people who were using the Redirect Old Slugs plugin
global $wpdb;
$wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'");
}
-
+/**
+ * Execute changes made in WordPress 2.5.0.
+ *
+ * @since 2.5.0
+ */
function upgrade_250() {
global $wp_current_db_version;
if ( $wp_current_db_version < 6689 ) {
populate_roles_250();
}
-
+
}
+/**
+ * Execute changes made in WordPress 2.5.1.
+ *
+ * @since 2.5.1
+ */
function upgrade_251() {
global $wp_current_db_version;
update_option('secret', wp_generate_password(64));
}
+/**
+ * Execute changes made in WordPress 2.5.2.
+ *
+ * @since 2.5.2
+ */
function upgrade_252() {
global $wpdb;
$wpdb->query("UPDATE $wpdb->users SET user_activation_key = ''");
}
+/**
+ * Execute changes made in WordPress 2.6.
+ *
+ * @since 2.6.0
+ */
function upgrade_260() {
+ global $wp_current_db_version;
+
if ( $wp_current_db_version < 8000 )
populate_roles_260();
}
}
+/**
+ * Execute changes made in WordPress 2.7.
+ *
+ * @since 2.7.0
+ */
+function upgrade_270() {
+ global $wpdb, $wp_current_db_version;
+
+ if ( $wp_current_db_version < 8980 )
+ populate_roles_270();
+
+ // Update post_date for unpublished posts with empty timestamp
+ if ( $wp_current_db_version < 8921 )
+ $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
+}
+
+
// The functions we use to actually do stuff
// General
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param string $table_name Database table name to create.
+ * @param string $create_ddl SQL statement to create table.
+ * @return bool If table already exists or was created by function.
+ */
function maybe_create_table($table_name, $create_ddl) {
global $wpdb;
foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
return false;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param string $table Database table name.
+ * @param string $index Index name to drop.
+ * @return bool True, when finished.
+ */
function drop_index($table, $index) {
global $wpdb;
$wpdb->hide_errors();
return true;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param string $table Database table name.
+ * @param string $index Database table index column.
+ * @return bool True, when done with execution.
+ */
function add_clean_index($table, $index) {
global $wpdb;
drop_index($table, $index);
return false;
}
-
-// get_alloptions as it was for 1.2.
+/**
+ * Retrieve all options as it was for 1.2.
+ *
+ * @since 1.2.0
+ *
+ * @return array List of options.
+ */
function get_alloptions_110() {
global $wpdb;
if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
return $all_options;
}
-// Version of get_option that is private to install/upgrade.
+/**
+ * Version of get_option that is private to install/upgrade.
+ *
+ * @since unknown
+ * @access private
+ *
+ * @param string $setting Option name.
+ * @return mixed
+ */
function __get_option($setting) {
global $wpdb;
return $option;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param string $content
+ * @return string
+ */
function deslash($content) {
// Note: \\\ inside a regex denotes a single backslash.
return $content;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $queries
+ * @param unknown_type $execute
+ * @return unknown
+ */
function dbDelta($queries, $execute = true) {
global $wpdb;
return $for_update;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ */
function make_db_current() {
global $wp_queries;
echo "</ol>\n";
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ */
function make_db_current_silent() {
global $wp_queries;
$alterations = dbDelta($wp_queries);
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $theme_name
+ * @param unknown_type $template
+ * @return unknown
+ */
function make_site_theme_from_oldschool($theme_name, $template) {
$home_path = get_home_path();
$site_dir = WP_CONTENT_DIR . "/themes/$template";
return true;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $theme_name
+ * @param unknown_type $template
+ * @return unknown
+ */
function make_site_theme_from_default($theme_name, $template) {
$site_dir = WP_CONTENT_DIR . "/themes/$template";
$default_dir = WP_CONTENT_DIR . '/themes/default';
}
// Create a site theme from the default theme.
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function make_site_theme() {
// Name the theme after the blog.
$theme_name = __get_option('blogname');
return $template;
}
+/**
+ * Translate user level to user role name.
+ *
+ * @since unknown
+ *
+ * @param int $level User level.
+ * @return string User role name.
+ */
function translate_level_to_role($level) {
switch ($level) {
case 10:
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ */
function wp_check_mysql_version() {
global $wpdb;
$result = $wpdb->check_database_version();
die( $result->get_error_message() );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ */
function maybe_disable_automattic_widgets() {
$plugins = __get_option( 'active_plugins' );
<?php
-
-// Creates a new user from the "Users" form using $_POST information.
+/**
+ * WordPress user administration API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Creates a new user from the "Users" form using $_POST information.
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param int $user_id Optional. User ID.
+ * @return null|WP_Error|int Null when adding user, WP_Error or User ID integer when no parameters.
+ */
function add_user() {
if ( func_num_args() ) { // The hackiest hack that ever did hack
global $current_user, $wp_roles;
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param int $user_id Optional. User ID.
+ * @return unknown
+ */
function edit_user( $user_id = 0 ) {
global $current_user, $wp_roles, $wpdb;
if ( $user_id != 0 ) {
else if ( isset( $_POST['rich_editing'] ) )
$user->rich_editing = $_POST['rich_editing'];
else
- $user->rich_editing = 'false';
+ $user->rich_editing = 'true';
+
+ $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] )? $_POST['comment_shortcuts'] : '';
+
+ $user->use_ssl = 0;
+ if ( !empty($_POST['use_ssl']) )
+ $user->use_ssl = 1;
if ( !$update )
$user->admin_color = 'fresh'; // Default to fresh for new users.
return $user_id;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @return array List of user IDs.
+ */
function get_author_user_ids() {
global $wpdb;
$level_key = $wpdb->prefix . 'user_level';
return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param int $user_id User ID.
+ * @return array|bool List of editable authors. False if no editable users.
+ */
function get_editable_authors( $user_id ) {
global $wpdb;
return apply_filters('get_editable_authors', $authors);
}
-function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @param int $user_id User ID.
+ * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros.
+ * @return unknown
+ */
+function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
global $wpdb;
$user = new WP_User( $user_id );
- if ( ! $user->has_cap('edit_others_posts') ) {
- if ( $user->has_cap('edit_posts') || $exclude_zeros == false )
+ if ( ! $user->has_cap("edit_others_{$post_type}s") ) {
+ if ( $user->has_cap("edit_{$post_type}s") || $exclude_zeros == false )
return array($user->id);
else
return false;
return $wpdb->get_col( $query );
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function get_nonauthor_user_ids() {
global $wpdb;
$level_key = $wpdb->prefix . 'user_level';
return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
}
+/**
+ * Retrieve editable posts from other users.
+ *
+ * @since unknown
+ *
+ * @param int $user_id User ID to not retrieve posts from.
+ * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
+ * @return array List of posts from others.
+ */
function get_others_unpublished_posts($user_id, $type='any') {
global $wpdb;
return apply_filters('get_others_drafts', $other_unpubs);
}
+/**
+ * Retrieve drafts from other users.
+ *
+ * @since unknown
+ *
+ * @param int $user_id User ID.
+ * @return array List of drafts from other users.
+ */
function get_others_drafts($user_id) {
return get_others_unpublished_posts($user_id, 'draft');
}
+/**
+ * Retrieve pending review posts from other users.
+ *
+ * @since unknown
+ *
+ * @param int $user_id User ID.
+ * @return array List of posts with pending review post type from other users.
+ */
function get_others_pending($user_id) {
return get_others_unpublished_posts($user_id, 'pending');
}
+/**
+ * Retrieve user data and filter it.
+ *
+ * @since unknown
+ *
+ * @param int $user_id User ID.
+ * @return object WP_User object with user data.
+ */
function get_user_to_edit( $user_id ) {
$user = new WP_User( $user_id );
$user->user_login = attribute_escape($user->user_login);
$user->last_name = attribute_escape($user->last_name);
$user->display_name = attribute_escape($user->display_name);
$user->nickname = attribute_escape($user->nickname);
- $user->aim = attribute_escape($user->aim);
- $user->yim = attribute_escape($user->yim);
- $user->jabber = attribute_escape($user->jabber);
- $user->description = wp_specialchars($user->description);
+ $user->aim = isset( $user->aim ) && !empty( $user->aim ) ? attribute_escape($user->aim) : '';
+ $user->yim = isset( $user->yim ) && !empty( $user->yim ) ? attribute_escape($user->yim) : '';
+ $user->jabber = isset( $user->jabber ) && !empty( $user->jabber ) ? attribute_escape($user->jabber) : '';
+ $user->description = isset( $user->description ) && !empty( $user->description ) ? wp_specialchars($user->description) : '';
return $user;
}
+/**
+ * Retrieve the user's drafts.
+ *
+ * @since unknown
+ *
+ * @param int $user_id User ID.
+ * @return array
+ */
function get_users_drafts( $user_id ) {
global $wpdb;
$query = $wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id);
return $wpdb->get_results( $query );
}
+/**
+ * Remove user and optionally reassign posts and links to another user.
+ *
+ * If the $reassign parameter is not assigned to an User ID, then all posts will
+ * be deleted of that user. The action 'delete_user' that is passed the User ID
+ * being deleted will be run after the posts are either reassigned or deleted.
+ * The user meta will also be deleted that are for that User ID.
+ *
+ * @since unknown
+ *
+ * @param int $id User ID.
+ * @param int $reassign Optional. Reassign posts and links to new User ID.
+ * @return bool True when finished.
+ */
function wp_delete_user($id, $reassign = 'novalue') {
global $wpdb;
return true;
}
+/**
+ * Remove all capabilities from user.
+ *
+ * @since unknown
+ *
+ * @param int $id User ID.
+ */
function wp_revoke_user($id) {
$id = (int) $id;
$user->remove_all_caps();
}
-// WP_User_Search class
-// by Mark Jaquith
-
if ( !class_exists('WP_User_Search') ) :
+/**
+ * WordPress User Search class.
+ *
+ * @since unknown
+ * @author Mark Jaquith
+ */
class WP_User_Search {
+
+ /**
+ * {@internal Missing Description}}
+ *
+ * @since unknown
+ * @access private
+ * @var unknown_type
+ */
var $results;
+
+ /**
+ * {@internal Missing Description}}
+ *
+ * @since unknown
+ * @access private
+ * @var unknown_type
+ */
var $search_term;
+
+ /**
+ * Page number.
+ *
+ * @since unknown
+ * @access private
+ * @var int
+ */
var $page;
+
+ /**
+ * Role name that users have.
+ *
+ * @since unknown
+ * @access private
+ * @var string
+ */
var $role;
+
+ /**
+ * Raw page number.
+ *
+ * @since unknown
+ * @access private
+ * @var int|bool
+ */
var $raw_page;
+
+ /**
+ * Amount of users to display per page.
+ *
+ * @since unknown
+ * @access public
+ * @var int
+ */
var $users_per_page = 50;
+
+ /**
+ * {@internal Missing Description}}
+ *
+ * @since unknown
+ * @access private
+ * @var unknown_type
+ */
var $first_user;
+
+ /**
+ * {@internal Missing Description}}
+ *
+ * @since unknown
+ * @access private
+ * @var int
+ */
var $last_user;
+
+ /**
+ * {@internal Missing Description}}
+ *
+ * @since unknown
+ * @access private
+ * @var unknown_type
+ */
var $query_limit;
+
+ /**
+ * {@internal Missing Description}}
+ *
+ * @since unknown
+ * @access private
+ * @var unknown_type
+ */
var $query_sort;
+
+ /**
+ * {@internal Missing Description}}
+ *
+ * @since unknown
+ * @access private
+ * @var unknown_type
+ */
var $query_from_where;
+
+ /**
+ * {@internal Missing Description}}
+ *
+ * @since unknown
+ * @access private
+ * @var int
+ */
var $total_users_for_query = 0;
+
+ /**
+ * {@internal Missing Description}}
+ *
+ * @since unknown
+ * @access private
+ * @var bool
+ */
var $too_many_total_users = false;
+
+ /**
+ * {@internal Missing Description}}
+ *
+ * @since unknown
+ * @access private
+ * @var unknown_type
+ */
var $search_errors;
- function WP_User_Search ($search_term = '', $page = '', $role = '') { // constructor
+ /**
+ * {@internal Missing Description}}
+ *
+ * @since unknown
+ * @access private
+ * @var unknown_type
+ */
+ var $paging_text;
+
+ /**
+ * PHP4 Constructor - Sets up the object properties.
+ *
+ * @since unknown
+ *
+ * @param string $search_term Search terms string.
+ * @param int $page Optional. Page ID.
+ * @param string $role Role name.
+ * @return WP_User_Search
+ */
+ function WP_User_Search ($search_term = '', $page = '', $role = '') {
$this->search_term = $search_term;
$this->raw_page = ( '' == $page ) ? false : (int) $page;
$this->page = (int) ( '' == $page ) ? 1 : $page;
$this->do_paging();
}
+ /**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ * @access public
+ */
function prepare_query() {
global $wpdb;
$this->first_user = ($this->page - 1) * $this->users_per_page;
}
+ /**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ * @access public
+ */
function query() {
global $wpdb;
$this->results = $wpdb->get_col('SELECT ID ' . $this->query_from_where . $this->query_sort . $this->query_limit);
$this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
}
+ /**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ * @access public
+ */
function prepare_vars_for_template_usage() {
$this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
}
+ /**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ * @access public
+ */
function do_paging() {
if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
$args = array();
'format' => 'userspage=%#%',
'add_args' => $args
) );
+ if ( $this->paging_text ) {
+ $this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
+ number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
+ number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
+ number_format_i18n( $this->total_users_for_query ),
+ $this->paging_text
+ );
+ }
}
}
+ /**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since unknown
+ * @access public
+ *
+ * @return unknown
+ */
function get_results() {
return (array) $this->results;
}
+ /**
+ * Displaying paging text.
+ *
+ * @see do_paging() Builds paging text.
+ *
+ * @since unknown
+ * @access public
+ */
function page_links() {
echo $this->paging_text;
}
+ /**
+ * Whether paging is enabled.
+ *
+ * @see do_paging() Builds paging text.
+ *
+ * @since unknown
+ * @access public
+ *
+ * @return bool
+ */
function results_are_paged() {
if ( $this->paging_text )
return true;
return false;
}
+ /**
+ * Whether there are search terms.
+ *
+ * @since unknown
+ * @access public
+ *
+ * @return bool
+ */
function is_search() {
if ( $this->search_term )
return true;
<?php
+/**
+ * WordPress Widgets Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
-// $_search is unsanitized
+/**
+ * Display list of widgets, either all or matching search.
+ *
+ * The search parameter are search terms separated by spaces.
+ *
+ * @since unknown
+ *
+ * @param string $show Optional, default is all. What to display, can be 'all', 'unused', or 'used'.
+ * @param string $_search Optional. Search for widgets. Should be unsanitized.
+ */
function wp_list_widgets( $show = 'all', $_search = false ) {
global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
if ( $_search ) {
if ( ( 'unused' == $show && $sidebar ) || ( 'used' == $show && !$sidebar ) )
continue;
+ if ( ! isset( $widget['params'][0] ) )
+ $widget['params'][0] = array();
ob_start();
- $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template', '_show' => $show ), 1 => $widget['params'][0] ) );
- $sidebar_args = call_user_func_array( 'wp_widget_control', $args );
+ $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template', '_show' => $show ), 1 => $widget['params'][0] ) );
+ $sidebar_args = call_user_func_array( 'wp_widget_control', $args );
$widget_control_template = ob_get_contents();
ob_end_clean();
'edit' => $widget['id'],
'key' => array_search( $widget['id'], $sidebars_widgets[$sidebar] ),
) ) );
-
+
$widget_control_template = '<textarea rows="1" cols="1">' . htmlspecialchars( $widget_control_template ) . '</textarea>';
}
<?php
}
-
-
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param string $sidebar
+ */
function wp_list_widget_controls( $sidebar ) {
add_filter( 'dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar' );
?>
<?php
}
-
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param array $params
+ * @return array
+ */
function wp_list_widget_controls_dynamic_sidebar( $params ) {
global $wp_registered_widgets;
static $i = 0;
return $params;
}
-/*
- * Meta widget used to display the control form for a widget. Called from dynamic_sidebar()
+/**
+ * Meta widget used to display the control form for a widget.
+ *
+ * Called from dynamic_sidebar().
+ *
+ * @since unknown
+ *
+ * @param array $sidebar_args
+ * @return array
*/
function wp_widget_control( $sidebar_args ) {
global $wp_registered_widgets, $wp_registered_widget_controls, $sidebars_widgets, $edit_widget;
$widget_id = $sidebar_args['widget_id'];
$sidebar_id = isset($sidebar_args['id']) ? $sidebar_args['id'] : false;
- $control = $wp_registered_widget_controls[$widget_id];
+ $control = isset($wp_registered_widget_controls[$widget_id]) ? $wp_registered_widget_controls[$widget_id] : 0;
$widget = $wp_registered_widgets[$widget_id];
$key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : 'no-key'; // position of widget in sidebar
$edit = -1 < $edit_widget && is_numeric($key) && $edit_widget === $key; // (bool) are we currently editing this widget
$id_format = $widget['id'];
+
+ if ( ! isset( $sidebar_args['_show'] ) )
+ $sidebar_args['_show'] = '';
+
+ if ( ! isset( $sidebar_args['_display'] ) )
+ $sidebar_args['_display'] = '';
+
// We aren't showing a widget control, we're outputing a template for a mult-widget control
if ( 'all' == $sidebar_args['_show'] && 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) {
// number == -1 implies a template where id numbers are replaced by a generic '%i%'
<?php if ( $control ) : ?>
- <a class="widget-action widget-control-save wp-no-js-hidden edit alignleft" href="#save:<?php echo $id_format; ?>"><?php _e('Change'); ?></a>
+ <a class="button widget-action widget-control-save hide-if-no-js edit alignleft" href="#save:<?php echo $id_format; ?>"><?php _e('Done'); ?></a>
<?php endif; ?>
- <a class="widget-action widget-control-remove delete alignright" href="<?php echo clean_url( wp_nonce_url( add_query_arg( array( 'remove' => $id_format, 'key' => $key ) ), "remove-widget_$widget[id]" ) ); ?>"><?php _e('Remove'); ?></a>
+ <a class="button widget-action widget-control-remove alignright" href="<?php echo clean_url( wp_nonce_url( add_query_arg( array( 'remove' => $id_format, 'key' => $key ) ), "remove-widget_$widget[id]" ) ); ?>"><?php _e('Remove'); ?></a>
<br class="clear" />
</div>
</div>
return $sidebar_args;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param string $string
+ * @return string
+ */
function wp_widget_control_ob_filter( $string ) {
if ( false === $beg = strpos( $string, '%BEG_OF_TITLE%' ) )
return '';
return trim( wp_specialchars( strip_tags( $string ) ) );
}
-?>
+?>
\ No newline at end of file
<?php
+/**
+ * Handle default dashboard widgets options AJAX.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
require_once('admin.php');
+
+/** Load WordPress Administration Dashboard API */
require( 'includes/dashboard.php' );
+
+/** Load Magpie RSS API or custom RSS API */
require_once (ABSPATH . WPINC . '/rss.php');
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
switch ( $_GET['jax'] ) {
-case 'incominglinks' :
+case 'dashboard_incoming_links' :
wp_dashboard_incoming_links_output();
break;
-case 'devnews' :
+case 'dashboard_primary' :
wp_dashboard_rss_output( 'dashboard_primary' );
break;
-case 'planetnews' :
+case 'dashboard_secondary' :
wp_dashboard_secondary_output();
break;
-case 'plugins' :
+case 'dashboard_plugins' :
wp_dashboard_plugins_output();
break;
}
-?>
+?>
\ No newline at end of file
<?php
-
+/**
+ * Dashboard Administration Panel
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
require_once('admin.php');
+/** Load WordPress dashboard API */
require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
wp_dashboard_setup();
-function index_js() {
-?>
-<script type="text/javascript">
-jQuery(function($) {
- var ajaxWidgets = {
- dashboard_incoming_links: 'incominglinks',
- dashboard_primary: 'devnews',
- dashboard_secondary: 'planetnews',
- dashboard_plugins: 'plugins'
- };
- $.each( ajaxWidgets, function(i,a) {
- var e = jQuery('#' + i + ' div.dashboard-widget-content').not('.dashboard-widget-control').find('.widget-loading');
- if ( e.size() ) { e.parent().load('index-extra.php?jax=' + a); }
- } );
-});
-</script>
-<?php
-}
-add_action( 'admin_head', 'index_js' );
-
-wp_enqueue_script( 'jquery' );
+wp_enqueue_script( 'dashboard' );
+wp_enqueue_script( 'plugin-install' );
+wp_enqueue_script( 'media-upload' );
wp_admin_css( 'dashboard' );
+wp_admin_css( 'plugin-install' );
+add_thickbox();
$title = __('Dashboard');
$parent_file = 'index.php';
?>
<div class="wrap">
-
-<h2><?php _e('Dashboard'); ?></h2>
-
-<div id="rightnow">
-<h3 class="reallynow">
- <span><?php _e('Right Now'); ?></span>
-
-<?php if ( $can_edit_posts = current_user_can( 'edit_posts' ) ) : ?>
- <a href="post-new.php" class="rbutton"><strong><?php _e('Write a New Post'); ?></strong></a>
-<?php endif; if ( $can_edit_pages = current_user_can( 'edit_pages' ) ) : ?>
- <a href="page-new.php" class="rbutton"><?php _e('Write a New Page'); ?></a>
-<?php endif; ?>
- <br class="clear" />
-</h3>
-
-<?php
-$num_posts = wp_count_posts( 'post' );
-$num_pages = wp_count_posts( 'page' );
-
-$num_cats = wp_count_terms('category');
-
-$num_tags = wp_count_terms('post_tag');
-
-$num_comm = get_comment_count( );
-
-$post_type_texts = array();
-
-if ( !empty($num_posts->publish) ) { // with feeds, anyone can tell how many posts there are. Just unlink if !current_user_can
- $post_text = sprintf( __ngettext( '%s post', '%s posts', $num_posts->publish ), number_format_i18n( $num_posts->publish ) );
- $post_type_texts[] = $can_edit_posts ? "<a href='edit.php'>$post_text</a>" : $post_text;
-}
-if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds. Don't show if !current_user_can
- $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
-}
-if ( $can_edit_posts && !empty($num_posts->draft) ) {
- $post_type_texts[] = '<a href="edit.php?post_status=draft">'.sprintf( __ngettext( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).'</a>';
-}
-if ( $can_edit_posts && !empty($num_posts->future) ) {
- $post_type_texts[] = '<a href="edit.php?post_status=future">'.sprintf( __ngettext( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).'</a>';
-}
-
-if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {
- $pending_text = sprintf( __ngettext( 'There is <a href="%1$s">%2$s post</a> pending your review.', 'There are <a href="%1$s">%2$s posts</a> pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) );
-} else {
- $pending_text = '';
-}
-
-$cats_text = sprintf( __ngettext( '%s category', '%s categories', $num_cats ), number_format_i18n( $num_cats ) );
-$tags_text = sprintf( __ngettext( '%s tag', '%s tags', $num_tags ), number_format_i18n( $num_tags ) );
-if ( current_user_can( 'manage_categories' ) ) {
- $cats_text = "<a href='categories.php'>$cats_text</a>";
- $tags_text = "<a href='edit-tags.php'>$tags_text</a>";
-}
-
-$total_comments = sprintf( __ngettext( '%1$s total', '%1$s total', $num_comm['total_comments'] ), number_format_i18n($num_comm['total_comments']) );
-$approved_comments = sprintf( __ngettext( '%1$s approved', '%1$s approved', $num_comm['approved'] ), number_format_i18n($num_comm['approved']) );
-$spam_comments = sprintf( __ngettext( '%1$s spam', '%1$s spam', $num_comm['spam'] ), number_format_i18n($num_comm['spam']) );
-$moderated_comments = sprintf( __ngettext( '%1$s awaiting moderation', '%1$s awaiting moderation', $num_comm['awaiting_moderation'] ), number_format_i18n($num_comm['awaiting_moderation']) );
-
-if( current_user_can( 'moderate_comments' ) ) {
- $total_comments = "<a href='edit-comments.php'>{$total_comments}</a>";
- $approved_comments = "<a href='edit-comments.php?comment_status=approved'>{$approved_comments}</a>";
- $moderated_comments = "<a href='edit-comments.php?comment_status=moderated'>{$moderated_comments}</a>";
-}
-
-$comm_text = sprintf( __ngettext( 'You have %1$s comment, %2$s, %3$s and %4$s.', 'You have %1$s comments, %2$s, %3$s and %4$s.', $num_comm['total_comments'] ), $total_comments, $approved_comments, $spam_comments, $moderated_comments );
-
-$post_type_text = implode(', ', $post_type_texts);
-
-// There is always a category
-$sentence = sprintf( __( 'You have %1$s, contained within %2$s and %3$s. %4$s %5$s' ), $post_type_text, $cats_text, $tags_text, $pending_text, $comm_text );
-$sentence = apply_filters( 'dashboard_count_sentence', $sentence, $post_type_text, $cats_text, $tags_text, $pending_text, $comm_text );
-
-?>
-<p class="youhave"><?php echo $sentence; ?></p>
-<?php
-$ct = current_theme_info();
-$sidebars_widgets = wp_get_sidebars_widgets();
-$num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ), 0 );
-$widgets_text = sprintf( __ngettext( '%d widget', '%d widgets', $num_widgets ), $num_widgets );
-if ( $can_switch_themes = current_user_can( 'switch_themes' ) )
- $widgets_text = "<a href='widgets.php'>$widgets_text</a>";
-?>
-<p class="youare">
- <?php printf( __( 'You are using the %1$s theme with %2$s.' ), $ct->title, $widgets_text ); ?>
- <?php if ( $can_switch_themes ) : ?>
- <a href="themes.php" class="rbutton"><?php _e('Change Theme'); ?></a>
- <?php endif; ?>
- <?php update_right_now_message(); ?>
-</p>
-<?php do_action( 'rightnow_end' ); ?>
-<?php do_action( 'activity_box_end' ); ?>
-</div><!-- rightnow -->
-
-<br class="clear" />
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
<div id="dashboard-widgets-wrap">
<?php wp_dashboard(); ?>
-
+<div class="clear"></div>
</div><!-- dashboard-widgets-wrap -->
</div><!-- wrap -->
-<?php require('./admin-footer.php'); ?>
+<?php require(ABSPATH . 'wp-admin/admin-footer.php'); ?>
<?php
+/**
+ * Plugins may load this file to gain access to special helper functions for
+ * plugin installation. This file is not included by WordPress and it is
+ * recommended, to prevent fatal errors, that this file is included using
+ * require_once().
+ *
+ * These functions are not optimized for speed, but they should only be used
+ * once in a while, so speed shouldn't be a concern. If it is and you are
+ * needing to use these functions a lot, you might experience time outs. If you
+ * do, then it is advised to just write the SQL code yourself.
+ *
+ * You can turn debugging on, by setting $debug to 1 after you include this
+ * file.
+ *
+ * <code>
+ * check_column('wp_links', 'link_description', 'mediumtext');
+ * if (check_column($wpdb->comments, 'comment_author', 'tinytext'))
+ * echo "ok\n";
+ *
+ * $error_count = 0;
+ * $tablename = $wpdb->links;
+ * // check the column
+ * if (!check_column($wpdb->links, 'link_description', 'varchar(255)')) {
+ * $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
+ * $q = $wpdb->query($ddl);
+ * }
+ *
+ * if (check_column($wpdb->links, 'link_description', 'varchar(255)')) {
+ * $res .= $tablename . ' - ok <br />';
+ * } else {
+ * $res .= 'There was a problem with ' . $tablename . '<br />';
+ * ++$error_count;
+ * }
+ * </code>
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ */
+
+/**
+ * @global bool $wp_only_load_config
+ * @name $wp_only_load_config
+ * @var bool
+ * @since unknown
+ */
$wp_only_load_config = true;
+
+/** Load WordPress Bootstrap */
require_once(dirname(dirname(__FILE__)).'/wp-load.php');
-$debug = 0;
/**
- ** maybe_create_table()
- ** Create db table if it doesn't exist.
- ** Returns: true if already exists or on successful completion
- ** false on error
+ * Turn debugging on or off.
+ * @global bool|int $debug
+ * @name $debug
+ * @var bool|int
+ * @since unknown
*/
+$debug = 0;
+
if ( ! function_exists('maybe_create_table') ) :
+/**
+ * Create database table, if it doesn't already exist.
+ *
+ * @since unknown
+ * @package WordPress
+ * @subpackage Plugin
+ * @uses $wpdb
+ *
+ * @param string $table_name Database table name.
+ * @param string $create_ddl Create database table SQL.
+ * @return bool False on error, true if already exists or success.
+ */
function maybe_create_table($table_name, $create_ddl) {
global $wpdb;
foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
}
endif;
+if ( ! function_exists('maybe_add_column') ) :
/**
- ** maybe_add_column()
- ** Add column to db table if it doesn't exist.
- ** Returns: true if already exists or on successful completion
- ** false on error
+ * Add column to database table, if column doesn't already exist in table.
+ *
+ * @since unknown
+ * @package WordPress
+ * @subpackage Plugin
+ * @uses $wpdb
+ * @uses $debug
+ *
+ * @param string $table_name Database table name
+ * @param string $column_name Table column name
+ * @param string $create_ddl SQL to add column to table.
+ * @return bool False on failure. True, if already exists or was successful.
*/
-if ( ! function_exists('maybe_add_column') ) :
function maybe_add_column($table_name, $column_name, $create_ddl) {
global $wpdb, $debug;
foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
if ($debug) echo("checking $column == $column_name<br />");
- if ($column == $column_name) {
- return true;
- }
+
+ if ($column == $column_name) {
+ return true;
+ }
}
//didn't find it try to create it.
$wpdb->query($create_ddl);
endif;
/**
- ** maybe_drop_column()
- ** Drop column from db table if it exists.
- ** Returns: true if it doesn't already exist or on successful drop
- ** false on error
+ * Drop column from database table, if it exists.
+ *
+ * @since unknown
+ * @package WordPress
+ * @subpackage Plugin
+ * @uses $wpdb
+ *
+ * @param string $table_name Table name
+ * @param string $column_name Column name
+ * @param string $drop_ddl SQL statement to drop column.
+ * @return bool False on failure, true on success or doesn't exist.
*/
function maybe_drop_column($table_name, $column_name, $drop_ddl) {
global $wpdb;
return true;
}
-
/**
- ** check_column()
- ** Check column matches passed in criteria.
- ** Pass in null to skip checking that criteria
- ** Returns: true if it matches
- ** false otherwise
- ** (case sensitive) Column names returned from DESC table are:
- ** Field
- ** Type
- ** Null
- ** Key
- ** Default
- ** Extra
+ * Check column matches criteria.
+ *
+ * Uses the SQL DESC for retrieving the table info for the column. It will help
+ * understand the parameters, if you do more research on what column information
+ * is returned by the SQL statement. Pass in null to skip checking that
+ * criteria.
+ *
+ * Column names returned from DESC table are case sensitive and are listed:
+ * Field
+ * Type
+ * Null
+ * Key
+ * Default
+ * Extra
+ *
+ * @since unknown
+ * @package WordPress
+ * @subpackage Plugin
+ *
+ * @param string $table_name Table name
+ * @param string $col_name Column name
+ * @param string $col_type Column type
+ * @param bool $is_null Optional. Check is null.
+ * @param mixed $key Optional. Key info.
+ * @param mixed $default Optional. Default value.
+ * @param mixed $extra Optional. Extra value.
+ * @return bool True, if matches. False, if not matching.
*/
function check_column($table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null) {
global $wpdb, $debug;
foreach ($results as $row ) {
if ($debug > 1) print_r($row);
- if ($row->Field == $col_name) {
- // got our column, check the params
- if ($debug) echo ("checking $row->Type against $col_type\n");
- if (($col_type != null) && ($row->Type != $col_type)) {
- ++$diffs;
- }
- if (($is_null != null) && ($row->Null != $is_null)) {
- ++$diffs;
- }
- if (($key != null) && ($row->Key != $key)) {
- ++$diffs;
- }
- if (($default != null) && ($row->Default != $default)) {
- ++$diffs;
- }
- if (($extra != null) && ($row->Extra != $extra)) {
- ++$diffs;
- }
- if ($diffs > 0) {
- if ($debug) echo ("diffs = $diffs returning false\n");
- return false;
- }
- return true;
- } // end if found our column
+
+ if ($row->Field == $col_name) {
+ // got our column, check the params
+ if ($debug) echo ("checking $row->Type against $col_type\n");
+ if (($col_type != null) && ($row->Type != $col_type)) {
+ ++$diffs;
+ }
+ if (($is_null != null) && ($row->Null != $is_null)) {
+ ++$diffs;
+ }
+ if (($key != null) && ($row->Key != $key)) {
+ ++$diffs;
+ }
+ if (($default != null) && ($row->Default != $default)) {
+ ++$diffs;
+ }
+ if (($extra != null) && ($row->Extra != $extra)) {
+ ++$diffs;
+ }
+ if ($diffs > 0) {
+ if ($debug) echo ("diffs = $diffs returning false\n");
+ return false;
+ }
+ return true;
+ } // end if found our column
}
return false;
}
-/*
-echo "<p>testing</p>";
-echo "<pre>";
-
-//check_column('wp_links', 'link_description', 'mediumtext');
-//if (check_column($wpdb->comments, 'comment_author', 'tinytext'))
-// echo "ok\n";
-$error_count = 0;
-$tablename = $wpdb->links;
-// check the column
-if (!check_column($wpdb->links, 'link_description', 'varchar(255)'))
-{
- $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
- $q = $wpdb->query($ddl);
-}
-if (check_column($wpdb->links, 'link_description', 'varchar(255)')) {
- $res .= $tablename . ' - ok <br />';
-} else {
- $res .= 'There was a problem with ' . $tablename . '<br />';
- ++$error_count;
-}
-echo "</pre>";
-*/
?>
<?php
+/**
+ * WordPress Installer
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * We are installing WordPress.
+ *
+ * @since unknown
+ * @var bool
+ */
define('WP_INSTALLING', true);
+/** Load WordPress Bootstrap */
require_once('../wp-load.php');
+
+/** Load WordPress Administration Upgrade API */
require_once('./includes/upgrade.php');
if (isset($_GET['step']))
$step = $_GET['step'];
else
$step = 0;
-function display_header(){
+
+/**
+ * Display install header.
+ *
+ * @since unknown
+ * @package WordPress
+ * @subpackage Installer
+ */
+function display_header() {
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
display_header();
// Fill in the data we gathered
- $weblog_title = stripslashes($_POST['weblog_title']);
- $admin_email = stripslashes($_POST['admin_email']);
- $public = (int) $_POST['blog_public'];
+ $weblog_title = isset($_POST['weblog_title']) ? stripslashes($_POST['weblog_title']) : '';
+ $admin_email = isset($_POST['admin_email']) ? stripslashes($_POST['admin_email']) : '';
+ $public = isset($_POST['blog_public']) ? (int) $_POST['blog_public'] : 0;
// check e-mail address
if (empty($admin_email)) {
// TODO: poka-yoke
var name = $("<span>" + $('name', r).text() + "</span>").html();
var id = $('cat', r).attr('id');
options[options.length] = new Option(name, id);
+
+ addAfter2( r, settings );
+ }
+
+ var addAfter2 = function( x, r ) {
+ var t = $(r.parsed.responses[0].data);
+ if ( t.length == 1 )
+ inlineEditTax.addEvents($(t.id));
}
var delAfter = function( r, settings ) {
if ( options )
$('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } );
else
- $('#the-list').wpList();
+ $('#the-list').wpList({ addAfter: addAfter2 });
+
+ if ( jQuery('#link-category-search-input').size() ) {
+ columns.init('edit-link-categories');
+ } else {
+ columns.init('categories');
+ }
});
-jQuery(document).ready( function() {
- add_postbox_toggles('comment');
-
- // close postboxes that should be closed
- jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
-
- // show things that should be visible, hide what should be hidden
+jQuery(document).ready( function($) {
jQuery('.hide-if-no-js').show();
jQuery('.hide-if-js').hide();
- jQuery('.edit-timestamp').click(function () {
- if (jQuery('#timestampdiv').is(":hidden")) {
- jQuery('#timestampdiv').slideDown("normal");
- jQuery('.edit-timestamp').text(commentL10n.cancel);
- } else {
- jQuery('#timestampdiv').hide();
- jQuery('#mm').val(jQuery('#hidden_mm').val());
- jQuery('#jj').val(jQuery('#hidden_jj').val());
- jQuery('#aa').val(jQuery('#hidden_aa').val());
- jQuery('#hh').val(jQuery('#hidden_hh').val());
- jQuery('#mn').val(jQuery('#hidden_mn').val());
- jQuery('.edit-timestamp').text(commentL10n.edit);
+ var stamp = $('#timestamp').html();
+ $('.edit-timestamp').click(function () {
+ if ($('#timestampdiv').is(":hidden")) {
+ $('#timestampdiv').slideDown("normal");
+ $('.edit-timestamp').hide();
}
return false;
- });
+ });
+
+ $('.cancel-timestamp').click(function() {
+ $('#timestampdiv').slideUp("normal");
+ $('#mm').val($('#hidden_mm').val());
+ $('#jj').val($('#hidden_jj').val());
+ $('#aa').val($('#hidden_aa').val());
+ $('#hh').val($('#hidden_hh').val());
+ $('#mn').val($('#hidden_mn').val());
+ $('#timestamp').html(stamp);
+ $('.edit-timestamp').show();
+ return false;
+ });
+
+ $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
+ $('#timestampdiv').slideUp("normal");
+ $('.edit-timestamp').show();
+ $('#timestamp').html(
+ commentL10n.submittedOn + ' <b>' +
+ $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
+ $('#jj').val() + ', ' +
+ $('#aa').val() + ' @ ' +
+ $('#hh').val() + ':' +
+ $('#mn').val() + '</b> '
+ );
+ return false;
+ });
});
\ No newline at end of file
-jQuery(document).ready( function() {
+
+var wpCookies = {
+// The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL.
+
+ each : function(o, cb, s) {
+ var n, l;
+
+ if (!o)
+ return 0;
+
+ s = s || o;
+
+ if (typeof(o.length) != 'undefined') {
+ for (n=0, l = o.length; n<l; n++) {
+ if (cb.call(s, o[n], n, o) === false)
+ return 0;
+ }
+ } else {
+ for (n in o) {
+ if (o.hasOwnProperty(n)) {
+ if (cb.call(s, o[n], n, o) === false)
+ return 0;
+ }
+ }
+ }
+ return 1;
+ },
+
+ getHash : function(n) {
+ var v = this.get(n), h;
+
+ if (v) {
+ this.each(v.split('&'), function(v) {
+ v = v.split('=');
+ h = h || {};
+ h[v[0]] = v[1];
+ });
+ }
+ return h;
+ },
+
+ setHash : function(n, v, e, p, d, s) {
+ var o = '';
+
+ this.each(v, function(v, k) {
+ o += (!o ? '' : '&') + k + '=' + v;
+ });
+
+ this.set(n, o, e, p, d, s);
+ },
+
+ get : function(n) {
+ var c = document.cookie, e, p = n + "=", b;
+
+ if (!c)
+ return;
+
+ b = c.indexOf("; " + p);
+
+ if (b == -1) {
+ b = c.indexOf(p);
+
+ if (b != 0)
+ return null;
+ } else
+ b += 2;
+
+ e = c.indexOf(";", b);
+
+ if (e == -1)
+ e = c.length;
+
+ return decodeURIComponent(c.substring(b + p.length, e));
+ },
+
+ set : function(n, v, e, p, d, s) {
+ document.cookie = n + "=" + encodeURIComponent(v) +
+ ((e) ? "; expires=" + e.toGMTString() : "") +
+ ((p) ? "; path=" + p : "") +
+ ((d) ? "; domain=" + d : "") +
+ ((s) ? "; secure" : "");
+ },
+
+ remove : function(n, p) {
+ var d = new Date();
+
+ d.setTime(d.getTime() - 1000);
+
+ this.set(n, '', d, p, d);
+ }
+};
+
+// Returns the value as string. Second arg or empty string is returned when value is not set.
+function getUserSetting( name, def ) {
+ var o = getAllUserSettings();
+
+ if ( o.hasOwnProperty(name) )
+ return o[name];
+
+ if ( typeof def != 'undefined' )
+ return def;
+
+ return '';
+}
+
+// Both name and value must be only ASCII letters, numbers or underscore
+// and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
+function setUserSetting( name, value, del ) {
+ var c = 'wp-settings-'+userSettings.uid, o = wpCookies.getHash(c) || {}, d = new Date();
+ var n = name.toString().replace(/[^A-Za-z0-9_]/, ''), v = value.toString().replace(/[^A-Za-z0-9_]/, '');
+
+ if ( del ) delete o[n];
+ else o[n] = v;
+
+ d.setTime( d.getTime() + 31536000000 );
+ p = userSettings.url;
+
+ wpCookies.setHash(c, o, d, p );
+ wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, d, p );
+}
+
+function deleteUserSetting( name ) {
+ setUserSetting( name, '', 1 );
+}
+
+// Returns all settings as js object.
+function getAllUserSettings() {
+ return wpCookies.getHash('wp-settings-'+userSettings.uid) || {};
+}
+
+
+jQuery(document).ready( function($) {
// pulse
- jQuery('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
+ $('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
- // Reveal
- jQuery('.wp-no-js-hidden').removeClass( 'wp-no-js-hidden' );
+ // show things that should be visible, hide what should be hidden
+ $('.hide-if-no-js').removeClass('hide-if-no-js');
+ $('.hide-if-js').hide();
// Basic form validation
- if ( ( 'undefined' != typeof wpAjax ) && jQuery.isFunction( wpAjax.validateForm ) ) {
- jQuery('form.validate').submit( function() { return wpAjax.validateForm( jQuery(this) ); } );
+ if ( ( 'undefined' != typeof wpAjax ) && $.isFunction( wpAjax.validateForm ) ) {
+ $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } );
}
+
+ // Move .updated and .error alert boxes
+ $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2');
+ $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first');
+
+ // screen settings tab
+ $('#show-settings-link').click(function () {
+ if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) {
+ $('#contextual-help-link-wrap').addClass('invisible');
+ }
+ $('#screen-options-wrap').slideToggle('fast', function(){
+ if ( $(this).hasClass('screen-options-open') ) {
+ $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
+ $('#contextual-help-link-wrap').removeClass('invisible');
+ $(this).removeClass('screen-options-open');
+
+ } else {
+ $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
+ $(this).addClass('screen-options-open');
+ }
+ });
+ return false;
+ });
+
+ // help tab
+ $('#contextual-help-link').click(function () {
+ if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') ) {
+ $('#screen-options-link-wrap').addClass('invisible');
+ }
+ $('#contextual-help-wrap').slideToggle('fast', function(){
+ if ( $(this).hasClass('contextual-help-open') ) {
+ $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right.gif")'});
+ $('#screen-options-link-wrap').removeClass('invisible');
+ $(this).removeClass('contextual-help-open');
+ } else {
+ $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'});
+ $(this).addClass('contextual-help-open');
+ }
+ });
+ return false;
+ });
+
+ // check all checkboxes
+ var lastClicked = false;
+ $( 'table:visible tbody .check-column :checkbox' ).click( function(e) {
+ if ( 'undefined' == e.shiftKey ) { return true; }
+ if ( e.shiftKey ) {
+ if ( !lastClicked ) { return true; }
+ var checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' );
+ var first = checks.index( lastClicked );
+ var last = checks.index( this );
+ var checked = $(this).attr('checked');
+ if ( 0 < first && 0 < last && first != last ) {
+ checks.slice( first, last ).attr( 'checked', function(){
+ if ( $(this).parents('tr').is(':visible') )
+ return checked ? 'checked' : '';
+
+ return '';
+ });
+ }
+ }
+ lastClicked = this;
+ return true;
+ } );
+ $( 'thead :checkbox, tfoot :checkbox' ).click( function(e) {
+ var c = $(this).attr('checked');
+ if ( 'undefined' == typeof toggleWithKeyboard)
+ toggleWithKeyboard = false;
+ var toggle = e.shiftKey || toggleWithKeyboard;
+ $(this).parents( 'form:first' ).find( 'table tbody:visible').find( '.check-column :checkbox' ).attr( 'checked', function() {
+ if ( $(this).parents('tr').is(':hidden') )
+ return '';
+ if ( toggle )
+ return $(this).attr( 'checked' ) ? '' : 'checked';
+ else if (c)
+ return 'checked';
+ return '';
+ });
+ $(this).parents( 'form:first' ).find( 'table thead:visible, table tfoot:visible').find( '.check-column :checkbox' ).attr( 'checked', function() {
+ if ( toggle )
+ return '';
+ else if (c)
+ return 'checked';
+ return '';
+ });
+ });
});
-(function(JQ) {
- JQ.fn.tTips = function() {
+var showNotice, adminMenu, columns;
- JQ('body').append('<div id="tTips"><p id="tTips_inside"></p></div>');
- var TT = JQ('#tTips');
+// stub for doing better warnings
+showNotice = {
+ warn : function(text) {
+ if ( confirm(text) )
+ return true;
- this.each(function() {
- var el = JQ(this), txt;
-
- if ( txt = el.attr('title') ) el.attr('tip', txt).removeAttr('title');
- else return;
- el.find('img').removeAttr('alt');
+ return false;
+ },
- el.mouseover(function(e) {
- txt = el.attr('tip'), o = el.offset();;
+ note : function(text) {
+ alert(text);
+ }
+};
+
+(function($){
+// sidebar admin menu
+adminMenu = {
- clearTimeout(TT.sD);
- TT.find('p').html(txt);
+ init : function() {
+ $('#adminmenu div.wp-menu-toggle').each( function() {
+ if ( $(this).siblings('.wp-submenu').length )
+ $(this).click(function(){ adminMenu.toggle( $(this).siblings('.wp-submenu') ); });
+ else
+ $(this).hide();
+ });
+ $('#adminmenu li.menu-top .wp-menu-image').click( function() { window.location = $(this).siblings('a.menu-top')[0].href; } );
+ this.favorites();
+
+ $('.wp-menu-separator').click(function(){
+ if ( $('#wpcontent').hasClass('folded') ) {
+ adminMenu.fold(1);
+ setUserSetting( 'mfold', 'o' );
+ } else {
+ adminMenu.fold();
+ setUserSetting( 'mfold', 'f' );
+ }
+ });
+
+ if ( 'f' != getUserSetting( 'mfold' ) ) {
+ this.restoreMenuState();
+ } else {
+ this.fold();
+ }
+ },
+
+ restoreMenuState : function() {
+ $('#adminmenu li.wp-has-submenu').each(function(i, e) {
+ var v = getUserSetting( 'm'+i );
+ if ( $(e).hasClass('wp-has-current-submenu') ) return true; // leave the current parent open
+
+ if ( 'o' == v ) $(e).addClass('wp-menu-open');
+ else if ( 'c' == v ) $(e).removeClass('wp-menu-open');
+ });
+ },
- TT.css({'top': o.top - 43, 'left': o.left - 5});
- TT.sD = setTimeout(function(){TT.fadeIn(150);}, 100);
+ toggle : function(el) {
+
+ el['slideToggle'](150, function(){el.css('display','');}).parent().toggleClass( 'wp-menu-open' );
+
+ $('#adminmenu li.wp-has-submenu').each(function(i, e) {
+ var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
+ setUserSetting( 'm'+i, v );
+ });
+
+ return false;
+ },
+
+ fold : function(off) {
+ if (off) {
+ $('#wpcontent').removeClass('folded');
+ $('#adminmenu li.wp-has-submenu').unbind();
+ } else {
+ $('#wpcontent').addClass('folded');
+ $('#adminmenu li.wp-has-submenu').hoverIntent({
+ over: function(e){
+ var m = $(this).find('.wp-submenu'), t = e.clientY, H = $(window).height(), h = m.height(), o;
+
+ if ( (t+h+10) > H ) {
+ o = (t+h+10) - H;
+ m.css({'marginTop':'-'+o+'px'});
+ } else if ( m.css('marginTop') ) {
+ m.css({'marginTop':''})
+ }
+ m.addClass('sub-open');
+ },
+ out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); },
+ timeout: 220,
+ sensitivity: 8,
+ interval: 100
});
- el.mouseout(function() {
- clearTimeout(TT.sD);
- TT.css({display : 'none'});
- })
+ }
+ },
+
+ favorites : function() {
+ $('#favorite-inside').width($('#favorite-actions').width()-4);
+ $('#favorite-toggle, #favorite-inside').bind( 'mouseenter', function(){$('#favorite-inside').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideDown') ) { $('#favorite-inside').slideDown(100); $('#favorite-first').addClass('slide-down'); }}, 200) } );
+
+ $('#favorite-toggle, #favorite-inside').bind( 'mouseleave', function(){$('#favorite-inside').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideUp') ) { $('#favorite-inside').slideUp(100, function(){ $('#favorite-first').removeClass('slide-down'); } ); }}, 300) } );
+ }
+};
+
+$(document).ready(function(){adminMenu.init();});
+})(jQuery);
+
+(function($){
+// show/hide/save table columns
+columns = {
+ init : function(page) {
+ $('.hide-column-tog').click( function() {
+ var column = $(this).val();
+ var show = $(this).attr('checked');
+ if ( show ) {
+ $('.column-' + column).show();
+ } else {
+ $('.column-' + column).hide();
+ }
+ columns.save_manage_columns_state(page);
+ } );
+ },
+
+ save_manage_columns_state : function(page) {
+ var hidden = $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(',');
+ $.post('admin-ajax.php', {
+ action: 'hidden-columns',
+ hidden: hidden,
+ hiddencolumnsnonce: $('#hiddencolumnsnonce').val(),
+ page: page
});
}
-}(jQuery));
+}
+
+})(jQuery);
+
-jQuery(function(){jQuery('#media-buttons a').tTips();});
+jQuery(document).ready(function($){
+ if ( 'undefined' != typeof google && google.gears ) return;
+
+ var gf = false;
+ if ( 'undefined' != typeof GearsFactory ) {
+ gf = new GearsFactory();
+ } else {
+ try {
+ gf = new ActiveXObject('Gears.Factory');
+ if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
+ gf.privateSetGlobalObject(this);
+ } catch (e) {
+ if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
+ gf = document.createElement("object");
+ gf.style.display = "none";
+ gf.width = 0;
+ gf.height = 0;
+ gf.type = "application/x-googlegears";
+ document.documentElement.appendChild(gf);
+ }
+ }
+ }
+ if ( gf && gf.hasPermission )
+ return;
+
+ $('.turbo-nag').show();
+});
--- /dev/null
+
+jQuery( function($) {
+
+// close postboxes that should be closed
+jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
+
+// These widgets are sometimes populated via ajax
+var ajaxWidgets = [
+ 'dashboard_incoming_links',
+ 'dashboard_primary',
+ 'dashboard_secondary',
+ 'dashboard_plugins'
+];
+
+var ajaxPopulateWidgets = function() {
+ $.each( ajaxWidgets, function() {
+ var e = jQuery('#' + this + ':visible div.inside').find('.widget-loading');
+ if ( e.size() ) { e.parent().load('index-extra.php?jax=' + this); }
+ } );
+};
+ajaxPopulateWidgets();
+
+postboxes.add_postbox_toggles('dashboard', { onShow: ajaxPopulateWidgets } );
+
+/* QuickPress */
+var quickPressLoad = function() {
+ var act = $('#quickpost-action');
+ var t = $('#quick-press').submit( function() {
+ $('#dashboard_quick_press h3').append( '<img src="images/loading.gif" style="margin: 0 6px 0 0; vertical-align: middle" />' );
+
+ if ( 'post' == act.val() ) {
+ act.val( 'post-quickpress-publish' );
+ }
+
+ $('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() {
+ $('#dashboard_quick_press h3 img').remove();
+ $('#dashboard_quick_press ul').find('li').each( function() {
+ $('#dashboard_recent_drafts ul').prepend( this );
+ } ).end().remove();
+ $(this).find('.hide-if-no-js').removeClass('hide-if-no-js');
+ tb_init('a.thickbox');
+ quickPressLoad();
+ } );
+ return false;
+ } );
+
+ $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
+
+};
+quickPressLoad();
+
+} );
var theList; var theExtraList;
-jQuery(function($) {
-
-var dimAfter = function( r, settings ) {
- $('li span.comment-count').each( function() {
- var a = $(this);
- var n = parseInt(a.html(),10);
- n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
- if ( n < 0 ) { n = 0; }
- a.html( n.toString() );
- $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
- });
- $('.post-com-count span.comment-count').each( function() {
- var a = $(this);
- var n = parseInt(a.html(),10);
- var t = parseInt(a.parent().attr('title'), 10);
- if ( $('#' + settings.element).is('.unapproved') ) { // we unapproved a formerly approved comment
- n = n - 1;
- t = t + 1;
- } else { // we approved a formerly unapproved comment
- n = n + 1;
- t = t - 1;
+(function($) {
+
+setCommentsList = function() {
+ var dimAfter = function( r, settings ) {
+ var c = $('#' + settings.element);
+
+ if ( c.is('.unapproved') )
+ c.find('div.comment_status').html('0')
+ else
+ c.find('div.comment_status').html('1')
+
+ $('span.pending-count').each( function() {
+ var a = $(this);
+ var n = a.html().replace(/[ ,.]+/g, '');
+ n = parseInt(n,10);
+ if ( isNaN(n) ) return;
+ n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
+ if ( n < 0 ) { n = 0; }
+ $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
+ n = n.toString();
+ if ( n.length > 3 )
+ n = n.substr(0, n.length-3)+' '+n.substr(-3);
+ a.html(n);
+ });
+ };
+
+ var delAfter = function( r, settings ) {
+ $('span.pending-count').each( function() {
+ var a = $(this);
+ var n = a.html().replace(/[ ,.]+/g, '');
+ n = parseInt(n,10);
+ if ( isNaN(n) ) return;
+ if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
+ n = n - 1;
+ } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
+ n = n + 1;
+ }
+ if ( n < 0 ) { n = 0; }
+ $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
+ n = n.toString();
+ if ( n.length > 3 )
+ n = n.substr(0, n.length-3)+' '+n.substr(-3);
+ a.html(n);
+ });
+
+ $('span.spam-count' ).each( function() {
+ var a = $(this);
+ var n = a.html().replace(/[ ,.]+/g, '');
+ n = parseInt(n,10);
+ if ( isNaN(n) ) return;
+ if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam
+ n = n + 1;
+ } else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam
+ n = n - 1;
+ }
+ if ( n < 0 ) { n = 0; }
+ n = n.toString();
+ if ( n.length > 3 )
+ n = n.substr(0, n.length-3)+' '+n.substr(-3);
+ a.html(n);
+ });
+
+ if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) {
+ return;
}
- if ( n < 0 ) { n = 0; }
- if ( t < 0 ) { t = 0; }
- if ( t >= 0 ) { a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); }
- if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
- a.html( n.toString() );
- });
-}
-
-var delAfter = function( r, settings ) {
- $('li span.comment-count').each( function() {
- var a = $(this);
- var n = parseInt(a.html(),10);
- if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
- n = n - 1;
- } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
- n = n + 1;
+
+ theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
+ $('#get-extra-comments').submit();
+ };
+
+ theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
+ theList = $('#the-comment-list').wpList( { alt: '', dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } );
+
+};
+
+$(document).ready(function(){
+ setCommentsList();
+});
+
+commentReply = {
+
+ init : function() {
+ var row = $('#replyrow');
+
+ $('a.cancel', row).click(function() { return commentReply.revert(); });
+ $('a.save', row).click(function() { return commentReply.send(this); });
+
+ // add events
+ $('#the-comment-list .column-comment > p').dblclick(function(){
+ commentReply.toggle($(this).parent());
+ });
+
+ $('#doaction, #doaction2, #post-query-submit').click(function(e){
+ if ( $('#the-comment-list #replyrow').length > 0 )
+ t.close();
+ });
+
+ },
+
+ addEvents : function(r) {
+ r.each(function() {
+ $(this).find('.column-comment > p').dblclick(function(){
+ commentReply.toggle($(this).parent());
+ });
+ });
+ },
+
+ toggle : function(el) {
+ if ( $(el).css('display') != 'none' )
+ $(el).find('a.vim-q').click();
+ },
+
+ revert : function() {
+
+ if ( $('#the-comment-list #replyrow').length < 1 )
+ return false;
+
+ $('#replyrow').fadeOut('fast', function(){
+ commentReply.close();
+ });
+
+ return false;
+ },
+
+ close : function() {
+ $(this.o).fadeIn('fast').css('backgroundColor', '');
+ $('#com-reply').append( $('#replyrow') );
+ $('#replycontent').val('');
+ $('#edithead input').val('');
+ $('#replysubmit .error').html('').hide();
+ $('#replysubmit .waiting').hide();
+ if ( $.browser.msie )
+ $('#replycontainer, #replycontent').css('height', '120px');
+ else
+ $('#replycontainer').resizable('destroy').css('height', '120px');
+ },
+
+ open : function(id, p, a) {
+ var t = this;
+ t.close();
+ t.o = '#comment-'+id;
+
+ $('#replyrow td').attr('colspan', $('.widefat thead th:visible').length);
+ var editRow = $('#replyrow'), rowData = $('#inline-'+id);
+ var act = t.act = (a == 'edit') ? 'edit-comment' : 'replyto-comment';
+
+ $('#action', editRow).val(act);
+ $('#comment_post_ID', editRow).val(p);
+ $('#comment_ID', editRow).val(id);
+
+ if ( a == 'edit' ) {
+ $('#author', editRow).val( $('div.author', rowData).text() );
+ $('#author-email', editRow).val( $('div.author-email', rowData).text() );
+ $('#author-url', editRow).val( $('div.author-url', rowData).text() );
+ $('#status', editRow).val( $('div.comment_status', rowData).text() );
+ $('#replycontent', editRow).val( $('textarea.comment', rowData).val() );
+ $('#edithead, #savebtn', editRow).show();
+ $('#replyhead, #replybtn', editRow).hide();
+
+ var h = $(t.o).height();
+ if ( h > 220 )
+ if ( $.browser.msie )
+ $('#replycontainer, #replycontent', editRow).height(h-105);
+ else
+ $('#replycontainer', editRow).height(h-105);
+
+ $(t.o).after(editRow.hide()).fadeOut('fast', function(){
+ $('#replyrow').fadeIn('fast');
+ });
+ } else {
+ $('#edithead, #savebtn', editRow).hide();
+ $('#replyhead, #replybtn', editRow).show();
+ $(t.o).after(editRow);
+ $('#replyrow').hide().fadeIn('fast');
}
- if ( n < 0 ) { n = 0; }
- a.html( n.toString() );
- $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
- });
- $('.post-com-count span.comment-count').each( function() {
- var a = $(this);
- if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
- var t = parseInt(a.parent().attr('title'), 10);
- if ( t < 1 ) { return; }
- t = t - 1;
- a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) );
- if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
- return;
+
+ if ( ! $.browser.msie )
+ $('#replycontainer').resizable({
+ handles : 's',
+ axis : 'y',
+ minHeight : 80,
+ stop : function() {
+ $('#replycontainer').width('auto');
+ }
+ });
+
+ setTimeout(function() {
+ var rtop = $('#replyrow').offset().top;
+ var rbottom = rtop + $('#replyrow').height();
+ var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
+ var vp = document.documentElement.clientHeight || self.innerHeight || 0;
+ var scrollBottom = scrollTop + vp;
+
+ if ( scrollBottom - 20 < rbottom )
+ window.scroll(0, rbottom - vp + 35);
+ else if ( rtop - 20 < scrollTop )
+ window.scroll(0, rtop - 35);
+
+ $('#replycontent').focus().keyup(function(e){
+ if (e.which == 27) commentReply.revert(); // close on Escape
+ });
+ }, 600);
+
+ return false;
+ },
+
+ send : function() {
+ var post = {};
+
+ $('#replysubmit .waiting').show();
+
+ $('#replyrow input').each(function() {
+ post[ $(this).attr('name') ] = $(this).val();
+ });
+
+ post.content = $('#replycontent').val();
+ post.id = post.comment_post_ID;
+
+ $.ajax({
+ type : 'POST',
+ url : wpListL10n.url,
+ data : post,
+ success : function(x) { commentReply.show(x); },
+ error : function(r) { commentReply.error(r); }
+ });
+
+ return false;
+ },
+
+ show : function(xml) {
+
+ if ( typeof(xml) == 'string' ) {
+ this.error({'responseText': xml});
+ return false;
+ }
+
+ var r = wpAjax.parseAjaxResponse(xml);
+ if ( r.errors ) {
+ this.error({'responseText': wpAjax.broken});
+ return false;
}
- var n = parseInt(a.html(),10) - 1;
- a.html( n.toString() );
- });
- if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) {
- return;
+ if ( 'edit-comment' == this.act )
+ $(this.o).remove();
+
+ r = r.responses[0];
+ var c = r.data;
+
+ $(c).hide()
+ $('#replyrow').after(c);
+ this.o = id = '#comment-'+r.id;
+ $(id+' .hide-if-no-js').removeClass('hide-if-no-js');
+ this.revert();
+ this.addEvents($(id));
+ var bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff';
+
+ $(id)
+ .animate( { 'backgroundColor':'#CCEEBB' }, 600 )
+ .animate( { 'backgroundColor': bg }, 600 );
+
+ $.fn.wpList.process($(id))
+ },
+
+ error : function(r) {
+ var er = r.statusText;
+
+ $('#replysubmit .waiting').hide();
+
+ if ( r.responseText )
+ er = r.responseText.replace( /<.[^<>]*?>/g, '' );
+
+ if ( er )
+ $('#replysubmit .error').html(er).show();
+
}
+};
+toggleWithKeyboard = false;
+$(document).ready(function(){
+ columns.init('edit-comments');
+ commentReply.init();
- theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
- $('#get-extra-comments').submit();
-}
+ if ( typeof QTags != 'undefined' )
+ ed_reply = new QTags('ed_reply', 'replycontent', 'replycontainer', 'more');
-theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
-theList = $('#the-comment-list').wpList( { alt: '', dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } );
+ if ( typeof $.table_hotkeys != 'undefined' ) {
+ var make_hotkeys_redirect = function(which) {
+ return function() {
+ var first_last = 'next' == which? 'first' : 'last';
+ var l=$('.'+which+'.page-numbers');
+ if (l.length)
+ window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1';
+ }
+ };
+ var edit_comment = function(event, current_row) {
+ window.location = $('span.edit a', current_row).attr('href');
+ };
+ var toggle_all = function() {
+ toggleWithKeyboard = true;
+ var master_checkbox = $('form#comments-form .check-column :checkbox:first');
+ master_checkbox.click().attr('checked', '');
+ toggleWithKeyboard = false;
+ }
+ var make_bulk = function(value) {
+ return function(event, _) {
+ $('option[value='+value+']').attr('selected', 'selected');
+ $('form#comments-form')[0].submit();
+ }
+ };
+ $.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', 'q', ['e', edit_comment],
+ ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')],
+ ['shift+d', make_bulk('delete')], ['shift+x', toggle_all],
+ ['shift+u', make_bulk('unapprove')]],
+ {highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
+ prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')}
+ );
+ }
+});
-} );
+})(jQuery);
-wpEditorInit = function() {
- // Activate tinyMCE if it's the user's default editor
- if ( ( 'undefined' == typeof wpTinyMCEConfig ) || 'tinymce' == wpTinyMCEConfig.defaultEditor ) {
- document.getElementById('editorcontainer').style.padding = '0px';
- tinyMCE.execCommand("mceAddControl", false, "content");
- } else {
- var H;
- if ( H = tinymce.util.Cookie.getHash("TinyMCE_content_size") )
- document.getElementById('content').style.height = H.ch - 30 + 'px';
- }
-};
-switchEditors = {
+var switchEditors = {
+
+ mode : '',
+
+ I : function(e) {
+ return document.getElementById(e);
+ },
- saveCallback : function(el, content, body) {
+ edInit : function() {
+ var h = tinymce.util.Cookie.getHash("TinyMCE_content_size"), H = this.I('edButtonHTML'), P = this.I('edButtonPreview');
- document.getElementById(el).style.color = '#fff';
- if ( tinyMCE.activeEditor.isHidden() )
- content = document.getElementById(el).value;
- else
- content = this.pre_wpautop(content);
+ // Activate TinyMCE if it's the user's default editor
+ if ( getUserSetting( 'editor' ) == 'html' ) {
+ if ( h )
+ try { this.I('content').style.height = h.ch - 30 + 'px'; } catch(e){};
+ } else {
+ try {
+ this.I("quicktags").style.display = "none";
+ } catch(e){};
+ tinyMCE.execCommand("mceAddControl", false, "content");
+ }
+ },
- return content;
- },
+ saveCallback : function(el, content, body) {
- pre_wpautop : function(content) {
- // We have a TON of cleanup to do. Line breaks are already stripped.
+ if ( tinyMCE.activeEditor.isHidden() )
+ content = this.I(el).value;
+ else
+ content = this.pre_wpautop(content);
- // Protect pre|script tags
- content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
- a = a.replace(/<br ?\/?>[\r\n]*/g, '<wp_temp>');
- return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '<wp_temp>');
- });
+ return content;
+ },
- // Pretty it up for the source editor
- var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p';
- content = content.replace(new RegExp('\\s*</('+blocklist1+')>\\s*', 'mg'), '</$1>\n');
- content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>');
+ pre_wpautop : function(content) {
+ // We have a TON of cleanup to do. Line breaks are already stripped.
- // Mark </p> if it has any attributes.
- content = content.replace(new RegExp('(<p [^>]+>.*?)</p>', 'mg'), '$1</p#>');
+ // Protect pre|script tags
+ content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
+ a = a.replace(/<br ?\/?>[\r\n]*/g, '<wp_temp>');
+ return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '<wp_temp>');
+ });
- // Sepatate <div> containing <p>
- content = content.replace(new RegExp('<div([^>]*)>\\s*<p>', 'mgi'), '<div$1>\n\n');
+ // Pretty it up for the source editor
+ var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p';
+ content = content.replace(new RegExp('\\s*</('+blocklist1+')>\\s*', 'mg'), '</$1>\n');
+ content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>');
- // Remove <p> and <br />
- content = content.replace(new RegExp('\\s*<p>', 'mgi'), '');
- content = content.replace(new RegExp('\\s*</p>\\s*', 'mgi'), '\n\n');
- content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n');
- content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
+ // Mark </p> if it has any attributes.
+ content = content.replace(new RegExp('(<p [^>]+>.*?)</p>', 'mg'), '$1</p#>');
- // Fix some block element newline issues
- content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
- content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n');
+ // Sepatate <div> containing <p>
+ content = content.replace(new RegExp('<div([^>]*)>\\s*<p>', 'mgi'), '<div$1>\n\n');
+
+ // Remove <p> and <br />
+ content = content.replace(new RegExp('\\s*<p>', 'mgi'), '');
+ content = content.replace(new RegExp('\\s*</p>\\s*', 'mgi'), '\n\n');
+ content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n');
+ content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
+
+ // Fix some block element newline issues
+ content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
+ content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n');
content = content.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n');
content = content.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption');
- var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre';
- content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
- content = content.replace(new RegExp('\\s*</('+blocklist2+')>\\s*', 'mg'), '</$1>\n');
- content = content.replace(new RegExp('<li([^>]*)>', 'g'), '\t<li$1>');
-
- if ( content.indexOf('<object') != -1 ) {
- content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'mg'), "<param$1>");
- content = content.replace(new RegExp('\\s*</embed>\\s*', 'mg'), '</embed>');
- }
-
- // Unmark special paragraph closing tags
- content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
- content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', 'mg'), '\n$1');
-
- // Trim whitespace
- content = content.replace(new RegExp('^\\s*', ''), '');
- content = content.replace(new RegExp('[\\s\\u00a0]*$', ''), '');
-
- // put back the line breaks in pre|script
- content = content.replace(/<wp_temp>/g, '\n');
-
- // Hope.
- return content;
- },
-
- go : function(id) {
- var ed = tinyMCE.get(id);
- var qt = document.getElementById('quicktags');
- var H = document.getElementById('edButtonHTML');
- var P = document.getElementById('edButtonPreview');
- var ta = document.getElementById(id);
- var ec = document.getElementById('editorcontainer');
-
- if ( ! ed || ed.isHidden() ) {
- ta.style.color = '#fff';
-
- this.edToggle(P, H);
- edCloseAllTags(); // :-(
-
- qt.style.display = 'none';
- ec.style.padding = '0px';
- ta.style.padding = '0px';
-
- ta.value = this.wpautop(ta.value);
-
- if ( ed ) ed.show();
- else tinyMCE.execCommand("mceAddControl", false, id);
-
- this.wpSetDefaultEditor('tinymce');
- } else {
- this.edToggle(H, P);
- ta.style.height = ed.getContentAreaContainer().offsetHeight + 6 + 'px';
-
- ed.hide();
- qt.style.display = 'block';
-
- if ( tinymce.isIE6 ) {
- ta.style.width = '98%';
- ec.style.padding = '0px';
- ta.style.padding = '6px';
- } else {
- ta.style.width = '100%';
- ec.style.padding = '6px';
- }
-
- ta.style.color = '';
- this.wpSetDefaultEditor('html');
- }
- },
-
- edToggle : function(A, B) {
- A.className = 'active';
- B.className = '';
-
- B.onclick = A.onclick;
- A.onclick = null;
- },
-
- wpSetDefaultEditor : function(editor) {
- try {
- editor = escape( editor.toString() );
- } catch(err) {
- editor = 'tinymce';
- }
-
- var userID = document.getElementById('user-id');
- var date = new Date();
- date.setTime(date.getTime()+(10*365*24*60*60*1000));
- document.cookie = "wordpress_editor_" + userID.value + "=" + editor + "; expires=" + date.toGMTString();
- },
-
- wpautop : function(pee) {
- var blocklist = 'table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]';
-
- pee = pee + "\n\n";
- pee = pee.replace(new RegExp('<br />\\s*<br />', 'gi'), "\n\n");
- pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1");
- pee = pee.replace(new RegExp('(</(?:'+blocklist+')>)', 'gi'), "$1\n\n");
- pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n");
- pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n");
- pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "<p>$1</p>\n");
- pee = pee.replace(new RegExp('<p>\\s*?</p>', 'gi'), '');
- pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
- pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
- pee = pee.replace(new RegExp('<p>\\s*<blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");
- pee = pee.replace(new RegExp('</blockquote>\\s*</p>', 'gi'), '</p></blockquote>');
- pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)', 'gi'), "$1");
- pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
- pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
- pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
- pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
- pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[caption$1[/caption]');
- // pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 ');
-
- // Fix the pre|script tags
- pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
+ var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre';
+ content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
+ content = content.replace(new RegExp('\\s*</('+blocklist2+')>\\s*', 'mg'), '</$1>\n');
+ content = content.replace(new RegExp('<li([^>]*)>', 'g'), '\t<li$1>');
+
+ if ( content.indexOf('<object') != -1 ) {
+ content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'mg'), "<param$1>");
+ content = content.replace(new RegExp('\\s*</embed>\\s*', 'mg'), '</embed>');
+ }
+
+ // Unmark special paragraph closing tags
+ content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
+ content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', 'mg'), '\n$1');
+
+ // Trim whitespace
+ content = content.replace(new RegExp('^\\s*', ''), '');
+ content = content.replace(new RegExp('[\\s\\u00a0]*$', ''), '');
+
+ // put back the line breaks in pre|script
+ content = content.replace(/<wp_temp>/g, '\n');
+
+ // Hope.
+ return content;
+ },
+
+ go : function(id, mode) {
+ id = id || 'content';
+ mode = mode || this.mode || '';
+
+ var ed = tinyMCE.get(id) || false;
+ var qt = this.I('quicktags');
+ var H = this.I('edButtonHTML');
+ var P = this.I('edButtonPreview');
+ var ta = this.I(id);
+
+ if ( 'tinymce' == mode ) {
+
+ if ( ed && ! ed.isHidden() )
+ return false;
+
+ this.mode = 'html';
+ ta.style.color = '#fff';
+
+ P.className = 'active';
+ H.className = '';
+ edCloseAllTags(); // :-(
+
+ qt.style.display = 'none';
+
+ ta.value = this.wpautop(ta.value);
+
+ if ( ed ) ed.show();
+ else tinyMCE.execCommand("mceAddControl", false, id);
+
+ setUserSetting( 'editor', 'tinymce' );
+ } else {
+ if ( ! ed || ed.isHidden() )
+ return false;
+
+ this.mode = 'tinymce';
+ H.className = 'active';
+ P.className = '';
+
+ ta.style.height = ed.getContentAreaContainer().offsetHeight + 6 + 'px';
+
+ ed.hide();
+ qt.style.display = 'block';
+
+ ta.style.color = '';
+ setUserSetting( 'editor', 'html' );
+ }
+ return false;
+ },
+
+ wpautop : function(pee) {
+ var blocklist = 'table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]';
+
+ pee = pee + "\n\n";
+ pee = pee.replace(new RegExp('<br />\\s*<br />', 'gi'), "\n\n");
+ pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1");
+ pee = pee.replace(new RegExp('(</(?:'+blocklist+')>)', 'gi'), "$1\n\n");
+ pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n");
+ pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n");
+ pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "<p>$1</p>\n");
+ pee = pee.replace(new RegExp('<p>\\s*?</p>', 'gi'), '');
+ pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
+ pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
+ pee = pee.replace(new RegExp('<p>\\s*<blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");
+ pee = pee.replace(new RegExp('</blockquote>\\s*</p>', 'gi'), '</p></blockquote>');
+ pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)', 'gi'), "$1");
+ pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
+ pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
+ pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
+ pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
+ pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[caption$1[/caption]');
+ // pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 ');
+
+ // Fix the pre|script tags
+ pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
a = a.replace(/<br ?\/?>[\r\n]*/g, '\n');
return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n');
- });
+ });
- return pee;
- }
-}
+ return pee;
+ }
+};
--- /dev/null
+// $Id: farbtastic.js,v 1.2 2007/01/08 22:53:01 unconed Exp $
+// Farbtastic 1.2
+
+var farbtastic_click = false;
+
+jQuery.fn.farbtastic = function (callback) {
+ jQuery.farbtastic(this, callback);
+ return this;
+};
+
+jQuery.farbtastic = function (container, callback) {
+ var container = jQuery(container).get(0);
+ return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback));
+}
+
+jQuery._farbtastic = function (container, callback) {
+ // Store farbtastic object
+ var fb = this;
+
+ // Insert markup
+ jQuery(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');
+ var e = jQuery('.farbtastic', container);
+ fb.wheel = jQuery('.wheel', container).get(0);
+ // Dimensions
+ fb.radius = 84;
+ fb.square = 100;
+ fb.width = 194;
+
+ // Fix background PNGs in IE6
+ if (navigator.appVersion.match(/MSIE [0-6]\./)) {
+ jQuery('*', e).each(function () {
+ if (this.currentStyle.backgroundImage != 'none') {
+ var image = this.currentStyle.backgroundImage;
+ image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
+ jQuery(this).css({
+ 'backgroundImage': 'none',
+ 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
+ });
+ }
+ });
+ }
+
+ /**
+ * Link to the given element(s) or callback.
+ */
+ fb.linkTo = function (callback) {
+ // Unbind previous nodes
+ if (typeof fb.callback == 'object') {
+ jQuery(fb.callback).unbind('keyup', fb.updateValue);
+ }
+
+ // Reset color
+ fb.color = null;
+
+ // Bind callback or elements
+ if (typeof callback == 'function') {
+ fb.callback = callback;
+ }
+ else if (typeof callback == 'object' || typeof callback == 'string') {
+ fb.callback = jQuery(callback);
+ fb.callback.bind('keyup', fb.updateValue);
+ if (fb.callback.get(0).value) {
+ fb.setColor(fb.callback.get(0).value);
+ }
+ }
+ return this;
+ }
+ fb.updateValue = function (event) {
+ if (this.value && this.value != fb.color) {
+ fb.setColor(this.value);
+ }
+ }
+
+ /**
+ * Change color with HTML syntax #123456
+ */
+ fb.setColor = function (color) {
+ var unpack = fb.unpack(color);
+ if (fb.color != color && unpack) {
+ fb.color = color;
+ fb.rgb = unpack;
+ fb.hsl = fb.RGBToHSL(fb.rgb);
+ fb.updateDisplay();
+ }
+ return this;
+ }
+
+ /**
+ * Change color with HSL triplet [0..1, 0..1, 0..1]
+ */
+ fb.setHSL = function (hsl) {
+ fb.hsl = hsl;
+ fb.rgb = fb.HSLToRGB(hsl);
+ fb.color = fb.pack(fb.rgb);
+ fb.updateDisplay();
+ return this;
+ }
+
+ /////////////////////////////////////////////////////
+
+ /**
+ * Retrieve the coordinates of the given event relative to the center
+ * of the widget.
+ */
+ fb.widgetCoords = function (event) {
+ var x, y;
+ var el = event.target || event.srcElement;
+ var reference = fb.wheel;
+
+ if (typeof event.offsetX != 'undefined') {
+ // Use offset coordinates and find common offsetParent
+ var pos = { x: event.offsetX, y: event.offsetY };
+
+ // Send the coordinates upwards through the offsetParent chain.
+ var e = el;
+ while (e) {
+ e.mouseX = pos.x;
+ e.mouseY = pos.y;
+ pos.x += e.offsetLeft;
+ pos.y += e.offsetTop;
+ e = e.offsetParent;
+ }
+
+ // Look for the coordinates starting from the wheel widget.
+ var e = reference;
+ var offset = { x: 0, y: 0 }
+ while (e) {
+ if (typeof e.mouseX != 'undefined') {
+ x = e.mouseX - offset.x;
+ y = e.mouseY - offset.y;
+ break;
+ }
+ offset.x += e.offsetLeft;
+ offset.y += e.offsetTop;
+ e = e.offsetParent;
+ }
+
+ // Reset stored coordinates
+ e = el;
+ while (e) {
+ e.mouseX = undefined;
+ e.mouseY = undefined;
+ e = e.offsetParent;
+ }
+ }
+ else {
+ // Use absolute coordinates
+ var pos = fb.absolutePosition(reference);
+ x = (event.pageX || 0*(event.clientX + jQuery('html').get(0).scrollLeft)) - pos.x;
+ y = (event.pageY || 0*(event.clientY + jQuery('html').get(0).scrollTop)) - pos.y;
+ }
+ // Subtract distance to middle
+ return { x: x - fb.width / 2, y: y - fb.width / 2 };
+ }
+
+ /**
+ * Mousedown handler
+ */
+ fb.mousedown = function (event) {
+ farbtastic_click = true;
+ // Capture mouse
+ if (!document.dragging) {
+ jQuery(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
+ document.dragging = true;
+ }
+
+ // Check which area is being dragged
+ var pos = fb.widgetCoords(event);
+ fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;
+
+ // Process
+ fb.mousemove(event);
+ return false;
+ }
+
+ /**
+ * Mousemove handler
+ */
+ fb.mousemove = function (event) {
+ // Get coordinates relative to color picker center
+ var pos = fb.widgetCoords(event);
+
+ // Set new HSL parameters
+ if (fb.circleDrag) {
+ var hue = Math.atan2(pos.x, -pos.y) / 6.28;
+ if (hue < 0) hue += 1;
+ fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
+ }
+ else {
+ var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
+ var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
+ fb.setHSL([fb.hsl[0], sat, lum]);
+ }
+ return false;
+ }
+
+ /**
+ * Mouseup handler
+ */
+ fb.mouseup = function () {
+ // Uncapture mouse
+ farbtastic_click = false;
+ jQuery(document).unbind('mousemove', fb.mousemove);
+ jQuery(document).unbind('mouseup', fb.mouseup);
+ document.dragging = false;
+ }
+
+ /**
+ * Update the markers and styles
+ */
+ fb.updateDisplay = function () {
+ // Markers
+ var angle = fb.hsl[0] * 6.28;
+ jQuery('.h-marker', e).css({
+ left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
+ top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
+ });
+
+ jQuery('.sl-marker', e).css({
+ left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
+ top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
+ });
+
+ // Saturation/Luminance gradient
+ jQuery('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));
+
+ // Linked elements or callback
+ if (typeof fb.callback == 'object') {
+ // Set background/foreground color
+ jQuery(fb.callback).css({
+ backgroundColor: fb.color,
+ color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
+ });
+
+ // Change linked value
+ jQuery(fb.callback).each(function() {
+ if (this.value && this.value != fb.color) {
+ this.value = fb.color;
+ }
+ });
+ }
+ else if (typeof fb.callback == 'function') {
+ fb.callback.call(fb, fb.color);
+ }
+ }
+
+ /**
+ * Get absolute position of element
+ */
+ fb.absolutePosition = function (el) {
+ var r = { x: el.offsetLeft, y: el.offsetTop };
+ // Resolve relative to offsetParent
+ if (el.offsetParent) {
+ var tmp = fb.absolutePosition(el.offsetParent);
+ r.x += tmp.x;
+ r.y += tmp.y;
+ }
+ return r;
+ };
+
+ /* Various color utility functions */
+ fb.pack = function (rgb) {
+ var r = Math.round(rgb[0] * 255);
+ var g = Math.round(rgb[1] * 255);
+ var b = Math.round(rgb[2] * 255);
+ return '#' + (r < 16 ? '0' : '') + r.toString(16) +
+ (g < 16 ? '0' : '') + g.toString(16) +
+ (b < 16 ? '0' : '') + b.toString(16);
+ }
+
+ fb.unpack = function (color) {
+ if (color.length == 7) {
+ return [parseInt('0x' + color.substring(1, 3)) / 255,
+ parseInt('0x' + color.substring(3, 5)) / 255,
+ parseInt('0x' + color.substring(5, 7)) / 255];
+ }
+ else if (color.length == 4) {
+ return [parseInt('0x' + color.substring(1, 2)) / 15,
+ parseInt('0x' + color.substring(2, 3)) / 15,
+ parseInt('0x' + color.substring(3, 4)) / 15];
+ }
+ }
+
+ fb.HSLToRGB = function (hsl) {
+ var m1, m2, r, g, b;
+ var h = hsl[0], s = hsl[1], l = hsl[2];
+ m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
+ m1 = l * 2 - m2;
+ return [this.hueToRGB(m1, m2, h+0.33333),
+ this.hueToRGB(m1, m2, h),
+ this.hueToRGB(m1, m2, h-0.33333)];
+ }
+
+ fb.hueToRGB = function (m1, m2, h) {
+ h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
+ if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
+ if (h * 2 < 1) return m2;
+ if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
+ return m1;
+ }
+
+ fb.RGBToHSL = function (rgb) {
+ var min, max, delta, h, s, l;
+ var r = rgb[0], g = rgb[1], b = rgb[2];
+ min = Math.min(r, Math.min(g, b));
+ max = Math.max(r, Math.max(g, b));
+ delta = max - min;
+ l = (min + max) / 2;
+ s = 0;
+ if (l > 0 && l < 1) {
+ s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
+ }
+ h = 0;
+ if (delta > 0) {
+ if (max == r && max != g) h += (g - b) / delta;
+ if (max == g && max != b) h += (2 + (b - r) / delta);
+ if (max == b && max != r) h += (4 + (r - g) / delta);
+ h /= 6;
+ }
+ return [h, s, l];
+ }
+
+ // Install mousedown handler (the others are set on the document on-demand)
+ jQuery('*', e).mousedown(fb.mousedown);
+
+ // Init color
+ fb.setColor('#000000');
+
+ // Set linked elements/callback
+ if (callback) {
+ fb.linkTo(callback);
+ }
+}
\ No newline at end of file
+++ /dev/null
-function checkAll(jQ) { // use attr( checked, fn )
- jQuery(jQ).find( 'tbody:visible :checkbox' ).attr( 'checked', function() {
- return jQuery(this).attr( 'checked' ) ? '' : 'checked';
- } );
-}
-
-jQuery( function($) {
- var lastClicked = false;
- $( 'tbody :checkbox' ).click( function(e) {
- if ( 'undefined' == e.shiftKey ) { return true; }
- if ( e.shiftKey ) {
- if ( !lastClicked ) { return true; }
- var checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' );
- var first = checks.index( lastClicked );
- var last = checks.index( this );
- if ( 0 < first && 0 < last && first != last ) {
- checks.slice( first, last ).attr( 'checked', $( this ).is( ':checked' ) ? 'checked' : '' );
- }
- }
- lastClicked = this;
- return true;
- } );
- $( 'thead :checkbox' ).click( function() {
- checkAll( $(this).parents( 'form:first' ) );
- } );
-} );
\ No newline at end of file
$('.menu_order_input').each(function(){
if ( this.value == '0' ) this.value = '';
});
+
+ if ( $('#media-items>*').length > 1 ) {
+ var w = wpgallery.getWin();
+
+ $('#save-all, #gallery-settings').show();
+ if ( typeof w.tinyMCE != 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) {
+ wpgallery.mcemode = true;
+ wpgallery.init();
+ } else {
+ $('#insert-gallery').show();
+ }
+ }
});
+
+jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup
+
+/* gallery settings */
+var tinymce = null, tinyMCE;
+
+var wpgallery = {
+ mcemode : false,
+ editor : {},
+ dom : {},
+ is_update : false,
+ el : {},
+
+ I : function(e) {
+ return document.getElementById(e);
+ },
+
+ init: function() {
+ var t = this, li, q, i, it, w = t.getWin();
+
+ if ( ! t.mcemode ) return;
+
+ li = ('' + document.location.search).replace(/^\?/, '').split('&');
+ q = {};
+ for (i=0; i<li.length; i++) {
+ it = li[i].split('=');
+ q[unescape(it[0])] = unescape(it[1]);
+ }
+
+ if (q.mce_rdomain)
+ document.domain = q.mce_rdomain;
+
+ // Find window & API
+ tinymce = w.tinymce;
+ tinyMCE = w.tinyMCE;
+ t.editor = tinymce.EditorManager.activeEditor;
+
+ t.setup();
+ },
+
+ getWin : function() {
+ return window.dialogArguments || opener || parent || top;
+ },
+
+ restoreSelection : function() {
+ var t = this;
+
+ if (tinymce.isIE)
+ t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
+ },
+
+ setup : function() {
+ var t = this, a, f = document.forms[0], ed = t.editor, el, g;
+ if ( ! t.mcemode ) return;
+
+ t.restoreSelection();
+ t.el = ed.selection.getNode();
+
+ if ( t.el.nodeName != 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
+ if ( (g = ed.dom.select('img.wpGallery')) && g[0] ) {
+ t.el = g[0];
+ } else {
+ if ( getUserSetting('galfile') == '1' ) t.I('linkto-file').checked = "checked";
+ if ( getUserSetting('galdesc') == '1' ) t.I('order-desc').checked = "checked";
+ if ( getUserSetting('galcols') ) t.I('columns').value = getUserSetting('galcols');
+ if ( getUserSetting('galord') ) t.I('orderby').value = getUserSetting('galord');
+ jQuery('#insert-gallery').show();
+ return;
+ }
+ }
+
+ a = ed.dom.getAttrib(t.el, 'title');
+ a = ed.dom.decode(a);
+
+ if ( a ) {
+ jQuery('#update-gallery').show();
+ t.is_update = true;
+
+ var columns = a.match(/columns=['"]([0-9]+)['"]/), link = a.match(/link=['"]([^'"]+)['"]/i);
+ var order = a.match(/order=['"]([^'"]+)['"]/i), orderby = a.match(/orderby=['"]([^'"]+)['"]/i), all = '';
+
+ if ( link && link[1] ) t.I('linkto-file').checked = "checked";
+ if ( order && order[1] ) t.I('order-desc').checked = "checked";
+ if ( columns && columns[1] ) t.I('columns').value = ''+columns[1];
+ if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1];
+ } else {
+ jQuery('#insert-gallery').show();
+ }
+ },
+
+ update : function() {
+ var t = this, ed = t.editor, el, all = '';
+
+ if ( ! t.mcemode || ! t.is_update ) {
+ var s = '[gallery'+t.getSettings()+']';
+ t.getWin().send_to_editor(s);
+ return;
+ }
+
+ if (t.el.nodeName != 'IMG') return;
+
+ all = ed.dom.decode(ed.dom.getAttrib(t.el, 'title'));
+ all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
+ all += t.getSettings();
+
+ ed.dom.setAttrib(t.el, 'title', all);
+ t.getWin().tb_remove();
+ },
+
+ getSettings : function() {
+ var I = this.I, s = '';
+
+ if ( I('linkto-file').checked ) {
+ s += ' link="file"';
+ setUserSetting('galfile', '1');
+ }
+
+ if ( I('order-desc').checked ) {
+ s += ' order="DESC"';
+ setUserSetting('galdesc', '1');
+ }
+
+ if ( I('columns').value != 3 ) {
+ s += ' columns="'+I('columns').value+'"';
+ setUserSetting('galcols', I('columns').value);
+ }
+
+ if ( I('orderby').value != 'menu_order' ) {
+ s += ' orderby="'+I('orderby').value+'"';
+ setUserSetting('galord', I('orderby').value);
+ }
+
+ return s;
+ }
+};
--- /dev/null
+
+(function($) {
+inlineEditPost = {
+
+ init : function() {
+ var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
+
+ t.type = $('table.widefat').hasClass('page') ? 'page' : 'post';
+ t.what = '#'+t.type+'-';
+
+ // get all editable rows
+ t.rows = $('tr.iedit');
+
+ // prepare the edit rows
+ qeRow.keyup(function(e) { if(e.which == 27) return inlineEditPost.revert(); });
+ bulkRow.keyup(function(e) { if (e.which == 27) return inlineEditPost.revert(); });
+
+ $('a.cancel', qeRow).click(function() { return inlineEditPost.revert(); });
+ $('a.save', qeRow).click(function() { return inlineEditPost.save(this); });
+ $('input, select', qeRow).keydown(function(e) { if(e.which == 13) return inlineEditPost.save(this); });
+
+ $('a.cancel', bulkRow).click(function() { return inlineEditPost.revert(); });
+
+ $('#inline-edit .inline-edit-private input[value=private]').click( function(){
+ var pw = $('input.inline-edit-password-input');
+ if ( $(this).attr('checked') ) {
+ pw.val('').attr('disabled', 'disabled');
+ } else {
+ pw.attr('disabled', '');
+ }
+ });
+
+ // add events
+ t.addEvents(t.rows);
+
+ $('#bulk-title-div').parents('fieldset').after(
+ $('#inline-edit fieldset.inline-edit-categories').clone()
+ ).siblings( 'fieldset:last' ).prepend(
+// ).siblings( 'fieldset:last' ).after( '<fieldset class="inline-edit-col-bottom"><div class="inline-edit-col"></div></fieldset>' );
+// $('fieldset.inline-edit-col-bottom').prepend(
+ $('#inline-edit label.inline-edit-tags').clone()
+ );
+
+ // categories expandable?
+ $('span.catshow').click(function() {
+ $('.inline-editor ul.cat-checklist').addClass("cat-hover");
+ $('.inline-editor span.cathide').show();
+ $(this).hide();
+ });
+
+ $('span.cathide').click(function() {
+ $('.inline-editor ul.cat-checklist').removeClass("cat-hover");
+ $('.inline-editor span.catshow').show();
+ $(this).hide();
+ });
+
+ $('select[name="_status"] option[value="future"]', bulkRow).remove();
+
+ $('#doaction, #doaction2').click(function(e){
+ var n = $(this).attr('id').substr(2);
+ if ( $('select[name="'+n+'"]').val() == 'edit' ) {
+ e.preventDefault();
+ t.setBulk();
+ } else if ( $('form#posts-filter tr.inline-editor').length > 0 ) {
+ t.revert();
+ }
+ });
+
+ $('#post-query-submit').click(function(e){
+ if ( $('form#posts-filter tr.inline-editor').length > 0 )
+ t.revert();
+ });
+
+ },
+
+ toggle : function(el) {
+ var t = this;
+
+ $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
+ },
+
+ addEvents : function(r) {
+ r.each(function() {
+ var row = $(this);
+ $('a.editinline', row).click(function() { inlineEditPost.edit(this); return false; });
+ });
+ },
+
+ setBulk : function() {
+ var te = '', c = '', type = this.type;
+ this.revert();
+
+ $('#bulk-edit td').attr('colspan', $('.widefat:first thead th:visible').length);
+ $('table.widefat tbody').prepend( $('#bulk-edit') );
+ $('#bulk-edit').addClass('inline-editor').show();
+
+ $('tbody th.check-column input[type="checkbox"]').each(function(i){
+ if ( $(this).attr('checked') ) {
+ var id = $(this).val();
+ var theTitle = $('#inline_'+id+' .post_title').text() || inlineEditL10n.notitle;
+ te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>';
+ }
+ });
+
+ $('#bulk-titles').html(te);
+ $('#bulk-titles a').click(function() {
+ var id = $(this).attr('id').substr(1), r = inlineEditPost.type+'-'+id;
+
+ $('table.widefat input[value="'+id+'"]').attr('checked', '');
+ $('#ttle'+id).remove();
+ });
+
+ // enable autocomplete for tags
+ if ( type == 'post' )
+ $('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
+ },
+
+ edit : function(id) {
+ var t = this;
+ t.revert();
+
+ if ( typeof(id) == 'object' )
+ id = t.getId(id);
+
+ var fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password'];
+ if ( t.type == 'page' ) fields.push('post_parent', 'menu_order', 'page_template');
+ if ( t.type == 'post' ) fields.push('tags_input');
+
+ // add the new blank row
+ var editRow = $('#inline-edit').clone(true);
+ $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
+
+ if ( $(t.what+id).hasClass('alternate') )
+ $(editRow).addClass('alternate');
+ $(t.what+id).hide().after(editRow);
+
+ // populate the data
+ var rowData = $('#inline_'+id);
+ for ( var f = 0; f < fields.length; f++ ) {
+ $(':input[name="'+fields[f]+'"]', editRow).val( $('.'+fields[f], rowData).text() );
+ }
+
+ if ( $('.comment_status', rowData).text() == 'open' )
+ $('input[name="comment_status"]', editRow).attr("checked", "checked");
+ if ( $('.ping_status', rowData).text() == 'open' )
+ $('input[name="ping_status"]', editRow).attr("checked", "checked");
+ if ( $('.sticky', rowData).text() == 'sticky' )
+ $('input[name="sticky"]', editRow).attr("checked", "checked");
+
+ // categories
+ var cats;
+ if ( cats = $('.post_category', rowData).text() )
+ $('ul.cat-checklist :checkbox', editRow).val(cats.split(','));
+
+ // handle the post status
+ var status = $('._status', rowData).text();
+ if ( status != 'future' ) $('select[name="_status"] option[value="future"]', editRow).remove();
+ if ( status == 'private' ) {
+ $('input[name="keep_private"]', editRow).attr("checked", "checked");
+ $('input.inline-edit-password-input').val('').attr('disabled', 'disabled');
+ }
+
+ // remove the current page and children from the parent dropdown
+ var pageOpt = $('select[name="post_parent"] option[value="'+id+'"]', editRow);
+ if ( pageOpt.length > 0 ) {
+ var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true;
+ while ( pageLoop ) {
+ var nextPage = nextPage.next('option');
+ if (nextPage.length == 0) break;
+ var nextLevel = nextPage[0].className.split('-')[1];
+ if ( nextLevel <= pageLevel ) {
+ pageLoop = false;
+ } else {
+ nextPage.remove();
+ nextPage = pageOpt;
+ }
+ }
+ pageOpt.remove();
+ }
+
+ $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
+ $('.ptitle', editRow).focus();
+
+ // enable autocomplete for tags
+ if ( t.type == 'post' )
+ $('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
+
+ return false;
+ },
+
+ save : function(id) {
+ if( typeof(id) == 'object' )
+ id = this.getId(id);
+
+ $('table.widefat .inline-edit-save .waiting').show();
+
+ var params = {
+ action: 'inline-save',
+ post_type: this.type,
+ post_ID: id,
+ edit_date: 'true'
+ };
+
+ var fields = $('#edit-'+id+' :input').fieldSerialize();
+ params = fields + '&' + $.param(params);
+
+ // make ajax request
+ $.post('admin-ajax.php', params,
+ function(r) {
+ $('table.widefat .inline-edit-save .waiting').hide();
+
+ if (r) {
+ if ( -1 != r.indexOf('<tr') ) {
+ $(inlineEditPost.what+id).remove();
+ $('#edit-'+id).before(r).remove();
+
+ var row = $(inlineEditPost.what+id);
+ row.hide();
+
+ if ( 'draft' == $('input[name="post_status"]').val() )
+ row.find('td.column-comments').hide();
+
+ row.find('.hide-if-no-js').removeClass('hide-if-no-js');
+ inlineEditPost.addEvents(row);
+ row.fadeIn();
+ } else {
+ r = r.replace( /<.[^<>]*?>/g, '' );
+ $('#edit-'+id+' .inline-edit-save').append('<span class="error">'+r+'</span>');
+ }
+ } else {
+ $('#edit-'+id+' .inline-edit-save').append('<span class="error">'+inlineEditL10n.error+'</span>');
+ }
+ }
+ , 'html');
+ return false;
+ },
+
+ revert : function() {
+ var id;
+
+ if ( id = $('table.widefat tr.inline-editor').attr('id') ) {
+ $('table.widefat .inline-edit-save .waiting').hide();
+
+ if ( 'bulk-edit' == id ) {
+ $('table.widefat #bulk-edit').removeClass('inline-editor').hide();
+ $('#bulk-titles').html('');
+ $('#inlineedit').append( $('#bulk-edit') );
+ } else {
+ $('#'+id).remove();
+ id = id.substr( id.lastIndexOf('-') + 1 );
+ $(this.what+id).show();
+ }
+ }
+
+ return false;
+ },
+
+ getId : function(o) {
+ var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id');
+ var parts = id.split('-');
+ return parts[parts.length - 1];
+ }
+};
+
+$(document).ready(function(){inlineEditPost.init();});
+})(jQuery);
--- /dev/null
+
+(function($) {
+inlineEditTax = {
+
+ init : function() {
+ var t = this, row = $('#inline-edit');
+
+ t.type = $('#the-list').attr('className').substr(5);
+ t.what = '#'+t.type+'-';
+
+ // get all editable rows
+ t.rows = $('tr.iedit');
+
+ // prepare the edit row
+ row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
+
+ $('a.cancel', row).click(function() { return inlineEditTax.revert(); });
+ $('a.save', row).click(function() { return inlineEditTax.save(this); });
+ $('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); });
+
+ // add events
+ t.addEvents(t.rows);
+
+ $('#posts-filter input[type="submit"]').click(function(e){
+ if ( $('form#posts-filter tr.inline-editor').length > 0 )
+ t.revert();
+ });
+ },
+
+ toggle : function(el) {
+ var t = this;
+
+ $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
+ },
+
+ addEvents : function(r) {
+ r.each(function() {
+ $(this).find('a.editinline').click(function() { inlineEditTax.edit(this); return false; });
+ $(this).find('.hide-if-no-js').removeClass('hide-if-no-js');
+ });
+ },
+
+ edit : function(id) {
+ var t = this;
+ t.revert();
+
+ if ( typeof(id) == 'object' )
+ id = t.getId(id);
+
+ var editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
+ $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
+
+ if ( $(t.what+id).hasClass('alternate') )
+ $(editRow).addClass('alternate');
+
+ $(t.what+id).hide().after(editRow);
+
+ $(':input[name="name"]', editRow).val( $('.name', rowData).text() );
+ $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
+
+ // cat parents
+ var cat_parent = $('.cat_parent', rowData).text();
+ if ( cat_parent != '0' )
+ $('select[name="parent"]', editRow).val(cat_parent);
+
+ // remove the current parent and children from the parent dropdown
+ var pageOpt = $('select[name="parent"] option[value="'+id+'"]', editRow);
+ if ( pageOpt.length > 0 ) {
+ var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true;
+ while ( pageLoop ) {
+ var nextPage = nextPage.next('option');
+ if (nextPage.length == 0) break;
+ var nextLevel = nextPage[0].className.split('-')[1];
+ if ( nextLevel <= pageLevel ) {
+ pageLoop = false;
+ } else {
+ nextPage.remove();
+ nextPage = pageOpt;
+ }
+ }
+ pageOpt.remove();
+ }
+
+ $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
+ $('.ptitle', editRow).eq(0).focus();
+
+ return false;
+ },
+
+ save : function(id) {
+ if( typeof(id) == 'object' )
+ id = this.getId(id);
+
+ $('table.widefat .inline-edit-save .waiting').show();
+
+ var params = {
+ action: 'inline-save-tax',
+ tax_type: this.type,
+ tax_ID: id
+ };
+
+ var fields = $('#edit-'+id+' :input').fieldSerialize();
+ params = fields + '&' + $.param(params);
+
+ // make ajax request
+ $.post('admin-ajax.php', params,
+ function(r) {
+
+ $('table.widefat .inline-edit-save .waiting').hide();
+
+ if (r) {
+ if ( -1 != r.indexOf('<tr') ) {
+ $(inlineEditTax.what+id).remove();
+ $('#edit-'+id).before(r).remove();
+
+ var row = $(inlineEditTax.what+id);
+ row.hide();
+
+ row.find('.hide-if-no-js').removeClass('hide-if-no-js');
+ inlineEditTax.addEvents(row);
+ row.fadeIn();
+ } else
+ $('#edit-'+id+' .inline-edit-save .error').html(r).show();
+ } else
+ $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
+ }
+ );
+ return false;
+ },
+
+ revert : function() {
+ var id = $('table.widefat tr.inline-editor').attr('id');
+
+ if ( id ) {
+ $('table.widefat .inline-edit-save .waiting').hide();
+ $('#'+id).remove();
+ id = id.substr( id.lastIndexOf('-') + 1 );
+ $(this.what+id).show();
+ }
+
+ return false;
+ },
+
+ getId : function(o) {
+ var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id');
+ var parts = id.split('-');
+ return parts[parts.length - 1];
+ }
+};
+
+$(document).ready(function(){inlineEditTax.init();});
+})(jQuery);
-jQuery(document).ready( function() {
+jQuery(document).ready( function($) {
// close postboxes that should be closed
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
jQuery('#link_name').focus();
// postboxes
- add_postbox_toggles('link');
+ postboxes.add_postbox_toggles('link');
// category tabs
var categoryTabs = jQuery('#category-tabs').tabs();
// Ajax Cat
var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } );
- jQuery('#category-add-sumbit').click( function() { newCat.focus(); } );
+ jQuery('#category-add-submit').click( function() { newCat.focus(); } );
var noSyncChecks = false; // prophylactic. necessary?
var syncChecks = function() {
if ( noSyncChecks )
response: 'category-ajax-response',
addAfter: catAddAfter
} );
+
+ $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
+ $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
+ if ( 'pop' == getUserSetting('cats') )
+ $('a[href="#categories-pop"]').click();
+
jQuery('#category-add-toggle').click( function() {
jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' );
categoryTabs.tabsClick( 1 );
if (tinymce.isIE)
ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
- if ( h.indexOf('[caption') != -1 )
- h = ed.plugins.wpeditimage._do_shcode(h);
-
+ if ( h.indexOf('[caption') === 0 ) {
+ if ( ed.plugins.wpeditimage )
+ h = ed.plugins.wpeditimage._do_shcode(h);
+ } else if ( h.indexOf('[gallery') === 0 ) {
+ if ( ed.plugins.wpgallery )
+ h = ed.plugins.wpgallery._do_gallery(h);
+ }
+
ed.execCommand('mceInsertContent', false, h);
- } else
+
+ } else if ( typeof edInsertContent == 'function' ) {
edInsertContent(edCanvas, h);
+ } else {
+ jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h );
+ }
tb_remove();
}
$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
});
};
-
+
jQuery('a.thickbox').click(function(){
if ( typeof tinyMCE != 'undefined' && tinyMCE.activeEditor ) {
tinyMCE.get('content').focus();
-jQuery(document).ready( function() {
- add_postbox_toggles('page');
+jQuery(document).ready( function($) {
+ postboxes.add_postbox_toggles('page');
make_slugedit_clickable();
// close postboxes that should be closed
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
- // show things that should be visible, hide what should be hidden
- jQuery('.hide-if-no-js').show();
- jQuery('.hide-if-js').hide();
-
jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } );
- // hide advanced slug field
- jQuery('#pageslugdiv').hide();
+ var stamp = $('#timestamp').html();
+
+ var visibility = $('#post-visibility-display').html();
+
+ function updateVisibility() {
+ if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) {
+ $('#sticky').attr('checked', false);
+ $('#sticky-span').hide();
+ } else {
+ $('#sticky-span').show();
+ }
+ if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) {
+ $('#password-span').hide();
+ } else {
+ $('#password-span').show();
+ }
+ }
+
+ function updateText() {
+ var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val());
+ var originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val());
+ var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val());
+ if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) {
+ var publishOn = postL10n.publishOnFuture;
+ $('#publish').val( postL10n.schedule );
+ } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) {
+ var publishOn = postL10n.publishOn;
+ $('#publish').val( postL10n.publish );
+ } else {
+ var publishOn = postL10n.publishOnPast;
+ $('#publish').val( postL10n.update );
+ }
+ if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack
+ $('#timestamp').html(stamp);
+ } else {
+ $('#timestamp').html(
+ publishOn + ' <b>' +
+ $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
+ $('#jj').val() + ', ' +
+ $('#aa').val() + ' @ ' +
+ $('#hh').val() + ':' +
+ $('#mn').val() + '</b> '
+ );
+ }
- jQuery('.edit-timestamp').click(function () {
- if (jQuery('#timestampdiv').is(":hidden")) {
- jQuery('#timestampdiv').slideDown("normal");
- jQuery('.edit-timestamp').text(postL10n.cancel);
+ if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) {
+ $('#publish').val( postL10n.update );
+ if ( $('#post_status option[value=publish]').length == 0 ) {
+ $('#post_status').append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
+ }
+ $('#post_status option[value=publish]').html( postL10n.privatelyPublished );
+ $('#post_status option[value=publish]').attr('selected', true);
+ $('.edit-post-status').hide();
} else {
- jQuery('#timestampdiv').hide();
- jQuery('#mm').val(jQuery('#hidden_mm').val());
- jQuery('#jj').val(jQuery('#hidden_jj').val());
- jQuery('#aa').val(jQuery('#hidden_aa').val());
- jQuery('#hh').val(jQuery('#hidden_hh').val());
- jQuery('#mn').val(jQuery('#hidden_mn').val());
- jQuery('.edit-timestamp').text(postL10n.edit);
+ if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) {
+ if ( $('#post_status option[value=publish]').length != 0 ) {
+ $('#post_status option[value=publish]').remove();
+ $('#post_status').val($('#hidden_post_status').val());
+ }
+ } else {
+ $('#post_status option[value=publish]').html( postL10n.published );
+ }
+ $('.edit-post-status').show();
+ }
+ $('#post-status-display').html($('#post_status :selected').text());
+ if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) {
+ $('#save-post').hide();
+ } else {
+ $('#save-post').show();
+ if ( $('#post_status :selected').val() == 'pending' ) {
+ $('#save-post').show().val( postL10n.savePending );
+ } else {
+ $('#save-post').show().val( postL10n.saveDraft );
+ }
+ }
+ }
+
+ $('.edit-visibility').click(function () {
+ if ($('#post-visibility-select').is(":hidden")) {
+ updateVisibility();
+ $('#post-visibility-select').slideDown("normal");
+ $('.edit-visibility').hide();
+ }
+ return false;
+ });
+
+ $('.cancel-post-visibility').click(function () {
+ $('#post-visibility-select').slideUp("normal");
+ $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true);
+ $('#post_password').val($('#hidden_post_password').val());
+ $('#post-visibility-display').html(visibility);
+ $('.edit-visibility').show();
+ updateText();
+ return false;
+ });
+
+ $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels
+ $('#post-visibility-select').slideUp("normal");
+ $('.edit-visibility').show();
+ updateText();
+
+ $('#post-visibility-display').html(
+ postL10n[$('#post-visibility-select input:radio:checked').val()]
+ );
+
+ return false;
+ });
+
+ $('#post-visibility-select input:radio').change(function() {
+ updateVisibility();
+ });
+
+ $('.edit-timestamp').click(function () {
+ if ($('#timestampdiv').is(":hidden")) {
+ $('#timestampdiv').slideDown("normal");
+ $('.edit-timestamp').hide();
+ }
+
+ return false;
+ });
+
+ $('.cancel-timestamp').click(function() {
+ $('#timestampdiv').slideUp("normal");
+ $('#mm').val($('#hidden_mm').val());
+ $('#jj').val($('#hidden_jj').val());
+ $('#aa').val($('#hidden_aa').val());
+ $('#hh').val($('#hidden_hh').val());
+ $('#mn').val($('#hidden_mn').val());
+ $('.edit-timestamp').show();
+
+ updateText();
+ return false;
+ });
+
+ $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
+ $('#timestampdiv').slideUp("normal");
+ $('.edit-timestamp').show();
+ updateText();
+
+ return false;
+ });
+
+ $('.edit-post-status').click(function() {
+ if ($('#post-status-select').is(":hidden")) {
+ $('#post-status-select').slideDown("normal");
+ $(this).hide();
}
+
+ return false;
+ });
+
+ $('.save-post-status').click(function() {
+ $('#post-status-select').slideUp("normal");
+ $('.edit-post-status').show();
+ updateText();
+ return false;
+ });
+
+ $('.cancel-post-status').click(function() {
+ $('#post-status-select').slideUp("normal");
+ $('#post_status').val($('#hidden_post_status').val());
+ $('.edit-post-status').show();
+
+ updateText();
+ return false;
+ });
+
+ // Custom Fields
+ jQuery('#the-list').wpList( { addAfter: function( xml, s ) {
+ $('table#list-table').show();
+ if ( jQuery.isFunction( autosave_update_post_ID ) ) {
+ autosave_update_post_ID(s.parsed.responses[0].supplemental.postid);
+ }
+ }, addBefore: function( s ) {
+ s.data += '&post_id=' + jQuery('#post_ID').val();
+ return s;
+ }
+ });
+
+ // preview
+ $('#post-preview').click(function(e){
+ if ( 1 > $('#post_ID').val() && autosaveFirst ) {
+ autosaveDelayPreview = true;
+ autosave();
+ return false;
+ }
+
+ $('input#wp-preview').val('dopreview');
+ $('form#post').attr('target', 'wp-preview').submit().attr('target', '');
+ $('input#wp-preview').val('');
return false;
- });
-});
\ No newline at end of file
+ });
+});
// Password strength meter
-// This jQuery plugin is written by firas kassem [2007.04.05]
-// Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com
-// for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/
-
-var shortPass = pwsL10n.short
-var badPass = pwsL10n.bad
-var goodPass = pwsL10n.good
-var strongPass = pwsL10n.strong
-
function passwordStrength(password,username) {
- score = 0
+ var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4;
- //password < 4
- if (password.length < 4 ) { return shortPass }
+ //password < 4
+ if (password.length < 4 ) { return shortPass };
//password == username
- if (password.toLowerCase()==username.toLowerCase()) return badPass
-
- //password length
- score += password.length * 4
- score += ( checkRepetition(1,password).length - password.length ) * 1
- score += ( checkRepetition(2,password).length - password.length ) * 1
- score += ( checkRepetition(3,password).length - password.length ) * 1
- score += ( checkRepetition(4,password).length - password.length ) * 1
-
- //password has 3 numbers
- if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) score += 5
-
- //password has 2 sybols
- if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5
-
- //password has Upper and Lower chars
- if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) score += 10
-
- //password has number and chars
- if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) score += 15
- //
- //password has number and symbol
- if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) score += 15
-
- //password has char and symbol
- if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) score += 15
-
- //password is just a nubers or chars
- if (password.match(/^\w+$/) || password.match(/^\d+$/) ) score -= 10
-
- //verifing 0 < score < 100
- if ( score < 0 ) score = 0
- if ( score > 100 ) score = 100
-
- if (score < 34 ) return badPass
- if (score < 68 ) return goodPass
- return strongPass
-}
-
-
-// checkRepetition(1,'aaaaaaabcbc') = 'abcbc'
-// checkRepetition(2,'aaaaaaabcbc') = 'aabc'
-// checkRepetition(2,'aaaaaaabcdbcd') = 'aabcd'
-
-function checkRepetition(pLen,str) {
- res = ""
- for ( i=0; i<str.length ; i++ ) {
- repeated=true
- for (j=0;j < pLen && (j+i+pLen) < str.length;j++)
- repeated=repeated && (str.charAt(j+i)==str.charAt(j+i+pLen))
- if (j<pLen) repeated=false
- if (repeated) {
- i+=pLen-1
- repeated=false
- }
- else {
- res+=str.charAt(i)
- }
- }
- return res
-}
-
+ if (password.toLowerCase()==username.toLowerCase()) return badPass;
+
+ var symbolSize = 0;
+ if (password.match(/[0-9]/)) symbolSize +=10;
+ if (password.match(/[a-z]/)) symbolSize +=26;
+ if (password.match(/[A-Z]/)) symbolSize +=26;
+ if (password.match(/[^a-zA-Z0-9]/)) symbolSize +=31;
+
+ var natLog = Math.log( Math.pow(symbolSize,password.length) );
+ var score = natLog / Math.LN2;
+ if (score < 40 ) return badPass
+ if (score < 56 ) return goodPass
+ return strongPass;
+}
\ No newline at end of file
--- /dev/null
+/* Plugin Browser Thickbox related JS*/
+jQuery(function($) {
+ var thickDims = function() {
+ var tbWindow = $('#TB_window');
+ var width = $(window).width();
+ var H = $(window).height();
+ var W = ( 720 < width ) ? 720 : width;
+
+ if ( tbWindow.size() ) {
+ tbWindow.width( W - 50 ).height( H - 45 );
+ $('#TB_iframeContent').width( W - 50 ).height( H - 75 );
+ tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
+ if ( ! ( $.browser.msie && $.browser.version.substr(0,1) < 7 ) )
+ tbWindow.css({'top':'20px','margin-top':'0'});
+ };
+
+ return $('a.thickbox').each( function() {
+ var href = $(this).attr('href');
+ if ( ! href )
+ return;
+ href = href.replace(/&width=[0-9]+/g, '');
+ href = href.replace(/&height=[0-9]+/g, '');
+ $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
+ });
+ };
+
+ thickDims().click( function() {
+ $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
+ $('#TB_ajaxWindowTitle').html('<strong>' + plugininstallL10n.plugin_information + '</strong> ' + $(this).attr('title') );
+ return false;
+ });
+});
+
+/* Plugin install related JS*/
+jQuery(function($) {
+ $('#install-plugins tbody.plugins tr').click( function() {
+ $(this).find('.action-links a.onclick').click();
+ return false;
+ });
+
+ $('#plugin-information #sidemenu a').click( function() {
+ var tab = $(this).attr('name');
+ //Flip the tab
+ $('#plugin-information-header a.current').removeClass('current');
+ $(this).addClass('current');
+ //Flip the content.
+ $('#section-holder div.section').hide(); //Hide 'em all
+ $('#section-' + tab).show();
+ return false;
+ });
+});
\ No newline at end of file
jQuery( '#tagchecklist' ).prepend( '<strong>'+postL10n.tagsUsed+'</strong><br />' );
}
-function tag_flush_to_text() {
- var newtags = jQuery('#tags-input').val() + ',' + jQuery('#newtag').val();
+function tag_flush_to_text(e,a) {
+ a = a || false;
+ var text = a ? jQuery(a).text() : jQuery('#newtag').val();
+ var newtags = jQuery('#tags-input').val();
+
+ var t = text.replace( /\s*([^,]+).*/, '$1,' );
+ newtags += ','
+
+ if ( newtags.indexOf(t) != -1 )
+ return false;
+
+ newtags += text;
+
// massage
newtags = newtags.replace( /\s+,+\s*/g, ',' ).replace( /,+/g, ',' ).replace( /,+\s+,+/g, ',' ).replace( /,+\s*$/g, '' ).replace( /^\s*,+/g, '' );
jQuery('#tags-input').val( newtags );
tag_update_quickclicks();
- jQuery('#newtag').val('');
- jQuery('#newtag').focus();
+ if ( ! a ) {
+ jQuery('#newtag').val('');
+ jQuery('#newtag').focus();
+ }
return false;
}
tag_flush_to_text();
return false;
}
-}
+};
+
+(function($){
+ tagCloud = {
+ init : function() {
+ $('#tagcloud-link').click(function(){tagCloud.get(); $(this).unbind().click(function(){return false;}); return false;});
+ },
+
+ get : function() {
+ $.post('admin-ajax.php', {'action':'get-tagcloud'}, function(r, stat) {
+ if ( 0 == r || 'success' != stat )
+ r = wpAjax.broken;
+
+ r = '<p id="the-tagcloud">'+r+'</p>';
+ $('#tagcloud-link').after($(r));
+ $('#the-tagcloud a').click(function(){
+ tag_flush_to_text(0,this);
+ return false;
+ });
+ });
+ }
+ }
+})(jQuery);
+
+jQuery(document).ready( function($) {
+ tagCloud.init();
-jQuery(document).ready( function() {
// close postboxes that should be closed
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
- // show things that should be visible, hide what should be hidden
- jQuery('.hide-if-no-js').show();
- jQuery('.hide-if-js').hide();
-
// postboxes
- add_postbox_toggles('post');
+ postboxes.add_postbox_toggles('post');
// Editable slugs
make_slugedit_clickable();
- // hide advanced slug field
- jQuery('#slugdiv').hide();
-
jQuery('#tags-input').hide();
tag_update_quickclicks();
// add the quickadd form
jQuery('#newcat').focus();
return false;
} );
+
+ $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
+ $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
+ if ( 'pop' == getUserSetting('cats') )
+ $('a[href="#categories-pop"]').click();
+
jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change();
+ var stamp = $('#timestamp').html();
+ var visibility = $('#post-visibility-display').html();
+ var sticky = '';
- jQuery('.edit-timestamp').click(function () {
- if (jQuery('#timestampdiv').is(":hidden")) {
- jQuery('#timestampdiv').slideDown("normal");
- jQuery('.edit-timestamp').text(postL10n.cancel);
+ function updateVisibility() {
+ if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) {
+ $('#sticky').attr('checked', false);
+ $('#sticky-span').hide();
} else {
- jQuery('#timestampdiv').hide();
- jQuery('#mm').val(jQuery('#hidden_mm').val());
- jQuery('#jj').val(jQuery('#hidden_jj').val());
- jQuery('#aa').val(jQuery('#hidden_aa').val());
- jQuery('#hh').val(jQuery('#hidden_hh').val());
- jQuery('#mn').val(jQuery('#hidden_mn').val());
- jQuery('.edit-timestamp').text(postL10n.edit);
+ $('#sticky-span').show();
+ }
+ if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) {
+ $('#password-span').hide();
+ } else {
+ $('#password-span').show();
+ }
+ }
+
+ function updateText() {
+ var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val());
+ var originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val());
+ var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val());
+ if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) {
+ var publishOn = postL10n.publishOnFuture;
+ $('#publish').val( postL10n.schedule );
+ } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) {
+ var publishOn = postL10n.publishOn;
+ $('#publish').val( postL10n.publish );
+ } else {
+ var publishOn = postL10n.publishOnPast;
+ $('#publish').val( postL10n.update );
+ }
+ if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack
+ $('#timestamp').html(stamp);
+ } else {
+ $('#timestamp').html(
+ publishOn + ' <b>' +
+ $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
+ $('#jj').val() + ', ' +
+ $('#aa').val() + ' @ ' +
+ $('#hh').val() + ':' +
+ $('#mn').val() + '</b> '
+ );
+ }
+
+ if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) {
+ $('#publish').val( postL10n.update );
+ if ( $('#post_status option[value=publish]').length == 0 ) {
+ $('#post_status').append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
+ }
+ $('#post_status option[value=publish]').html( postL10n.privatelyPublished );
+ $('#post_status option[value=publish]').attr('selected', true);
+ $('.edit-post-status').hide();
+ } else {
+ if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) {
+ if ( $('#post_status option[value=publish]').length != 0 ) {
+ $('#post_status option[value=publish]').remove();
+ $('#post_status').val($('#hidden_post_status').val());
+ }
+ } else {
+ $('#post_status option[value=publish]').html( postL10n.published );
+ }
+ $('.edit-post-status').show();
+ }
+ $('#post-status-display').html($('#post_status :selected').text());
+ if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) {
+ $('#save-post').hide();
+ } else {
+ $('#save-post').show();
+ if ( $('#post_status :selected').val() == 'pending' ) {
+ $('#save-post').show().val( postL10n.savePending );
+ } else {
+ $('#save-post').show().val( postL10n.saveDraft );
+ }
+ }
+ }
+
+ $('.edit-visibility').click(function () {
+ if ($('#post-visibility-select').is(":hidden")) {
+ updateVisibility();
+ $('#post-visibility-select').slideDown("normal");
+ $('.edit-visibility').hide();
+ }
+ return false;
+ });
+
+ $('.cancel-post-visibility').click(function () {
+ $('#post-visibility-select').slideUp("normal");
+ $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true);
+ $('#post_password').val($('#hidden_post_password').val());
+ $('#sticky').attr('checked', $('#hidden-post-sticky').attr('checked'));
+ $('#post-visibility-display').html(visibility);
+ $('.edit-visibility').show();
+ updateText();
+ return false;
+ });
+
+ $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels
+ $('#post-visibility-select').slideUp("normal");
+ $('.edit-visibility').show();
+ updateText();
+ if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) {
+ $('#sticky').attr('checked', false);
+ }
+
+ if ( true == $('#sticky').attr('checked') ) {
+ sticky = 'Sticky';
+ } else {
+ sticky = '';
+ }
+
+ $('#post-visibility-display').html(
+ postL10n[$('#post-visibility-select input:radio:checked').val() + sticky]
+ );
+
+ return false;
+ });
+
+ $('#post-visibility-select input:radio').change(function() {
+ updateVisibility();
+ });
+
+ $('.edit-timestamp').click(function () {
+ if ($('#timestampdiv').is(":hidden")) {
+ $('#timestampdiv').slideDown("normal");
+ $('.edit-timestamp').hide();
}
+
return false;
+ });
+ $('.cancel-timestamp').click(function() {
+ $('#timestampdiv').slideUp("normal");
+ $('#mm').val($('#hidden_mm').val());
+ $('#jj').val($('#hidden_jj').val());
+ $('#aa').val($('#hidden_aa').val());
+ $('#hh').val($('#hidden_hh').val());
+ $('#mn').val($('#hidden_mn').val());
+ $('.edit-timestamp').show();
+ updateText();
+ return false;
+ });
+
+ $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
+ $('#timestampdiv').slideUp("normal");
+ $('.edit-timestamp').show();
+ updateText();
+
+ return false;
+ });
+
+ $('.edit-post-status').click(function() {
+ if ($('#post-status-select').is(":hidden")) {
+ $('#post-status-select').slideDown("normal");
+ $(this).hide();
+ }
+
+ return false;
+ });
+
+ $('.save-post-status').click(function() {
+ $('#post-status-select').slideUp("normal");
+ $('.edit-post-status').show();
+ updateText();
+ return false;
+ });
+
+ $('.cancel-post-status').click(function() {
+ $('#post-status-select').slideUp("normal");
+ $('#post_status').val($('#hidden_post_status').val());
+ $('.edit-post-status').show();
+ updateText();
+ return false;
});
// Custom Fields
jQuery('#the-list').wpList( { addAfter: function( xml, s ) {
+ $('table#list-table').show();
if ( jQuery.isFunction( autosave_update_post_ID ) ) {
autosave_update_post_ID(s.parsed.responses[0].supplemental.postid);
}
return s;
}
});
+
+ // preview
+ $('#post-preview').click(function(e){
+ if ( 1 > $('#post_ID').val() && autosaveFirst ) {
+ autosaveDelayPreview = true;
+ autosave();
+ return false;
+ }
+
+ $('input#wp-preview').val('dopreview');
+ $('form#post').attr('target', 'wp-preview').submit().attr('target', '');
+ $('input#wp-preview').val('');
+ return false;
+ });
+
});
+
+(function($){
+ commentsBox = {
+ st : 0,
+
+ get : function(total, num) {
+ var st = this.st;
+ if ( ! num )
+ num = 20;
+
+ this.st += num;
+ this.total = total;
+ $('.waiting').show();
+
+ var data = {
+ 'action' : 'get-comments',
+ 'mode' : 'single',
+ '_ajax_nonce' : $('#add_comment_nonce').val(),
+ 'post_ID' : $('#post_ID').val(),
+ 'start' : st,
+ 'num' : num
+ };
+
+ $.post('admin-ajax.php', data,
+ function(r) {
+ var r = wpAjax.parseAjaxResponse(r);
+ $('#commentstatusdiv .widefat').show();
+ $('.waiting').hide();
+
+ if ( 'object' == typeof r && r.responses[0] ) {
+ $('#the-comment-list').append( r.responses[0].data );
+ $('#the-comment-list .hide-if-no-js').removeClass('hide-if-no-js');
+
+ theList = theExtraList = null;
+ $("a[className*=':']").unbind();
+ setCommentsList();
+
+ if ( commentsBox.st > commentsBox.total )
+ $('#show-comments').hide();
+ else
+ $('#show-comments').html(postL10n.showcomm);
+ return;
+ } else if ( 1 == r ) {
+ $('#show-comments').parent().html(postL10n.endcomm);
+ return;
+ }
+
+ $('#the-comment-list').append('<tr><td colspan="5">'+wpAjax.broken+'</td></tr>');
+ }
+ );
+
+ return false;
+ }
+ };
+
+})(jQuery);
+
-function add_postbox_toggles(page) {
- jQuery('.postbox h3').prepend('<a class="togbox">+</a> ');
- jQuery('.postbox h3').click( function() { jQuery(jQuery(this).parent().get(0)).toggleClass('closed'); save_postboxes_state(page); } );
-}
-
-function save_postboxes_state(page) {
- var closed = jQuery('.postbox').filter('.closed').map(function() { return this.id; }).get().join(',');
- jQuery.post(postboxL10n.requestFile, {
- action: 'closed-postboxes',
- closed: closed,
- closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
- page: page
- });
-}
+(function($) {
+ postboxes = {
+ add_postbox_toggles : function(page,args) {
+ $('.postbox h3, .postbox .handlediv').click( function() {
+ $($(this).parent().get(0)).toggleClass('closed');
+ postboxes.save_state(page);
+ } );
+ $('.postbox h3 a').click( function(e) {
+ e.stopPropagation();
+ } );
+
+ $('.hide-postbox-tog').click( function() {
+ var box = jQuery(this).val();
+ if ( jQuery(this).attr('checked') ) {
+ jQuery('#' + box).show();
+ if ( $.isFunction( postboxes.pbshow ) )
+ postboxes.pbshow( box );
+
+ } else {
+ jQuery('#' + box).hide();
+ if ( $.isFunction( postboxes.pbhide ) )
+ postboxes.pbhide( box );
+
+ }
+ postboxes.save_state(page);
+ } );
+
+ this.expandSidebar();
+ this.init(page,args);
+ },
+
+ expandSidebar : function(doIt) {
+ if ( doIt || $('#side-sortables > .postbox:visible').length ) {
+ if ( ! $('#post-body').hasClass('has-sidebar') ) {
+ $('#post-body').addClass('has-sidebar');
+ var h = Math.min( $('#post-body').height(), 300 );
+ $('#side-sortables').css({'minHeight':h+'px','height':'auto'});
+ }
+ } else {
+ $('#post-body').removeClass('has-sidebar');
+ $('#side-sortables').css({'minHeight':'0'});
+ if ( $.browser.msie && $.browser.version.charAt(0) == 7 )
+ $('#side-sortables').css({'height':'0'});
+ }
+ },
+
+ init : function(page, args) {
+ $.extend( this, args || {} );
+ $('#wpbody-content').css('overflow','hidden');
+ $('.meta-box-sortables').sortable( {
+ placeholder: 'sortable-placeholder',
+ connectWith: [ '.meta-box-sortables' ],
+ items: '> .postbox',
+ handle: '.hndle',
+ distance: 2,
+ tolerance: 'pointer',
+ toleranceMove: 'tolerance',
+ sort: function(e,ui) {
+ if ( $(document).width() - e.clientX < 300 ) {
+ if ( ! $('#post-body').hasClass('has-sidebar') ) {
+ var pos = $('#side-sortables').offset();
+
+ $('#side-sortables').append(ui.item)
+ $(ui.placeholder).css({'top':pos.top,'left':pos.left}).width($(ui.item).width())
+ postboxes.expandSidebar(1);
+ }
+ }
+ },
+ stop: function() {
+ var postVars = {
+ action: 'meta-box-order',
+ _ajax_nonce: $('#meta-box-order-nonce').val(),
+ page: page
+ }
+ $('.meta-box-sortables').each( function() {
+ postVars["order[" + this.id.split('-')[0] + "]"] = $(this).sortable( 'toArray' ).join(',');
+ } );
+ $.post( postboxL10n.requestFile, postVars, function() {
+ postboxes.expandSidebar();
+ } );
+ }
+ } );
+ },
+
+ save_state : function(page) {
+ var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(',');
+ var hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(',');
+ $.post(postboxL10n.requestFile, {
+ action: 'closed-postboxes',
+ closed: closed,
+ hidden: hidden,
+ closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
+ page: page
+ });
+ postboxes.expandSidebar();
+ },
+
+ /* Callbacks */
+ pbshow : false,
+
+ pbhide : false
+ };
+
+}(jQuery));
<?php
+
if ( !defined( 'ABSPATH' ) )
exit;
+/** @ignore */
function dvortr( $str ) {
return strtr(
$str,
'\',.pyfgcrl/=\\aoeuidhtns-;qjkxbmwvz"<>PYFGCRL?+|AOEUIDHTNS_:QJKXBMWVZ[]',
'qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?-='
);
-}
+}
$j = clean_url( site_url( '/wp-includes/js/jquery/jquery.js' ) );
$n = wp_specialchars( $GLOBALS['current_user']->data->display_name );
var revert_b = b.html();
var full = jQuery('#editable-post-name-full').html();
- b.html('<a href="" class="save">'+slugL10n.save+'</a> <a class="cancel" href="">'+slugL10n.cancel+'</a>');
+ b.html('<a href="" class="save button">'+slugL10n.save+'</a> <a class="cancel" href="">'+slugL10n.cancel+'</a>');
b.children('.save').click(function() {
var new_slug = e.children('input').val();
jQuery.post(slugL10n.requestFile, {
var name = $("<span>" + $('name', r).text() + "</span>").html();
var id = $('tag', r).attr('id');
options[options.length] = new Option(name, id);
+
+ }
+
+ var addAfter2 = function( x, r ) {
+ var t = $(r.parsed.responses[0].data);
+ if ( t.length == 1 )
+ inlineEditTax.addEvents($(t.id));
}
var delAfter = function( r, settings ) {
if ( options )
$('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } );
else
- $('#the-list').wpList();
-});
+ $('#the-list').wpList({ addAfter: addAfter2 });
+
+ columns.init('edit-tags');
+});
\ No newline at end of file
+++ /dev/null
-jQuery(document).ready( function() {
- theFileList = {
- currentImage: {ID: 0},
- nonce: '',
- tab: '',
- postID: 0,
-
- // cookie create and read functions adapted from http://www.quirksmode.org/js/cookies.html
- createCookie: function(name,value,days) {
- if (days) {
- var date = new Date();
- date.setTime(date.getTime()+(days*24*60*60*1000));
- var expires = "; expires="+date.toGMTString();
- }
- else var expires = "";
- document.cookie = name+"="+value+expires+"; path=/";
- },
-
- readCookie: function(name) {
- var nameEQ = name + "=";
- var ca = document.cookie.split(';');
- for(var i=0;i < ca.length;i++) {
- var c = ca[i];
- while (c.charAt(0)==' ') c = c.substring(1,c.length);
- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
- }
- return null;
- },
-
- assignCookieOnChange: function() {
- jQuery(this).bind("change", function(){
- theFileList.createCookie(jQuery(this).attr('name'),jQuery(this).attr('id'),365);
- });
- },
-
- checkCookieSetting: function(name, defaultSetting) {
- return this.readCookie(name) ? this.readCookie(name) : defaultSetting;
- },
-
- toQueryParams: function( s ) {
- var r = {}; if ( !s ) { return r; }
- var q = s.split('?'); if ( q[1] ) { s = q[1]; }
- var pp = s.split('&');
- for ( var i in pp ) {
- var p = pp[i].split('=');
- r[p[0]] = p[1];
- }
- return r;
- },
-
- toQueryString: function(params) {
- var qryStr = '';
- for ( var key in params )
- qryStr += key + '=' + params[key] + '&';
- return qryStr;
- },
-
- initializeVars: function() {
- this.urlData = document.location.href.split('?');
- this.params = this.toQueryParams(this.urlData[1]);
- this.postID = this.params['post_id'];
- this.tab = this.params['tab'];
- this.style = this.params['style'];
- this.ID = this.params['ID'];
- if ( !this.style )
- this.style = 'default';
- var nonceEl = jQuery('#nonce-value');
- if ( nonceEl )
- this.nonce = jQuery(nonceEl).val();
- if ( this.ID ) {
- this.grabImageData( this.ID );
- this.imageView( this.ID );
- }
- },
-
- initializeLinks: function() {
- if ( this.ID )
- return;
- jQuery('a.file-link').each(function() {
- var id = jQuery(this).attr('id').split('-').pop();
- jQuery(this).attr('href','javascript:void(0)').click(function(e) {
- theFileList[ 'inline' == theFileList.style ? 'imageView' : 'editView' ](id, e);
- });
- });
- },
-
- grabImageData: function(id) {
- if ( id == this.currentImage.ID )
- return;
- var thumbEl = jQuery('#attachment-thumb-url-' + id);
- if ( thumbEl ) {
- this.currentImage.thumb = ( 0 == id ? '' : jQuery(thumbEl).val() );
- this.currentImage.thumbBase = ( 0 == id ? '' : jQuery('#attachment-thumb-url-base-' + id).val() );
- } else {
- this.currentImage.thumb = false;
- }
- this.currentImage.src = ( 0 == id ? '' : jQuery('#attachment-url-' + id).val() );
- this.currentImage.srcBase = ( 0 == id ? '' : jQuery('#attachment-url-base-' + id).val() );
- this.currentImage.page = ( 0 == id ? '' : jQuery('#attachment-page-url-' + id).val() );
- this.currentImage.title = ( 0 == id ? '' : jQuery('#attachment-title-' + id).val() );
- this.currentImage.description = ( 0 == id ? '' : jQuery('#attachment-description-' + id).val() );
- var widthEl = jQuery('#attachment-width-' + id);
- if ( widthEl ) {
- this.currentImage.width = ( 0 == id ? '' : jQuery(widthEl).val() );
- this.currentImage.height = ( 0 == id ? '' : jQuery('#attachment-height-' + id).val() );
- } else {
- this.currentImage.width = false;
- this.currentImage.height = false;
- }
- this.currentImage.isImage = ( 0 == id ? 0 : jQuery('#attachment-is-image-' + id).val() );
- this.currentImage.ID = id;
- },
-
- imageView: function(id, e) {
- this.prepView(id);
- var h = '';
-
- h += "<div id='upload-file'>"
- if ( this.ID ) {
- var params = this.params;
- params.ID = '';
- params.action = '';
- h += "<a href='" + this.urlData[0] + '?' + this.toQueryString(params) + "'";
- } else {
- h += "<a href='#' onclick='return theFileList.cancelView();'";
- }
- h += " title='" + this.browseTitle + "' class='back'>" + this.back + "</a>";
- h += "<div id='file-title'>"
- if ( 0 == this.currentImage.isImage )
- h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>" + this.currentImage.title + "</a></h2>";
- else
- h += "<h2>" + this.currentImage.title + "</h2>";
- h += " — <span>";
- h += "<a href='#' onclick='return theFileList.editView(" + id + ");'>" + this.edit + "</a>"
- h += "</span>";
- h += '</div>'
- h += "<div id='upload-file-view' class='alignleft'>";
- if ( 1 == this.currentImage.isImage ) {
- h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>";
- h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
- h += "</a>";
- } else
- h += ' ';
- h += "</div>";
-
- h += "<form name='uploadoptions' id='uploadoptions' class='alignleft'>";
- h += "<table>";
- var display = [];
- var checkedDisplay = 'display-title';
- if ( 1 == this.currentImage.isImage ) {
- checkedDisplay = 'display-full';
- if ( this.currentImage.thumb ) {
- display.push("<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' /> " + this.thumb + "</label><br />");
- checkedDisplay = 'display-thumb';
- }
- display.push("<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> " + this.full + "</label>");
- } else if ( this.currentImage.thumb ) {
- display.push("<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' /> " + this.icon + "</label>");
- }
- if ( display.length ) {
- display.push("<br /><label for='display-title'><input type='radio' name='display' id='display-title' value='title' /> " + this.title + "</label>");
- h += "<tr><th style='padding-bottom:.5em'>" + this.show + "</th><td style='padding-bottom:.5em'>";
- jQuery(display).each( function() { h += this; } );
- h += "</td></tr>";
- }
-
- var checkedLink = 'link-file';
- h += "<tr><th>" + this.link + "</th><td>";
- h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' /> " + this.file + "</label><br />"; h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> " + this.page + "</label><br />";
- h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> " + this.none + "</label>";
- h += "</td></tr>";
-
- h += "<tr><td colspan='2'><p class='submit'>";
- h += "<input type='button' class='button' name='send' onclick='theFileList.sendToEditor(" + id + ")' value='" + this.editorText + "' />";
- h += "</p></td></tr></table>";
- h += "</form>";
-
- h += "</div>";
-
- jQuery(h).prependTo('#upload-content');
- jQuery("input[@name='display']").each(theFileList.assignCookieOnChange);
- jQuery("input[@name='link']").each(theFileList.assignCookieOnChange);
- checkedDisplay = this.checkCookieSetting('display', checkedDisplay);
- checkedLink = this.checkCookieSetting('link', checkedLink);
- jQuery('#' + checkedDisplay).attr('checked','checked');
- jQuery('#' + checkedLink).attr('checked','checked');
- if (e) return e.stopPropagation();
- return false;
- },
-
- editView: function(id, e) {
- this.prepView(id);
- var h = '';
-
- var action = 'upload.php?style=' + this.style + '&tab=upload';
- if ( this.postID )
- action += '&post_id=' + this.postID;
-
- h += "<form id='upload-file' method='post' action='" + action + "'>";
- if ( this.ID ) {
- var params = this.params;
- params.ID = '';
- params.action = '';
- h += "<a href='" + this.urlData[0] + '?' + this.toQueryString(params) + "'";
- } else {
- h += "<a href='#' onclick='return theFileList.cancelView();'";
- }
- h += " title='" + this.browseTitle + "' class='back'>" + this.back + "</a>";
- h += "<div id='file-title'>"
- if ( 0 == this.currentImage.isImage )
- h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>" + this.currentImage.title + "</a></h2>";
- else
- h += "<h2>" + this.currentImage.title + "</h2>";
- h += " — <span>";
- h += "<a href='#' onclick='return theFileList.imageView(" + id + ");'>" + this.insert + "</a>";
- h += "</span>";
- h += '</div>'
- h += "<div id='upload-file-view' class='alignleft'>";
- if ( 1 == this.currentImage.isImage ) {
- h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>";
- h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />";
- h += "</a>";
- } else
- h += ' ';
- h += "</div>";
-
-
- h += "<table><col /><col class='widefat' /><tr>";
- h += "<th scope='row'><label for='url'>" + this.urlText + "</label></th>";
- h += "<td><input type='text' id='url' class='readonly' value='" + this.currentImage.srcBase + this.currentImage.src + "' readonly='readonly' /></td>";
- h += "</tr><tr>";
- h += "<th scope='row'><label for='post_title'>" + this.title + "</label></th>";
- h += "<td><input type='text' id='post_title' name='post_title' value='" + this.currentImage.title + "' /></td>";
- h += "</tr><tr>";
- h += "<th scope='row'><label for='post_content'>" + this.desc + "</label></th>";
- h += "<td><textarea name='post_content' id='post_content'>" + this.currentImage.description + "</textarea></td>";
- h += "</tr><tr id='buttons' class='submit'><td colspan='2'><input type='button' id='delete' name='delete' class='delete alignleft' value='" + this.deleteText + "' onclick='theFileList.deleteFile(" + id + ");' />";
- h += "<input type='hidden' name='from_tab' value='" + this.tab + "' />";
- h += "<input type='hidden' name='post_parent' value='" + parseInt(this.postID,10) + "' />";
- h += "<input type='hidden' name='action' id='action-value' value='save' />";
- h += "<input type='hidden' name='ID' value='" + id + "' />";
- h += "<input type='hidden' name='_wpnonce' value='" + this.nonce + "' />";
- h += "<div class='submit'><input type='submit' value='" + this.saveText + "' /></div>";
- h += "</td></tr></table></form>";
-
- jQuery(h).prependTo('#upload-content');
- if (e) e.stopPropagation();
- return false;
- },
-
- prepView: function(id) {
- this.cancelView( true );
- var filesEl = jQuery('#upload-files');
- if ( filesEl )
- filesEl.hide();
- var navEl = jQuery('#current-tab-nav');
- if ( navEl )
- navEl.hide();
- this.grabImageData(id);
- },
-
- cancelView: function( prep ) {
- if ( !prep ) {
- var filesEl = jQuery('#upload-files');
- if ( filesEl )
- jQuery(filesEl).show();
- var navEl = jQuery('#current-tab-nav');
- if ( navEl )
- jQuery(navEl).show();
- }
- if ( !this.ID )
- this.grabImageData(0);
- var div = jQuery('#upload-file');
- if ( div )
- jQuery(div).remove();
- return false;
- },
-
- sendToEditor: function(id) {
- this.grabImageData(id);
- var link = '';
- var display = '';
- var h = '';
-
- link = jQuery('input[@type=radio][@name="link"][@checked]','#uploadoptions').val();
- displayEl = jQuery('input[@type=radio][@name="display"][@checked]','#uploadoptions');
- if ( displayEl )
- display = jQuery(displayEl).val();
- else if ( 1 == this.currentImage.isImage )
- display = 'full';
-
- if ( 'none' != link )
- h += "<a href='" + ( 'file' == link ? ( this.currentImage.srcBase + this.currentImage.src ) : ( this.currentImage.page + "' rel='attachment wp-att-" + this.currentImage.ID ) ) + "' title='" + this.currentImage.title + "'>";
- if ( display && 'title' != display )
- h += "<img src='" + ( 'thumb' == display ? ( this.currentImage.thumbBase + this.currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) ) + "' alt='" + this.currentImage.title + "' />";
- else
- h += this.currentImage.title;
- if ( 'none' != link )
- h += "</a>";
-
- var win = window.opener ? window.opener : window.dialogArguments;
- if ( !win )
- win = top;
- tinyMCE = win.tinyMCE;
- if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') ) {
- tinyMCE.selectedInstance.getWin().focus();
- tinyMCE.execCommand('mceInsertContent', false, h);
- } else
- win.edInsertContent(win.edCanvas, h);
- if ( !this.ID )
- this.cancelView();
- return false;
- },
-
- deleteFile: function(id) {
- if ( confirm( this.confirmText.replace(/%title%/g, this.currentImage.title) ) ) {
- jQuery('#action-value').attr('value','delete');
- jQuery('#upload-file').submit();
- return true;
- }
- return false;
- }
-
- };
-
- for ( var property in uploadL10n )
- theFileList[property] = uploadL10n[property];
- theFileList.initializeVars();
- theFileList.initializeLinks();
-} );
-jQuery( function($) { $('#users').wpList(); } );
+jQuery( function($) {
+ $('#users').wpList();
+
+ columns.init('users');
+});
jQuery(function($) {
$('.noscript-action').remove();
+ var reminded = false;
+ var lameWidgetReminder = function() {
+ if ( reminded )
+ return;
+ window.onbeforeunload = function () { return widgetsL10n.lamerReminder };
+ $('h2:first').after( '<div class="updated"><p>' + widgetsL10n.lameReminder + '</p></div>' );
+ $('#current-widgets .submit input[name=save-widgets]').css( 'background-color', '#ffffe0' ).click( function() {
+ window.onbeforeunload = null;
+ } );
+ reminded = true;
+ };
+
var increment = 1;
// Open or close widget control form
var n = parseInt( $('#widget-count').text(), 10 ) + 1;
$('#widget-count').text( n.toString() )
+ lameWidgetReminder();
return false;
};
// onclick for save links
$('a.widget-control-save', context).click( function() {
+ lameWidgetReminder();
toggleWidget( $(this).parents('li:first'), false ).blur()
return false;
} );
JQ('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '<span id="word-count">0</span>' ) );
t.block = 0;
t.wc(co.val());
- co.keyup( function(e) {
+ co.keyup( function(e) {
if ( e.keyCode == last ) return true;
if ( 13 == e.keyCode || 8 == last || 46 == last ) t.wc(co.val());
last = e.keyCode;
setTimeout( function() { t.block = 0; }, 2000 );
}, 1 );
}
- }
+ }
}(jQuery));
jQuery(document).ready( function(){ wpWordCount.init(); } );
createStore : function() {
if ( 'undefined' == typeof google || ! google.gears ) return;
- if ( 'undefined' == typeof localServer )
+ if ( 'undefined' == typeof localServer )
localServer = google.gears.factory.create("beta.localserver");
store = localServer.createManagedStore(this.storeName());
store.manifestUrl = "gears-manifest.php";
store.checkForUpdate();
- this.message();
+ this.message(3);
},
getPermission : function() {
+ var perm = true;
+
if ( 'undefined' != typeof google && google.gears ) {
if ( ! google.gears.factory.hasPermission )
- google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
+ perm = google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
- try {
- this.createStore();
- } catch(e) {} // silence if canceled
+ if ( perm )
+ try { this.createStore(); } catch(e) { this.message(); } // silence if canceled
+ else
+ this.message(4);
}
},
},
message : function(show) {
- var t = this, msg1 = t.I('gears-msg1'), msg2 = t.I('gears-msg2'), msg3 = t.I('gears-msg3'), num = t.I('gears-upd-number'), wait = t.I('gears-wait');
+ var t = this, msg1 = t.I('gears-msg1'), msg2 = t.I('gears-msg2'), msg3 = t.I('gears-msg3'), msg4 = t.I('gears-msg4'), num = t.I('gears-upd-number'), wait = t.I('gears-wait');
if ( ! msg1 ) return;
if ( 'undefined' != typeof google && google.gears ) {
- if ( google.gears.factory.hasPermission ) {
- msg1.style.display = msg2.style.display = 'none';
+ if ( show && show == 4 ) {
+ msg1.style.display = msg2.style.display = msg3.style.display = 'none';
+ msg4.style.display = 'block';
+ } else if ( google.gears.factory.hasPermission ) {
+ msg1.style.display = msg2.style.display = msg4.style.display = 'none';
msg3.style.display = 'block';
if ( 'undefined' == typeof store )
store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);};
store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);};
} else {
- msg1.style.display = msg3.style.display = 'none';
+ msg1.style.display = msg3.style.display = msg4.style.display = 'none';
msg2.style.display = 'block';
}
}
-
- if ( show ) t.I('gears-info-box').style.display = 'block';
},
I : function(id) {
<?php
+/**
+ * Add Link Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
require_once('admin.php');
-$title = __('Add Link');
-$this_file = 'link-manager.php';
-$parent_file = 'post-new.php';
-
+$title = __('Add New Link');
+$parent_file = 'link-manager.php';
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image',
'description', 'visible', 'target', 'category', 'link_id',
wp_enqueue_script('link');
wp_enqueue_script('xfn');
-require('admin-header.php');
-?>
-
-<?php if ($_GET['added'] && '' != $_POST['link_name']) : ?>
-<div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div>
-<?php endif; ?>
-
-<?php
$link = get_default_link_to_edit();
include('edit-link-form.php');
<?php
+/**
+ * Manage link category administration actions.
+ *
+ * This page is accessed by the link management pages and handles the forms and
+ * AJAX processes for category actions.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
require_once('admin.php');
wp_reset_vars(array('action', 'cat'));
$default_cat_id = get_option('default_link_category');
// Don't delete the default cats.
- if ( $cat_ID == $default_cat_id )
+ if ( $cat_ID == $default_cat_id )
wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
break;
case 'edit':
- $title = __('Categories');
- $parent_file = 'edit.php';
+ $title = __('Edit Category');
+ $parent_file = 'link-manager.php';
$submenu_file = 'edit-link-categories.php';
require_once ('admin-header.php');
$cat_ID = (int) $_GET['cat_ID'];
<?php
-
+/**
+ * Link Management Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
require_once ('admin.php');
// Handle bulk deletes
-if ( isset($_GET['deleteit']) && isset($_GET['linkcheck']) ) {
+if ( isset($_GET['action']) && isset($_GET['linkcheck']) ) {
check_admin_referer('bulk-bookmarks');
+ $doaction = $_GET['action'] ? $_GET['action'] : $_GET['action2'];
if ( ! current_user_can('manage_links') )
wp_die( __('You do not have sufficient permissions to edit the links for this blog.') );
- foreach ( (array) $_GET['linkcheck'] as $link_id) {
- $link_id = (int) $link_id;
+ if ( 'delete' == $doaction ) {
+ foreach ( (array) $_GET['linkcheck'] as $link_id ) {
+ $link_id = (int) $link_id;
- wp_delete_link($link_id);
- }
+ wp_delete_link($link_id);
+ }
- $sendback = wp_get_referer();
- $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
- wp_redirect($sendback);
- exit;
-} elseif ( !empty($_GET['_wp_http_referer']) ) {
- wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
+ wp_redirect( wp_get_referer() );
+ exit;
+ }
+} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
+ wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
exit;
}
-wp_enqueue_script('admin-forms');
-
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
-if (empty ($cat_id))
+if ( empty($cat_id) )
$cat_id = 'all';
-if (empty ($order_by))
+if ( empty($order_by) )
$order_by = 'order_name';
-$title = __('Manage Links');
-$this_file = $parent_file = 'edit.php';
+$title = __('Edit Links');
+$this_file = $parent_file = 'link-manager.php';
include_once ("./admin-header.php");
if (!current_user_can('manage_links'))
default :
$sqlorderby = 'name';
break;
-}
+} ?>
+
+<div class="wrap nosubsub">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title );
+if ( isset($_GET['s']) && $_GET['s'] )
+ printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
+</h2>
+<?php
if ( isset($_GET['deleted']) ) {
- echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
+ echo '<div id="message" class="updated fade"><p>';
$deleted = (int) $_GET['deleted'];
printf(__ngettext('%s link deleted.', '%s links deleted', $deleted), $deleted);
echo '</p></div>';
}
?>
-<div class="wrap">
-
-<form id="posts-filter" action="" method="get">
-<h2><?php printf( __( 'Manage Links (<a href="%s">add new</a>)' ), 'link-add.php' ); ?></h2>
-
-<p id="post-search">
- <label class="hidden" for="post-search-input"><?php _e( 'Search Links' ); ?>:</label>
- <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
+<form class="search-form" action="" method="get">
+<p class="search-box">
+ <label class="hidden" for="link-search-input"><?php _e( 'Search Links' ); ?>:</label>
+ <input type="text" class="search-input" id="link-search-input" name="s" value="<?php _admin_search_query(); ?>" />
<input type="submit" value="<?php _e( 'Search Links' ); ?>" class="button" />
</p>
-
+</form>
<br class="clear" />
+<form id="posts-filter" action="" method="get">
<div class="tablenav">
-<div class="alignleft">
-<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
+<div class="alignleft actions">
+<select name="action">
+<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
+
<?php
$categories = get_terms('link_category', "hide_empty=1");
$select_cat = "<select name=\"cat_id\">\n";
<br class="clear" />
</div>
-<br class="clear" />
-
-<?php
-$link_columns = array(
- 'name' => '<th style="width: 15%;">' . __('Name') . '</th>',
- 'url' => '<th>' . __('URL') . '</th>',
- 'categories' => '<th>' . __('Categories') . '</th>',
- 'rel' => '<th style="text-align: center">' . __('rel') . '</th>',
- 'visible' => '<th style="text-align: center">' . __('Visible') . '</th>',
-);
-$link_columns = apply_filters('manage_link_columns', $link_columns);
-?>
+<div class="clear"></div>
<?php
if ( 'all' == $cat_id )
$args['search'] = $_GET['s'];
$links = get_bookmarks( $args );
if ( $links ) {
+ $link_columns = get_column_headers('link-manager');
+ $hidden = get_hidden_columns('link-manager');
?>
<?php wp_nonce_field('bulk-bookmarks') ?>
-<table class="widefat">
+<table class="widefat fixed" cellspacing="0">
<thead>
<tr>
- <th scope="col" class="check-column"><input type="checkbox" /></th>
-<?php foreach($link_columns as $column_display_name) {
- echo $column_display_name;
-} ?>
+<?php print_column_headers('link-manager'); ?>
</tr>
</thead>
+
+ <tfoot>
+ <tr>
+<?php print_column_headers('link-manager', false); ?>
+ </tr>
+ </tfoot>
+
<tbody>
<?php
+ $alt = 0;
+
foreach ($links as $link) {
$link = sanitize_bookmark($link);
$link->link_name = attribute_escape($link->link_name);
$link->link_category = wp_get_link_cats($link->link_id);
$short_url = str_replace('http://', '', $link->link_url);
- $short_url = str_replace('www.', '', $short_url);
+ $short_url = preg_replace('/^www./i', '', $short_url);
if ('/' == substr($short_url, -1))
$short_url = substr($short_url, 0, -1);
if (strlen($short_url) > 35)
$short_url = substr($short_url, 0, 32).'...';
-
$visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
- ++ $i;
- $style = ($i % 2) ? '' : ' class="alternate"';
+ $style = ($alt % 2) ? '' : ' class="alternate"';
+ ++ $alt;
+ $edit_link = get_edit_bookmark_link();
?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php
- echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></th>';
foreach($link_columns as $column_name=>$column_display_name) {
+ $class = "class=\"column-$column_name\"";
+
+ $style = '';
+ if ( in_array($column_name, $hidden) )
+ $style = ' style="display:none;"';
+ if ( 'visible' == $column_name )
+ $style = empty($style) ? ' style="text-align: center;"' : ' style="text-align: center; display: none;"';
+ $attributes = "$class$style";
+
switch($column_name) {
+ case 'cb':
+ echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></th>';
+ break;
case 'name':
- echo "<td><strong><a class='row-title' href='link.php?link_id=$link->link_id&action=edit' title='" . attribute_escape(sprintf(__('Edit "%s"'), $link->link_name)) . "' class='edit'>$link->link_name</a></strong><br />";
- echo $link->link_description . "</td>";
+ echo "<td $attributes><strong><a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $link->link_name)) . "'>$link->link_name</a></strong><br />";
+ $actions = array();
+ $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
+ $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf( __("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
+ $action_count = count($actions);
+ $i = 0;
+ echo '<div class="row-actions">';
+ foreach ( $actions as $action => $linkaction ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ echo "<span class='$action'>$linkaction$sep</span>";
+ }
+ echo '</div>';
+ echo '</td>';
break;
case 'url':
- echo "<td><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>";
+ echo "<td $attributes><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>";
break;
case 'categories':
- ?><td><?php
+ ?><td <?php echo $attributes ?>><?php
$cat_names = array();
foreach ($link->link_category as $category) {
$cat = get_term($category, 'link_category', OBJECT, 'display');
$cat_names[] = $cat_name;
}
echo implode(', ', $cat_names);
- ?> </td><?php
+ ?></td><?php
break;
case 'rel':
- ?><td><?php echo $link->link_rel; ?></td><?php
+ ?><td <?php echo $attributes ?>><?php echo $link->link_rel; ?></td><?php
break;
case 'visible':
- ?><td style='text-align: center;'><?php echo $visible; ?></td><?php
+ ?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php
break;
default:
?>
<?php } else { ?>
<p><?php _e('No links found.') ?></p>
<?php } ?>
-</form>
-
-<div id="ajax-response"></div>
<div class="tablenav">
+
+<div class="alignleft actions">
+<select name="action2">
+<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
+</div>
+
<br class="clear" />
</div>
+</form>
+
+<div id="ajax-response"></div>
</div>
+<script type="text/javascript">
+/* <![CDATA[ */
+(function($){
+ $(document).ready(function(){
+ $('#doaction, #doaction2').click(function(){
+ if ( $('select[name^="action"]').val() == 'delete' ) {
+ var m = '<?php echo js_escape(__("You are about to delete the selected links.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
+ return showNotice.warn(m);
+ }
+ });
+ });
+})(jQuery);
+columns.init('link-manager');
+/* ]]> */
+</script>
+
<?php include('admin-footer.php'); ?>
<?php
+/**
+ * Parse OPML XML files and store in globals.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
require_once('../wp-load.php');
+global $opml, $map;
+
// columns we wish to find are: link_url, link_name, link_target, link_description
// we need to map XML attribute names to our columns
$opml_map = array('URL' => 'link_url',
$map = $opml_map;
/**
- ** startElement()
- ** Callback function. Called at the start of a new xml tag.
- **/
+ * XML callback function for the start of a new XML tag.
+ *
+ * @since unknown
+ * @access private
+ *
+ * @uses $updated_timestamp Not used inside function.
+ * @uses $all_links Not used inside function.
+ * @uses $map Stores names of attributes to use.
+ * @global array $names
+ * @global array $urls
+ * @global array $targets
+ * @global array $descriptions
+ * @global array $feeds
+ *
+ * @param mixed $parser XML Parser resource.
+ * @param string $tagName XML element name.
+ * @param array $attrs XML element attributes.
+ */
function startElement($parser, $tagName, $attrs) {
global $updated_timestamp, $all_links, $map;
global $names, $urls, $targets, $descriptions, $feeds;
}
/**
- ** endElement()
- ** Callback function. Called at the end of an xml tag.
- **/
+ * XML callback function that is called at the end of a XML tag.
+ *
+ * @since unknown
+ * @access private
+ * @package WordPress
+ * @subpackage Dummy
+ *
+ * @param mixed $parser XML Parser resource.
+ * @param string $tagName XML tag name.
+ */
function endElement($parser, $tagName) {
// nothing to do.
}
<?php
+/**
+ * Manage link administration actions.
+ *
+ * This page is accessed by the link management pages and handles the forms and
+ * AJAX processes for link actions.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
require_once ('admin.php');
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
if ( ! current_user_can('manage_links') )
wp_die( __('You do not have sufficient permissions to edit the links for this blog.') );
-if ('' != $_POST['deletebookmarks'])
+if ( !empty($_POST['deletebookmarks']) )
$action = 'deletebookmarks';
-if ('' != $_POST['move'])
+if ( !empty($_POST['move']) )
$action = 'move';
-if ('' != $_POST['linkcheck'])
- $linkcheck = $_POST[linkcheck];
+if ( !empty($_POST['linkcheck']) )
+ $linkcheck = $_POST['linkcheck'];
$this_file = 'link-manager.php';
wp_enqueue_script('link');
wp_enqueue_script('xfn');
- $parent_file = 'edit.php';
+ $parent_file = 'link-manager.php';
$submenu_file = 'link-manager.php';
$title = __('Edit Link');
if (!$link = get_link_to_edit($link_id))
wp_die(__('Link not found.'));
- include_once ('admin-header.php');
include ('edit-link-form.php');
include ('admin-footer.php');
break;
default :
break;
}
-?>
\ No newline at end of file
+?>
--- /dev/null
+<?php
+/**
+ * Upload new media Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+$_GET['inline'] = 'true';
+/** Administration bootstrap */
+require_once('admin.php');
+require_once('media-upload.php');
+
+?>
\ No newline at end of file
<?php
+/**
+ * Manage media uploaded file.
+ *
+ * There are many filters in here for media. Plugins can extend functionality
+ * by hooking into the filters.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
require_once('admin.php');
+
+if (!current_user_can('upload_files'))
+ wp_die(__('You do not have permission to upload files.'));
+
wp_enqueue_script('swfupload');
-wp_enqueue_script('swfupload-degrade');
+wp_enqueue_script('swfupload-swfobject');
wp_enqueue_script('swfupload-queue');
wp_enqueue_script('swfupload-handlers');
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
-if (!current_user_can('upload_files'))
- wp_die(__('You do not have permission to upload files.'));
-
// IDs should be integers
-$ID = isset($ID)? (int) $ID : 0;
+$ID = isset($ID) ? (int) $ID : 0;
$post_id = isset($post_id)? (int) $post_id : 0;
// Require an ID for the edit screen
if ( isset($action) && $action == 'edit' && !$ID )
wp_die(__("You are not allowed to be here"));
-// upload type: image, video, file, ..?
-if ( isset($_GET['type']) )
- $type = strval($_GET['type']);
-else
- $type = apply_filters('media_upload_default_type', 'file');
+if ( isset($_GET['inline']) ) {
+
+ if ( isset($_GET['upload-page-form']) ) {
+ $errors = media_upload_form_handler();
+
+ $location = 'upload.php';
+ if ( $errors )
+ $location .= '?message=3';
+
+ wp_redirect( admin_url($location) );
+ }
+
+ if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
+ // Upload File button was clicked
+ $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
+ unset($_FILES);
+ if ( is_wp_error($id) ) {
+ $errors['upload_error'] = $id;
+ $id = false;
+ }
+ }
+
+ $title = __('Upload New Media');
+ $parent_file = 'upload.php';
+ require_once('admin-header.php'); ?>
+ <div class="wrap">
+ <?php screen_icon(); ?>
+ <h2><?php echo wp_specialchars( $title ); ?></h2>
+
+ <form enctype="multipart/form-data" method="post" action="media-upload.php?inline=&upload-page-form=" class="media-upload-form type-form validate" id="file-form">
+
+ <?php media_upload_form(); ?>
+
+ <script type="text/javascript">
+ jQuery(function($){
+ var preloaded = $(".media-item.preloaded");
+ if ( preloaded.length > 0 ) {
+ preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
+ }
+ updateMediaForm();
+ post_id = 0;
+ shortform = 1;
+ });
+ </script>
+ <input type="hidden" name="post_id" id="post_id" value="0" />
+ <?php wp_nonce_field('media-form'); ?>
+ <div id="media-items"> </div>
+ <p>
+ <input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
+ </p>
+ </form>
+ </div>
+
+<?php
+ include('admin-footer.php');
+
+} else {
-// tab: gallery, library, or type-specific
-if ( isset($_GET['tab']) )
- $tab = strval($_GET['tab']);
-else
- $tab = apply_filters('media_upload_default_tab', 'type');
+ // upload type: image, video, file, ..?
+ if ( isset($_GET['type']) )
+ $type = strval($_GET['type']);
+ else
+ $type = apply_filters('media_upload_default_type', 'file');
-$body_id = 'media-upload';
+ // tab: gallery, library, or type-specific
+ if ( isset($_GET['tab']) )
+ $tab = strval($_GET['tab']);
+ else
+ $tab = apply_filters('media_upload_default_tab', 'type');
-// let the action code decide how to handle the request
-if ( $tab == 'type' )
- do_action("media_upload_$type");
-else
- do_action("media_upload_$tab");
+ $body_id = 'media-upload';
+ // let the action code decide how to handle the request
+ if ( $tab == 'type' || $tab == 'type_url' )
+ do_action("media_upload_$type");
+ else
+ do_action("media_upload_$tab");
+}
?>
<?php
-
+/**
+ * Media management action handler.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
require_once('admin.php');
-$parent_file = 'edit.php';
+$parent_file = 'upload.php';
$submenu_file = 'upload.php';
wp_reset_vars(array('action'));
$errors = media_upload_form_handler();
-
- check_admin_referer('media-form');
-
- if ( !current_user_can('edit_post', $attachment_id) )
- wp_die ( __('You are not allowed to edit this attachment.') );
-
if ( empty($errors) ) {
$location = 'media.php';
if ( $referer = wp_get_original_referer() ) {
add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
wp_enqueue_script( 'wp-ajax-response' );
- wp_admin_css( 'media' );
-
+// wp_admin_css( 'media' );
require( 'admin-header.php' );
+ $parent_file = 'upload.php';
$message = '';
$class = '';
if ( isset($_GET['message']) ) {
?>
<div class="wrap">
-
+<?php screen_icon(); ?>
<h2><?php _e( 'Edit Media' ); ?></h2>
<form method="post" action="<?php echo clean_url( remove_query_arg( 'message' ) ); ?>" class="media-upload-form" id="media-single-form">
-<div id="media-items" class="media-single">
+<div class="media-single">
<div id='media-item-<?php echo $att_id; ?>' class='media-item'>
-<?php echo get_media_item( $att_id, array( 'toggle' => false, 'send' => false, 'delete' => false, 'errors' => $errors ) ); ?>
+<?php echo get_media_item( $att_id, array( 'toggle' => false, 'send' => false, 'delete' => false, 'show_title' => false, 'errors' => $errors ) ); ?>
</div>
</div>
<p class="submit">
-<input type="submit" class="button" name="save" value="<?php _e('Save Changes'); ?>" />
+<input type="submit" class="button-primary" name="save" value="<?php _e('Update Media'); ?>" />
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
<input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo $att_id; ?>" />
<input type="hidden" name="action" value="editattachment" />
<?php
+/**
+ * Displays Administration Menu.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * The current page.
+ *
+ * @global string $self
+ * @name $self
+ * @var string
+ */
$self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
$self = preg_replace('|^.*/plugins/|i', '', $self);
get_admin_page_parent();
-// We're going to do this loop three times
-?>
-
-<ul id="dashmenu">
-<?php
-foreach ( $menu as $key => $item ) {
- if ( 3 < $key ) // get each menu item before 3
- continue;
- $class = '';
- // 0 = name, 1 = capability, 2 = file
- if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
-
- if ( !empty($submenu[$item[2]]) ) {
- $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
- $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
- if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
- echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
- else
- echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
- } else if ( current_user_can($item[1]) ) {
- $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
- if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
- echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
- else
- echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
+/**
+ * Display menu.
+ *
+ * @access private
+ * @since 2.7.0
+ *
+ * @param array $menu
+ * @param array $submenu
+ * @param bool $submenu_as_parent
+ */
+function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
+ global $self, $parent_file, $submenu_file, $plugin_page, $pagenow;
+
+ $first = true;
+ // 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src
+ foreach ( $menu as $key => $item ) {
+ $admin_is_parent = false;
+ $class = array();
+ if ( $first ) {
+ $class[] = 'wp-first-item';
+ $first = false;
+ }
+ if ( !empty($submenu[$item[2]]) )
+ $class[] = 'wp-has-submenu';
+
+ if ( ( $parent_file && $item[2] == $parent_file ) || strcmp($self, $item[2]) == 0 ) {
+ if ( !empty($submenu[$item[2]]) )
+ $class[] = 'wp-has-current-submenu wp-menu-open';
+ else
+ $class[] = 'current';
+ }
+
+ if ( isset($item[4]) && ! empty($item[4]) )
+ $class[] = $item[4];
+
+ $class = $class ? ' class="' . join( ' ', $class ) . '"' : '';
+ $tabindex = ' tabindex="1"';
+ $id = isset($item[5]) && ! empty($item[5]) ? ' id="' . preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $item[5] ) . '"' : '';
+ $img = '';
+ if ( isset($item[6]) && ! empty($item[6]) ) {
+ if ( 'div' === $item[6] )
+ $img = '<div class="wp-menu-image"><br /></div>';
+ else
+ $img = '<img class="wp-menu-image" src="' . $item[6] . '" alt="" />';
+ }
+ $toggle = '<div class="wp-menu-toggle"><br /></div>';
+
+ echo "\n\t<li$class$id>";
+
+ if ( false !== strpos($class, 'wp-menu-separator') ) {
+ echo '<br />';
+ } elseif ( $submenu_as_parent && !empty($submenu[$item[2]]) ) {
+ $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
+ $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
+ if ( ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") && ('index.php' != $submenu[$item[2]][0][2]) ) || !empty($menu_hook)) {
+ $admin_is_parent = true;
+ echo "$img$toggle<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class$tabindex>{$item[0]}</a>";
+ } else {
+ echo "\n\t$img$toggle<a href='{$submenu[$item[2]][0][2]}'$class$tabindex>{$item[0]}</a>";
+ }
+ } else if ( current_user_can($item[1]) ) {
+ $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
+ if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) ) {
+ $admin_is_parent = true;
+ echo "\n\t$img$toggle<a href='admin.php?page={$item[2]}'$class$tabindex>{$item[0]}</a>";
+ } else {
+ echo "\n\t$img$toggle<a href='{$item[2]}'$class$tabindex>{$item[0]}</a>";
+ }
+ }
+
+ if ( !empty($submenu[$item[2]]) ) {
+ echo "\n\t<div class='wp-submenu'><div class='wp-submenu-head'>{$item[0]}</div><ul>";
+ $first = true;
+ foreach ( $submenu[$item[2]] as $sub_key => $sub_item ) {
+ if ( !current_user_can($sub_item[1]) )
+ continue;
+
+ $class = array();
+ if ( $first ) {
+ $class[] = 'wp-first-item';
+ $first = false;
+ }
+ if ( isset($submenu_file) ) {
+ if ( $submenu_file == $sub_item[2] )
+ $class[] = 'current';
+ // If plugin_page is set the parent must either match the current page or not physically exist.
+ // This allows plugin pages with the same hook to exist under different parents.
+ } else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($item[2]) || ($item[2] == $self))) || (!isset($plugin_page) && $self == $sub_item[2]) ) {
+ $class[] = 'current';
+ }
+
+ $class = $class ? ' class="' . join( ' ', $class ) . '"' : '';
+
+ $menu_hook = get_plugin_page_hook($sub_item[2], $item[2]);
+
+ if ( ( file_exists(WP_PLUGIN_DIR . "/{$sub_item[2]}") && ('index.php' != $sub_item[2]) ) || ! empty($menu_hook) ) {
+ // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir
+ $parent_exists = (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/{$item[2]}") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") ) || file_exists($item[2]);
+ if ( $parent_exists )
+ echo "<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>";
+ elseif ( 'admin.php' == $pagenow || !$parent_exists )
+ echo "<li$class><a href='admin.php?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>";
+ else
+ echo "<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>";
+ } else {
+ echo "<li$class><a href='{$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>";
+ }
+ }
+ echo "</ul></div>";
+ }
+ echo "</li>";
}
}
-do_action( 'dashmenu' );
+
?>
-</ul>
<ul id="adminmenu">
-<?php
-foreach ( $menu as $key => $item ) {
- if ( 5 > $key || $key > 25 ) // get each menu item before 3
- continue;
-
- $class = '';
-
- // 0 = name, 1 = capability, 2 = file
- if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
-
- if ( !empty($submenu[$item[2]]) ) {
- $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
- $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
- if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
- echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
- else
- echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
- } else if ( current_user_can($item[1]) ) {
- $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
- if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
- echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
- else
- echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
- }
-}
-foreach ( $menu as $key => $item ) {
- if ( $key < 41 ) // there is a more efficient way to do this!
- continue;
-
- $class = '';
-
- // 0 = name, 1 = capability, 2 = file
- if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
-
- if ( !empty($submenu[$item[2]]) ) {
- $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
- $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
- if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
- echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
- else
- echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
- } else if ( current_user_can($item[1]) ) {
- $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
- if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
- echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
- else
- echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
- }
-}
-
-do_action( 'adminmenu' );
-?>
-</ul>
-
-<ul id="sidemenu">
<?php
-$side_items = array();
-foreach ( $menu as $key => $item ) {
- if ( 26 > $key || $key > 40 )
- continue;
-
- $class = '';
-
- // 0 = name, 1 = capability, 2 = file
- if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
-
- if ( !empty($submenu[$item[2]]) ) {
- $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
- $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
- if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
- $side_items[] = "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
- else
- $side_items[] = "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
- } else if ( current_user_can($item[1]) ) {
- $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
- if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
- $side_items[] = "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a>";
- else
- $side_items[] = "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a>";
- }
-}
-echo implode(' </li>', $side_items) . '</li>';
-unset($side_items);
-do_action( 'sidemenu' );
-?>
-</ul>
+_wp_menu_output( $menu, $submenu );
+do_action( 'adminmenu' );
-<?php
-// Sub-menu
-if ( isset($submenu["$parent_file"]) ) :
-?>
-<ul id="submenu">
-<?php
-foreach ($submenu["$parent_file"] as $item) :
- if ( !current_user_can($item[1]) )
- continue;
-
-if ( isset($submenu_file) ) {
- if ( $submenu_file == $item[2] ) $class = ' class="current"';
- else $class = '';
-} else if ( (isset($plugin_page) && $plugin_page == $item[2]) || (!isset($plugin_page) && $self == $item[2]) ) $class = ' class="current"';
-else $class = '';
-
-$menu_hook = get_plugin_page_hook($item[2], $parent_file);
-
-if (file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || ! empty($menu_hook)) {
- if ( 'admin.php' == $pagenow )
- echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
- else
- echo "\n\t<li><a href='{$parent_file}?page={$item[2]}'$class>{$item[0]}</a></li>";
- } else {
- echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
- }
-endforeach;
-?>
-
-</ul>
-<?php
-else :
?>
-<div id="minisub"></div>
-<?php
-
-endif;
-
-do_action('admin_notices');
-
-?>
\ No newline at end of file
+</ul>
\ No newline at end of file
<?php
-// This array constructs the admin menu bar.
-//
-// Menu item name
-// The minimum level the user needs to access the item: between 0 and 10
-// The URL of the item's file
-$menu[0] = array(__('Dashboard'), 'read', 'index.php');
-
-if (strpos($_SERVER['REQUEST_URI'], 'edit-pages.php') !== false)
- $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php');
-elseif (strpos($_SERVER['REQUEST_URI'], 'link-manager.php') !== false)
- $menu[5] = array(__('Write'), 'manage_links', 'link-add.php');
-else
- $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php');
-
-if (strpos($_SERVER['REQUEST_URI'], 'page-new.php') !== false)
- $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php');
-elseif (strpos($_SERVER['REQUEST_URI'], 'link-add.php') !== false)
- $menu[10] = array(__('Manage'), 'manage_links', 'link-manager.php');
-else
- $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
+/**
+ * Build Administration Menu.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Constructs the admin menu bar.
+ *
+ * The elements in the array are :
+ * 0: Menu item name
+ * 1: Minimum level or capability required.
+ * 2: The URL of the item's file
+ * 3: Class
+ * 4: ID
+ * 5: Icon for top level menu
+ *
+ * @global array $menu
+ * @name $menu
+ * @var array
+ */
$awaiting_mod = wp_count_comments();
$awaiting_mod = $awaiting_mod->moderated;
-$menu[15] = array(__('Design'), 'switch_themes', 'themes.php');
-$menu[20] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='comment-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php');
-$menu[30] = array(__('Settings'), 'manage_options', 'options-general.php');
-$update_plugins = get_option( 'update_plugins' );
-$update_count = count( $update_plugins->response );
-$menu[35] = array( sprintf( __('Plugins %s'), "<span id='update-plugins' class='count-$update_count'><span class='plugin-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'activate_plugins', 'plugins.php');
-if ( current_user_can('edit_users') )
- $menu[40] = array(__('Users'), 'edit_users', 'users.php');
-else
- $menu[40] = array(__('Profile'), 'read', 'profile.php');
+$menu[0] = array( __('Dashboard'), 'read', 'index.php', '', 'menu-top', 'menu-dashboard', 'div' );
+
+$menu[4] = array( '', 'read', '', '', 'wp-menu-separator' );
+
+$menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'wp-menu-open menu-top', 'menu-posts', 'div' );
+ $submenu['edit.php'][5] = array( __('Edit'), 'edit_posts', 'edit.php' );
+ $submenu['edit.php'][10] = array( _c('Add New|post'), 'edit_posts', 'post-new.php' );
+ $submenu['edit.php'][15] = array( __('Tags'), 'manage_categories', 'edit-tags.php' );
+ $submenu['edit.php'][20] = array( __('Categories'), 'manage_categories', 'categories.php' );
+
+$menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top', 'menu-media', 'div' );
+ $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
+ $submenu['upload.php'][10] = array( _c('Add New|file'), 'upload_files', 'media-new.php');
+
+$menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top', 'menu-links', 'div' );
+ $submenu['link-manager.php'][5] = array( __('Edit'), 'manage_links', 'link-manager.php' );
+ $submenu['link-manager.php'][10] = array( _c('Add New|links'), 'manage_links', 'link-add.php' );
+ $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-link-categories.php' );
+
+$menu[20] = array( __('Pages'), 'edit_pages', 'edit-pages.php', '', 'menu-top', 'menu-pages', 'div' );
+ $submenu['edit-pages.php'][5] = array( __('Edit'), 'edit_pages', 'edit-pages.php' );
+ $submenu['edit-pages.php'][10] = array( _c('Add New|page'), 'edit_pages', 'page-new.php' );
+
+$menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top', 'menu-comments', 'div' );
-$_wp_real_parent_file['post.php'] = 'post-new.php'; // Back-compat
-$submenu['post-new.php'][5] = array(__('Post'), 'edit_posts', 'post-new.php');
-$submenu['post-new.php'][10] = array(__('Page'), 'edit_pages', 'page-new.php');
-$submenu['post-new.php'][15] = array(__('Link'), 'manage_links', 'link-add.php');
+$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
-$submenu['edit-comments.php'][5] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
+$menu[39] = array( '', 'read', '', '', 'wp-menu-separator' );
-$submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php');
-$submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php');
-$submenu['edit.php'][15] = array(__('Links'), 'manage_links', 'link-manager.php');
-$submenu['edit.php'][20] = array(__('Categories'), 'manage_categories', 'categories.php');
-$submenu['edit.php'][25] = array(__('Tags'), 'manage_categories', 'edit-tags.php');
-$submenu['edit.php'][30] = array(__('Link Categories'), 'manage_categories', 'edit-link-categories.php');
-$submenu['edit.php'][35] = array(__('Media Library'), 'upload_files', 'upload.php');
-$submenu['edit.php'][40] = array(__('Import'), 'import', 'import.php');
-$submenu['edit.php'][45] = array(__('Export'), 'import', 'export.php');
+$menu[40] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top', 'menu-appearance', 'div' );
+ $submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
+ $submenu['themes.php'][10] = array(__('Editor'), 'edit_themes', 'theme-editor.php');
+
+$update_plugins = get_option( 'update_plugins' );
+$update_count = 0;
+if ( !empty($update_plugins->response) )
+ $update_count = count( $update_plugins->response );
+
+$menu[45] = array( sprintf( __('Plugins %s'), "<span class='update-plugins count-$update_count'><span class='plugin-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'activate_plugins', 'plugins.php', '', 'menu-top', 'menu-plugins', 'div' );
+ $submenu['plugins.php'][5] = array( __('Installed'), 'activate_plugins', 'plugins.php' );
+ $submenu['plugins.php'][10] = array(_c('Add New|plugin'), 'install_plugins', 'plugin-install.php');
+ $submenu['plugins.php'][15] = array( __('Editor'), 'edit_plugins', 'plugin-editor.php' );
+
+if ( current_user_can('edit_users') )
+ $menu[50] = array( __('Users'), 'edit_users', 'users.php', '', 'menu-top', 'menu-users', 'div' );
+else
+ $menu[50] = array( __('Profile'), 'read', 'profile.php', '', 'menu-top', 'menu-users', 'div' );
if ( current_user_can('edit_users') ) {
$_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
$submenu['users.php'][5] = array(__('Authors & Users'), 'edit_users', 'users.php');
- $submenu['users.php'][10] = array(__('Your Profile'), 'read', 'profile.php');
+ $submenu['users.php'][10] = array(__('Add New'), 'create_users', 'user-new.php');
+ $submenu['users.php'][15] = array(__('Your Profile'), 'read', 'profile.php');
} else {
$_wp_real_parent_file['users.php'] = 'profile.php';
$submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
}
-$submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php');
-$submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php');
-$submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php');
-$submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php');
-$submenu['options-general.php'][30] = array(__('Privacy'), 'manage_options', 'options-privacy.php');
-$submenu['options-general.php'][35] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
-$submenu['options-general.php'][40] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
+$menu[55] = array( __('Tools'), 'read', 'tools.php', '', 'menu-top', 'menu-tools', 'div' );
+ $submenu['tools.php'][5] = array( __('Tools'), 'read', 'tools.php' );
+ $submenu['tools.php'][10] = array( __('Import'), 'import', 'import.php' );
+ $submenu['tools.php'][15] = array( __('Export'), 'import', 'export.php' );
+ $submenu['tools.php'][20] = array( __('Upgrade'), 'install_plugins', 'update-core.php');
-$submenu['plugins.php'][5] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
-$submenu['plugins.php'][10] = array(__('Plugin Editor'), 'edit_plugins', 'plugin-editor.php');
+$menu[60] = array( __('Settings'), 'manage_options', 'options-general.php', '', 'menu-top', 'menu-settings', 'div' );
+ $submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php');
+ $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php');
+ $submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php');
+ $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php');
+ $submenu['options-general.php'][30] = array(__('Media'), 'manage_options', 'options-media.php');
+ $submenu['options-general.php'][35] = array(__('Privacy'), 'manage_options', 'options-privacy.php');
+ $submenu['options-general.php'][40] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
+ $submenu['options-general.php'][45] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
-$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
-$submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php');
+$_wp_last_utility_menu = 60; // The index of the last top-level menu in the utility menu group
+
+$menu[79] = array( '', 'read', '', '', 'wp-menu-separator-last' );
+
+// Back-compat for old top-levels
+$_wp_real_parent_file['post.php'] = 'edit.php';
+$_wp_real_parent_file['post-new.php'] = 'edit.php';
+$_wp_real_parent_file['page-new.php'] = 'edit-pages.php';
do_action('_admin_menu');
$_wp_submenu_nopriv = array();
$_wp_menu_nopriv = array();
// Loop over submenus and remove pages for which the user does not have privs.
-foreach ($submenu as $parent => $sub) {
- foreach ($sub as $index => $data) {
- if ( ! current_user_can($data[1]) ) {
- unset($submenu[$parent][$index]);
- $_wp_submenu_nopriv[$parent][$data[2]] = true;
+foreach ( array( 'submenu' ) as $sub_loop ) {
+ foreach ($$sub_loop as $parent => $sub) {
+ foreach ($sub as $index => $data) {
+ if ( ! current_user_can($data[1]) ) {
+ unset(${$sub_loop}[$parent][$index]);
+ $_wp_submenu_nopriv[$parent][$data[2]] = true;
+ }
}
- }
- if ( empty($submenu[$parent]) )
- unset($submenu[$parent]);
+ if ( empty(${$sub_loop}[$parent]) )
+ unset(${$sub_loop}[$parent]);
+ }
}
// Loop over the top-level menu.
unset($submenu[$old_parent][$index]);
}
unset($submenu[$old_parent]);
- $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent];
+
+ if ( isset($_wp_submenu_nopriv[$old_parent]) )
+ $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent];
}
}
}
}
+// Remove any duplicated seperators
+$seperator_found = false;
+foreach ( $menu as $id => $data ) {
+ if ( 0 == strcmp('wp-menu-separator', $data[4] ) ) {
+ if (false == $seperator_found) {
+ $seperator_found = true;
+ } else {
+ unset($menu[$id]);
+ $seperator_found = false;
+ }
+ } else {
+ $seperator_found = false;
+ }
+}
+
unset($id);
+function add_cssclass($add, $class) {
+ $class = empty($class) ? $add : $class .= ' ' . $add;
+ return $class;
+}
+
+function add_menu_classes($menu) {
+
+ $first = $lastorder = false;
+ $i = 0;
+ $mc = count($menu);
+ foreach ( $menu as $order => $top ) {
+ $i++;
+
+ if ( 0 == $order ) { // dashboard is always shown/single
+ $menu[0][4] = add_cssclass('menu-top-first menu-top-last', $top[4]);
+ continue;
+ }
+
+ if ( empty($top[2]) ) { // if separator
+ $first = true;
+ if ( $lastorder ) {
+ $c = $menu[$lastorder][4];
+ $menu[$lastorder][4] = add_cssclass('menu-top-last', $c);
+ }
+ continue;
+ }
+
+ if ( $first ) {
+ $c = $menu[$order][4];
+ $menu[$order][4] = add_cssclass('menu-top-first', $c);
+ $first = false;
+ }
+
+ if ( $mc == $i ) { // last item
+ $c = $menu[$order][4];
+ $menu[$order][4] = add_cssclass('menu-top-last', $c);
+ }
+
+ $lastorder = $order;
+ }
+
+ return apply_filters( 'add_menu_classes', $menu );
+}
+
uksort($menu, "strnatcasecmp"); // make it all pretty
+$menu = add_menu_classes($menu);
+
if (! user_can_access_admin_page()) {
do_action('admin_page_access_denied');
wp_die( __('You do not have sufficient permissions to access this page.') );
<?php
+/**
+ * Comment Moderation Administration Panel.
+ *
+ * Redirects to edit-comments.php?comment_status=moderated.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
require_once('../wp-load.php');
wp_redirect('edit-comments.php?comment_status=moderated');
?>
<?php
+/**
+ * Discussion settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
$title = __('Discussion Settings');
?>
<div class="wrap">
-<h2><?php _e('Discussion Settings') ?></h2>
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
<form method="post" action="options.php">
-<?php wp_nonce_field('update-options') ?>
+<?php settings_fields('discussion'); ?>
+
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Default article settings') ?></th>
</fieldset></td>
</tr>
<tr valign="top">
+<th scope="row"><?php _e('Other comment settings') ?></th>
+<td><fieldset><legend class="hidden"><?php _e('Other comment settings') ?></legend>
+<label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label>
+<br />
+<label for="comment_registration">
+<input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> />
+<?php _e('Users must be registered and logged in to comment') ?>
+</label>
+<br />
+
+<label for="close_comments_for_old_posts">
+<input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', get_option('close_comments_for_old_posts')); ?> />
+<?php printf( __('Automatically close comments on articles older than %s days'), '</label><input name="close_comments_days_old" type="text" id="close_comments_days_old" value="' . attribute_escape(get_option('close_comments_days_old')) . '" class="small-text" />') ?>
+<br />
+<label for="thread_comments">
+<input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', get_option('thread_comments')); ?> />
+<?php
+
+$maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 );
+
+$thread_comments_depth = '</label><select name="thread_comments_depth" id="thread_comments_depth">';
+for ( $i = 1; $i <= $maxdeep; $i++ ) {
+ $thread_comments_depth .= "<option value='$i'";
+ if ( get_option('thread_comments_depth') == $i ) $thread_comments_depth .= " selected='selected'";
+ $thread_comments_depth .= ">$i</option>";
+}
+$thread_comments_depth .= '</select>';
+
+printf( __('Enable threaded (nested) comments %s levels deep'), $thread_comments_depth );
+
+?><br />
+<label for="page_comments">
+<input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', get_option('page_comments')); ?> />
+<?php
+
+$default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"';
+if ( 'newest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
+$default_comments_page .= '>' . __('last') . '</option><option value="oldest"';
+if ( 'oldest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
+$default_comments_page .= '>' . __('first') . '</option></select>';
+
+printf( __('Break comments into pages with %1$s comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="text" id="comments_per_page" value="' . attribute_escape(get_option('comments_per_page')) . '" class="small-text" />', $default_comments_page );
+
+?></label>
+<br />
+<label for="comment_order"><?php
+
+$comment_order = '<select name="comment_order" id="comment_order"><option value="asc"';
+if ( 'asc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
+$comment_order .= '>' . __('older') . '</option><option value="desc"';
+if ( 'desc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
+$comment_order .= '>' . __('newer') . '</option></select>';
+
+printf( __('Comments should be displayed with the %s comments at the top of each page'), $comment_order );
+
+?></label>
+</fieldset></td>
+</tr>
+<tr valign="top">
<th scope="row"><?php _e('E-mail me whenever') ?></th>
<td><fieldset><legend class="hidden"><?php _e('E-mail me whenever') ?></legend>
<label for="comments_notify">
<input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_option('comment_moderation')); ?> />
<?php _e('An administrator must always approve the comment') ?> </label>
<br />
-<label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label>
-<br />
<label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_option('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label>
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Comment Moderation') ?></th>
<td><fieldset><legend class="hidden"><?php _e('Comment Moderation') ?></legend>
-<p><label for="comment_max_links"><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="text" id="comment_max_links" size="3" value="' . get_option('comment_max_links'). '" />' ) ?></label></p>
+<p><label for="comment_max_links"><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="text" id="comment_max_links" value="' . get_option('comment_max_links'). '" class="small-text" />' ) ?></label></p>
<p><label for="moderation_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the <a href="edit-comments.php?comment_status=moderated">moderation queue</a>. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?></label></p>
<p>
-<textarea name="moderation_keys" cols="60" rows="10" id="moderation_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('moderation_keys'); ?></textarea>
+<textarea name="moderation_keys" rows="10" cols="50" id="moderation_keys" class="large-text code"><?php form_option('moderation_keys'); ?></textarea>
</p>
</fieldset></td>
</tr>
<td><fieldset><legend class="hidden"><?php _e('Comment Blacklist') ?></legend>
<p><label for="blacklist_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be marked as spam. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?></label></p>
<p>
-<textarea name="blacklist_keys" cols="60" rows="10" id="blacklist_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('blacklist_keys'); ?></textarea>
+<textarea name="blacklist_keys" rows="10" cols="50" id="blacklist_keys" class="large-text code"><?php form_option('blacklist_keys'); ?></textarea>
</p>
</fieldset></td>
</tr>
+<?php do_settings_fields('discussion', 'default'); ?>
</table>
<h3><?php _e('Avatars') ?></h3>
</fieldset></td>
</tr>
-
+<?php do_settings_fields('discussion', 'avatars'); ?>
</table>
+<?php do_settings_sections('discussion'); ?>
<p class="submit">
-<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="default_pingback_flag,default_ping_status,default_comment_status,comments_notify,moderation_notify,comment_moderation,require_name_email,comment_whitelist,comment_max_links,moderation_keys,blacklist_keys,show_avatars,avatar_rating,avatar_default" />
-<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
+<input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</form>
</div>
<?php
+/**
+ * General settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('./admin.php');
$title = __('General Settings');
$parent_file = 'options-general.php';
+/**
+ * Display JavaScript on the page.
+ *
+ * @package WordPress
+ * @subpackage General_Settings_Panel
+ */
+function add_js() {
+?>
+<script type="text/javascript">
+//<![CDATA[
+ jQuery(document).ready(function($){
+ $("input[name='date_format']").click(function(){
+ if ( "date_format_custom_radio" != $(this).attr("id") )
+ $("input[name='date_format_custom']").val( $(this).val() );
+ });
+ $("input[name='date_format_custom']").focus(function(){
+ $("#date_format_custom_radio").attr("checked", "checked");
+ });
+
+ $("input[name='time_format']").click(function(){
+ if ( "time_format_custom_radio" != $(this).attr("id") )
+ $("input[name='time_format_custom']").val( $(this).val() );
+ });
+ $("input[name='time_format_custom']").focus(function(){
+ $("#time_format_custom_radio").attr("checked", "checked");
+ });
+ });
+//]]>
+</script>
+<?php
+}
+add_filter('admin_head', 'add_js');
+
include('./admin-header.php');
?>
<div class="wrap">
-<h2><?php _e('General Settings') ?></h2>
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
<form method="post" action="options.php">
-<?php wp_nonce_field('update-options') ?>
+<?php settings_fields('general'); ?>
+
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="blogname"><?php _e('Blog Title') ?></label></th>
-<td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" size="40" /></td>
+<td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" class="regular-text" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="blogdescription"><?php _e('Tagline') ?></label></th>
-<td><input name="blogdescription" type="text" id="blogdescription" style="width: 95%" value="<?php form_option('blogdescription'); ?>" size="45" />
-<br />
-<?php _e('In a few words, explain what this blog is about.') ?></td>
+<td><input name="blogdescription" type="text" id="blogdescription" value="<?php form_option('blogdescription'); ?>" class="regular-text" />
+<span class="setting-description"><?php _e('In a few words, explain what this blog is about.') ?></span></td>
</tr>
<tr valign="top">
<th scope="row"><label for="siteurl"><?php _e('WordPress address (URL)') ?></label></th>
-<td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" size="40" class="code<?php if ( defined( 'WP_SITEURL' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /></td>
+<td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" class="regular-text code<?php if ( defined( 'WP_SITEURL' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="home"><?php _e('Blog address (URL)') ?></label></th>
-<td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>" size="40" class="code<?php if ( defined( 'WP_HOME' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /><br /><?php _e('Enter the address here if you want your blog homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different from the directory</a> you installed WordPress.'); ?></td>
+<td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>" class="regular-text code<?php if ( defined( 'WP_HOME' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> />
+<span class="setting-description"><?php _e('Enter the address here if you want your blog homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different from the directory</a> you installed WordPress.'); ?></span></td>
</tr>
<tr valign="top">
<th scope="row"><label for="admin_email"><?php _e('E-mail address') ?> </label></th>
-<td><input name="admin_email" type="text" id="admin_email" value="<?php form_option('admin_email'); ?>" size="40" class="code" />
-<br />
-<?php _e('This address is used for admin purposes, like new user notification.') ?></td>
+<td><input name="admin_email" type="text" id="admin_email" value="<?php form_option('admin_email'); ?>" class="regular-text code" />
+<span class="setting-description"><?php _e('This address is used for admin purposes, like new user notification.') ?></span></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Membership') ?></th>
<td> <fieldset><legend class="hidden"><?php _e('Membership') ?></legend><label for="users_can_register">
<input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked('1', get_option('users_can_register')); ?> />
-<?php _e('Anyone can register') ?></label><br />
-<label for="comment_registration">
-<input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> />
-<?php _e('Users must be registered and logged in to comment') ?>
-</label>
+<?php _e('Anyone can register') ?></label>
</fieldset></td>
</tr>
<tr valign="top">
}
?>
</select>
-<?php _e('hours') ?><br />
-<?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), gmdate(__('Y-m-d G:i:s'))); ?><br />
-<?php if ($current_offset) printf(__('UTC %1$s is <code>%2$s</code>'), $current_offset_name, gmdate(__('Y-m-d G:i:s'), current_time('timestamp'))); ?><br />
-<?php _e('Unfortunately, you have to manually update this for Daylight Savings Time. Lame, we know, but will be fixed in the future.'); ?>
+<?php _e('hours') ?>
+<span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n(__('Y-m-d G:i:s'), false, 'gmt')); ?></span>
+<?php if ($current_offset) : ?>
+ <span id="local-time"><?php printf(__('UTC %1$s is <code>%2$s</code>'), $current_offset_name, date_i18n(__('Y-m-d G:i:s'))); ?></span>
+<?php endif; ?>
+<br/>
+<span class="setting-description"><?php _e('Unfortunately, you have to manually update this for Daylight Savings Time. Lame, we know, but will be fixed in the future.'); ?></span>
</td>
</tr>
<tr>
-<th scope="row"><label for="date_format"><?php _e('Date Format') ?></label></th>
-<td><input name="date_format" type="text" id="date_format" size="30" value="<?php form_option('date_format'); ?>" /><br />
-<?php _e('Output:') ?> <strong><?php echo mysql2date(get_option('date_format'), current_time('mysql')); ?></strong></td>
+<th scope="row"><?php _e('Date Format') ?></th>
+<td>
+ <fieldset><legend class="hidden"><?php _e('Date Format') ?></legend>
+<?php
+
+ $date_formats = apply_filters( 'date_formats', array(
+ __('F j, Y'),
+ 'Y/m/d',
+ 'm/d/Y',
+ 'd/m/Y',
+ ) );
+
+ $custom = TRUE;
+
+ foreach ( $date_formats as $format ) {
+ echo "\t<label title='" . attribute_escape($format) . "'><input type='radio' name='date_format' value='" . attribute_escape($format) . "'";
+ if ( get_option('date_format') === $format ) { // checked() uses "==" rather than "==="
+ echo " checked='checked'";
+ $custom = FALSE;
+ }
+ echo ' /> ' . date_i18n( $format ) . "</label><br />\n";
+ }
+
+ echo ' <label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
+ checked( $custom, TRUE );
+ echo '/> ' . __('Custom:') . ' </label><input type="text" name="date_format_custom" value="' . attribute_escape( get_option('date_format') ) . '" class="small-text" /> ' . date_i18n( get_option('date_format') ) . "\n";
+
+ echo "\t<p>" . __('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click "Save Changes" to update sample output.') . "</p>\n";
+?>
+ </fieldset>
+</td>
</tr>
<tr>
-<th scope="row"><label for="time_format"><?php _e('Time Format') ?></label></th>
-<td><input name="time_format" type="text" id="time_format" size="30" value="<?php form_option('time_format'); ?>" /><br />
-<?php _e('Output:') ?> <strong><?php echo gmdate(get_option('time_format'), current_time('timestamp')); ?></strong><br />
-<?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click "Save Changes" to update sample output.') ?></td>
+<th scope="row"><?php _e('Time Format') ?></th>
+<td>
+ <fieldset><legend class="hidden"><?php _e('Time Format') ?></legend>
+<?php
+
+ $time_formats = apply_filters( 'time_formats', array(
+ __('g:i a'),
+ 'g:i A',
+ 'H:i',
+ ) );
+
+ $custom = TRUE;
+
+ foreach ( $time_formats as $format ) {
+ echo "\t<label title='" . attribute_escape($format) . "'><input type='radio' name='time_format' value='" . attribute_escape($format) . "'";
+ if ( get_option('time_format') === $format ) { // checked() uses "==" rather than "==="
+ echo " checked='checked'";
+ $custom = FALSE;
+ }
+ echo ' /> ' . date_i18n( $format ) . "</label><br />\n";
+ }
+
+ echo ' <label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
+ checked( $custom, TRUE );
+ echo '/> ' . __('Custom:') . ' </label><input type="text" name="time_format_custom" value="' . attribute_escape( get_option('time_format') ) . '" class="small-text" /> ' . date_i18n( get_option('time_format') ) . "\n";
+?>
+ </fieldset>
+</td>
</tr>
<tr>
<th scope="row"><label for="start_of_week"><?php _e('Week Starts On') ?></label></th>
?>
</select></td>
</tr>
+<?php do_settings_fields('general', 'default'); ?>
</table>
-<p class="submit"><input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
-<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="<?php if ( ! defined( 'WP_SITEURL' ) ) echo 'siteurl,'; if ( ! defined( 'WP_HOME' ) ) echo 'home,'; ?>blogname,blogdescription,admin_email,users_can_register,gmt_offset,date_format,time_format,start_of_week,comment_registration,default_role" />
+<?php do_settings_sections('general'); ?>
+
+<p class="submit">
+<input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</form>
-<?php wp_reset_vars(array('action', 'standalone', 'option_group_id')); ?>
+<?php
+/**
+ * WordPress Options Header.
+ *
+ * Resets variables: 'action', 'standalone', and 'option_group_id'. Displays
+ * updated message, if updated variable is part of the URL query.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+wp_reset_vars(array('action', 'standalone', 'option_group_id'));
+?>
<?php if (isset($_GET['updated'])) : ?>
<div id="message" class="updated fade"><p><strong><?php _e('Settings saved.') ?></strong></p></div>
--- /dev/null
+<?php
+/**
+ * Media settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('admin.php');
+
+$title = __('Media Settings');
+$parent_file = 'options-general.php';
+
+include('admin-header.php');
+
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
+<form action="options.php" method="post">
+<?php settings_fields('media'); ?>
+
+<h3><?php _e('Image sizes') ?></h3>
+<p><?php _e('The sizes listed below determine the maximum dimensions in pixels to use when inserting an image into the body of a post.'); ?></p>
+
+<table class="form-table">
+<tr valign="top">
+<th scope="row"><?php _e('Thumbnail size') ?></th>
+<td>
+<label for="thumbnail_size_w"><?php _e('Width'); ?></label>
+<input name="thumbnail_size_w" type="text" id="thumbnail_size_w" value="<?php form_option('thumbnail_size_w'); ?>" class="small-text" />
+<label for="thumbnail_size_h"><?php _e('Height'); ?></label>
+<input name="thumbnail_size_h" type="text" id="thumbnail_size_h" value="<?php form_option('thumbnail_size_h'); ?>" class="small-text" /><br />
+<input name="thumbnail_crop" type="checkbox" id="thumbnail_crop" value="1" <?php checked('1', get_option('thumbnail_crop')); ?>/>
+<label for="thumbnail_crop"><?php _e('Crop thumbnail to exact dimensions (normally thumbnails are proportional)'); ?></label>
+</td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><?php _e('Medium size') ?></th>
+<td><fieldset><legend class="hidden"><?php _e('Medium size') ?></legend>
+<label for="medium_size_w"><?php _e('Max Width'); ?></label>
+<input name="medium_size_w" type="text" id="medium_size_w" value="<?php form_option('medium_size_w'); ?>" class="small-text" />
+<label for="medium_size_h"><?php _e('Max Height'); ?></label>
+<input name="medium_size_h" type="text" id="medium_size_h" value="<?php form_option('medium_size_h'); ?>" class="small-text" />
+</fieldset></td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><?php _e('Large size') ?></th>
+<td><fieldset><legend class="hidden"><?php _e('Large size') ?></legend>
+<label for="large_size_w"><?php _e('Max Width'); ?></label>
+<input name="large_size_w" type="text" id="large_size_w" value="<?php form_option('large_size_w'); ?>" class="small-text" />
+<label for="large_size_h"><?php _e('Max Height'); ?></label>
+<input name="large_size_h" type="text" id="large_size_h" value="<?php form_option('large_size_h'); ?>" class="small-text" />
+</fieldset></td>
+</tr>
+
+<?php do_settings_fields('media', 'default'); ?>
+</table>
+
+<?php do_settings_sections('media'); ?>
+
+<p class="submit">
+ <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
+</p>
+
+</form>
+
+</div>
+
+<?php include('./admin-footer.php'); ?>
<?php
+/**
+ * Miscellaneous settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
$title = __('Miscellaneous Settings');
?>
<div class="wrap">
-<h2><?php _e('Miscellaneous Settings') ?></h2>
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
<form method="post" action="options.php">
-<?php wp_nonce_field('update-options') ?>
-<h3><?php _e('Uploading'); ?></h3>
+<?php settings_fields('misc'); ?>
+
+<h3><?php _e('Uploading Files'); ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="upload_path"><?php _e('Store uploads in this folder'); ?></label></th>
-<td><input name="upload_path" type="text" id="upload_path" class="code" value="<?php echo attribute_escape(str_replace(ABSPATH, '', get_option('upload_path'))); ?>" size="40" />
-<br />
-<?php _e('Default is <code>wp-content/uploads</code>'); ?>
+<td><input name="upload_path" type="text" id="upload_path" value="<?php echo attribute_escape(str_replace(ABSPATH, '', get_option('upload_path'))); ?>" class="regular-text code" />
+<span class="setting-description"><?php _e('Default is <code>wp-content/uploads</code>'); ?></span>
</td>
</tr>
<tr valign="top">
-<th scope="row"><label for="upload_url_path"><?php _e('Full URL path to files (optional)'); ?></label></th>
-<td><input name="upload_url_path" type="text" id="upload_url_path" class="code" value="<?php echo attribute_escape( get_option('upload_url_path')); ?>" size="40" />
+<th scope="row"><label for="upload_url_path"><?php _e('Full URL path to files'); ?></label></th>
+<td><input name="upload_url_path" type="text" id="upload_url_path" value="<?php echo attribute_escape( get_option('upload_url_path')); ?>" class="regular-text code" />
+<span class="setting-description"><?php _e('Configuring this is optional by default it should be blank'); ?></span>
</td>
</tr>
<tr>
<th scope="row" colspan="2" class="th-full">
<label for="uploads_use_yearmonth_folders">
-<input name="uploads_use_yearmonth_folders" type="checkbox" id="uploads_use_yearmonth_folders" value="1" <?php checked('1', get_option('uploads_use_yearmonth_folders')); ?> />
+<input name="uploads_use_yearmonth_folders" type="checkbox" id="uploads_use_yearmonth_folders" value="1"<?php checked('1', get_option('uploads_use_yearmonth_folders')); ?> />
<?php _e('Organize my uploads into month- and year-based folders'); ?>
</label>
</th>
</tr>
+<?php do_settings_fields('misc', 'default'); ?>
</table>
-<h3><?php _e('Image sizes') ?></h3>
-<p><?php _e('The sizes listed below determine the maximum dimensions to use when inserting an image into the body of a post.'); ?></p>
-
-<table class="form-table">
-<tr valign="top">
-<th scope="row"><?php _e('Thumbnail size') ?></th>
-<td><fieldset><legend class="hidden"><?php _e('Thumbnail size') ?></legend>
-<label for="thumbnail_size_w"><?php _e('Width'); ?></label>
-<input name="thumbnail_size_w" type="text" id="thumbnail_size_w" value="<?php form_option('thumbnail_size_w'); ?>" size="6" />
-<label for="thumbnail_size_h"><?php _e('Height'); ?></label>
-<input name="thumbnail_size_h" type="text" id="thumbnail_size_h" value="<?php form_option('thumbnail_size_h'); ?>" size="6" /><br />
-<input name="thumbnail_crop" type="checkbox" id="thumbnail_crop" value="1" <?php checked('1', get_option('thumbnail_crop')); ?>/>
-<label for="thumbnail_crop"><?php _e('Crop thumbnail to exact dimensions (normally thumbnails are proportional)'); ?></label>
-</fieldset></td>
-</tr>
-<tr valign="top">
-<th scope="row"><?php _e('Medium size') ?></th>
-<td><fieldset><legend class="hidden"><?php _e('Medium size') ?></legend>
-<label for="medium_size_w"><?php _e('Max Width'); ?></label>
-<input name="medium_size_w" type="text" id="medium_size_w" value="<?php form_option('medium_size_w'); ?>" size="6" />
-<label for="medium_size_h"><?php _e('Max Height'); ?></label>
-<input name="medium_size_h" type="text" id="medium_size_h" value="<?php form_option('medium_size_h'); ?>" size="6" />
-</fieldset></td>
-</tr>
-</table>
-
-
-
<table class="form-table">
<tr>
<th scope="row" class="th-full">
<label for="use_linksupdate">
-<input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_option('use_linksupdate')); ?> />
+<input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1"<?php checked('1', get_option('use_linksupdate')); ?> />
<?php _e('Track Links’ Update Times') ?>
</label>
</th>
<th scope="row" class="th-full">
<label for="hack_file">
-<input type="checkbox" id="hack_file" name="hack_file" value="1" <?php checked('1', get_option('hack_file')); ?> />
+<input type="checkbox" id="hack_file" name="hack_file" value="1"<?php checked('1', get_option('hack_file')); ?> />
<?php _e('Use legacy <code>my-hacks.php</code> file support') ?>
</label>
</th>
</table>
+<?php do_settings_sections('misc'); ?>
+
<p class="submit">
-<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="hack_file,use_linksupdate,uploads_use_yearmonth_folders,upload_path,upload_url_path,thumbnail_size_w,thumbnail_size_h,thumbnail_crop,medium_size_w,medium_size_h" />
-<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" class="button" />
+ <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
+
</form>
</div>
-<?php include('./admin-footer.php'); ?>
\ No newline at end of file
+<?php include('./admin-footer.php'); ?>
<?php
+/**
+ * Permalink settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
$title = __('Permalink Settings');
$parent_file = 'options-general.php';
+/**
+ * Display JavaScript on the page.
+ *
+ * @package WordPress
+ * @subpackage Permalink_Settings_Panel
+ */
function add_js() {
?>
<script type="text/javascript">
<?php endif; ?>
<div class="wrap">
- <h2><?php _e('Customize Permalink Structure') ?></h2>
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
<form name="form" action="options-permalink.php" method="post">
<?php wp_nonce_field('update-permalink') ?>
+
<p><?php _e('By default WordPress uses web <abbr title="Universal Resource Locator">URL</abbr>s which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
<?php
</label>
</th>
<td>
- <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo attribute_escape($permalink_structure); ?>" size="50" />
+ <input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo attribute_escape($permalink_structure); ?>" class="regular-text code" />
</td>
</tr>
</table>
<h3><?php _e('Optional'); ?></h3>
<?php if ($is_apache) : ?>
- <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
+ <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <kbd>topics</kbd> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
<?php else : ?>
<p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code>http://example.org/index.php/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
<?php endif; ?>
<table class="form-table">
<tr>
<th><label for="category_base"><?php _e('Category base'); ?></label></th>
- <td><input name="category_base" id="category_base" type="text" class="code" value="<?php echo attribute_escape($category_base); ?>" size="30" /></td>
+ <td><input name="category_base" id="category_base" type="text" value="<?php echo attribute_escape($category_base); ?>" class="regular-text code" /></td>
</tr>
<tr>
<th><label for="tag_base"><?php _e('Tag base'); ?></label></th>
- <td><input name="tag_base" id="tag_base" type="text" class="code" value="<?php echo attribute_escape($tag_base); ?>" size="30" /></td>
+ <td><input name="tag_base" id="tag_base" type="text" value="<?php echo attribute_escape($tag_base); ?>" class="regular-text code" /></td>
</tr>
+ <?php do_settings_fields('permalink', 'optional'); ?>
</table>
-<p class="submit"><input type="submit" name="submit" class="button" value="<?php _e('Save Changes') ?>" /></p>
+
+<?php do_settings_sections('permalink'); ?>
+
+<p class="submit">
+ <input type="submit" name="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
+</p>
</form>
<?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
<p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
<form action="options-permalink.php" method="post">
<?php wp_nonce_field('update-permalink') ?>
- <p><textarea rows="5" style="width: 98%;" name="rules" id="rules"><?php echo wp_specialchars($wp_rewrite->mod_rewrite_rules()); ?></textarea></p>
+ <p><textarea rows="6" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo wp_specialchars($wp_rewrite->mod_rewrite_rules()); ?></textarea></p>
</form>
<?php endif; ?>
<?php
+/**
+ * Privacy Options Settings Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
require_once('./admin.php');
$title = __('Privacy Settings');
?>
<div class="wrap">
-<h2><?php _e('Privacy Settings') ?></h2>
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
<form method="post" action="options.php">
-<?php wp_nonce_field('update-options') ?>
+<?php settings_fields('privacy'); ?>
+
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Blog Visibility') ?> </th>
<?php do_action('blog_privacy_selector'); ?>
</fieldset></td>
</tr>
+<?php do_settings_fields('privacy', 'default'); ?>
</table>
-<p class="submit"><input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
-<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="blog_public" />
+<?php do_settings_sections('privacy'); ?>
+
+<p class="submit">
+ <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</form>
<?php
+/**
+ * Reading settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
$title = __('Reading Settings');
?>
<div class="wrap">
-<h2><?php _e('Reading Settings') ?></h2>
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
<form name="form1" method="post" action="options.php">
-<?php wp_nonce_field('update-options') ?>
+<?php settings_fields('reading'); ?>
+
<table class="form-table">
<?php if ( get_pages() ): ?>
<tr valign="top">
<tr valign="top">
<th scope="row"><label for="posts_per_page"><?php _e('Blog pages show at most') ?></label></th>
<td>
-<input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" size="3" /> <?php _e('posts') ?>
+<input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" class="small-text" /> <?php _e('posts') ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="posts_per_rss"><?php _e('Syndication feeds show the most recent') ?></label></th>
-<td><input name="posts_per_rss" type="text" id="posts_per_rss" value="<?php form_option('posts_per_rss'); ?>" size="3" /> <?php _e('posts') ?></td>
+<td><input name="posts_per_rss" type="text" id="posts_per_rss" value="<?php form_option('posts_per_rss'); ?>" class="small-text" /> <?php _e('posts') ?></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('For each article in a feed, show') ?> </th>
<tr valign="top">
<th scope="row"><label for="blog_charset"><?php _e('Encoding for pages and feeds') ?></label></th>
-<td><input name="blog_charset" type="text" id="blog_charset" value="<?php form_option('blog_charset'); ?>" size="20" class="code" /><br />
-<?php _e('The character encoding you write your blog in (UTF-8 is <a href="http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html">recommended</a>)') ?></td>
+<td><input name="blog_charset" type="text" id="blog_charset" value="<?php form_option('blog_charset'); ?>" class="regular-text code" />
+<span class="setting-description"><?php _e('The character encoding you write your blog in (UTF-8 is <a href="http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html">recommended</a>)') ?></span></td>
</tr>
+<?php do_settings_fields('reading', 'default'); ?>
</table>
+
+<?php do_settings_sections('reading'); ?>
+
<p class="submit">
-<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="posts_per_page,posts_per_rss,rss_use_excerpt,blog_charset,gzipcompression,show_on_front,page_on_front,page_for_posts" />
-<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
+ <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</form>
</div>
<?php
+/**
+ * Writing settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
$title = __('Writing Settings');
?>
<div class="wrap">
-<h2><?php _e('Writing Settings') ?></h2>
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
<form method="post" action="options.php">
-<?php wp_nonce_field('update-options') ?>
+<?php settings_fields('writing'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="default_post_edit_rows"> <?php _e('Size of the post box') ?></label></th>
-<td><input name="default_post_edit_rows" type="text" id="default_post_edit_rows" value="<?php form_option('default_post_edit_rows'); ?>" size="2" style="width: 1.5em;" />
+<td><input name="default_post_edit_rows" type="text" id="default_post_edit_rows" value="<?php form_option('default_post_edit_rows'); ?>" class="small-text" />
<?php _e('lines') ?></td>
</tr>
<tr valign="top">
</tr>
<tr valign="top">
<th scope="row"><label for="default_category"><?php _e('Default Post Category') ?></label></th>
-<td><select name="default_category" id="default_category">
+<td>
<?php
-$categories = get_categories('get=all');
-foreach ($categories as $category) :
-$category = sanitize_category($category);
-if ($category->term_id == get_option('default_category')) $selected = " selected='selected'";
-else $selected = '';
-echo "\n\t<option value='$category->term_id' $selected>$category->name</option>";
-endforeach;
+wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_category', 'orderby' => 'name', 'selected' => get_option('default_category'), 'hierarchical' => true));
?>
-</select></td>
+</td>
</tr>
<tr valign="top">
<th scope="row"><label for="default_link_category"><?php _e('Default Link Category') ?></label></th>
-<td><select name="default_link_category" id="default_link_category">
+<td>
<?php
-$link_categories = get_terms('link_category', 'get=all');
-foreach ($link_categories as $category) :
-$category = sanitize_term($category, 'link_category');
-if ($category->term_id == get_option('default_link_category')) $selected = " selected='selected'";
-else $selected = '';
-echo "\n\t<option value='$category->term_id' $selected>$category->name</option>";
-endforeach;
+wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_link_category', 'orderby' => 'name', 'selected' => get_option('default_link_category'), 'hierarchical' => true, 'type' => 'link'));
?>
-</select></td>
+</td>
</tr>
+<?php do_settings_fields('writing', 'default'); ?>
</table>
<h3><?php _e('Remote Publishing') ?></h3>
<input name="enable_xmlrpc" type="checkbox" id="enable_xmlrpc" value="1" <?php checked('1', get_option('enable_xmlrpc')); ?> />
<?php _e('Enable the WordPress, Movable Type, MetaWeblog and Blogger XML-RPC publishing protocols.') ?></label><br />
</fieldset></td>
-</tr></table>
+</tr>
+<?php do_settings_fields('writing', 'remote_publishing'); ?>
+</table>
<h3><?php _e('Post via e-mail') ?></h3>
-<p><?php printf(__('To post to WordPress by e-mail you must set up a secret e-mail account with POP3 access. Any mail received at this address will be posted, so it’s a good idea to keep this address very secret. Here are three random strings you could use: <code>%s</code>, <code>%s</code>, <code>%s</code>.'), wp_generate_password(8, false), wp_generate_password(8, false), wp_generate_password(8, false)) ?></p>
+<p><?php printf(__('To post to WordPress by e-mail you must set up a secret e-mail account with POP3 access. Any mail received at this address will be posted, so it’s a good idea to keep this address very secret. Here are three random strings you could use: <kbd>%s</kbd>, <kbd>%s</kbd>, <kbd>%s</kbd>.'), wp_generate_password(8, false), wp_generate_password(8, false), wp_generate_password(8, false)) ?></p>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="mailserver_url"><?php _e('Mail Server') ?></label></th>
-<td><input name="mailserver_url" type="text" id="mailserver_url" value="<?php form_option('mailserver_url'); ?>" size="40" />
+<td><input name="mailserver_url" type="text" id="mailserver_url" value="<?php form_option('mailserver_url'); ?>" class="regular-text" />
<label for="mailserver_port"><?php _e('Port') ?></label>
-<input name="mailserver_port" type="text" id="mailserver_port" value="<?php form_option('mailserver_port'); ?>" size="6" />
+<input name="mailserver_port" type="text" id="mailserver_port" value="<?php form_option('mailserver_port'); ?>" class="small-text" />
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="mailserver_login"><?php _e('Login Name') ?></label></th>
-<td><input name="mailserver_login" type="text" id="mailserver_login" value="<?php form_option('mailserver_login'); ?>" size="40" /></td>
+<td><input name="mailserver_login" type="text" id="mailserver_login" value="<?php form_option('mailserver_login'); ?>" class="regular-text" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="mailserver_pass"><?php _e('Password') ?></label></th>
<td>
-<input name="mailserver_pass" type="text" id="mailserver_pass" value="<?php form_option('mailserver_pass'); ?>" size="40" />
+<input name="mailserver_pass" type="text" id="mailserver_pass" value="<?php form_option('mailserver_pass'); ?>" class="regular-text" />
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="default_email_category"><?php _e('Default Mail Category') ?></label></th>
-<td><select name="default_email_category" id="default_email_category">
+<td>
<?php
-//Alreay have $categories from default_category
-foreach ($categories as $category) :
-$category = sanitize_category($category);
-if ($category->cat_ID == get_option('default_email_category')) $selected = " selected='selected'";
-else $selected = '';
-echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
-endforeach;
+wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_category', 'orderby' => 'name', 'selected' => get_option('default_email_category'), 'hierarchical' => true));
?>
-</select></td>
+</td>
</tr>
+<?php do_settings_fields('writing', 'post_via_email'); ?>
</table>
<h3><?php _e('Update Services') ?></h3>
<p><label for="ping_sites"><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="http://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service <abbr title="Universal Resource Locator">URL</abbr>s with line breaks.') ?></label></p>
-<textarea name="ping_sites" id="ping_sites" style="width: 98%;" rows="3" cols="50"><?php form_option('ping_sites'); ?></textarea>
+<textarea name="ping_sites" id="ping_sites" class="large-text" rows="3"><?php form_option('ping_sites'); ?></textarea>
<?php else : ?>
<?php endif; ?>
+<?php do_settings_sections('writing'); ?>
+
<p class="submit">
-<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags,default_link_category,enable_app,enable_xmlrpc" />
-<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
+ <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</form>
</div>
<?php
+/**
+ * Options Management Administration Panel.
+ *
+ * Just allows for displaying of options.
+ *
+ * This isn't referenced or linked to, but will show all of the options and
+ * allow editing. The issue is that serialized data is not supported to be
+ * modified. Options can not be removed.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
$title = __('Settings');
wp_reset_vars(array('action'));
+$whitelist_options = array(
+ 'general' => array( 'blogname', 'blogdescription', 'admin_email', 'users_can_register', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'default_role' ),
+ 'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
+ 'misc' => array( 'hack_file', 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path' ),
+ 'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ),
+ 'privacy' => array( 'blog_public' ),
+ 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ),
+ 'writing' => array( 'default_post_edit_rows', 'use_smilies', 'ping_sites', 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'enable_app', 'enable_xmlrpc' ),
+ 'options' => array( '' ) );
+if ( !defined( 'WP_SITEURL' ) ) $whitelist_options['general'][] = 'siteurl';
+if ( !defined( 'WP_HOME' ) ) $whitelist_options['general'][] = 'home';
+
+$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
+
if ( !current_user_can('manage_options') )
wp_die(__('Cheatin’ uh?'));
switch($action) {
case 'update':
- $any_changed = 0;
+ if ( isset($_POST[ 'option_page' ]) ) {
+ $option_page = $_POST[ 'option_page' ];
+ check_admin_referer( $option_page . '-options' );
+ } else {
+ // This is for back compat and will eventually be removed.
+ $option_page = 'options';
+ check_admin_referer( 'update-options' );
+ }
- check_admin_referer('update-options');
+ if ( !isset( $whitelist_options[ $option_page ] ) )
+ wp_die( __( 'Error! Options page not found.' ) );
- if ( !$_POST['page_options'] ) {
- foreach ( (array) $_POST as $key => $value) {
- if ( !in_array($key, array('_wpnonce', '_wp_http_referer')) )
- $options[] = $key;
- }
+ if ( 'options' == $option_page ) {
+ $options = explode(',', stripslashes( $_POST[ 'page_options' ] ));
} else {
- $options = explode(',', stripslashes($_POST['page_options']));
+ $options = $whitelist_options[ $option_page ];
+ }
+
+ // Handle custom date/time formats
+ if ( 'general' == $option_page ) {
+ if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) )
+ $_POST['date_format'] = $_POST['date_format_custom'];
+ if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
+ $_POST['time_format'] = $_POST['time_format_custom'];
}
- if ($options) {
- foreach ($options as $option) {
+ if ( $options ) {
+ foreach ( $options as $option ) {
$option = trim($option);
- $value = $_POST[$option];
- if(!is_array($value)) $value = trim($value);
+ $value = null;
+ if ( isset($_POST[$option]) )
+ $value = $_POST[$option];
+ if ( !is_array($value) ) $value = trim($value);
$value = stripslashes_deep($value);
update_option($option, $value);
}
}
- $goback = add_query_arg('updated', 'true', wp_get_referer());
- wp_redirect($goback);
- break;
+ $goback = add_query_arg( 'updated', 'true', wp_get_referer() );
+ wp_redirect( $goback );
+ break;
default:
include('admin-header.php'); ?>
<div class="wrap">
+<?php screen_icon(); ?>
<h2><?php _e('All Settings'); ?></h2>
<form name="form" action="options.php" method="post" id="all-options">
- <?php wp_nonce_field('update-options') ?>
+ <?php wp_nonce_field('options-options') ?>
<input type="hidden" name="action" value="update" />
+ <input type='hidden' name='option_page' value='options' />
<table class="form-table">
<?php
$options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
<td>";
if (strpos($value, "\n") !== false) echo "<textarea class='$class' name='$option->option_name' id='$option->option_name' cols='30' rows='5'>" . wp_specialchars($value) . "</textarea>";
- else echo "<input class='$class' type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . attribute_escape($value) . "'$disabled />";
+ else echo "<input class='regular-text $class' type='text' name='$option->option_name' id='$option->option_name' value='" . attribute_escape($value) . "'$disabled />";
echo "</td>
</tr>";
?>
</table>
<?php $options_to_update = implode(',', $options_to_update); ?>
-<p class="submit"><input type="hidden" name="page_options" value="<?php echo $options_to_update; ?>" /><input type="submit" name="Update" value="<?php _e('Save Changes') ?>" /></p>
+<p class="submit"><input type="hidden" name="page_options" value="<?php echo $options_to_update; ?>" /><input type="submit" name="Update" value="<?php _e('Save Changes') ?>" class="button-primary" /></p>
</form>
</div>
<?php
+/**
+ * New page administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
-$title = __('New Page');
-$parent_file = 'post-new.php';
+$title = __('Add New Page');
+$parent_file = 'edit-pages.php';
$editing = true;
wp_enqueue_script('autosave');
wp_enqueue_script('page');
wp_enqueue_script('media-upload');
wp_enqueue_script('word-count');
-require_once('admin-header.php');
-?>
-
-<?php if ( (isset($_GET['posted']) && $_GET['posted']) || isset($_GET['saved']) ) : ?>
-<div id="message" class="updated fade"><p><strong><?php _e('Page saved.') ?></strong> <a href="edit-pages.php"><?php _e('Manage pages'); ?></a> | <a href="<?php echo get_page_link( isset($_GET['posted']) ? $_GET['posted'] : $_GET['saved'] ); ?>"><?php _e('View page') ; ?></a></p></div>
-<?php endif; ?>
-
-<?php
if ( current_user_can('edit_pages') ) {
$action = 'post';
$post = get_default_page_to_edit();
include('edit-page-form.php');
}
-?>
-<?php include('admin-footer.php'); ?>
+include('admin-footer.php');
+
+?>
<?php
+/**
+ * Edit page administration panel.
+ *
+ * Manage edit page: post, edit, delete, etc.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
-$parent_file = 'edit.php';
+$parent_file = 'edit-pages.php';
$submenu_file = 'edit-pages.php';
wp_reset_vars(array('action'));
+/**
+ * Redirect to previous page.
+ *
+ * @param int $page_ID Page ID.
+ */
function redirect_page($page_ID) {
+ global $action;
+
$referredby = '';
if ( !empty($_POST['referredby']) ) {
$referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']);
$location = $_POST['referredby'];
} elseif ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) {
$location = 'sidebar.php?a=b';
- } elseif ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
- if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/page.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/page-new.php') === false )
- $location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "page.php?action=edit&post=$page_ID&message=1" );
- else
- $location = "page.php?action=edit&post=$page_ID&message=4";
- } elseif ($_POST['addmeta']) {
+ } elseif ( ( isset($_POST['save']) || isset($_POST['publish']) ) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
+ if ( isset($_POST['_wp_original_http_referer']) && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/page.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/page-new.php') === false )
+ $location = add_query_arg( array(
+ '_wp_original_http_referer' => urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ),
+ 'message' => 1
+ ), get_edit_post_link( $page_ID, 'url' ) );
+ else {
+ if ( isset( $_POST['publish'] ) ) {
+ if ( 'pending' == get_post_status( $page_ID ) )
+ $location = add_query_arg( 'message', 6, get_edit_post_link( $page_ID, 'url' ) );
+ else
+ $location = add_query_arg( 'message', 5, get_edit_post_link( $page_ID, 'url' ) );
+ } else {
+ $location = add_query_arg( 'message', 4, get_edit_post_link( $page_ID, 'url' ) );
+ }
+ }
+ } elseif ( isset($_POST['addmeta']) ) {
$location = add_query_arg( 'message', 2, wp_get_referer() );
$location = explode('#', $location);
$location = $location[0] . '#postcustom';
- } elseif ($_POST['deletemeta']) {
+ } elseif ( isset($_POST['deletemeta']) ) {
$location = add_query_arg( 'message', 3, wp_get_referer() );
$location = explode('#', $location);
$location = $location[0] . '#postcustom';
} elseif ($action == 'editattachment') {
$location = 'attachments.php';
} else {
- $location = "page.php?action=edit&post=$page_ID&message=4";
+ $location = add_query_arg( 'message', 4, get_edit_post_link( $page_ID, 'url' ) );
}
wp_redirect($location);
}
-if (isset($_POST['deletepost'])) {
-$action = "delete";
-}
+if (isset($_POST['deletepost']))
+ $action = "delete";
+elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] )
+ $action = 'preview';
switch($action) {
case 'post':
break;
case 'edit':
- $title = __('Edit');
+ $title = __('Edit Page');
$editing = true;
$page_ID = $post_ID = $p = (int) $_GET['post'];
$post = get_post_to_edit($page_ID);
}
}
- require_once('admin-header.php');
-
if ( !current_user_can('edit_page', $page_ID) )
die ( __('You are not allowed to edit this page.') );
}
$sendback = wp_get_referer();
- if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page.php');
+ if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?deleted=1');
elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
- $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
+ else $sendback = add_query_arg('deleted', 1, $sendback);
wp_redirect($sendback);
exit();
break;
+case 'preview':
+ check_admin_referer( 'autosave', 'autosavenonce' );
+
+ $url = post_preview();
+
+ wp_redirect($url);
+ exit();
+ break;
+
default:
wp_redirect('edit-pages.php');
exit();
<?php
+/**
+ * Edit plugin editor administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
$title = __("Edit Plugins");
<?php } ?>
</div>
<?php endif; ?>
- <div class="wrap">
-<div class="bordertitle">
- <h2><?php _e('Plugin Editor'); ?></h2>
-</div>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
<div class="tablenav">
<div class="alignleft">
-<big><strong><?php
+<big><?php
if ( is_plugin_active($file) ) {
if ( is_writeable($real_file) )
echo sprintf(__('Editing <strong>%s</strong> (active)'), $file);
else
echo sprintf(__('Browsing <strong>%s</strong> (inactive)'), $file);
}
- ?></strong></big>
+ ?></big>
</div>
<br class="clear" />
</div>
<p class="submit">
<?php
if ( isset($_GET['phperror']) )
- echo "<input type='hidden' name='phperror' value='1' /><input type='submit' name='submit' value='" . __('Update File and Attempt to Reactivate') . "' tabindex='2' />";
+ echo "<input type='hidden' name='phperror' value='1' /><input type='submit' name='submit' class='button-primary' value='" . __('Update File and Attempt to Reactivate') . "' tabindex='2' />";
else
- echo "<input type='submit' name='submit' value='" . __('Update File') . "' tabindex='2' />";
+ echo "<input type='submit' name='submit' class='button-primary' value='" . __('Update File') . "' tabindex='2' />";
?>
</p>
<?php else : ?>
--- /dev/null
+<?php
+/**
+ * Install plugin administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('admin.php');
+
+if ( ! current_user_can('install_plugins') )
+ wp_die(__('You do not have sufficient permissions to install plugins on this blog.'));
+
+include(ABSPATH . 'wp-admin/includes/plugin-install.php');
+
+$title = __('Install Plugins');
+$parent_file = 'plugins.php';
+
+wp_reset_vars( array('tab', 'paged') );
+wp_enqueue_style( 'plugin-install' );
+wp_enqueue_script( 'plugin-install' );
+add_thickbox();
+
+//These are the tabs which are shown on the page,
+$tabs = array();
+$tabs['dashboard'] = __('Start Page'); //TODO: Better name?
+if ( 'search' == $tab )
+ $tabs['search'] = __('Search Results');
+$tabs['featured'] = __('Featured');
+$tabs['popular'] = __('Popular');
+$tabs['new'] = __('Newest');
+$tabs['updated'] = __('Recently Updated');
+
+$nonmenu_tabs = array('install', 'plugin-information', 'upload'); //Valid actions to perform which do not have a Menu item.
+
+$tabs = apply_filters('install_plugins_tabs', $tabs );
+$nonmenu_tabs = apply_filters('install_plugins_nonmenu_tabs', $nonmenu_tabs);
+
+//If a non-valid menu tab has been selected, And its not a non-menu action.
+if( empty($tab) || ( ! isset($tabs[ $tab ]) && ! in_array($tab, (array)$nonmenu_tabs) ) ) {
+ $tab_actions = array_keys($tabs);
+ $tab = $tab_actions[0];
+}
+if( empty($paged) )
+ $paged = 1;
+
+$body_id = $tab;
+
+do_action('install_plugins_pre_' . $tab); //Used to override the general interface, Eg, install or plugin information.
+
+include('admin-header.php');
+?>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
+ <ul class="subsubsub">
+<?php
+$display_tabs = array();
+foreach ( (array)$tabs as $action => $text ) {
+ $sep = ( end($tabs) != $text ) ? ' | ' : '';
+ $class = ( $action == $tab ) ? ' class="current"' : '';
+ $href = admin_url('plugin-install.php?tab='. $action);
+ echo "\t\t<li><a href='$href'$class>$text</a>$sep</li>\n";
+}
+?>
+ </ul>
+ <br class="clear" />
+ <?php do_action('install_plugins_' . $tab, $paged); ?>
+</div>
+<?php
+include('admin-footer.php');
+?>
<?php
+/**
+ * Plugins administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
$action = '';
}
}
-if( isset($_GET['action']) )
- $action = $_GET['action'];
+if( isset($_REQUEST['action']) && !empty($_REQUEST['action']) )
+ $action = $_REQUEST['action'];
-$plugin = $_REQUEST['plugin'];
+$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
if( !empty($action) ) {
switch( $action ) {
check_admin_referer('activate-plugin_' . $plugin);
$result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin);
if ( is_wp_error( $result ) )
- wp_die( $result->get_error_message() );
+ wp_die($result);
$recent = (array)get_option('recently_activated');
- if( isset($recent[ $plugin ]) ){
+ if ( isset($recent[ $plugin ]) ) {
unset($recent[ $plugin ]);
update_option('recently_activated', $recent);
}
$recent = (array)get_option('recently_activated');
foreach( (array)$_POST['checked'] as $plugin => $time) {
- if( isset($recent[ $plugin ]) )
+ if ( isset($recent[ $plugin ]) )
unset($recent[ $plugin ]);
}
if( $recent != get_option('recently_activated') ) //If array changed, update it.
error_reporting( E_ALL ^ E_NOTICE );
@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
include(WP_PLUGIN_DIR . '/' . $plugin);
+ do_action('activate_' . $plugin);
exit;
break;
case 'deactivate':
check_admin_referer('bulk-manage-plugins');
deactivate_plugins($_POST['checked']);
$deactivated = array();
- foreach( (array)$_POST['checked'] as $plugin )
+ foreach ( (array)$_POST['checked'] as $plugin )
$deactivated[ $plugin ] = time();
update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
wp_redirect('plugins.php?deactivate-multi=true');
exit;
break;
case 'delete-selected':
- if( ! current_user_can('delete_plugins') )
+ if ( ! current_user_can('delete_plugins') )
wp_die(__('You do not have sufficient permissions to delete plugins for this blog.'));
-
+
check_admin_referer('bulk-manage-plugins');
-
+
$plugins = $_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen.
include(ABSPATH . 'wp-admin/update.php');
$title = __('Delete Plugin');
$parent_file = 'plugins.php';
-
- if( ! isset($_REQUEST['verify-delete']) ) {
+
+ if ( ! isset($_REQUEST['verify-delete']) ) {
wp_enqueue_script('jquery');
require_once('admin-header.php');
?>
<div class="wrap">
- <h2><?php _e('Delete Plugin(s)'); ?></h2>
+ <h2><?php _e('Delete Plugin(s)'); ?></h2>
<?php
$files_to_delete = $plugin_info = array();
- foreach( (array) $plugins as $plugin ) {
- if( '.' == dirname($plugin) ) {
+ foreach ( (array) $plugins as $plugin ) {
+ if ( '.' == dirname($plugin) ) {
$files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) )
$plugin_info[ $plugin ] = $data;
}
?>
<p><?php _e('Deleting the selected plugins will remove the following plugin(s) and their files:'); ?></p>
- <p>
<ul>
- <?php
- foreach( $plugin_info as $plugin )
- echo '<li>', $plugin['Title'], ' ', __('By'), ' ', $plugin['Author'], '</li>';
+ <?php
+ foreach ( $plugin_info as $plugin )
+ echo '<li>', sprintf(__('%s by %s'), $plugin['Name'], $plugin['Author']), '</li>';
?>
</ul>
- </p>
<p><?php _e('Are you sure you wish to delete these files?') ?></p>
<form method="post" action="<?php echo clean_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
<input type="hidden" name="verify-delete" value="1" />
<input type="hidden" name="delete-selected" value="1" />
<?php
- foreach( (array)$plugins as $plugin ) {
- $plugin = attribute_escape($plugin);
- echo "<input type='hidden' name='checked[]' value='$plugin' />";
- }
+ foreach ( (array)$plugins as $plugin )
+ echo '<input type="hidden" name="checked[]" value="' . attribute_escape($plugin) . '" />';
?>
<?php wp_nonce_field('bulk-manage-plugins') ?>
<input type="submit" name="submit" value="<?php _e('Yes, Delete these files') ?>" class="button" />
<div id="files-list" style="display:none;">
<ul>
<?php
- foreach( (array)$files_to_delete as $file ) {
- $file = str_replace(ABSPATH, '', $file);
- echo "<li>$file</li>";
- }
+ foreach ( (array)$files_to_delete as $file )
+ echo '<li>' . str_replace(WP_PLUGIN_DIR, '', $file) . '</li>';
?>
</ul>
- </div>
+ </div>
</div>
<?php
require_once('admin-footer.php');
}
}
-wp_enqueue_script('admin-forms');
+wp_enqueue_script('plugin-install');
+add_thickbox();
$title = __('Manage Plugins');
require_once('admin-header.php');
$invalid = validate_active_plugins();
-if( !empty($invalid) )
- foreach($invalid as $plugin_file => $error)
+if ( !empty($invalid) )
+ foreach ( $invalid as $plugin_file => $error )
echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), wp_specialchars($plugin_file), $error->get_error_message()) . '</p></div>';
?>
<?php endif; ?>
<div class="wrap">
-<h2><?php _e('Plugin Management'); ?></h2>
+<?php screen_icon(); ?>
+ <h2><?php echo wp_specialchars( $title ); ?></h2>
+
<p><?php _e('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.'); ?></p>
<?php
$active_plugins = array();
$inactive_plugins = array();
$recent_plugins = array();
-$recently_activated = (array)get_option('recently_activated');
+$recently_activated = (array) get_option('recently_activated');
//Clean out any plugins which were deactivated over a week ago.
-foreach( $recently_activated as $key => $time )
- if( $time + (7*24*60*60) < time() ) //1 week
+foreach ( $recently_activated as $key => $time )
+ if ( $time + (7*24*60*60) < time() ) //1 week
unset($recently_activated[ $key ]);
-if( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
+if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
update_option('recently_activated', $recently_activated);
-$plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
+foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
-foreach( (array)$all_plugins as $plugin_file => $plugin_data) {
-
- // Sanitize all displayed data
- $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags);
- $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags);
- $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags);
- $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags);
- if( ! empty($plugin_data['Author']) )
- $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>';
+ //Translate, Apply Markup, Sanitize HTML
+ $plugin_data = _get_plugin_data_markup_translate($plugin_data, true, true);
//Filter into individual sections
if ( is_plugin_active($plugin_file) ) {
?>
<?php
+/**
+ * @ignore
+ *
+ * @param array $plugins
+ * @param string $context
+ */
function print_plugins_table($plugins, $context = '') {
?>
-<table class="widefat" id="<?php echo $context ?>-plugins-table">
+<table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" /></th>
<th scope="col" class="action-links"><?php _e('Action'); ?></th>
</tr>
</thead>
+
+ <tfoot>
+ <tr>
+ <th scope="col" class="check-column"><input type="checkbox" /></th>
+ <th scope="col"><?php _e('Plugin'); ?></th>
+ <th scope="col" class="num"><?php _e('Version'); ?></th>
+ <th scope="col"><?php _e('Description'); ?></th>
+ <th scope="col" class="action-links"><?php _e('Action'); ?></th>
+ </tr>
+ </tfoot>
+
<tbody class="plugins">
<?php
- if( empty($plugins) ) {
+ if ( empty($plugins) ) {
echo '<tr>
<td colspan="6">' . __('No plugins to show') . '</td>
</tr>';
}
- foreach( (array)$plugins as $plugin_file => $plugin_data) {
+ foreach ( (array)$plugins as $plugin_file => $plugin_data) {
$action_links = array();
- if( 'active' == $context )
- $action_links[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '" class="delete">' . __('Deactivate') . '</a>';
- else //Available or Recently deactivated
+ if ( 'active' == $context )
+ $action_links[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
+ else //Inactive or Recently deactivated
$action_links[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
$action_links[] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';
- $action_links = apply_filters('plugin_action_links', $action_links, $plugin_file, $plugin_data, $context);
+ $action_links = apply_filters( 'plugin_action_links', $action_links, $plugin_file, $plugin_data, $context );
+ $action_links = apply_filters( "plugin_action_links_$plugin_file", $action_links, $plugin_file, $plugin_data, $context );
echo "
<tr class='$context'>
<td class='name'>{$plugin_data['Title']}</td>
<td class='vers'>{$plugin_data['Version']}</td>
<td class='desc'><p>{$plugin_data['Description']}</p></td>
- <td class='togl action-links'>";
+ <td class='togl action-links'>";
if ( !empty($action_links) )
echo implode(' | ', $action_links);
- echo '</td>
+ echo '</td>
</tr>';
do_action( 'after_plugin_row', $plugin_file, $plugin_data, $context );
+ do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $context );
}
?>
</tbody>
</table>
-<?php
+<?php
} //End print_plugins_table()
+
+/**
+ * @ignore
+ *
+ * @param string $context
+ */
+function print_plugin_actions($context) {
+?>
+ <div class="alignleft actions">
+ <select name="action">
+ <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
+ <?php if( 'active' != $context ) : ?>
+ <option value="activate-selected"><?php _e('Activate'); ?></option>
+ <?php endif; ?>
+ <?php if ( 'active' == $context ) : ?>
+ <option value="deactivate-selected"><?php _e('Deactivate'); ?></option>
+ <?php endif; ?>
+ <?php if( current_user_can('delete_plugins') && ( 'recent' == $context || 'inactive' == $context ) ) : ?>
+ <option value="delete-selected"><?php _e('Delete'); ?></option>
+ <?php endif; ?>
+ </select>
+ <input type="submit" name="doaction_active" value="<?php _e('Apply'); ?>" class="button-secondary action" />
+ <?php if( 'recent' == $context ) : ?>
+ <input type="submit" name="clear-recent-list" value="<?php _e('Clear List') ?>" class="button-secondary" />
+ <?php endif; ?>
+ </div>
+<?php
+}
?>
<?php if ( ! empty($active_plugins) ) : ?>
<?php wp_nonce_field('bulk-manage-plugins') ?>
<div class="tablenav">
- <div class="alignleft">
- <input type="submit" name="deactivate-selected" value="<?php _e('Deactivate') ?>" class="button-secondary" />
- </div>
+<?php print_plugin_actions('active') ?>
</div>
-<br class="clear" />
+<div class="clear"></div>
<?php print_plugins_table($active_plugins, 'active') ?>
</form>
<?php wp_nonce_field('bulk-manage-plugins') ?>
<div class="tablenav">
- <div class="alignleft">
- <input type="submit" name="activate-selected" value="<?php _e('Activate') ?>" class="button-secondary" />
-<?php if( current_user_can('delete_plugins') ) : ?>
- <input type="submit" name="delete-selected" value="<?php _e('Delete') ?>" class="button-secondary" />
-<?php endif; ?>
- <input type="submit" name="clear-recent-list" value="<?php _e('Clear List') ?>" class="button-secondary" />
- </div>
+<?php print_plugin_actions('recent') ?>
</div>
-<br class="clear" />
+<div class="clear"></div>
<?php print_plugins_table($recent_plugins, 'recent') ?>
</form>
<?php endif; ?>
<?php wp_nonce_field('bulk-manage-plugins') ?>
<div class="tablenav">
- <div class="alignleft">
- <input type="submit" name="activate-selected" value="<?php _e('Activate') ?>" class="button-secondary" />
-<?php if( current_user_can('delete_plugins') ) : ?>
- <input type="submit" name="delete-selected" value="<?php _e('Delete') ?>" class="button-secondary" />
-<?php endif; ?>
- </div>
+<?php print_plugin_actions('inactive') ?>
</div>
-<br class="clear" />
+<div class="clear"></div>
<?php print_plugins_table($inactive_plugins, 'inactive') ?>
</form>
<?php endif; ?>
<?php endif; ?>
<h2><?php _e('Get More Plugins'); ?></h2>
-<p><?php _e('You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>.'); ?></p>
-<p><?php printf(__('To install a plugin you generally just need to upload the plugin file into your <code>%s</code> directory. Once a plugin is uploaded, you may activate it here.'), WP_PLUGIN_DIR); ?></p>
+<p><?php _e('You can find additional plugins for your site by using the new <a href="plugin-install.php">Plugin Browser/Installer</a> functionality, Or by browsing the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> directly and installing manually.'); ?></p>
+<p><?php printf(__('To <em>manually</em> install a plugin you generally just need to upload the plugin file into your <code>%s</code> directory.'), WP_PLUGIN_DIR); ?></p>
+<p><?php _e('Once a plugin has been installed, you may activate it here.'); ?></p>
</div>
<?php
+/**
+ * New Post Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
require_once('admin.php');
-$title = __('Create New Post');
-$parent_file = 'post-new.php';
+$title = __('Add New Post');
+$parent_file = 'edit.php';
$editing = true;
wp_enqueue_script('autosave');
wp_enqueue_script('post');
wp_enqueue_script('media-upload');
wp_enqueue_script('word-count');
-require_once ('./admin-header.php');
-
-if ( ! current_user_can('edit_posts') ) { ?>
+if ( ! current_user_can('edit_posts') ) {
+ require_once ('./admin-header.php'); ?>
<div class="wrap">
<p><?php printf(__('Since you’re a newcomer, you’ll have to wait for an admin to add the <code>edit_posts</code> capability to your user, in order to be authorized to post.<br />
You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
exit();
}
-if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
-<div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&post=<?php echo $_GET['posted']; ?>"><?php _e('Edit post'); ?></a></p></div>
-<?php
-endif;
-?>
-
-
-<?php
-
// Show post form.
$post = get_default_post_to_edit();
include('edit-form-advanced.php');
<?php
+/**
+ * Edit post administration panel.
+ *
+ * Manage Post actions: post, edit, delete, etc.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
$parent_file = 'edit.php';
wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder'));
+/**
+ * Redirect to previous page.
+ *
+ * @param int $post_ID Optional. Post ID.
+ */
function redirect_post($post_ID = '') {
global $action;
if ( !empty($_POST['mode']) && 'bookmarklet' == $_POST['mode'] ) {
$location = $_POST['referredby'];
} elseif ( !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) {
- $location = 'sidebar.php?a=b';
- } elseif ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
- if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post-new.php') === false )
- $location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "post.php?action=edit&post=$post_ID&message=1" );
- else
- $location = "post.php?action=edit&post=$post_ID&message=4";
+ if ( isset($_POST['saveasdraft']) )
+ $location = 'sidebar.php?a=c';
+ elseif ( isset($_POST['publish']) )
+ $location = 'sidebar.php?a=b';
+ } elseif ( ( isset($_POST['save']) || isset($_POST['publish']) ) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
+ if ( isset($_POST['_wp_original_http_referer']) && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post-new.php') === false )
+ $location = add_query_arg( array(
+ '_wp_original_http_referer' => urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ),
+ 'message' => 1
+ ), get_edit_post_link( $post_ID, 'url' ) );
+ else {
+ if ( isset( $_POST['publish'] ) ) {
+ if ( 'pending' == get_post_status( $post_ID ) )
+ $location = add_query_arg( 'message', 8, get_edit_post_link( $post_ID, 'url' ) );
+ else
+ $location = add_query_arg( 'message', 6, get_edit_post_link( $post_ID, 'url' ) );
+ } else {
+ $location = add_query_arg( 'message', 7, get_edit_post_link( $post_ID, 'url' ) );
+ }
+ }
} elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
$location = add_query_arg( 'message', 2, wp_get_referer() );
$location = explode('#', $location);
} elseif (!empty($referredby) && $referredby != $referer) {
$location = $_POST['referredby'];
$location = remove_query_arg('_wp_original_http_referer', $location);
- if ( false !== strpos($location, 'edit.php') )
- $location = add_query_arg('posted', $post_ID, $location);
+ if ( false !== strpos($location, 'edit.php') || false !== strpos($location, 'edit-post-drafts.php') )
+ $location = add_query_arg('posted', $post_ID, $location);
elseif ( false !== strpos($location, 'wp-admin') )
$location = "post-new.php?posted=$post_ID";
} elseif ( isset($_POST['publish']) ) {
$location = "post-new.php?posted=$post_ID";
} elseif ($action == 'editattachment') {
$location = 'attachments.php';
+ } elseif ( 'post-quickpress-save-cont' == $_POST['action'] ) {
+ $location = "post.php?action=edit&post=$post_ID&message=7";
} else {
- $location = "post.php?action=edit&post=$post_ID&message=4";
+ $location = add_query_arg( 'message', 4, get_edit_post_link( $post_ID, 'url' ) );
}
wp_redirect( $location );
if ( isset( $_POST['deletepost'] ) )
$action = 'delete';
+elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] )
+ $action = 'preview';
switch($action) {
case 'postajaxpost':
case 'post':
+case 'post-quickpress-publish':
+case 'post-quickpress-save':
check_admin_referer('add-post');
- $post_ID = 'post' == $action ? write_post() : edit_post();
+ if ( 'post-quickpress-publish' == $action )
+ $_POST['publish'] = 'publish'; // tell write_post() to publish
+
+ if ( 'post-quickpress-publish' == $action || 'post-quickpress-save' == $action ) {
+ $_POST['comment_status'] = get_option('default_comment_status');
+ $_POST['ping_status'] = get_option('default_ping_status');
+ }
+
+ if ( !empty( $_POST['quickpress_post_ID'] ) ) {
+ $_POST['post_ID'] = (int) $_POST['quickpress_post_ID'];
+ $post_ID = edit_post();
+ } else {
+ $post_ID = 'postajaxpost' == $action ? edit_post() : write_post();
+ }
+
+ if ( 0 === strpos( $action, 'post-quickpress' ) ) {
+ $_POST['post_ID'] = $post_ID;
+ // output the quickpress dashboard widget
+ require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
+ wp_dashboard_quick_press();
+ exit;
+ }
redirect_post($post_ID);
exit();
break;
case 'edit':
- $title = __('Edit');
$editing = true;
if ( empty( $_GET['post'] ) ) {
add_thickbox();
wp_enqueue_script('media-upload');
wp_enqueue_script('word-count');
+ wp_enqueue_script( 'admin-comments' );
+ enqueue_comment_hotkeys_js();
if ( current_user_can('edit_post', $post_ID) ) {
if ( $last = wp_check_post_lock( $post->ID ) ) {
}
}
- require_once('admin-header.php');
+ $title = __('Edit Post');
if ( !current_user_can('edit_post', $post_ID) )
die ( __('You are not allowed to edit this post.') );
}
$sendback = wp_get_referer();
- if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('post-new.php');
+ if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?deleted=1');
elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
- $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
+ else $sendback = add_query_arg('deleted', 1, $sendback);
wp_redirect($sendback);
exit();
break;
+case 'preview':
+ check_admin_referer( 'autosave', 'autosavenonce' );
+
+ $url = post_preview();
+
+ wp_redirect($url);
+ exit();
+ break;
+
default:
wp_redirect('edit.php');
exit();
<?php
+/**
+ * Press This Display and Handler.
+ *
+ * @package WordPress
+ * @subpackage Press_This
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' ) );
+/**
+ * Replace forward slash with backslash and slash.
+ *
+ * @package WordPress
+ * @subpackage Press_This
+ * @since 2.6.0
+ *
+ * @param string $string
+ * @return string
+ */
function preg_quote2($string) {
return str_replace('/', '\/', preg_quote($string));
}
+
+/**
+ * Convert characters.
+ *
+ * @package WordPress
+ * @subpackage Press_This
+ * @since 2.6.0
+ *
+ * @param string $text
+ * @return string
+ */
function aposfix($text) {
$translation_table[chr(34)] = '"';
$translation_table[chr(38)] = '&';
$translation_table[chr(39)] = ''';
return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($text, $translation_table));
}
+
+/**
+ * Press It form handler.
+ *
+ * @package WordPress
+ * @subpackage Press_This
+ * @since 2.6.0
+ *
+ * @return int Post ID
+ */
function press_it() {
// define some basic variables
- $quick['post_status'] = isset($_REQUEST['publish']) ? 'publish' : 'draft';
+ $quick['post_status'] = 'draft'; // set as draft first
$quick['post_category'] = $_REQUEST['post_category'];
$quick['tags_input'] = $_REQUEST['tags_input'];
- $quick['post_title'] = $_REQUEST['post_title'];
+ $quick['post_title'] = $_REQUEST['title'];
$quick['post_content'] = '';
// insert the post with nothing in it, to get an ID
$post_ID = wp_insert_post($quick, true);
-
- $content = '';
- switch ( $_REQUEST['post_type'] ) {
- case 'text':
- case 'quote':
- $content .= $_REQUEST['content'];
- break;
-
- case 'photo':
- $content = $_REQUEST['content'];
-
- foreach( (array) $_REQUEST['photo_src'] as $key => $image) {
-
- // see if files exist in content - we don't want to upload non-used selected files.
- if( strpos($_REQUEST['content'], $image) !== false ) {
- $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]);
-
- // Replace the POSTED content <img> with correct uploaded ones.
- // escape quote for matching
- $quoted = preg_quote2($image);
- if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content);
- }
+ $content = $_REQUEST['content'];
+
+ if($_REQUEST['photo_src'])
+ foreach( (array) $_REQUEST['photo_src'] as $key => $image)
+ // see if files exist in content - we don't want to upload non-used selected files.
+ if( strpos($_REQUEST['content'], $image) !== false ) {
+ $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]);
+
+ // Replace the POSTED content <img> with correct uploaded ones.
+ // escape quote for matching
+ $quoted = preg_quote2($image);
+ if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content);
}
- break;
-
- case "video":
- if($_REQUEST['embed_code'])
- $content .= $_REQUEST['embed_code']."\n\n";
- $content .= $_REQUEST['content'];
- break;
- }
- // set the post_content
+ // set the post_content and status
+ $quick['post_status'] = isset($_REQUEST['publish']) ? 'publish' : 'draft';
$quick['post_content'] = $content;
-
// error handling for $post
if ( is_wp_error($post_ID)) {
wp_die($id);
}
// For submitted posts.
-if ( 'post' == $_REQUEST['action'] ) {
- check_admin_referer('press-this'); $post_ID = press_it(); ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
- <head>
- <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
- <title><?php _e('Press This') ?></title>
- <?php
- add_thickbox();
- wp_enqueue_style('press-this');
- wp_enqueue_style('press-this-ie');
- wp_enqueue_style( 'colors' );
- wp_enqueue_script('post');
-
- do_action('admin_print_styles');
- do_action('admin_print_scripts');
- do_action('admin_head');
- ?>
- </head>
- <body class="press-this">
- <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&post=<?php echo $post_ID; ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div>
- <div id="footer">
- <p><?php
- do_action('in_admin_footer', '');
- $upgrade = apply_filters( 'update_footer', '' );
- echo __('Thank you for creating with <a href="http://wordpress.org/">WordPress</a>');
- ?></p>
- </div>
- <?php do_action('admin_footer', ''); ?>
- </body>
- </html>
- <?php die;
+if ( 'post' == $_REQUEST['action'] ) {
+ check_admin_referer('press-this');
+ $post_ID = press_it();
+ $posted = $post_ID;
}
-// Ajax Requests
+// Set Variables
$title = wp_specialchars(aposfix(stripslashes($_GET['t'])));
-
$selection = trim( aposfix( stripslashes($_GET['s']) ) );
if ( ! empty($selection) ) {
$selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection);
$selection = '<p>'.str_replace('<p></p>', '', $selection).'</p>';
}
-
$url = clean_url($_GET['u']);
$image = $_GET['i'];
-if($_REQUEST['ajax'] == 'thickbox') { ?>
- <script type="text/javascript" charset="utf-8">
- jQuery('.cancel').click(function() {
- tb_remove();
- });
+if($_REQUEST['ajax']) {
+switch ($_REQUEST['ajax']) {
+ case 'video': ?>
+ <script type="text/javascript" charset="utf-8">
+ jQuery('.select').click(function() {
+ append_editor(jQuery('#embed-code').val());
+ jQuery('#extra_fields').hide();
+ jQuery('#extra_fields').html('');
+ });
+ jQuery('.close').click(function() {
+ jQuery('#extra_fields').hide();
+ jQuery('#extra_fields').html('');
+ });
+ </script>
+ <div class="postbox">
+ <h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
+ <div class="inside">
+ <textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo format_to_edit($selection, true); ?></textarea>
+ <p id="options"><a href="#" class="select button"><?php _e('Insert Video'); ?></a> <a href="#" class="close button"><?php _e('Cancel'); ?></a></p>
+ </div>
+ </div>
+ <?php break;
- jQuery('.select').click(function() {
- image_selector();
- });
- </script>
- <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3>
- <div class="titlewrap">
- <input id="this_photo_description" name="photo_description" class="text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/>
- </div>
+ case 'photo_thickbox': ?>
+ <script type="text/javascript" charset="utf-8">
+ jQuery('.cancel').click(function() {
+ tb_remove();
+ });
+ jQuery('.select').click(function() {
+ image_selector();
+ });
+ </script>
+ <h3 class="tb"><label for="this_photo_description"><?php _e('Description') ?></label></h3>
+ <div class="titlediv">
+ <div class="titlewrap">
+ <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/>
+ </div>
+ </div>
- <p class="centered"><input type="hidden" name="this_photo" value="<?php echo attribute_escape($image); ?>" id="this_photo" />
- <a href="#" class="select"><img src="<?php echo clean_url($image); ?>" alt="<?php echo attribute_escape(__('Click to insert.')); ?>" title="<?php echo attribute_escape(__('Click to insert.')); ?>" /></a></p>
+ <p class="centered"><input type="hidden" name="this_photo" value="<?php echo attribute_escape($image); ?>" id="this_photo" />
+ <a href="#" class="select"><img src="<?php echo clean_url($image); ?>" alt="<?php echo attribute_escape(__('Click to insert.')); ?>" title="<?php echo attribute_escape(__('Click to insert.')); ?>" /></a></p>
- <p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p>
-<?php die;
-}
+ <p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p>
-if($_REQUEST['ajax'] == 'thickbox_url') { ?>
- <script type="text/javascript" charset="utf-8">
- jQuery('.cancel').click(function() {
- tb_remove();
- });
- jQuery('.select').click(function() {
- image_selector();
- });
- </script>
- <h3 id="title"><label for="post_title"><?php _e('URL') ?></label></h3>
- <div class="titlewrap">
- <input id="this_photo" name="this_photo" class="text" onkeypress="if(event.keyCode==13) image_selector();" />
- </div>
+ <?php break;
+ case 'photo_thickbox_url': ?>
+ <script type="text/javascript" charset="utf-8">
+ jQuery('.cancel').click(function() {
+ tb_remove();
+ });
- <h3 id="title"><label for="post_title"><?php _e('Description') ?></label></h3>
- <div class="titlewrap">
- <input id="this_photo_description" name="photo_description" class="text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/>
- </div>
+ jQuery('.select').click(function() {
+ image_selector();
+ });
+ </script>
+ <h3 class="tb"><label for="this_photo"><?php _e('URL') ?></label></h3>
+ <div class="titlediv">
+ <div class="titlewrap">
+ <input id="this_photo" name="this_photo" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" />
+ </div>
+ </div>
- <p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p>
-<?php die;
-}
-if($_REQUEST['ajax'] == 'video') { ?>
- <h2 id="embededcode"><label for="embed_code"><?php _e('Embed Code') ?></label></h2>
- <div class="titlewrap" >
- <textarea name="embed_code" id="embed_code" rows="8" cols="40"><?php echo format_to_edit($selection); ?></textarea>
- </div>
-<?php die;
-}
+ <h3 class="tb"><label for="photo_description"><?php _e('Description') ?></label></h3>
+ <div id="titlediv">
+ <div class="titlewrap">
+ <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/>
+ </div>
+ </div>
-if($_REQUEST['ajax'] == 'photo_images') {
- function get_images_from_uri($uri) {
- if( preg_match('/\.(jpg|jpe|jpeg|png|gif)/', $uri) && !strpos($uri,'blogger.com') )
- return "'".$uri."'";
-
- $content = wp_remote_fopen($uri);
- if ( false === $content ) return '';
-
- $host = parse_url($uri);
-
- $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))[^<>\'\"]*(\2)([^>\/]*)\/*>/is';
- preg_match_all($pattern, $content, $matches);
-
- if ( empty($matches[1]) ) return '';
-
- $sources = array();
- foreach ($matches[3] as $src) {
- // if no http in url
- if(strpos($src, 'http') === false)
- // if it doesn't have a relative uri
- if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === true)
- $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
- else
- $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
-
- $sources[] = clean_url($src);
+ <p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p>
+ <?php break;
+ case 'photo_images':
+ /**
+ * Retrieve all image URLs from given URI.
+ *
+ * @package WordPress
+ * @subpackage Press_This
+ * @since 2.6.0
+ *
+ * @param string $uri
+ * @return string
+ */
+ function get_images_from_uri($uri) {
+ if( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
+ return "'".$uri."'";
+ $content = wp_remote_fopen($uri);
+ if ( false === $content )
+ return '';
+ $host = parse_url($uri);
+ $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))[^<>\'\"]*(\2)([^>\/]*)\/*>/is';
+ preg_match_all($pattern, $content, $matches);
+ if ( empty($matches[0]) )
+ return '';
+ $sources = array();
+ foreach ($matches[3] as $src) {
+ // if no http in url
+ if(strpos($src, 'http') === false)
+ // if it doesn't have a relative uri
+ if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
+ $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
+ else
+ $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
+ $sources[] = clean_url($src);
+ }
+ return "'" . implode("','", $sources) . "'";
}
- return "'" . implode("','", $sources) . "'";
- }
+ $url = urldecode($url);
+ $url = str_replace(' ', '%20', $url);
+ echo 'new Array('.get_images_from_uri($url).')';
- $url = urldecode($url);
- $url = str_replace(' ', '%20', $url);
- echo 'new Array('.get_images_from_uri($url).')';
-die;
-}
+ break;
+
+ case 'photo_js': ?>
+ // gather images and load some default JS
+ var last = null
+ var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
+ var my_src = eval(
+ jQuery.ajax({
+ type: "GET",
+ url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",
+ cache : false,
+ async : false,
+ data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
+ dataType : "script"
+ }).responseText
+ );
+ if(my_src.length == 0) {
+ var my_src = eval(
+ jQuery.ajax({
+ type: "GET",
+ url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",
+ cache : false,
+ async : false,
+ data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
+ dataType : "script"
+ }).responseText
+ );
+ if(my_src.length == 0) {
+ strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
+ }
+ }
+
+ for (i = 0; i < my_src.length; i++) {
+ img = new Image();
+ img.src = my_src[i];
+ img_attr = 'id="img' + i + '"';
+ skip = false;
+
+ maybeappend = '<a href="?ajax=photo_thickbox&i=' + encodeURIComponent(img.src) + '&u=<?php echo urlencode($url); ?>&height=400&width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';
+
+ if (img.width && img.height) {
+ if (img.width >= 30 && img.height >= 30) {
+ aspect = img.width / img.height;
+ scale = (aspect > 1) ? (71 / img.width) : (71 / img.height);
+
+ w = img.width;
+ h = img.height;
-if($_REQUEST['ajax'] == 'photo_js') { ?>
- // gather images and load some default JS
- var last = null
- var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
- var my_src = eval(
- jQuery.ajax({
- type: "GET",
- url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",
- cache : false,
- async : false,
- data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
- dataType : "script"
- }).responseText
- );
-
- for (i = 0; i < my_src.length; i++) {
- img = new Image();
- img.src = my_src[i];
- img_attr = 'id="img' + i + '"';
- skip = false;
- if (img.width && img.height) {
- if (img.width * img.height < 2500)
- skip = true;
- aspect = img.width / img.height;
- scale = (aspect > 1) ? (75 / img.width) : (75 / img.height);
-
- w = img.width;
- h = img.height;
-
- if (scale < 1) {
- w = parseInt(img.width * scale);
- h = parseInt(img.height * scale);
+ if (scale < 1) {
+ w = parseInt(img.width * scale);
+ h = parseInt(img.height * scale);
+ }
+ img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
+ strtoappend += maybeappend;
+ }
+ } else {
+ strtoappend += maybeappend;
}
- img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
}
- if (!skip) strtoappend += '<a href="?ajax=thickbox&i=' + img.src + '&u=<?php echo $url; ?>&height=400&width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';
- }
- function pick(img, desc) {
- if (img) {
- if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
- if(length == 0) length = 1;
- jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
- jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
- append_editor("\n\n" + '<p><img src="' + img +'" alt="' + desc + '" class="aligncenter"/></p>');
+ function pick(img, desc) {
+ if (img) {
+ if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
+ if(length == 0) length = 1;
+ jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
+ jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
+ insert_editor( "\n\n" + encodeURI('<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>'));
+ }
+ return false;
}
- tinyMCE.activeEditor.resizeToContent();
- return false;
- }
-
- function image_selector() {
- tb_remove();
- desc = jQuery('#this_photo_description').val();
- src = jQuery('#this_photo').val();
- pick(src, desc);
- return false;
- }
- jQuery(document).ready(function() {
- jQuery('#extra_fields').html('<div class="photolist"></div><small id="photo_directions"><?php _e("Click images to select:") ?> <span><a href="#" id="photo_add_url" class="thickbox"><?php _e("Add from URL") ?> +</a></span></small><div class="titlewrap"><div id="img_container"></div></div>');
- jQuery('#img_container').html(strtoappend);
- jQuery('#photo_add_url').attr('href', '?ajax=thickbox_url&height=200&width=500');
- tb_init('a.thickbox, area.thickbox, input.thickbox');
- });
+ function image_selector() {
+ tb_remove();
+ desc = jQuery('#this_photo_description').val();
+ src = jQuery('#this_photo').val();
+ pick(src, desc);
+ jQuery('#extra_fields').hide();
+ jQuery('#extra_fields').html('');
+ return false;
+ }
-<?php die;
-}
+ jQuery(document).ready(function() {
+ jQuery('#extra_fields').html('<div class="postbox"><h2>Photo <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul id="actions"><li><a href="#" id="photo_add_url" class="thickbox button"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
+ jQuery('.close').click(function() {
+ jQuery('#extra_fields').hide();
+ jQuery('#extra_fields').html('');
+ });
+ jQuery('.refresh').click(function() {
+ show('photo');
+ });
+ jQuery('#img_container').html(strtoappend);
+ jQuery('#photo_add_url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500');
+ tb_init('#extra_fields .thickbox');
-if($_REQUEST['ajax'] == 'photo') { ?>
-<?php die;
+ });
+ <?php break;
+}
+die;
}
+
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php _e('Press This') ?></title>
- <script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce.js?ver=311"></script>
<?php
add_thickbox();
wp_enqueue_style('press-this');
wp_enqueue_style('press-this-ie');
wp_enqueue_style( 'colors' );
- wp_enqueue_script('post');
- wp_enqueue_script('editor_functions');
+ wp_enqueue_script( 'post' );
+ wp_enqueue_script('editor');
do_action('admin_print_styles');
do_action('admin_print_scripts');
do_action('admin_head');
+
+ if ( user_can_richedit() ) {
+ add_filter( 'teeny_mce_before_init', create_function( '$a', '$a["height"] = "400"; $a["onpageload"] = ""; $a["mode"] = "textareas"; $a["editor_selector"] = "mceEditor"; return $a;' ) );
+ wp_tiny_mce( true );
+ }
?>
<script type="text/javascript">
- <?php if ( user_can_richedit() ) {
- $language = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) );
- // Add TinyMCE languages
- @include_once( dirname(__FILE__).'/../wp-includes/js/tinymce/langs/wp-langs.php' );
- if ( isset($strings) ) echo $strings; ?>
- (function() {
- var base = tinymce.baseURL, sl = tinymce.ScriptLoader, ln = "<?php echo $language; ?>";
- sl.markDone(base + '/langs/' + ln + '.js');
- sl.markDone(base + '/themes/advanced/langs/' + ln + '.js');
- sl.markDone(base + '/themes/advanced/langs/' + ln + '_dlg.js');
- })();
-
- tinyMCE.init({
- mode: "textareas",
- editor_selector: "mceEditor",
- language : "<?php echo $language; ?>",
- width: "100%",
- height: "300",
- theme : "advanced",
- theme_advanced_buttons1 : "bold,italic,underline,blockquote,separator,strikethrough,bullist,numlist,undo,redo,link,unlink",
- theme_advanced_buttons2 : "",
- theme_advanced_buttons3 : "",
- theme_advanced_toolbar_location : "top",
- theme_advanced_toolbar_align : "left",
- theme_advanced_statusbar_location : "bottom",
- theme_advanced_resizing : true,
- theme_advanced_resize_horizontal : false,
- skin : "wp_theme",
- dialog_type : "modal",
- relative_urls : false,
- remove_script_host : false,
- convert_urls : false,
- apply_source_formatting : false,
- remove_linebreaks : true,
- accessibility_focus : false,
- tab_focus : ":next",
- plugins : "safari,inlinepopups",
- entities : "38,amp,60,lt,62,gt",
- force_p_newlines : true,
- save_callback : 'switchEditors.saveCallback'
- });
- <?php } ?>
-
jQuery('#tags-input').hide();
-
tag_update_quickclicks();
-
// add the quickadd form
jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="submit" class="button" id="tagadd" value="' + postL10n.add + '" tabindex="3" onclick="return false;" /><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>');
jQuery(this).val( '' ).removeClass( 'form-input-tip' );
});
jQuery('#newtag').blur(function() {
- if ( this.value == '' )
+ if ( this.value == '' )
jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' );
});
-
// auto-save tags on post save/publish
jQuery('#publish').click( tag_save_on_publish );
- jQuery('#save-post').click( tag_save_on_publish );
-
- function set_menu(type) {
- jQuery('#text_button').removeClass('ui-tabs-selected');
- jQuery('#menu li').removeClass('ui-tabs-selected');
- jQuery('#' + type + '_button').addClass('ui-tabs-selected');
- jQuery("#post_type").val(type);
+ jQuery('#save').click( tag_save_on_publish );
+ function insert_plain_editor(text) {
+ edCanvas = document.getElementById('content');
+ edInsertContent(edCanvas, text);
}
-
function set_editor(text) {
if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>';
if ( tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, text);
}
-
+ function insert_editor(text) {
+ if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
+ tinyMCE.execCommand('mceInsertContent', false, '<p>' + decodeURI(tinymce.DOM.decode(text)) + '</p>', {format : 'raw'});
+ } else {
+ insert_plain_editor(decodeURI(text));
+ }
+ }
function append_editor(text) {
- if ( '' != text && tinyMCE.activeEditor ) tinyMCE.execCommand('mceInsertContent', false, text);
+ if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
+ tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
+ tinyMCE.execCommand('mceCleanup');
+ } else {
+ insert_plain_editor(text);
+ }
}
- function set_title(title) { jQuery("#content_type").text(title); }
-
function show(tab_name) {
- jQuery('body').removeClass('video_split');
- jQuery('#extra_fields').hide();
+ jQuery('#extra_fields').html('');
+ jQuery('#extra_fields').show();
switch(tab_name) {
- case 'text' :
- set_menu('text');
- set_title('<?php _e('Post') ?>');
- <?php if ($selection) { ?>
- set_editor('<?php echo $selection; ?><p><a href="<?php echo $url ?>"><?php echo $title; ?></a>.</p>');
- <?php } else { ?>
- set_editor('<p><a href="<?php echo $url ?>"><?php echo $title; ?></a></p>');
- <?php } ?>
- return false;
- break;
- case 'quote' :
- set_menu('quote');
- set_title('<?php _e('Quote') ?>');
- set_editor('<blockquote><?php echo $selection; ?> <p><cite><a href="<?php echo $url; ?>"><?php echo $title; ?> </a> </cite> </p></blockquote>');
- return false;
- break;
case 'video' :
- set_menu('video');
- set_title('<?php _e('Caption') ?>');
- jQuery('#extra_fields').show();
- jQuery('body').addClass('video_split');
jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo attribute_escape($selection); ?>'}, function() {
- <?php
+ <?php
$content = '';
if ( preg_match("/youtube\.com\/watch/i", $url) ) {
list($domain, $video_id) = split("v=", $url);
$content = $selection;
}
?>
- jQuery('#embed_code').prepend('<?php echo htmlentities($content); ?>');
-
- set_editor('<a href="<?php echo $url ?>"><?php echo $title; ?></a>.');
+ jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
});
return false;
break;
case 'photo' :
- set_menu('photo');
- set_title('<?php _e('Post') ?>');
- <?php if ($selection) { ?>
- set_editor('<?php echo $selection; ?><p><a href="<?php echo $url ?>"><?php echo $title; ?></a></p>');
- <?php } else { ?>
- set_editor('<p><a href="<?php echo $url ?>"><?php echo $title; ?></a></p>');
- <?php } ?>
- jQuery('#extra_fields').show();
- jQuery('#extra_fields').before('<h2 id="waiting"><img src="images/loading.gif" alt="" /><?php echo js_escape( __( 'Loading...' ) ); ?></h2>');
+ jQuery('#extra_fields').before('<p id="waiting"><img src="images/loading.gif" alt="" /> <?php echo js_escape( __( 'Loading...' ) ); ?></p>');
jQuery.ajax({
type: "GET",
cache : false,
break;
}
}
-
jQuery(document).ready(function() {
- jQuery('#menu li').click(function (){
- tab_name = this.id.split('_');
- tab_name = tab_name[0];
- show(tab_name);
- });
- // Set default tabs
+ //resize screen
+ window.resizeTo(720,570);
+ // set button actions
+ jQuery('#photo_button').click(function() { show('photo'); return false; });
+ jQuery('#video_button').click(function() { show('video'); return false; });
+ // auto select
<?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
show('video');
<?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
<?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
show('photo');
<?php } ?>
+ jQuery('#title').unbind();
+ jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); });
});
-
</script>
</head>
<body class="press-this">
-<div id="wphead">
- <h1><span id="viewsite"><a href="<?php echo get_option('home'); ?>/"><?php _e('Visit:') ?> <?php bloginfo('name'); ?></a></span></h1>
-</div>
+<div id="wphead"></div>
+<form action="press-this.php?action=post" method="post">
+<div id="poststuff" class="metabox-holder">
+ <div id="side-info-column">
+ <div class="sleeve">
+ <h1 id="viewsite"><a class="button" href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> › <?php _e('Press This') ?></a></span></h1>
-<ul id="menu" class="ui-tabs-nav">
- <li id="text_button" class="ui-tabs-selected"><a href="#"><?php _e('Text') ?></a></li>
- <li id="photo_button"><a href="#"><?php _e('Photo') ?></a></li>
- <li id="quote_button"><a href="#"><?php _e('Quote') ?></a></li>
- <li id="video_button"><a href="#"><?php _e('Video') ?></a></li>
-</ul>
+ <?php wp_nonce_field('press-this') ?>
+ <input type="hidden" name="post_type" id="post_type" value="text"/>
+ <input type="hidden" name="autosave" id="autosave" />
+ <input type="hidden" id="original_post_status" name="original_post_status" value="draft" />
+ <input type="hidden" id="prev_status" name="prev_status" value="draft" />
-<form action="press-this.php?action=post" method="post">
- <?php wp_nonce_field('press-this') ?>
- <input type="hidden" name="post_type" id="post_type" value="text"/>
- <div id="posting">
- <h2 id="title"><label for="post_title"><?php _e('Title') ?></label></h2>
- <div class="titlewrap">
- <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/>
- </div>
+ <!-- This div holds the photo metadata -->
+ <div class="photolist"></div>
- <div id="extra_fields" style="display: none"></div>
+ <div id="categorydiv" class="stuffbox">
+ <h2><?php _e('Categories') ?></h2>
+ <div class="inside">
+
+ <div id="categories-all" class="ui-tabs-panel">
+ <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
+ <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?>
+ </ul>
+ </div>
+
+ <div id="category-adder" class="wp-hidden-children">
+ <a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a>
+ <p id="category-add" class="wp-hidden-child">
+ <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
+ <label class="hidden" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
+ <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
+ <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
+ <span id="category-ajax-response"></span>
+ </p>
+ </div>
+ </div>
+ </div>
- <div class="editor_area">
- <h2 id="content_type"><label for="content"><?php _e('Post') ?></label></h2>
- <div class="editor-container">
- <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15"><?php if ($selection) { echo wp_richedit_pre($selection); } ?><a href="<?php echo $url ?>"><?php echo $title; ?></a>.</textarea>
+ <div class="stuffbox">
+ <h2><?php _e('Tags') ?></h2>
+ <div class="inside">
+
+ <div id="jaxtag">
+ <label class="hidden" for="newtag"><?php _e('Tags'); ?></label>
+ <input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
+ </div>
+ <div id="tagchecklist"></div>
+ </div>
+ </div>
+ <div id="submitdiv" class="postbox">
+ <h2><?php _e('Publish') ?></h2>
+ <div class="inside">
+ <p>
+ <input class="button" type="submit" name="draft" value="<?php _e('Save Draft') ?>" id="save" />
+ <input class="button-primary" type="submit" name="publish" value="<?php _e('Publish') ?>" id="publish" />
+ <img src="images/loading-publish.gif" alt="" id="saving" style="display:none;"/>
+ </p>
+ </div>
</div>
</div>
</div>
- <div id="categories">
- <div class="submitbox" id="submitpost">
- <div id="previewview"></div>
- <div class="inside">
- <h2><?php _e('Categories') ?></h2>
- <div id="categories-all">
- <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
- <?php wp_category_checklist() ?>
- </ul>
- </div>
-
- <h2><?php _e('Tags') ?></h2>
- <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p>
- <div id="tagchecklist"></div>
+ <div class="posting">
+ <?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?>
+ <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $post_ID ); ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div>
+ <?php } ?>
+
+ <div id="titlediv">
+ <div class="titlewrap">
+ <input name="title" id="title" class="text" value="<?php echo attribute_escape($title);?>"/>
</div>
+ </div>
+
+ <div id="extra_fields" style="display: none"></div>
- <p class="submit">
- <input type="submit" name="draft" value="<?php _e('Save') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/>
- <input type="submit" name="publish" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/>
- <img src="images/loading-publish.gif" alt="" id="photo_saving" style="display:none;"/>
- </p>
+ <div class="postdivrich">
+ <ul id="actions">
+ <li id="photo_button">
+ Add: <a title="<?php _e('Insert an Image'); ?>" href="#">
+<img alt="<?php _e('Insert an Image'); ?>" src="images/media-button-image.gif"/></a>
+ </li>
+ <li id="video_button">
+ <a title="<?php _e('Embed a Video'); ?>" href="#"><img alt="<?php _e('Embed a Video'); ?>" src="images/media-button-video.gif"/></a>
+ </li>
+ <?php if( user_can_richedit() ) { ?>
+ <li id="switcher">
+ <?php wp_print_scripts( 'quicktags' ); ?>
+ <?php add_filter('the_editor_content', 'wp_richedit_pre'); ?>
+ <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
+ <a id="edButtonPreview" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
+ <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
+ </li>
+ <?php } ?>
+ </ul>
+ <div id="quicktags"></div>
+ <div class="editor-container">
+ <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15">
+ <?php if ($selection) echo wp_richedit_pre(htmlspecialchars_decode($selection)); ?>
+ <?php if ($url) { echo '<p>'; if($selection) _e('via '); echo "<a href='$url'>$title</a>."; echo '</p>'; } ?>
+ </textarea>
+ </div>
</div>
</div>
+</div>
</form>
</body>
-</html>
\ No newline at end of file
+</html>
<?php
+/**
+ * User Profile Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * This is a profile page.
+ *
+ * @since unknown
+ * @var bool
+ */
define('IS_PROFILE_PAGE', true);
+
+/** Load User Editing Page */
require_once('user-edit.php');
?>
<?php
-
+/**
+ * Revisions administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
-wp_reset_vars(array('revision', 'left', 'right', 'action'));
+wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action'));
$revision_id = absint($revision);
$diff = absint($diff);
$left = absint($left);
( !wp_get_post_revision( $left_revision->ID ) && !wp_get_post_revision( $right_revision->ID ) )
)
break;
-
+
$post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
$h2 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title );
</tr>
<?php endif;
-// use get_post_to_edit filters?
+// use get_post_to_edit filters?
$identical = true;
foreach ( _wp_post_revision_fields() as $field => $field_title ) :
if ( 'diff' == $action ) {
-a:link, a:visited {
- text-decoration:none;
-}
-a:hover {
- text-decoration:underline;
-}
-.plugins .togl {
- border-right-width: 0;
- border-left-width: 1px;
- border-left-style: solid;
-}
-form#upload th {
- text-align:left;
-}
+/* 0 - 200
+=================================== */
td.available-theme {
- text-align:right;
+ text-align: right;
}
#current-theme img {
float: right;
- margin-right:0;
+ margin-right: 0;
margin-left: 1em;
}
.quicktags, .search {
- font-family: Tahoma;
+ font-family: Tahoma, "Times New Roman";
}
-/* 201 - 403
+/* 200 - 500
=================================== */
-.side-info ul {
- padding-left:0;
- padding-right:18px;
+#save-post {
+ float: right;
+}
+.preview {
+ float: left;
}
-.submit input, .button, .button-secondary, .button-highlighted {
- font-family: Tahoma;
+#sticky-span {
+ margin-left: 0;
+ margin-right: 18px;
}
-#wpcontent select {
- font-family: Tahoma;
+#post-body .misc-pub-section {
+ border-right-width: 0;
+ border-left-width: 1;
+ border-right-style: none;
+ border-left-style: solid;
+ float: right;
}
-/* #postdiv, #titlediv, #guiddiv, #poststuff .stuffbox {
- margin:0 0 0 8px;
-} */
-#quicktags #ed_code {
- font-family: Tahoma;
+#post-body .misc-pub-section-last {
+ border-left: 0;
}
-#searchform fieldset {
- float:right;
- margin: 0 0 1em 1.5ex;
+#delete-action {
+ text-align: right;
+ float: right;
}
-#searchform fieldset legend {
- padding: 0 1px .2em 0;
+#publishing-action {
+ text-align: left;
+ float: left;
+}
+.side-info ul {
+ padding-left: 0;
+ padding-right: 18px;
+}
+.submit input,
+.button,
+.button-primary,
+.button-secondary,
+.button-highlighted,
+#postcustomstuff .submit input {
+ font-family: Tahoma, "Times New Roman";
}
-#searchform #post-query-submit {
- float:right;
+#wpcontent select {
+ font-family: Tahoma, "Times New Roman";
}
-/* 404 - 804
+#quicktags {
+ background-position: right top;
+}
+/* 500 - 700
=================================== */
#template div {
- margin-right:0;
+ margin-right: 0;
margin-left: 190px;
}
* html #template div {
margin-left: 0;
}
#your-profile legend {
- font-family:arial;
+ font-family: "Times New Roman", Tahoma;
}
#ajax-response.alignleft {
- margin-left:0;
+ margin-left: 0;
margin-right: 2em;
}
.page-numbers {
- margin-right:0;
- margin-left:3px;
+ margin-right: 0;
+ margin-left: 1px;
}
-.comment-column {
- margin-left:0;
- margin-right: 5px;
+.column-author img, .column-username img {
+ float: right;
+ margin-right: 0;
+ margin-left: 10px;
}
.tablenav a.button-secondary {
- margin: 1px 0 0 8px;
+ margin: 8px 0 0 8px;
}
-#update-nag, .plugin-update {
- clear:both;
+.tablenav .tablenav-pages {
+ float: left;
}
-/* .tablenav .tablenav-pages {
- float:left;
-} */
-#user_info {
- right:auto;
- left:15px;
+.tablenav .displaying-num {
+ margin-right: 0;
+ margin-left: 10px;
+ font-family: Tahoma, "Times New Roman";
+}
+#postcustomstuff table input,
+#postcustomstuff table select,
+#postcustomstuff table textarea {
+ margin: 8px 8px 8px 0;
+}
+/* 700 - 1000
+=================================== */
+#pass-strength-result {
+ float: right;
+ margin: 12px 1px 5px 5px;
}
-#wphead #viewsite {
- margin-left:0;
- margin-right:10px;
+/* Admin Header */
+#user_info {
+ float: left;
}
-#wphead #viewsite a {
- font-family: Tahoma;
+#header-logo {
+ float: right;
+ margin: 7px 15px 0 0;
}
#wphead h1 {
- font-family:arial;
- margin-right:0;
- margin-left:15%;
- padding: 11px 12px 16px 170px;
+ font-family: "Times New Roman", Tahoma;
+ float: right;
}
-#dashmenu {
- right:0;
- left:auto;
- padding-left:0;
- padding-right: 9px;
+#wphead h1.long-title {
+ font-family: "Times New Roman", Tahoma;
}
-#dashmenu a {
- margin-right:0;
- margin-left:8px;
+#adminmenu .wp-submenu a {
+ padding-left: 0;
+ padding-right: 12px;
+ border-width: 0 0 0 1px;
+ border-style: none none none solid;
+ font-family: Tahoma, "Times New Roman";
}
-#adminmenu {
- padding-left:0;
- padding-right:11px;
+#adminmenu a.menu-top,
+#adminmenu .wp-submenu-head {
+ font-family: Tahoma, "Times New Roman";
}
-#adminmenu a {
- font-family:arial;
- font-weight:bold;
- padding:6px 7px;
+#adminmenu img.wp-menu-image {
+ float: right;
}
-#adminmenu a.current, #sidemenu a.current {
- font-weight:bold;
+.folded #adminmenu img.wp-menu-image {
+ padding: 7px 6px 0 0;
}
-#sidemenu {
- margin: -30px 0 0 15px;
- float: left;
- padding-left:0;
+#adminmenu .wp-submenu .wp-submenu-head {
+ padding: 6px 10px 6px 4px;
+}
+.folded #adminmenu .wp-submenu {
+ margin: -1px 28px 0 0;
+}
+.folded #adminmenu .wp-submenu a {
+ padding-left: 0;
padding-right: 10px;
- height: 1%; /* Peek-a-boo in IE6 */
}
-#sidemenu a {
- float:right;
+.folded #adminmenu a.wp-has-submenu {
+ margin-left: 0;
+ margin-right: 40px;
}
-#submenu li {
- padding: 0 17px 8px 0;
- font-size:13px;
+#adminmenu .wp-menu-toggle {
+ float: left;
+ padding: 1px 0 0 2px;
+ clear: left;
}
-#adminmenu li a #awaiting-mod span, #sidemenu li a #update-plugins span {
- right:auto;
- left:0;
+#adminmenu div.wp-menu-image {
+ float: right;
}
-#adminmenu li a:hover #awaiting-mod, #sidemenu li a:hover #update-plugins {
- background-position: -160px top;
+#wphead-info {
+ margin: 0 15px 0 0;
+ padding-right:0;
+ padding-left: 15px;
}
-/* 804 - 1004
+/* end side admin menu */
+/* 1000 - 1300
=================================== */
-#footer {
- padding: 10px 60px 0 0;
+#adminmenu #awaiting-mod,
+#adminmenu span.update-plugins,
+#sidemenu li a span.update-plugins {
+ font-family: tahoma;
+ margin-left: 0;
+ margin-right: 2px;
+}
+#adminmenu li #awaiting-mod span,
+#adminmenu li span.update-plugins span,
+#sidemenu li a span.update-plugins span {
+ float: right;
+}
+.post-com-count-wrapper {
+ font-family: tahoma;
+}
+.column-response .post-com-count {
+ float: right;
+ margin-right: 0;
+ margin-left: 5px;
}
-.form-table th {
- text-align:right;
+/* Tables used on comment.php and option/setting pages */
+.form-table th,
+#wpbody-content .describe th {
+ text-align: right;
}
.form-table input.tog {
- margin-right:0;
+ margin-right: 0;
margin-left: 2px;
float: right;
}
.form-table table.color-palette {
- float:right;
-}
-#pass-strength-result {
- float:right;
- margin-right:0;
- margin-left: 5px;
+ float: right;
}
#profile-page .form-table #rich_editing {
- margin-right:0;
+ margin-right: 0;
margin-left: 5px;
}
-#tagsdiv #newtag {
- margin-right:0;
+/* Post Screen */
+/* 1300 - 1500
+=================================== */
+#normal-sortables .postbox .submit {
+ float: left;
+}
+#post-body #tagsdiv #newtag {
+ margin-right: 0;
margin-left: 5px;
}
+#post-status-info {
+ padding: 0 7px 0 15px;
+}
+#comment-status-radio input {
+ margin: 2px 0 5px 3px;
+}
#tagchecklist {
- margin-left:0;
+ margin-left: 0;
margin-right: 10px;
}
#tagchecklist strong {
- margin-left:0;
+ margin-left: 0;
margin-right: -8px;
}
#tagchecklist span {
- margin-right:0;
- margin-left: 25px;
float: right;
}
#tagchecklist span a {
margin: 6px -9px 0 0;
float: right;
}
-/* 1005 - 1304
-=================================== */
.ac_results li {
- text-align:right;
+ text-align: right;
}
#poststuff h2 {
- clear:right;
+ clear: right;
}
-#poststuff .postbox, #poststuff .stuffbox, #titlediv, #poststuff .postarea {
- margin-left: 8px;
- margin-right: 20px;
+.setting-description, .form-wrap p {
+ font-family: Tahoma, Arial;
+}
+/* 1500 - 1800
+=================================== */
+.meta-box-sortables .postbox .handlediv {
+ float: left;
}
-#edit-slug-buttons a.save {
- margin-right:0;
- margin-left:4px;
+.howto {
+ font-family: Tahoma, Arial;
}
-#poststuff #edButtonPreview, #poststuff #edButtonHTML {
- margin: 5px 0 0 8px;
+.postarea h3 label {
+ float: right;
+}
+.postarea #add-media-button {
float: left;
+ right: auto;
+ left: 10px;
+}
+.wp_themeSkin tr.mceFirst td.mceToolbar {
+ background-position: right top;
}
-#poststuff #media-buttons {
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML {
+ margin: 5px 0 0 5px;
float: left;
- margin-right:0;
- margin-left: 20px;
}
-#poststuff #media-buttons a {
- padding: 0 2px 2px 5px;
-}
-#poststuff .togbox {
- margin-left:0;
- margin-right: -21px;
- -moz-border-radius-topleft:0;
- -khtml-border-top-left-radius:0;
- -webkit-border-top-left-radius:0;
- border-top-left-radius:0;
- -moz-border-radius-topright: 3px;
- -khtml-border-top-right-radius: 3px;
- -webkit-border-top-right-radius: 3px;
- border-top-right-radius: 3px;
- -moz-border-radius-bottomleft: 0;
- -khtml-border-bottom-left-radius:0;
- -webkit-border-bottom-left-radius:0;
- border-bottom-left-radius:0;
- -moz-border-radius-bottomright: 3px;
- -khtml-border-bottom-right-radius: 3px;
- -webkit-border-bottom-right-radius: 3px;
- border-bottom-right-radius: 3px;
+#poststuff #edButtonHTML {
+ margin-right: 0;
+ margin-left: 15px;
}
-.submitbox .submitdelete {
- margin-left:0;
- margin-right:8px;
+#media-buttons a {
+ padding: 0 10px 5px 0;
}
.submitbox .submit {
- text-align:right;
+ text-align: right;
+}
+
+.inside-submitbox #post_status {
+ margin: 2px -2px 2px 0;
}
.submitbox .submit input {
- margin-right:0;
- margin-left:3px;
+ margin-right: 0;
+ margin-left: 4px;
}
-#categorydiv #category-adder {
- margin-left:0;
+/* Categories */
+#category-adder {
+ margin-left: 0;
margin-right: 120px;
}
-#categorydiv ul#category-tabs {
- float: right;
- text-align: left;
- margin: 0 0 0 -120px;
-}
-ul#category-tabs li.ui-tabs-selected {
- -moz-border-radius-topleft:0;
- -khtml-border-top-left-radius:0;
- -webkit-border-top-left-radius:0;
- border-top-left-radius:0;
- -moz-border-radius-bottomleft:0;
- -khtml-border-bottom-left-radius:0;
- -webkit-border-bottom-left-radius:0;
- border-bottom-left-radius:0;
- -moz-border-radius-topright: 3px;
- -khtml-border-top-right-radius: 3px;
+#post-body ul#category-tabs li.ui-tabs-selected {
+ -moz-border-radius: 0 3px 3px 0;
+ -webkit-border-top-left-radius: 0;
-webkit-border-top-right-radius: 3px;
- border-top-right-radius: 3px;
- -moz-border-radius-bottomright: 3px;
- -khtml-border-bottom-right-radius: 3px;
+ -webkit-border-bottom-left-radius: 0;
-webkit-border-bottom-right-radius: 3px;
+ border-top-left-radius: 0;
+ border-top-right-radius: 3px;
+ border-bottom-left-radius: 0;
border-bottom-right-radius: 3px;
}
-div.ui-tabs-panel {
- margin: 0 120px 0 5px;
-}
-/* 1305 - elakh! :-)
-=================================== */
-#categorydiv ul.categorychecklist ul {
- margin-left:0;
- margin-right: 18px;
-}
-#linkcategorydiv #category-adder {
- margin-left:0;
- margin-right: 120px;
-}
-#linkcategorydiv ul#category-tabs {
+#post-body ul#category-tabs {
float: right;
text-align: left;
margin: 0 0 0 -120px;
}
+#post-body #categorydiv div.ui-tabs-panel,
+#post-body #linkcategorydiv div.ui-tabs-panel {
+ margin: 0 120px 0 5px;
+}
+/* 1800 - 2000
+=================================== */
+#side-info-column #category-tabs li {
+ padding-right: 0;
+ padding-left: 8px;
+}
+#categorydiv ul.categorychecklist ul,
#linkcategorydiv ul.categorychecklist ul {
- margin-left:0;
+ margin-left: 0;
margin-right: 18px;
}
-p#tag-search, p#post-search {
- right:auto;
- left:0;
+/* positioning etc. */
+p.search-box {
+ float: left;
}
#posts-filter fieldset {
float: right;
#posts-filter fieldset legend {
padding: 0 1px .2em 0;
}
-ul.view-switch {
+.view-switch {
float: left;
- margin: -23px 0 -2px 5px;
}
-ul.view-switch li {
+.filter {
float: right;
+ margin: -5px 10px 0 0;
}
#the-comment-list td.comment p.comment-author {
- margin-right: 0 ;
+ margin-right: 0;
}
#the-comment-list p.comment-author img {
float: right;
- margin-right:0;
+ margin-right: 0;
margin-left: 8px;
}
-#the-comment-list td.comment p {
- margin-left:0;
- margin-right: 8px;
+.tablenav .delete {
+ margin-right: 0;
+ margin-left: 20px;
+}
+td.action-links, th.action-links {
+ text-align: left;
+}
+/* 2000 - 2300
+=================================== */
+.filter .subsubsub {
+ margin-left: 0;
+ margin-right: -10px;
+}
+#wp-word-count {
+ margin-right: 10px;
+}
+.tool-box .title {
+ font-family: "Times New Roman", Tahoma;
+}
+.settings-toggle {
+ text-align: left;
+ margin: 5px 0 15px 7px;
}
-.curtime {
- background-position: right 2px;
- padding-left:0;
+.curtime #timestamp {
+ background-position: right top;
+ padding-left: 0;
padding-right: 18px;
}
-.tablenav .delete {
- margin-right:0;
- margin-left: 20px;
+/* media popup 0819 */
+#sidemenu {
+ margin: -30px 315px 0 15px;
+ float: left;
+ padding-left: 0;
+ padding-right: 10px;
}
-#tTips {
+#sidemenu a {
+ float: right;
}
-td.action-links, th.action-links {
- text-align:left;
+#replysubmit .button {
+ margin-right: 0;
+ margin-left: 5px;
+}
+/* 2300 - 2500
+=================================== */
+#edithead .inside {
+ float: right;
+ margin: 3px 5px 2px 0;
+}
+#replyrow #ed_reply_toolbar input {
+ margin: 1px 1px 1px 2px;
+}
+/* show/hide settings */
+#screen-meta-links {
+ margin: 0 0 0 9px;
}
-.info-box {
- left:auto;
- right: 50%;
+#screen-options-link-wrap,
+#contextual-help-link-wrap {
+ float: left;
+ font-family: Tahoma, "Times New Roman";
+ margin: 0 0 0 6px;
+}
+.metabox-prefs label {
+ padding-right: 0;
+ padding-left: 15px;
+}
+.metabox-prefs label input {
+ margin: 0 2px 0 5px;
+}
+.inline-editor .save,
+.inline-editor .cancel {
+ margin-right: 0;
+ margin-left: 5px;
+}
+/* 2500 - 2700
+=================================== */
+#bulk-titles div a {
+ float: right;
+ margin: 3px -2px 0 3px;
+}
+#wpbody-content .filename {
margin-left: 0;
- margin-right: -225px;
+ margin-right: 10px;
}
-.info-box .gears-img {
+#wpbody-content .inline-edit-row fieldset {
+ float: right;
+}
+#wpbody-content .quick-edit-row-page fieldset.inline-edit-col-right .inline-edit-col {
+ border-left: 0 none;
+ border-right: 1px solid;
+}
+#wpbody-content .bulk-edit-row .inline-edit-col-bottom {
float: left;
}
-/* LTR
+.inline-edit-row fieldset label span.title {
+ float: right;
+}
+.inline-edit-row fieldset label span.input-text-wrap {
+ margin-left: 0;
+ margin-right: 5em;
+}
+.quick-edit-row-post fieldset.inline-edit-col-right label span.title {
+ padding-right: 0;
+ padding-left: 0.5em;
+}
+#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child {
+ margin-right: 0;
+ margin-left: 0.5em;
+}
+/* 2700 - 3000
=================================== */
-#edit-slug-box, #trackback, #metakeyinput, #post_password, #link_url, #link_image, #rss_uri, #category_nicename, #slug, #dbuser, #dbpass, #dbname, #dbprefix, #dccharset, #gmpath, #archivespath, #lastentry, #dbhost, #pages-exclude, #newcontent, #email, #newcomment_author_url, #siteurl, #home, #admin_email, #date_format, #time_format, #gmt_offset, #mailserver_url, #mailserver_port, #mailserver_login, #mailserver_pass, #ping_sites, #posts_per_page, #posts_per_rss, #blog_charset, #moderation_keys, #blacklist_keys, #comment_max_links, #permalink_structure, #category_base, #tag_base, #upload_path, #upload_url_path, #thumbnail_size_w, #thumbnail_size_h, #medium_size_w, #medium_size_h, #user_login, #url, #pass1, #pass2, #aim, #yim, #jabber, #key, #src, #hostname, #username, #password, #rules {
- direction:ltr;
+.inline-edit-row fieldset span.title,
+.inline-edit-row fieldset span.checkbox-title {
+ font-family: Tahoma, "Times New Roman";
+}
+.inline-edit-row fieldset .inline-edit-date {
+ float: right;
+}
+.inline-edit-row fieldset ul.cat-checklist label,
+.inline-edit-row .catshow,
+.inline-edit-row .cathide,
+.inline-edit-row #bulk-titles div {
+ font-family: Tahoma, "Times New Roman";
+}
+.quick-edit-row-post fieldset label.inline-edit-status {
+ float: right;
+}
+.describe-toggle-on, .describe-toggle-off {
+ float: left;
+ margin-right: 0;
+ margin-left: 20px;
+}
+#wpbody-content #media-items .filename {
+ float: right;
+ margin-left: 0;
+ margin-right: 10px;
+}
+.media-item .pinkynail {
+ float: right;
+}
+#find-posts-response .found-radio {
+ padding: 8px 8px 0 0;
+}
+.find-box-buttons {
+ left: auto;
+ right: 12px;
+}
+.find-box-search label {
+ padding-right: 0;
+ padding-left: 6px;
+}
+/* favorite-actions */
+#favorite-actions {
+ float: left;
+}
+#favorite-first {
+ padding: 3px 12px 4px 30px;
+}
+#favorite-inside {
+}
+#favorite-inside a {
+ padding: 3px 10px 3px 5px;
+}
+#favorite-toggle {
+ right: auto;
+ left: 0;
+ background:transparent url(images/fav-arrow-rtl.gif) no-repeat 10px -4px;
+}
+#utc-time, #local-time {
+ padding-left: 0;
+ padding-right: 25px;
+ font-family: Tahoma, Arial;
+}
+.icon32 {
+ float: right;
+ margin: 14px 0 0 6px;
+}
+.subtitle {
+ padding-left: 0;
+ padding-right: 25px;
}
/* TinyMCE
=================================== */
.clearlooks2 .mceTop .mceLeft {
width:100% !important;
}
+/* ltr
+=================================== */
+#author-email, #author-url, #rss-url-1, #edit-slug-box, #post_name, #trackback_url, #metakeyinput, #post_password, #slug, #category_nicename, #link_url, #link_image, #rss_uri, #menu_order, #email, #newcomment_author_url, #pages-exclude, #template textarea, #user_login, #url, #pass1, #pass2, #aim, #yim, #jabber, #siteurl, #home, #admin_email, #gmt_offset, #default_post_edit_rows, #mailserver_url, #mailserver_login, #mailserver_pass, #mailserver_port, #ping_sites, #posts_per_page, #posts_per_rss, #blog_charset, #close_comments_days_old, #comments_per_page, #comment_max_links, #moderation_keys, #blacklist_keys, #thumbnail_size_w, #thumbnail_size_h, #medium_size_w, #medium_size_h, #large_size_w, #large_size_h, #permalink_structure, #category_base, #tag_base, #upload_path, #upload_url_path, #rules {
+ direction: ltr;
+}
<?php
+/**
+ * Retrieves and creates the wp-config.php file.
+ *
+ * The permissions for the base directory must allow for writing files in order
+ * for the wp-config.php to be created using this page.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * We are installing.
+ *
+ * @package WordPress
+ */
define('WP_INSTALLING', true);
-//These three defines are required to allow us to use require_wp_db() to load the database class while being wp-content/wp-db.php aware
+
+/**#@+
+ * These three defines are required to allow us to use require_wp_db() to load
+ * the database class while being wp-content/db.php aware.
+ * @ignore
+ */
define('ABSPATH', dirname(dirname(__FILE__)).'/');
define('WPINC', 'wp-includes');
define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
+/**#@-*/
require_once('../wp-includes/compat.php');
require_once('../wp-includes/functions.php');
wp_die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>");
// Check if wp-config.php exists above the root directory
-if (file_exists('../../wp-config.php'))
+if (file_exists('../../wp-config.php') && ! file_exists('../../wp-load.php'))
wp_die("<p>The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>");
if (isset($_GET['step']))
else
$step = 0;
-function display_header(){
+/**
+ * Display setup wp-config.php file header.
+ *
+ * @ignore
+ * @since 2.3.0
+ * @package WordPress
+ * @subpackage Installer_WP_Config
+ */
+function display_header() {
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WordPress › Setup Configuration File</title>
-<link rel="stylesheet" href="<?php echo $admin_dir; ?>css/install.css" type="text/css" />
+<link rel="stylesheet" href="css/install.css" type="text/css" />
</head>
<body>
<li>Table prefix (if you want to run more than one WordPress in a single database) </li>
</ol>
<p><strong>If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>. </strong></p>
-<p>In all likelihood, these items were supplied to you by your ISP. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…</p>
+<p>In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…</p>
<p class="step"><a href="setup-config.php?step=1" class="button">Let’s go!</a></p>
<?php
if (empty($prefix)) $prefix = 'wp_';
// Test the db connection.
+ /**#@+
+ * @ignore
+ */
define('DB_NAME', $dbname);
define('DB_USER', $uname);
define('DB_PASSWORD', $passwrd);
define('DB_HOST', $dbhost);
+ /**#@-*/
// We'll fail here if the values are no good.
require_wp_db();
<?php
+/**
+ * Quick way to create a WordPress Post.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * @var string
+ * @name $mode
+ */
$mode = 'sidebar';
+/** WordPress Administration Bootstrap */
require_once('admin.php');
if ( ! current_user_can('edit_posts') )
wp_die(__('Cheatin’ uh?'));
-if ('b' == $_GET['a']) {
-
-?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=UTF-8" />
-<title><?php _e('WordPress › Posted'); ?></title>
-<?php
-wp_admin_css( 'global', true );
-wp_admin_css( 'wp-admin', true );
-wp_admin_css( 'colors', true );
-?>
-</head>
-<body>
- <p><?php _e('Posted !'); ?></p>
- <p><?php printf(__('<a href="%s">Click here</a> to post again.'), 'sidebar.php'); ?></p>
-</body>
-</html><?php
-
-} else {
+$post = get_default_post_to_edit();
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('blog_charset'); ?>" />
-<title><?php _e('WordPress › Sidebar'); ?></title>
-<?php
-wp_admin_css( 'global', true );
-wp_admin_css( 'wp-admin', true );
-wp_admin_css( 'colors', true );
-?>
+<title><?php bloginfo('name') ?> › <?php _e('Sidebar'); ?></title>
<style type="text/css" media="screen">
+body {
+ font-size: 0.9em;
+ margin: 0;
+ padding: 0;
+}
form {
- padding: 3px;
+ padding: 1%;
+}
+.tags-wrap p {
+ font-size: 0.75em;
+ margin-top: 0.4em;
+}
+.button-highlighted, #wphead, label {
+ font-weight: bold;
}
-.sidebar-categories {
- display: block;
- height: 6.6em;
- overflow: auto;
- background-color: #f4f4f4;
+#post-title, #tags-input, #content {
+ width: 99%;
+ padding: 2px;
}
-.sidebar-categories label {
- font-size: 10px;
- display: block;
- width: 90%;
+#wphead {
+ font-size: 1.4em;
+ background-color: #E4F2FD;
+ color: #555555;
+ padding: 0.2em 1%;
+}
+#wphead p {
+ margin: 3px;
+}
+.button {
+ font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
+ padding: 3px 5px;
+ margin-right: 5px;
+ font-size: 0.75em;
+ line-height: 1.5em;
+ border: 1px solid #80b5d0;
+ -moz-border-radius: 3px;
+ -khtml-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
+ cursor: pointer;
+ background-color: #e5e5e5;
+ color: #246;
+}
+.button:hover {
+ border-color: #535353;
+}
+.updated {
+ background-color: #FFFBCC;
+ border: 1px solid #E6DB55;
+ margin-bottom: 1em;
+ padding: 0 0.6em;
+}
+.updated p {
+ margin: 0.6em;
}
</style>
</head>
<body id="sidebar">
-<h1 id="wphead"><a href="http://wordpress.org/" rel="external">WordPress</a></h1>
+<div id="wphead"><p><?php bloginfo('name') ?> › <?php _e('Sidebar'); ?></p></div>
<form name="post" action="post.php" method="post">
<div>
<input type="hidden" name="action" value="post" />
<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
<input type="hidden" name="mode" value="sidebar" />
-<?php wp_nonce_field('add-post'); ?>
-<p><label for="post_title"><?php _e('Title:'); ?></label>
-<input type="text" name="post_title" id="post_title" size="20" tabindex="1" style="width: 100%;" />
-</p>
-<p><?php _e('Categories:'); ?>
-<span class="sidebar-categories">
-<?php dropdown_categories(); ?>
-</span>
+<input type="hidden" name="ping_status" value="<?php echo $post->ping_status; ?>" />
+<input type="hidden" name="comment_status" value="<?php echo $post->comment_status; ?>" />
+<?php wp_nonce_field('add-post');
+
+if ( 'b' == $_GET['a'] )
+ echo '<div class="updated"><p>' . __('Post published.') . '</p></div>';
+elseif ( 'c' == $_GET['a'] )
+ echo '<div class="updated"><p>' . __('Post saved.') . '</p></div>';
+?>
+<p>
+<label for="post-title"><?php _e('Title:'); ?></label>
+<input type="text" name="post_title" id="post-title" size="20" tabindex="1" autocomplete="off" value="" />
</p>
+
<p>
-<label for="content">Post:</label>
-<textarea rows="8" cols="12" style="width: 100%" name="content" id="content" tabindex="2"></textarea>
+<label for="content"><?php _e('Post:'); ?></label>
+<textarea rows="8" cols="12" name="content" id="content" style="height:10em;line-height:1.4em;" tabindex="2"></textarea>
</p>
+
+<div class="tags-wrap">
+<label for="tags-input"><?php _e('Tags:') ?></label>
+<input type="text" name="tags_input" id="tags-input" tabindex="3" value="" />
+<p><?php _e('Separate tags with commas'); ?></p>
+</div>
+
<p>
- <input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" value="<?php _e('Save as Draft'); ?>" />
+<input name="saveasdraft" type="submit" id="saveasdraft" tabindex="9" accesskey="s" class="button" value="<?php _e('Save as Draft'); ?>" />
<?php if ( current_user_can('publish_posts') ) : ?>
- <input name="publish" type="submit" id="publish" tabindex="6" value="<?php _e('Publish') ?>" class="button button-highlighted" />
+<input name="publish" type="submit" id="publish" tabindex="6" accesskey="p" value="<?php _e('Publish') ?>" class="button button-highlighted" />
<?php endif; ?>
</p>
</div>
</body>
</html>
-<?php
-}
-?>
\ No newline at end of file
<?php
+/**
+ * Theme editor administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
$title = __("Edit Themes");
<?php endif;
$description = get_file_description($file);
-$desc_header = ( $description != $file_show ) ? "$description</strong> (%s)" : "%s";
+$desc_header = ( $description != $file_show ) ? "<strong>$description</strong> (%s)" : "%s";
?>
<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
<div class="bordertitle">
- <h2><?php _e('Theme Editor'); ?></h2>
- <form id="themeselector" name="theme" action="theme-editor.php" method="post">
+ <form id="themeselector" action="theme-editor.php" method="post">
<strong><label for="theme"><?php _e('Select theme to edit:'); ?> </label></strong>
<select name="theme" id="theme">
<?php
</div>
<div class="tablenav">
<div class="alignleft">
-<big><strong><?php echo sprintf($desc_header, $file_show); ?></big>
+<big><?php echo sprintf($desc_header, $file_show); ?></big>
</div>
<br class="clear" />
</div>
?>
<h4><?php _e('Templates'); ?></h4>
<ul>
-<?php foreach($themes[$theme]['Template Files'] as $template_file) :
- $description = get_file_description($template_file);
+<?php
+ $template_mapping = array();
+ $template_dir = $themes[$theme]['Template Dir'];
+ foreach($themes[$theme]['Template Files'] as $template_file) {
+ $description = trim( get_file_description($template_file) );
$template_show = basename($template_file);
$filedesc = ( $description != $template_file ) ? "$description <span class='nonessential'>($template_show)</span>" : "$description";
$filedesc = ( $template_file == $file ) ? "<span class='highlight'>$description <span class='nonessential'>($template_show)</span></span>" : $filedesc;
- ?>
+
+ // If we have two files of the same name prefer the one in the Template Directory
+ // This means that we display the correct files for child themes which overload Templates as well as Styles
+ if( array_key_exists($description, $template_mapping ) ) {
+ if ( false !== strpos( $template_file, $template_dir ) ) {
+ $template_mapping[ $description ] = array( $template_file, $filedesc );
+ }
+ } else {
+ $template_mapping[ $description ] = array( $template_file, $filedesc );
+ }
+ }
+ ksort( $template_mapping );
+ while ( list( $template_sorted_key, list( $template_file, $filedesc ) ) = each( $template_mapping ) ) :
+ ?>
<li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&theme=<?php echo urlencode($theme) ?>"><?php echo $filedesc ?></a></li>
-<?php endforeach; ?>
+<?php endwhile; ?>
</ul>
<h4><?php echo _c('Styles|Theme stylesheets in theme editor'); ?></h4>
<ul>
-<?php foreach($themes[$theme]['Stylesheet Files'] as $style_file) :
- $description = get_file_description($style_file);
+<?php
+ $template_mapping = array();
+ foreach($themes[$theme]['Stylesheet Files'] as $style_file) {
+ $description = trim( get_file_description($style_file) );
$style_show = basename($style_file);
$filedesc = ( $description != $style_file ) ? "$description <span class='nonessential'>($style_show)</span>" : "$description";
$filedesc = ( $style_file == $file ) ? "<span class='highlight'>$description <span class='nonessential'>($style_show)</span></span>" : $filedesc;
+ $template_mapping[ $description ] = array( $style_file, $filedesc );
+ }
+ ksort( $template_mapping );
+ while ( list( $template_sorted_key, list( $style_file, $filedesc ) ) = each( $template_mapping ) ) :
?>
<li><a href="theme-editor.php?file=<?php echo "$style_file"; ?>&theme=<?php echo urlencode($theme) ?>"><?php echo $filedesc ?></a></li>
-<?php endforeach; ?>
+<?php endwhile; ?>
</ul>
<?php endif; ?>
</div>
<?php if ( is_writeable($real_file) ) : ?>
<p class="submit">
<?php
- echo "<input type='submit' name='submit' value='" . __('Update File') . "' tabindex='2' />";
+ echo "<input type='submit' name='submit' class='button-primary' value='" . __('Update File') . "' tabindex='2' />";
?>
</p>
<?php else : ?>
<?php
+/**
+ * Themes administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
if ( isset($_GET['action']) ) {
$page_links = paginate_links( array(
'base' => add_query_arg( 'pagenum', '%#%' ) . '#themenav',
'format' => '',
+ 'prev_text' => __('«'),
+ 'next_text' => __('»'),
'total' => ceil($theme_total / $per_page),
'current' => $page
));
$themes = array_slice( $themes, $start, $per_page );
+/**
+ * Check if there is an update for a theme available.
+ *
+ * Will display link, if there is an update available.
+ *
+ * @since 2.7.0
+ *
+ * @param object $theme Theme data object.
+ * @return bool False if no valid info was passed.
+ */
+function theme_update_available( $theme ) {
+ static $themes_update;
+ if ( !isset($themes_update) )
+ $themes_update = get_option('update_themes');
+
+ if ( is_object($theme) && isset($theme->stylesheet) )
+ $stylesheet = $theme->stylesheet;
+ elseif ( is_array($theme) && isset($theme['Stylesheet']) )
+ $stylesheet = $theme['Stylesheet'];
+ else
+ return false; //No valid info passed.
+
+ if ( isset($themes_update->response[ $stylesheet ]) ) {
+ $update = $themes_update->response[ $stylesheet ];
+ $details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list.
+ $update_url = wp_nonce_url('update.php?action=upgrade-theme&theme=' . urlencode($stylesheet), 'upgrade-theme_' . $stylesheet);
+
+ if ( ! current_user_can('update_themes') )
+ printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a>.</p>'), $ct->name, $details_url, $update['new_version']);
+ else if ( empty($update->package) )
+ printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> <em>automatic upgrade unavailable for this theme</em>.</p>'), $ct->name, $details_url, $update['new_version']);
+ else
+ printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> or <a href="%4$s">upgrade automatically</a>.</p>'), $ct->name, $details_url, $update['new_version'], $update_url );
+ }
+}
+
?>
<div class="wrap">
-<h2><?php _e('Current Theme'); ?></h2>
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
+<h3><?php _e('Current Theme'); ?></h3>
<div id="current-theme">
<?php if ( $ct->screenshot ) : ?>
<img src="<?php echo WP_CONTENT_URL . $ct->stylesheet_dir . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
<?php endif; ?>
-<h3><?php printf(_c('%1$s %2$s by %3$s|1: theme title, 2: theme version, 3: theme author'), $ct->title, $ct->version, $ct->author) ; ?></h3>
+<h4><?php printf(_c('%1$s %2$s by %3$s|1: theme title, 2: theme version, 3: theme author'), $ct->title, $ct->version, $ct->author) ; ?></h4>
<p class="description"><?php echo $ct->description; ?></p>
<?php if ($ct->parent_theme) { ?>
<p><?php printf(__('The template files are located in <code>%2$s</code>. The stylesheet files are located in <code>%3$s</code>. <strong>%4$s</strong> uses templates from <strong>%5$s</strong>. Changes made to the templates will affect both themes.'), $ct->title, $ct->template_dir, $ct->stylesheet_dir, $ct->title, $ct->parent_theme); ?></p>
<?php if ( $ct->tags ) : ?>
<p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p>
<?php endif; ?>
-</div>
+<?php theme_update_available($ct); ?>
-<h2><?php _e('Available Themes'); ?></h2>
-<br class="clear" />
+</div>
+<div class="clear"></div>
+<h3><?php _e('Available Themes'); ?></h3>
+<div class="clear"></div>
<?php if ( $page_links ) : ?>
<div class="tablenav">
-<?php echo "<div class='tablenav-pages'>$page_links</div>"; ?>
-<br class="clear" />
+<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
+ number_format_i18n( $start + 1 ),
+ number_format_i18n( min( $page * $per_page, $theme_total ) ),
+ number_format_i18n( $theme_total ),
+ $page_links
+); echo $page_links_text; ?></div>
</div>
-<br class="clear" />
<?php endif; ?>
<?php if ( 1 < $theme_total ) { ?>
$screenshot = $themes[$theme_name]['Screenshot'];
$stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
$preview_link = clean_url( get_option('home') . '/');
- $preview_link = add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true', 'width' => 600, 'height' => 400 ), $preview_link );
+ $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true', 'width' => 600, 'height' => 400 ), $preview_link ) );
$preview_text = attribute_escape( sprintf( __('Preview of "%s"'), $title ) );
$tags = $themes[$theme_name]['Tags'];
$thickbox_class = 'thickbox';
<p><?php echo $description; ?></p>
<?php if ( $tags ) : ?>
<p><?php _e('Tags:'); ?> <?php echo join(', ', $tags); ?></p>
- <noscript><p class="themeactions"><a href="<?php echo $preview_link; ?>" title="<?php echo $preview_text; ?>"><?php _e('Preview'); ?></a> <a href="<?php echo $activate_link; ?>" title="<?php echo $activate_text; ?>"><?php _e('Activate'); ?></a></p></noscript>
<?php endif; ?>
+ <?php theme_update_available( $themes[$theme_name] ); ?>
+ <noscript><p class="themeactions"><a href="<?php echo $preview_link; ?>" title="<?php echo $preview_text; ?>"><?php _e('Preview'); ?></a> <a href="<?php echo $activate_link; ?>" title="<?php echo $activate_text; ?>"><?php _e('Activate'); ?></a></p></noscript>
<div style="display:none;"><a class="previewlink" href="<?php echo $preview_link; ?>"><?php echo $preview_text; ?></a> <a class="activatelink" href="<?php echo $activate_link; ?>"><?php echo $activate_text; ?></a></div>
<?php endif; // end if not empty theme_name ?>
</td>
<?php if ( $page_links ) : ?>
<div class="tablenav">
-<?php echo "<div class='tablenav-pages'>$page_links</div>"; ?>
+<?php echo "<div class='tablenav-pages'>$page_links_text</div>"; ?>
<br class="clear" />
</div>
<?php endif; ?>
--- /dev/null
+<?php
+/**
+ * Turbo Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('admin.php');
+
+$title = __('Tools');
+wp_enqueue_script( 'wp-gears' );
+
+require_once('admin-header.php');
+
+screen_icon();
+?>
+<div class="wrap">
+<h2><?php echo wp_specialchars( $title ); ?></h2>
+
+<div class="tool-box">
+<?php
+if ( ! $is_opera ) {
+?>
+ <div id="gears-msg1">
+ <h3 class="title"><?php _e('Turbo:'); ?> <?php _e('Speed up WordPress'); ?></h3>
+ <p><?php _e('WordPress now has support for Gears, which adds new features to your web browser.'); ?><br />
+ <a href="http://gears.google.com/" target="_blank" style="font-weight:normal;"><?php _e('More information...'); ?></a></p>
+ <p><?php _e('After you install and enable Gears, most of WordPress’ images, scripts, and CSS files will be stored locally on your computer. This speeds up page load time.'); ?></p>
+ <p><strong><?php _e('Don’t install on a public or shared computer.'); ?></strong></p>
+ <div class="buttons"><button onclick="window.location = 'http://gears.google.com/?action=install&return=<?php echo urlencode( admin_url() ); ?>';" class="button"><?php _e('Install Now'); ?></button></div>
+ </div>
+
+ <div id="gears-msg2" style="display:none;">
+ <h3 class="title"><?php _e('Turbo:'); ?> <?php _e('Gears Status'); ?></h3>
+ <p><?php _e('Gears is installed on this computer, but is not enabled for use with WordPress.'); ?></p>
+ <p><?php _e('To enable it click the button below.'); ?></p>
+ <p><strong><?php _e('Note: Do not enable Gears if this is a public or shared computer!'); ?></strong></p>
+ <div class="buttons"><button class="button" onclick="wpGears.getPermission();"><?php _e('Enable Gears'); ?></button></div>
+ </div>
+
+ <div id="gears-msg3" style="display:none;">
+ <h3 class="title"><?php _e('Turbo:'); ?> <?php _e('Gears Status'); ?></h3>
+ <p><?php
+
+ if ( $is_chrome )
+ _e('Gears is installed and enabled on this computer. You can disable it from your browser’s Options, Under the Hood menu.');
+ elseif ( $is_safari )
+ _e('Gears is installed and enabled on this computer. You can disable it from the Safari menu.');
+ else
+ _e('Gears is installed and enabled on this computer. You can disable it from your browser’s Tools menu.');
+
+ ?></p>
+ <p><?php _e('If there are any errors try disabling Gears, reloading the page, and re-enabling Gears.'); ?></p>
+ <p><?php _e('Local storage status:'); ?> <span id="gears-wait"><span style="color:#f00;"><?php _e('Updating files:'); ?></span> <span id="gears-upd-number"></span></span></p>
+ </div>
+
+ <div id="gears-msg4" style="display:none;">
+ <h3 class="title"><?php _e('Turbo:'); ?> <?php _e('Gears Status'); ?></h3>
+ <p><?php _e('Your browser’s settings do not permit this website to use Google Gears.'); ?></p>
+ <p><?php
+
+ if ( $is_chrome )
+ _e('To allow it, change the Gears settings in your browser’s Options, Under the Hood menu and reload this page.');
+ elseif ( $is_safari )
+ _e('To allow it, change the Gears settings in the Safari menu and reload this page.');
+ else
+ _e('To allow it, change the Gears settings in your browser’s Tools menu and reload this page.');
+
+ ?></p>
+ <p><strong><?php _e('Note: Do not enable Gears if this is a public or shared computer!'); ?></strong></p>
+ </div>
+ <script type="text/javascript">wpGears.message();</script>
+<?php } else {
+ _e('Turbo is not available for your browser.');
+} ?>
+</div>
+
+<?php if ( current_user_can('publish_posts') ) : ?>
+<div class="tool-box">
+ <h3 class="title"><?php _e('Press This') ?></h3>
+ <p><?php _e('Press This is a bookmarklet: a little app that runs in your browser and lets you grab bits of the web.');?></p>
+
+ <p><?php _e('Use Press This to clip text, images and videos from any web page. Then edit and add more straight from Press This before you save or publish it in a post on your blog.'); ?></p>
+ <p><?php _e('Drag-and-drop the following link to your bookmarks bar or right click it and add it to your favorites for a posting shortcut.') ?></p>
+ <p class="pressthis"><a href="<?php echo htmlspecialchars( get_shortcut_link() ); ?>" title="<?php echo attribute_escape(__('Press This')) ?>"><?php _e('Press This') ?></a></p>
+</div>
+<?php endif; ?>
+</div>
+<?php
+include('admin-footer.php');
+?>
--- /dev/null
+<?php
+/**
+ * Update Core administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('admin.php');
+
+if ( ! current_user_can('update_plugins') )
+ wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
+
+function list_core_update( $update ) {
+ $version_string = 'en_US' == $update->locale ?
+ $update->current : sprintf("%s–<strong>%s</strong>", $update->current, $update->locale);
+ $current = false;
+ if ( !isset($update->response) || 'latest' == $update->response )
+ $current = true;
+ $submit = __('Upgrade Automatically');
+ $form_action = 'update-core.php?action=do-core-upgrade';
+ if ( 'development' == $update->response ) {
+ $message = __('You are using a development version of WordPress. You can upgrade to the latest nightly build automatically or download the nightly build and install it manually:');
+ $download = __('Download nightly build');
+ } else {
+ if ( $current ) {
+ $message = sprintf(__('You have the latest version of WordPress. You do not need to upgrade. However, if you want to re-install version %s, you can do so automatically or download the package and re-install manually:'), $version_string);
+ $submit = __('Re-install Automatically');
+ $form_action = 'update-core.php?action=do-core-reinstall';
+ } else {
+ $message = sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string);
+ }
+ $download = sprintf(__('Download %s'), $version_string);
+ }
+
+ echo '<p>';
+ echo $message;
+ echo '</p>';
+ echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
+ wp_nonce_field('upgrade-core');
+ echo '<p>';
+ echo '<input id="upgrade" class="button" type="submit" value="' . $submit . '" name="upgrade" /> ';
+ echo '<input name="version" value="'.$update->current.'" type="hidden"/>';
+ echo '<input name="locale" value="'.$update->locale.'" type="hidden"/>';
+ echo '<a href="' . $update->package . '" class="button">' . $download . '</a> ';
+ if ( 'en_US' != $update->locale )
+ if ( !isset( $update->dismissed ) || !$update->dismissed )
+ echo '<input id="dismiss" class="button" type="submit" value="' . attribute_escape(__('Hide this update')) . '" name="dismiss" />';
+ else
+ echo '<input id="undismiss" class="button" type="submit" value="' . attribute_escape(__('Bring back this update')) . '" name="undismiss" />';
+ echo '</p>';
+ echo '</form>';
+
+}
+
+function dismissed_updates() {
+ $dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
+ if ( $dismissed ) {
+
+ $show_text = js_escape(__('Show hidden updates'));
+ $hide_text = js_escape(__('Hide hidden updates'));
+ ?>
+ <script type="text/javascript">
+
+ jQuery(function($) {
+ $('dismissed-updates').show();
+ $('#show-dismissed').toggle(function(){$(this).text('<?php echo $hide_text; ?>');}, function() {$(this).text('<?php echo $show_text; ?>')});
+ $('#show-dismissed').click(function() { $('#dismissed-updates').toggle('slow');});
+ });
+ </script>
+ <?php
+ echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
+ echo '<ul id="dismissed-updates" class="core-updates dismissed">';
+ foreach( (array) $dismissed as $update) {
+ echo '<li>';
+ list_core_update( $update );
+ echo '</li>';
+ }
+ echo '</ul>';
+ }
+}
+
+/**
+ * Display upgrade WordPress for downloading latest or upgrading automatically form.
+ *
+ * @since 2.7
+ *
+ * @return null
+ */
+function core_upgrade_preamble() {
+ $updates = get_core_updates();
+?>
+ <div class="wrap">
+ <?php screen_icon(); ?>
+ <h2><?php _e('Upgrade WordPress'); ?></h2>
+<?php
+ if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
+ echo '<h3>';
+ _e('You have the latest version of WordPress. You do not need to upgrade');
+ echo '</h3>';
+ } else {
+ echo '<div class="updated fade"><p>';
+ _e('<strong>Important:</strong> before upgrading, please <a href="http://codex.wordpress.org/WordPress_Backups">backup your database and files</a>.');
+ echo '</p></div>';
+
+ echo '<h3 class="response">';
+ _e( 'There is a new version of WordPress available for upgrade' );
+ echo '</h3>';
+ }
+
+ echo '<ul class="core-updates">';
+ $alternate = true;
+ foreach( (array) $updates as $update ) {
+ $class = $alternate? ' class="alternate"' : '';
+ $alternate = !$alternate;
+ echo "<li $class>";
+ list_core_update( $update );
+ echo '</li>';
+ }
+ echo '</ul>';
+ dismissed_updates();
+ echo '</div>';
+}
+
+
+/**
+ * Upgrade WordPress core display.
+ *
+ * @since 2.7
+ *
+ * @return null
+ */
+function do_core_upgrade( $reinstall = false ) {
+ global $wp_filesystem;
+
+ if ( $reinstall )
+ $url = 'update-core.php?action=do-core-reinstall';
+ else
+ $url = 'update-core.php?action=do-core-upgrade';
+ $url = wp_nonce_url($url, 'upgrade-core');
+ if ( false === ($credentials = request_filesystem_credentials($url)) )
+ return;
+
+ $version = isset( $_POST['version'] )? $_POST['version'] : false;
+ $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
+ $update = find_core_update( $version, $locale );
+ if ( !$update )
+ return;
+
+
+ if ( ! WP_Filesystem($credentials) ) {
+ request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
+ return;
+ }
+?>
+ <div class="wrap">
+ <?php screen_icon(); ?>
+ <h2><?php _e('Upgrade WordPress'); ?></h2>
+<?php
+ if ( $wp_filesystem->errors->get_error_code() ) {
+ foreach ( $wp_filesystem->errors->get_error_messages() as $message )
+ show_message($message);
+ echo '</div>';
+ return;
+ }
+
+ if ( $reinstall )
+ $update->response = 'reinstall';
+
+ $result = wp_update_core($update, 'show_message');
+
+ if ( is_wp_error($result) ) {
+ show_message($result);
+ if ('up_to_date' != $result->get_error_code() )
+ show_message( __('Installation Failed') );
+ } else {
+ show_message( __('WordPress upgraded successfully') );
+ }
+ echo '</div>';
+}
+
+function do_dismiss_core_update() {
+ $version = isset( $_POST['version'] )? $_POST['version'] : false;
+ $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
+ $update = find_core_update( $version, $locale );
+ if ( !$update )
+ return;
+ dismiss_core_update( $update );
+ wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
+}
+
+function do_undismiss_core_update() {
+ $version = isset( $_POST['version'] )? $_POST['version'] : false;
+ $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
+ $update = find_core_update( $version, $locale );
+ if ( !$update )
+ return;
+ undismiss_core_update( $version, $locale );
+ wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
+}
+
+$action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
+
+if ( 'upgrade-core' == $action ) {
+ $title = __('Upgrade WordPress');
+ $parent_file = 'tools.php';
+ require_once('admin-header.php');
+ core_upgrade_preamble();
+ include('admin-footer.php');
+} elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
+ check_admin_referer('upgrade-core');
+ $title = __('Upgrade WordPress');
+ $parent_file = 'tools.php';
+ // do the (un)dismiss actions before headers,
+ // so that they can redirect
+ if ( isset( $_POST['dismiss'] ) )
+ do_dismiss_core_update();
+ elseif ( isset( $_POST['undismiss'] ) )
+ do_undismiss_core_update();
+ require_once('admin-header.php');
+ if ( 'do-core-reinstall' == $action )
+ $reinstall = true;
+ else
+ $reinstall = false;
+ if ( isset( $_POST['upgrade'] ) )
+ do_core_upgrade($reinstall);
+ include('admin-footer.php');
+
+}?>
<?php
+/**
+ * Send blog links to pingomatic.com to update.
+ *
+ * You can disable this feature by deleting the option 'use_linksupdate' or
+ * setting the option to false. If no links exist, then no links are sent.
+ *
+ * Snoopy is included, but is not used. Fsockopen() is used instead to send link
+ * URLs.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
require_once('../wp-load.php');
-require_once( ABSPATH . 'wp-includes/class-snoopy.php');
if ( !get_option('use_linksupdate') )
wp_die(__('Feature disabled.'));
$query_string = "uris=$link_uris";
-$http_request = "POST /updated-batch/ HTTP/1.0\r\n";
-$http_request .= "Host: api.pingomatic.com\r\n";
-$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_option('blog_charset')."\r\n";
-$http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
-$http_request .= 'User-Agent: WordPress/' . $wp_version . "\r\n";
-$http_request .= "\r\n";
-$http_request .= $query_string;
-
-$response = '';
-if ( false !== ( $fs = @fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) {
- 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);
- $body = trim( $response[1] );
- $body = str_replace(array("\r\n", "\r"), "\n", $body);
-
- $returns = explode("\n", $body);
-
- foreach ($returns as $return) :
- $time = substr($return, 0, 19);
- $uri = preg_replace('/(.*?) | (.*?)/', '$2', $return);
- $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) );
- endforeach;
-}
+$options = array();
+$options['timeout'] = 30;
+$options['body'] = $query_string;
+
+$options['headers'] = array(
+ 'content-type' => 'application/x-www-form-urlencoded; charset='.get_option('blog_charset'),
+ 'content-length' => strlen( $query_string ),
+);
+
+$response = wp_remote_get('http://api.pingomatic.com/updated-batch/', $options);
+
+if ( is_wp_error( $response ) )
+ wp_die(__('Request Failed.'));
+
+if ( $response['response']['code'] != 200 )
+ wp_die(__('Request Failed.'));
+
+$body = str_replace(array("\r\n", "\r"), "\n", $response['body']);
+$returns = explode("\n", $body);
+
+foreach ($returns as $return) :
+ $time = substr($return, 0, 19);
+ $uri = preg_replace('/(.*?) | (.*?)/', '$2', $return);
+ $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) );
+endforeach;
+
?>
<?php
-
+/**
+ * Update Plugin/Theme administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
if ( ! current_user_can('update_plugins') )
wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
-function request_filesystem_credentials($form_post, $type = '', $error = false) {
- $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error);
- if ( '' !== $req_cred )
- return $req_cred;
-
- if ( empty($type) )
- $type = get_filesystem_method();
-
- if ( 'direct' == $type )
- return true;
-
- if( ! $credentials = get_option('ftp_credentials') )
- $credentials = array();
- // If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option)
- $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']);
- $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']);
- $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']);
- $credentials['ssl'] = defined('FTP_SSL') ? FTP_SSL : ( isset($_POST['ssl']) ? $_POST['ssl'] : $credentials['ssl']);
-
- if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) {
- $stored_credentials = $credentials;
- unset($stored_credentials['password']);
- update_option('ftp_credentials', $stored_credentials);
- return $credentials;
- }
- $hostname = '';
- $username = '';
- $password = '';
- $ssl = '';
- if ( !empty($credentials) )
- extract($credentials, EXTR_OVERWRITE);
- if( $error )
- echo '<div id="message" class="error"><p>' . __('<strong>Error:</strong> There was an error connecting to the server, Please verify the settings are correct.') . '</p></div>';
-?>
-<form action="<?php echo $form_post ?>" method="post">
-<div class="wrap">
-<h2><?php _e('FTP Connection Information') ?></h2>
-<p><?php _e('To perform the requested update, FTP connection information is required.') ?></p>
-<table class="form-table">
-<tr valign="top">
-<th scope="row"><label for="hostname"><?php _e('Hostname:') ?></label></th>
-<td><input name="hostname" type="text" id="hostname" value="<?php echo attribute_escape($hostname) ?>"<?php if( defined('FTP_HOST') ) echo ' disabled="disabled"' ?> size="40" /></td>
-</tr>
-<tr valign="top">
-<th scope="row"><label for="username"><?php _e('Username:') ?></label></th>
-<td><input name="username" type="text" id="username" value="<?php echo attribute_escape($username) ?>"<?php if( defined('FTP_USER') ) echo ' disabled="disabled"' ?> size="40" /></td>
-</tr>
-<tr valign="top">
-<th scope="row"><label for="password"><?php _e('Password:') ?></label></th>
-<td><input name="password" type="password" id="password" value=""<?php if( defined('FTP_PASS') ) echo ' disabled="disabled"' ?> size="40" /><?php if( defined('FTP_PASS') && !empty($password) ) echo '<em>'.__('(Password not shown)').'</em>'; ?></td>
-</tr>
-<tr valign="top">
-<th scope="row"><label for="ssl"><?php _e('Use SSL:') ?></label></th>
-<td>
-<select name="ssl" id="ssl"<?php if( defined('FTP_SSL') ) echo ' disabled="disabled"' ?>>
-<?php
-foreach ( array(0 => __('No'), 1 => __('Yes')) as $key => $value ) :
- $selected = ($ssl == $value) ? 'selected="selected"' : '';
- echo "\n\t<option value='$key' $selected>" . $value . '</option>';
-endforeach;
-?>
-</select>
-</td>
-</tr>
-</table>
-<p class="submit">
-<input type="submit" name="submit" value="<?php _e('Proceed'); ?>" />
-</p>
-</div>
-</form>
-<?php
- return false;
-}
-
-function show_message($message) {
- if( is_wp_error($message) ){
- if( $message->get_error_data() )
- $message = $message->get_error_message() . ': ' . $message->get_error_data();
- else
- $message = $message->get_error_message();
- }
- echo "<p>$message</p>\n";
-}
-
+/**
+ * Plugin upgrade display.
+ *
+ * @since 2.5
+ *
+ * @param string $plugin Plugin
+ */
function do_plugin_upgrade($plugin) {
global $wp_filesystem;
return;
if ( ! WP_Filesystem($credentials) ) {
- request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
+ $error = true;
+ if ( is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code() )
+ $error = $wp_filesystem->errors;
+ request_filesystem_credentials($url, '', $error); //Failed to connect, Error and request again
return;
}
if ( is_wp_error($result) ) {
show_message($result);
- show_message( __('Installation Failed') );
+ show_message( __('Plugin upgrade Failed') );
} else {
- //Result is the new plugin file relative to WP_PLUGIN_DIR
- show_message( __('Plugin upgraded successfully') );
+ $plugin_file = $result;
+ show_message( __('Plugin upgraded successfully') );
if( $result && $was_activated ){
show_message(__('Attempting reactivation of the plugin'));
- echo '<iframe style="border:0" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $result, 'activate-plugin_' . $result) .'"></iframe>';
+ echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) .'"></iframe>';
+ }
+ $update_actions = array(
+ 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . attribute_escape(__('Activate this plugin')) . '" target="_parent">' . __('Activate Plugin') . '</a>',
+ 'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . attribute_escape(__('Goto plugins page')) . '" target="_parent">' . __('Return to Plugins page') . '</a>'
+ );
+ if ( $was_activated )
+ unset( $update_actions['activate_plugin'] );
+
+ $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $plugin_file);
+ if ( ! empty($update_actions) )
+ show_message('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$update_actions));
+ }
+ echo '</div>';
+}
+
+/**
+ * Theme upgrade display.
+ *
+ * @since 2.5
+ *
+ * @param string $plugin Plugin
+ */
+function do_theme_upgrade($theme) {
+ global $wp_filesystem;
+
+ $url = wp_nonce_url('update.php?action=upgrade-theme&theme=' . urlencode($theme), 'upgrade-plugin_' . urlencode($theme));
+ if ( false === ($credentials = request_filesystem_credentials($url)) )
+ return;
+
+ if ( ! WP_Filesystem($credentials) ) {
+ $error = true;
+ if ( is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code() )
+ $error = $wp_filesystem->errors;
+ request_filesystem_credentials($url, '', $error); //Failed to connect, Error and request again
+ return;
+ }
+
+ echo '<div class="wrap">';
+ echo '<h2>' . __('Upgrade Theme') . '</h2>';
+ if ( $wp_filesystem->errors->get_error_code() ) {
+ foreach ( $wp_filesystem->errors->get_error_messages() as $message )
+ show_message($message);
+ echo '</div>';
+ return;
+ }
+
+ //TODO: Is theme currently active?
+ $was_current = false; //is_plugin_active($plugin); //Check now, It'll be deactivated by the next line if it is
+
+ $result = wp_update_theme($theme, 'show_message');
+
+ if ( is_wp_error($result) ) {
+ show_message($result);
+ show_message( __('Installation Failed') );
+ } else {
+ //Result is the new plugin file relative to WP_PLUGIN_DIR
+ show_message( __('Theme upgraded successfully') );
+ if( $result && $was_current ){
+ show_message(__('Setting theme as Current'));
+ //TODO: Actually set it as active again.
+ //echo '<iframe style="border:0" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $result, 'activate-plugin_' . $result) .'"></iframe>';
}
}
echo '</div>';
if ( isset($_GET['action']) ) {
$plugin = isset($_GET['plugin']) ? trim($_GET['plugin']) : '';
+ $theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';
+ $action = isset($_GET['action']) ? $_GET['action'] : '';
- if ( 'upgrade-plugin' == $_GET['action'] ) {
+ if ( 'upgrade-plugin' == $action ) {
check_admin_referer('upgrade-plugin_' . $plugin);
$title = __('Upgrade Plugin');
$parent_file = 'plugins.php';
require_once('admin-header.php');
do_plugin_upgrade($plugin);
include('admin-footer.php');
- } elseif ('activate-plugin' == $_GET['action'] ) {
+ } elseif ('activate-plugin' == $action ) {
check_admin_referer('activate-plugin_' . $plugin);
if( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
- wp_redirect( 'update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] );
+ wp_redirect( 'update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] );
activate_plugin($plugin);
- wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] );
+ wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] );
die();
}
- ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
-<head>
-<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
-<title><?php bloginfo('name') ?> › <?php _e('Plugin Reactivation'); ?> — <?php _e('WordPress'); ?></title>
-<?php
-wp_admin_css( 'global', true );
-wp_admin_css( 'colors', true );
-?>
-</head>
-<body>
-<?php
+ iframe_header( __('Plugin Reactivation'), true );
if( isset($_GET['success']) )
echo '<p>' . __('Plugin reactivated successfully.') . '</p>';
@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
include(WP_PLUGIN_DIR . '/' . $plugin);
}
- echo "</body></html>";
+ iframe_footer();
+ } elseif ( 'upgrade-theme' == $action ) {
+ check_admin_referer('upgrade-theme_' . $theme);
+ $title = __('Upgrade Theme');
+ $parent_file = 'themes.php';
+ require_once('admin-header.php');
+ do_theme_upgrade($theme);
+ include('admin-footer.php');
}
}
<?php
-// Deprecated. Use includes/upgrade.php.
+/**
+ * WordPress Upgrade Functions. Old file, must not be used. Include
+ * wp-admin/includes/upgrade.php instead.
+ *
+ * @deprecated 2.5
+ * @package WordPress
+ * @subpackage Administration
+ */
+
_deprecated_file( basename(__FILE__), '2.5', 'wp-admin/includes/upgrade.php' );
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
?>
<?php
+/**
+ * Upgrade WordPress Page.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * We are upgrading WordPress.
+ *
+ * @since unknown
+ * @var bool
+ */
define('WP_INSTALLING', true);
+/** Load WordPress Bootstrap */
require('../wp-load.php');
+
timer_start();
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
-if (isset($_GET['step']))
- $step = (int) $_GET['step'];
+if ( isset($_GET['step']) )
+ $step = $_GET['step'];
else
$step = 0;
+
+// Do it. No output.
+if ( 'upgrade_db' === $step ) {
+ wp_upgrade();
+ die('0');
+}
+
+$step = (int) $step;
+
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<body>
<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
-<?php if ( get_option('db_version') == $wp_db_version ) : ?>
+<?php if ( get_option('db_version') == $wp_db_version || !is_blog_installed()) : ?>
<h2><?php _e('No Upgrade Required'); ?></h2>
<p><?php _e('Your WordPress database is already up-to-date!'); ?></p>
endif;
?>
</body>
-</html>
\ No newline at end of file
+</html>
<?php
+/**
+ * Media Library administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
+wp_enqueue_script( 'wp-ajax-response' );
+wp_enqueue_script( 'jquery-ui-draggable' );
+wp_enqueue_script( 'jquery-ui-resizable' );
if (!current_user_can('upload_files'))
wp_die(__('You do not have permission to upload files.'));
-// Handle bulk deletes
-if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
+if ( isset($_GET['find_detached'] ) ) {
check_admin_referer('bulk-media');
- foreach( (array) $_GET['delete'] as $post_id_del ) {
- $post_del = & get_post($post_id_del);
- if ( !current_user_can('delete_post', $post_id_del) )
- wp_die( __('You are not allowed to delete this post.') );
+ if ( ! current_user_can('edit_posts') )
+ wp_die( __('You are not allowed to scan for lost attachments.') );
- if ( $post_del->post_type == 'attachment' )
- if ( ! wp_delete_attachment($post_id_del) )
- wp_die( __('Error in deleting...') );
+ $all_posts = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'post' OR post_type = 'page'");
+ $all_att = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'attachment'");
+
+ $lost = array();
+ foreach ( (array) $all_att as $att ) {
+ if ( $att->post_parent > 0 && ! in_array($att->post_parent, $all_posts) )
+ $lost[] = $att->ID;
}
+ $_GET['detached'] = 1;
+
+} elseif ( isset($_GET['found_post_id']) && isset($_GET['media']) ) {
+ check_admin_referer('bulk-media');
+
+ if ( ! ( $parent_id = (int) $_GET['found_post_id'] ) )
+ return;
+
+ $parent = &get_post($parent_id);
+ if ( !current_user_can('edit_post', $parent_id) )
+ wp_die( __('You are not allowed to edit this post.') );
+
+ $attach = array();
+ foreach( (array) $_GET['media'] as $att_id ) {
+ $att_id = (int) $att_id;
+
+ if ( !current_user_can('edit_post', $att_id) )
+ continue;
+
+ $attach[] = $att_id;
+ }
+
+ if ( ! empty($attach) ) {
+ $attach = implode(',', $attach);
+ $attached = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ($attach)", $parent_id) );
+ }
+
+ if ( isset($attached) ) {
+ $location = 'upload.php';
+ if ( $referer = wp_get_referer() ) {
+ if ( false !== strpos($referer, 'upload.php') )
+ $location = $referer;
+ }
- $location = 'upload.php';
- if ( $referer = wp_get_referer() ) {
- if ( false !== strpos($referer, 'upload.php') )
- $location = $referer;
+ $location = add_query_arg( array( 'detached' => 1, 'attached' => $attached ) , $location );
+ wp_redirect($location);
+ exit;
}
- $location = add_query_arg('message', 2, $location);
- $location = remove_query_arg('posted', $location);
- wp_redirect($location);
- exit;
-} elseif ( !empty($_GET['_wp_http_referer']) ) {
- wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
- exit;
+} elseif ( isset($_GET['action']) && isset($_GET['media']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
+ check_admin_referer('bulk-media');
+ $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
+
+ if ( 'delete' == $doaction ) {
+ foreach( (array) $_GET['media'] as $post_id_del ) {
+ $post_del = & get_post($post_id_del);
+
+ if ( !current_user_can('delete_post', $post_id_del) )
+ wp_die( __('You are not allowed to delete this post.') );
+
+ if ( $post_del->post_type == 'attachment' )
+ if ( ! wp_delete_attachment($post_id_del) )
+ wp_die( __('Error in deleting...') );
+ }
+
+ $location = 'upload.php';
+ if ( $referer = wp_get_referer() ) {
+ if ( false !== strpos($referer, 'upload.php') )
+ $location = $referer;
+ }
+
+ $location = add_query_arg('message', 2, $location);
+ $location = remove_query_arg('posted', $location);
+ wp_redirect($location);
+ exit;
+ }
+} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
+ wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
+ exit;
}
$title = __('Media Library');
-$parent_file = 'edit.php';
-wp_enqueue_script( 'admin-forms' );
+$parent_file = 'upload.php';
+
+if ( ! isset( $_GET['paged'] ) || $_GET['paged'] < 1 )
+ $_GET['paged'] = 1;
-list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
+if ( isset($_GET['detached']) ) {
-if ( is_singular() )
- wp_enqueue_script( 'admin-comments' );
+ if ( !empty($lost) ) {
+ $start = ( $_GET['paged'] - 1 ) * 50;
+ $page_links_total = ceil(count($lost) / 50);
+ $lost = implode(',', $lost);
-require_once('admin-header.php');
+ $orphans = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND ID IN ($lost) LIMIT $start, 50" );
+ } else {
+ $start = ( $_GET['paged'] - 1 ) * 25;
+ $orphans = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent < 1 LIMIT $start, 25" );
+ $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25);
+ }
-if ( !isset( $_GET['paged'] ) )
- $_GET['paged'] = 1;
+ $post_mime_types = array(
+ 'image' => array(__('Images'), __('Manage Images'), __ngettext_noop('Image (%s)', 'Images (%s)')),
+ 'audio' => array(__('Audio'), __('Manage Audio'), __ngettext_noop('Audio (%s)', 'Audio (%s)')),
+ 'video' => array(__('Video'), __('Manage Video'), __ngettext_noop('Video (%s)', 'Video (%s)')),
+ );
+ $post_mime_types = apply_filters('post_mime_types', $post_mime_types);
+ $avail_post_mime_types = get_available_post_mime_types('attachment');
+
+ if ( isset($_GET['post_mime_type']) && !array_intersect( (array) $_GET['post_mime_type'], array_keys($post_mime_types) ) )
+ unset($_GET['post_mime_type']);
+
+} else {
+ list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
+}
+
+require_once('admin-header.php'); ?>
+
+<?php
+if ( isset($_GET['posted']) && (int) $_GET['posted'] ) {
+ $_GET['message'] = '1';
+ $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
+}
+
+if ( isset($_GET['attached']) && (int) $_GET['attached'] ) {
+ $attached = (int) $_GET['attached'];
+ $message = sprintf( __ngettext('Reattached %d attachment', 'Reattached %d attachments', $attached), $attached );
+ $_SERVER['REQUEST_URI'] = remove_query_arg(array('attached'), $_SERVER['REQUEST_URI']);
+}
+
+$messages[1] = __('Media attachment updated.');
+$messages[2] = __('Media deleted.');
+$messages[3] = __('Error saving media attachment.');
+
+if ( isset($_GET['message']) && (int) $_GET['message'] ) {
+ $message = $messages[$_GET['message']];
+ $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
+}
?>
+<?php do_action('restrict_manage_posts'); ?>
+
<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title );
+if ( isset($_GET['s']) && $_GET['s'] )
+ printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( get_search_query() ) ); ?>
+</h2>
-<form id="posts-filter" action="" method="get">
-<h2><?php
-if ( is_singular() ) {
- printf(__('Comments on %s'), apply_filters( "the_title", $post->post_title));
-} else {
- $post_mime_type_label = _c('Manage Media|manage media header');
- if ( isset($_GET['post_mime_type']) && in_array( $_GET['post_mime_type'], array_keys($post_mime_types) ) )
- $post_mime_type_label = $post_mime_types[$_GET['post_mime_type']][1];
- if ( $post_listing_pageable && !is_archive() && !is_search() )
- $h2_noun = is_paged() ? sprintf(__( 'Previous %s' ), $post_mime_type_label) : sprintf(__('Latest %s'), $post_mime_type_label);
- else
- $h2_noun = $post_mime_type_label;
- // Use $_GET instead of is_ since they can override each other
- $h2_author = '';
- $_GET['author'] = (int) $_GET['author'];
- if ( $_GET['author'] != 0 ) {
- if ( $_GET['author'] == '-' . $user_ID ) { // author exclusion
- $h2_author = ' ' . __('by other authors');
- } else {
- $author_user = get_userdata( get_query_var( 'author' ) );
- $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
- }
- }
- $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( get_search_query() ) ) : '';
- $h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in “%s”'), single_cat_title('', false) ) : '';
- $h2_tag = isset($_GET['tag']) && $_GET['tag'] ? ' ' . sprintf( __('tagged with “%s”'), single_tag_title('', false) ) : '';
- $h2_month = isset($_GET['m']) && $_GET['m'] ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : '';
- printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: tagged with {s}, 6: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_tag, $h2_month );
+<?php
+if ( isset($message) ) { ?>
+<div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
+<?php
}
-?></h2>
+?>
<ul class="subsubsub">
<?php
$type_links = array();
$_num_posts = (array) wp_count_attachments();
+$_total_posts = array_sum( $_num_posts );
$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
foreach ( $matches as $type => $reals )
foreach ( $reals as $real )
- $num_posts[$type] += $_num_posts[$real];
-$class = empty($_GET['post_mime_type']) ? ' class="current"' : '';
-$type_links[] = "<li><a href=\"upload.php\"$class>".__('All Types')."</a>";
+ $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
+
+$class = empty($_GET['post_mime_type']) && ! isset($_GET['detached']) ? ' class="current"' : '';
+$type_links[] = "<li><a href='upload.php'$class>" . sprintf( __ngettext( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts ), number_format_i18n( $_total_posts ) ) . '</a>';
foreach ( $post_mime_types as $mime_type => $label ) {
$class = '';
if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
continue;
- if ( wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
+ if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
$class = ' class="current"';
- $type_links[] = "<li><a href=\"upload.php?post_mime_type=$mime_type\"$class>" .
- sprintf(__ngettext($label[2][0], $label[2][1], $num_posts[$mime_type]), number_format_i18n( $num_posts[$mime_type] )) . '</a>';
+ $type_links[] = "<li><a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( __ngettext( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>';
}
-echo implode(' | </li>', $type_links) . '</li>';
+$class = isset($_GET['detached']) ? ' class="current"' : '';
+$type_links[] = '<li><a href="upload.php?detached=1"' . $class . '>' . __('Unattached') . '</a>';
+
+echo implode( " |</li>\n", $type_links) . '</li>';
unset($type_links);
?>
</ul>
-<?php
-if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
-<div id="message" class="updated fade"><p><strong><?php _e('Your media has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View media'); ?></a> | <a href="media.php?action=edit&attachment_id=<?php echo $_GET['posted']; ?>"><?php _e('Edit media'); ?></a></p></div>
-<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
-endif;
-
-$messages[1] = __('Media updated.');
-$messages[2] = __('Media deleted.');
-
-if (isset($_GET['message'])) : ?>
-<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
-<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
-endif;
-?>
-
-<p id="post-search">
- <label class="hidden" for="post-search-input"><?php _e( 'Search Media' ); ?>:</label>
- <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
+<form class="search-form" action="" method="get">
+<p class="search-box">
+ <label class="hidden" for="media-search-input"><?php _e( 'Search Media' ); ?>:</label>
+ <input type="text" class="search-input" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
<input type="submit" value="<?php _e( 'Search Media' ); ?>" class="button" />
</p>
+</form>
-<?php do_action('restrict_manage_posts'); ?>
-
+<form id="posts-filter" action="" method="get">
<div class="tablenav">
-
<?php
+if ( ! isset($page_links_total) )
+ $page_links_total = $wp_query->max_num_pages;
+
$page_links = paginate_links( array(
'base' => add_query_arg( 'paged', '%#%' ),
'format' => '',
- 'total' => $wp_query->max_num_pages,
+ 'prev_text' => __('«'),
+ 'next_text' => __('»'),
+ 'total' => $page_links_total,
'current' => $_GET['paged']
));
-if ( $page_links )
- echo "<div class='tablenav-pages'>$page_links</div>";
-?>
-
-<div class="alignleft">
-<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
+if ( $page_links ) : ?>
+<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
+ number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ),
+ number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ),
+ number_format_i18n( $wp_query->found_posts ),
+ $page_links
+); echo $page_links_text; ?></div>
+<?php endif; ?>
+
+<div class="alignleft actions">
+<select name="action" class="select-action">
+<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+<?php if ( isset($orphans) ) { ?>
+<option value="attach"><?php _e('Attach to a post'); ?></option>
+<?php } ?>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-media'); ?>
-<?php
-if ( !is_singular() ) :
+<?php
+if ( ! is_singular() && ! isset($_GET['detached']) ) {
$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
$arc_result = $wpdb->get_results( $arc_query );
<input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
-<?php endif; // is_singular ?>
+<?php } // ! is_singular ?>
+
+<?php if ( isset($_GET['detached']) ) { ?>
+ <input type="submit" id="find_detached" name="find_detached" value="<?php _e('Scan for lost attachments'); ?>" class="button-secondary" />
+<?php } ?>
</div>
<br class="clear" />
</div>
-<br class="clear" />
+<div class="clear"></div>
-<?php include( 'edit-attachment-rows.php' ); ?>
+<?php if ( isset($orphans) ) { ?>
+<table class="widefat" cellspacing="0">
+<thead>
+<tr>
+ <th scope="col" class="check-column"><input type="checkbox" /></th>
+ <th scope="col"></th>
+ <th scope="col"><?php echo _c('Media|media column header'); ?></th>
+ <th scope="col"><?php echo _c('Date Added|media column header'); ?></th>
+</tr>
+</thead>
-</form>
+<tfoot>
+<tr>
+ <th scope="col" class="check-column"><input type="checkbox" /></th>
+ <th scope="col"></th>
+ <th scope="col"><?php echo _c('Media|media column header'); ?></th>
+ <th scope="col"><?php echo _c('Date Added|media column header'); ?></th>
+</tr>
+</tfoot>
+
+<tbody id="the-list" class="list:post">
+<?php
+ if ( $orphans ) {
+ foreach ( $orphans as $post ) {
+ $class = 'alternate' == $class ? '' : 'alternate';
+ $att_title = wp_specialchars( _draft_or_post_title($post->ID) );
+?>
+ <tr id='post-<?php echo $post->ID; ?>' class='<?php echo $class; ?>' valign="top">
+ <th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php echo $post->ID; ?>" /></th>
+
+ <td class="media-icon"><?php
+ if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) { ?>
+ <a href="media.php?action=edit&attachment_id=<?php echo $post->ID; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php echo $thumb; ?></a>
+<?php } ?></td>
+
+ <td><strong><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
+ <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
+
+ <p>
+ <?php
+ $actions = array();
+ if ( current_user_can('edit_post', $post->ID) )
+ $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
+ if ( current_user_can('delete_post', $post->ID) )
+ $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
+ $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
+ if ( current_user_can('edit_post', $post->ID) )
+ $actions['attach'] = '<a href="#the-list" onclick="findPosts.open(\'media[]\',\''.$post->ID.'\');return false;">'.__('Attach').'</a>';
+ $action_count = count($actions);
+ $i = 0;
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ echo "<span class='$action'>$link$sep</span>";
+ } ?>
+ </p></td>
+
+<?php if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
+ $t_time = $h_time = __('Unpublished');
+ } else {
+ $t_time = get_the_time(__('Y/m/d g:i:s A'));
+ $m_time = $post->post_date;
+ $time = get_post_time( 'G', true );
+ if ( ( abs($t_diff = time() - $time) ) < 86400 ) {
+ if ( $t_diff < 0 )
+ $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
+ else
+ $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
+ } else {
+ $h_time = mysql2date(__('Y/m/d'), $m_time);
+ }
+ } ?>
+ <td><?php echo $h_time ?></td>
+ </tr>
+<?php }
+
+ } else { ?>
+ <tr><td colspan="5"><?php _e('No posts found.') ?></td></tr>
+<?php } ?>
+</tbody>
+</table>
+
+<?php find_posts_div();
+
+} else {
+ include( 'edit-attachment-rows.php' );
+} ?>
<div id="ajax-response"></div>
<?php
if ( $page_links )
- echo "<div class='tablenav-pages'>$page_links</div>";
+ echo "<div class='tablenav-pages'>$page_links_text</div>";
?>
+<div class="alignleft actions">
+<select name="action2" class="select-action">
+<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+<?php if ( isset($orphans) ) { ?>
+<option value="attach"><?php _e('Attach to a post'); ?></option>
+<?php } ?>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
</div>
<br class="clear" />
-
-<?php
-
-if ( 1 == count($posts) && is_singular() ) :
-
- $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) );
- if ( $comments ) :
- // Make sure comments, post, and post_author are cached
- update_comment_cache($comments);
- $post = get_post($id);
- $authordata = get_userdata($post->post_author);
- ?>
-
+</div>
+</form>
<br class="clear" />
-<table class="widefat" style="margin-top: .5em">
-<thead>
- <tr>
- <th scope="col"><?php _e('Comment') ?></th>
- <th scope="col"><?php _e('Date') ?></th>
- <th scope="col"><?php _e('Actions') ?></th>
- </tr>
-</thead>
-<tbody id="the-comment-list" class="list:comment">
-<?php
- foreach ($comments as $comment)
- _wp_comment_row( $comment->comment_ID, 'detail', false, false );
-?>
-</tbody>
-</table>
+</div>
-<?php
+<script type="text/javascript">
+/* <![CDATA[ */
+(function($){
+ $(document).ready(function(){
+ $('#doaction, #doaction2').click(function(e){
+ if ( $('select[name^="action"]').val() == 'delete' ) {
+ var m = '<?php echo js_escape(__("You are about to delete the selected attachments.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
+ return showNotice.warn(m);
+ } else if ( $('select[name^="action"]').val() == 'attach' ) {
+ e.preventDefault();
+ findPosts.open();
+ }
+ });
+ });
+})(jQuery);
+columns.init('upload');
+/* ]]> */
+</script>
-endif; // comments
-endif; // posts;
+<?php
+include('admin-footer.php');
?>
-
-</div>
-
-<?php include('admin-footer.php'); ?>
<?php
-
+/**
+ * Edit user administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
if ( defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE )
else
$is_profile_page = false;
+/**
+ * Display JavaScript for profile page.
+ *
+ * @since 2.5.0
+ */
function profile_js ( ) {
?>
<script type="text/javascript">
- function check_pass_strength ( ) {
+(function($){
- var pass = jQuery('#pass1').val();
- var user = jQuery('#user_login').val();
+ function check_pass_strength () {
- // get the result as an object, i'm tired of typing it
- var res = jQuery('#pass-strength-result');
+ var pass = $('#pass1').val();
+ var user = $('#user_login').val();
- var strength = passwordStrength(pass, user);
+ $('#pass-strength-result').removeClass('short bad good strong');
+ if ( ! pass ) {
+ $('#pass-strength-result').html( pwsL10n.empty );
+ return;
+ }
- jQuery(res).removeClass('short bad good strong');
+ var strength = passwordStrength(pass, user);
- if ( strength == pwsL10n.bad ) {
- jQuery(res).addClass('bad');
- jQuery(res).html( pwsL10n.bad );
- }
- else if ( strength == pwsL10n.good ) {
- jQuery(res).addClass('good');
- jQuery(res).html( pwsL10n.good );
- }
- else if ( strength == pwsL10n.strong ) {
- jQuery(res).addClass('strong');
- jQuery(res).html( pwsL10n.strong );
- }
- else {
+ if ( 2 == strength )
+ $('#pass-strength-result').addClass('bad').html( pwsL10n.bad );
+ else if ( 3 == strength )
+ $('#pass-strength-result').addClass('good').html( pwsL10n.good );
+ else if ( 4 == strength )
+ $('#pass-strength-result').addClass('strong').html( pwsL10n.strong );
+ else
// this catches 'Too short' and the off chance anything else comes along
- jQuery(res).addClass('short');
- jQuery(res).html( pwsL10n.short );
- }
+ $('#pass-strength-result').addClass('short').html( pwsL10n.short );
}
-
- function update_nickname ( ) {
-
- var nickname = jQuery('#nickname').val();
- var display_nickname = jQuery('#display_nickname').val();
-
+
+ function update_nickname () {
+
+ var nickname = $('#nickname').val();
+ var display_nickname = $('#display_nickname').val();
+
if ( nickname == '' ) {
- jQuery('#display_nickname').remove();
+ $('#display_nickname').remove();
}
- jQuery('#display_nickname').val(nickname).html(nickname);
-
+ $('#display_nickname').val(nickname).html(nickname);
+
}
- jQuery(function($) {
- $('#pass1').keyup( check_pass_strength )
+ $(document).ready( function() {
+ $('#nickname').blur(update_nickname);
+ $('#pass1').val('').keyup( check_pass_strength );
$('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
- } );
-
- jQuery(document).ready( function() {
- jQuery('#pass1,#pass2').attr('autocomplete','off');
- jQuery('#nickname').blur(update_nickname);
});
+})(jQuery);
</script>
<?php
}
$user_id = (int) $user_id;
-if ( !$user_id )
+if ( !$user_id ) {
if ( $is_profile_page ) {
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
} else {
wp_die(__('Invalid user ID.'));
}
+} elseif ( !get_userdata($user_id) ) {
+ wp_die( __('Invalid user ID.') );
+}
+
+/**
+ * Optional SSL preference that can be turned on by hooking to the 'personal_options' action.
+ *
+ * @since 2.7.0
+ *
+ * @param object $user User data object
+ */
+function use_ssl_preference($user) {
+?>
+ <tr>
+ <th scope="row"><?php _e('Use https')?></th>
+ <td><label for="use_ssl"><input name="use_ssl" type="checkbox" id="use_ssl" value="1" <?php checked('1', $user->use_ssl); ?> /> <?php _e('Always use https when visiting the admin'); ?></label></td>
+ </tr>
+<?php
+}
switch ($action) {
case 'switchposts':
if ( !current_user_can('edit_user', $user_id) )
wp_die(__('You do not have permission to edit this user.'));
-if ( $is_profile_page ) {
+if ($is_profile_page)
do_action('personal_options_update');
-}
+else
+ do_action('edit_user_profile_update');
$errors = edit_user($user_id);
-if( !is_wp_error( $errors ) ) {
+if ( !is_wp_error( $errors ) ) {
$redirect = ($is_profile_page? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
$redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
wp_redirect($redirect);
$profileuser = get_user_to_edit($user_id);
if ( !current_user_can('edit_user', $user_id) )
- wp_die(__('You do not have permission to edit this user.'));
+ wp_die(__('You do not have permission to edit this user.'));
include ('admin-header.php');
?>
<div id="message" class="updated fade">
<p><strong><?php _e('User updated.') ?></strong></p>
<?php if ( $wp_http_referer && !$is_profile_page ) : ?>
- <p><a href="users.php"><?php _e('« Back to Authors and Users'); ?></a></p>
+ <p><a href="users.php"><?php _e('← Back to Authors and Users'); ?></a></p>
<?php endif; ?>
</div>
<?php endif; ?>
-<?php if ( is_wp_error( $errors ) ) : ?>
+<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
<div class="error">
<ul>
<?php
<?php endif; ?>
<div class="wrap" id="profile-page">
-<h2><?php $is_profile_page? _e('Your Profile and Personal Options') : _e('Edit User'); ?></h2>
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
-<form name="profile" id="your-profile" action="" method="post">
+<form id="your-profile" action="" method="post">
<?php wp_nonce_field('update-user_' . $user_id) ?>
<?php if ( $wp_http_referer ) : ?>
<input type="hidden" name="wp_http_referer" value="<?php echo clean_url($wp_http_referer); ?>" />
<?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
<tr>
<th scope="row"><?php _e('Visual Editor')?></th>
- <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', $profileuser->rich_editing); ?> /> <?php _e('Use the visual editor when writing'); ?></label></td>
+ <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked('false', $profileuser->rich_editing); ?> /> <?php _e('Disable the visual editor when writing'); ?></label></td>
</tr>
<?php endif; ?>
+<?php if (count($_wp_admin_css_colors) > 1 ) : ?>
<tr>
<th scope="row"><?php _e('Admin Color Scheme')?></th>
<td><fieldset><legend class="hidden"><?php _e('Admin Color Scheme')?></legend>
<div class="color-option"><input name="admin_color" id="admin_color_<?php echo $color; ?>" type="radio" value="<?php echo $color ?>" class="tog" <?php checked($color, $current_color); ?> />
<table class="color-palette">
<tr>
- <?php
- foreach ( $color_info->colors as $html_color ): ?>
+ <?php foreach ( $color_info->colors as $html_color ): ?>
<td style="background-color: <?php echo $html_color ?>" title="<?php echo $color ?>"> </td>
<?php endforeach; ?>
</tr>
</table>
-
+
<label for="admin_color_<?php echo $color; ?>"><?php echo $color_info->name ?></label>
</div>
-<?php endforeach; ?>
+ <?php endforeach; ?>
</fieldset></td>
</tr>
+<tr>
+<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
+<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( !empty($profileuser->comment_shortcuts) ) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e( 'Enable keyboard shortcuts for comment moderation. <a href="http://codex.wordpress.org/Keyboard_Shortcuts">More information</a>' ); ?></label></td>
+</tr>
+<?php
+endif;
+do_action('personal_options', $profileuser);
+?>
</table>
-
<?php
- if ( $is_profile_page ) {
- do_action('profile_personal_options');
- }
+ if ( $is_profile_page )
+ do_action('profile_personal_options', $profileuser);
?>
<h3><?php _e('Name') ?></h3>
<table class="form-table">
<tr>
<th><label for="user_login"><?php _e('Username'); ?></label></th>
- <td><input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" /> <?php _e('Your username cannot be changed'); ?></td>
+ <td><input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" class="regular-text" /> <?php _e('Your username cannot be changed.'); ?></td>
</tr>
<?php if ( !$is_profile_page ): ?>
<tr>
<th><label for="first_name"><?php _e('First name') ?></label></th>
- <td><input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" /></td>
+ <td><input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" class="regular-text" /></td>
</tr>
<tr>
<th><label for="last_name"><?php _e('Last name') ?></label></th>
- <td><input type="text" name="last_name" id="last_name" value="<?php echo $profileuser->last_name ?>" /></td>
+ <td><input type="text" name="last_name" id="last_name" value="<?php echo $profileuser->last_name ?>" class="regular-text" /></td>
</tr>
<tr>
<th><label for="nickname"><?php _e('Nickname') ?></label></th>
- <td><input type="text" name="nickname" id="nickname" value="<?php echo $profileuser->nickname ?>" /></td>
+ <td><input type="text" name="nickname" id="nickname" value="<?php echo $profileuser->nickname ?>" class="regular-text" /></td>
</tr>
<tr>
<table class="form-table">
<tr>
<th><label for="email"><?php _e('E-mail') ?></label></th>
- <td><input type="text" name="email" id="email" value="<?php echo $profileuser->user_email ?>" /> <?php _e('Required'); ?></td>
+ <td><input type="text" name="email" id="email" value="<?php echo $profileuser->user_email ?>" class="regular-text" /> <?php _e('Required.');?></td>
</tr>
<tr>
<th><label for="url"><?php _e('Website') ?></label></th>
- <td><input type="text" name="url" id="url" value="<?php echo $profileuser->user_url ?>" /></td>
+ <td><input type="text" name="url" id="url" value="<?php echo $profileuser->user_url ?>" class="regular-text" /></td>
</tr>
<tr>
<th><label for="aim"><?php _e('AIM') ?></label></th>
- <td><input type="text" name="aim" id="aim" value="<?php echo $profileuser->aim ?>" /></td>
+ <td><input type="text" name="aim" id="aim" value="<?php echo $profileuser->aim ?>" class="regular-text" /></td>
</tr>
<tr>
<th><label for="yim"><?php _e('Yahoo IM') ?></label></th>
- <td><input type="text" name="yim" id="yim" value="<?php echo $profileuser->yim ?>" /></td>
+ <td><input type="text" name="yim" id="yim" value="<?php echo $profileuser->yim ?>" class="regular-text" /></td>
</tr>
<tr>
<th><label for="jabber"><?php _e('Jabber / Google Talk') ?></label></th>
- <td><input type="text" name="jabber" id="jabber" value="<?php echo $profileuser->jabber ?>" /></td>
+ <td><input type="text" name="jabber" id="jabber" value="<?php echo $profileuser->jabber ?>" class="regular-text" /></td>
</tr>
</table>
?>
<tr>
<th><label for="pass1"><?php _e('New Password'); ?></label></th>
- <td><input type="password" name="pass1" id="pass1" size="16" value="" /> <?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?><br />
- <input type="password" name="pass2" id="pass2" size="16" value="" /> <?php _e("Type your new password again."); ?><br />
- <?php if ( $is_profile_page ): ?>
- <p><strong><?php _e('Password Strength'); ?></strong></p>
- <div id="pass-strength-result"><?php _e('Too short'); ?></div> <?php _e('Hint: Use upper and lower case characters, numbers and symbols like !"?$%^&( in your password.'); ?>
- <?php endif; ?>
+ <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?><br />
+ <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <?php _e("Type your new password again."); ?><br />
+ <?php if ( $is_profile_page ): ?>
+ <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
+ <p><?php _e('Hint: Your password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).'); ?></p>
+ <?php endif; ?>
</td>
</tr>
<?php endif; ?>
<p class="submit">
<input type="hidden" name="action" value="update" />
<input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
- <input type="submit" value="<?php $is_profile_page? _e('Update Profile') : _e('Update User') ?>" name="submit" />
- </p>
+ <input type="submit" class="button-primary" value="<?php $is_profile_page? _e('Update Profile') : _e('Update User') ?>" name="submit" />
+</p>
</form>
</div>
<?php
--- /dev/null
+<?php
+/**
+ * New User Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('admin.php');
+
+if ( !current_user_can('create_users') )
+ wp_die(__('Cheatin’ uh?'));
+
+/** WordPress Registration API */
+require_once( ABSPATH . WPINC . '/registration.php');
+
+if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) {
+ check_admin_referer('add-user');
+
+ if ( ! current_user_can('create_users') )
+ wp_die(__('You can’t create users.'));
+
+ $user_id = add_user();
+
+ if ( is_wp_error( $user_id ) ) {
+ $add_user_errors = $user_id;
+ } else {
+ $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
+ $redirect = 'users.php?usersearch='. urlencode($new_user_login) . '&update=add';
+ wp_redirect( $redirect . '#user-' . $user_id );
+ die();
+ }
+}
+
+$title = __('Add New User');
+$parent_file = 'users.php';
+
+wp_enqueue_script('admin-users');
+
+require_once ('admin-header.php');
+
+?>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2 id="add-new-user"><?php _e('Add New User') ?></h2>
+
+<?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
+ <div class="error">
+ <ul>
+ <?php
+ foreach ( $errors->get_error_messages() as $err )
+ echo "<li>$err</li>\n";
+ ?>
+ </ul>
+ </div>
+<?php endif;
+
+if ( ! empty($messages) ) {
+ foreach ( $messages as $msg )
+ echo $msg;
+} ?>
+
+<?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?>
+ <div class="error">
+ <?php
+ foreach ( $add_user_errors->get_error_messages() as $message )
+ echo "<p>$message</p>";
+ ?>
+ </div>
+<?php endif; ?>
+<div id="ajax-response"></div>
+
+<?php
+ if ( get_option('users_can_register') )
+ echo '<p>' . sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), site_url('wp-register.php')) . '</p>';
+ else
+ echo '<p>' . sprintf(__('Users cannot currently <a href="%1$s">register themselves</a>, but you can manually create users here.'), admin_url('options-general.php#users_can_register')) . '</p>';
+?>
+<form action="#add-new-user" method="post" name="adduser" id="adduser" class="add:users: validate">
+<?php wp_nonce_field('add-user') ?>
+<?php
+//Load up the passed data, else set to a default.
+foreach ( array('user_login' => 'login', 'first_name' => 'firstname', 'last_name' => 'lastname',
+ 'email' => 'email', 'url' => 'uri', 'role' => 'role') as $post_field => $var ) {
+ $var = "new_user_$var";
+ if ( ! isset($$var) )
+ $$var = isset($_POST[$post_field]) ? stripslashes($_POST[$post_field]) : '';
+}
+?>
+<table class="form-table">
+ <tr class="form-field form-required">
+ <th scope="row"><label for="user_login"><?php _e('Username (required)') ?></label><input name="action" type="hidden" id="action" value="adduser" /></th>
+ <td ><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" aria-required="true" /></td>
+ </tr>
+ <tr class="form-field">
+ <th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th>
+ <td><input name="first_name" type="text" id="first_name" value="<?php echo $new_user_firstname; ?>" /></td>
+ </tr>
+ <tr class="form-field">
+ <th scope="row"><label for="last_name"><?php _e('Last Name') ?> </label></th>
+ <td><input name="last_name" type="text" id="last_name" value="<?php echo $new_user_lastname; ?>" /></td>
+ </tr>
+ <tr class="form-field form-required">
+ <th scope="row"><label for="email"><?php _e('E-mail (required)') ?></label></th>
+ <td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td>
+ </tr>
+ <tr class="form-field">
+ <th scope="row"><label for="url"><?php _e('Website') ?></label></th>
+ <td><input name="url" type="text" id="url" value="<?php echo $new_user_uri; ?>" /></td>
+ </tr>
+
+<?php if ( apply_filters('show_password_fields', true) ) : ?>
+ <tr class="form-field form-required">
+ <th scope="row"><label for="pass1"><?php _e('Password (twice)') ?> </label></th>
+ <td><input name="pass1" type="password" id="pass1" autocomplete="off" />
+ <br />
+ <input name="pass2" type="password" id="pass2" autocomplete="off"/></td>
+ </tr>
+<?php endif; ?>
+
+ <tr class="form-field">
+ <th scope="row"><label for="role"><?php _e('Role'); ?></label></th>
+ <td><select name="role" id="role">
+ <?php
+ if ( !$new_user_role )
+ $new_user_role = !empty($current_role) ? $current_role : get_option('default_role');
+ wp_dropdown_roles($new_user_role);
+ ?>
+ </select>
+ </td>
+ </tr>
+</table>
+<p class="submit">
+ <input name="adduser" type="submit" id="addusersub" class="button-primary" value="<?php _e('Add User') ?>" />
+</p>
+</form>
+
+</div>
+
+<?php
+include('admin-footer.php');
+?>
\ No newline at end of file
<?php
+/**
+ * Users administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once('admin.php');
+
+/** WordPress Registration API */
require_once( ABSPATH . WPINC . '/registration.php');
if ( !current_user_can('edit_users') )
$title = __('Users');
$parent_file = 'users.php';
-$action = $_REQUEST['action'];
-$update = '';
+$update = $doaction = '';
+if ( isset($_REQUEST['action']) )
+ $doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2'];
-if ( empty($action) ) {
- if ( isset($_GET['deleteit']) )
- $action = 'delete';
- elseif ( isset($_GET['changeit']) && !empty($_GET['new_role']) )
- $action = 'promote';
+if ( empty($doaction) ) {
+ if ( isset($_GET['changeit']) && !empty($_GET['new_role']) )
+ $doaction = 'promote';
}
if ( empty($_REQUEST) ) {
$referer = '<input type="hidden" name="wp_http_referer" value="' . attribute_escape($redirect) . '" />';
} else {
$redirect = 'users.php';
+ $referer = '';
}
-switch ($action) {
+switch ($doaction) {
case 'promote':
check_admin_referer('bulk-users');
check_admin_referer('bulk-users');
- if ( empty($_REQUEST['users']) ) {
+ if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) {
wp_redirect($redirect);
exit();
}
if ( !current_user_can('delete_users') )
$errors = new WP_Error('edit_users', __('You can’t delete users.'));
- $userids = $_REQUEST['users'];
+ if ( empty($_REQUEST['users']) )
+ $userids = array(intval($_REQUEST['user']));
+ else
+ $userids = $_REQUEST['users'];
include ('admin-header.php');
?>
<?php echo $referer; ?>
<div class="wrap">
+<?php screen_icon(); ?>
<h2><?php _e('Delete Users'); ?></h2>
<p><?php _e('You have specified these users for deletion:'); ?></p>
<ul>
<?php
$go_delete = false;
foreach ( (array) $userids as $id ) {
+ $id = (int) $id;
$user = new WP_User($id);
if ( $id == $current_user->ID ) {
echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n";
break;
-case 'adduser':
- check_admin_referer('add-user');
-
- if ( ! current_user_can('create_users') )
- wp_die(__('You can’t create users.'));
-
- $user_id = add_user();
- $update = 'add';
- if ( is_wp_error( $user_id ) )
- $add_user_errors = $user_id;
- else {
- $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
- $redirect = add_query_arg( array('usersearch' => urlencode($new_user_login), 'update' => $update), $redirect );
- wp_redirect( $redirect . '#user-' . $user_id );
- die();
- }
-
default:
if ( !empty($_GET['_wp_http_referer']) ) {
}
wp_enqueue_script('admin-users');
- wp_enqueue_script('admin-forms');
include('admin-header.php');
+ $usersearch = isset($_GET['usersearch']) ? $_GET['usersearch'] : null;
+ $userspage = isset($_GET['userspage']) ? $_GET['userspage'] : null;
+ $role = isset($_GET['role']) ? $_GET['role'] : null;
+
// Query the users
- $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage'], $_GET['role']);
+ $wp_user_search = new WP_User_Search($usersearch, $userspage, $role);
+ $messages = array();
if ( isset($_GET['update']) ) :
switch($_GET['update']) {
case 'del':
case 'del_many':
- ?>
- <?php $delete_count = (int) $_GET['delete_count']; ?>
- <div id="message" class="updated fade"><p><?php printf(__ngettext('%s user deleted', '%s users deleted', $delete_count), $delete_count); ?></p></div>
- <?php
+ $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0;
+ $messages[] = '<div id="message" class="updated fade"><p>' . sprintf(__ngettext('%s user deleted', '%s users deleted', $delete_count), $delete_count) . '</p></div>';
break;
case 'add':
- ?>
- <div id="message" class="updated fade"><p><?php _e('New user created.'); ?></p></div>
- <?php
+ $messages[] = '<div id="message" class="updated fade"><p>' . __('New user created.') . '</p></div>';
break;
case 'promote':
- ?>
- <div id="message" class="updated fade"><p><?php _e('Changed roles.'); ?></p></div>
- <?php
+ $messages[] = '<div id="message" class="updated fade"><p>' . __('Changed roles.') . '</p></div>';
break;
case 'err_admin_role':
- ?>
- <div id="message" class="error"><p><?php _e("The current user's role must have user editing capabilities."); ?></p></div>
- <div id="message" class="updated fade"><p><?php _e('Other user roles have been changed.'); ?></p></div>
- <?php
+ $messages[] = '<div id="message" class="error"><p>' . __("The current user's role must have user editing capabilities.") . '</p></div>';
+ $messages[] = '<div id="message" class="updated fade"><p>' . __('Other user roles have been changed.') . '</p></div>';
break;
case 'err_admin_del':
- ?>
- <div id="message" class="error"><p><?php _e("You can't delete the current user."); ?></p></div>
- <div id="message" class="updated fade"><p><?php _e('Other users have been deleted.'); ?></p></div>
- <?php
+ $messages[] = '<div id="message" class="error"><p>' . __("You can't delete the current user.") . '</p></div>';
+ $messages[] = '<div id="message" class="updated fade"><p>' . __('Other users have been deleted.') . '</p></div>';
break;
}
endif; ?>
-<?php if ( is_wp_error( $errors ) ) : ?>
+<?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
<div class="error">
<ul>
<?php
- foreach ( $errors->get_error_messages() as $message )
- echo "<li>$message</li>";
+ foreach ( $errors->get_error_messages() as $err )
+ echo "<li>$err</li>\n";
?>
</ul>
</div>
-<?php endif; ?>
+<?php endif;
-<div class="wrap">
-<form id="posts-filter" action="" method="get">
- <?php if ( $wp_user_search->is_search() ) : ?>
- <h2><?php printf(__('Users Matching "%s"'), wp_specialchars($wp_user_search->search_term)); ?></h2>
- <?php else : ?>
- <h2><?php _e('Manage Users'); ?></h2>
- <?php endif; ?>
+if ( ! empty($messages) ) {
+ foreach ( $messages as $msg )
+ echo $msg;
+} ?>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title );
+if ( isset($_GET['s']) && $_GET['s'] )
+ printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( get_search_query() ) ); ?>
+</h2>
+
+<div class="filter">
+<form id="list-filter" action="" method="get">
<ul class="subsubsub">
<?php
$role_links = array();
$avail_roles = array();
$users_of_blog = get_users_of_blog();
-//var_dump($users_of_blog);
+$total_users = count( $users_of_blog );
foreach ( (array) $users_of_blog as $b_user ) {
$b_roles = unserialize($b_user->meta_value);
foreach ( (array) $b_roles as $b_role => $val ) {
unset($users_of_blog);
$current_role = false;
-$class = empty($_GET['role']) ? ' class="current"' : '';
-$role_links[] = "<li><a href=\"users.php\"$class>" . __('All Users') . "</a>";
-foreach ( $wp_roles->get_names() as $role => $name ) {
- if ( !isset($avail_roles[$role]) )
+$class = empty($role) ? ' class="current"' : '';
+$role_links[] = "<li><a href='users.php'$class>" . sprintf( __ngettext( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users ), number_format_i18n( $total_users ) ) . '</a>';
+foreach ( $wp_roles->get_names() as $this_role => $name ) {
+ if ( !isset($avail_roles[$this_role]) )
continue;
$class = '';
- if ( $role == $_GET['role'] ) {
- $current_role = $_GET['role'];
+ if ( $this_role == $role ) {
+ $current_role = $role;
$class = ' class="current"';
}
$name = translate_with_context($name);
- $name = sprintf(_c('%1$s (%2$s)|user role with count'), $name, $avail_roles[$role]);
- $role_links[] = "<li><a href=\"users.php?role=$role\"$class>" . $name . '</a>';
+ $name = sprintf( _c('%1$s <span class="count">(%2$s)</span>|user role with count'), $name, $avail_roles[$this_role] );
+ $role_links[] = "<li><a href='users.php?role=$this_role'$class>$name</a>";
}
-echo implode(' |</li>', $role_links) . '</li>';
+echo implode( " |</li>\n", $role_links) . '</li>';
unset($role_links);
?>
</ul>
- <p id="post-search">
- <label class="hidden" for="post-search-input"><?php _e( 'Search Users' ); ?>:</label>
- <input type="text" id="post-search-input" name="usersearch" value="<?php echo attribute_escape($wp_user_search->search_term); ?>" />
+</form>
+</div>
+
+<form class="search-form" action="" method="get">
+<p class="search-box">
+ <label class="hidden" for="user-search-input"><?php _e( 'Search Users' ); ?>:</label>
+ <input type="text" class="search-input" id="user-search-input" name="usersearch" value="<?php echo attribute_escape($wp_user_search->search_term); ?>" />
<input type="submit" value="<?php _e( 'Search Users' ); ?>" class="button" />
- </p>
+</p>
+</form>
+<form id="posts-filter" action="" method="get">
<div class="tablenav">
<?php if ( $wp_user_search->results_are_paged() ) : ?>
<div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div>
<?php endif; ?>
-<div class="alignleft">
-<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
-<label class="hidden" for="new_role"><?php _e('Change role to…') ?></label><select name="new_role" id="new_role"><option value=''><?php _e('Change role to…') ?></option>"<?php wp_dropdown_roles(); ?></select>
+<div class="alignleft actions">
+<select name="action">
+<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
+<label class="hidden" for="new_role"><?php _e('Change role to…') ?></label><select name="new_role" id="new_role"><option value=''><?php _e('Change role to…') ?></option><?php wp_dropdown_roles(); ?></select>
<input type="submit" value="<?php _e('Change'); ?>" name="changeit" class="button-secondary" />
<?php wp_nonce_field('bulk-users'); ?>
</div>
<br class="clear" />
</div>
-<br class="clear" />
-
<?php if ( is_wp_error( $wp_user_search->search_errors ) ) : ?>
<div class="error">
<ul>
<?php if ( $wp_user_search->get_results() ) : ?>
<?php if ( $wp_user_search->is_search() ) : ?>
- <p><a href="users.php"><?php _e('« Back to All Users'); ?></a></p>
+ <p><a href="users.php"><?php _e('← Back to All Users'); ?></a></p>
<?php endif; ?>
-<table class="widefat">
+<table class="widefat fixed" cellspacing="0">
<thead>
<tr class="thead">
- <th scope="col" class="check-column"><input type="checkbox" /></th>
- <th><?php _e('Username') ?></th>
- <th><?php _e('Name') ?></th>
- <th><?php _e('E-mail') ?></th>
- <th><?php _e('Role') ?></th>
- <th class="num"><?php _e('Posts') ?></th>
+<?php print_column_headers('users') ?>
</tr>
</thead>
+
+<tfoot>
+<tr class="thead">
+<?php print_column_headers('users', false) ?>
+</tr>
+</tfoot>
+
<tbody id="users" class="list:user user-list">
<?php
$style = '';
<div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div>
<?php endif; ?>
+<div class="alignleft actions">
+<select name="action2">
+<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<option value="delete"><?php _e('Delete'); ?></option>
+</select>
+<input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
+</div>
+
<br class="clear" />
</div>
</div>
<?php
- if ( is_wp_error($add_user_errors) ) {
- foreach ( array('user_login' => 'user_login', 'first_name' => 'user_firstname', 'last_name' => 'user_lastname', 'email' => 'user_email', 'url' => 'user_uri', 'role' => 'user_role') as $formpost => $var ) {
- $var = 'new_' . $var;
- $$var = attribute_escape(stripslashes($_REQUEST[$formpost]));
- }
- unset($name);
+ foreach ( array('user_login' => 'user_login', 'first_name' => 'user_firstname', 'last_name' => 'user_lastname', 'email' => 'user_email', 'url' => 'user_uri', 'role' => 'user_role') as $formpost => $var ) {
+ $var = 'new_' . $var;
+ $$var = isset($_REQUEST[$formpost]) ? attribute_escape(stripslashes($_REQUEST[$formpost])) : '';
}
+ unset($name);
?>
<br class="clear" />
-<?php if ( current_user_can('create_users') ) { ?>
-
-<div class="wrap">
-<h2 id="add-new-user"><?php _e('Add New User') ?></h2>
-
-<?php if ( is_wp_error( $add_user_errors ) ) : ?>
- <div class="error">
- <?php
- foreach ( $add_user_errors->get_error_messages() as $message )
- echo "<p>$message</p>";
- ?>
- </div>
-<?php endif; ?>
-<div id="ajax-response"></div>
-
<?php
- if ( get_option('users_can_register') )
- echo '<p>' . sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), site_url('wp-register.php')) . '</p>';
- else
- echo '<p>' . sprintf(__('Users cannot currently <a href="%1$s">register themselves</a>, but you can manually create users here.'), admin_url('options-general.php#users_can_register')) . '</p>';
-?>
-<form action="#add-new-user" method="post" name="adduser" id="adduser" class="add:users: validate">
-<?php wp_nonce_field('add-user') ?>
-<table class="form-table">
- <tr class="form-field form-required">
- <th scope="row"><label for="user_login"><?php _e('Username (required)') ?></label><input name="action" type="hidden" id="action" value="adduser" /></th>
- <td ><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" aria-required="true" /></td>
- </tr>
- <tr class="form-field">
- <th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th>
- <td><input name="first_name" type="text" id="first_name" value="<?php echo $new_user_firstname; ?>" /></td>
- </tr>
- <tr class="form-field">
- <th scope="row"><label for="last_name"><?php _e('Last Name') ?> </label></th>
- <td><input name="last_name" type="text" id="last_name" value="<?php echo $new_user_lastname; ?>" /></td>
- </tr>
- <tr class="form-field form-required">
- <th scope="row"><label for="email"><?php _e('E-mail (required)') ?></label></th>
- <td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td>
- </tr>
- <tr class="form-field">
- <th scope="row"><label for="url"><?php _e('Website') ?></label></th>
- <td><input name="url" type="text" id="url" value="<?php echo $new_user_uri; ?>" /></td>
- </tr>
-
-<?php if ( apply_filters('show_password_fields', true) ) : ?>
- <tr class="form-field form-required">
- <th scope="row"><label for="pass1"><?php _e('Password (twice)') ?> </label></th>
- <td><input name="pass1" type="password" id="pass1" />
- <br />
- <input name="pass2" type="password" id="pass2" /></td>
- </tr>
-<?php endif; ?>
-
- <tr class="form-field">
- <th scope="row"><label for="role"><?php _e('Role'); ?></label></th>
- <td><select name="role" id="role">
- <?php
- if ( !$new_user_role )
- $new_user_role = $current_role ? $current_role : get_option('default_role');
- wp_dropdown_roles($new_user_role);
- ?>
- </select>
- </td>
- </tr>
-</table>
-<p class="submit">
- <?php echo $referer; ?>
- <input name="adduser" type="submit" id="addusersub" value="<?php _e('Add User') ?>" />
-</p>
-</form>
-
-</div>
-
-<?php
-}
break;
-} // end of the $action switch
+} // end of the $doaction switch
include('admin-footer.php');
?>
<?php
-
+/**
+ * Widgets administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
require_once( 'admin.php' );
+
+/** WordPress Administration Widgets API */
require_once(ABSPATH . 'wp-admin/includes/widgets.php');
if ( ! current_user_can('switch_themes') )
require_once( 'admin-header.php' );
?>
- <div class="error">
- <p><?php _e( 'No Sidebars Defined' ); ?></p>
- </div>
-
<div class="wrap">
- <p><?php _e( 'You are seeing this message because the theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="http://automattic.com/code/widgets/themes/">follow these instructions</a>.' ); /* TODO: article on codex */; ?></p>
+ <?php screen_icon(); ?>
+ <h2><?php echo wp_specialchars( $title ); ?></h2>
+ <div class="error">
+ <p><?php _e( 'No Sidebars Defined' ); ?></p>
+ </div>
+ <p><?php _e( 'The theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="http://codex.wordpress.org/Widgetizing_Themes">follow these instructions</a>.' ); ?></p>
</div>
<?php
exit;
}
-
-
-
// What widget (if any) are we editing
$edit_widget = -1;
<h2><?php _e( 'Add Widget' ); ?></h2>
<br />
<form action="<?php echo clean_url( remove_query_arg( $query_args ) ); ?>" method="post">
-
+
<ul class="widget-control-list">
<li class="widget-list-control-item">
<div class="widget-top">
$show = isset($_GET['show']) && isset($show_values[$_GET['show']]) ? attribute_escape( $_GET['show'] ) : false;
-
$messages = array(
'updated' => __('Changes saved.')
);
-require_once( 'admin-header.php' );
-
-if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) : ?>
+require_once( 'admin-header.php' ); ?>
+<?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) : ?>
<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
-
<?php endif; ?>
<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo wp_specialchars( $title ); ?></h2>
<form id="widgets-filter" action="" method="get">
- <h2><?php _e( 'Widgets' ); ?></h2>
- <p id="widget-search">
- <label class="hidden" for="widget-search-input"><?php _e( 'Search Widgets' ); ?>:</label>
- <input type="text" id="widget-search-input" name="s" value="<?php echo attribute_escape( $widget_search ); ?>" />
- <input type="submit" class="button" value="<?php _e( 'Search Widgets' ); ?>" />
- </p>
-
<div class="widget-liquid-left-holder">
<div id="available-widgets-filter" class="widget-liquid-left">
<h3><label for="show"><?php _e('Available Widgets'); ?></label></h3>
<p class="submit">
<input type="hidden" id='sidebar' name='sidebar' value="<?php echo $sidebar; ?>" />
<input type="hidden" id="generated-time" name="generated-time" value="<?php echo time() - 1199145600; // Jan 1, 2008 ?>" />
- <input type="submit" name="save-widgets" value="<?php _e( 'Save Changes' ); ?>" />
+ <input type="submit" name="save-widgets" class="button-primary" value="<?php _e( 'Save Changes' ); ?>" />
<?php
wp_nonce_field( 'edit-sidebar_' . $sidebar );
?>
</div>
</form>
+ <br class="clear" />
</div>
<?php do_action( 'sidebar_admin_page' ); ?>
-<br class="clear" />
-
<?php require_once( 'admin-footer.php' ); ?>
+
-.plugins .name {
+
+p, ul, ol, blockquote { font-size: 12px; }
+
+.plugins .name,
+#pass-strength-result.strong,
+#pass-strength-result.short,
+.button-highlighted,
+#quicktags #ed_strong,
+#ed_reply_toolbar #ed_reply_strong {
font-weight: bold;
}
padding: 0;
}
-.plugins .togl {
- width: 150px;
- border-right-width: 1px;
- border-right-style: solid;
+.plugins .action-links {
+ white-space: nowrap;
}
.import-system {
font-size: 16px;
}
-#uploading {
- border-style: none;
- padding: 0;
- margin-bottom: 16px;
- height: 18em;
- width: 100%;
-}
-
-form#upload th {
- text-align: right;
-}
-
-form#upload #post_content, form#upload #post_title {
- width: 250px;
-}
-
-.form-invalid input {
- border-width: 1px !important;
- border-style: solid !important;
-}
-
-
-form#upload #post_content {
- height: 50px;
-}
-
-.attpreview {
- width: 1px; /* hug */
- text-align: center;
-}
-
.anchors {
margin: 10px 20px 10px 20px;
}
table#availablethemes {
- border-spacing: 0px;
- border: none;
- border-top: 1px solid #ccc;
- border-bottom: 1px solid #ccc;
+ border-spacing: 0;
+ border-width: 1px 0;
+ border-style: solid none;
margin: 10px auto;
+ width: 100%;
}
+
td.available-theme {
vertical-align: top;
width: 240px;
padding: 20px;
text-align: left;
}
+
table#availablethemes td {
- border: 1px solid #eee;
- border-top: none;
-}
-table#availablethemes td.top {
- border-top: none;
+ border-width: 0 1px 1px;
+ border-style: none solid solid;
}
-table#availablethemes td.right {
- border-right: none;
- border-left: none;
+
+table#availablethemes td.right,
+table#availablethemes td.left {
+ border-right: 0 none;
+ border-left: 0 none;
}
+
table#availablethemes td.bottom {
- border-bottom: none;
-}
-table#availablethemes td.left {
- border-right: none;
- border-left: none;
+ border-bottom: 0 none;
}
.available-theme a.screenshot {
width: 240px;
height: 180px;
display: block;
- border: 1px solid #efefef;
+ border-width: 1px;
+ border-style: solid;
margin-bottom: 10px;
overflow: hidden;
}
+
.available-theme img {
width: 240px;
}
+
.available-theme h3 {
margin: 15px 0 5px;
}
#current-theme {
- margin-top: 1em;
+ margin: 1em 0 1.5em;
}
#current-theme a {
#current-theme img {
float: left;
- border: 1px solid #666;
+ border-width: 1px;
+ border-style: solid;
margin-right: 1em;
margin-bottom: 1.5em;
width: 150px;
#TB_window #TB_title a.tb-theme-preview-link,
#TB_window #TB_title a.tb-theme-preview-link:visited {
font-weight: bold;
- color: #999;
text-decoration: none;
}
-#TB_window #TB_title a.tb-theme-preview-link:hover,
-#TB_window #TB_title a.tb-theme-preview-link:focus {
- color: #ccc;
-}
-
.checkbox {
border: none;
margin: 0;
padding: 0;
}
-.code {
- font-family: "Courier New", Courier, monospace;
+.code, code {
+ font-family: Consolas, Monaco, Courier, monospace;
+}
+
+kbd, code {
+ padding: 1px 3px;
+ margin: 0 1px;
+ font-size: 11px;
}
.commentlist li {
}
.commentlist li li {
- border-bottom: 0px;
+ border-bottom: 0;
padding: 0;
}
}
.quicktags, .search {
- font: 12px Georgia, "Times New Roman", Times, serif;
+ font: 12px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
}
.submit {
- border-top: 1px solid #ccc;
- padding: 1.5em 0 0 0;
- margin: 10px 0 0 0;
- -moz-border-radius-bottomleft: 3px;
- -khtml-border-bottom-left-radius: 3px;
+ padding: 1.5em 0;
+ margin: 5px 0;
+ -moz-border-radius: 0 0 3px 3px;
-webkit-border-bottom-left-radius: 3px;
- border-bottom-left-radius: 3px;
- -moz-border-radius-bottomright: 3px;
- -khtml-border-bottom-right-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
+ -khtml-border-bottom-left-radius: 3px;
+ -khtml-border-bottom-right-radius: 3px;
+ border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}
+form p.submit a.cancel:hover {
+ text-decoration: none;
+}
+
+#submitdiv h3,
+#pagesubmitdiv h3 {
+ margin-bottom: 0 !important;
+}
+
+#misc-publishing-actions {
+ padding: 6px 0 16px 0;
+}
+
+.misc-pub-section {
+ padding: 6px;
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
+}
+
+.misc-pub-section-last {
+ border-bottom: 0 none;
+}
+
+#minor-publishing-actions {
+ padding: 6px;
+ text-align: right;
+}
+
+#minor-publishing {
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
+}
+
+#save-post {
+ float: left;
+}
+
+.preview {
+ float: right;
+}
+
+#major-publishing-actions {
+ padding: 6px;
+ clear: both;
+ border-top: none;
+}
+
+#minor-publishing-actions input,
+#major-publishing-actions input,
+#minor-publishing-actions .preview {
+ min-width: 80px;
+ text-align: center;
+}
+
+#delete-action {
+ line-height: 25px;
+ vertical-align: middle;
+ text-align: left;
+ float: left;
+}
+
+#publishing-action {
+ text-align: right;
+ float: right;
+}
+
+#post-body #minor-publishing {
+ padding-bottom: 10px;
+}
+
+#post-body #misc-publishing-actions {
+ padding: 0;
+}
+
+#post-body .misc-pub-section {
+ border-right-width: 1px;
+ border-right-style: solid;
+ border-bottom: 0 none;
+ min-height: 30px;
+ float: left;
+ max-width: 32%;
+}
+
+#post-body .misc-pub-section-last {
+ border-right: 0;
+}
+
+#sticky-span {
+ margin-left: 18px;
+}
+
.side-info {
margin: 0;
padding: 4px;
list-style: square;
}
-.submit input, .button, .button-secondary, .button-highlighted {
- font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
- padding: 3px 5px;
- font-size: 12px;
- line-height: 1.5em;
+.submit input,
+.button,
+.button-primary,
+.button-secondary,
+.button-highlighted,
+#postcustomstuff .submit input {
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+ text-decoration: none;
+ font-size: 11px !important;
+ line-height: 16px;
+ padding: 2px 8px;
+ cursor: pointer;
border-width: 1px;
border-style: solid;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
- cursor: pointer;
- text-decoration: none;
+ -moz-border-radius: 11px;
+ -khtml-border-radius: 11px;
+ -webkit-border-radius: 11px;
+ border-radius: 11px;
+ -moz-box-sizing: content-box;
+ -webkit-box-sizing: content-box;
+ -khtml-box-sizing: content-box;
+ box-sizing: content-box;
+}
+
+a.button,
+a.button-primary,
+a.button-secondary {
+ line-height: 1.2em;
+ -webkit-border-radius: 10px;
+ padding: 4px 10px;
}
-.button-highlighted {
- font-weight: bold;
+#doaction,
+#doaction2 {
+ margin-right: 8px;
+}
+
+.tablenav select[name="action"],
+.tablenav select[name="action2"] {
+ width: 120px;
+}
+
+.tablenav select[name="m"] {
+ width: 120px;
+}
+
+.tablenav select#cat {
+ width: 150px;
}
#wpcontent select {
- font: 12px/20px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
+ font: 11px/20px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
padding: 2px;
-
border-width: 1px;
border-style: solid;
height: 2em;
- vertical-align:top;
+ vertical-align: top;
+}
+
+#wpcontent option {
+ padding: 2px;
}
.approve {
display: none;
}
-.unapproved .approve {
+.unapproved .approve, .spam .approve {
display: inline;
}
-.updated a {
- border-bottom-width: 1px;
- border-bottom-style: solid;
-}
-
-
.unapproved .unapprove {
display: none;
}
line-height: 150%;
}
-
table .vers {
text-align: center;
}
width: 250px;
}
-#postdiv, #titlediv, #guiddiv, #poststuff .stuffbox {
- margin: 0 8px 0 0;
- padding: 0;
+#namediv table {
+ width: 100%;
}
-#titlediv, #namediv, #poststuff #namediv {
- margin-top: 10px;
+#namediv td.first {
+ width: 10px;
+ white-space: nowrap;
}
-#postdivrich {
- margin: 0;
- padding: 0;
+#namediv input {
+ width: 98%;
+}
+
+#namediv p {
+ margin: 10px 0;
+}
+
+#wpbody-content .metabox-holder {
+ padding-top: 10px;
}
#content {
}
#editorcontainer #content {
- padding: 0;
+ padding: 6px;
line-height: 150%;
border: 0 none;
outline: none;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ -khtml-box-sizing: border-box;
+ box-sizing: border-box;
}
-#editorcontainer {
- padding: 6px;
- border-style: none solid solid;
+#editorcontainer,
+#quicktags {
+ border-style: solid;
border-width: 1px;
border-collapse: separate;
+ -moz-border-radius: 6px 6px 0 0;
+ -webkit-border-top-right-radius: 6px;
+ -webkit-border-top-left-radius: 6px;
+ -khtml-border-top-right-radius: 6px;
+ -khtml-border-top-left-radius: 6px;
+ border-top-right-radius: 6px;
+ border-top-left-radius: 6px;
}
#quicktags {
padding: 0;
- border: 0 none;
+ margin-bottom: -3px;
+ border-bottom-width: 3px;
+ background-image: url("images/ed-bg.gif");
+ background-position: left top;
+ background-repeat: repeat-x;
}
#quicktags #ed_toolbar {
- padding: 2px 4px;
+ padding: 2px 4px 0;
}
-#ed_toolbar input {
- margin: 3px 2px 2px;
- padding: 2px 4px;
+#ed_toolbar input,
+#ed_reply_toolbar input {
+ margin: 3px 1px 4px;
line-height: 18px;
display: inline-block;
+ border-width: 1px;
+ border-style: solid;
+ min-width: 26px;
+ padding: 2px 4px;
+ font-size: 12px;
+ -moz-border-radius: 3px;
+ -khtml-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
}
-#quicktags #ed_strong {
- font-weight: bold;
+#ed_reply_toolbar input {
+ margin: 1px 2px 1px 1px;
}
-#quicktags #ed_link {
+#quicktags #ed_link,
+#ed_reply_toolbar #ed_reply_link {
text-decoration: underline;
}
-#quicktags #ed_del {
+#quicktags #ed_del,
+#ed_reply_toolbar #ed_reply_del {
text-decoration: line-through;
}
-#quicktags #ed_em {
+#quicktags #ed_em,
+#ed_reply_toolbar #ed_reply_em {
font-style: italic;
}
-#quicktags #ed_code {
- font-family: "Courier New", Courier, mono;
- font-size: 1.1em;
- vertical-align: top;
-}
-
-
-#attachmentlinks textarea {
- width: 100%;
- height: 2.5em;
- margin-bottom: 6px;
-}
-
#excerpt, .attachmentlinks {
margin: 0;
height: 4em;
width: 98%;
}
-.plugins p {
+/* post meta postbox */
+#postcustomstuff table,
+#postcustomstuff input,
+#postcustomstuff textarea {
+ border-width: 1px;
+ border-style: solid;
+ -moz-border-radius: 3px;
+ -khtml-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
}
-#login .fullwidth {
- width: 320px;
+#postcustomstuff .updatemeta,
+#postcustomstuff .deletemeta {
+ margin: auto;
}
-#searchform fieldset {
- float: left;
- margin: 0 1.5ex 1em 0;
- padding: 0;
+#postcustomstuff thead th {
+ padding: 5px 8px 8px;
}
-#searchform fieldset legend {
- padding: 0 0 .2em 1px;
+#postcustom #postcustomstuff .submit,
+#pagecustomdiv #postcustomstuff .submit {
+ border: 0 none;
+ float: none;
+ padding: 5px 8px;
}
-#searchform #s {
- padding: 4px 3px;
+#side-sortables #postcustom #postcustomstuff .submit,
+#side-sortables #pagecustomdiv #postcustomstuff .submit {
+ padding: 0 5px;
}
-#searchform #post-query-submit {
- float: left;
- margin: 14px 0 1em;
- position: relative;
- top: .35em;
+#side-sortables #postcustom #postcustomstuff td.left input,
+#side-sortables #pagecustomdiv #postcustomstuff td.left input {
+ margin: 3px 3px 0;
}
-#postcustomstuff .updatemeta, #postcustomstuff .deletemeta {
- margin: auto;
+#side-sortables #postcustom #postcustomstuff #the-list textarea,
+#side-sortables #pagecustomdiv #postcustomstuff #the-list textarea {
+ height: 85px;
+ margin: 3px;
}
#postcustomstuff table {
width: 100%;
border-width: 1px;
border-style: solid;
+ border-spacing: 0;
}
-#postcustomstuff table input, #postcustomstuff table textarea {
+#postcustomstuff table input,
+#postcustomstuff table select,
+#postcustomstuff table textarea {
width: 95%;
+ margin: 8px 0 8px 8px;
+}
+
+#postcustomstuff th.left,
+#postcustomstuff td.left {
+ width: 38%;
+}
+
+#postcustomstuff .submit input {
+ width: auto;
+}
+
+#postcustomstuff #newmeta .submit {
+ padding: 0 8px;
}
#postcustomstuff table #addmetasub {
width: auto;
}
-#poststuff #post-body {
- margin-right: 230px;
+#postcustomstuff #newmetaleft {
+ vertical-align: top;
+}
+
+#postcustomstuff #newmetaleft a {
+ padding: 0 10px;
+ text-decoration: none;
}
#save {
margin-right: 0;
}
-#template, #template div, #editcat, #addcat {
- zoom: 1;
-}
-
/* A handy div class for hiding controls.
Some browsers will disable them when you
-set display:none; */
+set display: none; */
.zerosize {
height: 0;
width: 0;
}
#your-profile legend {
- font-family: Georgia, "Times New Roman", Times, serif;
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
font-size: 22px;
}
margin-left: 2em;
}
-
div.nav {
height: 2em;
padding: 7px 10px;
padding: 2px 4px;
}
-.page-numbers {
- padding: 2px 4px;
- margin-right: 3px;
- border-width: 1px;
- border-style: solid;
-}
-
-.page-numbers.current {
+a.page-numbers {
+ border-bottom-style: solid;
+ border-bottom-width: 2px;
font-weight: bold;
- border-width: 1px;
- border-style: solid;
+ margin-right: 1px;
+ padding: 0 2px;
}
p.pagenav {
font-weight: bold;
}
-.comment-column {
- margin-left: 5px;
+.column-comment p {
+ margin: 0.6em 0;
}
-.tablenav a.button-secondary {
- display: block;
- margin: 1px 8px 0 0;
-}
-
-.tablenav .button-secondary {
- padding: 2px 4px;
- vertical-align: top;
+.column-author img, .column-username img {
+ float: left;
+ margin-right: 10px;
+ margin-top: 3px;
}
-.tablenav .tablenav-pages a.next, .tablenav .tablenav-pages a.prev {
- text-decoration: underline;
+.tablenav a.button-secondary {
+ display: block;
+ margin: 3px 8px 0 0;
}
.tablenav {
- height: 2em;
- padding: 7px 10px;
clear: both;
- margin-bottom: -10px;
- margin-top: 8px;
- vertical-align: text-top;
+ height: 30px;
+ margin: 6px 0 4px;
+ vertical-align: middle;
}
.tablenav .tablenav-pages {
float: right;
- height: 18px;
- padding-top: 6px;
+ display: block;
+ cursor: default;
+ height: 30px;
+ line-height: 30px;
font-size: 11px;
}
-.tablenav .tablenav-pages a {
+.tablenav .tablenav-pages a, .tablenav-pages span.current {
text-decoration: none;
+ border: none;
+ padding: 3px 6px;
+ border-width: 1px;
+ border-style: solid;
+ -moz-border-radius: 5px;
+ -khtml-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+}
+
+.tablenav .displaying-num {
+ margin-right: 10px;
+ font-size: 12px;
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+ font-style: italic;
+}
+
+.tablenav .actions {
+ padding: 2px 8px 0 0;
}
td.media-icon {
vertical-align: middle;
text-align: center;
+ width: 80px;
}
td.media-icon img {
}
#pass-strength-result {
- padding: 3px 5px 3px 5px;
- margin-top: 3px;
- text-align: center;
- border-width: 1px;
border-style: solid;
+ border-width: 1px;
+ float: left;
+ margin: 12px 5px 5px 1px;
+ padding: 3px 5px;
+ text-align: center;
+ width: 200px;
}
-a.view-comment-post-link {
- position: absolute;
- text-decoration:underline;
+.row-actions {
+ visibility: hidden;
+ padding: 2px 0 0;
+}
+
+tr:hover .row-actions,
+div.comment-item:hover .row-actions {
+ visibility: visible;
}
/* Admin Header */
+#wphead-info {
+ margin: 0 0 0 15px;
+ padding-right: 15px;
+}
#user_info {
- position: absolute;
- right: 15px;
- top: 11px;
- font-size: 11px;
+ float: right;
+ font-size: 12px;
+ line-height: 46px;
+ height: 46px;
}
#user_info p {
margin: 0;
padding: 0;
+ line-height: 46px;
}
#wphead {
- border-top-width: 30px;
- border-top-style: solid;
+ height: 46px;
}
-#wphead a, #dashmenu a, #adminmenu a, #submenu a, #sidemenu a, #taglist a, #catlist a {
+#wphead a,
+#adminmenu a,
+#sidemenu a,
+#taglist a,
+#catlist a,
+#show-settings a {
text-decoration: none;
}
-#wphead #viewsite {
- position: absolute;
- margin-top: 12px;
- margin-left: 10px;
-}
-#wphead #viewsite a {
- font: 12px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
- padding: 3px 4px;
- display: block;
- letter-spacing: normal;
- border-width: 1px;
- border-style: solid;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
+#header-logo {
+ float: left;
+ margin: 7px 0 0 15px;
}
#wphead h1 {
- font: normal 36px Georgia, "Times New Roman", Times, serif;
- padding: 11px 170px 16px 12px;
+ font: normal 22px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+ padding: 10px 8px 5px;
margin: 0;
- margin-right: 15%;
+ float: left;
}
-/* menu stuff */
+#wphead h1.long-title {
+ font: normal 18px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+ padding: 12px 10px 5px;
+}
-#dashmenu {
- margin: 0;
+#wphead h1 span {
+ font-size: 50%;
+}
+
+/* side admin menu */
+#adminmenu * {
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -khtml-user-select: none;
+ user-select: none;
+}
+
+#adminmenu .wp-submenu {
+ display: none;
list-style: none;
- position: absolute;
- top: 7px;
- left: 0;
- font-size: 11px;
- padding-left: 9px;
+ padding: 0;
+ margin: 0;
+ position: relative;
+ z-index: 2;
+ border-width: 1px 0 0;
+ border-style: solid none none;
}
-#dashmenu a {
- padding: 5px 6px;
- line-height: 220%;
- margin-right: 8px;
+#adminmenu .wp-submenu a {
+ font: normal 11px/18px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
}
-#dashmenu a.current {
- border: none;
- -moz-border-radius-topleft: 3px;
- -khtml-border-top-left-radius: 3px;
- -webkit-border-top-left-radius: 3px;
- border-top-left-radius: 3px;
- -moz-border-radius-topright: 3px;
- -khtml-border-top-right-radius: 3px;
- -webkit-border-top-right-radius: 3px;
- border-top-right-radius: 3px;
+#adminmenu .wp-submenu li.current,
+#adminmenu .wp-submenu li.current a,
+#adminmenu .wp-submenu li.current a:hover {
+ font-weight: bold;
+}
+
+#adminmenu a.menu-top,
+#adminmenu .wp-submenu-head {
+ font: normal 13px/18px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+}
+
+#adminmenu div.wp-submenu-head {
+ display: none;
+}
+
+.folded #adminmenu div.wp-submenu-head,
+.folded #adminmenu li.wp-has-submenu div.sub-open {
+ display: block;
+}
+
+.folded #adminmenu a.menu-top,
+.folded #adminmenu .wp-submenu,
+.folded #adminmenu li.wp-menu-open .wp-submenu,
+.folded #adminmenu div.wp-menu-toggle {
+ display: none;
+}
+
+#adminmenu li.wp-menu-open .wp-submenu {
+ display: block;
}
-#adminmenu {
+#adminmenu div.wp-menu-image {
+ float: left;
+ width: 28px;
+ height: 28px;
+}
+
+#adminmenu li {
margin: 0;
- list-style: none;
- padding-left: 11px;
- border-bottom-width: 1px;
- border-bottom-style: solid;
+ padding: 0;
+ cursor: pointer;
}
#adminmenu a {
- font-size: 16px;
- padding: 5px 7px;
- line-height: 30px;
+ display: block;
+ line-height: 18px;
+ padding: 1px 5px 3px;
}
-#adminmenu a.current, #sidemenu a.current {
- font-weight: normal;
- padding-left: 6px;
- padding-right: 6px;
- -moz-border-radius-topleft: 4px;
- -khtml-border-top-left-radius: 4px;
- -webkit-border-top-left-radius: 4px;
- border-top-left-radius: 4px;
- -moz-border-radius-topright: 4px;
- -khtml-border-top-right-radius: 4px;
- -webkit-border-top-right-radius: 4px;
- border-top-right-radius: 4px;
+#adminmenu li.menu-top {
+ min-height: 26px;
+}
+
+#adminmenu a.menu-top {
+ line-height: 18px;
+ min-width: 10em;
+ padding: 5px 5px;
+ border-width: 1px 1px 0;
+ border-style: solid solid none;
+}
+
+#adminmenu .wp-submenu a {
+ margin: 0;
+ padding-left: 12px;
+ border-width: 0 1px 0 0;
+ border-style: none solid none none;
+}
+
+#adminmenu .menu-top-last ul.wp-submenu {
+ border-width: 0 0 1px;
+ border-style: none none solid;
+}
+
+#adminmenu .wp-submenu li {
+ padding: 0;
+ margin: 0;
+}
+
+.folded #adminmenu li.menu-top {
+ width: 28px;
+ height: 30px;
+ overflow: hidden;
+ border-width: 1px 1px 0;
+ border-style: solid solid none;
+}
+
+#adminmenu .menu-top-first a.menu-top,
+.folded #adminmenu li.menu-top-first,
+#adminmenu .wp-submenu .wp-submenu-head {
+ border-width: 1px 1px 0;
+ border-style: solid solid none;
+ -moz-border-radius-topleft :6px;
+ -moz-border-radius-topright: 6px;
+ -webkit-border-top-right-radius: 6px;
+ -webkit-border-top-left-radius: 6px;
+ -khtml-border-top-right-radius: 6px;
+ -khtml-border-top-left-radius: 6px;
+ border-top-right-radius: 6px;
+ border-top-left-radius: 6px;
+}
+
+#adminmenu .menu-top-last a.menu-top,
+.folded #adminmenu li.menu-top-last {
border-width: 1px;
border-style: solid;
+ -moz-border-radius-bottomleft: 6px;
+ -moz-border-radius-bottomright: 6px;
+ -webkit-border-bottom-right-radius: 6px;
+ -webkit-border-bottom-left-radius: 6px;
+ -khtml-border-bottom-right-radius: 6px;
+ -khtml-border-bottom-left-radius: 6px;
+ border-bottom-right-radius: 6px;
+ border-bottom-left-radius: 6px;
+}
+
+#adminmenu li.wp-menu-open a.menu-top-last {
+ border-bottom: 0 none;
+ -moz-border-radius-bottomright: 0;
+ -moz-border-radius-bottomleft: 0;
+ -webkit-border-bottom-right-radius: 0;
+ -webkit-border-bottom-left-radius: 0;
+ -khtml-border-bottom-right-radius: 0;
+ -khtml-border-bottom-left-radius: 0;
+ border-bottom-right-radius: 0;
+ border-bottom-left-radius: 0;
+}
+
+#adminmenu img.wp-menu-image {
+ float: left;
+ padding: 8px 6px 0;
+ opacity: 0.6;
+ filter: alpha(opacity=60);
}
-#adminmenu a.current {
- border-bottom-width: 2px;
+#adminmenu li.menu-top:hover img.wp-menu-image,
+#adminmenu li.wp-has-current-submenu img.wp-menu-image {
+ opacity: 1;
+ filter: alpha(opacity=100);
}
-#sidemenu {
- margin: -30px 15px 0 315px;
- list-style: none;
- position: relative;
- float: right;
+.folded #adminmenu img.wp-menu-image {
+ padding: 7px 0 0 6px;
+}
+
+#adminmenu li.wp-menu-separator {
+ height: 21px;
+ padding: 0;
+ margin: 0;
+ cursor: w-resize;
+}
+
+.folded #adminmenu li.wp-menu-separator {
+ cursor: e-resize;
+}
+
+#adminmenu .wp-menu-separator-last {
+ height: 10px;
+ width: 1px;
+}
+
+#adminmenu .wp-submenu .wp-submenu-head {
+ border-width: 1px;
+ border-style: solid;
+ padding: 6px 4px 6px 10px;
+ cursor: default;
+}
+
+.folded #adminmenu .wp-submenu {
+ position: absolute;
+ margin: -1px 0 0 28px;
+ padding: 0 8px 8px;
+ z-index: 999;
+ border: 0 none;
+}
+
+.folded #adminmenu .wp-submenu ul {
+ width: 140px;
+ border-width: 0 0 1px;
+ border-style: none none solid;
+}
+
+.folded #adminmenu .wp-submenu li.wp-first-item {
+ border-top: 0 none;
+}
+
+.folded #adminmenu .wp-submenu a {
padding-left: 10px;
- font-size:12px;
}
-#sidemenu a {
- padding: 0 7px;
- display: block;
- float: left;
- line-height: 28px;
- border-top-width: 1px;
- border-top-style: solid;
- border-bottom-width: 1px;
- border-bottom-style: solid;
+.folded #adminmenu a.wp-has-submenu {
+ margin-left: 40px;
}
-#dashmenu li, #adminmenu li, #submenu li, #sidemenu li {
- display: inline;
- line-height: 200%;
- list-style: none;
- text-align: center;
- white-space: nowrap;
- margin: 0;
- padding: 0;
+#adminmenu li.menu-top-last .wp-submenu ul {
+ border-width: 0 0 1px;
+ border-style: none none solid;
+}
+
+#adminmenu .wp-menu-toggle {
+ width: 22px;
+ clear: right;
+ float: right;
+ margin: 1px 0 0;
+ height: 27px;
+ padding: 1px 2px 0 0;
+ cursor: default;
}
-#submenu li {
- padding: 0 0 8px 17px;
+#adminmenu li.wp-has-current-submenu ul {
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
}
+/* end side admin menu */
-#adminmenu li a #awaiting-mod, #sidemenu li a #update-plugins {
+/* comments/plugins bubble in menu */
+#adminmenu #awaiting-mod,
+#adminmenu span.update-plugins,
+#sidemenu li a span.update-plugins {
position: absolute;
- margin-left: -0.4em;
- margin-top: 0.2em;
- font-size: 0.7em;
- background-repeat: no-repeat;
- background-position: 0 bottom;
- height: 0.9em;
- width: 1em;
+ font-family: Helvetica, Arial, sans-serif;
+ font-size: 7pt;
+ font-weight: bold;
+ margin-top: 2px;
+ margin-left: 2px;
+ -moz-border-radius: 7px;
+ -khtml-border-radius: 7px;
+ -webkit-border-radius: 7px;
+ border-radius: 7px;
+}
+
+#adminmenu li #awaiting-mod span,
+#adminmenu li span.update-plugins span,
+#sidemenu li a span.update-plugins span {
+ float: left;
+ display: block;
+ height: 1.6em;
+ line-height: 1.6em;
+ padding: 0 6px;
}
-#adminmenu li a .count-0, #sidemenu li a .count-0 {
+#adminmenu li span.count-0,
+#sidemenu li a .count-0 {
display: none;
}
+/* end menu stuff */
+/* comments bubble */
.post-com-count-wrapper {
min-width: 22px;
+ font-family: Helvetica, Arial, sans-serif;
}
.post-com-count {
}
.post-com-count span {
- height: 1.3em;
- line-height: 1.2em;
- padding: 0 0.5em;
- background-color: #bbb;
+ font-size: 9px;
+ font-weight: bild;
+ height: 1.7em;
+ line-height: 1.70em;
+ min-width: 0.7em;
+ padding: 0 6px;
display: inline-block;
cursor: pointer;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
+ -moz-border-radius: 5px;
+ -khtml-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
}
strong .post-com-count {
background-position: center -3px;
}
-#adminmenu li a:hover #awaiting-mod, #sidemenu li a:hover #update-plugins {
- background-position: -80px bottom;
-}
-
-#adminmenu li a #awaiting-mod span, #sidemenu li a #update-plugins span {
- top: -0.8em;
- right: 0;
- position: absolute;
- display: block;
- height: 1.3em;
- line-height: 1.3em;
- padding: 0 0.6em;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
-}
-
-#submenu {
- margin: 0;
- list-style: none;
- padding: 6px 0 3px 0;
-}
-
-#submenu li {
- font-size: 14px;
+.column-response .post-com-count {
+ float: left;
+ margin-right: 5px;
+ text-align: center;
}
-#minisub { /* for empty submenus */
- height: 15px;
+.response-links {
+ margin: 4px 0;
}
-/* end menu stuff */
-
/* Admin Footer */
-
-html, body {
- height:100%;
-}
-#wpwrap {
- position: relative;
- min-height: 100%;
-}
-#wpcontent{
- padding-bottom: 95px;
-}
#footer {
- clear: both;
- height: 65px;
- padding: 10px 0 0 60px;
- margin: 0;
- position: relative;
- margin-top: -75px;
+ margin-top: -45px;
+}
+
+#footer,
+#footer a {
font-size: 12px;
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+ font-style: italic;
}
#footer p {
margin: 0;
- padding: 7px 0;
+ padding: 15px;
+ line-height: 15px;
}
-#footer p a {
+#footer a {
text-decoration: none;
}
-#footer p a:hover {
+#footer a:hover {
text-decoration: underline;
}
.form-table {
border-collapse: collapse;
- margin-top: 1em;
+ margin-top: 0.5em;
width: 100%;
margin-bottom: -8px;
+ clear: both;
}
-.form-table td {
+.form-table td,
+#wpbody-content .describe td {
margin-bottom: 9px;
- padding: 10px;
+ padding: 4px 10px 12px;
line-height: 20px;
- border-bottom-width: 8px;
- border-bottom-style: solid;
font-size: 11px;
}
-.form-table th {
+.form-table th,
+.form-wrap label {
+ font-weight: normal;
+ text-shadow: rgba(255,255,255,1) 0 1px 0;
+}
+
+.form-table th,
+#wpbody-content .describe th {
vertical-align: top;
text-align: left;
padding: 10px;
- width: 150px;
- border-bottom-width: 8px;
- border-bottom-style: solid;
+ width: 200px;
}
.form-table th.th-full {
width: auto;
}
-.form-table input, .form-table textarea {
+.form-table input,
+.form-table textarea,
+#wpbody-content .describe input,
+#wpbody-content .describe textarea {
border-width: 1px;
border-style: solid;
}
.form-table div.color-option {
display: block;
clear: both;
+ margin-top: 12px;
}
.form-table input.tog {
.form-table table.color-palette {
vertical-align: bottom;
float: left;
- margin: -3px 3px 8px;
+ margin: -8px 3px 8px;
}
.form-table .color-palette td {
- border-bottom: none;
- border: 1px solid #fff;
- font-size: 1px;
- line-height: 1px;
+ border-width: 1px 1px 0;
+ border-stile: solid solid none;
+ height: 10px;
+ line-height: 20px;
+ width: 10px;
+}
+
+textarea.large-text {
+ width: 99%;
+}
+
+.form-table input.regular-text {
+ width: 325px;
+}
+
+.form-table input.small-text {
+ width: 50px;
}
#profile-page .form-table textarea {
margin-bottom: 6px;
}
-#profile-page .form-table input[type=text] {
+#profile-page .form-table input[type=text] {
width: 300px;
}
-#pass-strength-result {
- width: 197px;
- float: left;
- margin-right: 5px;
- border: 1px solid #ccc !important;
-}
-
#profile-page .form-table #rich_editing {
margin-right: 5px
}
font-size: 13px;
}
-/* Post Screen */
+/* divs for cats and tags pages */
-#tagsdiv #newtag {
- margin-right: 5px;
- width: 16em;
+.form-wrap {
+ margin: 10px 0;
+ width: 97%;
}
-#tagchecklist {
- margin-left: 10px;
+.form-wrap p,
+.form-wrap label {
+ font-size: 11px;
+}
+.form-wrap label {
+ display: block;
+ padding: 2px;
font-size: 12px;
- overflow: auto;
}
-#tagchecklist strong {
- margin-left: -8px;
- position: absolute;
+.form-field input,
+.form-field textarea {
+ border-style: solid;
+ border-width: 1px;
+ width: 95%;
}
-#tagchecklist span {
- margin-right: 25px;
- display: block;
- float: left;
- font-size: 11px;
- line-height: 1.8em;
- white-space: nowrap;
- cursor: default;
+.form-wrap p {
+ margin: 2px 0 5px;
}
-#tagchecklist span a {
- margin: 6px 0pt 0pt -9px;
- cursor: pointer;
- width: 10px;
- height: 10px;
- display: block;
+.setting-description, .form-wrap p {
+ font-style: italic;
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+}
+
+.form-wrap .form-field {
+ margin: 0 0 10px;
+ padding: 8px;
+}
+
+.col-wrap h3 {
+ margin: 12px 0;
+ font-size: 1.1em;
+}
+
+.col-wrap p.submit {
+ margin-top: -10px;
+}
+
+.tagcloud {
+ width: 97%;
+ margin: 0 0 40px;
+}
+
+.tagcloud h3 {
+ margin: 2px 0 12px;
+}
+
+/* Post Screen */
+#normal-sortables {
+ min-height: 50px;
+}
+
+.postbox {
+ position: relative;
+ min-width: 255px;
+ width: 99.5%;
+}
+
+#trackback_url {
+ width: 99%;
+}
+
+#normal-sortables .postbox .submit {
+ background: transparent none;
+ border: 0 none;
+ float: right;
+ padding: 0 12px;
+ margin: 0;
+}
+
+#normal-sortables .postbox #replyrow .submit {
+ float: none;
+ margin: 0;
+ padding: 3px 7px;
+}
+
+#side-sortables {
+ min-height: 300px;
+}
+
+#side-sortables .submitbox .submit input,
+#side-sortables .submitbox .submit .preview,
+#side-sortables .submitbox .submit a.preview:hover {
+ border: 0 none;
+}
+
+#side-sortables .inside-submitbox .insidebox,
+.stuffbox .insidebox {
+ margin: 11px 0;
+}
+
+#side-sortables .comments-box,
+#side-sortables #show-comments {
+ display: none;
+}
+
+#post-body #tagsdiv #newtag {
+ margin-right: 5px;
+ width: 16em;
+}
+
+#side-info-column input#post_password {
+ width: 94%
+}
+
+#side-info-column #tagsdiv #newtag {
+ width: 68%;
+}
+
+#post-status-info {
+ font-size: 12px;
+ line-height: 2;
+ padding: 0 15px 0 7px;
+ border-width: 0 1px 1px;
+ border-style: none solid solid;
+ -moz-border-radius: 0 0 6px 6px;
+ -webkit-border-bottom-left-radius: 6px;
+ -webkit-border-bottom-right-radius: 6px;
+ -khtml-border-bottom-left-radius: 6px;
+ -khtml-border-bottom-right-radius: 6px;
+ border-bottom-left-radius: 6px;
+ border-bottom-right-radius: 6px;
+}
+
+#editorcontent #post-status-info {
+ border: none;
+}
+
+#post-body-content .wp_themeSkin .mceStatusbar a.mceResize {
+ display: block;
+ float: right;
+ background: transparent url(images/resize.gif) no-repeat scroll right bottom;
+ width: 12px;
+ height: 12px;
+ cursor: se-resize;
+ margin: 0 2px;
+ position: relative;
+ right: 0;
+ top: 31px;
+}
+
+
+#pagesubmitdiv div.inside,
+#linksubmitdiv div.inside,
+ div.inside {
+ padding: 0;
+ margin: 0;
+}
+
+#comment-status-radio p {
+ margin: 3px 0 5px;
+}
+
+#comment-status-radio input {
+ margin: 2px 3px 5px 0;
+ vertical-align: middle;
+}
+
+#comment-status-radio label {
+ padding: 5px 0;
+}
+
+#tagchecklist {
+ margin-left: 10px;
+ font-size: 12px;
+ overflow: auto;
+}
+
+#tagchecklist strong {
+ margin-left: -8px;
+ position: absolute;
+}
+
+#tagchecklist span {
+ margin-right: 25px;
+ display: block;
+ float: left;
+ font-size: 11px;
+ line-height: 1.8em;
+ white-space: nowrap;
+ cursor: default;
+}
+
+#tagchecklist span a {
+ margin: 6px 0pt 0pt -9px;
+ cursor: pointer;
+ width: 10px;
+ height: 10px;
+ display: block;
float: left;
text-indent: -9999px;
overflow: hidden;
.howto {
font-style: italic;
display: block;
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
}
.ac_results {
clear: left;
}
-#poststuff h3 {
- font-size: 14px;
+.ui-sortable .postbox h3 {
+ cursor: pointer;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -khtml-user-select: none;
+ user-select: none;
+}
+
+.ui-sortable .postbox .hndle span {
+ padding: 6px 0;
+}
+
+.ui-sortable .postbox .hndle {
+ cursor: move;
+}
+
+.hndle a {
+ font-size: 11px;
+ font-weight: normal;
+}
+
+.meta-box-sortables .postbox .handlediv {
+ float: right;
+ width: 23px;
+ height: 26px;
+}
+
+.sortable-placeholder {
+ border-width: 1px;
+ border-style: dashed;
+ z-index: -1;
+}
+
+#poststuff h3,
+.metabox-holder h3 {
+ font-size: 12px;
font-weight: bold;
- padding: 7px;
- margin: 0 0 10px;
+ padding: 7px 9px;
+ margin: 0;
+ line-height: 1;
}
-#poststuff .postbox, #poststuff .stuffbox {
- margin-left: 20px;
- padding: 2px;
+.metabox-holder .postbox,
+#poststuff .postbox,
+#poststuff .stuffbox {
margin-bottom: 20px;
- margin-right: 8px;
border-width: 1px;
border-style: solid;
+ line-height: 1;
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+}
+
+.metabox-holder .postbox h3,
+#poststuff .postbox h3,
+#poststuff .stuffbox h3 {
+ -moz-border-radius: 6px 6px 0 0;
+ -webkit-border-top-right-radius: 6px;
+ -webkit-border-top-left-radius: 6px;
+ -khtml-border-top-right-radius: 6px;
+ -khtml-border-top-left-radius: 6px;
+ border-top-right-radius: 6px;
+ border-top-left-radius: 6px;
+}
+
+.postbox table.form-table {
+ margin-bottom: 0;
+}
+
+.postbox input[type="text"],
+.postbox textarea,
+.stuffbox input[type="text"],
+.stuffbox textarea {
+ border-width: 1px;
+ border-style: solid;
+}
+
+#poststuff .inside,
+#poststuff .inside p {
+ font-size: 11px;
+ margin: 6px;
+}
+
+#poststuff .inside .submitbox p {
+ margin: 1em 0;
+}
+
+#post-visibility-select {
+ line-height: 1.5em;
+ margin-top: 3px;
+}
+
+#poststuff #submitdiv .inside {
+ margin: 0;
}
#titlediv, #poststuff .postarea {
- margin-left: 20px;
margin-bottom: 20px;
- margin-right: 8px;
}
#titlediv {
margin-bottom: 20px;
}
+#titlediv label { cursor: text; }
#titlediv div.inside {
margin: 0;
}
-#titlediv #title {
+#poststuff #titlewrap {
border: 0;
padding: 0;
- font-size: 1.7em;
- width: 100%;
- outline: none;
+
}
-#poststuff #titlewrap {
- padding: 2px 3px;
+#titlediv #title {
+ padding: 3px 4px;
border-width: 1px;
border-style: solid;
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+ font-size: 1.7em;
+ width: 100%;
+ outline: none;
}
-#poststuff .inside {
- margin: 0 12px 12px;
+#poststuff .inside-submitbox,
+#side-info-column .inside-submitbox {
+ margin: 0 3px;
font-size: 11px;
}
-#link_name, #link_url, #link_description {
- font-size: 1.7em;
- padding: 4px 3px;
+input#link_description,
+input#link_url {
width: 98%;
}
+#pending {
+ background: 0 none;
+ border: 0 none;
+ padding: 0;
+ font-size: 11px;
+ margin-top: -1px;
+}
+
#edit-slug-box {
+ height: 1em;
margin-top: 8px;
+ padding: 0 7px;
}
-#editable-post-name-full {display: none;}
+#editable-post-name-full {
+ display: none;
+}
-#editable-post-name input {width: 16em;}
+#editable-post-name input {
+ width: 16em;
+}
-#edit-slug-buttons a.save {
- padding: 6px 4px;
- margin-right: 4px;
- text-decoration: none;
- border-width: 1px;
- border-style: solid;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
- font-weight: bold;
+.postarea h3 label {
+ float: left;
}
-#poststuff #editor-toolbar {
+.postarea #add-media-button {
+ float: right;
+ margin: 7px 0pt 0pt;
position: relative;
+ right: 10px;
+}
+
+#poststuff #editor-toolbar {
height: 30px;
- margin-top: -41px;
}
-#poststuff #edButtonPreview, #poststuff #edButtonHTML {
+.wp_themeSkin tr.mceFirst td.mceToolbar {
+ background-image: url("images/ed-bg.gif");
+ background-position: left top;
+ background-repeat: repeat-x;
+ border-width: 0 0 1px;
+ border-style: none none solid;
+}
+
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML {
display: block;
- height: 20px;
- padding: 5px 5px 1px;
- margin: 5px 8px 0 0;
+ height: 18px;
+ margin: 5px 5px 0 0;
+ padding: 4px 5px 2px;
float: right;
cursor: pointer;
-}
-
-#poststuff #editor-toolbar .active {
- font-weight: bold;
- -moz-border-radius-topright: 3px;
- -khtml-border-top-right-radius: 3px;
+ border-width: 1px;
+ border-style: solid;
+ -moz-border-radius: 3px 3px 0 0;
-webkit-border-top-right-radius: 3px;
- border-top-right-radius: 3px;
- -moz-border-radius-topleft: 3px;
- -khtml-border-top-left-radius: 3px;
-webkit-border-top-left-radius: 3px;
+ -khtml-border-top-right-radius: 3px;
+ -khtml-border-top-left-radius: 3px;
+ border-top-right-radius: 3px;
border-top-left-radius: 3px;
}
-#poststuff #media-buttons {
- float: right;
- margin-right: 20px;
- margin-top: 8px;
+#poststuff #edButtonHTML {
+ margin-right: 15px;
+}
+
+#media-buttons {
cursor: default;
- line-height: 1;
- height: 1.1em;
+ padding: 8px 8px 0;
}
-#poststuff #media-buttons a {
+#media-buttons a {
cursor: pointer;
- padding: 0 5px 2px 2px;
+ padding: 0 0 5px 10px;
}
-#poststuff #media-buttons img {
+#media-buttons img {
vertical-align: middle;
}
-#poststuff .togbox {
- background-position: -10px 16px;
- background-repeat: no-repeat;
- display: block;
- height: 37px;
- margin-left: -21px;
- margin-top: -10px;
- overflow: hidden;
- position: absolute;
- text-indent: -9999px;
- width: 12px;
- -moz-border-radius-topleft: 3px;
- -khtml-border-top-left-radius: 3px;
- -webkit-border-top-left-radius: 3px;
- border-top-left-radius: 3px;
- -moz-border-radius-bottomleft: 3px;
- -khtml-border-bottom-left-radius: 3px;
- -webkit-border-bottom-left-radius: 3px;
- border-bottom-left-radius: 3px;
+.submitbox .submit {
+ text-align: left;
+ padding: 12px 10px 10px;
+ font-size: 11px;
}
-#poststuff .closed .inside {
- display: none;
+.submitbox .submitdelete {
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
+ text-decoration: none;
+ padding: 1px 2px;
}
-#poststuff .closed h3 {
- margin: 0;
+.inside-submitbox #post_status {
+ margin: 2px 0 2px -2px;
}
-#poststuff .closed .togbox {
- background-position: 4px 15px;
+.submitbox .submit a:hover {
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
}
-.submitbox {
- width: 220px;
- float: right;
+.submitbox .submit input {
+ margin-bottom: 8px;
+ margin-right: 4px;
+ padding: 6px;
}
-.submitbox .inside strong {
- font-size: 14px;
+#post-status-select {
+ line-height: 2.5em;
+ margin-top: 3px;
}
-.submitbox .submitdelete {
- border-bottom-width: 1px;
- border-bottom-style: solid;
- text-decoration: none;
- margin-left: 8px;
- padding-bottom: 1px;
+/* Categories */
+
+#category-adder {
+ margin-left: 120px;
+ padding: 4px 0;
}
+#category-adder h4 {
+ margin: 0 0 8px;
+}
-.submitbox #previewview {
- padding: 15px 10px;
- -moz-border-radius-topleft: 3px;
- -khtml-border-top-left-radius: 3px;
- -webkit-border-top-left-radius: 3px;
- border-top-left-radius: 3px;
- -moz-border-radius-topright: 3px;
- -khtml-border-top-right-radius: 3px;
+#side-info-column #category-adder {
+ margin: 0;
+}
+
+#post-body #category-add input, #category-add select {
+ width: 30%;
+}
+
+#side-info-column #category-add input {
+ width: 94%;
+}
+
+#side-info-column #category-add select {
+ width: 100%;
+}
+
+#category-add input#category-add-sumbit {
+ width: auto;
+}
+
+#post-body ul#category-tabs {
+ float: left;
+ width: 120px;
+ text-align: right;
+ /* Negative margin for the sake of those without JS: all tabs display */
+ margin: 0 -120px 0 0;
+ padding: 0;
+}
+
+#post-body ul#category-tabs li {
+ padding: 8px;
+}
+
+#post-body ul#category-tabs li.ui-tabs-selected {
+ -moz-border-radius: 3px 0 0 3px;
+ -webkit-border-top-left-radius: 3px;
+ -webkit-border-bottom-left-radius: 3px;
+ -khtml-border-top-left-radius: 3px;
+ -khtml-border-bottom-left-radius: 3px;
+ border-top-left-radius: 3px;
+ border-bottom-left-radius: 3px;
+}
+
+#post-body ul#category-tabs li.ui-tabs-selected a {
+ font-weight: bold;
+ text-decoration: none;
+}
+
+#categorydiv div.ui-tabs-panel,
+#linkcategorydiv div.ui-tabs-panel {
+ height: 150px;
+ overflow: auto;
+ padding: 0.5em 0.9em;
+}
+
+#post-body #categorydiv div.ui-tabs-panel,
+#post-body #linkcategorydiv div.ui-tabs-panel {
+ margin: 0 5px 0 120px;
+ height: 10em;
+ overflow: auto;
+ border-width: 4px;
+ border-style: solid;
+}
+
+#side-info-column #category-tabs li {
+ display: inline;
+ padding-right: 8px;
+}
+
+#side-info-column #category-tabs a {
+ text-decoration: none;
+}
+
+#side-info-column #category-tabs {
+ margin-bottom: 3px;
+}
+
+#categorydiv ul,
+#linkcategorydiv ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+}
+
+#categorydiv ul.categorychecklist ul,
+#linkcategorydiv ul.categorychecklist ul {
+ margin-left: 18px;
+}
+
+ul.categorychecklist li {
+ margin: 0;
+ padding: 0;
+ line-height: 19px;
+}
+
+#category-adder h4 {
+ margin-top: 4px;
+ margin-bottom: 0px;
+}
+
+#categorydiv .ui-tabs-panel {
+ border-width: 3px;
+ border-style: solid;
+}
+
+ul#category-tabs {
+ margin-top: 12px;
+}
+
+ul#category-tabs li {
+ padding: 5px 8px;
+ -moz-border-radius: 3px 3px 0 0;
+ -webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
+ -khtml-border-top-left-radius: 3px;
+ -khtml-border-top-right-radius: 3px;
+ border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
-.submitbox #previewview a {
- padding: 6px;
+/* positioning etc. */
+
+form#tags-filter {
+ position: relative;
+}
+
+p.search-box {
+ float: right;
+ margin: -5px 0 0;
+}
+
+.search-input {
+ border-width: 1px;
+ border-style: solid;
+ padding: 2px;
+}
+
+#posts-filter fieldset {
+ float: left;
+ margin: 0 1.5ex 1em 0;
+ padding: 0;
+}
+
+#posts-filter fieldset legend {
+ padding: 0 0 .2em 1px;
+}
+
+.bordertitle {
+ padding-bottom: 5px;
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
+}
+
+/* Edit posts */
+
+td.post-title strong {
+ display: block;
+ margin-bottom: .2em;
+}
+
+td.post-title p {
+ margin: 6px 0;
+}
+
+/* Global classes */
+
+.wp-hidden-children .wp-hidden-child,
+.ui-tabs-hide {
+ display: none;
+}
+
+.commentlist .avatar {
+ vertical-align: text-top;
+}
+
+.defaultavatarpicker .avatar {
+ margin: 2px 0;
+ vertical-align: middle;
+}
+
+body.wp-admin {
+ min-width: 785px;
+}
+
+.view-switch {
+ float: right;
+ margin: 6px 8px 0;
+}
+
+.view-switch a {
text-decoration: none;
- font-weight: normal;
- border-bottom: none;
- font-size: 14px;
+}
+
+.filter {
+ float: left;
+ margin: -5px 0 0 10px;
+}
+
+.filter .subsubsub {
+ margin-left: -10px;
+ margin-top: 13px;
+}
+
+#the-comment-list td.comment p.comment-author {
+ margin-top: 0;
+ margin-left: 0;
+}
+
+#the-comment-list p.comment-author img {
+ float: left;
+ margin-right: 8px;
+}
+
+#the-comment-list p.comment-author strong a {
+ border: none;
+}
+
+#the-comment-list td {
+ vertical-align: top;
+}
+
+#the-comment-list td.comment {
+ word-wrap: break-word;
+}
+
+#the-comment-list .check-column {
+ padding-top: 8px;
+}
+
+#templateside ul li a {
+ text-decoration: none;
+}
+
+.tablenav .delete {
+ margin-right: 20px;
+}
+
+td.action-links, th.action-links {
+ text-align: right;
+}
+
+/* Diff */
+
+table.diff {
+ width: 100%;
+}
+
+table.diff col.content {
+ width: 50%;
+}
+
+table.diff tr {
+ background-color: transparent;
+}
+
+table.diff td, table.diff th {
+ padding: .5em;
+ font-family: Consolas, Monaco, Courier, monospace;
+ border: none;
+}
+
+table.diff .diff-deletedline del, table.diff .diff-addedline ins {
+ text-decoration: none;
+}
+
+#wp-word-count {
+ display: block;
+}
+
+fieldset {
+ border: 0;
+ padding: 0;
+ margin: 0;
+}
+
+.tool-box {
+ margin: 15px 0 35px;
+}
+
+.tool-box .buttons {
+ margin: 15px 0;
+}
+
+.tool-box .title {
+ margin: 8px 0;
+ font: 18px/24px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+}
+
+.pressthis a {
+ font-size: 1.2em;
+}
+
+#wp_editbtns,
+#wp_gallerybtns {
+ padding: 2px;
+ position: absolute;
+ display: none;
+ z-index: 999998;
+}
+
+#wp_editimgbtn,
+#wp_delimgbtn,
+#wp_editgallery,
+#wp_delgallery {
+ margin: 2px;
+ padding: 2px;
+ border-width: 1px;
+ border-style: solid;
-moz-border-radius: 3px;
-khtml-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
-.submitbox .submit {
- text-align: left;
- padding: 12px 10px 10px 10px;
- font-size: 11px;
+.settings-toggle {
+ text-align: right;
+ margin: 5px 7px 15px 0;
+ font-size: 12px;
+}
+
+.settings-toggle h3 {
+ margin: 0;
+}
+
+#timestampdiv select {
+ height: 20px;
+ line-height: 20px;
+ padding: 0;
+}
+
+#jj, #hh, #mn {
+ width: 2em;
+ padding: 1px;
+ font-size: 12px;
+}
+
+#aa {
+ width: 3.4em;
+ padding: 1px;
+ font-size: 12px;
+}
+
+.curtime #timestamp {
+ background-repeat: no-repeat;
+ background-position: left top;
+ padding-left: 18px;
+}
+
+#timestampdiv {
+ padding-top: 5px;
+ line-height: 23px;
+}
+
+#timestampdiv p {
+ margin: 8px 0 6px;
+}
+
+#timestampdiv input {
+ border-width: 1px;
+ border-style: solid;
+}
+
+/* media popup 0819 */
+#sidemenu {
+ margin: -30px 15px 0 315px;
+ list-style: none;
+ position: relative;
+ float: right;
+ padding-left: 10px;
+ font-size: 12px;
+}
+
+#sidemenu a {
+ padding: 0 7px;
+ display: block;
+ float: left;
+ line-height: 28px;
+ border-top-width: 1px;
+ border-top-style: solid;
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
+}
+
+#sidemenu li {
+ display: inline;
+ line-height: 200%;
+ list-style: none;
+ text-align: center;
+ white-space: nowrap;
+ margin: 0;
+ padding: 0;
+}
+
+#sidemenu a.current {
+ font-weight: normal;
+ padding-left: 6px;
+ padding-right: 6px;
+ -moz-border-radius: 4px 4px 0 0;
+ -webkit-border-top-left-radius: 4px;
+ -webkit-border-top-right-radius: 4px;
+ -khtml-border-top-left-radius: 4px;
+ -khtml-border-top-right-radius: 4px;
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
+ border-width: 1px;
+ border-style: solid;
+}
+
+#sidemenu {
+ margin: -30px 15px 0 315px;
+ list-style: none;
+ position: relative;
+ float: right;
+ padding-left: 10px;
+ font-size: 12px;
+}
+
+#sidemenu a {
+ padding: 0 7px;
+ display: block;
+ float: left;
+ line-height: 28px;
+ border-top-width: 1px;
+ border-top-style: solid;
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
+}
+
+#sidemenu li a .count-0 {
+ display: none;
+}
+
+/* reply to comments */
+#replyrow {
+ font-size: 11px;
+}
+
+#replyrow input {
+ border-width: 1px;
+ border-style: solid;
+}
+
+#replyrow td {
+ padding: 2px;
+}
+
+#replyrow #editorcontainer {
+ border: 0 none;
+}
+
+#replysubmit {
+ margin: 0;
+ padding: 3px 7px;
+}
+
+#replysubmit img.waiting,
+.inline-edit-save img.waiting,
+#commentstatusdiv img.waiting {
+ padding: 0 10px;
+ vertical-align: top;
+}
+
+#replysubmit .button {
+ margin-right: 5px;
+}
+
+#replyrow #editor-toolbar {
+ display: none;
+}
+
+#replyhead {
+ font-size: 12px;
+ font-weight: bold;
+ padding: 2px 10px 4px;
+}
+
+#edithead .inside {
+ float: left;
+ padding: 3px 0 2px 5px;
+ margin: 0;
+ text-align: center;
+ font-size: 11px;
+}
+
+#edithead .inside input {
+ width: 180px;
+ font-size: 11px;
+}
+
+#edithead label {
+ padding: 2px 0;
+}
+
+#replycontainer {
+ padding: 5px;
+ border: 0 none;
+ height: 120px;
+ overflow: hidden;
+ position: relative;
+}
+
+#replycontent {
+ resize: none;
+ margin: 0;
+ width: 100%;
+ height: 100%;
+ padding: 0;
+ line-height: 150%;
+ border: 0 none;
+ outline: none;
+ font-size: 12px;
+}
+
+#replyrow #ed_reply_toolbar {
+ margin: 0;
+ padding: 2px 3px;
+}
+
+/* show/hide settings */
+#screen-meta {
+ position: relative;
+ clear: both;
+}
+
+#screen-meta-links {
+ margin: 0 9px 0 0;
+}
+
+#screen-meta .invisible {
+ visibility: hidden;
+}
+
+#screen-options-link-wrap,
+#contextual-help-link-wrap {
+ float: right;
+ background: transparent url( images/screen-options-left.gif ) no-repeat 0 0;
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+ height: 22px;
+ padding: 0;
+ margin: 0 6px 0 0;
+}
+
+#screen-meta a.show-settings {
+ text-decoration: none;
+ z-index: 1;
+ padding: 0 16px 0 6px;
+ height: 22px;
+ line-height: 22px;
+ font-size: 10px;
+ display: block;
+ background-repeat: no-repeat;
+ background-position: right bottom;
+}
+
+#screen-meta a.show-settings {
+ background-image: url( images/screen-options-right.gif );
+}
+
+#screen-meta a.show-settings:hover {
+ text-decoration: none;
+}
+
+#screen-options-wrap h5,
+#contextual-help-wrap h5 {
+ margin: 8px 0;
+ font-size: 13px;
+}
+
+#screen-options-wrap,
+#contextual-help-wrap {
+ border-style: none solid solid;
+ border-top: 0 none;
+ border-width: 0 1px 1px;
+ margin: 0 15px;
+ padding: 8px 12px 12px;
+ -moz-border-radius: 0 0 0 4px;
+ -webkit-border-bottom-left-radius: 4px;
+ -khtml-border-bottom-left-radius: 4px;
+ border-bottom-left-radius: 4px;
+}
+
+.metabox-prefs label {
+ padding-right: 15px;
+ white-space: nowrap;
+ line-height: 30px;
+}
+
+.metabox-prefs label input {
+ margin: 0 5px 0 2px;
+}
+
+.metabox-prefs label a {
+ display: none;
+}
+
+/* Inline Editor
+ .quick-edit* is for Quick Edit
+ .bulk-edit* is for Bulk Edit
+ .inline-edit* is for everything
+*/
+/* Layout */
+tr.inline-edit-row td {
+ padding: 0 0.5em;
+}
+
+#wpbody-content .inline-edit-row fieldset {
+ font-size: 12px;
+ float: left;
+ margin: 0;
+ padding: 0;
+ width: 100%;
+}
+
+#wpbody-content .inline-edit-row fieldset .inline-edit-col {
+ padding: 0 0.5em;
+}
+
+#wpbody-content .quick-edit-row-page fieldset.inline-edit-col-right .inline-edit-col {
+ border-width: 0 0 0 1px;
+ border-style: none none none solid;
+}
+
+#wpbody-content .quick-edit-row-post .inline-edit-col-left {
+ width: 40%;
+}
+
+#wpbody-content .quick-edit-row-post .inline-edit-col-right {
+ width: 39%;
+}
+
+#wpbody-content .inline-edit-row-post .inline-edit-col-center {
+ width: 20%;
+}
+
+#wpbody-content .quick-edit-row-page .inline-edit-col-left {
+ width: 50%;
+}
+
+#wpbody-content .quick-edit-row-page .inline-edit-col-right,
+#wpbody-content .bulk-edit-row-post .inline-edit-col-right {
+ width: 49%;
+}
+
+#wpbody-content .bulk-edit-row .inline-edit-col-left {
+ width: 30%;
+}
+
+#wpbody-content .bulk-edit-row-page .inline-edit-col-right {
+ width: 69%;
+}
+
+#wpbody-content .bulk-edit-row .inline-edit-col-bottom {
+ float: right;
+ width: 69%;
+}
+
+#wpbody-content .inline-edit-row-page .inline-edit-col-right,
+#owpbody-content .bulk-edit-row-post .inline-edit-col-right {
+ margin-top: 27px;
+}
+
+.inline-edit-row fieldset .inline-edit-group {
+ clear: both;
+}
+
+.inline-edit-row fieldset .inline-edit-group:after {
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+}
+
+.inline-edit-row p.submit {
+ clear: both;
+ padding: 0.5em;
+ margin: 0.5em 0 0;
+}
+
+/* Positioning */
+.inline-edit-row h4 {
+ margin: .2em 0;
+ padding: 0;
+ line-height: 23px;
+}
+.inline-edit-row fieldset span.title,
+.inline-edit-row fieldset span.checkbox-title {
+ margin: 0;
+ padding: 0;
+ line-height: 27px;
+}
+
+.inline-edit-row fieldset label,
+.inline-edit-row fieldset span.inline-edit-categories-label {
+ display: block;
+ margin: .2em 0;
+}
+
+.inline-edit-row fieldset label.inline-edit-tags {
+ margin-top: 0;
+}
+
+.inline-edit-row fieldset label.inline-edit-tags span.title {
+ margin: .2em 0;
+}
+
+.inline-edit-row fieldset label span.title {
+ display: block;
+ float: left;
+ width: 5em;
+}
+
+.inline-edit-row fieldset label span.input-text-wrap {
+ display: block;
+ margin-left: 5em;
+}
+
+.quick-edit-row-post fieldset.inline-edit-col-right label span.title {
+ width: auto;
+ padding-right: 0.5em;
}
-.submitbox .submit a:hover {
- border-bottom-width: 1px;
- border-bottom-style: solid;
+.inline-edit-row .input-text-wrap input[type=text] {
+ width: 100%;
}
-.submitbox .submit input {
- margin-bottom: 8px;
- margin-right: 3px;
- padding: 6px 4px;
- border: none;
+.inline-edit-row fieldset label input[type=checkbox] {
+ vertical-align: text-bottom;
}
-.submitbox #autosave .error {
- margin-top: 10px;
+.inline-edit-row fieldset label textarea {
+ width: 100%;
+ height: 4em;
}
-/* Categories */
+#wpbody-content .bulk-edit-row fieldset .inline-edit-group label {
+ max-width: 50%;
+}
-#categorydiv #category-adder {
- margin-left: 120px;
- padding: 4px 0;
+#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child {
+ margin-right: 0.5em
}
-#category-add input, #category-add select {
- width: 30%;
+/* Styling */
+.inline-edit-row h4 {
+ text-transform: uppercase;
}
-#category-add input#category-add-sumbit {
- width: auto;
+.inline-edit-row fieldset span.title,
+.inline-edit-row fieldset span.checkbox-title {
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+ font-style: italic;
+ line-height: 1.8em;
+}
+
+/* Specific Elements */
+.inline-edit-row fieldset input[type="text"],
+.inline-edit-row fieldset textarea {
+ border-style: solid;
+ border-width: 1px;
}
-#categorydiv ul#category-tabs {
+.inline-edit-row fieldset .inline-edit-date {
float: left;
- width: 120px;
- text-align: right;
- /* Negative margin for the sake of those without JS: all tabs display */
- margin: 0 -120px 0 0;
- padding: 0;
}
-ul#category-tabs li {
- padding: 8px;
+.inline-edit-row fieldset input[name=jj],
+.inline-edit-row fieldset input[name=hh],
+.inline-edit-row fieldset input[name=mn] {
+ font-size: 12px;
+ width: 2.1em;
}
-ul#category-tabs li.ui-tabs-selected {
- -moz-border-radius-topleft: 3px;
- -khtml-border-top-left-radius: 3px;
- -webkit-border-top-left-radius: 3px;
- border-top-left-radius: 3px;
- -moz-border-radius-bottomleft: 3px;
- -khtml-border-bottom-left-radius: 3px;
- -webkit-border-bottom-left-radius: 3px;
- border-bottom-left-radius: 3px;
+.inline-edit-row fieldset input[name=aa] {
+ font-size: 12px;
+ width: 3.5em;
}
-ul#category-tabs li.ui-tabs-selected a {
- color: #333;
- font-weight: bold;
- text-decoration: none;
+.inline-edit-row fieldset label input.inline-edit-password-input {
+ width: 8em;
}
-div.ui-tabs-panel {
- margin: 0 5px 0 120px;
- padding: .5em .9em;
- height: 10em;
- overflow: auto;
- border-width: 4px;
+ul.cat-checklist {
+ height: 12em;
+ border-style: solid;
+ border-width: 1px;
+ overflow-y: scroll;
+ padding: 0 5px;
+ margin: 0 0 5px;
+}
+
+#bulk-titles {
+ display: block;
+ height: 12em;
border-style: solid;
+ border-width: 1px;
+ overflow-y: scroll;
+ padding: 0 5px;
+ margin: 0 0 5px;
}
-#categorydiv ul {
- list-style: none;
- padding: 0;
+.inline-edit-row fieldset ul.cat-checklist li,
+.inline-edit-row fieldset ul.cat-checklist input {
margin: 0;
}
-#categorydiv ul.categorychecklist ul {
- margin-left: 18px;
+.inline-edit-row fieldset ul.cat-checklist label,
+.inline-edit-row .catshow,
+.inline-edit-row .cathide,
+.inline-edit-row #bulk-titles div {
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+ font-style: normal;
+ font-size: 11px;
}
-ul.categorychecklist li {
- margin: 0;
- padding: 0;
- line-height: 19px;
+table .inline-edit-row fieldset ul.cat-hover {
+ height: auto;
+ max-height: 30em;
+ overflow-y: auto;
+ position: absolute;
}
-#linkcategorydiv #category-adder {
- margin-left: 120px;
- padding: 4px 0;
+.inline-edit-row fieldset label input.inline-edit-menu-order-input {
+ width: 3em;
}
-#category-adder h4 {
- margin: 0;
+.inline-edit-row fieldset label input.inline-edit-slug-input {
+ width: 75%;
}
-#linkcategorydiv ul#category-tabs {
+.quick-edit-row-post fieldset label.inline-edit-status {
float: left;
- width: 120px;
- text-align: right;
- /* Negative margin for the sake of those without JS: all tabs display */
- margin: 0 -120px 0 0;
- padding: 0;
}
-#linkcategorydiv ul {
- list-style: none;
- padding: 0;
- margin: 0;
+#bulk-titles {
+ line-height: 140%;
+}
+#bulk-titles div {
+ margin: 0.2em 0.3em;
}
-#linkcategorydiv ul.categorychecklist ul {
- margin-left: 18px;
+#bulk-titles div a {
+ cursor: pointer;
+ display: block;
+ float: left;
+ height: 10px;
+ margin: 3px 3px 0 -2px;
+ overflow: hidden;
+ position: relative;
+ text-indent: -9999px;
+ width: 10px;
}
-/* pasitioning etc. */
-form#tags-filter {
- position: relative;
+/* Media library */
+#wpbody-content #media-items .describe {
+ border-collapse: collapse;
+ width: 100%;
+ border-top-style: solid;
+ border-top-width: 1px;
+ clear: both;
+ cursor: default;
+ padding: 5px;
+ width: 100%;
}
-p#tag-search {
- position: absolute;
- right: 0;
- top: 0;
- margin: 0;
+#wpbody-content .describe .media-item-info tr {
+ background-color: transparent;
}
-form#posts-filter {
- position: relative;
+#wpbody-content .filename {
+ margin-left: 10px;
}
-p#post-search {
- position: absolute;
- right: 0;
- top: 0;
- margin: 0;
+#wpbody-content .media-item .thumbnail {
+ max-height: 128px;
+ max-width: 128px;
}
-#post-search .button, #widget-search .button {
- padding: 3px;
+#wpbody-content .media-upload-form label {
+ display: block;
font-size: 13px;
+ margin: 0.5em;
}
-#posts-filter fieldset {
- float: left;
- margin: 0 1.5ex 1em 0;
- padding: 0;
+abbr.required {
+ border: medium none;
+ text-decoration: none;
}
-#posts-filter fieldset legend {
- padding: 0 0 .2em 1px;
+#wpbody-content .describe input[type="text"],
+#wpbody-content .describe textarea {
+ width: 460px;
}
-.bordertitle {
- padding-bottom: 5px;
- border-bottom-width: 1px;
- border-bottom-style: solid;
+#wpbody-content .describe p.help {
+ margin: 0;
+ padding: 0;
}
-/* Global classes */
-.wp-hidden-children .wp-hidden-child { display: none; }
-.wp-no-js-hidden { display: none; }
-.ui-tabs-hide { display: none; }
+.describe-toggle-on, .describe-toggle-off {
+ display: block;
+ line-height: 36px;
+ float: right;
+ margin-right: 20px;
+}
-.commentlist .avatar {
- vertical-align:text-top;
+.describe-toggle-off {
+ display: none;
}
-.defaultavatarpicker .avatar {
- margin: 2px 0;
- vertical-align: middle;
+#wpbody-content .media-item {
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ min-height: 36px;
+ position: relative;
+ width: 100%;
}
-body.minwidth {
- min-width: 808px;
+#wpbody-content #media-items {
+ border-style: solid solid none;
+ border-width: 1px;
+ width: 670px;
}
-ul.view-switch {
- float: right;
- list-style: none;
- margin: -23px 5px -2px 0;
- position: relative;
+#wpbody-content #media-items .filename {
+ float: left;
+ line-height: 36px;
+ margin-left: 10px;
+ max-width: 430px;
+ overflow: hidden;
}
-ul.view-switch li {
+.media-item .pinkynail {
float: left;
- margin: 0;
- font-size: 11px;
- padding: 4px 6px;
- font-weight: bold;
+ height: 32px;
+ margin: 2px;
+ max-width: 40px;
+ max-height: 40px;
}
-ul.view-switch a {
- text-decoration: none;
+.media-item .startopen,
+.media-item .startclosed {
+ display: none;
}
-ul.view-switch li.current {
- border: none;
- -moz-border-radius-topleft: 3px;
- -khtml-border-top-left-radius: 3px;
- -webkit-border-top-left-radius: 3px;
- border-top-left-radius: 3px;
- -moz-border-radius-topright: 3px;
- -khtml-border-top-right-radius: 3px;
- -webkit-border-top-right-radius: 3px;
- border-top-right-radius: 3px;
+/* find posts */
+.find-box {
+ width: 400px;
+ height: 250px;
+ overflow: hidden;
+ padding: 33px 5px 50px;
+ position: absolute;
+ z-index: 1000;
}
+.find-box-head {
+ cursor: move;
+ font-weight: bold;
+ height: 2em;
+ line-height: 2em;
+ padding: 1px 12px;
+ position: absolute;
+ top: 5px;
+ width: 100%;
+}
-#the-comment-list .comment a {
- padding-bottom: 1px;
- text-decoration: none;
- border-bottom-width: 1px;
- border-bottom-style: solid;
+.find-box-inside {
+ overflow: auto;
+ width: 100%;
+ height: 100%;
}
+.find-box-search {
+ padding: 12px;
+ border-width: 1px;
+ border-style: none none solid;
+}
-#the-comment-list td.comment p.comment-author {
- margin-top: 0;
- margin-left: 0 ;
+#find-posts-response {
+ margin: 8px 0;
+ padding: 0 1px;
}
-#the-comment-list p.comment-author img {
- float: left;
- margin-right: 8px;
+#find-posts-response table {
+ width: 100%;
}
-#the-comment-list p.comment-author strong a {
- border: none;
+#find-posts-response .found-radio {
+ padding: 8px 0 0 8px;
+ width: 15px;
}
-#the-comment-list td {
- vertical-align: top;
+.find-box-buttons {
+ bottom: 12px;
+ left: 12px;
+ position: absolute;
}
-#the-comment-list td.comment {
- width: 65%;
- max-width: 460px;
- word-wrap: break-word;
+.find-box-search label {
+ padding-right: 6px;
}
-#the-comment-list td.comment p {
- margin-left: 8px;
+/* favorite-actions */
+#favorite-actions {
+ float: right;
+ margin: 11px 12px 0;
+ min-width: 130px;
+ position: relative;
}
-#the-comment-list .check-column {
- padding-top: 8px;
+#favorite-first {
+ -moz-border-radius: 12px;
+ -khtml-border-radius: 12px;
+ -webkit-border-radius: 12px;
+ border-radius: 12px;
+ line-height: 15px;
+ padding: 3px 30px 4px 12px;
+ border-width: 1px;
+ border-style: solid;
}
-#templateside ul li a {
- text-decoration: none;
+#favorite-inside {
+ margin: 0 0 0 0px;
+ padding: 0 1px 6px 1px;
+ border-width: 1px;
+ border-style: solid;
+ position: absolute;
+ z-index: 11;
+ display: none;
+ -moz-border-radius: 0 0 12px 12px;
+ -webkit-border-bottom-right-radius: 12px;
+ -webkit-border-bottom-left-radius: 12px;
+ -khtml-border-bottom-right-radius: 12px;
+ -khtml-border-bottom-left-radius: 12px;
+ border-bottom-right-radius: 12px;
+ border-bottom-left-radius: 12px;
}
-.curtime {
- background-image: url(images/date-button.gif);
- background-repeat: no-repeat;
- background-position: left 2px;
- padding-left: 18px;
+#favorite-actions a {
+ display: block;
+ text-decoration: none;
+ font-size: 11px;
}
-.tablenav .delete {
- margin-right: 20px;
+#favorite-inside a {
+ padding: 3px 5px 3px 10px;
}
-#tTips {
- display: none;
+#favorite-toggle {
+ height: 22px;
position: absolute;
- margin: 0;
- padding: 0 0 8px 0;
- background-image: url(images/tail.gif);
- background-repeat: no-repeat;
- background-position: 15px bottom;
- background-color: transparent;
+ right: 0;
+ top: 1px;
+ width: 28px;
+}
+
+#favorite-actions .slide-down {
+ background-image: url(images/fav-top.png);
+ background-repeat: repeat-x;
+ background-position: 0 top;
+ -moz-border-radius: 12px 12px 0 0;
+ -webkit-border-bottom-right-radius: 0;
+ -webkit-border-bottom-left-radius: 0;
+ -khtml-border-bottom-right-radius: 0;
+ -khtml-border-bottom-left-radius: 0;
+ border-bottom-right-radius: 0;
+ border-bottom-left-radius: 0;
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
}
-#tTips p#tTips_inside {
- margin: 0;
- padding: 8px 12px;
- text-align: center;
- -moz-border-radius: 8px;
- -khtml-border-radius: 8px;
- -webkit-border-radius: 8px;
- border-radius: 8px;
+#utc-time, #local-time {
+ padding-left: 25px;
+ font-style: italic;
+ font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
}
-td.action-links, th.action-links {
- text-align: right;
+ul#dismissed-updates {
+ display: none;
+}
+form.upgrade {
+ margin-top: 8px;
}
-#poststuff h3, #poststuff .closed h3 {
- cursor: pointer;
-}
-
-.hide-if-no-js {
- display: none;
+#tagsdiv #the-tagcloud {
+ margin: 5px 5px 10px;
+ padding: 8px;
+ border-width: 1px;
+ border-style: solid;
+ line-height: 1.8em;
+ word-spacing: 3px;
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
}
-/* Diff */
+br.clear {
+ height: 2px;
+ line-height: 2px;
+}
-table.diff {
- width: 100%;
+.swfupload {
+ margin: 5px 10px;
+ vertical-align: middle;
}
-table.diff col.content {
- width: 50%;
+/* table.fixed column width */
+table.fixed {
+ table-layout: fixed;
}
-table.diff tr {
- background-color: transparent;
+.fixed .column-date,
+.fixed .column-parent,
+.fixed .column-visible,
+.fixed .column-links {
+ width: 10%;
}
-table.diff td, table.diff th {
- padding: .5em;
- font-family: monospace;
- border: none;
+.fixed .column-response,
+.fixed .column-author,
+.fixed .column-categories,
+.fixed .column-tags,
+.fixed .column-rel,
+.fixed .column-role {
+ width: 15%;
}
-table.diff .diff-deletedline del, table.diff .diff-addedline ins {
- text-decoration: none;
+.fixed .column-comments {
+ width: 4em;
}
-#wp-word-count {
- display: block;
+.fixed .column-slug {
+ width: 25%;
}
-fieldset {
- border: 0;
- padding: 0;
- margin: 0;
+.fixed .column-posts {
+ width: 10%;
}
-.info-box {
- top: 100px;
- left: 50%;
- margin-left: -225px;
- height: 300px;
- width: 450px;
- border: 5px solid #ddd;
- background: #f8f8f8;
- position: absolute;
- padding: 15px 15px 10px;
- z-index: 1000;
- display: none;
+.fixed .column-icon {
+ width: 80px;
}
-.info-box .submit {
- position: absolute;
- bottom: 15px;
- width: 450px;
- padding: 15px 0 0;
+#commentstatusdiv .fixed .column-author,
+#comments-form .fixed .column-author,
+#commentstatusdiv .fixed .column-date {
+ width: 20%;
}
-.info-box .gears-img {
- float: right;
- margin: 10px;
+.widefat th,
+.widefat td {
+ overflow: hidden;
}
-.info-box-title {
- line-height: 2;
- margin: 0;
- padding: 0 7px;
+.widefat th {
+ text-shadow: rgba(255,255,255,0.8) 0 1px 0;
}
-#wp_editbtns {
- padding: 2px;
- position: absolute;
- display: none;
- z-index: 999998;
+.icon32 {
+ float: left;
+ height: 36px;
+ margin: 14px 6px 0 0;
+ width: 36px;
}
-#wp_editimgbtn, #wp_delimgbtn {
- margin: 2px;
- padding: 2px;
- border: 1px solid #999;
- background-color: #eee;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
+.key-labels label {
+ line-height: 24px;
}
-#wp_editimgbtn:hover, #wp_delimgbtn:hover {
- border-color: #555;
- background-color: #ccc;
+.subtitle {
+ font-size: 0.75em;
+ line-height: 1;
+ padding-left: 25px;
}
$always_authenticate = 1;
/**
- * log_app() - Writes logging info to a file.
+ * Writes logging info to a file.
*
+ * @since 2.2.0
* @uses $app_logging
* @package WordPress
* @subpackage Logging
if ( !function_exists('wp_set_current_user') ) :
/**
- * wp_set_current_user() - Sets the current WordPress User
- *
- * Pluggable function which is also found in pluggable.php.
- *
- * @see wp-includes/pluggable.php Documentation for this function.
- * @uses $current_user Global of current user to test whether $id is the same.
- *
- * @param int $id The user's ID
- * @param string $name Optional. The username of the user.
- * @return WP_User Current user's User object
+ * @ignore
*/
function wp_set_current_user($id, $name = '') {
global $current_user;
endif;
/**
- * wa_posts_where_include_drafts_filter() - Filter to add more post statuses
+ * Filter to add more post statuses.
*
- * @param string $where SQL statement to filter
- * @return string Filtered SQL statement with added post_status for where clause
+ * @since 2.2.0
+ *
+ * @param string $where SQL statement to filter.
+ * @return string Filtered SQL statement with added post_status for where clause.
*/
function wa_posts_where_include_drafts_filter($where) {
$where = str_replace("post_status = 'publish'","post_status = 'publish' OR post_status = 'future' OR post_status = 'draft' OR post_status = 'inherit'", $where);
add_filter('posts_where', 'wa_posts_where_include_drafts_filter');
/**
- * @internal
- * Left undocumented to work on later. If you want to finish, then please do so.
+ * WordPress AtomPub API implementation.
*
* @package WordPress
* @subpackage Publishing
+ * @since 2.2.0
*/
class AtomServer {
+ /**
+ * ATOM content type.
+ *
+ * @since 2.2.0
+ * @var string
+ */
var $ATOM_CONTENT_TYPE = 'application/atom+xml';
+
+ /**
+ * Categories ATOM content type.
+ *
+ * @since 2.2.0
+ * @var string
+ */
var $CATEGORIES_CONTENT_TYPE = 'application/atomcat+xml';
+
+ /**
+ * Service ATOM content type.
+ *
+ * @since 2.3.0
+ * @var string
+ */
var $SERVICE_CONTENT_TYPE = 'application/atomsvc+xml';
+ /**
+ * ATOM XML namespace.
+ *
+ * @since 2.3.0
+ * @var string
+ */
var $ATOM_NS = 'http://www.w3.org/2005/Atom';
+
+ /**
+ * ATOMPUB XML namespace.
+ *
+ * @since 2.3.0
+ * @var string
+ */
var $ATOMPUB_NS = 'http://www.w3.org/2007/app';
+ /**
+ * Entries path.
+ *
+ * @since 2.2.0
+ * @var string
+ */
var $ENTRIES_PATH = "posts";
+
+ /**
+ * Categories path.
+ *
+ * @since 2.2.0
+ * @var string
+ */
var $CATEGORIES_PATH = "categories";
+
+ /**
+ * Media path.
+ *
+ * @since 2.2.0
+ * @var string
+ */
var $MEDIA_PATH = "attachments";
+
+ /**
+ * Entry path.
+ *
+ * @since 2.2.0
+ * @var string
+ */
var $ENTRY_PATH = "post";
+
+ /**
+ * Service path.
+ *
+ * @since 2.2.0
+ * @var string
+ */
var $SERVICE_PATH = "service";
+
+ /**
+ * Media single path.
+ *
+ * @since 2.2.0
+ * @var string
+ */
var $MEDIA_SINGLE_PATH = "attachment";
+ /**
+ * ATOMPUB parameters.
+ *
+ * @since 2.2.0
+ * @var array
+ */
var $params = array();
+
+ /**
+ * Supported ATOMPUB media types.
+ *
+ * @since 2.3.0
+ * @var array
+ */
var $media_content_types = array('image/*','audio/*','video/*');
+
+ /**
+ * ATOMPUB content type(s).
+ *
+ * @since 2.2.0
+ * @var array
+ */
var $atom_content_types = array('application/atom+xml');
+ /**
+ * ATOMPUB methods.
+ *
+ * @since 2.2.0
+ * @var unknown_type
+ */
var $selectors = array();
- // support for head
+ /**
+ * Whether to do output.
+ *
+ * Support for head.
+ *
+ * @since 2.2.0
+ * @var bool
+ */
var $do_output = true;
+ /**
+ * PHP4 constructor - Sets up object properties.
+ *
+ * @since 2.2.0
+ * @return AtomServer
+ */
function AtomServer() {
$this->script_name = array_pop(explode('/',$_SERVER['SCRIPT_NAME']));
);
}
+ /**
+ * Handle ATOMPUB request.
+ *
+ * @since 2.2.0
+ */
function handle_request() {
global $always_authenticate;
if( !empty( $_SERVER['ORIG_PATH_INFO'] ) )
$path = $_SERVER['ORIG_PATH_INFO'];
else
- $path = $_SERVER['PATH_INFO'];
+ $path = $_SERVER['PATH_INFO'];
$method = $_SERVER['REQUEST_METHOD'];
$this->not_found();
}
+ /**
+ * Retrieve XML for ATOMPUB service.
+ *
+ * @since 2.2.0
+ */
function get_service() {
log_app('function','get_service()');
$this->output($service_doc, $this->SERVICE_CONTENT_TYPE);
}
+ /**
+ * Retrieve categories list in XML format.
+ *
+ * @since 2.2.0
+ */
function get_categories_xml() {
log_app('function','get_categories_xml()');
$this->output($output, $this->CATEGORIES_CONTENT_TYPE);
}
- /*
- * Create Post (No arguments)
+ /**
+ * Create new post.
+ *
+ * @since 2.2.0
*/
function create_post() {
global $blog_id, $user_ID;
$this->created($postID, $output);
}
+ /**
+ * Retrieve post.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Post ID.
+ */
function get_post($postID) {
global $entry;
}
+ /**
+ * Update post.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Post ID.
+ */
function put_post($postID) {
// checked for valid content-types (atom+xml)
// quick check and exit
$this->ok();
}
+ /**
+ * Remove post.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Post ID.
+ */
function delete_post($postID) {
// check for not found
}
- function get_attachment($postID = NULL) {
+ /**
+ * Retrieve attachment.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Optional. Post ID.
+ */
+ function get_attachment($postID = null) {
if( !current_user_can( 'upload_files' ) )
$this->auth_required( __( 'Sorry, you do not have permission to upload files.' ) );
}
}
+ /**
+ * Create new attachment.
+ *
+ * @since 2.2.0
+ */
function create_attachment() {
$type = $this->get_accepted_content_type();
$this->auth_required(__('You do not have permission to upload files.'));
$fp = fopen("php://input", "rb");
- $bits = NULL;
+ $bits = null;
while(!feof($fp)) {
$bits .= fread($fp, 4096);
}
log_app('function',"create_attachment($postID)");
}
+ /**
+ * Update attachment.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Post ID.
+ */
function put_attachment($postID) {
// checked for valid content-types (atom+xml)
// quick check and exit
$this->ok();
}
+ /**
+ * Remove attachment.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Post ID.
+ */
function delete_attachment($postID) {
log_app('function',"delete_attachment($postID). File '$location' deleted.");
$this->ok();
}
+ /**
+ * Retrieve attachment from post.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Post ID.
+ */
function get_file($postID) {
// check for not found
exit;
}
+ /**
+ * Upload file to blog and add attachment to post.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Post ID.
+ */
function put_file($postID) {
// first check if user can upload
$this->ok();
}
- function get_entries_url($page = NULL) {
+ /**
+ * Retrieve entries URL.
+ *
+ * @since 2.2.0
+ *
+ * @param int $page Page ID.
+ * @return string
+ */
+ function get_entries_url($page = null) {
if($GLOBALS['post_type'] == 'attachment') {
$path = $this->MEDIA_PATH;
} else {
return $url;
}
- function the_entries_url($page = NULL) {
+ /**
+ * Display entries URL.
+ *
+ * @since 2.2.0
+ *
+ * @param int $page Page ID.
+ */
+ function the_entries_url($page = null) {
echo $this->get_entries_url($page);
}
+ /**
+ * Retrieve categories URL.
+ *
+ * @since 2.2.0
+ *
+ * @param mixed $deprecated Optional, not used.
+ * @return string
+ */
function get_categories_url($deprecated = '') {
return $this->app_base . $this->CATEGORIES_PATH;
}
+ /**
+ * Display category URL.
+ *
+ * @since 2.2.0
+ */
function the_categories_url() {
echo $this->get_categories_url();
}
- function get_attachments_url($page = NULL) {
+ /**
+ * Retrieve attachment URL.
+ *
+ * @since 2.2.0
+ *
+ * @param int $page Page ID.
+ * @return string
+ */
+ function get_attachments_url($page = null) {
$url = $this->app_base . $this->MEDIA_PATH;
if(isset($page) && is_int($page)) {
$url .= "/$page";
return $url;
}
- function the_attachments_url($page = NULL) {
+ /**
+ * Display attachment URL.
+ *
+ * @since 2.2.0
+ *
+ * @param int $page Page ID.
+ */
+ function the_attachments_url($page = null) {
echo $this->get_attachments_url($page);
}
+ /**
+ * Retrieve service URL.
+ *
+ * @since 2.3.0
+ *
+ * @return string
+ */
function get_service_url() {
return $this->app_base . $this->SERVICE_PATH;
}
- function get_entry_url($postID = NULL) {
+ /**
+ * Retrieve entry URL.
+ *
+ * @since 2.7.0
+ *
+ * @param int $postID Post ID.
+ * @return string
+ */
+ function get_entry_url($postID = null) {
if(!isset($postID)) {
global $post;
$postID = (int) $post->ID;
return $url;
}
- function the_entry_url($postID = NULL) {
+ /**
+ * Display entry URL.
+ *
+ * @since 2.7.0
+ *
+ * @param int $postID Post ID.
+ */
+ function the_entry_url($postID = null) {
echo $this->get_entry_url($postID);
}
- function get_media_url($postID = NULL) {
+ /**
+ * Retrieve media URL.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Post ID.
+ * @return string
+ */
+ function get_media_url($postID = null) {
if(!isset($postID)) {
global $post;
$postID = (int) $post->ID;
return $url;
}
- function the_media_url($postID = NULL) {
+ /**
+ * Display the media URL.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Post ID.
+ */
+ function the_media_url($postID = null) {
echo $this->get_media_url($postID);
}
+ /**
+ * Set the current entry to post ID.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Post ID.
+ */
function set_current_entry($postID) {
global $entry;
log_app('function',"set_current_entry($postID)");
return;
}
+ /**
+ * Display posts XML.
+ *
+ * @since 2.2.0
+ *
+ * @param int $page Optional. Page ID.
+ * @param string $post_type Optional, default is 'post'. Post Type.
+ */
function get_posts($page = 1, $post_type = 'post') {
log_app('function',"get_posts($page, '$post_type')");
$feed = $this->get_feed($page, $post_type);
$this->output($feed);
}
+ /**
+ * Display attachment XML.
+ *
+ * @since 2.2.0
+ *
+ * @param int $page Page ID.
+ * @param string $post_type Optional, default is 'attachment'. Post type.
+ */
function get_attachments($page = 1, $post_type = 'attachment') {
- log_app('function',"get_attachments($page, '$post_type')");
- $GLOBALS['post_type'] = $post_type;
- $feed = $this->get_feed($page, $post_type);
- $this->output($feed);
+ log_app('function',"get_attachments($page, '$post_type')");
+ $GLOBALS['post_type'] = $post_type;
+ $feed = $this->get_feed($page, $post_type);
+ $this->output($feed);
}
+ /**
+ * Retrieve feed XML.
+ *
+ * @since 2.2.0
+ *
+ * @param int $page Page ID.
+ * @param string $post_type Optional, default is post. Post type.
+ * @return string
+ */
function get_feed($page = 1, $post_type = 'post') {
global $post, $wp, $wp_query, $posts, $wpdb, $blog_id;
log_app('function',"get_feed($page, '$post_type')");
return $feed;
}
+ /**
+ * Display entry XML.
+ *
+ * @since 2.2.0
+ *
+ * @param int $postID Post ID.
+ * @param string $post_type Optional, default is post. Post type.
+ * @return string.
+ */
function get_entry($postID, $post_type = 'post') {
log_app('function',"get_entry($postID, '$post_type')");
ob_start();
return $entry;
}
+ /**
+ * Display post content XML.
+ *
+ * @since 2.3.0
+ */
function echo_entry() { ?>
<entry xmlns="<?php echo $this->ATOM_NS ?>"
xmlns:app="<?php echo $this->ATOMPUB_NS ?>" xml:lang="<?php echo get_option('rss_language'); ?>">
</entry>
<?php }
+ /**
+ * Set 'OK' (200) status header.
+ *
+ * @since 2.2.0
+ */
function ok() {
log_app('Status','200: OK');
header('Content-Type: text/plain');
exit;
}
+ /**
+ * Set 'No Content' (204) status header.
+ *
+ * @since 2.2.0
+ */
function no_content() {
log_app('Status','204: No Content');
header('Content-Type: text/plain');
exit;
}
+ /**
+ * Display 'Internal Server Error' (500) status header.
+ *
+ * @since 2.2.0
+ *
+ * @param string $msg Optional. Status string.
+ */
function internal_error($msg = 'Internal Server Error') {
log_app('Status','500: Server Error');
header('Content-Type: text/plain');
exit;
}
+ /**
+ * Set 'Bad Request' (400) status header.
+ *
+ * @since 2.2.0
+ */
function bad_request() {
log_app('Status','400: Bad Request');
header('Content-Type: text/plain');
exit;
}
+ /**
+ * Set 'Length Required' (411) status header.
+ *
+ * @since 2.2.0
+ */
function length_required() {
log_app('Status','411: Length Required');
header("HTTP/1.1 411 Length Required");
exit;
}
+ /**
+ * Set 'Unsupported Media Type' (415) status header.
+ *
+ * @since 2.2.0
+ */
function invalid_media() {
log_app('Status','415: Unsupported Media Type');
header("HTTP/1.1 415 Unsupported Media Type");
exit;
}
+ /**
+ * Set 'Forbidden' (403) status header.
+ *
+ * @since 2.6.0
+ */
function forbidden($reason='') {
log_app('Status','403: Forbidden');
header('Content-Type: text/plain');
exit;
}
+ /**
+ * Set 'Not Found' (404) status header.
+ *
+ * @since 2.2.0
+ */
function not_found() {
log_app('Status','404: Not Found');
header('Content-Type: text/plain');
exit;
}
+ /**
+ * Set 'Not Allowed' (405) status header.
+ *
+ * @since 2.2.0
+ */
function not_allowed($allow) {
log_app('Status','405: Not Allowed');
header('Allow: ' . join(',', $allow));
exit;
}
+ /**
+ * Display Redirect (302) content and set status headers.
+ *
+ * @since 2.3.0
+ */
function redirect($url) {
log_app('Status','302: Redirect');
}
-
+ /**
+ * Set 'Client Error' (400) status header.
+ *
+ * @since 2.2.0
+ */
function client_error($msg = 'Client Error') {
log_app('Status','400: Client Error');
header('Content-Type: text/plain');
exit;
}
+ /**
+ * Set created status headers (201).
+ *
+ * Sets the 'content-type', 'content-location', and 'location'.
+ *
+ * @since 2.2.0
+ */
function created($post_ID, $content, $post_type = 'post') {
log_app('created()::$post_ID',"$post_ID, $post_type");
$edit = $this->get_entry_url($post_ID);
exit;
}
+ /**
+ * Set 'Auth Required' (401) headers.
+ *
+ * @since 2.2.0
+ *
+ * @param string $msg Status header content and HTML content.
+ */
function auth_required($msg) {
log_app('Status','401: Auth Required');
nocache_headers();
header('WWW-Authenticate: Basic realm="WordPress Atom Protocol"');
header("HTTP/1.1 401 $msg");
- header('Status: ' . $msg);
+ header('Status: 401 ' . $msg);
header('Content-Type: text/html');
$content = <<<EOD
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
exit;
}
+ /**
+ * Display XML and set headers with content type.
+ *
+ * @since 2.2.0
+ *
+ * @param string $xml Display feed content.
+ * @param string $ctype Optional, default is 'atom+xml'. Feed content type.
+ */
function output($xml, $ctype = 'application/atom+xml') {
status_header('200');
$xml = '<?xml version="1.0" encoding="' . strtolower(get_option('blog_charset')) . '"?>'."\n".$xml;
exit;
}
+ /**
+ * Sanitize content for database usage.
+ *
+ * @since 2.2.0
+ *
+ * @param array $array Sanitize array and multi-dimension array.
+ */
function escape(&$array) {
global $wpdb;
}
}
- /*
- * Access credential through various methods and perform login
+ /**
+ * Access credential through various methods and perform login.
+ *
+ * @since 2.2.0
+ *
+ * @return bool
*/
function authenticate() {
log_app("authenticate()",print_r($_ENV, true));
if(isset($_SERVER['HTTP_AUTHORIZATION'])) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
+ } else if (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
+ // Workaround for setups that do not forward HTTP_AUTHORIZATION
+ // See http://trac.wordpress.org/ticket/7361
+ list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
+ explode(':', base64_decode(substr($_SERVER['REDIRECT_REMOTE_USER'], 6)));
}
// If Basic Auth is working...
return false;
}
- function get_accepted_content_type($types = NULL) {
+ /**
+ * Retrieve accepted content types.
+ *
+ * @since 2.2.0
+ *
+ * @param array $types Optional. Content Types.
+ * @return string
+ */
+ function get_accepted_content_type($types = null) {
if(!isset($types)) {
$types = $this->media_content_types;
$this->invalid_media();
}
+ /**
+ * Process conditionals for posts.
+ *
+ * @since 2.2.0
+ */
function process_conditionals() {
if(empty($this->params)) return;
}
}
+ /**
+ * Convert RFC3339 time string to timestamp.
+ *
+ * @since 2.3.0
+ *
+ * @param string $str String to time.
+ * @return bool|int false if format is incorrect.
+ */
function rfc3339_str2time($str) {
- $match = false;
- if(!preg_match("/(\d{4}-\d{2}-\d{2})T(\d{2}\:\d{2}\:\d{2})\.?\d{0,3}(Z|[+-]+\d{2}\:\d{2})/", $str, $match))
+ $match = false;
+ if(!preg_match("/(\d{4}-\d{2}-\d{2})T(\d{2}\:\d{2}\:\d{2})\.?\d{0,3}(Z|[+-]+\d{2}\:\d{2})/", $str, $match))
return false;
- if($match[3] == 'Z')
+ if($match[3] == 'Z')
$match[3] == '+0000';
- return strtotime($match[1] . " " . $match[2] . " " . $match[3]);
+ return strtotime($match[1] . " " . $match[2] . " " . $match[3]);
}
+ /**
+ * Retrieve published time to display in XML.
+ *
+ * @since 2.3.0
+ *
+ * @param string $published Time string.
+ * @return string
+ */
function get_publish_time($published) {
- $pubtime = $this->rfc3339_str2time($published);
+ $pubtime = $this->rfc3339_str2time($published);
- if(!$pubtime) {
+ if(!$pubtime) {
return array(current_time('mysql'),current_time('mysql',1));
- } else {
+ } else {
return array(date("Y-m-d H:i:s", $pubtime), gmdate("Y-m-d H:i:s", $pubtime));
- }
+ }
}
}
+/**
+ * AtomServer
+ * @var AtomServer
+ * @global object $server
+ */
$server = new AtomServer();
$server->handle_request();
<?php
/**
- * Outputs the Atom feed XML format using the feed-atom.php file in wp-includes
- * folder. This file only sets the feed format and includes the feed-atom.php.
- *
- * This file is no longer used in WordPress and while it is not deprecated now.
- * This file will most likely be deprecated or removed in a later version.
- *
- * The link for the atom feed is /index.php?feed=atom with permalinks off.
+ * Redirects to the Atom feed
+ * This file is deprecated and only exists for backwards compatibility
*
* @package WordPress
*/
-if (empty($wp)) {
- require_once('./wp-load.php');
- wp('feed=atom');
-}
-
-require (ABSPATH . WPINC . '/feed-atom.php');
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( 'atom_url' ), 301 );
?>
\ No newline at end of file
exit;
}
-$comment_author = trim(strip_tags($_POST['author']));
-$comment_author_email = trim($_POST['email']);
-$comment_author_url = trim($_POST['url']);
-$comment_content = trim($_POST['comment']);
+$comment_author = ( isset($_POST['author']) ) ? trim(strip_tags($_POST['author'])) : null;
+$comment_author_email = ( isset($_POST['email']) ) ? trim($_POST['email']) : null;
+$comment_author_url = ( isset($_POST['url']) ) ? trim($_POST['url']) : null;
+$comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null;
// If the user is logged in
$user = wp_get_current_user();
if ( $user->ID ) {
+ if ( empty( $user->display_name ) )
+ $user->display_name=$user->user_login;
$comment_author = $wpdb->escape($user->display_name);
$comment_author_email = $wpdb->escape($user->user_email);
$comment_author_url = $wpdb->escape($user->user_url);
if ( '' == $comment_content )
wp_die( __('Error: please type a comment.') );
-$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID');
+$comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
+
+$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
$comment_id = wp_new_comment( $commentdata );
setcookie('comment_author_url_' . COOKIEHASH, clean_url($comment->comment_author_url), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
}
-$location = ( empty($_POST['redirect_to']) ? get_permalink($comment_post_ID) : $_POST['redirect_to'] ) . '#comment-' . $comment_id;
+$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;
$location = apply_filters('comment_post_redirect', $location, $comment);
wp_redirect($location);
<?php
/**
- * Outputs the RSS2 XML format comment feed using the feed-rss2.php file in
- * wp-includes folder. This file only sets the feed format and includes the
- * feed-rss2-comments.php.
- *
- * This file is no longer used in WordPress and while it is not deprecated now.
- * This file will most likely be deprecated or removed in a later version.
- *
- * The link for the rss2 comment feed is /index.php?feed=rss2&withcomments=1
- * with permalinks off.
+ * Redirects to the Comments RSS2 feed
+ * This file is deprecated and only exists for backwards compatibility
*
* @package WordPress
*/
-if (empty($wp)) {
- require_once('./wp-load.php');
- wp('feed=rss2&withcomments=1');
-}
-
-require (ABSPATH . WPINC . '/feed-rss2-comments.php');
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( 'comments_rss2_url' ), 301 );
?>
\ No newline at end of file
<?php\r
-// ** MySQL settings ** //\r
-define('DB_NAME', 'putyourdbnamehere'); // The name of the database\r
-define('DB_USER', 'usernamehere'); // Your MySQL username\r
-define('DB_PASSWORD', 'yourpasswordhere'); // ...and password\r
-define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value\r
+/** \r
+ * The base configurations of the WordPress.\r
+ *\r
+ * This file has the following configurations: MySQL settings, Table Prefix,\r
+ * Secret Keys, WordPress Language, and ABSPATH. You can find more information by\r
+ * visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing\r
+ * wp-config.php} Codex page. You can get the MySQL settings from your web host.\r
+ *\r
+ * This file is used by the wp-config.php creation script during the\r
+ * installation. You don't have to use the web site, you can just copy this file\r
+ * to "wp-config.php" and fill in the values.\r
+ *\r
+ * @package WordPress\r
+ */\r
+\r
+// ** MySQL settings - You can get this info from your web host ** //\r
+/** The name of the database for WordPress */\r
+define('DB_NAME', 'putyourdbnamehere');\r
+\r
+/** MySQL database username */\r
+define('DB_USER', 'usernamehere');\r
+\r
+/** MySQL database password */\r
+define('DB_PASSWORD', 'yourpasswordhere');\r
+\r
+/** MySQL hostname */\r
+define('DB_HOST', 'localhost');\r
+\r
+/** Database Charset to use in creating database tables. */\r
define('DB_CHARSET', 'utf8');\r
+\r
+/** The Database Collate type. Don't change this if in doubt. */\r
define('DB_COLLATE', '');\r
\r
-// Change each KEY to a different unique phrase. You won't have to remember the phrases later,\r
-// so make them long and complicated. You can visit http://api.wordpress.org/secret-key/1.1/\r
-// to get keys generated for you, or just make something up. Each key should have a different phrase.\r
-define('AUTH_KEY', 'put your unique phrase here'); // Change this to a unique phrase.\r
-define('SECURE_AUTH_KEY', 'put your unique phrase here'); // Change this to a unique phrase.\r
-define('LOGGED_IN_KEY', 'put your unique phrase here'); // Change this to a unique phrase.\r
+/**#@+\r
+ * Authentication Unique Keys.\r
+ *\r
+ * Change these to different unique phrases!\r
+ * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/ WordPress.org secret-key service}\r
+ *\r
+ * @since 2.6.0\r
+ */\r
+define('AUTH_KEY', 'put your unique phrase here');\r
+define('SECURE_AUTH_KEY', 'put your unique phrase here');\r
+define('LOGGED_IN_KEY', 'put your unique phrase here');\r
+define('NONCE_KEY', 'put your unique phrase here');\r
+/**#@-*/\r
\r
-// You can have multiple installations in one database if you give each a unique prefix\r
-$table_prefix = 'wp_'; // Only numbers, letters, and underscores please!\r
+/**\r
+ * WordPress Database Table prefix.\r
+ *\r
+ * You can have multiple installations in one database if you give each a unique\r
+ * prefix. Only numbers, letters, and underscores please!\r
+ */\r
+$table_prefix = 'wp_';\r
\r
-// Change this to localize WordPress. A corresponding MO file for the\r
-// chosen language must be installed to wp-content/languages.\r
-// For example, install de.mo to wp-content/languages and set WPLANG to 'de'\r
-// to enable German language support.\r
+/**\r
+ * WordPress Localized Language, defaults to English.\r
+ *\r
+ * Change this to localize WordPress. A corresponding MO file for the chosen\r
+ * language must be installed to wp-content/languages. For example, install\r
+ * de.mo to wp-content/languages and set WPLANG to 'de' to enable German\r
+ * language support.\r
+ */\r
define ('WPLANG', '');\r
\r
/* That's all, stop editing! Happy blogging. */\r
\r
+/** WordPress absolute path to the Wordpress directory. */\r
if ( !defined('ABSPATH') )\r
define('ABSPATH', dirname(__FILE__) . '/');\r
+\r
+/** Sets up WordPress vars and included files. */\r
require_once(ABSPATH . 'wp-settings.php');\r
?>\r
/*
Plugin Name: Akismet
Plugin URI: http://akismet.com/
-Description: Akismet checks your comments against the Akismet web service to see if they look like spam or not. You need a <a href="http://wordpress.com/api-keys/">WordPress.com API key</a> to use it. You can review the spam it catches under "Comments." To show off your Akismet stats just put <code><?php akismet_counter(); ?></code> in your template. See also: <a href="http://wordpress.org/extend/plugins/stats/">WP Stats plugin</a>.
-Version: 2.1.8
+Description: Akismet checks your comments against the Akismet web service to see if they look like spam or not. You need a <a href="http://wordpress.com/api-keys/">WordPress.com API key</a> to use it. You can review the spam it catches under "Comments." To show off your Akismet stats just put <code><?php akismet_counter(); ?></code> in your template. See also: <a href="http://wordpress.org/extend/plugins/stats/">WP Stats plugin</a>.
+Version: 2.2.3
Author: Matt Mullenweg
Author URI: http://ma.tt/
*/
$akismet_api_port = 80;
add_action('admin_menu', 'akismet_config_page');
+ add_action('admin_menu', 'akismet_stats_page');
}
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;
<?php
}
+function akismet_stats_page() {
+ if ( function_exists('add_submenu_page') )
+ add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
+
+}
+
+function akismet_stats_script() {
+ ?>
+<script type="text/javascript">
+function resizeIframe() {
+ var height = document.documentElement.clientHeight;
+ height -= document.getElementById('akismet-stats-frame').offsetTop;
+ height += 100; // magic padding
+
+ document.getElementById('akismet-stats-frame').style.height = height +"px";
+
+};
+function resizeIframeInit() {
+ document.getElementById('akismet-stats-frame').onload = resizeIframe;
+ window.onresize = resizeIframe;
+}
+addLoadEvent(resizeIframeInit);
+</script><?php
+}
+
+
+function akismet_stats_display() {
+ global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
+ $blog = urlencode( get_option('home') );
+ $url = "http://".get_option('wordpress_api_key').".web.akismet.com/1.0/user-stats.php?blog={$blog}";
+ ?>
+ <div class="wrap">
+ <iframe src="<?php echo $url; ?>" width="100%" height="100%" frameborder="0" id="akismet-stats-frame"></iframe>
+ </div>
+ <?php
+}
+
function akismet_verify_key( $key ) {
global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
$blog = urlencode( get_option('home') );
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 ) {
// WP 2.5+
function akismet_rightnow() {
- global $submenu;
- if ( isset( $submenu['edit-comments.php'] ) )
- $link = 'edit-comments.php';
+ 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';
+ $link = 'edit.php?page=akismet-admin';
if ( $count = get_option('akismet_spam_count') ) {
$intro = sprintf( __ngettext(
'and there\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
'and there are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
$queue_count
- ), number_format_i18n( $queue_count ), clean_url("$link?page=akismet-admin") );
+ ), number_format_i18n( $queue_count ), clean_url($link) );
} else {
- $queue_text = sprintf( __( "but there's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), clean_url("$link?page=akismet-admin") );
+ $queue_text = sprintf( __( "but there's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), clean_url($link) );
}
$text = sprintf( _c( '%1$s %2$s|akismet_rightnow' ), $intro, $queue_text );
<?php
+/**
+ * @package Hello_Dolly
+ * @author Matt Mullenweg
+ * @version 1.5
+ */
/*
Plugin Name: Hello Dolly
Plugin URI: http://wordpress.org/#
Author URI: http://ma.tt/
*/
-// These are the lyrics to Hello Dolly
-$lyrics = "Hello, Dolly
+function hello_dolly_get_lyric() {
+ /** These are the lyrics to Hello Dolly */
+ $lyrics = "Hello, Dolly
Well, hello, Dolly
It's so nice to have you back where you belong
You're lookin' swell, Dolly
Dolly'll never go away
Dolly'll never go away again";
-// Here we split it into lines
-$lyrics = explode("\n", $lyrics);
-// And then randomly choose a line
-$chosen = wptexturize( $lyrics[ mt_rand(0, count($lyrics) - 1) ] );
+ // Here we split it into lines
+ $lyrics = explode("\n", $lyrics);
+
+ // And then randomly choose a line
+ return wptexturize( $lyrics[ mt_rand(0, count($lyrics) - 1) ] );
+}
// This just echoes the chosen line, we'll position it later
function hello_dolly() {
- global $chosen;
+ $chosen = hello_dolly_get_lyric();
echo "<p id='dolly'>$chosen</p>";
}
<style type='text/css'>
#dolly {
position: absolute;
- top: 2.3em;
+ top: 4.5em;
margin: 0;
padding: 0;
- right: 10px;
- font-size: 16px;
- color: #d54e21;
+ right: 215px;
+ font-size: 11px;
}
</style>
";
add_action('admin_head', 'dolly_css');
-?>
\ No newline at end of file
+?>
<?php
-/* Don't remove these lines. */
-add_filter('comment_text', 'popuplinks');
-while( have_posts()) : the_post();
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+/**
+ * @package WordPress
+ * @subpackage Classic_Theme
+ */
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo get_option('blogname'); ?> - <?php echo sprintf(__("Comments on %s"), the_title('','',false)); ?></title>
<h1 id="header"><a href="" title="<?php echo get_option('blogname'); ?>"><?php echo get_option('blogname'); ?></a></h1>
+<?php
+/* Don't remove these lines. */
+add_filter('comment_text', 'popuplinks');
+if ( have_posts() ) :
+while( have_posts()) : the_post();
+?>
+
<h2 id="comments"><?php _e("Comments"); ?></h2>
<p><a href="<?php echo get_post_comments_feed_link($post->ID); ?>"><?php _e("<abbr title=\"Really Simple Syndication\">RSS</abbr> feed for comments on this post."); ?></a></p>
extract($commenter);
$comments = get_approved_comments($id);
$commentstatus = get_post($id);
-if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) { // and it doesn't match the cookie
+if ( post_password_required($commentstatus) ) { // and it doesn't match the cookie
echo(get_the_password_form());
} else { ?>
<?php foreach ($comments as $comment) { ?>
<li id="comment-<?php comment_ID() ?>">
<?php comment_text() ?>
- <p><cite><?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?> <?php _e("by"); ?> <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
+ <p><cite><?php comment_type(_c('Comment|noun'), __('Trackback'), __('Pingback')); ?> <?php _e("by"); ?> <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
</li>
<?php } // end for each comment ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( $user_ID ) : ?>
-<p><?php printf(__('Logged in as %s.'), '<a href="'.get_option('siteurl').'/wp-admin/profile.php">'.$user_identity.'</a>'); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php echo attribute_escape(__('Log out of this account')); ?>"><?php _e('Log out »'); ?></a></p>
+<p><?php printf(__('Logged in as %s.'), '<a href="'.get_option('siteurl').'/wp-admin/profile.php">'.$user_identity.'</a>'); ?> <a href="<?php echo wp_logout_url(); ?>" title="<?php echo attribute_escape(__('Log out of this account')); ?>"><?php _e('Log out »'); ?></a></p>
<?php else : ?>
<p>
<input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" />
<label for="author"><?php _e("Name"); ?></label>
- <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
- <input type="hidden" name="redirect_to" value="<?php echo attribute_escape($_SERVER["REQUEST_URI"]); ?>" />
</p>
<p>
</p>
<p>
+ <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
+ <input type="hidden" name="redirect_to" value="<?php echo attribute_escape($_SERVER["REQUEST_URI"]); ?>" />
<input name="submit" type="submit" tabindex="5" value="<?php _e("Say It!"); ?>" />
</p>
<?php do_action('comment_form', $post->ID); ?>
<div><strong><a href="javascript:window.close()"><?php _e("Close this window."); ?></a></strong></div>
<?php // if you delete this the sky will fall on your head
-endwhile;
+endwhile; //endwhile have_posts()
+else: //have_posts()
?>
+<p>Sorry, no posts matched your criteria.</p>
+<?php endif; ?>
<!-- // this is just the end of the motor - don't touch that line either :) -->
<?php //} ?>
-<?php if ( !empty($post->post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) : ?>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Classic_Theme
+ */
+
+if ( post_password_required() ) : ?>
<p><?php _e('Enter your password to view comments.'); ?></p>
<?php return; endif; ?>
<ol id="commentlist">
<?php foreach ($comments as $comment) : ?>
- <li id="comment-<?php comment_ID() ?>">
+ <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
<?php echo get_avatar( $comment, 32 ); ?>
<?php comment_text() ?>
- <p><cite><?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
+ <p><cite><?php comment_type(_c('Comment|noun'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
</li>
<?php endforeach; ?>
<?php if ( $user_ID ) : ?>
-<p><?php printf(__('Logged in as %s.'), '<a href="'.get_option('siteurl').'/wp-admin/profile.php">'.$user_identity.'</a>'); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php _e('Log out »'); ?></a></p>
+<p><?php printf(__('Logged in as %s.'), '<a href="'.get_option('siteurl').'/wp-admin/profile.php">'.$user_identity.'</a>'); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php _e('Log out of this account') ?>"><?php _e('Log out »'); ?></a></p>
<?php else : ?>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Classic_Theme
+ */
+?>
<!-- begin footer -->
</div>
<?php
+/**
+ * @package WordPress
+ * @subpackage Classic_Theme
+ */
if ( function_exists('register_sidebar') )
register_sidebar(array(
- 'before_widget' => '<li id="%1$s" class="widget %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '',
- 'after_title' => '',
- ));
+ 'before_widget' => '<li id="%1$s" class="widget %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '',
+ 'after_title' => '',
+ ));
?>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Classic_Theme
+ */
+?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
- <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
+ <title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title>
<style type="text/css" media="screen">
@import url( <?php bloginfo('stylesheet_url'); ?> );
<?php
+/**
+ * @package WordPress
+ * @subpackage Classic_Theme
+ */
get_header();
?>
<?php the_date('','<h2>','</h2>'); ?>
-<div class="post" id="post-<?php the_ID(); ?>">
+<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_tags(__('Tags: '), ', ', ' — '); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
border-right: 1px solid #ddd;
}
+#commentlist li .avatar {
+ margin-right: 0;
+ margin-left: 12px;
+}
+
+#commentlist li .avatar {
+ margin-right: 0;
+ margin-left: 12px;
+}
+
#content {
margin: 30px 3em 0 13em;
padding-right: 0;
-
+<?php
+/**
+ * @package WordPress
+ * @subpackage Classic_Theme
+ */
+?>
<!-- begin sidebar -->
<div id="menu">
-<?php get_header(); ?>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+
+get_header();
+?>
<div id="content" class="narrowcolumn">
-<?php get_header(); ?>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+
+get_header();
+?>
<div id="content" class="narrowcolumn">
</div>
<?php while (have_posts()) : the_post(); ?>
- <div class="post">
+ <div <?php post_class() ?>>
<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<small><?php the_time('l, F jS, Y') ?></small>
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
-
- <?php else : ?>
-
- <h2 class="center">Not Found</h2>
- <?php include (TEMPLATEPATH . '/searchform.php'); ?>
-
- <?php endif; ?>
+ <?php else :
+
+ if ( is_category() ) { // If this is a category archive
+ printf("<h2 class='center'>Sorry, but there aren't any posts in the %s category yet.</h2>", single_cat_title('',false));
+ } else if ( is_date() ) { // If this is a date archive
+ echo("<h2>Sorry, but there aren't any posts with this date.</h2>");
+ } else if ( is_author() ) { // If this is a category archive
+ $userdata = get_userdatabylogin(get_query_var('author_name'));
+ printf("<h2 class='center'>Sorry, but there aren't any posts by %s yet.</h2>", $userdata->display_name);
+ } else {
+ echo("<h2 class='center'>No posts found.</h2>");
+ }
+ get_search_form();
+
+ endif;
+?>
</div>
<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
/*
Template Name: Archives
*/
<div id="content" class="widecolumn">
-<?php include (TEMPLATEPATH . '/searchform.php'); ?>
+<?php get_search_form(); ?>
<h2>Archives by Month:</h2>
<ul>
<?php
-/* Don't remove these lines. */
-add_filter('comment_text', 'popuplinks');
-while ( have_posts()) : the_post();
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo get_option('blogname'); ?> - Comments on <?php the_title(); ?></title>
<h1 id="header"><a href="" title="<?php echo get_option('blogname'); ?>"><?php echo get_option('blogname'); ?></a></h1>
+<?php
+/* Don't remove these lines. */
+add_filter('comment_text', 'popuplinks');
+if ( have_posts() ) :
+while ( have_posts() ) : the_post();
+?>
<h2 id="comments">Comments</h2>
<p><a href="<?php echo get_post_comments_feed_link($post->ID); ?>"><abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.</a></p>
extract($commenter);
$comments = get_approved_comments($id);
$post = get_post($id);
-if (!empty($post->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
+if ( post_password_required($post) ) { // and it doesn't match the cookie
echo(get_the_password_form());
} else { ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( $user_ID ) : ?>
- <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Log out »</a></p>
+ <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out »</a></p>
<?php else : ?>
<p>
<input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" />
<label for="author">Name</label>
- <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
- <input type="hidden" name="redirect_to" value="<?php echo attribute_escape($_SERVER["REQUEST_URI"]); ?>" />
</p>
<p>
</p>
<p>
+ <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
+ <input type="hidden" name="redirect_to" value="<?php echo attribute_escape($_SERVER["REQUEST_URI"]); ?>" />
<input name="submit" type="submit" tabindex="5" value="Say It!" />
</p>
<?php do_action('comment_form', $post->ID); ?>
<div><strong><a href="javascript:window.close()">Close this window.</a></strong></div>
<?php // if you delete this the sky will fall on your head
-endwhile;
+endwhile; //endwhile have_posts()
+else: //have_posts()
?>
-
+<p>Sorry, no posts matched your criteria.</p>
+<?php endif; ?>
<!-- // this is just the end of the motor - don't touch that line either :) -->
<?php //} ?>
<p class="credit"><?php timer_stop(1); ?> <cite>Powered by <a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform"><strong>WordPress</strong></a></cite></p>
-<?php // Do not delete these lines
+<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+
+// Do not delete these lines
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');
- if (!empty($post->post_password)) { // if there's a password
- if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
- ?>
-
- <p class="nocomments">This post is password protected. Enter the password to view comments.</p>
-
- <?php
- return;
- }
+ if ( post_password_required() ) { ?>
+ <p class="nocomments">This post is password protected. Enter the password to view comments.</p>
+ <?php
+ return;
}
-
- /* This variable is for alternating comment background */
- $oddcomment = 'class="alt" ';
?>
<!-- You can start editing here. -->
-<?php if ($comments) : ?>
+<?php if ( have_comments() ) : ?>
<h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3>
- <ol class="commentlist">
-
- <?php foreach ($comments as $comment) : ?>
-
- <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
- <?php echo get_avatar( $comment, 32 ); ?>
- <cite><?php comment_author_link() ?></cite> Says:
- <?php if ($comment->comment_approved == '0') : ?>
- <em>Your comment is awaiting moderation.</em>
- <?php endif; ?>
- <br />
-
- <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php edit_comment_link('edit',' ',''); ?></small>
-
- <?php comment_text() ?>
-
- </li>
-
- <?php
- /* Changes every other comment to a different class */
- $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : '';
- ?>
-
- <?php endforeach; /* end for each comment */ ?>
+ <div class="navigation">
+ <div class="alignleft"><?php previous_comments_link() ?></div>
+ <div class="alignright"><?php next_comments_link() ?></div>
+ </div>
+ <ol class="commentlist">
+ <?php wp_list_comments(); ?>
</ol>
+ <div class="navigation">
+ <div class="alignleft"><?php previous_comments_link() ?></div>
+ <div class="alignright"><?php next_comments_link() ?></div>
+ </div>
<?php else : // this is displayed if there are no comments so far ?>
<?php if ('open' == $post->comment_status) : ?>
<?php if ('open' == $post->comment_status) : ?>
-<h3 id="respond">Leave a Reply</h3>
+<div id="respond">
+
+<h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>
+
+<div class="cancel-comment-reply">
+ <small><?php cancel_comment_reply_link(); ?></small>
+</div>
<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p>
<?php if ( $user_ID ) : ?>
-<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Log out »</a></p>
+<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out »</a></p>
<?php else : ?>
<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
-<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
+<?php comment_id_fields(); ?>
</p>
<?php do_action('comment_form', $post->ID); ?>
</form>
<?php endif; // If registration required and not logged in ?>
+</div>
<?php endif; // if you delete this the sky will fall on your head ?>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+?>
<hr />
<div id="footer">
<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+
if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_title' => '</h2>',
));
+/** @ignore */
function kubrick_head() {
$head = "<style type='text/css'>\n<!--";
$output = '';
if ( isset( $_REQUEST['saved'] ) ) echo '<div id="message" class="updated fade"><p><strong>'.__('Options saved.').'</strong></p></div>';
?>
<div class='wrap'>
+ <h2><?php _e('Customize Header'); ?></h2>
<div id="kubrick-header">
- <h2><?php _e('Header Image and Color'); ?></h2>
<div id="headwrap">
<div id="header">
<div id="headerimg">
<input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo attribute_escape(kubrick_upper_color()); ?>" />
<input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo attribute_escape(kubrick_lower_color()); ?>" />
<input type="hidden" name="headerimage" id="headerimage" value="<?php echo attribute_escape(kubrick_header_image()); ?>" />
- <p class="submit"><input type="submit" name="submitform" class="defbutton" value="<?php echo attribute_escape(__('Update Header')); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
+ <p class="submit"><input type="submit" name="submitform" class="button-primary" value="<?php echo attribute_escape(__('Update Header')); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
</form>
<div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
<div id="advanced">
+<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
-<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
+<title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
+<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<style type="text/css" media="screen">
</style>
+<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
+
<?php wp_head(); ?>
</head>
<body>
-<?php get_header(); ?>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+
+get_header();
+?>
<div id="content" class="widecolumn">
<h2><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> » <?php the_title(); ?></h2>
<div class="entry">
<p class="attachment"><a href="<?php echo wp_get_attachment_url($post->ID); ?>"><?php echo wp_get_attachment_image( $post->ID, 'medium' ); ?></a></p>
- <div class="caption"><?php if ( !empty($post->post_excerpt) ) the_excerpt(); // this is the "caption" ?></div>
+ <div class="caption"><?php if ( !empty($post->post_excerpt) ) the_excerpt(); // this is the "caption" ?></div>
<?php the_content('<p class="serif">Read the rest of this entry »</p>'); ?>
<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+/** @ignore */
$img = 'kubrickheader.jpg';
// If we don't have image processing support, redirect.
-<?php get_header(); ?>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+
+get_header(); ?>
<div id="content" class="narrowcolumn">
<?php while (have_posts()) : the_post(); ?>
- <div class="post" id="post-<?php the_ID(); ?>">
+ <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
- <?php include (TEMPLATEPATH . "/searchform.php"); ?>
+ <?php get_search_form(); ?>
<?php endif; ?>
<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+
/*
Template Name: Links
*/
-<?php get_header(); ?>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+
+get_header(); ?>
<div id="content" class="narrowcolumn">
-<?php get_header(); ?>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+
+get_header(); ?>
<div id="content" class="narrowcolumn">
<?php while (have_posts()) : the_post(); ?>
- <div class="post">
+ <div <?php post_class() ?>>
<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<small><?php the_time('l, F jS, Y') ?></small>
<?php else : ?>
<h2 class="center">No posts found. Try a different search?</h2>
- <?php include (TEMPLATEPATH . '/searchform.php'); ?>
+ <?php get_search_form(); ?>
<?php endif; ?>
+++ /dev/null
-<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
-<label class="hidden" for="s"><?php _e('Search for:'); ?></label>
-<div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
-<input type="submit" id="searchsubmit" value="Search" />
-</div>
-</form>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+?>
<div id="sidebar">
<ul>
<?php /* Widgetized sidebar, if you have the plugin installed. */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
<li>
- <?php include (TEMPLATEPATH . '/searchform.php'); ?>
+ <?php get_search_form(); ?>
</li>
<!-- Author information is disabled per default. Uncomment and fill in your details if you want to use it.
-<?php get_header(); ?>
+<?php
+/**
+ * @package WordPress
+ * @subpackage Default_Theme
+ */
+
+get_header();
+?>
<div id="content" class="widecolumn">
<div class="alignright"><?php next_post_link('%link »') ?></div>
</div>
- <div class="post" id="post-<?php the_ID(); ?>">
+ <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
text-align: center;
}
-.alt {
+.thread-alt {
background-color: #f8f8f8;
- border-top: 1px solid #ddd;
- border-bottom: 1px solid #ddd;
- }
+}
+.thread-even {
+ background-color: white;
+}
+.depth-1 {
+border: 1px solid #ddd;
+}
+
+.even, .alt {
+
+ border-left: 1px solid #ddd;
+}
#footer {
background: #eee url('images/kubrickfooter.jpg') no-repeat top;
.commentlist li, #commentform input, #commentform textarea {
font: 0.9em 'Lucida Grande', Verdana, Arial, Sans-Serif;
}
+.commentlist li ul li {
+ font-size: 1em;
+}
.commentlist li {
font-weight: bold;
- }
+}
.commentlist li .avatar {
float: right;
margin: 5px 5px 1px 0;
}
+#commentform {
+ margin: 5px 10px 0 0;
+ }
#commentform textarea {
width: 100%;
padding: 2px;
}
-
+#respond:after {
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+ }
#commentform #submit {
- margin: 0;
+ margin: 0 0 5px auto;
float: right;
}
/* End Form Elements */
}
.commentlist li {
- margin: 15px 0 3px;
- padding: 5px 10px 3px;
+ margin: 15px 0 10px;
+ padding: 5px 5px 10px 10px;
list-style: none;
+
}
+.commentlist li ul li {
+ margin-right: -5px;
+ margin-left: 10px;
+}
.commentlist p {
margin: 10px 5px 10px 0;
- }
+}
+.children { padding: 0; }
#commentform p {
margin: 5px 0;
if ( $_GET['check'] != wp_hash('187425') )
exit;
-if ( get_option('doing_cron') > time() )
- exit;
-
-update_option('doing_cron', time() + 30);
+$local_time = time();
$crons = _get_cron_array();
-$keys = array_keys($crons);
-if (!is_array($crons) || $keys[0] > time())
+$keys = array_keys( $crons );
+
+if (!is_array($crons) || $keys[0] > $local_time) {
+ update_option('doing_cron', 0);
return;
+}
+
+foreach ($crons as $timestamp => $cronhooks) {
+
+ if ( $timestamp > $local_time )
+ break;
-foreach ($crons as $timestamp => $cronhooks) {
- if ($timestamp > time()) break;
foreach ($cronhooks as $hook => $keys) {
- foreach ($keys as $key => $args) {
- $schedule = $args['schedule'];
+
+ foreach ($keys as $k => $v) {
+
+ $schedule = $v['schedule'];
+
if ($schedule != false) {
- $new_args = array($timestamp, $schedule, $hook, $args['args']);
+ $new_args = array($timestamp, $schedule, $hook, $v['args']);
call_user_func_array('wp_reschedule_event', $new_args);
}
- wp_unschedule_event($timestamp, $hook, $args['args']);
- do_action_ref_array($hook, $args['args']);
+
+ wp_unschedule_event($timestamp, $hook, $v['args']);
+
+ do_action_ref_array($hook, $v['args']);
}
}
}
update_option('doing_cron', 0);
-?>
\ No newline at end of file
+die();
+
+?>
<?php
/**
- * Outputs the RSS2 feed XML format. This file is a shortcut or compatibility
- * layer for easily finding the RSS feed for the site. It loads WordPress using
- * the wp-blog-header.php file and running do_feed() function.
- *
- * @see do_feed() Used to display the RSS2 feed
- *
- * This file is no longer used in WordPress and while it is not deprecated now.
- * This file will most likely be deprecated or removed in a later version.
- *
- * The link for the rss2 feed is /index.php?feed=rss2 with permalinks off.
+ * Redirects to the RSS2 feed
+ * This file is deprecated and only exists for backwards compatibility
*
* @package WordPress
*/
-if (empty($doing_rss)) {
- $doing_rss = 1;
- require(dirname(__FILE__) . '/wp-blog-header.php');
-}
-
-do_feed();
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( 'rss2_url' ), 301 );
-?>
+?>
\ No newline at end of file
* link to the author's posts.
*
* @link http://codex.wordpress.org/Template_Tags/the_author_posts_link
- * @since 1.2
+ * @since 1.2.0
* @uses $authordata The current author's DB object.
* @uses get_author_posts_url()
* @uses get_the_author()
/**
* Retrieve the URL to the author page of the author of the current post.
*
- * @since 2.1
+ * @since 2.1.0
* @uses $wp_rewrite WP_Rewrite
* @return string The URL to the author's page.
*/
* echo (boolean) (true): Set to false to return the output, instead of echoing.
*
* @link http://codex.wordpress.org/Template_Tags/wp_list_authors
- * @since 1.2
+ * @since 1.2.0
* @param array $args The argument array.
* @return null|string The output, if echo is set to false.
*/
$link .= ' ';
if (empty($feed_image))
$link .= '(';
- $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';
+ $link .= '<a href="' . get_author_feed_link($author->ID) . '"';
if ( !empty($feed) ) {
$title = ' title="' . $feed . '"';
*/
/**
- * The formatted output of a list of bookmarks
+ * The formatted output of a list of bookmarks.
*
* The $bookmarks array must contain bookmark objects and will be iterated over
* to retrieve the bookmark to be used in the output.
* of the bookmark.
* 'show_images' - Default is 1 (integer). Whether to show link image if
* available.
+ * 'show_name' - Default is 0 (integer). Whether to show link name if
+ * available.
* 'before' - Default is '<li>' (string). The html or text to prepend to each
* bookmarks.
* 'after' - Default is '</li>' (string). The html or text to append to each
* bookmarks.
+ * 'link_before' - Default is '' (string). The html or text to prepend to each
+ * bookmarks inside the <a> tag.
+ * 'link_after' - Default is '' (string). The html or text to append to each
+ * bookmarks inside the <a> tag.
* 'between' - Default is '\n' (string). The string for use in between the link,
* description, and image.
* 'show_rating' - Default is 0 (integer). Whether to show the link rating.
*
- * @since 2.1
+ * @since 2.1.0
* @access private
* @usedby wp_list_bookmarks()
*
function _walk_bookmarks($bookmarks, $args = '' ) {
$defaults = array(
'show_updated' => 0, 'show_description' => 0,
- 'show_images' => 1, 'before' => '<li>',
- 'after' => '</li>', 'between' => "\n",
- 'show_rating' => 0
+ 'show_images' => 1, 'show_name' => 0,
+ 'before' => '<li>', 'after' => '</li>', 'between' => "\n",
+ 'show_rating' => 0, 'link_before' => '', 'link_after' => ''
);
$r = wp_parse_args( $args, $defaults );
$output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
+ $output .= $link_before;
+
if ( $bookmark->link_image != null && $show_images ) {
if ( strpos($bookmark->link_image, 'http') !== false )
$output .= "<img src=\"$bookmark->link_image\" $alt $title />";
else // If it's a relative path
$output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />";
+
+ if ($show_name) $output .= $name;
} else {
$output .= $name;
}
+ $output .= $link_after;
+
$output .= '</a>';
if ( $show_updated && $bookmark->recently_updated )
$output .= $between . $desc;
if ($show_rating) {
- $output .= $between . get_linkrating($bookmark);
+ $output .= $between . sanitize_bookmark_field('link_rating', $bookmark->link_rating, $bookmark->link_id, 'display');
}
$output .= "$after\n";
}
/**
- * Retrieve or echo all of the bookmarks
+ * Retrieve or echo all of the bookmarks.
*
* List of default arguments are as follows:
* 'orderby' - Default is 'name' (string). How to order the links by. String is
* passed to get_bookmarks().
* @link http://codex.wordpress.org/Template_Tags/wp_list_bookmarks
*
- * @since 2.1
+ * @since 2.1.0
* @uses _list_bookmarks() Used to iterate over all of the bookmarks and return
* the html
* @uses get_terms() Gets all of the categories that are for links.
echo $output;
}
-?>
\ No newline at end of file
+?>
/**
* Retrieve Bookmark data based on ID
*
- * @since 2.1
+ * @since 2.1.0
* @uses $wpdb Database Object
*
* @param int $bookmark_id
* @param string $filter Optional, default is 'raw'.
* @return array|object Type returned depends on $output value.
*/
-function get_bookmark($bookmark_id, $output = OBJECT, $filter = 'raw') {
+function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw') {
global $wpdb;
- $link = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark_id));
- $link->link_category = array_unique( wp_get_object_terms($link->link_id, 'link_category', 'fields=ids') );
+ if ( empty($bookmark) ) {
+ if ( isset($GLOBALS['link']) )
+ $_bookmark = & $GLOBALS['link'];
+ else
+ $_bookmark = null;
+ } elseif ( is_object($bookmark) ) {
+ wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
+ $_bookmark = $bookmark;
+ } else {
+ if ( isset($GLOBALS['link']) && ($GLOBALS['link']->link_id == $bookmark) ) {
+ $_bookmark = & $GLOBALS['link'];
+ } elseif ( ! $_bookmark = wp_cache_get($bookmark, 'bookmark') ) {
+ $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark));
+ $_bookmark->link_category = array_unique( wp_get_object_terms($_bookmark->link_id, 'link_category', 'fields=ids') );
+ wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
+ }
+ }
- $link = sanitize_bookmark($link, $filter);
+ $_bookmark = sanitize_bookmark($_bookmark, $filter);
if ( $output == OBJECT ) {
- return $link;
+ return $_bookmark;
} elseif ( $output == ARRAY_A ) {
- return get_object_vars($link);
+ return get_object_vars($_bookmark);
} elseif ( $output == ARRAY_N ) {
- return array_values(get_object_vars($link));
+ return array_values(get_object_vars($_bookmark));
} else {
- return $link;
+ return $_bookmark;
}
}
/**
* Retrieve single bookmark data item or field.
*
- * @since 2.3
+ * @since 2.3.0
* @uses get_bookmark() Gets bookmark object using $bookmark as ID
* @uses sanitize_bookmark_field() Sanitizes Bookmark field based on $context.
*
/**
* Retrieve bookmark data based on ID.
*
- * @since 2.0
+ * @since 2.0.0
* @deprecated Use get_bookmark()
* @see get_bookmark()
*
* 'exclude' - Default is empty string (string). Exclude other categories
* separated by commas.
*
- * @since 2.1
+ * @since 2.1.0
* @uses $wpdb Database Object
* @link http://codex.wordpress.org/Template_Tags/get_bookmarks
*
/**
* Sanitizes all bookmark fields
*
- * @since 2.3
+ * @since 2.3.0
*
* @param object|array $bookmark Bookmark row
* @param string $context Optional, default is 'display'. How to filter the
'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_updated',
'link_rel', 'link_notes', 'link_rss', );
- $do_object = false;
- if ( is_object($bookmark) )
+ if ( is_object($bookmark) ) {
$do_object = true;
+ $link_id = $bookmark->link_id;
+ } else {
+ $do_object = false;
+ $link_id = $bookmark['link_id'];
+ }
foreach ( $fields as $field ) {
- if ( $do_object )
- $bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context);
- else
- $bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $bookmark['link_id'], $context);
+ if ( $do_object ) {
+ if ( isset($bookmark->$field) )
+ $bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $link_id, $context);
+ } else {
+ if ( isset($bookmark[$field]) )
+ $bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $link_id, $context);
+ }
}
return $bookmark;
* $field has the filter name and is passed the $value, $bookmark_id, and
* $context respectively.
*
- * @since 2.3
+ * @since 2.3.0
*
* @param string $field The bookmark field
* @param mixed $value The bookmark field value
}
/**
- * Deletes entire bookmark cache
+ * Deletes bookmark cache
*
- * @since 2.1
+ * @since 2.7.0
* @uses wp_cache_delete() Deletes the contents of 'get_bookmarks'
*/
-function delete_get_bookmark_cache() {
+function clean_bookmark_cache($bookmark_id) {
+ wp_cache_delete( $bookmark_id, 'bookmark' );
wp_cache_delete( 'get_bookmarks', 'bookmark' );
}
-add_action( 'add_link', 'delete_get_bookmark_cache' );
-add_action( 'edit_link', 'delete_get_bookmark_cache' );
-add_action( 'delete_link', 'delete_get_bookmark_cache' );
?>
/**
* Adds data to the cache, if the cache key doesn't aleady exist.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::add()
*
* does not mean that plugins can't implement this function when they need to
* make sure that the cache is cleaned up after WordPress no longer needs it.
*
- * @since 2.0
+ * @since 2.0.0
*
* @return bool Always returns True
*/
/**
* Removes the cache contents matching ID and flag.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::delete()
*
/**
* Removes all cache items.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::flush()
*
/**
* Retrieves the cache contents from the cache by ID and flag.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::get()
*
/**
* Sets up Object Cache Global and assigns it.
*
- * @since 2.0
+ * @since 2.0.0
* @global WP_Object_Cache $wp_object_cache WordPress Object Cache
*/
function wp_cache_init() {
/**
* Replaces the contents of the cache with new data.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wp_object_cache Object Cache Class
* @see WP_Object_Cache::replace()
*
/**
* Adds a group or set of groups to the list of global groups.
*
- * @since 2.6
+ * @since 2.6.0
*
* @param string|array $groups A group or an array of groups to add
*/
/**
* Adds a group or set of groups to the list of non-persistent groups.
*
- * @since 2.6
+ * @since 2.6.0
*
* @param string|array $groups A group or an array of groups to add
*/
*
* @var array
* @access private
- * @since 2.0
+ * @since 2.0.0
*/
var $cache = array ();
*
* @var array
* @access private
- * @since 2.0
+ * @since 2.0.0
*/
var $non_existant_objects = array ();
/**
* The amount of times the cache data was already stored in the cache.
*
- * @since 2.5
+ * @since 2.5.0
* @access private
* @var int
*/
*
* @var int
* @access public
- * @since 2.0
+ * @since 2.0.0
*/
var $cache_misses = 0;
* @uses WP_Object_Cache::set Sets the data after the checking the cache
* contents existance.
*
- * @since 2.0
+ * @since 2.0.0
*
* @param int|string $id What to call the contents in the cache
* @param mixed $data The contents to store in the cache
* to false, then nothing will happen. The $force parameter is set to false
* by default.
*
- * On success the group and the id will be added to the
+ * On success the group and the id will be added to the
* $non_existant_objects property in the class.
*
- * @since 2.0
+ * @since 2.0.0
*
* @param int|string $id What the contents in the cache are called
* @param string $group Where the cache contents are grouped
/**
* Clears the object cache of all data
*
- * @since 2.0
+ * @since 2.0.0
*
* @return bool Always returns true
*/
* misses will be incremented and the cache group and ID will be added to
* the nonexistant objects.
*
- * @since 2.0
+ * @since 2.0.0
*
* @param int|string $id What the contents in the cache are called
* @param string $group Where the cache contents are grouped
if (isset ($this->cache[$group][$id])) {
$this->cache_hits += 1;
- return $this->cache[$group][$id];
+ if ( is_object($this->cache[$group][$id]) )
+ return wp_clone($this->cache[$group][$id]);
+ else
+ return $this->cache[$group][$id];
}
if ( isset ($this->non_existant_objects[$group][$id]) )
/**
* Replace the contents in the cache, if contents already exist
*
- * @since 2.0
+ * @since 2.0.0
* @see WP_Object_Cache::set()
*
* @param int|string $id What to call the contents in the cache
* expire for each time a page is accessed and PHP finishes. The method is
* more for cache plugins which use files.
*
- * @since 2.0
+ * @since 2.0.0
*
* @param int|string $id What to call the contents in the cache
* @param mixed $data The contents to store in the cache
if (NULL === $data)
$data = '';
+ if ( is_object($data) )
+ $data = wp_clone($data);
+
$this->cache[$group][$id] = $data;
if(isset($this->non_existant_objects[$group][$id]))
* Gives the cache hits, and cache misses. Also prints every cached group,
* key and the data.
*
- * @since 2.0
+ * @since 2.0.0
*/
function stats() {
echo "<p>";
/**
* PHP4 constructor; Calls PHP 5 style constructor
*
- * @since 2.0
+ * @since 2.0.0
*
* @return WP_Object_Cache
*/
* @author Scott Yang
* @author Mark Jaquith
* @package WordPress
- * @since 2.3
+ * @since 2.3.0
*/
/**
- * Redirects incoming links to the proper URL based on the site url
+ * Redirects incoming links to the proper URL based on the site url.
*
* Search engines consider www.somedomain.com and somedomain.com to be two
* different URLs when they both go to the same location. This SEO enhancement
* not exist based on exact WordPress query. Will instead try to parse the URL
* or query in an attempt to figure the correct page to go to.
*
- * @since 2.3
+ * @since 2.3.0
* @uses $wp_rewrite
* @uses $is_IIS
*
* not needed or the string of the URL
*/
function redirect_canonical($requested_url=null, $do_redirect=true) {
- global $wp_rewrite, $is_IIS;
+ global $wp_rewrite, $is_IIS, $wp_query, $wpdb;
- if ( is_feed() || is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() )
+ if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() )
return;
if ( !$requested_url ) {
// build the URL in the address bar
- $requested_url = ( isset($_SERVER['HTTPS'] ) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
+ $requested_url = ( !empty($_SERVER['HTTPS'] ) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
$requested_url .= $_SERVER['HTTP_HOST'];
$requested_url .= $_SERVER['REQUEST_URI'];
}
return;
// Some PHP setups turn requests for / into /index.php in REQUEST_URI
- $original['path'] = preg_replace('|/index\.php$|', '/', $original['path']);
+ // See: http://trac.wordpress.org/ticket/5017
+ // See: http://trac.wordpress.org/ticket/7173
+ // Disabled, for now:
+ // $original['path'] = preg_replace('|/index\.php$|', '/', $original['path']);
$redirect = $original;
$redirect_url = false;
+ // Notice fixing
+ if ( !isset($redirect['path']) ) $redirect['path'] = '';
+ if ( !isset($redirect['query']) ) $redirect['query'] = '';
+
+ if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) {
+
+ $vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) );
+
+ if ( isset($vars[0]) && $vars = $vars[0] ) {
+ if ( 'revision' == $vars->post_type && $vars->post_parent > 0 )
+ $id = $vars->post_parent;
+
+ if ( $redirect_url = get_permalink($id) )
+ $redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id'), $redirect['query']);
+ }
+ }
+
// These tests give us a WP-generated permalink
if ( is_404() ) {
$redirect_url = redirect_guess_404_permalink();
} elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
- if ( is_single() && isset($_GET['p']) ) {
+ if ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
if ( $redirect_url = get_permalink(get_query_var('p')) )
$redirect['query'] = remove_query_arg('p', $redirect['query']);
- } elseif ( is_page() && isset($_GET['page_id']) ) {
+ if ( get_query_var( 'page' ) ) {
+ $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
+ $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
+ }
+ } elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
if ( $redirect_url = get_permalink(get_query_var('page_id')) )
$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
- } elseif ( isset($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {
+ } elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {
$m = get_query_var('m');
switch ( strlen($m) ) {
case 4: // Yearly
if ( $redirect_url )
$redirect['query'] = remove_query_arg('m', $redirect['query']);
// now moving on to non ?m=X year/month/day links
- } elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && isset($_GET['day']) ) {
+ } elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day']) ) {
if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) )
$redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']);
- } elseif ( is_month() && get_query_var('year') && isset($_GET['monthnum']) ) {
+ } elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) {
if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) )
$redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']);
- } elseif ( is_year() && isset($_GET['year']) ) {
+ } elseif ( is_year() && !empty($_GET['year']) ) {
if ( $redirect_url = get_year_link(get_query_var('year')) )
$redirect['query'] = remove_query_arg('year', $redirect['query']);
- } elseif ( is_category() && isset($_GET['cat']) ) {
+ } elseif ( is_category() && !empty($_GET['cat']) && preg_match( '|^[0-9]+$|', $_GET['cat'] ) ) {
if ( $redirect_url = get_category_link(get_query_var('cat')) )
$redirect['query'] = remove_query_arg('cat', $redirect['query']);
- } elseif ( is_author() && isset($_GET['author']) ) {
+ } elseif ( is_author() && !empty($_GET['author']) ) {
$author = get_userdata(get_query_var('author'));
- if ( false !== $author && $redirect_url = get_author_link(false, $author->ID, $author->user_nicename) )
+ if ( false !== $author && $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) )
$redirect['query'] = remove_query_arg('author', $redirect['author']);
}
- // paging
- if ( $paged = get_query_var('paged') ) {
- if ( $paged > 0 ) {
- if ( !$redirect_url )
- $redirect_url = $requested_url;
- $paged_redirect = @parse_url($redirect_url);
- $paged_redirect['path'] = preg_replace('|/page/[0-9]+?(/+)?$|', '/', $paged_redirect['path']); // strip off any existing paging
- $paged_redirect['path'] = preg_replace('|/index.php/?$|', '/', $paged_redirect['path']); // strip off trailing /index.php/
- if ( $paged > 1 && !is_single() ) {
- $paged_redirect['path'] = trailingslashit($paged_redirect['path']);
- if ( $wp_rewrite->using_index_permalinks() && strpos($paged_redirect['path'], '/index.php/') === false )
- $paged_redirect['path'] .= 'index.php/';
- $paged_redirect['path'] .= user_trailingslashit("page/$paged", 'paged');
- } elseif ( !is_home() && !is_single() ){
- $paged_redirect['path'] = user_trailingslashit($paged_redirect['path'], 'paged');
+ // paging and feeds
+ if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
+ if ( !$redirect_url )
+ $redirect_url = $requested_url;
+ $paged_redirect = @parse_url($redirect_url);
+ while ( preg_match( '#/page/[0-9]+?(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $paged_redirect['path'] ) ) {
+ // Strip off paging and feed
+ $paged_redirect['path'] = preg_replace('#/page/[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing paging
+ $paged_redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $paged_redirect['path']); // strip off feed endings
+ $paged_redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing comment paging
+ }
+
+ $addl_path = '';
+ if ( is_feed() ) {
+ $addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
+ if ( get_query_var( 'withcomments' ) )
+ $addl_path .= 'comments/';
+ $addl_path .= user_trailingslashit( 'feed/' . ( ( 'rss2' == get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' );
+ $redirect['query'] = remove_query_arg( 'feed', $redirect['query'] );
+ }
+
+ if ( get_query_var('paged') > 0 ) {
+ $paged = get_query_var('paged');
+ $redirect['query'] = remove_query_arg( 'paged', $redirect['query'] );
+ if ( !is_feed() ) {
+ if ( $paged > 1 && !is_single() ) {
+ $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("page/$paged", 'paged');
+ } elseif ( !is_single() ) {
+ $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit($paged_redirect['path'], 'paged');
+ }
+ } elseif ( $paged > 1 ) {
+ $redirect['query'] = add_query_arg( 'paged', $paged, $redirect['query'] );
}
- $redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path'];
- $redirect['path'] = $paged_redirect['path'];
}
- $redirect['query'] = remove_query_arg('paged', $redirect['query']);
+
+ if ( get_option('page_comments') && ( ( 'newest' == get_option('default_comments_page') && get_query_var('cpage') > 0 ) || ( 'newest' != get_option('default_comments_page') && get_query_var('cpage') > 1 ) ) ) {
+ $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( 'comment-page-' . get_query_var('cpage'), 'commentpaged' );
+ $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] );
+ }
+
+ $paged_redirect['path'] = user_trailingslashit( preg_replace('|/index.php/?$|', '/', $paged_redirect['path']) ); // strip off trailing /index.php/
+ if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($paged_redirect['path'], '/index.php/') === false )
+ $paged_redirect['path'] = trailingslashit($paged_redirect['path']) . 'index.php/';
+ if ( !empty( $addl_path ) )
+ $paged_redirect['path'] = trailingslashit($paged_redirect['path']) . $addl_path;
+ $redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path'];
+ $redirect['path'] = $paged_redirect['path'];
}
}
// tack on any additional query vars
- if ( $redirect_url && $redirect['query'] ) {
+ $redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
+ if ( $redirect_url && !empty($redirect['query']) ) {
if ( strpos($redirect_url, '?') !== false )
$redirect_url .= '&';
else
// www.example.com vs example.com
$user_home = @parse_url(get_option('home'));
- if ( isset($user_home['host']) )
+ if ( !empty($user_home['host']) )
$redirect['host'] = $user_home['host'];
+ if ( empty($user_home['path']) )
+ $user_home['path'] = '/';
// Handle ports
- if ( isset($user_home['port']) )
+ if ( !empty($user_home['port']) )
$redirect['port'] = $user_home['port'];
else
unset($redirect['port']);
- // trailing /index.php/
- $redirect['path'] = preg_replace('|/index.php/$|', '/', $redirect['path']);
+ // trailing /index.php
+ $redirect['path'] = preg_replace('|/index.php/*?$|', '/', $redirect['path']);
+
+ // Remove trailing spaces from the path
+ $redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] );
+
+ if ( !empty( $redirect['query'] ) ) {
+ // Remove trailing spaces from certain terminating query string args
+ $redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] );
+
+ // Clean up empty query strings
+ $redirect['query'] = trim(preg_replace( '#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&');
+
+ // Remove redundant leading ampersands
+ $redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
+ }
// strip /index.php/ when we're not using PATHINFO permalinks
if ( !$wp_rewrite->using_index_permalinks() )
$redirect['path'] = str_replace('/index.php/', '/', $redirect['path']);
// trailing slashes
- if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_home() || ( is_home() && (get_query_var('paged') > 1) ) ) ) {
+ if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || ( is_front_page() && (get_query_var('paged') > 1) ) ) ) {
$user_ts_type = '';
if ( get_query_var('paged') > 0 ) {
$user_ts_type = 'paged';
} else {
- foreach ( array('single', 'category', 'page', 'day', 'month', 'year') as $type ) {
+ foreach ( array('single', 'category', 'page', 'day', 'month', 'year', 'home') as $type ) {
$func = 'is_' . $type;
if ( call_user_func($func) ) {
$user_ts_type = $type;
}
}
$redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type);
- } elseif ( is_home() ) {
+ } elseif ( is_front_page() ) {
$redirect['path'] = trailingslashit($redirect['path']);
}
- // Always trailing slash the 'home' URL
- if ( $redirect['path'] == $user_home['path'] )
+ // Always trailing slash the Front Page URL
+ if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) )
$redirect['path'] = trailingslashit($redirect['path']);
// Ignore differences in host capitalization, as this can lead to infinite redirects
- if ( strtolower($original['host']) == strtolower($redirect['host']) )
+ // Only redirect no-www <=> yes-www
+ if ( strtolower($original['host']) == strtolower($redirect['host']) ||
+ ( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) )
$redirect['host'] = $original['host'];
- if ( array($original['host'], $original['port'], $original['path'], $original['query']) !== array($redirect['host'], $redirect['port'], $redirect['path'], $redirect['query']) ) {
+ $compare_original = array($original['host'], $original['path']);
+
+ if ( !empty( $original['port'] ) )
+ $compare_original[] = $original['port'];
+
+ if ( !empty( $original['query'] ) )
+ $compare_original[] = $original['query'];
+
+ $compare_redirect = array($redirect['host'], $redirect['path']);
+
+ if ( !empty( $redirect['port'] ) )
+ $compare_redirect[] = $redirect['port'];
+
+ if ( !empty( $redirect['query'] ) )
+ $compare_redirect[] = $redirect['query'];
+
+ if ( $compare_original !== $compare_redirect ) {
$redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
- if ( isset($redirect['port']) )
- $redirect_url .= ':' . $redirect['port'];
+ if ( !empty($redirect['port']) )
+ $redirect_url .= ':' . $redirect['port'];
$redirect_url .= $redirect['path'];
- if ( $redirect['query'] )
+ if ( !empty($redirect['query']) )
$redirect_url .= '?' . $redirect['query'];
}
if ( !$redirect_url || $redirect_url == $requested_url )
- return false;
+ return false;
// Note that you can use the "redirect_canonical" filter to cancel a canonical redirect for whatever reason by returning FALSE
$redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
if ( !$redirect_url || $redirect_url == $requested_url ) // yes, again -- in case the filter aborted the request
- return false;
+ return false;
if ( $do_redirect ) {
// protect against chained redirects
wp_redirect($redirect_url, 301);
exit();
} else {
+ // Debug
+ // die("1: $redirect_url<br />2: " . redirect_canonical( $redirect_url, false ) );
return false;
}
} else {
}
/**
- * Attempts to guess correct post based on query vars
+ * Attempts to guess correct post based on query vars.
*
- * @since 2.3
+ * @since 2.3.0
* @uses $wpdb
*
* @return bool|string Returns False, if it can't find post, returns correct
*/
function redirect_guess_404_permalink() {
global $wpdb;
+
if ( !get_query_var('name') )
return false;
<?php
-
+/**
+ * WordPress Roles and Capabilities.
+ *
+ * @package WordPress
+ * @subpackage User
+ */
+
+/**
+ * WordPress User Roles.
+ *
+ * The role option is simple, the structure is organized by role name that store
+ * the name in value of the 'name' key. The capabilities are stored as an array
+ * in the value of the 'capability' key.
+ *
+ * <code>
+ * array (
+ * 'rolename' => array (
+ * 'name' => 'rolename',
+ * 'capabilities' => array()
+ * )
+ * )
+ * </code>
+ *
+ * @since 2.0.0
+ * @package WordPress
+ * @subpackage User
+ */
class WP_Roles {
+ /**
+ * List of roles and capabilities.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var array
+ */
var $roles;
+ /**
+ * List of the role objects.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var array
+ */
var $role_objects = array();
+
+ /**
+ * List of role names.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var array
+ */
var $role_names = array();
+
+ /**
+ * Option name for storing role list.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var string
+ */
var $role_key;
+
+ /**
+ * Whether to use the database for retrieval and storage.
+ *
+ * @since 2.1.0
+ * @access public
+ * @var bool
+ */
var $use_db = true;
+ /**
+ * PHP4 Constructor - Call {@link WP_Roles::_init()} method.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @return WP_Roles
+ */
function WP_Roles() {
$this->_init();
}
+ /**
+ * Setup the object properties.
+ *
+ * The role key is set to the current prefix for the $wpdb object with
+ * 'user_roles' appended. If the $wp_user_roles global is set, then it will
+ * be used and the role option will not be updated or used.
+ *
+ * @since 2.1.0
+ * @access protected
+ * @uses $wpdb Used to get the database prefix.
+ * @global array $wp_user_roles Used to set the 'roles' property value.
+ */
function _init () {
global $wpdb;
global $wp_user_roles;
$this->role_key = $wpdb->prefix . 'user_roles';
- if ( ! empty($wp_user_roles) ) {
+ if ( ! empty( $wp_user_roles ) ) {
$this->roles = $wp_user_roles;
$this->use_db = false;
} else {
- $this->roles = get_option($this->role_key);
+ $this->roles = get_option( $this->role_key );
}
- if ( empty($this->roles) )
+ if ( empty( $this->roles ) )
return;
$this->role_objects = array();
$this->role_names = array();
- foreach ($this->roles as $role => $data) {
- $this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']);
+ foreach ( (array) $this->roles as $role => $data ) {
+ $this->role_objects[$role] = new WP_Role( $role, $this->roles[$role]['capabilities'] );
$this->role_names[$role] = $this->roles[$role]['name'];
}
}
- function add_role($role, $display_name, $capabilities = array()) {
- if ( isset($this->roles[$role]) )
+ /**
+ * Add role name with capabilities to list.
+ *
+ * Updates the list of roles, if the role doesn't already exist.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $role Role name.
+ * @param string $display_name Role display name.
+ * @param array $capabilities List of role capabilities.
+ * @return null|WP_Role WP_Role object if role is added, null if already exists.
+ */
+ function add_role( $role, $display_name, $capabilities = array() ) {
+ if ( isset( $this->roles[$role] ) )
return;
$this->roles[$role] = array(
'name' => $display_name,
- 'capabilities' => $capabilities);
+ 'capabilities' => $capabilities
+ );
if ( $this->use_db )
- update_option($this->role_key, $this->roles);
- $this->role_objects[$role] = new WP_Role($role, $capabilities);
+ update_option( $this->role_key, $this->roles );
+ $this->role_objects[$role] = new WP_Role( $role, $capabilities );
$this->role_names[$role] = $display_name;
return $this->role_objects[$role];
}
- function remove_role($role) {
- if ( ! isset($this->role_objects[$role]) )
+ /**
+ * Remove role by name.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $role Role name.
+ */
+ function remove_role( $role ) {
+ if ( ! isset( $this->role_objects[$role] ) )
return;
- unset($this->role_objects[$role]);
- unset($this->role_names[$role]);
- unset($this->roles[$role]);
+ unset( $this->role_objects[$role] );
+ unset( $this->role_names[$role] );
+ unset( $this->roles[$role] );
if ( $this->use_db )
- update_option($this->role_key, $this->roles);
+ update_option( $this->role_key, $this->roles );
}
- function add_cap($role, $cap, $grant = true) {
+ /**
+ * Add capability to role.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $role Role name.
+ * @param string $cap Capability name.
+ * @param bool $grant Optional, default is true. Whether role is capable of preforming capability.
+ */
+ function add_cap( $role, $cap, $grant = true ) {
$this->roles[$role]['capabilities'][$cap] = $grant;
if ( $this->use_db )
- update_option($this->role_key, $this->roles);
+ update_option( $this->role_key, $this->roles );
}
- function remove_cap($role, $cap) {
- unset($this->roles[$role]['capabilities'][$cap]);
+ /**
+ * Remove capability from role.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $role Role name.
+ * @param string $cap Capability name.
+ */
+ function remove_cap( $role, $cap ) {
+ unset( $this->roles[$role]['capabilities'][$cap] );
if ( $this->use_db )
- update_option($this->role_key, $this->roles);
+ update_option( $this->role_key, $this->roles );
}
- function &get_role($role) {
- if ( isset($this->role_objects[$role]) )
+ /**
+ * Retrieve role object by name.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $role Role name.
+ * @return object|null Null, if role does not exist. WP_Role object, if found.
+ */
+ function &get_role( $role ) {
+ if ( isset( $this->role_objects[$role] ) )
return $this->role_objects[$role];
else
return null;
}
+ /**
+ * Retrieve list of role names.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @return array List of role names.
+ */
function get_names() {
return $this->role_names;
}
- function is_role($role)
+ /**
+ * Whether role name is currently in the list of available roles.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $role Role name to look up.
+ * @return bool
+ */
+ function is_role( $role )
{
- return isset($this->role_names[$role]);
+ return isset( $this->role_names[$role] );
}
}
+/**
+ * WordPress Role class.
+ *
+ * @since 2.0.0
+ * @package WordPress
+ * @subpackage User
+ */
class WP_Role {
+ /**
+ * Role name.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var string
+ */
var $name;
+
+ /**
+ * List of capabilities the role contains.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var array
+ */
var $capabilities;
- function WP_Role($role, $capabilities) {
+ /**
+ * PHP4 Constructor - Setup object properties.
+ *
+ * The list of capabilities, must have the key as the name of the capability
+ * and the value a boolean of whether it is granted to the role or not.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $role Role name.
+ * @param array $capabilities List of capabilities.
+ * @return WP_Role
+ */
+ function WP_Role( $role, $capabilities ) {
$this->name = $role;
$this->capabilities = $capabilities;
}
- function add_cap($cap, $grant = true) {
+ /**
+ * Assign role a capability.
+ *
+ * @see WP_Roles::add_cap() Method uses implementation for role.
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $cap Capability name.
+ * @param bool $grant Whether role has capability privilege.
+ */
+ function add_cap( $cap, $grant = true ) {
global $wp_roles;
- if ( ! isset($wp_roles) )
+ if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
$this->capabilities[$cap] = $grant;
- $wp_roles->add_cap($this->name, $cap, $grant);
+ $wp_roles->add_cap( $this->name, $cap, $grant );
}
- function remove_cap($cap) {
+ /**
+ * Remove capability from role.
+ *
+ * This is a container for {@link WP_Roles::remove_cap()} to remove the
+ * capability from the role. That is to say, that {@link
+ * WP_Roles::remove_cap()} implements the functionality, but it also makes
+ * sense to use this class, because you don't need to enter the role name.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $cap Capability name.
+ */
+ function remove_cap( $cap ) {
global $wp_roles;
- if ( ! isset($wp_roles) )
+ if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
- unset($this->capabilities[$cap]);
- $wp_roles->remove_cap($this->name, $cap);
+ unset( $this->capabilities[$cap] );
+ $wp_roles->remove_cap( $this->name, $cap );
}
- function has_cap($cap) {
- $capabilities = apply_filters('role_has_cap', $this->capabilities, $cap, $this->name);
- if ( !empty($capabilities[$cap]) )
+ /**
+ * Whether role has capability.
+ *
+ * The capabilities is passed through the 'role_has_cap' filter. The first
+ * parameter for the hook is the list of capabilities the class has
+ * assigned. The second parameter is the capability name to look for. The
+ * third and final parameter for the hook is the role name.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $cap Capability name.
+ * @return bool True, if user has capability. False, if doesn't have capability.
+ */
+ function has_cap( $cap ) {
+ $capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name );
+ if ( !empty( $capabilities[$cap] ) )
return $capabilities[$cap];
else
return false;
}
+/**
+ * WordPress User class.
+ *
+ * @since 2.0.0
+ * @package WordPress
+ * @subpackage User
+ */
class WP_User {
+ /**
+ * User data container.
+ *
+ * This will be set as properties of the object.
+ *
+ * @since 2.0.0
+ * @access private
+ * @var array
+ */
var $data;
+
+ /**
+ * The user's ID.
+ *
+ * @since 2.1.0
+ * @access public
+ * @var int
+ */
var $ID = 0;
- var $id = 0; // Deprecated, use $ID instead.
+
+ /**
+ * The deprecated user's ID.
+ *
+ * @since 2.0.0
+ * @access public
+ * @deprecated Use WP_User::$ID
+ * @see WP_User::$ID
+ * @var int
+ */
+ var $id = 0;
+
+ /**
+ * The individual capabilities the user has been given.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var array
+ */
var $caps = array();
+
+ /**
+ * User metadata option name.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var string
+ */
var $cap_key;
+
+ /**
+ * The roles the user is part of.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var array
+ */
var $roles = array();
- var $allcaps = array();
- function WP_User($id, $name = '') {
+ /**
+ * All capabilities the user has, including individual and role based.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var array
+ */
+ var $allcaps = array();
- if ( empty($id) && empty($name) )
+ /**
+ * First name of the user.
+ *
+ * Created to prevent notices.
+ *
+ * @since 2.7.0
+ * @access public
+ * @var string
+ */
+ var $first_name = '';
+
+ /**
+ * Last name of the user.
+ *
+ * Created to prevent notices.
+ *
+ * @since 2.7.0
+ * @access public
+ * @var string
+ */
+ var $last_name = '';
+
+ /**
+ * PHP4 Constructor - Sets up the object properties.
+ *
+ * Retrieves the userdata and then assigns all of the data keys to direct
+ * properties of the object. Calls {@link WP_User::_init_caps()} after
+ * setting up the object's user data properties.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param int|string $id User's ID or username
+ * @param int $name Optional. User's username
+ * @return WP_User
+ */
+ function WP_User( $id, $name = '' ) {
+
+ if ( empty( $id ) && empty( $name ) )
return;
- if ( ! is_numeric($id) ) {
+ if ( ! is_numeric( $id ) ) {
$name = $id;
$id = 0;
}
- if ( ! empty($id) )
- $this->data = get_userdata($id);
+ if ( ! empty( $id ) )
+ $this->data = get_userdata( $id );
else
- $this->data = get_userdatabylogin($name);
+ $this->data = get_userdatabylogin( $name );
- if ( empty($this->data->ID) )
+ if ( empty( $this->data->ID ) )
return;
- foreach (get_object_vars($this->data) as $key => $value) {
+ foreach ( get_object_vars( $this->data ) as $key => $value ) {
$this->{$key} = $value;
}
$this->_init_caps();
}
+ /**
+ * Setup capability object properties.
+ *
+ * Will set the value for the 'cap_key' property to current database table
+ * prefix, followed by 'capabilities'. Will then check to see if the
+ * property matching the 'cap_key' exists and is an array. If so, it will be
+ * used.
+ *
+ * @since 2.1.0
+ * @access protected
+ */
function _init_caps() {
global $wpdb;
$this->cap_key = $wpdb->prefix . 'capabilities';
$this->caps = &$this->{$this->cap_key};
- if ( ! is_array($this->caps) )
+ if ( ! is_array( $this->caps ) )
$this->caps = array();
$this->get_role_caps();
}
+ /**
+ * Retrieve all of the role capabilities and merge with individual capabilities.
+ *
+ * All of the capabilities of the roles the user belongs to are merged with
+ * the users individual roles. This also means that the user can be denied
+ * specific roles that their role might have, but the specific user isn't
+ * granted permission to.
+ *
+ * @since 2.0.0
+ * @uses $wp_roles
+ * @access public
+ */
function get_role_caps() {
global $wp_roles;
- if ( ! isset($wp_roles) )
+ if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
//Filter out caps that are not role names and assign to $this->roles
- if(is_array($this->caps))
- $this->roles = array_filter(array_keys($this->caps), array(&$wp_roles, 'is_role'));
+ if ( is_array( $this->caps ) )
+ $this->roles = array_filter( array_keys( $this->caps ), array( &$wp_roles, 'is_role' ) );
//Build $allcaps from role caps, overlay user's $caps
$this->allcaps = array();
- foreach( (array) $this->roles as $role) {
- $role = $wp_roles->get_role($role);
- $this->allcaps = array_merge($this->allcaps, $role->capabilities);
+ foreach ( (array) $this->roles as $role ) {
+ $role =& $wp_roles->get_role( $role );
+ $this->allcaps = array_merge( $this->allcaps, $role->capabilities );
}
- $this->allcaps = array_merge($this->allcaps, $this->caps);
+ $this->allcaps = array_merge( $this->allcaps, $this->caps );
}
- function add_role($role) {
+ /**
+ * Add role to user.
+ *
+ * Updates the user's meta data option with capabilities and roles.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $role Role name.
+ */
+ function add_role( $role ) {
$this->caps[$role] = true;
- update_usermeta($this->ID, $this->cap_key, $this->caps);
+ update_usermeta( $this->ID, $this->cap_key, $this->caps );
$this->get_role_caps();
$this->update_user_level_from_caps();
}
- function remove_role($role) {
- if ( empty($this->roles[$role]) || (count($this->roles) <= 1) )
+ /**
+ * Remove role from user.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $role Role name.
+ */
+ function remove_role( $role ) {
+ if ( empty( $this->roles[$role] ) || ( count( $this->roles ) <= 1 ) )
return;
- unset($this->caps[$role]);
- update_usermeta($this->ID, $this->cap_key, $this->caps);
+ unset( $this->caps[$role] );
+ update_usermeta( $this->ID, $this->cap_key, $this->caps );
$this->get_role_caps();
}
- function set_role($role) {
- foreach($this->roles as $oldrole)
- unset($this->caps[$oldrole]);
- if ( !empty($role) ) {
+ /**
+ * Set the role of the user.
+ *
+ * This will remove the previous roles of the user and assign the user the
+ * new one. You can set the role to an empty string and it will remove all
+ * of the roles from the user.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $role Role name.
+ */
+ function set_role( $role ) {
+ foreach ( (array) $this->roles as $oldrole )
+ unset( $this->caps[$oldrole] );
+ if ( !empty( $role ) ) {
$this->caps[$role] = true;
- $this->roles = array($role => true);
+ $this->roles = array( $role => true );
} else {
$this->roles = false;
}
- update_usermeta($this->ID, $this->cap_key, $this->caps);
+ update_usermeta( $this->ID, $this->cap_key, $this->caps );
$this->get_role_caps();
$this->update_user_level_from_caps();
}
- function level_reduction($max, $item) {
- if(preg_match('/^level_(10|[0-9])$/i', $item, $matches)) {
- $level = intval($matches[1]);
- return max($max, $level);
+ /**
+ * Choose the maximum level the user has.
+ *
+ * Will compare the level from the $item parameter against the $max
+ * parameter. If the item is incorrect, then just the $max parameter value
+ * will be returned.
+ *
+ * Used to get the max level based on the capabilities the user has. This
+ * is also based on roles, so if the user is assigned the Administrator role
+ * then the capability 'level_10' will exist and the user will get that
+ * value.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param int $max Max level of user.
+ * @param string $item Level capability name.
+ * @return int Max Level.
+ */
+ function level_reduction( $max, $item ) {
+ if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) {
+ $level = intval( $matches[1] );
+ return max( $max, $level );
} else {
return $max;
}
}
+ /**
+ * Update the maximum user level for the user.
+ *
+ * Updates the 'user_level' user metadata (includes prefix that is the
+ * database table prefix) with the maximum user level. Gets the value from
+ * the all of the capabilities that the user has.
+ *
+ * @since 2.0.0
+ * @access public
+ */
function update_user_level_from_caps() {
global $wpdb;
- $this->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0);
- update_usermeta($this->ID, $wpdb->prefix.'user_level', $this->user_level);
+ $this->user_level = array_reduce( array_keys( $this->allcaps ), array( &$this, 'level_reduction' ), 0 );
+ update_usermeta( $this->ID, $wpdb->prefix.'user_level', $this->user_level );
}
- function add_cap($cap, $grant = true) {
+ /**
+ * Add capability and grant or deny access to capability.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $cap Capability name.
+ * @param bool $grant Whether to grant capability to user.
+ */
+ function add_cap( $cap, $grant = true ) {
$this->caps[$cap] = $grant;
- update_usermeta($this->ID, $this->cap_key, $this->caps);
+ update_usermeta( $this->ID, $this->cap_key, $this->caps );
}
- function remove_cap($cap) {
- if ( empty($this->caps[$cap]) ) return;
- unset($this->caps[$cap]);
- update_usermeta($this->ID, $this->cap_key, $this->caps);
+ /**
+ * Remove capability from user.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string $cap Capability name.
+ */
+ function remove_cap( $cap ) {
+ if ( empty( $this->caps[$cap] ) ) return;
+ unset( $this->caps[$cap] );
+ update_usermeta( $this->ID, $this->cap_key, $this->caps );
}
+ /**
+ * Remove all of the capabilities of the user.
+ *
+ * @since 2.1.0
+ * @access public
+ */
function remove_all_caps() {
global $wpdb;
$this->caps = array();
- update_usermeta($this->ID, $this->cap_key, '');
- update_usermeta($this->ID, $wpdb->prefix.'user_level', '');
+ update_usermeta( $this->ID, $this->cap_key, '' );
+ update_usermeta( $this->ID, $wpdb->prefix.'user_level', '' );
$this->get_role_caps();
}
- //has_cap(capability_or_role_name) or
- //has_cap('edit_post', post_id)
- function has_cap($cap) {
- if ( is_numeric($cap) )
- $cap = $this->translate_level_to_cap($cap);
-
- $args = array_slice(func_get_args(), 1);
- $args = array_merge(array($cap, $this->ID), $args);
- $caps = call_user_func_array('map_meta_cap', $args);
+ /**
+ * Whether user has capability or role name.
+ *
+ * This is useful for looking up whether the user has a specific role
+ * assigned to the user. The second optional parameter can also be used to
+ * check for capabilities against a specfic post.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param string|int $cap Capability or role name to search.
+ * @param int $post_id Optional. Post ID to check capability against specific post.
+ * @return bool True, if user has capability; false, if user does not have capability.
+ */
+ function has_cap( $cap ) {
+ if ( is_numeric( $cap ) )
+ $cap = $this->translate_level_to_cap( $cap );
+
+ $args = array_slice( func_get_args(), 1 );
+ $args = array_merge( array( $cap, $this->ID ), $args );
+ $caps = call_user_func_array( 'map_meta_cap', $args );
// Must have ALL requested caps
- $capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args);
- foreach ($caps as $cap) {
+ $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args );
+ foreach ( (array) $caps as $cap ) {
//echo "Checking cap $cap<br />";
- if(empty($capabilities[$cap]) || !$capabilities[$cap])
+ if ( empty( $capabilities[$cap] ) || !$capabilities[$cap] )
return false;
}
return true;
}
- function translate_level_to_cap($level) {
+ /**
+ * Convert numeric level to level capability name.
+ *
+ * Prepends 'level_' to level number.
+ *
+ * @since 2.0.0
+ * @access public
+ *
+ * @param int $level Level number, 1 to 10.
+ * @return string
+ */
+ function translate_level_to_cap( $level ) {
return 'level_' . $level;
}
}
-// Map meta capabilities to primitive capabilities.
-function map_meta_cap($cap, $user_id) {
- $args = array_slice(func_get_args(), 2);
+/**
+ * Map meta capabilities to primitive capabilities.
+ *
+ * This does not actually compare whether the user ID has the actual capability,
+ * just what the capability or capabilities are. Meta capability list value can
+ * be 'delete_user', 'edit_user', 'delete_post', 'delete_page', 'edit_post',
+ * 'edit_page', 'read_post', or 'read_page'.
+ *
+ * @since 2.0.0
+ *
+ * @param string $cap Capability name.
+ * @param int $user_id User ID.
+ * @return array Actual capabilities for meta capability.
+ */
+function map_meta_cap( $cap, $user_id ) {
+ $args = array_slice( func_get_args(), 2 );
$caps = array();
- switch ($cap) {
+ switch ( $cap ) {
case 'delete_user':
$caps[] = 'delete_users';
break;
case 'edit_user':
- if ( !isset($args[0]) || $user_id != $args[0] ) {
+ if ( !isset( $args[0] ) || $user_id != $args[0] ) {
$caps[] = 'edit_users';
}
break;
case 'delete_post':
- $author_data = get_userdata($user_id);
+ $author_data = get_userdata( $user_id );
//echo "post ID: {$args[0]}<br />";
- $post = get_post($args[0]);
+ $post = get_post( $args[0] );
if ( 'page' == $post->post_type ) {
- $args = array_merge(array('delete_page', $user_id), $args);
- return call_user_func_array('map_meta_cap', $args);
+ $args = array_merge( array( 'delete_page', $user_id ), $args );
+ return call_user_func_array( 'map_meta_cap', $args );
}
- $post_author_data = get_userdata($post->post_author);
+ $post_author_data = get_userdata( $post->post_author );
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br />";
// If the user is the author...
- if ($user_id == $post_author_data->ID) {
+ if ( $user_id == $post_author_data->ID ) {
// If the post is published...
- if ($post->post_status == 'publish')
+ if ( 'publish' == $post->post_status )
$caps[] = 'delete_published_posts';
else
// If the post is draft...
// The user is trying to edit someone else's post.
$caps[] = 'delete_others_posts';
// The post is published, extra cap required.
- if ($post->post_status == 'publish')
+ if ( 'publish' == $post->post_status )
$caps[] = 'delete_published_posts';
- else if ($post->post_status == 'private')
+ elseif ( 'private' == $post->post_status )
$caps[] = 'delete_private_posts';
}
break;
case 'delete_page':
- $author_data = get_userdata($user_id);
+ $author_data = get_userdata( $user_id );
//echo "post ID: {$args[0]}<br />";
- $page = get_page($args[0]);
- $page_author_data = get_userdata($page->post_author);
+ $page = get_page( $args[0] );
+ $page_author_data = get_userdata( $page->post_author );
//echo "current user id : $user_id, page author id: " . $page_author_data->ID . "<br />";
// If the user is the author...
- if ($user_id == $page_author_data->ID) {
+ if ( $user_id == $page_author_data->ID ) {
// If the page is published...
- if ($page->post_status == 'publish')
+ if ( $page->post_status == 'publish' )
$caps[] = 'delete_published_pages';
else
// If the page is draft...
// The user is trying to edit someone else's page.
$caps[] = 'delete_others_pages';
// The page is published, extra cap required.
- if ($page->post_status == 'publish')
+ if ( $page->post_status == 'publish' )
$caps[] = 'delete_published_pages';
- else if ($page->post_status == 'private')
+ elseif ( $page->post_status == 'private' )
$caps[] = 'delete_private_pages';
}
break;
// edit_post breaks down to edit_posts, edit_published_posts, or
// edit_others_posts
case 'edit_post':
- $author_data = get_userdata($user_id);
+ $author_data = get_userdata( $user_id );
//echo "post ID: {$args[0]}<br />";
- $post = get_post($args[0]);
+ $post = get_post( $args[0] );
if ( 'page' == $post->post_type ) {
- $args = array_merge(array('edit_page', $user_id), $args);
- return call_user_func_array('map_meta_cap', $args);
+ $args = array_merge( array( 'edit_page', $user_id ), $args );
+ return call_user_func_array( 'map_meta_cap', $args );
}
- $post_author_data = get_userdata($post->post_author);
+ $post_author_data = get_userdata( $post->post_author );
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br />";
// If the user is the author...
- if ($user_id == $post_author_data->ID) {
+ if ( $user_id == $post_author_data->ID ) {
// If the post is published...
- if ($post->post_status == 'publish')
+ if ( 'publish' == $post->post_status )
$caps[] = 'edit_published_posts';
else
// If the post is draft...
// The user is trying to edit someone else's post.
$caps[] = 'edit_others_posts';
// The post is published, extra cap required.
- if ($post->post_status == 'publish')
+ if ( 'publish' == $post->post_status )
$caps[] = 'edit_published_posts';
- else if ($post->post_status == 'private')
+ elseif ( 'private' == $post->post_status )
$caps[] = 'edit_private_posts';
}
break;
case 'edit_page':
- $author_data = get_userdata($user_id);
+ $author_data = get_userdata( $user_id );
//echo "post ID: {$args[0]}<br />";
- $page = get_page($args[0]);
- $page_author_data = get_userdata($page->post_author);
+ $page = get_page( $args[0] );
+ $page_author_data = get_userdata( $page->post_author );
//echo "current user id : $user_id, page author id: " . $page_author_data->ID . "<br />";
// If the user is the author...
- if ($user_id == $page_author_data->ID) {
+ if ( $user_id == $page_author_data->ID ) {
// If the page is published...
- if ($page->post_status == 'publish')
+ if ( 'publish' == $page->post_status )
$caps[] = 'edit_published_pages';
else
// If the page is draft...
// The user is trying to edit someone else's page.
$caps[] = 'edit_others_pages';
// The page is published, extra cap required.
- if ($page->post_status == 'publish')
+ if ( 'publish' == $page->post_status )
$caps[] = 'edit_published_pages';
- else if ($page->post_status == 'private')
+ elseif ( 'private' == $page->post_status )
$caps[] = 'edit_private_pages';
}
break;
case 'read_post':
- $post = get_post($args[0]);
+ $post = get_post( $args[0] );
if ( 'page' == $post->post_type ) {
- $args = array_merge(array('read_page', $user_id), $args);
- return call_user_func_array('map_meta_cap', $args);
+ $args = array_merge( array( 'read_page', $user_id ), $args );
+ return call_user_func_array( 'map_meta_cap', $args );
}
if ( 'private' != $post->post_status ) {
break;
}
- $author_data = get_userdata($user_id);
- $post_author_data = get_userdata($post->post_author);
- if ($user_id == $post_author_data->ID)
+ $author_data = get_userdata( $user_id );
+ $post_author_data = get_userdata( $post->post_author );
+ if ( $user_id == $post_author_data->ID )
$caps[] = 'read';
else
$caps[] = 'read_private_posts';
break;
case 'read_page':
- $page = get_page($args[0]);
+ $page = get_page( $args[0] );
if ( 'private' != $page->post_status ) {
$caps[] = 'read';
break;
}
- $author_data = get_userdata($user_id);
- $page_author_data = get_userdata($page->post_author);
- if ($user_id == $page_author_data->ID)
+ $author_data = get_userdata( $user_id );
+ $page_author_data = get_userdata( $page->post_author );
+ if ( $user_id == $page_author_data->ID )
$caps[] = 'read';
else
$caps[] = 'read_private_pages';
return $caps;
}
-// Capability checking wrapper around the global $current_user object.
-function current_user_can($capability) {
+/**
+ * Whether current user has capability or role.
+ *
+ * @since 2.0.0
+ *
+ * @param string $capability Capability or role name.
+ * @return bool
+ */
+function current_user_can( $capability ) {
$current_user = wp_get_current_user();
- if ( empty($current_user) )
+ if ( empty( $current_user ) )
return false;
- $args = array_slice(func_get_args(), 1);
- $args = array_merge(array($capability), $args);
+ $args = array_slice( func_get_args(), 1 );
+ $args = array_merge( array( $capability ), $args );
- return call_user_func_array(array(&$current_user, 'has_cap'), $args);
+ return call_user_func_array( array( &$current_user, 'has_cap' ), $args );
}
-// Convenience wrappers around $wp_roles.
-function get_role($role) {
+/**
+ * Retrieve role object.
+ *
+ * @see WP_Roles::get_role() Uses method to retrieve role object.
+ * @since 2.0.0
+ *
+ * @param string $role Role name.
+ * @return object
+ */
+function get_role( $role ) {
global $wp_roles;
- if ( ! isset($wp_roles) )
+ if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
- return $wp_roles->get_role($role);
+ return $wp_roles->get_role( $role );
}
-function add_role($role, $display_name, $capabilities = array()) {
+/**
+ * Add role, if it does not exist.
+ *
+ * @see WP_Roles::add_role() Uses method to add role.
+ * @since 2.0.0
+ *
+ * @param string $role Role name.
+ * @param string $display_name Display name for role.
+ * @param array $capabilities List of capabilities.
+ * @return null|WP_Role WP_Role object if role is added, null if already exists.
+ */
+function add_role( $role, $display_name, $capabilities = array() ) {
global $wp_roles;
- if ( ! isset($wp_roles) )
+ if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
- return $wp_roles->add_role($role, $display_name, $capabilities);
+ return $wp_roles->add_role( $role, $display_name, $capabilities );
}
-function remove_role($role) {
+/**
+ * Remove role, if it exists.
+ *
+ * @see WP_Roles::remove_role() Uses method to remove role.
+ * @since 2.0.0
+ *
+ * @param string $role Role name.
+ * @return null
+ */
+function remove_role( $role ) {
global $wp_roles;
- if ( ! isset($wp_roles) )
+ if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
- return $wp_roles->remove_role($role);
+ return $wp_roles->remove_role( $role );
}
?>
<?php
+/**
+ * Category Template Tags and API.
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
-function get_category_children($id, $before = '/', $after = '', $visited=array()) {
+/**
+ * Retrieve category children list separated before and after the term IDs.
+ *
+ * @since 1.2.0
+ *
+ * @param int $id Category ID to retrieve children.
+ * @param string $before Optional. Prepend before category term ID.
+ * @param string $after Optional, default is empty string. Append after category term ID.
+ * @param array $visited Optional. Category Term IDs that have already been added.
+ * @return string
+ */
+function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
if ( 0 == $id )
return '';
$chain = '';
- // TODO: consult hierarchy
+ /** TODO: consult hierarchy */
$cat_ids = get_all_category_ids();
- foreach ( $cat_ids as $cat_id ) {
+ foreach ( (array) $cat_ids as $cat_id ) {
if ( $cat_id == $id )
continue;
- $category = get_category($cat_id);
+ $category = get_category( $cat_id );
if ( is_wp_error( $category ) )
return $category;
- if ( $category->parent == $id && !in_array($category->term_id, $visited) ) {
+ if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) {
$visited[] = $category->term_id;
$chain .= $before.$category->term_id.$after;
- $chain .= get_category_children($category->term_id, $before, $after);
+ $chain .= get_category_children( $category->term_id, $before, $after );
}
}
return $chain;
}
-function get_category_link($category_id) {
+/**
+ * Retrieve category link URL.
+ *
+ * @since 1.0.0
+ * @uses apply_filters() Calls 'category_link' filter on category link and category ID.
+ *
+ * @param int $category_id Category ID.
+ * @return string
+ */
+function get_category_link( $category_id ) {
global $wp_rewrite;
$catlink = $wp_rewrite->get_category_permastruct();
- if ( empty($catlink) ) {
- $file = get_option('home') . '/';
+ if ( empty( $catlink ) ) {
+ $file = get_option( 'home' ) . '/';
$catlink = $file . '?cat=' . $category_id;
} else {
- $category = &get_category($category_id);
+ $category = &get_category( $category_id );
if ( is_wp_error( $category ) )
return $category;
$category_nicename = $category->slug;
- if ( $parent = $category->parent )
- $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename;
+ if ( $category->parent == $category_id ) // recursive recursion
+ $category->parent = 0;
+ elseif ($category->parent != 0 )
+ $category_nicename = get_category_parents( $category->parent, false, '/', true ) . $category_nicename;
- $catlink = str_replace('%category%', $category_nicename, $catlink);
- $catlink = get_option('home') . user_trailingslashit($catlink, 'category');
+ $catlink = str_replace( '%category%', $category_nicename, $catlink );
+ $catlink = get_option( 'home' ) . user_trailingslashit( $catlink, 'category' );
}
- return apply_filters('category_link', $catlink, $category_id);
+ return apply_filters( 'category_link', $catlink, $category_id );
}
-function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE, $visited = array()){
+/**
+ * Retrieve category parents with separator.
+ *
+ * @since 1.2.0
+ *
+ * @param int $id Category ID.
+ * @param bool $link Optional, default is false. Whether to format with link.
+ * @param string $separator Optional, default is '/'. How to separate categories.
+ * @param bool $nicename Optional, default is false. Whether to use nice name for display.
+ * @param array $visited Optional. Already linked to categories to prevent duplicates.
+ * @return string
+ */
+function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) {
$chain = '';
- $parent = &get_category($id);
+ $parent = &get_category( $id );
if ( is_wp_error( $parent ) )
return $parent;
else
$name = $parent->cat_name;
- if ( $parent->parent && ($parent->parent != $parent->term_id) && !in_array($parent->parent, $visited) ) {
+ if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) {
$visited[] = $parent->parent;
- $chain .= get_category_parents($parent->parent, $link, $separator, $nicename, $visited);
+ $chain .= get_category_parents( $parent->parent, $link, $separator, $nicename, $visited );
}
if ( $link )
- $chain .= '<a href="' . get_category_link($parent->term_id) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator;
+ $chain .= '<a href="' . get_category_link( $parent->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $parent->cat_name ) . '">'.$name.'</a>' . $separator;
else
$chain .= $name.$separator;
return $chain;
}
-function get_the_category($id = false) {
+/**
+ * Retrieve post categories.
+ *
+ * @since 0.71
+ * @uses $post
+ *
+ * @param int $id Optional, default to current post ID. The post ID.
+ * @return array
+ */
+function get_the_category( $id = false ) {
global $post;
$id = (int) $id;
if ( !$id )
$id = (int) $post->ID;
- $categories = get_object_term_cache($id, 'category');
- if ( false === $categories )
- $categories = wp_get_object_terms($id, 'category');
+ $categories = get_object_term_cache( $id, 'category' );
+ if ( false === $categories ) {
+ $categories = wp_get_object_terms( $id, 'category' );
+ wp_cache_add($id, $categories, 'category_relationships');
+ }
- if ( !empty($categories) )
- usort($categories, '_usort_terms_by_name');
+ if ( !empty( $categories ) )
+ usort( $categories, '_usort_terms_by_name' );
else
$categories = array();
- foreach(array_keys($categories) as $key) {
- _make_cat_compat($categories[$key]);
+ foreach ( (array) array_keys( $categories ) as $key ) {
+ _make_cat_compat( $categories[$key] );
}
return $categories;
}
-function _usort_terms_by_name($a, $b) {
- return strcmp($a->name, $b->name);
+/**
+ * Sort categories by name.
+ *
+ * Used by usort() as a callback, should not be used directly. Can actually be
+ * used to sort any term object.
+ *
+ * @since 2.3.0
+ * @access private
+ *
+ * @param object $a
+ * @param object $b
+ * @return int
+ */
+function _usort_terms_by_name( $a, $b ) {
+ return strcmp( $a->name, $b->name );
}
-function _usort_terms_by_ID($a, $b) {
+/**
+ * Sort categories by ID.
+ *
+ * Used by usort() as a callback, should not be used directly. Can actually be
+ * used to sort any term object.
+ *
+ * @since 2.3.0
+ * @access private
+ *
+ * @param object $a
+ * @param object $b
+ * @return int
+ */
+function _usort_terms_by_ID( $a, $b ) {
if ( $a->term_id > $b->term_id )
return 1;
elseif ( $a->term_id < $b->term_id )
return 0;
}
-function get_the_category_by_ID($cat_ID) {
+/**
+ * Retrieve category name based on category ID.
+ *
+ * @since 0.71
+ *
+ * @param int $cat_ID Category ID.
+ * @return string Category name.
+ */
+function get_the_category_by_ID( $cat_ID ) {
$cat_ID = (int) $cat_ID;
- $category = &get_category($cat_ID);
+ $category = &get_category( $cat_ID );
if ( is_wp_error( $category ) )
return $category;
return $category->name;
}
-function get_the_category_list($separator = '', $parents='', $post_id = false) {
+/**
+ * Retrieve category list in either HTML list or custom format.
+ *
+ * @since 1.5.1
+ *
+ * @param string $separator Optional, default is empty string. Separator for between the categories.
+ * @param string $parents Optional. How to display the parents.
+ * @param int $post_id Optional. Post ID to retrieve categories.
+ * @return string
+ */
+function get_the_category_list( $separator = '', $parents='', $post_id = false ) {
global $wp_rewrite;
- $categories = get_the_category($post_id);
- if (empty($categories))
- return apply_filters('the_category', __('Uncategorized'), $separator, $parents);
+ $categories = get_the_category( $post_id );
+ if ( empty( $categories ) )
+ return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents );
- $rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
+ $rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
$thelist = '';
if ( '' == $separator ) {
$thelist .= '<ul class="post-categories">';
foreach ( $categories as $category ) {
$thelist .= "\n\t<li>";
- switch ( strtolower($parents) ) {
+ switch ( strtolower( $parents ) ) {
case 'multiple':
- if ($category->parent)
- $thelist .= get_category_parents($category->parent, TRUE);
- $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>' . $category->name.'</a></li>';
+ if ( $category->parent )
+ $thelist .= get_category_parents( $category->parent, true, $separator );
+ $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . $rel . '>' . $category->name.'</a></li>';
break;
case 'single':
- $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>';
- if ($category->parent)
- $thelist .= get_category_parents($category->parent, FALSE);
+ $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . $rel . '>';
+ if ( $category->parent )
+ $thelist .= get_category_parents( $category->parent, false, $separator );
$thelist .= $category->name.'</a></li>';
break;
case '':
default:
- $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>' . $category->cat_name.'</a></li>';
+ $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . $rel . '>' . $category->cat_name.'</a></li>';
}
}
$thelist .= '</ul>';
foreach ( $categories as $category ) {
if ( 0 < $i )
$thelist .= $separator . ' ';
- switch ( strtolower($parents) ) {
+ switch ( strtolower( $parents ) ) {
case 'multiple':
if ( $category->parent )
- $thelist .= get_category_parents($category->parent, TRUE);
- $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>' . $category->cat_name.'</a>';
+ $thelist .= get_category_parents( $category->parent, true, $separator );
+ $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . $rel . '>' . $category->cat_name.'</a>';
break;
case 'single':
- $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>';
+ $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . $rel . '>';
if ( $category->parent )
- $thelist .= get_category_parents($category->parent, FALSE);
+ $thelist .= get_category_parents( $category->parent, false, $separator );
$thelist .= "$category->cat_name</a>";
break;
case '':
default:
- $thelist .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . $rel . '>' . $category->name.'</a>';
+ $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . $rel . '>' . $category->name.'</a>';
}
++$i;
}
}
- return apply_filters('the_category', $thelist, $separator, $parents);
+ return apply_filters( 'the_category', $thelist, $separator, $parents );
}
-/*
- * in_category() - Checks whether the current post is within a particular category
+
+/**
+ * Check if the current post in within any of the given categories.
*
- * This function checks to see if the post is within the supplied category. The categoy
- * can be specified by number or name and will be checked as a name first to allow for categories with numeric names.
- * Note: Prior to v2.5 of WordPress category names where not supported.
+ * The given categories are checked against the post's categories' term_ids, names and slugs.
+ * Categories given as integers will only be checked against the post's categories' term_ids.
+ *
+ * Prior to v2.5 of WordPress, category names were not supported.
+ * Prior to v2.7, category slugs were not supported.
+ * Prior to v2.7, only one category could be compared: in_category( $single_category ).
+ * Prior to v2.7, this function could only be used in the WordPress Loop.
+ * As of 2.7, the function can be used anywhere if it is provided a post ID or post object.
*
* @since 1.2.0
*
- * @param int|string $category
- * @return bool true if the post is in the supplied category
-*/
-function in_category( $category ) { // Check if the current post is in the given category
- global $post;
-
- if ( empty($category) )
+ * @uses is_object_in_term()
+ *
+ * @param int|string|array $category. Category ID, name or slug, or array of said.
+ * @param int|post object Optional. Post to check instead of the current post. @since 2.7.0
+ * @return bool True if the current post is in any of the given categories.
+ */
+function in_category( $category, $_post = null ) {
+ if ( empty( $category ) )
return false;
- // If category is not an int, check to see if it's a name
- if ( ! is_int($category) ) {
- $cat_ID = get_cat_ID($category);
- if ( $cat_ID )
- $category = $cat_ID;
+ if ( $_post ) {
+ $_post = get_post( $_post );
+ } else {
+ $_post =& $GLOBALS['post'];
}
- $categories = get_object_term_cache($post->ID, 'category');
- if ( false === $categories )
- $categories = wp_get_object_terms($post->ID, 'category');
- if ( array_key_exists($category, $categories) )
- return true;
- else
+ if ( !$_post )
+ return false;
+
+ $r = is_object_in_term( $_post->ID, 'category', $category );
+ if ( is_wp_error( $r ) )
return false;
+ return $r;
}
-function the_category($separator = '', $parents='', $post_id = false) {
- echo get_the_category_list($separator, $parents, $post_id);
+/**
+ * Display the category list for the post.
+ *
+ * @since 0.71
+ *
+ * @param string $separator Optional, default is empty string. Separator for between the categories.
+ * @param string $parents Optional. How to display the parents.
+ * @param int $post_id Optional. Post ID to retrieve categories.
+ */
+function the_category( $separator = '', $parents='', $post_id = false ) {
+ echo get_the_category_list( $separator, $parents, $post_id );
}
-function category_description($category = 0) {
+/**
+ * Retrieve category description.
+ *
+ * @since 1.0.0
+ *
+ * @param int $category Optional. Category ID. Will use global category ID by default.
+ * @return string Category description, available.
+ */
+function category_description( $category = 0 ) {
global $cat;
if ( !$category )
$category = $cat;
- return get_term_field('description', $category, 'category');
+ return get_term_field( 'description', $category, 'category' );
}
-function wp_dropdown_categories($args = '') {
+/**
+ * Display or retrieve the HTML dropdown list of categories.
+ *
+ * The list of arguments is below:
+ * 'show_option_all' (string) - Text to display for showing all categories.
+ * 'show_option_none' (string) - Text to display for showing no categories.
+ * 'orderby' (string) default is 'ID' - What column to use for ordering the
+ * categories.
+ * 'order' (string) default is 'ASC' - What direction to order categories.
+ * 'show_last_update' (bool|int) default is 0 - See {@link get_categories()}
+ * 'show_count' (bool|int) default is 0 - Whether to show how many posts are
+ * in the category.
+ * 'hide_empty' (bool|int) default is 1 - Whether to hide categories that
+ * don't have any posts attached to them.
+ * 'child_of' (int) default is 0 - See {@link get_categories()}.
+ * 'exclude' (string) - See {@link get_categories()}.
+ * 'echo' (bool|int) default is 1 - Whether to display or retrieve content.
+ * 'depth' (int) - The max depth.
+ * 'tab_index' (int) - Tab index for select element.
+ * 'name' (string) - The name attribute value for selected element.
+ * 'class' (string) - The class attribute value for selected element.
+ * 'selected' (int) - Which category ID is selected.
+ *
+ * The 'hierarchical' argument, which is disabled by default, will override the
+ * depth argument, unless it is true. When the argument is false, it will
+ * display all of the categories. When it is enabled it will use the value in
+ * the 'depth' argument.
+ *
+ * @since 2.1.0
+ *
+ * @param string|array $args Optional. Override default arguments.
+ * @return string HTML content only if 'echo' argument is 0.
+ */
+function wp_dropdown_categories( $args = '' ) {
$defaults = array(
'show_option_all' => '', 'show_option_none' => '',
'orderby' => 'ID', 'order' => 'ASC',
'depth' => 0, 'tab_index' => 0
);
- $defaults['selected'] = ( is_category() ) ? get_query_var('cat') : 0;
+ $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;
$r = wp_parse_args( $args, $defaults );
$r['include_last_update_time'] = $r['show_last_update'];
if ( (int) $tab_index > 0 )
$tab_index_attribute = " tabindex=\"$tab_index\"";
- $categories = get_categories($r);
+ $categories = get_categories( $r );
$output = '';
- if ( ! empty($categories) ) {
+ if ( ! empty( $categories ) ) {
$output = "<select name='$name' id='$name' class='$class' $tab_index_attribute>\n";
if ( $show_option_all ) {
- $show_option_all = apply_filters('list_cats', $show_option_all);
- $output .= "\t<option value='0'>$show_option_all</option>\n";
+ $show_option_all = apply_filters( 'list_cats', $show_option_all );
+ $selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : '';
+ $output .= "\t<option value='0'$selected>$show_option_all</option>\n";
}
- if ( $show_option_none) {
- $show_option_none = apply_filters('list_cats', $show_option_none);
- $output .= "\t<option value='-1'>$show_option_none</option>\n";
+ if ( $show_option_none ) {
+ $show_option_none = apply_filters( 'list_cats', $show_option_none );
+ $selected = ( '-1' === strval($r['selected']) ) ? " selected='selected'" : '';
+ $output .= "\t<option value='-1'$selected>$show_option_none</option>\n";
}
if ( $hierarchical )
else
$depth = -1; // Flat.
- $output .= walk_category_dropdown_tree($categories, $depth, $r);
+ $output .= walk_category_dropdown_tree( $categories, $depth, $r );
$output .= "</select>\n";
}
- $output = apply_filters('wp_dropdown_cats', $output);
+ $output = apply_filters( 'wp_dropdown_cats', $output );
if ( $echo )
echo $output;
return $output;
}
-function wp_list_categories($args = '') {
+/**
+ * Display or retrieve the HTML list of categories.
+ *
+ * The list of arguments is below:
+ * 'show_option_all' (string) - Text to display for showing all categories.
+ * 'orderby' (string) default is 'ID' - What column to use for ordering the
+ * categories.
+ * 'order' (string) default is 'ASC' - What direction to order categories.
+ * 'show_last_update' (bool|int) default is 0 - See {@link
+ * walk_category_dropdown_tree()}
+ * 'show_count' (bool|int) default is 0 - Whether to show how many posts are
+ * in the category.
+ * 'hide_empty' (bool|int) default is 1 - Whether to hide categories that
+ * don't have any posts attached to them.
+ * 'use_desc_for_title' (bool|int) default is 1 - Whether to use the
+ * description instead of the category title.
+ * 'feed' - See {@link get_categories()}.
+ * 'feed_type' - See {@link get_categories()}.
+ * 'feed_image' - See {@link get_categories()}.
+ * 'child_of' (int) default is 0 - See {@link get_categories()}.
+ * 'exclude' (string) - See {@link get_categories()}.
+ * 'exclude_tree' (string) - See {@link get_categories()}.
+ * 'echo' (bool|int) default is 1 - Whether to display or retrieve content.
+ * 'current_category' (int) - See {@link get_categories()}.
+ * 'hierarchical' (bool) - See {@link get_categories()}.
+ * 'title_li' (string) - See {@link get_categories()}.
+ * 'depth' (int) - The max depth.
+ *
+ * @since 2.1.0
+ *
+ * @param string|array $args Optional. Override default arguments.
+ * @return string HTML content only if 'echo' argument is 0.
+ */
+function wp_list_categories( $args = '' ) {
$defaults = array(
'show_option_all' => '', 'orderby' => 'name',
'order' => 'ASC', 'show_last_update' => 0,
'style' => 'list', 'show_count' => 0,
'hide_empty' => 1, 'use_desc_for_title' => 1,
'child_of' => 0, 'feed' => '', 'feed_type' => '',
- 'feed_image' => '', 'exclude' => '', 'current_category' => 0,
- 'hierarchical' => true, 'title_li' => __('Categories'),
+ 'feed_image' => '', 'exclude' => '', 'exclude_tree' => '', 'current_category' => 0,
+ 'hierarchical' => true, 'title_li' => __( 'Categories' ),
'echo' => 1, 'depth' => 0
);
$r['include_last_update_time'] = $r['show_date'];
}
+ if ( true == $r['hierarchical'] ) {
+ $r['exclude_tree'] = $r['exclude'];
+ $r['exclude'] = '';
+ }
+
extract( $r );
- $categories = get_categories($r);
+ $categories = get_categories( $r );
$output = '';
if ( $title_li && 'list' == $style )
$output = '<li class="categories">' . $r['title_li'] . '<ul>';
- if ( empty($categories) ) {
+ if ( empty( $categories ) ) {
if ( 'list' == $style )
- $output .= '<li>' . __("No categories") . '</li>';
+ $output .= '<li>' . __( "No categories" ) . '</li>';
else
- $output .= __("No categories");
+ $output .= __( "No categories" );
} else {
global $wp_query;
- if( !empty($show_option_all) )
- if ('list' == $style )
- $output .= '<li><a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a></li>';
+ if( !empty( $show_option_all ) )
+ if ( 'list' == $style )
+ $output .= '<li><a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a></li>';
else
- $output .= '<a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a>';
+ $output .= '<a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a>';
if ( empty( $r['current_category'] ) && is_category() )
$r['current_category'] = $wp_query->get_queried_object_id();
else
$depth = -1; // Flat.
- $output .= walk_category_tree($categories, $depth, $r);
+ $output .= walk_category_tree( $categories, $depth, $r );
}
if ( $title_li && 'list' == $style )
$output .= '</ul></li>';
- $output = apply_filters('wp_list_categories', $output);
+ $output = apply_filters( 'wp_list_categories', $output );
if ( $echo )
echo $output;
return $output;
}
+/**
+ * Display tag cloud.
+ *
+ * The text size is set by the 'smallest' and 'largest' arguments, which will
+ * use the 'unit' argument value for the CSS text size unit. The 'format'
+ * argument can be 'flat' (default), 'list', or 'array'. The flat value for the
+ * 'format' argument will separate tags with spaces. The list value for the
+ * 'format' argument will format the tags in a UL HTML list. The array value for
+ * the 'format' argument will return in PHP array type format.
+ *
+ * The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
+ * The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC'.
+ *
+ * The 'number' argument is how many tags to return. By default, the limit will
+ * be to return the top 45 tags in the tag cloud list.
+ *
+ * The 'topic_count_text_callback' argument is a function, which, given the count
+ * of the posts with that tag, returns a text for the tooltip of the tag link.
+ *
+ * The 'exclude' and 'include' arguments are used for the {@link get_tags()}
+ * function. Only one should be used, because only one will be used and the
+ * other ignored, if they are both set.
+ *
+ * @since 2.3.0
+ *
+ * @param array|string $args Optional. Override default arguments.
+ * @return array Generated tag cloud, only if no failures and 'array' is set for the 'format' argument.
+ */
function wp_tag_cloud( $args = '' ) {
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
- 'exclude' => '', 'include' => ''
+ 'exclude' => '', 'include' => '', 'link' => 'view'
);
$args = wp_parse_args( $args, $defaults );
- $tags = get_tags( array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) ); // Always query top tags
+ $tags = get_tags( array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags
- if ( empty($tags) )
+ if ( empty( $tags ) )
return;
- $return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
+ foreach ( $tags as $key => $tag ) {
+ if ( 'edit' == $args['link'] )
+ $link = get_edit_tag_link( $tag->term_id );
+ else
+ $link = get_tag_link( $tag->term_id );
+ if ( is_wp_error( $link ) )
+ return false;
- if ( is_wp_error( $return ) )
- return false;
+ $tags[ $key ]->link = $link;
+ $tags[ $key ]->id = $tag->term_id;
+ }
+
+ $return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
$return = apply_filters( 'wp_tag_cloud', $return, $args );
echo $return;
}
-// $tags = prefetched tag array ( get_tags() )
-// $args['format'] = 'flat' => whitespace separated, 'list' => UL, 'array' => array()
-// $args['orderby'] = 'name', 'count'
+/**
+ * Default text for tooltip for tag links
+ *
+ * @param integer $count number of posts with that tag
+ * @return string text for the tooltip of a tag link.
+ */
+function default_topic_count_text( $count ) {
+ return sprintf( __ngettext('%s topic', '%s topics', $count), number_format_i18n( $count ) );
+}
+
+/**
+ * Generates a tag cloud (heatmap) from provided data.
+ *
+ * The text size is set by the 'smallest' and 'largest' arguments, which will
+ * use the 'unit' argument value for the CSS text size unit. The 'format'
+ * argument can be 'flat' (default), 'list', or 'array'. The flat value for the
+ * 'format' argument will separate tags with spaces. The list value for the
+ * 'format' argument will format the tags in a UL HTML list. The array value for
+ * the 'format' argument will return in PHP array type format.
+ *
+ * The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
+ * The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC' or
+ * 'RAND'.
+ *
+ * The 'number' argument is how many tags to return. By default, the limit will
+ * be to return the entire tag cloud list.
+ *
+ * The 'topic_count_text_callback' argument is a function, which given the count
+ * of the posts with that tag returns a text for the tooltip of the tag link.
+ *
+ * @todo Complete functionality.
+ * @since 2.3.0
+ *
+ * @param array $tags List of tags.
+ * @param string|array $args Optional, override default arguments.
+ * @return string
+ */
function wp_generate_tag_cloud( $tags, $args = '' ) {
global $wp_rewrite;
$defaults = array(
- 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
- 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
+ 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 0,
+ 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
+ 'topic_count_text_callback' => 'default_topic_count_text',
);
- $args = wp_parse_args( $args, $defaults );
- extract($args);
- if ( !$tags )
- return;
- $counts = $tag_links = array();
- foreach ( (array) $tags as $tag ) {
- $counts[$tag->name] = $tag->count;
- $tag_links[$tag->name] = get_tag_link( $tag->term_id );
- if ( is_wp_error( $tag_links[$tag->name] ) )
- return $tag_links[$tag->name];
- $tag_ids[$tag->name] = $tag->term_id;
+ if ( !isset( $args['topic_count_text_callback'] ) && isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) {
+ $body = 'return sprintf (
+ __ngettext('.var_export($args['single_text'], true).', '.var_export($args['multiple_text'], true).', $count),
+ number_format_i18n( $count ));';
+ $args['topic_count_text_callback'] = create_function('$count', $body);
}
- $min_count = min($counts);
- $spread = max($counts) - $min_count;
- if ( $spread <= 0 )
- $spread = 1;
- $font_spread = $largest - $smallest;
- if ( $font_spread <= 0 )
- $font_spread = 1;
- $font_step = $font_spread / $spread;
+ $args = wp_parse_args( $args, $defaults );
+
+ extract( $args );
+
+ if ( empty( $tags ) )
+ return;
// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
if ( 'name' == $orderby )
- uksort($counts, 'strnatcasecmp');
+ uasort( $tags, create_function('$a, $b', 'return strnatcasecmp($a->name, $b->name);') );
else
- asort($counts);
+ uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') );
if ( 'DESC' == $order )
- $counts = array_reverse( $counts, true );
+ $tags = array_reverse( $tags, true );
elseif ( 'RAND' == $order ) {
- $keys = array_rand( $counts, count($counts) );
+ $keys = array_rand( $tags, count( $tags ) );
foreach ( $keys as $key )
- $temp[$key] = $counts[$key];
- $counts = $temp;
- unset($temp);
+ $temp[$key] = $tags[$key];
+ $tags = $temp;
+ unset( $temp );
}
+ if ( $number > 0 )
+ $tags = array_slice($tags, 0, $number);
+
+ $counts = array();
+ foreach ( (array) $tags as $key => $tag )
+ $counts[ $key ] = $tag->count;
+
+ $min_count = min( $counts );
+ $spread = max( $counts ) - $min_count;
+ if ( $spread <= 0 )
+ $spread = 1;
+ $font_spread = $largest - $smallest;
+ if ( $font_spread < 0 )
+ $font_spread = 1;
+ $font_step = $font_spread / $spread;
+
$a = array();
- $rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : '';
+ $rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : '';
- foreach ( $counts as $tag => $count ) {
- $tag_id = $tag_ids[$tag];
- $tag_link = clean_url($tag_links[$tag]);
- $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . attribute_escape( sprintf( __ngettext('%d topic','%d topics',$count), $count ) ) . "'$rel style='font-size: " .
+ foreach ( $tags as $key => $tag ) {
+ $count = $counts[ $key ];
+ $tag_link = '#' != $tag->link ? clean_url( $tag->link ) : '#';
+ $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key;
+ $tag_name = $tags[ $key ]->name;
+ $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . attribute_escape( $topic_count_text_callback( $count ) ) . "'$rel style='font-size: " .
( $smallest + ( ( $count - $min_count ) * $font_step ) )
- . "$unit;'>$tag</a>";
+ . "$unit;'>$tag_name</a>";
}
switch ( $format ) :
break;
case 'list' :
$return = "<ul class='wp-tag-cloud'>\n\t<li>";
- $return .= join("</li>\n\t<li>", $a);
+ $return .= join( "</li>\n\t<li>", $a );
$return .= "</li>\n</ul>\n";
break;
default :
- $return = join("\n", $a);
+ $return = join( "\n", $a );
break;
endswitch;
// Helper functions
//
+/**
+ * Retrieve HTML list content for category list.
+ *
+ * @uses Walker_Category to create HTML list content.
+ * @since 2.1.0
+ * @see Walker_Category::walk() for parameters and return description.
+ */
function walk_category_tree() {
- $walker = new Walker_Category;
$args = func_get_args();
- return call_user_func_array(array(&$walker, 'walk'), $args);
+ // the user's options are the third parameter
+ if ( empty($args[2]['walker']) || !is_a($args[2]['walker'], 'Walker') )
+ $walker = new Walker_Category;
+ else
+ $walker = $args[2]['walker'];
+
+ return call_user_func_array(array( &$walker, 'walk' ), $args );
}
+/**
+ * Retrieve HTML dropdown (select) content for category list.
+ *
+ * @uses Walker_CategoryDropdown to create HTML dropdown content.
+ * @since 2.1.0
+ * @see Walker_CategoryDropdown::walk() for parameters and return description.
+ */
function walk_category_dropdown_tree() {
- $walker = new Walker_CategoryDropdown;
$args = func_get_args();
- return call_user_func_array(array(&$walker, 'walk'), $args);
+ // the user's options are the third parameter
+ if ( empty($args[2]['walker']) || !is_a($args[2]['walker'], 'Walker') )
+ $walker = new Walker_CategoryDropdown;
+ else
+ $walker = $args[2]['walker'];
+
+ return call_user_func_array(array( &$walker, 'walk' ), $args );
}
//
// Tags
//
+/**
+ * Retrieve the link to the tag.
+ *
+ * @since 2.3.0
+ * @uses apply_filters() Calls 'tag_link' with tag link and tag ID as parameters.
+ *
+ * @param int $tag_id Tag (term) ID.
+ * @return string
+ */
function get_tag_link( $tag_id ) {
global $wp_rewrite;
$taglink = $wp_rewrite->get_tag_permastruct();
- $tag = &get_term($tag_id, 'post_tag');
+ $tag = &get_term( $tag_id, 'post_tag' );
if ( is_wp_error( $tag ) )
return $tag;
$slug = $tag->slug;
- if ( empty($taglink) ) {
- $file = get_option('home') . '/';
+ if ( empty( $taglink ) ) {
+ $file = get_option( 'home' ) . '/';
$taglink = $file . '?tag=' . $slug;
} else {
- $taglink = str_replace('%tag%', $slug, $taglink);
- $taglink = get_option('home') . user_trailingslashit($taglink, 'category');
+ $taglink = str_replace( '%tag%', $slug, $taglink );
+ $taglink = get_option( 'home' ) . user_trailingslashit( $taglink, 'category' );
}
- return apply_filters('tag_link', $taglink, $tag_id);
+ return apply_filters( 'tag_link', $taglink, $tag_id );
}
+/**
+ * Retrieve the tags for a post.
+ *
+ * @since 2.3.0
+ * @uses apply_filters() Calls 'get_the_tags' filter on the list of post tags.
+ *
+ * @param int $id Post ID.
+ * @return array
+ */
function get_the_tags( $id = 0 ) {
- return apply_filters( 'get_the_tags', get_the_terms($id, 'post_tag') );
+ return apply_filters( 'get_the_tags', get_the_terms( $id, 'post_tag' ) );
}
+/**
+ * Retrieve the tags for a post formatted as a string.
+ *
+ * @since 2.3.0
+ * @uses apply_filters() Calls 'the_tags' filter on string list of tags.
+ *
+ * @param string $before Optional. Before tags.
+ * @param string $sep Optional. Between tags.
+ * @param string $after Optional. After tags.
+ * @return string
+ */
function get_the_tag_list( $before = '', $sep = '', $after = '' ) {
- return apply_filters( 'the_tags', get_the_term_list(0, 'post_tag', $before, $sep, $after) );
+ return apply_filters( 'the_tags', get_the_term_list( 0, 'post_tag', $before, $sep, $after ) );
}
+/**
+ * Retrieve the tags for a post.
+ *
+ * @since 2.3.0
+ *
+ * @param string $before Optional. Before list.
+ * @param string $sep Optional. Separate items using this.
+ * @param string $after Optional. After list.
+ * @return string
+ */
function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) {
return the_terms( 0, 'post_tag', $before, $sep, $after );
}
+/**
+ * Retrieve the terms of the taxonomy that are attached to the post.
+ *
+ * This function can only be used within the loop.
+ *
+ * @since 2.5.0
+ *
+ * @param int $id Post ID. Is not optional.
+ * @param string $taxonomy Taxonomy name.
+ * @return array|bool False on failure. Array of term objects on success.
+ */
function get_the_terms( $id = 0, $taxonomy ) {
global $post;
if ( !$id )
$id = (int) $post->ID;
- $terms = get_object_term_cache($id, $taxonomy);
+ $terms = get_object_term_cache( $id, $taxonomy );
if ( false === $terms )
- $terms = wp_get_object_terms($id, $taxonomy);
+ $terms = wp_get_object_terms( $id, $taxonomy );
if ( empty( $terms ) )
return false;
return $terms;
}
+/**
+ * Retrieve terms as a list with specified format.
+ *
+ * @since 2.5.0
+ *
+ * @param int $id Term ID.
+ * @param string $taxonomy Taxonomy name.
+ * @param string $before Optional. Before list.
+ * @param string $sep Optional. Separate items using this.
+ * @param string $after Optional. After list.
+ * @return string
+ */
function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after = '' ) {
- $terms = get_the_terms($id, $taxonomy);
+ $terms = get_the_terms( $id, $taxonomy );
- if ( is_wp_error($terms) )
+ if ( is_wp_error( $terms ) )
return $terms;
if ( empty( $terms ) )
return false;
foreach ( $terms as $term ) {
- $link = get_term_link($term, $taxonomy);
+ $link = get_term_link( $term, $taxonomy );
if ( is_wp_error( $link ) )
return $link;
$term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
$term_links = apply_filters( "term_links-$taxonomy", $term_links );
- return $before . join($sep, $term_links) . $after;
+ return $before . join( $sep, $term_links ) . $after;
}
+/**
+ * Display the terms in a list.
+ *
+ * @since 2.5.0
+ *
+ * @param int $id Term ID.
+ * @param string $taxonomy Taxonomy name.
+ * @param string $before Optional. Before list.
+ * @param string $sep Optional. Separate items using this.
+ * @param string $after Optional. After list.
+ * @return null|bool False on WordPress error. Returns null when displaying.
+ */
function the_terms( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {
- $return = get_the_term_list($id, $taxonomy, $before, $sep, $after);
+ $return = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
if ( is_wp_error( $return ) )
return false;
else
}
/**
- * Check if the current post has the given tag
+ * Check if the current post has any of given tags.
*
- * @package WordPress
- * @since 2.6
+ * The given tags are checked against the post's tags' term_ids, names and slugs.
+ * Tags given as integers will only be checked against the post's tags' term_ids.
+ * If no tags are given, determines if post has any tags.
+ *
+ * Prior to v2.7 of WordPress, tags given as integers would also be checked against the post's tags' names and slugs (in addition to term_ids)
+ * Prior to v2.7, this function could only be used in the WordPress Loop.
+ * As of 2.7, the function can be used anywhere if it is provided a post ID or post object.
+ *
+ * @since 2.6.0
*
- * @uses wp_get_object_terms() Gets the tags.
+ * @uses is_object_in_term()
*
- * @param string|int|array $tag Optional. The tag name/id/slug or array of them to check for
- * @return bool True if the current post has the given tag, or any tag, if no tag specified
+ * @param string|int|array $tag Optional. The tag name/term_id/slug or array of them to check for.
+ * @param int|post object Optional. Post to check instead of the current post. @since 2.7.0
+ * @return bool True if the current post has any of the the given tags (or any tag, if no tag specified).
*/
-function has_tag($tag = '') {
- global $post;
- $taxonomy = 'post_tag';
-
- if ( !in_the_loop() ) return false; // in-the-loop function
-
- $post_id = (int) $post->ID;
-
- $terms = get_object_term_cache($post_id, $taxonomy);
- if (empty($terms))
- $terms = wp_get_object_terms($post_id, $taxonomy);
- if (empty($terms)) return false;
-
- if (empty($tag)) return (!empty($terms));
-
- $tag = (array) $tag;
-
- foreach($terms as $term) {
- if ( in_array( $term->term_id, $tag ) ) return true;
- if ( in_array( $term->name, $tag ) ) return true;
- if ( in_array( $term->slug, $tag ) ) return true;
+function has_tag( $tag = '', $_post = null ) {
+ if ( $_post ) {
+ $_post = get_post( $_post );
+ } else {
+ $_post =& $GLOBALS['post'];
}
- return false;
+ if ( !$_post )
+ return false;
+
+ $r = is_object_in_term( $_post->ID, 'post_tag', $tag );
+ if ( is_wp_error( $r ) )
+ return false;
+ return $r;
}
?>
* @return object List of all of the category IDs.
*/
function get_all_category_ids() {
- if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) {
- $cat_ids = get_terms('category', 'fields=ids&get=all');
- wp_cache_add('all_category_ids', $cat_ids, 'category');
+ if ( ! $cat_ids = wp_cache_get( 'all_category_ids', 'category' ) ) {
+ $cat_ids = get_terms( 'category', 'fields=ids&get=all' );
+ wp_cache_add( 'all_category_ids', $cat_ids, 'category' );
}
return $cat_ids;
* @param string|array $args Optional. Change the defaults retrieving categories.
* @return array List of categories.
*/
-function &get_categories($args = '') {
- $defaults = array('type' => 'category');
- $args = wp_parse_args($args, $defaults);
+function &get_categories( $args = '' ) {
+ $defaults = array( 'type' => 'category' );
+ $args = wp_parse_args( $args, $defaults );
- $taxonomy = 'category';
+ $taxonomy = apply_filters( 'get_categories_taxonomy', 'category', $args );
if ( 'link' == $args['type'] )
$taxonomy = 'link_category';
- $categories = get_terms($taxonomy, $args);
+ $categories = (array) get_terms( $taxonomy, $args );
- foreach ( array_keys($categories) as $k )
- _make_cat_compat($categories[$k]);
+ foreach ( array_keys( $categories ) as $k )
+ _make_cat_compat( $categories[$k] );
return $categories;
}
*
* The category will converted to maintain backwards compatibility.
*
- * @since 2.1.0
+ * @since 1.5.1
* @uses get_term() Used to get the category data from the taxonomy.
*
* @param int|object $category Category ID or Category row object
* @param string $filter Optional. Default is raw or no WordPress defined filter will applied.
* @return mixed Category data in type defined by $output parameter.
*/
-function &get_category($category, $output = OBJECT, $filter = 'raw') {
- $category = get_term($category, 'category', $output, $filter);
+function &get_category( $category, $output = OBJECT, $filter = 'raw' ) {
+ $category = get_term( $category, 'category', $output, $filter );
if ( is_wp_error( $category ) )
return $category;
- _make_cat_compat($category);
+ _make_cat_compat( $category );
return $category;
}
* @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N
* @return null|object|array Null on failure. Type is based on $output value.
*/
-function get_category_by_path($category_path, $full_match = true, $output = OBJECT) {
- $category_path = rawurlencode(urldecode($category_path));
- $category_path = str_replace('%2F', '/', $category_path);
- $category_path = str_replace('%20', ' ', $category_path);
- $category_paths = '/' . trim($category_path, '/');
- $leaf_path = sanitize_title(basename($category_paths));
- $category_paths = explode('/', $category_paths);
+function get_category_by_path( $category_path, $full_match = true, $output = OBJECT ) {
+ $category_path = rawurlencode( urldecode( $category_path ) );
+ $category_path = str_replace( '%2F', '/', $category_path );
+ $category_path = str_replace( '%20', ' ', $category_path );
+ $category_paths = '/' . trim( $category_path, '/' );
+ $leaf_path = sanitize_title( basename( $category_paths ) );
+ $category_paths = explode( '/', $category_paths );
$full_path = '';
foreach ( (array) $category_paths as $pathdir )
- $full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title($pathdir);
+ $full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title( $pathdir );
- $categories = get_terms('category', "get=all&slug=$leaf_path");
+ $categories = get_terms( 'category', "get=all&slug=$leaf_path" );
- if ( empty($categories) )
+ if ( empty( $categories ) )
return null;
- foreach ($categories as $category) {
+ foreach ( $categories as $category ) {
$path = '/' . $leaf_path;
$curcategory = $category;
- while ( ($curcategory->parent != 0) && ($curcategory->parent != $curcategory->term_id) ) {
- $curcategory = get_term($curcategory->parent, 'category');
+ while ( ( $curcategory->parent != 0 ) && ( $curcategory->parent != $curcategory->term_id ) ) {
+ $curcategory = get_term( $curcategory->parent, 'category' );
if ( is_wp_error( $curcategory ) )
return $curcategory;
$path = '/' . $curcategory->slug . $path;
}
if ( $path == $full_path )
- return get_category($category->term_id, $output);
+ return get_category( $category->term_id, $output );
}
// If full matching is not required, return the first cat that matches the leaf.
if ( ! $full_match )
- return get_category($categories[0]->term_id, $output);
+ return get_category( $categories[0]->term_id, $output );
return null;
}
* @return object Category data object
*/
function get_category_by_slug( $slug ) {
- $category = get_term_by('slug', $slug, 'category');
+ $category = get_term_by( 'slug', $slug, 'category' );
if ( $category )
- _make_cat_compat($category);
+ _make_cat_compat( $category );
return $category;
}
* @param string $cat_name Optional. Default is 'General' and can be any category name.
* @return int 0, if failure and ID of category on success.
*/
-function get_cat_ID($cat_name='General') {
- $cat = get_term_by('name', $cat_name, 'category');
- if ($cat)
+function get_cat_ID( $cat_name='General' ) {
+ $cat = get_term_by( 'name', $cat_name, 'category' );
+ if ( $cat )
return $cat->term_id;
return 0;
}
* @param int $cat_ID Category ID
* @return string category name
*/
-function get_catname($cat_ID) {
- return get_cat_name($cat_ID);
+function get_catname( $cat_ID ) {
+ return get_cat_name( $cat_ID );
}
* @param int $cat_id Category ID
* @return string Category name
*/
-function get_cat_name($cat_id) {
+function get_cat_name( $cat_id ) {
$cat_id = (int) $cat_id;
- $category = &get_category($cat_id);
+ $category = &get_category( $cat_id );
return $category->name;
}
* @param int|object $cat2 The child category.
* @return bool Whether $cat2 is child of $cat1
*/
-function cat_is_ancestor_of($cat1, $cat2) {
- if ( is_int($cat1) )
- $cat1 = & get_category($cat1);
- if ( is_int($cat2) )
- $cat2 = & get_category($cat2);
+function cat_is_ancestor_of( $cat1, $cat2 ) {
+ if ( is_int( $cat1 ) )
+ $cat1 = &get_category( $cat1 );
+ if ( is_int( $cat2 ) )
+ $cat2 = &get_category( $cat2 );
if ( !$cat1->term_id || !$cat2->parent )
return false;
if ( $cat2->parent == $cat1->term_id )
return true;
- return cat_is_ancestor_of($cat1, get_category($cat2->parent));
+ return cat_is_ancestor_of( $cat1, get_category( $cat2->parent ) );
}
* @param string $context Optional. Default is 'display'.
* @return object|array Same type as $category with sanitized data for safe use.
*/
-function sanitize_category($category, $context = 'display') {
- return sanitize_term($category, 'category', $context);
+function sanitize_category( $category, $context = 'display' ) {
+ return sanitize_term( $category, 'category', $context );
}
* @param string $context What filter to use, 'raw', 'display', etc.
* @return mixed Same type as $value after $value has been sanitized.
*/
-function sanitize_category_field($field, $value, $cat_id, $context) {
- return sanitize_term_field($field, $value, $cat_id, 'category', $context);
+function sanitize_category_field( $field, $value, $cat_id, $context ) {
+ return sanitize_term_field( $field, $value, $cat_id, 'category', $context );
}
/* Tags */
* @param string|array $args Tag arguments to use when retrieving tags.
* @return array List of tags.
*/
-function &get_tags($args = '') {
- $tags = get_terms('post_tag', $args);
+function &get_tags( $args = '' ) {
+ $tags = get_terms( 'post_tag', $args );
- if ( empty($tags) )
- return array();
+ if ( empty( $tags ) ) {
+ $return = array();
+ return $return;
+ }
- $tags = apply_filters('get_tags', $tags, $args);
+ $tags = apply_filters( 'get_tags', $tags, $args );
return $tags;
}
* @param string $filter Optional. Default is raw or no WordPress defined filter will applied.
* @return object|array Return type based on $output value.
*/
-function &get_tag($tag, $output = OBJECT, $filter = 'raw') {
- return get_term($tag, 'post_tag', $output, $filter);
+function &get_tag( $tag, $output = OBJECT, $filter = 'raw' ) {
+ return get_term( $tag, 'post_tag', $output, $filter );
}
*
* @param int $id Category ID
*/
-function clean_category_cache($id) {
- clean_term_cache($id, 'category');
+function clean_category_cache( $id ) {
+ clean_term_cache( $id, 'category' );
}
*
* @param array|object $category Category Row object or array
*/
-function _make_cat_compat( &$category) {
- if ( is_object($category) ) {
+function _make_cat_compat( &$category ) {
+ if ( is_object( $category ) ) {
$category->cat_ID = &$category->term_id;
$category->category_count = &$category->count;
$category->category_description = &$category->description;
$category->cat_name = &$category->name;
$category->category_nicename = &$category->slug;
$category->category_parent = &$category->parent;
- } else if ( is_array($category) && isset($category['term_id']) ) {
+ } elseif ( is_array( $category ) && isset( $category['term_id'] ) ) {
$category['cat_ID'] = &$category['term_id'];
$category['category_count'] = &$category['count'];
$category['category_description'] = &$category['description'];
class IXR_Value {
var $data;
var $type;
+
function IXR_Value ($data, $type = false) {
$this->data = $data;
if (!$type) {
}
}
}
+
function calculateType() {
if ($this->data === true || $this->data === false) {
return 'boolean';
return 'array';
}
}
+
function getXml() {
/* Return XML for this value */
switch ($this->type) {
}
return false;
}
+
function isStruct($array) {
/* Nasty function to check if an array is a struct or not */
$expected = 0;
return true;
}
function tag_open($parser, $tag, $attr) {
- $this->_currentTagContents = '';
+ $this->_currentTagContents = '';
$this->currentTag = $tag;
switch($tag) {
case 'methodCall':
$this->params[] = $value;
}
}
- $this->_currentTagContents = '';
+ $this->_currentTagContents = '';
}
}
}
function call($methodname, $args) {
if (!$this->hasMethod($methodname)) {
- return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
+ return new IXR_Error(-32601, 'server error. requested method '.
+ $methodname.' does not exist.');
}
$method = $this->callbacks[$methodname];
// Perform the callback and send the response
// It's a class method - check it exists
$method = substr($method, 5);
if (!method_exists($this, $method)) {
- return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
+ return new IXR_Error(-32601, 'server error. requested class method "'.
+ $method.'" does not exist.');
}
// Call the method
$result = $this->$method($args);
} else {
// It's a function - does it exist?
if (is_array($method)) {
- if (!method_exists($method[0], $method[1])) {
- return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
- }
+ if (!method_exists($method[0], $method[1])) {
+ return new IXR_Error(-32601, 'server error. requested object method "'.
+ $method[1].'" does not exist.');
+ }
} else if (!function_exists($method)) {
- return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
+ return new IXR_Error(-32601, 'server error. requested function "'.
+ $method.'" does not exist.');
}
// Call the function
$result = call_user_func($method, $args);
var $response;
var $message = false;
var $debug = false;
- var $timeout;
+ var $timeout;
// Storage place for an error message
var $error = false;
function IXR_Client($server, $path = false, $port = 80, $timeout = false) {
$this->path = $path;
$this->port = $port;
}
- $this->useragent = 'Incutio XML-RPC';
- $this->timeout = $timeout;
+ $this->useragent = 'The Incutio XML-RPC PHP Library';
+ $this->timeout = $timeout;
}
function query() {
$args = func_get_args();
$gettingHeaders = false;
}
if (!$gettingHeaders) {
- $contents .= trim($line)."\n";
+ $contents .= trim($line);
}
}
if ($this->debug) {
var $message;
function IXR_Error($code, $message) {
$this->code = $code;
+ // WP adds htmlspecialchars(). See #5666
$this->message = htmlspecialchars($message);
}
function getXml() {
var $hour;
var $minute;
var $second;
+ var $timezone;
function IXR_Date($time) {
// $time can be a PHP timestamp or an ISO one
if (is_numeric($time)) {
$this->hour = date('H', $timestamp);
$this->minute = date('i', $timestamp);
$this->second = date('s', $timestamp);
+ // WP adds timezone. See #2036
+ $this->timezone = '';
}
function parseIso($iso) {
$this->year = substr($iso, 0, 4);
$this->hour = substr($iso, 9, 2);
$this->minute = substr($iso, 12, 2);
$this->second = substr($iso, 15, 2);
+ // WP adds timezone. See #2036
$this->timezone = substr($iso, 17);
}
function getIso() {
+ // WP adds timezone. See #2036
return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
}
function getXml() {
$this->portable_hashes = $portable_hashes;
$this->random_state = microtime() . (function_exists('getmypid') ? getmypid() : '') . uniqid(rand(), TRUE);
-
+
}
function get_random_bytes($count)
<?php
-/**
- * PHPMailer - PHP email class
- *
- * Class for sending email using either sendmail, PHP mail(), or SMTP. Methods
- * are based upon the standard AspEmail(tm) classes.
- *
- * @copyright 2001 - 2003 Brent R. Matzelle
- * @license LGPL
- * @package PHPMailer
+/*~ class.phpmailer.php
+.---------------------------------------------------------------------------.
+| Software: PHPMailer - PHP email class |
+| Version: 2.0.2 |
+| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
+| Info: http://phpmailer.sourceforge.net |
+| Support: http://sourceforge.net/projects/phpmailer/ |
+| ------------------------------------------------------------------------- |
+| Author: Andy Prevost (project admininistrator) |
+| Author: Brent R. Matzelle (original founder) |
+| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
+| Copyright (c) 2001-2003, Brent R. Matzelle |
+| ------------------------------------------------------------------------- |
+| License: Distributed under the Lesser General Public License (LGPL) |
+| http://www.gnu.org/copyleft/lesser.html |
+| This program is distributed in the hope that it will be useful - WITHOUT |
+| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+| FITNESS FOR A PARTICULAR PURPOSE. |
+| ------------------------------------------------------------------------- |
+| We offer a number of paid services (www.codeworxtech.com): |
+| - Web Hosting on highly optimized fast and secure servers |
+| - Technology Consulting |
+| - Oursourcing (highly qualified programmers and graphic designers) |
+'---------------------------------------------------------------------------'
*/
-
/**
* PHPMailer - PHP email transport class
* @package PHPMailer
- * @author Brent R. Matzelle
- * @copyright 2001 - 2003 Brent R. Matzelle
+ * @author Andy Prevost
+ * @copyright 2004 - 2008 Andy Prevost
*/
-class PHPMailer
-{
- /////////////////////////////////////////////////
- // PUBLIC VARIABLES
- /////////////////////////////////////////////////
-
- /**
- * Email priority (1 = High, 3 = Normal, 5 = low).
- * @var int
- */
- var $Priority = 3;
-
- /**
- * Sets the CharSet of the message.
- * @var string
- */
- var $CharSet = "UTF-8";
-
- /**
- * Sets the Content-type of the message.
- * @var string
- */
- var $ContentType = "text/plain";
-
- /**
- * Sets the Encoding of the message. Options for this are "8bit",
- * "7bit", "binary", "base64", and "quoted-printable".
- * @var string
- */
- var $Encoding = "8bit";
-
- /**
- * Holds the most recent mailer error message.
- * @var string
- */
- var $ErrorInfo = "";
-
- /**
- * Sets the From email address for the message.
- * @var string
- */
- var $From = "localhost.localdomain";
-
- /**
- * Sets the From name of the message.
- * @var string
- */
- var $FromName = "Support";
-
- /**
- * Sets the Sender email (Return-Path) of the message. If not empty,
- * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
- * @var string
- */
- var $Sender = "";
-
- /**
- * Sets the Subject of the message.
- * @var string
- */
- var $Subject = "";
-
- /**
- * Sets the Body of the message. This can be either an HTML or text body.
- * If HTML then run IsHTML(true).
- * @var string
- */
- var $Body = "";
-
- /**
- * Sets the text-only body of the message. This automatically sets the
- * email to multipart/alternative. This body can be read by mail
- * clients that do not have HTML email capability such as mutt. Clients
- * that can read HTML will view the normal Body.
- * @var string
- */
- var $AltBody = "";
-
- /**
- * Sets word wrapping on the body of the message to a given number of
- * characters.
- * @var int
- */
- var $WordWrap = 0;
-
- /**
- * Method to send mail: ("mail", "sendmail", or "smtp").
- * @var string
- */
- var $Mailer = "mail";
-
- /**
- * Sets the path of the sendmail program.
- * @var string
- */
- var $Sendmail = "/usr/sbin/sendmail";
-
- /**
- * Path to PHPMailer plugins. This is now only useful if the SMTP class
- * is in a different directory than the PHP include path.
- * @var string
- */
- var $PluginDir = "";
-
- /**
- * Holds PHPMailer version.
- * @var string
- */
- var $Version = "1.73";
-
- /**
- * Sets the email address that a reading confirmation will be sent.
- * @var string
- */
- var $ConfirmReadingTo = "";
-
- /**
- * Sets the hostname to use in Message-Id and Received headers
- * and as default HELO string. If empty, the value returned
- * by SERVER_NAME is used or 'localhost.localdomain'.
- * @var string
- */
- var $Hostname = "";
-
- /////////////////////////////////////////////////
- // SMTP VARIABLES
- /////////////////////////////////////////////////
-
- /**
- * Sets the SMTP hosts. All hosts must be separated by a
- * semicolon. You can also specify a different port
- * for each host by using this format: [hostname:port]
- * (e.g. "smtp1.example.com:25;smtp2.example.com").
- * Hosts will be tried in order.
- * @var string
- */
- var $Host = "localhost";
-
- /**
- * Sets the default SMTP server port.
- * @var int
- */
- var $Port = 25;
-
- /**
- * Sets the SMTP HELO of the message (Default is $Hostname).
- * @var string
- */
- var $Helo = "";
-
- /**
- * Sets SMTP authentication. Utilizes the Username and Password variables.
- * @var bool
- */
- var $SMTPAuth = false;
-
- /**
- * Sets SMTP username.
- * @var string
- */
- var $Username = "";
-
- /**
- * Sets SMTP password.
- * @var string
- */
- var $Password = "";
-
- /**
- * Sets the SMTP server timeout in seconds. This function will not
- * work with the win32 version.
- * @var int
- */
- var $Timeout = 10;
-
- /**
- * Sets SMTP class debugging on or off.
- * @var bool
- */
- var $SMTPDebug = false;
-
- /**
- * Prevents the SMTP connection from being closed after each mail
- * sending. If this is set to true then to close the connection
- * requires an explicit call to SmtpClose().
- * @var bool
- */
- var $SMTPKeepAlive = false;
-
- /**#@+
- * @access private
- */
- var $smtp = NULL;
- var $to = array();
- var $cc = array();
- var $bcc = array();
- var $ReplyTo = array();
- var $attachment = array();
- var $CustomHeader = array();
- var $message_type = "";
- var $boundary = array();
- var $language = array();
- var $error_count = 0;
- var $LE = "\n";
- /**#@-*/
-
- /////////////////////////////////////////////////
- // VARIABLE METHODS
- /////////////////////////////////////////////////
-
- /**
- * Sets message type to HTML.
- * @param bool $bool
- * @return void
- */
- function IsHTML($bool) {
- if($bool == true)
- $this->ContentType = "text/html";
- else
- $this->ContentType = "text/plain";
- }
-
- /**
- * Sets Mailer to send message using SMTP.
- * @return void
- */
- function IsSMTP() {
- $this->Mailer = "smtp";
- }
-
- /**
- * Sets Mailer to send message using PHP mail() function.
- * @return void
- */
- function IsMail() {
- $this->Mailer = "mail";
- }
-
- /**
- * Sets Mailer to send message using the $Sendmail program.
- * @return void
- */
- function IsSendmail() {
- $this->Mailer = "sendmail";
- }
-
- /**
- * Sets Mailer to send message using the qmail MTA.
- * @return void
- */
- function IsQmail() {
- $this->Sendmail = "/var/qmail/bin/sendmail";
- $this->Mailer = "sendmail";
- }
-
-
- /////////////////////////////////////////////////
- // RECIPIENT METHODS
- /////////////////////////////////////////////////
-
- /**
- * Adds a "To" address.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddAddress($address, $name = "") {
- $cur = count($this->to);
- $this->to[$cur][0] = trim($address);
- $this->to[$cur][1] = $name;
- }
-
- /**
- * Adds a "Cc" address. Note: this function works
- * with the SMTP mailer on win32, not with the "mail"
- * mailer.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddCC($address, $name = "") {
- $cur = count($this->cc);
- $this->cc[$cur][0] = trim($address);
- $this->cc[$cur][1] = $name;
- }
-
- /**
- * Adds a "Bcc" address. Note: this function works
- * with the SMTP mailer on win32, not with the "mail"
- * mailer.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddBCC($address, $name = "") {
- $cur = count($this->bcc);
- $this->bcc[$cur][0] = trim($address);
- $this->bcc[$cur][1] = $name;
- }
-
- /**
- * Adds a "Reply-to" address.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddReplyTo($address, $name = "") {
- $cur = count($this->ReplyTo);
- $this->ReplyTo[$cur][0] = trim($address);
- $this->ReplyTo[$cur][1] = $name;
- }
-
-
- /////////////////////////////////////////////////
- // MAIL SENDING METHODS
- /////////////////////////////////////////////////
-
- /**
- * Creates message and assigns Mailer. If the message is
- * not sent successfully then it returns false. Use the ErrorInfo
- * variable to view description of the error.
- * @return bool
- */
- function Send() {
- $header = "";
- $body = "";
- $result = true;
- if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
- {
- $this->SetError($this->Lang("provide_address"));
- return false;
- }
+class PHPMailer {
+
+ /////////////////////////////////////////////////
+ // PROPERTIES, PUBLIC
+ /////////////////////////////////////////////////
+
+ /**
+ * Email priority (1 = High, 3 = Normal, 5 = low).
+ * @var int
+ */
+ var $Priority = 3;
+
+ /**
+ * Sets the CharSet of the message.
+ * @var string
+ */
+ var $CharSet = 'iso-8859-1';
+
+ /**
+ * Sets the Content-type of the message.
+ * @var string
+ */
+ var $ContentType = 'text/plain';
+
+ /**
+ * Sets the Encoding of the message. Options for this are "8bit",
+ * "7bit", "binary", "base64", and "quoted-printable".
+ * @var string
+ */
+ var $Encoding = '8bit';
+
+ /**
+ * Holds the most recent mailer error message.
+ * @var string
+ */
+ var $ErrorInfo = '';
+
+ /**
+ * Sets the From email address for the message.
+ * @var string
+ */
+ var $From = 'root@localhost';
+
+ /**
+ * Sets the From name of the message.
+ * @var string
+ */
+ var $FromName = 'Root User';
+
+ /**
+ * Sets the Sender email (Return-Path) of the message. If not empty,
+ * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
+ * @var string
+ */
+ var $Sender = '';
+
+ /**
+ * Sets the Subject of the message.
+ * @var string
+ */
+ var $Subject = '';
+
+ /**
+ * Sets the Body of the message. This can be either an HTML or text body.
+ * If HTML then run IsHTML(true).
+ * @var string
+ */
+ var $Body = '';
+
+ /**
+ * Sets the text-only body of the message. This automatically sets the
+ * email to multipart/alternative. This body can be read by mail
+ * clients that do not have HTML email capability such as mutt. Clients
+ * that can read HTML will view the normal Body.
+ * @var string
+ */
+ var $AltBody = '';
+
+ /**
+ * Sets word wrapping on the body of the message to a given number of
+ * characters.
+ * @var int
+ */
+ var $WordWrap = 0;
+
+ /**
+ * Method to send mail: ("mail", "sendmail", or "smtp").
+ * @var string
+ */
+ var $Mailer = 'mail';
+
+ /**
+ * Sets the path of the sendmail program.
+ * @var string
+ */
+ var $Sendmail = '/usr/sbin/sendmail';
+
+ /**
+ * Path to PHPMailer plugins. This is now only useful if the SMTP class
+ * is in a different directory than the PHP include path.
+ * @var string
+ */
+ var $PluginDir = '';
+
+ /**
+ * Holds PHPMailer version.
+ * @var string
+ */
+ var $Version = "2.0.2";
+
+ /**
+ * Sets the email address that a reading confirmation will be sent.
+ * @var string
+ */
+ var $ConfirmReadingTo = '';
+
+ /**
+ * Sets the hostname to use in Message-Id and Received headers
+ * and as default HELO string. If empty, the value returned
+ * by SERVER_NAME is used or 'localhost.localdomain'.
+ * @var string
+ */
+ var $Hostname = '';
+
+ /**
+ * Sets the message ID to be used in the Message-Id header.
+ * If empty, a unique id will be generated.
+ * @var string
+ */
+ var $MessageID = '';
+
+ /////////////////////////////////////////////////
+ // PROPERTIES FOR SMTP
+ /////////////////////////////////////////////////
+
+ /**
+ * Sets the SMTP hosts. All hosts must be separated by a
+ * semicolon. You can also specify a different port
+ * for each host by using this format: [hostname:port]
+ * (e.g. "smtp1.example.com:25;smtp2.example.com").
+ * Hosts will be tried in order.
+ * @var string
+ */
+ var $Host = 'localhost';
+
+ /**
+ * Sets the default SMTP server port.
+ * @var int
+ */
+ var $Port = 25;
+
+ /**
+ * Sets the SMTP HELO of the message (Default is $Hostname).
+ * @var string
+ */
+ var $Helo = '';
+
+ /**
+ * Sets connection prefix.
+ * Options are "", "ssl" or "tls"
+ * @var string
+ */
+ var $SMTPSecure = "";
+
+ /**
+ * Sets SMTP authentication. Utilizes the Username and Password variables.
+ * @var bool
+ */
+ var $SMTPAuth = false;
+
+ /**
+ * Sets SMTP username.
+ * @var string
+ */
+ var $Username = '';
+
+ /**
+ * Sets SMTP password.
+ * @var string
+ */
+ var $Password = '';
+
+ /**
+ * Sets the SMTP server timeout in seconds. This function will not
+ * work with the win32 version.
+ * @var int
+ */
+ var $Timeout = 10;
+
+ /**
+ * Sets SMTP class debugging on or off.
+ * @var bool
+ */
+ var $SMTPDebug = false;
+
+ /**
+ * Prevents the SMTP connection from being closed after each mail
+ * sending. If this is set to true then to close the connection
+ * requires an explicit call to SmtpClose().
+ * @var bool
+ */
+ var $SMTPKeepAlive = false;
+
+ /**
+ * Provides the ability to have the TO field process individual
+ * emails, instead of sending to entire TO addresses
+ * @var bool
+ */
+ var $SingleTo = false;
+
+ /////////////////////////////////////////////////
+ // PROPERTIES, PRIVATE
+ /////////////////////////////////////////////////
+
+ var $smtp = NULL;
+ var $to = array();
+ var $cc = array();
+ var $bcc = array();
+ var $ReplyTo = array();
+ var $attachment = array();
+ var $CustomHeader = array();
+ var $message_type = '';
+ var $boundary = array();
+ var $language = array();
+ var $error_count = 0;
+ var $LE = "\n";
+ var $sign_key_file = "";
+ var $sign_key_pass = "";
+
+ /////////////////////////////////////////////////
+ // METHODS, VARIABLES
+ /////////////////////////////////////////////////
+
+ /**
+ * Sets message type to HTML.
+ * @param bool $bool
+ * @return void
+ */
+ function IsHTML($bool) {
+ if($bool == true) {
+ $this->ContentType = 'text/html';
+ } else {
+ $this->ContentType = 'text/plain';
+ }
+ }
+
+ /**
+ * Sets Mailer to send message using SMTP.
+ * @return void
+ */
+ function IsSMTP() {
+ $this->Mailer = 'smtp';
+ }
+
+ /**
+ * Sets Mailer to send message using PHP mail() function.
+ * @return void
+ */
+ function IsMail() {
+ $this->Mailer = 'mail';
+ }
+
+ /**
+ * Sets Mailer to send message using the $Sendmail program.
+ * @return void
+ */
+ function IsSendmail() {
+ $this->Mailer = 'sendmail';
+ }
+
+ /**
+ * Sets Mailer to send message using the qmail MTA.
+ * @return void
+ */
+ function IsQmail() {
+ $this->Sendmail = '/var/qmail/bin/sendmail';
+ $this->Mailer = 'sendmail';
+ }
+
+ /////////////////////////////////////////////////
+ // METHODS, RECIPIENTS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds a "To" address.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddAddress($address, $name = '') {
+ $cur = count($this->to);
+ $this->to[$cur][0] = trim($address);
+ $this->to[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Cc" address. Note: this function works
+ * with the SMTP mailer on win32, not with the "mail"
+ * mailer.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddCC($address, $name = '') {
+ $cur = count($this->cc);
+ $this->cc[$cur][0] = trim($address);
+ $this->cc[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Bcc" address. Note: this function works
+ * with the SMTP mailer on win32, not with the "mail"
+ * mailer.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddBCC($address, $name = '') {
+ $cur = count($this->bcc);
+ $this->bcc[$cur][0] = trim($address);
+ $this->bcc[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Reply-To" address.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddReplyTo($address, $name = '') {
+ $cur = count($this->ReplyTo);
+ $this->ReplyTo[$cur][0] = trim($address);
+ $this->ReplyTo[$cur][1] = $name;
+ }
+
+ /////////////////////////////////////////////////
+ // METHODS, MAIL SENDING
+ /////////////////////////////////////////////////
+
+ /**
+ * Creates message and assigns Mailer. If the message is
+ * not sent successfully then it returns false. Use the ErrorInfo
+ * variable to view description of the error.
+ * @return bool
+ */
+ function Send() {
+ $header = '';
+ $body = '';
+ $result = true;
+
+ if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
+ $this->SetError($this->Lang('provide_address'));
+ return false;
+ }
- // Set whether the message is multipart/alternative
- if(!empty($this->AltBody))
- $this->ContentType = "multipart/alternative";
-
- $this->error_count = 0; // reset errors
- $this->SetMessageType();
- $header .= $this->CreateHeader();
- $body = $this->CreateBody();
-
- if($body == "") { return false; }
-
- // Choose the mailer
- switch($this->Mailer)
- {
- case "sendmail":
- $result = $this->SendmailSend($header, $body);
- break;
- case "mail":
- $result = $this->MailSend($header, $body);
- break;
- case "smtp":
- $result = $this->SmtpSend($header, $body);
- break;
- default:
- $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
- $result = false;
- break;
- }
+ /* Set whether the message is multipart/alternative */
+ if(!empty($this->AltBody)) {
+ $this->ContentType = 'multipart/alternative';
+ }
- return $result;
+ $this->error_count = 0; // reset errors
+ $this->SetMessageType();
+ $header .= $this->CreateHeader();
+ $body = $this->CreateBody();
+
+ if($body == '') {
+ return false;
}
- /**
- * Sends mail using the $Sendmail program.
- * @access private
- * @return bool
- */
- function SendmailSend($header, $body) {
- if ($this->Sender != "")
- $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, escapeshellarg($this->Sender));
- else
- $sendmail = sprintf("%s -oi -t", $this->Sendmail);
+ /* Choose the mailer */
+ switch($this->Mailer) {
+ case 'sendmail':
+ $result = $this->SendmailSend($header, $body);
+ break;
+ case 'smtp':
+ $result = $this->SmtpSend($header, $body);
+ break;
+ case 'mail':
+ $result = $this->MailSend($header, $body);
+ break;
+ default:
+ $result = $this->MailSend($header, $body);
+ break;
+ //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported'));
+ //$result = false;
+ //break;
+ }
- if(!@$mail = popen($sendmail, "w"))
- {
- $this->SetError($this->Lang("execute") . $this->Sendmail);
- return false;
- }
+ return $result;
+ }
+
+ /**
+ * Sends mail using the $Sendmail program.
+ * @access private
+ * @return bool
+ */
+ function SendmailSend($header, $body) {
+ if ($this->Sender != '') {
+ $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
+ } else {
+ $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
+ }
- fputs($mail, $header);
- fputs($mail, $body);
+ if(!@$mail = popen($sendmail, 'w')) {
+ $this->SetError($this->Lang('execute') . $this->Sendmail);
+ return false;
+ }
- $result = pclose($mail) >> 8 & 0xFF;
- if($result != 0)
- {
- $this->SetError($this->Lang("execute") . $this->Sendmail);
- return false;
- }
+ fputs($mail, $header);
+ fputs($mail, $body);
- return true;
+ $result = pclose($mail);
+ if (version_compare(phpversion(), '4.2.3') == -1) {
+ $result = $result >> 8 & 0xFF;
+ }
+ if($result != 0) {
+ $this->SetError($this->Lang('execute') . $this->Sendmail);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends mail using the PHP mail() function.
+ * @access private
+ * @return bool
+ */
+ function MailSend($header, $body) {
+
+ $to = '';
+ for($i = 0; $i < count($this->to); $i++) {
+ if($i != 0) { $to .= ', '; }
+ $to .= $this->AddrFormat($this->to[$i]);
}
- /**
- * Sends mail using the PHP mail() function.
- * @access private
- * @return bool
- */
- function MailSend($header, $body) {
- $to = "";
- for($i = 0; $i < count($this->to); $i++)
- {
- if($i != 0) { $to .= ", "; }
- $to .= $this->to[$i][0];
- }
+ $toArr = split(',', $to);
- if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)
- {
- $old_from = ini_get("sendmail_from");
- ini_set("sendmail_from", $this->Sender);
- $params = sprintf("-oi -f %s", $this->Sender);
- $rt = @mail($to, $this->EncodeHeader($this->Subject), $body,
- $header, $params);
+ $params = sprintf("-oi -f %s", $this->Sender);
+ if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) {
+ $old_from = ini_get('sendmail_from');
+ ini_set('sendmail_from', $this->Sender);
+ if ($this->SingleTo === true && count($toArr) > 1) {
+ foreach ($toArr as $key => $val) {
+ $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
}
- else
- $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
+ } else {
+ $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
+ }
+ } else {
+ if ($this->SingleTo === true && count($toArr) > 1) {
+ foreach ($toArr as $key => $val) {
+ $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
+ }
+ } else {
+ $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
+ }
+ }
- if (isset($old_from))
- ini_set("sendmail_from", $old_from);
+ if (isset($old_from)) {
+ ini_set('sendmail_from', $old_from);
+ }
- if(!$rt)
- {
- $this->SetError($this->Lang("instantiate"));
- return false;
- }
+ if(!$rt) {
+ $this->SetError($this->Lang('instantiate'));
+ return false;
+ }
- return true;
- }
-
- /**
- * Sends mail via SMTP using PhpSMTP (Author:
- * Chris Ryan). Returns bool. Returns false if there is a
- * bad MAIL FROM, RCPT, or DATA input.
- * @access private
- * @return bool
- */
- function SmtpSend($header, $body) {
- include_once($this->PluginDir . "class-smtp.php");
- $error = "";
- $bad_rcpt = array();
-
- if(!$this->SmtpConnect())
- return false;
-
- $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender;
- if(!$this->smtp->Mail($smtp_from))
- {
- $error = $this->Lang("from_failed") . $smtp_from;
- $this->SetError($error);
- $this->smtp->Reset();
- return false;
- }
+ return true;
+ }
+
+ /**
+ * Sends mail via SMTP using PhpSMTP (Author:
+ * Chris Ryan). Returns bool. Returns false if there is a
+ * bad MAIL FROM, RCPT, or DATA input.
+ * @access private
+ * @return bool
+ */
+ function SmtpSend($header, $body) {
+ include_once($this->PluginDir . 'class-smtp.php');
+ $error = '';
+ $bad_rcpt = array();
+
+ if(!$this->SmtpConnect()) {
+ return false;
+ }
- // Attempt to send attach all recipients
- for($i = 0; $i < count($this->to); $i++)
- {
- if(!$this->smtp->Recipient($this->to[$i][0]))
- $bad_rcpt[] = $this->to[$i][0];
- }
- for($i = 0; $i < count($this->cc); $i++)
- {
- if(!$this->smtp->Recipient($this->cc[$i][0]))
- $bad_rcpt[] = $this->cc[$i][0];
- }
- for($i = 0; $i < count($this->bcc); $i++)
- {
- if(!$this->smtp->Recipient($this->bcc[$i][0]))
- $bad_rcpt[] = $this->bcc[$i][0];
+ $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
+ if(!$this->smtp->Mail($smtp_from)) {
+ $error = $this->Lang('from_failed') . $smtp_from;
+ $this->SetError($error);
+ $this->smtp->Reset();
+ return false;
+ }
+
+ /* Attempt to send attach all recipients */
+ for($i = 0; $i < count($this->to); $i++) {
+ if(!$this->smtp->Recipient($this->to[$i][0])) {
+ $bad_rcpt[] = $this->to[$i][0];
+ }
+ }
+ for($i = 0; $i < count($this->cc); $i++) {
+ if(!$this->smtp->Recipient($this->cc[$i][0])) {
+ $bad_rcpt[] = $this->cc[$i][0];
+ }
+ }
+ for($i = 0; $i < count($this->bcc); $i++) {
+ if(!$this->smtp->Recipient($this->bcc[$i][0])) {
+ $bad_rcpt[] = $this->bcc[$i][0];
+ }
+ }
+
+ if(count($bad_rcpt) > 0) { // Create error message
+ for($i = 0; $i < count($bad_rcpt); $i++) {
+ if($i != 0) {
+ $error .= ', ';
}
+ $error .= $bad_rcpt[$i];
+ }
+ $error = $this->Lang('recipients_failed') . $error;
+ $this->SetError($error);
+ $this->smtp->Reset();
+ return false;
+ }
- if(count($bad_rcpt) > 0) // Create error message
- {
- for($i = 0; $i < count($bad_rcpt); $i++)
- {
- if($i != 0) { $error .= ", "; }
- $error .= $bad_rcpt[$i];
- }
- $error = $this->Lang("recipients_failed") . $error;
- $this->SetError($error);
- $this->smtp->Reset();
- return false;
+ if(!$this->smtp->Data($header . $body)) {
+ $this->SetError($this->Lang('data_not_accepted'));
+ $this->smtp->Reset();
+ return false;
+ }
+ if($this->SMTPKeepAlive == true) {
+ $this->smtp->Reset();
+ } else {
+ $this->SmtpClose();
+ }
+
+ return true;
+ }
+
+ /**
+ * Initiates a connection to an SMTP server. Returns false if the
+ * operation failed.
+ * @access private
+ * @return bool
+ */
+ function SmtpConnect() {
+ if($this->smtp == NULL) {
+ $this->smtp = new SMTP();
+ }
+
+ $this->smtp->do_debug = $this->SMTPDebug;
+ $hosts = explode(';', $this->Host);
+ $index = 0;
+ $connection = ($this->smtp->Connected());
+
+ /* Retry while there is no connection */
+ while($index < count($hosts) && $connection == false) {
+ $hostinfo = array();
+ if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {
+ $host = $hostinfo[1];
+ $port = $hostinfo[2];
+ } else {
+ $host = $hosts[$index];
+ $port = $this->Port;
+ }
+
+ if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) {
+ if ($this->Helo != '') {
+ $this->smtp->Hello($this->Helo);
+ } else {
+ $this->smtp->Hello($this->ServerHostname());
}
- if(!$this->smtp->Data($header . $body))
- {
- $this->SetError($this->Lang("data_not_accepted"));
+ $connection = true;
+ if($this->SMTPAuth) {
+ if(!$this->smtp->Authenticate($this->Username, $this->Password)) {
+ $this->SetError($this->Lang('authenticate'));
$this->smtp->Reset();
- return false;
+ $connection = false;
+ }
}
- if($this->SMTPKeepAlive == true)
- $this->smtp->Reset();
- else
- $this->SmtpClose();
-
- return true;
- }
-
- /**
- * Initiates a connection to an SMTP server. Returns false if the
- * operation failed.
- * @access private
- * @return bool
- */
- function SmtpConnect() {
- if($this->smtp == NULL) { $this->smtp = new SMTP(); }
-
- $this->smtp->do_debug = $this->SMTPDebug;
- $hosts = explode(";", $this->Host);
- $index = 0;
- $connection = ($this->smtp->Connected());
-
- // Retry while there is no connection
- while($index < count($hosts) && $connection == false)
- {
- if(strstr($hosts[$index], ":"))
- list($host, $port) = explode(":", $hosts[$index]);
- else
- {
- $host = $hosts[$index];
- $port = $this->Port;
- }
+ }
+ $index++;
+ }
+ if(!$connection) {
+ $this->SetError($this->Lang('connect_host'));
+ }
- if($this->smtp->Connect($host, $port, $this->Timeout))
- {
- if ($this->Helo != '')
- $this->smtp->Hello($this->Helo);
- else
- $this->smtp->Hello($this->ServerHostname());
-
- if($this->SMTPAuth)
- {
- if(!$this->smtp->Authenticate($this->Username,
- $this->Password))
- {
- $this->SetError($this->Lang("authenticate"));
- $this->smtp->Reset();
- $connection = false;
- }
- }
- $connection = true;
- }
- $index++;
- }
- if(!$connection)
- $this->SetError($this->Lang("connect_host"));
-
- return $connection;
- }
-
- /**
- * Closes the active SMTP session if one exists.
- * @return void
- */
- function SmtpClose() {
- if($this->smtp != NULL)
- {
- if($this->smtp->Connected())
- {
- $this->smtp->Quit();
- $this->smtp->Close();
- }
- }
+ return $connection;
+ }
+
+ /**
+ * Closes the active SMTP session if one exists.
+ * @return void
+ */
+ function SmtpClose() {
+ if($this->smtp != NULL) {
+ if($this->smtp->Connected()) {
+ $this->smtp->Quit();
+ $this->smtp->Close();
+ }
+ }
+ }
+
+ /**
+ * Sets the language for all class error messages. Returns false
+ * if it cannot load the language file. The default language type
+ * is English.
+ * @param string $lang_type Type of language (e.g. Portuguese: "br")
+ * @param string $lang_path Path to the language file directory
+ * @access public
+ * @return bool
+ */
+ function SetLanguage($lang_type, $lang_path = 'language/') {
+ if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) {
+ include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
+ } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) {
+ include($lang_path.'phpmailer.lang-en.php');
+ } else {
+ $this->SetError('Could not load language file');
+ return false;
+ }
+ $this->language = $PHPMAILER_LANG;
+
+ return true;
+ }
+
+ /////////////////////////////////////////////////
+ // METHODS, MESSAGE CREATION
+ /////////////////////////////////////////////////
+
+ /**
+ * Creates recipient headers.
+ * @access private
+ * @return string
+ */
+ function AddrAppend($type, $addr) {
+ $addr_str = $type . ': ';
+ $addr_str .= $this->AddrFormat($addr[0]);
+ if(count($addr) > 1) {
+ for($i = 1; $i < count($addr); $i++) {
+ $addr_str .= ', ' . $this->AddrFormat($addr[$i]);
+ }
+ }
+ $addr_str .= $this->LE;
+
+ return $addr_str;
+ }
+
+ /**
+ * Formats an address correctly.
+ * @access private
+ * @return string
+ */
+ function AddrFormat($addr) {
+ if(empty($addr[1])) {
+ $formatted = $this->SecureHeader($addr[0]);
+ } else {
+ $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
}
- /**
- * Sets the language for all class error messages. Returns false
- * if it cannot load the language file. The default language type
- * is English.
- * @param string $lang_type Type of language (e.g. Portuguese: "br")
- * @param string $lang_path Path to the language file directory
- * @access public
- * @return bool
- */
- function SetLanguage($lang_type, $lang_path = "language/") {
- if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php'))
- include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
- else if(file_exists($lang_path.'phpmailer.lang-en.php'))
- include($lang_path.'phpmailer.lang-en.php');
- else
- {
- $this->SetError("Could not load language file");
- return false;
- }
- $this->language = $PHPMAILER_LANG;
-
- return true;
- }
-
- /////////////////////////////////////////////////
- // MESSAGE CREATION METHODS
- /////////////////////////////////////////////////
-
- /**
- * Creates recipient headers.
- * @access private
- * @return string
- */
- function AddrAppend($type, $addr) {
- $addr_str = $type . ": ";
- $addr_str .= $this->AddrFormat($addr[0]);
- if(count($addr) > 1)
- {
- for($i = 1; $i < count($addr); $i++)
- $addr_str .= ", " . $this->AddrFormat($addr[$i]);
- }
- $addr_str .= $this->LE;
-
- return $addr_str;
- }
-
- /**
- * Formats an address correctly.
- * @access private
- * @return string
- */
- function AddrFormat($addr) {
- if(empty($addr[1]))
- $formatted = $addr[0];
- else
- {
- $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" .
- $addr[0] . ">";
- }
+ return $formatted;
+ }
+
+ /**
+ * Wraps message for use with mailers that do not
+ * automatically perform wrapping and for quoted-printable.
+ * Original written by philippe.
+ * @access private
+ * @return string
+ */
+ function WrapText($message, $length, $qp_mode = false) {
+ $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
+ // If utf-8 encoding is used, we will need to make sure we don't
+ // split multibyte characters when we wrap
+ $is_utf8 = (strtolower($this->CharSet) == "utf-8");
+
+ $message = $this->FixEOL($message);
+ if (substr($message, -1) == $this->LE) {
+ $message = substr($message, 0, -1);
+ }
- return $formatted;
- }
-
- /**
- * Wraps message for use with mailers that do not
- * automatically perform wrapping and for quoted-printable.
- * Original written by philippe.
- * @access private
- * @return string
- */
- function WrapText($message, $length, $qp_mode = false) {
- $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
-
- $message = $this->FixEOL($message);
- if (substr($message, -1) == $this->LE)
- $message = substr($message, 0, -1);
-
- $line = explode($this->LE, $message);
- $message = "";
- for ($i=0 ;$i < count($line); $i++)
- {
- $line_part = explode(" ", $line[$i]);
- $buf = "";
- for ($e = 0; $e<count($line_part); $e++)
- {
- $word = $line_part[$e];
- if ($qp_mode and (strlen($word) > $length))
- {
- $space_left = $length - strlen($buf) - 1;
- if ($e != 0)
- {
- if ($space_left > 20)
- {
- $len = $space_left;
- if (substr($word, $len - 1, 1) == "=")
- $len--;
- elseif (substr($word, $len - 2, 1) == "=")
- $len -= 2;
- $part = substr($word, 0, $len);
- $word = substr($word, $len);
- $buf .= " " . $part;
- $message .= $buf . sprintf("=%s", $this->LE);
- }
- else
- {
- $message .= $buf . $soft_break;
- }
- $buf = "";
- }
- while (strlen($word) > 0)
- {
- $len = $length;
- if (substr($word, $len - 1, 1) == "=")
- $len--;
- elseif (substr($word, $len - 2, 1) == "=")
- $len -= 2;
- $part = substr($word, 0, $len);
- $word = substr($word, $len);
-
- if (strlen($word) > 0)
- $message .= $part . sprintf("=%s", $this->LE);
- else
- $buf = $part;
- }
- }
- else
- {
- $buf_o = $buf;
- $buf .= ($e == 0) ? $word : (" " . $word);
-
- if (strlen($buf) > $length and $buf_o != "")
- {
- $message .= $buf_o . $soft_break;
- $buf = $word;
- }
+ $line = explode($this->LE, $message);
+ $message = '';
+ for ($i=0 ;$i < count($line); $i++) {
+ $line_part = explode(' ', $line[$i]);
+ $buf = '';
+ for ($e = 0; $e<count($line_part); $e++) {
+ $word = $line_part[$e];
+ if ($qp_mode and (strlen($word) > $length)) {
+ $space_left = $length - strlen($buf) - 1;
+ if ($e != 0) {
+ if ($space_left > 20) {
+ $len = $space_left;
+ if ($is_utf8) {
+ $len = $this->UTF8CharBoundary($word, $len);
+ } elseif (substr($word, $len - 1, 1) == "=") {
+ $len--;
+ } elseif (substr($word, $len - 2, 1) == "=") {
+ $len -= 2;
}
+ $part = substr($word, 0, $len);
+ $word = substr($word, $len);
+ $buf .= ' ' . $part;
+ $message .= $buf . sprintf("=%s", $this->LE);
+ } else {
+ $message .= $buf . $soft_break;
+ }
+ $buf = '';
}
- $message .= $buf . $this->LE;
- }
+ while (strlen($word) > 0) {
+ $len = $length;
+ if ($is_utf8) {
+ $len = $this->UTF8CharBoundary($word, $len);
+ } elseif (substr($word, $len - 1, 1) == "=") {
+ $len--;
+ } elseif (substr($word, $len - 2, 1) == "=") {
+ $len -= 2;
+ }
+ $part = substr($word, 0, $len);
+ $word = substr($word, $len);
- return $message;
- }
-
- /**
- * Set the body wrapping.
- * @access private
- * @return void
- */
- function SetWordWrap() {
- if($this->WordWrap < 1)
- return;
-
- switch($this->message_type)
- {
- case "alt":
- // fall through
- case "alt_attachments":
- $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
- break;
- default:
- $this->Body = $this->WrapText($this->Body, $this->WordWrap);
- break;
+ if (strlen($word) > 0) {
+ $message .= $part . sprintf("=%s", $this->LE);
+ } else {
+ $buf = $part;
+ }
+ }
+ } else {
+ $buf_o = $buf;
+ $buf .= ($e == 0) ? $word : (' ' . $word);
+
+ if (strlen($buf) > $length and $buf_o != '') {
+ $message .= $buf_o . $soft_break;
+ $buf = $word;
+ }
}
+ }
+ $message .= $buf . $this->LE;
}
- /**
- * Assembles message header.
- * @access private
- * @return string
- */
- function CreateHeader() {
- $result = "";
-
- // Set the boundaries
- $uniq_id = md5(uniqid(time()));
- $this->boundary[1] = "b1_" . $uniq_id;
- $this->boundary[2] = "b2_" . $uniq_id;
-
- $result .= $this->HeaderLine("Date", $this->RFCDate());
- if($this->Sender == "")
- $result .= $this->HeaderLine("Return-Path", trim($this->From));
- else
- $result .= $this->HeaderLine("Return-Path", trim($this->Sender));
-
- // To be created automatically by mail()
- if($this->Mailer != "mail")
- {
- if(count($this->to) > 0)
- $result .= $this->AddrAppend("To", $this->to);
- else if (count($this->cc) == 0)
- $result .= $this->HeaderLine("To", "undisclosed-recipients:;");
- if(count($this->cc) > 0)
- $result .= $this->AddrAppend("Cc", $this->cc);
+ return $message;
+ }
+
+ /**
+ * Finds last character boundary prior to maxLength in a utf-8
+ * quoted (printable) encoded string.
+ * Original written by Colin Brown.
+ * @access private
+ * @param string $encodedText utf-8 QP text
+ * @param int $maxLength find last character boundary prior to this length
+ * @return int
+ */
+ function UTF8CharBoundary($encodedText, $maxLength) {
+ $foundSplitPos = false;
+ $lookBack = 3;
+ while (!$foundSplitPos) {
+ $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
+ $encodedCharPos = strpos($lastChunk, "=");
+ if ($encodedCharPos !== false) {
+ // Found start of encoded character byte within $lookBack block.
+ // Check the encoded byte value (the 2 chars after the '=')
+ $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
+ $dec = hexdec($hex);
+ if ($dec < 128) { // Single byte character.
+ // If the encoded char was found at pos 0, it will fit
+ // otherwise reduce maxLength to start of the encoded char
+ $maxLength = ($encodedCharPos == 0) ? $maxLength :
+ $maxLength - ($lookBack - $encodedCharPos);
+ $foundSplitPos = true;
+ } elseif ($dec >= 192) { // First byte of a multi byte character
+ // Reduce maxLength to split at start of character
+ $maxLength = $maxLength - ($lookBack - $encodedCharPos);
+ $foundSplitPos = true;
+ } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
+ $lookBack += 3;
}
+ } else {
+ // No encoded character found
+ $foundSplitPos = true;
+ }
+ }
+ return $maxLength;
+ }
+
+ /**
+ * Set the body wrapping.
+ * @access private
+ * @return void
+ */
+ function SetWordWrap() {
+ if($this->WordWrap < 1) {
+ return;
+ }
+
+ switch($this->message_type) {
+ case 'alt':
+ /* fall through */
+ case 'alt_attachments':
+ $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
+ break;
+ default:
+ $this->Body = $this->WrapText($this->Body, $this->WordWrap);
+ break;
+ }
+ }
+
+ /**
+ * Assembles message header.
+ * @access private
+ * @return string
+ */
+ function CreateHeader() {
+ $result = '';
+
+ /* Set the boundaries */
+ $uniq_id = md5(uniqid(time()));
+ $this->boundary[1] = 'b1_' . $uniq_id;
+ $this->boundary[2] = 'b2_' . $uniq_id;
+
+ $result .= $this->HeaderLine('Date', $this->RFCDate());
+ if($this->Sender == '') {
+ $result .= $this->HeaderLine('Return-Path', trim($this->From));
+ } else {
+ $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
+ }
+
+ /* To be created automatically by mail() */
+ if($this->Mailer != 'mail') {
+ if(count($this->to) > 0) {
+ $result .= $this->AddrAppend('To', $this->to);
+ } elseif (count($this->cc) == 0) {
+ $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
+ }
+ if(count($this->cc) > 0) {
+ $result .= $this->AddrAppend('Cc', $this->cc);
+ }
+ }
- $from = array();
- $from[0][0] = trim($this->From);
- $from[0][1] = $this->FromName;
- $result .= $this->AddrAppend("From", $from);
+ $from = array();
+ $from[0][0] = trim($this->From);
+ $from[0][1] = $this->FromName;
+ $result .= $this->AddrAppend('From', $from);
- // sendmail and mail() extract Bcc from the header before sending
- if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
- $result .= $this->AddrAppend("Bcc", $this->bcc);
+ /* sendmail and mail() extract Cc from the header before sending */
+ if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) {
+ $result .= $this->AddrAppend('Cc', $this->cc);
+ }
- if(count($this->ReplyTo) > 0)
- $result .= $this->AddrAppend("Reply-to", $this->ReplyTo);
+ /* sendmail and mail() extract Bcc from the header before sending */
+ if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
+ $result .= $this->AddrAppend('Bcc', $this->bcc);
+ }
- // mail() sets the subject itself
- if($this->Mailer != "mail")
- $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject)));
+ if(count($this->ReplyTo) > 0) {
+ $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);
+ }
- $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
- $result .= $this->HeaderLine("X-Priority", $this->Priority);
+ /* mail() sets the subject itself */
+ if($this->Mailer != 'mail') {
+ $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
+ }
- if($this->ConfirmReadingTo != "")
- {
- $result .= $this->HeaderLine("Disposition-Notification-To",
- "<" . trim($this->ConfirmReadingTo) . ">");
- }
+ if($this->MessageID != '') {
+ $result .= $this->HeaderLine('Message-ID',$this->MessageID);
+ } else {
+ $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
+ }
+ $result .= $this->HeaderLine('X-Priority', $this->Priority);
+ $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']');
- // Add custom headers
- for($index = 0; $index < count($this->CustomHeader); $index++)
- {
- $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]),
- $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
- }
- $result .= $this->HeaderLine("MIME-Version", "1.0");
-
- switch($this->message_type)
- {
- case "plain":
- $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding);
- $result .= sprintf("Content-Type: %s; charset=\"%s\"",
- $this->ContentType, $this->CharSet);
- break;
- case "attachments":
- // fall through
- case "alt_attachments":
- if($this->InlineImageExists())
- {
- $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s",
- "multipart/related", $this->LE, $this->LE,
- $this->boundary[1], $this->LE);
- }
- else
- {
- $result .= $this->HeaderLine("Content-Type", "multipart/mixed;");
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
- }
- break;
- case "alt":
- $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
- break;
- }
+ if($this->ConfirmReadingTo != '') {
+ $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
+ }
- if($this->Mailer != "mail")
- $result .= $this->LE.$this->LE;
-
- return $result;
- }
-
- /**
- * Assembles the message body. Returns an empty string on failure.
- * @access private
- * @return string
- */
- function CreateBody() {
- $result = "";
-
- $this->SetWordWrap();
-
- switch($this->message_type)
- {
- case "alt":
- $result .= $this->GetBoundary($this->boundary[1], "",
- "text/plain", "");
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
- $result .= $this->LE.$this->LE;
- $result .= $this->GetBoundary($this->boundary[1], "",
- "text/html", "");
-
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- $result .= $this->EndBoundary($this->boundary[1]);
- break;
- case "plain":
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- break;
- case "attachments":
- $result .= $this->GetBoundary($this->boundary[1], "", "", "");
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE;
-
- $result .= $this->AttachAll();
- break;
- case "alt_attachments":
- $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
- $result .= sprintf("Content-Type: %s;%s" .
- "\tboundary=\"%s\"%s",
- "multipart/alternative", $this->LE,
- $this->boundary[2], $this->LE.$this->LE);
-
- // Create text body
- $result .= $this->GetBoundary($this->boundary[2], "",
- "text/plain", "") . $this->LE;
-
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- // Create the HTML body
- $result .= $this->GetBoundary($this->boundary[2], "",
- "text/html", "") . $this->LE;
-
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- $result .= $this->EndBoundary($this->boundary[2]);
-
- $result .= $this->AttachAll();
- break;
+ // Add custom headers
+ for($index = 0; $index < count($this->CustomHeader); $index++) {
+ $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
+ }
+ if (!$this->sign_key_file) {
+ $result .= $this->HeaderLine('MIME-Version', '1.0');
+ $result .= $this->GetMailMIME();
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns the message MIME.
+ * @access private
+ * @return string
+ */
+ function GetMailMIME() {
+ $result = '';
+ switch($this->message_type) {
+ case 'plain':
+ $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
+ $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
+ break;
+ case 'attachments':
+ /* fall through */
+ case 'alt_attachments':
+ if($this->InlineImageExists()){
+ $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
+ } else {
+ $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
+ $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
}
- if($this->IsError())
- $result = "";
+ break;
+ case 'alt':
+ $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
+ $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+ break;
+ }
- return $result;
+ if($this->Mailer != 'mail') {
+ $result .= $this->LE.$this->LE;
}
- /**
- * Returns the start of a message boundary.
- * @access private
- */
- function GetBoundary($boundary, $charSet, $contentType, $encoding) {
- $result = "";
- if($charSet == "") { $charSet = $this->CharSet; }
- if($contentType == "") { $contentType = $this->ContentType; }
- if($encoding == "") { $encoding = $this->Encoding; }
+ return $result;
+ }
+
+ /**
+ * Assembles the message body. Returns an empty string on failure.
+ * @access private
+ * @return string
+ */
+ function CreateBody() {
+ $result = '';
+ if ($this->sign_key_file) {
+ $result .= $this->GetMailMIME();
+ }
- $result .= $this->TextLine("--" . $boundary);
- $result .= sprintf("Content-Type: %s; charset = \"%s\"",
- $contentType, $charSet);
+ $this->SetWordWrap();
+
+ switch($this->message_type) {
+ case 'alt':
+ $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
+ $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+ $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+ $result .= $this->EndBoundary($this->boundary[1]);
+ break;
+ case 'plain':
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ break;
+ case 'attachments':
+ $result .= $this->GetBoundary($this->boundary[1], '', '', '');
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
$result .= $this->LE;
- $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding);
- $result .= $this->LE;
-
- return $result;
- }
-
- /**
- * Returns the end of a message boundary.
- * @access private
- */
- function EndBoundary($boundary) {
- return $this->LE . "--" . $boundary . "--" . $this->LE;
- }
-
- /**
- * Sets the message type.
- * @access private
- * @return void
- */
- function SetMessageType() {
- if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
- $this->message_type = "plain";
- else
- {
- if(count($this->attachment) > 0)
- $this->message_type = "attachments";
- if(strlen($this->AltBody) > 0 && count($this->attachment) < 1)
- $this->message_type = "alt";
- if(strlen($this->AltBody) > 0 && count($this->attachment) > 0)
- $this->message_type = "alt_attachments";
- }
+ $result .= $this->AttachAll();
+ break;
+ case 'alt_attachments':
+ $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
+ $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
+ $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
+ $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+ $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+ $result .= $this->EndBoundary($this->boundary[2]);
+ $result .= $this->AttachAll();
+ break;
}
- /**
- * Returns a formatted header line.
- * @access private
- * @return string
- */
- function HeaderLine($name, $value) {
- return $name . ": " . $value . $this->LE;
- }
-
- /**
- * Returns a formatted mail line.
- * @access private
- * @return string
- */
- function TextLine($value) {
- return $value . $this->LE;
- }
-
- /////////////////////////////////////////////////
- // ATTACHMENT METHODS
- /////////////////////////////////////////////////
-
- /**
- * Adds an attachment from a path on the filesystem.
- * Returns false if the file could not be found
- * or accessed.
- * @param string $path Path to the attachment.
- * @param string $name Overrides the attachment name.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return bool
- */
- function AddAttachment($path, $name = "", $encoding = "base64",
- $type = "application/octet-stream") {
- if(!@is_file($path))
- {
- $this->SetError($this->Lang("file_access") . $path);
- return false;
- }
+ if($this->IsError()) {
+ $result = '';
+ } else if ($this->sign_key_file) {
+ $file = tempnam("", "mail");
+ $fp = fopen($file, "w");
+ fwrite($fp, $result);
+ fclose($fp);
+ $signed = tempnam("", "signed");
+
+ if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_key_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) {
+ $fp = fopen($signed, "r");
+ $result = fread($fp, filesize($this->sign_key_file));
+ fclose($fp);
+ } else {
+ $this->SetError($this->Lang("signing").openssl_error_string());
+ $result = '';
+ }
- $filename = basename($path);
- if($name == "")
- $name = $filename;
-
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $path;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $name;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = false; // isStringAttachment
- $this->attachment[$cur][6] = "attachment";
- $this->attachment[$cur][7] = 0;
-
- return true;
- }
-
- /**
- * Attaches all fs, string, and binary attachments to the message.
- * Returns an empty string on failure.
- * @access private
- * @return string
- */
- function AttachAll() {
- // Return text of body
- $mime = array();
-
- // Add all attachments
- for($i = 0; $i < count($this->attachment); $i++)
- {
- // Check for string attachment
- $bString = $this->attachment[$i][5];
- if ($bString)
- $string = $this->attachment[$i][0];
- else
- $path = $this->attachment[$i][0];
-
- $filename = $this->attachment[$i][1];
- $name = $this->attachment[$i][2];
- $encoding = $this->attachment[$i][3];
- $type = $this->attachment[$i][4];
- $disposition = $this->attachment[$i][6];
- $cid = $this->attachment[$i][7];
-
- $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
- $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
- $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
-
- if($disposition == "inline")
- $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
-
- $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s",
- $disposition, $name, $this->LE.$this->LE);
-
- // Encode as string attachment
- if($bString)
- {
- $mime[] = $this->EncodeString($string, $encoding);
- if($this->IsError()) { return ""; }
- $mime[] = $this->LE.$this->LE;
- }
- else
- {
- $mime[] = $this->EncodeFile($path, $encoding);
- if($this->IsError()) { return ""; }
- $mime[] = $this->LE.$this->LE;
- }
- }
+ unlink($file);
+ unlink($signed);
+ }
- $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
+ return $result;
+ }
+
+ /**
+ * Returns the start of a message boundary.
+ * @access private
+ */
+ function GetBoundary($boundary, $charSet, $contentType, $encoding) {
+ $result = '';
+ if($charSet == '') {
+ $charSet = $this->CharSet;
+ }
+ if($contentType == '') {
+ $contentType = $this->ContentType;
+ }
+ if($encoding == '') {
+ $encoding = $this->Encoding;
+ }
+ $result .= $this->TextLine('--' . $boundary);
+ $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
+ $result .= $this->LE;
+ $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
+ $result .= $this->LE;
+
+ return $result;
+ }
+
+ /**
+ * Returns the end of a message boundary.
+ * @access private
+ */
+ function EndBoundary($boundary) {
+ return $this->LE . '--' . $boundary . '--' . $this->LE;
+ }
+
+ /**
+ * Sets the message type.
+ * @access private
+ * @return void
+ */
+ function SetMessageType() {
+ if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
+ $this->message_type = 'plain';
+ } else {
+ if(count($this->attachment) > 0) {
+ $this->message_type = 'attachments';
+ }
+ if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
+ $this->message_type = 'alt';
+ }
+ if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
+ $this->message_type = 'alt_attachments';
+ }
+ }
+ }
+
+ /* Returns a formatted header line.
+ * @access private
+ * @return string
+ */
+ function HeaderLine($name, $value) {
+ return $name . ': ' . $value . $this->LE;
+ }
+
+ /**
+ * Returns a formatted mail line.
+ * @access private
+ * @return string
+ */
+ function TextLine($value) {
+ return $value . $this->LE;
+ }
+
+ /////////////////////////////////////////////////
+ // CLASS METHODS, ATTACHMENTS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds an attachment from a path on the filesystem.
+ * Returns false if the file could not be found
+ * or accessed.
+ * @param string $path Path to the attachment.
+ * @param string $name Overrides the attachment name.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return bool
+ */
+ function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
+ if(!@is_file($path)) {
+ $this->SetError($this->Lang('file_access') . $path);
+ return false;
+ }
- return join("", $mime);
+ $filename = basename($path);
+ if($name == '') {
+ $name = $filename;
}
- /**
- * Encodes attachment in requested format. Returns an
- * empty string on failure.
- * @access private
- * @return string
- */
- function EncodeFile ($path, $encoding = "base64") {
- if(!@$fd = fopen($path, "rb"))
- {
- $this->SetError($this->Lang("file_open") . $path);
- return "";
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $path;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $name;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = false; // isStringAttachment
+ $this->attachment[$cur][6] = 'attachment';
+ $this->attachment[$cur][7] = 0;
+
+ return true;
+ }
+
+ /**
+ * Attaches all fs, string, and binary attachments to the message.
+ * Returns an empty string on failure.
+ * @access private
+ * @return string
+ */
+ function AttachAll() {
+ /* Return text of body */
+ $mime = array();
+
+ /* Add all attachments */
+ for($i = 0; $i < count($this->attachment); $i++) {
+ /* Check for string attachment */
+ $bString = $this->attachment[$i][5];
+ if ($bString) {
+ $string = $this->attachment[$i][0];
+ } else {
+ $path = $this->attachment[$i][0];
+ }
+
+ $filename = $this->attachment[$i][1];
+ $name = $this->attachment[$i][2];
+ $encoding = $this->attachment[$i][3];
+ $type = $this->attachment[$i][4];
+ $disposition = $this->attachment[$i][6];
+ $cid = $this->attachment[$i][7];
+
+ $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
+ $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
+ $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
+
+ if($disposition == 'inline') {
+ $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
+ }
+
+ $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE);
+
+ /* Encode as string attachment */
+ if($bString) {
+ $mime[] = $this->EncodeString($string, $encoding);
+ if($this->IsError()) {
+ return '';
}
- $magic_quotes = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
- $file_buffer = fread($fd, filesize($path));
- $file_buffer = $this->EncodeString($file_buffer, $encoding);
- fclose($fd);
- set_magic_quotes_runtime($magic_quotes);
-
- return $file_buffer;
- }
-
- /**
- * Encodes string to requested format. Returns an
- * empty string on failure.
- * @access private
- * @return string
- */
- function EncodeString ($str, $encoding = "base64") {
- $encoded = "";
- switch(strtolower($encoding)) {
- case "base64":
- // chunk_split is found in PHP >= 3.0.6
- $encoded = chunk_split(base64_encode($str), 76, $this->LE);
- break;
- case "7bit":
- case "8bit":
- $encoded = $this->FixEOL($str);
- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
- $encoded .= $this->LE;
- break;
- case "binary":
- $encoded = $str;
- break;
- case "quoted-printable":
- $encoded = $this->EncodeQP($str);
- break;
- default:
- $this->SetError($this->Lang("encoding") . $encoding);
- break;
+ $mime[] = $this->LE.$this->LE;
+ } else {
+ $mime[] = $this->EncodeFile($path, $encoding);
+ if($this->IsError()) {
+ return '';
}
- return $encoded;
- }
-
- /**
- * Encode a header string to best of Q, B, quoted or none.
- * @access private
- * @return string
- */
- function EncodeHeader ($str, $position = 'text') {
- $x = 0;
-
- switch (strtolower($position)) {
- case 'phrase':
- if (!preg_match('/[\200-\377]/', $str)) {
- // Can't use addslashes as we don't know what value has magic_quotes_sybase.
- $encoded = addcslashes($str, "\0..\37\177\\\"");
-
- if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
- return ($encoded);
- else
- return ("\"$encoded\"");
- }
- $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
- break;
- case 'comment':
- $x = preg_match_all('/[()"]/', $str, $matches);
- // Fall-through
- case 'text':
- default:
- $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
- break;
+ $mime[] = $this->LE.$this->LE;
}
+ }
- if ($x == 0)
- return ($str);
+ $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
+
+ return join('', $mime);
+ }
+
+ /**
+ * Encodes attachment in requested format. Returns an
+ * empty string on failure.
+ * @access private
+ * @return string
+ */
+ function EncodeFile ($path, $encoding = 'base64') {
+ if(!@$fd = fopen($path, 'rb')) {
+ $this->SetError($this->Lang('file_open') . $path);
+ return '';
+ }
+ $magic_quotes = get_magic_quotes_runtime();
+ set_magic_quotes_runtime(0);
+ $file_buffer = fread($fd, filesize($path));
+ $file_buffer = $this->EncodeString($file_buffer, $encoding);
+ fclose($fd);
+ set_magic_quotes_runtime($magic_quotes);
+
+ return $file_buffer;
+ }
+
+ /**
+ * Encodes string to requested format. Returns an
+ * empty string on failure.
+ * @access private
+ * @return string
+ */
+ function EncodeString ($str, $encoding = 'base64') {
+ $encoded = '';
+ switch(strtolower($encoding)) {
+ case 'base64':
+ /* chunk_split is found in PHP >= 3.0.6 */
+ $encoded = chunk_split(base64_encode($str), 76, $this->LE);
+ break;
+ case '7bit':
+ case '8bit':
+ $encoded = $this->FixEOL($str);
+ if (substr($encoded, -(strlen($this->LE))) != $this->LE)
+ $encoded .= $this->LE;
+ break;
+ case 'binary':
+ $encoded = $str;
+ break;
+ case 'quoted-printable':
+ $encoded = $this->EncodeQP($str);
+ break;
+ default:
+ $this->SetError($this->Lang('encoding') . $encoding);
+ break;
+ }
+ return $encoded;
+ }
+
+ /**
+ * Encode a header string to best of Q, B, quoted or none.
+ * @access private
+ * @return string
+ */
+ function EncodeHeader ($str, $position = 'text') {
+ $x = 0;
+
+ switch (strtolower($position)) {
+ case 'phrase':
+ if (!preg_match('/[\200-\377]/', $str)) {
+ /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */
+ $encoded = addcslashes($str, "\0..\37\177\\\"");
+ if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
+ return ($encoded);
+ } else {
+ return ("\"$encoded\"");
+ }
+ }
+ $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
+ break;
+ case 'comment':
+ $x = preg_match_all('/[()"]/', $str, $matches);
+ /* Fall-through */
+ case 'text':
+ default:
+ $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
+ break;
+ }
+
+ if ($x == 0) {
+ return ($str);
+ }
- $maxlen = 75 - 7 - strlen($this->CharSet);
- // Try to select the encoding which should produce the shortest output
- if (strlen($str)/3 < $x) {
- $encoding = 'B';
+ $maxlen = 75 - 7 - strlen($this->CharSet);
+ /* Try to select the encoding which should produce the shortest output */
+ if (strlen($str)/3 < $x) {
+ $encoding = 'B';
+ if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
+ // Use a custom function which correctly encodes and wraps long
+ // multibyte strings without breaking lines within a character
+ $encoded = $this->Base64EncodeWrapMB($str);
+ } else {
$encoded = base64_encode($str);
$maxlen -= $maxlen % 4;
$encoded = trim(chunk_split($encoded, $maxlen, "\n"));
- } else {
- $encoding = 'Q';
- $encoded = $this->EncodeQ($str, $position);
- $encoded = $this->WrapText($encoded, $maxlen, true);
- $encoded = str_replace("=".$this->LE, "\n", trim($encoded));
}
+ } else {
+ $encoding = 'Q';
+ $encoded = $this->EncodeQ($str, $position);
+ $encoded = $this->WrapText($encoded, $maxlen, true);
+ $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
+ }
- $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
- $encoded = trim(str_replace("\n", $this->LE, $encoded));
+ $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
+ $encoded = trim(str_replace("\n", $this->LE, $encoded));
+
+ return $encoded;
+ }
+
+ /**
+ * Checks if a string contains multibyte characters.
+ * @access private
+ * @param string $str multi-byte text to wrap encode
+ * @return bool
+ */
+ function HasMultiBytes($str) {
+ if (function_exists('mb_strlen')) {
+ return (strlen($str) > mb_strlen($str, $this->CharSet));
+ } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
+ return False;
+ }
+ }
+
+ /**
+ * Correctly encodes and wraps long multibyte strings for mail headers
+ * without breaking lines within a character.
+ * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
+ * @access private
+ * @param string $str multi-byte text to wrap encode
+ * @return string
+ */
+ function Base64EncodeWrapMB($str) {
+ $start = "=?".$this->CharSet."?B?";
+ $end = "?=";
+ $encoded = "";
+
+ $mb_length = mb_strlen($str, $this->CharSet);
+ // Each line must have length <= 75, including $start and $end
+ $length = 75 - strlen($start) - strlen($end);
+ // Average multi-byte ratio
+ $ratio = $mb_length / strlen($str);
+ // Base64 has a 4:3 ratio
+ $offset = $avgLength = floor($length * $ratio * .75);
+
+ for ($i = 0; $i < $mb_length; $i += $offset) {
+ $lookBack = 0;
+
+ do {
+ $offset = $avgLength - $lookBack;
+ $chunk = mb_substr($str, $i, $offset, $this->CharSet);
+ $chunk = base64_encode($chunk);
+ $lookBack++;
+ }
+ while (strlen($chunk) > $length);
- return $encoded;
+ $encoded .= $chunk . $this->LE;
}
- /**
- * Encode string to quoted-printable.
- * @access private
- * @return string
- */
- function EncodeQP ($str) {
- $encoded = $this->FixEOL($str);
- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
- $encoded .= $this->LE;
-
- // Replace every high ascii, control and = characters
- $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
- "'='.sprintf('%02X', ord('\\1'))", $encoded);
- // Replace every spaces and tabs when it's the last character on a line
- $encoded = preg_replace("/([\011\040])".$this->LE."/e",
- "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
-
- // Maximum line length of 76 characters before CRLF (74 + space + '=')
- $encoded = $this->WrapText($encoded, 74, true);
-
- return $encoded;
- }
-
- /**
- * Encode string to q encoding.
- * @access private
- * @return string
- */
- function EncodeQ ($str, $position = "text") {
- // There should not be any EOL in the string
- $encoded = preg_replace("[\r\n]", "", $str);
-
- switch (strtolower($position)) {
- case "phrase":
- $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
- break;
- case "comment":
- $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
- case "text":
- default:
- // Replace every high ascii, control =, ? and _ characters
- $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
- "'='.sprintf('%02X', ord('\\1'))", $encoded);
- break;
+ // Chomp the last linefeed
+ $encoded = substr($encoded, 0, -strlen($this->LE));
+ return $encoded;
+ }
+
+ /**
+ * Encode string to quoted-printable.
+ * @access private
+ * @return string
+ */
+ function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) {
+ $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
+ $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
+ $eol = "\r\n";
+ $escape = '=';
+ $output = '';
+ while( list(, $line) = each($lines) ) {
+ $linlen = strlen($line);
+ $newline = '';
+ for($i = 0; $i < $linlen; $i++) {
+ $c = substr( $line, $i, 1 );
+ $dec = ord( $c );
+ if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
+ $c = '=2E';
}
-
- // Replace every spaces to _ (more readable than =20)
- $encoded = str_replace(" ", "_", $encoded);
-
- return $encoded;
- }
-
- /**
- * Adds a string or binary attachment (non-filesystem) to the list.
- * This method can be used to attach ascii or binary data,
- * such as a BLOB record from a database.
- * @param string $string String attachment data.
- * @param string $filename Name of the attachment.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return void
- */
- function AddStringAttachment($string, $filename, $encoding = "base64",
- $type = "application/octet-stream") {
- // Append to $attachment array
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $string;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $filename;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = true; // isString
- $this->attachment[$cur][6] = "attachment";
- $this->attachment[$cur][7] = 0;
- }
-
- /**
- * Adds an embedded attachment. This can include images, sounds, and
- * just about any other document. Make sure to set the $type to an
- * image type. For JPEG images use "image/jpeg" and for GIF images
- * use "image/gif".
- * @param string $path Path to the attachment.
- * @param string $cid Content ID of the attachment. Use this to identify
- * the Id for accessing the image in an HTML form.
- * @param string $name Overrides the attachment name.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return bool
- */
- function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64",
- $type = "application/octet-stream") {
-
- if(!@is_file($path))
- {
- $this->SetError($this->Lang("file_access") . $path);
- return false;
+ if ( $dec == 32 ) {
+ if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
+ $c = '=20';
+ } else if ( $space_conv ) {
+ $c = '=20';
+ }
+ } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
+ $h2 = floor($dec/16);
+ $h1 = floor($dec%16);
+ $c = $escape.$hex[$h2].$hex[$h1];
}
-
- $filename = basename($path);
- if($name == "")
- $name = $filename;
-
- // Append to $attachment array
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $path;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $name;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = false; // isStringAttachment
- $this->attachment[$cur][6] = "inline";
- $this->attachment[$cur][7] = $cid;
-
- return true;
- }
-
- /**
- * Returns true if an inline attachment is present.
- * @access private
- * @return bool
- */
- function InlineImageExists() {
- $result = false;
- for($i = 0; $i < count($this->attachment); $i++)
- {
- if($this->attachment[$i][6] == "inline")
- {
- $result = true;
- break;
- }
+ if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
+ $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
+ $newline = '';
+ // check if newline first character will be point or not
+ if ( $dec == 46 ) {
+ $c = '=2E';
+ }
}
+ $newline .= $c;
+ } // end of for
+ $output .= $newline.$eol;
+ } // end of while
+ return trim($output);
+ }
+
+ /**
+ * Encode string to q encoding.
+ * @access private
+ * @return string
+ */
+ function EncodeQ ($str, $position = 'text') {
+ /* There should not be any EOL in the string */
+ $encoded = preg_replace("/[\r\n]/", '', $str);
+
+ switch (strtolower($position)) {
+ case 'phrase':
+ $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ break;
+ case 'comment':
+ $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ case 'text':
+ default:
+ /* Replace every high ascii, control =, ? and _ characters */
+ $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
+ "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ break;
+ }
- return $result;
+ /* Replace every spaces to _ (more readable than =20) */
+ $encoded = str_replace(' ', '_', $encoded);
+
+ return $encoded;
+ }
+
+ /**
+ * Adds a string or binary attachment (non-filesystem) to the list.
+ * This method can be used to attach ascii or binary data,
+ * such as a BLOB record from a database.
+ * @param string $string String attachment data.
+ * @param string $filename Name of the attachment.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return void
+ */
+ function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
+ /* Append to $attachment array */
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $string;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $filename;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = true; // isString
+ $this->attachment[$cur][6] = 'attachment';
+ $this->attachment[$cur][7] = 0;
+ }
+
+ /**
+ * Adds an embedded attachment. This can include images, sounds, and
+ * just about any other document. Make sure to set the $type to an
+ * image type. For JPEG images use "image/jpeg" and for GIF images
+ * use "image/gif".
+ * @param string $path Path to the attachment.
+ * @param string $cid Content ID of the attachment. Use this to identify
+ * the Id for accessing the image in an HTML form.
+ * @param string $name Overrides the attachment name.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return bool
+ */
+ function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
+
+ if(!@is_file($path)) {
+ $this->SetError($this->Lang('file_access') . $path);
+ return false;
}
- /////////////////////////////////////////////////
- // MESSAGE RESET METHODS
- /////////////////////////////////////////////////
-
- /**
- * Clears all recipients assigned in the TO array. Returns void.
- * @return void
- */
- function ClearAddresses() {
- $this->to = array();
- }
-
- /**
- * Clears all recipients assigned in the CC array. Returns void.
- * @return void
- */
- function ClearCCs() {
- $this->cc = array();
- }
-
- /**
- * Clears all recipients assigned in the BCC array. Returns void.
- * @return void
- */
- function ClearBCCs() {
- $this->bcc = array();
- }
-
- /**
- * Clears all recipients assigned in the ReplyTo array. Returns void.
- * @return void
- */
- function ClearReplyTos() {
- $this->ReplyTo = array();
- }
-
- /**
- * Clears all recipients assigned in the TO, CC and BCC
- * array. Returns void.
- * @return void
- */
- function ClearAllRecipients() {
- $this->to = array();
- $this->cc = array();
- $this->bcc = array();
- }
-
- /**
- * Clears all previously set filesystem, string, and binary
- * attachments. Returns void.
- * @return void
- */
- function ClearAttachments() {
- $this->attachment = array();
- }
-
- /**
- * Clears all custom headers. Returns void.
- * @return void
- */
- function ClearCustomHeaders() {
- $this->CustomHeader = array();
- }
-
-
- /////////////////////////////////////////////////
- // MISCELLANEOUS METHODS
- /////////////////////////////////////////////////
-
- /**
- * Adds the error message to the error container.
- * Returns void.
- * @access private
- * @return void
- */
- function SetError($msg) {
- $this->error_count++;
- $this->ErrorInfo = $msg;
- }
-
- /**
- * Returns the proper RFC 822 formatted date.
- * @access private
- * @return string
- */
- function RFCDate() {
- $tz = date("Z");
- $tzs = ($tz < 0) ? "-" : "+";
- $tz = abs($tz);
- $tz = ($tz/3600)*100 + ($tz%3600)/60;
- $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
-
- return $result;
- }
-
- /**
- * Returns the appropriate server variable. Should work with both
- * PHP 4.1.0+ as well as older versions. Returns an empty string
- * if nothing is found.
- * @access private
- * @return mixed
- */
- function ServerVar($varName) {
- global $HTTP_SERVER_VARS;
- global $HTTP_ENV_VARS;
-
- if(!isset($_SERVER))
- {
- $_SERVER = $HTTP_SERVER_VARS;
- if(!isset($_SERVER["REMOTE_ADDR"]))
- $_SERVER = $HTTP_ENV_VARS; // must be Apache
- }
-
- if(isset($_SERVER[$varName]))
- return $_SERVER[$varName];
- else
- return "";
- }
-
- /**
- * Returns the server hostname or 'localhost.localdomain' if unknown.
- * @access private
- * @return string
- */
- function ServerHostname() {
- if ($this->Hostname != "")
- $result = $this->Hostname;
- elseif ($this->ServerVar('SERVER_NAME') != "")
- $result = $this->ServerVar('SERVER_NAME');
- else
- $result = "localhost.localdomain";
-
- return $result;
- }
-
- /**
- * Returns a message in the appropriate language.
- * @access private
- * @return string
- */
- function Lang($key) {
- if(count($this->language) < 1)
- $this->SetLanguage("en"); // set the default language
-
- if(isset($this->language[$key]))
- return $this->language[$key];
- else
- return "Language string failed to load: " . $key;
- }
-
- /**
- * Returns true if an error occurred.
- * @return bool
- */
- function IsError() {
- return ($this->error_count > 0);
- }
-
- /**
- * Changes every end of line from CR or LF to CRLF.
- * @access private
- * @return string
- */
- function FixEOL($str) {
- $str = str_replace("\r\n", "\n", $str);
- $str = str_replace("\r", "\n", $str);
- $str = str_replace("\n", $this->LE, $str);
- return $str;
- }
-
- /**
- * Adds a custom header.
- * @return void
- */
- function AddCustomHeader($custom_header) {
- $this->CustomHeader[] = explode(":", $custom_header, 2);
+ $filename = basename($path);
+ if($name == '') {
+ $name = $filename;
}
+
+ /* Append to $attachment array */
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $path;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $name;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = false;
+ $this->attachment[$cur][6] = 'inline';
+ $this->attachment[$cur][7] = $cid;
+
+ return true;
+ }
+
+ /**
+ * Returns true if an inline attachment is present.
+ * @access private
+ * @return bool
+ */
+ function InlineImageExists() {
+ $result = false;
+ for($i = 0; $i < count($this->attachment); $i++) {
+ if($this->attachment[$i][6] == 'inline') {
+ $result = true;
+ break;
+ }
+ }
+
+ return $result;
+ }
+
+ /////////////////////////////////////////////////
+ // CLASS METHODS, MESSAGE RESET
+ /////////////////////////////////////////////////
+
+ /**
+ * Clears all recipients assigned in the TO array. Returns void.
+ * @return void
+ */
+ function ClearAddresses() {
+ $this->to = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the CC array. Returns void.
+ * @return void
+ */
+ function ClearCCs() {
+ $this->cc = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the BCC array. Returns void.
+ * @return void
+ */
+ function ClearBCCs() {
+ $this->bcc = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the ReplyTo array. Returns void.
+ * @return void
+ */
+ function ClearReplyTos() {
+ $this->ReplyTo = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the TO, CC and BCC
+ * array. Returns void.
+ * @return void
+ */
+ function ClearAllRecipients() {
+ $this->to = array();
+ $this->cc = array();
+ $this->bcc = array();
+ }
+
+ /**
+ * Clears all previously set filesystem, string, and binary
+ * attachments. Returns void.
+ * @return void
+ */
+ function ClearAttachments() {
+ $this->attachment = array();
+ }
+
+ /**
+ * Clears all custom headers. Returns void.
+ * @return void
+ */
+ function ClearCustomHeaders() {
+ $this->CustomHeader = array();
+ }
+
+ /////////////////////////////////////////////////
+ // CLASS METHODS, MISCELLANEOUS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds the error message to the error container.
+ * Returns void.
+ * @access private
+ * @return void
+ */
+ function SetError($msg) {
+ $this->error_count++;
+ $this->ErrorInfo = $msg;
+ }
+
+ /**
+ * Returns the proper RFC 822 formatted date.
+ * @access private
+ * @return string
+ */
+ function RFCDate() {
+ $tz = date('Z');
+ $tzs = ($tz < 0) ? '-' : '+';
+ $tz = abs($tz);
+ $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
+ $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
+
+ return $result;
+ }
+
+ /**
+ * Returns the appropriate server variable. Should work with both
+ * PHP 4.1.0+ as well as older versions. Returns an empty string
+ * if nothing is found.
+ * @access private
+ * @return mixed
+ */
+ function ServerVar($varName) {
+ global $HTTP_SERVER_VARS;
+ global $HTTP_ENV_VARS;
+
+ if(!isset($_SERVER)) {
+ $_SERVER = $HTTP_SERVER_VARS;
+ if(!isset($_SERVER['REMOTE_ADDR'])) {
+ $_SERVER = $HTTP_ENV_VARS; // must be Apache
+ }
+ }
+
+ if(isset($_SERVER[$varName])) {
+ return $_SERVER[$varName];
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Returns the server hostname or 'localhost.localdomain' if unknown.
+ * @access private
+ * @return string
+ */
+ function ServerHostname() {
+ if ($this->Hostname != '') {
+ $result = $this->Hostname;
+ } elseif ($this->ServerVar('SERVER_NAME') != '') {
+ $result = $this->ServerVar('SERVER_NAME');
+ } else {
+ $result = 'localhost.localdomain';
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns a message in the appropriate language.
+ * @access private
+ * @return string
+ */
+ function Lang($key) {
+ if(count($this->language) < 1) {
+ $this->SetLanguage('en'); // set the default language
+ }
+
+ if(isset($this->language[$key])) {
+ return $this->language[$key];
+ } else {
+ return 'Language string failed to load: ' . $key;
+ }
+ }
+
+ /**
+ * Returns true if an error occurred.
+ * @return bool
+ */
+ function IsError() {
+ return ($this->error_count > 0);
+ }
+
+ /**
+ * Changes every end of line from CR or LF to CRLF.
+ * @access private
+ * @return string
+ */
+ function FixEOL($str) {
+ $str = str_replace("\r\n", "\n", $str);
+ $str = str_replace("\r", "\n", $str);
+ $str = str_replace("\n", $this->LE, $str);
+ return $str;
+ }
+
+ /**
+ * Adds a custom header.
+ * @return void
+ */
+ function AddCustomHeader($custom_header) {
+ $this->CustomHeader[] = explode(':', $custom_header, 2);
+ }
+
+ /**
+ * Evaluates the message and returns modifications for inline images and backgrounds
+ * @access public
+ * @return $message
+ */
+ function MsgHTML($message,$basedir='') {
+ preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
+ if(isset($images[2])) {
+ foreach($images[2] as $i => $url) {
+ // do not change urls for absolute images (thanks to corvuscorax)
+ if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) {
+ $filename = basename($url);
+ $directory = dirname($url);
+ ($directory == '.')?$directory='':'';
+ $cid = 'cid:' . md5($filename);
+ $fileParts = split("\.", $filename);
+ $ext = $fileParts[1];
+ $mimeType = $this->_mime_types($ext);
+ if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
+ if ( strlen($directory) > 1 && substr($basedir,-1) != '/') { $directory .= '/'; }
+ $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType);
+ if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
+ $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
+ }
+ }
+ }
+ }
+ $this->IsHTML(true);
+ $this->Body = $message;
+ $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
+ if ( !empty($textMsg) && empty($this->AltBody) ) {
+ $this->AltBody = $textMsg;
+ }
+ if ( empty($this->AltBody) ) {
+ $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n";
+ }
+ }
+
+ /**
+ * Gets the mime type of the embedded or inline image
+ * @access private
+ * @return mime type of ext
+ */
+ function _mime_types($ext = '') {
+ $mimes = array(
+ 'hqx' => 'application/mac-binhex40',
+ 'cpt' => 'application/mac-compactpro',
+ 'doc' => 'application/msword',
+ 'bin' => 'application/macbinary',
+ 'dms' => 'application/octet-stream',
+ 'lha' => 'application/octet-stream',
+ 'lzh' => 'application/octet-stream',
+ 'exe' => 'application/octet-stream',
+ 'class' => 'application/octet-stream',
+ 'psd' => 'application/octet-stream',
+ 'so' => 'application/octet-stream',
+ 'sea' => 'application/octet-stream',
+ 'dll' => 'application/octet-stream',
+ 'oda' => 'application/oda',
+ 'pdf' => 'application/pdf',
+ 'ai' => 'application/postscript',
+ 'eps' => 'application/postscript',
+ 'ps' => 'application/postscript',
+ 'smi' => 'application/smil',
+ 'smil' => 'application/smil',
+ 'mif' => 'application/vnd.mif',
+ 'xls' => 'application/vnd.ms-excel',
+ 'ppt' => 'application/vnd.ms-powerpoint',
+ 'wbxml' => 'application/vnd.wap.wbxml',
+ 'wmlc' => 'application/vnd.wap.wmlc',
+ 'dcr' => 'application/x-director',
+ 'dir' => 'application/x-director',
+ 'dxr' => 'application/x-director',
+ 'dvi' => 'application/x-dvi',
+ 'gtar' => 'application/x-gtar',
+ 'php' => 'application/x-httpd-php',
+ 'php4' => 'application/x-httpd-php',
+ 'php3' => 'application/x-httpd-php',
+ 'phtml' => 'application/x-httpd-php',
+ 'phps' => 'application/x-httpd-php-source',
+ 'js' => 'application/x-javascript',
+ 'swf' => 'application/x-shockwave-flash',
+ 'sit' => 'application/x-stuffit',
+ 'tar' => 'application/x-tar',
+ 'tgz' => 'application/x-tar',
+ 'xhtml' => 'application/xhtml+xml',
+ 'xht' => 'application/xhtml+xml',
+ 'zip' => 'application/zip',
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mpga' => 'audio/mpeg',
+ 'mp2' => 'audio/mpeg',
+ 'mp3' => 'audio/mpeg',
+ 'aif' => 'audio/x-aiff',
+ 'aiff' => 'audio/x-aiff',
+ 'aifc' => 'audio/x-aiff',
+ 'ram' => 'audio/x-pn-realaudio',
+ 'rm' => 'audio/x-pn-realaudio',
+ 'rpm' => 'audio/x-pn-realaudio-plugin',
+ 'ra' => 'audio/x-realaudio',
+ 'rv' => 'video/vnd.rn-realvideo',
+ 'wav' => 'audio/x-wav',
+ 'bmp' => 'image/bmp',
+ 'gif' => 'image/gif',
+ 'jpeg' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'jpe' => 'image/jpeg',
+ 'png' => 'image/png',
+ 'tiff' => 'image/tiff',
+ 'tif' => 'image/tiff',
+ 'css' => 'text/css',
+ 'html' => 'text/html',
+ 'htm' => 'text/html',
+ 'shtml' => 'text/html',
+ 'txt' => 'text/plain',
+ 'text' => 'text/plain',
+ 'log' => 'text/plain',
+ 'rtx' => 'text/richtext',
+ 'rtf' => 'text/rtf',
+ 'xml' => 'text/xml',
+ 'xsl' => 'text/xml',
+ 'mpeg' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'mpe' => 'video/mpeg',
+ 'qt' => 'video/quicktime',
+ 'mov' => 'video/quicktime',
+ 'avi' => 'video/x-msvideo',
+ 'movie' => 'video/x-sgi-movie',
+ 'doc' => 'application/msword',
+ 'word' => 'application/msword',
+ 'xl' => 'application/excel',
+ 'eml' => 'message/rfc822'
+ );
+ return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
+ }
+
+ /**
+ * Set (or reset) Class Objects (variables)
+ *
+ * Usage Example:
+ * $page->set('X-Priority', '3');
+ *
+ * @access public
+ * @param string $name Parameter Name
+ * @param mixed $value Parameter Value
+ * NOTE: will not work with arrays, there are no arrays to set/reset
+ */
+ function set ( $name, $value = '' ) {
+ if ( isset($this->$name) ) {
+ $this->$name = $value;
+ } else {
+ $this->SetError('Cannot set or reset variable ' . $name);
+ return false;
+ }
+ }
+
+ /**
+ * Read a file from a supplied filename and return it.
+ *
+ * @access public
+ * @param string $filename Parameter File Name
+ */
+ function getFile($filename) {
+ $return = '';
+ if ($fp = fopen($filename, 'rb')) {
+ while (!feof($fp)) {
+ $return .= fread($fp, 1024);
+ }
+ fclose($fp);
+ return $return;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Strips newlines to prevent header injection.
+ * @access private
+ * @param string $str String
+ * @return string
+ */
+ function SecureHeader($str) {
+ $str = trim($str);
+ $str = str_replace("\r", "", $str);
+ $str = str_replace("\n", "", $str);
+ return $str;
+ }
+
+ /**
+ * Set the private key file and password to sign the message.
+ *
+ * @access public
+ * @param string $key_filename Parameter File Name
+ * @param string $key_pass Password for private key
+ */
+ function Sign($key_filename, $key_pass) {
+ $this->sign_key_file = $key_filename;
+ $this->sign_key_pass = $key_pass;
+ }
+
}
?>
*
* pop3 class
*
- * $Id: class-pop3.php 8082 2008-06-14 16:36:13Z westi $
+ * $Id: class-pop3.php 9503 2008-11-03 23:25:11Z ryan $
*/
-/**
- * POP3
- *
- * @package SquirrelMail
- */
class POP3 {
var $ERROR = ''; // Error string.
<?php
-/**
- * SMTP - PHP SMTP class
- *
- * Define an SMTP class that can be used to connect and communicate with any
- * SMTP server. It implements all the SMTP functions defined in RFC821 except
- * TURN.
- *
- * @version 1.02
- * @author Chris Ryan
- * @license LGPL
- * @package PHPMailer
+/*~ class.smtp.php
+.---------------------------------------------------------------------------.
+| Software: PHPMailer - PHP email class |
+| Version: 2.0.2 |
+| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
+| Info: http://phpmailer.sourceforge.net |
+| Support: http://sourceforge.net/projects/phpmailer/ |
+| ------------------------------------------------------------------------- |
+| Author: Andy Prevost (project admininistrator) |
+| Author: Brent R. Matzelle (original founder) |
+| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
+| Copyright (c) 2001-2003, Brent R. Matzelle |
+| ------------------------------------------------------------------------- |
+| License: Distributed under the Lesser General Public License (LGPL) |
+| http://www.gnu.org/copyleft/lesser.html |
+| This program is distributed in the hope that it will be useful - WITHOUT |
+| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+| FITNESS FOR A PARTICULAR PURPOSE. |
+| ------------------------------------------------------------------------- |
+| We offer a number of paid services (www.codeworxtech.com): |
+| - Web Hosting on highly optimized fast and secure servers |
+| - Technology Consulting |
+| - Oursourcing (highly qualified programmers and graphic designers) |
+'---------------------------------------------------------------------------'
*/
-
/**
* SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
* commands except TURN which will always return a not implemented
* error. SMTP also provides some utility methods for sending mail
* to an SMTP server.
- *
* @package PHPMailer
* @author Chris Ryan
*/
+
class SMTP
{
- /**
- * SMTP server port
- * @var int
- */
- var $SMTP_PORT = 25;
-
- /**
- * SMTP reply line ending
- * @var string
- */
- var $CRLF = "\r\n";
-
- /**
- * Sets whether debugging is turned on
- * @var bool
- */
- var $do_debug; # the level of debug to perform
-
- /**#@+
- * @access private
- */
- var $smtp_conn; # the socket to the server
- var $error; # error if any on the last call
- var $helo_rply; # the reply the server sent to us for HELO
- /**#@-*/
-
- /**
- * Initialize the class so that the data is in a known state.
- * @access public
- * @return void
- */
- function SMTP() {
- $this->smtp_conn = 0;
- $this->error = null;
- $this->helo_rply = null;
-
- $this->do_debug = 0;
+ /**
+ * SMTP server port
+ * @var int
+ */
+ var $SMTP_PORT = 25;
+
+ /**
+ * SMTP reply line ending
+ * @var string
+ */
+ var $CRLF = "\r\n";
+
+ /**
+ * Sets whether debugging is turned on
+ * @var bool
+ */
+ var $do_debug; # the level of debug to perform
+
+ /**
+ * Sets VERP use on/off (default is off)
+ * @var bool
+ */
+ var $do_verp = false;
+
+ /**#@+
+ * @access private
+ */
+ var $smtp_conn; # the socket to the server
+ var $error; # error if any on the last call
+ var $helo_rply; # the reply the server sent to us for HELO
+ /**#@-*/
+
+ /**
+ * Initialize the class so that the data is in a known state.
+ * @access public
+ * @return void
+ */
+ function SMTP() {
+ $this->smtp_conn = 0;
+ $this->error = null;
+ $this->helo_rply = null;
+
+ $this->do_debug = 0;
+ }
+
+ /*************************************************************
+ * CONNECTION FUNCTIONS *
+ ***********************************************************/
+
+ /**
+ * Connect to the server specified on the port specified.
+ * If the port is not specified use the default SMTP_PORT.
+ * If tval is specified then a connection will try and be
+ * established with the server for that number of seconds.
+ * If tval is not specified the default is 30 seconds to
+ * try on the connection.
+ *
+ * SMTP CODE SUCCESS: 220
+ * SMTP CODE FAILURE: 421
+ * @access public
+ * @return bool
+ */
+ function Connect($host,$port=0,$tval=30) {
+ # set the error val to null so there is no confusion
+ $this->error = null;
+
+ # make sure we are __not__ connected
+ if($this->connected()) {
+ # ok we are connected! what should we do?
+ # for now we will just give an error saying we
+ # are already connected
+ $this->error = array("error" => "Already connected to a server");
+ return false;
}
- /*************************************************************
- * CONNECTION FUNCTIONS *
- ***********************************************************/
-
- /**
- * Connect to the server specified on the port specified.
- * If the port is not specified use the default SMTP_PORT.
- * If tval is specified then a connection will try and be
- * established with the server for that number of seconds.
- * If tval is not specified the default is 30 seconds to
- * try on the connection.
- *
- * SMTP CODE SUCCESS: 220
- * SMTP CODE FAILURE: 421
- * @access public
- * @return bool
- */
- function Connect($host,$port=0,$tval=30) {
- # set the error val to null so there is no confusion
- $this->error = null;
-
- # make sure we are __not__ connected
- if($this->connected()) {
- # ok we are connected! what should we do?
- # for now we will just give an error saying we
- # are already connected
- $this->error =
- array("error" => "Already connected to a server");
- return false;
- }
-
- if(empty($port)) {
- $port = $this->SMTP_PORT;
- }
-
- #connect to the smtp server
- $this->smtp_conn = fsockopen($host, # the host of the server
- $port, # the port to use
- $errno, # error number if any
- $errstr, # error message if any
- $tval); # give up after ? secs
- # verify we connected properly
- if(empty($this->smtp_conn)) {
- $this->error = array("error" => "Failed to connect to server",
- "errno" => $errno,
- "errstr" => $errstr);
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": $errstr ($errno)" . $this->CRLF;
- }
- return false;
- }
+ if(empty($port)) {
+ $port = $this->SMTP_PORT;
+ }
- # sometimes the SMTP server takes a little longer to respond
- # so we will give it a longer timeout for the first read
- // Windows still does not have support for this timeout function
- if(substr(PHP_OS, 0, 3) != "WIN")
- socket_set_timeout($this->smtp_conn, $tval, 0);
+ #connect to the smtp server
+ $this->smtp_conn = fsockopen($host, # the host of the server
+ $port, # the port to use
+ $errno, # error number if any
+ $errstr, # error message if any
+ $tval); # give up after ? secs
+ # verify we connected properly
+ if(empty($this->smtp_conn)) {
+ $this->error = array("error" => "Failed to connect to server",
+ "errno" => $errno,
+ "errstr" => $errstr);
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": $errstr ($errno)" . $this->CRLF;
+ }
+ return false;
+ }
- # get any announcement stuff
- $announce = $this->get_lines();
+ # sometimes the SMTP server takes a little longer to respond
+ # so we will give it a longer timeout for the first read
+ // Windows still does not have support for this timeout function
+ if(substr(PHP_OS, 0, 3) != "WIN")
+ socket_set_timeout($this->smtp_conn, $tval, 0);
- # set the timeout of any socket functions at 1/10 of a second
- //if(function_exists("socket_set_timeout"))
- // socket_set_timeout($this->smtp_conn, 0, 100000);
+ # get any announcement stuff
+ $announce = $this->get_lines();
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
- }
+ # set the timeout of any socket functions at 1/10 of a second
+ //if(function_exists("socket_set_timeout"))
+ // socket_set_timeout($this->smtp_conn, 0, 100000);
- return true;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
}
- /**
- * Performs SMTP authentication. Must be run after running the
- * Hello() method. Returns true if successfully authenticated.
- * @access public
- * @return bool
- */
- function Authenticate($username, $password) {
- // Start authentication
- fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 334) {
- $this->error =
- array("error" => "AUTH not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- // Send encoded username
- fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 334) {
- $this->error =
- array("error" => "Username not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
+ return true;
+ }
+
+ /**
+ * Performs SMTP authentication. Must be run after running the
+ * Hello() method. Returns true if successfully authenticated.
+ * @access public
+ * @return bool
+ */
+ function Authenticate($username, $password) {
+ // Start authentication
+ fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 334) {
+ $this->error =
+ array("error" => "AUTH not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
- // Send encoded password
- fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 235) {
- $this->error =
- array("error" => "Password not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
+ // Send encoded username
+ fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 334) {
+ $this->error =
+ array("error" => "Username not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
- return true;
+ // Send encoded password
+ fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 235) {
+ $this->error =
+ array("error" => "Password not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
}
- /**
- * Returns true if connected to a server otherwise false
- * @access private
- * @return bool
- */
- function Connected() {
- if(!empty($this->smtp_conn)) {
- $sock_status = socket_get_status($this->smtp_conn);
- if($sock_status["eof"]) {
- # hmm this is an odd situation... the socket is
- # valid but we aren't connected anymore
- if($this->do_debug >= 1) {
- echo "SMTP -> NOTICE:" . $this->CRLF .
- "EOF caught while checking if connected";
- }
- $this->Close();
- return false;
- }
- return true; # everything looks good
+ return true;
+ }
+
+ /**
+ * Returns true if connected to a server otherwise false
+ * @access private
+ * @return bool
+ */
+ function Connected() {
+ if(!empty($this->smtp_conn)) {
+ $sock_status = socket_get_status($this->smtp_conn);
+ if($sock_status["eof"]) {
+ # hmm this is an odd situation... the socket is
+ # valid but we are not connected anymore
+ if($this->do_debug >= 1) {
+ echo "SMTP -> NOTICE:" . $this->CRLF .
+ "EOF caught while checking if connected";
}
+ $this->Close();
return false;
+ }
+ return true; # everything looks good
}
-
- /**
- * Closes the socket and cleans up the state of the class.
- * It is not considered good to use this function without
- * first trying to use QUIT.
- * @access public
- * @return void
- */
- function Close() {
- $this->error = null; # so there is no confusion
- $this->helo_rply = null;
- if(!empty($this->smtp_conn)) {
- # close the connection and cleanup
- fclose($this->smtp_conn);
- $this->smtp_conn = 0;
- }
+ return false;
+ }
+
+ /**
+ * Closes the socket and cleans up the state of the class.
+ * It is not considered good to use this function without
+ * first trying to use QUIT.
+ * @access public
+ * @return void
+ */
+ function Close() {
+ $this->error = null; # so there is no confusion
+ $this->helo_rply = null;
+ if(!empty($this->smtp_conn)) {
+ # close the connection and cleanup
+ fclose($this->smtp_conn);
+ $this->smtp_conn = 0;
+ }
+ }
+
+ /***************************************************************
+ * SMTP COMMANDS *
+ *************************************************************/
+
+ /**
+ * Issues a data command and sends the msg_data to the server
+ * finializing the mail transaction. $msg_data is the message
+ * that is to be send with the headers. Each header needs to be
+ * on a single line followed by a <CRLF> with the message headers
+ * and the message body being seperated by and additional <CRLF>.
+ *
+ * Implements rfc 821: DATA <CRLF>
+ *
+ * SMTP CODE INTERMEDIATE: 354
+ * [data]
+ * <CRLF>.<CRLF>
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 552,554,451,452
+ * SMTP CODE FAILURE: 451,554
+ * SMTP CODE ERROR : 500,501,503,421
+ * @access public
+ * @return bool
+ */
+ function Data($msg_data) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Data() without being connected");
+ return false;
}
+ fputs($this->smtp_conn,"DATA" . $this->CRLF);
- /***************************************************************
- * SMTP COMMANDS *
- *************************************************************/
-
- /**
- * Issues a data command and sends the msg_data to the server
- * finializing the mail transaction. $msg_data is the message
- * that is to be send with the headers. Each header needs to be
- * on a single line followed by a <CRLF> with the message headers
- * and the message body being separated by and additional <CRLF>.
- *
- * Implements rfc 821: DATA <CRLF>
- *
- * SMTP CODE INTERMEDIATE: 354
- * [data]
- * <CRLF>.<CRLF>
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 552,554,451,452
- * SMTP CODE FAILURE: 451,554
- * SMTP CODE ERROR : 500,501,503,421
- * @access public
- * @return bool
- */
- function Data($msg_data) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Data() without being connected");
- return false;
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- fputs($this->smtp_conn,"DATA" . $this->CRLF);
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ if($code != 354) {
+ $this->error =
+ array("error" => "DATA command not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
+ # the server is ready to accept data!
+ # according to rfc 821 we should not send more than 1000
+ # including the CRLF
+ # characters on a single line so we will break the data up
+ # into lines by \r and/or \n then if needed we will break
+ # each of those into smaller lines to fit within the limit.
+ # in addition we will be looking for lines that start with
+ # a period '.' and append and additional period '.' to that
+ # line. NOTE: this does not count towards are limit.
+
+ # normalize the line breaks so we know the explode works
+ $msg_data = str_replace("\r\n","\n",$msg_data);
+ $msg_data = str_replace("\r","\n",$msg_data);
+ $lines = explode("\n",$msg_data);
+
+ # we need to find a good way to determine is headers are
+ # in the msg_data or if it is a straight msg body
+ # currently I am assuming rfc 822 definitions of msg headers
+ # and if the first field of the first line (':' sperated)
+ # does not contain a space then it _should_ be a header
+ # and we can process all lines before a blank "" line as
+ # headers.
+ $field = substr($lines[0],0,strpos($lines[0],":"));
+ $in_headers = false;
+ if(!empty($field) && !strstr($field," ")) {
+ $in_headers = true;
+ }
- if($code != 354) {
- $this->error =
- array("error" => "DATA command not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
+ $max_line_length = 998; # used below; set here for ease in change
- # the server is ready to accept data!
- # according to rfc 821 we should not send more than 1000
- # including the CRLF
- # characters on a single line so we will break the data up
- # into lines by \r and/or \n then if needed we will break
- # each of those into smaller lines to fit within the limit.
- # in addition we will be looking for lines that start with
- # a period '.' and append and additional period '.' to that
- # line. NOTE: this does not count towards are limit.
-
- # normalize the line breaks so we know the explode works
- $msg_data = str_replace("\r\n","\n",$msg_data);
- $msg_data = str_replace("\r","\n",$msg_data);
- $lines = explode("\n",$msg_data);
-
- # we need to find a good way to determine is headers are
- # in the msg_data or if it is a straight msg body
- # currently I'm assuming rfc 822 definitions of msg headers
- # and if the first field of the first line (':' sperated)
- # does not contain a space then it _should_ be a header
- # and we can process all lines before a blank "" line as
- # headers.
- $field = substr($lines[0],0,strpos($lines[0],":"));
+ while(list(,$line) = @each($lines)) {
+ $lines_out = null;
+ if($line == "" && $in_headers) {
$in_headers = false;
- if(!empty($field) && !strstr($field," ")) {
- $in_headers = true;
+ }
+ # ok we need to break this line up into several
+ # smaller lines
+ while(strlen($line) > $max_line_length) {
+ $pos = strrpos(substr($line,0,$max_line_length)," ");
+
+ # Patch to fix DOS attack
+ if(!$pos) {
+ $pos = $max_line_length - 1;
}
- $max_line_length = 998; # used below; set here for ease in change
-
- while(list(,$line) = @each($lines)) {
- $lines_out = null;
- if($line == "" && $in_headers) {
- $in_headers = false;
- }
- # ok we need to break this line up into several
- # smaller lines
- while(strlen($line) > $max_line_length) {
- $pos = strrpos(substr($line,0,$max_line_length)," ");
-
- # Patch to fix DOS attack
- if(!$pos) {
- $pos = $max_line_length - 1;
- }
-
- $lines_out[] = substr($line,0,$pos);
- $line = substr($line,$pos + 1);
- # if we are processing headers we need to
- # add a LWSP-char to the front of the new line
- # rfc 822 on long msg headers
- if($in_headers) {
- $line = "\t" . $line;
- }
- }
- $lines_out[] = $line;
-
- # now send the lines to the server
- while(list(,$line_out) = @each($lines_out)) {
- if(strlen($line_out) > 0)
- {
- if(substr($line_out, 0, 1) == ".") {
- $line_out = "." . $line_out;
- }
- }
- fputs($this->smtp_conn,$line_out . $this->CRLF);
- }
+ $lines_out[] = substr($line,0,$pos);
+ $line = substr($line,$pos + 1);
+ # if we are processing headers we need to
+ # add a LWSP-char to the front of the new line
+ # rfc 822 on long msg headers
+ if($in_headers) {
+ $line = "\t" . $line;
}
+ }
+ $lines_out[] = $line;
- # ok all the message data has been sent so lets get this
- # over with aleady
- fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "DATA not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
+ # now send the lines to the server
+ while(list(,$line_out) = @each($lines_out)) {
+ if(strlen($line_out) > 0)
+ {
+ if(substr($line_out, 0, 1) == ".") {
+ $line_out = "." . $line_out;
+ }
}
- return true;
+ fputs($this->smtp_conn,$line_out . $this->CRLF);
+ }
}
- /**
- * Expand takes the name and asks the server to list all the
- * people who are members of the _list_. Expand will return
- * back and array of the result or false if an error occurs.
- * Each value in the array returned has the format of:
- * [ <full-name> <sp> ] <path>
- * The definition of <path> is defined in rfc 821
- *
- * Implements rfc 821: EXPN <SP> <string> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 550
- * SMTP CODE ERROR : 500,501,502,504,421
- * @access public
- * @return string array
- */
- function Expand($name) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Expand() without being connected");
- return false;
- }
+ # ok all the message data has been sent so lets get this
+ # over with aleady
+ fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
- fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
+ if($code != 250) {
+ $this->error =
+ array("error" => "DATA not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Expand takes the name and asks the server to list all the
+ * people who are members of the _list_. Expand will return
+ * back and array of the result or false if an error occurs.
+ * Each value in the array returned has the format of:
+ * [ <full-name> <sp> ] <path>
+ * The definition of <path> is defined in rfc 821
+ *
+ * Implements rfc 821: EXPN <SP> <string> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 550
+ * SMTP CODE ERROR : 500,501,502,504,421
+ * @access public
+ * @return string array
+ */
+ function Expand($name) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Expand() without being connected");
+ return false;
+ }
- if($code != 250) {
- $this->error =
- array("error" => "EXPN not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
+ fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
- # parse the reply and place in our array to return to user
- $entries = explode($this->CRLF,$rply);
- while(list(,$l) = @each($entries)) {
- $list[] = substr($l,4);
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- return $list;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
- /**
- * Sends the HELO command to the smtp server.
- * This makes sure that we and the server are in
- * the same known state.
- *
- * Implements from rfc 821: HELO <SP> <domain> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500, 501, 504, 421
- * @access public
- * @return bool
- */
- function Hello($host="") {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Hello() without being connected");
- return false;
- }
-
- # if a hostname for the HELO wasn't specified determine
- # a suitable one to send
- if(empty($host)) {
- # we need to determine some sort of appopiate default
- # to send to the server
- $host = "localhost";
- }
+ if($code != 250) {
+ $this->error =
+ array("error" => "EXPN not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
- // Send extended hello first (RFC 2821)
- if(!$this->SendHello("EHLO", $host))
- {
- if(!$this->SendHello("HELO", $host))
- return false;
- }
+ # parse the reply and place in our array to return to user
+ $entries = explode($this->CRLF,$rply);
+ while(list(,$l) = @each($entries)) {
+ $list[] = substr($l,4);
+ }
- return true;
+ return $list;
+ }
+
+ /**
+ * Sends the HELO command to the smtp server.
+ * This makes sure that we and the server are in
+ * the same known state.
+ *
+ * Implements from rfc 821: HELO <SP> <domain> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500, 501, 504, 421
+ * @access public
+ * @return bool
+ */
+ function Hello($host="") {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Hello() without being connected");
+ return false;
}
- /**
- * Sends a HELO/EHLO command.
- * @access private
- * @return bool
- */
- function SendHello($hello, $host) {
- fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
+ # if a hostname for the HELO was not specified determine
+ # a suitable one to send
+ if(empty($host)) {
+ # we need to determine some sort of appopiate default
+ # to send to the server
+ $host = "localhost";
+ }
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ // Send extended hello first (RFC 2821)
+ if(!$this->SendHello("EHLO", $host))
+ {
+ if(!$this->SendHello("HELO", $host))
+ return false;
+ }
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
- }
+ return true;
+ }
- if($code != 250) {
- $this->error =
- array("error" => $hello . " not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
+ /**
+ * Sends a HELO/EHLO command.
+ * @access private
+ * @return bool
+ */
+ function SendHello($hello, $host) {
+ fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
- $this->helo_rply = $rply;
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- return true;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
}
- /**
- * Gets help information on the keyword specified. If the keyword
- * is not specified then returns generic help, ussually contianing
- * A list of keywords that help is available on. This function
- * returns the results back to the user. It is up to the user to
- * handle the returned data. If an error occurs then false is
- * returned with $this->error set appropiately.
- *
- * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
- *
- * SMTP CODE SUCCESS: 211,214
- * SMTP CODE ERROR : 500,501,502,504,421
- * @access public
- * @return string
- */
- function Help($keyword="") {
- $this->error = null; # to avoid confusion
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Help() without being connected");
- return false;
- }
-
- $extra = "";
- if(!empty($keyword)) {
- $extra = " " . $keyword;
- }
+ if($code != 250) {
+ $this->error =
+ array("error" => $hello . " not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
- fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
+ $this->helo_rply = $rply;
+
+ return true;
+ }
+
+ /**
+ * Gets help information on the keyword specified. If the keyword
+ * is not specified then returns generic help, ussually contianing
+ * A list of keywords that help is available on. This function
+ * returns the results back to the user. It is up to the user to
+ * handle the returned data. If an error occurs then false is
+ * returned with $this->error set appropiately.
+ *
+ * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
+ *
+ * SMTP CODE SUCCESS: 211,214
+ * SMTP CODE ERROR : 500,501,502,504,421
+ * @access public
+ * @return string
+ */
+ function Help($keyword="") {
+ $this->error = null; # to avoid confusion
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Help() without being connected");
+ return false;
+ }
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ $extra = "";
+ if(!empty($keyword)) {
+ $extra = " " . $keyword;
+ }
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
+ fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
- if($code != 211 && $code != 214) {
- $this->error =
- array("error" => "HELP not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- return $rply;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command.
- *
- * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,421
- * @access public
- * @return bool
- */
- function Mail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Mail() without being connected");
- return false;
- }
+ if($code != 211 && $code != 214) {
+ $this->error =
+ array("error" => "HELP not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
- fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $this->CRLF);
+ return $rply;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command.
+ *
+ * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,421
+ * @access public
+ * @return bool
+ */
+ function Mail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Mail() without being connected");
+ return false;
+ }
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ $useVerp = ($this->do_verp ? "XVERP" : "");
+ fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- if($code != 250) {
- $this->error =
- array("error" => "MAIL not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
- /**
- * Sends the command NOOP to the SMTP server.
- *
- * Implements from rfc 821: NOOP <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500, 421
- * @access public
- * @return bool
- */
- function Noop() {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Noop() without being connected");
- return false;
- }
+ if($code != 250) {
+ $this->error =
+ array("error" => "MAIL not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the command NOOP to the SMTP server.
+ *
+ * Implements from rfc 821: NOOP <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500, 421
+ * @access public
+ * @return bool
+ */
+ function Noop() {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Noop() without being connected");
+ return false;
+ }
- fputs($this->smtp_conn,"NOOP" . $this->CRLF);
+ fputs($this->smtp_conn,"NOOP" . $this->CRLF);
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "NOOP not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
- /**
- * Sends the quit command to the server and then closes the socket
- * if there is no error or the $close_on_error argument is true.
- *
- * Implements from rfc 821: QUIT <CRLF>
- *
- * SMTP CODE SUCCESS: 221
- * SMTP CODE ERROR : 500
- * @access public
- * @return bool
- */
- function Quit($close_on_error=true) {
- $this->error = null; # so there is no confusion
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Quit() without being connected");
- return false;
- }
-
- # send the quit command to the server
- fputs($this->smtp_conn,"quit" . $this->CRLF);
-
- # get any good-bye messages
- $byemsg = $this->get_lines();
+ if($code != 250) {
+ $this->error =
+ array("error" => "NOOP not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the quit command to the server and then closes the socket
+ * if there is no error or the $close_on_error argument is true.
+ *
+ * Implements from rfc 821: QUIT <CRLF>
+ *
+ * SMTP CODE SUCCESS: 221
+ * SMTP CODE ERROR : 500
+ * @access public
+ * @return bool
+ */
+ function Quit($close_on_error=true) {
+ $this->error = null; # so there is no confusion
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Quit() without being connected");
+ return false;
+ }
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
- }
+ # send the quit command to the server
+ fputs($this->smtp_conn,"quit" . $this->CRLF);
- $rval = true;
- $e = null;
-
- $code = substr($byemsg,0,3);
- if($code != 221) {
- # use e as a tmp var cause Close will overwrite $this->error
- $e = array("error" => "SMTP server rejected quit command",
- "smtp_code" => $code,
- "smtp_rply" => substr($byemsg,4));
- $rval = false;
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $e["error"] . ": " .
- $byemsg . $this->CRLF;
- }
- }
+ # get any good-bye messages
+ $byemsg = $this->get_lines();
- if(empty($e) || $close_on_error) {
- $this->Close();
- }
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
+ }
- return $rval;
+ $rval = true;
+ $e = null;
+
+ $code = substr($byemsg,0,3);
+ if($code != 221) {
+ # use e as a tmp var cause Close will overwrite $this->error
+ $e = array("error" => "SMTP server rejected quit command",
+ "smtp_code" => $code,
+ "smtp_rply" => substr($byemsg,4));
+ $rval = false;
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $e["error"] . ": " .
+ $byemsg . $this->CRLF;
+ }
}
- /**
- * Sends the command RCPT to the SMTP server with the TO: argument of $to.
- * Returns true if the recipient was accepted false if it was rejected.
- *
- * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250,251
- * SMTP CODE FAILURE: 550,551,552,553,450,451,452
- * SMTP CODE ERROR : 500,501,503,421
- * @access public
- * @return bool
- */
- function Recipient($to) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Recipient() without being connected");
- return false;
- }
+ if(empty($e) || $close_on_error) {
+ $this->Close();
+ }
- fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
+ return $rval;
+ }
+
+ /**
+ * Sends the command RCPT to the SMTP server with the TO: argument of $to.
+ * Returns true if the recipient was accepted false if it was rejected.
+ *
+ * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250,251
+ * SMTP CODE FAILURE: 550,551,552,553,450,451,452
+ * SMTP CODE ERROR : 500,501,503,421
+ * @access public
+ * @return bool
+ */
+ function Recipient($to) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Recipient() without being connected");
+ return false;
+ }
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- if($code != 250 && $code != 251) {
- $this->error =
- array("error" => "RCPT not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
- /**
- * Sends the RSET command to abort and transaction that is
- * currently in progress. Returns true if successful false
- * otherwise.
- *
- * Implements rfc 821: RSET <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500,501,504,421
- * @access public
- * @return bool
- */
- function Reset() {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Reset() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"RSET" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ if($code != 250 && $code != 251) {
+ $this->error =
+ array("error" => "RCPT not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the RSET command to abort and transaction that is
+ * currently in progress. Returns true if successful false
+ * otherwise.
+ *
+ * Implements rfc 821: RSET <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500,501,504,421
+ * @access public
+ * @return bool
+ */
+ function Reset() {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Reset() without being connected");
+ return false;
+ }
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
+ fputs($this->smtp_conn,"RSET" . $this->CRLF);
- if($code != 250) {
- $this->error =
- array("error" => "RSET failed",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- return true;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the users terminal if they are logged
- * in.
- *
- * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function Send($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Send() without being connected");
- return false;
- }
+ if($code != 250) {
+ $this->error =
+ array("error" => "RSET failed",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
- fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in.
+ *
+ * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function Send($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Send() without being connected");
+ return false;
+ }
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- if($code != 250) {
- $this->error =
- array("error" => "SEND not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the users terminal if they are logged
- * in and send them an email.
- *
- * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function SendAndMail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called SendAndMail() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
+ if($code != 250) {
+ $this->error =
+ array("error" => "SEND not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in and send them an email.
+ *
+ * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function SendAndMail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called SendAndMail() without being connected");
+ return false;
+ }
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- if($code != 250) {
- $this->error =
- array("error" => "SAML not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the users terminal if they are logged
- * in or mail it to them if they are not.
- *
- * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function SendOrMail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called SendOrMail() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
+ if($code != 250) {
+ $this->error =
+ array("error" => "SAML not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in or mail it to them if they are not.
+ *
+ * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function SendOrMail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called SendOrMail() without being connected");
+ return false;
+ }
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- if($code != 250) {
- $this->error =
- array("error" => "SOML not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
- /**
- * This is an optional command for SMTP that this class does not
- * support. This method is here to make the RFC821 Definition
- * complete for this class and __may__ be implimented in the future
- *
- * Implements from rfc 821: TURN <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 502
- * SMTP CODE ERROR : 500, 503
- * @access public
- * @return bool
- */
- function Turn() {
- $this->error = array("error" => "This method, TURN, of the SMTP ".
- "is not implemented");
- if($this->do_debug >= 1) {
- echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
- }
- return false;
+ if($code != 250) {
+ $this->error =
+ array("error" => "SOML not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * This is an optional command for SMTP that this class does not
+ * support. This method is here to make the RFC821 Definition
+ * complete for this class and __may__ be implimented in the future
+ *
+ * Implements from rfc 821: TURN <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 502
+ * SMTP CODE ERROR : 500, 503
+ * @access public
+ * @return bool
+ */
+ function Turn() {
+ $this->error = array("error" => "This method, TURN, of the SMTP ".
+ "is not implemented");
+ if($this->do_debug >= 1) {
+ echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
+ }
+ return false;
+ }
+
+ /**
+ * Verifies that the name is recognized by the server.
+ * Returns false if the name could not be verified otherwise
+ * the response from the server is returned.
+ *
+ * Implements rfc 821: VRFY <SP> <string> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250,251
+ * SMTP CODE FAILURE: 550,551,553
+ * SMTP CODE ERROR : 500,501,502,421
+ * @access public
+ * @return int
+ */
+ function Verify($name) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Verify() without being connected");
+ return false;
}
- /**
- * Verifies that the name is recognized by the server.
- * Returns false if the name could not be verified otherwise
- * the response from the server is returned.
- *
- * Implements rfc 821: VRFY <SP> <string> <CRLF>
- *
- * SMTP CODE SUCCESS: 250,251
- * SMTP CODE FAILURE: 550,551,553
- * SMTP CODE ERROR : 500,501,502,421
- * @access public
- * @return int
- */
- function Verify($name) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Verify() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
+ fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
- if($code != 250 && $code != 251) {
- $this->error =
- array("error" => "VRFY failed on name '$name'",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return $rply;
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
}
- /*******************************************************************
- * INTERNAL FUNCTIONS *
- ******************************************************************/
-
- /**
- * Read in as many lines as possible
- * either before eof or socket timeout occurs on the operation.
- * With SMTP we can tell if we have more lines to read if the
- * 4th character is '-' symbol. If it is a space then we don't
- * need to read anything else.
- * @access private
- * @return string
- */
- function get_lines() {
- $data = "";
- while($str = fgets($this->smtp_conn,515)) {
- if($this->do_debug >= 4) {
- echo "SMTP -> get_lines(): \$data was \"$data\"" .
- $this->CRLF;
- echo "SMTP -> get_lines(): \$str is \"$str\"" .
- $this->CRLF;
- }
- $data .= $str;
- if($this->do_debug >= 4) {
- echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
- }
- # if the 4th character is a space then we are done reading
- # so just break the loop
- if(substr($str,3,1) == " ") { break; }
- }
- return $data;
+ if($code != 250 && $code != 251) {
+ $this->error =
+ array("error" => "VRFY failed on name '$name'",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return $rply;
+ }
+
+ /*******************************************************************
+ * INTERNAL FUNCTIONS *
+ ******************************************************************/
+
+ /**
+ * Read in as many lines as possible
+ * either before eof or socket timeout occurs on the operation.
+ * With SMTP we can tell if we have more lines to read if the
+ * 4th character is '-' symbol. If it is a space then we don't
+ * need to read anything else.
+ * @access private
+ * @return string
+ */
+ function get_lines() {
+ $data = "";
+ while($str = @fgets($this->smtp_conn,515)) {
+ if($this->do_debug >= 4) {
+ echo "SMTP -> get_lines(): \$data was \"$data\"" .
+ $this->CRLF;
+ echo "SMTP -> get_lines(): \$str is \"$str\"" .
+ $this->CRLF;
+ }
+ $data .= $str;
+ if($this->do_debug >= 4) {
+ echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
+ }
+ # if the 4th character is a space then we are done reading
+ # so just break the loop
+ if(substr($str,3,1) == " ") { break; }
}
+ return $data;
+ }
}
<?php
-/**
- * Snoopy - the PHP net client
- * @author Monte Ohrt <monte@ispi.net>
- * @copyright 1999-2000 ispi, all rights reserved
- * @version 1.01
- * @license GNU Lesser GPL
- * @link http://snoopy.sourceforge.net/
- * @package Snoopy
- */
-
if ( !in_array('Snoopy', get_declared_classes() ) ) :
-/**
- * Snoopy - the PHP net client
- *
- * @author Monte Ohrt <monte@ispi.net>
- * @copyright (c): 1999-2000 ispi, all rights reserved
- * @version 1.01
- *
+/*************************************************
+
+Snoopy - the PHP net client
+Author: Monte Ohrt <monte@ispi.net>
+Copyright (c): 1999-2008 New Digital Group, all rights reserved
+Version: 1.2.4
+
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * You may contact the author of Snoopy by e-mail at:
- * monte@ispi.net
- *
- * Or, write to:
- * Monte Ohrt
- * CTO, ispi
- * 237 S. 70th suite 220
- * Lincoln, NE 68510
- *
- * @link http://snoopy.sourceforge.net/ The latest version of Snoopy can be
- * obtained
- */
+
+You may contact the author of Snoopy by e-mail at:
+monte@ohrt.com
+
+The latest version of Snoopy can be obtained from:
+http://snoopy.sourceforge.net/
+
+*************************************************/
+
class Snoopy
{
/**** Public variables ****/
var $proxy_user = ""; // proxy user to use
var $proxy_pass = ""; // proxy password to use
- var $agent = "Snoopy v1.2.3"; // agent we masquerade as
+ var $agent = "Snoopy v1.2.4"; // agent we masquerade as
var $referer = ""; // referer info to pass
var $cookies = array(); // array of cookies to pass
// $cookies["username"]="joe";
var $error = ""; // error messages sent here
var $response_code = ""; // response code returned from server
var $headers = array(); // headers returned from server sent here
- var $maxlength = 8192; // max return data length (body)
+ var $maxlength = 500000; // max return data length (body)
var $read_timeout = 0; // timeout on read operations, in seconds
// supported only since PHP 4 Beta 4
// set to 0 to disallow timeouts
chr(176),
chr(39),
chr(128),
- "ä",
- "ö",
- "ü",
- "Ä",
- "Ö",
- "Ü",
- "ß",
+ "ä",
+ "ö",
+ "ü",
+ "Ä",
+ "Ö",
+ "Ü",
+ "ß",
);
$text = preg_replace($search,$replace,$document);
$headerfile = tempnam($temp_dir, "sno");
- $safer_URI = strtr( $URI, "\"", " " ); // strip quotes from the URI to avoid shell access
- exec(escapeshellcmd($this->curl_path." -D \"$headerfile\"".$cmdline_params." \"".$safer_URI."\""),$results,$return);
+ exec($this->curl_path." -k -D \"$headerfile\"".$cmdline_params." \"".escapeshellcmd($URI)."\"",$results,$return);
if($return)
{
if (!is_readable($file_name)) continue;
$fp = fopen($file_name, "r");
- while (!feof($fp)) {
- $file_content .= fread($fp, filesize($file_name));
- }
+ $file_content = fread($fp, filesize($file_name));
fclose($fp);
$base_name = basename($file_name);
}
}
endif;
-
?>
<?php
-
+/**
+ * BackPress Scripts enqueue.
+ *
+ * These classes were refactored from the WordPress WP_Scripts and WordPress
+ * script enqueue API.
+ *
+ * @package BackPress
+ * @since r74
+ */
+
+/**
+ * BackPress enqueued dependiences class.
+ *
+ * @package BackPress
+ * @uses _WP_Dependency
+ * @since r74
+ */
class WP_Dependencies {
var $registered = array();
var $queue = array();
return false; // Abort this branch.
else
continue; // We're at the top level. Move on to the next one.
- }
+ }
$this->to_do[$handle] = true;
}
<?php
-
+/**
+ * BackPress Scripts enqueue.
+ *
+ * These classes were refactored from the WordPress WP_Scripts and WordPress
+ * script enqueue API.
+ *
+ * @package BackPress
+ * @since r16
+ */
+
+/**
+ * BackPress Scripts enqueue class.
+ *
+ * @package BackPress
+ * @uses WP_Dependencies
+ * @since r16
+ */
class WP_Scripts extends WP_Dependencies {
var $base_url; // Full URL with trailing slash
var $default_version;
echo "\t$object_name = {\n";
$eol = '';
foreach ( $this->registered[$handle]->extra['l10n'][1] as $var => $val ) {
+ if ( 'l10n_print_after' == $var ) {
+ $after = $val;
+ continue;
+ }
echo "$eol\t\t$var: \"" . js_escape( $val ) . '"';
$eol = ",\n";
}
echo "\n\t}\n";
+ echo isset($after) ? "\t$after\n" : '';
echo "/* ]]> */\n";
echo "</script>\n";
<?php
-
+/**
+ * BackPress Styles enqueue.
+ *
+ * These classes were refactored from the WordPress WP_Scripts and WordPress
+ * script enqueue API.
+ *
+ * @package BackPress
+ * @since r74
+ */
+
+/**
+ * BackPress Styles enqueue class.
+ *
+ * @package BackPress
+ * @uses WP_Dependencies
+ * @since r74
+ */
class WP_Styles extends WP_Dependencies {
var $base_url;
var $default_version;
<?php
+/**
+ * Holds Most of the WordPress classes.
+ *
+ * Some of the other classes are contained in other files. For example, the
+ * WordPress cache is in cache.php and the WordPress roles API is in
+ * capabilities.php. The third party libraries are contained in their own
+ * separate files.
+ *
+ * @package WordPress
+ */
+/**
+ * WordPress environment setup class.
+ *
+ * @package WordPress
+ * @since 2.0.0
+ */
class WP {
- var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term');
-
- var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm');
+ /**
+ * Public query variables.
+ *
+ * Long list of public query variables.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var array
+ */
+ var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage');
+
+ /**
+ * Private query variables.
+ *
+ * Long list of private query variables.
+ *
+ * @since 2.0.0
+ * @var array
+ */
+ var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm', 'comments_per_page');
+
+ /**
+ * Extra query variables set by the user.
+ *
+ * @since 2.1.0
+ * @var array
+ */
var $extra_query_vars = array();
+ /**
+ * Query variables for setting up the WordPress Query Loop.
+ *
+ * @since 2.0.0
+ * @var array
+ */
var $query_vars;
+
+ /**
+ * String parsed to set the query variables.
+ *
+ * @since 2.0.0
+ * @var string
+ */
var $query_string;
+
+ /**
+ * Permalink or requested URI.
+ *
+ * @since 2.0.0
+ * @var string
+ */
var $request;
+
+ /**
+ * Rewrite rule the request matched.
+ *
+ * @since 2.0.0
+ * @var string
+ */
var $matched_rule;
+
+ /**
+ * Rewrite query the request matched.
+ *
+ * @since 2.0.0
+ * @var string
+ */
var $matched_query;
+
+ /**
+ * Whether already did the permalink.
+ *
+ * @since 2.0.0
+ * @var bool
+ */
var $did_permalink = false;
+ /**
+ * Add name to list of public query variables.
+ *
+ * @since 2.1.0
+ *
+ * @param string $qv Query variable name.
+ */
function add_query_var($qv) {
if ( !in_array($qv, $this->public_query_vars) )
$this->public_query_vars[] = $qv;
}
+ /**
+ * Set the value of a query variable.
+ *
+ * @since 2.3.0
+ *
+ * @param string $key Query variable name.
+ * @param mixed $value Query variable value.
+ */
function set_query_var($key, $value) {
$this->query_vars[$key] = $value;
}
+ /**
+ * Parse request to find correct WordPress query.
+ *
+ * Sets up the query variables based on the request. There are also many
+ * filters and actions that can be used to further manipulate the result.
+ *
+ * @since 2.0.0
+ *
+ * @param array|string $extra_query_vars Set the extra query variables.
+ */
function parse_request($extra_query_vars = '') {
global $wp_rewrite;
// Look for matches.
$request_match = $request;
- foreach ($rewrite as $match => $query) {
+ foreach ( (array) $rewrite as $match => $query) {
// Don't try to match against AtomPub calls
if ( $req_uri == 'wp-app.php' )
break;
$query = preg_replace("!^.+\?!", '', $query);
// Substitute the substring matches into the query.
- eval("\$query = \"" . addslashes($query) . "\";");
+ eval("@\$query = \"" . addslashes($query) . "\";");
+
$this->matched_query = $query;
// Parse the query.
}
}
- foreach ($this->private_query_vars as $var) {
+ foreach ( (array) $this->private_query_vars as $var) {
if (isset($this->extra_query_vars[$var]))
$this->query_vars[$var] = $this->extra_query_vars[$var];
elseif (isset($GLOBALS[$var]) && '' != $GLOBALS[$var])
do_action_ref_array('parse_request', array(&$this));
}
+ /**
+ * Send additional HTTP headers for caching, content type, etc.
+ *
+ * Sets the X-Pingback header, 404 status (if 404), Content-type. If showing
+ * a feed, it will also send last-modified, etag, and 304 status if needed.
+ *
+ * @since 2.0.0
+ */
function send_headers() {
@header('X-Pingback: '. get_bloginfo('pingback_url'));
if ( is_user_logged_in() )
do_action_ref_array('send_headers', array(&$this));
}
+ /**
+ * Sets the query string property based off of the query variable property.
+ *
+ * The 'query_string' filter is deprecated, but still works. Plugins should
+ * use the 'request' filter instead.
+ *
+ * @since 2.0.0
+ */
function build_query_string() {
$this->query_string = '';
- foreach (array_keys($this->query_vars) as $wpvar) {
+ foreach ( (array) array_keys($this->query_vars) as $wpvar) {
if ( '' != $this->query_vars[$wpvar] ) {
$this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars.
}
}
+ /**
+ * Setup the WordPress Globals.
+ *
+ * The query_vars property will be extracted to the GLOBALS. So care should
+ * be taken when naming global variables that might interfere with the
+ * WordPress environment.
+ *
+ * @global string $query_string Query string for the loop.
+ * @global int $more Only set, if single page or post.
+ * @global int $single If single page or post. Only set, if single page or post.
+ *
+ * @since 2.0.0
+ */
function register_globals() {
global $wp_query;
// Extract updated query vars back into global namespace.
- foreach ($wp_query->query_vars as $key => $value) {
+ foreach ( (array) $wp_query->query_vars as $key => $value) {
$GLOBALS[$key] = $value;
}
}
}
+ /**
+ * Setup the current user.
+ *
+ * @since 2.0.0
+ */
function init() {
wp_get_current_user();
}
+ /**
+ * Setup the Loop based on the query variables.
+ *
+ * @uses WP::$query_vars
+ * @since 2.0.0
+ */
function query_posts() {
global $wp_the_query;
$this->build_query_string();
$wp_the_query->query($this->query_vars);
}
+ /**
+ * Set the Headers for 404, if permalink is not found.
+ *
+ * Issue a 404 if a permalink request doesn't match any posts. Don't issue
+ * a 404 if one was already issued, if the request was a search, or if the
+ * request was a regular query string request rather than a permalink
+ * request. Issues a 200, if not 404.
+ *
+ * @since 2.0.0
+ */
function handle_404() {
global $wp_query;
- // Issue a 404 if a permalink request doesn't match any posts. Don't
- // issue a 404 if one was already issued, if the request was a search,
- // or if the request was a regular query string request rather than a
- // permalink request.
+
if ( (0 == count($wp_query->posts)) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
+ // Don't 404 for these queries if they matched an object.
+ if ( ( is_tag() || is_category() || is_author() ) && $wp_query->get_queried_object() ) {
+ if ( !is_404() )
+ status_header( 200 );
+ return;
+ }
$wp_query->set_404();
status_header( 404 );
nocache_headers();
- } elseif( is_404() != true ) {
+ } elseif ( !is_404() ) {
status_header( 200 );
}
}
+ /**
+ * Sets up all of the variables required by the WordPress environment.
+ *
+ * The action 'wp' has one parameter that references the WP object. It
+ * allows for accessing the properties and methods to further manipulate the
+ * object.
+ *
+ * @since 2.0.0
+ *
+ * @param string|array $query_args Passed to {@link parse_request()}
+ */
function main($query_args = '') {
$this->init();
$this->parse_request($query_args);
do_action_ref_array('wp', array(&$this));
}
+ /**
+ * PHP4 Constructor - Does nothing.
+ *
+ * Call main() method when ready to run setup.
+ *
+ * @since 2.0.0
+ *
+ * @return WP
+ */
function WP() {
// Empty.
}
}
+/**
+ * WordPress Error class.
+ *
+ * Container for checking for WordPress errors and error messages. Return
+ * WP_Error and use {@link is_wp_error()} to check if this class is returned.
+ * Many core WordPress functions pass this class in the event of an error and
+ * if not handled properly will result in code errors.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ */
class WP_Error {
+ /**
+ * Stores the list of errors.
+ *
+ * @since 2.1.0
+ * @var array
+ * @access private
+ */
var $errors = array();
+
+ /**
+ * Stores the list of data for error codes.
+ *
+ * @since 2.1.0
+ * @var array
+ * @access private
+ */
var $error_data = array();
+ /**
+ * PHP4 Constructor - Sets up error message.
+ *
+ * If code parameter is empty then nothing will be done. It is possible to
+ * add multiple messages to the same code, but with other methods in the
+ * class.
+ *
+ * All parameters are optional, but if the code parameter is set, then the
+ * data parameter is optional.
+ *
+ * @since 2.1.0
+ *
+ * @param string|int $code Error code
+ * @param string $message Error message
+ * @param mixed $data Optional. Error data.
+ * @return WP_Error
+ */
function WP_Error($code = '', $message = '', $data = '') {
if ( empty($code) )
return;
$this->error_data[$code] = $data;
}
+ /**
+ * Retrieve all error codes.
+ *
+ * @since 2.1.0
+ * @access public
+ *
+ * @return array List of error codes, if avaiable.
+ */
function get_error_codes() {
if ( empty($this->errors) )
return array();
return array_keys($this->errors);
}
+ /**
+ * Retrieve first error code available.
+ *
+ * @since 2.1.0
+ * @access public
+ *
+ * @return string|int Empty string, if no error codes.
+ */
function get_error_code() {
$codes = $this->get_error_codes();
return $codes[0];
}
+ /**
+ * Retrieve all error messages or error messages matching code.
+ *
+ * @since 2.1.0
+ *
+ * @param string|int $code Optional. Retrieve messages matching code, if exists.
+ * @return array Error strings on success, or empty array on failure (if using codee parameter).
+ */
function get_error_messages($code = '') {
// Return all messages if no code specified.
if ( empty($code) ) {
$all_messages = array();
- foreach ( $this->errors as $code => $messages )
+ foreach ( (array) $this->errors as $code => $messages )
$all_messages = array_merge($all_messages, $messages);
return $all_messages;
return array();
}
+ /**
+ * Get single error message.
+ *
+ * This will get the first message available for the code. If no code is
+ * given then the first code available will be used.
+ *
+ * @since 2.1.0
+ *
+ * @param string|int $code Optional. Error code to retrieve message.
+ * @return string
+ */
function get_error_message($code = '') {
if ( empty($code) )
$code = $this->get_error_code();
return $messages[0];
}
+ /**
+ * Retrieve error data for error code.
+ *
+ * @since 2.1.0
+ *
+ * @param string|int $code Optional. Error code.
+ * @return mixed Null, if no errors.
+ */
function get_error_data($code = '') {
if ( empty($code) )
$code = $this->get_error_code();
return null;
}
+ /**
+ * Append more error messages to list of error messages.
+ *
+ * @since 2.1.0
+ * @access public
+ *
+ * @param string|int $code Error code.
+ * @param string $message Error message.
+ * @param mixed $data Optional. Error data.
+ */
function add($code, $message, $data = '') {
$this->errors[$code][] = $message;
if ( ! empty($data) )
$this->error_data[$code] = $data;
}
+ /**
+ * Add data for error code.
+ *
+ * The error code can only contain one error data.
+ *
+ * @since 2.1.0
+ *
+ * @param mixed $data Error data.
+ * @param string|int $code Error code.
+ */
function add_data($data, $code = '') {
if ( empty($code) )
$code = $this->get_error_code();
}
}
+/**
+ * Check whether variable is a WordPress Error.
+ *
+ * Looks at the object and if a WP_Error class. Does not check to see if the
+ * parent is also WP_Error, so can't inherit WP_Error and still use this
+ * function.
+ *
+ * @since 2.1.0
+ *
+ * @param mixed $thing Check if unknown variable is WordPress Error object.
+ * @return bool True, if WP_Error. False, if not WP_Error.
+ */
function is_wp_error($thing) {
if ( is_object($thing) && is_a($thing, 'WP_Error') )
return true;
return false;
}
-/*
+/**
* A class for displaying various tree-like structures.
- * Extend the Walker class to use it, see examples at the bottom
+ *
+ * Extend the Walker class to use it, see examples at the below. Child classes
+ * do not need to implement all of the abstract methods in the class. The child
+ * only needs to implement the methods that are needed. Also, the methods are
+ * not strictly abstract in that the parameter definition needs to be followed.
+ * The child classes can have additional parameters.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ * @abstract
*/
class Walker {
+ /**
+ * What the class handles.
+ *
+ * @since 2.1.0
+ * @var string
+ * @access public
+ */
var $tree_type;
+
+ /**
+ * DB fields to use.
+ *
+ * @since 2.1.0
+ * @var array
+ * @access protected
+ */
var $db_fields;
- //abstract callbacks
+ /**
+ * Max number of pages walked by the paged walker
+ *
+ * @since 2.7.0
+ * @var int
+ * @access protected
+ */
+ var $max_pages = 1;
+
+ /**
+ * Starts the list before the elements are added.
+ *
+ * Additional parameters are used in child classes. The args parameter holds
+ * additional values that may be used with the child class methods. This
+ * method is called at the start of the output list.
+ *
+ * @since 2.1.0
+ * @abstract
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ */
function start_lvl(&$output) {}
+
+ /**
+ * Ends the list of after the elements are added.
+ *
+ * Additional parameters are used in child classes. The args parameter holds
+ * additional values that may be used with the child class methods. This
+ * method finishes the list at the end of output of the elements.
+ *
+ * @since 2.1.0
+ * @abstract
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ */
function end_lvl(&$output) {}
+
+ /**
+ * Start the element output.
+ *
+ * Additional parameters are used in child classes. The args parameter holds
+ * additional values that may be used with the child class methods. Includes
+ * the element output also.
+ *
+ * @since 2.1.0
+ * @abstract
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ */
function start_el(&$output) {}
+
+ /**
+ * Ends the element output, if needed.
+ *
+ * Additional parameters are used in child classes. The args parameter holds
+ * additional values that may be used with the child class methods.
+ *
+ * @since 2.1.0
+ * @abstract
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ */
function end_el(&$output) {}
- /*
- * display one element if the element doesn't have any children
- * otherwise, display the element and its children
- */
+ /**
+ * Traverse elements to create list from elements.
+ *
+ * Display one element if the element doesn't have any children otherwise,
+ * display the element and its children. Will only traverse up to the max
+ * depth and no ignore elements under that depth. It is possible to set the
+ * max depth to include all depths, see walk() method.
+ *
+ * This method shouldn't be called directly, use the walk() method instead.
+ *
+ * @since 2.5.0
+ *
+ * @param object $element Data object
+ * @param array $children_elements List of elements to continue traversing.
+ * @param int $max_depth Max depth to traverse.
+ * @param int $depth Depth of current element.
+ * @param array $args
+ * @param string $output Passed by reference. Used to append additional content.
+ * @return null Null on failure with no changes to parameters.
+ */
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
if ( !$element )
return;
$id_field = $this->db_fields['id'];
- $parent_field = $this->db_fields['parent'];
//display this element
+ if ( is_array( $args[0] ) )
+ $args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] );
$cb_args = array_merge( array(&$output, $element, $depth), $args);
call_user_func_array(array(&$this, 'start_el'), $cb_args);
- if ( $max_depth == 0 ||
- ($max_depth != 0 && $max_depth > $depth+1 )) { //whether to descend
-
- $num_elements = sizeof( $children_elements );
- for ( $i = 0; $i < $num_elements; $i++ ) {
+ $id = $element->$id_field;
- $child = $children_elements[$i];
- if ( $child->$parent_field == $element->$id_field ) {
+ // descend only when the depth is right and there are childrens for this element
+ if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) {
- if ( !isset($newlevel) ) {
- $newlevel = true;
- //start the child delimiter
- $cb_args = array_merge( array(&$output, $depth), $args);
- call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
- }
+ foreach( $children_elements[ $id ] as $child ){
- array_splice( $children_elements, $i, 1 );
- $num_elements--;
- $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
- $i = -1;
+ if ( !isset($newlevel) ) {
+ $newlevel = true;
+ //start the child delimiter
+ $cb_args = array_merge( array(&$output, $depth), $args);
+ call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
}
+ $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
}
+ unset( $children_elements[ $id ] );
}
if ( isset($newlevel) && $newlevel ){
call_user_func_array(array(&$this, 'end_el'), $cb_args);
}
- /*
- * displays array of elements hierarchically
- * it is a generic function which does not assume any existing order of elements
- * max_depth = -1 means flatly display every element
- * max_depth = 0 means display all levels
- * max_depth > 0 specifies the number of display levels.
- */
+ /**
+ * Display array of elements hierarchically.
+ *
+ * It is a generic function which does not assume any existing order of
+ * elements. max_depth = -1 means flatly display every element. max_depth =
+ * 0 means display all levels. max_depth > 0 specifies the number of
+ * display levels.
+ *
+ * @since 2.1.0
+ *
+ * @param array $elements
+ * @param int $max_depth
+ * @return string
+ */
function walk( $elements, $max_depth) {
$args = array_slice(func_get_args(), 2);
/*
* need to display in hierarchical order
- * splice elements into two buckets: those without parent and those with parent
+ * seperate elements into two buckets: top level and children elements
+ * children_elements is two dimensional array, eg.
+ * children_elements[10][] contains all sub-elements whose parent is 10.
*/
$top_level_elements = array();
$children_elements = array();
if ( 0 == $e->$parent_field )
$top_level_elements[] = $e;
else
- $children_elements[] = $e;
+ $children_elements[ $e->$parent_field ][] = $e;
}
/*
- * none of the elements is top level
- * the first one must be root of the sub elements
+ * when none of the elements is top level
+ * assume the first one must be root of the sub elements
*/
- if ( !$top_level_elements ) {
-
- $root = $children_elements[0];
- $num_elements = sizeof($children_elements);
- for ( $i = 0; $i < $num_elements; $i++ ) {
-
- $child = $children_elements[$i];
- if ($root->$parent_field == $child->$parent_field ) {
- $top_level_elements[] = $child;
- array_splice( $children_elements, $i, 1 );
- $num_elements--;
- $i--;
- }
+ if ( empty($top_level_elements) ) {
+
+ $first = array_slice( $elements, 0, 1 );
+ $root = $first[0];
+
+ $top_level_elements = array();
+ $children_elements = array();
+ foreach ( $elements as $e) {
+ if ( $root->$parent_field == $e->$parent_field )
+ $top_level_elements[] = $e;
+ else
+ $children_elements[ $e->$parent_field ][] = $e;
}
}
$this->display_element( $e, $children_elements, $max_depth, 0, $args, $output );
/*
- * if we are displaying all levels, and remaining children_elements is not empty,
- * then we got orphans, which should be displayed regardless
- */
- if ( ( $max_depth == 0 ) && sizeof( $children_elements ) > 0 ) {
+ * if we are displaying all levels, and remaining children_elements is not empty,
+ * then we got orphans, which should be displayed regardless
+ */
+ if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) {
$empty_array = array();
- foreach ( $children_elements as $orphan_e )
- $this->display_element( $orphan_e, $empty_array, 1, 0, $args, $output );
+ foreach ( $children_elements as $orphans )
+ foreach( $orphans as $op )
+ $this->display_element( $op, $empty_array, 1, 0, $args, $output );
}
+
return $output;
}
+
+ /**
+ * paged_walk() - produce a page of nested elements
+ *
+ * Given an array of hierarchical elements, the maximum depth, a specific page number,
+ * and number of elements per page, this function first determines all top level root elements
+ * belonging to that page, then lists them and all of their children in hierarchical order.
+ *
+ * @package WordPress
+ * @since 2.7
+ * @param $max_depth = 0 means display all levels; $max_depth > 0 specifies the number of display levels.
+ * @param $page_num the specific page number, beginning with 1.
+ * @return XHTML of the specified page of elements
+ */
+ function paged_walk( $elements, $max_depth, $page_num, $per_page ) {
+
+ /* sanity check */
+ if ( empty($elements) || $max_depth < -1 )
+ return '';
+
+ $args = array_slice( func_get_args(), 4 );
+ $output = '';
+
+ $id_field = $this->db_fields['id'];
+ $parent_field = $this->db_fields['parent'];
+
+ $count = -1;
+ if ( -1 == $max_depth )
+ $total_top = count( $elements );
+ if ( $page_num < 1 || $per_page < 0 ) {
+ // No paging
+ $paging = false;
+ $start = 0;
+ if ( -1 == $max_depth )
+ $end = $total_top;
+ $this->max_pages = 1;
+ } else {
+ $paging = true;
+ $start = ( (int)$page_num - 1 ) * (int)$per_page;
+ $end = $start + $per_page;
+ if ( -1 == $max_depth )
+ $this->max_pages = ceil($total_top / $per_page);
+ }
+
+ // flat display
+ if ( -1 == $max_depth ) {
+ if ( !empty($args[0]['reverse_top_level']) ) {
+ $elements = array_reverse( $elements );
+ $oldstart = $start;
+ $start = $total_top - $end;
+ $end = $total_top - $oldstart;
+ }
+
+ $empty_array = array();
+ foreach ( $elements as $e ) {
+ $count++;
+ if ( $count < $start )
+ continue;
+ if ( $count >= $end )
+ break;
+ $this->display_element( $e, $empty_array, 1, 0, $args, $output );
+ }
+ return $output;
+ }
+
+ /*
+ * seperate elements into two buckets: top level and children elements
+ * children_elements is two dimensional array, eg.
+ * children_elements[10][] contains all sub-elements whose parent is 10.
+ */
+ $top_level_elements = array();
+ $children_elements = array();
+ foreach ( $elements as $e) {
+ if ( 0 == $e->$parent_field )
+ $top_level_elements[] = $e;
+ else
+ $children_elements[ $e->$parent_field ][] = $e;
+ }
+
+ $total_top = count( $top_level_elements );
+ if ( $paging )
+ $this->max_pages = ceil($total_top / $per_page);
+ else
+ $end = $total_top;
+
+ if ( !empty($args[0]['reverse_top_level']) ) {
+ $top_level_elements = array_reverse( $top_level_elements );
+ $oldstart = $start;
+ $start = $total_top - $end;
+ $end = $total_top - $oldstart;
+ }
+ if ( !empty($args[0]['reverse_children']) ) {
+ foreach ( $children_elements as $parent => $children )
+ $children_elements[$parent] = array_reverse( $children );
+ }
+
+ foreach ( $top_level_elements as $e ) {
+ $count++;
+
+ //for the last page, need to unset earlier children in order to keep track of orphans
+ if ( $end >= $total_top && $count < $start )
+ $this->unset_children( $e, $children_elements );
+
+ if ( $count < $start )
+ continue;
+
+ if ( $count >= $end )
+ break;
+
+ $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output );
+ }
+
+ if ( $end >= $total_top && count( $children_elements ) > 0 ) {
+ $empty_array = array();
+ foreach ( $children_elements as $orphans )
+ foreach( $orphans as $op )
+ $this->display_element( $op, $empty_array, 1, 0, $args, $output );
+ }
+
+ return $output;
+ }
+
+ function get_number_of_root_elements( $elements ){
+
+ $num = 0;
+ $parent_field = $this->db_fields['parent'];
+
+ foreach ( $elements as $e) {
+ if ( 0 == $e->$parent_field )
+ $num++;
+ }
+ return $num;
+ }
+
+ // unset all the children for a given top level element
+ function unset_children( $e, &$children_elements ){
+
+ if ( !$e || !$children_elements )
+ return;
+
+ $id_field = $this->db_fields['id'];
+ $id = $e->$id_field;
+
+ if ( !empty($children_elements[$id]) && is_array($children_elements[$id]) )
+ foreach ( (array) $children_elements[$id] as $child )
+ $this->unset_children( $child, $children_elements );
+
+ if ( isset($children_elements[$id]) )
+ unset( $children_elements[$id] );
+
+ }
}
+/**
+ * Create HTML list of pages.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ * @uses Walker
+ */
class Walker_Page extends Walker {
+ /**
+ * @see Walker::$tree_type
+ * @since 2.1.0
+ * @var string
+ */
var $tree_type = 'page';
- var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
+ /**
+ * @see Walker::$db_fields
+ * @since 2.1.0
+ * @todo Decouple this.
+ * @var array
+ */
+ var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
+
+ /**
+ * @see Walker::start_lvl()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param int $depth Depth of page. Used for padding.
+ */
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul>\n";
}
+ /**
+ * @see Walker::end_lvl()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param int $depth Depth of page. Used for padding.
+ */
function end_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
}
- function start_el(&$output, $page, $depth, $current_page, $args) {
+ /**
+ * @see Walker::start_el()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $page Page data object.
+ * @param int $depth Depth of page. Used for padding.
+ * @param int $current_page Page ID.
+ * @param array $args
+ */
+ function start_el(&$output, $page, $depth, $args, $current_page) {
if ( $depth )
$indent = str_repeat("\t", $depth);
else
$css_class = 'page_item page-item-'.$page->ID;
if ( !empty($current_page) ) {
$_current_page = get_page( $current_page );
- if ( in_array($page->ID, (array) $_current_page->ancestors) )
+ if ( isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors) )
$css_class .= ' current_page_ancestor';
if ( $page->ID == $current_page )
$css_class .= ' current_page_item';
elseif ( $_current_page && $page->ID == $_current_page->post_parent )
$css_class .= ' current_page_parent';
+ } elseif ( $page->ID == get_option('page_for_posts') ) {
+ $css_class .= ' current_page_parent';
}
- $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . apply_filters('the_title', $page->post_title) . '</a>';
+ $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . $link_before . apply_filters('the_title', $page->post_title) . $link_after . '</a>';
if ( !empty($show_date) ) {
if ( 'modified' == $show_date )
}
}
+ /**
+ * @see Walker::end_el()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $page Page data object. Not used.
+ * @param int $depth Depth of page. Not Used.
+ */
function end_el(&$output, $page, $depth) {
$output .= "</li>\n";
}
}
+/**
+ * Create HTML dropdown list of pages.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ * @uses Walker
+ */
class Walker_PageDropdown extends Walker {
+ /**
+ * @see Walker::$tree_type
+ * @since 2.1.0
+ * @var string
+ */
var $tree_type = 'page';
- var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
+ /**
+ * @see Walker::$db_fields
+ * @since 2.1.0
+ * @todo Decouple this
+ * @var array
+ */
+ var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
+
+ /**
+ * @see Walker::start_el()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $page Page data object.
+ * @param int $depth Depth of page in reference to parent pages. Used for padding.
+ * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element.
+ */
function start_el(&$output, $page, $depth, $args) {
$pad = str_repeat(' ', $depth * 3);
- $output .= "\t<option value=\"$page->ID\"";
+ $output .= "\t<option class=\"level-$depth\" value=\"$page->ID\"";
if ( $page->ID == $args['selected'] )
$output .= ' selected="selected"';
$output .= '>';
}
}
+/**
+ * Create HTML list of categories.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ * @uses Walker
+ */
class Walker_Category extends Walker {
+ /**
+ * @see Walker::$tree_type
+ * @since 2.1.0
+ * @var string
+ */
var $tree_type = 'category';
- var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
+ /**
+ * @see Walker::$db_fields
+ * @since 2.1.0
+ * @todo Decouple this
+ * @var array
+ */
+ var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
+
+ /**
+ * @see Walker::start_lvl()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param int $depth Depth of category. Used for tab indentation.
+ * @param array $args Will only append content if style argument value is 'list'.
+ */
function start_lvl(&$output, $depth, $args) {
if ( 'list' != $args['style'] )
return;
$output .= "$indent<ul class='children'>\n";
}
+ /**
+ * @see Walker::end_lvl()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param int $depth Depth of category. Used for tab indentation.
+ * @param array $args Will only append content if style argument value is 'list'.
+ */
function end_lvl(&$output, $depth, $args) {
if ( 'list' != $args['style'] )
return;
$output .= "$indent</ul>\n";
}
+ /**
+ * @see Walker::start_el()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $category Category data object.
+ * @param int $depth Depth of category in reference to parents.
+ * @param array $args
+ */
function start_el(&$output, $category, $depth, $args) {
extract($args);
}
}
+ /**
+ * @see Walker::end_el()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $page Not used.
+ * @param int $depth Depth of category. Not used.
+ * @param array $args Only uses 'list' for whether should append to output.
+ */
function end_el(&$output, $page, $depth, $args) {
if ( 'list' != $args['style'] )
return;
}
+/**
+ * Create HTML dropdown list of Categories.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ * @uses Walker
+ */
class Walker_CategoryDropdown extends Walker {
+ /**
+ * @see Walker::$tree_type
+ * @since 2.1.0
+ * @var string
+ */
var $tree_type = 'category';
- var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
+ /**
+ * @see Walker::$db_fields
+ * @since 2.1.0
+ * @todo Decouple this
+ * @var array
+ */
+ var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
+
+ /**
+ * @see Walker::start_el()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $category Category data object.
+ * @param int $depth Depth of category. Used for padding.
+ * @param array $args Uses 'selected', 'show_count', and 'show_last_update' keys, if they exist.
+ */
function start_el(&$output, $category, $depth, $args) {
$pad = str_repeat(' ', $depth * 3);
$cat_name = apply_filters('list_cats', $category->name, $category);
- $output .= "\t<option value=\"".$category->term_id."\"";
+ $output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\"";
if ( $category->term_id == $args['selected'] )
$output .= ' selected="selected"';
$output .= '>';
}
}
+/**
+ * Send XML response back to AJAX request.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ */
class WP_Ajax_Response {
+ /**
+ * Store XML responses to send.
+ *
+ * @since 2.1.0
+ * @var array
+ * @access private
+ */
var $responses = array();
+ /**
+ * PHP4 Constructor - Passes args to {@link WP_Ajax_Response::add()}.
+ *
+ * @since 2.1.0
+ * @see WP_Ajax_Response::add()
+ *
+ * @param string|array $args Optional. Will be passed to add() method.
+ * @return WP_Ajax_Response
+ */
function WP_Ajax_Response( $args = '' ) {
if ( !empty($args) )
$this->add($args);
}
- // a WP_Error object can be passed in 'id' or 'data'
+ /**
+ * Append to XML response based on given arguments.
+ *
+ * The arguments that can be passed in the $args parameter are below. It is
+ * also possible to pass a WP_Error object in either the 'id' or 'data'
+ * argument. The parameter isn't actually optional, content should be given
+ * in order to send the correct response.
+ *
+ * 'what' argument is a string that is the XMLRPC response type.
+ * 'action' argument is a boolean or string that acts like a nonce.
+ * 'id' argument can be WP_Error or an integer.
+ * 'old_id' argument is false by default or an integer of the previous ID.
+ * 'position' argument is an integer or a string with -1 = top, 1 = bottom,
+ * html ID = after, -html ID = before.
+ * 'data' argument is a string with the content or message.
+ * 'supplemental' argument is an array of strings that will be children of
+ * the supplemental element.
+ *
+ * @since 2.1.0
+ *
+ * @param string|array $args Override defaults.
+ * @return string XML response.
+ */
function add( $args = '' ) {
$defaults = array(
'what' => 'object', 'action' => false,
'id' => '0', 'old_id' => false,
- 'position' => 1, // -1 = top, 1 = bottom, html ID = after, -html ID = before
+ 'position' => 1,
'data' => '', 'supplemental' => array()
);
$response = '';
if ( is_wp_error($data) ) {
- foreach ( $data->get_error_codes() as $code ) {
+ foreach ( (array) $data->get_error_codes() as $code ) {
$response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message($code) . "]]></wp_error>";
if ( !$error_data = $data->get_error_data($code) )
continue;
}
$s = '';
- if ( (array) $supplemental ) {
+ if ( is_array($supplemental) ) {
foreach ( $supplemental as $k => $v )
$s .= "<$k><![CDATA[$v]]></$k>";
$s = "<supplemental>$s</supplemental>";
return $x;
}
+ /**
+ * Display XML formatted responses.
+ *
+ * Sets the content type header to text/xml.
+ *
+ * @since 2.1.0
+ */
function send() {
header('Content-Type: text/xml');
echo "<?xml version='1.0' standalone='yes'?><wp_ajax>";
- foreach ( $this->responses as $response )
+ foreach ( (array) $this->responses as $response )
echo $response;
echo '</wp_ajax>';
die();
* If the comment has an empty comment_author field, then 'Anonymous' person is
* assumed.
*
- * @since 1.5
+ * @since 1.5.0
* @uses apply_filters() Calls 'get_comment_author' hook on the comment author
*
* @return string The comment author
*/
function get_comment_author() {
global $comment;
- if ( empty($comment->comment_author) )
- $author = __('Anonymous');
- else
+ if ( empty($comment->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);
}
/**
* Retrieve the email of the author of the current comment.
*
- * @since 1.5
+ * @since 1.5.0
* @uses apply_filters() Calls the 'get_comment_author_email' hook on the comment author email
* @uses $comment
*
*
* @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 $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;
- echo $before;
- echo "<a href='mailto:$email'>$display</a>";
- echo $after;
+ $return = $before;
+ $return .= "<a href='mailto:$email'>$display</a>";
+ $return .= $after;
+ return $return;
+ } else {
+ return '';
}
}
/**
* Retrieve the html link to the url of the author of the current comment.
*
- * @since 1.5
+ * @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
if ( empty( $url ) || 'http://' == $url )
$return = $author;
else
- $return = "<a href='$url' rel='external nofollow'>$author</a>";
+ $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
return apply_filters('get_comment_author_link', $return);
}
/**
* Retrieve the IP address of the author of the current comment.
*
- * @since 1.5
+ * @since 1.5.0
* @uses $comment
* @uses apply_filters()
*
/**
* Retrieve the url of the author of the current comment.
*
- * @since 1.5
+ * @since 1.5.0
* @uses apply_filters() Calls 'get_comment_author_url' hook on the comment author's URL
*
* @return string
* 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
+ * @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
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 comment-author-' . $user->user_nicename;
+ // 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
+ * @since 1.5.0
* @uses apply_filters() Calls 'get_comment_date' hook with the formated date and the $d parameter respectively
* @uses $comment
*
* If the word count is less than 20, then no truncating is done and no '...'
* will appear.
*
- * @since 1.5
+ * @since 1.5.0
* @uses $comment
* @uses apply_filters() Calls 'get_comment_excerpt' on truncated comment
*
/**
* Display the excerpt of the current comment.
*
- * @since 1.2
+ * @since 1.2.0
* @uses apply_filters() Calls 'comment_excerpt' hook before displaying excerpt
*/
function comment_excerpt() {
/**
* Retrieve the comment id of the current comment.
*
- * @since 1.5
+ * @since 1.5.0
* @uses $comment
* @uses apply_filters() Calls the 'get_comment_ID' hook for the comment ID
*
}
/**
- * Retrieve the link to the current comment.
+ * Retrieve the link to a given comment.
*
- * @since 1.5
+ * @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 current comment
*/
-function get_comment_link() {
- global $comment;
- return get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID;
+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() )
+ return user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' ) . '#comment-' . $comment->comment_ID;
+ else
+ return add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ) . '#comment-' . $comment->comment_ID;
+ } else {
+ return get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID;
+ }
}
/**
* Retrieves the link to the current post comments.
*
- * @since 1.5
+ * @since 1.5.0
*
* @return string The link to the comments
*/
/**
* Retrieve the amount of comments a post has.
*
- * @since 1.5
+ * @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
/**
* Retrieve the text of the current comment.
*
- * @since 1.5
+ * @since 1.5.0
* @uses $comment
*
* @return string The comment content
/**
* Retrieve the comment time of the current comment.
*
- * @since 1.5
+ * @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.
*
/**
* Retrieve the comment type of the current comment.
*
- * @since 1.5
+ * @since 1.5.0
* @uses $comment
* @uses apply_filters() Calls the 'get_comment_type' hook on the comment type
*
* 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
+ * @since 1.5.0
* @uses apply_filters() Calls 'trackback_url' on the resulting trackback URL
* @uses $id
*
/**
* Whether the current post is open for comments.
*
- * @since 1.5
+ * @since 1.5.0
* @uses $post
*
* @param int $post_id An optional post ID to check instead of the current post.
/**
* Whether the current post is open for pings.
*
- * @since 1.5
+ * @since 1.5.0
* @uses $post
*
* @param int $post_id An optional post ID to check instead of the current post.
* above. Does not exist in versions prior to 2.0.10 in the 2.0 branch and in
* the 2.1 branch, prior to 2.1.3. Technically added in 2.2.0.
*
- * @since 2.0.10 Backported to 2.0 branch
+ * Backported to 2.0.10.
+ *
* @since 2.1.3
* @uses $post Gets the ID of the current post for the token
*/
function wp_comment_form_unfiltered_html_nonce() {
global $post;
+
+ $post_id = 0;
+ if ( !empty($post) )
+ $post_id = $post->ID;
+
if ( current_user_can('unfiltered_html') )
- wp_nonce_field('unfiltered-html-comment_' . $post->ID, '_wp_unfiltered_html_comment', false);
+ wp_nonce_field('unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment', false);
}
/**
* default theme. If either does not exist, then the WordPress process will be
* halted. It is advised for that reason, that the default theme is not deleted.
*
- * @since 1.5
+ * @since 1.5.0
* @global array $comment List of comment objects for the current post
* @uses $wpdb
* @uses $id
* @uses $withcomments Will not try to get the comments if the post has none.
*
* @param string $file Optional, default '/comments.php'. The file to load
+ * @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false.
* @return null Returns null if no comments appear
*/
-function comments_template( $file = '/comments.php' ) {
- global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
+function comments_template( $file = '/comments.php', $separate_comments = false ) {
+ global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
if ( ! (is_single() || is_page() || $withcomments) )
return;
+ if ( empty($file) )
+ $file = '/comments.php';
+
$req = get_option('require_name_email');
$commenter = wp_get_current_commenter();
extract($commenter, EXTR_SKIP);
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date", $post->ID, $comment_author, $comment_author_email));
}
- // keep $comments for legacy's sake (remember $table*? ;) )
- $comments = $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );
+ // keep $comments for legacy's sake
+ $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );
+ $comments = &$wp_query->comments;
$wp_query->comment_count = count($wp_query->comments);
- update_comment_cache($comments);
+ update_comment_cache($wp_query->comments);
+
+ if ( $separate_comments ) {
+ $wp_query->comments_by_type = &separate_comments($comments);
+ $comments_by_type = &$wp_query->comments_by_type;
+ }
+
+ $overridden_cpage = FALSE;
+ if ( '' == get_query_var('cpage') && get_option('page_comments') ) {
+ set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 );
+ $overridden_cpage = TRUE;
+ }
define('COMMENTS_TEMPLATE', true);
- $include = apply_filters('comments_template', TEMPLATEPATH . $file );
+
+ $include = apply_filters('comments_template', STYLESHEETPATH . $file );
if ( file_exists( $include ) )
require( $include );
+ elseif ( file_exists( TEMPLATEPATH . $file ) )
+ require( TEMPLATEPATH . $file );
else
- require( WP_CONTENT_DIR . '/themes/default/comments.php');
+ require( get_theme_root() . '/default/comments.php');
}
/**
return;
}
- if ( !empty($post->post_password) ) { // if there's a password
- if ( !isset($_COOKIE['wp-postpass_' . COOKIEHASH]) || $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password ) { // and it doesn't match the cookie
- echo __('Enter your password to view comments');
- return;
- }
+ if ( post_password_required() ) {
+ echo __('Enter your password to view comments');
+ return;
}
echo '<a href="';
echo '</a>';
}
-?>
\ No newline at end of file
+/**
+ * Retrieve HTML content for reply to comment link.
+ *
+ * The default arguments that can be override are 'add_below', 'respond_id',
+ * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be
+ * used, if the user must log in or register first before posting a comment. The
+ * 'reply_text' will be used, if they can post a reply. The 'add_below' and
+ * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function
+ * parameters.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args Optional. Override default options.
+ * @param int $comment Optional. Comment being replied to.
+ * @param int $post Optional. Post that the comment is going to be displayed on.
+ * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
+ */
+function get_comment_reply_link($args = array(), $comment = null, $post = null) {
+ global $user_ID;
+
+ $defaults = array('add_below' => 'comment', 'respond_id' => 'respond', 'reply_text' => __('Reply'),
+ 'login_text' => __('Log in to Reply'), 'depth' => 0, 'before' => '', 'after' => '');
+
+ $args = wp_parse_args($args, $defaults);
+
+ if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] )
+ return;
+
+ extract($args, EXTR_SKIP);
+
+ $comment = get_comment($comment);
+ $post = get_post($post);
+
+ if ( 'open' != $post->comment_status )
+ return false;
+
+ $link = '';
+
+ if ( get_option('comment_registration') && !$user_ID )
+ $link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>';
+ else
+ $link = "<a rel='nofollow' class='comment-reply-link' href='" . wp_specialchars( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
+ return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post);
+}
+
+/**
+ * Displays the HTML content for reply to comment link.
+ *
+ * @since 2.7.0
+ * @see get_comment_reply_link() Echoes result
+ *
+ * @param array $args Optional. Override default options.
+ * @param int $comment Optional. Comment being replied to.
+ * @param int $post Optional. Post that the comment is going to be displayed on.
+ * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
+ */
+function comment_reply_link($args = array(), $comment = null, $post = null) {
+ echo get_comment_reply_link($args, $comment, $post);
+}
+
+/**
+ * Retrieve HTML content for reply to post link.
+ *
+ * The default arguments that can be override are 'add_below', 'respond_id',
+ * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be
+ * used, if the user must log in or register first before posting a comment. The
+ * 'reply_text' will be used, if they can post a reply. The 'add_below' and
+ * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function
+ * parameters.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args Optional. Override default options.
+ * @param int|object $post Optional. Post that the comment is going to be displayed on. Defaults to current post.
+ * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
+ */
+function get_post_reply_link($args = array(), $post = null) {
+ global $user_ID;
+
+ $defaults = array('add_below' => 'post', 'respond_id' => 'respond', 'reply_text' => __('Leave a Comment'),
+ 'login_text' => __('Log in to leave a Comment'), 'before' => '', 'after' => '');
+
+ $args = wp_parse_args($args, $defaults);
+ extract($args, EXTR_SKIP);
+ $post = get_post($post);
+
+ if ( !comments_open($post->ID) )
+ return false;
+
+ if ( get_option('comment_registration') && !$user_ID ) {
+ $link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>';
+ } else {
+ $link = "<a rel='nofollow' class='comment-reply-link' href='" . get_permalink($post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
+ }
+ return apply_filters('post_comments_link', $before . $link . $after, $post);
+}
+
+/**
+ * Displays the HTML content for reply to post link.
+ * @since 2.7.0
+ * @see get_post_reply_link()
+ *
+ * @param array $args Optional. Override default options.
+ * @param int|object $post Optional. Post that the comment is going to be displayed on.
+ * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
+ */
+function post_reply_link($args = array(), $post = null) {
+ echo get_post_reply_link($args, $post);
+}
+
+/**
+ * Retrieve HTML content for cancel comment reply link.
+ *
+ * @since 2.7.0
+ *
+ * @param string $text Optional. Text to display for cancel reply link.
+ */
+function get_cancel_comment_reply_link($text = '') {
+ if ( empty($text) )
+ $text = __('Click here to cancel reply.');
+
+ $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';
+ $link = wp_specialchars( remove_query_arg('replytocom') ) . '#respond';
+ return apply_filters('cancel_comment_reply_link', '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>', $link, $text);
+}
+
+/**
+ * Display HTML content for cancel comment reply link.
+ *
+ * @since 2.7.0
+ *
+ * @param string $text Optional. Text to display for cancel reply link.
+ */
+function cancel_comment_reply_link($text = '') {
+ echo get_cancel_comment_reply_link($text);
+}
+
+/**
+ * Output hidden input HTML for replying to comments.
+ *
+ * @since 2.7.0
+ */
+function comment_id_fields() {
+ global $id;
+
+ $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
+ echo "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
+ echo "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
+}
+
+/**
+ * Display text based on comment reply status. Only affects users with Javascript disabled.
+ *
+ * @since 2.7.0
+ *
+ * @param string $noreplytext Optional. Text to display when not replying to a comment.
+ * @param string $replytext Optional. Text to display when replying to a comment. Accepts "%s" for the author of the comment being replied to.
+ * @param string $linktoparent Optional. Boolean to control making the author's name a link to their comment.
+ */
+function comment_form_title( $noreplytext = 'Leave a Reply', $replytext = 'Leave a Reply to %s', $linktoparent = TRUE ) {
+ global $comment;
+
+ $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
+
+ if ( 0 == $replytoid )
+ echo $noreplytext;
+ else {
+ $comment = get_comment($replytoid);
+ $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author() . '</a>' : get_comment_author();
+ printf( $replytext, $author );
+ }
+}
+
+/**
+ * HTML comment list class.
+ *
+ * @package WordPress
+ * @uses Walker
+ * @since unknown
+ */
+class Walker_Comment extends Walker {
+ /**
+ * @see Walker::$tree_type
+ * @since unknown
+ * @var string
+ */
+ var $tree_type = 'comment';
+
+ /**
+ * @see Walker::$db_fields
+ * @since unknown
+ * @var array
+ */
+ var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
+
+ /**
+ * @see Walker::start_lvl()
+ * @since unknown
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param int $depth Depth of comment.
+ * @param array $args Uses 'style' argument for type of HTML list.
+ */
+ function start_lvl(&$output, $depth, $args) {
+ $GLOBALS['comment_depth'] = $depth + 1;
+
+ switch ( $args['style'] ) {
+ case 'div':
+ break;
+ case 'ol':
+ echo "<ol class='children'>\n";
+ break;
+ default:
+ case 'ul':
+ echo "<ul class='children'>\n";
+ break;
+ }
+ }
+
+ /**
+ * @see Walker::end_lvl()
+ * @since unknown
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param int $depth Depth of comment.
+ * @param array $args Will only append content if style argument value is 'ol' or 'ul'.
+ */
+ function end_lvl(&$output, $depth, $args) {
+ $GLOBALS['comment_depth'] = $depth + 1;
+
+ switch ( $args['style'] ) {
+ case 'div':
+ break;
+ case 'ol':
+ echo "</ol>\n";
+ break;
+ default:
+ case 'ul':
+ echo "</ul>\n";
+ break;
+ }
+ }
+
+ /**
+ * @see Walker::start_el()
+ * @since unknown
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $comment Comment data object.
+ * @param int $depth Depth of comment in reference to parents.
+ * @param array $args
+ */
+ function start_el(&$output, $comment, $depth, $args) {
+ $depth++;
+ $GLOBALS['comment_depth'] = $depth;
+
+ if ( !empty($args['callback']) ) {
+ call_user_func($args['callback'], $comment, $args, $depth);
+ return;
+ }
+
+ $GLOBALS['comment'] = $comment;
+ extract($args, EXTR_SKIP);
+
+ if ( 'div' == $args['style'] ) {
+ $tag = 'div';
+ $add_below = 'comment';
+ } else {
+ $tag = 'li';
+ $add_below = 'div-comment';
+ }
+?>
+ <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
+ <?php if ( 'ul' == $args['style'] ) : ?>
+ <div id="div-comment-<?php comment_ID() ?>">
+ <?php endif; ?>
+ <div class="comment-author vcard">
+ <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
+ <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
+ </div>
+<?php if ($comment->comment_approved == '0') : ?>
+ <em><?php _e('Your comment is awaiting moderation.') ?></em>
+ <br />
+<?php endif; ?>
+
+ <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','') ?></div>
+
+ <?php comment_text() ?>
+
+ <div class="reply">
+ <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
+ </div>
+ <?php if ( 'ul' == $args['style'] ) : ?>
+ </div>
+ <?php endif; ?>
+<?php
+ }
+
+ /**
+ * @see Walker::end_el()
+ * @since unknown
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $comment
+ * @param int $depth Depth of comment.
+ * @param array $args
+ */
+ function end_el(&$output, $comment, $depth, $args) {
+ if ( !empty($args['end-callback']) ) {
+ call_user_func($args['end-callback'], $comment, $args, $depth);
+ return;
+ }
+ if ( 'div' == $args['style'] )
+ echo "</div>\n";
+ else
+ echo "</li>\n";
+ }
+
+}
+
+/**
+ * List comments
+ *
+ * Used in the comments.php template to list comments for a particular post
+ *
+ * @since 2.7.0
+ * @uses Walker_Comment
+ *
+ * @param string|array $args Formatting options
+ * @param array $comments Optional array of comment objects. Defaults to $wp_query->comments
+ */
+function wp_list_comments($args = array(), $comments = null ) {
+ global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
+
+ $in_comment_loop = true;
+
+ $comment_alt = $comment_thread_alt = 0;
+ $comment_depth = 1;
+
+ $defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
+ 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
+
+ $r = wp_parse_args( $args, $defaults );
+
+ // Figure out what comments we'll be looping through ($_comments)
+ if ( null !== $comments ) {
+ $comments = (array) $comments;
+ if ( empty($comments) )
+ return;
+ if ( 'all' != $r['type'] ) {
+ $comments_by_type = &separate_comments($comments);
+ if ( empty($comments_by_type[$r['type']]) )
+ return;
+ $_comments = $comments_by_type[$r['type']];
+ } else {
+ $_comments = $comments;
+ }
+ } else {
+ if ( empty($wp_query->comments) )
+ return;
+ if ( 'all' != $r['type'] ) {
+ if ( empty($wp_query->comments_by_type) )
+ $wp_query->comments_by_type = &separate_comments($wp_query->comments);
+ if ( empty($wp_query->comments_by_type[$r['type']]) )
+ return;
+ $_comments = $wp_query->comments_by_type[$r['type']];
+ } else {
+ $_comments = $wp_query->comments;
+ }
+ }
+
+ if ( '' === $r['per_page'] && get_option('page_comments') )
+ $r['per_page'] = get_query_var('comments_per_page');
+
+ if ( empty($r['per_page']) ) {
+ $r['per_page'] = 0;
+ $r['page'] = 0;
+ }
+
+ if ( '' === $r['max_depth'] ) {
+ if ( get_option('thread_comments') )
+ $r['max_depth'] = get_option('thread_comments_depth');
+ else
+ $r['max_depth'] = -1;
+ }
+
+ if ( '' === $r['page'] ) {
+ if ( empty($overridden_cpage) ) {
+ $r['page'] = get_query_var('cpage');
+ } else {
+ $threaded = ( -1 == $r['max_depth'] ) ? false : true;
+ $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1;
+ set_query_var( 'cpage', $r['page'] );
+ }
+ }
+ // Validation check
+ $r['page'] = intval($r['page']);
+ if ( 0 == $r['page'] && 0 != $r['per_page'] )
+ $r['page'] = 1;
+
+ if ( null === $r['reverse_top_level'] )
+ $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ) ? TRUE : FALSE;
+
+ extract( $r, EXTR_SKIP );
+
+ if ( empty($walker) )
+ $walker = new Walker_Comment;
+
+ $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
+ $wp_query->max_num_comment_pages = $walker->max_pages;
+
+ $in_comment_loop = false;
+}
+
+?>
* Manages WordPress comments
*
* @package WordPress
+ * @subpackage Comment
*/
/**
* Checks whether a comment passes internal checks to be allowed to add.
*
* If comment moderation is set in the administration, then all comments,
- * regardless of their type and whitelist will be set to false.
+ * regardless of their type and whitelist will be set to false. If the number of
+ * links exceeds the amount in the administration, then the check fails. If any
+ * of the parameter contents match the blacklist of words, then the check fails.
*
* If the number of links exceeds the amount in the administration, then the
- * check fails.
- *
- * If any of the parameter contents match the blacklist of words, then the check
- * fails.
+ * check fails. If any of the parameter contents match the blacklist of words,
+ * then the check fails.
*
* If the comment is a trackback and part of the blogroll, then the trackback is
* automatically whitelisted. If the comment author was approved before, then
* If none of the checks fail, then the failback is to set the check to pass
* (return true).
*
- * @since 1.2
+ * @since 1.2.0
* @uses $wpdb
*
* @param string $author Comment Author's name
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 ( get_option('comment_max_links') && preg_match_all("/<[Aa][^>]*[Hh][Rr][Ee][Ff]=['\"]([^\"'>]+)[^>]*>/", apply_filters('comment_text',$comment), $out) >= get_option('comment_max_links') )
return false; // Check # of external links
$mod_keys = trim(get_option('moderation_keys'));
if ( !empty($mod_keys) ) {
$words = explode("\n", $mod_keys );
- foreach ($words as $word) {
+ foreach ( (array) $words as $word) {
$word = trim($word);
// Skip empty lines
/**
* Retrieve the approved comments for post $post_id.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wpdb
*
* @param int $post_id The ID of the post
* Retrieves comment data given a comment ID or comment object.
*
* If an object is passed then the comment data will be cached and then returned
- * after being passed through a filter.
+ * after being passed through a filter. If the comment is empty, then the global
+ * comment variable will be used, if it is set.
*
* If the comment is empty, then the global comment variable will be used, if it
* is set.
*
- * @since 2.0
+ * @since 2.0.0
* @uses $wpdb
*
* @param object|string|int $comment Comment to retrieve.
- * @param string $output Optional. OBJECT or ARRAY_A or ARRAY_N constants
+ * @param string $output Optional. OBJECT or ARRAY_A or ARRAY_N constants.
* @return object|array|null Depends on $output value.
*/
function &get_comment(&$comment, $output = OBJECT) {
if ( $output == OBJECT ) {
return $_comment;
} elseif ( $output == ARRAY_A ) {
- return get_object_vars($_comment);
+ $__comment = get_object_vars($_comment);
+ return $__comment;
} elseif ( $output == ARRAY_N ) {
- return array_values(get_object_vars($_comment));
+ $__comment = array_values(get_object_vars($_comment));
+ return $__comment;
} else {
return $_comment;
}
}
/**
- * Retrieve an array of comment data about comment $comment_ID.
- *
- * get_comment() technically does the same thing as this function. This function
- * also appears to reference variables and then not use them or not update them
- * when needed. It is advised to switch to get_comment(), since this function
- * might be deprecated in favor of using get_comment().
+ * Retrieve a list of comments.
*
- * @deprecated Use get_comment()
- * @see get_comment()
- * @since 0.71
+ * The list of comment arguments are 'status', 'orderby', 'comment_date_gmt',
+ * 'order', 'number', 'offset', and 'post_id'.
*
- * @uses $postc Comment cache, might not be used any more
- * @uses $id
- * @uses $wpdb Database Object
+ * @since 2.7.0
+ * @uses $wpdb
*
- * @param int $comment_ID The ID of the comment
- * @param int $no_cache Whether to use the cache or not (casted to bool)
- * @param bool $include_unapproved Whether to include unapproved comments or not
- * @return array The comment data
+ * @param mixed $args Optional. Array or string of options to override defaults.
+ * @return array List of comments.
*/
-function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) {
- global $postc, $wpdb;
- if ( $no_cache ) {
- $query = $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d", $comment_ID);
- if ( false == $include_unapproved )
- $query .= " AND comment_approved = '1'";
- $myrow = $wpdb->get_row($query, ARRAY_A);
+function get_comments( $args = '' ) {
+ global $wpdb;
+
+ $defaults = array('status' => '', 'orderby' => 'comment_date_gmt', 'order' => 'DESC', 'number' => '', 'offset' => '', 'post_id' => 0);
+
+ $args = wp_parse_args( $args, $defaults );
+ extract( $args, EXTR_SKIP );
+
+ // $args can be whatever, only use the args defined in defaults to compute the key
+ $key = md5( serialize( compact(array_keys($defaults)) ) );
+ $last_changed = wp_cache_get('last_changed', 'comment');
+ if ( !$last_changed ) {
+ $last_changed = time();
+ wp_cache_set('last_changed', $last_changed, 'comment');
+ }
+ $cache_key = "get_comments:$key:$last_changed";
+
+ if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) {
+ return $cache;
+ }
+
+ $post_id = absint($post_id);
+
+ if ( 'hold' == $status )
+ $approved = "comment_approved = '0'";
+ elseif ( 'approve' == $status )
+ $approved = "comment_approved = '1'";
+ elseif ( 'spam' == $status )
+ $approved = "comment_approved = 'spam'";
+ else
+ $approved = "( comment_approved = '0' OR comment_approved = '1' )";
+
+ $order = ( 'ASC' == $order ) ? 'ASC' : 'DESC';
+
+ $orderby = 'comment_date_gmt'; // Hard code for now
+
+ $number = absint($number);
+ $offset = absint($offset);
+
+ if ( !empty($number) ) {
+ if ( $offset )
+ $number = 'LIMIT ' . $offset . ',' . $number;
+ else
+ $number = 'LIMIT ' . $number;
+
} else {
- $myrow['comment_ID'] = $postc->comment_ID;
- $myrow['comment_post_ID'] = $postc->comment_post_ID;
- $myrow['comment_author'] = $postc->comment_author;
- $myrow['comment_author_email'] = $postc->comment_author_email;
- $myrow['comment_author_url'] = $postc->comment_author_url;
- $myrow['comment_author_IP'] = $postc->comment_author_IP;
- $myrow['comment_date'] = $postc->comment_date;
- $myrow['comment_content'] = $postc->comment_content;
- $myrow['comment_karma'] = $postc->comment_karma;
- $myrow['comment_approved'] = $postc->comment_approved;
- $myrow['comment_type'] = $postc->comment_type;
+ $number = '';
}
- return $myrow;
+
+ if ( ! empty($post_id) )
+ $post_where = $wpdb->prepare( 'comment_post_ID = %d AND', $post_id );
+ else
+ $post_where = '';
+
+ $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE $post_where $approved ORDER BY $orderby $order $number" );
+ wp_cache_add( $cache_key, $comments, 'comment' );
+
+ return $comments;
}
/**
- * The date the last comment was modified.
+ * Retrieve all of the WordPress supported comment statuses.
*
- * {@internal Missing Long Description}}
+ * Comments have a limited set of valid status values, this provides the comment
+ * status values and descriptions.
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 2.7.0
+ *
+ * @return array List of comment statuses.
+ */
+function get_comment_statuses( ) {
+ $status = array(
+ 'hold' => __('Unapproved'),
+ 'approve' => __('Approved'),
+ 'spam' => _c('Spam|adjective'),
+ );
+
+ return $status;
+}
+
+
+/**
+ * The date the last comment was modified.
*
* @since 1.5.0
* @uses $wpdb
* @global array $cache_lastcommentmodified
*
* @param string $timezone Which timezone to use in reference to 'gmt', 'blog',
- * or 'server' locations
- * @return string Last comment modified date
+ * or 'server' locations.
+ * @return string Last comment modified date.
*/
function get_lastcommentmodified($timezone = 'server') {
global $cache_lastcommentmodified, $wpdb;
/**
* The amount of comments in a post or total comments.
*
- * {@internal Missing Long Description}}
+ * A lot like {@link wp_count_comments()}, in that they both return comment
+ * stats (albeit with different types). The {@link wp_count_comments()} actual
+ * caches, but this function does not.
*
* @since 2.0.0
* @uses $wpdb
*
- * @param int $post_id Optional. Comment amount in post if > 0, else total comments blog wide
- * @return array The amount of spam, approved, awaiting moderation, and total
+ * @param int $post_id Optional. Comment amount in post if > 0, else total comments blog wide.
+ * @return array The amount of spam, approved, awaiting moderation, and total comments.
*/
function get_comment_count( $post_id = 0 ) {
global $wpdb;
/**
* Validates whether this comment is allowed to be made or not.
*
- * {@internal Missing Long Description}}
- *
* @since 2.0.0
* @uses $wpdb
* @uses apply_filters() Calls 'pre_comment_approved' hook on the type of comment
if ( $comment_author_email )
$dupe .= "OR comment_author_email = '$comment_author_email' ";
$dupe .= ") AND comment_content = '$comment_content' LIMIT 1";
- if ( $wpdb->get_var($dupe) )
+ if ( $wpdb->get_var($dupe) ) {
+ if ( defined('DOING_AJAX') )
+ die( __('Duplicate comment detected; it looks as though you\'ve already said that!') );
+
wp_die( __('Duplicate comment detected; it looks as though you\'ve already said that!') );
+ }
do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt );
$post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", $comment_post_ID));
}
- if ( $userdata && ( $user_id == $post_author || $user->has_cap('moderate_comments') ) ) {
+ if ( isset($userdata) && ( $user_id == $post_author || $user->has_cap('moderate_comments') ) ) {
// The author and the admins get respect.
$approved = 1;
} else {
}
/**
- * {@internal Missing Short Description}}
+ * Check whether comment flooding is occurring.
*
- * {@internal Missing Long Description}}
+ * Won't run, if current user can manage options, so to not block
+ * administrators.
*
* @since 2.3.0
* @uses $wpdb
- * @uses apply_filters() {@internal Missing Description}}
- * @uses do_action() {@internal Missing Description}}
- *
- * @param string $ip {@internal Missing Description}}
- * @param string $email {@internal Missing Description}}
- * @param unknown_type $date {@internal Missing Description}}
+ * @uses apply_filters() Calls 'comment_flood_filter' filter with first
+ * parameter false, last comment timestamp, new comment timestamp.
+ * @uses do_action() Calls 'comment_flood_trigger' action with parameters with
+ * last comment timestamp and new comment timestamp.
+ *
+ * @param string $ip Comment IP.
+ * @param string $email Comment author email address.
+ * @param string $date MySQL time string.
*/
function check_comment_flood_db( $ip, $email, $date ) {
global $wpdb;
$flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
if ( $flood_die ) {
do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
- wp_die( __('You are posting comments too quickly. Slow down.') );
+
+ if ( defined('DOING_AJAX') )
+ die( __('You are posting comments too quickly. Slow down.') );
+
+ wp_die( __('You are posting comments too quickly. Slow down.'), '', array('response' => 403) );
}
}
}
/**
- * Does comment contain blacklisted characters or words.
+ * Separates an array of comments into an array keyed by comment_type.
+ *
+ * @since 2.7.0
+ *
+ * @param array $comments Array of comments
+ * @return array Array of comments keyed by comment_type.
+ */
+function &separate_comments(&$comments) {
+ $comments_by_type = array('comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array());
+ $count = count($comments);
+ for ( $i = 0; $i < $count; $i++ ) {
+ $type = $comments[$i]->comment_type;
+ if ( empty($type) )
+ $type = 'comment';
+ $comments_by_type[$type][] = &$comments[$i];
+ if ( 'trackback' == $type || 'pingback' == $type )
+ $comments_by_type['pings'][] = &$comments[$i];
+ }
+
+ return $comments_by_type;
+}
+
+/**
+ * Calculate the total number of comment pages.
*
- * {@internal Missing Long Description}}
+ * @since 2.7.0
+ * @uses get_query_var() Used to fill in the default for $per_page parameter.
+ * @uses get_option() Used to fill in defaults for parameters.
+ * @uses Walker_Comment
+ *
+ * @param array $comments Optional array of comment objects. Defaults to $wp_query->comments
+ * @param int $per_page Optional comments per page.
+ * @param boolean $threaded Optional control over flat or threaded comments.
+ * @return int Number of comment pages.
+ */
+function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {
+ global $wp_query;
+
+ if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) )
+ return $wp_query->max_num_comment_pages;
+
+ if ( !$comments || !is_array($comments) )
+ $comments = $wp_query->comments;
+
+ if ( empty($comments) )
+ return 0;
+
+ if ( !isset($per_page) )
+ $per_page = (int) get_query_var('comments_per_page');
+ if ( 0 === $per_page )
+ $per_page = (int) get_option('comments_per_page');
+ if ( 0 === $per_page )
+ return 1;
+
+ if ( !isset($threaded) )
+ $threaded = get_option('thread_comments');
+
+ if ( $threaded ) {
+ $walker = new Walker_Comment;
+ $count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page );
+ } else {
+ $count = ceil( count( $comments ) / $per_page );
+ }
+
+ return $count;
+}
+
+/**
+ * Calculate what page number a comment will appear on for comment paging.
+ *
+ * @since 2.7.0
+ * @uses get_comment() Gets the full comment of the $comment_ID parameter.
+ * @uses get_option() Get various settings to control function and defaults.
+ * @uses get_page_of_comment() Used to loop up to top level comment.
+ *
+ * @param int $comment_ID Comment ID.
+ * @param array $args Optional args.
+ * @return int|null Comment page number or null on error.
+ */
+function get_page_of_comment( $comment_ID, $args = array() ) {
+ global $wpdb;
+
+ if ( !$comment = get_comment( $comment_ID ) )
+ return;
+
+ $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_query_var('comments_per_page');
+ if ( empty($args['per_page']) ) {
+ $args['per_page'] = 0;
+ $args['page'] = 0;
+ }
+ if ( $args['per_page'] < 1 )
+ return 1;
+
+ if ( '' === $args['max_depth'] ) {
+ if ( get_option('thread_comments') )
+ $args['max_depth'] = get_option('thread_comments_depth');
+ else
+ $args['max_depth'] = -1;
+ }
+
+ // Find this comment's top level parent if threading is enabled
+ if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent )
+ return get_page_of_comment( $comment->comment_parent, $args );
+
+ $allowedtypes = array(
+ 'comment' => '',
+ 'pingback' => 'pingback',
+ 'trackback' => 'trackback',
+ );
+
+ $comtypewhere = ( 'all' != $args['type'] && isset($allowedtypes[$args['type']]) ) ? " AND comment_type = '" . $allowedtypes[$args['type']] . "'" : '';
+
+ // Count comments older than this one
+ $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) );
+
+ // No older comments? Then it's page #1.
+ if ( 0 == $oldercoms )
+ return 1;
+
+ // Divide comments older than this one by comments per page to get this comment's page number
+ return ceil( ( $oldercoms + 1 ) / $args['per_page'] );
+}
+
+/**
+ * Does comment contain blacklisted characters or words.
*
* @since 1.5.0
- * @uses do_action() Calls 'wp_blacklist_check' hook for all parameters
+ * @uses do_action() Calls 'wp_blacklist_check' hook for all parameters.
*
* @param string $author The author of the comment
* @param string $email The email of the comment
}
/**
- * {@internal Missing Short Description}}
+ * Retrieve total comments for blog or single post.
*
- * {@internal Missing Long Description}}
+ * The properties of the returned object contain the 'moderated', 'approved',
+ * and spam comments for either the entire blog or single post. Those properties
+ * contain the amount of comments that match the status. The 'total_comments'
+ * property contains the integer of total comments.
*
- * @param unknown_type $post_id
- * @return unknown
+ * The comment stats are cached and then retrieved, if they already exist in the
+ * cache.
+ *
+ * @since 2.5.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @return object Comment stats.
*/
function wp_count_comments( $post_id = 0 ) {
global $wpdb;
$post_id = (int) $post_id;
+ $stats = apply_filters('wp_count_comments', array(), $post_id);
+ if ( !empty($stats) )
+ return $stats;
+
$count = wp_cache_get("comments-{$post_id}", 'counts');
if ( false !== $count )
$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
$total = 0;
- $stats = array( );
$approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam');
+ $known_types = array_keys( $approved );
foreach( (array) $count as $row_num => $row ) {
$total += $row['num_comments'];
- $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
+ if ( in_array( $row['comment_approved'], $known_types ) )
+ $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
}
$stats['total_comments'] = $total;
* @uses $wpdb
* @uses do_action() Calls 'delete_comment' hook on comment ID
* @uses do_action() Calls 'wp_set_comment_status' hook on comment ID with 'delete' set for the second parameter
+ * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
*
* @param int $comment_id Comment ID
- * @return bool False if delete comment query failure, true on success
+ * @return bool False if delete comment query failure, true on success.
*/
function wp_delete_comment($comment_id) {
global $wpdb;
clean_comment_cache($comment_id);
do_action('wp_set_comment_status', $comment_id, 'delete');
+ wp_transition_comment_status('delete', $comment->comment_approved, $comment);
return true;
}
* @since 1.0.0
*
* @param int $comment_id Comment ID
- * @return string|bool Status might be 'deleted', 'approved', 'unapproved', 'spam'. False on failure
+ * @return string|bool Status might be 'deleted', 'approved', 'unapproved', 'spam'. False on failure.
*/
function wp_get_comment_status($comment_id) {
$comment = get_comment($comment_id);
return false;
}
+/**
+ * Call hooks for when a comment status transition occurs.
+ *
+ * Calls hooks for comment status transitions. If the new comment status is not the same
+ * as the previous comment status, then two hooks will be ran, the first is
+ * 'transition_comment_status' with new status, old status, and comment data. The
+ * next action called is 'comment_OLDSTATUS_to_NEWSTATUS' the NEWSTATUS is the
+ * $new_status parameter and the OLDSTATUS is $old_status parameter; it has the
+ * comment data.
+ *
+ * The final action will run whether or not the comment statuses are the same. The
+ * action is named 'comment_NEWSTATUS_COMMENTTYPE', NEWSTATUS is from the $new_status
+ * parameter and COMMENTTYPE is comment_type comment data.
+ *
+ * @since 2.7.0
+ *
+ * @param string $new_status New comment status.
+ * @param string $old_status Previous comment status.
+ * @param object $comment Comment data.
+ */
+function wp_transition_comment_status($new_status, $old_status, $comment) {
+ // Translate raw statuses to human readable formats for the hooks
+ // This is not a complete list of comment status, it's only the ones that need to be renamed
+ $comment_statuses = array(
+ 0 => 'unapproved',
+ 'hold' => 'unapproved', // wp_set_comment_status() uses "hold"
+ 1 => 'approved',
+ 'approve' => 'approved', // wp_set_comment_status() uses "approve"
+ );
+ if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status];
+ if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status];
+
+ // Call the hooks
+ if ( $new_status != $old_status ) {
+ do_action('transition_comment_status', $new_status, $old_status, $comment);
+ do_action("comment_${old_status}_to_$new_status", $comment);
+ }
+ do_action("comment_${new_status}_$comment->comment_type", $comment->comment_ID, $comment);
+}
+
/**
* Get current commenter's name, email, and URL.
*
- * Expects cookies content to already be sanitized. User of this function
- * might wish to recheck the returned array for validity.
+ * Expects cookies content to already be sanitized. User of this function might
+ * wish to recheck the returned array for validity.
*
* @see sanitize_comment_cookies() Use to sanitize cookies
*
* @since 2.0.4
*
- * @return array Comment author, email, url respectively
+ * @return array Comment author, email, url respectively.
*/
function wp_get_current_commenter() {
// Cookies should already be sanitized.
/**
* Inserts a comment to the database.
*
- * {@internal Missing Long Description}}
+ * The available comment data key names are 'comment_author_IP', 'comment_date',
+ * 'comment_date_gmt', 'comment_parent', 'comment_approved', and 'user_id'.
*
* @since 2.0.0
* @uses $wpdb
*
- * @param array $commentdata Contains information on the comment
- * @return int The new comment's id
+ * @param array $commentdata Contains information on the comment.
+ * @return int The new comment's ID.
*/
function wp_insert_comment($commentdata) {
global $wpdb;
$comment_approved = 1;
if ( ! isset($user_id) )
$user_id = 0;
+ if ( ! isset($comment_type) )
+ $comment_type = '';
$result = $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->comments
(comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id)
}
/**
- * Parses and returns comment information.
+ * Filters and sanitizes comment data.
*
* Sets the comment data 'filtered' field to true when finished. This can be
* checked as to whether the comment should be filtered and to keep from
* @uses apply_filters() Calls 'pre_comment_author_url' hook on comment author's URL
* @uses apply_filters() Calls 'pre_comment_author_email' hook on comment author's email address
*
- * @param array $commentdata Contains information on the comment
- * @return array Parsed comment information
+ * @param array $commentdata Contains information on the comment.
+ * @return array Parsed comment information.
*/
function wp_filter_comment($commentdata) {
$commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']);
}
/**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
+ * Whether comment should be blocked because of comment flood.
*
* @since 2.1.0
*
- * @param unknown_type $block {@internal Missing Description}}
- * @param unknown_type $time_lastcomment {@internal Missing Description}}
- * @param unknown_type $time_newcomment {@internal Missing Description}}
- * @return unknown {@internal Missing Description}}
+ * @param bool $block Whether plugin has already blocked comment.
+ * @param int $time_lastcomment Timestamp for last comment.
+ * @param int $time_newcomment Timestamp for new comment.
+ * @return bool Whether comment should be blocked.
*/
function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) {
if ( $block ) // a plugin has already blocked... we'll let that decision stand
}
/**
- * Parses and adds a new comment to the database.
+ * Adds a new comment to the database.
*
- * {@internal Missing Long Description}}
+ * Filters new comment to ensure that the fields are sanitized and valid before
+ * inserting comment into database. Calls 'comment_post' action with comment ID
+ * and whether comment is approved by WordPress. Also has 'preprocess_comment'
+ * filter for processing the comment data before the function handles it.
*
* @since 1.5.0
* @uses apply_filters() Calls 'preprocess_comment' hook on $commentdata parameter array before processing
* @uses do_action() Calls 'comment_post' hook on $comment_ID returned from adding the comment and if the comment was approved.
- * @uses wp_filter_comment() Used to filter comment before adding comment
+ * @uses wp_filter_comment() Used to filter comment before adding comment.
* @uses wp_allow_comment() checks to see if comment is approved.
- * @uses wp_insert_comment() Does the actual comment insertion to the database
+ * @uses wp_insert_comment() Does the actual comment insertion to the database.
*
- * @param array $commentdata Contains information on the comment
+ * @param array $commentdata Contains information on the comment.
* @return int The ID of the comment after adding.
*/
function wp_new_comment( $commentdata ) {
$commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
$commentdata['user_ID'] = (int) $commentdata['user_ID'];
+ $commentdata['comment_parent'] = absint($commentdata['comment_parent']);
+ $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
+ $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
+
$commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] );
$commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'];
}
/**
- * Sets the status of comment ID.
+ * Sets the status of a comment.
*
- * {@internal Missing Long Description}}
+ * The 'wp_set_comment_status' action is called after the comment is handled and
+ * will only be called, if the comment status is either 'hold', 'approve', or
+ * 'spam'. If the comment status is not in the list, then false is returned and
+ * if the status is 'delete', then the comment is deleted without calling the
+ * action.
*
* @since 1.0.0
+ * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
*
- * @param int $comment_id Comment ID
- * @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'delete'
+ * @param int $comment_id Comment ID.
+ * @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'delete'.
* @return bool False on failure or deletion and true on success.
*/
function wp_set_comment_status($comment_id, $comment_status) {
clean_comment_cache($comment_id);
- do_action('wp_set_comment_status', $comment_id, $comment_status);
$comment = get_comment($comment_id);
+
+ do_action('wp_set_comment_status', $comment_id, $comment_status);
+ wp_transition_comment_status($comment_status, $comment->comment_approved, $comment);
+
wp_update_comment_count($comment->comment_post_ID);
return true;
}
/**
- * Parses and updates an existing comment in the database.
+ * Updates an existing comment in the database.
*
- * {@internal Missing Long Description}}
+ * Filters the comment and makes sure certain fields are valid before updating.
*
* @since 2.0.0
* @uses $wpdb
+ * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
*
- * @param array $commentarr Contains information on the comment
+ * @param array $commentarr Contains information on the comment.
* @return int Comment was updated if value is 1, or was not updated if value is 0.
*/
function wp_update_comment($commentarr) {
$comment_date_gmt = get_gmt_from_date($comment_date);
+ if ( !isset($comment_approved) )
+ $comment_approved = 1;
+ else if ( 'hold' == $comment_approved )
+ $comment_approved = 0;
+ else if ( 'approve' == $comment_approved )
+ $comment_approved = 1;
+
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->comments SET
comment_content = %s,
comment_author = %s,
clean_comment_cache($comment_ID);
wp_update_comment_count($comment_post_ID);
do_action('edit_comment', $comment_ID);
+ $comment = get_comment($comment_ID);
+ wp_transition_comment_status($comment_approved, $comment->comment_approved, $comment);
return $rval;
}
* previously deferred updated post comment counts will then be automatically
* updated without having to call wp_update_comment_count() after.
*
- * @since 2.5
+ * @since 2.5.0
* @staticvar bool $_defer
*
* @param bool $defer
/**
* Updates the comment count for the post.
*
- * @since 2.5
+ * @since 2.5.0
* @uses $wpdb
* @uses do_action() Calls 'wp_update_comment_count' hook on $post_id, $new, and $old
* @uses do_action() Calls 'edit_posts' hook on $post_id and $post
/**
* Finds a pingback server URI based on the given URL.
*
- * {@internal Missing Long Description}}
+ * Checks the HTML for the rel="pingback" link and x-pingback headers. It does
+ * a check for the x-pingback headers first and returns that, if available. The
+ * check for the rel="pingback" has more overhead than just the header.
*
* @since 1.5.0
- * @uses $wp_version
*
- * @param string $url URL to ping
- * @param int $timeout_bytes Number of bytes to timeout at. Prevents big file downloads, default is 2048.
+ * @param string $url URL to ping.
+ * @param int $deprecated Not Used.
* @return bool|string False on failure, string containing URI on success.
*/
-function discover_pingback_server_uri($url, $timeout_bytes = 2048) {
- global $wp_version;
+function discover_pingback_server_uri($url, $deprecated = 2048) {
- $byte_count = 0;
- $contents = '';
- $headers = '';
$pingback_str_dquote = 'rel="pingback"';
$pingback_str_squote = 'rel=\'pingback\'';
- $x_pingback_str = 'x-pingback: ';
- extract(parse_url($url), EXTR_SKIP);
+ /** @todo Should use Filter Extension or custom preg_match instead. */
+ $parsed_url = parse_url($url);
- if ( !isset($host) ) // Not an URL. This should never happen.
+ if ( ! isset( $parsed_url['host'] ) ) // Not an URL. This should never happen.
return false;
- $path = ( !isset($path) ) ? '/' : $path;
- $path .= ( isset($query) ) ? '?' . $query : '';
- $port = ( isset($port) ) ? $port : 80;
+ $response = wp_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.1' ) );
- // Try to connect to the server at $host
- $fp = @fsockopen($host, $port, $errno, $errstr, 2);
- if ( !$fp ) // Couldn't open a connection to $host
+ if ( is_wp_error( $response ) )
return false;
- // Send the GET request
- $request = "GET $path HTTP/1.1\r\nHost: $host\r\nUser-Agent: WordPress/$wp_version \r\n\r\n";
- // ob_end_flush();
- fputs($fp, $request);
-
- // Let's check for an X-Pingback header first
- while ( !feof($fp) ) {
- $line = fgets($fp, 512);
- if ( trim($line) == '' )
- break;
- $headers .= trim($line)."\n";
- $x_pingback_header_offset = strpos(strtolower($headers), $x_pingback_str);
- if ( $x_pingback_header_offset ) {
- // We got it!
- preg_match('#x-pingback: (.+)#is', $headers, $matches);
- $pingback_server_url = trim($matches[1]);
- return $pingback_server_url;
- }
- if ( strpos(strtolower($headers), 'content-type: ') ) {
- preg_match('#content-type: (.+)#is', $headers, $matches);
- $content_type = trim($matches[1]);
- }
- }
+ if ( isset( $response['headers']['x-pingback'] ) )
+ return $response['headers']['x-pingback'];
- 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.
+ if ( isset( $response['headers']['content-type'] ) && preg_match('#(image|audio|video|model)/#is', $response['headers']['content-type']) )
return false;
- while ( !feof($fp) ) {
- $line = fgets($fp, 1024);
- $contents .= trim($line);
- $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
- $pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
- if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) {
- $quote = ($pingback_link_offset_dquote) ? '"' : '\'';
- $pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
- $pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset);
- $pingback_href_start = $pingback_href_pos+6;
- $pingback_href_end = @strpos($contents, $quote, $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);
- // We may find rel="pingback" but an incomplete pingback URL
- if ( $pingback_server_url_len > 0 ) { // We got it!
- fclose($fp);
- return $pingback_server_url;
- }
- }
- $byte_count += strlen($line);
- if ( $byte_count > $timeout_bytes ) {
- // It's no use going further, there probably isn't any pingback
- // server to find in this file. (Prevents loading large files.)
- fclose($fp);
- return false;
+ $contents = $response['body'];
+
+ $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
+ $pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
+ if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) {
+ $quote = ($pingback_link_offset_dquote) ? '"' : '\'';
+ $pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
+ $pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset);
+ $pingback_href_start = $pingback_href_pos+6;
+ $pingback_href_end = @strpos($contents, $quote, $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);
+
+ // We may find rel="pingback" but an incomplete pingback URL
+ if ( $pingback_server_url_len > 0 ) { // We got it!
+ return $pingback_server_url;
}
}
- // We didn't find anything.
- fclose($fp);
return false;
}
/**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
+ * Perform all pingbacks, enclosures, trackbacks, and send to pingback services.
*
* @since 2.1.0
* @uses $wpdb
}
/**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
+ * Perform trackbacks.
*
* @since 1.5.0
* @uses $wpdb
*
- * @param int $post_id Post ID to do trackbacks on
+ * @param int $post_id Post ID to do trackbacks on.
*/
function do_trackbacks($post_id) {
global $wpdb;
}
/**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
+ * Sends pings to all of the ping site services.
*
* @since 1.2.0
*
/**
* Pings back the links found in a post.
*
- * {@internal Missing Long Description}}
- *
* @since 0.71
* @uses $wp_version
* @uses IXR_Client
*
- * @param string $content {@internal Missing Description}}
- * @param int $post_ID {@internal Missing Description}}
+ * @param string $content Post content to check for links.
+ * @param int $post_ID Post ID.
*/
function pingback($content, $post_ID) {
global $wp_version;
// http://dummy-weblog.org/post.php
// We don't wanna ping first and second types, even if they have a valid <link/>
- foreach ( $post_links_temp[0] as $link_test ) :
+ foreach ( (array) $post_links_temp[0] as $link_test ) :
if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
&& !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
- $test = parse_url($link_test);
- if ( isset($test['query']) )
- $post_links[] = $link_test;
- elseif ( ($test['path'] != '/') && ($test['path'] != '') )
- $post_links[] = $link_test;
+ if ( $test = @parse_url($link_test) ) {
+ if ( isset($test['query']) )
+ $post_links[] = $link_test;
+ elseif ( ($test['path'] != '/') && ($test['path'] != '') )
+ $post_links[] = $link_test;
+ }
endif;
endforeach;
}
/**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
+ * Check whether blog is public before returning sites.
*
* @since 2.1.0
*
- * @param unknown_type $sites {@internal Missing Description}}
- * @return unknown {@internal Missing Description}}
+ * @param mixed $sites Will return if blog is public, will not return if not public.
+ * @return mixed Empty string if blog is not public, returns $sites, if site is public.
*/
function privacy_ping_filter($sites) {
if ( '0' != get_option('blog_public') )
*
* @since 0.71
* @uses $wpdb
- * @uses $wp_version WordPress version
*
* @param string $trackback_url URL to send trackbacks.
- * @param string $title Title of post
- * @param string $excerpt Excerpt of post
- * @param int $ID Post ID
- * @return mixed Database query from update
+ * @param string $title Title of post.
+ * @param string $excerpt Excerpt of post.
+ * @param int $ID Post ID.
+ * @return mixed Database query from update.
*/
function trackback($trackback_url, $title, $excerpt, $ID) {
- global $wpdb, $wp_version;
+ global $wpdb;
if ( empty($trackback_url) )
return;
- $title = urlencode($title);
- $excerpt = urlencode($excerpt);
- $blog_name = urlencode(get_option('blogname'));
- $tb_url = $trackback_url;
- $url = urlencode(get_permalink($ID));
- $query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
- $trackback_url = parse_url($trackback_url);
- $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'.$trackback_url['query'] : '') . " HTTP/1.0\r\n";
- $http_request .= 'Host: '.$trackback_url['host']."\r\n";
- $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_option('blog_charset')."\r\n";
- $http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
- $http_request .= "User-Agent: WordPress/" . $wp_version;
- $http_request .= "\r\n\r\n";
- $http_request .= $query_string;
- if ( '' == $trackback_url['port'] )
- $trackback_url['port'] = 80;
- $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
- @fputs($fs, $http_request);
- @fclose($fs);
-
- $tb_url = addslashes( $tb_url );
+ $options = array();
+ $options['timeout'] = 4;
+ $options['body'] = array(
+ 'title' => $title,
+ 'url' => get_permalink($ID),
+ 'blog_name' => get_option('blogname'),
+ 'excerpt' => $excerpt
+ );
+
+ $response = wp_remote_post($trackback_url, $options);
+
+ if ( is_wp_error( $response ) )
+ return;
+
+ $tb_url = addslashes( $trackback_url );
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = %d", $ID) );
return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_url', '')) WHERE ID = %d", $ID) );
}
/**
* Updates the comment cache of given comments.
*
- * Will add the comments in $comments to the cache. If comment ID already
- * exists in the comment cache then it will not be updated.
- *
- * The comment is added to the cache using the comment group with the key
- * using the ID of the comments.
+ * Will add the comments in $comments to the cache. If comment ID already exists
+ * in the comment cache then it will not be updated. The comment is added to the
+ * cache using the comment group with the key using the ID of the comments.
*
* @since 2.3.0
+ * @package WordPress
+ * @subpackage Cache
*
* @param array $comments Array of comment row objects
*/
wp_cache_add($comment->comment_ID, $comment, 'comment');
}
+//
+// Internal
+//
+
+/**
+ * Close comments on old posts on the fly, without any extra DB queries. Hooked to the_posts.
+ *
+ * @access private
+ * @since 2.7.0
+ *
+ * @param object $posts Post data object.
+ * @return object
+ */
+function _close_comments_for_old_posts( $posts ) {
+ if ( empty($posts) || !is_singular() || !get_option('close_comments_for_old_posts') )
+ return $posts;
+
+ $days_old = (int) get_option('close_comments_days_old');
+ if ( !$days_old )
+ return $posts;
+
+ if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) {
+ $posts[0]->comment_status = 'closed';
+ $posts[0]->ping_status = 'closed';
+ }
+
+ return $posts;
+}
+
+/**
+ * Close comments on an old post. Hooked to comments_open and pings_open.
+ *
+ * @access private
+ * @since 2.7.0
+ *
+ * @param bool $open Comments open or closed
+ * @param int $post_id Post ID
+ * @return bool $open
+ */
+function _close_comments_for_old_post( $open, $post_id ) {
+ if ( ! $open )
+ return $open;
+
+ if ( !get_option('close_comments_for_old_posts') )
+ return $open;
+
+ $days_old = (int) get_option('close_comments_days_old');
+ if ( !$days_old )
+ return $open;
+
+ $post = get_post($post_id);
+
+ if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) )
+ return false;
+
+ return $open;
+}
+
?>
return implode( '', $chars );
}
+if ( !function_exists( 'htmlspecialchars_decode' ) ) {
+ // Added in PHP 5.1.0
+ // Error checks from PEAR::PHP_Compat
+ function htmlspecialchars_decode( $str, $quote_style = ENT_COMPAT )
+ {
+ if ( !is_scalar( $string ) ) {
+ trigger_error( 'htmlspecialchars_decode() expects parameter 1 to be string, ' . gettype( $string ) . ' given', E_USER_WARNING );
+ return;
+ }
+
+ if ( !is_int( $quote_style ) && $quote_style !== null ) {
+ trigger_error( 'htmlspecialchars_decode() expects parameter 2 to be integer, ' . gettype( $quote_style ) . ' given', E_USER_WARNING );
+ return;
+ }
+
+ return wp_specialchars_decode( $str, $quote_style );
+ }
+}
+
?>
<?php
-
+/**
+ * WordPress CRON API
+ *
+ * @package WordPress
+ */
+
+/**
+ * Schedules a hook to run only once.
+ *
+ * Schedules a hook which will be executed once by the Wordpress actions core at
+ * a time which you specify. The action will fire off when someone visits your
+ * WordPress site, if the schedule time has passed.
+ *
+ * @since 2.1.0
+ * @link http://codex.wordpress.org/Function_Reference/wp_schedule_single_event
+ *
+ * @param int $timestamp Timestamp for when to run the event.
+ * @param string $hook Action hook to execute when cron is run.
+ * @param array $args Optional. Arguments to pass to the hook's callback function.
+ */
function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
+ // don't schedule a duplicate if there's already an identical event due in the next 10 minutes
+ $next = wp_next_scheduled($hook, $args);
+ if ( $next && $next <= $timestamp + 600 )
+ return;
+
$crons = _get_cron_array();
$key = md5(serialize($args));
$crons[$timestamp][$hook][$key] = array( 'schedule' => false, 'args' => $args );
_set_cron_array( $crons );
}
+/**
+ * Schedule a periodic event.
+ *
+ * Schedules a hook which will be executed by the WordPress actions core on a
+ * specific interval, specified by you. The action will trigger when someone
+ * visits your WordPress site, if the scheduled time has passed.
+ *
+ * @since 2.1.0
+ *
+ * @param int $timestamp Timestamp for when to run the event.
+ * @param string $recurrence How often the event should recur.
+ * @param string $hook Action hook to execute when cron is run.
+ * @param array $args Optional. Arguments to pass to the hook's callback function.
+ * @return bool|null False on failure, null when complete with scheduling event.
+ */
function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
$crons = _get_cron_array();
$schedules = wp_get_schedules();
_set_cron_array( $crons );
}
+/**
+ * Reschedule a recurring event.
+ *
+ * @since 2.1.0
+ *
+ * @param int $timestamp Timestamp for when to run the event.
+ * @param string $recurrence How often the event should recur.
+ * @param string $hook Action hook to execute when cron is run.
+ * @param array $args Optional. Arguments to pass to the hook's callback function.
+ * @return bool|null False on failure. Null when event is rescheduled.
+ */
function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) {
$crons = _get_cron_array();
$schedules = wp_get_schedules();
wp_schedule_event( $timestamp, $recurrence, $hook, $args );
}
+/**
+ * Unschedule a previously scheduled cron job.
+ *
+ * The $timestamp and $hook parameters are required, so that the event can be
+ * identified.
+ *
+ * @since 2.1.0
+ *
+ * @param int $timestamp Timestamp for when to run the event.
+ * @param string $hook Action hook, the execution of which will be unscheduled.
+ * @param array $args Arguments to pass to the hook's callback function.
+ * Although not passed to a callback function, these arguments are used
+ * to uniquely identify the scheduled event, so they should be the same
+ * as those used when originally scheduling the event.
+ */
function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
$crons = _get_cron_array();
$key = md5(serialize($args));
_set_cron_array( $crons );
}
+/**
+ * Unschedule all cron jobs attached to a specific hook.
+ *
+ * @since 2.1.0
+ *
+ * @param string $hook Action hook, the execution of which will be unscheduled.
+ * @param mixed $args,... Optional. Event arguments.
+ */
function wp_clear_scheduled_hook( $hook ) {
$args = array_slice( func_get_args(), 1 );
wp_unschedule_event( $timestamp, $hook, $args );
}
+/**
+ * Retrieve the next timestamp for a cron event.
+ *
+ * @since 2.1.0
+ *
+ * @param string $hook Action hook to execute when cron is run.
+ * @param array $args Optional. Arguments to pass to the hook's callback function.
+ * @return bool|int The UNIX timestamp of the next time the scheduled event will occur.
+ */
function wp_next_scheduled( $hook, $args = array() ) {
$crons = _get_cron_array();
$key = md5(serialize($args));
return false;
}
-function spawn_cron() {
- $crons = _get_cron_array();
+/**
+ * Send request to run cron through HTTP request that doesn't halt page loading.
+ *
+ * @since 2.1.0
+ *
+ * @return null Cron could not be spawned, because it is not needed to run.
+ */
+function spawn_cron( $local_time ) {
+
+ /*
+ * do not even start the cron if local server timer has drifted
+ * such as due to power failure, or misconfiguration
+ */
+ $timer_accurate = check_server_timer( $local_time );
+ if ( !$timer_accurate )
+ return;
+ //sanity check
+ $crons = _get_cron_array();
if ( !is_array($crons) )
return;
$keys = array_keys( $crons );
- if ( array_shift( $keys ) > time() )
+ $timestamp = $keys[0];
+ if ( $timestamp > $local_time )
return;
- $cron_url = get_option( 'siteurl' ) . '/wp-cron.php';
- $parts = parse_url( $cron_url );
-
- if ($parts['scheme'] == 'https') {
- // support for SSL was added in 4.3.0
- if (version_compare(phpversion(), '4.3.0', '>=') && function_exists('openssl_open')) {
- $port = isset($parts['port']) ? $parts['port'] : 443;
- $argyle = @fsockopen('ssl://' . $parts['host'], $port, $errno, $errstr, 0.01);
- } else {
- return false;
+ $cron_url = get_option( 'siteurl' ) . '/wp-cron.php?check=' . wp_hash('187425');
+ /*
+ * multiple processes on multiple web servers can run this code concurrently
+ * try to make this as atomic as possible by setting doing_cron switch
+ */
+ $flag = get_option('doing_cron');
+
+ // clean up potential invalid value resulted from various system chaos
+ if ( $flag != 0 ) {
+ if ( $flag > $local_time + 10*60 || $flag < $local_time - 10*60 ) {
+ update_option('doing_cron', 0);
+ $flag = 0;
}
- } else {
- $port = isset($parts['port']) ? $parts['port'] : 80;
- $argyle = @ fsockopen( $parts['host'], $port, $errno, $errstr, 0.01 );
}
- if ( $argyle )
- fputs( $argyle,
- "GET {$parts['path']}?check=" . wp_hash('187425') . " HTTP/1.0\r\n"
- . "Host: {$_SERVER['HTTP_HOST']}\r\n\r\n"
- );
+ //don't run if another process is currently running it
+ if ( $flag > $local_time )
+ return;
+
+ update_option( 'doing_cron', $local_time + 30 );
+
+ wp_remote_post($cron_url, array('timeout' => 0.01, 'blocking' => false));
}
+/**
+ * Run scheduled callbacks or spawn cron for all scheduled events.
+ *
+ * @since 2.1.0
+ *
+ * @return null When doesn't need to run Cron.
+ */
function wp_cron() {
+
// Prevent infinite loops caused by lack of wp-cron.php
if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false )
return;
if ( isset($keys[0]) && $keys[0] > time() )
return;
+ $local_time = time();
$schedules = wp_get_schedules();
foreach ( $crons as $timestamp => $cronhooks ) {
- if ( $timestamp > time() ) break;
- foreach ( $cronhooks as $hook => $args ) {
+ if ( $timestamp > $local_time ) break;
+ foreach ( (array) $cronhooks as $hook => $args ) {
if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
continue;
- spawn_cron();
+ spawn_cron( $local_time );
break 2;
}
}
}
+/**
+ * Retrieve supported and filtered Cron recurrences.
+ *
+ * The supported recurrences are 'hourly' and 'daily'. A plugin may add more by
+ * hooking into the 'cron_schedules' filter. The filter accepts an array of
+ * arrays. The outer array has a key that is the name of the schedule or for
+ * example 'weekly'. The value is an array with two keys, one is 'interval' and
+ * the other is 'display'.
+ *
+ * The 'interval' is a number in seconds of when the cron job should run. So for
+ * 'hourly', the time is 3600 or 60*60. For weekly, the value would be
+ * 60*60*24*7 or 604800. The value of 'interval' would then be 604800.
+ *
+ * The 'display' is the description. For the 'weekly' key, the 'display' would
+ * be <code>__('Once Weekly')</code>.
+ *
+ * For your plugin, you will be passed an array. you can easily add your
+ * schedule by doing the following.
+ * <code>
+ * // filter parameter variable name is 'array'
+ * $array['weekly'] = array(
+ * 'interval' => 604800,
+ * 'display' => __('Once Weekly')
+ * );
+ * </code>
+ *
+ * @since 2.1.0
+ *
+ * @return array
+ */
function wp_get_schedules() {
$schedules = array(
'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ),
return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
}
+/**
+ * Retrieve Cron schedule for hook with arguments.
+ *
+ * @since 2.1.0
+ *
+ * @param string $hook Action hook to execute when cron is run.
+ * @param array $args Optional. Arguments to pass to the hook's callback function.
+ * @return string|bool False, if no schedule. Schedule on success.
+ */
function wp_get_schedule($hook, $args = array()) {
$crons = _get_cron_array();
$key = md5(serialize($args));
// Private functions
//
+/**
+ * Retrieve cron info array option.
+ *
+ * @since 2.1.0
+ * @access private
+ *
+ * @return array CRON info array.
+ */
function _get_cron_array() {
$cron = get_option('cron');
if ( ! is_array($cron) )
return $cron;
}
+/**
+ * Updates the CRON option with the new CRON array.
+ *
+ * @since 2.1.0
+ * @access private
+ *
+ * @param array $cron Cron info array from {@link _get_cron_array()}.
+ */
function _set_cron_array($cron) {
$cron['version'] = 2;
update_option( 'cron', $cron );
}
+/**
+ * Upgrade a Cron info array.
+ *
+ * This function upgrades the Cron info array to version 2.
+ *
+ * @since 2.1.0
+ * @access private
+ *
+ * @param array $cron Cron info array from {@link _get_cron_array()}.
+ * @return array An upgraded Cron info array.
+ */
function _upgrade_cron_array($cron) {
if ( isset($cron['version']) && 2 == $cron['version'])
return $cron;
$new_cron = array();
- foreach ($cron as $timestamp => $hooks) {
- foreach ( $hooks as $hook => $args ) {
+ foreach ( (array) $cron as $timestamp => $hooks) {
+ foreach ( (array) $hooks as $hook => $args ) {
$key = md5(serialize($args['args']));
$new_cron[$timestamp][$hook][$key] = $args;
}
return $new_cron;
}
+// stub for checking server timer accuracy, using outside standard time sources
+function check_server_timer( $local_time ) {
+ return true;
+}
+
?>
add_filter('comment_email', 'antispambot');
add_filter('option_tag_base', '_wp_filter_taxonomy_base');
add_filter('option_category_base', '_wp_filter_taxonomy_base');
+add_filter( 'the_posts', '_close_comments_for_old_posts' );
+add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 );
+add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 );
+add_filter( 'editable_slug', 'urldecode' );
-//Atom SSL support
+// Atom SSL support
add_filter('atom_service_url','atom_service_url_filter');
// Actions
add_action('wp_head', 'locale_stylesheet');
add_action('publish_future_post', 'check_and_publish_future_post', 10, 1);
add_action('wp_head', 'noindex', 1);
+add_action('wp_head', 'wp_print_styles', 9);
add_action('wp_head', 'wp_print_scripts');
add_action('wp_head', 'wp_generator');
if(!defined('DOING_CRON'))
add_action('template_redirect', 'wp_old_slug_redirect');
add_action('edit_post', 'wp_check_for_changed_slugs');
add_action('edit_form_advanced', 'wp_remember_old_slug');
+add_action('init', '_show_post_preview');
?>
<?php
/**
- * Deprecated functions from past WordPress versions
+ * Deprecated functions from past WordPress versions. You shouldn't use these
+ * globals and functions and look for the alternatives instead. The functions
+ * and globals will be removed in a later version.
+ *
* @package WordPress
* @subpackage Deprecated
*/
*/
/**
- * get_postdata() - Entire Post data
+ * Entire Post data.
*
* @since 0.71
* @deprecated Use get_post()
}
/**
- * start_wp() - Sets up the WordPress Loop
+ * Sets up the WordPress Loop.
*
* @since 1.0.1
* @deprecated Since 1.5 - {@link http://codex.wordpress.org/The_Loop Use new WordPress Loop}
}
/**
- * the_category_ID() - Return or Print Category ID
+ * Return or Print Category ID.
*
* @since 0.71
* @deprecated use get_the_category()
}
/**
- * the_category_head() - Print category with optional text before and after
+ * Print category with optional text before and after.
*
* @since 0.71
* @deprecated use get_the_category_by_ID()
}
/**
- * previous_post() - Prints link to the previous post
+ * Prints link to the previous post.
*
* @since 1.5
* @deprecated Use previous_post_link()
}
/**
- * next_post() - Prints link to the next post
+ * Prints link to the next post.
*
* @since 0.71
* @deprecated Use next_post_link()
}
/**
- * user_can_create_post() - Whether user can create a post
+ * Whether user can create a post.
*
* @since 1.5
* @deprecated Use current_user_can()
}
/**
- * user_can_create_draft() - Whether user can create a post
+ * Whether user can create a post.
*
* @since 1.5
* @deprecated Use current_user_can()
}
/**
- * user_can_edit_post() - Whether user can edit a post
+ * Whether user can edit a post.
*
* @since 1.5
* @deprecated Use current_user_can()
}
/**
- * user_can_delete_post() - Whether user can delete a post
+ * Whether user can delete a post.
*
* @since 1.5
* @deprecated Use current_user_can()
}
/**
- * user_can_set_post_date() - Whether user can set new posts' dates
+ * Whether user can set new posts' dates.
*
* @since 1.5
* @deprecated Use current_user_can()
return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
}
-/* returns true if $user_id can edit $post_id's date */
/**
- * user_can_edit_post_date() - Whether user can delete a post
+ * Whether user can delete a post.
*
* @since 1.5
* @deprecated Use current_user_can()
* @param int $user_id
* @param int $post_id
* @param int $blog_id Not Used
- * @return bool
+ * @return bool returns true if $user_id can edit $post_id's date
*/
function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
_deprecated_function(__FUNCTION__, '0.0', 'current_user_can()');
return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
}
-/* returns true if $user_id can edit $post_id's comments */
/**
- * user_can_edit_post_comments() - Whether user can delete a post
+ * Whether user can delete a post.
*
* @since 1.5
* @deprecated Use current_user_can()
* @param int $user_id
* @param int $post_id
* @param int $blog_id Not Used
- * @return bool
+ * @return bool returns true if $user_id can edit $post_id's comments
*/
function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
_deprecated_function(__FUNCTION__, '0.0', 'current_user_can()');
return user_can_edit_post($user_id, $post_id, $blog_id);
}
-/* returns true if $user_id can delete $post_id's comments */
/**
- * user_can_delete_post_comments() - Whether user can delete a post
+ * Whether user can delete a post.
*
* @since 1.5
* @deprecated Use current_user_can()
* @param int $user_id
* @param int $post_id
* @param int $blog_id Not Used
- * @return bool
+ * @return bool returns true if $user_id can delete $post_id's comments
*/
function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
_deprecated_function(__FUNCTION__, '0.0', 'current_user_can()');
}
/**
- * user_can_edit_user() - Can user can edit other user
+ * Can user can edit other user.
*
* @since 1.5
* @deprecated Use current_user_can()
}
/**
- * get_linksbyname() - Gets the links associated with category $cat_name.
+ * Gets the links associated with category $cat_name.
*
* @since 0.71
* @deprecated Use get_links()
* @see get_links()
*
- * @param string $cat_name Optional. The category name to use. If no match is found uses all.
- * @param string $before Optional. The html to output before the link.
- * @param string $after Optional. The html to output after the link.
- * @param string $between Optional. The html to output between the link/image and it's description. Not used if no image or $show_images is true.
- * @param bool $show_images Optional. Whether to show images (if defined).
- * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 'description' or 'rating'. Or maybe owner.
+ * @param string $cat_name Optional. The category name to use. If no match is found uses all.
+ * @param string $before Optional. The html to output before the link.
+ * @param string $after Optional. The html to output after the link.
+ * @param string $between Optional. The html to output between the link/image and it's description. Not used if no image or $show_images is true.
+ * @param bool $show_images Optional. Whether to show images (if defined).
+ * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 'description' or 'rating'. Or maybe owner.
* If you start the name with an underscore the order will be reversed. You can also specify 'rand' as the order which will return links in a
* random order.
- * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined.
- * @param bool $show_rating Optional. Show rating stars/chars.
- * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown.
- * @param int $show_updated Optional. Whether to show last updated timestamp
+ * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined.
+ * @param bool $show_rating Optional. Show rating stars/chars.
+ * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown.
+ * @param int $show_updated Optional. Whether to show last updated timestamp
*/
function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id',
$show_description = true, $show_rating = false,
}
/**
- * wp_get_linksbyname() - Gets the links associated with the named category.
+ * Gets the links associated with the named category.
*
* @since 1.0.1
* @deprecated Use wp_get_links()
}
/**
- * get_linkobjectsbyname() - Gets an array of link objects associated with category $cat_name.
+ * Gets an array of link objects associated with category $cat_name.
*
* <code>
* $links = get_linkobjectsbyname('fred');
}
/**
- * get_linkobjects() - Gets an array of link objects associated with category n.
+ * Gets an array of link objects associated with category n.
*
* Usage:
* <code>
}
/**
- * get_linksbyname_withrating() - Gets the links associated with category 'cat_name' and display rating stars/chars.
+ * Gets the links associated with category 'cat_name' and display rating stars/chars.
*
* @since 0.71
* @deprecated Use get_bookmarks()
}
/**
- * get_links_withrating() - Gets the links associated with category n and display rating stars/chars.
+ * Gets the links associated with category n and display rating stars/chars.
*
* @since 0.71
* @deprecated Use get_bookmarks()
}
/**
- * get_autotoggle() - Gets the auto_toggle setting
+ * Gets the auto_toggle setting.
*
* @since 0.71
* @deprecated No alternative function available
}
/**
- * wp_set_post_cats() - Sets the categories that the post id belongs to.
+ * Sets the categories that the post id belongs to.
*
* @since 1.0.1
* @deprecated Use wp_set_post_categories()
}
/**
- * get_author_link() - Returns or Prints link to the author's posts
+ * Returns or Prints link to the author's posts.
*
* @since 1.2
* @deprecated Use get_author_posts_url()
}
/**
- * link_pages() - Print list of pages based on arguments
+ * Print list of pages based on arguments.
*
* @since 0.71
* @deprecated Use wp_link_pages()
}
/**
- * get_settings() - Get value based on option
+ * Get value based on option.
*
* @since 0.71
* @deprecated Use get_option()
}
/**
- * permalink_link() - Print the permalink of the current post in the loop
+ * Print the permalink of the current post in the loop.
*
* @since 0.71
* @deprecated Use the_permalink()
}
/**
- * permalink_single_rss() - Print the permalink to the RSS feed
+ * Print the permalink to the RSS feed.
*
* @since 0.71
* @deprecated Use the_permalink_rss()
}
/**
- * wp_get_links() - Gets the links associated with category.
+ * Gets the links associated with category.
*
* @see get_links() for argument information that can be used in $args
* @since 1.0.1
}
/**
- * get_links() - Gets the links associated with category by id.
+ * Gets the links associated with category by id.
*
* @since 0.71
* @deprecated Use get_bookmarks()
}
/**
- * get_links_list() - Output entire list of links by category
+ * Output entire list of links by category.
*
- * Output a list of all links, listed by category, using the
- * settings in $wpdb->linkcategories and output it as a nested
- * HTML unordered list.
+ * Output a list of all links, listed by category, using the settings in
+ * $wpdb->linkcategories and output it as a nested HTML unordered list.
*
* @author Dougal
* @since 1.0.1
}
/**
- * links_popup_script() - Show the link to the links popup and the number of links
+ * Show the link to the links popup and the number of links.
*
* @author Fullo
* @link http://sprite.csr.unibo.it/fullo/
}
/**
- * get_linkcatname() - Gets the name of category by id.
+ * Gets the name of category by id.
*
* @since 0.71
* @deprecated Use get_category()
}
/**
- * comment_rss_link() - Print RSS comment feed link
+ * Print RSS comment feed link.
*
* @since 1.0.1
* @deprecated Use post_comments_feed_link()
}
/**
- * get_category_rss_link() - Print/Return link to category RSS2 feed
+ * Print/Return link to category RSS2 feed.
*
* @since 1.2
* @deprecated Use get_category_feed_link()
}
/**
- * get_author_rss_link() - Print/Return link to author RSS feed
+ * Print/Return link to author RSS feed.
*
* @since 1.2
* @deprecated Use get_author_feed_link()
}
/**
- * comments_rss() - Return link to the post RSS feed
+ * Return link to the post RSS feed.
*
* @since 1.5
* @deprecated Use get_post_comments_feed_link()
}
/**
- * create_user() - An alias of wp_create_user().
+ * An alias of wp_create_user().
+ *
* @param string $username The user's username.
* @param string $password The user's password.
* @param string $email The user's email (optional).
}
/**
- * documentation_link() - Unused Admin function
+ * Unused Admin function.
+ *
* @since 2.0
* @param string $deprecated Unknown
* @deprecated 2.5
}
/**
- * gzip_compression() - Unused function
+ * Unused function.
*
* @deprecated 2.5
*/
-
function gzip_compression() {
return false;
}
+
+/**
+ * Retrieve an array of comment data about comment $comment_ID.
+ *
+ * @deprecated Use get_comment()
+ * @see get_comment()
+ * @since 0.71
+ *
+ * @uses $id
+ * @uses $wpdb Database Object
+ *
+ * @param int $comment_ID The ID of the comment
+ * @param int $no_cache Whether to use the cache or not (casted to bool)
+ * @param bool $include_unapproved Whether to include unapproved comments or not
+ * @return array The comment data
+ */
+function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) {
+ _deprecated_function( __FUNCTION__, '2.7', 'get_comment()' );
+ return get_comment($comment_ID, ARRAY_A);
+}
+
?>
\ No newline at end of file
<feed
xmlns="http://www.w3.org/2005/Atom"
xml:lang="<?php echo get_option('rss_language'); ?>"
+ xmlns:thr="http://purl.org/syndication/thread/1.0"
<?php do_action('atom_ns'); ?>
>
<title type="text"><?php
if ( is_singular() )
- printf(__('Comments on: %s'), get_the_title_rss());
+ printf(ent2ncr(__('Comments on: %s')), get_the_title_rss());
elseif ( is_search() )
- printf(__('Comments for %1$s searching on %2$s'), get_bloginfo_rss( 'name' ), attribute_escape(get_search_query()));
+ printf(ent2ncr(__('Comments for %1$s searching on %2$s')), get_bloginfo_rss( 'name' ), attribute_escape(get_search_query()));
else
- printf(__('Comments for %s'), get_bloginfo_rss( 'name' ) . get_wp_title_rss());
+ printf(ent2ncr(__('Comments for %s')), get_bloginfo_rss( 'name' ) . get_wp_title_rss());
?></title>
<subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
if ( !is_singular() ) {
$title = get_the_title($comment_post->ID);
$title = apply_filters('the_title_rss', $title);
- printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());
+ printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss());
} else {
- printf(__('By: %s'), get_comment_author_rss());
+ printf(ent2ncr(__('By: %s')), get_comment_author_rss());
}
?></title>
<link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss('html_type'); ?>" />
</author>
- <id><?php comment_link(); ?></id>
+ <id><?php comment_guid(); ?></id>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true), false); ?></updated>
<published><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true), false); ?></published>
-<?php if (!empty($comment_post->post_password) && $_COOKIE['wp-postpass'] != $comment_post->post_password) : ?>
+<?php if ( post_password_required($comment_post) ) : ?>
<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content>
<?php else : // post pass ?>
<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content>
<?php endif; // post pass
+ // Return comment threading information (http://www.ietf.org/rfc/rfc4685.txt)
+ if ( $comment->comment_parent == 0 ) : // This comment is top level ?>
+ <thr:in-reply-to ref="<?php the_guid() ?>" href="<?php the_permalink_rss() ?>" type="<?php bloginfo_rss('html_type'); ?>" />
+<?php else : // This comment is in reply to another comment
+ $parent_comment = get_comment($comment->comment_parent);
+ // The rel attribute below and the id tag above should be GUIDs, but WP doesn't create them for comments (unlike posts). Either way, its more important that they both use the same system
+?>
+ <thr:in-reply-to ref="<?php comment_guid($parent_comment) ?>" href="<?php echo get_comment_link($parent_comment) ?>" type="<?php bloginfo_rss('html_type'); ?>" />
+<?php endif;
do_action('comment_atom_entry', $comment->comment_ID, $comment_post->ID);
?>
</entry>
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
+ xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
>
<channel>
<title><?php
if ( is_singular() )
- printf(__('Comments on: %s'), get_the_title_rss());
+ printf(ent2ncr(__('Comments on: %s')), get_the_title_rss());
elseif ( is_search() )
- printf(__('Comments for %s searching on %s'), get_bloginfo_rss( 'name' ), attribute_escape($wp_query->query_vars['s']));
+ printf(ent2ncr(__('Comments for %s searching on %s')), get_bloginfo_rss( 'name' ), attribute_escape($wp_query->query_vars['s']));
else
- printf(__('Comments for %s'), get_bloginfo_rss( 'name' ) . get_wp_title_rss());
+ printf(ent2ncr(__('Comments for %s')), get_bloginfo_rss( 'name' ) . get_wp_title_rss());
?></title>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link>
<description><?php bloginfo_rss("description") ?></description>
<pubDate><?php echo gmdate('r'); ?></pubDate>
<?php the_generator( 'rss2' ); ?>
+ <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
+ <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
<?php do_action('commentsrss2_head'); ?>
<?php
if ( have_comments() ) : while ( have_comments() ) : the_comment();
if ( !is_singular() ) {
$title = get_the_title($comment_post->ID);
$title = apply_filters('the_title_rss', $title);
- printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());
+ printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss());
} else {
- printf(__('By: %s'), get_comment_author_rss());
+ printf(ent2ncr(__('By: %s')), get_comment_author_rss());
}
?></title>
<link><?php comment_link() ?></link>
<dc:creator><?php echo get_comment_author_rss() ?></dc:creator>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>
<guid isPermaLink="false"><?php comment_guid() ?></guid>
-<?php if (!empty($comment_post->post_password) && $_COOKIE['wp-postpass'] != $comment_post->post_password) : ?>
- <description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description>
+<?php if ( post_password_required($comment_post) ) : ?>
+ <description><?php echo ent2ncr(__('Protected Comments: Please enter your password to view comments.')); ?></description>
<content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
<?php else : // post pass ?>
<description><?php comment_text_rss() ?></description>
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
+ xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
<?php do_action('rss2_ns'); ?>
>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
<?php the_generator( 'rss2' ); ?>
<language><?php echo get_option('rss_language'); ?></language>
+ <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
+ <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
<?php do_action('rss2_head'); ?>
<?php while( have_posts()) : the_post(); ?>
<item>
* @package WordPress
* @subpackage Feed
* @since unknown
+ *
+ * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
*/
-function comment_guid() {
- echo get_comment_guid();
+function comment_guid($comment_id = null) {
+ echo get_comment_guid($comment_id);
}
/**
* @subpackage Feed
* @since unknown
*
+ * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
* @return bool|string false on failure or guid for comment on success.
*/
-function get_comment_guid() {
- global $comment;
+function get_comment_guid($comment_id = null) {
+ $comment = get_comment($comment_id);
if ( !is_object($comment) )
return false;
* @since 1.5.0
*/
function comment_link() {
- echo get_comment_link();
+ echo clean_url( get_comment_link() );
}
/**
* @package WordPress
* @subpackage Feed
* @since 2.1.0
- * @uses apply_filters()
+ * @uses apply_filters()
*
* @param string $type Optional, default is 'rss'. Either 'rss', 'atom', or 'rdf'.
* @return string All of the post categories for displaying in the feed.
elseif ( 'atom' == $type )
$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $cat_name ) );
else
- $the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n";
+ $the_list .= "\n\t\t<category><![CDATA[" . html_entity_decode( $cat_name ) . "]]></category>\n";
}
return apply_filters('the_category_rss', $the_list, $type);
* @uses get_post_custom() To get the current post enclosure metadata.
*/
function rss_enclosure() {
- global $post;
- if ( !empty($post->post_password) && (!isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
+ if ( post_password_required() )
return;
- foreach (get_post_custom() as $key => $val) {
+ foreach ( (array) get_post_custom() as $key => $val) {
if ($key == 'enclosure') {
- foreach ((array)$val as $enc) {
+ foreach ( (array) $val as $enc ) {
$enclosure = split("\n", $enc);
- echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
+
+ //only get the the first element eg, audio/mpeg from 'audio/mpeg mpga mp2 mp3'
+ $t = split('[ \t]', trim($enclosure[2]) );
+ $type = $t[0];
+
+ echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . $type . '" />' . "\n");
}
}
}
* @uses get_post_custom() To get the current post enclosure metadata.
*/
function atom_enclosure() {
- global $post;
- if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
+ if ( post_password_required() )
return;
- foreach (get_post_custom() as $key => $val) {
+ foreach ( (array) get_post_custom() as $key => $val ) {
if ($key == 'enclosure') {
- foreach ((array)$val as $enc) {
+ foreach ( (array) $val as $enc ) {
$enclosure = split("\n", $enc);
echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
}
* @since 2.5
*/
function self_link() {
- echo 'http'
- . ( $_SERVER['https'] == 'on' ? 's' : '' ) . '://'
- . $_SERVER['HTTP_HOST']
- . wp_specialchars(stripslashes($_SERVER['REQUEST_URI']), 1);
+ $host = @parse_url(get_option('home'));
+ $host = $host['host'];
+ echo clean_url(
+ 'http'
+ . ( (isset($_SERVER['https']) && $_SERVER['https'] == 'on') ? 's' : '' ) . '://'
+ . $host
+ . stripslashes($_SERVER['REQUEST_URI'])
+ );
}
-?>
\ No newline at end of file
+?>
<?php
+/**
+ * Main Wordpress Formatting API.
+ *
+ * Handles many functions for formatting output.
+ *
+ * @package WordPress
+ **/
+/**
+ * Replaces common plain text characters into formatted entities
+ *
+ * As an example,
+ * <code>
+ * 'cause today's effort makes it worth tomorrow's "holiday"...
+ * </code>
+ * Becomes:
+ * <code>
+ * ’cause today’s effort makes it worth tomorrow’s “holiday”…
+ * </code>
+ * Code within certain html blocks are skipped.
+ *
+ * @since 0.71
+ * @uses $wp_cockneyreplace Array of formatted entities for certain common phrases
+ *
+ * @param string $text The text to be formatted
+ * @return string The string replaced with html entities
+ */
function wptexturize($text) {
global $wp_cockneyreplace;
$next = true;
$dynamic_replacements = array('’$1','$1‘', '$1″', '$1′', '$1’$2', '$1“$2', '”$1', '’$1', '$1×$2');
for ( $i = 0; $i < $stop; $i++ ) {
- $curl = $textarr[$i];
+ $curl = $textarr[$i];
- if (isset($curl{0}) && '<' != $curl{0} && '[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag
+ if ( !empty($curl) && '<' != $curl{0} && '[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag
// static strings
$curl = str_replace($static_characters, $static_replacements, $curl);
// regular expressions
$output .= $curl;
}
- return $output;
+ return $output;
}
-// Accepts matches array from preg_replace_callback in wpautop()
-// or a string
+/**
+ * Accepts matches array from preg_replace_callback in wpautop() or a string.
+ *
+ * Ensures that the contents of a <<pre>>...<</pre>> HTML block are not
+ * converted into paragraphs or line-breaks.
+ *
+ * @since 1.2.0
+ *
+ * @param array|string $matches The array or string
+ * @return string The pre block without paragraph/line-break conversion.
+ */
function clean_pre($matches) {
if ( is_array($matches) )
$text = $matches[1] . $matches[2] . "</pre>";
return $text;
}
+/**
+ * Replaces double line-breaks with paragraph elements.
+ *
+ * A group of regex replaces used to identify text formatted with newlines and
+ * replace double line-breaks with HTML paragraph tags. The remaining
+ * line-breaks after conversion become <<br />> tags, unless $br is set to '0'
+ * or 'false'.
+ *
+ * @since 0.71
+ *
+ * @param string $pee The text which has to be formatted.
+ * @param int|bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true.
+ * @return string Text which has been converted into correct paragraph tags.
+ */
function wpautop($pee, $br = 1) {
$pee = $pee . "\n"; // just to make things a little easier, pad the end
$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
$pee = preg_replace('|\s*</embed>\s*|', '</embed>', $pee);
}
$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
- $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
+ // make paragraphs, including one at the end
+ $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY);
+ $pee = '';
+ foreach ( $pees as $tinkle )
+ $pee .= '<p>' . trim($tinkle, "\n") . "</p>\n";
$pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
$pee = preg_replace('!<p>([^<]+)\s*?(</(?:div|address|form)[^>]*>)!', "<p>$1</p>$2", $pee);
$pee = preg_replace( '|<p>|', "$1<p>", $pee );
return $pee;
}
-
+/**
+ * Checks to see if a string is utf8 encoded.
+ *
+ * @author bmorel at ssi dot fr
+ *
+ * @since 1.2.1
+ *
+ * @param string $Str The string to be checked
+ * @return bool True if $Str fits a UTF-8 model, false otherwise.
+ */
function seems_utf8($Str) { # by bmorel at ssi dot fr
$length = strlen($Str);
for ($i=0; $i < $length; $i++) {
return true;
}
-function wp_specialchars( $text, $quotes = 0 ) {
- // Like htmlspecialchars except don't double-encode HTML entities
- $text = str_replace('&&', '&&', $text);
- $text = str_replace('&&', '&&', $text);
- $text = preg_replace('/&(?:$|([^#])(?![a-z1-4]{1,8};))/', '&$1', $text);
- $text = str_replace('<', '<', $text);
- $text = str_replace('>', '>', $text);
- if ( 'double' === $quotes ) {
- $text = str_replace('"', '"', $text);
- } elseif ( 'single' === $quotes ) {
- $text = str_replace("'", ''', $text);
- } elseif ( $quotes ) {
- $text = str_replace('"', '"', $text);
- $text = str_replace("'", ''', $text);
+/**
+ * Converts a number of special characters into their HTML entities.
+ *
+ * Specifically deals with: &, <, >, ", and '.
+ *
+ * $quote_style can be set to ENT_COMPAT to encode " to
+ * ", or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded.
+ *
+ * @since 1.2.2
+ *
+ * @param string $string The text which is to be encoded.
+ * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
+ * @param string $charset Optional. The character encoding of the string. Default is false.
+ * @param boolean $double_encode Optional. Whether or not to encode existing html entities. Default is false.
+ * @return string The encoded text with HTML entities.
+ */
+function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false )
+{
+ $string = (string) $string;
+
+ if ( 0 === strlen( $string ) ) {
+ return '';
}
- return $text;
+
+ // Don't bother if there are no specialchars - saves some processing
+ if ( !preg_match( '/[&<>"\']/', $string ) ) {
+ return $string;
+ }
+
+ // Account for the previous behaviour of the function when the $quote_style is not an accepted value
+ if ( empty( $quote_style ) ) {
+ $quote_style = ENT_NOQUOTES;
+ } elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) {
+ $quote_style = ENT_QUOTES;
+ }
+
+ // Store the site charset as a static to avoid multiple calls to wp_load_alloptions()
+ if ( !$charset ) {
+ static $_charset;
+ if ( !isset( $_charset ) ) {
+ $alloptions = wp_load_alloptions();
+ $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : '';
+ }
+ $charset = $_charset;
+ }
+ if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) ) {
+ $charset = 'UTF-8';
+ }
+
+ $_quote_style = $quote_style;
+
+ if ( $quote_style === 'double' ) {
+ $quote_style = ENT_COMPAT;
+ $_quote_style = ENT_COMPAT;
+ } elseif ( $quote_style === 'single' ) {
+ $quote_style = ENT_NOQUOTES;
+ }
+
+ // Handle double encoding ourselves
+ if ( !$double_encode ) {
+ $string = wp_specialchars_decode( $string, $_quote_style );
+ $string = preg_replace( '/&(#?x?[0-9]+|[a-z]+);/i', '|wp_entity|$1|/wp_entity|', $string );
+ }
+
+ $string = @htmlspecialchars( $string, $quote_style, $charset );
+
+ // Handle double encoding ourselves
+ if ( !$double_encode ) {
+ $string = str_replace( array( '|wp_entity|', '|/wp_entity|' ), array( '&', ';' ), $string );
+ }
+
+ // Backwards compatibility
+ if ( 'single' === $_quote_style ) {
+ $string = str_replace( "'", ''', $string );
+ }
+
+ return $string;
+}
+
+/**
+ * Converts a number of HTML entities into their special characters.
+ *
+ * Specifically deals with: &, <, >, ", and '.
+ *
+ * $quote_style can be set to ENT_COMPAT to decode " entities,
+ * or ENT_QUOTES to do both " and '. Default is ENT_NOQUOTES where no quotes are decoded.
+ *
+ * @since 2.8
+ *
+ * @param string $string The text which is to be decoded.
+ * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old wp_specialchars() values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
+ * @return string The decoded text without HTML entities.
+ */
+function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES )
+{
+ $string = (string) $string;
+
+ if ( 0 === strlen( $string ) ) {
+ return '';
+ }
+
+ // Don't bother if there are no entities - saves a lot of processing
+ if ( strpos( $string, '&' ) === false ) {
+ return $string;
+ }
+
+ // Match the previous behaviour of wp_specialchars() when the $quote_style is not an accepted value
+ if ( empty( $quote_style ) ) {
+ $quote_style = ENT_NOQUOTES;
+ } elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) {
+ $quote_style = ENT_QUOTES;
+ }
+
+ // More complete than get_html_translation_table( HTML_SPECIALCHARS )
+ $single = array( ''' => '\'', ''' => '\'' );
+ $single_preg = array( '/�*39;/' => ''', '/�*27;/i' => ''' );
+ $double = array( '"' => '"', '"' => '"', '"' => '"' );
+ $double_preg = array( '/�*34;/' => '"', '/�*22;/i' => '"' );
+ $others = array( '<' => '<', '<' => '<', '>' => '>', '>' => '>', '&' => '&', '&' => '&', '&' => '&' );
+ $others_preg = array( '/�*60;/' => '<', '/�*62;/' => '>', '/�*38;/' => '&', '/�*26;/i' => '&' );
+
+ if ( $quote_style === ENT_QUOTES ) {
+ $translation = array_merge( $single, $double, $others );
+ $translation_preg = array_merge( $single_preg, $double_preg, $others_preg );
+ } elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) {
+ $translation = array_merge( $double, $others );
+ $translation_preg = array_merge( $double_preg, $others_preg );
+ } elseif ( $quote_style === 'single' ) {
+ $translation = array_merge( $single, $others );
+ $translation_preg = array_merge( $single_preg, $others_preg );
+ } elseif ( $quote_style === ENT_NOQUOTES ) {
+ $translation = $others;
+ $translation_preg = $others_preg;
+ }
+
+ // Remove zero padding on numeric entities
+ $string = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $string );
+
+ // Replace characters according to translation table
+ return strtr( $string, $translation );
}
+/**
+ * Checks for invalid UTF8 in a string.
+ *
+ * @since 2.8
+ *
+ * @param string $string The text which is to be checked.
+ * @param boolean $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
+ * @return string The checked text.
+ */
+function wp_check_invalid_utf8( $string, $strip = false )
+{
+ $string = (string) $string;
+
+ if ( 0 === strlen( $string ) ) {
+ return '';
+ }
+
+ // Store the site charset as a static to avoid multiple calls to get_option()
+ static $is_utf8;
+ if ( !isset( $is_utf8 ) ) {
+ $is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) );
+ }
+ if ( !$is_utf8 ) {
+ return $string;
+ }
+
+ // Check for support for utf8 in the installed PCRE library once and store the result in a static
+ static $utf8_pcre;
+ if ( !isset( $utf8_pcre ) ) {
+ $utf8_pcre = @preg_match( '/^./u', 'a' );
+ }
+ // We can't demand utf8 in the PCRE installation, so just return the string in those cases
+ if ( !$utf8_pcre ) {
+ return $string;
+ }
+
+ // preg_match fails when it encounters invalid UTF8 in $string
+ if ( 1 === @preg_match( '/^./us', $string ) ) {
+ return $string;
+ }
+
+ // Attempt to strip the bad chars if requested (not recommended)
+ if ( $strip && function_exists( 'iconv' ) ) {
+ return iconv( 'utf-8', 'utf-8', $string );
+ }
+
+ return '';
+}
+
+/**
+ * Encode the Unicode values to be used in the URI.
+ *
+ * @since 1.5.0
+ *
+ * @param string $utf8_string
+ * @param int $length Max length of the string
+ * @return string String with Unicode encoded for URI.
+ */
function utf8_uri_encode( $utf8_string, $length = 0 ) {
$unicode = '';
$values = array();
return $unicode;
}
+/**
+ * Converts all accent characters to ASCII characters.
+ *
+ * If there are no accent characters, then the string given is just returned.
+ *
+ * @since 1.2.1
+ *
+ * @param string $string Text that might have accent characters
+ * @return string Filtered string with replaced "nice" characters.
+ */
function remove_accents($string) {
if ( !preg_match('/[\x80-\xff]/', $string) )
return $string;
return $string;
}
+/**
+ * Filters certain characters from the file name.
+ *
+ * Turns all strings to lowercase removing most characters except alphanumeric
+ * with spaces, dashes and periods. All spaces and underscores are converted to
+ * dashes. Multiple dashes are converted to a single dash. Finally, if the file
+ * name ends with a dash, it is removed.
+ *
+ * @since 2.1.0
+ *
+ * @param string $name The file name
+ * @return string Sanitized file name
+ */
function sanitize_file_name( $name ) { // Like sanitize_title, but with periods
$name = strtolower( $name );
$name = preg_replace('/&.+?;/', '', $name); // kill entities
return $name;
}
+/**
+ * Sanitize username stripping out unsafe characters.
+ *
+ * If $strict is true, only alphanumeric characters (as well as _, space, ., -,
+ * @) are returned.
+ * Removes tags, octets, entities, and if strict is enabled, will remove all
+ * non-ASCII characters. After sanitizing, it passes the username, raw username
+ * (the username in the parameter), and the strict parameter as parameters for
+ * the filter.
+ *
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'sanitize_user' hook on username, raw username,
+ * and $strict parameter.
+ *
+ * @param string $username The username to be sanitized.
+ * @param bool $strict If set limits $username to specific characters. Default false.
+ * @return string The sanitized username, after passing through filters.
+ */
function sanitize_user( $username, $strict = false ) {
$raw_username = $username;
$username = strip_tags($username);
return apply_filters('sanitize_user', $username, $raw_username, $strict);
}
+/**
+ * Sanitizes title or use fallback title.
+ *
+ * Specifically, HTML and PHP tags are stripped. Further actions can be added
+ * via the plugin API. If $title is empty and $fallback_title is set, the latter
+ * will be used.
+ *
+ * @since 1.0.0
+ *
+ * @param string $title The string to be sanitized.
+ * @param string $fallback_title Optional. A title to use if $title is empty.
+ * @return string The sanitized string.
+ */
function sanitize_title($title, $fallback_title = '') {
$title = strip_tags($title);
$title = apply_filters('sanitize_title', $title);
return $title;
}
+/**
+ * Sanitizes title, replacing whitespace with dashes.
+ *
+ * Limits the output to alphanumeric characters, underscore (_) and dash (-).
+ * Whitespace becomes a dash.
+ *
+ * @since 1.2.0
+ *
+ * @param string $title The title to be sanitized.
+ * @return string The sanitized title.
+ */
function sanitize_title_with_dashes($title) {
$title = strip_tags($title);
// Preserve escaped octets.
return $title;
}
-// ensures a string is a valid SQL order by clause like: post_name ASC, ID DESC
-// accepts one or more columns, with or without ASC/DESC, and also accepts RAND()
+/**
+ * Ensures a string is a valid SQL order by clause.
+ *
+ * Accepts one or more columns, with or without ASC/DESC, and also accepts
+ * RAND().
+ *
+ * @since 2.5.1
+ *
+ * @param string $orderby Order by string to be checked.
+ * @return string|false Returns the order by clause if it is a match, false otherwise.
+ */
function sanitize_sql_orderby( $orderby ){
preg_match('/^\s*([a-z0-9_]+(\s+(ASC|DESC))?(\s*,\s*|\s*$))+|^\s*RAND\(\s*\)\s*$/i', $orderby, $obmatches);
if ( !$obmatches )
return $orderby;
}
+/**
+ * Converts a number of characters from a string.
+ *
+ * Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are
+ * converted into correct XHTML and Unicode characters are converted to the
+ * valid range.
+ *
+ * @since 0.71
+ *
+ * @param string $content String of characters to be converted.
+ * @param string $deprecated Not used.
+ * @return string Converted string.
+ */
function convert_chars($content, $deprecated = '') {
// Translation of invalid Unicode references range to valid range
$wp_htmltranswinuni = array(
return $content;
}
+/**
+ * Fixes javascript bugs in browsers.
+ *
+ * Converts unicode characters to HTML numbered entities.
+ *
+ * @since 1.5.0
+ * @uses $is_macIE
+ * @uses $is_winIE
+ *
+ * @param string $text Text to be made safe.
+ * @return string Fixed text.
+ */
function funky_javascript_fix($text) {
// Fixes for browsers' javascript bugs
global $is_macIE, $is_winIE;
+ /** @todo use preg_replace_callback() instead */
if ( $is_winIE || $is_macIE )
$text = preg_replace("/\%u([0-9A-F]{4,4})/e", "'&#'.base_convert('\\1',16,10).';'", $text);
return $text;
}
+/**
+ * Will only balance the tags if forced to and the option is set to balance tags.
+ *
+ * The option 'use_balanceTags' is used for whether the tags will be balanced.
+ * Both the $force parameter and 'use_balanceTags' option will have to be true
+ * before the tags will be balanced.
+ *
+ * @since 0.71
+ *
+ * @param string $text Text to be balanced
+ * @param bool $force Forces balancing, ignoring the value of the option. Default false.
+ * @return string Balanced text
+ */
function balanceTags( $text, $force = false ) {
if ( !$force && get_option('use_balanceTags') == 0 )
return $text;
return force_balance_tags( $text );
}
-/*
- force_balance_tags
-
- Balances Tags of string using a modified stack.
-
- @param text Text to be balanced
- @param force Forces balancing, ignoring the value of the option
- @return Returns balanced text
- @author Leonard Lin (leonard@acm.org)
- @version v1.1
- @date November 4, 2001
- @license GPL v2.0
- @notes
- @changelog
- --- Modified by Scott Reilly (coffee2code) 02 Aug 2004
- 1.2 ***TODO*** Make better - change loop condition to $text
- 1.1 Fixed handling of append/stack pop order of end text
- Added Cleaning Hooks
- 1.0 First Version
-*/
+/**
+ * Balances tags of string using a modified stack.
+ *
+ * @since 2.0.4
+ *
+ * @author Leonard Lin <leonard@acm.org>
+ * @license GPL v2.0
+ * @copyright November 4, 2001
+ * @version 1.1
+ * @todo Make better - change loop condition to $text in 1.2
+ * @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004
+ * 1.1 Fixed handling of append/stack pop order of end text
+ * Added Cleaning Hooks
+ * 1.0 First Version
+ *
+ * @param string $text Text to be balanced.
+ * @return string Balanced text.
+ */
function force_balance_tags( $text ) {
$tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
$single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags
return $newtext;
}
+/**
+ * Acts on text which is about to be edited.
+ *
+ * Unless $richedit is set, it is simply a holder for the 'format_to_edit'
+ * filter. If $richedit is set true htmlspecialchars() will be run on the
+ * content, converting special characters to HTMl entities.
+ *
+ * @since 0.71
+ *
+ * @param string $content The text about to be edited.
+ * @param bool $richedit Whether or not the $content should pass through htmlspecialchars(). Default false.
+ * @return string The text after the filter (and possibly htmlspecialchars()) has been run.
+ */
function format_to_edit($content, $richedit = false) {
$content = apply_filters('format_to_edit', $content);
if (! $richedit )
return $content;
}
+/**
+ * Holder for the 'format_to_post' filter.
+ *
+ * @since 0.71
+ *
+ * @param string $content The text to pass through the filter.
+ * @return string Text returned from the 'format_to_post' filter.
+ */
function format_to_post($content) {
$content = apply_filters('format_to_post', $content);
return $content;
}
-function zeroise($number,$threshold) { // function to add leading zeros when necessary
+/**
+ * Add leading zeros when necessary.
+ *
+ * If you set the threshold to '4' and the number is '10', then you will get
+ * back '0010'. If you set the number to '4' and the number is '5000', then you
+ * will get back '5000'.
+ *
+ * Uses sprintf to append the amount of zeros based on the $threshold parameter
+ * and the size of the number. If the number is large enough, then no zeros will
+ * be appended.
+ *
+ * @since 0.71
+ *
+ * @param mixed $number Number to append zeros to if not greater than threshold.
+ * @param int $threshold Digit places number needs to be to not have zeros added.
+ * @return string Adds leading zeros to number if needed.
+ */
+function zeroise($number, $threshold) {
return sprintf('%0'.$threshold.'s', $number);
}
-
+/**
+ * Adds backslashes before letters and before a number at the start of a string.
+ *
+ * @since 0.71
+ *
+ * @param string $string Value to which backslashes will be added.
+ * @return string String with backslashes inserted.
+ */
function backslashit($string) {
$string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string);
$string = preg_replace('/([a-z])/i', '\\\\\1', $string);
return $string;
}
+/**
+ * Appends a trailing slash.
+ *
+ * Will remove trailing slash if it exists already before adding a trailing
+ * slash. This prevents double slashing a string or path.
+ *
+ * The primary use of this is for paths and thus should be used for paths. It is
+ * not restricted to paths and offers no specific path support.
+ *
+ * @since 1.2.0
+ * @uses untrailingslashit() Unslashes string if it was slashed already.
+ *
+ * @param string $string What to add the trailing slash to.
+ * @return string String with trailing slash added.
+ */
function trailingslashit($string) {
return untrailingslashit($string) . '/';
}
+/**
+ * Removes trailing slash if it exists.
+ *
+ * The primary use of this is for paths and thus should be used for paths. It is
+ * not restricted to paths and offers no specific path support.
+ *
+ * @since 2.2.0
+ *
+ * @param string $string What to remove the trailing slash from.
+ * @return string String without the trailing slash.
+ */
function untrailingslashit($string) {
return rtrim($string, '/');
}
+/**
+ * Adds slashes to escape strings.
+ *
+ * Slashes will first be removed if magic_quotes_gpc is set, see {@link
+ * http://www.php.net/magic_quotes} for more details.
+ *
+ * @since 0.71
+ *
+ * @param string $gpc The string returned from HTTP request data.
+ * @return string Returns a string escaped with slashes.
+ */
function addslashes_gpc($gpc) {
global $wpdb;
return $wpdb->escape($gpc);
}
-
+/**
+ * Navigates through an array and removes slashes from the values.
+ *
+ * If an array is passed, the array_map() function causes a callback to pass the
+ * value back to the function. The slashes from this value will removed.
+ *
+ * @since 2.0.0
+ *
+ * @param array|string $value The array or string to be striped.
+ * @return array|string Stripped array (or string in the callback).
+ */
function stripslashes_deep($value) {
- $value = is_array($value) ?
- array_map('stripslashes_deep', $value) :
- stripslashes($value);
-
- return $value;
+ $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
+ return $value;
}
+/**
+ * Navigates through an array and encodes the values to be used in a URL.
+ *
+ * Uses a callback to pass the value of the array back to the function as a
+ * string.
+ *
+ * @since 2.2.0
+ *
+ * @param array|string $value The array or string to be encoded.
+ * @return array|string $value The encoded array (or string from the callback).
+ */
function urlencode_deep($value) {
- $value = is_array($value) ?
- array_map('urlencode_deep', $value) :
- urlencode($value);
-
- return $value;
+ $value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value);
+ return $value;
}
+/**
+ * Converts email addresses characters to HTML entities to block spam bots.
+ *
+ * @since 0.71
+ *
+ * @param string $emailaddy Email address.
+ * @param int $mailto Optional. Range from 0 to 1. Used for encoding.
+ * @return string Converted email address.
+ */
function antispambot($emailaddy, $mailto=0) {
$emailNOSPAMaddy = '';
srand ((float) microtime() * 1000000);
return $emailNOSPAMaddy;
}
+/**
+ * Callback to convert URI match to HTML A element.
+ *
+ * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
+ * make_clickable()}.
+ *
+ * @since 2.3.2
+ * @access private
+ *
+ * @param array $matches Single Regex Match.
+ * @return string HTML A element with URI address.
+ */
function _make_url_clickable_cb($matches) {
$ret = '';
$url = $matches[2];
return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $ret;
}
+/**
+ * Callback to convert URL match to HTML A element.
+ *
+ * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
+ * make_clickable()}.
+ *
+ * @since 2.3.2
+ * @access private
+ *
+ * @param array $matches Single Regex Match.
+ * @return string HTML A element with URL address.
+ */
function _make_web_ftp_clickable_cb($matches) {
$ret = '';
$dest = $matches[2];
return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>" . $ret;
}
+/**
+ * Callback to convert email address match to HTML A element.
+ *
+ * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
+ * make_clickable()}.
+ *
+ * @since 2.3.2
+ * @access private
+ *
+ * @param array $matches Single Regex Match.
+ * @return string HTML A element with email address.
+ */
function _make_email_clickable_cb($matches) {
$email = $matches[2] . '@' . $matches[3];
return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
}
+/**
+ * Convert plaintext URI to HTML links.
+ *
+ * Converts URI, www and ftp, and email addresses. Finishes by fixing links
+ * within links.
+ *
+ * @since 0.71
+ *
+ * @param string $ret Content to convert URIs.
+ * @return string Content with converted URIs.
+ */
function make_clickable($ret) {
$ret = ' ' . $ret;
// in testing, using arrays here was found to be faster
- $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret);
- $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret);
+ $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret);
+ $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret);
$ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
// this one is not in an array because we need it to run last, for cleanup of accidental links within links
$ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret);
return $ret;
}
+/**
+ * Adds rel nofollow string to all HTML A elements in content.
+ *
+ * @since 1.5.0
+ *
+ * @param string $text Content that may contain HTML A elements.
+ * @return string Converted content.
+ */
function wp_rel_nofollow( $text ) {
global $wpdb;
// This is a pre save filter, so text is already escaped.
return $text;
}
+/**
+ * Callback to used to add rel=nofollow string to HTML A element.
+ *
+ * Will remove already existing rel="nofollow" and rel='nofollow' from the
+ * string to prevent from invalidating (X)HTML.
+ *
+ * @since 2.3.0
+ *
+ * @param array $matches Single Match
+ * @return string HTML A Element with rel nofollow.
+ */
function wp_rel_nofollow_callback( $matches ) {
$text = $matches[1];
$text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text);
return "<a $text rel=\"nofollow\">";
}
+/**
+ * Convert text equivalent of smilies to images.
+ *
+ * Will only convert smilies if the option 'use_smilies' is true and the globals
+ * used in the function aren't empty.
+ *
+ * @since 0.71
+ * @uses $wp_smiliessearch, $wp_smiliesreplace Smiley replacement arrays.
+ *
+ * @param string $text Content to convert smilies from text.
+ * @return string Converted content with text smilies replaced with images.
+ */
function convert_smilies($text) {
global $wp_smiliessearch, $wp_smiliesreplace;
- $output = '';
+ $output = '';
if ( get_option('use_smilies') && !empty($wp_smiliessearch) && !empty($wp_smiliesreplace) ) {
// HTML loop taken from texturize function, could possible be consolidated
$textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between
return $output;
}
-
+/**
+ * Checks to see if the text is a valid email address.
+ *
+ * @since 0.71
+ *
+ * @param string $user_email The email address to be checked.
+ * @return bool Returns true if valid, otherwise false.
+ */
function is_email($user_email) {
$chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i";
if (strpos($user_email, '@') !== false && strpos($user_email, '.') !== false) {
}
}
-// used by wp-mail to handle charsets in email subjects
+/**
+ * Convert to ASCII from email subjects.
+ *
+ * @since 1.2.0
+ * @usedby wp_mail() handles charsets in email subjects
+ *
+ * @param string $string Subject line
+ * @return string Converted string to ASCII
+ */
function wp_iso_descrambler($string) {
- /* this may only work with iso-8859-1, I'm afraid */
- if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
- return $string;
- } else {
- $subject = str_replace('_', ' ', $matches[2]);
- $subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject);
- return $subject;
- }
+ /* this may only work with iso-8859-1, I'm afraid */
+ if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
+ return $string;
+ } else {
+ $subject = str_replace('_', ' ', $matches[2]);
+ $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', create_function('$match', 'return chr(hexdec(strtolower($match[1])));'), $subject);
+ return $subject;
+ }
}
-
-// give it a date, it will give you the same date as GMT
+/**
+ * Returns a date in the GMT equivalent.
+ *
+ * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the
+ * value of the 'gmt_offset' option.
+ *
+ * @since 1.2.0
+ *
+ * @uses get_option() to retrieve the the value of 'gmt_offset'.
+ * @param string $string The date to be converted.
+ * @return string GMT version of the date provided.
+ */
function get_gmt_from_date($string) {
- // note: this only substracts $time_difference from the given date
- preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
- $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
- $string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_option('gmt_offset') * 3600);
- return $string_gmt;
+ preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
+ $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
+ $string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_option('gmt_offset') * 3600);
+ return $string_gmt;
}
-// give it a GMT date, it will give you the same date with $time_difference added
+/**
+ * Converts a GMT date into the correct format for the blog.
+ *
+ * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of
+ * gmt_offset.
+ *
+ * @since 1.2.0
+ *
+ * @param string $string The date to be converted.
+ * @return string Formatted date relative to the GMT offset.
+ */
function get_date_from_gmt($string) {
- // note: this only adds $time_difference to the given date
- preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
- $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
- $string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_option('gmt_offset')*3600);
- return $string_localtime;
+ preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
+ $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
+ $string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_option('gmt_offset')*3600);
+ return $string_localtime;
}
-// computes an offset in seconds from an iso8601 timezone
+/**
+ * Computes an offset in seconds from an iso8601 timezone.
+ *
+ * @since 1.5.0
+ *
+ * @param string $timezone Either 'Z' for 0 offset or '±hhmm'.
+ * @return int|float The offset in seconds.
+ */
function iso8601_timezone_to_offset($timezone) {
- // $timezone is either 'Z' or '[+|-]hhmm'
- if ($timezone == 'Z') {
- $offset = 0;
- } else {
- $sign = (substr($timezone, 0, 1) == '+') ? 1 : -1;
- $hours = intval(substr($timezone, 1, 2));
- $minutes = intval(substr($timezone, 3, 4)) / 60;
- $offset = $sign * 3600 * ($hours + $minutes);
- }
- return $offset;
-}
-
-// converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]
-function iso8601_to_datetime($date_string, $timezone = USER) {
- if ($timezone == GMT) {
- preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);
- if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
- $offset = iso8601_timezone_to_offset($date_bits[7]);
- } else { // we don't have a timezone, so we assume user local timezone (not server's!)
- $offset = 3600 * get_option('gmt_offset');
- }
- $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);
- $timestamp -= $offset;
- return gmdate('Y-m-d H:i:s', $timestamp);
- } elseif ($timezone == USER) {
- return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string);
- }
+ // $timezone is either 'Z' or '[+|-]hhmm'
+ if ($timezone == 'Z') {
+ $offset = 0;
+ } else {
+ $sign = (substr($timezone, 0, 1) == '+') ? 1 : -1;
+ $hours = intval(substr($timezone, 1, 2));
+ $minutes = intval(substr($timezone, 3, 4)) / 60;
+ $offset = $sign * 3600 * ($hours + $minutes);
+ }
+ return $offset;
}
+/**
+ * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt].
+ *
+ * @since 1.5.0
+ *
+ * @param string $date_string Date and time in ISO 8601 format {@link http://en.wikipedia.org/wiki/ISO_8601}.
+ * @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'.
+ * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s.
+ */
+function iso8601_to_datetime($date_string, $timezone = 'user') {
+ $timezone = strtolower($timezone);
+
+ if ($timezone == 'gmt') {
+
+ preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);
+
+ if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
+ $offset = iso8601_timezone_to_offset($date_bits[7]);
+ } else { // we don't have a timezone, so we assume user local timezone (not server's!)
+ $offset = 3600 * get_option('gmt_offset');
+ }
+
+ $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);
+ $timestamp -= $offset;
+
+ return gmdate('Y-m-d H:i:s', $timestamp);
+
+ } else if ($timezone == 'user') {
+ return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string);
+ }
+}
+
+/**
+ * Adds a element attributes to open links in new windows.
+ *
+ * Comment text in popup windows should be filtered through this. Right now it's
+ * a moderately dumb function, ideally it would detect whether a target or rel
+ * attribute was already there and adjust its actions accordingly.
+ *
+ * @since 0.71
+ *
+ * @param string $text Content to replace links to open in a new window.
+ * @return string Content that has filtered links.
+ */
function popuplinks($text) {
- // Comment text in popup windows should be filtered through this.
- // Right now it's a moderately dumb function, ideally it would detect whether
- // a target or rel attribute was already there and adjust its actions accordingly.
$text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
return $text;
}
+/**
+ * Strips out all characters that are not allowable in an email.
+ *
+ * @since 1.5.0
+ *
+ * @param string $email Email address to filter.
+ * @return string Filtered email address.
+ */
function sanitize_email($email) {
return preg_replace('/[^a-z0-9+_.@-]/i', '', $email);
}
+/**
+ * Determines the difference between two timestamps.
+ *
+ * The difference is returned in a human readable format such as "1 hour",
+ * "5 mins", "2 days".
+ *
+ * @since 1.5.0
+ *
+ * @param int $from Unix timestamp from which the difference begins.
+ * @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set.
+ * @return string Human readable time difference.
+ */
function human_time_diff( $from, $to = '' ) {
if ( empty($to) )
$to = time();
return $since;
}
-function wp_trim_excerpt($text) { // Fakes an excerpt if needed
+/**
+ * Generates an excerpt from the content, if needed.
+ *
+ * The excerpt word amount will be 55 words and if the amount is greater than
+ * that, then the string '[...]' will be appended to the excerpt. If the string
+ * is less than 55 words, then the content will be returned as is.
+ *
+ * @since 1.5.0
+ *
+ * @param string $text The exerpt. If set to empty an excerpt is generated.
+ * @return string The excerpt.
+ */
+function wp_trim_excerpt($text) {
if ( '' == $text ) {
$text = get_the_content('');
-
- $text = strip_shortcodes( $text );
-
+
+ $text = strip_shortcodes( $text );
+
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
- $excerpt_length = 55;
+ $excerpt_length = apply_filters('excerpt_length', 55);
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
return $text;
}
+/**
+ * Converts named entities into numbered entities.
+ *
+ * @since 1.5.1
+ *
+ * @param string $text The text within which entities will be converted.
+ * @return string Text with converted entities.
+ */
function ent2ncr($text) {
$to_ncr = array(
'"' => '"',
return str_replace( array_keys($to_ncr), array_values($to_ncr), $text );
}
+/**
+ * Formats text for the rich text editor.
+ *
+ * The filter 'richedit_pre' is applied here. If $text is empty the filter will
+ * be applied to an empty string.
+ *
+ * @since 2.0.0
+ *
+ * @param string $text The text to be formatted.
+ * @return string The formatted text after filter is applied.
+ */
function wp_richedit_pre($text) {
// Filtering a blank results in an annoying <br />\n
if ( empty($text) ) return apply_filters('richedit_pre', '');
return apply_filters('richedit_pre', $output);
}
+/**
+ * Formats text for the HTML editor.
+ *
+ * Unless $output is empty it will pass through htmlspecialchars before the
+ * 'htmledit_pre' filter is applied.
+ *
+ * @since 2.5.0
+ *
+ * @param string $output The text to be formatted.
+ * @return string Formatted text after filter applied.
+ */
function wp_htmledit_pre($output) {
if ( !empty($output) )
$output = htmlspecialchars($output, ENT_NOQUOTES); // convert only < > &
return apply_filters('htmledit_pre', $output);
}
+/**
+ * Checks and cleans a URL.
+ *
+ * A number of characters are removed from the URL. If the URL is for displaying
+ * (the default behaviour) amperstands are also replaced. The 'clean_url' filter
+ * is applied to the returned cleaned URL.
+ *
+ * @since 1.2.0
+ * @uses wp_kses_bad_protocol() To only permit protocols in the URL set
+ * via $protocols or the common ones set in the function.
+ *
+ * @param string $url The URL to be cleaned.
+ * @param array $protocols Optional. An array of acceptable protocols.
+ * Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set.
+ * @param string $context Optional. How the URL will be used. Default is 'display'.
+ * @return string The cleaned $url after the 'cleaned_url' filter is applied.
+ */
function clean_url( $url, $protocols = null, $context = 'display' ) {
$original_url = $url;
if ('' == $url) return $url;
- $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@()]|i', '', $url);
+ $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$*\'()\\x80-\\xff]|i', '', $url);
$strip = array('%0d', '%0a');
$url = str_replace($strip, '', $url);
$url = str_replace(';//', '://', $url);
/* If the URL doesn't appear to contain a scheme, we
* presume it needs http:// appended (unless a relative
* link starting with / or a php file).
- */
+ */
if ( strpos($url, ':') === false &&
substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )
$url = 'http://' . $url;
- // Replace ampersands ony when displaying.
- if ( 'display' == $context )
+ // Replace ampersands and single quotes only when displaying.
+ if ( 'display' == $context ) {
$url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url);
+ $url = str_replace( "'", ''', $url );
+ }
if ( !is_array($protocols) )
$protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet');
return apply_filters('clean_url', $url, $original_url, $context);
}
+/**
+ * Performs clean_url() for database usage.
+ *
+ * @see clean_url()
+ *
+ * @since 2.3.1
+ *
+ * @param string $url The URL to be cleaned.
+ * @param array $protocols An array of acceptable protocols.
+ * @return string The cleaned URL.
+ */
function sanitize_url( $url, $protocols = null ) {
- return clean_url( $url, $protocols, 'db');
+ return clean_url( $url, $protocols, 'db' );
}
-// Borrowed from the PHP Manual user notes. Convert entities, while
-// preserving already-encoded entities:
+/**
+ * Convert entities, while preserving already-encoded entities.
+ *
+ * @link http://www.php.net/htmlentities Borrowed from the PHP Manual user notes.
+ *
+ * @since 1.2.2
+ *
+ * @param string $myHTML The text to be converted.
+ * @return string Converted text.
+ */
function htmlentities2($myHTML) {
- $translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES);
+ $translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );
$translation_table[chr(38)] = '&';
- return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($myHTML, $translation_table));
+ return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", strtr($myHTML, $translation_table) );
}
-// Escape single quotes, specialchar double quotes, and fix line endings.
+/**
+ * Escape single quotes, specialchar double quotes, and fix line endings.
+ *
+ * The filter 'js_escape' is also applied here.
+ *
+ * @since 2.0.4
+ *
+ * @param string $text The text to be escaped.
+ * @return string Escaped text.
+ */
function js_escape($text) {
- $safe_text = wp_specialchars($text, 'double');
- $safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text));
- $safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text));
- return apply_filters('js_escape', $safe_text, $text);
+ $safe_text = wp_check_invalid_utf8( $text );
+ $safe_text = wp_specialchars( $safe_text, ENT_COMPAT );
+ $safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) );
+ $safe_text = preg_replace( "/\r?\n/", "\\n", addslashes( $safe_text ) );
+ return apply_filters( 'js_escape', $safe_text, $text );
}
-// Escaping for HTML attributes
-function attribute_escape($text) {
- $safe_text = wp_specialchars($text, true);
- return apply_filters('attribute_escape', $safe_text, $text);
+/**
+ * Escaping for HTML attributes.
+ *
+ * @since 2.0.6
+ *
+ * @param string $text
+ * @return string
+ */
+function attribute_escape( $text ) {
+ $safe_text = wp_check_invalid_utf8( $text );
+ $safe_text = wp_specialchars( $safe_text, ENT_QUOTES );
+ return apply_filters( 'attribute_escape', $safe_text, $text );
}
-// Escape a HTML tag name
+/**
+ * Escape a HTML tag name.
+ *
+ * @since 2.5.0
+ *
+ * @param string $tag_name
+ * @return string
+ */
function tag_escape($tag_name) {
- $safe_tag = strtolower( preg_replace('[^a-zA-Z_:]', '', $tag_name) );
+ $safe_tag = strtolower( preg_replace('/[^a-zA-Z_:]/', '', $tag_name) );
return apply_filters('tag_escape', $safe_tag, $tag_name);
}
/**
- * Escapes text for SQL LIKE special characters % and _
+ * Escapes text for SQL LIKE special characters % and _.
+ *
+ * @since 2.5.0
*
- * @param string text the text to be escaped
- * @return string text, safe for inclusion in LIKE query
+ * @param string $text The text to be escaped.
+ * @return string text, safe for inclusion in LIKE query.
*/
function like_escape($text) {
return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
}
+/**
+ * Convert full URL paths to absolute paths.
+ *
+ * Removes the http or https protocols and the domain. Keeps the path '/' at the
+ * beginning, so it isn't a true relative link, but from the web root base.
+ *
+ * @since 2.1.0
+ *
+ * @param string $link Full URL path.
+ * @return string Absolute path.
+ */
function wp_make_link_relative( $link ) {
- return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link );
+ return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link );
}
-function sanitize_option($option, $value) { // Remember to call stripslashes!
+/**
+ * Sanitises various option values based on the nature of the option.
+ *
+ * This is basically a switch statement which will pass $value through a number
+ * of functions depending on the $option.
+ *
+ * @since 2.0.5
+ *
+ * @param string $option The name of the option.
+ * @param string $value The unsanitised value.
+ * @return string Sanitized value.
+ */
+function sanitize_option($option, $value) {
switch ($option) {
case 'admin_email':
$value = sanitize_email($value);
break;
+ case 'thumbnail_size_w':
+ case 'thumbnail_size_h':
+ case 'medium_size_w':
+ case 'medium_size_h':
+ case 'large_size_w':
+ case 'large_size_h':
case 'default_post_edit_rows':
case 'mailserver_port':
case 'comment_max_links':
case 'default_category':
case 'default_email_category':
case 'default_link_category':
+ case 'close_comments_days_old':
+ case 'comments_per_page':
+ case 'thread_comments_depth':
$value = abs((int) $value);
break;
return $value;
}
+/**
+ * Parses a string into variables to be stored in an array.
+ *
+ * Uses {@link http://www.php.net/parse_str parse_str()} and stripslashes if
+ * {@link http://www.php.net/magic_quotes magic_quotes_gpc} is on.
+ *
+ * @since 2.2.1
+ * @uses apply_filters() for the 'wp_parse_str' filter.
+ *
+ * @param string $string The string to be parsed.
+ * @param array $array Variables will be stored in this array.
+ */
function wp_parse_str( $string, &$array ) {
parse_str( $string, $array );
if ( get_magic_quotes_gpc() )
- $array = stripslashes_deep( $array ); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str
+ $array = stripslashes_deep( $array );
$array = apply_filters( 'wp_parse_str', $array );
}
-// Convert lone less than signs. KSES already converts lone greater than signs.
+/**
+ * Convert lone less than signs.
+ *
+ * KSES already converts lone greater than signs.
+ *
+ * @uses wp_pre_kses_less_than_callback in the callback function.
+ * @since 2.3.0
+ *
+ * @param string $text Text to be converted.
+ * @return string Converted text.
+ */
function wp_pre_kses_less_than( $text ) {
return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text);
}
+/**
+ * Callback function used by preg_replace.
+ *
+ * @uses wp_specialchars to format the $matches text.
+ * @since 2.3.0
+ *
+ * @param array $matches Populated by matches to preg_replace.
+ * @return string The text returned after wp_specialchars if needed.
+ */
function wp_pre_kses_less_than_callback( $matches ) {
if ( false === strpos($matches[0], '>') )
return wp_specialchars($matches[0]);
}
/**
- * wp_sprintf() - sprintf() with filters
+ * WordPress implementation of PHP sprintf() with filters.
+ *
+ * @since 2.5.0
+ * @link http://www.php.net/sprintf
+ *
+ * @param string $pattern The string which formatted args are inserted.
+ * @param mixed $args,... Arguments to be formatted into the $pattern string.
+ * @return string The formatted string.
*/
function wp_sprintf( $pattern ) {
$args = func_get_args( );
}
/**
- * wp_sprintf_l - List specifier %l for wp_sprintf
+ * Localize list items before the rest of the content.
+ *
+ * The '%l' must be at the first characters can then contain the rest of the
+ * content. The list items will have ', ', ', and', and ' and ' added depending
+ * on the amount of list items in the $args parameter.
*
- * @param unknown_type $pattern
- * @param unknown_type $args
- * @return unknown
+ * @since 2.5.0
+ *
+ * @param string $pattern Content containing '%l' at the beginning.
+ * @param array $args List items to prepend to the content and replace '%l'.
+ * @return string Localized list items and rest of the content.
*/
function wp_sprintf_l($pattern, $args) {
// Not a match
if ( count($args) == 1 )
$result .= $l['between_only_two'] . array_shift($args);
// Loop when more than two args
- while ( count($args) ) {
+ $i = count($args);
+ while ( $i ) {
$arg = array_shift($args);
+ $i--;
if ( $i == 1 )
$result .= $l['between_last_two'] . $arg;
else
}
/**
- * Safely extracts not more than the first $count characters from html string
+ * Safely extracts not more than the first $count characters from html string.
+ *
+ * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT*
+ * be counted as one character. For example & will be counted as 4, < as
+ * 3, etc.
*
- * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT* be
- * counted as one character. For example & will be counted as 4, < as 3, etc.
+ * @since 2.5.0
*
- * @param integer $str String to get the excerpt from
- * @param integer $count Maximum number of characters to take
- * @eaturn string the excerpt
+ * @param integer $str String to get the excerpt from.
+ * @param integer $count Maximum number of characters to take.
+ * @return string The excerpt.
*/
function wp_html_excerpt( $str, $count ) {
$str = strip_tags( $str );
return $str;
}
+/**
+ * Add a Base url to relative links in passed content.
+ *
+ * By default it supports the 'src' and 'href' attributes. However this can be
+ * changed via the 3rd param.
+ *
+ * @since 2.7.0
+ *
+ * @param string $content String to search for links in.
+ * @param string $base The base URL to prefix to links.
+ * @param array $attrs The attributes which should be processed.
+ * @return string The processed content.
+ */
+function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) {
+ $attrs = implode('|', (array)$attrs);
+ return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i",
+ create_function('$m', 'return _links_add_base($m, "' . $base . '");'),
+ $content);
+}
+
+/**
+ * Callback to add a base url to relative links in passed content.
+ *
+ * @since 2.7.0
+ * @access private
+ *
+ * @param string $m The matched link.
+ * @param string $base The base URL to prefix to links.
+ * @return string The processed link.
+ */
+function _links_add_base($m, $base) {
+ //1 = attribute name 2 = quotation mark 3 = URL
+ return $m[1] . '=' . $m[2] .
+ (strpos($m[3], 'http://') === false ?
+ path_join($base, $m[3]) :
+ $m[3])
+ . $m[2];
+}
+
+/**
+ * Adds a Target attribute to all links in passed content.
+ *
+ * This function by default only applies to <a> tags, however this can be
+ * modified by the 3rd param.
+ *
+ * <b>NOTE:</b> Any current target attributed will be striped and replaced.
+ *
+ * @since 2.7.0
+ *
+ * @param string $content String to search for links in.
+ * @param string $target The Target to add to the links.
+ * @param array $tags An array of tags to apply to.
+ * @return string The processed content.
+ */
+function links_add_target( $content, $target = '_blank', $tags = array('a') ) {
+ $tags = implode('|', (array)$tags);
+ return preg_replace_callback("!<($tags)(.+?)>!i",
+ create_function('$m', 'return _links_add_target($m, "' . $target . '");'),
+ $content);
+}
+/**
+ * Callback to add a target attribute to all links in passed content.
+ *
+ * @since 2.7.0
+ * @access private
+ *
+ * @param string $m The matched link.
+ * @param string $target The Target to add to the links.
+ * @return string The processed link.
+ */
+function _links_add_target( $m, $target ) {
+ $tag = $m[1];
+ $link = preg_replace('|(target=[\'"](.*?)[\'"])|i', '', $m[2]);
+ return '<' . $tag . $link . ' target="' . $target . '">';
+}
+
+// normalize EOL characters and strip duplicate whitespace
+function normalize_whitespace( $str ) {
+ $str = trim($str);
+ $str = str_replace("\r", "\n", $str);
+ $str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str );
+ return $str;
+}
+
?>
* The 'mysql' type will return the time in the format for MySQL DATETIME field.
* The 'timestamp' type will return the current timestamp.
*
- * If the $gmt is set to either '1' or 'true', then both types will use the
- * GMT offset in the WordPress option to add the GMT offset to the time.
+ * If $gmt is set to either '1' or 'true', then both types will use GMT time.
+ * if $gmt is false, the output is adjusted with the GMT offset in the WordPress option.
*
* @since 1.0.0
*
* @param string $type Either 'mysql' or 'timestamp'.
- * @param int|bool $gmt Optional. Whether to use $gmt offset. Default is false.
- * @return unknown
+ * @param int|bool $gmt Optional. Whether to use GMT timezone. Default is false.
+ * @return int|string String if $type is 'gmt', int if $type is 'timestamp'.
*/
function current_time( $type, $gmt = 0 ) {
switch ( $type ) {
* @param int $unixtimestamp Unix timestamp
* @return string The date, translated if locale specifies it.
*/
-function date_i18n( $dateformatstring, $unixtimestamp ) {
+function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
global $wp_locale;
$i = $unixtimestamp;
// Sanity check for PHP 5.1.0-
- if ( -1 == $i )
- $i = false;
-
+ if ( false === $i || intval($i) < 0 ) {
+ if ( ! $gmt )
+ $i = current_time( 'timestamp' );
+ else
+ $i = time();
+ // we should not let date() interfere with our
+ // specially computed timestamp
+ $gmt = true;
+ }
+
+ $datefunc = $gmt? 'gmdate' : 'date';
+
if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) {
- $datemonth = $wp_locale->get_month( date( 'm', $i ) );
+ $datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) );
$datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );
- $dateweekday = $wp_locale->get_weekday( date( 'w', $i ) );
+ $dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) );
$dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );
- $datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) );
- $datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) );
+ $datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) );
+ $datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) );
$dateformatstring = ' '.$dateformatstring;
$dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring );
$dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring );
$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
}
- $j = @date( $dateformatstring, $i );
+ $j = @$datefunc( $dateformatstring, $i );
return $j;
}
*
* @param int|string $bytes Number of bytes. Note max integer size for integers.
* @param int $decimals Precision of number of decimal places.
- * @return unknown
+ * @return bool|string False on failure. Number string on success.
*/
function size_format( $bytes, $decimals = null ) {
$quant = array(
return false;
}
-
+/**
+ * Get the week start and end from the datetime or date string from mysql.
+ *
+ * @since 0.71
+ *
+ * @param string $mysqlstring Date or datetime field type from mysql.
+ * @param int $start_of_week Optional. Start of the week as an integer.
+ * @return array Keys are 'start' and 'end'.
+ */
function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
- $my = substr( $mysqlstring, 0, 4 );
- $mm = substr( $mysqlstring, 8, 2 );
- $md = substr( $mysqlstring, 5, 2 );
- $day = mktime( 0, 0, 0, $md, $mm, $my );
- $weekday = date( 'w', $day );
- $i = 86400;
+ $my = substr( $mysqlstring, 0, 4 ); // Mysql string Year
+ $mm = substr( $mysqlstring, 8, 2 ); // Mysql string Month
+ $md = substr( $mysqlstring, 5, 2 ); // Mysql string day
+ $day = mktime( 0, 0, 0, $md, $mm, $my ); // The timestamp for mysqlstring day.
+ $weekday = date( 'w', $day ); // The day of the week from the timestamp
+ $i = 86400; // One day
if( !is_numeric($start_of_week) )
$start_of_week = get_option( 'start_of_week' );
* There is a second filter called 'option_$option' with the $option being
* replaced with the option name. This gives the value as the only parameter.
*
+ * If the option was serialized, when the option was added and, or updated, then
+ * it will be unserialized, when it is returned.
+ *
* @since 1.5.0
* @package WordPress
* @subpackage Option
* @param string $setting Name of option to retrieve. Should already be SQL-escaped
* @return mixed Value set for the option.
*/
-function get_option( $setting ) {
+function get_option( $setting, $default = false ) {
global $wpdb;
// Allow plugins to short-circuit options.
// prevent non-existent options from triggering multiple queries
$notoptions = wp_cache_get( 'notoptions', 'options' );
if ( isset( $notoptions[$setting] ) )
- return false;
+ return $default;
$alloptions = wp_load_alloptions();
} else { // option does not exist, so we must cache its non-existence
$notoptions[$setting] = true;
wp_cache_set( 'notoptions', $notoptions, 'options' );
- return false;
+ return $default;
}
}
}
/**
* Protect WordPress special option from being modified.
*
- * Will die if $option is in protected list.
+ * Will die if $option is in protected list. Protected options are 'alloptions'
+ * and 'notoptions' options.
*
* @since 2.2.0
* @package WordPress
/**
* Retrieve all autoload options or all options, if no autoloaded ones exist.
*
- * This is different from wp_load_alloptions(), in this that function does not
- * cache all options and will retrieve all options from the database every time
+ * This is different from wp_load_alloptions() in that this function does not
+ * cache its results and will retrieve all options from the database every time
+ *
* it is called.
*
* @since 1.0.0
* @return array List of all options.
*/
function get_alloptions() {
- global $wpdb, $wp_queries;
+ global $wpdb;
$show = $wpdb->hide_errors();
if ( !$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
$wpdb->show_errors($show);
- foreach ( $options as $option ) {
+ foreach ( (array) $options as $option ) {
// "When trying to design a foolproof system,
// never underestimate the ingenuity of the fools :)" -- Dougal
if ( in_array( $option->option_name, array( 'siteurl', 'home', 'category_base', 'tag_base' ) ) )
/**
* Update the value of an option that was already added.
*
+ * You do not need to serialize values, if the value needs to be serialize, then
+ * it will be serialized before it is inserted into the database. Remember,
+ * resources can not be serialized or added as an option.
+ *
* If the option does not exist, then the option will be added with the option
* value, but you will not be able to set whether it is autoloaded. If you want
* to set whether an option autoloaded, then you need to use the add_option().
/**
* Add a new option.
*
+ * You do not need to serialize values, if the value needs to be serialize, then
+ * it will be serialized before it is inserted into the database. Remember,
+ * resources can not be serialized or added as an option.
+ *
* You can create options without values and then add values later. Does not
* check whether the option has already been added, but does check that you
* aren't adding a protected WordPress option. Care should be taken to not name
*
* @package WordPress
* @subpackage Option
- * @since unknown
+ * @since 1.2.0
*
* @param string $name Option name to remove.
* @return bool True, if succeed. False, if failure.
return true;
}
+/**
+ * Saves and restores user interface settings stored in a cookie.
+ *
+ * Checks if the current user-settings cookie is updated and stores it. When no
+ * cookie exists (different browser used), adds the last saved cookie restoring
+ * the settings.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.7.0
+ */
+function wp_user_settings() {
+
+ if ( ! is_admin() )
+ return;
+
+ if ( defined('DOING_AJAX') )
+ return;
+
+ if ( ! $user = wp_get_current_user() )
+ return;
+
+ $settings = get_user_option( 'user-settings', $user->ID, false );
+
+ if ( isset( $_COOKIE['wp-settings-' . $user->ID] ) ) {
+ $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user->ID] );
+
+ if ( ! empty( $cookie ) && strpos( $cookie, '=' ) ) {
+ if ( $cookie == $settings )
+ return;
+
+ $last_time = (int) get_user_option( 'user-settings-time', $user->ID, false );
+ $saved = isset( $_COOKIE['wp-settings-time-' . $user->ID]) ? preg_replace( '/[^0-9]/', '', $_COOKIE['wp-settings-time-' . $user->ID] ) : 0;
+
+ if ( $saved > $last_time ) {
+ update_user_option( $user->ID, 'user-settings', $cookie, false );
+ update_user_option( $user->ID, 'user-settings-time', time() - 5, false );
+ return;
+ }
+ }
+ }
+
+ setcookie( 'wp-settings-' . $user->ID, $settings, time() + 31536000, SITECOOKIEPATH );
+ setcookie( 'wp-settings-time-' . $user->ID, time(), time() + 31536000, SITECOOKIEPATH );
+}
+
+/**
+ * Retrieve user interface setting value based on setting name.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.7.0
+ *
+ * @param string $name The name of the setting.
+ * @param string $default Optional default value to return when $name is not set.
+ * @return mixed the last saved user setting or the default value/false if it doesn't exist.
+ */
+function get_user_setting( $name, $default = false ) {
+
+ $arr = get_all_user_settings();
+
+ return isset($arr[$name]) ? $arr[$name] : $default;
+}
+
+/**
+ * Delete user interface settings.
+ *
+ * Deleting settings would reset them to the defaults.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.7.0
+ *
+ * @param mixed $names The name or array of names of the setting to be deleted.
+ */
+function delete_user_setting( $names ) {
+ global $current_user;
+
+ $arr = get_all_user_settings();
+ $names = (array) $names;
+
+ foreach ( $names as $name ) {
+ if ( isset($arr[$name]) ) {
+ unset($arr[$name]);
+ $settings = '';
+ }
+ }
+
+ if ( isset($settings) ) {
+ foreach ( $arr as $k => $v )
+ $settings .= $k . '=' . $v . '&';
+
+ $settings = rtrim($settings, '&');
+
+ update_user_option( $current_user->ID, 'user-settings', $settings );
+ setcookie('wp-settings-'.$current_user->ID, $settings, time() + 31536000, SITECOOKIEPATH);
+ }
+}
+
+/**
+ * Retrieve all user interface settings.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.7.0
+ *
+ * @return array the last saved user settings or empty array.
+ */
+function get_all_user_settings() {
+ if ( ! $user = wp_get_current_user() )
+ return array();
+
+ if ( isset($_COOKIE['wp-settings-'.$user->ID]) ) {
+ $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-'.$user->ID] );
+
+ if ( $cookie && strpos($cookie, '=') ) { // the '=' cannot be 1st char
+ parse_str($cookie, $arr);
+ return $arr;
+ }
+ }
+
+ return array();
+}
+
+/**
+ * Delete the user settings of the current user.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.7.0
+ */
+function delete_all_user_settings() {
+ if ( ! $user = wp_get_current_user() )
+ return;
+
+ delete_usermeta( $user->ID, 'user-settings' );
+ setcookie('wp-settings-'.$user->ID, ' ', time() - 31536000, SITECOOKIEPATH);
+}
+
/**
* Serialize data, if needed.
*
+ * @since 2.0.5
+ *
* @param mixed $data Data that might be serialized.
* @return mixed A scalar data
*/
return $data;
}
-
+/**
+ * Strip HTML and put links at the bottom of stripped content.
+ *
+ * Searches for all of the links, strips them out of the content, and places
+ * them at the bottom of the content with numbers.
+ *
+ * @since 0.71
+ *
+ * @param string $content Content to get links
+ * @return string HTML stripped out of content with links at the bottom.
+ */
function make_url_footnote( $content ) {
preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches );
- $j = 0;
+ $links_summary = "\n";
for ( $i=0; $i<count($matches[0]); $i++ ) {
- $links_summary = ( !$j ) ? "\n" : $links_summary;
- $j++;
$link_match = $matches[0][$i];
$link_number = '['.($i+1).']';
$link_url = $matches[2][$i];
return $content;
}
-
+/**
+ * Retrieve post title from XMLRPC XML.
+ *
+ * If the title element is not part of the XML, then the default post title from
+ * the $post_default_title will be used instead.
+ *
+ * @package WordPress
+ * @subpackage XMLRPC
+ * @since 0.71
+ *
+ * @global string $post_default_title Default XMLRPC post title.
+ *
+ * @param string $content XMLRPC XML Request content
+ * @return string Post title
+ */
function xmlrpc_getposttitle( $content ) {
global $post_default_title;
if ( preg_match( '/<title>(.+?)<\/title>/is', $content, $matchtitle ) ) {
return $post_title;
}
-
+/**
+ * Retrieve the post category or categories from XMLRPC XML.
+ *
+ * If the category element is not found, then the default post category will be
+ * used. The return type then would be what $post_default_category. If the
+ * category is found, then it will always be an array.
+ *
+ * @package WordPress
+ * @subpackage XMLRPC
+ * @since 0.71
+ *
+ * @global string $post_default_category Default XMLRPC post category.
+ *
+ * @param string $content XMLRPC XML Request content
+ * @return string|array List of categories or category name.
+ */
function xmlrpc_getpostcategory( $content ) {
global $post_default_category;
if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) {
return $post_category;
}
-
+/**
+ * XMLRPC XML content without title and category elements.
+ *
+ * @package WordPress
+ * @subpackage XMLRPC
+ * @since 0.71
+ *
+ * @param string $content XMLRPC XML Request content
+ * @return string XMLRPC XML Request content without title and category elements.
+ */
function xmlrpc_removepostdata( $content ) {
$content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content );
$content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content );
* @see fopen() for mode options.
* @package WordPress
* @subpackage Debug
- * @since unknown
+ * @since 0.71
* @uses $debug Used for whether debugging is enabled.
*
* @param string $filename File path to debug file.
*
* @package WordPress
* @subpackage Debug
- * @since unknown
+ * @since 0.71
* @uses $debug Used for whether debugging is enabled.
*
* @param resource $fp File handle for debugging file.
*
* @package WordPress
* @subpackage Debug
- * @since unknown
+ * @since 0.71
* @uses $debug Used for whether debugging is enabled.
*
* @param resource $fp Debug File handle.
fclose( $fp );
}
+/**
+ * Check content for video and audio links to add as enclosures.
+ *
+ * Will not add enclosures that have already been added. This is called as
+ * pingbacks and trackbacks.
+ *
+ * @package WordPress
+ * @since 1.5.0
+ *
+ * @uses $wpdb
+ *
+ * @param string $content Post Content
+ * @param int $post_ID Post ID
+ */
function do_enclose( $content, $post_ID ) {
global $wpdb;
include_once( ABSPATH . WPINC . '/class-IXR.php' );
debug_fwrite( $log, 'Post contents:' );
debug_fwrite( $log, $content . "\n" );
- foreach ( $post_links_temp[0] as $link_test ) {
+ foreach ( (array) $post_links_temp[0] as $link_test ) {
if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
$test = parse_url( $link_test );
if ( isset( $test['query'] ) )
}
}
- foreach ( $post_links as $url ) {
+ foreach ( (array) $post_links as $url ) {
if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%' ) ) ) {
if ( $headers = wp_get_http_headers( $url) ) {
$len = (int) $headers['content-length'];
* If $file_path is a writable filename, this will do a GET request and write
* the file to that path.
*
- * @since unknown
+ * @since 2.5.0
*
- * @param string $url
+ * @param string $url URL to fetch.
* @param string|bool $file_path Optional. File path to write request to.
- * @param int $red Optional. Number of Redirects. Stops at 5 redirects.
+ * @param bool $deprecated Deprecated. Not used.
* @return bool|string False on failure and string of headers if HEAD request.
*/
-function wp_get_http( $url, $file_path = false, $red = 1 ) {
- global $wp_version;
+function wp_get_http( $url, $file_path = false, $deprecated = false ) {
@set_time_limit( 60 );
- if ( $red > 5 )
- return false;
-
- $parts = parse_url( $url );
- $file = $parts['path'] . ( ( $parts['query'] ) ? '?' . $parts['query'] : '' );
- $host = $parts['host'];
- if ( !isset( $parts['port'] ) )
- $parts['port'] = 80;
+ $options = array();
+ $options['redirection'] = 5;
- if ( $file_path )
- $request_type = 'GET';
+ if ( false == $file_path )
+ $options['method'] = 'HEAD';
else
- $request_type = 'HEAD';
+ $options['method'] = 'GET';
- $head = "$request_type $file HTTP/1.1\r\nHOST: $host\r\nUser-Agent: WordPress/" . $wp_version . "\r\n\r\n";
+ $response = wp_remote_request($url, $options);
- $fp = @fsockopen( $host, $parts['port'], $err_num, $err_msg, 3 );
- if ( !$fp )
+ if ( is_wp_error( $response ) )
return false;
- $response = '';
- fputs( $fp, $head );
- while ( !feof( $fp ) && strpos( $response, "\r\n\r\n" ) == false )
- $response .= fgets( $fp, 2048 );
- preg_match_all( '/(.*?): (.*)\r/', $response, $matches );
- $count = count( $matches[1] );
- for ( $i = 0; $i < $count; $i++ ) {
- $key = strtolower( $matches[1][$i] );
- $headers["$key"] = $matches[2][$i];
- }
-
- preg_match( '/.*([0-9]{3}).*/', $response, $return );
- $headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404
-
- $code = $headers['response'];
- if ( ( '302' == $code || '301' == $code ) && isset( $headers['location'] ) ) {
- fclose($fp);
- return wp_get_http( $headers['location'], $file_path, ++$red );
- }
-
- // make a note of the final location, so the caller can tell if we were redirected or not
- $headers['x-final-location'] = $url;
+ $headers = wp_remote_retrieve_headers( $response );
+ $headers['response'] = $response['response']['code'];
- // HEAD request only
- if ( !$file_path ) {
- fclose($fp);
+ if ( false == $file_path )
return $headers;
- }
- // GET request - fetch and write it to the supplied filename
- $content_length = $headers['content-length'];
- $got_bytes = 0;
+ // GET request - write it to the supplied filename
$out_fp = fopen($file_path, 'w');
- while ( !feof($fp) ) {
- $buf = fread( $fp, 4096 );
- fwrite( $out_fp, $buf );
- $got_bytes += strlen($buf);
- // don't read past the content-length
- if ($content_length and $got_bytes >= $content_length)
- break;
- }
+ if ( !$out_fp )
+ return $headers;
+ fwrite( $out_fp, $response['body']);
fclose($out_fp);
- fclose($fp);
+
return $headers;
}
* @since 1.5.1
*
* @param string $url
- * @param int $red Optional. Number of redirects.
+ * @param bool $deprecated Not Used.
* @return bool|string False on failure, headers on success.
*/
-function wp_get_http_headers( $url, $red = 1 ) {
- return wp_get_http( $url, false, $red );
+function wp_get_http_headers( $url, $deprecated = false ) {
+ $response = wp_remote_head( $url );
+
+ if ( is_wp_error( $response ) )
+ return false;
+
+ return wp_remote_retrieve_headers( $response );
}
/**
* Whether today is a new day.
*
- * {@internal Need to find out how this function is used.}}
- *
* @since 0.71
* @uses $day Today
* @uses $previousday Previous day
* @link http://us2.php.net/manual/en/function.http-build-query.php more on what
* http_build_query() does.
*
- * @since unknown
+ * @since 2.3.0
*
* @param array $data URL-encode key/value pairs.
* @return string URL encoded string
*/
function build_query( $data ) {
- return _http_build_query( $data, NULL, '&', '', false );
+ return _http_build_query( $data, null, '&', '', false );
}
/**
* @param mixed $param1 Either newkey or an associative_array
* @param mixed $param2 Either newvalue or oldquery or uri
* @param mixed $param3 Optional. Old query or uri
- * @return unknown
+ * @return string New URL query string.
*/
function add_query_arg() {
$ret = '';
$qs[func_get_arg( 0 )] = func_get_arg( 1 );
}
- foreach ( $qs as $k => $v ) {
+ foreach ( (array) $qs as $k => $v ) {
if ( $v === false )
unset( $qs[$k] );
}
*
* @param string|array $key Query key or keys to remove.
* @param bool $query When false uses the $_SERVER value.
- * @return unknown
+ * @return string New URL query string.
*/
function remove_query_arg( $key, $query=false ) {
if ( is_array( $key ) ) { // removing multiple keys
- foreach ( (array) $key as $k )
+ foreach ( $key as $k )
$query = add_query_arg( $k, false, $query );
return $query;
}
* Walks the array while sanitizing the contents.
*
* @uses $wpdb Used to sanitize values
+ * @since 0.71
*
* @param array $array Array to used to walk while sanitizing contents.
* @return array Sanitized $array.
function add_magic_quotes( $array ) {
global $wpdb;
- foreach ( $array as $k => $v ) {
+ foreach ( (array) $array as $k => $v ) {
if ( is_array( $v ) ) {
$array[$k] = add_magic_quotes( $v );
} else {
/**
* HTTP request for URI to retrieve content.
*
- * Tries to retrieve the HTTP content with fopen first and then using cURL, if
- * fopen can't be used.
- *
- * @since unknown
+ * @since 1.5.1
+ * @uses wp_remote_get()
*
* @param string $uri URI/URL of web page to retrieve.
- * @return string HTTP content.
+ * @return bool|string HTTP content. False on failure.
*/
function wp_remote_fopen( $uri ) {
- $timeout = 10;
$parsed_url = @parse_url( $uri );
if ( !$parsed_url || !is_array( $parsed_url ) )
return false;
- if ( !isset( $parsed_url['scheme'] ) || !in_array( $parsed_url['scheme'], array( 'http','https' ) ) )
- $uri = 'http://' . $uri;
+ $options = array();
+ $options['timeout'] = 10;
- if ( ini_get( 'allow_url_fopen' ) ) {
- $fp = @fopen( $uri, 'r' );
- if ( !$fp )
- return false;
+ $response = wp_remote_get( $uri, $options );
- //stream_set_timeout($fp, $timeout); // Requires php 4.3
- $linea = '';
- while ( $remote_read = fread( $fp, 4096 ) )
- $linea .= $remote_read;
- fclose( $fp );
- return $linea;
- } elseif ( function_exists( 'curl_init' ) ) {
- $handle = curl_init();
- curl_setopt( $handle, CURLOPT_URL, $uri);
- curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 );
- curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 );
- curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout );
- $buffer = curl_exec( $handle );
- curl_close( $handle );
- return $buffer;
- } else {
+ if ( is_wp_error( $response ) )
return false;
- }
-}
+ return $response['body'];
+}
+/**
+ * Setup the WordPress query.
+ *
+ * @since 2.0.0
+ *
+ * @param string $query_vars Default WP_Query arguments.
+ */
function wp( $query_vars = '' ) {
global $wp, $wp_query, $wp_the_query;
$wp->main( $query_vars );
/**
* Set HTTP status header.
*
- * @since unknown
+ * @since 2.0.0
* @uses apply_filters() Calls 'status_header' on status header string, HTTP
* HTTP code, HTTP code description, and protocol string as separate
* parameters.
return ( strtolower( $yn ) == 'y' );
}
-
+/**
+ * Loads the feed template from the use of an action hook.
+ *
+ * If the feed action does not have a hook, then the function will die with a
+ * message telling the visitor that the feed is not valid.
+ *
+ * It is better to only have one hook for each feed.
+ *
+ * @since 2.1.0
+ * @uses $wp_query Used to tell if the use a comment feed.
+ * @uses do_action() Calls 'do_feed_$feed' hook, if a hook exists for the feed.
+ */
function do_feed() {
global $wp_query;
}
}
-
+/**
+ * Test whether blog is already installed.
+ *
+ * The cache will be checked first. If you have a cache plugin, which saves the
+ * cache values, then this will work. If you use the default WordPress cache,
+ * and the database goes away, then you might have problems.
+ *
+ * Checks for the option siteurl for whether WordPress is installed.
+ *
+ * @since 2.1.0
+ * @uses $wpdb
+ *
+ * @return bool Whether blog is already installed.
+ */
function is_blog_installed() {
global $wpdb;
- // Check cache first. If options table goes away and we have true cached, oh well.
+ // Check cache first. If options table goes away and we have true cached, oh well.
if ( wp_cache_get('is_blog_installed') )
return true;
return $installed;
}
-
+/**
+ * Retrieve URL with nonce added to URL query.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param string $actionurl URL to add nonce action
+ * @param string $action Optional. Nonce action name
+ * @return string URL with nonce action added.
+ */
function wp_nonce_url( $actionurl, $action = -1 ) {
$actionurl = str_replace( '&', '&', $actionurl );
return wp_specialchars( add_query_arg( '_wpnonce', wp_create_nonce( $action ), $actionurl ) );
}
-
+/**
+ * Retrieve or display nonce hidden field for forms.
+ *
+ * The nonce field is used to validate that the contents of the form came from
+ * the location on the current site and not somewhere else. The nonce does not
+ * offer absolute protection, but should protect against most cases. It is very
+ * important to use nonce field in forms.
+ *
+ * If you set $echo to true and set $referer to true, then you will need to
+ * retrieve the {@link wp_referer_field() wp referer field}. If you have the
+ * $referer set to true and are echoing the nonce field, it will also echo the
+ * referer field.
+ *
+ * The $action and $name are optional, but if you want to have better security,
+ * it is strongly suggested to set those two parameters. It is easier to just
+ * call the function without any parameters, because validation of the nonce
+ * doesn't require any parameters, but since crackers know what the default is
+ * it won't be difficult for them to find a way around your nonce and cause
+ * damage.
+ *
+ * The input name will be whatever $name value you gave. The input value will be
+ * the nonce creation value.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param string $action Optional. Action name.
+ * @param string $name Optional. Nonce name.
+ * @param bool $referer Optional, default true. Whether to set the referer field for validation.
+ * @param bool $echo Optional, default true. Whether to display or return hidden form field.
+ * @return string Nonce field.
+ */
function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
$name = attribute_escape( $name );
$nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
if ( $echo )
echo $nonce_field;
-
+
if ( $referer )
wp_referer_field( $echo, 'previous' );
-
+
return $nonce_field;
}
-
+/**
+ * Retrieve or display referer hidden field for forms.
+ *
+ * The referer link is the current Request URI from the server super global. The
+ * input name is '_wp_http_referer', in case you wanted to check manually.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param bool $echo Whether to echo or return the referer field.
+ * @return string Referer field.
+ */
function wp_referer_field( $echo = true) {
$ref = attribute_escape( $_SERVER['REQUEST_URI'] );
$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />';
return $referer_field;
}
+/**
+ * Retrieve or display original referer hidden field for forms.
+ *
+ * The input name is '_wp_original_http_referer' and will be either the same
+ * value of {@link wp_referer_field()}, if that was posted already or it will
+ * be the current page, if it doesn't exist.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param bool $echo Whether to echo the original http referer
+ * @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to.
+ * @return string Original referer field.
+ */
function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
$jump_back_to = ( 'previous' == $jump_back_to ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
$ref = ( wp_get_original_referer() ) ? wp_get_original_referer() : $jump_back_to;
return $orig_referer_field;
}
-
+/**
+ * Retrieve referer from '_wp_http_referer', HTTP referer, or current page respectively.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @return string|bool False on failure. Referer URL on success.
+ */
function wp_get_referer() {
+ $ref = '';
if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
$ref = $_REQUEST['_wp_http_referer'];
else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
return false;
}
-
+/**
+ * Retrieve original referer that was posted, if it exists.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @return string|bool False if no original referer or original referer if set.
+ */
function wp_get_original_referer() {
if ( !empty( $_REQUEST['_wp_original_http_referer'] ) )
return $_REQUEST['_wp_original_http_referer'];
return false;
}
-
+/**
+ * Recursive directory creation based on full path.
+ *
+ * Will attempt to set permissions on folders.
+ *
+ * @since 2.0.1
+ *
+ * @param string $target Full path to attempt to create.
+ * @return bool Whether the path was created or not. True if path already exists.
+ */
function wp_mkdir_p( $target ) {
// from php.net/mkdir user contributed notes
$target = str_replace( '//', '/', $target );
}
// If the above failed, attempt to create the parent node, then try again.
- if ( wp_mkdir_p( dirname( $target ) ) )
+ if ( ( $target != '/' ) && ( wp_mkdir_p( dirname( $target ) ) ) )
return wp_mkdir_p( $target );
return false;
}
-// Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows')
+/**
+ * Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows').
+ *
+ * @since 2.5.0
+ *
+ * @param string $path File path
+ * @return bool True if path is absolute, false is not absolute.
+ */
function path_is_absolute( $path ) {
// this is definitive if true but fails if $path does not exist or contains a symbolic link
if ( realpath($path) == $path )
return (bool) preg_match('#^[/\\\\]#', $path);
}
-// Join two filesystem paths together (e.g. 'give me $path relative to $base')
+/**
+ * Join two filesystem paths together (e.g. 'give me $path relative to $base').
+ *
+ * If the $path is absolute, then it the full path is returned.
+ *
+ * @since 2.5.0
+ *
+ * @param string $base
+ * @param string $path
+ * @return string The path with the base or absolute path.
+ */
function path_join( $base, $path ) {
if ( path_is_absolute($path) )
return $path;
return rtrim($base, '/') . '/' . ltrim($path, '/');
}
-// Returns an array containing the current upload directory's path and url, or an error message.
-function wp_upload_dir( $time = NULL ) {
+/**
+ * Get an array containing the current upload directory's path and url.
+ *
+ * Checks the 'upload_path' option, which should be from the web root folder,
+ * and if it isn't empty it will be used. If it is empty, then the path will be
+ * 'WP_CONTENT_DIR/uploads'. If the 'UPLOADS' constant is defined, then it will
+ * override the 'upload_path' option and 'WP_CONTENT_DIR/uploads' path.
+ *
+ * The upload URL path is set either by the 'upload_url_path' option or by using
+ * the 'WP_CONTENT_URL' constant and appending '/uploads' to the path.
+ *
+ * If the 'uploads_use_yearmonth_folders' is set to true (checkbox if checked in
+ * the administration settings panel), then the time will be used. The format
+ * will be year first and then month.
+ *
+ * If the path couldn't be created, then an error will be returned with the key
+ * 'error' containing the error message. The error suggests that the parent
+ * directory is not writable by the server.
+ *
+ * On success, the returned array will have many indices:
+ * 'path' - base directory and sub directory or full path to upload directory.
+ * 'url' - base url and sub directory or absolute URL to upload directory.
+ * 'subdir' - sub directory if uploads use year/month folders option is on.
+ * 'basedir' - path without subdir.
+ * 'baseurl' - URL path without subdir.
+ * 'error' - set to false.
+ *
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'upload_dir' on returned array.
+ *
+ * @param string $time Optional. Time formatted in 'yyyy/mm'.
+ * @return array See above for description.
+ */
+function wp_upload_dir( $time = null ) {
$siteurl = get_option( 'siteurl' );
$upload_path = get_option( 'upload_path' );
$upload_path = trim($upload_path);
if ( empty($upload_path) )
$dir = WP_CONTENT_DIR . '/uploads';
- else
+ else
$dir = $upload_path;
// $dir is absolute, $path is (maybe) relative to ABSPATH
$dir = path_join( ABSPATH, $dir );
-
+
if ( !$url = get_option( 'upload_url_path' ) ) {
if ( empty($upload_path) or ( $upload_path == $dir ) )
$url = WP_CONTENT_URL . '/uploads';
$url = trailingslashit( $siteurl ) . UPLOADS;
}
- $bdir = $dir;
+ $bdir = $dir;
$burl = $url;
$subdir = '';
$message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $dir );
return array( 'error' => $message );
}
-
+
$uploads = array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $bdir, 'baseurl' => $burl, 'error' => false );
return apply_filters( 'upload_dir', $uploads );
}
-// return a filename that is sanitized and unique for the given directory
-function wp_unique_filename( $dir, $filename, $unique_filename_callback = NULL ) {
+/**
+ * Get a filename that is sanitized and unique for the given directory.
+ *
+ * If the filename is not unique, then a number will be added to the filename
+ * before the extension, and will continue adding numbers until the filename is
+ * unique.
+ *
+ * The callback must accept two parameters, the first one is the directory and
+ * the second is the filename. The callback must be a function.
+ *
+ * @since 2.5
+ *
+ * @param string $dir
+ * @param string $filename
+ * @param string $unique_filename_callback Function name, must be a function.
+ * @return string New filename, if given wasn't unique.
+ */
+function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) {
$filename = strtolower( $filename );
// separate the filename into a name and extension
$info = pathinfo($filename);
- $ext = $info['extension'];
+ $ext = !empty($info['extension']) ? $info['extension'] : '';
$name = basename($filename, ".{$ext}");
-
+
// edge case: if file is named '.ext', treat as an empty name
if( $name === ".$ext" )
$name = '';
} else {
$number = '';
- if ( empty( $ext ) )
- $ext = '';
- else
+ if ( !empty( $ext ) )
$ext = strtolower( ".$ext" );
$filename = str_replace( $ext, '', $filename );
return $filename;
}
-function wp_upload_bits( $name, $deprecated, $bits, $time = NULL ) {
+/**
+ * Create a file in the upload folder with given content.
+ *
+ * If there is an error, then the key 'error' will exist with the error message.
+ * If success, then the key 'file' will have the unique file path, the 'url' key
+ * will have the link to the new file. and the 'error' key will be set to false.
+ *
+ * This function will not move an uploaded file to the upload folder. It will
+ * create a new file with the content in $bits parameter. If you move the upload
+ * file, read the content of the uploaded file, and then you can give the
+ * filename and content to this function, which will add it to the upload
+ * folder.
+ *
+ * The permissions will be set on the new file automatically by this function.
+ *
+ * @since 2.0.0
+ *
+ * @param string $name
+ * @param null $deprecated Not used. Set to null.
+ * @param mixed $bits File content
+ * @param string $time Optional. Time formatted in 'yyyy/mm'.
+ * @return array
+ */
+function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
if ( empty( $name ) )
- return array( 'error' => __( "Empty filename" ) );
+ return array( 'error' => __( 'Empty filename' ) );
$wp_filetype = wp_check_filetype( $name );
if ( !$wp_filetype['ext'] )
- return array( 'error' => __( "Invalid file type" ) );
+ return array( 'error' => __( 'Invalid file type' ) );
$upload = wp_upload_dir( $time );
return array( 'file' => $new_file, 'url' => $url, 'error' => false );
}
+/**
+ * Retrieve the file type based on the extension name.
+ *
+ * @package WordPress
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'ext2type' hook on default supported types.
+ *
+ * @param string $ext The extension to search.
+ * @return string|null The file type, example: audio, video, document, spreadsheet, etc. Null if not found.
+ */
function wp_ext2type( $ext ) {
$ext2type = apply_filters('ext2type', array(
'audio' => array('aac','ac3','aif','aiff','mp1','mp2','mp3','m3a','m4a','m4b','ogg','ram','wav','wma'),
'video' => array('asf','avi','divx','dv','mov','mpg','mpeg','mp4','mpv','ogm','qt','rm','vob','wmv'),
- 'document' => array('doc','pages','odt','rtf','pdf'),
- 'spreadsheet' => array('xls','numbers','ods'),
- 'interactive' => array('ppt','key','odp','swf'),
+ 'document' => array('doc','docx','pages','odt','rtf','pdf'),
+ 'spreadsheet' => array('xls','xlsx','numbers','ods'),
+ 'interactive' => array('ppt','pptx','key','odp','swf'),
'text' => array('txt'),
'archive' => array('tar','bz2','gz','cab','dmg','rar','sea','sit','sqx','zip'),
'code' => array('css','html','php','js'),
return $type;
}
+/**
+ * Retrieve the file type from the file name.
+ *
+ * You can optionally define the mime array, if needed.
+ *
+ * @since 2.0.4
+ *
+ * @param string $filename File name or path.
+ * @param array $mimes Optional. Key is the file extension with value as the mime type.
+ * @return array Values with extension first and mime type.
+ */
function wp_check_filetype( $filename, $mimes = null ) {
// Accepted MIME types are set here as PCRE unless provided.
$mimes = ( is_array( $mimes ) ) ? $mimes : apply_filters( 'upload_mimes', array(
'ico' => 'image/x-icon',
'asf|asx|wax|wmv|wmx' => 'video/asf',
'avi' => 'video/avi',
+ 'divx' => 'video/divx',
'mov|qt' => 'video/quicktime',
'mpeg|mpg|mpe|mp4' => 'video/mpeg',
'txt|c|cc|h' => 'text/plain',
'rtf' => 'application/rtf',
'js' => 'application/javascript',
'pdf' => 'application/pdf',
- 'doc' => 'application/msword',
- 'pot|pps|ppt' => 'application/vnd.ms-powerpoint',
+ 'doc|docx' => 'application/msword',
+ 'pot|pps|ppt|pptx' => 'application/vnd.ms-powerpoint',
'wri' => 'application/vnd.ms-write',
- 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel',
+ 'xla|xls|xlsx|xlt|xlw' => 'application/vnd.ms-excel',
'mdb' => 'application/vnd.ms-access',
'mpp' => 'application/vnd.ms-project',
'swf' => 'application/x-shockwave-flash',
return compact( 'ext', 'type' );
}
+/**
+ * Retrieve nonce action "Are you sure" message.
+ *
+ * The action is split by verb and noun. The action format is as follows:
+ * verb-action_extra. The verb is before the first dash and has the format of
+ * letters and no spaces and numbers. The noun is after the dash and before the
+ * underscore, if an underscore exists. The noun is also only letters.
+ *
+ * The filter will be called for any action, which is not defined by WordPress.
+ * You may use the filter for your plugin to explain nonce actions to the user,
+ * when they get the "Are you sure?" message. The filter is in the format of
+ * 'explain_nonce_$verb-$noun' with the $verb replaced by the found verb and the
+ * $noun replaced by the found noun. The two parameters that are given to the
+ * hook are the localized "Are you sure you want to do this?" message with the
+ * extra text (the text after the underscore).
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param string $action Nonce action.
+ * @return string Are you sure message.
+ */
function wp_explain_nonce( $action ) {
if ( $action !== -1 && preg_match( '/([a-z]+)-([a-z]+)(_(.+))?/', $action, $matches ) ) {
$verb = $matches[1];
$trans['edit']['plugin'] = array( __( 'Your attempt to edit this plugin file: "%s" has failed.' ), 'use_id' );
$trans['activate']['plugin'] = array( __( 'Your attempt to activate this plugin: "%s" has failed.' ), 'use_id' );
$trans['deactivate']['plugin'] = array( __( 'Your attempt to deactivate this plugin: "%s" has failed.' ), 'use_id' );
- $trans['upgrade']['plugin'] = array( __( 'Your attempt to upgrade this plugin: "%s" has failed.' ), 'use_id' );
+ $trans['upgrade']['plugin'] = array( __( 'Your attempt to upgrade this plugin: "%s" has failed.' ), 'use_id' );
$trans['add']['post'] = array( __( 'Your attempt to add this post has failed.' ), false );
$trans['delete']['post'] = array( __( 'Your attempt to delete this post: "%s" has failed.' ), 'get_the_title' );
$trans['edit']['theme'] = array( __( 'Your attempt to edit this theme file: "%s" has failed.' ), 'use_id' );
$trans['switch']['theme'] = array( __( 'Your attempt to switch to this theme: "%s" has failed.' ), 'use_id' );
+ $trans['log']['out'] = array( sprintf( __( 'You are attempting to log out of %s' ), get_bloginfo( 'sitename' ) ), false );
+
if ( isset( $trans[$verb][$noun] ) ) {
if ( !empty( $trans[$verb][$noun][1] ) ) {
$lookup = $trans[$verb][$noun][1];
return apply_filters( 'explain_nonce_' . $verb . '-' . $noun, __( 'Are you sure you want to do this?' ), $matches[4] );
}
-
+/**
+ * Display "Are You Sure" message to confirm the action being taken.
+ *
+ * If the action has the nonce explain message, then it will be displayed along
+ * with the "Are you sure?" message.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param string $action The nonce action.
+ */
function wp_nonce_ays( $action ) {
$title = __( 'WordPress Failure Notice' );
- $html = wp_specialchars( wp_explain_nonce( $action ) ) . '</p>';
+ $html = wp_specialchars( wp_explain_nonce( $action ) );
if ( wp_get_referer() )
- $html .= "<p><a href='" . remove_query_arg( 'updated', clean_url( wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>";
+ $html .= "</p><p><a href='" . remove_query_arg( 'updated', clean_url( wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>";
+ elseif ( 'log-out' == $action )
+ $html .= "</p><p>" . sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_nonce_url( site_url('wp-login.php?action=logout', 'login'), 'log-out' ) );
+
wp_die( $html, $title);
}
-
-function wp_die( $message, $title = '' ) {
+/**
+ * Kill WordPress execution and display HTML message with error message.
+ *
+ * Call this function complements the die() PHP function. The difference is that
+ * HTML will be displayed to the user. It is recommended to use this function
+ * only, when the execution should not continue any further. It is not
+ * recommended to call this function very often and try to handle as many errors
+ * as possible siliently.
+ *
+ * @since 2.0.4
+ *
+ * @param string $message Error message.
+ * @param string $title Error title.
+ * @param string|array $args Optional arguements to control behaviour.
+ */
+function wp_die( $message, $title = '', $args = array() ) {
global $wp_locale;
+ $defaults = array( 'response' => 500 );
+ $r = wp_parse_args($args, $defaults);
+
if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
if ( empty( $title ) ) {
$error_data = $message->get_error_data();
if ( !function_exists( 'did_action' ) || !did_action( 'admin_head' ) ) :
if( !headers_sent() ){
- status_header( 500 );
+ status_header( $r['response'] );
nocache_headers();
header( 'Content-Type: text/html; charset=utf-8' );
}
<body id="error-page">
<?php endif; ?>
<?php echo $message; ?>
+ <?php if ( strlen($message) < 512) echo str_repeat(' ', 512-strlen($message)); ?>
</body>
</html>
<?php
die();
}
-
+/**
+ * Retrieve the WordPress home page URL.
+ *
+ * If the constant named 'WP_HOME' exists, then it willl be used and returned by
+ * the function. This can be used to counter the redirection on your local
+ * development environment.
+ *
+ * @access private
+ * @package WordPress
+ * @since 2.2.0
+ *
+ * @param string $url URL for the home location
+ * @return string Homepage location.
+ */
function _config_wp_home( $url = '' ) {
if ( defined( 'WP_HOME' ) )
return WP_HOME;
return $url;
}
-
+/**
+ * Retrieve the WordPress site URL.
+ *
+ * If the constant named 'WP_SITEURL' is defined, then the value in that
+ * constant will always be returned. This can be used for debugging a site on
+ * your localhost while not having to change the database to your URL.
+ *
+ * @access private
+ * @package WordPress
+ * @since 2.2.0
+ *
+ * @param string $url URL to set the WordPress site location.
+ * @return string The WordPress Site URL
+ */
function _config_wp_siteurl( $url = '' ) {
if ( defined( 'WP_SITEURL' ) )
return WP_SITEURL;
return $url;
}
-
+/**
+ * Set the localized direction for MCE plugin.
+ *
+ * Will only set the direction to 'rtl', if the WordPress locale has the text
+ * direction set to 'rtl'.
+ *
+ * Fills in the 'directionality', 'plugins', and 'theme_advanced_button1' array
+ * keys. These keys are then returned in the $input array.
+ *
+ * @access private
+ * @package WordPress
+ * @subpackage MCE
+ * @since 2.1.0
+ *
+ * @param array $input MCE plugin array.
+ * @return array Direction set for 'rtl', if needed by locale.
+ */
function _mce_set_direction( $input ) {
global $wp_locale;
return $input;
}
-
+/**
+ * Convert smiley code to the icon graphic file equivalent.
+ *
+ * You can turn off smilies, by going to the write setting screen and unchecking
+ * the box, or by setting 'use_smilies' option to false or removing the option.
+ *
+ * Plugins may override the default smiley list by setting the $wpsmiliestrans
+ * to an array, with the key the code the blogger types in and the value the
+ * image file.
+ *
+ * The $wp_smiliessearch global is for the regular expression array and is
+ * set each time the function is called. The $wp_smiliesreplace is the full
+ * replacement. Supposely, the $wp_smiliessearch array is looped over using
+ * preg_replace() or just setting the array of $wp_smiliessearch along with the
+ * array of $wp_smiliesreplace in the search and replace parameters of
+ * preg_replace(), which would be faster and less overhead. Either way, both are
+ * used with preg_replace() and can be defined after the function is called.
+ *
+ * The full list of smilies can be found in the function and won't be listed in
+ * the description. Probably should create a Codex page for it, so that it is
+ * available.
+ *
+ * @global array $wpsmiliestrans
+ * @global array $wp_smiliesreplace
+ * @global array $wp_smiliessearch
+ * @since 2.2.0
+ */
function smilies_init() {
global $wpsmiliestrans, $wp_smiliessearch, $wp_smiliesreplace;
* wp-admin/setup-config.php We must globalise $wpdb to ensure that it is
* defined globally by the inline code in wp-db.php.
*
- * @since 2.5
+ * @since 2.5.0
* @global $wpdb WordPress Database Object
*/
function require_wp_db() {
* search engines from caching the message. Custom DB messages should do the
* same.
*
- * @since 2.5
+ * This function was backported to the the WordPress 2.3.2, but originally was
+ * added in WordPress 2.5.0.
+ *
+ * @since 2.3.2
* @uses $wpdb
*/
function dead_db() {
/**
* Converts value to positive integer.
*
- * @since 2.5
- *
- * @param mixed $maybeint data you wish to have convered to an absolute integer
- * @return int an absolute integer
+ * @since 2.5.0
+ *
+ * @param mixed $maybeint Data you wish to have convered to an absolute integer
+ * @return int An absolute integer
*/
function absint( $maybeint ) {
return abs( intval( $maybeint ) );
* Determines if blog can be accessed over SSL by using cURL to access the site
* using the https in the siteurl. Requires cURL extension to work correctly.
*
- * @since 2.5
+ * @since 2.5.0
*
* @return bool Whether or not SSL access is available
*/
function url_is_accessable_via_ssl($url)
{
if (in_array('curl', get_loaded_extensions())) {
- $ssl = preg_replace( '/^http:\/\//', 'https://', $url );
+ $ssl = preg_replace( '/^http:\/\//', 'https://', $url );
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $ssl);
- curl_setopt($ch, CURLOPT_FAILONERROR, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $ssl);
+ curl_setopt($ch, CURLOPT_FAILONERROR, true);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_exec($ch);
+ curl_exec($ch);
- $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- curl_close ($ch);
+ $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close ($ch);
- if ($status == 200 || $status == 401) {
- return true;
- }
+ if ($status == 200 || $status == 401) {
+ return true;
+ }
}
return false;
}
/**
* Secure URL, if available or the given URL.
*
- * @since 2.5
+ * @since 2.5.0
*
* @param string $url Complete URL path with transport.
* @return string Secure or regular URL path.
*
* @package WordPress
* @package Debug
- * @since 2.5
+ * @since 2.5.0
* @access private
*
* @uses do_action() Calls 'deprecated_function_run' and passes the function name and what to use instead.
* @uses apply_filters() Calls 'deprecated_function_trigger_error' and expects boolean value of true to do trigger or false to not trigger error.
*
* @param string $function The function that was called
- * @param string $version The version of WordPress that depreceated the function
+ * @param string $version The version of WordPress that deprecated the function
* @param string $replacement Optional. The function that should have been called
*/
function _deprecated_function($function, $version, $replacement=null) {
*
* @package WordPress
* @package Debug
- * @since 2.5
+ * @since 2.5.0
* @access private
*
* @uses do_action() Calls 'deprecated_file_included' and passes the file name and what to use instead.
* @uses apply_filters() Calls 'deprecated_file_trigger_error' and expects boolean value of true to do trigger or false to not trigger error.
*
* @param string $file The file that was included
- * @param string $version The version of WordPress that depreceated the function
+ * @param string $version The version of WordPress that deprecated the function
* @param string $replacement Optional. The function that should have been called
*/
function _deprecated_file($file, $version, $replacement=null) {
/**
* Is the server running earlier than 1.5.0 version of lighttpd
*
- * @since unknown
+ * @since 2.5.0
*
* @return bool Whether the server is running lighttpd < 1.5.0
*/
/**
* Does the specified module exist in the apache config?
*
- * @since unknown
+ * @since 2.5.0
*
* @param string $mod e.g. mod_rewrite
* @param bool $default The default return value if the module is not found
* character. A return value of '3' means that the file is not in the allowed
* files list.
*
- * @since 2.6
+ * @since 1.2.0
*
* @param string $file File path.
* @param array $allowed_files List of allowed files.
/**
* Determine if SSL is used.
*
- * @since 2.6
+ * @since 2.6.0
*
* @return bool True if SSL, false if not used.
*/
function is_ssl() {
- return ( isset($_SERVER['HTTPS']) && 'on' == strtolower($_SERVER['HTTPS']) ) ? true : false;
+ if ( isset($_SERVER['HTTPS']) ) {
+ if ( 'on' == strtolower($_SERVER['HTTPS']) )
+ return true;
+ if ( '1' == $_SERVER['HTTPS'] )
+ return true;
+ } elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
+ return true;
+ }
+ return false;
}
/**
* Whether SSL login should be forced.
*
- * @since 2.6
+ * @since 2.6.0
*
* @param string|bool $force Optional.
* @return bool True if forced, false if not forced.
/**
* Whether to force SSL used for the Administration Panels.
*
- * @since 2.6
+ * @since 2.6.0
*
* @param string|bool $force
* @return bool True if forced, false if not forced.
* Will remove wp-admin links to retrieve only return URLs not in the wp-admin
* directory.
*
- * @since 2.6
+ * @since 2.6.0
*
* @return string
*/
return $url;
}
-?>
\ No newline at end of file
+/**
+ * Suspend cache invalidation.
+ *
+ * Turns cache invalidation on and off. Useful during imports where you don't wont to do invalidations
+ * every time a post is inserted. Callers must be sure that what they are doing won't lead to an inconsistent
+ * cache when invalidation is suspended.
+ *
+ * @since 2.7.0
+ *
+ * @param bool $suspend Whether to suspend or enable cache invalidation
+ * @return bool The current suspend setting
+ */
+function wp_suspend_cache_invalidation($suspend = true) {
+ global $_wp_suspend_cache_invalidation;
+
+ $current_suspend = $_wp_suspend_cache_invalidation;
+ $_wp_suspend_cache_invalidation = $suspend;
+ return $current_suspend;
+}
+
+/**
+ * Copy an object.
+ *
+ * Returns a cloned copy of an object.
+ *
+ * @since 2.7.0
+ *
+ * @param object $object The object to clone
+ * @return object The cloned object
+ */
+function wp_clone( $object ) {
+ static $can_clone;
+ if ( !isset( $can_clone ) ) {
+ $can_clone = version_compare( phpversion(), '5.0', '>=' );
+ }
+ return $can_clone ? clone( $object ) : $object;
+}
+
+
+?>
<?php
+/**
+ * BackPress script procedural API.
+ *
+ * @package BackPress
+ * @since r16
+ */
/**
- * Prints script tags in document head
+ * Prints script tags in document head.
*
- * Called by admin-header.php and by wp_head hook. Since it is called by wp_head on every page load,
- * the function does not instantiate the WP_Scripts object unless script names are explicitly passed.
- * Does make use of already instantiated $wp_scripts if present.
- * Use provided wp_print_scripts hook to register/enqueue new scripts.
+ * Called by admin-header.php and by wp_head hook. Since it is called by wp_head
+ * on every page load, the function does not instantiate the WP_Scripts object
+ * unless script names are explicitly passed. Does make use of already
+ * instantiated $wp_scripts if present. Use provided wp_print_scripts hook to
+ * register/enqueue new scripts.
*
+ * @since r16
* @see WP_Scripts::print_scripts()
*/
function wp_print_scripts( $handles = false ) {
return $wp_scripts->do_items( $handles );
}
+/**
+ * Register new JavaScript file.
+ *
+ * @since r16
+ * @see WP_Scripts::add() For parameter information.
+ */
function wp_register_script( $handle, $src, $deps = array(), $ver = false ) {
global $wp_scripts;
if ( !is_a($wp_scripts, 'WP_Scripts') )
}
/**
- * Localizes a script
+ * Localizes a script.
*
- * Localizes only if script has already been added
+ * Localizes only if script has already been added.
*
+ * @since r16
* @see WP_Script::localize()
*/
function wp_localize_script( $handle, $object_name, $l10n ) {
return $wp_scripts->localize( $handle, $object_name, $l10n );
}
+/**
+ * Remove a registered script.
+ *
+ * @since r16
+ * @see WP_Scripts::remove() For parameter information.
+ */
function wp_deregister_script( $handle ) {
global $wp_scripts;
if ( !is_a($wp_scripts, 'WP_Scripts') )
}
/**
- * Equeues script
+ * Enqueues script.
*
* Registers the script if src provided (does NOT overwrite) and enqueues.
*
+ * @since r16
* @see WP_Script::add(), WP_Script::enqueue()
*/
function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false ) {
<?php
+/**
+ * BackPress styles procedural API.
+ *
+ * @package BackPress
+ * @since r79
+ */
+/**
+ * Display styles that are in the queue or part of $handles.
+ *
+ * @since r79
+ * @uses do_action() Calls 'wp_print_styles' hook.
+ * @global object $wp_styles The WP_Styles object for printing styles.
+ *
+ * @param array $handles (optional) Styles to be printed. (void) prints queue, (string) prints that style, (array of strings) prints those styles.
+ * @return bool True on success, false on failure.
+ */
function wp_print_styles( $handles = false ) {
do_action( 'wp_print_styles' );
if ( '' === $handles ) // for wp_head
return $wp_styles->do_items( $handles );
}
-function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = false ) {
+/**
+ * Register CSS style file.
+ *
+ * @since r79
+ * @see WP_Styles::add() For parameter and additional information.
+ */
+function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
global $wp_styles;
if ( !is_a($wp_styles, 'WP_Styles') )
$wp_styles = new WP_Styles();
$wp_styles->add( $handle, $src, $deps, $ver, $media );
}
+/**
+ * Remove a registered CSS file.
+ *
+ * @since r79
+ * @see WP_Styles::remove() For parameter and additional information.
+ */
function wp_deregister_style( $handle ) {
global $wp_styles;
if ( !is_a($wp_styles, 'WP_Styles') )
$wp_styles->remove( $handle );
}
+/**
+ * Enqueue a CSS style file.
+ *
+ * @since r79
+ * @see WP_Styles::add(), WP_Styles::enqueue()
+ */
function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = false ) {
global $wp_styles;
if ( !is_a($wp_styles, 'WP_Styles') )
<?php
+/**
+ * General template tags that can go anywhere in a template.
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
-/* Note: these tags go anywhere in the template */
-
-function get_header() {
+/**
+ * Load header template.
+ *
+ * Includes the header template for a theme or if a name is specified then a
+ * specialised header will be included. If the theme contains no header.php file
+ * then the header from the default theme will be included.
+ *
+ * For the parameter, if the file is called "header-special.php" then specify
+ * "special".
+ *
+ * @uses locate_template()
+ * @since 1.5.0
+ * @uses do_action() Calls 'get_header' action.
+ *
+ * @param string $name The name of the specialised header.
+ */
+function get_header( $name = null ) {
do_action( 'get_header' );
- if ( file_exists( TEMPLATEPATH . '/header.php') )
- load_template( TEMPLATEPATH . '/header.php');
- else
- load_template( WP_CONTENT_DIR . '/themes/default/header.php');
-}
+ $templates = array();
+ if ( isset($name) )
+ $templates[] = "header-{$name}.php";
-function get_footer() {
- do_action( 'get_footer' );
- if ( file_exists( TEMPLATEPATH . '/footer.php') )
- load_template( TEMPLATEPATH . '/footer.php');
- else
- load_template( WP_CONTENT_DIR . '/themes/default/footer.php');
+ $templates[] = "header.php";
+
+ if ('' == locate_template($templates, true))
+ load_template( get_theme_root() . '/default/header.php');
}
+/**
+ * Load footer template.
+ *
+ * Includes the footer template for a theme or if a name is specified then a
+ * specialised footer will be included. If the theme contains no footer.php file
+ * then the footer from the default theme will be included.
+ *
+ * For the parameter, if the file is called "footer-special.php" then specify
+ * "special".
+ *
+ * @uses locate_template()
+ * @since 1.5.0
+ * @uses do_action() Calls 'get_footer' action.
+ *
+ * @param string $name The name of the specialised footer.
+ */
+function get_footer( $name = null ) {
+ do_action( 'get_footer' );
+
+ $templates = array();
+ if ( isset($name) )
+ $templates[] = "footer-{$name}.php";
+
+ $templates[] = "footer.php";
+
+ if ('' == locate_template($templates, true))
+ load_template( get_theme_root() . '/default/footer.php');
+}
+/**
+ * Load sidebar template.
+ *
+ * Includes the sidebar template for a theme or if a name is specified then a
+ * specialised sidebar will be included. If the theme contains no sidebar.php
+ * file then the sidebar from the default theme will be included.
+ *
+ * For the parameter, if the file is called "sidebar-special.php" then specify
+ * "special".
+ *
+ * @uses locate_template()
+ * @since 1.5.0
+ * @uses do_action() Calls 'get_sidebar' action.
+ *
+ * @param string $name The name of the specialised sidebar.
+ */
function get_sidebar( $name = null ) {
do_action( 'get_sidebar' );
- if ( isset($name) && file_exists( TEMPLATEPATH . "/sidebar-{$name}.php") )
- load_template( TEMPLATEPATH . "/sidebar-{$name}.php");
- elseif ( file_exists( TEMPLATEPATH . '/sidebar.php') )
- load_template( TEMPLATEPATH . '/sidebar.php');
- else
- load_template( WP_CONTENT_DIR . '/themes/default/sidebar.php');
+
+ $templates = array();
+ if ( isset($name) )
+ $templates[] = "sidebar-{$name}.php";
+
+ $templates[] = "sidebar.php";
+
+ if ('' == locate_template($templates, true))
+ load_template( get_theme_root() . '/default/sidebar.php');
}
+/**
+ * Display search form.
+ *
+ * Will first attempt to locate the searchform.php file in either the child or
+ * the parent, then load it. If it doesn't exist, then the default search form
+ * will be displayed.
+ *
+ * @since 2.7.0
+ */
+function get_search_form() {
+ do_action( 'get_search_form' );
+
+ if ( '' != locate_template(array('searchform.php'), true) )
+ return;
+
+ $form = '<form method="get" id="searchform" action="' . get_option('home') . '/" >
+ <label class="hidden" for="s">' . __('Search for:') . '</label>
+ <div><input type="text" value="' . attribute_escape(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />
+ <input type="submit" id="searchsubmit" value="'.attribute_escape(__('Search')).'" />
+ </div>
+ </form>';
+
+ echo apply_filters('get_search_form', $form);
+}
+/**
+ * Display the Log In/Out link.
+ *
+ * Displays a link, which allows the user to navigate to the Log In page to log in
+ * or log out depending on whether or not they are currently logged in.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'loginout' hook on HTML link content.
+ */
function wp_loginout() {
if ( ! is_user_logged_in() )
- $link = '<a href="' . site_url('wp-login.php', 'login') . '">' . __('Log in') . '</a>';
+ $link = '<a href="' . wp_login_url() . '">' . __('Log in') . '</a>';
else
- $link = '<a href="' . site_url('wp-login.php?action=logout', 'login') . '">' . __('Log out') . '</a>';
+ $link = '<a href="' . wp_logout_url() . '">' . __('Log out') . '</a>';
echo apply_filters('loginout', $link);
}
+/**
+ * Returns the Log Out URL.
+ *
+ * Returns the URL that allows the user to log out of the site
+ *
+ * @since 2.7
+ * @uses wp_nonce_url() To protect against CSRF
+ * @uses site_url() To generate the log in URL
+ *
+ * @param string $redirect Path to redirect to on logout.
+ */
+function wp_logout_url($redirect = '') {
+ if ( strlen($redirect) )
+ $redirect = "&redirect_to=$redirect";
+
+ return wp_nonce_url( site_url("wp-login.php?action=logout$redirect", 'login'), 'log-out' );
+}
+/**
+ * Returns the Log In URL.
+ *
+ * Returns the URL that allows the user to log in to the site
+ *
+ * @since 2.7
+ * @uses site_url() To generate the log in URL
+ *
+ * @param string $redirect Path to redirect to on login.
+ */
+function wp_login_url($redirect = '') {
+ if ( strlen($redirect) )
+ $redirect = "?redirect_to=$redirect";
+
+ return site_url("wp-login.php$redirect", 'login');
+}
+
+/**
+ * Display the Registration or Admin link.
+ *
+ * Display a link which allows the user to navigate to the registration page if
+ * not logged in and registration is enabled or to the dashboard if logged in.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'register' hook on register / admin link content.
+ *
+ * @param string $before Text to output before the link (defaults to <li>).
+ * @param string $after Text to output after the link (defaults to </li>).
+ */
function wp_register( $before = '<li>', $after = '</li>' ) {
if ( ! is_user_logged_in() ) {
echo apply_filters('register', $link);
}
-
+/**
+ * Theme container function for the 'wp_meta' action.
+ *
+ * The 'wp_meta' action can have several purposes, depending on how you use it,
+ * but one purpose might have been to allow for theme switching.
+ *
+ * @since 1.5.0
+ * @link http://trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
+ * @uses do_action() Calls 'wp_meta' hook.
+ */
function wp_meta() {
do_action('wp_meta');
}
-
+/**
+ * Display information about the blog.
+ *
+ * @see get_bloginfo() For possible values for the parameter.
+ * @since 0.71
+ *
+ * @param string $show What to display.
+ */
function bloginfo($show='') {
echo get_bloginfo($show, 'display');
}
/**
- * Note: some of these values are DEPRECATED. Meaning they could be
- * taken out at any time and shouldn't be relied upon. Options
- * without "// DEPRECATED" are the preferred and recommended ways
- * to get the information.
+ * Retrieve information about the blog.
+ *
+ * Some show parameter values are deprecated and will be removed in future
+ * versions. Care should be taken to check the function contents and know what
+ * the deprecated blog info options are. Options without "// DEPRECATED" are
+ * the preferred and recommended ways to get the information.
+ *
+ * The possible values for the 'show' parameter are listed below.
+ * <ol>
+ * <li><strong>url<strong> - Blog URI to homepage.</li>
+ * <li><strong>wpurl</strong> - Blog URI path to WordPress.</li>
+ * <li><strong>description</strong> - Secondary title</li>
+ * </ol>
+ *
+ * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
+ * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
+ * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
+ * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
+ *
+ * There are many other options and you should check the function contents:
+ * {@source 32 37}
+ *
+ * @since 0.71
+ *
+ * @param string $show Blog info to retrieve.
+ * @param string $filter How to filter what is retrieved.
+ * @return string Mostly string values, might be empty.
*/
function get_bloginfo($show = '', $filter = 'raw') {
return $output;
}
-
+/**
+ * Display or retrieve page title for all areas of blog.
+ *
+ * By default, the page title will display the separator before the page title,
+ * so that the blog title will be before the page title. This is not good for
+ * title display, since the blog title shows up on most tabs and not what is
+ * important, which is the page that the user is looking at.
+ *
+ * There are also SEO benefits to having the blog title after or to the 'right'
+ * or the page title. However, it is mostly common sense to have the blog title
+ * to the right with most browsers supporting tabs. You can achieve this by
+ * using the seplocation parameter and setting the value to 'right'. This change
+ * was introduced around 2.5.0, in case backwards compatibility of themes is
+ * important.
+ *
+ * @since 1.0.0
+ *
+ * @param string $sep Optional, default is '»'. How to separate the various items within the page title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @param string $seplocation Optional. Direction to display title, 'right'.
+ * @return string|null String on retrieve, null when displaying.
+ */
function wp_title($sep = '»', $display = true, $seplocation = '') {
global $wpdb, $wp_locale, $wp_query;
$day = get_query_var('day');
$title = '';
+ $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
+
// If there's a category
if ( !empty($cat) ) {
// category exclusion
$my_year = substr($m, 0, 4);
$my_month = $wp_locale->get_month(substr($m, 4, 2));
$my_day = intval(substr($m, 6, 2));
- $title = "$my_year" . ($my_month ? "$sep $my_month" : "") . ($my_day ? "$sep $my_day" : "");
+ $title = "$my_year" . ($my_month ? "$t_sep$my_month" : "") . ($my_day ? "$t_sep$my_day" : "");
}
if ( !empty($year) ) {
$title = $year;
if ( !empty($monthnum) )
- $title .= " $sep " . $wp_locale->get_month($monthnum);
+ $title .= "$t_sep" . $wp_locale->get_month($monthnum);
if ( !empty($day) )
- $title .= " $sep " . zeroise($day, 2);
+ $title .= "$t_sep" . zeroise($day, 2);
}
// If there is a post
- if ( is_single() || is_page() ) {
+ if ( is_single() || ( is_page() && !is_front_page() ) ) {
$post = $wp_query->get_queried_object();
$title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) );
}
$tax = $tax->label;
$term = $wp_query->get_queried_object();
$term = $term->name;
- if ( 'right' == $seplocation )
- $title = "$term $sep $tax";
- else
- $title = "$tax $sep $term";
+ $title = "$tax$t_sep$term";
+ }
+
+ if ( is_404() ) {
+ $title = __('Page not found');
}
$prefix = '';
if ( !empty($title) )
$prefix = " $sep ";
- // Determines position of the separator
- if ( 'right' == $seplocation )
- $title = $title . $prefix;
- else
- $title = $prefix . $title;
+ // Determines position of the separator and direction of the breadcrumb
+ if ( 'right' == $seplocation ) { // sep on right, so reverse the order
+ $title_array = explode( $t_sep, $title );
+ $title_array = array_reverse( $title_array );
+ $title = implode( " $sep ", $title_array ) . $prefix;
+ } else {
+ $title_array = explode( $t_sep, $title );
+ $title = $prefix . implode( " $sep ", $title_array );
+ }
- $title = apply_filters('wp_title', $title, $sep);
+ $title = apply_filters('wp_title', $title, $sep, $seplocation);
// Send it out
if ( $display )
}
-
+/**
+ * Display or retrieve page title for post.
+ *
+ * This is optimized for single.php template file for displaying the post title.
+ * Only useful for posts, does not support pages for example.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 0.71
+ * @uses $wpdb
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
function single_post_title($prefix = '', $display = true) {
global $wpdb;
$p = get_query_var('p');
}
}
-
+/**
+ * Display or retrieve page title for category archive.
+ *
+ * This is useful for category template file or files, because it is optimized
+ * for category page title and with less overhead than {@link wp_title()}.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 0.71
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
function single_cat_title($prefix = '', $display = true ) {
$cat = intval( get_query_var('cat') );
if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
}
}
-
+/**
+ * Display or retrieve page title for tag post archive.
+ *
+ * Useful for tag template files for displaying the tag page title. It has less
+ * overhead than {@link wp_title()}, because of its limited implementation.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 2.3.0
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
function single_tag_title($prefix = '', $display = true ) {
if ( !is_tag() )
return;
}
}
-
+/**
+ * Display or retrieve page title for post archive based on date.
+ *
+ * Useful for when the template only needs to display the month and year, if
+ * either are available. Optimized for just this purpose, so if it is all that
+ * is needed, should be better than {@link wp_title()}.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 0.71
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
function single_month_title($prefix = '', $display = true ) {
global $wp_locale;
echo $result;
}
-
-/* link navigation hack by Orien http://icecode.com/ */
+/**
+ * Retrieve archive link content based on predefined or custom code.
+ *
+ * The format can be one of four styles. The 'link' for head element, 'option'
+ * for use in the select element, 'html' for use in list (either ol or ul HTML
+ * elements). Custom content is also supported using the before and after
+ * parameters.
+ *
+ * The 'link' format uses the link HTML element with the <em>archives</em>
+ * relationship. The before and after parameters are not used. The text
+ * parameter is used to describe the link.
+ *
+ * The 'option' format uses the option HTML element for use in select element.
+ * The value is the url parameter and the before and after parameters are used
+ * between the text description.
+ *
+ * The 'html' format, which is the default, uses the li HTML element for use in
+ * the list HTML elements. The before parameter is before the link and the after
+ * parameter is after the closing link.
+ *
+ * The custom format uses the before parameter before the link ('a' HTML
+ * element) and the after parameter after the closing link tag. If the above
+ * three values for the format are not used, then custom format is assumed.
+ *
+ * @since 1.0.0
+ * @author Orien
+ * @link http://icecode.com/ link navigation hack by Orien
+ *
+ * @param string $url URL to archive.
+ * @param string $text Archive text description.
+ * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
+ * @param string $before Optional.
+ * @param string $after Optional.
+ * @return string HTML link content for archive.
+ */
function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
$text = wptexturize($text);
$title_text = attribute_escape($text);
$link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";
$link_html = apply_filters( "get_archives_link", $link_html );
-
+
return $link_html;
}
-
+/**
+ * Display archive links based on type and format.
+ *
+ * The 'type' argument offers a few choices and by default will display monthly
+ * archive links. The other options for values are 'daily', 'weekly', 'monthly',
+ * 'yearly', 'postbypost' or 'alpha'. Both 'postbypost' and 'alpha' display the
+ * same archive link list, the difference between the two is that 'alpha'
+ * will order by post title and 'postbypost' will order by post date.
+ *
+ * The date archives will logically display dates with links to the archive post
+ * page. The 'postbypost' and 'alpha' values for 'type' argument will display
+ * the post titles.
+ *
+ * The 'limit' argument will only display a limited amount of links, specified
+ * by the 'limit' integer value. By default, there is no limit. The
+ * 'show_post_count' argument will show how many posts are within the archive.
+ * By default, the 'show_post_count' argument is set to false.
+ *
+ * For the 'format', 'before', and 'after' arguments, see {@link
+ * get_archives_link()}. The values of these arguments have to do with that
+ * function.
+ *
+ * @since 1.2.0
+ *
+ * @param string|array $args Optional. Override defaults.
+ */
function wp_get_archives($args = '') {
global $wpdb, $wp_locale;
$defaults = array(
'type' => 'monthly', 'limit' => '',
'format' => 'html', 'before' => '',
- 'after' => '', 'show_post_count' => false
+ 'after' => '', 'show_post_count' => false,
+ 'echo' => 1
);
$r = wp_parse_args( $args, $defaults );
$where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
$join = apply_filters('getarchives_join', "", $r);
+ $output = '';
+
if ( 'monthly' == $type ) {
$query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit";
$key = md5($query);
}
if ( $arcresults ) {
$afterafter = $after;
- foreach ( $arcresults as $arcresult ) {
- $url = get_month_link($arcresult->year, $arcresult->month);
+ foreach ( (array) $arcresults as $arcresult ) {
+ $url = get_month_link( $arcresult->year, $arcresult->month );
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
if ( $show_post_count )
$after = ' ('.$arcresult->posts.')' . $afterafter;
- echo get_archives_link($url, $text, $format, $before, $after);
+ $output .= get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ('yearly' == $type) {
}
if ($arcresults) {
$afterafter = $after;
- foreach ($arcresults as $arcresult) {
+ foreach ( (array) $arcresults as $arcresult) {
$url = get_year_link($arcresult->year);
$text = sprintf('%d', $arcresult->year);
if ($show_post_count)
$after = ' ('.$arcresult->posts.')' . $afterafter;
- echo get_archives_link($url, $text, $format, $before, $after);
+ $output .= get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ( 'daily' == $type ) {
}
if ( $arcresults ) {
$afterafter = $after;
- foreach ( $arcresults as $arcresult ) {
+ foreach ( (array) $arcresults as $arcresult ) {
$url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
$date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
$text = mysql2date($archive_day_date_format, $date);
if ($show_post_count)
$after = ' ('.$arcresult->posts.')'.$afterafter;
- echo get_archives_link($url, $text, $format, $before, $after);
+ $output .= get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ( 'weekly' == $type ) {
$arc_w_last = '';
$afterafter = $after;
if ( $arcresults ) {
- foreach ( $arcresults as $arcresult ) {
+ foreach ( (array) $arcresults as $arcresult ) {
if ( $arcresult->week != $arc_w_last ) {
$arc_year = $arcresult->yr;
$arc_w_last = $arcresult->week;
$text = $arc_week_start . $archive_week_separator . $arc_week_end;
if ($show_post_count)
$after = ' ('.$arcresult->posts.')'.$afterafter;
- echo get_archives_link($url, $text, $format, $before, $after);
+ $output .= get_archives_link($url, $text, $format, $before, $after);
}
}
}
} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
- ('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC ";
+ $orderby = ('alpha' == $type) ? "post_title ASC " : "post_date DESC ";
$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
$key = md5($query);
$cache = wp_cache_get( 'wp_get_archives' , 'general');
$arcresults = $cache[ $key ];
}
if ( $arcresults ) {
- foreach ( $arcresults as $arcresult ) {
+ foreach ( (array) $arcresults as $arcresult ) {
if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
$url = get_permalink($arcresult);
$arc_title = $arcresult->post_title;
$text = strip_tags(apply_filters('the_title', $arc_title));
else
$text = $arcresult->ID;
- echo get_archives_link($url, $text, $format, $before, $after);
+ $output .= get_archives_link($url, $text, $format, $before, $after);
}
}
}
}
+ if ( $echo )
+ echo $output;
+ else
+ return $output;
}
-
-// Used in get_calendar
+/**
+ * Get number of days since the start of the week.
+ *
+ * @since 1.5.0
+ * @usedby get_calendar()
+ *
+ * @param int $num Number of day.
+ * @return int Days since the start of the week.
+ */
function calendar_week_mod($num) {
$base = 7;
return ($num - $base*floor($num/$base));
}
-
+/**
+ * Display calendar with days that have posts as links.
+ *
+ * The calendar is cached, which will be retrieved, if it exists. If there are
+ * no posts for the month, then it will not be displayed.
+ *
+ * @since 1.0.0
+ *
+ * @param bool $initial Optional, default is true. Use initial calendar names.
+ */
function get_calendar($initial = true) {
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
AND post_type = 'post' AND post_status = 'publish'
AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
if ( $dayswithposts ) {
- foreach ( $dayswithposts as $daywith ) {
+ foreach ( (array) $dayswithposts as $daywith ) {
$daywithpost[] = $daywith[0];
}
} else {
."AND post_type = 'post' AND post_status = 'publish'"
);
if ( $ak_post_titles ) {
- foreach ( $ak_post_titles as $ak_post_title ) {
+ foreach ( (array) $ak_post_titles as $ak_post_title ) {
$post_title = apply_filters( "the_title", $ak_post_title->post_title );
$post_title = str_replace('"', '"', wptexturize( $post_title ));
wp_cache_set( 'get_calendar', $cache, 'calendar' );
}
+/**
+ * Purge the cached results of get_calendar.
+ *
+ * @see get_calendar
+ * @since 2.1.0
+ */
function delete_get_calendar_cache() {
wp_cache_delete( 'get_calendar', 'calendar' );
}
add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
-
+/**
+ * Display all of the allowed tags in HTML format with attributes.
+ *
+ * This is useful for displaying in the comment area, which elements and
+ * attributes are supported. As well as any plugins which want to display it.
+ *
+ * @since 1.0.1
+ * @uses $allowedtags
+ *
+ * @return string HTML allowed tags entity encoded.
+ */
function allowed_tags() {
global $allowedtags;
$allowed = '';
- foreach ( $allowedtags as $tag => $attributes ) {
+ foreach ( (array) $allowedtags as $tag => $attributes ) {
$allowed .= '<'.$tag;
if ( 0 < count($attributes) ) {
foreach ( $attributes as $attribute => $limits ) {
return htmlentities($allowed);
}
-
/***** Date/Time tags *****/
-
+/**
+ * Outputs the date in iso8601 format for xml files.
+ *
+ * @since 1.0.0
+ */
function the_date_xml() {
global $post;
echo mysql2date('Y-m-d', $post->post_date);
- //echo ""+$post->post_date;
}
-
+/**
+ * Display or Retrieve the date the post was written.
+ *
+ * Will only output the date if the current post's date is different from the
+ * previous one output.
+ *
+ * @since 0.71
+ *
+ * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
+ * @param string $before Optional. Output before the date.
+ * @param string $after Optional. Output after the date.
+ * @param bool $echo Optional, default is display. Whether to echo the date or return it.
+ * @return string|null Null if displaying, string if retrieving.
+ */
function the_date($d='', $before='', $after='', $echo = true) {
global $post, $day, $previousday;
$the_date = '';
return $the_date;
}
-
+/**
+ * Display the date on which the post was last modified.
+ *
+ * @since 2.1.0
+ *
+ * @param string $d Optional. PHP date format.
+ * @return string
+ */
function the_modified_date($d = '') {
echo apply_filters('the_modified_date', get_the_modified_date($d), $d);
}
-
+/**
+ * Retrieve the date on which the post was last modified.
+ *
+ * @since 2.1.0
+ *
+ * @param string $d Optional. PHP date format. Defaults to the "date_format" option
+ * @return string
+ */
function get_the_modified_date($d = '') {
if ( '' == $d )
$the_time = get_post_modified_time(get_option('date_format'));
return apply_filters('get_the_modified_date', $the_time, $d);
}
-
+/**
+ * Display the time at which the post was written.
+ *
+ * @since 0.71
+ *
+ * @param string $d Either 'G', 'U', or php date format.
+ */
function the_time( $d = '' ) {
echo apply_filters('the_time', get_the_time( $d ), $d);
}
+/**
+ * Retrieve the time at which the post was written.
+ *
+ * @since 1.5.0
+ *
+ * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
+ * @param int|object $post Optional post ID or object. Default is global $post object.
+ * @return string
+ */
+function get_the_time( $d = '', $post = null ) {
+ $post = get_post($post);
-function get_the_time( $d = '' ) {
if ( '' == $d )
- $the_time = get_post_time(get_option('time_format'));
+ $the_time = get_post_time(get_option('time_format'), false, $post);
else
- $the_time = get_post_time($d);
- return apply_filters('get_the_time', $the_time, $d);
+ $the_time = get_post_time($d, false, $post);
+ return apply_filters('get_the_time', $the_time, $d, $post);
}
+/**
+ * Retrieve the time at which the post was written.
+ *
+ * @since 2.0.0
+ *
+ * @param string $d Either 'G', 'U', or php date format.
+ * @param bool $gmt Whether of not to return the gmt time.
+ * @param int|object $post Optional post ID or object. Default is global $post object.
+ * @return string
+ */
+function get_post_time( $d = 'U', $gmt = false, $post = null ) { // returns timestamp
+ $post = get_post($post);
-function get_post_time( $d = 'U', $gmt = false ) { // returns timestamp
- global $post;
if ( $gmt )
$time = $post->post_date_gmt;
else
return apply_filters('get_post_time', $time, $d, $gmt);
}
-
+/**
+ * Display the time at which the post was last modified.
+ *
+ * @since 2.0.0
+ *
+ * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
+ */
function the_modified_time($d = '') {
echo apply_filters('the_modified_time', get_the_modified_time($d), $d);
}
-
+/**
+ * Retrieve the time at which the post was last modified.
+ *
+ * @since 2.0.0
+ *
+ * @param string $d Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
+ * @return string
+ */
function get_the_modified_time($d = '') {
if ( '' == $d )
$the_time = get_post_modified_time(get_option('time_format'));
return apply_filters('get_the_modified_time', $the_time, $d);
}
-
-function get_post_modified_time( $d = 'U', $gmt = false ) { // returns timestamp
+/**
+ * Retrieve the time at which the post was last modified.
+ *
+ * @since 2.0.0
+ *
+ * @param string $d Either 'G', 'U', or php date format.
+ * @param bool $gmt Whether of not to return the gmt time.
+ * @return string Returns timestamp
+ */
+function get_post_modified_time( $d = 'U', $gmt = false ) {
global $post;
if ( $gmt )
return apply_filters('get_the_modified_time', $time, $d, $gmt);
}
-
+/**
+ * Display the weekday on which the post was written.
+ *
+ * @since 0.71
+ * @uses $wp_locale
+ * @uses $post
+ */
function the_weekday() {
global $wp_locale, $post;
$the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date));
echo $the_weekday;
}
-
+/**
+ * Display the weekday on which the post was written.
+ *
+ * Will only output the weekday if the current post's weekday is different from
+ * the previous one output.
+ *
+ * @since 0.71
+ *
+ * @param string $before output before the date.
+ * @param string $after output after the date.
+ */
function the_weekday_date($before='',$after='') {
global $wp_locale, $post, $day, $previousweekday;
$the_weekday_date = '';
echo $the_weekday_date;
}
+/**
+ * Fire the wp_head action
+ *
+ * @since 1.2.0
+ * @uses do_action() Calls 'wp_head' hook.
+ */
function wp_head() {
do_action('wp_head');
}
+/**
+ * Fire the wp_footer action
+ *
+ * @since 1.5.1
+ * @uses do_action() Calls 'wp_footer' hook.
+ */
function wp_footer() {
do_action('wp_footer');
}
+/**
+ * Display the link to the Really Simple Discovery service endpoint.
+ *
+ * @link http://archipelago.phrasewise.com/rsd
+ * @since 2.0.0
+ */
function rsd_link() {
echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
}
+/**
+ * Display the link to the Windows Live Writer manifest file.
+ *
+ * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
+ * @since 2.3.1
+ */
function wlwmanifest_link() {
echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="'
. get_bloginfo('wpurl') . '/wp-includes/wlwmanifest.xml" /> ' . "\n";
}
+/**
+ * Display a noindex meta tag if required by the blog configuration.
+ *
+ * If a blog is marked as not being public then the noindex meta tag will be
+ * output to tell web robots not to index the page content.
+ *
+ * @since 2.1.0
+ */
function noindex() {
// If the blog is not public, tell robots to go away.
if ( '0' == get_option('blog_public') )
echo "<meta name='robots' content='noindex,nofollow' />\n";
}
+/**
+ * Determine if TinyMCE is available.
+ *
+ * Checks to see if the user has deleted the tinymce files to slim down there WordPress install.
+ *
+ * @since 2.1.0
+ *
+ * @return bool Whether of not TinyMCE exists.
+ */
function rich_edit_exists() {
global $wp_rich_edit_exists;
if ( !isset($wp_rich_edit_exists) )
return $wp_rich_edit_exists;
}
+/**
+ * Whether or not the user should have a WYSIWIG editor.
+ *
+ * Checks that the user requires a WYSIWIG editor and that the editor is
+ * supported in the users browser.
+ *
+ * @since 2.0.0
+ *
+ * @return bool
+ */
function user_can_richedit() {
global $wp_rich_edit, $pagenow;
return apply_filters('user_can_richedit', $wp_rich_edit);
}
+/**
+ * Find out which editor should be displayed by default.
+ *
+ * Works out which of the two editors to display as the current editor for a
+ * user.
+ *
+ * @since 2.5.0
+ *
+ * @return string Either 'tinymce', or 'html', or 'test'
+ */
function wp_default_editor() {
$r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
if ( $user = wp_get_current_user() ) { // look for cookie
- if ( isset($_COOKIE['wordpress_editor_' . $user->ID]) && in_array($_COOKIE['wordpress_editor_' . $user->ID], array('tinymce', 'html', 'test') ) )
- $r = $_COOKIE['wordpress_editor_' . $user->ID];
+ $ed = get_user_setting('editor', 'tinymce');
+ $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
}
return apply_filters( 'wp_default_editor', $r ); // filter
}
+/**
+ * Display visual editor forms: TinyMCE, or HTML, or both.
+ *
+ * The amount of rows the text area will have for the content has to be between
+ * 3 and 100 or will default at 12. There is only one option used for all users,
+ * named 'default_post_edit_rows'.
+ *
+ * If the user can not use the rich editor (TinyMCE), then the switch button
+ * will not be displayed.
+ *
+ * @since 2.1.0
+ *
+ * @param string $content Textarea content.
+ * @param string $id HTML ID attribute value.
+ * @param string $prev_id HTML ID name for switching back and forth between visual editors.
+ * @param bool $media_buttons Optional, default is true. Whether to display media buttons.
+ * @param int $tab_index Optional, default is 2. Tabindex for textarea element.
+ */
function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2) {
$rows = get_option('default_post_edit_rows');
if (($rows < 3) || ($rows > 100))
$rows = 12;
- $rows = "rows='$rows'"; ?>
+ if ( !current_user_can( 'upload_files' ) )
+ $media_buttons = false;
+
+ $richedit = user_can_richedit();
+ $rows = "rows='$rows'";
+
+ if ( $richedit || $media_buttons ) { ?>
<div id="editor-toolbar">
- <?php if ( user_can_richedit() ) {
+ <?php if ( $richedit ) {
$wp_default_editor = wp_default_editor(); ?>
<div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
- <?php if ( 'tinymce' == $wp_default_editor ) {
- add_filter('the_editor_content', 'wp_richedit_pre'); ?>
- <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>');"><?php _e('HTML'); ?></a>
- <a id="edButtonPreview" class="active"><?php _e('Visual'); ?></a>
- <?php } elseif ( 'html' == $wp_default_editor ) {
+ <?php if ( 'html' == $wp_default_editor ) {
add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
- <a id="edButtonHTML" class="active"><?php _e('HTML'); ?></a>
- <a id="edButtonPreview" onclick="switchEditors.go('<?php echo $id; ?>');"><?php _e('Visual'); ?></a>
+ <a id="edButtonHTML" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
+ <a id="edButtonPreview" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
+ <?php } else {
+ add_filter('the_editor_content', 'wp_richedit_pre'); ?>
+ <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
+ <a id="edButtonPreview" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
<?php }
- }
+ }
- if ( $media_buttons ) { ?>
- <div id="media-buttons" class="hide-if-no-js">
- <?php do_action( 'media_buttons' ); ?>
- </div>
- <?php } ?>
+ if ( $media_buttons ) { ?>
+ <div id="media-buttons" class="hide-if-no-js">
+ <?php do_action( 'media_buttons' ); ?>
+ </div>
+ <?php } ?>
</div>
+ <?php } ?>
<div id="quicktags">
<?php wp_print_scripts( 'quicktags' ); ?>
<script type="text/javascript">edToolbar()</script>
</div>
- <?php if ( 'html' != $wp_default_editor ) : ?>
- <script type="text/javascript">
- // <![CDATA[
- if ( typeof tinyMCE != "undefined" )
- document.getElementById("quicktags").style.display="none";
- // ]]>
- </script>
- <?php endif; // 'html' != $wp_default_editor
-
- $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea class='' $rows cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
+ <?php $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea $rows cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
$the_editor_content = apply_filters('the_editor_content', $content);
printf($the_editor, $the_editor_content);
?>
- <script type="text/javascript">
- // <![CDATA[
- edCanvas = document.getElementById('<?php echo $id; ?>');
- <?php if ( $prev_id && user_can_richedit() ) : ?>
- // If tinyMCE is defined.
- if ( typeof tinyMCE != 'undefined' ) {
- // This code is meant to allow tabbing from Title to Post (TinyMCE).
- document.getElementById('<?php echo $prev_id; ?>').onkeydown = function (e) {
- e = e || window.event;
- if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
- if ( tinyMCE.activeEditor ) {
- if ( (jQuery("#post_ID").val() < 1) && (jQuery("#title").val().length > 0) ) { autosave(); }
- e = null;
- if ( tinyMCE.activeEditor.isHidden() ) return true;
- tinyMCE.activeEditor.focus();
- return false;
- }
- return true;
- }
- }
- }
- <?php endif; ?>
- // ]]>
- </script>
- <?php
+ <script type="text/javascript">
+ // <![CDATA[
+ edCanvas = document.getElementById('<?php echo $id; ?>');
+ <?php if ( user_can_richedit() && $prev_id ) { ?>
+ var dotabkey = true;
+ // If tinyMCE is defined.
+ if ( typeof tinyMCE != 'undefined' ) {
+ // This code is meant to allow tabbing from Title to Post (TinyMCE).
+ jQuery('#<?php echo $prev_id; ?>')[jQuery.browser.opera ? 'keypress' : 'keydown'](function (e) {
+ if (e.which == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
+ if ( (jQuery("#post_ID").val() < 1) && (jQuery("#title").val().length > 0) ) { autosave(); }
+ if ( tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden() && dotabkey ) {
+ e.preventDefault();
+ dotabkey = false;
+ tinyMCE.activeEditor.focus();
+ return false;
+ }
+ }
+ });
+ }
+ <?php } ?>
+ // ]]>
+ </script>
+ <?php
}
+/**
+ * Retrieve the contents of the search WordPress query variable.
+ *
+ * @since 2.3.0
+ *
+ * @return string
+ */
function get_search_query() {
return apply_filters( 'get_search_query', stripslashes( get_query_var( 's' ) ) );
}
+/**
+ * Display the contents of the search query variable.
+ *
+ * The search query string is passed through {@link attribute_escape()}
+ * to ensure that it is safe for placing in an html attribute.
+ *
+ * @uses attribute_escape
+ * @since 2.1.0
+ */
function the_search_query() {
echo attribute_escape( apply_filters( 'the_search_query', get_search_query() ) );
}
+/**
+ * Display the language attributes for the html tag.
+ *
+ * Builds up a set of html attributes containing the text direction and language
+ * information for the page.
+ *
+ * @since 2.1.0
+ *
+ * @param string $doctype The type of html document (xhtml|html).
+ */
function language_attributes($doctype = 'html') {
$attributes = array();
$output = '';
$attributes[] = "dir=\"$dir\"";
if ( $lang = get_bloginfo('language') ) {
- if ( get_option('html_type') == 'text/html' || $doctype == 'xhtml' )
+ if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
$attributes[] = "lang=\"$lang\"";
if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
echo $output;
}
+/**
+ * Retrieve paginated link for archive post pages.
+ *
+ * Technically, the function can be used to create paginated link list for any
+ * area. The 'base' argument is used to reference the url, which will be used to
+ * create the paginated links. The 'format' argument is then used for replacing
+ * the page number. It is however, most likely and by default, to be used on the
+ * archive post pages.
+ *
+ * The 'type' argument controls format of the returned value. The default is
+ * 'plain', which is just a string with the links separated by a newline
+ * character. The other possible values are either 'array' or 'list'. The
+ * 'array' value will return an array of the paginated link list to offer full
+ * control of display. The 'list' value will place all of the paginated links in
+ * an unordered HTML list.
+ *
+ * The 'total' argument is the total amount of pages and is an integer. The
+ * 'current' argument is the current page number and is also an integer.
+ *
+ * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
+ * and the '%_%' is required. The '%_%' will be replaced by the contents of in
+ * the 'format' argument. An example for the 'format' argument is "?page=%#%"
+ * and the '%#%' is also required. The '%#%' will be replaced with the page
+ * number.
+ *
+ * You can include the previous and next links in the list by setting the
+ * 'prev_next' argument to true, which it is by default. You can set the
+ * previous text, by using the 'prev_text' argument. You can set the next text
+ * by setting the 'next_text' argument.
+ *
+ * If the 'show_all' argument is set to true, then it will show all of the pages
+ * instead of a short list of the pages near the current page. By default, the
+ * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
+ * arguments. The 'end_size' argument is how many numbers on either the start
+ * and the end list edges, by default is 1. The 'mid_size' argument is how many
+ * numbers to either side of current page, but not including current page.
+ *
+ * It is possible to add query vars to the link by using the 'add_args' argument
+ * and see {@link add_query_arg()} for more information.
+ *
+ * @since 2.1.0
+ *
+ * @param string|array $args Optional. Override defaults.
+ * @return array|string String of page links or array of page links.
+ */
function paginate_links( $args = '' ) {
$defaults = array(
'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
'prev_next' => true,
'prev_text' => __('« Previous'),
'next_text' => __('Next »'),
- 'end_size' => 1, // How many numbers on either end including the end
- 'mid_size' => 2, // How many numbers to either side of current not including current
+ 'end_size' => 1,
+ 'mid_size' => 2,
'type' => 'plain',
- 'add_args' => false // array of query args to aadd
+ 'add_args' => false, // array of query args to add
+ 'add_fragment' => ''
);
$args = wp_parse_args( $args, $defaults );
extract($args, EXTR_SKIP);
// Who knows what else people pass in $args
- $total = (int) $total;
+ $total = (int) $total;
if ( $total < 2 )
return;
$current = (int) $current;
$link = str_replace('%#%', $current - 1, $link);
if ( $add_args )
$link = add_query_arg( $add_args, $link );
+ $link .= $add_fragment;
$page_links[] = "<a class='prev page-numbers' href='" . clean_url($link) . "'>$prev_text</a>";
endif;
for ( $n = 1; $n <= $total; $n++ ) :
+ $n_display = number_format_i18n($n);
if ( $n == $current ) :
- $page_links[] = "<span class='page-numbers current'>$n</span>";
+ $page_links[] = "<span class='page-numbers current'>$n_display</span>";
$dots = true;
else :
if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
$link = str_replace('%#%', $n, $link);
if ( $add_args )
$link = add_query_arg( $add_args, $link );
- $page_links[] = "<a class='page-numbers' href='" . clean_url($link) . "'>$n</a>";
+ $link .= $add_fragment;
+ $page_links[] = "<a class='page-numbers' href='" . clean_url($link) . "'>$n_display</a>";
$dots = true;
elseif ( $dots && !$show_all ) :
$page_links[] = "<span class='page-numbers dots'>...</span>";
$link = str_replace('%#%', $current + 1, $link);
if ( $add_args )
$link = add_query_arg( $add_args, $link );
+ $link .= $add_fragment;
$page_links[] = "<a class='next page-numbers' href='" . clean_url($link) . "'>$next_text</a>";
endif;
switch ( $type ) :
return $r;
}
+/**
+ * Registers an admin colour scheme css file.
+ *
+ * Allows a plugin to register a new admin colour scheme. For example:
+ * <code>
+ * wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"),
+ * array('#07273E', '#14568A', '#D54E21', '#2683AE'));
+ * </code>
+ *
+ * @since 2.5.0
+ *
+ * @param string $key The unique key for this theme.
+ * @param string $name The name of the theme.
+ * @param string $url The url of the css file containing the colour scheme.
+ * @param array @colors An array of CSS color definitions which are used to give the user a feel for the theme.
+ */
function wp_admin_css_color($key, $name, $url, $colors = array()) {
global $_wp_admin_css_colors;
}
/**
- * wp_admin_css_uri() - Outputs the URL of a WordPress admin CSS file
+ * Display the URL of a WordPress admin CSS file.
*
* @see WP_Styles::_css_href and its style_loader_src filter.
*
+ * @since 2.3.0
+ *
* @param string $file file relative to wp-admin/ without its ".css" extension.
*/
-
function wp_admin_css_uri( $file = 'wp-admin' ) {
if ( defined('WP_INSTALLING') ) {
$_file = "./$file.css";
}
/**
- * wp_admin_css() - Enqueues or directly prints a stylesheet link to the specified CSS file.
+ * Enqueues or directly prints a stylesheet link to the specified CSS file.
*
- * "Intelligently" decides to enqueue or to print the CSS file.
- * If the wp_print_styles action has *not* yet been called, the CSS file will be enqueued.
- * If the wp_print_styles action *has* been called, the CSS link will be printed.
- * Printing may be forced by passing TRUE as the $force_echo (second) parameter.
+ * "Intelligently" decides to enqueue or to print the CSS file. If the
+ * 'wp_print_styles' action has *not* yet been called, the CSS file will be
+ * enqueued. If the wp_print_styles action *has* been called, the CSS link will
+ * be printed. Printing may be forced by passing TRUE as the $force_echo
+ * (second) parameter.
*
- * For backward compatibility with WordPress 2.3 calling method:
- * If the $file (first) parameter does not correspond to a registered CSS file, we assume $file is a
- * file relative to wp-admin/ without its ".css" extension. A stylesheet link to that generated URL is printed.
+ * For backward compatibility with WordPress 2.3 calling method: If the $file
+ * (first) parameter does not correspond to a registered CSS file, we assume
+ * $file is a file relative to wp-admin/ without its ".css" extension. A
+ * stylesheet link to that generated URL is printed.
*
* @package WordPress
- * @since 2.3
- *
+ * @since 2.3.0
* @uses $wp_styles WordPress Styles Object
*
* @param string $file Style handle name or file name (without ".css" extension) relative to wp-admin/
* @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
*/
-
function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
global $wp_styles;
if ( !is_a($wp_styles, 'WP_Styles') )
}
/**
- * Enqueues the default ThickBox js and css.
- * If any of the settings need to be changed, this can be done with another js file
- * similar to media-upload.js and theme-preview.js. That file should require array('thickbox')
- * to ensure it is loaded after.
+ * Enqueues the default ThickBox js and css.
+ *
+ * If any of the settings need to be changed, this can be done with another js
+ * file similar to media-upload.js and theme-preview.js. That file should
+ * require array('thickbox') to ensure it is loaded after.
+ *
+ * @since 2.5.0
*/
function add_thickbox() {
wp_enqueue_script( 'thickbox' );
}
/**
- * Outputs the XHTML generator that is generated on the wp_head hook.
+ * Display the XHTML generator that is generated on the wp_head hook.
+ *
+ * @since 2.5.0
*/
-function wp_generator()
-{
+function wp_generator() {
the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
}
/**
- * Outputs the generator XML or Comment for RSS, ATOM, etc.
- * @param {String} $type The type of generator to return.
+ * Display the generator XML or Comment for RSS, ATOM, etc.
+ *
+ * Returns the correct generator type for the requested output format. Allows
+ * for a plugin to filter generators overall the the_generator filter.
+ *
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'the_generator' hook.
+ *
+ * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
*/
-function the_generator ( $type ) {
- echo apply_filters('the_generator',get_the_generator($type),$type) . "\n";
+function the_generator( $type ) {
+ echo apply_filters('the_generator', get_the_generator($type), $type) . "\n";
}
/**
* Creates the generator XML or Comment for RSS, ATOM, etc.
- * @param {String} $type The type of generator to return.
+ *
+ * Returns the correct generator type for the requested output format. Allows
+ * for a plugin to filter generators on an individual basis using the
+ * 'get_the_generator_{$type}' filter.
+ *
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'get_the_generator_$type' hook.
+ *
+ * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
+ * @return string The HTML content for the generator.
*/
-function get_the_generator ( $type ) {
+function get_the_generator( $type ) {
switch ($type) {
case 'html':
$gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">' . "\n";
}
return apply_filters( "get_the_generator_{$type}", $gen, $type );
}
+
?>
--- /dev/null
+<?php
+/**
+ * Simple and uniform HTTP request API.
+ *
+ * Will eventually replace and standardize the WordPress HTTP requests made.
+ *
+ * @link http://trac.wordpress.org/ticket/4779 HTTP API Proposal
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7
+ * @author Jacob Santos <wordpress@santosj.name>
+ */
+
+/**
+ * WordPress HTTP Class for managing HTTP Transports and making HTTP requests.
+ *
+ * This class is called for the functionality of making HTTP requests and should
+ * replace Snoopy functionality, eventually. There is no available functionality
+ * to add HTTP transport implementations, since most of the HTTP transports are
+ * added and available for use.
+ *
+ * The exception is that cURL is not available as a transport and lacking an
+ * implementation. It will be added later and should be a patch on the WordPress
+ * Trac.
+ *
+ * There are no properties, because none are needed and for performance reasons.
+ * Some of the functions are static and while they do have some overhead over
+ * functions in PHP4, the purpose is maintainability. When PHP5 is finally the
+ * requirement, it will be easy to add the static keyword to the code. It is not
+ * as easy to convert a function to a method after enough code uses the old way.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7
+ */
+class WP_Http {
+
+ /**
+ * PHP4 style Constructor - Calls PHP5 Style Constructor
+ *
+ * @since 2.7
+ * @return WP_Http
+ */
+ function WP_Http() {
+ $this->__construct();
+ }
+
+ /**
+ * PHP5 style Constructor - Setup available transport if not available.
+ *
+ * PHP4 does not have the 'self' keyword and since WordPress supports PHP4,
+ * the class needs to be used for the static call.
+ *
+ * The transport are setup to save time. This should only be called once, so
+ * the overhead should be fine.
+ *
+ * @since 2.7
+ * @return WP_Http
+ */
+ function __construct() {
+ WP_Http::_getTransport();
+ WP_Http::_postTransport();
+ }
+
+ /**
+ * Tests the WordPress HTTP objects for an object to use and returns it.
+ *
+ * Tests all of the objects and returns the object that passes. Also caches
+ * that object to be used later.
+ *
+ * The order for the GET/HEAD requests are Streams, HTTP Extension, Fopen,
+ * and finally Fsockopen. fsockopen() is used last, because it has the most
+ * overhead in its implementation. There isn't any real way around it, since
+ * redirects have to be supported, much the same way the other transports
+ * also handle redirects.
+ *
+ * There are currently issues with "localhost" not resolving correctly with
+ * DNS. This may cause an error "failed to open stream: A connection attempt
+ * failed because the connected party did not properly respond after a
+ * period of time, or established connection failed because connected host
+ * has failed to respond."
+ *
+ * @since 2.7
+ * @access private
+ *
+ * @param array $args Request args, default us an empty array
+ * @return object|null Null if no transports are available, HTTP transport object.
+ */
+ function &_getTransport( $args = array() ) {
+ static $working_transport, $blocking_transport, $nonblocking_transport;
+
+ if ( is_null($working_transport) ) {
+ if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) {
+ $working_transport['exthttp'] = new WP_Http_ExtHttp();
+ $blocking_transport[] = &$working_transport['exthttp'];
+ } else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) {
+ $working_transport['curl'] = new WP_Http_Curl();
+ $blocking_transport[] = &$working_transport['curl'];
+ } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) {
+ $working_transport['streams'] = new WP_Http_Streams();
+ $blocking_transport[] = &$working_transport['streams'];
+ } else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) ) {
+ $working_transport['fopen'] = new WP_Http_Fopen();
+ $blocking_transport[] = &$working_transport['fopen'];
+ } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) {
+ $working_transport['fsockopen'] = new WP_Http_Fsockopen();
+ $blocking_transport[] = &$working_transport['fsockopen'];
+ }
+
+ foreach ( array('curl', 'streams', 'fopen', 'fsockopen', 'exthttp') as $transport ) {
+ if ( isset($working_transport[$transport]) )
+ $nonblocking_transport[] = &$working_transport[$transport];
+ }
+ }
+
+ if ( isset($args['blocking']) && !$args['blocking'] )
+ return $nonblocking_transport;
+ else
+ return $blocking_transport;
+ }
+
+ /**
+ * Tests the WordPress HTTP objects for an object to use and returns it.
+ *
+ * Tests all of the objects and returns the object that passes. Also caches
+ * that object to be used later. This is for posting content to a URL and
+ * is used when there is a body. The plain Fopen Transport can not be used
+ * to send content, but the streams transport can. This is a limitation that
+ * is addressed here, by just not including that transport.
+ *
+ * @since 2.7
+ * @access private
+ *
+ * @param array $args Request args, default us an empty array
+ * @return object|null Null if no transports are available, HTTP transport object.
+ */
+ function &_postTransport( $args = array() ) {
+ static $working_transport, $blocking_transport, $nonblocking_transport;
+
+ if ( is_null($working_transport) ) {
+ if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) {
+ $working_transport['exthttp'] = new WP_Http_ExtHttp();
+ $blocking_transport[] = &$working_transport['exthttp'];
+ } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) {
+ $working_transport['streams'] = new WP_Http_Streams();
+ $blocking_transport[] = &$working_transport['streams'];
+ } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) {
+ $working_transport['fsockopen'] = new WP_Http_Fsockopen();
+ $blocking_transport[] = &$working_transport['fsockopen'];
+ }
+
+ foreach ( array('streams', 'fsockopen', 'exthttp') as $transport ) {
+ if ( isset($working_transport[$transport]) )
+ $nonblocking_transport[] = &$working_transport[$transport];
+ }
+ }
+
+ if ( isset($args['blocking']) && !$args['blocking'] )
+ return $nonblocking_transport;
+ else
+ return $blocking_transport;
+ }
+
+ /**
+ * Send a HTTP request to a URI.
+ *
+ * The body and headers are part of the arguments. The 'body' argument is
+ * for the body and will accept either a string or an array. The 'headers'
+ * argument should be an array, but a string is acceptable. If the 'body'
+ * argument is an array, then it will automatically be escaped using
+ * http_build_query().
+ *
+ * The only URI that are supported in the HTTP Transport implementation are
+ * the HTTP and HTTPS protocols. HTTP and HTTPS are assumed so the server
+ * might not know how to handle the send headers. Other protocols are
+ * unsupported and most likely will fail.
+ *
+ * The defaults are 'method', 'timeout', 'redirection', 'httpversion',
+ * 'blocking' and 'user-agent'.
+ *
+ * Accepted 'method' values are 'GET', 'POST', and 'HEAD', some transports
+ * technically allow others, but should not be assumed. The 'timeout' is
+ * used to sent how long the connection should stay open before failing when
+ * no response. 'redirection' is used to track how many redirects were taken
+ * and used to sent the amount for other transports, but not all transports
+ * accept setting that value.
+ *
+ * The 'httpversion' option is used to sent the HTTP version and accepted
+ * values are '1.0', and '1.1' and should be a string. Version 1.1 is not
+ * supported, because of chunk response. The 'user-agent' option is the
+ * user-agent and is used to replace the default user-agent, which is
+ * 'WordPress/WP_Version', where WP_Version is the value from $wp_version.
+ *
+ * 'blocking' is the default, which is used to tell the transport, whether
+ * it should halt PHP while it performs the request or continue regardless.
+ * Actually, that isn't entirely correct. Blocking mode really just means
+ * whether the fread should just pull what it can whenever it gets bytes or
+ * if it should wait until it has enough in the buffer to read or finishes
+ * reading the entire content. It doesn't actually always mean that PHP will
+ * continue going after making the request.
+ *
+ * @access public
+ * @since 2.7
+ *
+ * @param string $url URI resource.
+ * @param str|array $args Optional. Override the defaults.
+ * @return boolean
+ */
+ function request( $url, $args = array() ) {
+ global $wp_version;
+
+ $defaults = array(
+ 'method' => 'GET',
+ 'timeout' => apply_filters( 'http_request_timeout', 5),
+ 'redirection' => apply_filters( 'http_request_redirection_count', 5),
+ 'httpversion' => apply_filters( 'http_request_version', '1.0'),
+ 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version ),
+ 'blocking' => true,
+ 'headers' => array(), 'body' => null
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+ $r = apply_filters( 'http_request_args', $r );
+
+ if ( is_null( $r['headers'] ) )
+ $r['headers'] = array();
+
+ if ( ! is_array($r['headers']) ) {
+ $processedHeaders = WP_Http::processHeaders($r['headers']);
+ $r['headers'] = $processedHeaders['headers'];
+ }
+
+ if ( isset($r['headers']['User-Agent']) ) {
+ $r['user-agent'] = $r['headers']['User-Agent'];
+ unset($r['headers']['User-Agent']);
+ }
+
+ if ( isset($r['headers']['user-agent']) ) {
+ $r['user-agent'] = $r['headers']['user-agent'];
+ unset($r['headers']['user-agent']);
+ }
+
+ if ( is_null($r['body']) ) {
+ // Some servers fail when sending content without the content-length
+ // header being set.
+ $r['headers']['Content-Length'] = 0;
+ $transports = WP_Http::_getTransport($r);
+ } else {
+ if ( is_array( $r['body'] ) || is_object( $r['body'] ) ) {
+ $r['body'] = http_build_query($r['body'], null, '&');
+ $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset');
+ $r['headers']['Content-Length'] = strlen($r['body']);
+ }
+
+ if ( ! isset( $r['headers']['Content-Length'] ) && ! isset( $r['headers']['content-length'] ) )
+ $r['headers']['Content-Length'] = strlen($r['body']);
+
+ $transports = WP_Http::_postTransport($r);
+ }
+
+ $response = array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') );
+ foreach( (array) $transports as $transport ) {
+ $response = $transport->request($url, $r);
+
+ if( !is_wp_error($response) )
+ return $response;
+ }
+
+ return $response;
+ }
+
+ /**
+ * Uses the POST HTTP method.
+ *
+ * Used for sending data that is expected to be in the body.
+ *
+ * @access public
+ * @since 2.7
+ *
+ * @param string $url URI resource.
+ * @param str|array $args Optional. Override the defaults.
+ * @return boolean
+ */
+ function post($url, $args = array()) {
+ $defaults = array('method' => 'POST');
+ $r = wp_parse_args( $args, $defaults );
+ return $this->request($url, $r);
+ }
+
+ /**
+ * Uses the GET HTTP method.
+ *
+ * Used for sending data that is expected to be in the body.
+ *
+ * @access public
+ * @since 2.7
+ *
+ * @param string $url URI resource.
+ * @param str|array $args Optional. Override the defaults.
+ * @return boolean
+ */
+ function get($url, $args = array()) {
+ $defaults = array('method' => 'GET');
+ $r = wp_parse_args( $args, $defaults );
+ return $this->request($url, $r);
+ }
+
+ /**
+ * Uses the HEAD HTTP method.
+ *
+ * Used for sending data that is expected to be in the body.
+ *
+ * @access public
+ * @since 2.7
+ *
+ * @param string $url URI resource.
+ * @param str|array $args Optional. Override the defaults.
+ * @return boolean
+ */
+ function head($url, $args = array()) {
+ $defaults = array('method' => 'HEAD');
+ $r = wp_parse_args( $args, $defaults );
+ return $this->request($url, $r);
+ }
+
+ /**
+ * Parses the responses and splits the parts into headers and body.
+ *
+ * @access public
+ * @static
+ * @since 2.7
+ *
+ * @param string $strResponse The full response string
+ * @return array Array with 'headers' and 'body' keys.
+ */
+ function processResponse($strResponse) {
+ list($theHeaders, $theBody) = explode("\r\n\r\n", $strResponse, 2);
+ return array('headers' => $theHeaders, 'body' => $theBody);
+ }
+
+ /**
+ * Transform header string into an array.
+ *
+ * If an array is given then it is assumed to be raw header data with
+ * numeric keys with the headers as the values. No headers must be passed
+ * that were already processed.
+ *
+ * @access public
+ * @static
+ * @since 2.7
+ *
+ * @param string|array $headers
+ * @return array Processed string headers
+ */
+ function processHeaders($headers) {
+ if ( is_string($headers) )
+ $headers = explode("\n", str_replace(array("\r\n", "\r"), "\n", $headers) );
+
+ $response = array('code' => 0, 'message' => '');
+
+ $newheaders = array();
+ foreach ( $headers as $tempheader ) {
+ if ( empty($tempheader) )
+ continue;
+
+ if ( false === strpos($tempheader, ':') ) {
+ list( , $iResponseCode, $strResponseMsg) = explode(' ', $tempheader, 3);
+ $response['code'] = $iResponseCode;
+ $response['message'] = $strResponseMsg;
+ continue;
+ }
+
+ list($key, $value) = explode(':', $tempheader, 2);
+
+ if ( ! empty($value) )
+ $newheaders[strtolower($key)] = trim($value);
+ }
+
+ return array('response' => $response, 'headers' => $newheaders);
+ }
+
+ /**
+ * Decodes chunk transfer-encoding, based off the HTTP 1.1 specification.
+ *
+ * Based off the HTTP http_encoding_dechunk function. Does not support
+ * UTF-8. Does not support returning footer headers. Shouldn't be too
+ * difficult to support it though.
+ *
+ * @todo Add support for footer chunked headers.
+ * @access public
+ * @since 2.7
+ * @static
+ *
+ * @param string $body Body content
+ * @return string Chunked decoded body on success or raw body on failure.
+ */
+ function chunkTransferDecode($body) {
+ $body = str_replace(array("\r\n", "\r"), "\n", $body);
+ // The body is not chunked encoding or is malformed.
+ if ( ! preg_match( '/^[0-9a-f]+(\s|\n)+/mi', trim($body) ) )
+ return $body;
+
+ $parsedBody = '';
+ //$parsedHeaders = array(); Unsupported
+
+ while ( true ) {
+ $hasChunk = (bool) preg_match( '/^([0-9a-f]+)(\s|\n)+/mi', $body, $match );
+
+ if ( $hasChunk ) {
+ if ( empty($match[1]) )
+ return $body;
+
+ $length = hexdec( $match[1] );
+ $chunkLength = strlen( $match[0] );
+
+ $strBody = substr($body, $chunkLength, $length);
+ $parsedBody .= $strBody;
+
+ $body = ltrim(str_replace(array($match[0], $strBody), '', $body), "\n");
+
+ if( "0" == trim($body) )
+ return $parsedBody; // Ignore footer headers.
+ } else {
+ return $body;
+ }
+ }
+ }
+}
+
+/**
+ * HTTP request method uses fsockopen function to retrieve the url.
+ *
+ * This would be the preferred method, but the fsockopen implementation has the
+ * most overhead of all the HTTP transport implementations.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7
+ */
+class WP_Http_Fsockopen {
+ /**
+ * Send a HTTP request to a URI using fsockopen().
+ *
+ * Does not support non-blocking mode.
+ *
+ * @see WP_Http::request For default options descriptions.
+ *
+ * @since 2.7
+ * @access public
+ * @param string $url URI resource.
+ * @param str|array $args Optional. Override the defaults.
+ * @return array 'headers', 'body', and 'response' keys.
+ */
+ function request($url, $args = array()) {
+ $defaults = array(
+ 'method' => 'GET', 'timeout' => 5,
+ 'redirection' => 5, 'httpversion' => '1.0',
+ 'blocking' => true,
+ 'headers' => array(), 'body' => null
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+
+ if ( isset($r['headers']['User-Agent']) ) {
+ $r['user-agent'] = $r['headers']['User-Agent'];
+ unset($r['headers']['User-Agent']);
+ } else if( isset($r['headers']['user-agent']) ) {
+ $r['user-agent'] = $r['headers']['user-agent'];
+ unset($r['headers']['user-agent']);
+ }
+
+ $iError = null; // Store error number
+ $strError = null; // Store error string
+
+ $arrURL = parse_url($url);
+
+ $secure_transport = false;
+
+ if ( ! isset($arrURL['port']) ) {
+ if ( ($arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https') && extension_loaded('openssl') ) {
+ $arrURL['host'] = 'ssl://' . $arrURL['host'];
+ $arrURL['port'] = apply_filters('http_request_port', 443);
+ $secure_transport = true;
+ } else {
+ $arrURL['port'] = apply_filters('http_request_default_port', 80);
+ }
+ } else {
+ $arrURL['port'] = apply_filters('http_request_port', $arrURL['port']);
+ }
+
+ // There are issues with the HTTPS and SSL protocols that cause errors
+ // that can be safely ignored and should be ignored.
+ if ( true === $secure_transport )
+ $error_reporting = error_reporting(0);
+
+ $startDelay = time();
+
+ if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )
+ $handle = @fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] );
+ else
+ $handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] );
+
+ $endDelay = time();
+
+ // If the delay is greater than the timeout then fsockopen should't be
+ // used, because it will cause a long delay.
+ $elapseDelay = ($endDelay-$startDelay) > $r['timeout'];
+ if ( true === $elapseDelay )
+ add_option( 'disable_fsockopen', $endDelay, null, true );
+
+ if ( false === $handle )
+ return new WP_Error('http_request_failed', $iError . ': ' . $strError);
+
+ // WordPress supports PHP 4.3, which has this function. Removed sanity
+ // checking for performance reasons.
+ stream_set_timeout($handle, $r['timeout'] );
+
+ $requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' );
+ $requestPath = empty($requestPath) ? '/' : $requestPath;
+
+ $strHeaders = '';
+ $strHeaders .= strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n";
+ $strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
+
+ if( isset($r['user-agent']) )
+ $strHeaders .= 'User-agent: ' . $r['user-agent'] . "\r\n";
+
+ if ( is_array($r['headers']) ) {
+ foreach ( (array) $r['headers'] as $header => $headerValue )
+ $strHeaders .= $header . ': ' . $headerValue . "\r\n";
+ } else {
+ $strHeaders .= $r['headers'];
+ }
+
+ $strHeaders .= "\r\n";
+
+ if ( ! is_null($r['body']) )
+ $strHeaders .= $r['body'];
+
+ fwrite($handle, $strHeaders);
+
+ if ( ! $r['blocking'] ) {
+ fclose($handle);
+ return array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') );
+ }
+
+ $strResponse = '';
+ while ( ! feof($handle) )
+ $strResponse .= fread($handle, 4096);
+
+ fclose($handle);
+
+ if ( true === $secure_transport )
+ error_reporting($error_reporting);
+
+ $process = WP_Http::processResponse($strResponse);
+ $arrHeaders = WP_Http::processHeaders($process['headers']);
+
+ // Is the response code within the 400 range?
+ if ( (int) $arrHeaders['response']['code'] >= 400 && (int) $arrHeaders['response']['code'] < 500 )
+ return new WP_Error('http_request_failed', $arrHeaders['response']['code'] . ': ' . $arrHeaders['response']['message']);
+
+ // If location is found, then assume redirect and redirect to location.
+ if ( isset($arrHeaders['headers']['location']) ) {
+ if ( $r['redirection']-- > 0 ) {
+ return $this->request($arrHeaders['headers']['location'], $r);
+ } else {
+ return new WP_Error('http_request_failed', __('Too many redirects.'));
+ }
+ }
+
+ // If the body was chunk encoded, then decode it.
+ if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] )
+ $process['body'] = WP_Http::chunkTransferDecode($process['body']);
+
+ return array('headers' => $arrHeaders['headers'], 'body' => $process['body'], 'response' => $arrHeaders['response']);
+ }
+
+ /**
+ * Whether this class can be used for retrieving an URL.
+ *
+ * @since 2.7
+ * @static
+ * @return boolean False means this class can not be used, true means it can.
+ */
+ function test() {
+ if ( false !== ($option = get_option( 'disable_fsockopen' )) && time()-$option < 43200 ) // 12 hours
+ return false;
+
+ if ( function_exists( 'fsockopen' ) )
+ return true;
+
+ return false;
+ }
+}
+
+/**
+ * HTTP request method uses fopen function to retrieve the url.
+ *
+ * Requires PHP version greater than 4.3.0 for stream support. Does not allow
+ * for $context support, but should still be okay, to write the headers, before
+ * getting the response. Also requires that 'allow_url_fopen' to be enabled.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7
+ */
+class WP_Http_Fopen {
+ /**
+ * Send a HTTP request to a URI using fopen().
+ *
+ * This transport does not support sending of headers and body, therefore
+ * should not be used in the instances, where there is a body and headers.
+ *
+ * Notes: Does not support non-blocking mode. Ignores 'redirection' option.
+ *
+ * @see WP_Http::retrieve For default options descriptions.
+ *
+ * @access public
+ * @since 2.7
+ *
+ * @param string $url URI resource.
+ * @param str|array $args Optional. Override the defaults.
+ * @return array 'headers', 'body', and 'response' keys.
+ */
+ function request($url, $args = array()) {
+ global $http_response_header;
+
+ $defaults = array(
+ 'method' => 'GET', 'timeout' => 5,
+ 'redirection' => 5, 'httpversion' => '1.0',
+ 'blocking' => true,
+ 'headers' => array(), 'body' => null
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+
+ $arrURL = parse_url($url);
+
+ if ( false === $arrURL )
+ return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url));
+
+ if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
+ $url = str_replace($arrURL['scheme'], 'http', $url);
+
+ if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )
+ $handle = @fopen($url, 'r');
+ else
+ $handle = fopen($url, 'r');
+
+ if (! $handle)
+ return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url));
+
+ // WordPress supports PHP 4.3, which has this function. Removed sanity
+ // checking for performance reasons.
+ stream_set_timeout($handle, $r['timeout'] );
+
+ if ( ! $r['blocking'] ) {
+ fclose($handle);
+ return array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') );
+ }
+
+ $strResponse = '';
+ while ( ! feof($handle) )
+ $strResponse .= fread($handle, 4096);
+
+ $theHeaders = '';
+ if ( function_exists('stream_get_meta_data') ) {
+ $meta = stream_get_meta_data($handle);
+ $theHeaders = $meta['wrapper_data'];
+ if( isset( $meta['wrapper_data']['headers'] ) )
+ $theHeaders = $meta['wrapper_data']['headers'];
+ } else {
+ if( ! isset( $http_response_header ) )
+ global $http_response_header;
+ $theHeaders = $http_response_header;
+ }
+
+ fclose($handle);
+
+ $processedHeaders = WP_Http::processHeaders($theHeaders);
+
+ if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] )
+ $strResponse = WP_Http::chunkTransferDecode($strResponse);
+
+ return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']);
+ }
+
+ /**
+ * Whether this class can be used for retrieving an URL.
+ *
+ * @static
+ * @return boolean False means this class can not be used, true means it can.
+ */
+ function test() {
+ if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) )
+ return false;
+
+ return true;
+ }
+}
+
+/**
+ * HTTP request method uses Streams to retrieve the url.
+ *
+ * Requires PHP 5.0+ and uses fopen with stream context. Requires that
+ * 'allow_url_fopen' PHP setting to be enabled.
+ *
+ * Second preferred method for getting the URL, for PHP 5.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7
+ */
+class WP_Http_Streams {
+ /**
+ * Send a HTTP request to a URI using streams with fopen().
+ *
+ * @access public
+ * @since 2.7
+ *
+ * @param string $url
+ * @param str|array $args Optional. Override the defaults.
+ * @return array 'headers', 'body', and 'response' keys.
+ */
+ function request($url, $args = array()) {
+ $defaults = array(
+ 'method' => 'GET', 'timeout' => 5,
+ 'redirection' => 5, 'httpversion' => '1.0',
+ 'blocking' => true,
+ 'headers' => array(), 'body' => null
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+
+ if ( isset($r['headers']['User-Agent']) ) {
+ $r['user-agent'] = $r['headers']['User-Agent'];
+ unset($r['headers']['User-Agent']);
+ } else if( isset($r['headers']['user-agent']) ) {
+ $r['user-agent'] = $r['headers']['user-agent'];
+ unset($r['headers']['user-agent']);
+ }
+
+ $arrURL = parse_url($url);
+
+ if ( false === $arrURL )
+ return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url));
+
+ if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
+ $url = str_replace($arrURL['scheme'], 'http', $url);
+
+ // Convert Header array to string.
+ $strHeaders = '';
+ if ( is_array( $r['headers'] ) )
+ foreach( $r['headers'] as $name => $value )
+ $strHeaders .= "{$name}: $value\r\n";
+ else if ( is_string( $r['headers'] ) )
+ $strHeaders = $r['headers'];
+
+ $arrContext = array('http' =>
+ array(
+ 'method' => strtoupper($r['method']),
+ 'user_agent' => $r['user-agent'],
+ 'max_redirects' => $r['redirection'],
+ 'protocol_version' => (float) $r['httpversion'],
+ 'header' => $strHeaders,
+ 'timeout' => $r['timeout']
+ )
+ );
+
+ if ( ! is_null($r['body']) && ! empty($r['body'] ) )
+ $arrContext['http']['content'] = $r['body'];
+
+ $context = stream_context_create($arrContext);
+
+ if ( ! defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )
+ $handle = @fopen($url, 'r', false, $context);
+ else
+ $handle = fopen($url, 'r', false, $context);
+
+ if ( ! $handle)
+ return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url));
+
+ // WordPress supports PHP 4.3, which has this function. Removed sanity
+ // checking for performance reasons.
+ stream_set_timeout($handle, $r['timeout'] );
+
+ if ( ! $r['blocking'] ) {
+ stream_set_blocking($handle, 0);
+ fclose($handle);
+ return array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') );
+ }
+
+ $strResponse = stream_get_contents($handle);
+ $meta = stream_get_meta_data($handle);
+
+ $processedHeaders = array();
+ if( isset( $meta['wrapper_data']['headers'] ) )
+ $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']['headers']);
+ else
+ $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']);
+
+ if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] )
+ $strResponse = WP_Http::chunkTransferDecode($strResponse);
+
+ fclose($handle);
+
+ return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']);
+ }
+
+ /**
+ * Whether this class can be used for retrieving an URL.
+ *
+ * @static
+ * @access public
+ * @since 2.7
+ *
+ * @return boolean False means this class can not be used, true means it can.
+ */
+ function test() {
+ if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) )
+ return false;
+
+ if ( version_compare(PHP_VERSION, '5.0', '<') )
+ return false;
+
+ return true;
+ }
+}
+
+/**
+ * HTTP request method uses HTTP extension to retrieve the url.
+ *
+ * Requires the HTTP extension to be installed. This would be the preferred
+ * transport since it can handle a lot of the problems that forces the others to
+ * use the HTTP version 1.0. Even if PHP 5.2+ is being used, it doesn't mean
+ * that the HTTP extension will be enabled.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7
+ */
+class WP_Http_ExtHTTP {
+ /**
+ * Send a HTTP request to a URI using HTTP extension.
+ *
+ * Does not support non-blocking.
+ *
+ * @access public
+ * @since 2.7
+ *
+ * @param string $url
+ * @param str|array $args Optional. Override the defaults.
+ * @return array 'headers', 'body', and 'response' keys.
+ */
+ function request($url, $args = array()) {
+ $defaults = array(
+ 'method' => 'GET', 'timeout' => 5,
+ 'redirection' => 5, 'httpversion' => '1.0',
+ 'blocking' => true,
+ 'headers' => array(), 'body' => null
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+
+ if ( isset($r['headers']['User-Agent']) ) {
+ $r['user-agent'] = $r['headers']['User-Agent'];
+ unset($r['headers']['User-Agent']);
+ } else if( isset($r['headers']['user-agent']) ) {
+ $r['user-agent'] = $r['headers']['user-agent'];
+ unset($r['headers']['user-agent']);
+ }
+
+ switch ( $r['method'] ) {
+ case 'POST':
+ $r['method'] = HTTP_METH_POST;
+ break;
+ case 'HEAD':
+ $r['method'] = HTTP_METH_HEAD;
+ break;
+ case 'GET':
+ default:
+ $r['method'] = HTTP_METH_GET;
+ }
+
+ $arrURL = parse_url($url);
+
+ if ( 'http' != $arrURL['scheme'] || 'https' != $arrURL['scheme'] )
+ $url = str_replace($arrURL['scheme'], 'http', $url);
+
+ $options = array(
+ 'timeout' => $r['timeout'],
+ 'connecttimeout' => $r['timeout'],
+ 'redirect' => $r['redirection'],
+ 'useragent' => $r['user-agent'],
+ 'headers' => $r['headers'],
+ );
+
+ if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) //Emits warning level notices for max redirects and timeouts
+ $strResponse = @http_request($r['method'], $url, $r['body'], $options, $info);
+ else
+ $strResponse = http_request($r['method'], $url, $r['body'], $options, $info); //Emits warning level notices for max redirects and timeouts
+
+ if ( false === $strResponse || ! empty($info['error']) ) //Error may still be set, Response may return headers or partial document, and error contains a reason the request was aborted, eg, timeout expired or max-redirects reached
+ return new WP_Error('http_request_failed', $info['response_code'] . ': ' . $info['error']);
+
+ if ( ! $r['blocking'] )
+ return array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') );
+
+ list($theHeaders, $theBody) = explode("\r\n\r\n", $strResponse, 2);
+ $theHeaders = WP_Http::processHeaders($theHeaders);
+
+ if ( ! empty( $theBody ) && isset( $theHeaders['headers']['transfer-encoding'] ) && 'chunked' == $theHeaders['headers']['transfer-encoding'] ) {
+ if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )
+ $theBody = @http_chunked_decode($theBody);
+ else
+ $theBody = http_chunked_decode($theBody);
+ }
+
+ $theResponse = array();
+ $theResponse['code'] = $info['response_code'];
+ $theResponse['message'] = get_status_header_desc($info['response_code']);
+
+ return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $theResponse);
+ }
+
+ /**
+ * Whether this class can be used for retrieving an URL.
+ *
+ * @static
+ * @since 2.7
+ *
+ * @return boolean False means this class can not be used, true means it can.
+ */
+ function test() {
+ if ( function_exists('http_request') )
+ return true;
+
+ return false;
+ }
+}
+
+/**
+ * HTTP request method uses Curl extension to retrieve the url.
+ *
+ * Requires the Curl extension to be installed.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7
+ */
+class WP_Http_Curl {
+ /**
+ * Send a HTTP request to a URI using cURL extension.
+ *
+ * @access public
+ * @since 2.7
+ *
+ * @param string $url
+ * @param str|array $args Optional. Override the defaults.
+ * @return array 'headers', 'body', and 'response' keys.
+ */
+ function request($url, $args = array()) {
+ $defaults = array(
+ 'method' => 'GET', 'timeout' => 5,
+ 'redirection' => 5, 'httpversion' => '1.0',
+ 'blocking' => true,
+ 'headers' => array(), 'body' => null
+ );
+
+ $r = wp_parse_args( $args, $defaults );
+
+ if ( isset($r['headers']['User-Agent']) ) {
+ $r['user-agent'] = $r['headers']['User-Agent'];
+ unset($r['headers']['User-Agent']);
+ } else if( isset($r['headers']['user-agent']) ) {
+ $r['user-agent'] = $r['headers']['user-agent'];
+ unset($r['headers']['user-agent']);
+ }
+
+ // cURL extension will sometimes fail when the timeout is less than 1 as
+ // it may round down to 0, which gives it unlimited timeout.
+ if ( $r['timeout'] > 0 && $r['timeout'] < 1 )
+ $r['timeout'] = 1;
+
+ $handle = curl_init();
+ curl_setopt( $handle, CURLOPT_URL, $url);
+
+ // The cURL extension requires that the option be set for the HEAD to
+ // work properly.
+ if ( 'HEAD' === $r['method'] ) {
+ curl_setopt( $handle, CURLOPT_NOBODY, true );
+ }
+
+ if ( true === $r['blocking'] ) {
+ curl_setopt( $handle, CURLOPT_HEADER, true );
+ curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 );
+ } else {
+ curl_setopt( $handle, CURLOPT_HEADER, false );
+ curl_setopt( $handle, CURLOPT_NOBODY, true );
+ curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 0 );
+ }
+
+ curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] );
+ curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 );
+ curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] );
+ curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] );
+
+ // The option doesn't work with safe mode or when open_basedir is set.
+ if ( !ini_get('safe_mode') && !ini_get('open_basedir') )
+ curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true );
+
+ if( ! is_null($r['headers']) )
+ curl_setopt( $handle, CURLOPT_HTTPHEADER, $r['headers'] );
+
+ if ( $r['httpversion'] == '1.0' )
+ curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 );
+ else
+ curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
+
+ if ( ! $r['blocking'] ) {
+ curl_exec( $handle );
+ curl_close( $handle );
+ return array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') );
+ }
+
+ $theResponse = curl_exec( $handle );
+
+ if ( !empty($theResponse) ) {
+ $headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
+ $theHeaders = trim( substr($theResponse, 0, $headerLength) );
+ $theBody = substr( $theResponse, $headerLength );
+ if ( false !== strrpos($theHeaders, "\r\n\r\n") ) {
+ $headerParts = explode("\r\n\r\n", $theHeaders);
+ $theHeaders = $headerParts[ count($headerParts) -1 ];
+ }
+ $theHeaders = WP_Http::processHeaders($theHeaders);
+ } else {
+ if ( $curl_error = curl_error($handle) )
+ return new WP_Error('http_request_failed', $curl_error);
+ if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) )
+ return new WP_Error('http_request_failed', __('Too many redirects.'));
+
+ $theHeaders = array( 'headers' => array() );
+ $theBody = '';
+ }
+ $response = array();
+ $response['code'] = curl_getinfo( $handle, CURLINFO_HTTP_CODE );
+ $response['message'] = get_status_header_desc($response['code']);
+
+ curl_close( $handle );
+
+ return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $response);
+ }
+
+ /**
+ * Whether this class can be used for retrieving an URL.
+ *
+ * @static
+ * @since 2.7
+ *
+ * @return boolean False means this class can not be used, true means it can.
+ */
+ function test() {
+ if ( function_exists('curl_init') && function_exists('curl_exec') )
+ return true;
+
+ return false;
+ }
+}
+
+/**
+ * Returns the initialized WP_Http Object
+ *
+ * @since 2.7
+ * @access private
+ *
+ * @return WP_Http HTTP Transport object.
+ */
+function &_wp_http_get_object() {
+ static $http;
+
+ if ( is_null($http) )
+ $http = new WP_Http();
+
+ return $http;
+}
+
+/**
+ * Retrieve the raw response from the HTTP request.
+ *
+ * The array structure is a little complex.
+ *
+ * <code>
+ * $res = array( 'headers' => array(), 'response' => array('code', 'message') );
+ * </code>
+ *
+ * All of the headers in $res['headers'] are with the name as the key and the
+ * value as the value. So to get the User-Agent, you would do the following.
+ *
+ * <code>
+ * $user_agent = $res['headers']['user-agent'];
+ * </code>
+ *
+ * The body is the raw response content and can be retrieved from $res['body'].
+ *
+ * This function is called first to make the request and there are other API
+ * functions to abstract out the above convoluted setup.
+ *
+ * @since 2.7.0
+ *
+ * @param string $url Site URL to retrieve.
+ * @param array $args Optional. Override the defaults.
+ * @return string The body of the response
+ */
+function wp_remote_request($url, $args = array()) {
+ $objFetchSite = _wp_http_get_object();
+ return $objFetchSite->request($url, $args);
+}
+
+/**
+ * Retrieve the raw response from the HTTP request using the GET method.
+ *
+ * @see wp_remote_request() For more information on the response array format.
+ *
+ * @since 2.7
+ *
+ * @param string $url Site URL to retrieve.
+ * @param array $args Optional. Override the defaults.
+ * @return string The body of the response
+ */
+function wp_remote_get($url, $args = array()) {
+ $objFetchSite = _wp_http_get_object();
+
+ return $objFetchSite->get($url, $args);
+}
+
+/**
+ * Retrieve the raw response from the HTTP request using the POST method.
+ *
+ * @see wp_remote_request() For more information on the response array format.
+ *
+ * @since 2.7
+ *
+ * @param string $url Site URL to retrieve.
+ * @param array $args Optional. Override the defaults.
+ * @return string The body of the response
+ */
+function wp_remote_post($url, $args = array()) {
+ $objFetchSite = _wp_http_get_object();
+ return $objFetchSite->post($url, $args);
+}
+
+/**
+ * Retrieve the raw response from the HTTP request using the HEAD method.
+ *
+ * @see wp_remote_request() For more information on the response array format.
+ *
+ * @since 2.7
+ *
+ * @param string $url Site URL to retrieve.
+ * @param array $args Optional. Override the defaults.
+ * @return string The body of the response
+ */
+function wp_remote_head($url, $args = array()) {
+ $objFetchSite = _wp_http_get_object();
+ return $objFetchSite->head($url, $args);
+}
+
+/**
+ * Retrieve only the headers from the raw response.
+ *
+ * @since 2.7
+ *
+ * @param array $response HTTP response.
+ * @return array The headers of the response. Empty array if incorrect parameter given.
+ */
+function wp_remote_retrieve_headers(&$response) {
+ if ( ! isset($response['headers']) || ! is_array($response['headers']))
+ return array();
+
+ return $response['headers'];
+}
+
+/**
+ * Retrieve a single header by name from the raw response.
+ *
+ * @since 2.7
+ *
+ * @param array $response
+ * @param string $header Header name to retrieve value from.
+ * @return array The header value. Empty string on if incorrect parameter given.
+ */
+function wp_remote_retrieve_header(&$response, $header) {
+ if ( ! isset($response['headers']) || ! is_array($response['headers']))
+ return '';
+
+ if ( array_key_exists($header, $response['headers']) )
+ return $response['headers'][$header];
+
+ return '';
+}
+
+/**
+ * Retrieve only the response code from the raw response.
+ *
+ * Will return an empty array if incorrect parameter value is given.
+ *
+ * @since 2.7
+ *
+ * @param array $response HTTP response.
+ * @return array The keys 'code' and 'message' give information on the response.
+ */
+function wp_remote_retrieve_response_code(&$response) {
+ if ( ! isset($response['response']) || ! is_array($response['response']))
+ return '';
+
+ return $response['response']['code'];
+}
+
+/**
+ * Retrieve only the response message from the raw response.
+ *
+ * Will return an empty array if incorrect parameter value is given.
+ *
+ * @since 2.7
+ *
+ * @param array $response HTTP response.
+ * @return array The keys 'code' and 'message' give information on the response.
+ */
+function wp_remote_retrieve_response_message(&$response) {
+ if ( ! isset($response['response']) || ! is_array($response['response']))
+ return '';
+
+ return $response['response']['message'];
+}
+
+/**
+ * Retrieve only the body from the raw response.
+ *
+ * @since 2.7
+ *
+ * @param array $response HTTP response.
+ * @return string The body of the response. Empty string if no body or incorrect parameter given.
+ */
+function wp_remote_retrieve_body(&$response) {
+ if ( ! isset($response['body']) )
+ return '';
+
+ return $response['body'];
+}
+
+?>
var autosaveLast = '';
var autosavePeriodical;
var autosaveOldMessage = '';
-var autosaveDelayURL = null;
-var previewwin;
+var autosaveDelayPreview = false;
+var autosaveFirst = true;
jQuery(function($) {
autosaveLast = $('#post #title').val()+$('#post #content').val();
//Disable autosave after the form has been submitted
$("#post").submit(function() { $.cancel(autosavePeriodical); });
-
- // Autosave when the preview button is clicked.
- $('#previewview a').click(function(e) {
- autosave();
- autosaveDelayURL = this.href;
- previewwin = window.open('','_blank');
-
- e.preventDefault();
- return false;
- });
});
function autosave_parse_response(response) {
});
}
- // if no errors: add preview link and slug UI
+ // if no errors: add slug UI
if ( !res.errors ) {
var postID = parseInt( res.responses[0].id );
if ( !isNaN(postID) && postID > 0 ) {
- autosave_update_preview_link(postID);
autosave_update_slug(postID);
}
}
var tempID = jQuery('#post_ID').val();
var postID = parseInt( res.responses[0].id );
autosave_update_post_ID( postID ); // disabled form buttons are re-enabled here
- if ( tempID < 0 && postID > 0) // update media buttons
+ if ( tempID < 0 && postID > 0 ) // update media buttons
jQuery('#media-buttons a').each(function(){
this.href = this.href.replace(tempID, postID);
});
+ // activate preview
+ autosaveFirst = false;
+ if ( autosaveDelayPreview )
+ jQuery('#post-preview').click();
} else {
autosave_enable_buttons(); // re-enable disabled form buttons
}
}
}
-function autosave_update_preview_link(post_id) {
- // Add preview button if not already there
- if ( !jQuery('#previewview > *').size() ) {
- var post_type = jQuery('#post_type').val();
- var previewText = 'page' == post_type ? autosaveL10n.previewPageText : autosaveL10n.previewPostText;
- jQuery.post(autosaveL10n.requestFile, {
- action: "get-permalink",
- post_id: post_id,
- getpermalinknonce: jQuery('#getpermalinknonce').val()
- }, function(permalink) {
- jQuery('#previewview').html('<a target="_blank" href="'+permalink+'" tabindex="4">'+previewText+'</a>');
-
- // Autosave when the preview button is clicked.
- jQuery('#previewview a').click(function(e) {
- autosave();
- autosaveDelayURL = this.href;
- previewwin = window.open('','_blank');
-
- e.preventDefault();
- return false;
- });
- });
- }
-}
-
function autosave_update_slug(post_id) {
// create slug area only if not already there
if ( jQuery.isFunction(make_slugedit_clickable) && !jQuery('#edit-slug-box > *').size() ) {
{
action: 'sample-permalink',
post_id: post_id,
- new_title: jQuery('#title').val(),
+ new_title: jQuery('#title').val(),
samplepermalinknonce: jQuery('#samplepermalinknonce').val()
},
function(data) {
}
function autosave_enable_buttons() {
- jQuery("#submitpost :button:disabled, #submitpost :submit:disabled").attr('disabled', '');
- if ( autosaveDelayURL ) {
- previewwin.location = autosaveDelayURL;
- autosaveDelayURL = null;
- }
+ jQuery(".submitbox :button:disabled, .submitbox :submit:disabled").attr('disabled', '');
}
function autosave_disable_buttons() {
- jQuery("#submitpost :button:enabled, #submitpost :submit:enabled").attr('disabled', 'disabled');
+ jQuery(".submitbox :button:enabled, .submitbox :submit:enabled").attr('disabled', 'disabled');
setTimeout(autosave_enable_buttons, 5000); // Re-enable 5 sec later. Just gives autosave a head start to avoid collisions.
}
doAutoSave = false;
/* Gotta do this up here so we can check the length when tinyMCE is in use */
- if ( rich ) {
+ if ( rich ) {
var ed = tinyMCE.activeEditor;
if ( 'mce_fullscreen' == ed.id )
tinyMCE.get('content').setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
tinyMCE.get('content').save();
}
-
+
post_data["content"] = jQuery("#content").val();
if ( jQuery('#post_name').val() )
post_data["post_name"] = jQuery('#post_name').val();
post_data["excerpt"] = jQuery("#excerpt").val();
if ( jQuery("#post_author").size() )
post_data["post_author"] = jQuery("#post_author").val();
+ post_data["user_ID"] = jQuery("#user-id").val();
// Don't run while the TinyMCE spellcheck is on. Why? Who knows.
if ( rich && tinyMCE.activeEditor.plugins.spellchecker && tinyMCE.activeEditor.plugins.spellchecker.active ) {
if(parseInt(post_data["post_ID"]) < 1) {
post_data["temp_ID"] = post_data["post_ID"];
- var successCallback = autosave_saved_new;; // new post
+ var successCallback = autosave_saved_new; // new post
} else {
var successCallback = autosave_saved; // pre-existing post
}
--- /dev/null
+
+addComment = {
+ moveForm : function(commId, parentId, respondId, postId) {
+ var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent'), post = t.I('comment_post_ID');
+
+ if ( ! comm || ! respond || ! cancel || ! parent )
+ return;
+
+ t.respondId = respondId;
+ postId = postId || false;
+
+ if ( ! t.I('wp-temp-form-div') ) {
+ div = document.createElement('div');
+ div.id = 'wp-temp-form-div';
+ div.style.display = 'none';
+ respond.parentNode.insertBefore(div, respond);
+ }
+
+ comm.parentNode.insertBefore(respond, comm.nextSibling);
+ if ( post && postId )
+ post.value = postId;
+ parent.value = parentId;
+ cancel.style.display = '';
+
+ cancel.onclick = function() {
+ var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId);
+
+ if ( ! temp || ! respond )
+ return;
+
+ t.I('comment_parent').value = '0';
+ temp.parentNode.insertBefore(respond, temp);
+ temp.parentNode.removeChild(temp);
+ this.style.display = 'none';
+ this.onclick = null;
+ return false;
+ }
+
+ try { t.I('comment').focus(); }
+ catch(e) {}
+
+ return false;
+ },
+
+ I : function(e) {
+ return document.getElementById(e);
+ }
+}
--- /dev/null
+/**
+* hoverIntent is similar to jQuery's built-in "hover" function except that
+* instead of firing the onMouseOver event immediately, hoverIntent checks
+* to see if the user's mouse has slowed down (beneath the sensitivity
+* threshold) before firing the onMouseOver event.
+*
+* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
+* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
+*
+* hoverIntent is currently available for use in all personal or commercial
+* projects under both MIT and GPL licenses. This means that you can choose
+* the license that best suits your project, and use it accordingly.
+*
+* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
+* $("ul li").hoverIntent( showNav , hideNav );
+*
+* // advanced usage receives configuration object only
+* $("ul li").hoverIntent({
+* sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
+* interval: 100, // number = milliseconds of polling interval
+* over: showNav, // function = onMouseOver callback (required)
+* timeout: 0, // number = milliseconds delay before onMouseOut function call
+* out: hideNav // function = onMouseOut callback (required)
+* });
+*
+* @param f onMouseOver function || An object with configuration options
+* @param g onMouseOut function || Nothing (use configuration options object)
+* @author Brian Cherne <brian@cherne.net>
+*/
+(function($) {
+ $.fn.hoverIntent = function(f,g) {
+ // default configuration options
+ var cfg = {
+ sensitivity: 7,
+ interval: 100,
+ timeout: 0
+ };
+ // override configuration options with user supplied object
+ cfg = $.extend(cfg, g ? { over: f, out: g } : f );
+
+ // instantiate variables
+ // cX, cY = current X and Y position of mouse, updated by mousemove event
+ // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
+ var cX, cY, pX, pY;
+
+ // A private function for getting mouse position
+ var track = function(ev) {
+ cX = ev.pageX;
+ cY = ev.pageY;
+ };
+
+ // A private function for comparing current and previous mouse position
+ var compare = function(ev,ob) {
+ ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
+ // compare mouse positions to see if they've crossed the threshold
+ if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
+ $(ob).unbind("mousemove",track);
+ // set hoverIntent state to true (so mouseOut can be called)
+ ob.hoverIntent_s = 1;
+ return cfg.over.apply(ob,[ev]);
+ } else {
+ // set previous coordinates for next time
+ pX = cX; pY = cY;
+ // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
+ ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
+ }
+ };
+
+ // A private function for delaying the mouseOut function
+ var delay = function(ev,ob) {
+ ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
+ ob.hoverIntent_s = 0;
+ return cfg.out.apply(ob,[ev]);
+ };
+
+ // workaround for Mozilla bug: not firing mouseout/mouseleave on absolute positioned elements over textareas and input type="text"
+ var handleHover = function(e) {
+ var t = this;
+
+ // next two lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
+ var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
+ while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
+ if ( p == this ) {
+ if ( $.browser.mozilla ) {
+ if ( e.type == "mouseout" ) {
+ t.mtout = setTimeout( function(){doHover(e,t);}, 30 );
+ } else {
+ if (t.mtout) { t.mtout = clearTimeout(t.mtout); }
+ }
+ }
+ return;
+ } else {
+ if (t.mtout) { t.mtout = clearTimeout(t.mtout); }
+ doHover(e,t);
+ }
+ };
+
+ // A private function for handling mouse 'hovering'
+ var doHover = function(e,ob) {
+
+ // copy objects to be passed into t (required for event object to be passed in IE)
+ var ev = jQuery.extend({},e);
+
+ // cancel hoverIntent timer if it exists
+ if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
+
+ // else e.type == "onmouseover"
+ if (e.type == "mouseover") {
+ // set "previous" X and Y position based on initial entry point
+ pX = ev.pageX; pY = ev.pageY;
+ // update "current" X and Y position based on mousemove
+ $(ob).bind("mousemove",track);
+ // start polling interval (self-calling timeout) to compare mouse coordinates over time
+ if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
+
+ // else e.type == "onmouseout"
+ } else {
+ // unbind expensive mousemove event
+ $(ob).unbind("mousemove",track);
+ // if hoverIntent state is true, then call the mouseOut function after the specified delay
+ if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
+ }
+ };
+
+ // bind the function to the two event listeners
+ return this.mouseover(handleHover).mouseout(handleHover);
+ };
+})(jQuery);
\ No newline at end of file
--- /dev/null
+/******************************************************************************************************************************
+
+ * @ Original idea by by Binny V A, Original version: 2.00.A
+ * @ http://www.openjs.com/scripts/events/keyboard_shortcuts/
+ * @ Original License : BSD
+
+ * @ jQuery Plugin by Tzury Bar Yochay
+ mail: tzury.by@gmail.com
+ blog: evalinux.wordpress.com
+ face: facebook.com/profile.php?id=513676303
+
+ (c) Copyrights 2007
+
+ * @ jQuery Plugin version Beta (0.0.2)
+ * @ License: jQuery-License.
+
+TODO:
+ add queue support (as in gmail) e.g. 'x' then 'y', etc.
+ add mouse + mouse wheel events.
+
+USAGE:
+ $.hotkeys.add('Ctrl+c', function(){ alert('copy anyone?');});
+ $.hotkeys.add('Ctrl+c', {target:'div#editor', type:'keyup', propagate: true},function(){ alert('copy anyone?');});>
+ $.hotkeys.remove('Ctrl+c');
+ $.hotkeys.remove('Ctrl+c', {target:'div#editor', type:'keypress'});
+
+******************************************************************************************************************************/
+(function (jQuery){
+ this.version = '(beta)(0.0.3)';
+ this.all = {};
+ this.special_keys = {
+ 27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll', 20: 'capslock',
+ 144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',35:'end', 33: 'pageup',
+ 34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down', 112:'f1',113:'f2', 114:'f3',
+ 115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8', 120:'f9', 121:'f10', 122:'f11', 123:'f12'};
+
+ this.shift_nums = { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&",
+ "8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<",
+ ".":">", "/":"?", "\\":"|" };
+
+ this.add = function(combi, options, callback) {
+ if (jQuery.isFunction(options)){
+ callback = options;
+ options = {};
+ }
+ var opt = {},
+ defaults = {type: 'keydown', propagate: false, disableInInput: false, target: jQuery('html')[0]},
+ that = this;
+ opt = jQuery.extend( opt , defaults, options || {} );
+ combi = combi.toLowerCase();
+
+ // inspect if keystroke matches
+ var inspector = function(event) {
+ event = jQuery.event.fix(event); // jQuery event normalization.
+ var element = event.target;
+ // @ TextNode -> nodeType == 3
+ element = (element.nodeType==3) ? element.parentNode : element;
+
+ if(opt['disableInInput']) { // Disable shortcut keys in Input, Textarea fields
+ var target = jQuery(element);
+ if( target.is("input") || target.is("textarea")){
+ return;
+ }
+ }
+ var code = event.which,
+ type = event.type,
+ character = String.fromCharCode(code).toLowerCase(),
+ special = that.special_keys[code],
+ shift = event.shiftKey,
+ ctrl = event.ctrlKey,
+ alt= event.altKey,
+ meta = event.metaKey,
+ propagate = true, // default behaivour
+ mapPoint = null;
+
+ // in opera + safari, the event.target is unpredictable.
+ // for example: 'keydown' might be associated with HtmlBodyElement
+ // or the element where you last clicked with your mouse.
+ if (jQuery.browser.opera || jQuery.browser.safari){
+ while (!that.all[element] && element.parentNode){
+ element = element.parentNode;
+ }
+ }
+ var cbMap = that.all[element].events[type].callbackMap;
+ if(!shift && !ctrl && !alt && !meta) { // No Modifiers
+ mapPoint = cbMap[special] || cbMap[character]
+ }
+ // deals with combinaitons (alt|ctrl|shift+anything)
+ else{
+ var modif = '';
+ if(alt) modif +='alt+';
+ if(ctrl) modif+= 'ctrl+';
+ if(shift) modif += 'shift+';
+ if(meta) modif += 'meta+';
+ // modifiers + special keys or modifiers + characters or modifiers + shift characters
+ mapPoint = cbMap[modif+special] || cbMap[modif+character] || cbMap[modif+that.shift_nums[character]]
+ }
+ if (mapPoint){
+ mapPoint.cb(event);
+ if(!mapPoint.propagate) {
+ event.stopPropagation();
+ event.preventDefault();
+ return false;
+ }
+ }
+ };
+ // first hook for this element
+ if (!this.all[opt.target]){
+ this.all[opt.target] = {events:{}};
+ }
+ if (!this.all[opt.target].events[opt.type]){
+ this.all[opt.target].events[opt.type] = {callbackMap: {}}
+ jQuery.event.add(opt.target, opt.type, inspector);
+ }
+ this.all[opt.target].events[opt.type].callbackMap[combi] = {cb: callback, propagate:opt.propagate};
+ return jQuery;
+ };
+ this.remove = function(exp, opt) {
+ opt = opt || {};
+ target = opt.target || jQuery('html')[0];
+ type = opt.type || 'keydown';
+ exp = exp.toLowerCase();
+ delete this.all[target].events[type].callbackMap[exp]
+ return jQuery;
+ };
+ jQuery.hotkeys = this;
+ return jQuery;
+})(jQuery);
\ No newline at end of file
--- /dev/null
+(function($){
+ $.fn.filter_visible = function(depth) {
+ depth = depth || 3;
+ var is_visible = function() {
+ var p = $(this);
+ for(i=0; i<depth-1; ++i) {
+ if (!p.is(':visible')) return false;
+ p = p.parent();
+ }
+ return true;
+ }
+ return this.filter(is_visible);
+ };
+ $.table_hotkeys = function(table, keys, opts) {
+ opts = $.extend($.table_hotkeys.defaults, opts);
+ var selected_class = opts.class_prefix + opts.selected_suffix;
+ var destructive_class = opts.class_prefix + opts.destructive_suffix;
+ var set_current_row = function (tr) {
+ if ($.table_hotkeys.current_row) $.table_hotkeys.current_row.removeClass(selected_class);
+ tr.addClass(selected_class);
+ tr[0].scrollIntoView(false);
+ $.table_hotkeys.current_row = tr;
+ };
+ var adjacent_row_callback = function(which) {
+ if (!adjacent_row(which) && $.isFunction(opts[which+'_page_link_cb'])) {
+ opts[which+'_page_link_cb']();
+ }
+ };
+ var get_adjacent_row = function(which) {
+ if (!$.table_hotkeys.current_row) {
+ var first_row = get_first_row();
+ $.table_hotkeys.current_row = first_row;
+ return first_row[0];
+ }
+ var method = 'prev' == which? $.fn.prevAll : $.fn.nextAll;
+ return method.call($.table_hotkeys.current_row, opts.cycle_expr).filter_visible()[0];
+ };
+ var adjacent_row = function(which) {
+ var adj = get_adjacent_row(which);
+ if (!adj) return false;
+ set_current_row($(adj));
+ return true;
+ };
+ var prev_row = function() { return adjacent_row('prev'); };
+ var next_row = function() { return adjacent_row('next'); };
+ var check = function() {
+ $(opts.checkbox_expr, $.table_hotkeys.current_row).each(function() {
+ this.checked = !this.checked;
+ });
+ };
+ var get_first_row = function() {
+ return $(opts.cycle_expr, table).filter_visible().eq(opts.start_row_index);
+ };
+ var get_last_row = function() {
+ var rows = $(opts.cycle_expr, table).filter_visible();
+ return rows.eq(rows.length-1);
+ };
+ var make_key_callback = function(expr) {
+ return function() {
+ if ( null == $.table_hotkeys.current_row ) return false;
+ var clickable = $(expr, $.table_hotkeys.current_row);
+ if (!clickable.length) return false;
+ if (clickable.is('.'+destructive_class)) next_row() || prev_row();
+ clickable.click();
+ }
+ };
+ var first_row = get_first_row();
+ if (!first_row.length) return;
+ if (opts.highlight_first)
+ set_current_row(first_row);
+ else if (opts.highlight_last)
+ set_current_row(get_last_row());
+ jQuery.hotkeys.add(opts.prev_key, opts.hotkeys_opts, function() {return adjacent_row_callback('prev')});
+ jQuery.hotkeys.add(opts.next_key, opts.hotkeys_opts, function() {return adjacent_row_callback('next')});
+ jQuery.hotkeys.add(opts.mark_key, opts.hotkeys_opts, check);
+ jQuery.each(keys, function() {
+ if ($.isFunction(this[1])) {
+ var callback = this[1];
+ var key = this[0];
+ jQuery.hotkeys.add(key, opts.hotkeys_opts, function(event) { return callback(event, $.table_hotkeys.current_row); });
+ } else {
+ var key = this;
+ jQuery.hotkeys.add(key, opts.hotkeys_opts, make_key_callback('.'+opts.class_prefix+key));
+ }
+ });
+
+ };
+ $.table_hotkeys.current_row = null;
+ $.table_hotkeys.defaults = {cycle_expr: 'tr', class_prefix: 'vim-', selected_suffix: 'current',
+ destructive_suffix: 'destructive', hotkeys_opts: {disableInInput: true, type: 'keypress'},
+ checkbox_expr: ':checkbox', next_key: 'j', prev_key: 'k', mark_key: 'x',
+ start_row_index: 2, highlight_first: false, highlight_last: false, next_page_link_cb: false, prev_page_link_cb: false};
+})(jQuery);
-eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(3(C){C.8={2s:{1o:3(E,F,H){6 G=C.8[E].n;1v(6 D 2r H){G.w[D]=G.w[D]||[];G.w[D].2q([F,H[D]])}},1n:3(D,F,E){6 H=D.w[F];5(!H){4}1v(6 G=0;G<H.2p;G++){5(D.a[H[G][0]]){H[G][1].u(D.c,E)}}}},o:{},f:3(D){5(C.8.o[D]){4 C.8.o[D]}6 E=C(\'<2o 2n="8-2m">\').1i(D).f({2l:"2k",12:"-1u",2j:"-1u",2i:"2h"}).2g("1t");C.8.o[D]=!!((!(/2f|2e/).h(E.f("2d"))||(/^[1-9]/).h(E.f("2c"))||(/^[1-9]/).h(E.f("2b"))||!(/1r/).h(E.f("2a"))||!(/29|28\\(0, 0, 0, 0\\)/).h(E.f("27"))));26{C("1t").1s(0).25(E.1s(0))}24(F){}4 C.8.o[D]},23:3(D){D.j="1g";D.1q=3(){4 7};5(D.v){D.v.1p="1r"}},22:3(D){D.j="21";D.1q=3(){4 d};5(D.v){D.v.1p=""}},20:3(G,E){6 D=/12/.h(E||"12")?"1Z":"1Y",F=7;5(G[D]>0){4 d}G[D]=1;F=G[D]>0?d:7;G[D]=0;4 F}};6 B=C.10.t;C.10.t=3(){C("*",2).1o(2).1X("t");4 B.u(2,1m)};3 A(E,F,G){6 D=C[E][F].1W||[];D=(W D=="V"?D.11(/,?\\s+/):D);4(C.1V(G,D)!=-1)}C.l=3(E,D){6 F=E.11(".")[0];E=E.11(".")[1];C.10[E]=3(J){6 H=(W J=="V"),I=1U.n.1T.1n(1m,1);5(H&&A(F,E,J)){6 G=C.Z(2[0],E);4(G?G[J].u(G,I):1S)}4 2.1R(3(){6 K=C.Z(2,E);5(H&&K&&C.1Q(K[J])){K[J].u(K,I)}1P{5(!H){C.Z(2,E,1O C[F][E](2,J))}}})};C[F][E]=3(I,H){6 G=2;2.e=E;2.1h=F+"-"+E;2.a=C.1l({},C.l.p,C[F][E].p,H);2.c=C(I).g("m."+E,3(L,J,K){4 G.m(J,K)}).g("Y."+E,3(K,J){4 G.Y(J)}).g("t",3(){4 G.1j()});2.1k()};C[F][E].n=C.1l({},C.l.n,D)};C.l.n={1k:3(){},1j:3(){2.c.1N(2.e)},Y:3(D){4 2.a[D]},m:3(D,E){2.a[D]=E;5(D=="k"){2.c[E?"1i":"1M"](2.1h+"-k")}},1L:3(){2.m("k",7)},1K:3(){2.m("k",d)}};C.l.p={k:7};C.8.14={1J:3(){6 D=2;2.c.g("1I."+2.e,3(E){4 D.1e(E)});5(C.U.T){2.1f=2.c.X("j");2.c.X("j","1g")}2.1H=7},1G:3(){2.c.R("."+2.e);(C.U.T&&2.c.X("j",2.1f))},1e:3(F){(2.b&&2.i(F));2.r=F;6 E=2,G=(F.1F==1),D=(W 2.a.y=="V"?C(F.1E).1D(2.a.y):7);5(!G||D||!2.15(F)){4 d}2.q=!2.a.x;5(!2.q){2.1C=1B(3(){E.q=d},2.a.x)}5(2.P(F)&&2.N(F)){2.b=(2.M(F)!==7);5(!2.b){F.1A();4 d}}2.S=3(H){4 E.1d(H)};2.Q=3(H){4 E.i(H)};C(1c).g("1b."+2.e,2.S).g("1a."+2.e,2.Q);4 7},1d:3(D){5(C.U.T&&!D.1z){4 2.i(D)}5(2.b){2.z(D);4 7}5(2.P(D)&&2.N(D)){2.b=(2.M(2.r,D)!==7);(2.b?2.z(D):2.i(D))}4!2.b},i:3(D){C(1c).R("1b."+2.e,2.S).R("1a."+2.e,2.Q);5(2.b){2.b=7;2.16(D)}4 7},P:3(D){4(O.1y(O.18(2.r.19-D.19),O.18(2.r.17-D.17))>=2.a.13)},N:3(D){4 2.q},M:3(D){},z:3(D){},16:3(D){},15:3(D){4 d}};C.8.14.p={y:1x,13:1,x:0}})(1w)',62,153,'||this|function|return|if|var|false|ui||options|_mouseStarted|element|true|widgetName|css|bind|test|mouseUp|unselectable|disabled|widget|setData|prototype|cssCache|defaults|_mouseDelayMet|_mouseDownEvent||remove|apply|style|plugins|delay|cancel|mouseDrag|||||||||||||mouseStart|mouseDelayMet|Math|mouseDistanceMet|_mouseUpDelegate|unbind|_mouseMoveDelegate|msie|browser|string|typeof|attr|getData|data|fn|split|top|distance|mouse|mouseCapture|mouseStop|pageY|abs|pageX|mouseup|mousemove|document|mouseMove|mouseDown|_mouseUnselectable|on|widgetBaseClass|addClass|destroy|init|extend|arguments|call|add|MozUserSelect|onselectstart|none|get|body|5000px|for|jQuery|null|max|button|preventDefault|setTimeout|_mouseDelayTimer|is|target|which|mouseDestroy|started|mousedown|mouseInit|disable|enable|removeClass|removeData|new|else|isFunction|each|undefined|slice|Array|inArray|getter|trigger|scrollLeft|scrollTop|hasScroll|off|enableSelection|disableSelection|catch|removeChild|try|backgroundColor|rgba|transparent|backgroundImage|width|height|cursor|default|auto|appendTo|block|display|left|absolute|position|gen|class|div|length|push|in|plugin'.split('|'),0,{}))
+eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(3(C){C.8={2r:{V:3(E,F,H){6 G=C.8[E].o;1v(6 D 2q H){G.w[D]=G.w[D]||[];G.w[D].2p([F,H[D]])}},1p:3(D,F,E){6 H=D.w[F];5(!H){4}1v(6 G=0;G<H.1e;G++){5(D.a[H[G][0]]){H[G][1].v(D.c,E)}}}},p:{},d:3(D){5(C.8.p[D]){4 C.8.p[D]}6 E=C(\'<2o 2n="8-2m">\').1k(D).d({2l:"2k",12:"-1u",2j:"-1u",2i:"2h"}).2g("1t");C.8.p[D]=!!((!(/2f|2e/).h(E.d("2d"))||(/^[1-9]/).h(E.d("2c"))||(/^[1-9]/).h(E.d("2b"))||!(/1r/).h(E.d("2a"))||!(/29|28\\(0, 0, 0, 0\\)/).h(E.d("27"))));26{C("1t").1s(0).25(E.1s(0))}24(F){}4 C.8.p[D]},23:3(D){C(D).k("j","1i").d("1q","1r")},22:3(D){C(D).k("j","21").d("1q","")},20:3(G,E){6 D=/12/.h(E||"12")?"1Z":"1Y",F=7;5(G[D]>0){4 f}G[D]=1;F=G[D]>0?f:7;G[D]=0;4 F}};6 B=C.10.u;C.10.u=3(){C("*",2).V(2).1X("u");4 B.v(2,1o)};3 A(E,F,G){6 D=C[E][F].1W||[];D=(X D=="W"?D.11(/,?\\s+/):D);4(C.1V(G,D)!=-1)}C.m=3(E,D){6 F=E.11(".")[0];E=E.11(".")[1];C.10[E]=3(J){6 H=(X J=="W"),I=1U.o.1T.1p(1o,1);5(H&&A(F,E,J)){6 G=C.Z(2[0],E);4(G?G[J].v(G,I):1S)}4 2.1R(3(){6 K=C.Z(2,E);5(H&&K&&C.1Q(K[J])){K[J].v(K,I)}1P{5(!H){C.Z(2,E,1O C[F][E](2,J))}}})};C[F][E]=3(I,H){6 G=2;2.e=E;2.1j=F+"-"+E;2.a=C.1n({},C.m.q,C[F][E].q,H);2.c=C(I).g("n."+E,3(L,J,K){4 G.n(J,K)}).g("Y."+E,3(K,J){4 G.Y(J)}).g("u",3(){4 G.1l()});2.1m()};C[F][E].o=C.1n({},C.m.o,D)};C.m.o={1m:3(){},1l:3(){2.c.1N(2.e)},Y:3(D){4 2.a[D]},n:3(D,E){2.a[D]=E;5(D=="l"){2.c[E?"1k":"1M"](2.1j+"-l")}},1L:3(){2.n("l",7)},1K:3(){2.n("l",f)}};C.m.q={l:7};C.8.14={1J:3(){6 D=2;2.c.g("1I."+2.e,3(E){4 D.1g(E)});5(C.U.T){2.1h=2.c.k("j");2.c.k("j","1i")}2.1H=7},1G:3(){2.c.R("."+2.e);(C.U.T&&2.c.k("j",2.1h))},1g:3(F){(2.b&&2.i(F));2.t=F;6 E=2,G=(F.1F==1),D=(X 2.a.y=="W"?C(F.1f).1E().V(F.1f).1D(2.a.y).1e:7);5(!G||D||!2.15(F)){4 f}2.r=!2.a.x;5(!2.r){2.1C=1B(3(){E.r=f},2.a.x)}5(2.P(F)&&2.N(F)){2.b=(2.M(F)!==7);5(!2.b){F.1A();4 f}}2.S=3(H){4 E.1d(H)};2.Q=3(H){4 E.i(H)};C(1c).g("1b."+2.e,2.S).g("1a."+2.e,2.Q);4 7},1d:3(D){5(C.U.T&&!D.1z){4 2.i(D)}5(2.b){2.z(D);4 7}5(2.P(D)&&2.N(D)){2.b=(2.M(2.t,D)!==7);(2.b?2.z(D):2.i(D))}4!2.b},i:3(D){C(1c).R("1b."+2.e,2.S).R("1a."+2.e,2.Q);5(2.b){2.b=7;2.16(D)}4 7},P:3(D){4(O.1y(O.18(2.t.19-D.19),O.18(2.t.17-D.17))>=2.a.13)},N:3(D){4 2.r},M:3(D){},z:3(D){},16:3(D){},15:3(D){4 f}};C.8.14.q={y:1x,13:1,x:0}})(1w)',62,152,'||this|function|return|if|var|false|ui||options|_mouseStarted|element|css|widgetName|true|bind|test|mouseUp|unselectable|attr|disabled|widget|setData|prototype|cssCache|defaults|_mouseDelayMet||_mouseDownEvent|remove|apply|plugins|delay|cancel|mouseDrag|||||||||||||mouseStart|mouseDelayMet|Math|mouseDistanceMet|_mouseUpDelegate|unbind|_mouseMoveDelegate|msie|browser|add|string|typeof|getData|data|fn|split|top|distance|mouse|mouseCapture|mouseStop|pageY|abs|pageX|mouseup|mousemove|document|mouseMove|length|target|mouseDown|_mouseUnselectable|on|widgetBaseClass|addClass|destroy|init|extend|arguments|call|MozUserSelect|none|get|body|5000px|for|jQuery|null|max|button|preventDefault|setTimeout|_mouseDelayTimer|filter|parents|which|mouseDestroy|started|mousedown|mouseInit|disable|enable|removeClass|removeData|new|else|isFunction|each|undefined|slice|Array|inArray|getter|triggerHandler|scrollLeft|scrollTop|hasScroll|off|enableSelection|disableSelection|catch|removeChild|try|backgroundColor|rgba|transparent|backgroundImage|width|height|cursor|default|auto|appendTo|block|display|left|absolute|position|gen|class|div|push|in|plugin'.split('|'),0,{}))
--- /dev/null
+(function(B){var A={dragStart:"start.draggable",drag:"drag.draggable",dragStop:"stop.draggable",maxHeight:"maxHeight.resizable",minHeight:"minHeight.resizable",maxWidth:"maxWidth.resizable",minWidth:"minWidth.resizable",resizeStart:"start.resizable",resize:"drag.resizable",resizeStop:"stop.resizable"};B.widget("ui.dialog",{init:function(){var J=this,K=this.options,D=typeof K.resizable=="string"?K.resizable:"n,e,s,w,se,sw,ne,nw",E=this.element.addClass("ui-dialog-content").wrap("<div/>").wrap("<div/>"),G=(this.uiDialogContainer=E.parent().addClass("ui-dialog-container").css({position:"relative",width:"100%",height:"100%"})),H=K.title||E.attr("title")||"",C=(this.uiDialogTitlebar=B('<div class="ui-dialog-titlebar"/>')).append('<span class="ui-dialog-title">'+H+"</span>").append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>').prependTo(G),I=(this.uiDialog=G.parent()).appendTo(document.body).hide().addClass("ui-dialog").addClass(K.dialogClass).addClass(E.attr("className")).removeClass("ui-dialog-content").css({position:"absolute",width:K.width,height:K.height,overflow:"hidden",zIndex:K.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(L){if(K.closeOnEscape){var M=27;(L.keyCode&&L.keyCode==M&&J.close())}}).mousedown(function(){J.moveToTop()}),F=(this.uiDialogButtonPane=B("<div/>")).addClass("ui-dialog-buttonpane").css({position:"absolute",bottom:0}).appendTo(I);this.uiDialogTitlebarClose=B(".ui-dialog-titlebar-close",C).hover(function(){B(this).addClass("ui-dialog-titlebar-close-hover")},function(){B(this).removeClass("ui-dialog-titlebar-close-hover")}).mousedown(function(L){L.stopPropagation()}).click(function(){J.close();return false});this.uiDialogTitlebar.find("*").add(this.uiDialogTitlebar).each(function(){B.ui.disableSelection(this)});if(B.fn.draggable){I.draggable({cancel:".ui-dialog-content",helper:K.dragHelper,handle:".ui-dialog-titlebar",start:function(M,L){J.moveToTop();(K.dragStart&&K.dragStart.apply(J.element[0],arguments))},drag:function(M,L){(K.drag&&K.drag.apply(J.element[0],arguments))},stop:function(M,L){(K.dragStop&&K.dragStop.apply(J.element[0],arguments));B.ui.dialog.overlay.resize()}});(K.draggable||I.draggable("disable"))}if(B.fn.resizable){I.resizable({cancel:".ui-dialog-content",helper:K.resizeHelper,maxWidth:K.maxWidth,maxHeight:K.maxHeight,minWidth:K.minWidth,minHeight:K.minHeight,start:function(){(K.resizeStart&&K.resizeStart.apply(J.element[0],arguments))},resize:function(M,L){(K.autoResize&&J.size.apply(J));(K.resize&&K.resize.apply(J.element[0],arguments))},handles:D,stop:function(M,L){(K.autoResize&&J.size.apply(J));(K.resizeStop&&K.resizeStop.apply(J.element[0],arguments));B.ui.dialog.overlay.resize()}});(K.resizable||I.resizable("disable"))}this.createButtons(K.buttons);this.isOpen=false;(K.bgiframe&&B.fn.bgiframe&&I.bgiframe());(K.autoOpen&&this.open())},setData:function(C,D){(A[C]&&this.uiDialog.data(A[C],D));switch(C){case"buttons":this.createButtons(D);break;case"draggable":this.uiDialog.draggable(D?"enable":"disable");break;case"height":this.uiDialog.height(D);break;case"position":this.position(D);break;case"resizable":(typeof D=="string"&&this.uiDialog.data("handles.resizable",D));this.uiDialog.resizable(D?"enable":"disable");break;case"title":B(".ui-dialog-title",this.uiDialogTitlebar).text(D);break;case"width":this.uiDialog.width(D);break}B.widget.prototype.setData.apply(this,arguments)},position:function(H){var D=B(window),E=B(document),F=E.scrollTop(),C=E.scrollLeft(),G=F;if(B.inArray(H,["center","top","right","bottom","left"])>=0){H=[H=="right"||H=="left"?H:"center",H=="top"||H=="bottom"?H:"middle"]}if(H.constructor!=Array){H=["center","middle"]}if(H[0].constructor==Number){C+=H[0]}else{switch(H[0]){case"left":C+=0;break;case"right":C+=D.width()-this.uiDialog.width();break;default:case"center":C+=(D.width()-this.uiDialog.width())/2}}if(H[1].constructor==Number){F+=H[1]}else{switch(H[1]){case"top":F+=0;break;case"bottom":F+=D.height()-this.uiDialog.height();break;default:case"middle":F+=(D.height()-this.uiDialog.height())/2}}F=Math.max(F,G);this.uiDialog.css({top:F,left:C})},size:function(){var D=this.uiDialogContainer,G=this.uiDialogTitlebar,E=this.element,F=parseInt(E.css("margin-top"),10)+parseInt(E.css("margin-bottom"),10),C=parseInt(E.css("margin-left"),10)+parseInt(E.css("margin-right"),10);E.height(D.height()-G.outerHeight()-F);E.width(D.width()-C)},open:function(){if(this.isOpen){return }this.overlay=this.options.modal?new B.ui.dialog.overlay(this):null;(this.uiDialog.next().length>0)&&this.uiDialog.appendTo("body");this.position(this.options.position);this.uiDialog.show(this.options.show);this.options.autoResize&&this.size();this.moveToTop(true);var C=null;var D={options:this.options};this.uiDialogTitlebarClose.focus();this.element.triggerHandler("dialogopen",[C,D],this.options.open);this.isOpen=true},moveToTop:function(E){if((this.options.modal&&!E)||(!this.options.stack&&!this.options.modal)){return this.element.triggerHandler("dialogfocus",[null,{options:this.options}],this.options.focus)}var D=this.options.zIndex,C=this.options;B(".ui-dialog:visible").each(function(){D=Math.max(D,parseInt(B(this).css("z-index"),10)||C.zIndex)});(this.overlay&&this.overlay.$el.css("z-index",++D));this.uiDialog.css("z-index",++D);this.element.triggerHandler("dialogfocus",[null,{options:this.options}],this.options.focus)},close:function(){(this.overlay&&this.overlay.destroy());this.uiDialog.hide(this.options.hide);var D=null;var C={options:this.options};this.element.triggerHandler("dialogclose",[D,C],this.options.close);B.ui.dialog.overlay.resize();this.isOpen=false},destroy:function(){(this.overlay&&this.overlay.destroy());this.uiDialog.hide();this.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content").hide().appendTo("body");this.uiDialog.remove()},createButtons:function(F){var E=this,C=false,D=this.uiDialogButtonPane;D.empty().hide();B.each(F,function(){return !(C=true)});if(C){D.show();B.each(F,function(G,H){B("<button/>").text(G).click(function(){H.apply(E.element[0],arguments)}).appendTo(D)})}}});B.extend(B.ui.dialog,{defaults:{autoOpen:true,autoResize:true,bgiframe:false,buttons:{},closeOnEscape:true,draggable:true,height:200,minHeight:100,minWidth:150,modal:false,overlay:{},position:"center",resizable:true,stack:true,width:300,zIndex:1000},overlay:function(C){this.$el=B.ui.dialog.overlay.create(C)}});B.extend(B.ui.dialog.overlay,{instances:[],events:B.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(C){return C+".dialog-overlay"}).join(" "),create:function(D){if(this.instances.length===0){setTimeout(function(){B("a, :input").bind(B.ui.dialog.overlay.events,function(){var F=false;var H=B(this).parents(".ui-dialog");if(H.length){var E=B(".ui-dialog-overlay");if(E.length){var G=parseInt(E.css("z-index"),10);E.each(function(){G=Math.max(G,parseInt(B(this).css("z-index"),10))});F=parseInt(H.css("z-index"),10)>G}else{F=true}}return F})},1);B(document).bind("keydown.dialog-overlay",function(E){var F=27;(E.keyCode&&E.keyCode==F&&D.close())});B(window).bind("resize.dialog-overlay",B.ui.dialog.overlay.resize)}var C=B("<div/>").appendTo(document.body).addClass("ui-dialog-overlay").css(B.extend({borderWidth:0,margin:0,padding:0,position:"absolute",top:0,left:0,width:this.width(),height:this.height()},D.options.overlay));(D.options.bgiframe&&B.fn.bgiframe&&C.bgiframe());this.instances.push(C);return C},destroy:function(C){this.instances.splice(B.inArray(this.instances,C),1);if(this.instances.length===0){B("a, :input").add([document,window]).unbind(".dialog-overlay")}C.remove()},height:function(){if(B.browser.msie&&B.browser.version<7){var D=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);var C=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);if(D<C){return B(window).height()+"px"}else{return D+"px"}}else{return B(document).height()+"px"}},width:function(){if(B.browser.msie&&B.browser.version<7){var C=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);var D=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);if(C<D){return B(window).width()+"px"}else{return C+"px"}}else{return B(document).width()+"px"}},resize:function(){var C=B([]);B.each(B.ui.dialog.overlay.instances,function(){C=C.add(this)});C.css({width:0,height:0}).css({width:B.ui.dialog.overlay.width(),height:B.ui.dialog.overlay.height()})}});B.extend(B.ui.dialog.overlay.prototype,{destroy:function(){B.ui.dialog.overlay.destroy(this.$el)}})})(jQuery)
\ No newline at end of file
--- /dev/null
+(function(A){A.widget("ui.draggable",A.extend({},A.ui.mouse,{init:function(){var B=this.options;if(B.helper=="original"&&!(/(relative|absolute|fixed)/).test(this.element.css("position"))){this.element.css("position","relative")}this.element.addClass("ui-draggable");(B.disabled&&this.element.addClass("ui-draggable-disabled"));this.mouseInit()},mouseStart:function(F){var H=this.options;if(this.helper||H.disabled||A(F.target).is(".ui-resizable-handle")){return false}var C=!this.options.handle||!A(this.options.handle,this.element).length?true:false;A(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==F.target){C=true}});if(!C){return false}if(A.ui.ddmanager){A.ui.ddmanager.current=this}this.helper=A.isFunction(H.helper)?A(H.helper.apply(this.element[0],[F])):(H.helper=="clone"?this.element.clone():this.element);if(!this.helper.parents("body").length){this.helper.appendTo((H.appendTo=="parent"?this.element[0].parentNode:H.appendTo))}if(this.helper[0]!=this.element[0]&&!(/(fixed|absolute)/).test(this.helper.css("position"))){this.helper.css("position","absolute")}this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)};this.cssPosition=this.helper.css("position");this.offset=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.offset.click={left:F.pageX-this.offset.left,top:F.pageY-this.offset.top};this.offsetParent=this.helper.offsetParent();var B=this.offsetParent.offset();if(this.offsetParent[0]==document.body&&A.browser.mozilla){B={top:0,left:0}}this.offset.parent={top:B.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:B.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};var E=this.element.position();this.offset.relative=this.cssPosition=="relative"?{top:E.top-(parseInt(this.helper.css("top"),10)||0)+this.offsetParent[0].scrollTop,left:E.left-(parseInt(this.helper.css("left"),10)||0)+this.offsetParent[0].scrollLeft}:{top:0,left:0};this.originalPosition=this.generatePosition(F);this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};if(H.cursorAt){if(H.cursorAt.left!=undefined){this.offset.click.left=H.cursorAt.left+this.margins.left}if(H.cursorAt.right!=undefined){this.offset.click.left=this.helperProportions.width-H.cursorAt.right+this.margins.left}if(H.cursorAt.top!=undefined){this.offset.click.top=H.cursorAt.top+this.margins.top}if(H.cursorAt.bottom!=undefined){this.offset.click.top=this.helperProportions.height-H.cursorAt.bottom+this.margins.top}}if(H.containment){if(H.containment=="parent"){H.containment=this.helper[0].parentNode}if(H.containment=="document"||H.containment=="window"){this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,A(H.containment=="document"?document:window).width()-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),(A(H.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)]}if(!(/^(document|window|parent)$/).test(H.containment)){var D=A(H.containment)[0];var G=A(H.containment).offset();this.containment=[G.left+(parseInt(A(D).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left,G.top+(parseInt(A(D).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top,G.left+Math.max(D.scrollWidth,D.offsetWidth)-(parseInt(A(D).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),G.top+Math.max(D.scrollHeight,D.offsetHeight)-(parseInt(A(D).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)]}}this.propagate("start",F);this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};if(A.ui.ddmanager&&!H.dropBehaviour){A.ui.ddmanager.prepareOffsets(this,F)}this.helper.addClass("ui-draggable-dragging");this.mouseDrag(F);return true},convertPositionTo:function(C,D){if(!D){D=this.position}var B=C=="absolute"?1:-1;return{top:(D.top+this.offset.relative.top*B+this.offset.parent.top*B-(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollTop)*B+(this.cssPosition=="fixed"?A(document).scrollTop():0)*B+this.margins.top*B),left:(D.left+this.offset.relative.left*B+this.offset.parent.left*B-(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollLeft)*B+(this.cssPosition=="fixed"?A(document).scrollLeft():0)*B+this.margins.left*B)}},generatePosition:function(E){var F=this.options;var B={top:(E.pageY-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollTop)-(this.cssPosition=="fixed"?A(document).scrollTop():0)),left:(E.pageX-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollLeft)-(this.cssPosition=="fixed"?A(document).scrollLeft():0))};if(!this.originalPosition){return B}if(this.containment){if(B.left<this.containment[0]){B.left=this.containment[0]}if(B.top<this.containment[1]){B.top=this.containment[1]}if(B.left>this.containment[2]){B.left=this.containment[2]}if(B.top>this.containment[3]){B.top=this.containment[3]}}if(F.grid){var D=this.originalPosition.top+Math.round((B.top-this.originalPosition.top)/F.grid[1])*F.grid[1];B.top=this.containment?(!(D<this.containment[1]||D>this.containment[3])?D:(!(D<this.containment[1])?D-F.grid[1]:D+F.grid[1])):D;var C=this.originalPosition.left+Math.round((B.left-this.originalPosition.left)/F.grid[0])*F.grid[0];B.left=this.containment?(!(C<this.containment[0]||C>this.containment[2])?C:(!(C<this.containment[0])?C-F.grid[0]:C+F.grid[0])):C}return B},mouseDrag:function(B){this.position=this.generatePosition(B);this.positionAbs=this.convertPositionTo("absolute");this.position=this.propagate("drag",B)||this.position;if(!this.options.axis||this.options.axis!="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!="x"){this.helper[0].style.top=this.position.top+"px"}if(A.ui.ddmanager){A.ui.ddmanager.drag(this,B)}return false},mouseStop:function(C){var D=false;if(A.ui.ddmanager&&!this.options.dropBehaviour){var D=A.ui.ddmanager.drop(this,C)}if((this.options.revert=="invalid"&&!D)||(this.options.revert=="valid"&&D)||this.options.revert===true){var B=this;A(this.helper).animate(this.originalPosition,parseInt(this.options.revert,10)||500,function(){B.propagate("stop",C);B.clear()})}else{this.propagate("stop",C);this.clear()}return false},clear:function(){this.helper.removeClass("ui-draggable-dragging");if(this.options.helper!="original"&&!this.cancelHelperRemoval){this.helper.remove()}this.helper=null;this.cancelHelperRemoval=false},plugins:{},uiHash:function(B){return{helper:this.helper,position:this.position,absolutePosition:this.positionAbs,options:this.options}},propagate:function(C,B){A.ui.plugin.call(this,C,[B,this.uiHash()]);if(C=="drag"){this.positionAbs=this.convertPositionTo("absolute")}return this.element.triggerHandler(C=="drag"?C:"drag"+C,[B,this.uiHash()],this.options[C])},destroy:function(){if(!this.element.data("draggable")){return }this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable");this.mouseDestroy()}}));A.extend(A.ui.draggable,{defaults:{appendTo:"parent",axis:false,cancel:":input",delay:0,distance:1,helper:"original"}});A.ui.plugin.add("draggable","cursor",{start:function(D,C){var B=A("body");if(B.css("cursor")){C.options._cursor=B.css("cursor")}B.css("cursor",C.options.cursor)},stop:function(C,B){if(B.options._cursor){A("body").css("cursor",B.options._cursor)}}});A.ui.plugin.add("draggable","zIndex",{start:function(D,C){var B=A(C.helper);if(B.css("zIndex")){C.options._zIndex=B.css("zIndex")}B.css("zIndex",C.options.zIndex)},stop:function(C,B){if(B.options._zIndex){A(B.helper).css("zIndex",B.options._zIndex)}}});A.ui.plugin.add("draggable","opacity",{start:function(D,C){var B=A(C.helper);if(B.css("opacity")){C.options._opacity=B.css("opacity")}B.css("opacity",C.options.opacity)},stop:function(C,B){if(B.options._opacity){A(B.helper).css("opacity",B.options._opacity)}}});A.ui.plugin.add("draggable","iframeFix",{start:function(C,B){A(B.options.iframeFix===true?"iframe":B.options.iframeFix).each(function(){A('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css(A(this).offset()).appendTo("body")})},stop:function(C,B){A("div.DragDropIframeFix").each(function(){this.parentNode.removeChild(this)})}});A.ui.plugin.add("draggable","scroll",{start:function(D,C){var E=C.options;var B=A(this).data("draggable");E.scrollSensitivity=E.scrollSensitivity||20;E.scrollSpeed=E.scrollSpeed||20;B.overflowY=function(F){do{if(/auto|scroll/.test(F.css("overflow"))||(/auto|scroll/).test(F.css("overflow-y"))){return F}F=F.parent()}while(F[0].parentNode);return A(document)}(this);B.overflowX=function(F){do{if(/auto|scroll/.test(F.css("overflow"))||(/auto|scroll/).test(F.css("overflow-x"))){return F}F=F.parent()}while(F[0].parentNode);return A(document)}(this);if(B.overflowY[0]!=document&&B.overflowY[0].tagName!="HTML"){B.overflowYOffset=B.overflowY.offset()}if(B.overflowX[0]!=document&&B.overflowX[0].tagName!="HTML"){B.overflowXOffset=B.overflowX.offset()}},drag:function(D,C){var E=C.options;var B=A(this).data("draggable");if(B.overflowY[0]!=document&&B.overflowY[0].tagName!="HTML"){if((B.overflowYOffset.top+B.overflowY[0].offsetHeight)-D.pageY<E.scrollSensitivity){B.overflowY[0].scrollTop=B.overflowY[0].scrollTop+E.scrollSpeed}if(D.pageY-B.overflowYOffset.top<E.scrollSensitivity){B.overflowY[0].scrollTop=B.overflowY[0].scrollTop-E.scrollSpeed}}else{if(D.pageY-A(document).scrollTop()<E.scrollSensitivity){A(document).scrollTop(A(document).scrollTop()-E.scrollSpeed)}if(A(window).height()-(D.pageY-A(document).scrollTop())<E.scrollSensitivity){A(document).scrollTop(A(document).scrollTop()+E.scrollSpeed)}}if(B.overflowX[0]!=document&&B.overflowX[0].tagName!="HTML"){if((B.overflowXOffset.left+B.overflowX[0].offsetWidth)-D.pageX<E.scrollSensitivity){B.overflowX[0].scrollLeft=B.overflowX[0].scrollLeft+E.scrollSpeed}if(D.pageX-B.overflowXOffset.left<E.scrollSensitivity){B.overflowX[0].scrollLeft=B.overflowX[0].scrollLeft-E.scrollSpeed}}else{if(D.pageX-A(document).scrollLeft()<E.scrollSensitivity){A(document).scrollLeft(A(document).scrollLeft()-E.scrollSpeed)}if(A(window).width()-(D.pageX-A(document).scrollLeft())<E.scrollSensitivity){A(document).scrollLeft(A(document).scrollLeft()+E.scrollSpeed)}}}});A.ui.plugin.add("draggable","snap",{start:function(D,C){var B=A(this).data("draggable");B.snapElements=[];A(C.options.snap===true?".ui-draggable":C.options.snap).each(function(){var F=A(this);var E=F.offset();if(this!=B.element[0]){B.snapElements.push({item:this,width:F.outerWidth(),height:F.outerHeight(),top:E.top,left:E.left})}})},drag:function(J,N){var I=A(this).data("draggable");var L=N.options.snapTolerance||20;var D=N.absolutePosition.left,C=D+I.helperProportions.width,P=N.absolutePosition.top,O=P+I.helperProportions.height;for(var H=I.snapElements.length-1;H>=0;H--){var E=I.snapElements[H].left,B=E+I.snapElements[H].width,R=I.snapElements[H].top,M=R+I.snapElements[H].height;if(!((E-L<D&&D<B+L&&R-L<P&&P<M+L)||(E-L<D&&D<B+L&&R-L<O&&O<M+L)||(E-L<C&&C<B+L&&R-L<P&&P<M+L)||(E-L<C&&C<B+L&&R-L<O&&O<M+L))){continue}if(N.options.snapMode!="inner"){var K=Math.abs(R-O)<=20;var Q=Math.abs(M-P)<=20;var G=Math.abs(E-C)<=20;var F=Math.abs(B-D)<=20;if(K){N.position.top=I.convertPositionTo("relative",{top:R-I.helperProportions.height,left:0}).top}if(Q){N.position.top=I.convertPositionTo("relative",{top:M,left:0}).top}if(G){N.position.left=I.convertPositionTo("relative",{top:0,left:E-I.helperProportions.width}).left}if(F){N.position.left=I.convertPositionTo("relative",{top:0,left:B}).left}}if(N.options.snapMode!="outer"){var K=Math.abs(R-P)<=20;var Q=Math.abs(M-O)<=20;var G=Math.abs(E-D)<=20;var F=Math.abs(B-C)<=20;if(K){N.position.top=I.convertPositionTo("relative",{top:R,left:0}).top}if(Q){N.position.top=I.convertPositionTo("relative",{top:M-I.helperProportions.height,left:0}).top}if(G){N.position.left=I.convertPositionTo("relative",{top:0,left:E}).left}if(F){N.position.left=I.convertPositionTo("relative",{top:0,left:B-I.helperProportions.width}).left}}}}});A.ui.plugin.add("draggable","connectToSortable",{start:function(D,C){var B=A(this).data("draggable");B.sortables=[];A(C.options.connectToSortable).each(function(){if(A.data(this,"sortable")){var E=A.data(this,"sortable");B.sortables.push({instance:E,shouldRevert:E.options.revert});E.refreshItems();E.propagate("activate",D,B)}})},stop:function(D,C){var B=A(this).data("draggable");A.each(B.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;B.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert){this.instance.options.revert=true}this.instance.mouseStop(D);this.instance.element.triggerHandler("sortreceive",[D,A.extend(this.instance.ui(),{sender:B.element})],this.instance.options["receive"]);this.instance.options.helper=this.instance.options._helper}else{this.instance.propagate("deactivate",D,B)}})},drag:function(F,E){var D=A(this).data("draggable"),B=this;var C=function(K){var H=K.left,J=H+K.width,I=K.top,G=I+K.height;return(H<(this.positionAbs.left+this.offset.click.left)&&(this.positionAbs.left+this.offset.click.left)<J&&I<(this.positionAbs.top+this.offset.click.top)&&(this.positionAbs.top+this.offset.click.top)<G)};A.each(D.sortables,function(G){if(C.call(D,this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=A(B).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return E.helper[0]};F.target=this.instance.currentItem[0];this.instance.mouseCapture(F,true);this.instance.mouseStart(F,true,true);this.instance.offset.click.top=D.offset.click.top;this.instance.offset.click.left=D.offset.click.left;this.instance.offset.parent.left-=D.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=D.offset.parent.top-this.instance.offset.parent.top;D.propagate("toSortable",F)}if(this.instance.currentItem){this.instance.mouseDrag(F)}}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance.mouseStop(F,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();if(this.instance.placeholder){this.instance.placeholder.remove()}D.propagate("fromSortable",F)}}})}});A.ui.plugin.add("draggable","stack",{start:function(D,B){var C=A.makeArray(A(B.options.stack.group)).sort(function(F,E){return(parseInt(A(F).css("zIndex"),10)||B.options.stack.min)-(parseInt(A(E).css("zIndex"),10)||B.options.stack.min)});A(C).each(function(E){this.style.zIndex=B.options.stack.min+E});this[0].style.zIndex=B.options.stack.min+C.length}})})(jQuery)
\ No newline at end of file
--- /dev/null
+(function(A){A.widget("ui.resizable",A.extend({},A.ui.mouse,{init:function(){var M=this,N=this.options;var Q=this.element.css("position");this.originalElement=this.element;this.element.addClass("ui-resizable").css({position:/static/.test(Q)?"relative":Q});A.extend(N,{_aspectRatio:!!(N.aspectRatio),helper:N.helper||N.ghost||N.animate?N.helper||"proxy":null,knobHandles:N.knobHandles===true?"ui-resizable-knob-handle":N.knobHandles});var H="1px solid #DEDEDE";N.defaultTheme={"ui-resizable":{display:"block"},"ui-resizable-handle":{position:"absolute",background:"#F2F2F2",fontSize:"0.1px"},"ui-resizable-n":{cursor:"n-resize",height:"4px",left:"0px",right:"0px",borderTop:H},"ui-resizable-s":{cursor:"s-resize",height:"4px",left:"0px",right:"0px",borderBottom:H},"ui-resizable-e":{cursor:"e-resize",width:"4px",top:"0px",bottom:"0px",borderRight:H},"ui-resizable-w":{cursor:"w-resize",width:"4px",top:"0px",bottom:"0px",borderLeft:H},"ui-resizable-se":{cursor:"se-resize",width:"4px",height:"4px",borderRight:H,borderBottom:H},"ui-resizable-sw":{cursor:"sw-resize",width:"4px",height:"4px",borderBottom:H,borderLeft:H},"ui-resizable-ne":{cursor:"ne-resize",width:"4px",height:"4px",borderRight:H,borderTop:H},"ui-resizable-nw":{cursor:"nw-resize",width:"4px",height:"4px",borderLeft:H,borderTop:H}};N.knobTheme={"ui-resizable-handle":{background:"#F2F2F2",border:"1px solid #808080",height:"8px",width:"8px"},"ui-resizable-n":{cursor:"n-resize",top:"0px",left:"45%"},"ui-resizable-s":{cursor:"s-resize",bottom:"0px",left:"45%"},"ui-resizable-e":{cursor:"e-resize",right:"0px",top:"45%"},"ui-resizable-w":{cursor:"w-resize",left:"0px",top:"45%"},"ui-resizable-se":{cursor:"se-resize",right:"0px",bottom:"0px"},"ui-resizable-sw":{cursor:"sw-resize",left:"0px",bottom:"0px"},"ui-resizable-nw":{cursor:"nw-resize",left:"0px",top:"0px"},"ui-resizable-ne":{cursor:"ne-resize",right:"0px",top:"0px"}};N._nodeName=this.element[0].nodeName;if(N._nodeName.match(/canvas|textarea|input|select|button|img/i)){var B=this.element;if(/relative/.test(B.css("position"))&&A.browser.opera){B.css({position:"relative",top:"auto",left:"auto"})}B.wrap(A('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:B.css("position"),width:B.outerWidth(),height:B.outerHeight(),top:B.css("top"),left:B.css("left")}));var J=this.element;this.element=this.element.parent();this.element.data("resizable",this);this.element.css({marginLeft:J.css("marginLeft"),marginTop:J.css("marginTop"),marginRight:J.css("marginRight"),marginBottom:J.css("marginBottom")});J.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});if(A.browser.safari&&N.preventDefault){J.css("resize","none")}N.proportionallyResize=J.css({position:"static",zoom:1,display:"block"});this.element.css({margin:J.css("margin")});this._proportionallyResize()}if(!N.handles){N.handles=!A(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}}if(N.handles.constructor==String){N.zIndex=N.zIndex||1000;if(N.handles=="all"){N.handles="n,e,s,w,se,sw,ne,nw"}var O=N.handles.split(",");N.handles={};var G={handle:"position: absolute; display: none; overflow:hidden;",n:"top: 0pt; width:100%;",e:"right: 0pt; height:100%;",s:"bottom: 0pt; width:100%;",w:"left: 0pt; height:100%;",se:"bottom: 0pt; right: 0px;",sw:"bottom: 0pt; left: 0px;",ne:"top: 0pt; right: 0px;",nw:"top: 0pt; left: 0px;"};for(var R=0;R<O.length;R++){var S=A.trim(O[R]),L=N.defaultTheme,F="ui-resizable-"+S,C=!A.ui.css(F)&&!N.knobHandles,P=A.ui.css("ui-resizable-knob-handle"),T=A.extend(L[F],L["ui-resizable-handle"]),D=A.extend(N.knobTheme[F],!P?N.knobTheme["ui-resizable-handle"]:{});var K=/sw|se|ne|nw/.test(S)?{zIndex:++N.zIndex}:{};var I=(C?G[S]:""),E=A(['<div class="ui-resizable-handle ',F,'" style="',I,G.handle,'"></div>'].join("")).css(K);N.handles[S]=".ui-resizable-"+S;this.element.append(E.css(C?T:{}).css(N.knobHandles?D:{}).addClass(N.knobHandles?"ui-resizable-knob-handle":"").addClass(N.knobHandles))}if(N.knobHandles){this.element.addClass("ui-resizable-knob").css(!A.ui.css("ui-resizable-knob")?{}:{})}}this._renderAxis=function(Y){Y=Y||this.element;for(var V in N.handles){if(N.handles[V].constructor==String){N.handles[V]=A(N.handles[V],this.element).show()}if(N.transparent){N.handles[V].css({opacity:0})}if(this.element.is(".ui-wrapper")&&N._nodeName.match(/textarea|input|select|button/i)){var W=A(N.handles[V],this.element),X=0;X=/sw|ne|nw|se|n|s/.test(V)?W.outerHeight():W.outerWidth();var U=["padding",/ne|nw|n/.test(V)?"Top":/se|sw|s/.test(V)?"Bottom":/^e$/.test(V)?"Right":"Left"].join("");if(!N.transparent){Y.css(U,X)}this._proportionallyResize()}if(!A(N.handles[V]).length){continue}}};this._renderAxis(this.element);N._handles=A(".ui-resizable-handle",M.element);if(N.disableSelection){N._handles.each(function(U,V){A.ui.disableSelection(V)})}N._handles.mouseover(function(){if(!N.resizing){if(this.className){var U=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}M.axis=N.axis=U&&U[1]?U[1]:"se"}});if(N.autoHide){N._handles.hide();A(M.element).addClass("ui-resizable-autohide").hover(function(){A(this).removeClass("ui-resizable-autohide");N._handles.show()},function(){if(!N.resizing){A(this).addClass("ui-resizable-autohide");N._handles.hide()}})}this.mouseInit()},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,options:this.options,originalSize:this.originalSize,originalPosition:this.originalPosition}},propagate:function(C,B){A.ui.plugin.call(this,C,[B,this.ui()]);if(C!="resize"){this.element.triggerHandler(["resize",C].join(""),[B,this.ui()],this.options[C])}},destroy:function(){var D=this.element,C=D.children(".ui-resizable").get(0);this.mouseDestroy();var B=function(E){A(E).removeClass("ui-resizable ui-resizable-disabled").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};B(D);if(D.is(".ui-wrapper")&&C){D.parent().append(A(C).css({position:D.css("position"),width:D.outerWidth(),height:D.outerHeight(),top:D.css("top"),left:D.css("left")})).end().remove();B(C)}},mouseStart:function(K){if(this.options.disabled){return false}var J=false;for(var H in this.options.handles){if(A(this.options.handles[H])[0]==K.target){J=true}}if(!J){return false}var C=this.options,B=this.element.position(),D=this.element,I=function(O){return parseInt(O,10)||0},G=A.browser.msie&&A.browser.version<7;C.resizing=true;C.documentScroll={top:A(document).scrollTop(),left:A(document).scrollLeft()};if(D.is(".ui-draggable")||(/absolute/).test(D.css("position"))){var M=A.browser.msie&&!C.containment&&(/absolute/).test(D.css("position"))&&!(/relative/).test(D.parent().css("position"));var L=M?C.documentScroll.top:0,F=M?C.documentScroll.left:0;D.css({position:"absolute",top:(B.top+L),left:(B.left+F)})}if(A.browser.opera&&/relative/.test(D.css("position"))){D.css({position:"relative",top:"auto",left:"auto"})}this._renderProxy();var N=I(this.helper.css("left")),E=I(this.helper.css("top"));if(C.containment){N+=A(C.containment).scrollLeft()||0;E+=A(C.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:N,top:E};this.size=C.helper||G?{width:D.outerWidth(),height:D.outerHeight()}:{width:D.width(),height:D.height()};this.originalSize=C.helper||G?{width:D.outerWidth(),height:D.outerHeight()}:{width:D.width(),height:D.height()};this.originalPosition={left:N,top:E};this.sizeDiff={width:D.outerWidth()-D.width(),height:D.outerHeight()-D.height()};this.originalMousePosition={left:K.pageX,top:K.pageY};C.aspectRatio=(typeof C.aspectRatio=="number")?C.aspectRatio:((this.originalSize.height/this.originalSize.width)||1);if(C.preserveCursor){A("body").css("cursor",this.axis+"-resize")}this.propagate("start",K);return true},mouseDrag:function(I){var D=this.helper,C=this.options,J={},M=this,F=this.originalMousePosition,K=this.axis;var N=(I.pageX-F.left)||0,L=(I.pageY-F.top)||0;var E=this._change[K];if(!E){return false}var H=E.apply(this,[I,N,L]),G=A.browser.msie&&A.browser.version<7,B=this.sizeDiff;if(C._aspectRatio||I.shiftKey){H=this._updateRatio(H,I)}H=this._respectSize(H,I);this.propagate("resize",I);D.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!C.helper&&C.proportionallyResize){this._proportionallyResize()}this._updateCache(H);this.element.triggerHandler("resize",[I,this.ui()],this.options["resize"]);return false},mouseStop:function(I){this.options.resizing=false;var E=this.options,H=function(M){return parseInt(M,10)||0},K=this;if(E.helper){var D=E.proportionallyResize,B=D&&(/textarea/i).test(D.get(0).nodeName),C=B&&A.ui.hasScroll(D.get(0),"left")?0:K.sizeDiff.height,G=B?0:K.sizeDiff.width;var L={width:(K.size.width-G),height:(K.size.height-C)},F=(parseInt(K.element.css("left"),10)+(K.position.left-K.originalPosition.left))||null,J=(parseInt(K.element.css("top"),10)+(K.position.top-K.originalPosition.top))||null;if(!E.animate){this.element.css(A.extend(L,{top:J,left:F}))}if(E.helper&&!E.animate){this._proportionallyResize()}}if(E.preserveCursor){A("body").css("cursor","auto")}this.propagate("stop",I);if(E.helper){this.helper.remove()}return false},_updateCache:function(B){var C=this.options;this.offset=this.helper.offset();if(B.left){this.position.left=B.left}if(B.top){this.position.top=B.top}if(B.height){this.size.height=B.height}if(B.width){this.size.width=B.width}},_updateRatio:function(D,E){var F=this.options,G=this.position,C=this.size,B=this.axis;if(D.height){D.width=(C.height/F.aspectRatio)}else{if(D.width){D.height=(C.width*F.aspectRatio)}}if(B=="sw"){D.left=G.left+(C.width-D.width);D.top=null}if(B=="nw"){D.top=G.top+(C.height-D.height);D.left=G.left+(C.width-D.width)}return D},_respectSize:function(H,I){var F=this.helper,E=this.options,N=E._aspectRatio||I.shiftKey,M=this.axis,P=H.width&&E.maxWidth&&E.maxWidth<H.width,J=H.height&&E.maxHeight&&E.maxHeight<H.height,D=H.width&&E.minWidth&&E.minWidth>H.width,O=H.height&&E.minHeight&&E.minHeight>H.height;if(D){H.width=E.minWidth}if(O){H.height=E.minHeight}if(P){H.width=E.maxWidth}if(J){H.height=E.maxHeight}var C=this.originalPosition.left+this.originalSize.width,L=this.position.top+this.size.height;var G=/sw|nw|w/.test(M),B=/nw|ne|n/.test(M);if(D&&G){H.left=C-E.minWidth}if(P&&G){H.left=C-E.maxWidth}if(O&&B){H.top=L-E.minHeight}if(J&&B){H.top=L-E.maxHeight}var K=!H.width&&!H.height;if(K&&!H.left&&H.top){H.top=null}else{if(K&&!H.top&&H.left){H.left=null}}return H},_proportionallyResize:function(){var F=this.options;if(!F.proportionallyResize){return }var D=F.proportionallyResize,C=this.helper||this.element;if(!F.borderDif){var B=[D.css("borderTopWidth"),D.css("borderRightWidth"),D.css("borderBottomWidth"),D.css("borderLeftWidth")],E=[D.css("paddingTop"),D.css("paddingRight"),D.css("paddingBottom"),D.css("paddingLeft")];F.borderDif=A.map(B,function(G,I){var H=parseInt(G,10)||0,J=parseInt(E[I],10)||0;return H+J})}D.css({height:(C.height()-F.borderDif[0]-F.borderDif[2])+"px",width:(C.width()-F.borderDif[1]-F.borderDif[3])+"px"})},_renderProxy:function(){var C=this.element,F=this.options;this.elementOffset=C.offset();if(F.helper){this.helper=this.helper||A('<div style="overflow:hidden;"></div>');var B=A.browser.msie&&A.browser.version<7,D=(B?1:0),E=(B?2:-1);this.helper.addClass(F.helper).css({width:C.outerWidth()+E,height:C.outerHeight()+E,position:"absolute",left:this.elementOffset.left-D+"px",top:this.elementOffset.top-D+"px",zIndex:++F.zIndex});this.helper.appendTo("body");if(F.disableSelection){A.ui.disableSelection(this.helper.get(0))}}else{this.helper=C}},_change:{e:function(D,C,B){return{width:this.originalSize.width+C}},w:function(F,C,B){var G=this.options,D=this.originalSize,E=this.originalPosition;return{left:E.left+C,width:D.width-C}},n:function(F,C,B){var G=this.options,D=this.originalSize,E=this.originalPosition;return{top:E.top+B,height:D.height-B}},s:function(D,C,B){return{height:this.originalSize.height+B}},se:function(D,C,B){return A.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[D,C,B]))},sw:function(D,C,B){return A.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[D,C,B]))},ne:function(D,C,B){return A.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[D,C,B]))},nw:function(D,C,B){return A.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[D,C,B]))}}}));A.extend(A.ui.resizable,{defaults:{cancel:":input",distance:1,delay:0,preventDefault:true,transparent:false,minWidth:10,minHeight:10,aspectRatio:false,disableSelection:true,preserveCursor:true,autoHide:false,knobHandles:false}});A.ui.plugin.add("resizable","containment",{start:function(I,K){var E=K.options,M=A(this).data("resizable"),G=M.element;var C=E.containment,F=(C instanceof A)?C.get(0):(/parent/.test(C))?G.parent().get(0):C;if(!F){return }M.containerElement=A(F);if(/document/.test(C)||C==document){M.containerOffset={left:0,top:0};M.containerPosition={left:0,top:0};M.parentData={element:A(document),left:0,top:0,width:A(document).width(),height:A(document).height()||document.body.parentNode.scrollHeight}}else{M.containerOffset=A(F).offset();M.containerPosition=A(F).position();M.containerSize={height:A(F).innerHeight(),width:A(F).innerWidth()};var J=M.containerOffset,B=M.containerSize.height,H=M.containerSize.width,D=(A.ui.hasScroll(F,"left")?F.scrollWidth:H),L=(A.ui.hasScroll(F)?F.scrollHeight:B);M.parentData={element:F,left:J.left,top:J.top,width:D,height:L}}},resize:function(H,K){var E=K.options,N=A(this).data("resizable"),C=N.containerSize,J=N.containerOffset,G=N.size,I=N.position,L=E._aspectRatio||H.shiftKey,B={top:0,left:0},D=N.containerElement;if(D[0]!=document&&/static/.test(D.css("position"))){B=N.containerPosition}if(I.left<(E.helper?J.left:B.left)){N.size.width=N.size.width+(E.helper?(N.position.left-J.left):(N.position.left-B.left));if(L){N.size.height=N.size.width*E.aspectRatio}N.position.left=E.helper?J.left:B.left}if(I.top<(E.helper?J.top:0)){N.size.height=N.size.height+(E.helper?(N.position.top-J.top):N.position.top);if(L){N.size.width=N.size.height/E.aspectRatio}N.position.top=E.helper?J.top:0}var F=(E.helper?N.offset.left-J.left:(N.position.left-B.left))+N.sizeDiff.width,M=(E.helper?N.offset.top-J.top:N.position.top)+N.sizeDiff.height;if(F+N.size.width>=N.parentData.width){N.size.width=N.parentData.width-F;if(L){N.size.height=N.size.width*E.aspectRatio}}if(M+N.size.height>=N.parentData.height){N.size.height=N.parentData.height-M;if(L){N.size.width=N.size.height/E.aspectRatio}}},stop:function(G,J){var C=J.options,L=A(this).data("resizable"),H=L.position,I=L.containerOffset,B=L.containerPosition,D=L.containerElement;var E=A(L.helper),M=E.offset(),K=E.innerWidth(),F=E.innerHeight();if(C.helper&&!C.animate&&/relative/.test(D.css("position"))){A(this).css({left:(M.left-I.left),top:(M.top-I.top),width:K,height:F})}if(C.helper&&!C.animate&&/static/.test(D.css("position"))){A(this).css({left:B.left+(M.left-I.left),top:B.top+(M.top-I.top),width:K,height:F})}}});A.ui.plugin.add("resizable","grid",{resize:function(H,J){var D=J.options,L=A(this).data("resizable"),G=L.size,E=L.originalSize,F=L.originalPosition,K=L.axis,I=D._aspectRatio||H.shiftKey;D.grid=typeof D.grid=="number"?[D.grid,D.grid]:D.grid;var C=Math.round((G.width-E.width)/(D.grid[0]||1))*(D.grid[0]||1),B=Math.round((G.height-E.height)/(D.grid[1]||1))*(D.grid[1]||1);if(/^(se|s|e)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B}else{if(/^(ne)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B;L.position.top=F.top-B}else{if(/^(sw)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B;L.position.left=F.left-C}else{L.size.width=E.width+C;L.size.height=E.height+B;L.position.top=F.top-B;L.position.left=F.left-C}}}}});A.ui.plugin.add("resizable","animate",{stop:function(I,K){var F=K.options,L=A(this).data("resizable");var E=F.proportionallyResize,B=E&&(/textarea/i).test(E.get(0).nodeName),C=B&&A.ui.hasScroll(E.get(0),"left")?0:L.sizeDiff.height,H=B?0:L.sizeDiff.width;var D={width:(L.size.width-H),height:(L.size.height-C)},G=(parseInt(L.element.css("left"),10)+(L.position.left-L.originalPosition.left))||null,J=(parseInt(L.element.css("top"),10)+(L.position.top-L.originalPosition.top))||null;L.element.animate(A.extend(D,J&&G?{top:J,left:G}:{}),{duration:F.animateDuration||"slow",easing:F.animateEasing||"swing",step:function(){var M={width:parseInt(L.element.css("width"),10),height:parseInt(L.element.css("height"),10),top:parseInt(L.element.css("top"),10),left:parseInt(L.element.css("left"),10)};if(E){E.css({width:M.width,height:M.height})}L._updateCache(M);L.propagate("animate",I)}})}});A.ui.plugin.add("resizable","ghost",{start:function(E,D){var F=D.options,B=A(this).data("resizable"),G=F.proportionallyResize,C=B.size;if(!G){B.ghost=B.element.clone()}else{B.ghost=G.clone()}B.ghost.css({opacity:0.25,display:"block",position:"relative",height:C.height,width:C.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof F.ghost=="string"?F.ghost:"");B.ghost.appendTo(B.helper)},resize:function(D,C){var E=C.options,B=A(this).data("resizable"),F=E.proportionallyResize;if(B.ghost){B.ghost.css({position:"relative",height:B.size.height,width:B.size.width})}},stop:function(D,C){var E=C.options,B=A(this).data("resizable"),F=E.proportionallyResize;if(B.ghost&&B.helper){B.helper.get(0).removeChild(B.ghost.get(0))}}});A.ui.plugin.add("resizable","alsoResize",{start:function(E,C){var F=C.options,B=A(this).data("resizable"),D=function(G){A(G).each(function(){A(this).data("resizable-alsoresize",{width:parseInt(A(this).width(),10),height:parseInt(A(this).height(),10),left:parseInt(A(this).css("left"),10),top:parseInt(A(this).css("top"),10)})})};if(typeof (F.alsoResize)=="object"){if(F.alsoResize.length){F.alsoResize=F.alsoResize[0];D(F.alsoResize)}else{A.each(F.alsoResize,function(G,H){D(G)})}}else{D(F.alsoResize)}},resize:function(F,E){var G=E.options,C=A(this).data("resizable"),D=C.originalSize,I=C.originalPosition;var H={height:(C.size.height-D.height)||0,width:(C.size.width-D.width)||0,top:(C.position.top-I.top)||0,left:(C.position.left-I.left)||0},B=function(J,K){A(J).each(function(){var N=A(this).data("resizable-alsoresize"),M={},L=K&&K.length?K:["width","height","top","left"];A.each(L||["width","height","top","left"],function(O,Q){var P=(N[Q]||0)+(H[Q]||0);if(P&&P>=0){M[Q]=P||null}});A(this).css(M)})};if(typeof (G.alsoResize)=="object"){A.each(G.alsoResize,function(J,K){B(J,K)})}else{B(G.alsoResize)}},stop:function(C,B){A(this).removeData("resizable-alsoresize-start")}})})(jQuery)
\ No newline at end of file
-eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(b(B){b A(E,D){9 C=B.2U.3W&&B.2U.3V<3U;5(E.2T&&!C){d E.2T(D)}5(E.2S){d!!(E.2S(D)&16)}1R(D=D.1g){5(D==E){d U}}d w}B.3T("m.q",B.2h(B.m.3S,{3R:b(){9 C=4.8;4.P={};4.g.27("m-q");4.2L();4.13=4.c.z?(/6|25/).18(4.c[0].u.f("3Q")):w;5(!(/(2R|1t|3P)/).18(4.g.f("W"))){4.g.f("W","2R")}4.a=4.g.a();4.3O()},3N:{},m:b(C){d{k:(C||4)["k"],r:(C||4)["r"]||B([]),W:(C||4)["W"],3M:(C||4)["1c"],8:4.8,g:4.g,u:(C||4)["i"],3L:C?C.g:O}},v:b(F,E,C,D){B.m.1m.15(4,F,[E,4.m(C)]);5(!D){4.g.3K(F=="1C"?F:"1C"+F,[E,4.m(C)],4.8[F])}},2g:b(E){9 C=(B.1O(4.8.c)?4.8.c.15(4.g):B(4.8.c,4.g)).1Y(".m-q-k");9 D=[];E=E||{};C.1y(b(){9 F=(B(4).2O(E.3J||"2N")||"").3I(E.2P||(/(.+)[-=3H](.+)/));5(F){D.1z((E.2Q||F[1])+"[]="+(E.2Q&&E.2P?F[1]:F[2]))}});d D.3G("&")},2f:b(C){9 D=(B.1O(4.8.c)?4.8.c.15(4.g):B(4.8.c,4.g)).1Y(".m-q-k");9 E=[];D.1y(b(){E.1z(B(4).2O(C||"2N"))});d E},2G:b(J){9 E=4.1c.6,D=E+4.s.n,I=4.1c.7,H=I+4.s.o;9 F=J.6,C=F+J.n,K=J.7,G=K+J.o;5(4.8.1p=="2M"||(4.8.1p=="1V"&&4.s[4.13?"n":"o"]>J[4.13?"n":"o"])){d(I+4.a.p.7>K&&I+4.a.p.7<G&&E+4.a.p.6>F&&E+4.a.p.6<C)}Z{d(F<E+(4.s.n/2)&&D-(4.s.n/2)<C&&K<I+(4.s.o/2)&&H-(4.s.o/2)<G)}},2u:b(J){9 E=4.1c.6,D=E+4.s.n,I=4.1c.7,H=I+4.s.o;9 F=J.6,C=F+J.n,K=J.7,G=K+J.o;5(4.8.1p=="2M"||(4.8.1p=="1V"&&4.s[4.13?"n":"o"]>J[4.13?"n":"o"])){5(!(I+4.a.p.7>K&&I+4.a.p.7<G&&E+4.a.p.6>F&&E+4.a.p.6<C)){d w}5(4.13){5(E+4.a.p.6>F&&E+4.a.p.6<F+J.n/2){d 2}5(E+4.a.p.6>F+J.n/2&&E+4.a.p.6<C){d 1}}Z{5(I+4.a.p.7>K&&I+4.a.p.7<K+J.o/2){d 2}5(I+4.a.p.7>K+J.o/2&&I+4.a.p.7<G){d 1}}}Z{5(!(F<E+(4.s.n/2)&&D-(4.s.n/2)<C&&K<I+(4.s.o/2)&&H-(4.s.o/2)<G)){d w}5(4.13){5(D>F&&E<F){d 2}5(E<C&&D>C){d 1}}Z{5(H>K&&I<K){d 1}5(I<G&&H>G){d 2}}}d w},2L:b(){4.28();4.1I()},28:b(){4.c=[];4.e=[4];9 D=4.c;9 C=4;9 F=[[B.1O(4.8.c)?4.8.c.15(4.g,O,{8:4.8,u:4.i}):B(4.8.c,4.g),4]];5(4.8.2a){Q(9 G=4.8.2a.z-1;G>=0;G--){9 I=B(4.8.2a[G]);Q(9 E=I.z-1;E>=0;E--){9 H=B.1f(I[E],"q");5(H&&!H.8.29){F.1z([B.1O(H.8.c)?H.8.c.15(H.g):B(H.8.c,H.g),H]);4.e.1z(H)}}}}Q(9 G=F.z-1;G>=0;G--){F[G][0].1y(b(){B.1f(4,"q-u",F[G][1]);D.1z({u:B(4),2K:F[G][1],n:0,o:0,6:0,7:0})})}},1I:b(D){5(4.t){9 C=4.t.a();4.a.l={7:C.7+4.1w.7,6:C.6+4.1w.6}}Q(9 F=4.c.z-1;F>=0;F--){5(4.c[F].2K!=4.1x&&4.1x&&4.c[F].u[0]!=4.i[0]){1L}9 E=4.8.2J?B(4.8.2J,4.c[F].u):4.c[F].u;5(!D){4.c[F].n=E.1v();4.c[F].o=E.1u()}9 G=E.a();4.c[F].6=G.6;4.c[F].7=G.7}Q(9 F=4.e.z-1;F>=0;F--){9 G=4.e[F].g.a();4.e[F].P.6=G.6;4.e[F].P.7=G.7;4.e[F].P.n=4.e[F].g.1v();4.e[F].P.o=4.e[F].g.1u()}},3F:b(){4.g.3E("m-q m-q-29").2I("q").3D(".q");4.3C();Q(9 C=4.c.z-1;C>=0;C--){4.c[C].u.2I("q-u")}},26:b(E){9 C=E||4,F=C.8;5(F.r.3B==3A){9 D=F.r;F.r={g:b(){d B("<2H></2H>").27(D)[0]},1q:b(G,H){H.f(G.a()).f({n:G.1v(),o:G.1u()})}}}C.r=B(F.r.g.15(C.g,C.i)).1o("T").f({W:"1t"});F.r.1q.15(C.g,C.i,C.r)},2s:b(F){Q(9 D=4.e.z-1;D>=0;D--){5(4.2G(4.e[D].P)){5(!4.e[D].P.1b){5(4.1x!=4.e[D]){9 I=3z;9 H=O;9 E=4.1c[4.e[D].13?"6":"7"];Q(9 C=4.c.z-1;C>=0;C--){5(!A(4.e[D].g[0],4.c[C].u[0])){1L}9 G=4.c[C][4.e[D].13?"6":"7"];5(1k.2F(G-E)<I){I=1k.2F(G-E);H=4.c[C]}}5(!H&&!4.8.2e){1L}5(4.r){4.r.1G()}5(4.e[D].8.r){4.e[D].26(4)}Z{4.r=O}4.1x=4.e[D];H?4.1J(F,H,O,U):4.1J(F,O,4.e[D].g,U);4.v("21",F);4.e[D].v("21",F,4)}4.e[D].v("1b",F,4);4.e[D].P.1b=1}}Z{5(4.e[D].P.1b){4.e[D].v("2k",F,4);4.e[D].P.1b=0}}}},3y:b(G,F){5(4.8.29||4.8.2t=="3x"){d w}4.28();9 E=O,D=4,C=B(G.1N).2D().1y(b(){5(B.1f(4,"q-u")==D){E=B(4);d w}});5(B.1f(G.1N,"q-u")==D){E=B(G.1N)}5(!E){d w}5(4.8.2E&&!F){9 H=w;B(4.8.2E,E).3w("*").3v().1y(b(){5(4==G.1N){H=U}});5(!H){d w}}4.i=E;d U},3u:b(H,F,C){9 J=4.8;4.1x=4;4.1I();4.k=3t J.k=="b"?B(J.k.3s(4.g[0],[H,4.i])):4.i.1W();5(!4.k.2D("T").z){4.k.1o((J.1o!="l"?J.1o:4.i[0].1g))}4.k.f({W:"1t",1H:"3r"}).27("m-q-k");4.V={6:(L(4.i.f("3q"),10)||0),7:(L(4.i.f("3p"),10)||0)};4.a=4.i.a();4.a={7:4.a.7-4.V.7,6:4.a.6-4.V.6};4.a.p={6:H.1d-4.a.6,7:H.1e-4.a.7};4.t=4.k.t();9 D=4.t.a();4.1w={7:(L(4.t.f("23"),10)||0),6:(L(4.t.f("24"),10)||0)};4.a.l={7:D.7+4.1w.7,6:D.6+4.1w.6};4.1j=4.22(H);4.1X={1r:4.i.1r()[0],l:4.i.l()[0]};4.s={n:4.k.1v(),o:4.k.1u()};5(J.r){4.26()}4.v("1l",H);4.s={n:4.k.1v(),o:4.k.1u()};5(J.12){5(J.12.6!=1M){4.a.p.6=J.12.6}5(J.12.25!=1M){4.a.p.6=4.s.n-J.12.25}5(J.12.7!=1M){4.a.p.7=J.12.7}5(J.12.2C!=1M){4.a.p.7=4.s.o-J.12.2C}}5(J.j){5(J.j=="l"){J.j=4.k[0].1g}5(J.j=="h"||J.j=="17"){4.j=[0-4.a.l.6,0-4.a.l.7,B(J.j=="h"?h:17).n()-4.a.l.6-4.s.n-4.V.6-(L(4.g.f("2B"),10)||0),(B(J.j=="h"?h:17).o()||h.T.1g.2z)-4.a.l.7-4.s.o-4.V.7-(L(4.g.f("2y"),10)||0)]}5(!(/^(h|17|l)$/).18(J.j)){9 G=B(J.j)[0];9 I=B(J.j).a();4.j=[I.6+(L(B(G).f("24"),10)||0)-4.a.l.6,I.7+(L(B(G).f("23"),10)||0)-4.a.l.7,I.6+1k.2A(G.3o,G.2b)-(L(B(G).f("24"),10)||0)-4.a.l.6-4.s.n-4.V.6-(L(4.i.f("2B"),10)||0),I.7+1k.2A(G.2z,G.2c)-(L(B(G).f("23"),10)||0)-4.a.l.7-4.s.o-4.V.7-(L(4.i.f("2y"),10)||0)]}}5(4.8.r!="1W"){4.i.f("2i","3n")}5(!C){Q(9 E=4.e.z-1;E>=0;E--){4.e[E].v("3m",H,4)}}5(B.m.14){B.m.14.3l=4}5(B.m.14&&!J.2n){B.m.14.3k(4,H)}4.2j=U;4.2w(H);d U},2v:b(D,E){5(!E){E=4.W}9 C=D=="1t"?1:-1;d{7:(E.7+4.a.l.7*C-(4.t[0]==h.T?0:4.t[0].N)*C+4.V.7*C),6:(E.6+4.a.l.6*C-(4.t[0]==h.T?0:4.t[0].M)*C+4.V.6*C)}},22:b(F){9 G=4.8;9 C={7:(F.1e-4.a.p.7-4.a.l.7+(4.t[0]==h.T?0:4.t[0].N)),6:(F.1d-4.a.p.6-4.a.l.6+(4.t[0]==h.T?0:4.t[0].M))};5(!4.1j){d C}5(4.j){5(C.6<4.j[0]){C.6=4.j[0]}5(C.7<4.j[1]){C.7=4.j[1]}5(C.6>4.j[2]){C.6=4.j[2]}5(C.7>4.j[3]){C.7=4.j[3]}}5(G.11){9 E=4.1j.7+1k.2x((C.7-4.1j.7)/G.11[1])*G.11[1];C.7=4.j?(!(E<4.j[1]||E>4.j[3])?E:(!(E<4.j[1])?E-G.11[1]:E+G.11[1])):E;9 D=4.1j.6+1k.2x((C.6-4.1j.6)/G.11[0])*G.11[0];C.6=4.j?(!(D<4.j[0]||D>4.j[2])?D:(!(D<4.j[0])?D-G.11[0]:D+G.11[0])):D}d C},2w:b(D){4.W=4.22(D);4.1c=4.2v("1t");Q(9 C=4.c.z-1;C>=0;C--){9 E=4.2u(4.c[C]);5(!E){1L}5(4.c[C].u[0]!=4.i[0]&&4.i[E==1?"3j":"1r"]()[0]!=4.c[C].u[0]&&!A(4.i[0],4.c[C].u[0])&&(4.8.2t=="3i-3h"?!A(4.g[0],4.c[C].u[0]):U)){4.2p=E==1?"2o":"3g";4.1J(D,4.c[C]);4.v("21",D);3f}}4.2s(D);4.v("1C",D);5(!4.8.1K||4.8.1K=="x"){4.k[0].2r.6=4.W.6+"2q"}5(!4.8.1K||4.8.1K=="y"){4.k[0].2r.7=4.W.7+"2q"}5(B.m.14){B.m.14.3e(4,D)}d w},1J:b(H,G,D,F){D?D.3d(4.i):G.u[4.2p=="2o"?"3c":"3b"](4.i);4.1s=4.1s?++4.1s:1;9 E=4,C=4.1s;17.3a(b(){5(C==E.1s){E.1I(!F)}},0);5(4.8.r){4.8.r.1q.15(4.g,4.i,4.r)}},39:b(E,D){5(B.m.14&&!4.8.2n){B.m.14.38(4,E)}5(4.8.1Z){9 C=4;9 F=C.i.a();5(C.r){C.r.2m({19:"37"},(L(4.8.1Z,10)||2l)-36)}B(4.k).2m({6:F.6-4.a.l.6-C.V.6+(4.t[0]==h.T?0:4.t[0].M),7:F.7-4.a.l.7-C.V.7+(4.t[0]==h.T?0:4.t[0].N)},L(4.8.1Z,10)||2l,b(){C.1H(E)})}Z{4.1H(E,D)}d w},1H:b(E,D){5(4.1X.1r!=4.i.1r().1Y(".m-q-k")[0]||4.1X.l!=4.i.l()[0]){4.v("1q",E,O,D)}5(!A(4.g[0],4.i[0])){4.v("1G",E,O,D);Q(9 C=4.e.z-1;C>=0;C--){5(A(4.e[C].g[0],4.i[0])){4.e[C].v("1q",E,4,D);4.e[C].v("35",E,4,D)}}}Q(9 C=4.e.z-1;C>=0;C--){4.e[C].v("34",E,4,D);5(4.e[C].P.1b){4.e[C].v("2k",E,4);4.e[C].P.1b=0}}4.2j=w;5(4.33){4.v("1n",E,O,D);d w}B(4.i).f("2i","");5(4.r){4.r.1G()}4.k.1G();4.k=O;4.v("1n",E,O,D);d U}}));B.2h(B.m.q,{32:"2g 2f",31:{k:"1W",1p:"1V",30:1,2Z:0,1h:U,Y:20,X:20,2Y:":2X",c:"> *",1a:2W,2e:U,1o:"l"}});B.m.1m.1F("q","1i",{1l:b(E,D){9 C=B("T");5(C.f("1i")){D.8.1U=C.f("1i")}C.f("1i",D.8.1i)},1n:b(D,C){5(C.8.1U){B("T").f("1i",C.8.1U)}}});B.m.1m.1F("q","1a",{1l:b(E,D){9 C=D.k;5(C.f("1a")){D.8.1T=C.f("1a")}C.f("1a",D.8.1a)},1n:b(D,C){5(C.8.1T){B(C.k).f("1a",C.8.1T)}}});B.m.1m.1F("q","19",{1l:b(E,D){9 C=D.k;5(C.f("19")){D.8.1S=C.f("19")}C.f("19",D.8.19)},1n:b(D,C){5(C.8.1S){B(C.k).f("19",C.8.1S)}}});B.m.1m.1F("q","1h",{1l:b(E,D){9 F=D.8;9 C=B(4).1f("q");C.S=b(G){2d{5(/1E|1h/.18(G.f("1D"))||(/1E|1h/).18(G.f("1D-y"))){d G}G=G.l()}1R(G[0].1g);d B(h)}(C.i);C.R=b(G){2d{5(/1E|1h/.18(G.f("1D"))||(/1E|1h/).18(G.f("1D-x"))){d G}G=G.l()}1R(G[0].1g);d B(h)}(C.i);5(C.S[0]!=h&&C.S[0].1B!="1A"){C.1Q=C.S.a()}5(C.R[0]!=h&&C.R[0].1B!="1A"){C.1P=C.R.a()}},1C:b(E,D){9 F=D.8;9 C=B(4).1f("q");5(C.S[0]!=h&&C.S[0].1B!="1A"){5((C.1Q.7+C.S[0].2c)-E.1e<F.Y){C.S[0].N=C.S[0].N+F.X}5(E.1e-C.1Q.7<F.Y){C.S[0].N=C.S[0].N-F.X}}Z{5(E.1e-B(h).N()<F.Y){B(h).N(B(h).N()-F.X)}5(B(17).o()-(E.1e-B(h).N())<F.Y){B(h).N(B(h).N()+F.X)}}5(C.R[0]!=h&&C.R[0].1B!="1A"){5((C.1P.6+C.R[0].2b)-E.1d<F.Y){C.R[0].M=C.R[0].M+F.X}5(E.1d-C.1P.6<F.Y){C.R[0].M=C.R[0].M-F.X}}Z{5(E.1d-B(h).M()<F.Y){B(h).M(B(h).M()-F.X)}5(B(17).n()-(E.1d-B(h).M())<F.Y){B(h).M(B(h).M()+F.X)}}}})})(2V)',62,245,'||||this|if|left|top|options|var|offset|function|items|return|containers|css|element|document|currentItem|containment|helper|parent|ui|width|height|click|sortable|placeholder|helperProportions|offsetParent|item|propagate|false|||length||||||||||||parseInt|scrollLeft|scrollTop|null|containerCache|for|overflowX|overflowY|body|true|margins|position|scrollSpeed|scrollSensitivity|else||grid|cursorAt|floating|ddmanager|call||window|test|opacity|zIndex|over|positionAbs|pageX|pageY|data|parentNode|scroll|cursor|originalPosition|Math|start|plugin|stop|appendTo|tolerance|update|prev|counter|absolute|outerHeight|outerWidth|offsetParentBorders|currentContainer|each|push|HTML|tagName|sort|overflow|auto|add|remove|clear|refreshPositions|rearrange|axis|continue|undefined|target|isFunction|overflowXOffset|overflowYOffset|while|_opacity|_zIndex|_cursor|guess|clone|domPosition|not|revert||change|generatePosition|borderTopWidth|borderLeftWidth|right|createPlaceholder|addClass|refreshItems|disabled|connectWith|offsetWidth|offsetHeight|do|dropOnEmpty|toArray|serialize|extend|visibility|dragging|out|500|animate|dropBehaviour|down|direction|px|style|contactContainers|type|intersectsWithEdge|convertPositionTo|mouseDrag|round|marginBottom|scrollHeight|max|marginRight|bottom|parents|handle|abs|intersectsWith|div|removeData|toleranceElement|instance|refresh|pointer|id|attr|expression|key|relative|compareDocumentPosition|contains|browser|jQuery|1000|input|cancel|delay|distance|defaults|getter|cancelHelperRemoval|deactivate|receive|50|hide|drop|mouseStop|setTimeout|after|before|append|drag|break|up|dynamic|semi|next|prepareOffsets|current|activate|hidden|scrollWidth|marginTop|marginLeft|both|apply|typeof|mouseStart|andSelf|find|static|mouseCapture|10000|String|constructor|mouseDestroy|unbind|removeClass|destroy|join|_|match|attribute|triggerHandler|sender|absolutePosition|plugins|mouseInit|fixed|float|init|mouse|widget|522|version|safari'.split('|'),0,{}))
-
+(function(B){function A(E,D){var C=B.browser.safari&&B.browser.version<522;if(E.contains&&!C){return E.contains(D)}if(E.compareDocumentPosition){return !!(E.compareDocumentPosition(D)&16)}while(D=D.parentNode){if(D==E){return true}}return false}B.widget("ui.sortable",B.extend({},B.ui.mouse,{init:function(){var C=this.options;this.containerCache={};this.element.addClass("ui-sortable");this.refresh();this.floating=this.items.length?(/left|right/).test(this.items[0].item.css("float")):false;if(!(/(relative|absolute|fixed)/).test(this.element.css("position"))){this.element.css("position","relative")}this.offset=this.element.offset();this.mouseInit()},plugins:{},ui:function(C){return{helper:(C||this)["helper"],placeholder:(C||this)["placeholder"]||B([]),position:(C||this)["position"],absolutePosition:(C||this)["positionAbs"],options:this.options,element:this.element,item:(C||this)["currentItem"],sender:C?C.element:null}},propagate:function(F,E,C,D){B.ui.plugin.call(this,F,[E,this.ui(C)]);if(!D){this.element.triggerHandler(F=="sort"?F:"sort"+F,[E,this.ui(C)],this.options[F])}},serialize:function(E){var C=(B.isFunction(this.options.items)?this.options.items.call(this.element):B(this.options.items,this.element)).not(".ui-sortable-helper");var D=[];E=E||{};C.each(function(){var F=(B(this).attr(E.attribute||"id")||"").match(E.expression||(/(.+)[-=_](.+)/));if(F){D.push((E.key||F[1])+"[]="+(E.key&&E.expression?F[1]:F[2]))}});return D.join("&")},toArray:function(C){var D=(B.isFunction(this.options.items)?this.options.items.call(this.element):B(this.options.items,this.element)).not(".ui-sortable-helper");var E=[];D.each(function(){E.push(B(this).attr(C||"id"))});return E},intersectsWith:function(J){var E=this.positionAbs.left,D=E+this.helperProportions.width,I=this.positionAbs.top,H=I+this.helperProportions.height;var F=J.left,C=F+J.width,K=J.top,G=K+J.height;if(this.options.tolerance=="pointer"||this.options.forcePointerForContainers||(this.options.tolerance=="guess"&&this.helperProportions[this.floating?"width":"height"]>J[this.floating?"width":"height"])){return(I+this.offset.click.top>K&&I+this.offset.click.top<G&&E+this.offset.click.left>F&&E+this.offset.click.left<C)}else{return(F<E+(this.helperProportions.width/2)&&D-(this.helperProportions.width/2)<C&&K<I+(this.helperProportions.height/2)&&H-(this.helperProportions.height/2)<G)}},intersectsWithEdge:function(J){var E=this.positionAbs.left,D=E+this.helperProportions.width,I=this.positionAbs.top,H=I+this.helperProportions.height;var F=J.left,C=F+J.width,K=J.top,G=K+J.height;if(this.options.toleranceMove=="pointer"||(this.options.toleranceMove=="guess"&&this.helperProportions[this.floating?"width":"height"]>J[this.floating?"width":"height"])){if(!(I+this.offset.click.top>K&&I+this.offset.click.top<G&&E+this.offset.click.left>F&&E+this.offset.click.left<C)){return false}if(this.floating){if(E+this.offset.click.left>F&&E+this.offset.click.left<F+J.width/2){return 2}if(E+this.offset.click.left>F+J.width/2&&E+this.offset.click.left<C){return 1}}else{if(I+this.offset.click.top>K&&I+this.offset.click.top<K+J.height/2){return 2}if(I+this.offset.click.top>K+J.height/2&&I+this.offset.click.top<G){return 1}}}else{if(!(F<E+(this.helperProportions.width/2)&&D-(this.helperProportions.width/2)<C&&K<I+(this.helperProportions.height/2)&&H-(this.helperProportions.height/2)<G)){return false}if(this.floating){if(D>F&&E<F){return 2}if(E<C&&D>C){return 1}}else{if(H>K&&I<K){return 1}if(I<G&&H>G){return 2}}}return false},refresh:function(){this.refreshItems();this.refreshPositions()},refreshItems:function(){this.items=[];this.containers=[this];var D=this.items;var C=this;var F=[[B.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):B(this.options.items,this.element),this]];if(this.options.connectWith){for(var G=this.options.connectWith.length-1;G>=0;G--){var I=B(this.options.connectWith[G]);for(var E=I.length-1;E>=0;E--){var H=B.data(I[E],"sortable");if(H&&!H.options.disabled){F.push([B.isFunction(H.options.items)?H.options.items.call(H.element):B(H.options.items,H.element),H]);this.containers.push(H)}}}}for(var G=F.length-1;G>=0;G--){F[G][0].each(function(){B.data(this,"sortable-item",F[G][1]);D.push({item:B(this),instance:F[G][1],width:0,height:0,left:0,top:0})})}},refreshPositions:function(D){if(this.offsetParent){var C=this.offsetParent.offset();this.offset.parent={top:C.top+this.offsetParentBorders.top,left:C.left+this.offsetParentBorders.left}}for(var F=this.items.length-1;F>=0;F--){if(this.items[F].instance!=this.currentContainer&&this.currentContainer&&this.items[F].item[0]!=this.currentItem[0]){continue}var E=this.options.toleranceElement?B(this.options.toleranceElement,this.items[F].item):this.items[F].item;if(!D){this.items[F].width=E[0].offsetWidth;this.items[F].height=E[0].offsetHeight}var G=E.offset();this.items[F].left=G.left;this.items[F].top=G.top}if(this.options.custom&&this.options.custom.refreshContainers){this.options.custom.refreshContainers.call(this)}else{for(var F=this.containers.length-1;F>=0;F--){var G=this.containers[F].element.offset();this.containers[F].containerCache.left=G.left;this.containers[F].containerCache.top=G.top;this.containers[F].containerCache.width=this.containers[F].element.outerWidth();this.containers[F].containerCache.height=this.containers[F].element.outerHeight()}}},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this.mouseDestroy();for(var C=this.items.length-1;C>=0;C--){this.items[C].item.removeData("sortable-item")}},createPlaceholder:function(E){var C=E||this,F=C.options;if(F.placeholder.constructor==String){var D=F.placeholder;F.placeholder={element:function(){return B("<div></div>").addClass(D)[0]},update:function(G,H){H.css(G.offset()).css({width:G.outerWidth(),height:G.outerHeight()})}}}C.placeholder=B(F.placeholder.element.call(C.element,C.currentItem)).appendTo("body").css({position:"absolute"});F.placeholder.update.call(C.element,C.currentItem,C.placeholder)},contactContainers:function(F){for(var D=this.containers.length-1;D>=0;D--){if(this.intersectsWith(this.containers[D].containerCache)){if(!this.containers[D].containerCache.over){if(this.currentContainer!=this.containers[D]){var I=10000;var H=null;var E=this.positionAbs[this.containers[D].floating?"left":"top"];for(var C=this.items.length-1;C>=0;C--){if(!A(this.containers[D].element[0],this.items[C].item[0])){continue}var G=this.items[C][this.containers[D].floating?"left":"top"];if(Math.abs(G-E)<I){I=Math.abs(G-E);H=this.items[C]}}if(!H&&!this.options.dropOnEmpty){continue}if(this.placeholder){this.placeholder.remove()}if(this.containers[D].options.placeholder){this.containers[D].createPlaceholder(this)}else{this.placeholder=null}this.currentContainer=this.containers[D];H?this.rearrange(F,H,null,true):this.rearrange(F,null,this.containers[D].element,true);this.propagate("change",F);this.containers[D].propagate("change",F,this)}this.containers[D].propagate("over",F,this);this.containers[D].containerCache.over=1}}else{if(this.containers[D].containerCache.over){this.containers[D].propagate("out",F,this);this.containers[D].containerCache.over=0}}}},mouseCapture:function(G,F){if(this.options.disabled||this.options.type=="static"){return false}this.refreshItems();var E=null,D=this,C=B(G.target).parents().each(function(){if(B.data(this,"sortable-item")==D){E=B(this);return false}});if(B.data(G.target,"sortable-item")==D){E=B(G.target)}if(!E){return false}if(this.options.handle&&!F){var H=false;B(this.options.handle,E).find("*").andSelf().each(function(){if(this==G.target){H=true}});if(!H){return false}}this.currentItem=E;return true},mouseStart:function(H,F,C){var J=this.options;this.currentContainer=this;this.refreshPositions();this.helper=typeof J.helper=="function"?B(J.helper.apply(this.element[0],[H,this.currentItem])):this.currentItem.clone();if(!this.helper.parents("body").length){B(J.appendTo!="parent"?J.appendTo:this.currentItem[0].parentNode)[0].appendChild(this.helper[0])}this.helper.css({position:"absolute",clear:"both"}).addClass("ui-sortable-helper");this.margins={left:(parseInt(this.currentItem.css("marginLeft"),10)||0),top:(parseInt(this.currentItem.css("marginTop"),10)||0)};this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.offset.click={left:H.pageX-this.offset.left,top:H.pageY-this.offset.top};this.offsetParent=this.helper.offsetParent();var D=this.offsetParent.offset();this.offsetParentBorders={top:(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};this.offset.parent={top:D.top+this.offsetParentBorders.top,left:D.left+this.offsetParentBorders.left};this.originalPosition=this.generatePosition(H);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};if(J.placeholder){this.createPlaceholder()}this.propagate("start",H);this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};if(J.cursorAt){if(J.cursorAt.left!=undefined){this.offset.click.left=J.cursorAt.left}if(J.cursorAt.right!=undefined){this.offset.click.left=this.helperProportions.width-J.cursorAt.right}if(J.cursorAt.top!=undefined){this.offset.click.top=J.cursorAt.top}if(J.cursorAt.bottom!=undefined){this.offset.click.top=this.helperProportions.height-J.cursorAt.bottom}}if(J.containment){if(J.containment=="parent"){J.containment=this.helper[0].parentNode}if(J.containment=="document"||J.containment=="window"){this.containment=[0-this.offset.parent.left,0-this.offset.parent.top,B(J.containment=="document"?document:window).width()-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),(B(J.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)]}if(!(/^(document|window|parent)$/).test(J.containment)){var G=B(J.containment)[0];var I=B(J.containment).offset();this.containment=[I.left+(parseInt(B(G).css("borderLeftWidth"),10)||0)-this.offset.parent.left,I.top+(parseInt(B(G).css("borderTopWidth"),10)||0)-this.offset.parent.top,I.left+Math.max(G.scrollWidth,G.offsetWidth)-(parseInt(B(G).css("borderLeftWidth"),10)||0)-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.currentItem.css("marginRight"),10)||0),I.top+Math.max(G.scrollHeight,G.offsetHeight)-(parseInt(B(G).css("borderTopWidth"),10)||0)-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.currentItem.css("marginBottom"),10)||0)]}}if(this.options.placeholder!="clone"){this.currentItem.css("visibility","hidden")}if(!C){for(var E=this.containers.length-1;E>=0;E--){this.containers[E].propagate("activate",H,this)}}if(B.ui.ddmanager){B.ui.ddmanager.current=this}if(B.ui.ddmanager&&!J.dropBehaviour){B.ui.ddmanager.prepareOffsets(this,H)}this.dragging=true;this.mouseDrag(H);return true},convertPositionTo:function(D,E){if(!E){E=this.position}var C=D=="absolute"?1:-1;return{top:(E.top+this.offset.parent.top*C-(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)*C+this.margins.top*C),left:(E.left+this.offset.parent.left*C-(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft)*C+this.margins.left*C)}},generatePosition:function(F){var G=this.options;var C={top:(F.pageY-this.offset.click.top-this.offset.parent.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)),left:(F.pageX-this.offset.click.left-this.offset.parent.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft))};if(!this.originalPosition){return C}if(this.containment){if(C.left<this.containment[0]){C.left=this.containment[0]}if(C.top<this.containment[1]){C.top=this.containment[1]}if(C.left>this.containment[2]){C.left=this.containment[2]}if(C.top>this.containment[3]){C.top=this.containment[3]}}if(G.grid){var E=this.originalPosition.top+Math.round((C.top-this.originalPosition.top)/G.grid[1])*G.grid[1];C.top=this.containment?(!(E<this.containment[1]||E>this.containment[3])?E:(!(E<this.containment[1])?E-G.grid[1]:E+G.grid[1])):E;var D=this.originalPosition.left+Math.round((C.left-this.originalPosition.left)/G.grid[0])*G.grid[0];C.left=this.containment?(!(D<this.containment[0]||D>this.containment[2])?D:(!(D<this.containment[0])?D-G.grid[0]:D+G.grid[0])):D}return C},mouseDrag:function(D){this.position=this.generatePosition(D);this.positionAbs=this.convertPositionTo("absolute");B.ui.plugin.call(this,"sort",[D,this.ui()]);this.positionAbs=this.convertPositionTo("absolute");this.helper[0].style.left=this.position.left+"px";this.helper[0].style.top=this.position.top+"px";for(var C=this.items.length-1;C>=0;C--){var E=this.intersectsWithEdge(this.items[C]);if(!E){continue}if(this.items[C].item[0]!=this.currentItem[0]&&this.currentItem[E==1?"next":"prev"]()[0]!=this.items[C].item[0]&&!A(this.currentItem[0],this.items[C].item[0])&&(this.options.type=="semi-dynamic"?!A(this.element[0],this.items[C].item[0]):true)){this.direction=E==1?"down":"up";this.rearrange(D,this.items[C]);this.propagate("change",D);break}}this.contactContainers(D);if(B.ui.ddmanager){B.ui.ddmanager.drag(this,D)}this.element.triggerHandler("sort",[D,this.ui()],this.options["sort"]);return false},rearrange:function(H,G,D,F){D?D[0].appendChild(this.currentItem[0]):G.item[0].parentNode.insertBefore(this.currentItem[0],(this.direction=="down"?G.item[0]:G.item[0].nextSibling));this.counter=this.counter?++this.counter:1;var E=this,C=this.counter;window.setTimeout(function(){if(C==E.counter){E.refreshPositions(!F)}},0);if(this.options.placeholder){this.options.placeholder.update.call(this.element,this.currentItem,this.placeholder)}},mouseStop:function(E,D){if(B.ui.ddmanager&&!this.options.dropBehaviour){B.ui.ddmanager.drop(this,E)}if(this.options.revert){var C=this;var F=C.currentItem.offset();if(C.placeholder){C.placeholder.animate({opacity:"hide"},(parseInt(this.options.revert,10)||500)-50)}B(this.helper).animate({left:F.left-this.offset.parent.left-C.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:F.top-this.offset.parent.top-C.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){C.clear(E)})}else{this.clear(E,D)}return false},clear:function(E,D){if(this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0]){this.propagate("update",E,null,D)}if(!A(this.element[0],this.currentItem[0])){this.propagate("remove",E,null,D);for(var C=this.containers.length-1;C>=0;C--){if(A(this.containers[C].element[0],this.currentItem[0])){this.containers[C].propagate("update",E,this,D);this.containers[C].propagate("receive",E,this,D)}}}for(var C=this.containers.length-1;C>=0;C--){this.containers[C].propagate("deactivate",E,this,D);if(this.containers[C].containerCache.over){this.containers[C].propagate("out",E,this);this.containers[C].containerCache.over=0}}this.dragging=false;if(this.cancelHelperRemoval){this.propagate("stop",E,null,D);return false}B(this.currentItem).css("visibility","");if(this.placeholder){this.placeholder.remove()}this.helper.remove();this.helper=null;this.propagate("stop",E,null,D);return true}}));B.extend(B.ui.sortable,{getter:"serialize toArray",defaults:{helper:"clone",tolerance:"guess",toleranceMove:"guess",distance:1,delay:0,scroll:true,scrollSensitivity:20,scrollSpeed:20,cancel:":input",items:"> *",zIndex:1000,dropOnEmpty:true,appendTo:"parent"}});B.ui.plugin.add("sortable","cursor",{start:function(E,D){var C=B("body");if(C.css("cursor")){D.options._cursor=C.css("cursor")}C.css("cursor",D.options.cursor)},stop:function(D,C){if(C.options._cursor){B("body").css("cursor",C.options._cursor)}}});B.ui.plugin.add("sortable","zIndex",{start:function(E,D){var C=D.helper;if(C.css("zIndex")){D.options._zIndex=C.css("zIndex")}C.css("zIndex",D.options.zIndex)},stop:function(D,C){if(C.options._zIndex){B(C.helper).css("zIndex",C.options._zIndex)}}});B.ui.plugin.add("sortable","opacity",{start:function(E,D){var C=D.helper;if(C.css("opacity")){D.options._opacity=C.css("opacity")}C.css("opacity",D.options.opacity)},stop:function(D,C){if(C.options._opacity){B(C.helper).css("opacity",C.options._opacity)}}});B.ui.plugin.add("sortable","scroll",{start:function(E,D){var F=D.options;var C=B(this).data("sortable");C.overflowY=function(G){do{if(/auto|scroll/.test(G.css("overflow"))||(/auto|scroll/).test(G.css("overflow-y"))){return G}G=G.parent()}while(G[0].parentNode);return B(document)}(C.currentItem);C.overflowX=function(G){do{if(/auto|scroll/.test(G.css("overflow"))||(/auto|scroll/).test(G.css("overflow-x"))){return G}G=G.parent()}while(G[0].parentNode);return B(document)}(C.currentItem);if(C.overflowY[0]!=document&&C.overflowY[0].tagName!="HTML"){C.overflowYOffset=C.overflowY.offset()}if(C.overflowX[0]!=document&&C.overflowX[0].tagName!="HTML"){C.overflowXOffset=C.overflowX.offset()}},sort:function(E,D){var F=D.options;var C=B(this).data("sortable");if(C.overflowY[0]!=document&&C.overflowY[0].tagName!="HTML"){if((C.overflowYOffset.top+C.overflowY[0].offsetHeight)-E.pageY<F.scrollSensitivity){C.overflowY[0].scrollTop=C.overflowY[0].scrollTop+F.scrollSpeed}if(E.pageY-C.overflowYOffset.top<F.scrollSensitivity){C.overflowY[0].scrollTop=C.overflowY[0].scrollTop-F.scrollSpeed}}else{if(E.pageY-B(document).scrollTop()<F.scrollSensitivity){B(document).scrollTop(B(document).scrollTop()-F.scrollSpeed)}if(B(window).height()-(E.pageY-B(document).scrollTop())<F.scrollSensitivity){B(document).scrollTop(B(document).scrollTop()+F.scrollSpeed)}}if(C.overflowX[0]!=document&&C.overflowX[0].tagName!="HTML"){if((C.overflowXOffset.left+C.overflowX[0].offsetWidth)-E.pageX<F.scrollSensitivity){C.overflowX[0].scrollLeft=C.overflowX[0].scrollLeft+F.scrollSpeed}if(E.pageX-C.overflowXOffset.left<F.scrollSensitivity){C.overflowX[0].scrollLeft=C.overflowX[0].scrollLeft-F.scrollSpeed}}else{if(E.pageX-B(document).scrollLeft()<F.scrollSensitivity){B(document).scrollLeft(B(document).scrollLeft()-F.scrollSpeed)}if(B(window).width()-(E.pageX-B(document).scrollLeft())<F.scrollSensitivity){B(document).scrollLeft(B(document).scrollLeft()+F.scrollSpeed)}}}});B.ui.plugin.add("sortable","axis",{sort:function(E,D){var C=B(this).data("sortable");if(D.options.axis=="y"){C.position.left=C.originalPosition.left}if(D.options.axis=="x"){C.position.top=C.originalPosition.top}}})})(jQuery)
\ No newline at end of file
-eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(4(A){A.39("8.3",{38:4(){2.c.v+=".3";2.1e(1c)},37:4(B,C){5((/^7/).1Z(B)){2.16(C)}n{2.c[B]=C;2.1e()}},i:4(){f 2.$3.i},1E:4(B){f B.24&&B.24.13(/\\s/g,"23").13(/[^A-36-35-9\\-23:\\.]/g,"")||2.c.1Q+A.e(B)},8:4(C,B){f{c:2.c,34:C,1M:B}},1e:4(O){2.$h=A("1i:33(a[o])",2.l);2.$3=2.$h.1s(4(){f A("a",2)[0]});2.$b=A([]);6 P=2,D=2.c;2.$3.V(4(R,Q){5(Q.u&&Q.u.13("#","")){P.$b=P.$b.1b(Q.u)}n{5(A(Q).12("o")!="#"){A.e(Q,"o.3",Q.o);A.e(Q,"q.3",Q.o);6 T=P.1E(Q);Q.o="#"+T;6 S=A("#"+T);5(!S.i){S=A(D.1x).12("1f",T).m(D.18).32(P.$b[R-1]||P.l);S.e("1a.3",1c)}P.$b=P.$b.1b(S)}n{D.d.1U(R+1)}}});5(O){2.l.m(D.1w);2.$b.V(4(){6 Q=A(2);Q.m(D.18)});5(D.7===1p){5(1J.u){2.$3.V(4(S,Q){5(Q.u==1J.u){D.7=S;5(A.W.1g||A.W.31){6 R=A(1J.u),T=R.12("1f");R.12("1f","");1z(4(){R.12("1f",T)},30)}2Z(0,0);f p}})}n{5(D.Y){6 J=2Y(A.Y("8-3"+A.e(P.l)),10);5(J&&P.$3[J]){D.7=J}}n{5(P.$h.z("."+D.k).i){D.7=P.$h.Z(P.$h.z("."+D.k)[0])}}}}D.7=D.7===j||D.7!==1p?D.7:0;D.d=A.2X(D.d.2W(A.1s(2.$h.z("."+D.U),4(R,Q){f P.$h.Z(R)}))).1T();5(A.1r(D.7,D.d)!=-1){D.d.2V(A.1r(D.7,D.d),1)}2.$b.m(D.w);2.$h.r(D.k);5(D.7!==j){2.$b.t(D.7).1G().r(D.w);2.$h.t(D.7).m(D.k);6 K=4(){A(P.l).y("20",[j,P.8(P.$3[D.7],P.$b[D.7])],D.1G)};5(A.e(2.$3[D.7],"q.3")){2.q(D.7,K)}n{K()}}A(2U).15("2T",4(){P.$3.14(".3");P.$h=P.$3=P.$b=j})}2S(6 G=0,N;N=2.$h[G];G++){A(N)[A.1r(G,D.d)!=-1&&!A(N).11(D.k)?"m":"r"](D.U)}5(D.x===p){2.$3.1m("x.3")}6 C,I,B={"2R-2Q":0,1I:1},E="2P";5(D.X&&D.X.2O==2N){C=D.X[0]||B,I=D.X[1]||B}n{C=I=D.X||B}6 H={1q:"",2M:"",2L:""};5(!A.W.1g){H.1H=""}4 M(R,Q,S){Q.22(C,C.1I||E,4(){Q.m(D.w).1d(H);5(A.W.1g&&C.1H){Q[0].21.z=""}5(S){L(R,S,Q)}})}4 L(R,S,Q){5(I===B){S.1d("1q","1D")}S.22(I,I.1I||E,4(){S.r(D.w).1d(H);5(A.W.1g&&I.1H){S[0].21.z=""}A(P.l).y("20",[j,P.8(R,S[0])],D.1G)})}4 F(R,T,Q,S){T.m(D.k).2K().r(D.k);M(R,Q,S)}2.$3.14(".3").15(D.v,4(){6 T=A(2).2J("1i:t(0)"),Q=P.$b.z(":2I"),S=A(2.u);5((T.11(D.k)&&!D.1h)||T.11(D.U)||A(2).11(D.17)||A(P.l).y("2H",[j,P.8(2,S[0])],D.16)===p){2.1t();f p}P.c.7=P.$3.Z(2);5(D.1h){5(T.11(D.k)){P.c.7=j;T.r(D.k);P.$b.1F();M(2,Q);2.1t();f p}n{5(!Q.i){P.$b.1F();6 R=2;P.q(P.$3.Z(2),4(){T.m(D.k).m(D.1v);L(R,S)});2.1t();f p}}}5(D.Y){A.Y("8-3"+A.e(P.l),P.c.7,D.Y)}P.$b.1F();5(S.i){6 R=2;P.q(P.$3.Z(2),Q.i?4(){F(R,T,Q,S)}:4(){T.m(D.k);L(R,S)})}n{2G"1K 2F 2E: 2D 2C 2B."}5(A.W.1g){2.1t()}f p});5(!(/^1y/).1Z(D.v)){2.$3.15("1y.3",4(){f p})}},1b:4(E,D,C){5(C==1p){C=2.$3.i}6 G=2.c;6 I=A(G.1P.13(/#\\{o\\}/g,E).13(/#\\{1j\\}/g,D));I.e("1a.3",1c);6 H=E.2A("#")==0?E.13("#",""):2.1E(A("a:2z-2y",I)[0]);6 F=A("#"+H);5(!F.i){F=A(G.1x).12("1f",H).m(G.w).e("1a.3",1c)}F.m(G.18);5(C>=2.$h.i){I.1Y(2.l);F.1Y(2.l[0].2x)}n{I.1X(2.$h[C]);F.1X(2.$b[C])}G.d=A.1s(G.d,4(K,J){f K>=C?++K:K});2.1e();5(2.$3.i==1){I.m(G.k);F.r(G.w);6 B=A.e(2.$3[0],"q.3");5(B){2.q(C,B)}}2.l.y("2w",[j,2.8(2.$3[C],2.$b[C])],G.1b)},19:4(B){6 D=2.c,E=2.$h.t(B).19(),C=2.$b.t(B).19();5(E.11(D.k)&&2.$3.i>1){2.16(B+(B+1<2.$3.i?1:-1))}D.d=A.1s(A.1W(D.d,4(G,F){f G!=B}),4(G,F){f G>=B?--G:G});2.1e();2.l.y("2v",[j,2.8(E.1C("a")[0],C[0])],D.19)},1V:4(B){6 C=2.c;5(A.1r(B,C.d)==-1){f}6 D=2.$h.t(B).r(C.U);5(A.W.2u){D.1d("1q","2t-1D");1z(4(){D.1d("1q","1D")},0)}C.d=A.1W(C.d,4(F,E){f F!=B});2.l.y("2s",[j,2.8(2.$3[B],2.$b[B])],C.1V)},1S:4(C){6 B=2,D=2.c;5(C!=D.7){2.$h.t(C).m(D.U);D.d.1U(C);D.d.1T();2.l.y("2r",[j,2.8(2.$3[C],2.$b[C])],D.1S)}},16:4(B){5(2q B=="2p"){B=2.$3.Z(2.$3.z("[o$="+B+"]")[0])}2.$3.t(B).2o(2.c.v)},q:4(G,K){6 L=2,D=2.c,E=2.$3.t(G),J=E[0],H=K==1p||K===p,B=E.e("q.3");K=K||4(){};5(!B||!H&&A.e(J,"x.3")){K();f}6 M=4(N){6 O=A(N),P=O.1C("*:2n");f P.i&&P||O};6 C=4(){L.$3.z("."+D.17).r(D.17).V(4(){5(D.1l){M(2).2m().1o(M(2).e("1j.3"))}});L.1n=j};5(D.1l){6 I=M(J).1o();M(J).2l("<1B></1B>").1C("1B").e("1j.3",I).1o(D.1l)}6 F=A.1L({},D.1k,{1R:B,1A:4(O,N){A(J.u).1o(O);C();5(D.x){A.e(J,"x.3",1c)}A(L.l).y("2k",[j,L.8(L.$3[G],L.$b[G])],D.q);D.1k.1A&&D.1k.1A(O,N);K()}});5(2.1n){2.1n.2j();C()}E.m(D.17);1z(4(){L.1n=A.2i(F)},0)},1R:4(C,B){2.$3.t(C).1m("x.3").e("q.3",B)},1a:4(){6 B=2.c;2.l.14(".3").r(B.1w).1m("3");2.$3.V(4(){6 C=A.e(2,"o.3");5(C){2.o=C}6 D=A(2).14(".3");A.V(["o","q","x"],4(E,F){D.1m(F+".3")})});2.$h.1b(2.$b).V(4(){5(A.e(2,"1a.3")){A(2).19()}n{A(2).r([B.k,B.1v,B.U,B.18,B.w].2h(" "))}})}});A.8.3.2g={1h:p,v:"1y",d:[],Y:j,1l:"2fe;",x:p,1Q:"8-3-",1k:{},X:j,1P:\'<1i><a o="#{o}"><1O>#{1j}</1O></a></1i>\',1x:"<1N></1N>",1w:"8-3-2d",k:"8-3-7",1v:"8-3-1h",U:"8-3-d",18:"8-3-1M",w:"8-3-2c",17:"8-3-2b"};A.8.3.2a="i";A.1L(A.8.3.29,{1u:j,28:4(C,F){F=F||p;6 B=2,E=2.c.7;4 G(){B.1u=27(4(){E=++E<B.$3.i?E:0;B.16(E)},C)}4 D(H){5(!H||H.26){25(B.1u)}}5(C){G();5(!F){2.$3.15(2.c.v,D)}n{2.$3.15(2.c.v,4(){D();E=B.c.7;G()})}}n{D();2.$3.14(2.c.v,D)}}})})(1K)',62,196,'||this|tabs|function|if|var|selected|ui|||panels|options|disabled|data|return||lis|length|null|selectedClass|element|addClass|else|href|false|load|removeClass||eq|hash|event|hideClass|cache|triggerHandler|filter|||||||||||||||||||||disabledClass|each|browser|fx|cookie|index||hasClass|attr|replace|unbind|bind|select|loadingClass|panelClass|remove|destroy|add|true|css|tabify|id|msie|unselect|li|label|ajaxOptions|spinner|removeData|xhr|html|undefined|display|inArray|map|blur|rotation|unselectClass|navClass|panelTemplate|click|setTimeout|success|em|find|block|tabId|stop|show|opacity|duration|location|jQuery|extend|panel|div|span|tabTemplate|idPrefix|url|disable|sort|push|enable|grep|insertBefore|appendTo|test|tabsshow|style|animate|_|title|clearInterval|clientX|setInterval|rotate|prototype|getter|loading|hide|nav|8230|Loading|defaults|join|ajax|abort|tabsload|wrapInner|parent|last|trigger|string|typeof|tabsdisable|tabsenable|inline|safari|tabsremove|tabsadd|parentNode|child|first|indexOf|identifier|fragment|Mismatching|Tabs|UI|throw|tabsselect|visible|parents|siblings|height|overflow|Array|constructor|normal|width|min|for|unload|window|splice|concat|unique|parseInt|scrollTo|500|opera|insertAfter|has|tab|z0|Za|setData|init|widget'.split('|'),0,{}))
+eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(4(A){A.3g("8.3",{3f:4(){2.c.t+=".3";2.1f(1d)},3e:4(B,C){5((/^7/).26(B)){2.17(C)}m{2.c[B]=C;2.1f()}},j:4(){d 2.$3.j},1G:4(B){d B.2b&&B.2b.14(/\\s/g,"2a").14(/[^A-3d-3c-9\\-2a:\\.]/g,"")||2.c.1S+A.f(B)},8:4(C,B){d{c:2.c,3b:C,1O:B,V:2.$3.V(C)}},1f:4(O){2.$i=A("1j:3a(a[n])",2.h);2.$3=2.$i.1t(4(){d A("a",2)[0]});2.$b=A([]);6 P=2,D=2.c;2.$3.X(4(R,Q){5(Q.v&&Q.v.14("#","")){P.$b=P.$b.1c(Q.v)}m{5(A(Q).13("n")!="#"){A.f(Q,"n.3",Q.n);A.f(Q,"p.3",Q.n);6 T=P.1G(Q);Q.n="#"+T;6 S=A("#"+T);5(!S.j){S=A(D.1z).13("1g",T).l(D.19).39(P.$b[R-1]||P.h);S.f("1b.3",1d)}P.$b=P.$b.1c(S)}m{D.e.1Y(R+1)}}});5(O){2.h.l(D.1y);2.$b.X(4(){6 Q=A(2);Q.l(D.19)});5(D.7===1q){5(1L.v){2.$3.X(4(S,Q){5(Q.v==1L.v){D.7=S;5(A.Y.1h||A.Y.38){6 R=A(1L.v),T=R.13("1g");R.13("1g","");1B(4(){R.13("1g",T)},37)}36(0,0);d o}})}m{5(D.11){6 J=35(A.11("8-3"+A.f(P.h)),10);5(J&&P.$3[J]){D.7=J}}m{5(P.$i.U("."+D.k).j){D.7=P.$i.V(P.$i.U("."+D.k)[0])}}}}D.7=D.7===w||D.7!==1q?D.7:0;D.e=A.34(D.e.33(A.1t(2.$i.U("."+D.W),4(R,Q){d P.$i.V(R)}))).1X();5(A.1s(D.7,D.e)!=-1){D.e.32(A.1s(D.7,D.e),1)}2.$b.l(D.x);2.$i.q(D.k);5(D.7!==w){2.$b.r(D.7).1I().q(D.x);2.$i.r(D.7).l(D.k);6 K=4(){A(P.h).z("1v",[P.u("1v"),P.8(P.$3[D.7],P.$b[D.7])],D.1I)};5(A.f(2.$3[D.7],"p.3")){2.p(D.7,K)}m{K()}}A(31).16("30",4(){P.$3.15(".3");P.$i=P.$3=P.$b=w})}2Z(6 G=0,N;N=2.$i[G];G++){A(N)[A.1s(G,D.e)!=-1&&!A(N).12(D.k)?"l":"q"](D.W)}5(D.y===o){2.$3.1n("y.3")}6 C,I,B={"2Y-2X":0,1K:1},E="2W";5(D.Z&&D.Z.2V==2U){C=D.Z[0]||B,I=D.Z[1]||B}m{C=I=D.Z||B}6 H={1r:"",2T:"",2S:""};5(!A.Y.1h){H.1J=""}4 M(R,Q,S){Q.29(C,C.1K||E,4(){Q.l(D.x).1e(H);5(A.Y.1h&&C.1J){Q[0].28.U=""}5(S){L(R,S,Q)}})}4 L(R,S,Q){5(I===B){S.1e("1r","1F")}S.29(I,I.1K||E,4(){S.q(D.x).1e(H);5(A.Y.1h&&I.1J){S[0].28.U=""}A(P.h).z("1v",[P.u("1v"),P.8(R,S[0])],D.1I)})}4 F(R,T,Q,S){T.l(D.k).2R().q(D.k);M(R,Q,S)}2.$3.15(".3").16(D.t,4(){6 T=A(2).2Q("1j:r(0)"),Q=P.$b.U(":2P"),S=A(2.v);5((T.12(D.k)&&!D.1i)||T.12(D.W)||A(2).12(D.18)||A(P.h).z("27",[P.u("27"),P.8(2,S[0])],D.17)===o){2.1u();d o}P.c.7=P.$3.V(2);5(D.1i){5(T.12(D.k)){P.c.7=w;T.q(D.k);P.$b.1H();M(2,Q);2.1u();d o}m{5(!Q.j){P.$b.1H();6 R=2;P.p(P.$3.V(2),4(){T.l(D.k).l(D.1x);L(R,S)});2.1u();d o}}}5(D.11){A.11("8-3"+A.f(P.h),P.c.7,D.11)}P.$b.1H();5(S.j){6 R=2;P.p(P.$3.V(2),Q.j?4(){F(R,T,Q,S)}:4(){T.l(D.k);L(R,S)})}m{2O"1M 2N 2M: 2L 2K 2J."}5(A.Y.1h){2.1u()}d o});5(!(/^1A/).26(D.t)){2.$3.16("1A.3",4(){d o})}},1c:4(E,D,C){5(C==1q){C=2.$3.j}6 G=2.c;6 I=A(G.1R.14(/#\\{n\\}/g,E).14(/#\\{1k\\}/g,D));I.f("1b.3",1d);6 H=E.2I("#")==0?E.14("#",""):2.1G(A("a:2H-2G",I)[0]);6 F=A("#"+H);5(!F.j){F=A(G.1z).13("1g",H).l(G.x).f("1b.3",1d)}F.l(G.19);5(C>=2.$i.j){I.25(2.h);F.25(2.h[0].2F)}m{I.24(2.$i[C]);F.24(2.$b[C])}G.e=A.1t(G.e,4(K,J){d K>=C?++K:K});2.1f();5(2.$3.j==1){I.l(G.k);F.q(G.x);6 B=A.f(2.$3[0],"p.3");5(B){2.p(C,B)}}2.h.z("23",[2.u("23"),2.8(2.$3[C],2.$b[C])],G.1c)},1a:4(B){6 D=2.c,E=2.$i.r(B).1a(),C=2.$b.r(B).1a();5(E.12(D.k)&&2.$3.j>1){2.17(B+(B+1<2.$3.j?1:-1))}D.e=A.1t(A.21(D.e,4(G,F){d G!=B}),4(G,F){d G>=B?--G:G});2.1f();2.h.z("22",[2.u("22"),2.8(E.1E("a")[0],C[0])],D.1a)},1Z:4(B){6 C=2.c;5(A.1s(B,C.e)==-1){d}6 D=2.$i.r(B).q(C.W);5(A.Y.2E){D.1e("1r","2D-1F");1B(4(){D.1e("1r","1F")},0)}C.e=A.21(C.e,4(F,E){d F!=B});2.h.z("20",[2.u("20"),2.8(2.$3[B],2.$b[B])],C.1Z)},1V:4(C){6 B=2,D=2.c;5(C!=D.7){2.$i.r(C).l(D.W);D.e.1Y(C);D.e.1X();2.h.z("1W",[2.u("1W"),2.8(2.$3[C],2.$b[C])],D.1V)}},17:4(B){5(2C B=="2B"){B=2.$3.V(2.$3.U("[n$="+B+"]")[0])}2.$3.r(B).2A(2.c.t)},p:4(G,K){6 L=2,D=2.c,E=2.$3.r(G),J=E[0],H=K==1q||K===o,B=E.f("p.3");K=K||4(){};5(!B||!H&&A.f(J,"y.3")){K();d}6 M=4(N){6 O=A(N),P=O.1E("*:2z");d P.j&&P.2y(":2x(2w)")&&P||O};6 C=4(){L.$3.U("."+D.18).q(D.18).X(4(){5(D.1m){M(2).2v().1p(M(2).f("1k.3"))}});L.1o=w};5(D.1m){6 I=M(J).1p();M(J).2u("<1D></1D>").1E("1D").f("1k.3",I).1p(D.1m)}6 F=A.1N({},D.1l,{1T:B,1C:4(O,N){A(J.v).1p(O);C();5(D.y){A.f(J,"y.3",1d)}A(L.h).z("1U",[L.u("1U"),L.8(L.$3[G],L.$b[G])],D.p);D.1l.1C&&D.1l.1C(O,N);K()}});5(2.1o){2.1o.2t();C()}E.l(D.18);1B(4(){L.1o=A.2s(F)},0)},1T:4(C,B){2.$3.r(C).1n("y.3").f("p.3",B)},1b:4(){6 B=2.c;2.h.15(".3").q(B.1y).1n("3");2.$3.X(4(){6 C=A.f(2,"n.3");5(C){2.n=C}6 D=A(2).15(".3");A.X(["n","p","y"],4(E,F){D.1n(F+".3")})});2.$i.1c(2.$b).X(4(){5(A.f(2,"1b.3")){A(2).1a()}m{A(2).q([B.k,B.1x,B.W,B.19,B.x].2r(" "))}})},u:4(B){d A.t.2q({2p:B,2o:2.h[0]})}});A.8.3.2n={1i:o,t:"1A",e:[],11:w,1m:"2ml;",y:o,1S:"8-3-",1l:{},Z:w,1R:\'<1j><a n="#{n}"><1Q>#{1k}</1Q></a></1j>\',1z:"<1P></1P>",1y:"8-3-2k",k:"8-3-7",1x:"8-3-1i",W:"8-3-e",19:"8-3-1O",x:"8-3-2j",18:"8-3-2i"};A.8.3.2h="j";A.1N(A.8.3.2g,{1w:w,2f:4(C,F){F=F||o;6 B=2,E=2.c.7;4 G(){B.1w=2e(4(){E=++E<B.$3.j?E:0;B.17(E)},C)}4 D(H){5(!H||H.2d){2c(B.1w)}}5(C){G();5(!F){2.$3.16(2.c.t,D)}m{2.$3.16(2.c.t,4(){D();E=B.c.7;G()})}}m{D();2.$3.15(2.c.t,D)}}})})(1M)',62,203,'||this|tabs|function|if|var|selected|ui|||panels|options|return|disabled|data||element|lis|length|selectedClass|addClass|else|href|false|load|removeClass|eq||event|fakeEvent|hash|null|hideClass|cache|triggerHandler|||||||||||||||||||||filter|index|disabledClass|each|browser|fx||cookie|hasClass|attr|replace|unbind|bind|select|loadingClass|panelClass|remove|destroy|add|true|css|tabify|id|msie|unselect|li|label|ajaxOptions|spinner|removeData|xhr|html|undefined|display|inArray|map|blur|tabsshow|rotation|unselectClass|navClass|panelTemplate|click|setTimeout|success|em|find|block|tabId|stop|show|opacity|duration|location|jQuery|extend|panel|div|span|tabTemplate|idPrefix|url|tabsload|disable|tabsdisable|sort|push|enable|tabsenable|grep|tabsremove|tabsadd|insertBefore|appendTo|test|tabsselect|style|animate|_|title|clearInterval|clientX|setInterval|rotate|prototype|getter|loading|hide|nav|8230|Loading|defaults|target|type|fix|join|ajax|abort|wrapInner|parent|img|not|is|last|trigger|string|typeof|inline|safari|parentNode|child|first|indexOf|identifier|fragment|Mismatching|Tabs|UI|throw|visible|parents|siblings|height|overflow|Array|constructor|normal|width|min|for|unload|window|splice|concat|unique|parseInt|scrollTo|500|opera|insertAfter|has|tab|z0|Za|setData|init|widget'.split('|'),0,{}))
edInsertContent(myField, myValue);
}
}
+
+
+// Allow multiple instances.
+// Name = unique value, id = textarea id, container = container div.
+// Can disable some buttons by passing comma delimited string as 4th param.
+var QTags = function(name, id, container, disabled) {
+ var t = this, cont = document.getElementById(container);
+
+ t.Buttons = [];
+ t.Links = [];
+ t.OpenTags = [];
+ t.Canvas = document.getElementById(id);
+
+ if ( ! t.Canvas || ! cont )
+ return;
+
+ disabled = ( typeof disabled != 'undefined' ) ? ','+disabled+',' : '';
+
+ t.edShowButton = function(button, i) {
+ if ( disabled && (disabled.indexOf(','+button.display+',') != -1) )
+ return '';
+ else if ( button.id == name+'_img' )
+ return '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage('+name+'.Canvas);" value="' + button.display + '" />';
+ else if (button.id == name+'_link')
+ return '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="'+name+'.edInsertLink('+i+');" value="'+button.display+'" />';
+ else
+ return '<input type="button" id="' + button.id + '" accesskey="'+button.access+'" class="ed_button" onclick="'+name+'.edInsertTag('+i+');" value="'+button.display+'" />';
+ };
+
+ t.edAddTag = function(button) {
+ if ( t.Buttons[button].tagEnd != '' ) {
+ t.OpenTags[t.OpenTags.length] = button;
+ document.getElementById(t.Buttons[button].id).value = '/' + document.getElementById(t.Buttons[button].id).value;
+ }
+ };
+
+ t.edRemoveTag = function(button) {
+ for ( var i = 0; i < t.OpenTags.length; i++ ) {
+ if ( t.OpenTags[i] == button ) {
+ t.OpenTags.splice(i, 1);
+ document.getElementById(t.Buttons[button].id).value = document.getElementById(t.Buttons[button].id).value.replace('/', '');
+ }
+ }
+ };
+
+ t.edCheckOpenTags = function(button) {
+ var tag = 0;
+ for ( var i = 0; i < t.OpenTags.length; i++ ) {
+ if ( t.OpenTags[i] == button )
+ tag++;
+ }
+ if ( tag > 0 ) return true; // tag found
+ else return false; // tag not found
+ };
+
+ this.edCloseAllTags = function() {
+ var count = t.OpenTags.length;
+ for ( var o = 0; o < count; o++ )
+ t.edInsertTag(t.OpenTags[t.OpenTags.length - 1]);
+ };
+
+ this.edQuickLink = function(i, thisSelect) {
+ if ( i > -1 ) {
+ var newWin = '';
+ if ( Links[i].newWin == 1 ) {
+ newWin = ' target="_blank"';
+ }
+ var tempStr = '<a href="' + Links[i].URL + '"' + newWin + '>'
+ + Links[i].display
+ + '</a>';
+ thisSelect.selectedIndex = 0;
+ edInsertContent(t.Canvas, tempStr);
+ } else {
+ thisSelect.selectedIndex = 0;
+ }
+ };
+
+ // insertion code
+ t.edInsertTag = function(i) {
+ //IE support
+ if ( document.selection ) {
+ t.Canvas.focus();
+ sel = document.selection.createRange();
+ if ( sel.text.length > 0 ) {
+ sel.text = t.Buttons[i].tagStart + sel.text + t.Buttons[i].tagEnd;
+ } else {
+ if ( ! t.edCheckOpenTags(i) || t.Buttons[i].tagEnd == '' ) {
+ sel.text = t.Buttons[i].tagStart;
+ t.edAddTag(i);
+ } else {
+ sel.text = t.Buttons[i].tagEnd;
+ t.edRemoveTag(i);
+ }
+ }
+ t.Canvas.focus();
+ } else if ( t.Canvas.selectionStart || t.Canvas.selectionStart == '0' ) { //MOZILLA/NETSCAPE support
+ var startPos = t.Canvas.selectionStart;
+ var endPos = t.Canvas.selectionEnd;
+ var cursorPos = endPos;
+ var scrollTop = t.Canvas.scrollTop;
+
+ if ( startPos != endPos ) {
+ t.Canvas.value = t.Canvas.value.substring(0, startPos)
+ + t.Buttons[i].tagStart
+ + t.Canvas.value.substring(startPos, endPos)
+ + t.Buttons[i].tagEnd
+ + t.Canvas.value.substring(endPos, t.Canvas.value.length);
+ cursorPos += t.Buttons[i].tagStart.length + t.Buttons[i].tagEnd.length;
+ } else {
+ if ( !t.edCheckOpenTags(i) || t.Buttons[i].tagEnd == '' ) {
+ t.Canvas.value = t.Canvas.value.substring(0, startPos)
+ + t.Buttons[i].tagStart
+ + t.Canvas.value.substring(endPos, t.Canvas.value.length);
+ t.edAddTag(i);
+ cursorPos = startPos + t.Buttons[i].tagStart.length;
+ } else {
+ t.Canvas.value = t.Canvas.value.substring(0, startPos)
+ + t.Buttons[i].tagEnd
+ + t.Canvas.value.substring(endPos, t.Canvas.value.length);
+ t.edRemoveTag(i);
+ cursorPos = startPos + t.Buttons[i].tagEnd.length;
+ }
+ }
+ t.Canvas.focus();
+ t.Canvas.selectionStart = cursorPos;
+ t.Canvas.selectionEnd = cursorPos;
+ t.Canvas.scrollTop = scrollTop;
+ } else {
+ if ( ! t.edCheckOpenTags(i) || t.Buttons[i].tagEnd == '' ) {
+ t.Canvas.value += Buttons[i].tagStart;
+ t.edAddTag(i);
+ } else {
+ t.Canvas.value += Buttons[i].tagEnd;
+ t.edRemoveTag(i);
+ }
+ t.Canvas.focus();
+ }
+ };
+
+ this.edInsertLink = function(i, defaultValue) {
+ if ( ! defaultValue )
+ defaultValue = 'http://';
+
+ if ( ! t.edCheckOpenTags(i) ) {
+ var URL = prompt(quicktagsL10n.enterURL, defaultValue);
+ if ( URL ) {
+ t.Buttons[i].tagStart = '<a href="' + URL + '">';
+ t.edInsertTag(i);
+ }
+ } else {
+ t.edInsertTag(i);
+ }
+ };
+
+ this.edInsertImage = function() {
+ var myValue = prompt(quicktagsL10n.enterImageURL, 'http://');
+ if ( myValue ) {
+ myValue = '<img src="'
+ + myValue
+ + '" alt="' + prompt(quicktagsL10n.enterImageDescription, '')
+ + '" />';
+ edInsertContent(t.Canvas, myValue);
+ }
+ };
+
+ t.Buttons[t.Buttons.length] = new edButton(name+'_strong','b','<strong>','</strong>','b');
+ t.Buttons[t.Buttons.length] = new edButton(name+'_em','i','<em>','</em>','i');
+ t.Buttons[t.Buttons.length] = new edButton(name+'_link','link','','</a>','a'); // special case
+ t.Buttons[t.Buttons.length] = new edButton(name+'_block','b-quote','\n\n<blockquote>','</blockquote>\n\n','q');
+ t.Buttons[t.Buttons.length] = new edButton(name+'_del','del','<del datetime="' + datetime + '">','</del>','d');
+ t.Buttons[t.Buttons.length] = new edButton(name+'_ins','ins','<ins datetime="' + datetime + '">','</ins>','s');
+ t.Buttons[t.Buttons.length] = new edButton(name+'_img','img','','','m',-1); // special case
+ t.Buttons[t.Buttons.length] = new edButton(name+'_ul','ul','<ul>\n','</ul>\n\n','u');
+ t.Buttons[t.Buttons.length] = new edButton(name+'_ol','ol','<ol>\n','</ol>\n\n','o');
+ t.Buttons[t.Buttons.length] = new edButton(name+'_li','li','\t<li>','</li>\n','l');
+ t.Buttons[t.Buttons.length] = new edButton(name+'_code','code','<code>','</code>','c');
+ t.Buttons[t.Buttons.length] = new edButton(name+'_more','more','<!--more-->','','t',-1);
+// t.Buttons[t.Buttons.length] = new edButton(name+'_next','page','<!--nextpage-->','','p',-1);
+
+ var tb = document.createElement('div');
+ tb.id = name+'_qtags';
+
+ var html = '<div id="'+name+'_toolbar">';
+ for (var i = 0; i < t.Buttons.length; i++)
+ html += t.edShowButton(t.Buttons[i], i);
+
+ html += '<input type="button" id="'+name+'_ed_spell" class="ed_button" onclick="edSpell('+name+'.Canvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />';
+ html += '<input type="button" id="'+name+'_ed_close" class="ed_button" onclick="'+name+'.edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" /></div>';
+
+ tb.innerHTML = html;
+ cont.parentNode.insertBefore(tb, cont);
+
+};
jQuery('#media-item-' + fileObj.id + ' .bar').remove();
jQuery('#media-item-' + fileObj.id + ' .progress').hide();
+ var f = ( typeof shortform == 'undefined' ) ? 1 : 2;
// Old style: Append the HTML returned by the server -- thumbnail and form inputs
if ( isNaN(serverData) || !serverData ) {
jQuery('#media-item-' + fileObj.id).append(serverData);
}
// New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
else {
- jQuery('#media-item-' + fileObj.id).load('async-upload.php', {attachment_id:serverData, fetch:1}, function(){prepareMediaItemInit(fileObj);updateMediaForm()});
+ jQuery('#media-item-' + fileObj.id).load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm()});
}
}
jQuery('#media-item-' + fileObj.id + ' .filename.original').replaceWith(jQuery('#media-item-' + fileObj.id + ' .filename.new'));
// Also bind toggle to the links
- jQuery('#media-item-' + fileObj.id + ' a.toggle').bind('click', function(){jQuery(this).siblings('.slidetoggle').slideToggle(150, function(){window.scrollTo(0,this.parentNode.offsetTop);});jQuery(this).parent().eq(0).children('.toggle').toggle();jQuery(this).siblings('a.toggle').focus();return false;});
+ jQuery('#media-item-' + fileObj.id + ' a.toggle').bind('click', function(){jQuery(this).siblings('.slidetoggle').slideToggle(150, function(){var o=jQuery(this).offset();window.scrollTo(0,o.top-36);});jQuery(this).parent().eq(0).children('.toggle').toggle();jQuery(this).siblings('a.toggle').focus();return false;});
// Bind AJAX to the new Delete button
jQuery('#media-item-' + fileObj.id + ' a.delete').bind('click',function(){
}
function updateMediaForm() {
+ storeState();
// Just one file, no need for collapsible part
if ( jQuery('.type-form #media-items>*').length == 1 ) {
jQuery('#media-items .slidetoggle').slideDown(500).parent().eq(0).children('.toggle').toggle();
}
}
+function swfuploadPreLoad() {
+ var swfupload_element = jQuery('#'+swfu.customSettings.swfupload_element_id).get(0);
+ jQuery('#' + swfu.customSettings.degraded_element_id).hide();
+ // Doing this directly because jQuery().show() seems to have timing problems
+ if ( swfupload_element && ! swfupload_element.style.display )
+ swfupload_element.style.display = 'block';
+}
+
+function swfuploadLoadFailed() {
+ jQuery('#' + swfu.customSettings.swfupload_element_id).hide();
+ jQuery('#' + swfu.customSettings.degraded_element_id).show();
+}
+
function uploadError(fileObj, error_code, message) {
// first the file specific error
if ( error_code == SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL ) {
wpQueueError(swfuploadL10n.security_error);
}
}
+
+// remember the last used image size, alignment and url
+var storeState;
+(function($){
+
+storeState = function(){
+ var align = getUserSetting('align') || '', imgsize = getUserSetting('imgsize') || '';
+
+ $('tr.align input[type="radio"]').click(function(){
+ setUserSetting('align', $(this).val());
+ }).filter(function(){
+ if ( $(this).val() == align )
+ return true;
+ return false;
+ }).attr('checked','checked');
+
+ $('tr.image-size input[type="radio"]').click(function(){
+ setUserSetting('imgsize', $(this).val());
+ }).filter(function(){
+ if ( $(this).attr('disabled') || $(this).val() != imgsize )
+ return false;
+ return true;
+ }).attr('checked','checked');
+
+ $('tr.url button').click(function(){
+ var c = this.className || '';
+ c = c.replace(/.*?(url[^ '"]+).*/, '$1');
+ if (c) setUserSetting('urlbutton', c);
+ $(this).siblings('.urlfield').val( $(this).attr('title') );
+ });
+
+ $('tr.url .urlfield').each(function(){
+ var b = getUserSetting('urlbutton');
+ $(this).val( $(this).siblings('button.'+b).attr('title') );
+ });
+}
+})(jQuery);
var SWFUpload;
if (typeof(SWFUpload) === "function") {
- SWFUpload.prototype.initSettings = function (old_initSettings) {
- return function (init_settings) {
- if (typeof(old_initSettings) === "function") {
- old_initSettings.call(this, init_settings);
+ SWFUpload.prototype.initSettings = function (oldInitSettings) {
+ return function () {
+ if (typeof(oldInitSettings) === "function") {
+ oldInitSettings.call(this);
}
this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point
};
}(SWFUpload.prototype.initSettings);
- // refreshes the post_params and updates SWFUpload. The send_to_flash parameters is optional and defaults to True
- SWFUpload.prototype.refreshCookies = function (send_to_flash) {
- if (send_to_flash !== false) send_to_flash = true;
+ // refreshes the post_params and updates SWFUpload. The sendToFlash parameters is optional and defaults to True
+ SWFUpload.prototype.refreshCookies = function (sendToFlash) {
+ if (sendToFlash === undefined) {
+ sendToFlash = true;
+ }
+ sendToFlash = !!sendToFlash;
// Get the post_params object
- var post_params = this.getSetting("post_params");
+ var postParams = this.settings.post_params;
// Get the cookies
- var i, cookie_array = document.cookie.split(';'), ca_length = cookie_array.length, c, eq_index, name, value;
- for(i = 0; i < ca_length; i++) {
- c = cookie_array[i];
+ var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value;
+ for (i = 0; i < caLength; i++) {
+ c = cookieArray[i];
// Left Trim spaces
- while (c.charAt(0) == " ") {
+ while (c.charAt(0) === " ") {
c = c.substring(1, c.length);
}
- eq_index = c.indexOf("=");
- if (eq_index > 0) {
- name = c.substring(0, eq_index);
- value = c.substring(eq_index+1);
- post_params[name] = value;
+ eqIndex = c.indexOf("=");
+ if (eqIndex > 0) {
+ name = c.substring(0, eqIndex);
+ value = c.substring(eqIndex + 1);
+ postParams[name] = value;
}
}
- if (send_to_flash) {
- this.setPostParams(post_params);
+ if (sendToFlash) {
+ this.setPostParams(postParams);
}
};
Queue Plug-in
Features:
- cancelQueue method for cancelling the entire queue.
- All queued files are uploaded when startUpload() is called.
- If false is returned from uploadComplete then the queue upload is stopped. If false is not returned (strict comparison) then the queue upload is continued.
+ *Adds a cancelQueue() method for cancelling the entire queue.
+ *All queued files are uploaded when startUpload() is called.
+ *If false is returned from uploadComplete then the queue upload is stopped.
+ If false is not returned (strict comparison) then the queue upload is continued.
+ *Adds a QueueComplete event that is fired when all the queued files have finished uploading.
+ Set the event handler with the queue_complete_handler setting.
*/
if (typeof(SWFUpload) === "function") {
SWFUpload.queue = {};
- SWFUpload.prototype.initSettings = function (old_initSettings) {
- return function (init_settings) {
- if (typeof(old_initSettings) === "function") {
- old_initSettings.call(this, init_settings);
+ SWFUpload.prototype.initSettings = (function (oldInitSettings) {
+ return function () {
+ if (typeof(oldInitSettings) === "function") {
+ oldInitSettings.call(this);
}
this.customSettings.queue_cancelled_flag = false;
+ this.customSettings.queue_upload_count = 0;
- this.addSetting("user_upload_complete_handler", init_settings.upload_complete_handler, SWFUpload.uploadComplete);
- this.uploadComplete_handler = SWFUpload.queue.uploadComplete;
+ this.settings.user_upload_complete_handler = this.settings.upload_complete_handler;
+ this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
+
+ this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
};
- }(SWFUpload.prototype.initSettings);
+ })(SWFUpload.prototype.initSettings);
- SWFUpload.prototype.cancelQueue = function () {
- var stats = this.getStats();
+ SWFUpload.prototype.startUpload = function (fileID) {
this.customSettings.queue_cancelled_flag = false;
+ this.callFlash("StartUpload", false, [fileID]);
+ };
- if (stats.in_progress > 0) {
- this.customSettings.queue_cancelled_flag = true;
- }
+ SWFUpload.prototype.cancelQueue = function () {
+ this.customSettings.queue_cancelled_flag = true;
+ this.stopUpload();
- while(stats.files_queued > 0) {
+ var stats = this.getStats();
+ while (stats.files_queued > 0) {
this.cancelUpload();
stats = this.getStats();
}
};
- SWFUpload.queue.uploadComplete = function (file) {
- var user_upload_complete_handler = this.getSetting("user_upload_complete_handler");
- var continue_upload = true;
+ SWFUpload.queue.uploadCompleteHandler = function (file) {
+ var user_upload_complete_handler = this.settings.user_upload_complete_handler;
+ var continueUpload;
+
+ if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
+ this.customSettings.queue_upload_count++;
+ }
+
if (typeof(user_upload_complete_handler) === "function") {
- continue_upload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
+ continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
+ } else {
+ continueUpload = true;
}
- if (continue_upload) {
+ if (continueUpload) {
var stats = this.getStats();
if (stats.files_queued > 0 && this.customSettings.queue_cancelled_flag === false) {
this.startUpload();
+ } else if (this.customSettings.queue_cancelled_flag === false) {
+ this.queueEvent("queue_complete_handler", [this.customSettings.queue_upload_count]);
+ this.customSettings.queue_upload_count = 0;
} else {
this.customSettings.queue_cancelled_flag = false;
+ this.customSettings.queue_upload_count = 0;
}
}
};
-}
+}
\ No newline at end of file
--- /dev/null
+/*
+ SWFUpload.SWFObject Plugin
+
+ Summary:
+ This plugin uses SWFObject to embed SWFUpload dynamically in the page. SWFObject provides accurate Flash Player detection and DOM Ready loading.
+ This plugin replaces the Graceful Degradation plugin.
+
+ Features:
+ * swfupload_load_failed_hander event
+ * swfupload_pre_load_handler event
+ * minimum_flash_version setting (default: "9.0.28")
+ * SWFUpload.onload event for early loading
+
+ Usage:
+ Provide handlers and settings as needed. When using the SWFUpload.SWFObject plugin you should initialize SWFUploading
+ in SWFUpload.onload rather than in window.onload. When initialized this way SWFUpload can load earlier preventing the UI flicker
+ that was seen using the Graceful Degradation plugin.
+
+ <script type="text/javascript">
+ var swfu;
+ SWFUpload.onload = function () {
+ swfu = new SWFUpload({
+ minimum_flash_version: "9.0.28",
+ swfupload_pre_load_handler: swfuploadPreLoad,
+ swfupload_load_failed_handler: swfuploadLoadFailed
+ });
+ };
+ </script>
+
+ Notes:
+ You must provide set minimum_flash_version setting to "8" if you are using SWFUpload for Flash Player 8.
+ The swfuploadLoadFailed event is only fired if the minimum version of Flash Player is not met. Other issues such as missing SWF files, browser bugs
+ or corrupt Flash Player installations will not trigger this event.
+ The swfuploadPreLoad event is fired as soon as the minimum version of Flash Player is found. It does not wait for SWFUpload to load and can
+ be used to prepare the SWFUploadUI and hide alternate content.
+ swfobject's onDomReady event is cross-browser safe but will default to the window.onload event when DOMReady is not supported by the browser.
+ Early DOM Loading is supported in major modern browsers but cannot be guaranteed for every browser ever made.
+*/
+
+
+/* SWFObject v2.0 rc4 <http://code.google.com/p/swfobject/>
+ Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
+ This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
+*/
+var swfobject=function(){var X="undefined",P="object",a="visibility:visible",e="visibility:hidden",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",V="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,S=false,C=false;var Y=function(){var l=typeof g.getElementById!=X&&typeof g.getElementsByTagName!=X&&typeof g.createElement!=X&&typeof g.appendChild!=X&&typeof g.replaceChild!=X&&typeof g.removeChild!=X&&typeof g.cloneNode!=X,t=[0,0,0],n=null;if(typeof N.plugins!=X&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=X){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var d=function(){if(!Y.w3cdom){return }J(I);if(Y.ie&&Y.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=b("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);U()}}}}catch(j){}}if(Y.webkit&&typeof g.readyState!=X){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){U()}},10)}if(typeof g.addEventListener!=X){g.addEventListener("DOMContentLoaded",U,null)}M(U)}();function U(){if(S){return }if(Y.ie&&Y.win){var m=W("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=X){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=X){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=X){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(Y.pv[0]>0){var k=b(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(Y.webkit&&Y.webkit<312){T(k)}}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(Y.win||Y.mac)){D(H[j])}else{c(k)}}}}A("#"+m,a)}}function T(m){var k=m.getElementsByTagName(P)[0];if(k){var p=W("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(Y.ie&&Y.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=b(i);for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)})}}function D(j){C=true;var o=b(j.id);if(o){if(j.altContentId){var l=b(j.altContentId);if(l){L=l}}else{L=Z(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=Y.ie&&Y.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(Y.ie&&Y.win&&o.readyState!=4){var i=W("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function c(j){if(Y.ie&&Y.win&&j.readyState!=4){var i=W("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(Z(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(Z(j),j)}}function Z(n){var m=W("div");if(Y.win&&Y.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=b(q);if(typeof AE.id==X){AE.id=q}if(Y.ie&&Y.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=b(AE.id)}else{if(Y.webkit&&Y.webkit<312){var AA=W("embed");AA.setAttribute("type",V);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=W(P);s.setAttribute("type",V);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=W("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function b(i){return g.getElementById(i)}function W(i){return g.createElement(i)}function O(k){var j=Y.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(Y.ie&&Y.mac){return }var l=g.getElementsByTagName("head")[0],k=W("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(Y.ie&&Y.win)&&typeof g.createTextNode!=X){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(Y.ie&&Y.win&&typeof g.styleSheets!=X&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}return{registerObject:function(l,i,k){if(!Y.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;A("#"+l,e)},getObjectById:function(l){var i=null;if(Y.w3cdom&&S){var j=b(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=X)){i=j}else{if(typeof k.SetVariable!=X){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!Y.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){A("#"+u,e);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=X){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);A("#"+u,a)})}else{if(m&&!C&&O("6.0.65")&&(Y.win||Y.mac)){A("#"+u,e);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i);A("#"+u,a)})}}},getFlashPlayerVersion:function(){return{major:Y.pv[0],minor:Y.pv[1],release:Y.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(Y.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(Y.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=b(K);if(i){i.parentNode.replaceChild(L,i);L=null;C=false}}}}}();
+
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+ SWFUpload.onload = function () {};
+
+ swfobject.addDomLoadEvent(function () {
+ if (typeof(SWFUpload.onload) === "function") {
+ SWFUpload.onload.call(window);
+ }
+ });
+
+ SWFUpload.prototype.initSettings = (function (oldInitSettings) {
+ return function () {
+ if (typeof(oldInitSettings) === "function") {
+ oldInitSettings.call(this);
+ }
+
+ this.ensureDefault = function (settingName, defaultValue) {
+ this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
+ };
+
+ this.ensureDefault("minimum_flash_version", "9.0.28");
+ this.ensureDefault("swfupload_pre_load_handler", null);
+ this.ensureDefault("swfupload_load_failed_handler", null);
+
+ delete this.ensureDefault;
+
+ };
+ })(SWFUpload.prototype.initSettings);
+
+
+ SWFUpload.prototype.loadFlash = function (oldLoadFlash) {
+ return function () {
+ var hasFlash = swfobject.hasFlashPlayerVersion(this.settings.minimum_flash_version);
+
+ if (hasFlash) {
+ this.queueEvent("swfupload_pre_load_handler");
+ if (typeof(oldLoadFlash) === "function") {
+ oldLoadFlash.call(this);
+ }
+ } else {
+ this.queueEvent("swfupload_load_failed_handler");
+ }
+ };
+
+ }(SWFUpload.prototype.loadFlash);
+
+ SWFUpload.prototype.displayDebugInfo = function (oldDisplayDebugInfo) {
+ return function () {
+ if (typeof(oldDisplayDebugInfo) === "function") {
+ oldDisplayDebugInfo.call(this);
+ }
+
+ this.debug(
+ [
+ "SWFUpload.SWFObject Plugin settings:", "\n",
+ "\t", "minimum_flash_version: ", this.settings.minimum_flash_version, "\n",
+ "\t", "swfupload_pre_load_handler assigned: ", (typeof(this.settings.swfupload_pre_load_handler) === "function").toString(), "\n",
+ "\t", "swfupload_load_failed_handler assigned: ", (typeof(this.settings.swfupload_load_failed_handler) === "function").toString(), "\n",
+ ].join("")
+ );
+ };
+ }(SWFUpload.prototype.displayDebugInfo);
+}
/**
- * SWFUpload v2.0 by Jacob Roberts, Nov 2007, http://www.swfupload.org, http://linebyline.blogspot.com
- * -------- -------- -------- -------- -------- -------- -------- --------
- * SWFUpload is (c) 2006 Lars Huring and Mammon Media and is released under the MIT License:
+ * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
+ *
+ * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
+ *
+ * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
- * See Changelog.txt for version history
+ * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
*
- * Development Notes:
- * * This version of SWFUpload requires Flash Player 9.0.28 and should autodetect the correct flash version.
- * * In Linux Flash Player 9 setting the post file variable name does not work. It is always set to "Filedata".
- * * There is a lot of repeated code that could be refactored to single functions. Feel free.
- * * It's dangerous to do "circular calls" between Flash and JavaScript. I've taken steps to try to work around issues
- * by having the event calls pipe through setTimeout. However you should still avoid calling in to Flash from
- * within the event handler methods. Especially the "startUpload" event since it cannot use the setTimeout hack.
*/
-/* *********** */
-/* Constructor */
-/* *********** */
-
-var SWFUpload = function (init_settings) {
- this.initSWFUpload(init_settings);
-};
-
-SWFUpload.prototype.initSWFUpload = function (init_settings) {
- // Remove background flicker in IE (read this: http://misterpixel.blogspot.com/2006/09/forensic-analysis-of-ie6.html)
- // This doesn't have anything to do with SWFUpload but can help your UI behave better in IE.
- try {
- document.execCommand('BackgroundImageCache', false, true);
- } catch (ex1) {
- }
+/* ******************* */
+/* Constructor & Init */
+/* ******************* */
+var SWFUpload;
+if (SWFUpload == undefined) {
+ SWFUpload = function (settings) {
+ this.initSWFUpload(settings);
+ };
+}
+SWFUpload.prototype.initSWFUpload = function (settings) {
try {
this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
- this.settings = {};
+ this.settings = settings;
this.eventQueue = [];
this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
this.movieElement = null;
SWFUpload.instances[this.movieName] = this;
// Load the settings. Load the Flash movie.
- this.initSettings(init_settings);
+ this.initSettings();
this.loadFlash();
-
this.displayDebugInfo();
-
- } catch (ex2) {
- this.debug(ex2);
+ } catch (ex) {
+ delete SWFUpload.instances[this.movieName];
+ throw ex;
}
-}
+};
/* *************** */
-/* Static thingies */
+/* Static Members */
/* *************** */
SWFUpload.instances = {};
SWFUpload.movieCount = 0;
+SWFUpload.version = "2.2.0 Beta 2";
SWFUpload.QUEUE_ERROR = {
QUEUE_LIMIT_EXCEEDED : -100,
FILE_EXCEEDS_SIZE_LIMIT : -110,
COMPLETE : -4,
CANCELLED : -5
};
+SWFUpload.BUTTON_ACTION = {
+ SELECT_FILE : -100,
+ SELECT_FILES : -110,
+ START_UPLOAD : -120
+};
+SWFUpload.CURSOR = {
+ ARROW : -1,
+ HAND : -2
+};
+SWFUpload.WINDOW_MODE = {
+ WINDOW : "window",
+ TRANSPARENT : "transparent",
+ OPAQUE : "opaque"
+};
+/* ******************** */
+/* Instance Members */
+/* ******************** */
-/* ***************** */
-/* Instance Thingies */
-/* ***************** */
-// init is a private method that ensures that all the object settings are set, getting a default value if one was not assigned.
-
-SWFUpload.prototype.initSettings = function (init_settings) {
+// Private: initSettings ensures that all the
+// settings are set, getting a default value if one was not assigned.
+SWFUpload.prototype.initSettings = function () {
+ this.ensureDefault = function (settingName, defaultValue) {
+ this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
+ };
+
// Upload backend settings
- this.addSetting("upload_url", init_settings.upload_url, "");
- this.addSetting("file_post_name", init_settings.file_post_name, "Filedata");
- this.addSetting("post_params", init_settings.post_params, {});
-
+ this.ensureDefault("upload_url", "");
+ this.ensureDefault("file_post_name", "Filedata");
+ this.ensureDefault("post_params", {});
+ this.ensureDefault("use_query_string", false);
+ this.ensureDefault("requeue_on_error", false);
+ this.ensureDefault("http_success", []);
+
// File Settings
- this.addSetting("file_types", init_settings.file_types, "*.*");
- this.addSetting("file_types_description", init_settings.file_types_description, "All Files");
- this.addSetting("file_size_limit", init_settings.file_size_limit, "1024");
- this.addSetting("file_upload_limit", init_settings.file_upload_limit, "0");
- this.addSetting("file_queue_limit", init_settings.file_queue_limit, "0");
+ this.ensureDefault("file_types", "*.*");
+ this.ensureDefault("file_types_description", "All Files");
+ this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
+ this.ensureDefault("file_upload_limit", 0);
+ this.ensureDefault("file_queue_limit", 0);
// Flash Settings
- this.addSetting("flash_url", init_settings.flash_url, "swfupload.swf");
- this.addSetting("flash_width", init_settings.flash_width, "1px");
- this.addSetting("flash_height", init_settings.flash_height, "1px");
- this.addSetting("flash_color", init_settings.flash_color, "#FFFFFF");
-
+ this.ensureDefault("flash_url", "swfupload.swf");
+ this.ensureDefault("prevent_swf_caching", true);
+
+ // Button Settings
+ this.ensureDefault("button_image_url", "");
+ this.ensureDefault("button_width", 1);
+ this.ensureDefault("button_height", 1);
+ this.ensureDefault("button_text", "");
+ this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
+ this.ensureDefault("button_text_top_padding", 0);
+ this.ensureDefault("button_text_left_padding", 0);
+ this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
+ this.ensureDefault("button_disabled", false);
+ this.ensureDefault("button_placeholder_id", null);
+ this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
+ this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
+
// Debug Settings
- this.addSetting("debug_enabled", init_settings.debug, false);
-
+ this.ensureDefault("debug", false);
+ this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
+
// Event Handlers
- this.flashReady_handler = SWFUpload.flashReady; // This is a non-overrideable event handler
- this.swfUploadLoaded_handler = this.retrieveSetting(init_settings.swfupload_loaded_handler, SWFUpload.swfUploadLoaded);
+ this.settings.return_upload_start_handler = this.returnUploadStart;
+ this.ensureDefault("swfupload_loaded_handler", null);
+ this.ensureDefault("file_dialog_start_handler", null);
+ this.ensureDefault("file_queued_handler", null);
+ this.ensureDefault("file_queue_error_handler", null);
+ this.ensureDefault("file_dialog_complete_handler", null);
- this.fileDialogStart_handler = this.retrieveSetting(init_settings.file_dialog_start_handler, SWFUpload.fileDialogStart);
- this.fileQueued_handler = this.retrieveSetting(init_settings.file_queued_handler, SWFUpload.fileQueued);
- this.fileQueueError_handler = this.retrieveSetting(init_settings.file_queue_error_handler, SWFUpload.fileQueueError);
- this.fileDialogComplete_handler = this.retrieveSetting(init_settings.file_dialog_complete_handler, SWFUpload.fileDialogComplete);
+ this.ensureDefault("upload_start_handler", null);
+ this.ensureDefault("upload_progress_handler", null);
+ this.ensureDefault("upload_error_handler", null);
+ this.ensureDefault("upload_success_handler", null);
+ this.ensureDefault("upload_complete_handler", null);
- this.uploadStart_handler = this.retrieveSetting(init_settings.upload_start_handler, SWFUpload.uploadStart);
- this.uploadProgress_handler = this.retrieveSetting(init_settings.upload_progress_handler, SWFUpload.uploadProgress);
- this.uploadError_handler = this.retrieveSetting(init_settings.upload_error_handler, SWFUpload.uploadError);
- this.uploadSuccess_handler = this.retrieveSetting(init_settings.upload_success_handler, SWFUpload.uploadSuccess);
- this.uploadComplete_handler = this.retrieveSetting(init_settings.upload_complete_handler, SWFUpload.uploadComplete);
+ this.ensureDefault("debug_handler", this.debugMessage);
- this.debug_handler = this.retrieveSetting(init_settings.debug_handler, SWFUpload.debug);
+ this.ensureDefault("custom_settings", {});
// Other settings
- this.customSettings = this.retrieveSetting(init_settings.custom_settings, {});
+ this.customSettings = this.settings.custom_settings;
+
+ // Update the flash url if needed
+ if (this.settings.prevent_swf_caching) {
+ this.settings.flash_url = this.settings.flash_url + "?swfuploadrnd=" + Math.floor(Math.random() * 999999999);
+ }
+
+ delete this.ensureDefault;
};
-// loadFlash is a private method that generates the HTML tag for the Flash
-// It then adds the flash to the "target" or to the body and stores a
-// reference to the flash element in "movieElement".
SWFUpload.prototype.loadFlash = function () {
- var html, target_element, container;
+ if (this.settings.button_placeholder_id !== "") {
+ this.replaceWithFlash();
+ } else {
+ this.appendFlash();
+ }
+};
+
+// Private: appendFlash gets the HTML tag for the Flash
+// It then appends the flash to the body
+SWFUpload.prototype.appendFlash = function () {
+ var targetElement, container;
// Make sure an element with the ID we are going to use doesn't already exist
if (document.getElementById(this.movieName) !== null) {
- return false;
+ throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
}
// Get the body tag where we will be adding the flash movie
- try {
- target_element = document.getElementsByTagName("body")[0];
- if (typeof(target_element) === "undefined" || target_element === null) {
- this.debug('Could not find the BODY element. SWFUpload failed to load.');
- return false;
- }
- } catch (ex) {
- return false;
+ targetElement = document.getElementsByTagName("body")[0];
+
+ if (targetElement == undefined) {
+ throw "Could not find the 'body' element.";
}
// Append the container and load the flash
container = document.createElement("div");
- container.style.width = this.getSetting("flash_width");
- container.style.height = this.getSetting("flash_height");
+ container.style.width = "1px";
+ container.style.height = "1px";
+ container.style.overflow = "hidden";
- target_element.appendChild(container);
+ targetElement.appendChild(container);
container.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
};
-// Generates the embed/object tags needed to embed the flash in to the document
-SWFUpload.prototype.getFlashHTML = function () {
- var html = "";
+// Private: replaceWithFlash replaces the button_placeholder element with the flash movie.
+SWFUpload.prototype.replaceWithFlash = function () {
+ var targetElement, tempParent;
- // Create Mozilla Embed HTML
- if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
- // Build the basic embed html
- html = '<embed type="application/x-shockwave-flash" src="' + this.getSetting("flash_url") + '" width="' + this.getSetting("flash_width") + '" height="' + this.getSetting("flash_height") + '"';
- html += ' id="' + this.movieName + '" name="' + this.movieName + '" ';
- html += 'bgcolor="' + this.getSetting("flash_color") + '" quality="high" menu="false" flashvars="';
-
- html += this.getFlashVars();
-
- html += '" />';
-
- // Create IE Object HTML
- } else {
-
- // Build the basic Object tag
- html = '<object id="' + this.movieName + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.getSetting("flash_width") + '" height="' + this.getSetting("flash_height") + '">';
- html += '<param name="movie" value="' + this.getSetting("flash_url") + '">';
+ // Make sure an element with the ID we are going to use doesn't already exist
+ if (document.getElementById(this.movieName) !== null) {
+ throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
+ }
- html += '<param name="bgcolor" value="' + this.getSetting("flash_color") + '" />';
- html += '<param name="quality" value="high" />';
- html += '<param name="menu" value="false" />';
+ // Get the element where we will be placing the flash movie
+ targetElement = document.getElementById(this.settings.button_placeholder_id);
- html += '<param name="flashvars" value="' + this.getFlashVars() + '" />';
- html += '</object>';
+ if (targetElement == undefined) {
+ throw "Could not find the placeholder element.";
}
- return html;
+ // Append the container and load the flash
+ tempParent = document.createElement("div");
+ tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
+ targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
+
};
-// This private method builds the parameter string that will be passed
-// to flash.
+// Private: getFlashHTML generates the object tag needed to embed the flash in to the document
+SWFUpload.prototype.getFlashHTML = function () {
+ // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
+ return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
+ '<param name="wmode" value="', this.settings.button_window_mode , '" />',
+ '<param name="movie" value="', this.settings.flash_url, '" />',
+ '<param name="quality" value="high" />',
+ '<param name="menu" value="false" />',
+ '<param name="allowScriptAccess" value="always" />',
+ '<param name="flashvars" value="' + this.getFlashVars() + '" />',
+ '</object>'].join("");
+};
+
+// Private: getFlashVars builds the parameter string that will be passed
+// to flash in the flashvars param.
SWFUpload.prototype.getFlashVars = function () {
// Build a string from the post param object
- var param_string = this.buildParamString();
-
+ var paramString = this.buildParamString();
+ var httpSuccessString = this.settings.http_success.join(",");
+
// Build the parameter string
- var html = "";
- html += "movieName=" + encodeURIComponent(this.movieName);
- html += "&uploadURL=" + encodeURIComponent(this.getSetting("upload_url"));
- html += "¶ms=" + encodeURIComponent(param_string);
- html += "&filePostName=" + encodeURIComponent(this.getSetting("file_post_name"));
- html += "&fileTypes=" + encodeURIComponent(this.getSetting("file_types"));
- html += "&fileTypesDescription=" + encodeURIComponent(this.getSetting("file_types_description"));
- html += "&fileSizeLimit=" + encodeURIComponent(this.getSetting("file_size_limit"));
- html += "&fileUploadLimit=" + encodeURIComponent(this.getSetting("file_upload_limit"));
- html += "&fileQueueLimit=" + encodeURIComponent(this.getSetting("file_queue_limit"));
- html += "&debugEnabled=" + encodeURIComponent(this.getSetting("debug_enabled"));
-
- return html;
-};
-
+ return ["movieName=", encodeURIComponent(this.movieName),
+ "&uploadURL=", encodeURIComponent(this.settings.upload_url),
+ "&useQueryString=", encodeURIComponent(this.settings.use_query_string),
+ "&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
+ "&httpSuccess=", encodeURIComponent(httpSuccessString),
+ "&params=", encodeURIComponent(paramString),
+ "&filePostName=", encodeURIComponent(this.settings.file_post_name),
+ "&fileTypes=", encodeURIComponent(this.settings.file_types),
+ "&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
+ "&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
+ "&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
+ "&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
+ "&debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
+ "&buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
+ "&buttonWidth=", encodeURIComponent(this.settings.button_width),
+ "&buttonHeight=", encodeURIComponent(this.settings.button_height),
+ "&buttonText=", encodeURIComponent(this.settings.button_text),
+ "&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
+ "&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
+ "&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
+ "&buttonAction=", encodeURIComponent(this.settings.button_action),
+ "&buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
+ "&buttonCursor=", encodeURIComponent(this.settings.button_cursor)
+ ].join("");
+};
+
+// Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
+// The element is cached after the first lookup
SWFUpload.prototype.getMovieElement = function () {
- if (typeof(this.movieElement) === "undefined" || this.movieElement === null) {
+ if (this.movieElement == undefined) {
this.movieElement = document.getElementById(this.movieName);
-
- // Fix IEs "Flash can't callback when in a form" issue (http://www.extremefx.com.ar/blog/fixing-flash-external-interface-inside-form-on-internet-explorer)
- // Removed because Revision 6 always adds the flash to the body (inside a containing div)
- // If you insist on adding the Flash file inside a Form then in IE you have to make you wait until the DOM is ready
- // and run this code to make the form's ID available from the window object so Flash and JavaScript can communicate.
- //if (typeof(window[this.movieName]) === "undefined" || window[this.moveName] !== this.movieElement) {
- // window[this.movieName] = this.movieElement;
- //}
}
+ if (this.movieElement === null) {
+ throw "Could not find Flash element";
+ }
+
return this.movieElement;
};
+// Private: buildParamString takes the name/value pairs in the post_params setting object
+// and joins them up in to a string formatted "name=value&name=value"
SWFUpload.prototype.buildParamString = function () {
- var post_params = this.getSetting("post_params");
- var param_string_pairs = [];
- var i, value, name;
-
- // Retrieve the user defined parameters
- if (typeof(post_params) === "object") {
- for (name in post_params) {
- if (post_params.hasOwnProperty(name)) {
- if (typeof(post_params[name]) === "string") {
- param_string_pairs.push(encodeURIComponent(name) + "=" + encodeURIComponent(post_params[name]));
- }
+ var postParams = this.settings.post_params;
+ var paramStringPairs = [];
+
+ if (typeof(postParams) === "object") {
+ for (var name in postParams) {
+ if (postParams.hasOwnProperty(name)) {
+ paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
}
}
}
- return param_string_pairs.join("&");
+ return paramStringPairs.join("&");
};
-// Saves a setting. If the value given is undefined or null then the default_value is used.
-SWFUpload.prototype.addSetting = function (name, value, default_value) {
- if (typeof(value) === "undefined" || value === null) {
- this.settings[name] = default_value;
- } else {
- this.settings[name] = value;
+// Public: Used to remove a SWFUpload instance from the page. This method strives to remove
+// all references to the SWF, and other objects so memory is properly freed.
+// Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
+SWFUpload.prototype.destroy = function () {
+ try {
+ // Make sure Flash is done before we try to remove it
+ this.stopUpload();
+
+ // Remove the SWFUpload DOM nodes
+ var movieElement = null;
+ try {
+ movieElement = this.getMovieElement();
+ } catch (ex) {
+ }
+
+ if (movieElement != undefined && movieElement.parentNode != undefined && typeof movieElement.parentNode.removeChild === "function") {
+ var container = movieElement.parentNode;
+ if (container != undefined) {
+ container.removeChild(movieElement);
+ if (container.parentNode != undefined && typeof container.parentNode.removeChild === "function") {
+ container.parentNode.removeChild(container);
+ }
+ }
+ }
+
+ // Destroy references
+ SWFUpload.instances[this.movieName] = null;
+ delete SWFUpload.instances[this.movieName];
+
+ delete this.movieElement;
+ delete this.settings;
+ delete this.customSettings;
+ delete this.eventQueue;
+ delete this.movieName;
+
+ delete window[this.movieName];
+
+ return true;
+ } catch (ex1) {
+ return false;
}
-
- return this.settings[name];
};
-// Gets a setting. Returns empty string if not found.
-SWFUpload.prototype.getSetting = function (name) {
- if (typeof(this.settings[name]) === "undefined") {
- return "";
- } else {
- return this.settings[name];
+// Public: displayDebugInfo prints out settings and configuration
+// information about this SWFUpload instance.
+// This function (and any references to it) can be deleted when placing
+// SWFUpload in production.
+SWFUpload.prototype.displayDebugInfo = function () {
+ this.debug(
+ [
+ "---SWFUpload Instance Info---\n",
+ "Version: ", SWFUpload.version, "\n",
+ "Movie Name: ", this.movieName, "\n",
+ "Settings:\n",
+ "\t", "upload_url: ", this.settings.upload_url, "\n",
+ "\t", "flash_url: ", this.settings.flash_url, "\n",
+ "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
+ "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
+ "\t", "http_success: ", this.settings.http_success.join(", "), "\n",
+ "\t", "file_post_name: ", this.settings.file_post_name, "\n",
+ "\t", "post_params: ", this.settings.post_params.toString(), "\n",
+ "\t", "file_types: ", this.settings.file_types, "\n",
+ "\t", "file_types_description: ", this.settings.file_types_description, "\n",
+ "\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
+ "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
+ "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
+ "\t", "debug: ", this.settings.debug.toString(), "\n",
+
+ "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
+
+ "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
+ "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
+ "\t", "button_width: ", this.settings.button_width.toString(), "\n",
+ "\t", "button_height: ", this.settings.button_height.toString(), "\n",
+ "\t", "button_text: ", this.settings.button_text.toString(), "\n",
+ "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
+ "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
+ "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
+ "\t", "button_action: ", this.settings.button_action.toString(), "\n",
+ "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
+
+ "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
+ "Event Handlers:\n",
+ "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
+ "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
+ "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
+ "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
+ "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
+ "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
+ "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
+ "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
+ "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
+ "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"
+ ].join("")
+ );
+};
+
+/* Note: addSetting and getSetting are no longer used by SWFUpload but are included
+ the maintain v2 API compatibility
+*/
+// Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
+SWFUpload.prototype.addSetting = function (name, value, default_value) {
+ if (value == undefined) {
+ return (this.settings[name] = default_value);
+ } else {
+ return (this.settings[name] = value);
}
};
-// Gets a setting, if the setting is undefined then return the default value
-// This does not affect or use the interal setting object.
-SWFUpload.prototype.retrieveSetting = function (value, default_value) {
- if (typeof(value) === "undefined" || value === null) {
- return default_value;
- } else {
- return value;
+// Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
+SWFUpload.prototype.getSetting = function (name) {
+ if (this.settings[name] != undefined) {
+ return this.settings[name];
}
-};
-
-// It loops through all the settings and displays
-// them in the debug Console.
-SWFUpload.prototype.displayDebugInfo = function () {
- var key, debug_message = "";
-
- debug_message += "----- SWFUPLOAD SETTINGS ----\nID: " + this.moveName + "\n";
-
- debug_message += this.outputObject(this.settings);
+ return "";
+};
- debug_message += "----- SWFUPLOAD SETTINGS END ----\n";
- debug_message += "\n";
- this.debug(debug_message);
-};
-SWFUpload.prototype.outputObject = function (object, prefix) {
- var output = "", key;
- if (typeof(prefix) !== "string") {
- prefix = "";
- }
- if (typeof(object) !== "object") {
- return "";
- }
+// Private: callFlash handles function calls made to the Flash element.
+// Calls are made with a setTimeout for some functions to work around
+// bugs in the ExternalInterface library.
+SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
+ argumentArray = argumentArray || [];
+
+ var movieElement = this.getMovieElement();
+ var returnValue;
- for (key in object) {
- if (object.hasOwnProperty(key)) {
- if (typeof(object[key]) === "object") {
- output += (prefix + key + ": { \n" + this.outputObject(object[key], "\t" + prefix) + prefix + "}" + "\n");
- } else {
- output += (prefix + key + ": " + object[key] + "\n");
- }
+ if (typeof movieElement[functionName] === "function") {
+ // We have to go through all this if/else stuff because the Flash functions don't have apply() and only accept the exact number of arguments.
+ if (argumentArray.length === 0) {
+ returnValue = movieElement[functionName]();
+ } else if (argumentArray.length === 1) {
+ returnValue = movieElement[functionName](argumentArray[0]);
+ } else if (argumentArray.length === 2) {
+ returnValue = movieElement[functionName](argumentArray[0], argumentArray[1]);
+ } else if (argumentArray.length === 3) {
+ returnValue = movieElement[functionName](argumentArray[0], argumentArray[1], argumentArray[2]);
+ } else {
+ throw "Too many arguments";
}
+
+ // Unescape file post param values
+ if (returnValue != undefined && typeof returnValue.post === "object") {
+ returnValue = this.unescapeFilePostParams(returnValue);
+ }
+
+ return returnValue;
+ } else {
+ throw "Invalid function name: " + functionName;
}
-
- return output;
};
+
/* *****************************
-- Flash control methods --
Your UI should use these
to operate SWFUpload
***************************** */
+// Public: selectFile causes a File Selection Dialog window to appear. This
+// dialog only allows 1 file to be selected. WARNING: this function does not work in Flash Player 10
SWFUpload.prototype.selectFile = function () {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SelectFile) === "function") {
- try {
- movie_element.SelectFile();
- }
- catch (ex) {
- this.debug("Could not call SelectFile: " + ex);
- }
- } else {
- this.debug("Could not find Flash element");
- }
-
+ this.callFlash("SelectFile");
};
+// Public: selectFiles causes a File Selection Dialog window to appear/ This
+// dialog allows the user to select any number of files
+// Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
+// If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
+// for this bug. WARNING: this function does not work in Flash Player 10
SWFUpload.prototype.selectFiles = function () {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SelectFiles) === "function") {
- try {
- movie_element.SelectFiles();
- }
- catch (ex) {
- this.debug("Could not call SelectFiles: " + ex);
- }
- } else {
- this.debug("Could not find Flash element");
- }
-
+ this.callFlash("SelectFiles");
};
-/* Start the upload. If a file_id is specified that file is uploaded. Otherwise the first
- * file in the queue is uploaded. If no files are in the queue then nothing happens.
- * This call uses setTimeout since Flash will be calling back in to JavaScript
- */
-SWFUpload.prototype.startUpload = function (file_id) {
- var self = this;
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.StartUpload) === "function") {
- setTimeout(
- function () {
- try {
- movie_element.StartUpload(file_id);
- }
- catch (ex) {
- self.debug("Could not call StartUpload: " + ex);
- }
- }, 0
- );
- } else {
- this.debug("Could not find Flash element");
- }
-
+// Public: startUpload starts uploading the first file in the queue unless
+// the optional parameter 'fileID' specifies the ID
+SWFUpload.prototype.startUpload = function (fileID) {
+ this.callFlash("StartUpload", [fileID]);
};
-/* Cancels a the file upload. You must specify a file_id */
-SWFUpload.prototype.cancelUpload = function (file_id) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.CancelUpload) === "function") {
- try {
- movie_element.CancelUpload(file_id);
- }
- catch (ex) {
- this.debug("Could not call CancelUpload: " + ex);
- }
- } else {
- this.debug("Could not find Flash element");
+// Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index.
+// If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
+// If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
+SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
+ if (triggerErrorEvent !== false) {
+ triggerErrorEvent = true;
}
-
+ this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
};
-// Stops the current upload. The file is re-queued. If nothing is currently uploading then nothing happens.
+// Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
+// If nothing is currently uploading then nothing happens.
SWFUpload.prototype.stopUpload = function () {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.StopUpload) === "function") {
- try {
- movie_element.StopUpload();
- }
- catch (ex) {
- this.debug("Could not call StopUpload: " + ex);
- }
- } else {
- this.debug("Could not find Flash element");
- }
-
+ this.callFlash("StopUpload");
};
/* ************************
* Settings methods
- * These methods change the settings inside SWFUpload
- * They shouldn't need to be called in a setTimeout since they
- * should not call back from Flash to JavaScript (except perhaps in a Debug call)
- * and some need to return data so setTimeout won't work.
- */
+ * These methods change the SWFUpload settings.
+ * SWFUpload settings should not be changed directly on the settings object
+ * since many of the settings need to be passed to Flash in order to take
+ * effect.
+ * *********************** */
-/* Gets the file statistics object. It looks like this (where n = number):
- {
- files_queued: n,
- complete_uploads: n,
- upload_errors: n,
- uploads_cancelled: n,
- queue_errors: n
- }
-*/
+// Public: getStats gets the file statistics object.
SWFUpload.prototype.getStats = function () {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.GetStats) === "function") {
- try {
- return movie_element.GetStats();
- }
- catch (ex) {
- this.debug("Could not call GetStats");
- }
- } else {
- this.debug("Could not find Flash element");
- }
+ return this.callFlash("GetStats");
};
-SWFUpload.prototype.setStats = function (stats_object) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SetStats) === "function") {
- try {
- movie_element.SetStats(stats_object);
- }
- catch (ex) {
- this.debug("Could not call SetStats");
- }
- } else {
- this.debug("Could not find Flash element");
- }
+
+// Public: setStats changes the SWFUpload statistics. You shouldn't need to
+// change the statistics but you can. Changing the statistics does not
+// affect SWFUpload accept for the successful_uploads count which is used
+// by the upload_limit setting to determine how many files the user may upload.
+SWFUpload.prototype.setStats = function (statsObject) {
+ this.callFlash("SetStats", [statsObject]);
};
-SWFUpload.prototype.setCredentials = function(name, password) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SetCredentials) === "function") {
- try {
- return movie_element.SetCredentials(name, password);
- }
- catch (ex) {
- this.debug("Could not call SetCredentials");
- }
+// Public: getFile retrieves a File object by ID or Index. If the file is
+// not found then 'null' is returned.
+SWFUpload.prototype.getFile = function (fileID) {
+ if (typeof(fileID) === "number") {
+ return this.callFlash("GetFileByIndex", [fileID]);
} else {
- this.debug("Could not find Flash element");
+ return this.callFlash("GetFile", [fileID]);
}
};
-SWFUpload.prototype.getFile = function (file_id) {
- var movie_element = this.getMovieElement();
- if (typeof(file_id) === "number") {
- if (movie_element !== null && typeof(movie_element.GetFileByIndex) === "function") {
- try {
- return movie_element.GetFileByIndex(file_id);
- }
- catch (ex) {
- this.debug("Could not call GetFileByIndex");
- }
- } else {
- this.debug("Could not find Flash element");
- }
- } else {
- if (movie_element !== null && typeof(movie_element.GetFile) === "function") {
- try {
- return movie_element.GetFile(file_id);
- }
- catch (ex) {
- this.debug("Could not call GetFile");
- }
- } else {
- this.debug("Could not find Flash element");
- }
- }
+// Public: addFileParam sets a name/value pair that will be posted with the
+// file specified by the Files ID. If the name already exists then the
+// exiting value will be overwritten.
+SWFUpload.prototype.addFileParam = function (fileID, name, value) {
+ return this.callFlash("AddFileParam", [fileID, name, value]);
};
-SWFUpload.prototype.addFileParam = function (file_id, name, value) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.AddFileParam) === "function") {
- try {
- return movie_element.AddFileParam(file_id, name, value);
- }
- catch (ex) {
- this.debug("Could not call AddFileParam");
- }
- } else {
- this.debug("Could not find Flash element");
- }
+// Public: removeFileParam removes a previously set (by addFileParam) name/value
+// pair from the specified file.
+SWFUpload.prototype.removeFileParam = function (fileID, name) {
+ this.callFlash("RemoveFileParam", [fileID, name]);
};
-SWFUpload.prototype.removeFileParam = function (file_id, name) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.RemoveFileParam) === "function") {
- try {
- return movie_element.RemoveFileParam(file_id, name);
- }
- catch (ex) {
- this.debug("Could not call AddFileParam");
- }
- } else {
- this.debug("Could not find Flash element");
- }
+// Public: setUploadUrl changes the upload_url setting.
+SWFUpload.prototype.setUploadURL = function (url) {
+ this.settings.upload_url = url.toString();
+ this.callFlash("SetUploadURL", [url]);
+};
+// Public: setPostParams changes the post_params setting
+SWFUpload.prototype.setPostParams = function (paramsObject) {
+ this.settings.post_params = paramsObject;
+ this.callFlash("SetPostParams", [paramsObject]);
};
-SWFUpload.prototype.setUploadURL = function (url) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SetUploadURL) === "function") {
- try {
- this.addSetting("upload_url", url);
- movie_element.SetUploadURL(this.getSetting("upload_url"));
- }
- catch (ex) {
- this.debug("Could not call SetUploadURL");
- }
- } else {
- this.debug("Could not find Flash element in setUploadURL");
- }
+// Public: addPostParam adds post name/value pair. Each name can have only one value.
+SWFUpload.prototype.addPostParam = function (name, value) {
+ this.settings.post_params[name] = value;
+ this.callFlash("SetPostParams", [this.settings.post_params]);
};
-SWFUpload.prototype.setPostParams = function (param_object) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SetPostParams) === "function") {
- try {
- this.addSetting("post_params", param_object);
- movie_element.SetPostParams(this.getSetting("post_params"));
- }
- catch (ex) {
- this.debug("Could not call SetPostParams");
- }
- } else {
- this.debug("Could not find Flash element in SetPostParams");
- }
+// Public: removePostParam deletes post name/value pair.
+SWFUpload.prototype.removePostParam = function (name) {
+ delete this.settings.post_params[name];
+ this.callFlash("SetPostParams", [this.settings.post_params]);
};
+// Public: setFileTypes changes the file_types setting and the file_types_description setting
SWFUpload.prototype.setFileTypes = function (types, description) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SetFileTypes) === "function") {
- try {
- this.addSetting("file_types", types);
- this.addSetting("file_types_description", description);
- movie_element.SetFileTypes(this.getSetting("file_types"), this.getSetting("file_types_description"));
- }
- catch (ex) {
- this.debug("Could not call SetFileTypes");
- }
- } else {
- this.debug("Could not find Flash element in SetFileTypes");
- }
+ this.settings.file_types = types;
+ this.settings.file_types_description = description;
+ this.callFlash("SetFileTypes", [types, description]);
};
-SWFUpload.prototype.setFileSizeLimit = function (file_size_limit) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SetFileSizeLimit) === "function") {
- try {
- this.addSetting("file_size_limit", file_size_limit);
- movie_element.SetFileSizeLimit(this.getSetting("file_size_limit"));
- }
- catch (ex) {
- this.debug("Could not call SetFileSizeLimit");
- }
- } else {
- this.debug("Could not find Flash element in SetFileSizeLimit");
- }
+// Public: setFileSizeLimit changes the file_size_limit setting
+SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
+ this.settings.file_size_limit = fileSizeLimit;
+ this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
};
-SWFUpload.prototype.setFileUploadLimit = function (file_upload_limit) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SetFileUploadLimit) === "function") {
- try {
- this.addSetting("file_upload_limit", file_upload_limit);
- movie_element.SetFileUploadLimit(this.getSetting("file_upload_limit"));
- }
- catch (ex) {
- this.debug("Could not call SetFileUploadLimit");
- }
- } else {
- this.debug("Could not find Flash element in SetFileUploadLimit");
- }
+// Public: setFileUploadLimit changes the file_upload_limit setting
+SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
+ this.settings.file_upload_limit = fileUploadLimit;
+ this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
};
-SWFUpload.prototype.setFileQueueLimit = function (file_queue_limit) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SetFileQueueLimit) === "function") {
- try {
- this.addSetting("file_queue_limit", file_queue_limit);
- movie_element.SetFileQueueLimit(this.getSetting("file_queue_limit"));
- }
- catch (ex) {
- this.debug("Could not call SetFileQueueLimit");
- }
- } else {
- this.debug("Could not find Flash element in SetFileQueueLimit");
- }
+// Public: setFileQueueLimit changes the file_queue_limit setting
+SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
+ this.settings.file_queue_limit = fileQueueLimit;
+ this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
};
-SWFUpload.prototype.setFilePostName = function (file_post_name) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SetFilePostName) === "function") {
- try {
- this.addSetting("file_post_name", file_post_name);
- movie_element.SetFilePostName(this.getSetting("file_post_name"));
- }
- catch (ex) {
- this.debug("Could not call SetFilePostName");
- }
- } else {
- this.debug("Could not find Flash element in SetFilePostName");
- }
+// Public: setFilePostName changes the file_post_name setting
+SWFUpload.prototype.setFilePostName = function (filePostName) {
+ this.settings.file_post_name = filePostName;
+ this.callFlash("SetFilePostName", [filePostName]);
};
-SWFUpload.prototype.setDebugEnabled = function (debug_enabled) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.SetDebugEnabled) === "function") {
- try {
- this.addSetting("debug_enabled", debug_enabled);
- movie_element.SetDebugEnabled(this.getSetting("debug_enabled"));
- }
- catch (ex) {
- this.debug("Could not call SetDebugEnabled");
- }
- } else {
- this.debug("Could not find Flash element in SetDebugEnabled");
- }
+// Public: setUseQueryString changes the use_query_string setting
+SWFUpload.prototype.setUseQueryString = function (useQueryString) {
+ this.settings.use_query_string = useQueryString;
+ this.callFlash("SetUseQueryString", [useQueryString]);
};
-/* *******************************
- Internal Event Callers
- Don't override these! These event callers ensure that your custom event handlers
- are called safely and in order.
-******************************* */
+// Public: setRequeueOnError changes the requeue_on_error setting
+SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
+ this.settings.requeue_on_error = requeueOnError;
+ this.callFlash("SetRequeueOnError", [requeueOnError]);
+};
-/* This is the callback method that the Flash movie will call when it has been loaded and is ready to go.
- Calling this or showUI() "manually" will bypass the Flash Detection built in to SWFUpload.
- Use a ui_function setting if you want to control the UI loading after the flash has loaded.
-*/
-SWFUpload.prototype.flashReady = function () {
- // Check that the movie element is loaded correctly with its ExternalInterface methods defined
- var movie_element = this.getMovieElement();
- if (movie_element === null || typeof(movie_element.StartUpload) !== "function") {
- this.debug("ExternalInterface methods failed to initialize.");
- return;
+// Public: setHTTPSuccess changes the http_success setting
+SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
+ if (typeof http_status_codes === "string") {
+ http_status_codes = http_status_codes.replace(" ", "").split(",");
}
- var self = this;
- if (typeof(self.flashReady_handler) === "function") {
- this.eventQueue[this.eventQueue.length] = function() { self.flashReady_handler(); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- } else {
- this.debug("flashReady_handler event not defined");
- }
+ this.settings.http_success = http_status_codes;
+ this.callFlash("SetHTTPSuccess", [http_status_codes]);
};
-/*
- Event Queue. Rather can call events directly from Flash they events are
- are placed in a queue and then executed. This ensures that each event is
- executed in the order it was called which is not guarenteed when calling
- setTimeout. Out of order events was especially problematic in Safari.
-*/
-SWFUpload.prototype.executeNextEvent = function () {
- var f = this.eventQueue.shift();
- if (typeof(f) === "function") {
- f();
- }
-}
-/* This is a chance to do something before the browse window opens */
-SWFUpload.prototype.fileDialogStart = function () {
- var self = this;
- if (typeof(self.fileDialogStart_handler) === "function") {
- this.eventQueue[this.eventQueue.length] = function() { self.fileDialogStart_handler(); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- } else {
- this.debug("fileDialogStart event not defined");
- }
+// Public: setDebugEnabled changes the debug_enabled setting
+SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
+ this.settings.debug_enabled = debugEnabled;
+ this.callFlash("SetDebugEnabled", [debugEnabled]);
};
-
-/* Called when a file is successfully added to the queue. */
-SWFUpload.prototype.fileQueued = function (file) {
- var self = this;
- if (typeof(self.fileQueued_handler) === "function") {
- this.eventQueue[this.eventQueue.length] = function() { self.fileQueued_handler(file); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- } else {
- this.debug("fileQueued event not defined");
+// Public: setButtonImageURL loads a button image sprite
+SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
+ if (buttonImageURL == undefined) {
+ buttonImageURL = "";
}
+
+ this.settings.button_image_url = buttonImageURL;
+ this.callFlash("SetButtonImageURL", [buttonImageURL]);
};
-
-/* Handle errors that occur when an attempt to queue a file fails. */
-SWFUpload.prototype.fileQueueError = function (file, error_code, message) {
- var self = this;
- if (typeof(self.fileQueueError_handler) === "function") {
- this.eventQueue[this.eventQueue.length] = function() { self.fileQueueError_handler(file, error_code, message); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- } else {
- this.debug("fileQueueError event not defined");
+// Public: setButtonDimensions resizes the Flash Movie and button
+SWFUpload.prototype.setButtonDimensions = function (width, height) {
+ this.settings.button_width = width;
+ this.settings.button_height = height;
+
+ var movie = this.getMovieElement();
+ if (movie != undefined) {
+ movie.style.width = width + "px";
+ movie.style.height = height + "px";
}
+
+ this.callFlash("SetButtonDimensions", [width, height]);
};
-
-/* Called after the file dialog has closed and the selected files have been queued.
- You could call startUpload here if you want the queued files to begin uploading immediately. */
-SWFUpload.prototype.fileDialogComplete = function (num_files_selected) {
- var self = this;
- if (typeof(self.fileDialogComplete_handler) === "function") {
- this.eventQueue[this.eventQueue.length] = function() { self.fileDialogComplete_handler(num_files_selected); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- } else {
- this.debug("fileDialogComplete event not defined");
- }
+// Public: setButtonText Changes the text overlaid on the button
+SWFUpload.prototype.setButtonText = function (html) {
+ this.settings.button_text = html;
+ this.callFlash("SetButtonText", [html]);
};
-
-/* Gets called when a file upload is about to be started. Return true to continue the upload. Return false to stop the upload.
- If you return false then uploadError and uploadComplete are called (like normal).
-
- This is a good place to do any file validation you need.
- */
-SWFUpload.prototype.uploadStart = function (file) {
- var self = this;
- if (typeof(self.fileDialogComplete_handler) === "function") {
- this.eventQueue[this.eventQueue.length] = function() { self.returnUploadStart(self.uploadStart_handler(file)); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- } else {
- this.debug("uploadStart event not defined");
- }
+// Public: setButtonTextPadding changes the top and left padding of the text overlay
+SWFUpload.prototype.setButtonTextPadding = function (left, top) {
+ this.settings.button_text_top_padding = top;
+ this.settings.button_text_left_padding = left;
+ this.callFlash("SetButtonTextPadding", [left, top]);
};
-/* Note: Internal use only. This function returns the result of uploadStart to
- flash. Since returning values in the normal way can result in Flash/JS circular
- call issues we split up the call in a Timeout. This is transparent from the API
- point of view.
-*/
-SWFUpload.prototype.returnUploadStart = function (return_value) {
- var movie_element = this.getMovieElement();
- if (movie_element !== null && typeof(movie_element.ReturnUploadStart) === "function") {
- try {
- movie_element.ReturnUploadStart(return_value);
- }
- catch (ex) {
- this.debug("Could not call ReturnUploadStart");
- }
- } else {
- this.debug("Could not find Flash element in returnUploadStart");
- }
+// Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
+SWFUpload.prototype.setButtonTextStyle = function (css) {
+ this.settings.button_text_style = css;
+ this.callFlash("SetButtonTextStyle", [css]);
+};
+// Public: setButtonDisabled disables/enables the button
+SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
+ this.settings.button_disabled = isDisabled;
+ this.callFlash("SetButtonDisabled", [isDisabled]);
+};
+// Public: setButtonAction sets the action that occurs when the button is clicked
+SWFUpload.prototype.setButtonAction = function (buttonAction) {
+ this.settings.button_action = buttonAction;
+ this.callFlash("SetButtonAction", [buttonAction]);
};
+// Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
+SWFUpload.prototype.setButtonCursor = function (cursor) {
+ this.settings.button_cursor = cursor;
+ this.callFlash("SetButtonCursor", [cursor]);
+};
+/* *******************************
+ Flash Event Interfaces
+ These functions are used by Flash to trigger the various
+ events.
+
+ All these functions a Private.
+
+ Because the ExternalInterface library is buggy the event calls
+ are added to a queue and the queue then executed by a setTimeout.
+ This ensures that events are executed in a determinate order and that
+ the ExternalInterface bugs are avoided.
+******************************* */
-/* Called during upload as the file progresses. Use this event to update your UI. */
-SWFUpload.prototype.uploadProgress = function (file, bytes_complete, bytes_total) {
- var self = this;
- if (typeof(self.uploadProgress_handler) === "function") {
- this.eventQueue[this.eventQueue.length] = function() { self.uploadProgress_handler(file, bytes_complete, bytes_total); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- } else {
- this.debug("uploadProgress event not defined");
+SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
+
+ if (argumentArray == undefined) {
+ argumentArray = [];
+ } else if (!(argumentArray instanceof Array)) {
+ argumentArray = [argumentArray];
}
-};
-
-/* Called when an error occurs during an upload. Use error_code and the SWFUpload.UPLOAD_ERROR constants to determine
- which error occurred. The uploadComplete event is called after an error code indicating that the next file is
- ready for upload. For files cancelled out of order the uploadComplete event will not be called. */
-SWFUpload.prototype.uploadError = function (file, error_code, message) {
+
var self = this;
- if (typeof(this.uploadError_handler) === "function") {
- this.eventQueue[this.eventQueue.length] = function() { self.uploadError_handler(file, error_code, message); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- } else {
- this.debug("uploadError event not defined");
- }
-};
+ if (typeof this.settings[handlerName] === "function") {
+ // Queue the event
+ this.eventQueue.push(function () {
+ this.settings[handlerName].apply(this, argumentArray);
+ });
+
+ // Execute the next queued event
+ setTimeout(function () {
+ self.executeNextEvent();
+ }, 0);
+
+ } else if (this.settings[handlerName] !== null) {
+ throw "Event handler " + handlerName + " is unknown or is not a function";
+ }
+};
+
+// Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout
+// we must queue them in order to garentee that they are executed in order.
+SWFUpload.prototype.executeNextEvent = function () {
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
-/* This gets called when a file finishes uploading and the server-side upload script has completed and returned a 200
-status code. Any text returned by the server is available in server_data.
-**NOTE: The upload script MUST return some text or the uploadSuccess and uploadComplete events will not fire and the
-upload will become 'stuck'. */
-SWFUpload.prototype.uploadSuccess = function (file, server_data) {
- var self = this;
- if (typeof(self.uploadSuccess_handler) === "function") {
- this.eventQueue[this.eventQueue.length] = function() { self.uploadSuccess_handler(file, server_data); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- } else {
- this.debug("uploadSuccess event not defined");
+ var f = this.eventQueue ? this.eventQueue.shift() : null;
+ if (typeof(f) === "function") {
+ f.apply(this);
}
};
-/* uploadComplete is called when the file is uploaded or an error occurred and SWFUpload is ready to make the next upload.
- If you want the next upload to start to automatically you can call startUpload() from this event. */
-SWFUpload.prototype.uploadComplete = function (file) {
- var self = this;
- if (typeof(self.uploadComplete_handler) === "function") {
- this.eventQueue[this.eventQueue.length] = function() { self.uploadComplete_handler(file); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- } else {
- this.debug("uploadComplete event not defined");
- }
-};
+// Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
+// properties that contain characters that are not valid for JavaScript identifiers. To work around this
+// the Flash Component escapes the parameter names and we must unescape again before passing them along.
+SWFUpload.prototype.unescapeFilePostParams = function (file) {
+ var reg = /[$]([0-9a-f]{4})/i;
+ var unescapedPost = {};
+ var uk;
-/* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
- internal debug console. You can override this event and have messages written where you want. */
-SWFUpload.prototype.debug = function (message) {
- var self = this;
- if (typeof(self.debug_handler) === "function") {
- this.eventQueue[this.eventQueue.length] = function() { self.debug_handler(message); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- } else {
- this.eventQueue[this.eventQueue.length] = function() { self.debugMessage(message); };
- setTimeout(function () { self.executeNextEvent();}, 0);
- }
-};
+ if (file != undefined) {
+ for (var k in file.post) {
+ if (file.post.hasOwnProperty(k)) {
+ uk = k;
+ var match;
+ while ((match = reg.exec(uk)) !== null) {
+ uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
+ }
+ unescapedPost[uk] = file.post[k];
+ }
+ }
+ file.post = unescapedPost;
+ }
-/* **********************************
- Default Event Handlers.
- These event handlers are used by default if an overriding handler is
- not defined in the SWFUpload settings object.
-
- JS Note: even though these are defined on the SWFUpload object (rather than the prototype) they
- are attached (read: copied) to a SWFUpload instance and 'this' is given the proper context.
- ********************************** */
+ return file;
+};
-/* This is a special event handler that has no override in the settings. Flash calls this when it has
- been loaded by the browser and is ready for interaction. You should not override it. If you need
- to do something with SWFUpload has loaded then use the swfupload_loaded_handler setting.
-*/
-SWFUpload.flashReady = function () {
- try {
- this.debug("Flash called back and is ready.");
+SWFUpload.prototype.flashReady = function () {
+ // Check that the movie element is loaded correctly with its ExternalInterface methods defined
+ var movieElement = this.getMovieElement();
+ if (typeof movieElement.StartUpload !== "function") {
+ throw "ExternalInterface methods failed to initialize.";
+ }
- if (typeof(this.swfUploadLoaded_handler) === "function") {
- this.swfUploadLoaded_handler();
- }
- } catch (ex) {
- this.debug(ex);
+ // Fix IE Flash/Form bug
+ if (window[this.movieName] == undefined) {
+ window[this.movieName] = movieElement;
}
+
+ this.queueEvent("swfupload_loaded_handler");
};
-/* This is a chance to something immediately after SWFUpload has loaded.
- Like, hide the default/degraded upload form and display the SWFUpload form. */
-SWFUpload.swfUploadLoaded = function () {
-};
/* This is a chance to do something before the browse window opens */
-SWFUpload.fileDialogStart = function () {
+SWFUpload.prototype.fileDialogStart = function () {
+ this.queueEvent("file_dialog_start_handler");
};
/* Called when a file is successfully added to the queue. */
-SWFUpload.fileQueued = function (file) {
+SWFUpload.prototype.fileQueued = function (file) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("file_queued_handler", file);
};
/* Handle errors that occur when an attempt to queue a file fails. */
-SWFUpload.fileQueueError = function (file, error_code, message) {
- try {
- switch (error_code) {
- case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
- this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
- break;
- case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
- this.debug("Error Code: Zero Byte File, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
- break;
- case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
- this.debug("Error Code: Upload limit reached, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
- break;
- case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
- this.debug("Error Code: File extension is not allowed, Message: " + message);
- break;
- default:
- this.debug("Error Code: Unhandled error occured. Errorcode: " + error_code);
- }
- } catch (ex) {
- this.debug(ex);
- }
+SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
};
/* Called after the file dialog has closed and the selected files have been queued.
You could call startUpload here if you want the queued files to begin uploading immediately. */
-SWFUpload.fileDialogComplete = function (num_files_selected) {
+SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued) {
+ this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued]);
};
-/* Gets called when a file upload is about to be started. Return true to continue the upload. Return false to stop the upload.
- If you return false then the uploadError callback is called and then uploadComplete (like normal).
+SWFUpload.prototype.uploadStart = function (file) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("return_upload_start_handler", file);
+};
+
+SWFUpload.prototype.returnUploadStart = function (file) {
+ var returnValue;
+ if (typeof this.settings.upload_start_handler === "function") {
+ file = this.unescapeFilePostParams(file);
+ returnValue = this.settings.upload_start_handler.call(this, file);
+ } else if (this.settings.upload_start_handler != undefined) {
+ throw "upload_start_handler must be a function";
+ }
+
+ // Convert undefined to true so if nothing is returned from the upload_start_handler it is
+ // interpretted as 'true'.
+ if (returnValue === undefined) {
+ returnValue = true;
+ }
- This is a good place to do any file validation you need.
+ returnValue = !!returnValue;
- This is the only function that cannot be called on a setTimeout because it must return a value to Flash.
- You SHOULD NOT make any calls in to Flash (e.i, changing settings, getting stats, etc). Flash Player bugs prevent
- calls in to Flash from working reliably.
-*/
-SWFUpload.uploadStart = function (file) {
- return true;
+ this.callFlash("ReturnUploadStart", [returnValue]);
};
-// Called during upload as the file progresses
-SWFUpload.uploadProgress = function (file, bytes_complete, bytes_total) {
- this.debug("File Progress: " + file.id + ", Bytes: " + bytes_complete + ". Total: " + bytes_total);
-};
-/* This gets called when a file finishes uploading and the upload script has completed and returned a 200 status code. Any text returned by the
-server is available in server_data. The upload script must return some text or uploadSuccess will not fire (neither will uploadComplete). */
-SWFUpload.uploadSuccess = function (file, server_data) {
- this.debug("Upload Success: " + file.id + ", Server: " + server_data);
+
+SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
};
-/* This is called last. The file is uploaded or an error occurred and SWFUpload is ready to make the next upload.
- If you want to automatically start the next file just call startUpload from here.
-*/
-SWFUpload.uploadComplete = function (file) {
- this.debug("Upload Complete: " + file.id);
+SWFUpload.prototype.uploadError = function (file, errorCode, message) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("upload_error_handler", [file, errorCode, message]);
};
-// Called by SWFUpload JavaScript and Flash functions when debug is enabled.
-// Override this method in your settings to call your own debug message handler
-SWFUpload.debug = function (message) {
- if (this.getSetting("debug_enabled")) {
- this.debugMessage(message);
- }
+SWFUpload.prototype.uploadSuccess = function (file, serverData) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("upload_success_handler", [file, serverData]);
};
-/* Called when an upload occurs during upload. For HTTP errors 'message' will contain the HTTP STATUS CODE */
-SWFUpload.uploadError = function (file, errcode, msg) {
- try {
- switch (errcode) {
- case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
- this.debug("Error Code: File ID specified for upload was not found, Message: " + msg);
- break;
- case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
- this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + msg);
- break;
- case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
- this.debug("Error Code: No backend file, File name: " + file.name + ", Message: " + msg);
- break;
- case SWFUpload.UPLOAD_ERROR.IO_ERROR:
- this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + msg);
- break;
- case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
- this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + msg);
- break;
- case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
- this.debug("Error Code: Upload limit reached, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg);
- break;
- case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
- this.debug("Error Code: Upload Initialization exception, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg);
- break;
- case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
- this.debug("Error Code: uploadStart callback returned false, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg);
- break;
- case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
- this.debug("Error Code: The file upload was cancelled, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg);
- break;
- case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
- this.debug("Error Code: The file upload was stopped, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg);
- break;
- default:
- this.debug("Error Code: Unhandled error occured. Errorcode: " + errcode);
- }
- } catch (ex) {
- this.debug(ex);
- }
+SWFUpload.prototype.uploadComplete = function (file) {
+ file = this.unescapeFilePostParams(file);
+ this.queueEvent("upload_complete_handler", file);
};
+/* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
+ internal debug console. You can override this event and have messages written where you want. */
+SWFUpload.prototype.debug = function (message) {
+ this.queueEvent("debug_handler", message);
+};
/* **********************************
The console is automatically scrolled as messages appear.
- You can override this console (to use FireBug's console for instance) by setting the debug event method to your own function
- that handles the debug message
- ********************************** */
+ If you are using your own debug handler or when you deploy to production and
+ have debug disabled you can remove these functions to reduce the file size
+ and complexity.
+********************************** */
+
+// Private: debugMessage is the default debug_handler. If you want to print debug messages
+// call the debug() function. When overriding the function your own function should
+// check to see if the debug setting is true before outputting debug information.
SWFUpload.prototype.debugMessage = function (message) {
- var exception_message, exception_values;
-
- if (typeof(message) === "object" && typeof(message.name) === "string" && typeof(message.message) === "string") {
- exception_message = "";
- exception_values = [];
- for (var key in message) {
- exception_values.push(key + ": " + message[key]);
+ if (this.settings.debug) {
+ var exceptionMessage, exceptionValues = [];
+
+ // Check for an exception object and print it nicely
+ if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
+ for (var key in message) {
+ if (message.hasOwnProperty(key)) {
+ exceptionValues.push(key + ": " + message[key]);
+ }
+ }
+ exceptionMessage = exceptionValues.join("\n") || "";
+ exceptionValues = exceptionMessage.split("\n");
+ exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
+ SWFUpload.Console.writeLine(exceptionMessage);
+ } else {
+ SWFUpload.Console.writeLine(message);
}
- exception_message = exception_values.join("\n");
- exception_values = exception_message.split("\n");
- exception_message = "EXCEPTION: " + exception_values.join("\nEXCEPTION: ");
- SWFUpload.Console.writeLine(exception_message);
- } else {
- SWFUpload.Console.writeLine(message);
}
};
/* ---------->>> thickbox specific link and font settings <<<------------------------------------------------------*/
/* ----------------------------------------------------------------------------------------------------------------*/
#TB_window {
- font: 12px Arial, Helvetica, sans-serif;
+ font: 12px "Lucida Grande", Verdana, Arial, sans-serif;
color: #333333;
}
#TB_secondLine {
- font: 10px Arial, Helvetica, sans-serif;
+ font: 10px "Lucida Grande", Verdana, Arial, sans-serif;
color:#666666;
}
.TB_overlayMacFFBGHack {background: url(macFFBgHack.png) repeat;}
.TB_overlayBG {
background-color:#000;
+ -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";
filter:alpha(opacity=75);
-moz-opacity: 0.75;
opacity: 0.75;
z-index: 102;
color:#000000;
display:none;
- border: 4px solid #525252;
text-align:left;
top:50%;
left:50%;
+ border: 1px solid #555;
+ -moz-box-shadow: rgba(0,0,0,1) 0 4px 30px;
+ -webkit-box-shadow: rgba(0,0,0,1) 0 4px 30px;
+ -khtml-box-shadow: rgba(0,0,0,1) 0 4px 30px;
+ box-shadow: rgba(0,0,0,1) 0 4px 30px;
}
* html #TB_window { /* ie6 hack */
top: 50%;
left: 50%;
background-color: #E8E8E8;
- border: 4px solid #525252;
+ border: 1px solid #555;
margin: -45px 0pt 0pt -125px;
padding: 40px 15px 15px;
}
}
function tb_position() {
+var isIE6 = typeof document.body.style.maxHeight === "undefined";
jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
- if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
+ if ( ! isIE6 ) { // take away IE6
jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
}
}
--- /dev/null
+tinyMCE.addI18n({en:{
+common:{
+edit_confirm:"Do you want to use the WYSIWYG mode for this textarea?",
+apply:"Apply",
+insert:"Insert",
+update:"Update",
+cancel:"Cancel",
+close:"Close",
+browse:"Browse",
+class_name:"Class",
+not_set:"-- Not set --",
+clipboard_msg:"Copy/Cut/Paste is not available in Mozilla and Firefox.",
+clipboard_no_support:"Currently not supported by your browser, use keyboard shortcuts instead.",
+popup_blocked:"Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.",
+invalid_data:"Error: Invalid values entered, these are marked in red.",
+more_colors:"More colors"
+},
+contextmenu:{
+align:"Alignment",
+left:"Left",
+center:"Center",
+right:"Right",
+full:"Full"
+},
+insertdatetime:{
+date_fmt:"%Y-%m-%d",
+time_fmt:"%H:%M:%S",
+insertdate_desc:"Insert date",
+inserttime_desc:"Insert time",
+months_long:"January,February,March,April,May,June,July,August,September,October,November,December",
+months_short:"Jan_January_abbreviation,Feb_February_abbreviation,Mar_March_abbreviation,Apr_April_abbreviation,May_May_abbreviation,Jun_June_abbreviation,Jul_July_abbreviation,Aug_August_abbreviation,Sep_September_abbreviation,Oct_October_abbreviation,Nov_November_abbreviation,Dec_December_abbreviation",
+day_long:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",
+day_short:"Sun,Mon,Tue,Wed,Thu,Fri,Sat"
+},
+print:{
+print_desc:"Print"
+},
+preview:{
+preview_desc:"Preview"
+},
+directionality:{
+ltr_desc:"Direction left to right",
+rtl_desc:"Direction right to left"
+},
+layer:{
+insertlayer_desc:"Insert new layer",
+forward_desc:"Move forward",
+backward_desc:"Move backward",
+absolute_desc:"Toggle absolute positioning",
+content:"New layer..."
+},
+save:{
+save_desc:"Save",
+cancel_desc:"Cancel all changes"
+},
+nonbreaking:{
+nonbreaking_desc:"Insert non-breaking space character"
+},
+iespell:{
+iespell_desc:"Run spell checking",
+download:"ieSpell not detected. Do you want to install it now?"
+},
+advhr:{
+advhr_desc:"Horizontale rule"
+},
+emotions:{
+emotions_desc:"Emotions"
+},
+searchreplace:{
+search_desc:"Find",
+replace_desc:"Find/Replace"
+},
+advimage:{
+image_desc:"Insert/edit image"
+},
+advlink:{
+link_desc:"Insert/edit link"
+},
+xhtmlxtras:{
+cite_desc:"Citation",
+abbr_desc:"Abbreviation",
+acronym_desc:"Acronym",
+del_desc:"Deletion",
+ins_desc:"Insertion",
+attribs_desc:"Insert/Edit Attributes"
+},
+style:{
+desc:"Edit CSS Style"
+},
+paste:{
+paste_text_desc:"Paste as Plain Text",
+paste_word_desc:"Paste from Word",
+selectall_desc:"Select All"
+},
+paste_dlg:{
+text_title:"Use CTRL+V on your keyboard to paste the text into the window.",
+text_linebreaks:"Keep linebreaks",
+word_title:"Use CTRL+V on your keyboard to paste the text into the window."
+},
+table:{
+desc:"Inserts a new table",
+row_before_desc:"Insert row before",
+row_after_desc:"Insert row after",
+delete_row_desc:"Delete row",
+col_before_desc:"Insert column before",
+col_after_desc:"Insert column after",
+delete_col_desc:"Remove column",
+split_cells_desc:"Split merged table cells",
+merge_cells_desc:"Merge table cells",
+row_desc:"Table row properties",
+cell_desc:"Table cell properties",
+props_desc:"Table properties",
+paste_row_before_desc:"Paste table row before",
+paste_row_after_desc:"Paste table row after",
+cut_row_desc:"Cut table row",
+copy_row_desc:"Copy table row",
+del:"Delete table",
+row:"Row",
+col:"Column",
+cell:"Cell"
+},
+autosave:{
+unload_msg:"The changes you made will be lost if you navigate away from this page."
+},
+fullscreen:{
+desc:"Toggle fullscreen mode (Alt+Shift+G)"
+},
+media:{
+desc:"Insert / edit embedded media",
+delta_width:"0",
+delta_height:"0",
+edit:"Edit embedded media"
+},
+fullpage:{
+desc:"Document properties"
+},
+template:{
+desc:"Insert predefined template content"
+},
+visualchars:{
+desc:"Visual control characters on/off."
+},
+spellchecker:{
+desc:"Toggle spellchecker (Alt+Shift+N)",
+menu:"Spellchecker settings",
+ignore_word:"Ignore word",
+ignore_words:"Ignore all",
+langs:"Languages",
+wait:"Please wait...",
+sug:"Suggestions",
+no_sug:"No suggestions",
+no_mpell:"No misspellings found."
+},
+pagebreak:{
+desc:"Insert page break."
+}}});
+
+tinyMCE.addI18n("en.advanced",{
+style_select:"Styles",
+font_size:"Font size",
+fontdefault:"Font family",
+block:"Format",
+paragraph:"Paragraph",
+div:"Div",
+address:"Address",
+pre:"Preformatted",
+h1:"Heading 1",
+h2:"Heading 2",
+h3:"Heading 3",
+h4:"Heading 4",
+h5:"Heading 5",
+h6:"Heading 6",
+blockquote:"Blockquote",
+code:"Code",
+samp:"Code sample",
+dt:"Definition term ",
+dd:"Definition description",
+bold_desc:"Bold (Ctrl / Alt+Shift + B)",
+italic_desc:"Italic (Ctrl / Alt+Shift + I)",
+underline_desc:"Underline",
+striketrough_desc:"Strikethrough (Alt+Shift+D)",
+justifyleft_desc:"Align left (Alt+Shift+L)",
+justifycenter_desc:"Align center (Alt+Shift+C)",
+justifyright_desc:"Align right (Alt+Shift+R)",
+justifyfull_desc:"Align full (Alt+Shift+J)",
+bullist_desc:"Unordered list (Alt+Shift+U)",
+numlist_desc:"Ordered list (Alt+Shift+O)",
+outdent_desc:"Outdent",
+indent_desc:"Indent",
+undo_desc:"Undo (Ctrl+Z)",
+redo_desc:"Redo (Ctrl+Y)",
+link_desc:"Insert/edit link (Alt+Shift+A)",
+link_delta_width:"0",
+link_delta_height:"0",
+unlink_desc:"Unlink (Alt+Shift+S)",
+image_desc:"Insert/edit image (Alt+Shift+M)",
+image_delta_width:"0",
+image_delta_height:"0",
+cleanup_desc:"Cleanup messy code",
+code_desc:"Edit HTML Source",
+sub_desc:"Subscript",
+sup_desc:"Superscript",
+hr_desc:"Insert horizontal ruler",
+removeformat_desc:"Remove formatting",
+forecolor_desc:"Select text color",
+backcolor_desc:"Select background color",
+charmap_desc:"Insert custom character",
+visualaid_desc:"Toggle guidelines/invisible elements",
+anchor_desc:"Insert/edit anchor",
+cut_desc:"Cut",
+copy_desc:"Copy",
+paste_desc:"Paste",
+image_props_desc:"Image properties",
+newdocument_desc:"New document",
+help_desc:"Help",
+blockquote_desc:"Blockquote (Alt+Shift+Q)",
+clipboard_msg:"Copy/Cut/Paste is not available in Mozilla and Firefox.",
+path:"Path",
+newdocument:"Are you sure you want to clear all contents?",
+toolbar_focus:"Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X",
+more_colors:"More colors",
+colorpicker_delta_width:"0",
+colorpicker_delta_height:"0"
+});
+
+tinyMCE.addI18n("en.advanced_dlg",{
+about_title:"About TinyMCE",
+about_general:"About",
+about_help:"Help",
+about_license:"License",
+about_plugins:"Plugins",
+about_plugin:"Plugin",
+about_author:"Author",
+about_version:"Version",
+about_loaded:"Loaded plugins",
+anchor_title:"Insert/edit anchor",
+anchor_name:"Anchor name",
+code_title:"HTML Source Editor",
+code_wordwrap:"Word wrap",
+colorpicker_title:"Select a color",
+colorpicker_picker_tab:"Picker",
+colorpicker_picker_title:"Color picker",
+colorpicker_palette_tab:"Palette",
+colorpicker_palette_title:"Palette colors",
+colorpicker_named_tab:"Named",
+colorpicker_named_title:"Named colors",
+colorpicker_color:"Color:",
+colorpicker_name:"Name:",
+charmap_title:"Select custom character",
+image_title:"Insert/edit image",
+image_src:"Image URL",
+image_alt:"Image description",
+image_list:"Image list",
+image_border:"Border",
+image_dimensions:"Dimensions",
+image_vspace:"Vertical space",
+image_hspace:"Horizontal space",
+image_align:"Alignment",
+image_align_baseline:"Baseline",
+image_align_top:"Top",
+image_align_middle:"Middle",
+image_align_bottom:"Bottom",
+image_align_texttop:"Text top",
+image_align_textbottom:"Text bottom",
+image_align_left:"Left",
+image_align_right:"Right",
+link_title:"Insert/edit link",
+link_url:"Link URL",
+link_target:"Target",
+link_target_same:"Open link in the same window",
+link_target_blank:"Open link in a new window",
+link_titlefield:"Title",
+link_is_email:"The URL you entered seems to be an email address, do you want to add the required mailto: prefix?",
+link_is_external:"The URL you entered seems to external link, do you want to add the required http:// prefix?",
+link_list:"Link list"
+});
+
+tinyMCE.addI18n("en.media_dlg",{
+title:"Insert / edit embedded media",
+general:"General",
+advanced:"Advanced",
+file:"File/URL",
+list:"List",
+size:"Dimensions",
+preview:"Preview",
+constrain_proportions:"Constrain proportions",
+type:"Type",
+id:"Id",
+name:"Name",
+class_name:"Class",
+vspace:"V-Space",
+hspace:"H-Space",
+play:"Auto play",
+loop:"Loop",
+menu:"Show menu",
+quality:"Quality",
+scale:"Scale",
+align:"Align",
+salign:"SAlign",
+wmode:"WMode",
+bgcolor:"Background",
+base:"Base",
+flashvars:"Flashvars",
+liveconnect:"SWLiveConnect",
+autohref:"AutoHREF",
+cache:"Cache",
+hidden:"Hidden",
+controller:"Controller",
+kioskmode:"Kiosk mode",
+playeveryframe:"Play every frame",
+targetcache:"Target cache",
+correction:"No correction",
+enablejavascript:"Enable JavaScript",
+starttime:"Start time",
+endtime:"End time",
+href:"Href",
+qtsrcchokespeed:"Choke speed",
+target:"Target",
+volume:"Volume",
+autostart:"Auto start",
+enabled:"Enabled",
+fullscreen:"Fullscreen",
+invokeurls:"Invoke URLs",
+mute:"Mute",
+stretchtofit:"Stretch to fit",
+windowlessvideo:"Windowless video",
+balance:"Balance",
+baseurl:"Base URL",
+captioningid:"Captioning id",
+currentmarker:"Current marker",
+currentposition:"Current position",
+defaultframe:"Default frame",
+playcount:"Play count",
+rate:"Rate",
+uimode:"UI Mode",
+flash_options:"Flash options",
+qt_options:"Quicktime options",
+wmp_options:"Windows media player options",
+rmp_options:"Real media player options",
+shockwave_options:"Shockwave options",
+autogotourl:"Auto goto URL",
+center:"Center",
+imagestatus:"Image status",
+maintainaspect:"Maintain aspect",
+nojava:"No java",
+prefetch:"Prefetch",
+shuffle:"Shuffle",
+console:"Console",
+numloop:"Num loops",
+controls:"Controls",
+scriptcallbacks:"Script callbacks",
+swstretchstyle:"Stretch style",
+swstretchhalign:"Stretch H-Align",
+swstretchvalign:"Stretch V-Align",
+sound:"Sound",
+progress:"Progress",
+qtsrc:"QT Src",
+qt_stream_warn:"Streamed rtsp resources should be added to the QT Src field under the advanced tab.",
+align_top:"Top",
+align_right:"Right",
+align_bottom:"Bottom",
+align_left:"Left",
+align_center:"Center",
+align_top_left:"Top left",
+align_top_right:"Top right",
+align_bottom_left:"Bottom left",
+align_bottom_right:"Bottom right",
+flv_options:"Flash video options",
+flv_scalemode:"Scale mode",
+flv_buffer:"Buffer",
+flv_startimage:"Start image",
+flv_starttime:"Start time",
+flv_defaultvolume:"Default volume",
+flv_hiddengui:"Hidden GUI",
+flv_autostart:"Auto start",
+flv_loop:"Loop",
+flv_showscalemodes:"Show scale modes",
+flv_smoothvideo:"Smooth video",
+flv_jscallback:"JS Callback"
+});
+
+tinyMCE.addI18n("en.wordpress",{
+wp_adv_desc:"Show/Hide Kitchen Sink (Alt+Shift+Z)",
+wp_more_desc:"Insert More tag (Alt+Shift+T)",
+wp_page_desc:"Insert Page break (Alt+Shift+P)",
+wp_help_desc:"Help (Alt+Shift+H)",
+wp_more_alt:"More...",
+wp_page_alt:"Next page...",
+add_media:"Add Media",
+add_image:"Add an Image",
+add_video:"Add Video",
+add_audio:"Add Audio",
+editgallery:"Edit Gallery",
+delgallery:"Delete Gallery"
+});
+
+tinyMCE.addI18n("en.wpeditimage",{
+edit_img:"Edit Image",
+del_img:"Delete Image",
+adv_settings:"Advanced Settings",
+none:"None",
+size:"Size",
+thumbnail:"Thumbnail",
+medium:"Medium",
+full_size:"Full Size",
+current_link:"Current Link",
+link_to_img:"Link to Image",
+link_help:"Enter a link URL or click above for presets.",
+adv_img_settings:"Advanced Image Settings",
+source:"Source",
+width:"Width",
+height:"Height",
+orig_size:"Original Size",
+css:"CSS Class",
+adv_link_settings:"Advanced Link Settings",
+link_rel:"Link Rel",
+height:"Height",
+orig_size:"Original Size",
+css:"CSS Class",
+s60:"60%",
+s70:"70%",
+s80:"80%",
+s90:"90%",
+s100:"100%",
+s110:"110%",
+s120:"120%",
+s130:"130%",
+img_title:"Edit Image Title",
+caption:"Edit Image Caption",
+alt:"Edit Alternate Text"
+});
<?php
+function mce_put_file( $path, $content ) {
+ if ( function_exists('file_put_contents') )
+ return @file_put_contents( $path, $content );
+
+ $newfile = false;
+ $fp = @fopen( $path, 'wb' );
+ if ($fp) {
+ $newfile = fwrite( $fp, $content );
+ fclose($fp);
+ }
+ return $newfile;
+}
+
// escape text only if it needs translating
function mce_escape($text) {
global $language;
else return js_escape($text);
}
-$strings = 'tinyMCE.addI18n({' . $language . ':{
+$lang = 'tinyMCE.addI18n({' . $language . ':{
common:{
edit_confirm:"' . mce_escape( __('Do you want to use the WYSIWYG mode for this textarea?') ) . '",
apply:"' . mce_escape( __('Apply') ) . '",
add_media:"' . mce_escape( __('Add Media') ) . '",
add_image:"' . mce_escape( __('Add an Image') ) . '",
add_video:"' . mce_escape( __('Add Video') ) . '",
-add_audio:"' . mce_escape( __('Add Audio') ) . '"
+add_audio:"' . mce_escape( __('Add Audio') ) . '",
+editgallery:"' . mce_escape( __('Edit Gallery') ) . '",
+delgallery:"' . mce_escape( __('Delete Gallery') ) . '"
});
tinyMCE.addI18n("' . $language . '.wpeditimage",{
alt:"' . mce_escape( __('Edit Alternate Text') ) . '"
});
';
-?>
\ No newline at end of file
+++ /dev/null
-Check the TinyMCE documentation for details on this plugin.\r
-(function(){var DOM=tinymce.DOM;tinymce.create('tinymce.plugins.FullScreenPlugin',{init:function(ed,url){var t=this,s={},vp;t.editor=ed;ed.addCommand('mceFullScreen',function(){var win,de=DOM.doc.documentElement;if(ed.getParam('fullscreen_is_enabled')){if(ed.getParam('fullscreen_new_window'))closeFullscreen();else{DOM.win.setTimeout(function(){tinymce.dom.Event.remove(DOM.win,'resize',t.resizeFunc);tinyMCE.get(ed.getParam('fullscreen_editor_id')).setContent(ed.getContent({format:'raw'}),{format:'raw'});tinyMCE.remove(ed);DOM.remove('mce_fullscreen_container');de.style.overflow=ed.getParam('fullscreen_html_overflow');DOM.setStyle(DOM.doc.body,'overflow',ed.getParam('fullscreen_overflow'));DOM.win.scrollTo(ed.getParam('fullscreen_scrollx'),ed.getParam('fullscreen_scrolly'));tinyMCE.settings=tinyMCE.oldSettings;},10);}return;}if(ed.getParam('fullscreen_new_window')){win=DOM.win.open(url+"/fullscreen.htm","mceFullScreenPopup","fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width="+screen.availWidth+",height="+screen.availHeight);try{win.resizeTo(screen.availWidth,screen.availHeight);}catch(e){}}else{tinyMCE.oldSettings=tinyMCE.settings;s.fullscreen_overflow=DOM.getStyle(DOM.doc.body,'overflow',1)||'auto';s.fullscreen_html_overflow=DOM.getStyle(de,'overflow',1);vp=DOM.getViewPort();s.fullscreen_scrollx=vp.x;s.fullscreen_scrolly=vp.y;if(tinymce.isOpera&&s.fullscreen_overflow=='visible')s.fullscreen_overflow='auto';if(tinymce.isIE&&s.fullscreen_overflow=='scroll')s.fullscreen_overflow='auto';if(s.fullscreen_overflow=='0px')s.fullscreen_overflow='';DOM.setStyle(DOM.doc.body,'overflow','hidden');de.style.overflow='hidden';vp=DOM.getViewPort();DOM.win.scrollTo(0,0);if(tinymce.isIE)vp.h-=1;n=DOM.add(DOM.doc.body,'div',{id:'mce_fullscreen_container',style:'position:'+(tinymce.isIE6||(tinymce.isIE&&!DOM.boxModel)?'absolute':'fixed')+';top:0;left:0;width:'+vp.w+'px;height:'+vp.h+'px;z-index:200000;'});DOM.add(n,'div',{id:'mce_fullscreen'});tinymce.each(ed.settings,function(v,n){s[n]=v;});s.id='mce_fullscreen';s.width=n.clientWidth;s.height=n.clientHeight-15;s.fullscreen_is_enabled=true;s.fullscreen_editor_id=ed.id;s.theme_advanced_resizing=false;s.save_onsavecallback=function(){ed.setContent(tinyMCE.get(s.id).getContent({format:'raw'}),{format:'raw'});ed.execCommand('mceSave');};tinymce.each(ed.getParam('fullscreen_settings'),function(v,k){s[k]=v;});if(s.theme_advanced_toolbar_location==='external')s.theme_advanced_toolbar_location='top';t.fullscreenEditor=new tinymce.Editor('mce_fullscreen',s);t.fullscreenEditor.onInit.add(function(){t.fullscreenEditor.setContent(ed.getContent());t.fullscreenEditor.focus();});t.fullscreenEditor.render();tinyMCE.add(t.fullscreenEditor);t.fullscreenElement=new tinymce.dom.Element('mce_fullscreen_container');t.fullscreenElement.update();t.resizeFunc=tinymce.dom.Event.add(DOM.win,'resize',function(){var vp=tinymce.DOM.getViewPort();t.fullscreenEditor.theme.resizeTo(vp.w,vp.h);});}});ed.addButton('fullscreen',{title:'fullscreen.desc',cmd:'mceFullScreen'});ed.onNodeChange.add(function(ed,cm){cm.setActive('fullscreen',ed.getParam('fullscreen_is_enabled'));});},getInfo:function(){return{longname:'Fullscreen',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen',version:tinymce.majorVersion+"."+tinymce.minorVersion};}});tinymce.PluginManager.add('fullscreen',tinymce.plugins.FullScreenPlugin);})();
\ No newline at end of file
+(function(){var DOM=tinymce.DOM;tinymce.create('tinymce.plugins.FullScreenPlugin',{init:function(ed,url){var t=this,s={},vp;t.editor=ed;ed.addCommand('mceFullScreen',function(){var win,de=DOM.doc.documentElement;if(ed.getParam('fullscreen_is_enabled')){if(ed.getParam('fullscreen_new_window'))closeFullscreen();else{DOM.win.setTimeout(function(){tinymce.dom.Event.remove(DOM.win,'resize',t.resizeFunc);tinyMCE.get(ed.getParam('fullscreen_editor_id')).setContent(ed.getContent({format:'raw'}),{format:'raw'});tinyMCE.remove(ed);DOM.remove('mce_fullscreen_container');de.style.overflow=ed.getParam('fullscreen_html_overflow');DOM.setStyle(DOM.doc.body,'overflow',ed.getParam('fullscreen_overflow'));DOM.win.scrollTo(ed.getParam('fullscreen_scrollx'),ed.getParam('fullscreen_scrolly'));tinyMCE.settings=tinyMCE.oldSettings;},10);}return;}if(ed.getParam('fullscreen_new_window')){win=DOM.win.open(url+"/fullscreen.htm","mceFullScreenPopup","fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width="+screen.availWidth+",height="+screen.availHeight);try{win.resizeTo(screen.availWidth,screen.availHeight);}catch(e){}}else{tinyMCE.oldSettings=tinyMCE.settings;s.fullscreen_overflow=DOM.getStyle(DOM.doc.body,'overflow',1)||'auto';s.fullscreen_html_overflow=DOM.getStyle(de,'overflow',1);vp=DOM.getViewPort();s.fullscreen_scrollx=vp.x;s.fullscreen_scrolly=vp.y;if(tinymce.isOpera&&s.fullscreen_overflow=='visible')s.fullscreen_overflow='auto';if(tinymce.isIE&&s.fullscreen_overflow=='scroll')s.fullscreen_overflow='auto';if(tinymce.isIE&&(s.fullscreen_html_overflow=='visible'||s.fullscreen_html_overflow=='scroll'))s.fullscreen_html_overflow='auto';if(s.fullscreen_overflow=='0px')s.fullscreen_overflow='';DOM.setStyle(DOM.doc.body,'overflow','hidden');de.style.overflow='hidden';vp=DOM.getViewPort();DOM.win.scrollTo(0,0);if(tinymce.isIE)vp.h-=1;n=DOM.add(DOM.doc.body,'div',{id:'mce_fullscreen_container',style:'position:'+(tinymce.isIE6||(tinymce.isIE&&!DOM.boxModel)?'absolute':'fixed')+';top:0;left:0;width:'+vp.w+'px;height:'+vp.h+'px;z-index:200000;'});DOM.add(n,'div',{id:'mce_fullscreen'});tinymce.each(ed.settings,function(v,n){s[n]=v;});s.id='mce_fullscreen';s.width=n.clientWidth;s.height=n.clientHeight-15;s.fullscreen_is_enabled=true;s.fullscreen_editor_id=ed.id;s.theme_advanced_resizing=false;s.save_onsavecallback=function(){ed.setContent(tinyMCE.get(s.id).getContent({format:'raw'}),{format:'raw'});ed.execCommand('mceSave');};tinymce.each(ed.getParam('fullscreen_settings'),function(v,k){s[k]=v;});if(s.theme_advanced_toolbar_location==='external')s.theme_advanced_toolbar_location='top';t.fullscreenEditor=new tinymce.Editor('mce_fullscreen',s);t.fullscreenEditor.onInit.add(function(){t.fullscreenEditor.setContent(ed.getContent());t.fullscreenEditor.focus();});t.fullscreenEditor.render();tinyMCE.add(t.fullscreenEditor);t.fullscreenElement=new tinymce.dom.Element('mce_fullscreen_container');t.fullscreenElement.update();t.resizeFunc=tinymce.dom.Event.add(DOM.win,'resize',function(){var vp=tinymce.DOM.getViewPort();t.fullscreenEditor.theme.resizeTo(vp.w,vp.h);});}});ed.addButton('fullscreen',{title:'fullscreen.desc',cmd:'mceFullScreen'});ed.onNodeChange.add(function(ed,cm){cm.setActive('fullscreen',ed.getParam('fullscreen_is_enabled'));});},getInfo:function(){return{longname:'Fullscreen',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen',version:tinymce.majorVersion+"."+tinymce.minorVersion};}});tinymce.PluginManager.add('fullscreen',tinymce.plugins.FullScreenPlugin);})();
\ No newline at end of file
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <script type="text/javascript" src="../../tiny_mce.js?ver=311"></script>
+ <script type="text/javascript" src="../../tiny_mce.js?ver=3211"></script>
<script type="text/javascript">
function patchCallback(settings, key) {
if (settings[key])
-(function(){var DOM=tinymce.DOM,Element=tinymce.dom.Element,Event=tinymce.dom.Event,each=tinymce.each,is=tinymce.is;tinymce.create('tinymce.plugins.InlinePopups',{init:function(ed,url){ed.onBeforeRenderUI.add(function(){ed.windowManager=new tinymce.InlineWindowManager(ed);DOM.loadCSS(url+'/skins/'+(ed.settings.inlinepopups_skin||'clearlooks2')+"/window.css");});},getInfo:function(){return{longname:'InlinePopups',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups',version:tinymce.majorVersion+"."+tinymce.minorVersion};}});tinymce.create('tinymce.InlineWindowManager:tinymce.WindowManager',{InlineWindowManager:function(ed){var t=this;t.parent(ed);t.zIndex=300000;t.count=0;},open:function(f,p){var t=this,id,opt='',ed=t.editor,dw=0,dh=0,vp,po,mdf,clf,we,w,u;f=f||{};p=p||{};if(!f.inline)return t.parent(f,p);if(!f.type)t.bookmark=ed.selection.getBookmark('simple');id=DOM.uniqueId();vp=DOM.getViewPort();f.width=parseInt(f.width||320);f.height=parseInt(f.height||240)+(tinymce.isIE?8:0);f.min_width=parseInt(f.min_width||150);f.min_height=parseInt(f.min_height||100);f.max_width=parseInt(f.max_width||2000);f.max_height=parseInt(f.max_height||2000);f.left=f.left||Math.round(Math.max(vp.x,vp.x+(vp.w/ 2.0) - (f.width /2.0)));f.top=f.top||Math.round(Math.max(vp.y,vp.y+(vp.h/ 2.0) - (f.height /2.0)));f.movable=f.resizable=true;p.mce_width=f.width;p.mce_height=f.height;p.mce_inline=true;p.mce_window_id=id;p.mce_auto_focus=f.auto_focus;t.features=f;t.params=p;t.onOpen.dispatch(t,f,p);if(f.type){opt+=' mceModal';if(f.type)opt+=' mce'+f.type.substring(0,1).toUpperCase()+f.type.substring(1);f.resizable=false;}if(f.statusbar)opt+=' mceStatusbar';if(f.resizable)opt+=' mceResizable';if(f.minimizable)opt+=' mceMinimizable';if(f.maximizable)opt+=' mceMaximizable';if(f.movable)opt+=' mceMovable';t._addAll(DOM.doc.body,['div',{id:id,'class':ed.settings.inlinepopups_skin||'clearlooks2',style:'width:100px;height:100px'},['div',{id:id+'_wrapper','class':'mceWrapper'+opt},['div',{id:id+'_top','class':'mceTop'},['div',{'class':'mceLeft'}],['div',{'class':'mceCenter'}],['div',{'class':'mceRight'}],['span',{id:id+'_title'},f.title||'']],['div',{id:id+'_middle','class':'mceMiddle'},['div',{id:id+'_left','class':'mceLeft'}],['span',{id:id+'_content'}],['div',{id:id+'_right','class':'mceRight'}]],['div',{id:id+'_bottom','class':'mceBottom'},['div',{'class':'mceLeft'}],['div',{'class':'mceCenter'}],['div',{'class':'mceRight'}],['span',{id:id+'_status'},'Content']],['a',{'class':'mceMove',tabindex:'-1',href:'javascript:;'}],['a',{'class':'mceMin',tabindex:'-1',href:'javascript:;',onmousedown:'return false;'}],['a',{'class':'mceMax',tabindex:'-1',href:'javascript:;',onmousedown:'return false;'}],['a',{'class':'mceMed',tabindex:'-1',href:'javascript:;',onmousedown:'return false;'}],['a',{'class':'mceClose',tabindex:'-1',href:'javascript:;',onmousedown:'return false;'}],['a',{id:id+'_resize_n','class':'mceResize mceResizeN',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_s','class':'mceResize mceResizeS',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_w','class':'mceResize mceResizeW',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_e','class':'mceResize mceResizeE',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_nw','class':'mceResize mceResizeNW',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_ne','class':'mceResize mceResizeNE',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_sw','class':'mceResize mceResizeSW',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_se','class':'mceResize mceResizeSE',tabindex:'-1',href:'javascript:;'}]]]);DOM.setStyles(id,{top:-10000,left:-10000});if(tinymce.isGecko)DOM.setStyle(id,'overflow','auto');if(!f.type){dw+=DOM.get(id+'_left').clientWidth;dw+=DOM.get(id+'_right').clientWidth;dh+=DOM.get(id+'_top').clientHeight;dh+=DOM.get(id+'_bottom').clientHeight;}DOM.setStyles(id,{top:f.top,left:f.left,width:f.width+dw,height:f.height+dh});u=f.url||f.file;if(u){if(tinymce.relaxedDomain)u+=(u.indexOf('?')==-1?'?':'&')+'mce_rdomain='+tinymce.relaxedDomain;u=tinymce._addVer(u);}if(!f.type){DOM.add(id+'_content','iframe',{id:id+'_ifr',src:'javascript:""',frameBorder:0,style:'border:0;width:10px;height:10px'});DOM.setStyles(id+'_ifr',{width:f.width,height:f.height});DOM.setAttrib(id+'_ifr','src',u);}else{DOM.add(id+'_wrapper','a',{id:id+'_ok','class':'mceButton mceOk',href:'javascript:;',onmousedown:'return false;'},'Ok');if(f.type=='confirm')DOM.add(id+'_wrapper','a',{'class':'mceButton mceCancel',href:'javascript:;',onmousedown:'return false;'},'Cancel');DOM.add(id+'_middle','div',{'class':'mceIcon'});DOM.setHTML(id+'_content',f.content.replace('\n','<br />'));}mdf=Event.add(id,'mousedown',function(e){var n=e.target,w,vp;w=t.windows[id];t.focus(id);if(n.nodeName=='A'||n.nodeName=='a'){if(n.className=='mceMax'){w.oldPos=w.element.getXY();w.oldSize=w.element.getSize();vp=DOM.getViewPort();vp.w-=2;vp.h-=2;w.element.moveTo(vp.x,vp.y);w.element.resizeTo(vp.w,vp.h);DOM.setStyles(id+'_ifr',{width:vp.w-w.deltaWidth,height:vp.h-w.deltaHeight});DOM.addClass(id+'_wrapper','mceMaximized');}else if(n.className=='mceMed'){w.element.moveTo(w.oldPos.x,w.oldPos.y);w.element.resizeTo(w.oldSize.w,w.oldSize.h);w.iframeElement.resizeTo(w.oldSize.w-w.deltaWidth,w.oldSize.h-w.deltaHeight);DOM.removeClass(id+'_wrapper','mceMaximized');}else if(n.className=='mceMove')return t._startDrag(id,e,n.className);else if(DOM.hasClass(n,'mceResize'))return t._startDrag(id,e,n.className.substring(13));}});clf=Event.add(id,'click',function(e){var n=e.target;t.focus(id);if(n.nodeName=='A'||n.nodeName=='a'){switch(n.className){case'mceClose':t.close(null,id);return Event.cancel(e);case'mceButton mceOk':case'mceButton mceCancel':f.button_func(n.className=='mceButton mceOk');return Event.cancel(e);}}});t.windows=t.windows||{};w=t.windows[id]={id:id,mousedown_func:mdf,click_func:clf,element:new Element(id,{blocker:1,container:ed.getContainer()}),iframeElement:new Element(id+'_ifr'),features:f,deltaWidth:dw,deltaHeight:dh};w.iframeElement.on('focus',function(){t.focus(id);});if(t.count==0&&t.editor.getParam('dialog_type')=='modal'){DOM.add(DOM.doc.body,'div',{id:'mceModalBlocker','class':(t.editor.settings.inlinepopups_skin||'clearlooks2')+'_modalBlocker',style:{left:vp.x,top:vp.y,zIndex:t.zIndex-1}});DOM.show('mceModalBlocker');}else DOM.setStyle('mceModalBlocker','z-index',t.zIndex-1);if(tinymce.isIE6||(tinymce.isIE&&!DOM.boxModel))DOM.setStyles('mceModalBlocker',{position:'absolute',width:vp.w-2,height:vp.h-2});t.focus(id);t._fixIELayout(id,1);if(DOM.get(id+'_ok'))DOM.get(id+'_ok').focus();t.count++;return w;},focus:function(id){var t=this,w=t.windows[id];w.zIndex=this.zIndex++;w.element.setStyle('zIndex',w.zIndex);w.element.update();id=id+'_wrapper';DOM.removeClass(t.lastId,'mceFocus');DOM.addClass(id,'mceFocus');t.lastId=id;},_addAll:function(te,ne){var i,n,t=this,dom=tinymce.DOM;if(is(ne,'string'))te.appendChild(dom.doc.createTextNode(ne));else if(ne.length){te=te.appendChild(dom.create(ne[0],ne[1]));for(i=2;i<ne.length;i++)t._addAll(te,ne[i]);}},_startDrag:function(id,se,ac){var t=this,mu,mm,d=DOM.doc,eb,w=t.windows[id],we=w.element,sp=we.getXY(),p,sz,ph,cp,vp,sx,sy,sex,sey,dx,dy,dw,dh;cp={x:0,y:0};vp=DOM.getViewPort();vp.w-=2;vp.h-=2;sex=se.screenX;sey=se.screenY;dx=dy=dw=dh=0;mu=Event.add(d,'mouseup',function(e){Event.remove(d,'mouseup',mu);Event.remove(d,'mousemove',mm);if(eb)eb.remove();we.moveBy(dx,dy);we.resizeBy(dw,dh);sz=we.getSize();DOM.setStyles(id+'_ifr',{width:sz.w-w.deltaWidth,height:sz.h-w.deltaHeight});t._fixIELayout(id,1);return Event.cancel(e);});if(ac!='Move')startMove();function startMove(){if(eb)return;t._fixIELayout(id,0);DOM.add(d.body,'div',{id:'mceEventBlocker','class':'mceEventBlocker '+(t.editor.settings.inlinepopups_skin||'clearlooks2'),style:{left:vp.x,top:vp.y,zIndex:t.zIndex+1}});if(tinymce.isIE6||(tinymce.isIE&&!DOM.boxModel))DOM.setStyles('mceEventBlocker',{position:'absolute',width:vp.w-2,height:vp.h-2});eb=new Element('mceEventBlocker');eb.update();p=we.getXY();sz=we.getSize();sx=cp.x+p.x-vp.x;sy=cp.y+p.y-vp.y;DOM.add(eb.get(),'div',{id:'mcePlaceHolder','class':'mcePlaceHolder',style:{left:sx,top:sy,width:sz.w,height:sz.h}});ph=new Element('mcePlaceHolder');};mm=Event.add(d,'mousemove',function(e){var x,y,v;startMove();x=e.screenX-sex;y=e.screenY-sey;switch(ac){case'ResizeW':dx=x;dw=0-x;break;case'ResizeE':dw=x;break;case'ResizeN':case'ResizeNW':case'ResizeNE':if(ac=="ResizeNW"){dx=x;dw=0-x;}else if(ac=="ResizeNE")dw=x;dy=y;dh=0-y;break;case'ResizeS':case'ResizeSW':case'ResizeSE':if(ac=="ResizeSW"){dx=x;dw=0-x;}else if(ac=="ResizeSE")dw=x;dh=y;break;case'mceMove':dx=x;dy=y;break;}if(dw<(v=w.features.min_width-sz.w)){if(dx!==0)dx+=dw-v;dw=v;}if(dh<(v=w.features.min_height-sz.h)){if(dy!==0)dy+=dh-v;dh=v;}dw=Math.min(dw,w.features.max_width-sz.w);dh=Math.min(dh,w.features.max_height-sz.h);dx=Math.max(dx,vp.x-(sx+vp.x));dy=Math.max(dy,vp.y-(sy+vp.y));dx=Math.min(dx,(vp.w+vp.x)-(sx+sz.w+vp.x));dy=Math.min(dy,(vp.h+vp.y)-(sy+sz.h+vp.y));if(dx+dy!==0){if(sx+dx<0)dx=0;if(sy+dy<0)dy=0;ph.moveTo(sx+dx,sy+dy);}if(dw+dh!==0)ph.resizeTo(sz.w+dw,sz.h+dh);return Event.cancel(e);});return Event.cancel(se);},resizeBy:function(dw,dh,id){var w=this.windows[id];if(w){w.element.resizeBy(dw,dh);w.iframeElement.resizeBy(dw,dh);}},close:function(win,id){var t=this,w,d=DOM.doc,ix=0,fw,id;id=t._findId(id||win);t.count--;if(t.count==0)DOM.remove('mceModalBlocker');if(!id&&win){t.parent(win);return;}if(w=t.windows[id]){t.onClose.dispatch(t);Event.remove(d,'mousedown',w.mousedownFunc);Event.remove(d,'click',w.clickFunc);Event.clear(id);Event.clear(id+'_ifr');DOM.setAttrib(id+'_ifr','src','javascript:""');w.element.remove();delete t.windows[id];each(t.windows,function(w){if(w.zIndex>ix){fw=w;ix=w.zIndex;}});if(fw)t.focus(fw.id);}},setTitle:function(w,ti){var e;w=this._findId(w);if(e=DOM.get(w+'_title'))e.innerHTML=DOM.encode(ti);},alert:function(txt,cb,s){var t=this,w;w=t.open({title:t,type:'alert',button_func:function(s){if(cb)cb.call(s||t,s);t.close(null,w.id);},content:DOM.encode(t.editor.getLang(txt,txt)),inline:1,width:400,height:130});},confirm:function(txt,cb,s){var t=this,w;w=t.open({title:t,type:'confirm',button_func:function(s){if(cb)cb.call(s||t,s);t.close(null,w.id);},content:DOM.encode(t.editor.getLang(txt,txt)),inline:1,width:400,height:130});},_findId:function(w){var t=this;if(typeof(w)=='string')return w;each(t.windows,function(wo){var ifr=DOM.get(wo.id+'_ifr');if(ifr&&w==ifr.contentWindow){w=wo.id;return false;}});return w;},_fixIELayout:function(id,s){var w,img;if(!tinymce.isIE6)return;each(['n','s','w','e','nw','ne','sw','se'],function(v){var e=DOM.get(id+'_resize_'+v);DOM.setStyles(e,{width:s?e.clientWidth:'',height:s?e.clientHeight:'',cursor:DOM.getStyle(e,'cursor',1)});DOM.setStyle(id+"_bottom",'bottom','-1px');e=0;});if(w=this.windows[id]){w.element.hide();w.element.show();each(DOM.select('div,a',id),function(e,i){if(e.currentStyle.backgroundImage!='none'){img=new Image();img.src=e.currentStyle.backgroundImage.replace(/url\(\"(.+)\"\)/,'$1');}});DOM.get(id).style.filter='';}}});tinymce.PluginManager.add('inlinepopups',tinymce.plugins.InlinePopups);})();
\ No newline at end of file
+(function(){var DOM=tinymce.DOM,Element=tinymce.dom.Element,Event=tinymce.dom.Event,each=tinymce.each,is=tinymce.is;tinymce.create('tinymce.plugins.InlinePopups',{init:function(ed,url){ed.onBeforeRenderUI.add(function(){ed.windowManager=new tinymce.InlineWindowManager(ed);DOM.loadCSS(url+'/skins/'+(ed.settings.inlinepopups_skin||'clearlooks2')+"/window.css");});},getInfo:function(){return{longname:'InlinePopups',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups',version:tinymce.majorVersion+"."+tinymce.minorVersion};}});tinymce.create('tinymce.InlineWindowManager:tinymce.WindowManager',{InlineWindowManager:function(ed){var t=this;t.parent(ed);t.zIndex=300000;t.count=0;t.windows={};},open:function(f,p){var t=this,id,opt='',ed=t.editor,dw=0,dh=0,vp,po,mdf,clf,we,w,u;f=f||{};p=p||{};if(!f.inline)return t.parent(f,p);if(!f.type)t.bookmark=ed.selection.getBookmark('simple');id=DOM.uniqueId();vp=DOM.getViewPort();f.width=parseInt(f.width||320);f.height=parseInt(f.height||240)+(tinymce.isIE?8:0);f.min_width=parseInt(f.min_width||150);f.min_height=parseInt(f.min_height||100);f.max_width=parseInt(f.max_width||2000);f.max_height=parseInt(f.max_height||2000);f.left=f.left||Math.round(Math.max(vp.x,vp.x+(vp.w/ 2.0) - (f.width /2.0)));f.top=f.top||Math.round(Math.max(vp.y,vp.y+(vp.h/ 2.0) - (f.height /2.0)));f.movable=f.resizable=true;p.mce_width=f.width;p.mce_height=f.height;p.mce_inline=true;p.mce_window_id=id;p.mce_auto_focus=f.auto_focus;t.features=f;t.params=p;t.onOpen.dispatch(t,f,p);if(f.type){opt+=' mceModal';if(f.type)opt+=' mce'+f.type.substring(0,1).toUpperCase()+f.type.substring(1);f.resizable=false;}if(f.statusbar)opt+=' mceStatusbar';if(f.resizable)opt+=' mceResizable';if(f.minimizable)opt+=' mceMinimizable';if(f.maximizable)opt+=' mceMaximizable';if(f.movable)opt+=' mceMovable';t._addAll(DOM.doc.body,['div',{id:id,'class':ed.settings.inlinepopups_skin||'clearlooks2',style:'width:100px;height:100px'},['div',{id:id+'_wrapper','class':'mceWrapper'+opt},['div',{id:id+'_top','class':'mceTop'},['div',{'class':'mceLeft'}],['div',{'class':'mceCenter'}],['div',{'class':'mceRight'}],['span',{id:id+'_title'},f.title||'']],['div',{id:id+'_middle','class':'mceMiddle'},['div',{id:id+'_left','class':'mceLeft'}],['span',{id:id+'_content'}],['div',{id:id+'_right','class':'mceRight'}]],['div',{id:id+'_bottom','class':'mceBottom'},['div',{'class':'mceLeft'}],['div',{'class':'mceCenter'}],['div',{'class':'mceRight'}],['span',{id:id+'_status'},'Content']],['a',{'class':'mceMove',tabindex:'-1',href:'javascript:;'}],['a',{'class':'mceMin',tabindex:'-1',href:'javascript:;',onmousedown:'return false;'}],['a',{'class':'mceMax',tabindex:'-1',href:'javascript:;',onmousedown:'return false;'}],['a',{'class':'mceMed',tabindex:'-1',href:'javascript:;',onmousedown:'return false;'}],['a',{'class':'mceClose',tabindex:'-1',href:'javascript:;',onmousedown:'return false;'}],['a',{id:id+'_resize_n','class':'mceResize mceResizeN',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_s','class':'mceResize mceResizeS',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_w','class':'mceResize mceResizeW',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_e','class':'mceResize mceResizeE',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_nw','class':'mceResize mceResizeNW',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_ne','class':'mceResize mceResizeNE',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_sw','class':'mceResize mceResizeSW',tabindex:'-1',href:'javascript:;'}],['a',{id:id+'_resize_se','class':'mceResize mceResizeSE',tabindex:'-1',href:'javascript:;'}]]]);DOM.setStyles(id,{top:-10000,left:-10000});if(tinymce.isGecko)DOM.setStyle(id,'overflow','auto');if(!f.type){dw+=DOM.get(id+'_left').clientWidth;dw+=DOM.get(id+'_right').clientWidth;dh+=DOM.get(id+'_top').clientHeight;dh+=DOM.get(id+'_bottom').clientHeight;}DOM.setStyles(id,{top:f.top,left:f.left,width:f.width+dw,height:f.height+dh});u=f.url||f.file;if(u){if(tinymce.relaxedDomain)u+=(u.indexOf('?')==-1?'?':'&')+'mce_rdomain='+tinymce.relaxedDomain;u=tinymce._addVer(u);}if(!f.type){DOM.add(id+'_content','iframe',{id:id+'_ifr',src:'javascript:""',frameBorder:0,style:'border:0;width:10px;height:10px'});DOM.setStyles(id+'_ifr',{width:f.width,height:f.height});DOM.setAttrib(id+'_ifr','src',u);}else{DOM.add(id+'_wrapper','a',{id:id+'_ok','class':'mceButton mceOk',href:'javascript:;',onmousedown:'return false;'},'Ok');if(f.type=='confirm')DOM.add(id+'_wrapper','a',{'class':'mceButton mceCancel',href:'javascript:;',onmousedown:'return false;'},'Cancel');DOM.add(id+'_middle','div',{'class':'mceIcon'});DOM.setHTML(id+'_content',f.content.replace('\n','<br />'));}mdf=Event.add(id,'mousedown',function(e){var n=e.target,w,vp;w=t.windows[id];t.focus(id);if(n.nodeName=='A'||n.nodeName=='a'){if(n.className=='mceMax'){w.oldPos=w.element.getXY();w.oldSize=w.element.getSize();vp=DOM.getViewPort();vp.w-=2;vp.h-=2;w.element.moveTo(vp.x,vp.y);w.element.resizeTo(vp.w,vp.h);DOM.setStyles(id+'_ifr',{width:vp.w-w.deltaWidth,height:vp.h-w.deltaHeight});DOM.addClass(id+'_wrapper','mceMaximized');}else if(n.className=='mceMed'){w.element.moveTo(w.oldPos.x,w.oldPos.y);w.element.resizeTo(w.oldSize.w,w.oldSize.h);w.iframeElement.resizeTo(w.oldSize.w-w.deltaWidth,w.oldSize.h-w.deltaHeight);DOM.removeClass(id+'_wrapper','mceMaximized');}else if(n.className=='mceMove')return t._startDrag(id,e,n.className);else if(DOM.hasClass(n,'mceResize'))return t._startDrag(id,e,n.className.substring(13));}});clf=Event.add(id,'click',function(e){var n=e.target;t.focus(id);if(n.nodeName=='A'||n.nodeName=='a'){switch(n.className){case'mceClose':t.close(null,id);return Event.cancel(e);case'mceButton mceOk':case'mceButton mceCancel':f.button_func(n.className=='mceButton mceOk');return Event.cancel(e);}}});w=t.windows[id]={id:id,mousedown_func:mdf,click_func:clf,element:new Element(id,{blocker:1,container:ed.getContainer()}),iframeElement:new Element(id+'_ifr'),features:f,deltaWidth:dw,deltaHeight:dh};w.iframeElement.on('focus',function(){t.focus(id);});if(t.count==0&&t.editor.getParam('dialog_type','modal')=='modal'){DOM.add(DOM.doc.body,'div',{id:'mceModalBlocker','class':(t.editor.settings.inlinepopups_skin||'clearlooks2')+'_modalBlocker',style:{zIndex:t.zIndex-1}});DOM.show('mceModalBlocker');}else DOM.setStyle('mceModalBlocker','z-index',t.zIndex-1);if(tinymce.isIE6||/Firefox\/2\./.test(navigator.userAgent)||(tinymce.isIE&&!DOM.boxModel))DOM.setStyles('mceModalBlocker',{position:'absolute',width:vp.w-2,height:vp.h-2});t.focus(id);t._fixIELayout(id,1);if(DOM.get(id+'_ok'))DOM.get(id+'_ok').focus();t.count++;return w;},focus:function(id){var t=this,w;if(w=t.windows[id]){w.zIndex=this.zIndex++;w.element.setStyle('zIndex',w.zIndex);w.element.update();id=id+'_wrapper';DOM.removeClass(t.lastId,'mceFocus');DOM.addClass(id,'mceFocus');t.lastId=id;}},_addAll:function(te,ne){var i,n,t=this,dom=tinymce.DOM;if(is(ne,'string'))te.appendChild(dom.doc.createTextNode(ne));else if(ne.length){te=te.appendChild(dom.create(ne[0],ne[1]));for(i=2;i<ne.length;i++)t._addAll(te,ne[i]);}},_startDrag:function(id,se,ac){var t=this,mu,mm,d=DOM.doc,eb,w=t.windows[id],we=w.element,sp=we.getXY(),p,sz,ph,cp,vp,sx,sy,sex,sey,dx,dy,dw,dh;cp={x:0,y:0};vp=DOM.getViewPort();vp.w-=2;vp.h-=2;sex=se.screenX;sey=se.screenY;dx=dy=dw=dh=0;mu=Event.add(d,'mouseup',function(e){Event.remove(d,'mouseup',mu);Event.remove(d,'mousemove',mm);if(eb)eb.remove();we.moveBy(dx,dy);we.resizeBy(dw,dh);sz=we.getSize();DOM.setStyles(id+'_ifr',{width:sz.w-w.deltaWidth,height:sz.h-w.deltaHeight});t._fixIELayout(id,1);return Event.cancel(e);});if(ac!='Move')startMove();function startMove(){if(eb)return;t._fixIELayout(id,0);DOM.add(d.body,'div',{id:'mceEventBlocker','class':'mceEventBlocker '+(t.editor.settings.inlinepopups_skin||'clearlooks2'),style:{zIndex:t.zIndex+1}});if(tinymce.isIE6||(tinymce.isIE&&!DOM.boxModel))DOM.setStyles('mceEventBlocker',{position:'absolute',width:vp.w-2,height:vp.h-2});eb=new Element('mceEventBlocker');eb.update();p=we.getXY();sz=we.getSize();sx=cp.x+p.x-vp.x;sy=cp.y+p.y-vp.y;DOM.add(eb.get(),'div',{id:'mcePlaceHolder','class':'mcePlaceHolder',style:{left:sx,top:sy,width:sz.w,height:sz.h}});ph=new Element('mcePlaceHolder');};mm=Event.add(d,'mousemove',function(e){var x,y,v;startMove();x=e.screenX-sex;y=e.screenY-sey;switch(ac){case'ResizeW':dx=x;dw=0-x;break;case'ResizeE':dw=x;break;case'ResizeN':case'ResizeNW':case'ResizeNE':if(ac=="ResizeNW"){dx=x;dw=0-x;}else if(ac=="ResizeNE")dw=x;dy=y;dh=0-y;break;case'ResizeS':case'ResizeSW':case'ResizeSE':if(ac=="ResizeSW"){dx=x;dw=0-x;}else if(ac=="ResizeSE")dw=x;dh=y;break;case'mceMove':dx=x;dy=y;break;}if(dw<(v=w.features.min_width-sz.w)){if(dx!==0)dx+=dw-v;dw=v;}if(dh<(v=w.features.min_height-sz.h)){if(dy!==0)dy+=dh-v;dh=v;}dw=Math.min(dw,w.features.max_width-sz.w);dh=Math.min(dh,w.features.max_height-sz.h);dx=Math.max(dx,vp.x-(sx+vp.x));dy=Math.max(dy,vp.y-(sy+vp.y));dx=Math.min(dx,(vp.w+vp.x)-(sx+sz.w+vp.x));dy=Math.min(dy,(vp.h+vp.y)-(sy+sz.h+vp.y));if(dx+dy!==0){if(sx+dx<0)dx=0;if(sy+dy<0)dy=0;ph.moveTo(sx+dx,sy+dy);}if(dw+dh!==0)ph.resizeTo(sz.w+dw,sz.h+dh);return Event.cancel(e);});return Event.cancel(se);},resizeBy:function(dw,dh,id){var w=this.windows[id];if(w){w.element.resizeBy(dw,dh);w.iframeElement.resizeBy(dw,dh);}},close:function(win,id){var t=this,w,d=DOM.doc,ix=0,fw,id;id=t._findId(id||win);if(!t.windows[id]){t.parent(win);return;}t.count--;if(t.count==0)DOM.remove('mceModalBlocker');if(w=t.windows[id]){t.onClose.dispatch(t);Event.remove(d,'mousedown',w.mousedownFunc);Event.remove(d,'click',w.clickFunc);Event.clear(id);Event.clear(id+'_ifr');DOM.setAttrib(id+'_ifr','src','javascript:""');w.element.remove();delete t.windows[id];each(t.windows,function(w){if(w.zIndex>ix){fw=w;ix=w.zIndex;}});if(fw)t.focus(fw.id);}},setTitle:function(w,ti){var e;w=this._findId(w);if(e=DOM.get(w+'_title'))e.innerHTML=DOM.encode(ti);},alert:function(txt,cb,s){var t=this,w;w=t.open({title:t,type:'alert',button_func:function(s){if(cb)cb.call(s||t,s);t.close(null,w.id);},content:DOM.encode(t.editor.getLang(txt,txt)),inline:1,width:400,height:130});},confirm:function(txt,cb,s){var t=this,w;w=t.open({title:t,type:'confirm',button_func:function(s){if(cb)cb.call(s||t,s);t.close(null,w.id);},content:DOM.encode(t.editor.getLang(txt,txt)),inline:1,width:400,height:130});},_findId:function(w){var t=this;if(typeof(w)=='string')return w;each(t.windows,function(wo){var ifr=DOM.get(wo.id+'_ifr');if(ifr&&w==ifr.contentWindow){w=wo.id;return false;}});return w;},_fixIELayout:function(id,s){var w,img;if(!tinymce.isIE6)return;each(['n','s','w','e','nw','ne','sw','se'],function(v){var e=DOM.get(id+'_resize_'+v);DOM.setStyles(e,{width:s?e.clientWidth:'',height:s?e.clientHeight:'',cursor:DOM.getStyle(e,'cursor',1)});DOM.setStyle(id+"_bottom",'bottom','-1px');e=0;});if(w=this.windows[id]){w.element.hide();w.element.show();each(DOM.select('div,a',id),function(e,i){if(e.currentStyle.backgroundImage!='none'){img=new Image();img.src=e.currentStyle.backgroundImage.replace(/url\(\"(.+)\"\)/,'$1');}});DOM.get(id).style.filter='';}}});tinymce.PluginManager.add('inlinepopups',tinymce.plugins.InlinePopups);})();
\ No newline at end of file
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Template for dialogs</title>
-<link rel="stylesheet" type="text/css" href="skins/clearlooks2/window.css?ver=311" />
+<link rel="stylesheet" type="text/css" href="skins/clearlooks2/window.css?ver=3211" />
</head>
<body>
-(function(){var each=tinymce.each;tinymce.create('tinymce.plugins.MediaPlugin',{init:function(ed,url){var t=this;t.editor=ed;t.url=url;function isMediaElm(n){return/^(mceItemFlash|mceItemShockWave|mceItemWindowsMedia|mceItemQuickTime|mceItemRealMedia)$/.test(n.className);};ed.onPreInit.add(function(){ed.serializer.addRules('param[name|value|_value]');});ed.addCommand('mceMedia',function(){ed.windowManager.open({file:url+'/media.htm',width:430+parseInt(ed.getLang('media.delta_width',0)),height:470+parseInt(ed.getLang('media.delta_height',0)),inline:1},{plugin_url:url});});ed.addButton('media',{title:'media.desc',cmd:'mceMedia'});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('media',n.nodeName=='IMG'&&isMediaElm(n));});ed.onInit.add(function(){var lo={mceItemFlash:'flash',mceItemShockWave:'shockwave',mceItemWindowsMedia:'windowsmedia',mceItemQuickTime:'quicktime',mceItemRealMedia:'realmedia'};if(ed.settings.content_css!==false)ed.dom.loadCSS(url+"/css/content.css");if(ed.theme.onResolveName){ed.theme.onResolveName.add(function(th,o){if(o.name=='img'){each(lo,function(v,k){if(ed.dom.hasClass(o.node,k)){o.name=v;o.title=ed.dom.getAttrib(o.node,'title');return false;}});}});}if(ed&&ed.plugins.contextmenu){ed.plugins.contextmenu.onContextMenu.add(function(th,m,e){if(e.nodeName=='IMG'&&/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(e.className)){m.add({title:'media.edit',icon:'media',cmd:'mceMedia'});}});}});ed.onBeforeSetContent.add(function(ed,o){var h=o.content;h=h.replace(/<script[^>]*>\s*write(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)\(\{([^\)]*)\}\);\s*<\/script>/gi,function(a,b,c){var o=t._parse(c);return'<img class="mceItem'+b+'" title="'+ed.dom.encode(c)+'" src="'+url+'/img/trans.gif" width="'+o.width+'" height="'+o.height+'" />'});h=h.replace(/<object([^>]*)>/gi,'<span class="mceItemObject" $1>');h=h.replace(/<embed([^>]*)\/?>/gi,'<span class="mceItemEmbed" $1></span>');h=h.replace(/<embed([^>]*)>/gi,'<span class="mceItemEmbed" $1>');h=h.replace(/<\/(object)([^>]*)>/gi,'</span>');h=h.replace(/<\/embed>/gi,'');h=h.replace(/<param([^>]*)>/gi,function(a,b){return'<span '+b.replace(/value=/gi,'_value=')+' class="mceItemParam"></span>'});h=h.replace(/\/ class=\"mceItemParam\"><\/span>/gi,'class="mceItemParam"></span>');o.content=h;});ed.onSetContent.add(function(){t._spansToImgs(ed.getBody());});ed.onPreProcess.add(function(ed,o){var dom=ed.dom;if(o.set){t._spansToImgs(o.node);each(dom.select('IMG',o.node),function(n){var p;if(isMediaElm(n)){p=t._parse(n.title);dom.setAttrib(n,'width',dom.getAttrib(n,'width',p.width||100));dom.setAttrib(n,'height',dom.getAttrib(n,'height',p.height||100));}});}if(o.get){each(dom.select('IMG',o.node),function(n){var ci,cb,mt;if(ed.getParam('media_use_script')){if(isMediaElm(n))n.className=n.className.replace(/mceItem/g,'mceTemp');return;}switch(n.className){case'mceItemFlash':ci='d27cdb6e-ae6d-11cf-96b8-444553540000';cb='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';mt='application/x-shockwave-flash';break;case'mceItemShockWave':ci='166b1bca-3f9c-11cf-8075-444553540000';cb='http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0';mt='application/x-director';break;case'mceItemWindowsMedia':ci=ed.getParam('media_wmp6_compatible')?'05589fa1-c356-11ce-bf01-00aa0055595a':'6bf52a52-394a-11d3-b153-00c04f79faa6';cb='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';mt='application/x-mplayer2';break;case'mceItemQuickTime':ci='02bf25d5-8c17-4b23-bc80-d3488abddc6b';cb='http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0';mt='video/quicktime';break;case'mceItemRealMedia':ci='cfcdaa03-8be4-11cf-b84b-0020afbbccfa';cb='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';mt='audio/x-pn-realaudio-plugin';break;}if(ci){dom.replace(t._buildObj({classid:ci,codebase:cb,type:mt},n),n);}});}});ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/_value=/g,'value=');});if(ed.getParam('media_use_script')){function getAttr(s,n){n=new RegExp(n+'=\"([^\"]+)\"','g').exec(s);return n?ed.dom.decode(n[1]):'';};ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/<img[^>]+>/g,function(im){var cl=getAttr(im,'class');if(/^(mceTempFlash|mceTempShockWave|mceTempWindowsMedia|mceTempQuickTime|mceTempRealMedia)$/.test(cl)){at=t._parse(getAttr(im,'title'));at.width=getAttr(im,'width');at.height=getAttr(im,'height');im='<script type="text/javascript">write'+cl.substring(7)+'({'+t._serialize(at)+'});</script>';}return im;});});}},getInfo:function(){return{longname:'Media',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/media',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_buildObj:function(o,n){var ob,ed=this.editor,dom=ed.dom,p=this._parse(n.title);p.width=o.width=dom.getAttrib(n,'width')||100;p.height=o.height=dom.getAttrib(n,'height')||100;ob=dom.create('span',{mce_name:'object',classid:"clsid:"+o.classid,codebase:o.codebase,width:o.width,height:o.height});if(p.src)p.src=ed.convertURL(p.src,'src',n);each(p,function(v,k){if(!/^(width|height|codebase|classid)$/.test(k)){if(o.type=='application/x-mplayer2'&&k=='src')k='url';dom.add(ob,'span',{mce_name:'param',name:k,'_value':v});}});dom.add(ob,'span',tinymce.extend({mce_name:'embed',type:o.type},p));return ob;},_spansToImgs:function(p){var t=this,dom=t.editor.dom,im,ci;each(dom.select('span',p),function(n){if(dom.getAttrib(n,'class')=='mceItemObject'){ci=dom.getAttrib(n,"classid").toLowerCase().replace(/\s+/g,'');switch(ci){case'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000':dom.replace(t._createImg('mceItemFlash',n),n);break;case'clsid:166b1bca-3f9c-11cf-8075-444553540000':dom.replace(t._createImg('mceItemShockWave',n),n);break;case'clsid:6bf52a52-394a-11d3-b153-00c04f79faa6':case'clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95':case'clsid:05589fa1-c356-11ce-bf01-00aa0055595a':dom.replace(t._createImg('mceItemWindowsMedia',n),n);break;case'clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b':dom.replace(t._createImg('mceItemQuickTime',n),n);break;case'clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa':dom.replace(t._createImg('mceItemRealMedia',n),n);break;default:dom.replace(t._createImg('mceItemFlash',n),n);}return;}if(dom.getAttrib(n,'class')=='mceItemEmbed'){switch(dom.getAttrib(n,'type')){case'application/x-shockwave-flash':dom.replace(t._createImg('mceItemFlash',n),n);break;case'application/x-director':dom.replace(t._createImg('mceItemShockWave',n),n);break;case'application/x-mplayer2':dom.replace(t._createImg('mceItemWindowsMedia',n),n);break;case'video/quicktime':dom.replace(t._createImg('mceItemQuickTime',n),n);break;case'audio/x-pn-realaudio-plugin':dom.replace(t._createImg('mceItemRealMedia',n),n);break;default:dom.replace(t._createImg('mceItemFlash',n),n);}}});},_createImg:function(cl,n){var im,dom=this.editor.dom,pa={},ti='';im=dom.create('img',{src:this.url+'/img/trans.gif',width:dom.getAttrib(n,'width')||100,height:dom.getAttrib(n,'height')||100,'class':cl});each(['id','name','width','height','bgcolor','align','flashvars','src','wmode'],function(na){var v=dom.getAttrib(n,na);if(v)pa[na]=v;});each(dom.select('span',n),function(n){if(dom.hasClass(n,'mceItemParam'))pa[dom.getAttrib(n,'name')]=dom.getAttrib(n,'_value');});if(pa.movie){pa.src=pa.movie;delete pa.movie;}delete pa.width;delete pa.height;im.title=this._serialize(pa);return im;},_parse:function(s){return tinymce.util.JSON.parse('{'+s+'}');},_serialize:function(o){return tinymce.util.JSON.serialize(o).replace(/[{}]/g,'');}});tinymce.PluginManager.add('media',tinymce.plugins.MediaPlugin);})();
\ No newline at end of file
+(function(){var each=tinymce.each;tinymce.create('tinymce.plugins.MediaPlugin',{init:function(ed,url){var t=this;t.editor=ed;t.url=url;function isMediaElm(n){return/^(mceItemFlash|mceItemShockWave|mceItemWindowsMedia|mceItemQuickTime|mceItemRealMedia)$/.test(n.className);};ed.onPreInit.add(function(){ed.serializer.addRules('param[name|value|_mce_value]');});ed.addCommand('mceMedia',function(){ed.windowManager.open({file:url+'/media.htm',width:430+parseInt(ed.getLang('media.delta_width',0)),height:470+parseInt(ed.getLang('media.delta_height',0)),inline:1},{plugin_url:url});});ed.addButton('media',{title:'media.desc',cmd:'mceMedia'});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('media',n.nodeName=='IMG'&&isMediaElm(n));});ed.onInit.add(function(){var lo={mceItemFlash:'flash',mceItemShockWave:'shockwave',mceItemWindowsMedia:'windowsmedia',mceItemQuickTime:'quicktime',mceItemRealMedia:'realmedia'};ed.selection.onSetContent.add(function(){t._spansToImgs(ed.getBody());});ed.selection.onBeforeSetContent.add(t._objectsToSpans,t);if(ed.settings.content_css!==false)ed.dom.loadCSS(url+"/css/content.css");if(ed.theme.onResolveName){ed.theme.onResolveName.add(function(th,o){if(o.name=='img'){each(lo,function(v,k){if(ed.dom.hasClass(o.node,k)){o.name=v;o.title=ed.dom.getAttrib(o.node,'title');return false;}});}});}if(ed&&ed.plugins.contextmenu){ed.plugins.contextmenu.onContextMenu.add(function(th,m,e){if(e.nodeName=='IMG'&&/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(e.className)){m.add({title:'media.edit',icon:'media',cmd:'mceMedia'});}});}});ed.onBeforeSetContent.add(t._objectsToSpans,t);ed.onSetContent.add(function(){t._spansToImgs(ed.getBody());});ed.onPreProcess.add(function(ed,o){var dom=ed.dom;if(o.set){t._spansToImgs(o.node);each(dom.select('IMG',o.node),function(n){var p;if(isMediaElm(n)){p=t._parse(n.title);dom.setAttrib(n,'width',dom.getAttrib(n,'width',p.width||100));dom.setAttrib(n,'height',dom.getAttrib(n,'height',p.height||100));}});}if(o.get){each(dom.select('IMG',o.node),function(n){var ci,cb,mt;if(ed.getParam('media_use_script')){if(isMediaElm(n))n.className=n.className.replace(/mceItem/g,'mceTemp');return;}switch(n.className){case'mceItemFlash':ci='d27cdb6e-ae6d-11cf-96b8-444553540000';cb='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';mt='application/x-shockwave-flash';break;case'mceItemShockWave':ci='166b1bca-3f9c-11cf-8075-444553540000';cb='http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0';mt='application/x-director';break;case'mceItemWindowsMedia':ci=ed.getParam('media_wmp6_compatible')?'05589fa1-c356-11ce-bf01-00aa0055595a':'6bf52a52-394a-11d3-b153-00c04f79faa6';cb='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';mt='application/x-mplayer2';break;case'mceItemQuickTime':ci='02bf25d5-8c17-4b23-bc80-d3488abddc6b';cb='http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0';mt='video/quicktime';break;case'mceItemRealMedia':ci='cfcdaa03-8be4-11cf-b84b-0020afbbccfa';cb='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';mt='audio/x-pn-realaudio-plugin';break;}if(ci){dom.replace(t._buildObj({classid:ci,codebase:cb,type:mt},n),n);}});}});ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/_mce_value=/g,'value=');});if(ed.getParam('media_use_script')){function getAttr(s,n){n=new RegExp(n+'=\"([^\"]+)\"','g').exec(s);return n?ed.dom.decode(n[1]):'';};ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/<img[^>]+>/g,function(im){var cl=getAttr(im,'class');if(/^(mceTempFlash|mceTempShockWave|mceTempWindowsMedia|mceTempQuickTime|mceTempRealMedia)$/.test(cl)){at=t._parse(getAttr(im,'title'));at.width=getAttr(im,'width');at.height=getAttr(im,'height');im='<script type="text/javascript">write'+cl.substring(7)+'({'+t._serialize(at)+'});</script>';}return im;});});}},getInfo:function(){return{longname:'Media',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/media',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_objectsToSpans:function(ed,o){var t=this,h=o.content;h=h.replace(/<script[^>]*>\s*write(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)\(\{([^\)]*)\}\);\s*<\/script>/gi,function(a,b,c){var o=t._parse(c);return'<img class="mceItem'+b+'" title="'+ed.dom.encode(c)+'" src="'+t.url+'/img/trans.gif" width="'+o.width+'" height="'+o.height+'" />'});h=h.replace(/<object([^>]*)>/gi,'<span class="mceItemObject" $1>');h=h.replace(/<embed([^>]*)\/?>/gi,'<span class="mceItemEmbed" $1></span>');h=h.replace(/<embed([^>]*)>/gi,'<span class="mceItemEmbed" $1>');h=h.replace(/<\/(object)([^>]*)>/gi,'</span>');h=h.replace(/<\/embed>/gi,'');h=h.replace(/<param([^>]*)>/gi,function(a,b){return'<span '+b.replace(/value=/gi,'_mce_value=')+' class="mceItemParam"></span>'});h=h.replace(/\/ class=\"mceItemParam\"><\/span>/gi,'class="mceItemParam"></span>');o.content=h;},_buildObj:function(o,n){var ob,ed=this.editor,dom=ed.dom,p=this._parse(n.title),stc;stc=ed.getParam('media_strict',true)&&o.type=='application/x-shockwave-flash';p.width=o.width=dom.getAttrib(n,'width')||100;p.height=o.height=dom.getAttrib(n,'height')||100;if(p.src)p.src=ed.convertURL(p.src,'src',n);if(stc){ob=dom.create('span',{mce_name:'object',type:'application/x-shockwave-flash',data:p.src,width:o.width,height:o.height});}else{ob=dom.create('span',{mce_name:'object',classid:"clsid:"+o.classid,codebase:o.codebase,width:o.width,height:o.height});}each(p,function(v,k){if(!/^(width|height|codebase|classid|_cx|_cy)$/.test(k)){if(o.type=='application/x-mplayer2'&&k=='src')k='url';if(v)dom.add(ob,'span',{mce_name:'param',name:k,'_mce_value':v});}});if(!stc)dom.add(ob,'span',tinymce.extend({mce_name:'embed',type:o.type},p));return ob;},_spansToImgs:function(p){var t=this,dom=t.editor.dom,im,ci;each(dom.select('span',p),function(n){if(dom.getAttrib(n,'class')=='mceItemObject'){ci=dom.getAttrib(n,"classid").toLowerCase().replace(/\s+/g,'');switch(ci){case'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000':dom.replace(t._createImg('mceItemFlash',n),n);break;case'clsid:166b1bca-3f9c-11cf-8075-444553540000':dom.replace(t._createImg('mceItemShockWave',n),n);break;case'clsid:6bf52a52-394a-11d3-b153-00c04f79faa6':case'clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95':case'clsid:05589fa1-c356-11ce-bf01-00aa0055595a':dom.replace(t._createImg('mceItemWindowsMedia',n),n);break;case'clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b':dom.replace(t._createImg('mceItemQuickTime',n),n);break;case'clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa':dom.replace(t._createImg('mceItemRealMedia',n),n);break;default:dom.replace(t._createImg('mceItemFlash',n),n);}return;}if(dom.getAttrib(n,'class')=='mceItemEmbed'){switch(dom.getAttrib(n,'type')){case'application/x-shockwave-flash':dom.replace(t._createImg('mceItemFlash',n),n);break;case'application/x-director':dom.replace(t._createImg('mceItemShockWave',n),n);break;case'application/x-mplayer2':dom.replace(t._createImg('mceItemWindowsMedia',n),n);break;case'video/quicktime':dom.replace(t._createImg('mceItemQuickTime',n),n);break;case'audio/x-pn-realaudio-plugin':dom.replace(t._createImg('mceItemRealMedia',n),n);break;default:dom.replace(t._createImg('mceItemFlash',n),n);}}});},_createImg:function(cl,n){var im,dom=this.editor.dom,pa={},ti='',args;args=['id','name','width','height','bgcolor','align','flashvars','src','wmode','allowfullscreen','quality'];im=dom.create('img',{src:this.url+'/img/trans.gif',width:dom.getAttrib(n,'width')||100,height:dom.getAttrib(n,'height')||100,'class':cl});each(args,function(na){var v=dom.getAttrib(n,na);if(v)pa[na]=v;});each(dom.select('span',n),function(n){if(dom.hasClass(n,'mceItemParam'))pa[dom.getAttrib(n,'name')]=dom.getAttrib(n,'_mce_value');});if(pa.movie){pa.src=pa.movie;delete pa.movie;}n=dom.select('.mceItemEmbed',n)[0];if(n){each(args,function(na){var v=dom.getAttrib(n,na);if(v&&!pa[na])pa[na]=v;});}delete pa.width;delete pa.height;im.title=this._serialize(pa);return im;},_parse:function(s){return tinymce.util.JSON.parse('{'+s+'}');},_serialize:function(o){return tinymce.util.JSON.serialize(o).replace(/[{}]/g,'');}});tinymce.PluginManager.add('media',tinymce.plugins.MediaPlugin);})();
\ No newline at end of file
tinyMCEPopup.restoreSelection();
if (!AutoValidator.validate(f)) {
- alert(ed.getLang('invalid_data'));
+ tinyMCEPopup.alert(ed.getLang('invalid_data'));
return false;
}
d.getElementById('shockwave_options').style.display = 'none';
d.getElementById('wmp_options').style.display = 'none';
d.getElementById('rmp_options').style.display = 'none';
- d.getElementById(t + '_options').style.display = 'block';
+
+ if (t)
+ d.getElementById(t + '_options').style.display = 'block';
}
function serializeParameters() {
// Avoid annoying warning about insecure items
if (!tinymce.isIE || document.location.protocol != 'https:') {
- h += '<object classid="clsid:' + cls + '" codebase="' + codebase + '" width="' + pl.width + '" height="' + pl.height + '" id="' + pl.id + '" name="' + pl.name + '" align="' + pl.align + '">';
+ h += '<object classid="' + cls + '" codebase="' + codebase + '" width="' + pl.width + '" height="' + pl.height + '" id="' + pl.id + '" name="' + pl.name + '" align="' + pl.align + '">';
for (n in pl) {
h += '<param name="' + n + '" value="' + pl[n] + '">';
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{#media_dlg.title}</title>
- <script type="text/javascript" src="../../tiny_mce_popup.js?ver=311"></script>
- <script type="text/javascript" src="js/media.js?ver=311"></script>
- <script type="text/javascript" src="../../utils/mctabs.js?ver=311"></script>
- <script type="text/javascript" src="../../utils/validate.js?ver=311"></script>
- <script type="text/javascript" src="../../utils/form_utils.js?ver=311"></script>
- <script type="text/javascript" src="../../utils/editable_selects.js?ver=311"></script>
- <link href="css/media.css?ver=311" rel="stylesheet" type="text/css" />
+ <script type="text/javascript" src="../../tiny_mce_popup.js?ver=3211"></script>
+ <script type="text/javascript" src="js/media.js?ver=3211"></script>
+ <script type="text/javascript" src="../../utils/mctabs.js?ver=3211"></script>
+ <script type="text/javascript" src="../../utils/validate.js?ver=3211"></script>
+ <script type="text/javascript" src="../../utils/form_utils.js?ver=3211"></script>
+ <script type="text/javascript" src="../../utils/editable_selects.js?ver=3211"></script>
+ <link href="css/media.css?ver=3211" rel="stylesheet" type="text/css" />
<base target="_self" />
</head>
<body style="display: none">
<head>
<title>blank_page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link href="css/blank.css?ver=311" rel="stylesheet" type="text/css" />
+<link href="css/blank.css?ver=3211" rel="stylesheet" type="text/css" />
<base target="_self" />
<script type="text/javascript">
function init() {
-(function(){var Event=tinymce.dom.Event;tinymce.create('tinymce.plugins.PastePlugin',{init:function(ed,url){var t=this;t.editor=ed;ed.addCommand('mcePasteText',function(ui,v){if(ui){if((ed.getParam('paste_use_dialog',true))||(!tinymce.isIE)){ed.windowManager.open({file:url+'/pastetext.htm',width:450,height:400,inline:1},{plugin_url:url});}else t._insertText(clipboardData.getData("Text"),true);}else t._insertText(v.html,v.linebreaks);});ed.addCommand('mcePasteWord',function(ui,v){if(ui){if((ed.getParam('paste_use_dialog',true))||(!tinymce.isIE)){ed.windowManager.open({file:url+'/pasteword.htm',width:450,height:400,inline:1},{plugin_url:url});}else t._insertText(t._clipboardHTML());}else t._insertWordContent(v);});ed.addCommand('mceSelectAll',function(){ed.execCommand('selectall');});ed.addButton('pastetext',{title:'paste.paste_text_desc',cmd:'mcePasteText',ui:true});ed.addButton('pasteword',{title:'paste.paste_word_desc',cmd:'mcePasteWord',ui:true});ed.addButton('selectall',{title:'paste.selectall_desc',cmd:'mceSelectAll'});if(ed.getParam("paste_auto_cleanup_on_paste",false)){ed.onPaste.add(function(ed,e){return t._handlePasteEvent(e)});}if(!tinymce.isIE&&ed.getParam("paste_auto_cleanup_on_paste",false)){ed.onKeyDown.add(function(ed,e){if(e.ctrlKey&&e.keyCode==86){window.setTimeout(function(){ed.execCommand("mcePasteText",true);},1);Event.cancel(e);}});}},getInfo:function(){return{longname:'Paste text/word',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_handlePasteEvent:function(e){var html=this._clipboardHTML(),ed=this.editor,sel=ed.selection,r;if(ed&&(r=sel.getRng())&&r.text.length>0)ed.execCommand('delete');if(html&&html.length>0)ed.execCommand('mcePasteWord',false,html);return Event.cancel(e);},_insertText:function(content,bLinebreaks){content=this.editor.dom.encode(content);if(content&&content.length>0){if(bLinebreaks){if(this.editor.getParam("paste_create_paragraphs",true)){var rl=this.editor.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);content=content.replace(/\r\n\r\n/g,'</p><p>');content=content.replace(/\r\r/g,'</p><p>');content=content.replace(/\n\n/g,'</p><p>');if((pos=content.indexOf('</p><p>'))!=-1){this.editor.execCommand("Delete");var node=this.editor.selection.getNode();var breakElms=[];do{if(node.nodeType==1){if(node.nodeName=="TD"||node.nodeName=="BODY")break;breakElms[breakElms.length]=node;}}while(node=node.parentNode);var before="",after="</p>";before+=content.substring(0,pos);for(var i=0;i<breakElms.length;i++){before+="</"+breakElms[i].nodeName+">";after+="<"+breakElms[(breakElms.length-1)-i].nodeName+">";}before+="<p>";content=before+content.substring(pos+7)+after;}}if(this.editor.getParam("paste_create_linebreaks",true)){content=content.replace(/\r\n/g,'<br />');content=content.replace(/\r/g,'<br />');content=content.replace(/\n/g,'<br />');}}this.editor.execCommand("mceInsertRawHTML",false,content);}},_insertWordContent:function(content){var t=this,ed=t.editor;if(content&&content.length>0){var bull=String.fromCharCode(8226);var middot=String.fromCharCode(183);if(ed.getParam('paste_insert_word_content_callback'))content=ed.execCallback('paste_insert_word_content_callback','before',content);var rl=ed.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);if(this.editor.getParam("paste_convert_headers_to_strong",false)){content=content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>','gi'),'<p><b>$1</b></p>');}content=content.replace(new RegExp('tab-stops: list [0-9]+.0pt">','gi'),'">'+"--list--");content=content.replace(new RegExp(bull+"(.*?)<BR>","gi"),"<p>"+middot+"$1</p>");content=content.replace(new RegExp('<SPAN style="mso-list: Ignore">','gi'),"<span>"+bull);content=content.replace(/<o:p><\/o:p>/gi,"");content=content.replace(new RegExp('<br style="page-break-before: always;.*>','gi'),'-- page break --');content=content.replace(new RegExp('<(!--)([^>]*)(--)>','g'),"");if(this.editor.getParam("paste_remove_spans",true))content=content.replace(/<\/?span[^>]*>/gi,"");if(this.editor.getParam("paste_remove_styles",true))content=content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)','gi'),"<$1$3");content=content.replace(/<\/?font[^>]*>/gi,"");switch(this.editor.getParam("paste_strip_class_attributes","all")){case"all":content=content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");break;case"mso":content=content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)','gi'),"<$1$3");break;}content=content.replace(new RegExp('href="?'+this._reEscape(""+document.location)+'','gi'),'href="'+this.editor.documentBaseURI.getURI());content=content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");content=content.replace(/<\\?\?xml[^>]*>/gi,"");content=content.replace(/<\/?\w+:[^>]*>/gi,"");content=content.replace(/-- page break --\s*<p> <\/p>/gi,"");content=content.replace(/-- page break --/gi,"");if(!this.editor.getParam('force_p_newlines')){content=content.replace('','','gi');content=content.replace('</p>','<br /><br />','gi');}if(!tinymce.isIE&&!this.editor.getParam('force_p_newlines')){content=content.replace(/<\/?p[^>]*>/gi,"");}content=content.replace(/<\/?div[^>]*>/gi,"");if(this.editor.getParam("paste_convert_middot_lists",true)){var div=ed.dom.create("div",null,content);var className=this.editor.getParam("paste_unindented_list_class","unIndentedList");while(this._convertMiddots(div,"--list--"));while(this._convertMiddots(div,middot,className));while(this._convertMiddots(div,bull));content=div.innerHTML;}if(this.editor.getParam("paste_convert_headers_to_strong",false)){content=content.replace(/<h[1-6]> <\/h[1-6]>/gi,'<p> </p>');content=content.replace(/<h[1-6]>/gi,'<p><b>');content=content.replace(/<\/h[1-6]>/gi,'</b></p>');content=content.replace(/<b> <\/b>/gi,'<b> </b>');content=content.replace(/^( )*/gi,'');}content=content.replace(/--list--/gi,"");if(ed.getParam('paste_insert_word_content_callback'))content=ed.execCallback('paste_insert_word_content_callback','after',content);this.editor.execCommand("mceInsertContent",false,content);if(this.editor.getParam('paste_force_cleanup_wordpaste',true)){var ed=this.editor;window.setTimeout(function(){ed.execCommand("mceCleanup");},1);}}},_reEscape:function(s){var l="?.\\*[](){}+^$:";var o="";for(var i=0;i<s.length;i++){var c=s.charAt(i);if(l.indexOf(c)!=-1)o+='\\'+c;else o+=c;}return o;},_convertMiddots:function(div,search,class_name){var ed=this.editor,mdot=String.fromCharCode(183),bull=String.fromCharCode(8226);var nodes,prevul,i,p,ul,li,np,cp,li;nodes=div.getElementsByTagName("p");for(i=0;i<nodes.length;i++){p=nodes[i];if(p.innerHTML.indexOf(search)==0){ul=ed.dom.create("ul");if(class_name)ul.className=class_name;li=ed.dom.create("li");li.innerHTML=p.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--| ',"gi"),'');ul.appendChild(li);np=p.nextSibling;while(np){if(np.nodeType==3&&new RegExp('^\\s$','m').test(np.nodeValue)){np=np.nextSibling;continue;}if(search==mdot){if(np.nodeType==1&&new RegExp('^o(\\s+| )').test(np.innerHTML)){if(!prevul){prevul=ul;ul=ed.dom.create("ul");prevul.appendChild(ul);}np.innerHTML=np.innerHTML.replace(/^o/,'');}else{if(prevul){ul=prevul;prevul=null;}if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}}else{if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}cp=np.nextSibling;li=ed.dom.create("li");li.innerHTML=np.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--| ',"gi"),'');np.parentNode.removeChild(np);ul.appendChild(li);np=cp;}p.parentNode.replaceChild(ul,p);return true;}}return false;},_clipboardHTML:function(){var div=document.getElementById('_TinyMCE_clipboardHTML');if(!div){var div=document.createElement('DIV');div.id='_TinyMCE_clipboardHTML';with(div.style){visibility='hidden';overflow='hidden';position='absolute';width=1;height=1;}document.body.appendChild(div);}div.innerHTML='';var rng=document.body.createTextRange();rng.moveToElementText(div);rng.execCommand('Paste');var html=div.innerHTML;div.innerHTML='';return html;}});tinymce.PluginManager.add('paste',tinymce.plugins.PastePlugin);})();
\ No newline at end of file
+(function(){var Event=tinymce.dom.Event;tinymce.create('tinymce.plugins.PastePlugin',{init:function(ed,url){var t=this;t.editor=ed;ed.addCommand('mcePasteText',function(ui,v){if(ui){if((ed.getParam('paste_use_dialog',true))||(!tinymce.isIE)){ed.windowManager.open({file:url+'/pastetext.htm',width:450,height:400,inline:1},{plugin_url:url});}else t._insertText(clipboardData.getData("Text"),true);}else t._insertText(v.html,v.linebreaks);});ed.addCommand('mcePasteWord',function(ui,v){if(ui){if((ed.getParam('paste_use_dialog',true))||(!tinymce.isIE)){ed.windowManager.open({file:url+'/pasteword.htm',width:450,height:400,inline:1},{plugin_url:url});}else t._insertText(t._clipboardHTML());}else t._insertWordContent(v);});ed.addCommand('mceSelectAll',function(){ed.execCommand('selectall');});ed.addButton('pastetext',{title:'paste.paste_text_desc',cmd:'mcePasteText',ui:true});ed.addButton('pasteword',{title:'paste.paste_word_desc',cmd:'mcePasteWord',ui:true});ed.addButton('selectall',{title:'paste.selectall_desc',cmd:'mceSelectAll'});if(ed.getParam("paste_auto_cleanup_on_paste",false)){ed.onPaste.add(function(ed,e){return t._handlePasteEvent(e)});}if(!tinymce.isIE&&ed.getParam("paste_auto_cleanup_on_paste",false)){ed.onKeyDown.add(function(ed,e){if(e.ctrlKey&&e.keyCode==86){window.setTimeout(function(){ed.execCommand("mcePasteText",true);},1);Event.cancel(e);}});}},getInfo:function(){return{longname:'Paste text/word',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_handlePasteEvent:function(e){var html=this._clipboardHTML(),ed=this.editor,sel=ed.selection,r;if(ed&&(r=sel.getRng())&&r.text.length>0)ed.execCommand('delete');if(html&&html.length>0)ed.execCommand('mcePasteWord',false,html);return Event.cancel(e);},_insertText:function(content,bLinebreaks){content=this.editor.dom.encode(content);if(content&&content.length>0){if(!this.editor.selection.isCollapsed())this.editor.execCommand("Delete");if(bLinebreaks){if(this.editor.getParam("paste_create_paragraphs",true)){var rl=this.editor.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);content=content.replace(/\r\n\r\n/g,'</p><p>');content=content.replace(/\r\r/g,'</p><p>');content=content.replace(/\n\n/g,'</p><p>');if((pos=content.indexOf('</p><p>'))!=-1){this.editor.execCommand("Delete");var node=this.editor.selection.getNode();var breakElms=[];do{if(node.nodeType==1){if(node.nodeName=="TD"||node.nodeName=="BODY")break;breakElms[breakElms.length]=node;}}while(node=node.parentNode);var before="",after="</p>";before+=content.substring(0,pos);for(var i=0;i<breakElms.length;i++){before+="</"+breakElms[i].nodeName+">";after+="<"+breakElms[(breakElms.length-1)-i].nodeName+">";}before+="<p>";content=before+content.substring(pos+7)+after;}}if(this.editor.getParam("paste_create_linebreaks",true)){content=content.replace(/\r\n/g,'<br />');content=content.replace(/\r/g,'<br />');content=content.replace(/\n/g,'<br />');}}this.editor.execCommand("mceInsertRawHTML",false,content);}},_insertWordContent:function(content){var t=this,ed=t.editor;if(content&&content.length>0){var bull=String.fromCharCode(8226);var middot=String.fromCharCode(183);if(ed.getParam('paste_insert_word_content_callback'))content=ed.execCallback('paste_insert_word_content_callback','before',content);var rl=ed.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\x93|\x94|\u201c|\u201d,",\x60|\x91|\x92|\u2018|\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);if(this.editor.getParam("paste_convert_headers_to_strong",false)){content=content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>','gi'),'<p><b>$1</b></p>');}content=content.replace(new RegExp('tab-stops: list [0-9]+.0pt">','gi'),'">'+"--list--");content=content.replace(new RegExp(bull+"(.*?)<BR>","gi"),"<p>"+middot+"$1</p>");content=content.replace(new RegExp('<SPAN style="mso-list: Ignore">','gi'),"<span>"+bull);content=content.replace(/<o:p><\/o:p>/gi,"");content=content.replace(new RegExp('<br style="page-break-before: always;.*>','gi'),'-- page break --');content=content.replace(/<!--([\s\S]*?)-->|<style>[\s\S]*?<\/style>/g,"");content=content.replace(/<(meta|link)[^>]+>/g,"");if(this.editor.getParam("paste_remove_spans",true))content=content.replace(/<\/?span[^>]*>/gi,"");if(this.editor.getParam("paste_remove_styles",true))content=content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)','gi'),"<$1$3");content=content.replace(/<\/?font[^>]*>/gi,"");switch(this.editor.getParam("paste_strip_class_attributes","all")){case"all":content=content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");break;case"mso":content=content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)','gi'),"<$1$3");break;}content=content.replace(new RegExp('href="?'+this._reEscape(""+document.location)+'','gi'),'href="'+this.editor.documentBaseURI.getURI());content=content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");content=content.replace(/<\\?\?xml[^>]*>/gi,"");content=content.replace(/<\/?\w+:[^>]*>/gi,"");content=content.replace(/-- page break --\s*<p> <\/p>/gi,"");content=content.replace(/-- page break --/gi,"");if(!this.editor.getParam('force_p_newlines')){content=content.replace('','','gi');content=content.replace('</p>','<br /><br />','gi');}if(!tinymce.isIE&&!this.editor.getParam('force_p_newlines')){content=content.replace(/<\/?p[^>]*>/gi,"");}content=content.replace(/<\/?div[^>]*>/gi,"");if(this.editor.getParam("paste_convert_middot_lists",true)){var div=ed.dom.create("div",null,content);var className=this.editor.getParam("paste_unindented_list_class","unIndentedList");while(this._convertMiddots(div,"--list--"));while(this._convertMiddots(div,middot,className));while(this._convertMiddots(div,bull));content=div.innerHTML;}if(this.editor.getParam("paste_convert_headers_to_strong",false)){content=content.replace(/<h[1-6]> <\/h[1-6]>/gi,'<p> </p>');content=content.replace(/<h[1-6]>/gi,'<p><b>');content=content.replace(/<\/h[1-6]>/gi,'</b></p>');content=content.replace(/<b> <\/b>/gi,'<b> </b>');content=content.replace(/^( )*/gi,'');}content=content.replace(/--list--/gi,"");if(ed.getParam('paste_insert_word_content_callback'))content=ed.execCallback('paste_insert_word_content_callback','after',content);this.editor.execCommand("mceInsertContent",false,content);if(this.editor.getParam('paste_force_cleanup_wordpaste',true)){var ed=this.editor;window.setTimeout(function(){ed.execCommand("mceCleanup");},1);}}},_reEscape:function(s){var l="?.\\*[](){}+^$:";var o="";for(var i=0;i<s.length;i++){var c=s.charAt(i);if(l.indexOf(c)!=-1)o+='\\'+c;else o+=c;}return o;},_convertMiddots:function(div,search,class_name){var ed=this.editor,mdot=String.fromCharCode(183),bull=String.fromCharCode(8226);var nodes,prevul,i,p,ul,li,np,cp,li;nodes=div.getElementsByTagName("p");for(i=0;i<nodes.length;i++){p=nodes[i];if(p.innerHTML.indexOf(search)==0){ul=ed.dom.create("ul");if(class_name)ul.className=class_name;li=ed.dom.create("li");li.innerHTML=p.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--| ',"gi"),'');ul.appendChild(li);np=p.nextSibling;while(np){if(np.nodeType==3&&new RegExp('^\\s$','m').test(np.nodeValue)){np=np.nextSibling;continue;}if(search==mdot){if(np.nodeType==1&&new RegExp('^o(\\s+| )').test(np.innerHTML)){if(!prevul){prevul=ul;ul=ed.dom.create("ul");prevul.appendChild(ul);}np.innerHTML=np.innerHTML.replace(/^o/,'');}else{if(prevul){ul=prevul;prevul=null;}if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}}else{if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}cp=np.nextSibling;li=ed.dom.create("li");li.innerHTML=np.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--| ',"gi"),'');np.parentNode.removeChild(np);ul.appendChild(li);np=cp;}p.parentNode.replaceChild(ul,p);return true;}}return false;},_clipboardHTML:function(){var div=document.getElementById('_TinyMCE_clipboardHTML');if(!div){var div=document.createElement('DIV');div.id='_TinyMCE_clipboardHTML';with(div.style){visibility='hidden';overflow='hidden';position='absolute';width=1;height=1;}document.body.appendChild(div);}div.innerHTML='';var rng=document.body.createTextRange();rng.moveToElementText(div);rng.execCommand('Paste');var html=div.innerHTML;div.innerHTML='';return html;}});tinymce.PluginManager.add('paste',tinymce.plugins.PastePlugin);})();
\ No newline at end of file
<head>
<title>{#paste.paste_text_desc}</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <script type="text/javascript" src="../../tiny_mce_popup.js?ver=311"></script>
- <script type="text/javascript" src="js/pastetext.js?ver=311"></script>
+ <script type="text/javascript" src="../../tiny_mce_popup.js?ver=3211"></script>
+ <script type="text/javascript" src="js/pastetext.js?ver=3211"></script>
<base target="_self" />
</head>
<body onresize="resizeInputs();" style="display:none; overflow:hidden;">
</div>
</form>
</body>
-</html>
\ No newline at end of file
+</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>{#paste.paste_word_desc}</title>
- <script type="text/javascript" src="../../tiny_mce_popup.js?ver=311"></script>
- <script type="text/javascript" src="js/pasteword.js?ver=311"></script>
- <link href="css/pasteword.css?ver=311" rel="stylesheet" type="text/css" />
+ <script type="text/javascript" src="../../tiny_mce_popup.js?ver=3211"></script>
+ <script type="text/javascript" src="js/pasteword.js?ver=3211"></script>
+ <link href="css/pasteword.css?ver=3211" rel="stylesheet" type="text/css" />
<base target="_self" />
</head>
<body onresize="resizeInputs();" style="display:none; overflow:hidden;">
-(function(){var Event=tinymce.dom.Event,grep=tinymce.grep,each=tinymce.each,inArray=tinymce.inArray,isOldWebKit=tinymce.isOldWebKit;tinymce.create('tinymce.plugins.Safari',{init:function(ed){var t=this,dom;if(!tinymce.isWebKit)return;t.editor=ed;t.webKitFontSizes=['x-small','small','medium','large','x-large','xx-large','-webkit-xxx-large'];t.namedFontSizes=['xx-small','x-small','small','medium','large','x-large','xx-large'];ed.addCommand('CreateLink',function(u,v){var n=ed.selection.getNode(),dom=ed.dom,a;if(n&&(/^(left|right)$/i.test(dom.getStyle(n,'float',1))||/^(left|right)$/i.test(dom.getAttrib(n,'align')))){a=dom.create('a',{href:v},n.cloneNode());n.parentNode.replaceChild(a,n);ed.selection.select(a);}else ed.getDoc().execCommand("CreateLink",false,v);});ed.onPaste.add(function(ed,e){function removeStyles(e){e=e.target;if(e.nodeType==1){e.style.cssText='';each(ed.dom.select('*',e),function(e){e.style.cssText='';});}};Event.add(ed.getDoc(),'DOMNodeInserted',removeStyles);window.setTimeout(function(){Event.remove(ed.getDoc(),'DOMNodeInserted',removeStyles);},0);});ed.onKeyUp.add(function(ed,e){var h,b;if(e.keyCode==46||e.keyCode==8){b=ed.getBody();h=b.innerHTML;if(b.childNodes.length==1&&!/<(img|hr)/.test(h)&&tinymce.trim(h.replace(/<[^>]+>/g,'')).length==0)ed.setContent('',{format:'raw'});}});ed.addCommand('FormatBlock',function(u,v){var dom=ed.dom,e=dom.getParent(ed.selection.getNode(),dom.isBlock);if(e)dom.replace(dom.create(v),e,1);else ed.getDoc().execCommand("FormatBlock",false,v);});ed.addCommand('mceInsertContent',function(u,v){ed.getDoc().execCommand("InsertText",false,'mce_marker');ed.getBody().innerHTML=ed.getBody().innerHTML.replace(/mce_marker/g,v+'<span id="_mce_tmp">XX</span>');ed.selection.select(ed.dom.get('_mce_tmp'));ed.getDoc().execCommand("Delete",false,' ');});ed.onKeyPress.add(function(ed,e){if(e.keyCode==13&&(e.shiftKey||ed.settings.force_br_newlines&&ed.selection.getNode().nodeName!='LI')){t._insertBR(ed);Event.cancel(e);}});ed.addQueryValueHandler('FontSize',function(u,v){var e,v;if((e=ed.dom.getParent(ed.selection.getStart(),'span'))&&(v=e.style.fontSize))return tinymce.inArray(t.namedFontSizes,v)+1;if((e=ed.dom.getParent(ed.selection.getEnd(),'span'))&&(v=e.style.fontSize))return tinymce.inArray(t.namedFontSizes,v)+1;return ed.getDoc().queryCommandValue('FontSize');});ed.addQueryValueHandler('FontName',function(u,v){var e,v;if((e=ed.dom.getParent(ed.selection.getStart(),'span'))&&(v=e.style.fontFamily))return v.replace(/, /g,',');if((e=ed.dom.getParent(ed.selection.getEnd(),'span'))&&(v=e.style.fontFamily))return v.replace(/, /g,',');return ed.getDoc().queryCommandValue('FontName');});ed.onClick.add(function(ed,e){e=e.target;if(e.nodeName=='IMG'){t.selElm=e;ed.selection.select(e);}else t.selElm=null;});ed.onInit.add(function(){t._fixWebKitSpans();if(isOldWebKit)t._patchSafari2x(ed);});ed.onSetContent.add(function(){dom=ed.dom;each(['strong','b','em','u','strike','sub','sup','a'],function(v){each(grep(dom.select(v)).reverse(),function(n){var nn=n.nodeName.toLowerCase(),st;if(nn=='a'){if(n.name)dom.replace(dom.create('img',{mce_name:'a',name:n.name,'class':'mceItemAnchor'}),n);return;}switch(nn){case'b':case'strong':if(nn=='b')nn='strong';st='font-weight: bold;';break;case'em':st='font-style: italic;';break;case'u':st='text-decoration: underline;';break;case'sub':st='vertical-align: sub;';break;case'sup':st='vertical-align: super;';break;case'strike':st='text-decoration: line-through;';break;}dom.replace(dom.create('span',{mce_name:nn,style:st,'class':'Apple-style-span'}),n,1);});});});ed.onPreProcess.add(function(ed,o){dom=ed.dom;each(grep(o.node.getElementsByTagName('span')).reverse(),function(n){var v,bg;if(o.get){if(dom.hasClass(n,'Apple-style-span')){bg=n.style.backgroundColor;switch(dom.getAttrib(n,'mce_name')){case'font':if(!ed.settings.convert_fonts_to_spans)dom.setAttrib(n,'style','');break;case'strong':case'em':case'sub':case'sup':dom.setAttrib(n,'style','');break;case'strike':case'u':if(!ed.settings.inline_styles)dom.setAttrib(n,'style','');else dom.setAttrib(n,'mce_name','');break;default:if(!ed.settings.inline_styles)dom.setAttrib(n,'style','');}if(bg)n.style.backgroundColor=bg;}}if(dom.hasClass(n,'mceItemRemoved'))dom.remove(n,1);});});ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/<br \/><\/(h[1-6]|div|p|address|pre)>/g,'</$1>');o.content=o.content.replace(/ id=\"undefined\"/g,'');});},getInfo:function(){return{longname:'Safari compatibility',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/safari',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_fixWebKitSpans:function(){var t=this,ed=t.editor;if(!isOldWebKit){Event.add(ed.getDoc(),'DOMNodeInserted',function(e){e=e.target;if(e&&e.nodeType==1)t._fixAppleSpan(e);});}else{ed.onExecCommand.add(function(){each(ed.dom.select('span'),function(n){t._fixAppleSpan(n);});ed.nodeChanged();});}},_fixAppleSpan:function(e){var ed=this.editor,dom=ed.dom,fz=this.webKitFontSizes,fzn=this.namedFontSizes,s=ed.settings,st,p;if(dom.getAttrib(e,'mce_fixed'))return;if(e.nodeName=='SPAN'&&e.className=='Apple-style-span'){st=e.style;if(!s.convert_fonts_to_spans){if(st.fontSize){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'size',inArray(fz,st.fontSize)+1);}if(st.fontFamily){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'face',st.fontFamily);}if(st.color){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'color',dom.toHex(st.color));}if(st.backgroundColor){dom.setAttrib(e,'mce_name','font');dom.setStyle(e,'background-color',st.backgroundColor);}}else{if(st.fontSize)dom.setStyle(e,'fontSize',fzn[inArray(fz,st.fontSize)]);}if(st.fontWeight=='bold')dom.setAttrib(e,'mce_name','strong');if(st.fontStyle=='italic')dom.setAttrib(e,'mce_name','em');if(st.textDecoration=='underline')dom.setAttrib(e,'mce_name','u');if(st.textDecoration=='line-through')dom.setAttrib(e,'mce_name','strike');if(st.verticalAlign=='super')dom.setAttrib(e,'mce_name','sup');if(st.verticalAlign=='sub')dom.setAttrib(e,'mce_name','sub');dom.setAttrib(e,'mce_fixed','1');}},_patchSafari2x:function(ed){var t=this,setContent,getNode,dom=ed.dom,lr;if(ed.windowManager.onBeforeOpen){ed.windowManager.onBeforeOpen.add(function(){r=ed.selection.getRng();});}ed.selection.select=function(n){this.getSel().setBaseAndExtent(n,0,n,1);};getNode=ed.selection.getNode;ed.selection.getNode=function(){return t.selElm||getNode.call(this);};ed.selection.getRng=function(){var t=this,s=t.getSel(),d=ed.getDoc(),r,rb,ra,di;if(s.anchorNode){r=d.createRange();try{rb=d.createRange();rb.setStart(s.anchorNode,s.anchorOffset);rb.collapse(1);ra=d.createRange();ra.setStart(s.focusNode,s.focusOffset);ra.collapse(1);di=rb.compareBoundaryPoints(rb.START_TO_END,ra)<0;r.setStart(di?s.anchorNode:s.focusNode,di?s.anchorOffset:s.focusOffset);r.setEnd(di?s.focusNode:s.anchorNode,di?s.focusOffset:s.anchorOffset);lr=r;}catch(ex){}}return r||lr;};setContent=ed.selection.setContent;ed.selection.setContent=function(h,s){var r=this.getRng(),b;try{setContent.call(this,h,s);}catch(ex){b=dom.create('body');b.innerHTML=h;each(b.childNodes,function(n){r.insertNode(n.cloneNode(true));});}};},_insertBR:function(ed){var dom=ed.dom,s=ed.selection,r=s.getRng(),br;r.insertNode(br=dom.create('br'));r.setStartAfter(br);r.setEndAfter(br);s.setRng(r);if(s.getSel().focusNode==br.previousSibling){s.select(dom.insertAfter(dom.doc.createTextNode('\u00a0'),br));s.collapse(1);}ed.getWin().scrollTo(0,dom.getPos(s.getRng().startContainer).y);}});tinymce.PluginManager.add('safari',tinymce.plugins.Safari);})();
\ No newline at end of file
+(function(){var Event=tinymce.dom.Event,grep=tinymce.grep,each=tinymce.each,inArray=tinymce.inArray,isOldWebKit=tinymce.isOldWebKit;function isEmpty(d,e,f){var w,n;w=d.createTreeWalker(e,NodeFilter.SHOW_ALL,null,false);while(n=w.nextNode()){if(f){if(!f(n))return false;}if(n.nodeType==3&&n.nodeValue&&/[^\s\u00a0]+/.test(n.nodeValue))return false;if(n.nodeType==1&&/^(HR|IMG|TABLE)$/.test(n.nodeName))return false;}return true;};tinymce.create('tinymce.plugins.Safari',{init:function(ed){var t=this,dom;if(!tinymce.isWebKit)return;t.editor=ed;t.webKitFontSizes=['x-small','small','medium','large','x-large','xx-large','-webkit-xxx-large'];t.namedFontSizes=['xx-small','x-small','small','medium','large','x-large','xx-large'];ed.addCommand('CreateLink',function(u,v){var n=ed.selection.getNode(),dom=ed.dom,a;if(n&&(/^(left|right)$/i.test(dom.getStyle(n,'float',1))||/^(left|right)$/i.test(dom.getAttrib(n,'align')))){a=dom.create('a',{href:v},n.cloneNode());n.parentNode.replaceChild(a,n);ed.selection.select(a);}else ed.getDoc().execCommand("CreateLink",false,v);});ed.onPaste.add(function(ed,e){function removeStyles(e){e=e.target;if(e.nodeType==1){e.style.cssText='';each(ed.dom.select('*',e),function(e){e.style.cssText='';});}};Event.add(ed.getDoc(),'DOMNodeInserted',removeStyles);window.setTimeout(function(){Event.remove(ed.getDoc(),'DOMNodeInserted',removeStyles);},0);});ed.onKeyUp.add(function(ed,e){var h,b,r,n,s;if(e.keyCode==46||e.keyCode==8){b=ed.getBody();h=b.innerHTML;s=ed.selection;if(b.childNodes.length==1&&!/<(img|hr)/.test(h)&&tinymce.trim(h.replace(/<[^>]+>/g,'')).length==0){ed.setContent('<p><br mce_bogus="1" /></p>',{format:'raw'});n=b.firstChild;r=s.getRng();r.setStart(n,0);r.setEnd(n,0);s.setRng(r);}}});ed.addCommand('FormatBlock',function(u,v){var dom=ed.dom,e=dom.getParent(ed.selection.getNode(),dom.isBlock);if(e)dom.replace(dom.create(v),e,1);else ed.getDoc().execCommand("FormatBlock",false,v);});ed.addCommand('mceInsertContent',function(u,v){ed.getDoc().execCommand("InsertText",false,'mce_marker');ed.getBody().innerHTML=ed.getBody().innerHTML.replace(/mce_marker/g,ed.dom.processHTML(v)+'<span id="_mce_tmp">XX</span>');ed.selection.select(ed.dom.get('_mce_tmp'));ed.getDoc().execCommand("Delete",false,' ');});ed.onKeyPress.add(function(ed,e){var se,li,lic,r1,r2,n,sel,doc,be,af,pa;if(e.keyCode==13){sel=ed.selection;se=sel.getNode();if(e.shiftKey||ed.settings.force_br_newlines&&se.nodeName!='LI'){t._insertBR(ed);Event.cancel(e);}if(li=dom.getParent(se,'LI')){lic=dom.getParent(li,'OL,UL');doc=ed.getDoc();pa=dom.create('p');dom.add(pa,'br',{mce_bogus:"1"});if(isEmpty(doc,li)){if(n=dom.getParent(lic.parentNode,'LI,OL,UL'))return;n=dom.getParent(lic,'p,h1,h2,h3,h4,h5,h6,div')||lic;r1=doc.createRange();r1.setStartBefore(n);r1.setEndBefore(li);r2=doc.createRange();r2.setStartAfter(li);r2.setEndAfter(n);be=r1.cloneContents();af=r2.cloneContents();if(!isEmpty(doc,af))dom.insertAfter(af,n);dom.insertAfter(pa,n);if(!isEmpty(doc,be))dom.insertAfter(be,n);dom.remove(n);n=pa.firstChild;r1=doc.createRange();r1.setStartBefore(n);r1.setEndBefore(n);sel.setRng(r1);return Event.cancel(e);}}}});ed.onExecCommand.add(function(ed,cmd){var sel,dom,bl,bm;if(cmd=='InsertUnorderedList'||cmd=='InsertOrderedList'){sel=ed.selection;dom=ed.dom;if(bl=dom.getParent(sel.getNode(),function(n){return/^(H[1-6]|P|ADDRESS|PRE)$/.test(n.nodeName);})){bm=sel.getBookmark();dom.remove(bl,1);sel.moveToBookmark(bm);}}});ed.onClick.add(function(ed,e){e=e.target;if(e.nodeName=='IMG'){t.selElm=e;ed.selection.select(e);}else t.selElm=null;});ed.onInit.add(function(){t._fixWebKitSpans();if(isOldWebKit)t._patchSafari2x(ed);});ed.onSetContent.add(function(){dom=ed.dom;each(['strong','b','em','u','strike','sub','sup','a'],function(v){each(grep(dom.select(v)).reverse(),function(n){var nn=n.nodeName.toLowerCase(),st;if(nn=='a'){if(n.name)dom.replace(dom.create('img',{mce_name:'a',name:n.name,'class':'mceItemAnchor'}),n);return;}switch(nn){case'b':case'strong':if(nn=='b')nn='strong';st='font-weight: bold;';break;case'em':st='font-style: italic;';break;case'u':st='text-decoration: underline;';break;case'sub':st='vertical-align: sub;';break;case'sup':st='vertical-align: super;';break;case'strike':st='text-decoration: line-through;';break;}dom.replace(dom.create('span',{mce_name:nn,style:st,'class':'Apple-style-span'}),n,1);});});});ed.onPreProcess.add(function(ed,o){dom=ed.dom;each(grep(o.node.getElementsByTagName('span')).reverse(),function(n){var v,bg;if(o.get){if(dom.hasClass(n,'Apple-style-span')){bg=n.style.backgroundColor;switch(dom.getAttrib(n,'mce_name')){case'font':if(!ed.settings.convert_fonts_to_spans)dom.setAttrib(n,'style','');break;case'strong':case'em':case'sub':case'sup':dom.setAttrib(n,'style','');break;case'strike':case'u':if(!ed.settings.inline_styles)dom.setAttrib(n,'style','');else dom.setAttrib(n,'mce_name','');break;default:if(!ed.settings.inline_styles)dom.setAttrib(n,'style','');}if(bg)n.style.backgroundColor=bg;}}if(dom.hasClass(n,'mceItemRemoved'))dom.remove(n,1);});});ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/<br \/><\/(h[1-6]|div|p|address|pre)>/g,'</$1>');o.content=o.content.replace(/ id=\"undefined\"/g,'');});},getInfo:function(){return{longname:'Safari compatibility',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/safari',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_fixWebKitSpans:function(){var t=this,ed=t.editor;if(!isOldWebKit){Event.add(ed.getDoc(),'DOMNodeInserted',function(e){e=e.target;if(e&&e.nodeType==1)t._fixAppleSpan(e);});}else{ed.onExecCommand.add(function(){each(ed.dom.select('span'),function(n){t._fixAppleSpan(n);});ed.nodeChanged();});}},_fixAppleSpan:function(e){var ed=this.editor,dom=ed.dom,fz=this.webKitFontSizes,fzn=this.namedFontSizes,s=ed.settings,st,p;if(dom.getAttrib(e,'mce_fixed'))return;if(e.nodeName=='SPAN'&&e.className=='Apple-style-span'){st=e.style;if(!s.convert_fonts_to_spans){if(st.fontSize){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'size',inArray(fz,st.fontSize)+1);}if(st.fontFamily){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'face',st.fontFamily);}if(st.color){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'color',dom.toHex(st.color));}if(st.backgroundColor){dom.setAttrib(e,'mce_name','font');dom.setStyle(e,'background-color',st.backgroundColor);}}else{if(st.fontSize)dom.setStyle(e,'fontSize',fzn[inArray(fz,st.fontSize)]);}if(st.fontWeight=='bold')dom.setAttrib(e,'mce_name','strong');if(st.fontStyle=='italic')dom.setAttrib(e,'mce_name','em');if(st.textDecoration=='underline')dom.setAttrib(e,'mce_name','u');if(st.textDecoration=='line-through')dom.setAttrib(e,'mce_name','strike');if(st.verticalAlign=='super')dom.setAttrib(e,'mce_name','sup');if(st.verticalAlign=='sub')dom.setAttrib(e,'mce_name','sub');dom.setAttrib(e,'mce_fixed','1');}},_patchSafari2x:function(ed){var t=this,setContent,getNode,dom=ed.dom,lr;if(ed.windowManager.onBeforeOpen){ed.windowManager.onBeforeOpen.add(function(){r=ed.selection.getRng();});}ed.selection.select=function(n){this.getSel().setBaseAndExtent(n,0,n,1);};getNode=ed.selection.getNode;ed.selection.getNode=function(){return t.selElm||getNode.call(this);};ed.selection.getRng=function(){var t=this,s=t.getSel(),d=ed.getDoc(),r,rb,ra,di;if(s.anchorNode){r=d.createRange();try{rb=d.createRange();rb.setStart(s.anchorNode,s.anchorOffset);rb.collapse(1);ra=d.createRange();ra.setStart(s.focusNode,s.focusOffset);ra.collapse(1);di=rb.compareBoundaryPoints(rb.START_TO_END,ra)<0;r.setStart(di?s.anchorNode:s.focusNode,di?s.anchorOffset:s.focusOffset);r.setEnd(di?s.focusNode:s.anchorNode,di?s.focusOffset:s.anchorOffset);lr=r;}catch(ex){}}return r||lr;};setContent=ed.selection.setContent;ed.selection.setContent=function(h,s){var r=this.getRng(),b;try{setContent.call(this,h,s);}catch(ex){b=dom.create('body');b.innerHTML=h;each(b.childNodes,function(n){r.insertNode(n.cloneNode(true));});}};},_insertBR:function(ed){var dom=ed.dom,s=ed.selection,r=s.getRng(),br;r.insertNode(br=dom.create('br'));r.setStartAfter(br);r.setEndAfter(br);s.setRng(r);if(s.getSel().focusNode==br.previousSibling){s.select(dom.insertAfter(dom.doc.createTextNode('\u00a0'),br));s.collapse(1);}ed.getWin().scrollTo(0,dom.getPos(s.getRng().startContainer).y);}});tinymce.PluginManager.add('safari',tinymce.plugins.Safari);})();
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ *
+ * This class was contributed by Michel Weimerskirch.
+ *
+ * @package MCManager.includes
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+class EnchantSpell extends SpellChecker {
+ /**
+ * Spellchecks an array of words.
+ *
+ * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1
+ * @param Array $words Array of words to check.
+ * @return Array of misspelled words.
+ */
+ function &checkWords($lang, $words) {
+ $r = enchant_broker_init();
+
+ if (enchant_broker_dict_exists($r,$lang)) {
+ $d = enchant_broker_request_dict($r, $lang);
+
+ $returnData = array();
+ foreach($words as $key => $value) {
+ $correct = enchant_dict_check($d, $value);
+ if(!$correct) {
+ $returnData[] = trim($value);
+ }
+ }
+
+ return $returnData;
+ enchant_broker_free_dict($d);
+ } else {
+
+ }
+ enchant_broker_free($r);
+ }
+
+ /**
+ * Returns suggestions for a specific word.
+ *
+ * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1
+ * @param String $word Specific word to get suggestions for.
+ * @return Array of suggestions for the specified word.
+ */
+ function &getSuggestions($lang, $word) {
+ $r = enchant_broker_init();
+ $suggs = array();
+
+ if (enchant_broker_dict_exists($r,$lang)) {
+ $d = enchant_broker_request_dict($r, $lang);
+ $suggs = enchant_dict_suggest($d, $word);
+
+ enchant_broker_free_dict($d);
+ } else {
+
+ }
+ enchant_broker_free($r);
+
+ return $suggs;
+ }
+}
+
+?>
\ No newline at end of file
/**
* $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
*
+ * @package MCManager.includes
* @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
*/
/**
* $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
*
+ * @package MCManager.includes
* @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
*/
/**
* $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
*
+ * @package MCManager.includes
* @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
*/
$this->_tmpfile = tempnam($this->_config['PSpellShell.tmp'], "tinyspell");
if(preg_match("#win#i", php_uname()))
- return $this->_config['PSpellShell.aspell'] . " -a --lang=". $lang . " --encoding=utf-8 -H < " . $this->_tmpfile . " 2>&1";
+ return $this->_config['PSpellShell.aspell'] . " -a --lang=". escapeshellarg($lang) . " --encoding=utf-8 -H < " . $this->_tmpfile . " 2>&1";
- return "cat ". $this->_tmpfile ." | " . $this->_config['PSpellShell.aspell'] . " -a --encoding=utf-8 -H --lang=". $lang;
+ return "cat ". $this->_tmpfile ." | " . $this->_config['PSpellShell.aspell'] . " -a --encoding=utf-8 -H --lang=". escapeshellarg($lang);
}
}
-?>
+?>
\ No newline at end of file
/**
* $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
*
+ * @package MCManager.includes
* @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
*/
* Simple loopback function everything that gets in will be send back.
*
* @param $args.. Arguments.
- * @return {Array} Array of all input arguments.
+ * @return {Array} Array of all input arguments.
*/
function &loopback(/* args.. */) {
return func_get_args();
<?php
+/**
+ * config.php
+ * @package MCManager.includes
+ * @author Moxiecode
+ * @copyright Copyright © 2007, Moxiecode Systems AB, All rights reserved.
+ */
// General settings
$config['general.engine'] = 'GoogleSpell';
//$config['general.engine'] = 'PSpell';
//$config['general.engine'] = 'PSpellShell';
+ //$config['general.remote_rpc_url'] = 'http://some.other.site/some/url/rpc.php';
// PSpell settings
$config['PSpell.mode'] = PSPELL_FAST;
author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker',
- version : tinymce.majorVersion + "." + tinymce.minorVersion
+ version : "2.0.2"
};
},
},
_sendRPC : function(m, p, cb) {
- var t = this, url = t.editor.getParam("spellchecker_rpc_url", this.url+"/rpc.php");
+ var t = this, url = t.editor.getParam("spellchecker_rpc_url", this.url+'/rpc.php');
if (url == '{backend}') {
t.editor.setProgressState(0);
// Register plugin
tinymce.PluginManager.add('spellchecker', tinymce.plugins.SpellcheckerPlugin);
-})();
\ No newline at end of file
+})();
<?php
/**
- * $Id: rpc.php 354 2007-11-05 20:48:49Z spocke $
+ * $Id: rpc.php 822 2008-04-28 13:45:03Z spocke $
*
+ * @package MCManager.includes
* @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
*/
if (!$raw)
die('{"result":null,"id":null,"error":{"errstr":"Could not get raw post data.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
+// Passthrough request to remote server
+if (isset($config['general.remote_rpc_url'])) {
+ $url = parse_url($config['general.remote_rpc_url']);
+
+ // Setup request
+ $req = "POST " . $url["path"] . " HTTP/1.0\r\n";
+ $req .= "Connection: close\r\n";
+ $req .= "Host: " . $url['host'] . "\r\n";
+ $req .= "Content-Length: " . strlen($raw) . "\r\n";
+ $req .= "\r\n" . $raw;
+
+ if (!isset($url['port']) || !$url['port'])
+ $url['port'] = 80;
+
+ $errno = $errstr = "";
+
+ $socket = fsockopen($url['host'], intval($url['port']), $errno, $errstr, 30);
+ if ($socket) {
+ // Send request headers
+ fputs($socket, $req);
+
+ // Read response headers and data
+ $resp = "";
+ while (!feof($socket))
+ $resp .= fgets($socket, 4096);
+
+ fclose($socket);
+
+ // Split response header/data
+ $resp = explode("\r\n\r\n", $resp);
+ echo $resp[1]; // Output body
+ }
+
+ die();
+}
+
// Get JSON data
$json = new Moxiecode_JSON();
$input = $json->decode($raw);
var moreHTML = '<img src="' + url + '/img/trans.gif" class="mceWPmore mceItemNoResize" title="'+ed.getLang('wordpress.wp_more_alt')+'" />';
var nextpageHTML = '<img src="' + url + '/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+ed.getLang('wordpress.wp_page_alt')+'" />';
- if ( tinymce.util.Cookie.get('kitchenSink') == '1' )
+ if ( getUserSetting('hidetb', '0') == '1' )
ed.settings.wordpress_adv_hidden = 0;
// Hides the specified toolbar and resizes the iframe
});
ed.addCommand('WP_Adv', function() {
- var id = ed.controlManager.get(tbId).id, cm = ed.controlManager, cook = tinymce.util.Cookie, date;
-
- date = new Date();
- date.setTime(date.getTime()+(10*365*24*60*60*1000));
+ var id = ed.controlManager.get(tbId).id, cm = ed.controlManager;
if (DOM.isHidden(id)) {
cm.setActive('wp_adv', 1);
DOM.show(id);
t._resizeIframe(ed, tbId, -28);
ed.settings.wordpress_adv_hidden = 0;
- cook.set('kitchenSink', '1', date);
+ setUserSetting('hidetb', '1');
} else {
cm.setActive('wp_adv', 0);
DOM.hide(id);
t._resizeIframe(ed, tbId, 28);
ed.settings.wordpress_adv_hidden = 1;
- cook.set('kitchenSink', '0', date);
+ setUserSetting('hidetb', '0');
}
});
do_align : function(n, a) {
var P, DL, DIV, cls, c, ed = tinyMCE.activeEditor;
+ if ( /^(mceItemFlash|mceItemShockWave|mceItemWindowsMedia|mceItemQuickTime|mceItemRealMedia)$/.test(n.className) )
+ return;
+
P = ed.dom.getParent(n, 'p');
DL = ed.dom.getParent(n, 'dl');
DIV = ed.dom.getParent(n, 'div');
}
.submit input,
-.button {
+.button,
+.button-primary,
+.button-secondary,
+.button-highlighted {
font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
- padding: 3px 5px;
- font-size: 12px;
- line-height: 1.5em;
+ text-decoration: none;
+ font-size: 11px !important;
+ line-height: 16px;
+ padding: 2px 8px;
+ cursor: pointer;
border-width: 1px;
border-style: solid;
- -moz-border-radius: 3px;
- -khtml-border-radius: 3px;
- -webkit-border-radius: 3px;
- border-radius: 3px;
- cursor: pointer;
- text-decoration: none;
+ -moz-border-radius: 11px;
+ -khtml-border-radius: 11px;
+ -webkit-border-radius: 11px;
+ border-radius: 11px;
+ -moz-box-sizing: content-box;
+ -webkit-box-sizing: content-box;
+ -khtml-box-sizing: content-box;
+ box-sizing: content-box;
+}
+
+a.button {
+ padding: 4px 8px;
}
textarea,
overflow: hidden;
}
-#media-upload #img-edit {
- border: 1px solid #c0c0c0;
+#img-edit {
+ border: 1px solid #dfdfdf;
width: 623px;
margin: 15px auto;
}
}
#img_demo_txt {
- font-size: 6px;
- line-height: 10px;
- font-family: "Courier New",Courier,monotype;
- color: #ccc;
- background-color: #ccc;
+ font-size: 9px;
+ line-height: 13px;
+ font-family: Monaco,"Courier New",Courier,monospace;
+ color: #888;
}
#img_demo {
border-top-width: 1px;
display: block;
float: left;
+ height: 28px;
line-height: 28px;
text-decoration: none;
text-align: center;
#img_align_td {
padding: 2px 0 8px;
}
+
+#media-upload tr.align td.field {
+ text-align: center;
+}
+
+.describe td {
+ vertical-align: middle;
+}
+
+#media-upload .describe th.label {
+ padding-top: .5em;
+ text-align: left;
+}
+
+#media-upload .describe {
+ border-top-width: 1px;
+ border-top-style: solid;
+ padding: 5px;
+ width: 100%;
+ clear: both;
+ cursor: default;
+}
+
+form {
+ margin: 1em;
+}
+
+.describe input[type="text"],
+.describe textarea {
+ width: 460px;
+ border: 1px solid #dfdfdf;
+}
+
+
+.media-upload-form label,
+.media-upload-form legend {
+ font-weight: bold;
+ font-size: 13px;
+ color: #464646;
+}
+
+.align .field label {
+ display: inline;
+ padding: 0 0 0 28px;
+ margin: 0 1em 0 0;
+}
+.image-align-none-label {
+ background: url(../../../../../../wp-admin/images/align-none.png) no-repeat center left;
+}
+
+.image-align-left-label {
+ background: url(../../../../../../wp-admin/images/align-left.png) no-repeat center left;
+}
+
+.image-align-center-label {
+ background: url(../../../../../../wp-admin/images/align-center.png) no-repeat center left;
+}
+
+.image-align-right-label {
+ background: url(../../../../../../wp-admin/images/align-right.png) no-repeat center left;
+}
+
+div#media-upload-header {
+ margin: 0;
+ padding: 0 5px;
+ font-weight: bold;
+ position: relative;
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
+ height: 2.5em;
+}
+
+body#media-upload ul#sidemenu {
+ font-weight: normal;
+ margin: 0 5px;
+ position: relative;
+ left: 0px;
+ bottom: -4px;
+}
+
+div#media-upload-error {
+ margin: 1em;
+ font-weight: bold;
+}
+
+* html #sidemenu li {
+ zoom: 100%;
+}
+
+* html #sidemenu a {
+ height: 27px;
+ line-height: 26px;
+}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
-<script type="text/javascript" src="js/editimage.js?ver=311g"></script>
-<script type="text/javascript" src="../../utils/form_utils.js?ver=311"></script>
+<script type="text/javascript" src="js/editimage.js?ver=321"></script>
+<script type="text/javascript" src="../../utils/form_utils.js?ver=321"></script>
+
+<link rel="stylesheet" href="css/editimage.css?ver=321" type="text/css" media="all" />
-<link rel="stylesheet" href="css/editimage.css?ver=311g" type="text/css" media="all" />
-<link rel="stylesheet" href="../../../../../wp-admin/css/media.css?ver=2.6.1" type="text/css" media="all" />
<script type="text/javascript">
if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
- document.write('<link rel="stylesheet" href="css/editimage-rtl.css?ver=311" type="text/css" media="all" />');
+ document.write('<link rel="stylesheet" href="css/editimage-rtl.css?ver=321" type="text/css" media="all" />');
</script>
<base target="_self" />
</head>
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
ed.addCommand('WP_EditImage', function() {
- var el = ed.selection.getNode();
+ var el = ed.selection.getNode(), vp = tinymce.DOM.getViewPort(), H = vp.h, W = ( 720 < vp.w ) ? 720 : vp.w;
+ var cls = ed.dom.getAttrib(el, 'class');
- if ( ed.dom.getAttrib(el, 'class').indexOf('mceItem') != -1 || el.nodeName != 'IMG' )
+ if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 || el.nodeName != 'IMG' )
return;
- tb_show('', url + '/editimage.html?ver=311g&TB_iframe=true');
+ tb_show('', url + '/editimage.html?ver=321&TB_iframe=true');
+ tinymce.DOM.setStyles('TB_window', {
+ 'width':( W - 50 )+'px',
+ 'height':( H - 45 )+'px',
+ 'margin-left':'-'+parseInt((( W - 50 ) / 2),10) + 'px'
+ });
+
+ if ( ! tinymce.isIE6 ) {
+ tinymce.DOM.setStyles('TB_window', {
+ 'top':'20px',
+ 'marginTop':'0'
+ });
+ }
+
+ tinymce.DOM.setStyles('TB_iframeContent', {
+ 'width':( W - 50 )+'px',
+ 'height':( H - 75 )+'px'
+ });
tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
});
showButtons : function(n) {
var t = this, ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y;
+ var cls = ed.dom.getAttrib(n, 'class');
- if (ed.dom.getAttrib(n, 'class').indexOf('mceItem') != -1)
+ if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 )
return;
vp = ed.dom.getViewPort(ed.getWin());
--- /dev/null
+\r
+(function() {\r
+ tinymce.create('tinymce.plugins.wpGallery', {\r
+\r
+ init : function(ed, url) {\r
+ var t = this;\r
+\r
+ t.url = url;\r
+ t._createButtons();\r
+\r
+ // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');\r
+ ed.addCommand('WP_Gallery', function() {\r
+ var el = ed.selection.getNode(), vp = tinymce.DOM.getViewPort(), W = ( 720 < vp.w ) ? 720 : vp.w;\r
+\r
+ if ( el.nodeName != 'IMG' ) return;\r
+ if ( ed.dom.getAttrib(el, 'class').indexOf('wpGallery') == -1 ) return;\r
+\r
+ var post_id = tinymce.DOM.get('post_ID').value;\r
+ tb_show('', tinymce.documentBaseURL + '/media-upload.php?post_id='+post_id+'&tab=gallery&TB_iframe=true');\r
+\r
+ tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );\r
+ });\r
+\r
+ ed.onInit.add(function(ed) {\r
+ tinymce.dom.Event.add(ed.getWin(), 'scroll', function(e) {\r
+ ed.plugins.wpgallery.hideButtons();\r
+ });\r
+ });\r
+\r
+ ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) {\r
+ ed.plugins.wpgallery.hideButtons();\r
+ });\r
+\r
+ ed.onSaveContent.add(function(ed, o) {\r
+ ed.plugins.wpgallery.hideButtons();\r
+ });\r
+\r
+ ed.onMouseUp.add(function(ed, e) {\r
+ if ( tinymce.isOpera ) {\r
+ if ( e.target.nodeName == 'IMG' )\r
+ ed.plugins.wpgallery.showButtons(e.target);\r
+ }\r
+\r
+ });\r
+\r
+ ed.onMouseDown.add(function(ed, e) {\r
+ if ( tinymce.isOpera || e.target.nodeName != 'IMG' ) {\r
+ t.hideButtons();\r
+ return;\r
+ }\r
+ ed.plugins.wpgallery.showButtons(e.target);\r
+ });\r
+\r
+ ed.onBeforeSetContent.add(function(ed, o) {\r
+ o.content = t._do_gallery(o.content);\r
+ });\r
+\r
+ ed.onPostProcess.add(function(ed, o) {\r
+ if (o.get)\r
+ o.content = t._get_gallery(o.content);\r
+ });\r
+ },\r
+\r
+ _do_gallery : function(co) {\r
+ return co.replace(/\[gallery([^\]]*)\]/g, function(a,b){\r
+ return '<img src="'+tinymce.baseURL+'/plugins/wpgallery/img/t.gif" class="wpGallery mceItem" title="gallery'+tinymce.DOM.encode(b)+'" />';\r
+ });\r
+ },\r
+\r
+ _get_gallery : function(co) {\r
+\r
+ function getAttr(s, n) {\r
+ n = new RegExp(n + '=\"([^\"]+)\"', 'g').exec(s);\r
+ return n ? tinymce.DOM.decode(n[1]) : '';\r
+ };\r
+\r
+ return co.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g, function(a,im) {\r
+ var cls = getAttr(im, 'class');\r
+\r
+ if ( cls.indexOf('wpGallery') != -1 )\r
+ return '<p>['+tinymce.trim(getAttr(im, 'title'))+']</p>';\r
+\r
+ return a;\r
+ });\r
+ },\r
+\r
+ showButtons : function(n) {\r
+ var t = this, ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y;\r
+\r
+ if (ed.dom.getAttrib(n, 'class').indexOf('wpGallery') == -1)\r
+ return;\r
+\r
+ vp = ed.dom.getViewPort(ed.getWin());\r
+ p1 = DOM.getPos(ed.getContentAreaContainer());\r
+ p2 = ed.dom.getPos(n);\r
+\r
+ X = Math.max(p2.x - vp.x, 0) + p1.x;\r
+ Y = Math.max(p2.y - vp.y, 0) + p1.y;\r
+\r
+ DOM.setStyles('wp_gallerybtns', {\r
+ 'top' : Y+5+'px',\r
+ 'left' : X+5+'px',\r
+ 'display' : 'block'\r
+ });\r
+\r
+ t.btnsTout = window.setTimeout( function(){ed.plugins.wpgallery.hideButtons();}, 5000 );\r
+ },\r
+\r
+ hideButtons : function() {\r
+ if ( tinymce.DOM.isHidden('wp_gallerybtns') ) return;\r
+\r
+ tinymce.DOM.hide('wp_gallerybtns');\r
+ window.clearTimeout(this.btnsTout);\r
+ },\r
+\r
+ _createButtons : function() {\r
+ var t = this, ed = tinyMCE.activeEditor, DOM = tinymce.DOM;\r
+\r
+ DOM.remove('wp_gallerybtns');\r
+\r
+ var wp_gallerybtns = DOM.add(document.body, 'div', {\r
+ id : 'wp_gallerybtns',\r
+ style : 'display:none;'\r
+ });\r
+\r
+ var wp_editgallery = DOM.add('wp_gallerybtns', 'img', {\r
+ src : t.url+'/img/edit.png',\r
+ id : 'wp_editgallery',\r
+ width : '24',\r
+ height : '24',\r
+ title : ed.getLang('wordpress.editgallery')\r
+ });\r
+\r
+ wp_editgallery.onmousedown = function(e) {\r
+ var ed = tinyMCE.activeEditor;\r
+ ed.windowManager.bookmark = ed.selection.getBookmark('simple');\r
+ ed.execCommand("WP_Gallery");\r
+ this.parentNode.style.display = 'none';\r
+ };\r
+\r
+ var wp_delgallery = DOM.add('wp_gallerybtns', 'img', {\r
+ src : t.url+'/img/delete.png',\r
+ id : 'wp_delgallery',\r
+ width : '24',\r
+ height : '24',\r
+ title : ed.getLang('wordpress.delgallery')\r
+ });\r
+\r
+ wp_delgallery.onmousedown = function(e) {\r
+ var ed = tinyMCE.activeEditor, el = ed.selection.getNode();\r
+\r
+ if ( el.nodeName == 'IMG' && ed.dom.getAttrib(el, 'class').indexOf('wpGallery') != -1 ) {\r
+ ed.dom.remove(el);\r
+\r
+ this.parentNode.style.display = 'none';\r
+ ed.execCommand('mceRepaint');\r
+ return false;\r
+ }\r
+ };\r
+ },\r
+\r
+ getInfo : function() {\r
+ return {\r
+ longname : 'Gallery Settings',\r
+ author : 'WordPress',\r
+ authorurl : 'http://wordpress.org',\r
+ infourl : '',\r
+ version : "1.0"\r
+ };\r
+ }\r
+ });\r
+\r
+ tinymce.PluginManager.add('wpgallery', tinymce.plugins.wpGallery);\r
+})();\r
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{#advanced_dlg.about_title}</title>
- <script type="text/javascript" src="../../tiny_mce_popup.js?ver=311"></script>
- <script type="text/javascript" src="../../utils/mctabs.js?ver=311"></script>
- <script type="text/javascript" src="js/about.js?ver=311"></script>
+ <script type="text/javascript" src="../../tiny_mce_popup.js?ver=3211"></script>
+ <script type="text/javascript" src="../../utils/mctabs.js?ver=3211"></script>
+ <script type="text/javascript" src="js/about.js?ver=3211"></script>
</head>
<body id="about" style="display: none">
<div class="tabs">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{#advanced_dlg.anchor_title}</title>
- <script type="text/javascript" src="../../tiny_mce_popup.js?ver=311"></script>
- <script type="text/javascript" src="js/anchor.js?ver=311"></script>
+ <script type="text/javascript" src="../../tiny_mce_popup.js?ver=3211"></script>
+ <script type="text/javascript" src="js/anchor.js?ver=3211"></script>
<base target="_self" />
</head>
<body style="display: none">
<head>
<title>{#advanced_dlg.charmap_title}</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
- <script type="text/javascript" src="../../tiny_mce_popup.js?ver=311"></script>
- <script type="text/javascript" src="js/charmap.js?ver=311"></script>
+ <script type="text/javascript" src="../../tiny_mce_popup.js?ver=3211"></script>
+ <script type="text/javascript" src="js/charmap.js?ver=3211"></script>
<base target="_self" />
</head>
<body id="charmap" style="display:none">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{#advanced_dlg.colorpicker_title}</title>
- <script type="text/javascript" src="../../tiny_mce_popup.js?ver=311"></script>
- <script type="text/javascript" src="../../utils/mctabs.js?ver=311"></script>
- <script type="text/javascript" src="js/color_picker.js?ver=311"></script>
+ <script type="text/javascript" src="../../tiny_mce_popup.js?ver=3211"></script>
+ <script type="text/javascript" src="../../utils/mctabs.js?ver=3211"></script>
+ <script type="text/javascript" src="js/color_picker.js?ver=3211"></script>
<base target="_self" />
</head>
<body id="colorpicker" style="display: none">
-(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,extend=tinymce.extend,each=tinymce.each,Cookie=tinymce.util.Cookie,lastExtID,explode=tinymce.explode;tinymce.ThemeManager.requireLangPack('advanced');tinymce.create('tinymce.themes.AdvancedTheme',{controls:{bold:['bold_desc','Bold'],italic:['italic_desc','Italic'],underline:['underline_desc','Underline'],strikethrough:['striketrough_desc','Strikethrough'],justifyleft:['justifyleft_desc','JustifyLeft'],justifycenter:['justifycenter_desc','JustifyCenter'],justifyright:['justifyright_desc','JustifyRight'],justifyfull:['justifyfull_desc','JustifyFull'],bullist:['bullist_desc','InsertUnorderedList'],numlist:['numlist_desc','InsertOrderedList'],outdent:['outdent_desc','Outdent'],indent:['indent_desc','Indent'],cut:['cut_desc','Cut'],copy:['copy_desc','Copy'],paste:['paste_desc','Paste'],undo:['undo_desc','Undo'],redo:['redo_desc','Redo'],link:['link_desc','mceLink'],unlink:['unlink_desc','unlink'],image:['image_desc','mceImage'],cleanup:['cleanup_desc','mceCleanup'],help:['help_desc','mceHelp'],code:['code_desc','mceCodeEditor'],hr:['hr_desc','InsertHorizontalRule'],removeformat:['removeformat_desc','RemoveFormat'],sub:['sub_desc','subscript'],sup:['sup_desc','superscript'],forecolor:['forecolor_desc','ForeColor'],forecolorpicker:['forecolor_desc','mceForeColor'],backcolor:['backcolor_desc','HiliteColor'],backcolorpicker:['backcolor_desc','mceBackColor'],charmap:['charmap_desc','mceCharMap'],visualaid:['visualaid_desc','mceToggleVisualAid'],anchor:['anchor_desc','mceInsertAnchor'],newdocument:['newdocument_desc','mceNewDocument'],blockquote:['blockquote_desc','mceBlockQuote']},stateControls:['bold','italic','underline','strikethrough','bullist','numlist','justifyleft','justifycenter','justifyright','justifyfull','sub','sup','blockquote'],init:function(ed,url){var t=this,s,v;t.editor=ed;t.url=url;t.onResolveName=new tinymce.util.Dispatcher(this);t.settings=s=extend({theme_advanced_path:true,theme_advanced_toolbar_location:'bottom',theme_advanced_buttons1:"bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",theme_advanced_buttons3:"hr,removeformat,visualaid,|,sub,sup,|,charmap",theme_advanced_blockformats:"p,address,pre,h1,h2,h3,h4,h5,h6",theme_advanced_toolbar_align:"center",theme_advanced_fonts:"Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",theme_advanced_font_sizes:"1,2,3,4,5,6,7",theme_advanced_more_colors:1,theme_advanced_row_height:23,theme_advanced_resize_horizontal:1,theme_advanced_resizing_use_cookie:1},ed.settings);if((v=s.theme_advanced_path_location)&&v!='none')s.theme_advanced_statusbar_location=s.theme_advanced_path_location;if(s.theme_advanced_statusbar_location=='none')s.theme_advanced_statusbar_location=0;ed.onInit.add(function(){ed.onNodeChange.add(t._nodeChanged,t);if(ed.settings.content_css!==false)ed.dom.loadCSS(ed.baseURI.toAbsolute("themes/advanced/skins/"+ed.settings.skin+"/content.css"));});ed.onSetProgressState.add(function(ed,b,ti){var co,id=ed.id,tb;if(b){t.progressTimer=setTimeout(function(){co=ed.getContainer();co=co.insertBefore(DOM.create('DIV',{style:'position:relative'}),co.firstChild);tb=DOM.get(ed.id+'_tbl');DOM.add(co,'div',{id:id+'_blocker','class':'mceBlocker',style:{width:tb.clientWidth+2,height:tb.clientHeight+2}});DOM.add(co,'div',{id:id+'_progress','class':'mceProgress',style:{left:tb.clientWidth/ 2, top : tb.clientHeight /2}});},ti||0);}else{DOM.remove(id+'_blocker');DOM.remove(id+'_progress');clearTimeout(t.progressTimer);}});DOM.loadCSS(ed.baseURI.toAbsolute(s.editor_css||"themes/advanced/skins/"+ed.settings.skin+"/ui.css"));if(s.skin_variant)DOM.loadCSS(ed.baseURI.toAbsolute(s.editor_css||"themes/advanced/skins/"+ed.settings.skin+"/ui_"+s.skin_variant+".css"));},createControl:function(n,cf){var cd,c;if(c=cf.createControl(n))return c;switch(n){case"styleselect":return this._createStyleSelect();case"formatselect":return this._createBlockFormats();case"fontselect":return this._createFontSelect();case"fontsizeselect":return this._createFontSizeSelect();case"forecolor":return this._createForeColorMenu();case"backcolor":return this._createBackColorMenu();}if((cd=this.controls[n]))return cf.createButton(n,{title:"advanced."+cd[0],cmd:cd[1],ui:cd[2],value:cd[3]});},execCommand:function(cmd,ui,val){var f=this['_'+cmd];if(f){f.call(this,ui,val);return true;}return false;},_importClasses:function(e){var ed=this.editor,c=ed.controlManager.get('styleselect');if(c.getLength()==0){each(ed.dom.getClasses(),function(o){c.add(o['class'],o['class']);});}},_createStyleSelect:function(n){var t=this,ed=t.editor,cf=ed.controlManager,c=cf.createListBox('styleselect',{title:'advanced.style_select',onselect:function(v){if(c.selectedValue===v){ed.execCommand('mceSetStyleInfo',0,{command:'removeformat'});c.select();return false;}else ed.execCommand('mceSetCSSClass',0,v);}});if(c){each(ed.getParam('theme_advanced_styles','','hash'),function(v,k){if(v)c.add(t.editor.translate(k),v);});c.onPostRender.add(function(ed,n){Event.add(n.id+'_text','focus',t._importClasses,t);Event.add(n.id+'_text','mousedown',t._importClasses,t);});}return c;},_createFontSelect:function(){var c,t=this,ed=t.editor;c=ed.controlManager.createListBox('fontselect',{title:'advanced.fontdefault',cmd:'FontName'});if(c){each(ed.getParam('theme_advanced_fonts',t.settings.theme_advanced_fonts,'hash'),function(v,k){c.add(ed.translate(k),v,{style:v.indexOf('dings')==-1?'font-family:'+v:''});});}return c;},_createFontSizeSelect:function(){var t=this,ed=t.editor,c,lo=["1 (8 pt)","2 (10 pt)","3 (12 pt)","4 (14 pt)","5 (18 pt)","6 (24 pt)","7 (36 pt)"],fz=[8,10,12,14,18,24,36];c=ed.controlManager.createListBox('fontsizeselect',{title:'advanced.font_size',cmd:'FontSize'});if(c){each(ed.getParam('theme_advanced_font_sizes',t.settings.theme_advanced_font_sizes,'hash'),function(v,k){c.add(k!=v?k:lo[parseInt(v)-1],v,{'style':'font-size:'+fz[v-1]+'pt','class':'mceFontSize'+v});});}return c;},_createBlockFormats:function(){var c,fmts={p:'advanced.paragraph',address:'advanced.address',pre:'advanced.pre',h1:'advanced.h1',h2:'advanced.h2',h3:'advanced.h3',h4:'advanced.h4',h5:'advanced.h5',h6:'advanced.h6',div:'advanced.div',blockquote:'advanced.blockquote',code:'advanced.code',dt:'advanced.dt',dd:'advanced.dd',samp:'advanced.samp'},t=this;c=t.editor.controlManager.createListBox('formatselect',{title:'advanced.block',cmd:'FormatBlock'});if(c){each(t.editor.getParam('theme_advanced_blockformats',t.settings.theme_advanced_blockformats,'hash'),function(v,k){c.add(t.editor.translate(k!=v?k:fmts[v]),v,{'class':'mce_formatPreview mce_'+v});});}return c;},_createForeColorMenu:function(){var c,t=this,s=t.settings,o={},v;if(s.theme_advanced_more_colors){o.more_colors_func=function(){t._mceColorPicker(0,{color:c.value,func:function(co){c.setColor(co);}});};}if(v=s.theme_advanced_text_colors)o.colors=v;o.title='advanced.forecolor_desc';o.cmd='ForeColor';o.scope=this;c=t.editor.controlManager.createColorSplitButton('forecolor',o);return c;},_createBackColorMenu:function(){var c,t=this,s=t.settings,o={},v;if(s.theme_advanced_more_colors){o.more_colors_func=function(){t._mceColorPicker(0,{color:c.value,func:function(co){c.setColor(co);}});};}if(v=s.theme_advanced_background_colors)o.colors=v;o.title='advanced.backcolor_desc';o.cmd='HiliteColor';o.scope=this;c=t.editor.controlManager.createColorSplitButton('backcolor',o);return c;},renderUI:function(o){var n,ic,tb,t=this,ed=t.editor,s=t.settings,sc,p,nl;n=p=DOM.create('span',{id:ed.id+'_parent','class':'mceEditor '+ed.settings.skin+'Skin'+(s.skin_variant?' '+ed.settings.skin+'Skin'+t._ufirst(s.skin_variant):'')});if(!DOM.boxModel)n=DOM.add(n,'div',{'class':'mceOldBoxModel'});n=sc=DOM.add(n,'table',{id:ed.id+'_tbl','class':'mceLayout',cellSpacing:0,cellPadding:0});n=tb=DOM.add(n,'tbody');switch((s.theme_advanced_layout_manager||'').toLowerCase()){case"rowlayout":ic=t._rowLayout(s,tb,o);break;case"customlayout":ic=ed.execCallback("theme_advanced_custom_layout",s,tb,o,p);break;default:ic=t._simpleLayout(s,tb,o,p);}n=o.targetNode;nl=DOM.stdMode?sc.getElementsByTagName('tr'):sc.rows;DOM.addClass(nl[0],'mceFirst');DOM.addClass(nl[nl.length-1],'mceLast');each(DOM.select('tr',tb),function(n){DOM.addClass(n.firstChild,'mceFirst');DOM.addClass(n.childNodes[n.childNodes.length-1],'mceLast');});if(DOM.get(s.theme_advanced_toolbar_container))DOM.get(s.theme_advanced_toolbar_container).appendChild(p);else DOM.insertAfter(p,n);Event.add(ed.id+'_path_row','click',function(e){e=e.target;if(e.nodeName=='A'){t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/,'$1'));return Event.cancel(e);}});if(!ed.getParam('accessibility_focus')||ed.getParam('tab_focus'))Event.add(DOM.add(p,'a',{href:'#'},'<!-- IE -->'),'focus',function(){tinyMCE.get(ed.id).focus();});if(s.theme_advanced_toolbar_location=='external')o.deltaHeight=0;t.deltaHeight=o.deltaHeight;o.targetNode=null;return{iframeContainer:ic,editorContainer:ed.id+'_parent',sizeContainer:sc,deltaHeight:o.deltaHeight};},getInfo:function(){return{longname:'Advanced theme',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',version:tinymce.majorVersion+"."+tinymce.minorVersion}},resizeBy:function(dw,dh){var e=DOM.get(this.editor.id+'_tbl');this.resizeTo(e.clientWidth+dw,e.clientHeight+dh);},resizeTo:function(w,h){var ed=this.editor,s=ed.settings,e=DOM.get(ed.id+'_tbl'),ifr=DOM.get(ed.id+'_ifr'),dh;w=Math.max(s.theme_advanced_resizing_min_width||100,w);h=Math.max(s.theme_advanced_resizing_min_height||100,h);w=Math.min(s.theme_advanced_resizing_max_width||0xFFFF,w);h=Math.min(s.theme_advanced_resizing_max_height||0xFFFF,h);dh=e.clientHeight-ifr.clientHeight;DOM.setStyle(ifr,'height',h-dh);DOM.setStyles(e,{width:w,height:h});},destroy:function(){var id=this.editor.id;Event.clear(id+'_resize');Event.clear(id+'_path_row');Event.clear(id+'_external_close');},_simpleLayout:function(s,tb,o,p){var t=this,ed=t.editor,lo=s.theme_advanced_toolbar_location,sl=s.theme_advanced_statusbar_location,n,ic,etb,c;if(lo=='top')t._addToolbars(tb,o);if(lo=='external'){n=c=DOM.create('div',{style:'position:relative'});n=DOM.add(n,'div',{id:ed.id+'_external','class':'mceExternalToolbar'});DOM.add(n,'a',{id:ed.id+'_external_close',href:'javascript:;','class':'mceExternalClose'});n=DOM.add(n,'table',{id:ed.id+'_tblext',cellSpacing:0,cellPadding:0});etb=DOM.add(n,'tbody');if(p.firstChild.className=='mceOldBoxModel')p.firstChild.appendChild(c);else p.insertBefore(c,p.firstChild);t._addToolbars(etb,o);ed.onMouseUp.add(function(){var e=DOM.get(ed.id+'_external');DOM.show(e);DOM.hide(lastExtID);var f=Event.add(ed.id+'_external_close','click',function(){DOM.hide(ed.id+'_external');Event.remove(ed.id+'_external_close','click',f);});DOM.show(e);DOM.setStyle(e,'top',0-DOM.getRect(ed.id+'_tblext').h-1);DOM.hide(e);DOM.show(e);e.style.filter='';lastExtID=ed.id+'_external';e=null;});}if(sl=='top')t._addStatusBar(tb,o);if(!s.theme_advanced_toolbar_container){n=DOM.add(tb,'tr');n=ic=DOM.add(n,'td',{'class':'mceIframeContainer'});}if(lo=='bottom')t._addToolbars(tb,o);if(sl=='bottom')t._addStatusBar(tb,o);return ic;},_rowLayout:function(s,tb,o){var t=this,ed=t.editor,dc,da,cf=ed.controlManager,n,ic,to,a;dc=s.theme_advanced_containers_default_class||'';da=s.theme_advanced_containers_default_align||'center';each(explode(s.theme_advanced_containers||''),function(c,i){var v=s['theme_advanced_container_'+c]||'';switch(v.toLowerCase()){case'mceeditor':n=DOM.add(tb,'tr');n=ic=DOM.add(n,'td',{'class':'mceIframeContainer'});break;case'mceelementpath':t._addStatusBar(tb,o);break;default:a=(s['theme_advanced_container_'+c+'_align']||da).toLowerCase();a='mce'+t._ufirst(a);n=DOM.add(DOM.add(tb,'tr'),'td',{'class':'mceToolbar '+(s['theme_advanced_container_'+c+'_class']||dc)+' '+a||da});to=cf.createToolbar("toolbar"+i);t._addControls(v,to);DOM.setHTML(n,to.renderHTML());o.deltaHeight-=s.theme_advanced_row_height;}});return ic;},_addControls:function(v,tb){var t=this,s=t.settings,di,cf=t.editor.controlManager;if(s.theme_advanced_disable&&!t._disabled){di={};each(explode(s.theme_advanced_disable),function(v){di[v]=1;});t._disabled=di;}else di=t._disabled;each(explode(v),function(n){var c;if(di&&di[n])return;if(n=='tablecontrols'){each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"],function(n){n=t.createControl(n,cf);if(n)tb.add(n);});return;}c=t.createControl(n,cf);if(c)tb.add(c);});},_addToolbars:function(c,o){var t=this,i,tb,ed=t.editor,s=t.settings,v,cf=ed.controlManager,di,n,h=[],a;a=s.theme_advanced_toolbar_align.toLowerCase();a='mce'+t._ufirst(a);n=DOM.add(DOM.add(c,'tr'),'td',{'class':'mceToolbar '+a});if(!ed.getParam('accessibility_focus')||ed.getParam('tab_focus'))h.push(DOM.createHTML('a',{href:'#',onfocus:'tinyMCE.get(\''+ed.id+'\').focus();'},'<!-- IE -->'));h.push(DOM.createHTML('a',{href:'#',accesskey:'q',title:ed.getLang("advanced.toolbar_focus")},'<!-- IE -->'));for(i=1;(v=s['theme_advanced_buttons'+i]);i++){tb=cf.createToolbar("toolbar"+i,{'class':'mceToolbarRow'+i});if(s['theme_advanced_buttons'+i+'_add'])v+=','+s['theme_advanced_buttons'+i+'_add'];if(s['theme_advanced_buttons'+i+'_add_before'])v=s['theme_advanced_buttons'+i+'_add_before']+','+v;t._addControls(v,tb);h.push(tb.renderHTML());o.deltaHeight-=s.theme_advanced_row_height;}h.push(DOM.createHTML('a',{href:'#',accesskey:'z',title:ed.getLang("advanced.toolbar_focus"),onfocus:'tinyMCE.getInstanceById(\''+ed.id+'\').focus();'},'<!-- IE -->'));DOM.setHTML(n,h.join(''));},_addStatusBar:function(tb,o){var n,t=this,ed=t.editor,s=t.settings,r,mf,me,td;n=DOM.add(tb,'tr');n=td=DOM.add(n,'td',{'class':'mceStatusbar'});n=DOM.add(n,'div',{id:ed.id+'_path_row'},s.theme_advanced_path?ed.translate('advanced.path')+': ':' ');DOM.add(n,'a',{href:'#',accesskey:'x'});if(s.theme_advanced_resizing&&!tinymce.isOldWebKit){DOM.add(td,'a',{id:ed.id+'_resize',href:'javascript:;',onclick:"return false;",'class':'mceResize'});if(s.theme_advanced_resizing_use_cookie){ed.onPostRender.add(function(){var o=Cookie.getHash("TinyMCE_"+ed.id+"_size"),c=DOM.get(ed.id+'_tbl');if(!o)return;if(s.theme_advanced_resize_horizontal)c.style.width=Math.max(10,o.cw)+'px';c.style.height=Math.max(10,o.ch)+'px';DOM.get(ed.id+'_ifr').style.height=Math.max(10,parseInt(o.ch)+t.deltaHeight)+'px';});}ed.onPostRender.add(function(){Event.add(ed.id+'_resize','mousedown',function(e){var c,p,w,h,n,pa;c=DOM.get(ed.id+'_tbl');w=c.clientWidth;h=c.clientHeight;miw=s.theme_advanced_resizing_min_width||100;mih=s.theme_advanced_resizing_min_height||100;maw=s.theme_advanced_resizing_max_width||0xFFFF;mah=s.theme_advanced_resizing_max_height||0xFFFF;p=DOM.add(DOM.get(ed.id+'_parent'),'div',{'class':'mcePlaceHolder'});DOM.setStyles(p,{width:w,height:h});DOM.hide(c);DOM.show(p);r={x:e.screenX,y:e.screenY,w:w,h:h,dx:null,dy:null};mf=Event.add(DOM.doc,'mousemove',function(e){var w,h;r.dx=e.screenX-r.x;r.dy=e.screenY-r.y;w=Math.max(miw,r.w+r.dx);h=Math.max(mih,r.h+r.dy);w=Math.min(maw,w);h=Math.min(mah,h);if(s.theme_advanced_resize_horizontal)p.style.width=w+'px';p.style.height=h+'px';return Event.cancel(e);});me=Event.add(DOM.doc,'mouseup',function(e){var ifr;Event.remove(DOM.doc,'mousemove',mf);Event.remove(DOM.doc,'mouseup',me);c.style.display='';DOM.remove(p);if(r.dx===null)return;ifr=DOM.get(ed.id+'_ifr');if(s.theme_advanced_resize_horizontal)c.style.width=Math.max(10,r.w+r.dx)+'px';c.style.height=Math.max(10,r.h+r.dy)+'px';ifr.style.height=Math.max(10,ifr.clientHeight+r.dy)+'px';if(s.theme_advanced_resizing_use_cookie){Cookie.setHash("TinyMCE_"+ed.id+"_size",{cw:r.w+r.dx,ch:r.h+r.dy});}});return Event.cancel(e);});});}o.deltaHeight-=21;n=tb=null;},_nodeChanged:function(ed,cm,n,co){var t=this,p,de=0,v,c,s=t.settings;tinymce.each(t.stateControls,function(c){cm.setActive(c,ed.queryCommandState(t.controls[c][1]));});cm.setActive('visualaid',ed.hasVisual);cm.setDisabled('undo',!ed.undoManager.hasUndo()&&!ed.typing);cm.setDisabled('redo',!ed.undoManager.hasRedo());cm.setDisabled('outdent',!ed.queryCommandState('Outdent'));p=DOM.getParent(n,'A');if(c=cm.get('link')){if(!p||!p.name){c.setDisabled(!p&&co);c.setActive(!!p);}}if(c=cm.get('unlink')){c.setDisabled(!p&&co);c.setActive(!!p&&!p.name);}if(c=cm.get('anchor')){c.setActive(!!p&&p.name);if(tinymce.isWebKit){p=DOM.getParent(n,'IMG');c.setActive(!!p&&DOM.getAttrib(p,'mce_name')=='a');}}p=DOM.getParent(n,'IMG');if(c=cm.get('image'))c.setActive(!!p&&n.className.indexOf('mceItem')==-1);if(c=cm.get('styleselect')){if(n.className){t._importClasses();c.select(n.className);}else c.select();}if(c=cm.get('formatselect')){p=DOM.getParent(n,DOM.isBlock);if(p)c.select(p.nodeName.toLowerCase());}if(c=cm.get('fontselect'))c.select(ed.queryCommandValue('FontName'));if(c=cm.get('fontsizeselect'))c.select(''+ed.queryCommandValue('FontSize'));if(s.theme_advanced_path&&s.theme_advanced_statusbar_location){p=DOM.get(ed.id+'_path')||DOM.add(ed.id+'_path_row','span',{id:ed.id+'_path'});DOM.setHTML(p,'');ed.dom.getParent(n,function(n){var na=n.nodeName.toLowerCase(),u,pi,ti='';if(n.nodeType!=1||(DOM.hasClass(n,'mceItemHidden')||DOM.hasClass(n,'mceItemRemoved')))return;if(v=DOM.getAttrib(n,'mce_name'))na=v;if(tinymce.isIE&&n.scopeName!=='HTML')na=n.scopeName+':'+na;na=na.replace(/mce\:/g,'');switch(na){case'b':na='strong';break;case'i':na='em';break;case'img':if(v=DOM.getAttrib(n,'src'))ti+='src: '+v+' ';break;case'a':if(v=DOM.getAttrib(n,'name')){ti+='name: '+v+' ';na+='#'+v;}if(v=DOM.getAttrib(n,'href'))ti+='href: '+v+' ';break;case'font':if(s.convert_fonts_to_spans)na='span';if(v=DOM.getAttrib(n,'face'))ti+='font: '+v+' ';if(v=DOM.getAttrib(n,'size'))ti+='size: '+v+' ';if(v=DOM.getAttrib(n,'color'))ti+='color: '+v+' ';break;case'span':if(v=DOM.getAttrib(n,'style'))ti+='style: '+v+' ';break;}if(v=DOM.getAttrib(n,'id'))ti+='id: '+v+' ';if(v=n.className){v=v.replace(/(webkit-[\w\-]+|Apple-[\w\-]+|mceItem\w+|mceVisualAid)/g,'');if(v&&v.indexOf('mceItem')==-1){ti+='class: '+v+' ';if(DOM.isBlock(n)||na=='img'||na=='span')na+='.'+v;}}na=na.replace(/(html:)/g,'');na={name:na,node:n,title:ti};t.onResolveName.dispatch(t,na);ti=na.title;na=na.name;pi=DOM.create('a',{'href':"javascript:;",onmousedown:"return false;",title:ti,'class':'mcePath_'+(de++)},na);if(p.hasChildNodes()){p.insertBefore(DOM.doc.createTextNode(' \u00bb '),p.firstChild);p.insertBefore(pi,p.firstChild);}else p.appendChild(pi);},ed.getBody());}},_sel:function(v){this.editor.execCommand('mceSelectNodeDepth',false,v);},_mceInsertAnchor:function(ui,v){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/anchor.htm',width:320+parseInt(ed.getLang('advanced.anchor_delta_width',0)),height:90+parseInt(ed.getLang('advanced.anchor_delta_height',0)),inline:true},{theme_url:this.url});},_mceCharMap:function(){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/charmap.htm',width:550+parseInt(ed.getLang('advanced.charmap_delta_width',0)),height:250+parseInt(ed.getLang('advanced.charmap_delta_height',0)),inline:true},{theme_url:this.url});},_mceHelp:function(){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/about.htm',width:480,height:380,inline:true},{theme_url:this.url});},_mceColorPicker:function(u,v){var ed=this.editor;v=v||{};ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/color_picker.htm',width:375+parseInt(ed.getLang('advanced.colorpicker_delta_width',0)),height:250+parseInt(ed.getLang('advanced.colorpicker_delta_height',0)),close_previous:false,inline:true},{input_color:v.color,func:v.func,theme_url:this.url});},_mceCodeEditor:function(ui,val){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/source_editor.htm',width:parseInt(ed.getParam("theme_advanced_source_editor_width",720)),height:parseInt(ed.getParam("theme_advanced_source_editor_height",580)),inline:true,resizable:true,maximizable:true},{theme_url:this.url});},_mceImage:function(ui,val){var ed=this.editor;if(ed.dom.getAttrib(ed.selection.getNode(),'class').indexOf('mceItem')!=-1)return;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/image.htm',width:355+parseInt(ed.getLang('advanced.image_delta_width',0)),height:275+parseInt(ed.getLang('advanced.image_delta_height',0)),inline:true},{theme_url:this.url});},_mceLink:function(ui,val){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/link.htm',width:310+parseInt(ed.getLang('advanced.link_delta_width',0)),height:200+parseInt(ed.getLang('advanced.link_delta_height',0)),inline:true},{theme_url:this.url});},_mceNewDocument:function(){var ed=this.editor;ed.windowManager.confirm('advanced.newdocument',function(s){if(s)ed.execCommand('mceSetContent',false,'');});},_mceForeColor:function(){var t=this;this._mceColorPicker(0,{color:t.fgColor,func:function(co){t.fgColor=co;t.editor.execCommand('ForeColor',false,co);}});},_mceBackColor:function(){var t=this;this._mceColorPicker(0,{color:t.bgColor,func:function(co){t.bgColor=co;t.editor.execCommand('HiliteColor',false,co);}});},_ufirst:function(s){return s.substring(0,1).toUpperCase()+s.substring(1);}});tinymce.ThemeManager.add('advanced',tinymce.themes.AdvancedTheme);}());
\ No newline at end of file
+(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,extend=tinymce.extend,each=tinymce.each,Cookie=tinymce.util.Cookie,lastExtID,explode=tinymce.explode;tinymce.ThemeManager.requireLangPack('advanced');tinymce.create('tinymce.themes.AdvancedTheme',{sizes:[8,10,12,14,18,24,36],controls:{bold:['bold_desc','Bold'],italic:['italic_desc','Italic'],underline:['underline_desc','Underline'],strikethrough:['striketrough_desc','Strikethrough'],justifyleft:['justifyleft_desc','JustifyLeft'],justifycenter:['justifycenter_desc','JustifyCenter'],justifyright:['justifyright_desc','JustifyRight'],justifyfull:['justifyfull_desc','JustifyFull'],bullist:['bullist_desc','InsertUnorderedList'],numlist:['numlist_desc','InsertOrderedList'],outdent:['outdent_desc','Outdent'],indent:['indent_desc','Indent'],cut:['cut_desc','Cut'],copy:['copy_desc','Copy'],paste:['paste_desc','Paste'],undo:['undo_desc','Undo'],redo:['redo_desc','Redo'],link:['link_desc','mceLink'],unlink:['unlink_desc','unlink'],image:['image_desc','mceImage'],cleanup:['cleanup_desc','mceCleanup'],help:['help_desc','mceHelp'],code:['code_desc','mceCodeEditor'],hr:['hr_desc','InsertHorizontalRule'],removeformat:['removeformat_desc','RemoveFormat'],sub:['sub_desc','subscript'],sup:['sup_desc','superscript'],forecolor:['forecolor_desc','ForeColor'],forecolorpicker:['forecolor_desc','mceForeColor'],backcolor:['backcolor_desc','HiliteColor'],backcolorpicker:['backcolor_desc','mceBackColor'],charmap:['charmap_desc','mceCharMap'],visualaid:['visualaid_desc','mceToggleVisualAid'],anchor:['anchor_desc','mceInsertAnchor'],newdocument:['newdocument_desc','mceNewDocument'],blockquote:['blockquote_desc','mceBlockQuote']},stateControls:['bold','italic','underline','strikethrough','bullist','numlist','justifyleft','justifycenter','justifyright','justifyfull','sub','sup','blockquote'],init:function(ed,url){var t=this,s,v,o;t.editor=ed;t.url=url;t.onResolveName=new tinymce.util.Dispatcher(this);t.settings=s=extend({theme_advanced_path:true,theme_advanced_toolbar_location:'bottom',theme_advanced_buttons1:"bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",theme_advanced_buttons3:"hr,removeformat,visualaid,|,sub,sup,|,charmap",theme_advanced_blockformats:"p,address,pre,h1,h2,h3,h4,h5,h6",theme_advanced_toolbar_align:"center",theme_advanced_fonts:"Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",theme_advanced_more_colors:1,theme_advanced_row_height:23,theme_advanced_resize_horizontal:1,theme_advanced_resizing_use_cookie:1,theme_advanced_font_sizes:"1,2,3,4,5,6,7",readonly:ed.settings.readonly},ed.settings);if(!s.font_size_style_values)s.font_size_style_values="8pt,10pt,12pt,14pt,18pt,24pt,36pt";if(tinymce.is(s.theme_advanced_font_sizes,'string')){s.font_size_style_values=tinymce.explode(s.font_size_style_values);s.font_size_classes=tinymce.explode(s.font_size_classes||'');o={};ed.settings.theme_advanced_font_sizes=s.theme_advanced_font_sizes;each(ed.getParam('theme_advanced_font_sizes','','hash'),function(v,k){var cl;if(k==v&&v>=1&&v<=7){k=v+' ('+t.sizes[v-1]+'pt)';if(ed.settings.convert_fonts_to_spans){cl=s.font_size_classes[v-1];v=s.font_size_style_values[v-1]||(t.sizes[v-1]+'pt');}}if(/\s*\./.test(v))cl=v.replace(/\./g,'');o[k]=cl?{'class':cl}:{fontSize:v};});s.theme_advanced_font_sizes=o;}if((v=s.theme_advanced_path_location)&&v!='none')s.theme_advanced_statusbar_location=s.theme_advanced_path_location;if(s.theme_advanced_statusbar_location=='none')s.theme_advanced_statusbar_location=0;ed.onInit.add(function(){ed.onNodeChange.add(t._nodeChanged,t);if(ed.settings.content_css!==false)ed.dom.loadCSS(ed.baseURI.toAbsolute("themes/advanced/skins/"+ed.settings.skin+"/content.css"));});ed.onSetProgressState.add(function(ed,b,ti){var co,id=ed.id,tb;if(b){t.progressTimer=setTimeout(function(){co=ed.getContainer();co=co.insertBefore(DOM.create('DIV',{style:'position:relative'}),co.firstChild);tb=DOM.get(ed.id+'_tbl');DOM.add(co,'div',{id:id+'_blocker','class':'mceBlocker',style:{width:tb.clientWidth+2,height:tb.clientHeight+2}});DOM.add(co,'div',{id:id+'_progress','class':'mceProgress',style:{left:tb.clientWidth/ 2, top : tb.clientHeight /2}});},ti||0);}else{DOM.remove(id+'_blocker');DOM.remove(id+'_progress');clearTimeout(t.progressTimer);}});DOM.loadCSS(s.editor_css?ed.documentBaseURI.toAbsolute(s.editor_css):url+"/skins/"+ed.settings.skin+"/ui.css");if(s.skin_variant)DOM.loadCSS(url+"/skins/"+ed.settings.skin+"/ui_"+s.skin_variant+".css");},createControl:function(n,cf){var cd,c;if(c=cf.createControl(n))return c;switch(n){case"styleselect":return this._createStyleSelect();case"formatselect":return this._createBlockFormats();case"fontselect":return this._createFontSelect();case"fontsizeselect":return this._createFontSizeSelect();case"forecolor":return this._createForeColorMenu();case"backcolor":return this._createBackColorMenu();}if((cd=this.controls[n]))return cf.createButton(n,{title:"advanced."+cd[0],cmd:cd[1],ui:cd[2],value:cd[3]});},execCommand:function(cmd,ui,val){var f=this['_'+cmd];if(f){f.call(this,ui,val);return true;}return false;},_importClasses:function(e){var ed=this.editor,c=ed.controlManager.get('styleselect');if(c.getLength()==0){each(ed.dom.getClasses(),function(o){c.add(o['class'],o['class']);});}},_createStyleSelect:function(n){var t=this,ed=t.editor,cf=ed.controlManager,c=cf.createListBox('styleselect',{title:'advanced.style_select',onselect:function(v){if(c.selectedValue===v){ed.execCommand('mceSetStyleInfo',0,{command:'removeformat'});c.select();return false;}else ed.execCommand('mceSetCSSClass',0,v);}});if(c){each(ed.getParam('theme_advanced_styles','','hash'),function(v,k){if(v)c.add(t.editor.translate(k),v);});c.onPostRender.add(function(ed,n){if(!c.NativeListBox){Event.add(n.id+'_text','focus',t._importClasses,t);Event.add(n.id+'_text','mousedown',t._importClasses,t);Event.add(n.id+'_open','focus',t._importClasses,t);Event.add(n.id+'_open','mousedown',t._importClasses,t);}else Event.add(n.id,'focus',t._importClasses,t);});}return c;},_createFontSelect:function(){var c,t=this,ed=t.editor;c=ed.controlManager.createListBox('fontselect',{title:'advanced.fontdefault',cmd:'FontName'});if(c){each(ed.getParam('theme_advanced_fonts',t.settings.theme_advanced_fonts,'hash'),function(v,k){c.add(ed.translate(k),v,{style:v.indexOf('dings')==-1?'font-family:'+v:''});});}return c;},_createFontSizeSelect:function(){var t=this,ed=t.editor,c,i=0,cl=[];c=ed.controlManager.createListBox('fontsizeselect',{title:'advanced.font_size',onselect:function(v){if(v.fontSize)ed.execCommand('FontSize',false,v.fontSize);else{each(t.settings.theme_advanced_font_sizes,function(v,k){if(v['class'])cl.push(v['class']);});ed.editorCommands._applyInlineStyle('span',{'class':v['class']},{check_classes:cl});}}});if(c){each(t.settings.theme_advanced_font_sizes,function(v,k){var fz=v.fontSize;if(fz>=1&&fz<=7)fz=t.sizes[parseInt(fz)-1]+'pt';c.add(k,v,{'style':'font-size:'+fz,'class':'mceFontSize'+(i++)+(' '+(v['class']||''))});});}return c;},_createBlockFormats:function(){var c,fmts={p:'advanced.paragraph',address:'advanced.address',pre:'advanced.pre',h1:'advanced.h1',h2:'advanced.h2',h3:'advanced.h3',h4:'advanced.h4',h5:'advanced.h5',h6:'advanced.h6',div:'advanced.div',blockquote:'advanced.blockquote',code:'advanced.code',dt:'advanced.dt',dd:'advanced.dd',samp:'advanced.samp'},t=this;c=t.editor.controlManager.createListBox('formatselect',{title:'advanced.block',cmd:'FormatBlock'});if(c){each(t.editor.getParam('theme_advanced_blockformats',t.settings.theme_advanced_blockformats,'hash'),function(v,k){c.add(t.editor.translate(k!=v?k:fmts[v]),v,{'class':'mce_formatPreview mce_'+v});});}return c;},_createForeColorMenu:function(){var c,t=this,s=t.settings,o={},v;if(s.theme_advanced_more_colors){o.more_colors_func=function(){t._mceColorPicker(0,{color:c.value,func:function(co){c.setColor(co);}});};}if(v=s.theme_advanced_text_colors)o.colors=v;if(s.theme_advanced_default_foreground_color)o.default_color=s.theme_advanced_default_foreground_color;o.title='advanced.forecolor_desc';o.cmd='ForeColor';o.scope=this;c=t.editor.controlManager.createColorSplitButton('forecolor',o);return c;},_createBackColorMenu:function(){var c,t=this,s=t.settings,o={},v;if(s.theme_advanced_more_colors){o.more_colors_func=function(){t._mceColorPicker(0,{color:c.value,func:function(co){c.setColor(co);}});};}if(v=s.theme_advanced_background_colors)o.colors=v;if(s.theme_advanced_default_background_color)o.default_color=s.theme_advanced_default_background_color;o.title='advanced.backcolor_desc';o.cmd='HiliteColor';o.scope=this;c=t.editor.controlManager.createColorSplitButton('backcolor',o);return c;},renderUI:function(o){var n,ic,tb,t=this,ed=t.editor,s=t.settings,sc,p,nl;n=p=DOM.create('span',{id:ed.id+'_parent','class':'mceEditor '+ed.settings.skin+'Skin'+(s.skin_variant?' '+ed.settings.skin+'Skin'+t._ufirst(s.skin_variant):'')});if(!DOM.boxModel)n=DOM.add(n,'div',{'class':'mceOldBoxModel'});n=sc=DOM.add(n,'table',{id:ed.id+'_tbl','class':'mceLayout',cellSpacing:0,cellPadding:0});n=tb=DOM.add(n,'tbody');switch((s.theme_advanced_layout_manager||'').toLowerCase()){case"rowlayout":ic=t._rowLayout(s,tb,o);break;case"customlayout":ic=ed.execCallback("theme_advanced_custom_layout",s,tb,o,p);break;default:ic=t._simpleLayout(s,tb,o,p);}n=o.targetNode;nl=DOM.stdMode?sc.getElementsByTagName('tr'):sc.rows;DOM.addClass(nl[0],'mceFirst');DOM.addClass(nl[nl.length-1],'mceLast');each(DOM.select('tr',tb),function(n){DOM.addClass(n.firstChild,'mceFirst');DOM.addClass(n.childNodes[n.childNodes.length-1],'mceLast');});if(DOM.get(s.theme_advanced_toolbar_container))DOM.get(s.theme_advanced_toolbar_container).appendChild(p);else DOM.insertAfter(p,n);Event.add(ed.id+'_path_row','click',function(e){e=e.target;if(e.nodeName=='A'){t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/,'$1'));return Event.cancel(e);}});if(!ed.getParam('accessibility_focus')||ed.getParam('tab_focus'))Event.add(DOM.add(p,'a',{href:'#'},'<!-- IE -->'),'focus',function(){tinyMCE.get(ed.id).focus();});if(s.theme_advanced_toolbar_location=='external')o.deltaHeight=0;t.deltaHeight=o.deltaHeight;o.targetNode=null;return{iframeContainer:ic,editorContainer:ed.id+'_parent',sizeContainer:sc,deltaHeight:o.deltaHeight};},getInfo:function(){return{longname:'Advanced theme',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',version:tinymce.majorVersion+"."+tinymce.minorVersion}},resizeBy:function(dw,dh){var e=DOM.get(this.editor.id+'_tbl');this.resizeTo(e.clientWidth+dw,e.clientHeight+dh);},resizeTo:function(w,h){var ed=this.editor,s=ed.settings,e=DOM.get(ed.id+'_tbl'),ifr=DOM.get(ed.id+'_ifr'),dh;w=Math.max(s.theme_advanced_resizing_min_width||100,w);h=Math.max(s.theme_advanced_resizing_min_height||100,h);w=Math.min(s.theme_advanced_resizing_max_width||0xFFFF,w);h=Math.min(s.theme_advanced_resizing_max_height||0xFFFF,h);dh=e.clientHeight-ifr.clientHeight;DOM.setStyle(ifr,'height',h-dh);DOM.setStyles(e,{width:w,height:h});},destroy:function(){var id=this.editor.id;Event.clear(id+'_resize');Event.clear(id+'_path_row');Event.clear(id+'_external_close');},_simpleLayout:function(s,tb,o,p){var t=this,ed=t.editor,lo=s.theme_advanced_toolbar_location,sl=s.theme_advanced_statusbar_location,n,ic,etb,c;if(s.readonly){n=DOM.add(tb,'tr');n=ic=DOM.add(n,'td',{'class':'mceIframeContainer'});return ic;}if(lo=='top')t._addToolbars(tb,o);if(lo=='external'){n=c=DOM.create('div',{style:'position:relative'});n=DOM.add(n,'div',{id:ed.id+'_external','class':'mceExternalToolbar'});DOM.add(n,'a',{id:ed.id+'_external_close',href:'javascript:;','class':'mceExternalClose'});n=DOM.add(n,'table',{id:ed.id+'_tblext',cellSpacing:0,cellPadding:0});etb=DOM.add(n,'tbody');if(p.firstChild.className=='mceOldBoxModel')p.firstChild.appendChild(c);else p.insertBefore(c,p.firstChild);t._addToolbars(etb,o);ed.onMouseUp.add(function(){var e=DOM.get(ed.id+'_external');DOM.show(e);DOM.hide(lastExtID);var f=Event.add(ed.id+'_external_close','click',function(){DOM.hide(ed.id+'_external');Event.remove(ed.id+'_external_close','click',f);});DOM.show(e);DOM.setStyle(e,'top',0-DOM.getRect(ed.id+'_tblext').h-1);DOM.hide(e);DOM.show(e);e.style.filter='';lastExtID=ed.id+'_external';e=null;});}if(sl=='top')t._addStatusBar(tb,o);if(!s.theme_advanced_toolbar_container){n=DOM.add(tb,'tr');n=ic=DOM.add(n,'td',{'class':'mceIframeContainer'});}if(lo=='bottom')t._addToolbars(tb,o);if(sl=='bottom')t._addStatusBar(tb,o);return ic;},_rowLayout:function(s,tb,o){var t=this,ed=t.editor,dc,da,cf=ed.controlManager,n,ic,to,a;dc=s.theme_advanced_containers_default_class||'';da=s.theme_advanced_containers_default_align||'center';each(explode(s.theme_advanced_containers||''),function(c,i){var v=s['theme_advanced_container_'+c]||'';switch(v.toLowerCase()){case'mceeditor':n=DOM.add(tb,'tr');n=ic=DOM.add(n,'td',{'class':'mceIframeContainer'});break;case'mceelementpath':t._addStatusBar(tb,o);break;default:a=(s['theme_advanced_container_'+c+'_align']||da).toLowerCase();a='mce'+t._ufirst(a);n=DOM.add(DOM.add(tb,'tr'),'td',{'class':'mceToolbar '+(s['theme_advanced_container_'+c+'_class']||dc)+' '+a||da});to=cf.createToolbar("toolbar"+i);t._addControls(v,to);DOM.setHTML(n,to.renderHTML());o.deltaHeight-=s.theme_advanced_row_height;}});return ic;},_addControls:function(v,tb){var t=this,s=t.settings,di,cf=t.editor.controlManager;if(s.theme_advanced_disable&&!t._disabled){di={};each(explode(s.theme_advanced_disable),function(v){di[v]=1;});t._disabled=di;}else di=t._disabled;each(explode(v),function(n){var c;if(di&&di[n])return;if(n=='tablecontrols'){each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"],function(n){n=t.createControl(n,cf);if(n)tb.add(n);});return;}c=t.createControl(n,cf);if(c)tb.add(c);});},_addToolbars:function(c,o){var t=this,i,tb,ed=t.editor,s=t.settings,v,cf=ed.controlManager,di,n,h=[],a;a=s.theme_advanced_toolbar_align.toLowerCase();a='mce'+t._ufirst(a);n=DOM.add(DOM.add(c,'tr'),'td',{'class':'mceToolbar '+a});if(!ed.getParam('accessibility_focus')||ed.getParam('tab_focus'))h.push(DOM.createHTML('a',{href:'#',onfocus:'tinyMCE.get(\''+ed.id+'\').focus();'},'<!-- IE -->'));h.push(DOM.createHTML('a',{href:'#',accesskey:'q',title:ed.getLang("advanced.toolbar_focus")},'<!-- IE -->'));for(i=1;(v=s['theme_advanced_buttons'+i]);i++){tb=cf.createToolbar("toolbar"+i,{'class':'mceToolbarRow'+i});if(s['theme_advanced_buttons'+i+'_add'])v+=','+s['theme_advanced_buttons'+i+'_add'];if(s['theme_advanced_buttons'+i+'_add_before'])v=s['theme_advanced_buttons'+i+'_add_before']+','+v;t._addControls(v,tb);h.push(tb.renderHTML());o.deltaHeight-=s.theme_advanced_row_height;}h.push(DOM.createHTML('a',{href:'#',accesskey:'z',title:ed.getLang("advanced.toolbar_focus"),onfocus:'tinyMCE.getInstanceById(\''+ed.id+'\').focus();'},'<!-- IE -->'));DOM.setHTML(n,h.join(''));},_addStatusBar:function(tb,o){var n,t=this,ed=t.editor,s=t.settings,r,mf,me,td;n=DOM.add(tb,'tr');n=td=DOM.add(n,'td',{'class':'mceStatusbar'});n=DOM.add(n,'div',{id:ed.id+'_path_row'},s.theme_advanced_path?ed.translate('advanced.path')+': ':' ');DOM.add(n,'a',{href:'#',accesskey:'x'});if(s.theme_advanced_resizing&&!tinymce.isOldWebKit){DOM.add(td,'a',{id:ed.id+'_resize',href:'javascript:;',onclick:"return false;",'class':'mceResize'});if(s.theme_advanced_resizing_use_cookie){ed.onPostRender.add(function(){var o=Cookie.getHash("TinyMCE_"+ed.id+"_size"),c=DOM.get(ed.id+'_tbl');if(!o)return;if(s.theme_advanced_resize_horizontal)c.style.width=Math.max(10,o.cw)+'px';c.style.height=Math.max(10,o.ch)+'px';DOM.get(ed.id+'_ifr').style.height=Math.max(10,parseInt(o.ch)+t.deltaHeight)+'px';});}ed.onPostRender.add(function(){Event.add(ed.id+'_resize','mousedown',function(e){var c,p,w,h,n,pa;c=DOM.get(ed.id+'_tbl');w=c.clientWidth;h=c.clientHeight;miw=s.theme_advanced_resizing_min_width||100;mih=s.theme_advanced_resizing_min_height||100;maw=s.theme_advanced_resizing_max_width||0xFFFF;mah=s.theme_advanced_resizing_max_height||0xFFFF;p=DOM.add(DOM.get(ed.id+'_parent'),'div',{'class':'mcePlaceHolder'});DOM.setStyles(p,{width:w,height:h});DOM.hide(c);DOM.show(p);r={x:e.screenX,y:e.screenY,w:w,h:h,dx:null,dy:null};mf=Event.add(DOM.doc,'mousemove',function(e){var w,h;r.dx=e.screenX-r.x;r.dy=e.screenY-r.y;w=Math.max(miw,r.w+r.dx);h=Math.max(mih,r.h+r.dy);w=Math.min(maw,w);h=Math.min(mah,h);if(s.theme_advanced_resize_horizontal)p.style.width=w+'px';p.style.height=h+'px';return Event.cancel(e);});me=Event.add(DOM.doc,'mouseup',function(e){var ifr;Event.remove(DOM.doc,'mousemove',mf);Event.remove(DOM.doc,'mouseup',me);c.style.display='';DOM.remove(p);if(r.dx===null)return;ifr=DOM.get(ed.id+'_ifr');if(s.theme_advanced_resize_horizontal)c.style.width=Math.max(10,r.w+r.dx)+'px';c.style.height=Math.max(10,r.h+r.dy)+'px';ifr.style.height=Math.max(10,ifr.clientHeight+r.dy)+'px';if(s.theme_advanced_resizing_use_cookie){Cookie.setHash("TinyMCE_"+ed.id+"_size",{cw:r.w+r.dx,ch:r.h+r.dy});}});return Event.cancel(e);});});}o.deltaHeight-=21;n=tb=null;},_nodeChanged:function(ed,cm,n,co){var t=this,p,de=0,v,c,s=t.settings,cl,fz,fn;if(s.readonly)return;tinymce.each(t.stateControls,function(c){cm.setActive(c,ed.queryCommandState(t.controls[c][1]));});cm.setActive('visualaid',ed.hasVisual);cm.setDisabled('undo',!ed.undoManager.hasUndo()&&!ed.typing);cm.setDisabled('redo',!ed.undoManager.hasRedo());cm.setDisabled('outdent',!ed.queryCommandState('Outdent'));p=DOM.getParent(n,'A');if(c=cm.get('link')){if(!p||!p.name){c.setDisabled(!p&&co);c.setActive(!!p);}}if(c=cm.get('unlink')){c.setDisabled(!p&&co);c.setActive(!!p&&!p.name);}if(c=cm.get('anchor')){c.setActive(!!p&&p.name);if(tinymce.isWebKit){p=DOM.getParent(n,'IMG');c.setActive(!!p&&DOM.getAttrib(p,'mce_name')=='a');}}p=DOM.getParent(n,'IMG');if(c=cm.get('image'))c.setActive(!!p&&n.className.indexOf('mceItem')==-1);if(c=cm.get('styleselect')){if(n.className){t._importClasses();c.select(n.className);}else c.select();}if(c=cm.get('formatselect')){p=DOM.getParent(n,DOM.isBlock);if(p)c.select(p.nodeName.toLowerCase());}if(ed.settings.convert_fonts_to_spans){ed.dom.getParent(n,function(n){if(n.nodeName==='SPAN'){if(!cl&&n.className)cl=n.className;if(!fz&&n.style.fontSize)fz=n.style.fontSize;if(!fn&&n.style.fontFamily)fn=n.style.fontFamily.replace(/[\"\']+/g,'').replace(/^([^,]+).*/,'$1').toLowerCase();}return false;});if(c=cm.get('fontselect')){c.select(function(v){return v.replace(/^([^,]+).*/,'$1').toLowerCase()==fn;});}if(c=cm.get('fontsizeselect')){c.select(function(v){if(v.fontSize&&v.fontSize===fz)return true;if(v['class']&&v['class']===cl)return true;});}}else{if(c=cm.get('fontselect'))c.select(ed.queryCommandValue('FontName'));if(c=cm.get('fontsizeselect')){v=ed.queryCommandValue('FontSize');c.select(function(iv){return iv.fontSize==v;});}}if(s.theme_advanced_path&&s.theme_advanced_statusbar_location){p=DOM.get(ed.id+'_path')||DOM.add(ed.id+'_path_row','span',{id:ed.id+'_path'});DOM.setHTML(p,'');ed.dom.getParent(n,function(n){var na=n.nodeName.toLowerCase(),u,pi,ti='';if(n.nodeType!=1||n.nodeName==='BR'||(DOM.hasClass(n,'mceItemHidden')||DOM.hasClass(n,'mceItemRemoved')))return;if(v=DOM.getAttrib(n,'mce_name'))na=v;if(tinymce.isIE&&n.scopeName!=='HTML')na=n.scopeName+':'+na;na=na.replace(/mce\:/g,'');switch(na){case'b':na='strong';break;case'i':na='em';break;case'img':if(v=DOM.getAttrib(n,'src'))ti+='src: '+v+' ';break;case'a':if(v=DOM.getAttrib(n,'name')){ti+='name: '+v+' ';na+='#'+v;}if(v=DOM.getAttrib(n,'href'))ti+='href: '+v+' ';break;case'font':if(s.convert_fonts_to_spans)na='span';if(v=DOM.getAttrib(n,'face'))ti+='font: '+v+' ';if(v=DOM.getAttrib(n,'size'))ti+='size: '+v+' ';if(v=DOM.getAttrib(n,'color'))ti+='color: '+v+' ';break;case'span':if(v=DOM.getAttrib(n,'style'))ti+='style: '+v+' ';break;}if(v=DOM.getAttrib(n,'id'))ti+='id: '+v+' ';if(v=n.className){v=v.replace(/(webkit-[\w\-]+|Apple-[\w\-]+|mceItem\w+|mceVisualAid)/g,'');if(v&&v.indexOf('mceItem')==-1){ti+='class: '+v+' ';if(DOM.isBlock(n)||na=='img'||na=='span')na+='.'+v;}}na=na.replace(/(html:)/g,'');na={name:na,node:n,title:ti};t.onResolveName.dispatch(t,na);ti=na.title;na=na.name;pi=DOM.create('a',{'href':"javascript:;",onmousedown:"return false;",title:ti,'class':'mcePath_'+(de++)},na);if(p.hasChildNodes()){p.insertBefore(DOM.doc.createTextNode(' \u00bb '),p.firstChild);p.insertBefore(pi,p.firstChild);}else p.appendChild(pi);},ed.getBody());}},_sel:function(v){this.editor.execCommand('mceSelectNodeDepth',false,v);},_mceInsertAnchor:function(ui,v){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/anchor.htm',width:320+parseInt(ed.getLang('advanced.anchor_delta_width',0)),height:90+parseInt(ed.getLang('advanced.anchor_delta_height',0)),inline:true},{theme_url:this.url});},_mceCharMap:function(){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/charmap.htm',width:550+parseInt(ed.getLang('advanced.charmap_delta_width',0)),height:250+parseInt(ed.getLang('advanced.charmap_delta_height',0)),inline:true},{theme_url:this.url});},_mceHelp:function(){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/about.htm',width:480,height:380,inline:true},{theme_url:this.url});},_mceColorPicker:function(u,v){var ed=this.editor;v=v||{};ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/color_picker.htm',width:375+parseInt(ed.getLang('advanced.colorpicker_delta_width',0)),height:250+parseInt(ed.getLang('advanced.colorpicker_delta_height',0)),close_previous:false,inline:true},{input_color:v.color,func:v.func,theme_url:this.url});},_mceCodeEditor:function(ui,val){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/source_editor.htm',width:parseInt(ed.getParam("theme_advanced_source_editor_width",720)),height:parseInt(ed.getParam("theme_advanced_source_editor_height",580)),inline:true,resizable:true,maximizable:true},{theme_url:this.url});},_mceImage:function(ui,val){var ed=this.editor;if(ed.dom.getAttrib(ed.selection.getNode(),'class').indexOf('mceItem')!=-1)return;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/image.htm',width:355+parseInt(ed.getLang('advanced.image_delta_width',0)),height:275+parseInt(ed.getLang('advanced.image_delta_height',0)),inline:true},{theme_url:this.url});},_mceLink:function(ui,val){var ed=this.editor;ed.windowManager.open({url:tinymce.baseURL+'/themes/advanced/link.htm',width:310+parseInt(ed.getLang('advanced.link_delta_width',0)),height:200+parseInt(ed.getLang('advanced.link_delta_height',0)),inline:true},{theme_url:this.url});},_mceNewDocument:function(){var ed=this.editor;ed.windowManager.confirm('advanced.newdocument',function(s){if(s)ed.execCommand('mceSetContent',false,'');});},_mceForeColor:function(){var t=this;this._mceColorPicker(0,{color:t.fgColor,func:function(co){t.fgColor=co;t.editor.execCommand('ForeColor',false,co);}});},_mceBackColor:function(){var t=this;this._mceColorPicker(0,{color:t.bgColor,func:function(co){t.bgColor=co;t.editor.execCommand('HiliteColor',false,co);}});},_ufirst:function(s){return s.substring(0,1).toUpperCase()+s.substring(1);}});tinymce.ThemeManager.add('advanced',tinymce.themes.AdvancedTheme);}());
\ No newline at end of file
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{#advanced_dlg.image_title}</title>
- <script type="text/javascript" src="../../tiny_mce_popup.js?ver=311"></script>
- <script type="text/javascript" src="../../utils/mctabs.js?ver=311"></script>
- <script type="text/javascript" src="../../utils/form_utils.js?ver=311"></script>
- <script type="text/javascript" src="js/image.js?ver=311"></script>
+ <script type="text/javascript" src="../../tiny_mce_popup.js?ver=3211"></script>
+ <script type="text/javascript" src="../../utils/mctabs.js?ver=3211"></script>
+ <script type="text/javascript" src="../../utils/form_utils.js?ver=3211"></script>
+ <script type="text/javascript" src="js/image.js?ver=3211"></script>
<base target="_self" />
</head>
<body id="image" style="display: none">
ed = tinyMCEPopup.editor;
// Give FF some time
- window.setTimeout('insertHelpIFrame();', 10);
+ window.setTimeout(insertHelpIFrame, 10);
tcont = document.getElementById('plugintablecontainer');
document.getElementById('plugins_tab').style.display = 'none';
});
} else
args.style = this.styleVal;
-
+
tinymce.extend(args, {
src : f.src.value,
alt : f.alt.value,
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{#advanced_dlg.link_title}</title>
- <script type="text/javascript" src="../../tiny_mce_popup.js?ver=311"></script>
- <script type="text/javascript" src="../../utils/mctabs.js?ver=311"></script>
- <script type="text/javascript" src="../../utils/form_utils.js?ver=311"></script>
- <script type="text/javascript" src="../../utils/validate.js?ver=311"></script>
- <script type="text/javascript" src="js/link.js?ver=311"></script>
+ <script type="text/javascript" src="../../tiny_mce_popup.js?ver=3211"></script>
+ <script type="text/javascript" src="../../utils/mctabs.js?ver=3211"></script>
+ <script type="text/javascript" src="../../utils/form_utils.js?ver=3211"></script>
+ <script type="text/javascript" src="../../utils/validate.js?ver=3211"></script>
+ <script type="text/javascript" src="js/link.js?ver=3211"></script>
<base target="_self" />
</head>
<body id="link" style="display: none">
a.browse span {display:block; width:20px; height:18px; background:url(../../img/icons.gif) -860px 0; border:1px solid #FFF; margin-left:1px;}
.mceOldBoxModel a.browse span {width:22px; height:20px;}
a.browse:hover span {border:1px solid #0A246A; background-color:#B2BBD0;}
-a.browse span.disabled {border:1px solid white; -moz-opacity:0.3; opacity:0.3; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);}
+a.browse span.disabled {border:1px solid white; opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
a.browse:hover span.disabled {border:1px solid white; background-color:transparent;}
a.pickcolor span {display:block; width:20px; height:16px; background:url(../../img/icons.gif) -840px 0; margin-left:2px;}
.mceOldBoxModel a.pickcolor span {width:21px; height:17px;}
.defaultSkin .mceButton {display:block; border:1px solid #F0F0EE; width:20px; height:20px; margin-right:1px}
.defaultSkin a.mceButtonEnabled:hover {border:1px solid #0A246A; background-color:#B2BBD0}
.defaultSkin a.mceButtonActive, .defaultSkin a.mceButtonSelected {border:1px solid #0A246A; background-color:#C2CBE0}
-.defaultSkin .mceButtonDisabled .mceIcon {opacity:0.3; filter:alpha(opacity=30)}
+.defaultSkin .mceButtonDisabled .mceIcon {opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
.defaultSkin .mceButtonLabeled {width:auto}
.defaultSkin .mceButtonLabeled span.mceIcon {float:left}
.defaultSkin span.mceButtonLabel {display:block; font-size:10px; padding:4px 6px 0 22px; font-family:Tahoma,Verdana,Arial,Helvetica}
.defaultSkin .mceSplitButton a, .defaultSkin .mceSplitButton span {height:20px; display:block}
.defaultSkin .mceSplitButton a.mceAction {width:20px; border:1px solid #F0F0EE; border-right:0;}
.defaultSkin .mceSplitButton span.mceAction {width:20px; background:url(../../img/icons.gif) 20px 20px;}
-.defaultSkin .mceSplitButton a.mceOpen {width:9px; border:1px solid #F0F0EE;}
-.defaultSkin .mceSplitButton span.mceOpen {width:9px; background:url(../../img/icons.gif) -741px 0;}
+.defaultSkin .mceSplitButton a.mceOpen {width:9px; background:url(../../img/icons.gif) -741px 0; border:1px solid #F0F0EE;}
+.defaultSkin .mceSplitButton span.mceOpen {display:none}
.defaultSkin table.mceSplitButtonEnabled:hover a.mceAction, .defaultSkin .mceSplitButtonHover a.mceAction, .defaultSkin .mceSplitButtonSelected a.mceAction {border:1px solid #0A246A; border-right:0; background-color:#B2BBD0}
-.defaultSkin table.mceSplitButtonEnabled:hover a.mceOpen, .defaultSkin .mceSplitButtonHover a.mceOpen, .defaultSkin .mceSplitButtonSelected a.mceOpen {border:1px solid #0A246A;}
-.defaultSkin table.mceSplitButtonEnabled:hover span.mceOpen, .defaultSkin .mceSplitButtonHover span.mceOpen, .defaultSkin .mceSplitButtonSelected span.mceOpen {background-color:#B2BBD0}
-.defaultSkin .mceSplitButtonDisabled .mceAction, .defaultSkin .mceSplitButtonDisabled span.mceOpen {opacity:0.3; filter:alpha(opacity=30)}
+.defaultSkin table.mceSplitButtonEnabled:hover a.mceOpen, .defaultSkin .mceSplitButtonHover a.mceOpen, .defaultSkin .mceSplitButtonSelected a.mceOpen {background-color:#B2BBD0; border:1px solid #0A246A;}
+.defaultSkin .mceSplitButtonDisabled .mceAction, .defaultSkin .mceSplitButtonDisabled a.mceOpen {opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
.defaultSkin .mceSplitButtonActive a.mceAction {border:1px solid #0A246A; background-color:#C2CBE0}
.defaultSkin .mceSplitButtonActive a.mceOpen {border-left:0;}
.defaultSkin .mceMenuItemSub a {background:url(img/menu_arrow.gif) no-repeat top right;}
/* Progress,Resize */
-.defaultSkin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; filter:alpha(opacity=50); background:#FFF}
+.defaultSkin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; -ms-filter:'alpha(opacity=50)'; filter:alpha(opacity=50); background:#FFF}
.defaultSkin .mceProgress {position:absolute; left:0; top:0; z-index:1001; background:url(img/progress.gif) no-repeat; width:32px; height:32px; margin:-16px 0 0 -16px}
.defaultSkin .mcePlaceHolder {border:1px dotted gray}
a.browse span {display:block; width:20px; height:18px; background:url(../../img/icons.gif) -860px 0; border:1px solid #FFF; margin-left:1px;}
.mceOldBoxModel a.browse span {width:22px; height:20px;}
a.browse:hover span {border:1px solid #0A246A; background-color:#B2BBD0;}
-a.browse span.disabled {border:1px solid white; -moz-opacity:0.3; opacity:0.3; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);}
+a.browse span.disabled {border:1px solid white; opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
a.browse:hover span.disabled {border:1px solid white; background-color:transparent;}
a.pickcolor span {display:block; width:20px; height:16px; background:url(../../img/icons.gif) -840px 0; margin-left:2px;}
.mceOldBoxModel a.pickcolor span {width:21px; height:17px;}
.o2k7Skin .mceOldBoxModel a.mceButton span, .o2k7Skin .mceOldBoxModel a.mceButton img {margin:0 0 0 1px}
.o2k7Skin a.mceButtonEnabled:hover {background-color:#B2BBD0; background-position:0 -22px}
.o2k7Skin a.mceButtonActive, .o2k7Skin a.mceButtonSelected {background-position:0 -44px}
-.o2k7Skin .mceButtonDisabled .mceIcon {opacity:0.3; filter:alpha(opacity=30)}
+.o2k7Skin .mceButtonDisabled .mceIcon {opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
.o2k7Skin .mceButtonLabeled {width:auto}
.o2k7Skin .mceButtonLabeled span.mceIcon {float:left}
.o2k7Skin span.mceButtonLabel {display:block; font-size:10px; padding:4px 6px 0 22px; font-family:Tahoma,Verdana,Arial,Helvetica}
.o2k7Skin .mceSplitButton {background:url(img/button_bg.png)}
.o2k7Skin .mceSplitButton a.mceAction {width:22px}
.o2k7Skin .mceSplitButton span.mceAction {width:22px; background:url(../../img/icons.gif) 20px 20px}
-.o2k7Skin .mceSplitButton a.mceOpen {width:10px}
-.o2k7Skin .mceSplitButton span.mceOpen {width:10px; background:url(img/button_bg.png) -44px 0}
+.o2k7Skin .mceSplitButton a.mceOpen {width:10px; background:url(img/button_bg.png) -44px 0}
+.o2k7Skin .mceSplitButton span.mceOpen {display:none}
.o2k7Skin table.mceSplitButtonEnabled:hover a.mceAction, .o2k7Skin .mceSplitButtonHover a.mceAction, .o2k7Skin .mceSplitButtonSelected {background:url(img/button_bg.png) 0 -22px}
-.o2k7Skin table.mceSplitButtonEnabled:hover span.mceOpen, .o2k7Skin .mceSplitButtonHover span.mceOpen, .o2k7Skin .mceSplitButtonSelected span.mceOpen {background-position:-44px -44px}
-.o2k7Skin .mceSplitButtonDisabled .mceAction {opacity:0.3; filter:alpha(opacity=30)}
+.o2k7Skin table.mceSplitButtonEnabled:hover a.mceOpen, .o2k7Skin .mceSplitButtonHover a.mceOpen, .o2k7Skin .mceSplitButtonSelected a.mceOpen {background-position:-44px -44px}
+.o2k7Skin .mceSplitButtonDisabled .mceAction {opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
.o2k7Skin .mceSplitButtonActive {background-position:0 -44px}
/* ColorSplitButton */
.o2k7Skin .mceMenuItemSub a {background:url(../default/img/menu_arrow.gif) no-repeat top right;}
/* Progress,Resize */
-.o2k7Skin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; filter:alpha(opacity=50); background:#FFF}
+.o2k7Skin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=50); background:#FFF}
.o2k7Skin .mceProgress {position:absolute; left:0; top:0; z-index:1001; background:url(../default/img/progress.gif) no-repeat; width:32px; height:32px; margin:-16px 0 0 -16px}
.o2k7Skin .mcePlaceHolder {border:1px dotted gray}
/* Black */
-.o2k7SkinBlack .mceToolbar .mceToolbarStart span, .o2k7SkinBlack .mceToolbar .mceToolbarEnd span, .o2k7SkinBlack .mceButton, .o2k7SkinBlack .mceSplitButton, .o2k7SkinBlack .mceSeparator, .o2k7SkinBlack .mceSplitButton span.mceOpen, .o2k7SkinBlack .mceListBox .mceOpen {background-image:url(img/button_bg_black.png)}
+.o2k7SkinBlack .mceToolbar .mceToolbarStart span, .o2k7SkinBlack .mceToolbar .mceToolbarEnd span, .o2k7SkinBlack .mceButton, .o2k7SkinBlack .mceSplitButton, .o2k7SkinBlack .mceSeparator, .o2k7SkinBlack .mceSplitButton a.mceOpen, .o2k7SkinBlack .mceListBox a.mceOpen {background-image:url(img/button_bg_black.png)}
.o2k7SkinBlack table, .o2k7SkinBlack .mceMenuItemTitle a, .o2k7SkinBlack .mceMenuItemTitle span.mceText, .o2k7SkinBlack .mceStatusbar div, .o2k7SkinBlack .mceStatusbar span, .o2k7SkinBlack .mceStatusbar a {background:#535353; color:#FFF}
.o2k7SkinBlack table.mceListBoxEnabled .mceText, o2k7SkinBlack .mceListBox .mceText {background:#FFF; border:1px solid #CBCFD4; border-bottom-color:#989FA9; border-right:0}
-.o2k7SkinBlack table.mceListBoxEnabled:hover .mceText, .o2k7Skin .mceListBoxHover .mceText, .o2k7Skin .mceListBoxSelected .mceText {background:#FFF; border:1px solid #FFBD69; border-right:0}
+.o2k7SkinBlack table.mceListBoxEnabled:hover .mceText, .o2k7SkinBlack .mceListBoxHover .mceText, .o2k7SkinBlack .mceListBoxSelected .mceText {background:#FFF; border:1px solid #FFBD69; border-right:0}
.o2k7SkinBlack .mceExternalToolbar, .o2k7SkinBlack .mceListBox .mceText, .o2k7SkinBlack div.mceMenu, .o2k7SkinBlack table.mceLayout, .o2k7SkinBlack .mceMenuItemTitle a, .o2k7SkinBlack table.mceLayout tr.mceFirst td, .o2k7SkinBlack table.mceLayout, .o2k7SkinBlack .mceMenuItemTitle a, .o2k7SkinBlack table.mceLayout tr.mceLast td, .o2k7SkinBlack .mceIframeContainer {border-color: #535353;}
-.o2k7SkinBlack table.mceSplitButtonEnabled:hover a.mceAction, .o2k7Skin .mceSplitButtonHover a.mceAction, .o2k7Skin .mceSplitButtonSelected {background-image:url(img/button_bg_black.png)}
-.o2k7SkinBlack .mceMenu .mceMenuItemEnabled a:hover, .o2k7Skin .mceMenu .mceMenuItemActive {background-color:#FFE7A1}
\ No newline at end of file
+.o2k7SkinBlack table.mceSplitButtonEnabled:hover a.mceAction, .o2k7SkinBlack .mceSplitButtonHover a.mceAction, .o2k7SkinBlack .mceSplitButtonSelected {background-image:url(img/button_bg_black.png)}
+.o2k7SkinBlack .mceMenu .mceMenuItemEnabled a:hover, .o2k7SkinBlack .mceMenu .mceMenuItemActive {background-color:#FFE7A1}
\ No newline at end of file
/* Silver */
-.o2k7SkinSilver .mceToolbar .mceToolbarStart span, .o2k7SkinSilver .mceButton, .o2k7SkinSilver .mceSplitButton, .o2k7SkinSilver .mceSeparator, .o2k7SkinSilver .mceSplitButton span.mceOpen, .o2k7SkinSilver .mceListBox .mceOpen {background-image:url(img/button_bg_silver.png)}
+.o2k7SkinSilver .mceToolbar .mceToolbarStart span, .o2k7SkinSilver .mceButton, .o2k7SkinSilver .mceSplitButton, .o2k7SkinSilver .mceSeparator, .o2k7SkinSilver .mceSplitButton a.mceOpen, .o2k7SkinSilver .mceListBox a.mceOpen {background-image:url(img/button_bg_silver.png)}
.o2k7SkinSilver table, .o2k7SkinSilver .mceMenuItemTitle a {background:#eee}
.o2k7SkinSilver .mceListBox .mceText {background:#FFF}
.o2k7SkinSilver .mceExternalToolbar, .o2k7SkinSilver .mceListBox .mceText, .o2k7SkinSilver div.mceMenu, .o2k7SkinSilver table.mceLayout, .o2k7SkinSilver .mceMenuItemTitle a, .o2k7SkinSilver table.mceLayout tr.mceFirst td, .o2k7SkinSilver table.mceLayout, .o2k7SkinSilver .mceMenuItemTitle a, .o2k7SkinSilver table.mceLayout tr.mceLast td, .o2k7SkinSilver .mceIframeContainer {border-color: #bbb}
/* Generic */
body {
font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;
-/*scrollbar-3dlight-color:#F0F0EE;
-scrollbar-arrow-color:#676662;
-scrollbar-base-color:#F0F0EE;
-scrollbar-darkshadow-color:#DDDDDD;
-scrollbar-face-color:#E0E0DD;
-scrollbar-highlight-color:#F0F0EE;
-scrollbar-shadow-color:#F0F0EE;
-scrollbar-track-color:#F5F5F5;*/
-background:#E4F2FD;
+background:#f1f1f1;
padding:0;
margin:8px 8px 0 8px;
}
-html {background:#E4F2FD;}
+html {background:#f1f1f1;}
td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;}
textarea {resize:none;outline:none;}
a:link, a:visited {color:black;}
a:hover {color:#2B6FB6;}
/* Forms */
-fieldset {margin:0; padding:4px; border:1px solid #919B9C; font-family:Verdana, Arial; font-size:10px;}
+fieldset {margin:0; padding:4px; border:1px solid #dfdfdf; font-family:Verdana, Arial; font-size:10px;}
legend {color:#2B6FB6; font-weight:bold;}
label.msg {display:none;}
label.invalid {color:#EE0000; display:inline;}
input.invalid {border:1px solid #EE0000;}
-input {background:#FFF; border:1px solid #CCC;}
+input {background:#FFF; border:1px solid #dfdfdf;}
input, select, textarea {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;}
-input, select, textarea {border:1px solid #808080;}
+input, select, textarea {border:1px solid #dfdfdf;}
input.radio {border:1px none #000000; background:transparent; vertical-align:middle;}
input.checkbox {border:1px none #000000; background:transparent; vertical-align:middle;}
.input_noborder {border:0;}
/* Buttons */
-#insert, #cancel, input.mceButton, .updateButton {
-border: 1px solid #bbb;
-margin:0;
-padding:0 0 1px;
-font-weight:bold;
-font-size: 11px;
-width:94px;
-height:24px;
-background:url(img/fade-butt.png) 0 0;
-cursor:pointer;
+#insert, #cancel, #apply, .mceActionPanel .button, input.mceButton, .updateButton {
+ border: 1px solid #bbb;
+ margin:0;
+ padding:0 0 1px;
+ font-weight:bold;
+ font-size: 11px;
+ width:94px;
+ height:24px;
+ background:url(img/fade-butt.png) 0 0;
+ cursor:pointer;
+ -moz-border-radius: 3px;
+ -khtml-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
}
#insert:hover, #cancel:hover, input.mceButton:hover, .updateButton:hover,
#insert:focus, #cancel:focus, input.mceButton:focus, .updateButton:focus {
-border: 1px solid #555;
-}
+ border: 1px solid #555;
+}
/* Browse */
a.browse span {display:block; width:20px; height:18px; background:url(../../img/icons.gif) -860px 0; border:1px solid #FFF; margin-left:1px;}
.wp_themeSkin table.mceToolbar, .wp_themeSkin tr.mceFirst .mceToolbar tr td, .wp_themeSkin tr.mceLast .mceToolbar tr td {border:0; margin:0; padding:0}
.wp_themeSkin table.mceLayout {border:0;}
.wp_themeSkin .mceIframeContainer {}
-.wp_themeSkin .mceStatusbar {display:block; font-family:'MS Sans Serif',sans-serif,Verdana,Arial; font-size:9pt; line-height:16px; overflow:visible;height:20px;}
+.wp_themeSkin .mceStatusbar {
+ display: block;
+ font-family: 'MS Sans Serif',sans-serif,Verdana,Arial;
+ font-size: 9pt;
+ line-height: 16px;
+ overflow: visible;
+ height: 20px;
+ border-top-width: 1px;
+ border-top-style: solid;
+}
.wp_themeSkin .mceStatusbar div {float:left; padding:2px;}
-.wp_themeSkin .mceStatusbar a.mceResize {display:block; float:right; background:url(../../img/icons.gif) -800px 0; width:20px; height:20px; cursor:se-resize}
+.wp_themeSkin .mceStatusbar a.mceResize {
+ display: block;
+ float: right;
+ background: url(../../img/icons.gif) -800px 0;
+ width: 20px;
+ height: 20px;
+ cursor: se-resize
+}
.wp_themeSkin .mceStatusbar a:hover {text-decoration:underline}
.wp_themeSkin table.mceToolbar {margin: 0 2px 2px;}
.wp_themeSkin #content_toolbar1 {margin-top: 2px;}
padding: 1px 2px;
margin: 1px;
background-image: url(img/butt2.png);
- background-position: 2px 1px;
- background-repeat: no-repeat;
+ background-position: left top;
+ background-repeat: repeat-x;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-khtml-border-radius: 3px;
.wp_themeSkin a.mceButton span, .wp_themeSkin a.mceButton img {}
.wp_themeSkin .mceOldBoxModel a.mceButton span, .wp_themeSkin .mceOldBoxModel a.mceButton img {margin:0 0 0 1px}
.wp_themeSkin a.mceButtonEnabled:hover {
- background-position:0 -20px;
+ background-position:0 -10px;
}
.wp_themeSkin a.mceButtonActive, .wp_themeSkin a.mceButtonSelected {
- background-position:0 -20px;
+ background-image: inherit;
}
.wp_themeSkin .mceButtonDisabled .mceIcon {opacity:0.3; filter:alpha(opacity=30);}
.wp_themeSkin .mceButtonDisabled {}
text-decoration: none !important;
width:70px;
background-image: url(img/butt2.png);
- background-position: 1px 1px;
+ background-position: left top;
background-repeat: repeat-x;
font-family: Tahoma,Verdana,Arial,Helvetica;
font-size: 11px;
height: 20px;
border-collapse: separate;
background-image: url(img/butt2.png);
- background-position: 1px 1px;
+ background-position: left top;
background-repeat: repeat-x;
padding: 1px;
border-left: 0 none !important;
height:20px;
width:20px;
background-image: url(img/butt2.png);
- background-position: 1px 1px;
+ background-position: left top;
background-repeat: repeat-x;
padding: 1px 2px;
}
height:20px;
border-collapse:separate;
background-image: url(img/butt2.png);
- background-position: 1px 1px;
+ background-position: left top;
background-repeat: repeat-x;
padding: 1px;
border-left: 0 none !important;
.wp_themeSkin .mceColorSplitMenu a.mceMoreColors {width:100%; height:auto; text-align:center; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; line-height:20px;}
.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover {}
.wp_themeSkin a.mceMoreColors:hover {}
-.wp_themeSkin .mceColorPreview {position:absolute; top:15px; left:2px; width:16px; height:4px; overflow:hidden}
+.wp_themeSkin .mceColorPreview {margin: -4px 0 0 2px; width:16px; height:4px; overflow:hidden}
/* Menu */
.wp_themeSkin .mceMenu {position:absolute; left:0; top:0; z-index:1000;}
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>{#advanced_dlg.code_title}</title>
- <script type="text/javascript" src="../../tiny_mce_popup.js?ver=311"></script>
- <script type="text/javascript" src="js/source_editor.js?ver=311"></script>
+ <script type="text/javascript" src="../../tiny_mce_popup.js?ver=3211"></script>
+ <script type="text/javascript" src="js/source_editor.js?ver=3211"></script>
<base target="_self" />
</head>
<body onresize="resizeInputs();" style="display:none; overflow:hidden;">
-var tinymce={majorVersion:'3',minorVersion:'1.1',releaseDate:'2008-06-25',_init:function(){var t=this,d=document,w=window,na=navigator,ua=na.userAgent,i,nl,n,base,p,v;t.isOpera=w.opera&&opera.buildNumber;t.isWebKit=/WebKit/.test(ua);t.isOldWebKit=t.isWebKit&&!w.getSelection().getRangeAt;t.isIE=!t.isWebKit&&!t.isOpera&&(/MSIE/gi).test(ua)&&(/Explorer/gi).test(na.appName);t.isIE6=t.isIE&&/MSIE [56]/.test(ua);t.isGecko=!t.isWebKit&&/Gecko/.test(ua);t.isMac=ua.indexOf('Mac')!=-1;if(w.tinyMCEPreInit){t.suffix=tinyMCEPreInit.suffix;t.baseURL=tinyMCEPreInit.base;t.query=tinyMCEPreInit.query;return;}t.suffix='';nl=d.getElementsByTagName('base');for(i=0;i<nl.length;i++){if(v=nl[i].href){if(/^https?:\/\/[^\/]+$/.test(v))v+='/';base=v?v.match(/.*\//)[0]:'';}}function getBase(n){if(n.src&&/tiny_mce(|_dev|_src|_gzip|_jquery|_prototype).js/.test(n.src)){if(/_(src|dev)\.js/g.test(n.src))t.suffix='_src';if((p=n.src.indexOf('?'))!=-1)t.query=n.src.substring(p+1);t.baseURL=n.src.substring(0,n.src.lastIndexOf('/'));if(base&&t.baseURL.indexOf('://')==-1)t.baseURL=base+t.baseURL;return t.baseURL;}return null;};nl=d.getElementsByTagName('script');for(i=0;i<nl.length;i++){if(getBase(nl[i]))return;}n=d.getElementsByTagName('head')[0];if(n){nl=n.getElementsByTagName('script');for(i=0;i<nl.length;i++){if(getBase(nl[i]))return;}}return;},is:function(o,t){var n=typeof(o);if(!t)return n!='undefined';if(t=='array'&&(o instanceof Array))return true;return n==t;},each:function(o,cb,s){var n,l;if(!o)return 0;s=s||o;if(typeof(o.length)!='undefined'){for(n=0,l=o.length;n<l;n++){if(cb.call(s,o[n],n,o)===false)return 0;}}else{for(n in o){if(o.hasOwnProperty(n)){if(cb.call(s,o[n],n,o)===false)return 0;}}}return 1;},map:function(a,f){var o=[];tinymce.each(a,function(v){o.push(f(v));});return o;},grep:function(a,f){var o=[];tinymce.each(a,function(v){if(!f||f(v))o.push(v);});return o;},inArray:function(a,v){var i,l;if(a){for(i=0,l=a.length;i<l;i++){if(a[i]===v)return i;}}return-1;},extend:function(o,e){var i,a=arguments;for(i=1;i<a.length;i++){e=a[i];tinymce.each(e,function(v,n){if(typeof(v)!=='undefined')o[n]=v;});}return o;},trim:function(s){return(s?''+s:'').replace(/^\s*|\s*$/g,'');},create:function(s,p){var t=this,sp,ns,cn,scn,c,de=0;s=/^((static) )?([\w.]+)(:([\w.]+))?/.exec(s);cn=s[3].match(/(^|\.)(\w+)$/i)[2];ns=t.createNS(s[3].replace(/\.\w+$/,''));if(ns[cn])return;if(s[2]=='static'){ns[cn]=p;if(this.onCreate)this.onCreate(s[2],s[3],ns[cn]);return;}if(!p[cn]){p[cn]=function(){};de=1;}ns[cn]=p[cn];t.extend(ns[cn].prototype,p);if(s[5]){sp=t.resolve(s[5]).prototype;scn=s[5].match(/\.(\w+)$/i)[1];c=ns[cn];if(de){ns[cn]=function(){return sp[scn].apply(this,arguments);};}else{ns[cn]=function(){this.parent=sp[scn];return c.apply(this,arguments);};}ns[cn].prototype[cn]=ns[cn];t.each(sp,function(f,n){ns[cn].prototype[n]=sp[n];});t.each(p,function(f,n){if(sp[n]){ns[cn].prototype[n]=function(){this.parent=sp[n];return f.apply(this,arguments);};}else{if(n!=cn)ns[cn].prototype[n]=f;}});}t.each(p['static'],function(f,n){ns[cn][n]=f;});if(this.onCreate)this.onCreate(s[2],s[3],ns[cn].prototype);},walk:function(o,f,n,s){s=s||this;if(o){if(n)o=o[n];tinymce.each(o,function(o,i){if(f.call(s,o,i,n)===false)return false;tinymce.walk(o,f,n,s);});}},createNS:function(n,o){var i,v;o=o||window;n=n.split('.');for(i=0;i<n.length;i++){v=n[i];if(!o[v])o[v]={};o=o[v];}return o;},resolve:function(n,o){var i,l;o=o||window;n=n.split('.');for(i=0,l=n.length;i<l;i++){o=o[n[i]];if(!o)break;}return o;},addUnload:function(f,s){var t=this,w=window;f={func:f,scope:s||this};if(!t.unloads){function unload(){var li=t.unloads,o,n;if(li){for(n in li){o=li[n];if(o&&o.func)o.func.call(o.scope,1);}if(w.detachEvent){w.detachEvent('onbeforeunload',fakeUnload);w.detachEvent('onunload',unload);}else if(w.removeEventListener)w.removeEventListener('unload',unload,false);t.unloads=o=li=w=unload=null;if(window.CollectGarbage)window.CollectGarbage();}};function fakeUnload(){var d=document;if(d.readyState=='interactive'){function stop(){d.detachEvent('onstop',stop);unload();d=null;};d.attachEvent('onstop',stop);window.setTimeout(function(){d.detachEvent('onstop',stop);},0);}};if(w.attachEvent){w.attachEvent('onunload',unload);w.attachEvent('onbeforeunload',fakeUnload);}else if(w.addEventListener)w.addEventListener('unload',unload,false);t.unloads=[f];}else t.unloads.push(f);return f;},removeUnload:function(f){var u=this.unloads,r=null;tinymce.each(u,function(o,i){if(o&&o.func==f){u.splice(i,1);r=f;return false;}});return r;},explode:function(s,d){return s?tinymce.map(s.split(d||','),tinymce.trim):s;},_addVer:function(u){var v;if(!this.query)return u;v=(u.indexOf('?')==-1?'?':'&')+this.query;if(u.indexOf('#')==-1)return u+v;return u.replace('#',v+'#');}};window.tinymce=tinymce;tinymce._init();tinymce.create('tinymce.util.Dispatcher',{scope:null,listeners:null,Dispatcher:function(s){this.scope=s||this;this.listeners=[];},add:function(cb,s){this.listeners.push({cb:cb,scope:s||this.scope});return cb;},addToTop:function(cb,s){this.listeners.unshift({cb:cb,scope:s||this.scope});return cb;},remove:function(cb){var l=this.listeners,o=null;tinymce.each(l,function(c,i){if(cb==c.cb){o=cb;l.splice(i,1);return false;}});return o;},dispatch:function(){var s,a=arguments,i,li=this.listeners,c;for(i=0;i<li.length;i++){c=li[i];s=c.cb.apply(c.scope,a);if(s===false)break;}return s;}});(function(){var each=tinymce.each;tinymce.create('tinymce.util.URI',{URI:function(u,s){var t=this,o,a,b;s=t.settings=s||{};if(/^(mailto|news|javascript|about):/i.test(u)||/^\s*#/.test(u)){t.source=u;return;}if(u.indexOf('/')===0&&u.indexOf('//')!==0)u=(s.base_uri?s.base_uri.protocol||'http':'http')+'://mce_host'+u;if(u.indexOf('://')===-1&&u.indexOf('//')!==0)u=(s.base_uri.protocol||'http')+'://mce_host'+t.toAbsPath(s.base_uri.path,u);u=u.replace(/@@/g,'(mce_at)');u=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(u);each(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],function(v,i){var s=u[i];if(s)s=s.replace(/\(mce_at\)/g,'@@');t[v]=s;});if(b=s.base_uri){if(!t.protocol)t.protocol=b.protocol;if(!t.userInfo)t.userInfo=b.userInfo;if(!t.port&&t.host=='mce_host')t.port=b.port;if(!t.host||t.host=='mce_host')t.host=b.host;t.source='';}},setPath:function(p){var t=this;p=/^(.*?)\/?(\w+)?$/.exec(p);t.path=p[0];t.directory=p[1];t.file=p[2];t.source='';t.getURI();},toRelative:function(u){var t=this,o;u=new tinymce.util.URI(u,{base_uri:t});if((u.host!='mce_host'&&t.host!=u.host&&u.host)||t.port!=u.port||t.protocol!=u.protocol)return u.getURI();o=t.toRelPath(t.path,u.path);if(u.query)o+='?'+u.query;if(u.anchor)o+='#'+u.anchor;return o;},toAbsolute:function(u,nh){var u=new tinymce.util.URI(u,{base_uri:this});return u.getURI(this.host==u.host?nh:0);},toRelPath:function(base,path){var items,bp=0,out='',i;base=base.substring(0,base.lastIndexOf('/'));base=base.split('/');items=path.split('/');if(base.length>=items.length){for(i=0;i<base.length;i++){if(i>=items.length||base[i]!=items[i]){bp=i+1;break;}}}if(base.length<items.length){for(i=0;i<items.length;i++){if(i>=base.length||base[i]!=items[i]){bp=i+1;break;}}}if(bp==1)return path;for(i=0;i<base.length-(bp-1);i++)out+="../";for(i=bp-1;i<items.length;i++){if(i!=bp-1)out+="/"+items[i];else out+=items[i];}return out;},toAbsPath:function(base,path){var i,nb=0,o=[];base=base.split('/');path=path.split('/');each(base,function(k){if(k)o.push(k);});base=o;for(i=path.length-1,o=[];i>=0;i--){if(path[i].length==0||path[i]==".")continue;if(path[i]=='..'){nb++;continue;}if(nb>0){nb--;continue;}o.push(path[i]);}i=base.length-nb;if(i<=0)return'/'+o.reverse().join('/');return'/'+base.slice(0,i).join('/')+'/'+o.reverse().join('/');},getURI:function(nh){var s,t=this;if(!t.source||nh){s='';if(!nh){if(t.protocol)s+=t.protocol+'://';if(t.userInfo)s+=t.userInfo+'@';if(t.host)s+=t.host;if(t.port)s+=':'+t.port;}if(t.path)s+=t.path;if(t.query)s+='?'+t.query;if(t.anchor)s+='#'+t.anchor;t.source=s;}return t.source;}});})();(function(){var each=tinymce.each;tinymce.create('static tinymce.util.Cookie',{getHash:function(n){var v=this.get(n),h;if(v){each(v.split('&'),function(v){v=v.split('=');h=h||{};h[unescape(v[0])]=unescape(v[1]);});}return h;},setHash:function(n,v,e,p,d,s){var o='';each(v,function(v,k){o+=(!o?'':'&')+escape(k)+'='+escape(v);});this.set(n,o,e,p,d,s);},get:function(n){var c=document.cookie,e,p=n+"=",b;if(!c)return;b=c.indexOf("; "+p);if(b==-1){b=c.indexOf(p);if(b!=0)return null;}else b+=2;e=c.indexOf(";",b);if(e==-1)e=c.length;return unescape(c.substring(b+p.length,e));},set:function(n,v,e,p,d,s){document.cookie=n+"="+escape(v)+((e)?"; expires="+e.toGMTString():"")+((p)?"; path="+escape(p):"")+((d)?"; domain="+d:"")+((s)?"; secure":"");},remove:function(n,p){var d=new Date();d.setTime(d.getTime()-1000);this.set(n,'',d,p,d);}});})();tinymce.create('static tinymce.util.JSON',{serialize:function(o){var i,v,s=tinymce.util.JSON.serialize,t;if(o==null)return'null';t=typeof o;if(t=='string'){v='\bb\tt\nn\ff\rr\""\'\'\\\\';return'"'+o.replace(/([\u0080-\uFFFF\x00-\x1f\"\'])/g,function(a,b){i=v.indexOf(b);if(i+1)return'\\'+v.charAt(i+1);a=b.charCodeAt().toString(16);return'\\u'+'0000'.substring(a.length)+a;})+'"';}if(t=='object'){if(o instanceof Array){for(i=0,v='[';i<o.length;i++)v+=(i>0?',':'')+s(o[i]);return v+']';}v='{';for(i in o)v+=typeof o[i]!='function'?(v.length>1?',"':'"')+i+'":'+s(o[i]):'';return v+'}';}return''+o;},parse:function(s){try{return eval('('+s+')');}catch(ex){}}});tinymce.create('static tinymce.util.XHR',{send:function(o){var x,t,w=window,c=0;o.scope=o.scope||this;o.success_scope=o.success_scope||o.scope;o.error_scope=o.error_scope||o.scope;o.async=o.async===false?false:true;o.data=o.data||'';function get(s){x=0;try{x=new ActiveXObject(s);}catch(ex){}return x;};x=w.XMLHttpRequest?new XMLHttpRequest():get('Microsoft.XMLHTTP')||get('Msxml2.XMLHTTP');if(x){if(x.overrideMimeType)x.overrideMimeType(o.content_type);x.open(o.type||(o.data?'POST':'GET'),o.url,o.async);if(o.content_type)x.setRequestHeader('Content-Type',o.content_type);x.send(o.data);function ready(){if(!o.async||x.readyState==4||c++>10000){if(o.success&&c<10000&&x.status==200)o.success.call(o.success_scope,''+x.responseText,x,o);else if(o.error)o.error.call(o.error_scope,c>10000?'TIMED_OUT':'GENERAL',x,o);x=null;}else w.setTimeout(ready,10);};if(!o.async)return ready();t=w.setTimeout(ready,10);}}});(function(){var extend=tinymce.extend,JSON=tinymce.util.JSON,XHR=tinymce.util.XHR;tinymce.create('tinymce.util.JSONRequest',{JSONRequest:function(s){this.settings=extend({},s);this.count=0;},send:function(o){var ecb=o.error,scb=o.success;o=extend(this.settings,o);o.success=function(c,x){c=JSON.parse(c);if(typeof(c)=='undefined'){c={error:'JSON Parse error.'};}if(c.error)ecb.call(o.error_scope||o.scope,c.error,x);else scb.call(o.success_scope||o.scope,c.result);};o.error=function(ty,x){ecb.call(o.error_scope||o.scope,ty,x);};o.data=JSON.serialize({id:o.id||'c'+(this.count++),method:o.method,params:o.params});o.content_type='application/json';XHR.send(o);},'static':{sendRPC:function(o){return new tinymce.util.JSONRequest().send(o);}}});}());(function(){var each=tinymce.each,is=tinymce.is;var isWebKit=tinymce.isWebKit,isIE=tinymce.isIE;tinymce.create('tinymce.dom.DOMUtils',{doc:null,root:null,files:null,listeners:{},pixelStyles:/^(top|left|bottom|right|width|height|borderWidth)$/,cache:{},idPattern:/^#[\w]+$/,elmPattern:/^[\w_*]+$/,elmClassPattern:/^([\w_]*)\.([\w_]+)$/,DOMUtils:function(d,s){var t=this;t.doc=d;t.win=window;t.files={};t.cssFlicker=false;t.counter=0;t.boxModel=!tinymce.isIE||d.compatMode=="CSS1Compat";t.stdMode=d.documentMode===8;this.settings=s=tinymce.extend({keep_values:false,hex_colors:1,process_html:1},s);if(tinymce.isIE6){try{d.execCommand('BackgroundImageCache',false,true);}catch(e){t.cssFlicker=true;}}tinymce.addUnload(t.destroy,t);},getRoot:function(){var t=this,s=t.settings;return(s&&t.get(s.root_element))||t.doc.body;},getViewPort:function(w){var d,b;w=!w?this.win:w;d=w.document;b=this.boxModel?d.documentElement:d.body;return{x:w.pageXOffset||b.scrollLeft,y:w.pageYOffset||b.scrollTop,w:w.innerWidth||b.clientWidth,h:w.innerHeight||b.clientHeight};},getRect:function(e){var p,t=this,w,h;e=t.get(e);p=t.getPos(e);w=t.getStyle(e,'width');h=t.getStyle(e,'height');if(w.indexOf('px')===-1)w=0;if(h.indexOf('px')===-1)h=0;return{x:p.x,y:p.y,w:parseInt(w)||e.offsetWidth||e.clientWidth,h:parseInt(h)||e.offsetHeight||e.clientHeight};},getParent:function(n,f,r){var na,se=this.settings;n=this.get(n);if(se.strict_root)r=r||this.getRoot();if(is(f,'string')){na=f.toUpperCase();f=function(n){var s=false;if(n.nodeType==1&&na==='*'){s=true;return false;}each(na.split(','),function(v){if(n.nodeType==1&&((se.strict&&n.nodeName.toUpperCase()==v)||n.nodeName.toUpperCase()==v)){s=true;return false;}});return s;};}while(n){if(n==r)return null;if(f(n))return n;n=n.parentNode;}return null;},get:function(e){var n;if(e&&this.doc&&typeof(e)=='string'){n=e;e=this.doc.getElementById(e);if(e&&e.id!==n)return this.doc.getElementsByName(n)[1];}return e;},select:function(pa,s){var t=this,cs,c,pl,o=[],x,i,l,n;s=t.get(s)||t.doc;if(s.querySelectorAll){if(s!=t.doc){i=s.id;s.id='_mc_tmp';pa='#_mc_tmp '+pa;}l=tinymce.grep(s.querySelectorAll(pa));s.id=i;return l;}if(t.settings.strict){function get(s,n){return s.getElementsByTagName(n.toLowerCase());};}else{function get(s,n){return s.getElementsByTagName(n);};}if(t.elmPattern.test(pa)){x=get(s,pa);for(i=0,l=x.length;i<l;i++)o.push(x[i]);return o;}if(t.elmClassPattern.test(pa)){pl=t.elmClassPattern.exec(pa);x=get(s,pl[1]||'*');c=' '+pl[2]+' ';for(i=0,l=x.length;i<l;i++){n=x[i];if(n.className&&(' '+n.className+' ').indexOf(c)!==-1)o.push(n);}return o;}function collect(n){if(!n.mce_save){n.mce_save=1;o.push(n);}};function collectIE(n){if(!n.getAttribute('mce_save')){n.setAttribute('mce_save','1');o.push(n);}};function find(n,f,r){var i,l,nl=get(r,n);for(i=0,l=nl.length;i<l;i++)f(nl[i]);};each(pa.split(','),function(v,i){v=tinymce.trim(v);if(t.elmPattern.test(v)){each(get(s,v),function(n){collect(n);});return;}if(t.elmClassPattern.test(v)){x=t.elmClassPattern.exec(v);each(get(s,x[1]),function(n){if(t.hasClass(n,x[2]))collect(n);});return;}if(!(cs=t.cache[pa])){cs='x=(function(cf, s) {';pl=v.split(' ');each(pl,function(v){var p=/^([\w\\*]+)?(?:#([\w\\]+))?(?:\.([\w\\\.]+))?(?:\[\@([\w\\]+)([\^\$\*!]?=)([\w\\]+)\])?(?:\:([\w\\]+))?/i.exec(v);p[1]=p[1]||'*';cs+='find("'+p[1]+'", function(n) {';if(p[2])cs+='if (n.id !== "'+p[2]+'") return;';if(p[3]){cs+='var c = " " + n.className + " ";';cs+='if (';c='';each(p[3].split('.'),function(v){if(v)c+=(c?'||':'')+'c.indexOf(" '+v+' ") === -1';});cs+=c+') return;';}});cs+='cf(n);';for(i=pl.length-1;i>=0;i--)cs+='}, '+(i?'n':'s')+');';cs+='})';t.cache[pa]=cs=eval(cs);}cs(isIE?collectIE:collect,s);});each(o,function(n){if(isIE)n.removeAttribute('mce_save');else delete n.mce_save;});return o;},add:function(p,n,a,h,c){var t=this;return this.run(p,function(p){var e,k;e=is(n,'string')?t.doc.createElement(n):n;if(a){for(k in a){if(a.hasOwnProperty(k)&&!is(a[k],'object'))t.setAttrib(e,k,''+a[k]);}if(a.style&&!is(a.style,'string')){each(a.style,function(v,n){t.setStyle(e,n,v);});}}if(h){if(h.nodeType)e.appendChild(h);else t.setHTML(e,h);}return!c?p.appendChild(e):e;});},create:function(n,a,h){return this.add(this.doc.createElement(n),n,a,h,1);},createHTML:function(n,a,h){var o='',t=this,k;o+='<'+n;for(k in a){if(a.hasOwnProperty(k))o+=' '+k+'="'+t.encode(a[k])+'"';}if(tinymce.is(h))return o+'>'+h+'</'+n+'>';return o+' />';},remove:function(n,k){return this.run(n,function(n){var p,g;p=n.parentNode;if(!p)return null;if(k){each(n.childNodes,function(c){p.insertBefore(c.cloneNode(true),n);});}return p.removeChild(n);});},setStyle:function(n,na,v){var t=this;return t.run(n,function(e){var s,i;s=e.style;na=na.replace(/-(\D)/g,function(a,b){return b.toUpperCase();});if(t.pixelStyles.test(na)&&(tinymce.is(v,'number')||/^[\-0-9\.]+$/.test(v)))v+='px';switch(na){case'opacity':if(isIE){s.filter=v===''?'':"alpha(opacity="+(v*100)+")";if(!n.currentStyle||!n.currentStyle.hasLayout)s.display='inline-block';}s[na]=s['-moz-opacity']=s['-khtml-opacity']=v||'';break;case'float':isIE?s.styleFloat=v:s.cssFloat=v;break;default:s[na]=v||'';}if(t.settings.update_styles)t.setAttrib(e,'mce_style');});},getStyle:function(n,na,c){n=this.get(n);if(!n)return false;if(this.doc.defaultView&&c){na=na.replace(/[A-Z]/g,function(a){return'-'+a;});try{return this.doc.defaultView.getComputedStyle(n,null).getPropertyValue(na);}catch(ex){return null;}}na=na.replace(/-(\D)/g,function(a,b){return b.toUpperCase();});if(na=='float')na=isIE?'styleFloat':'cssFloat';if(n.currentStyle&&c)return n.currentStyle[na];return n.style[na];},setStyles:function(e,o){var t=this,s=t.settings,ol;ol=s.update_styles;s.update_styles=0;each(o,function(v,n){t.setStyle(e,n,v);});s.update_styles=ol;if(s.update_styles)t.setAttrib(e,s.cssText);},setAttrib:function(e,n,v){var t=this;if(t.settings.strict)n=n.toLowerCase();return this.run(e,function(e){var s=t.settings;switch(n){case"style":if(s.keep_values){if(v&&!t._isRes(v))e.setAttribute('mce_style',v,2);else e.removeAttribute('mce_style',2);}e.style.cssText=v;break;case"class":e.className=v||'';break;case"src":case"href":if(s.keep_values){if(s.url_converter)v=s.url_converter.call(s.url_converter_scope||t,v,n,e);t.setAttrib(e,'mce_'+n,v,2);}break;case"shape":e.setAttribute('mce_style',v);break;}if(is(v)&&v!==null&&v.length!==0)e.setAttribute(n,''+v,2);else e.removeAttribute(n,2);});},setAttribs:function(e,o){var t=this;return this.run(e,function(e){each(o,function(v,n){t.setAttrib(e,n,v);});});},getAttrib:function(e,n,dv){var v,t=this;e=t.get(e);if(!e||e.nodeType!==1)return false;if(!is(dv))dv="";if(/^(src|href|style|coords|shape)$/.test(n)){v=e.getAttribute("mce_"+n);if(v)return v;}v=e.getAttribute(n,2);if(!v){switch(n){case'class':v=e.className;break;default:if(isIE&&n==='name'&&e.nodeName==='A'){v=e.name;break;}v=e.attributes[n];v=v&&is(v.nodeValue)?v.nodeValue:v;}}switch(n){case'style':v=v||e.style.cssText;if(v){v=t.serializeStyle(t.parseStyle(v));if(t.settings.keep_values&&!t._isRes(v))e.setAttribute('mce_style',v);}break;}if(isWebKit&&n==="class"&&v)v=v.replace(/(apple|webkit)\-[a-z\-]+/gi,'');if(isIE){switch(n){case'rowspan':case'colspan':if(v===1)v='';break;case'size':if(v==='+0')v='';break;case'hspace':if(v===-1)v='';break;case'maxlength':case'tabindex':if(v===32768||v===2147483647)v='';break;case'noshade':if(v===65535)return'noshade';break;case'shape':v=v.toLowerCase();break;default:if(n.indexOf('on')===0&&v)v=(''+v).replace(/^function\s+anonymous\(\)\s+\{\s+(.*)\s+\}$/,'$1');}}return(v&&v!='')?''+v:dv;},getPos:function(n){var t=this,x=0,y=0,e,d=t.doc,r;n=t.get(n);if(n&&isIE){n=n.getBoundingClientRect();e=t.boxModel?d.documentElement:d.body;x=t.getStyle(t.select('html')[0],'borderWidth');x=(x=='medium'||t.boxModel&&!t.isIE6)&&2||x;n.top+=t.win.self!=t.win.top?2:0;return{x:n.left+e.scrollLeft-x,y:n.top+e.scrollTop-x};}r=n;while(r){x+=r.offsetLeft||0;y+=r.offsetTop||0;r=r.offsetParent;}r=n;while(r){if(!/^table-row|inline.*/i.test(t.getStyle(r,"display",1))){x-=r.scrollLeft||0;y-=r.scrollTop||0;}r=r.parentNode;if(r==d.body)break;}return{x:x,y:y};},parseStyle:function(st){var t=this,s=t.settings,o={};if(!st)return o;function compress(p,s,ot){var t,r,b,l;t=o[p+'-top'+s];if(!t)return;r=o[p+'-right'+s];if(t!=r)return;b=o[p+'-bottom'+s];if(r!=b)return;l=o[p+'-left'+s];if(b!=l)return;o[ot]=l;delete o[p+'-top'+s];delete o[p+'-right'+s];delete o[p+'-bottom'+s];delete o[p+'-left'+s];};function compress2(ta,a,b,c){var t;t=o[a];if(!t)return;t=o[b];if(!t)return;t=o[c];if(!t)return;o[ta]=o[a]+' '+o[b]+' '+o[c];delete o[a];delete o[b];delete o[c];};st=st.replace(/&(#?[a-z0-9]+);/g,'&$1_MCE_SEMI_');each(st.split(';'),function(v){var sv,ur=[];if(v){v=v.replace(/_MCE_SEMI_/g,';');v=v.replace(/url\([^\)]+\)/g,function(v){ur.push(v);return'url('+ur.length+')';});v=v.split(':');sv=tinymce.trim(v[1]);sv=sv.replace(/url\(([^\)]+)\)/g,function(a,b){return ur[parseInt(b)-1];});sv=sv.replace(/rgb\([^\)]+\)/g,function(v){return t.toHex(v);});if(s.url_converter){sv=sv.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g,function(x,c){return'url('+s.url_converter.call(s.url_converter_scope||t,t.decode(c),'style',null)+')';});}o[tinymce.trim(v[0]).toLowerCase()]=sv;}});compress("border","","border");compress("border","-width","border-width");compress("border","-color","border-color");compress("border","-style","border-style");compress("padding","","padding");compress("margin","","margin");compress2('border','border-width','border-style','border-color');if(isIE){if(o.border=='medium none')o.border='';}return o;},serializeStyle:function(o){var s='';each(o,function(v,k){if(k&&v){if(tinymce.isGecko&&k.indexOf('-moz-')===0)return;switch(k){case'color':case'background-color':v=v.toLowerCase();break;}s+=(s?' ':'')+k+': '+v+';';}});return s;},loadCSS:function(u){var t=this,d=t.doc;if(!u)u='';each(u.split(','),function(u){if(t.files[u])return;t.files[u]=true;t.add(t.select('head')[0],'link',{rel:'stylesheet',href:tinymce._addVer(u)});});},addClass:function(e,c){return this.run(e,function(e){var o;if(!c)return 0;if(this.hasClass(e,c))return e.className;o=this.removeClass(e,c);return e.className=(o!=''?(o+' '):'')+c;});},removeClass:function(e,c){var t=this,re;return t.run(e,function(e){var v;if(t.hasClass(e,c)){if(!re)re=new RegExp("(^|\\s+)"+c+"(\\s+|$)","g");v=e.className.replace(re,' ');return e.className=tinymce.trim(v!=' '?v:'');}return e.className;});},hasClass:function(n,c){n=this.get(n);if(!n||!c)return false;return(' '+n.className+' ').indexOf(' '+c+' ')!==-1;},show:function(e){return this.setStyle(e,'display','block');},hide:function(e){return this.setStyle(e,'display','none');},isHidden:function(e){e=this.get(e);return e.style.display=='none'||this.getStyle(e,'display')=='none';},uniqueId:function(p){return(!p?'mce_':p)+(this.counter++);},setHTML:function(e,h){var t=this;return this.run(e,function(e){var x,i,nl,n,p,x;h=t.processHTML(h);if(isIE){function set(){try{e.innerHTML='<br />'+h;e.removeChild(e.firstChild);}catch(ex){while(e.firstChild)e.firstChild.removeNode();x=t.create('div');x.innerHTML='<br />'+h;each(x.childNodes,function(n,i){if(i)e.appendChild(n);});}};if(t.settings.fix_ie_paragraphs)h=h.replace(/<p><\/p>|<p([^>]+)><\/p>|<p[^\/+]\/>/gi,'<p$1 mce_keep="true"> </p>');set();if(t.settings.fix_ie_paragraphs){nl=e.getElementsByTagName("p");for(i=nl.length-1,x=0;i>=0;i--){n=nl[i];if(!n.hasChildNodes()){if(!n.mce_keep){x=1;break;}n.removeAttribute('mce_keep');}}}if(x){h=h.replace(/<p([^>]+)>|<p>/g,'<div$1 mce_tmp="1">');h=h.replace(/<\/p>/g,'</div>');set();if(t.settings.fix_ie_paragraphs){nl=e.getElementsByTagName("DIV");for(i=nl.length-1;i>=0;i--){n=nl[i];if(n.mce_tmp){p=t.doc.createElement('p');n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi,function(a,b){var v;if(b!=='mce_tmp'){v=n.getAttribute(b);if(!v&&b==='class')v=n.className;p.setAttribute(b,v);}});for(x=0;x<n.childNodes.length;x++)p.appendChild(n.childNodes[x].cloneNode(true));n.swapNode(p);}}}}}else e.innerHTML=h;return h;});},processHTML:function(h){var t=this,s=t.settings;if(!s.process_html)return h;if(tinymce.isGecko){h=h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi,'<$1b$2>');h=h.replace(/<(\/?)em>|<em( [^>]+)>/gi,'<$1i$2>');}else if(isIE)h=h.replace(/'/g,''');h=h.replace(/<a( )([^>]+)\/>|<a\/>/gi,'<a$1$2></a>');if(s.keep_values){if(/<script|style/.test(h)){function trim(s){s=s.replace(/^[\r\n]*|[\r\n]*$/g,'');s=s.replace(/^\s*(\/\/\s*<!--|\/\/\s*<\[CDATA\[|<!--|<\[CDATA\[)[\r\n]*/g,'');s=s.replace(/\s*(\/\/\s*\]\]>|\/\/\s*-->|\]\]>|-->)\s*$/g,'');return s;};h=h.replace(/<script([^>]+|)>([\s\S]*?)<\/script>/g,function(v,a,b){b=trim(b);if(!a)a=' type="text/javascript"';if(b)b='<!--\n'+b+'\n// -->';return'<mce:script'+a+'>'+b+'</mce:script>';});h=h.replace(/<style([^>]+|)>([\s\S]*?)<\/style>/g,function(v,a,b){b=trim(b);return'<mce:style'+a+'><!--\n'+b+'\n--></mce:style><style'+a+' mce_bogus="1">'+b+'</style>';});}h=h.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi,function(a,n){function handle(m,b,c){var u=c;if(a.indexOf('mce_'+b)!=-1)return m;if(b=='style'){if(t._isRes(c))return m;if(s.hex_colors){u=u.replace(/rgb\([^\)]+\)/g,function(v){return t.toHex(v);});}if(s.url_converter){u=u.replace(/url\([\'\"]?([^\)\'\"]+)\)/g,function(x,c){return'url('+t.encode(s.url_converter.call(s.url_converter_scope||t,t.decode(c),b,n))+')';});}}else if(b!='coords'&&b!='shape'){if(s.url_converter)u=t.encode(s.url_converter.call(s.url_converter_scope||t,t.decode(c),b,n));}return' '+b+'="'+c+'" mce_'+b+'="'+u+'"';};a=a.replace(/ (src|href|style|coords|shape)=[\"]([^\"]+)[\"]/gi,handle);a=a.replace(/ (src|href|style|coords|shape)=[\']([^\']+)[\']/gi,handle);return a.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi,handle);});}return h;},getOuterHTML:function(e){var d;e=this.get(e);if(!e)return null;if(isIE)return e.outerHTML;d=(e.ownerDocument||this.doc).createElement("body");d.appendChild(e.cloneNode(true));return d.innerHTML;},setOuterHTML:function(e,h,d){var t=this;return this.run(e,function(e){var n,tp;e=t.get(e);d=d||e.ownerDocument||t.doc;if(isIE&&e.nodeType==1)e.outerHTML=h;else{tp=d.createElement("body");tp.innerHTML=h;n=tp.lastChild;while(n){t.insertAfter(n.cloneNode(true),e);n=n.previousSibling;}t.remove(e);}});},decode:function(s){var e;if(/&[^;]+;/.test(s)){e=this.doc.createElement("div");e.innerHTML=s;return!e.firstChild?s:e.firstChild.nodeValue;}return s;},encode:function(s){return s?(''+s).replace(/[<>&\"]/g,function(c,b){switch(c){case'&':return'&';case'"':return'"';case'<':return'<';case'>':return'>';}return c;}):s;},insertAfter:function(n,r){var t=this;r=t.get(r);return this.run(n,function(n){var p,ns;p=r.parentNode;ns=r.nextSibling;if(ns)p.insertBefore(n,ns);else p.appendChild(n);return n;});},isBlock:function(n){if(n.nodeType&&n.nodeType!==1)return false;n=n.nodeName||n;return/^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n);},replace:function(n,o,k){if(is(o,'array'))n=n.cloneNode(true);return this.run(o,function(o){if(k){each(o.childNodes,function(c){n.appendChild(c.cloneNode(true));});}return o.parentNode.replaceChild(n,o);});},toHex:function(s){var c=/^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(s);function hex(s){s=parseInt(s).toString(16);return s.length>1?s:'0'+s;};if(c){s='#'+hex(c[1])+hex(c[2])+hex(c[3]);return s;}return s;},getClasses:function(){var t=this,cl=[],i,lo={},f=t.settings.class_filter,ov;if(t.classes)return t.classes;function addClasses(s){each(s.imports,function(r){addClasses(r);});each(s.cssRules||s.rules,function(r){switch(r.type||1){case 1:if(r.selectorText){each(r.selectorText.split(','),function(v){v=v.replace(/^\s*|\s*$|^\s\./g,"");if(/\.mce/.test(v)||!/\.[\w\-]+$/.test(v))return;ov=v;v=v.replace(/.*\.([a-z0-9_\-]+).*/i,'$1');if(f&&!(v=f(v,ov)))return;if(!lo[v]){cl.push({'class':v});lo[v]=1;}});}break;case 3:addClasses(r.styleSheet);break;}});};try{each(t.doc.styleSheets,addClasses);}catch(ex){}if(cl.length>0)t.classes=cl;return cl;},run:function(e,f,s){var t=this,o;if(t.doc&&typeof(e)==='string')e=t.doc.getElementById(e);if(!e)return false;s=s||this;if(!e.nodeType&&(e.length||e.length===0)){o=[];each(e,function(e,i){if(e){if(typeof(e)=='string')e=t.doc.getElementById(e);o.push(f.call(s,e,i));}});return o;}return f.call(s,e);},getAttribs:function(n){var o;n=this.get(n);if(!n)return[];if(isIE){o=[];if(n.nodeName=='OBJECT')return n.attributes;n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi,function(a,b){o.push({specified:1,nodeName:b});});return o;}return n.attributes;},destroy:function(s){var t=this;t.win=t.doc=t.root=null;if(!s)tinymce.removeUnload(t.destroy);},_isRes:function(c){return/^(top|left|bottom|right|width|height)/i.test(c)||/;\s*(top|left|bottom|right|width|height)/i.test(c);}});tinymce.DOM=new tinymce.dom.DOMUtils(document,{process_html:0});})();(function(){var each=tinymce.each,DOM=tinymce.DOM,isIE=tinymce.isIE,isWebKit=tinymce.isWebKit,Event;tinymce.create('static tinymce.dom.Event',{inits:[],events:[],add:function(o,n,f,s){var cb,t=this,el=t.events,r;if(o&&o instanceof Array){r=[];each(o,function(o){o=DOM.get(o);r.push(t.add(o,n,f,s));});return r;}o=DOM.get(o);if(!o)return;cb=function(e){e=e||window.event;if(e&&!e.target&&isIE)e.target=e.srcElement;if(!s)return f(e);return f.call(s,e);};if(n=='unload'){tinymce.unloads.unshift({func:cb});return cb;}if(n=='init'){if(t.domLoaded)cb();else t.inits.push(cb);return cb;}el.push({obj:o,name:n,func:f,cfunc:cb,scope:s});t._add(o,n,cb);return f;},remove:function(o,n,f){var t=this,a=t.events,s=false,r;if(o&&o instanceof Array){r=[];each(o,function(o){o=DOM.get(o);r.push(t.remove(o,n,f));});return r;}o=DOM.get(o);each(a,function(e,i){if(e.obj==o&&e.name==n&&(!f||(e.func==f||e.cfunc==f))){a.splice(i,1);t._remove(o,n,e.cfunc);s=true;return false;}});return s;},clear:function(o){var t=this,a=t.events,i,e;if(o){o=DOM.get(o);for(i=a.length-1;i>=0;i--){e=a[i];if(e.obj===o){t._remove(e.obj,e.name,e.cfunc);e.obj=e.cfunc=null;a.splice(i,1);}}}},cancel:function(e){if(!e)return false;this.stop(e);return this.prevent(e);},stop:function(e){if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true;return false;},prevent:function(e){if(e.preventDefault)e.preventDefault();else e.returnValue=false;return false;},_unload:function(){var t=Event;each(t.events,function(e,i){t._remove(e.obj,e.name,e.cfunc);e.obj=e.cfunc=null;});t.events=[];t=null;},_add:function(o,n,f){if(o.attachEvent)o.attachEvent('on'+n,f);else if(o.addEventListener)o.addEventListener(n,f,false);else o['on'+n]=f;},_remove:function(o,n,f){if(o){try{if(o.detachEvent)o.detachEvent('on'+n,f);else if(o.removeEventListener)o.removeEventListener(n,f,false);else o['on'+n]=null;}catch(ex){}}},_pageInit:function(){var e=Event;e._remove(window,'DOMContentLoaded',e._pageInit);e.domLoaded=true;each(e.inits,function(c){c();});e.inits=[];},_wait:function(){var t;if(window.tinyMCE_GZ&&tinyMCE_GZ.loaded){Event.domLoaded=1;return;}if(isIE&&document.location.protocol!='https:'){document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');DOM.get("__ie_onload").onreadystatechange=function(){if(this.readyState=="complete"){Event._pageInit();DOM.get("__ie_onload").onreadystatechange=null;}};}else{Event._add(window,'DOMContentLoaded',Event._pageInit,Event);if(isIE||isWebKit){t=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(t);Event._pageInit();}},10);}}}});Event=tinymce.dom.Event;Event._wait();tinymce.addUnload(Event._unload);})();(function(){var each=tinymce.each;tinymce.create('tinymce.dom.Element',{Element:function(id,s){var t=this,dom,el;s=s||{};t.id=id;t.dom=dom=s.dom||tinymce.DOM;t.settings=s;if(!tinymce.isIE)el=t.dom.get(t.id);each(['getPos','getRect','getParent','add','setStyle','getStyle','setStyles','setAttrib','setAttribs','getAttrib','addClass','removeClass','hasClass','getOuterHTML','setOuterHTML','remove','show','hide','isHidden','setHTML','get'],function(k){t[k]=function(){var a=arguments,o;if(tinymce.isOpera){a=[id];each(arguments,function(v){a.push(v);});}else Array.prototype.unshift.call(a,el||id);o=dom[k].apply(dom,a);t.update(k);return o;};});},on:function(n,f,s){return tinymce.dom.Event.add(this.id,n,f,s);},getXY:function(){return{x:parseInt(this.getStyle('left')),y:parseInt(this.getStyle('top'))};},getSize:function(){var n=this.dom.get(this.id);return{w:parseInt(this.getStyle('width')||n.clientWidth),h:parseInt(this.getStyle('height')||n.clientHeight)};},moveTo:function(x,y){this.setStyles({left:x,top:y});},moveBy:function(x,y){var p=this.getXY();this.moveTo(p.x+x,p.y+y);},resizeTo:function(w,h){this.setStyles({width:w,height:h});},resizeBy:function(w,h){var s=this.getSize();this.resizeTo(s.w+w,s.h+h);},update:function(k){var t=this,b,dom=t.dom;if(tinymce.isIE6&&t.settings.blocker){k=k||'';if(k.indexOf('get')===0||k.indexOf('has')===0||k.indexOf('is')===0)return;if(k=='remove'){dom.remove(t.blocker);return;}if(!t.blocker){t.blocker=dom.uniqueId();b=dom.add(t.settings.container||dom.getRoot(),'iframe',{id:t.blocker,style:'position:absolute;',frameBorder:0,src:'javascript:""'});dom.setStyle(b,'opacity',0);}else b=dom.get(t.blocker);dom.setStyle(b,'left',t.getStyle('left',1));dom.setStyle(b,'top',t.getStyle('top',1));dom.setStyle(b,'width',t.getStyle('width',1));dom.setStyle(b,'height',t.getStyle('height',1));dom.setStyle(b,'display',t.getStyle('display',1));dom.setStyle(b,'zIndex',parseInt(t.getStyle('zIndex',1)||0)-1);}}});})();(function(){function trimNl(s){return s.replace(/[\n\r]+/g,'');};var is=tinymce.is,isIE=tinymce.isIE,each=tinymce.each;tinymce.create('tinymce.dom.Selection',{Selection:function(dom,win,serializer){var t=this;t.dom=dom;t.win=win;t.serializer=serializer;tinymce.addUnload(t.destroy,t);},getContent:function(s){var t=this,r=t.getRng(),e=t.dom.create("body"),se=t.getSel(),wb,wa,n;s=s||{};wb=wa='';s.get=true;s.format=s.format||'html';if(s.format=='text')return t.isCollapsed()?'':(r.text||(se.toString?se.toString():''));if(r.cloneContents){n=r.cloneContents();if(n)e.appendChild(n);}else if(is(r.item)||is(r.htmlText))e.innerHTML=r.item?r.item(0).outerHTML:r.htmlText;else e.innerHTML=r.toString();if(/^\s/.test(e.innerHTML))wb=' ';if(/\s+$/.test(e.innerHTML))wa=' ';s.getInner=true;return t.isCollapsed()?'':wb+t.serializer.serialize(e,s)+wa;},setContent:function(h,s){var t=this,r=t.getRng(),d=t.win.document;s=s||{format:'html'};s.set=true;h=t.dom.processHTML(h);if(r.insertNode){if(tinymce.isGecko&&h.indexOf('<')==-1){r.deleteContents();r.insertNode(t.getRng().createContextualFragment(h+'<span id="__caret">_</span>'));t.select(t.dom.get('__caret'));t.getRng().deleteContents();return;}try{if(d.queryCommandEnabled('InsertHTML'))return d.execCommand('InsertHTML',false,h);}catch(ex){r.deleteContents();r.insertNode(t.getRng().createContextualFragment(h));}}else{if(r.item){d.execCommand('Delete',false,null);r=t.getRng();}r.pasteHTML(h);}},getStart:function(){var t=this,r=t.getRng(),e;if(isIE){if(r.item)return r.item(0);r=r.duplicate();r.collapse(1);e=r.parentElement();if(e&&e.nodeName=='BODY')return e.firstChild;return e;}else{e=r.startContainer;if(e.nodeName=='BODY')return e.firstChild;return t.dom.getParent(e,function(n){return n.nodeType==1;});}},getEnd:function(){var t=this,r=t.getRng(),e;if(isIE){if(r.item)return r.item(0);r=r.duplicate();r.collapse(0);e=r.parentElement();if(e&&e.nodeName=='BODY')return e.lastChild;return e;}else{e=r.endContainer;if(e.nodeName=='BODY')return e.lastChild;return t.dom.getParent(e,function(n){return n.nodeType==1;});}},getBookmark:function(si){var t=this,r=t.getRng(),tr,sx,sy,vp=t.dom.getViewPort(t.win),e,sp,bp,le,c=-0xFFFFFF,s,ro=t.dom.getRoot(),wb=0,wa=0,nv;sx=vp.x;sy=vp.y;if(si=='simple')return{rng:r,scrollX:sx,scrollY:sy};if(isIE){if(r.item){e=r.item(0);each(t.dom.select(e.nodeName),function(n,i){if(e==n){sp=i;return false;}});return{tag:e.nodeName,index:sp,scrollX:sx,scrollY:sy};}tr=t.dom.doc.body.createTextRange();tr.moveToElementText(ro);tr.collapse(true);bp=Math.abs(tr.move('character',c));tr=r.duplicate();tr.collapse(true);sp=Math.abs(tr.move('character',c));tr=r.duplicate();tr.collapse(false);le=Math.abs(tr.move('character',c))-sp;return{start:sp-bp,length:le,scrollX:sx,scrollY:sy};}e=t.getNode();s=t.getSel();if(!s)return null;if(e&&e.nodeName=='IMG'){return{scrollX:sx,scrollY:sy};}function getPos(r,sn,en){var w=t.dom.doc.createTreeWalker(r,NodeFilter.SHOW_TEXT,null,false),n,p=0,d={};while((n=w.nextNode())!=null){if(n==sn)d.start=p;if(n==en){d.end=p;return d;}p+=trimNl(n.nodeValue||'').length;}return null;};if(s.anchorNode==s.focusNode&&s.anchorOffset==s.focusOffset){e=getPos(ro,s.anchorNode,s.focusNode);if(!e)return{scrollX:sx,scrollY:sy};trimNl(s.anchorNode.nodeValue||'').replace(/^\s+/,function(a){wb=a.length;});return{start:Math.max(e.start+s.anchorOffset-wb,0),end:Math.max(e.end+s.focusOffset-wb,0),scrollX:sx,scrollY:sy,beg:s.anchorOffset-wb==0};}else{e=getPos(ro,r.startContainer,r.endContainer);if(!e)return{scrollX:sx,scrollY:sy};return{start:Math.max(e.start+r.startOffset-wb,0),end:Math.max(e.end+r.endOffset-wa,0),scrollX:sx,scrollY:sy,beg:r.startOffset-wb==0};}},moveToBookmark:function(b){var t=this,r=t.getRng(),s=t.getSel(),ro=t.dom.getRoot(),sd,nvl,nv;function getPos(r,sp,ep){var w=t.dom.doc.createTreeWalker(r,NodeFilter.SHOW_TEXT,null,false),n,p=0,d={},o,v,wa,wb;while((n=w.nextNode())!=null){wa=wb=0;nv=n.nodeValue||'';nvl=trimNl(nv).length;p+=nvl;if(p>=sp&&!d.startNode){o=sp-(p-nvl);if(b.beg&&o>=nvl)continue;d.startNode=n;d.startOffset=o+wb;}if(p>=ep){d.endNode=n;d.endOffset=ep-(p-nvl)+wb;return d;}}return null;};if(!b)return false;t.win.scrollTo(b.scrollX,b.scrollY);if(isIE){if(r=b.rng){try{r.select();}catch(ex){}return true;}t.win.focus();if(b.tag){r=ro.createControlRange();each(t.dom.select(b.tag),function(n,i){if(i==b.index)r.addElement(n);});}else{try{if(b.start<0)return true;r=s.createRange();r.moveToElementText(ro);r.collapse(true);r.moveStart('character',b.start);r.moveEnd('character',b.length);}catch(ex2){return true;}}try{r.select();}catch(ex){}return true;}if(!s)return false;if(b.rng){s.removeAllRanges();s.addRange(b.rng);}else{if(is(b.start)&&is(b.end)){try{sd=getPos(ro,b.start,b.end);if(sd){r=t.dom.doc.createRange();r.setStart(sd.startNode,sd.startOffset);r.setEnd(sd.endNode,sd.endOffset);s.removeAllRanges();s.addRange(r);}if(!tinymce.isOpera)t.win.focus();}catch(ex){}}}},select:function(n,c){var t=this,r=t.getRng(),s=t.getSel(),b,fn,ln,d=t.win.document;function first(n){return n?d.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,false).nextNode():null;};function last(n){var c,o,w;if(!n)return null;w=d.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,false);while(c=w.nextNode())o=c;return o;};if(isIE){try{b=d.body;if(/^(IMG|TABLE)$/.test(n.nodeName)){r=b.createControlRange();r.addElement(n);}else{r=b.createTextRange();r.moveToElementText(n);}r.select();}catch(ex){}}else{if(c){fn=first(n);ln=last(n);if(fn&&ln){r=d.createRange();r.setStart(fn,0);r.setEnd(ln,ln.nodeValue.length);}else r.selectNode(n);}else r.selectNode(n);t.setRng(r);}return n;},isCollapsed:function(){var t=this,r=t.getRng(),s=t.getSel();if(!r||r.item)return false;return!s||r.boundingWidth==0||s.isCollapsed;},collapse:function(b){var t=this,r=t.getRng(),n;if(r.item){n=r.item(0);r=this.win.document.body.createTextRange();r.moveToElementText(n);}r.collapse(!!b);t.setRng(r);},getSel:function(){var t=this,w=this.win;return w.getSelection?w.getSelection():w.document.selection;},getRng:function(){var t=this,s=t.getSel(),r;try{if(s)r=s.rangeCount>0?s.getRangeAt(0):(s.createRange?s.createRange():t.win.document.createRange());}catch(ex){}if(!r)r=isIE?t.win.document.body.createTextRange():t.win.document.createRange();return r;},setRng:function(r){var s;if(!isIE){s=this.getSel();if(s){s.removeAllRanges();s.addRange(r);}}else{try{r.select();}catch(ex){}}},setNode:function(n){var t=this;t.setContent(t.dom.getOuterHTML(n));return n;},getNode:function(){var t=this,r=t.getRng(),s=t.getSel(),e;if(!isIE){if(!r)return t.dom.getRoot();e=r.commonAncestorContainer;if(!r.collapsed){if(tinymce.isWebKit&&s.anchorNode&&s.anchorNode.nodeType==1)return s.anchorNode.childNodes[s.anchorOffset];if(r.startContainer==r.endContainer){if(r.startOffset-r.endOffset<2){if(r.startContainer.hasChildNodes())e=r.startContainer.childNodes[r.startOffset];}}}return t.dom.getParent(e,function(n){return n.nodeType==1;});}return r.item?r.item(0):r.parentElement();},destroy:function(s){var t=this;t.win=null;if(!s)tinymce.removeUnload(t.destroy);}});})();(function(){tinymce.create('tinymce.dom.XMLWriter',{node:null,XMLWriter:function(s){function getXML(){var i=document.implementation;if(!i||!i.createDocument){try{return new ActiveXObject('MSXML2.DOMDocument');}catch(ex){}try{return new ActiveXObject('Microsoft.XmlDom');}catch(ex){}}else return i.createDocument('','',null);};this.doc=getXML();this.valid=tinymce.isOpera||tinymce.isWebKit;this.reset();},reset:function(){var t=this,d=t.doc;if(d.firstChild)d.removeChild(d.firstChild);t.node=d.appendChild(d.createElement("html"));},writeStartElement:function(n){var t=this;t.node=t.node.appendChild(t.doc.createElement(n));},writeAttribute:function(n,v){if(this.valid)v=v.replace(/>/g,'%MCGT%');this.node.setAttribute(n,v);},writeEndElement:function(){this.node=this.node.parentNode;},writeFullEndElement:function(){var t=this,n=t.node;n.appendChild(t.doc.createTextNode(""));t.node=n.parentNode;},writeText:function(v){if(this.valid)v=v.replace(/>/g,'%MCGT%');this.node.appendChild(this.doc.createTextNode(v));},writeCDATA:function(v){this.node.appendChild(this.doc.createCDATA(v));},writeComment:function(v){this.node.appendChild(this.doc.createComment(v.replace(/\-\-/g,' ')));},getContent:function(){var h;h=this.doc.xml||new XMLSerializer().serializeToString(this.doc);h=h.replace(/<\?[^?]+\?>|<html>|<\/html>|<html\/>|<!DOCTYPE[^>]+>/g,'');h=h.replace(/ ?\/>/g,' />');if(this.valid)h=h.replace(/\%MCGT%/g,'>');return h;}});})();(function(){tinymce.create('tinymce.dom.StringWriter',{str:null,tags:null,count:0,settings:null,indent:null,StringWriter:function(s){this.settings=tinymce.extend({indent_char:' ',indentation:1},s);this.reset();},reset:function(){this.indent='';this.str="";this.tags=[];this.count=0;},writeStartElement:function(n){this._writeAttributesEnd();this.writeRaw('<'+n);this.tags.push(n);this.inAttr=true;this.count++;this.elementCount=this.count;},writeAttribute:function(n,v){var t=this;t.writeRaw(" "+t.encode(n)+'="'+t.encode(v)+'"');},writeEndElement:function(){var n;if(this.tags.length>0){n=this.tags.pop();if(this._writeAttributesEnd(1))this.writeRaw('</'+n+'>');if(this.settings.indentation>0)this.writeRaw('\n');}},writeFullEndElement:function(){if(this.tags.length>0){this._writeAttributesEnd();this.writeRaw('</'+this.tags.pop()+'>');if(this.settings.indentation>0)this.writeRaw('\n');}},writeText:function(v){this._writeAttributesEnd();this.writeRaw(this.encode(v));this.count++;},writeCDATA:function(v){this._writeAttributesEnd();this.writeRaw('<![CDATA['+v+']]>');this.count++;},writeComment:function(v){this._writeAttributesEnd();this.writeRaw('<!-- '+v+'-->');this.count++;},writeRaw:function(v){this.str+=v;},encode:function(s){return s.replace(/[<>&"]/g,function(v){switch(v){case'<':return'<';case'>':return'>';case'&':return'&';case'"':return'"';}return v;});},getContent:function(){return this.str;},_writeAttributesEnd:function(s){if(!this.inAttr)return;this.inAttr=false;if(s&&this.elementCount==this.count){this.writeRaw(' />');return false;}this.writeRaw('>');return true;}});})();(function(){var extend=tinymce.extend,each=tinymce.each,Dispatcher=tinymce.util.Dispatcher,isIE=tinymce.isIE,isGecko=tinymce.isGecko;function getIEAtts(n){var o=[];if(n.nodeName=='OBJECT')return n.attributes;n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi,function(a,b){o.push({specified:1,nodeName:b});});return o;};function wildcardToRE(s){return s.replace(/([?+*])/g,'.$1');};tinymce.create('tinymce.dom.Serializer',{Serializer:function(s){var t=this;t.key=0;t.onPreProcess=new Dispatcher(t);t.onPostProcess=new Dispatcher(t);if(tinymce.relaxedDomain&&tinymce.isGecko){t.writer=new tinymce.dom.StringWriter();}else{try{t.writer=new tinymce.dom.XMLWriter();}catch(ex){t.writer=new tinymce.dom.StringWriter();}}t.settings=s=extend({dom:tinymce.DOM,valid_nodes:0,node_filter:0,attr_filter:0,invalid_attrs:/^(mce_|_moz_)/,closed:/(br|hr|input|meta|img|link|param)/,entity_encoding:'named',entities:'160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro',valid_elements:'*[*]',extended_valid_elements:0,valid_child_elements:0,invalid_elements:0,fix_table_elements:0,fix_list_elements:true,fix_content_duplication:true,convert_fonts_to_spans:false,font_size_classes:0,font_size_style_values:0,apply_source_formatting:0,indent_mode:'simple',indent_char:'\t',indent_levels:1,remove_linebreaks:1},s);t.dom=s.dom;if(s.fix_list_elements){t.onPreProcess.add(function(se,o){var nl,x,a=['ol','ul'],i,n,p,r=/^(OL|UL)$/,np;function prevNode(e,n){var a=n.split(','),i;while((e=e.previousSibling)!=null){for(i=0;i<a.length;i++){if(e.nodeName==a[i])return e;}}return null;};for(x=0;x<a.length;x++){nl=t.dom.select(a[x],o.node);for(i=0;i<nl.length;i++){n=nl[i];p=n.parentNode;if(r.test(p.nodeName)){np=prevNode(n,'LI');if(!np){np=t.dom.create('li');np.innerHTML=' ';np.appendChild(n);p.insertBefore(np,p.firstChild);}else np.appendChild(n);}}}});}if(s.fix_table_elements){t.onPreProcess.add(function(se,o){each(t.dom.select('table',o.node),function(e){var pa=t.dom.getParent(e,'H1,H2,H3,H4,H5,H6,P'),pa2,n,tm,pl=[],i,ns;if(pa){pa2=pa.cloneNode(false);pl.push(e);for(n=e;n=n.parentNode;){pl.push(n);if(n==pa)break;}tm=pa2;for(i=pl.length-1;i>=0;i--){if(i==pl.length-1){while(ns=pl[i-1].nextSibling)tm.appendChild(ns.parentNode.removeChild(ns));}else{n=pl[i].cloneNode(false);if(i!=0){while(ns=pl[i-1].nextSibling)n.appendChild(ns.parentNode.removeChild(ns));}tm=tm.appendChild(n);}}e=t.dom.insertAfter(e.parentNode.removeChild(e),pa);t.dom.insertAfter(e,pa);t.dom.insertAfter(pa2,e);}});});}},setEntities:function(s){var t=this,a,i,l={},re='',v;if(t.entityLookup)return;a=s.split(',');for(i=0;i<a.length;i+=2){v=a[i];if(v==34||v==38||v==60||v==62)continue;l[String.fromCharCode(a[i])]=a[i+1];v=parseInt(a[i]).toString(16);re+='\\u'+'0000'.substring(v.length)+v;}if(!re){t.settings.entity_encoding='raw';return;}t.entitiesRE=new RegExp('['+re+']','g');t.entityLookup=l;},setValidChildRules:function(s){this.childRules=null;this.addValidChildRules(s);},addValidChildRules:function(s){var t=this,inst,intr,bloc;if(!s)return;inst='A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment';intr='A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment';bloc='H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP';each(s.split(','),function(s){var p=s.split(/\[|\]/),re;s='';each(p[1].split('|'),function(v){if(s)s+='|';switch(v){case'%itrans':v=intr;break;case'%itrans_na':v=intr.substring(2);break;case'%istrict':v=inst;break;case'%istrict_na':v=inst.substring(2);break;case'%btrans':v=bloc;break;case'%bstrict':v=bloc;break;}s+=v;});re=new RegExp('^('+s.toLowerCase()+')$','i');each(p[0].split('/'),function(s){t.childRules=t.childRules||{};t.childRules[s]=re;});});s='';each(t.childRules,function(v,k){if(s)s+='|';s+=k;});t.parentElementsRE=new RegExp('^('+s.toLowerCase()+')$','i');},setRules:function(s){var t=this;t._setup();t.rules={};t.wildRules=[];t.validElements={};return t.addRules(s);},addRules:function(s){var t=this,dr;if(!s)return;t._setup();each(s.split(','),function(s){var p=s.split(/\[|\]/),tn=p[0].split('/'),ra,at,wat,va=[];if(dr)at=tinymce.extend([],dr.attribs);if(p.length>1){each(p[1].split('|'),function(s){var ar={},i;at=at||[];s=s.replace(/::/g,'~');s=/^([!\-])?([\w*.?~_\-]+|)([=:<])?(.+)?$/.exec(s);s[2]=s[2].replace(/~/g,':');if(s[1]=='!'){ra=ra||[];ra.push(s[2]);}if(s[1]=='-'){for(i=0;i<at.length;i++){if(at[i].name==s[2]){at.splice(i,1);return;}}}switch(s[3]){case'=':ar.defaultVal=s[4]||'';break;case':':ar.forcedVal=s[4];break;case'<':ar.validVals=s[4].split('?');break;}if(/[*.?]/.test(s[2])){wat=wat||[];ar.nameRE=new RegExp('^'+wildcardToRE(s[2])+'$');wat.push(ar);}else{ar.name=s[2];at.push(ar);}va.push(s[2]);});}each(tn,function(s,i){var pr=s.charAt(0),x=1,ru={};if(dr){if(dr.noEmpty)ru.noEmpty=dr.noEmpty;if(dr.fullEnd)ru.fullEnd=dr.fullEnd;if(dr.padd)ru.padd=dr.padd;}switch(pr){case'-':ru.noEmpty=true;break;case'+':ru.fullEnd=true;break;case'#':ru.padd=true;break;default:x=0;}tn[i]=s=s.substring(x);t.validElements[s]=1;if(/[*.?]/.test(tn[0])){ru.nameRE=new RegExp('^'+wildcardToRE(tn[0])+'$');t.wildRules=t.wildRules||{};t.wildRules.push(ru);}else{ru.name=tn[0];if(tn[0]=='@')dr=ru;t.rules[s]=ru;}ru.attribs=at;if(ra)ru.requiredAttribs=ra;if(wat){s='';each(va,function(v){if(s)s+='|';s+='('+wildcardToRE(v)+')';});ru.validAttribsRE=new RegExp('^'+s.toLowerCase()+'$');ru.wildAttribs=wat;}});});s='';each(t.validElements,function(v,k){if(s)s+='|';if(k!='@')s+=k;});t.validElementsRE=new RegExp('^('+wildcardToRE(s.toLowerCase())+')$');},findRule:function(n){var t=this,rl=t.rules,i,r;t._setup();r=rl[n];if(r)return r;rl=t.wildRules;for(i=0;i<rl.length;i++){if(rl[i].nameRE.test(n))return rl[i];}return null;},findAttribRule:function(ru,n){var i,wa=ru.wildAttribs;for(i=0;i<wa.length;i++){if(wa[i].nameRE.test(n))return wa[i];}return null;},serialize:function(n,o){var h,t=this;t._setup();o=o||{};o.format=o.format||'html';t.processObj=o;n=n.cloneNode(true);t.key=''+(parseInt(t.key)+1);if(!o.no_events){o.node=n;t.onPreProcess.dispatch(t,o);}t.writer.reset();t._serializeNode(n,o.getInner);o.content=t.writer.getContent();if(!o.no_events)t.onPostProcess.dispatch(t,o);t._postProcess(o);o.node=null;return tinymce.trim(o.content);},_postProcess:function(o){var t=this,s=t.settings,h=o.content,sc=[],p;if(o.format=='html'){p=t._protect({content:h,patterns:[{pattern:/(<script[^>]*>)(.*?)(<\/script>)/g},{pattern:/(<style[^>]*>)(.*?)(<\/style>)/g},{pattern:/(<pre[^>]*>)(.*?)(<\/pre>)/g,encode:1}]});h=p.content;if(s.entity_encoding!=='raw')h=t._encode(h);if(!o.set){h=h.replace(/<p>\s+<\/p>|<p([^>]+)>\s+<\/p>/g,s.entity_encoding=='numeric'?'<p$1> </p>':'<p$1> </p>');if(s.remove_linebreaks){h=h.replace(/\r?\n|\r/g,' ');h=h.replace(/(<[^>]+>)\s+/g,'$1 ');h=h.replace(/\s+(<\/[^>]+>)/g,' $1');h=h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object) ([^>]+)>\s+/g,'<$1 $2>');h=h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>\s+/g,'<$1>');h=h.replace(/\s+<\/(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>/g,'</$1>');}if(s.apply_source_formatting&&s.indent_mode=='simple'){h=h.replace(/<(\/?)(ul|hr|table|meta|link|tbody|tr|object|body|head|html|map)(|[^>]+)>\s*/g,'\n<$1$2$3>\n');h=h.replace(/\s*<(p|h[1-6]|blockquote|div|title|style|pre|script|td|li|area)(|[^>]+)>/g,'\n<$1$2>');h=h.replace(/<\/(p|h[1-6]|blockquote|div|title|style|pre|script|td|li)>\s*/g,'</$1>\n');h=h.replace(/\n\n/g,'\n');}}h=t._unprotect(h,p);if(s.entity_encoding=='raw')h=h.replace(/<p> <\/p>|<p([^>]+)> <\/p>/g,'<p$1>\u00a0</p>');}o.content=h;},_serializeNode:function(n,inn){var t=this,s=t.settings,w=t.writer,hc,el,cn,i,l,a,at,no,v,nn,ru,ar,iv;if(!s.node_filter||s.node_filter(n)){switch(n.nodeType){case 1:if(n.hasAttribute?n.hasAttribute('mce_bogus'):n.getAttribute('mce_bogus'))return;iv=false;hc=n.hasChildNodes();nn=n.getAttribute('mce_name')||n.nodeName.toLowerCase();if(isIE){if(n.scopeName!=='HTML'&&n.scopeName!=='html')nn=n.scopeName+':'+nn;}if(nn.indexOf('mce:')===0)nn=nn.substring(4);if(!t.validElementsRE.test(nn)||(t.invalidElementsRE&&t.invalidElementsRE.test(nn))||inn){iv=true;break;}if(isIE){if(s.fix_content_duplication){if(n.mce_serialized==t.key)return;n.mce_serialized=t.key;}if(nn.charAt(0)=='/')nn=nn.substring(1);}else if(isGecko){if(n.nodeName==='BR'&&n.getAttribute('type')=='_moz')return;}if(t.childRules){if(t.parentElementsRE.test(t.elementName)){if(!t.childRules[t.elementName].test(nn)){iv=true;break;}}t.elementName=nn;}ru=t.findRule(nn);nn=ru.name||nn;if((!hc&&ru.noEmpty)||(isIE&&!nn)){iv=true;break;}if(ru.requiredAttribs){a=ru.requiredAttribs;for(i=a.length-1;i>=0;i--){if(this.dom.getAttrib(n,a[i])!=='')break;}if(i==-1){iv=true;break;}}w.writeStartElement(nn);if(ru.attribs){for(i=0,at=ru.attribs,l=at.length;i<l;i++){a=at[i];v=t._getAttrib(n,a);if(v!==null)w.writeAttribute(a.name,v);}}if(ru.validAttribsRE){at=isIE?getIEAtts(n):n.attributes;for(i=at.length-1;i>-1;i--){no=at[i];if(no.specified){a=no.nodeName.toLowerCase();if(s.invalid_attrs.test(a)||!ru.validAttribsRE.test(a))continue;ar=t.findAttribRule(ru,a);v=t._getAttrib(n,ar,a);if(v!==null)w.writeAttribute(a,v);}}}if(!hc&&ru.padd)w.writeText('\u00a0');break;case 3:if(t.childRules&&t.parentElementsRE.test(t.elementName)){if(!t.childRules[t.elementName].test(n.nodeName))return;}return w.writeText(n.nodeValue);case 4:return w.writeCDATA(n.nodeValue);case 8:return w.writeComment(n.nodeValue);}}else if(n.nodeType==1)hc=n.hasChildNodes();if(hc){cn=n.firstChild;while(cn){t._serializeNode(cn);t.elementName=nn;cn=cn.nextSibling;}}if(!iv){if(hc||!s.closed.test(nn))w.writeFullEndElement();else w.writeEndElement();}},_protect:function(o){var t=this;o.items=o.items||[];function enc(s){return s.replace(/[\r\n\\]/g,function(c){if(c==='\n')return'\\n';else if(c==='\\')return'\\\\';return'\\r';});};function dec(s){return s.replace(/\\[\\rn]/g,function(c){if(c==='\\n')return'\n';else if(c==='\\\\')return'\\';return'\r';});};each(o.patterns,function(p){o.content=dec(enc(o.content).replace(p.pattern,function(x,a,b,c){b=dec(b);if(p.encode)b=t._encode(b);o.items.push(b);return a+'<!--mce:'+(o.items.length-1)+'-->'+c;}));});return o;},_unprotect:function(h,o){h=h.replace(/\<!--mce:([0-9]+)--\>/g,function(a,b){return o.items[parseInt(b)];});o.items=[];return h;},_encode:function(h){var t=this,s=t.settings,l;if(s.entity_encoding!=='raw'){if(s.entity_encoding.indexOf('named')!=-1){t.setEntities(s.entities);l=t.entityLookup;h=h.replace(t.entitiesRE,function(a){var v;if(v=l[a])a='&'+v+';';return a;});}if(s.entity_encoding.indexOf('numeric')!=-1){h=h.replace(/[\u007E-\uFFFF]/g,function(a){return'&#'+a.charCodeAt(0)+';';});}}return h;},_setup:function(){var t=this,s=this.settings;if(t.done)return;t.done=1;t.setRules(s.valid_elements);t.addRules(s.extended_valid_elements);t.addValidChildRules(s.valid_child_elements);if(s.invalid_elements)t.invalidElementsRE=new RegExp('^('+wildcardToRE(s.invalid_elements.replace(/,/g,'|').toLowerCase())+')$');if(s.attrib_value_filter)t.attribValueFilter=s.attribValueFilter;},_getAttrib:function(n,a,na){var i,v;na=na||a.name;if(a.forcedVal&&(v=a.forcedVal)){if(v==='{$uid}')return this.dom.uniqueId();return v;}v=this.dom.getAttrib(n,na);switch(na){case'rowspan':case'colspan':if(v=='1')v='';break;}if(this.attribValueFilter)v=this.attribValueFilter(na,v,n);if(a.validVals){for(i=a.validVals.length-1;i>=0;i--){if(v==a.validVals[i])break;}if(i==-1)return null;}if(v===''&&typeof(a.defaultVal)!='undefined'){v=a.defaultVal;if(v==='{$uid}')return this.dom.uniqueId();return v;}else{if(na=='class'&&this.processObj.get)v=v.replace(/\s?mceItem\w+\s?/g,'');}if(v==='')return null;return v;}});})();(function(){var each=tinymce.each;tinymce.create('tinymce.dom.ScriptLoader',{ScriptLoader:function(s){this.settings=s||{};this.queue=[];this.lookup={};},isDone:function(u){return this.lookup[u]?this.lookup[u].state==2:0;},markDone:function(u){this.lookup[u]={state:2,url:u};},add:function(u,cb,s,pr){var t=this,lo=t.lookup,o;if(o=lo[u]){if(cb&&o.state==2)cb.call(s||this);return o;}o={state:0,url:u,func:cb,scope:s||this};if(pr)t.queue.unshift(o);else t.queue.push(o);lo[u]=o;return o;},load:function(u,cb,s){var t=this,o;if(o=t.lookup[u]){if(cb&&o.state==2)cb.call(s||t);return o;}function loadScript(u){if(tinymce.dom.Event.domLoaded||t.settings.strict_mode){tinymce.util.XHR.send({url:tinymce._addVer(u),error:t.settings.error,async:false,success:function(co){t.eval(co);}});}else document.write('<script type="text/javascript" src="'+tinymce._addVer(u)+'"></script>');};if(!tinymce.is(u,'string')){each(u,function(u){loadScript(u);});if(cb)cb.call(s||t);}else{loadScript(u);if(cb)cb.call(s||t);}},loadQueue:function(cb,s){var t=this;if(!t.queueLoading){t.queueLoading=1;t.queueCallbacks=[];t.loadScripts(t.queue,function(){t.queueLoading=0;if(cb)cb.call(s||t);each(t.queueCallbacks,function(o){o.func.call(o.scope);});});}else if(cb)t.queueCallbacks.push({func:cb,scope:s||t});},eval:function(co){var w=window;if(!w.execScript){try{eval.call(w,co);}catch(ex){eval(co,w);}}else w.execScript(co);},loadScripts:function(sc,cb,s){var t=this,lo=t.lookup;function done(o){o.state=2;if(o.func)o.func.call(o.scope||t);};function allDone(){var l;l=sc.length;each(sc,function(o){o=lo[o.url];if(o.state===2){done(o);l--;}else load(o);});if(l===0&&cb){cb.call(s||t);cb=0;}};function load(o){if(o.state>0)return;o.state=1;tinymce.util.XHR.send({url:o.url,error:t.settings.error,success:function(co){t.eval(co);done(o);allDone();}});};each(sc,function(o){var u=o.url;if(!lo[u]){lo[u]=o;t.queue.push(o);}else o=lo[u];if(o.state>0)return;if(!tinymce.dom.Event.domLoaded&&!t.settings.strict_mode){var ix,ol='';if(cb||o.func){o.state=1;ix=tinymce.dom.ScriptLoader._addOnLoad(function(){done(o);allDone();});if(tinymce.isIE)ol=' onreadystatechange="';else ol=' onload="';ol+='tinymce.dom.ScriptLoader._onLoad(this,\''+u+'\','+ix+');"';}document.write('<script type="text/javascript" src="'+tinymce._addVer(u)+'"'+ol+'></script>');if(!o.func)done(o);}else load(o);});allDone();},'static':{_addOnLoad:function(f){var t=this;t._funcs=t._funcs||[];t._funcs.push(f);return t._funcs.length-1;},_onLoad:function(e,u,ix){if(!tinymce.isIE||e.readyState=='complete')this._funcs[ix].call(this);}}});tinymce.ScriptLoader=new tinymce.dom.ScriptLoader();})();(function(){var DOM=tinymce.DOM,is=tinymce.is;tinymce.create('tinymce.ui.Control',{Control:function(id,s){this.id=id;this.settings=s=s||{};this.rendered=false;this.onRender=new tinymce.util.Dispatcher(this);this.classPrefix='';this.scope=s.scope||this;this.disabled=0;this.active=0;},setDisabled:function(s){var e;if(s!=this.disabled){e=DOM.get(this.id);if(e&&this.settings.unavailable_prefix){if(s){this.prevTitle=e.title;e.title=this.settings.unavailable_prefix+": "+e.title;}else e.title=this.prevTitle;}this.setState('Disabled',s);this.setState('Enabled',!s);this.disabled=s;}},isDisabled:function(){return this.disabled;},setActive:function(s){if(s!=this.active){this.setState('Active',s);this.active=s;}},isActive:function(){return this.active;},setState:function(c,s){var n=DOM.get(this.id);c=this.classPrefix+c;if(s)DOM.addClass(n,c);else DOM.removeClass(n,c);},isRendered:function(){return this.rendered;},renderHTML:function(){},renderTo:function(n){DOM.setHTML(n,this.renderHTML());},postRender:function(){var t=this,b;if(is(t.disabled)){b=t.disabled;t.disabled=-1;t.setDisabled(b);}if(is(t.active)){b=t.active;t.active=-1;t.setActive(b);}},remove:function(){DOM.remove(this.id);this.destroy();},destroy:function(){tinymce.dom.Event.clear(this.id);}});})();tinymce.create('tinymce.ui.Container:tinymce.ui.Control',{Container:function(id,s){this.parent(id,s);this.controls=[];this.lookup={};},add:function(c){this.lookup[c.id]=c;this.controls.push(c);return c;},get:function(n){return this.lookup[n];}});tinymce.create('tinymce.ui.Separator:tinymce.ui.Control',{Separator:function(id,s){this.parent(id,s);this.classPrefix='mceSeparator';},renderHTML:function(){return tinymce.DOM.createHTML('span',{'class':this.classPrefix});}});(function(){var is=tinymce.is,DOM=tinymce.DOM,each=tinymce.each,walk=tinymce.walk;tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control',{MenuItem:function(id,s){this.parent(id,s);this.classPrefix='mceMenuItem';},setSelected:function(s){this.setState('Selected',s);this.selected=s;},isSelected:function(){return this.selected;},postRender:function(){var t=this;t.parent();if(is(t.selected))t.setSelected(t.selected);}});})();(function(){var is=tinymce.is,DOM=tinymce.DOM,each=tinymce.each,walk=tinymce.walk;tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem',{Menu:function(id,s){var t=this;t.parent(id,s);t.items={};t.collapsed=false;t.menuCount=0;t.onAddItem=new tinymce.util.Dispatcher(this);},expand:function(d){var t=this;if(d){walk(t,function(o){if(o.expand)o.expand();},'items',t);}t.collapsed=false;},collapse:function(d){var t=this;if(d){walk(t,function(o){if(o.collapse)o.collapse();},'items',t);}t.collapsed=true;},isCollapsed:function(){return this.collapsed;},add:function(o){if(!o.settings)o=new tinymce.ui.MenuItem(o.id||DOM.uniqueId(),o);this.onAddItem.dispatch(this,o);return this.items[o.id]=o;},addSeparator:function(){return this.add({separator:true});},addMenu:function(o){if(!o.collapse)o=this.createMenu(o);this.menuCount++;return this.add(o);},hasMenus:function(){return this.menuCount!==0;},remove:function(o){delete this.items[o.id];},removeAll:function(){var t=this;walk(t,function(o){if(o.removeAll)o.removeAll();else o.remove();o.destroy();},'items',t);t.items={};},createMenu:function(o){var m=new tinymce.ui.Menu(o.id||DOM.uniqueId(),o);m.onAddItem.add(this.onAddItem.dispatch,this.onAddItem);return m;}});})();(function(){var is=tinymce.is,DOM=tinymce.DOM,each=tinymce.each,Event=tinymce.dom.Event,Element=tinymce.dom.Element;tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu',{DropMenu:function(id,s){s=s||{};s.container=s.container||DOM.doc.body;s.offset_x=s.offset_x||0;s.offset_y=s.offset_y||0;s.vp_offset_x=s.vp_offset_x||0;s.vp_offset_y=s.vp_offset_y||0;if(is(s.icons)&&!s.icons)s['class']+=' mceNoIcons';this.parent(id,s);this.onShowMenu=new tinymce.util.Dispatcher(this);this.onHideMenu=new tinymce.util.Dispatcher(this);this.classPrefix='mceMenu';},createMenu:function(s){var t=this,cs=t.settings,m;s.container=s.container||cs.container;s.parent=t;s.constrain=s.constrain||cs.constrain;s['class']=s['class']||cs['class'];s.vp_offset_x=s.vp_offset_x||cs.vp_offset_x;s.vp_offset_y=s.vp_offset_y||cs.vp_offset_y;m=new tinymce.ui.DropMenu(s.id||DOM.uniqueId(),s);m.onAddItem.add(t.onAddItem.dispatch,t.onAddItem);return m;},update:function(){var t=this,s=t.settings,tb=DOM.get('menu_'+t.id+'_tbl'),co=DOM.get('menu_'+t.id+'_co'),tw,th;tw=s.max_width?Math.min(tb.clientWidth,s.max_width):tb.clientWidth;th=s.max_height?Math.min(tb.clientHeight,s.max_height):tb.clientHeight;if(!DOM.boxModel)t.element.setStyles({width:tw+2,height:th+2});else t.element.setStyles({width:tw,height:th});if(s.max_width)DOM.setStyle(co,'width',tw);if(s.max_height){DOM.setStyle(co,'height',th);if(tb.clientHeight<s.max_height)DOM.setStyle(co,'overflow','hidden');}},showMenu:function(x,y,px){var t=this,s=t.settings,co,vp=DOM.getViewPort(),w,h,mx,my,ot=2,dm,tb,cp=t.classPrefix;t.collapse(1);if(t.isMenuVisible)return;if(!t.rendered){co=DOM.add(t.settings.container,t.renderNode());each(t.items,function(o){o.postRender();});t.element=new Element('menu_'+t.id,{blocker:1,container:s.container});}else co=DOM.get('menu_'+t.id);if(!tinymce.isOpera)DOM.setStyles(co,{left:-0xFFFF,top:-0xFFFF});DOM.show(co);t.update();x+=s.offset_x||0;y+=s.offset_y||0;vp.w-=4;vp.h-=4;if(s.constrain){w=co.clientWidth-ot;h=co.clientHeight-ot;mx=vp.x+vp.w;my=vp.y+vp.h;if((x+s.vp_offset_x+w)>mx)x=px?px-w:Math.max(0,(mx-s.vp_offset_x)-w);if((y+s.vp_offset_y+h)>my)y=Math.max(0,(my-s.vp_offset_y)-h);}DOM.setStyles(co,{left:x,top:y});t.element.update();t.isMenuVisible=1;t.mouseClickFunc=Event.add(co,'click',function(e){var m;e=e.target;if(e&&(e=DOM.getParent(e,'TR'))&&!DOM.hasClass(e,cp+'ItemSub')){m=t.items[e.id];if(m.isDisabled())return;dm=t;while(dm){if(dm.hideMenu)dm.hideMenu();dm=dm.settings.parent;}if(m.settings.onclick)m.settings.onclick(e);return Event.cancel(e);}});if(t.hasMenus()){t.mouseOverFunc=Event.add(co,'mouseover',function(e){var m,r,mi;e=e.target;if(e&&(e=DOM.getParent(e,'TR'))){m=t.items[e.id];if(t.lastMenu)t.lastMenu.collapse(1);if(m.isDisabled())return;if(e&&DOM.hasClass(e,cp+'ItemSub')){r=DOM.getRect(e);m.showMenu((r.x+r.w-ot),r.y-ot,r.x);t.lastMenu=m;DOM.addClass(DOM.get(m.id).firstChild,cp+'ItemActive');}}});}t.onShowMenu.dispatch(t);if(s.keyboard_focus){Event.add(co,'keydown',t._keyHandler,t);DOM.select('a','menu_'+t.id)[0].focus();t._focusIdx=0;}},hideMenu:function(c){var t=this,co=DOM.get('menu_'+t.id),e;if(!t.isMenuVisible)return;Event.remove(co,'mouseover',t.mouseOverFunc);Event.remove(co,'click',t.mouseClickFunc);Event.remove(co,'keydown',t._keyHandler);DOM.hide(co);t.isMenuVisible=0;if(!c)t.collapse(1);if(t.element)t.element.hide();if(e=DOM.get(t.id))DOM.removeClass(e.firstChild,t.classPrefix+'ItemActive');t.onHideMenu.dispatch(t);},add:function(o){var t=this,co;o=t.parent(o);if(t.isRendered&&(co=DOM.get('menu_'+t.id)))t._add(DOM.select('tbody',co)[0],o);return o;},collapse:function(d){this.parent(d);this.hideMenu(1);},remove:function(o){DOM.remove(o.id);this.destroy();return this.parent(o);},destroy:function(){var t=this,co=DOM.get('menu_'+t.id);Event.remove(co,'mouseover',t.mouseOverFunc);Event.remove(co,'click',t.mouseClickFunc);if(t.element)t.element.remove();DOM.remove(co);},renderNode:function(){var t=this,s=t.settings,n,tb,co,w;w=DOM.create('div',{id:'menu_'+t.id,'class':s['class'],'style':'position:absolute;left:0;top:0;z-index:200000'});co=DOM.add(w,'div',{id:'menu_'+t.id+'_co','class':t.classPrefix+(s['class']?' '+s['class']:'')});t.element=new Element('menu_'+t.id,{blocker:1,container:s.container});if(s.menu_line)DOM.add(co,'span',{'class':t.classPrefix+'Line'});n=DOM.add(co,'table',{id:'menu_'+t.id+'_tbl',border:0,cellPadding:0,cellSpacing:0});tb=DOM.add(n,'tbody');each(t.items,function(o){t._add(tb,o);});t.rendered=true;return w;},_keyHandler:function(e){var t=this,kc=e.keyCode;function focus(d){var i=t._focusIdx+d,e=DOM.select('a','menu_'+t.id)[i];if(e){t._focusIdx=i;e.focus();}};switch(kc){case 38:focus(-1);return;case 40:focus(1);return;case 13:return;case 27:return this.hideMenu();}},_add:function(tb,o){var n,s=o.settings,a,ro,it,cp=this.classPrefix;if(s.separator){ro=DOM.add(tb,'tr',{id:o.id,'class':cp+'ItemSeparator'});DOM.add(ro,'td',{'class':cp+'ItemSeparator'});if(n=ro.previousSibling)DOM.addClass(n,'mceLast');return;}n=ro=DOM.add(tb,'tr',{id:o.id,'class':cp+'Item '+cp+'ItemEnabled'});n=it=DOM.add(n,'td');n=a=DOM.add(n,'a',{href:'javascript:;',onclick:"return false;",onmousedown:'return false;'});DOM.addClass(it,s['class']);DOM.add(n,'span',{'class':'mceIcon'+(s.icon?' mce_'+s.icon:'')});n=DOM.add(n,s.element||'span',{'class':'mceText',title:o.settings.title},o.settings.title);if(o.settings.style)DOM.setAttrib(n,'style',o.settings.style);if(tb.childNodes.length==1)DOM.addClass(ro,'mceFirst');if((n=ro.previousSibling)&&DOM.hasClass(n,cp+'ItemSeparator'))DOM.addClass(ro,'mceFirst');if(o.collapse)DOM.addClass(ro,cp+'ItemSub');if(n=ro.previousSibling)DOM.removeClass(n,'mceLast');DOM.addClass(ro,'mceLast');}});})();(function(){var DOM=tinymce.DOM;tinymce.create('tinymce.ui.Button:tinymce.ui.Control',{Button:function(id,s){this.parent(id,s);this.classPrefix='mceButton';},renderHTML:function(){var cp=this.classPrefix,s=this.settings,h,l;l=DOM.encode(s.label||'');h='<a id="'+this.id+'" href="javascript:;" class="'+cp+' '+cp+'Enabled '+s['class']+(l?' '+cp+'Labeled':'')+'" onmousedown="return false;" onclick="return false;" title="'+DOM.encode(s.title)+'">';if(s.image)h+='<img class="mceIcon" src="'+s.image+'" />'+l+'</a>';else h+='<span class="mceIcon '+s['class']+'"></span>'+(l?'<span class="'+cp+'Label">'+l+'</span>':'')+'</a>';return h;},postRender:function(){var t=this,s=t.settings;tinymce.dom.Event.add(t.id,'click',function(e){if(!t.isDisabled())return s.onclick.call(s.scope,e);});}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,each=tinymce.each,Dispatcher=tinymce.util.Dispatcher;tinymce.create('tinymce.ui.ListBox:tinymce.ui.Control',{ListBox:function(id,s){var t=this;t.parent(id,s);t.items=[];t.onChange=new Dispatcher(t);t.onPostRender=new Dispatcher(t);t.onAdd=new Dispatcher(t);t.onRenderMenu=new tinymce.util.Dispatcher(this);t.classPrefix='mceListBox';},select:function(v){var t=this,e,fv;if(v!=t.selectedValue){e=DOM.get(t.id+'_text');t.selectedValue=v;each(t.items,function(o){if(o.value==v){DOM.setHTML(e,DOM.encode(o.title));fv=1;return false;}});if(!fv){DOM.setHTML(e,DOM.encode(t.settings.title));DOM.addClass(e,'mceTitle');e=0;return;}else DOM.removeClass(e,'mceTitle');}e=0;},add:function(n,v,o){var t=this;o=o||{};o=tinymce.extend(o,{title:n,value:v});t.items.push(o);t.onAdd.dispatch(t,o);},getLength:function(){return this.items.length;},renderHTML:function(){var h='',t=this,s=t.settings,cp=t.classPrefix;h='<table id="'+t.id+'" cellpadding="0" cellspacing="0" class="'+cp+' '+cp+'Enabled'+(s['class']?(' '+s['class']):'')+'"><tbody><tr>';h+='<td>'+DOM.createHTML('a',{id:t.id+'_text',href:'javascript:;','class':'mceText',onclick:"return false;",onmousedown:'return false;'},DOM.encode(t.settings.title))+'</td>';h+='<td>'+DOM.createHTML('a',{id:t.id+'_open',tabindex:-1,href:'javascript:;','class':'mceOpen',onclick:"return false;",onmousedown:'return false;'},'<span></span>')+'</td>';h+='</tr></tbody></table>';return h;},showMenu:function(){var t=this,p1,p2,e=DOM.get(this.id),m;if(t.isDisabled()||t.items.length==0)return;if(t.menu&&t.menu.isMenuVisible)return t.hideMenu();if(!t.isMenuRendered){t.renderMenu();t.isMenuRendered=true;}p1=DOM.getPos(this.settings.menu_container);p2=DOM.getPos(e);m=t.menu;m.settings.offset_x=p2.x;m.settings.offset_y=p2.y;m.settings.keyboard_focus=!tinymce.isOpera;if(t.oldID)m.items[t.oldID].setSelected(0);each(t.items,function(o){if(o.value===t.selectedValue){m.items[o.id].setSelected(1);t.oldID=o.id;}});m.showMenu(0,e.clientHeight);Event.add(DOM.doc,'mousedown',t.hideMenu,t);DOM.addClass(t.id,t.classPrefix+'Selected');},hideMenu:function(e){var t=this;if(e&&e.type=="mousedown"&&(e.target.id==t.id+'_text'||e.target.id==t.id+'_open'))return;if(!e||!DOM.getParent(e.target,function(n){return DOM.hasClass(n,'mceMenu');})){DOM.removeClass(t.id,t.classPrefix+'Selected');Event.remove(DOM.doc,'mousedown',t.hideMenu,t);if(t.menu)t.menu.hideMenu();}},renderMenu:function(){var t=this,m;m=t.settings.control_manager.createDropMenu(t.id+'_menu',{menu_line:1,'class':t.classPrefix+'Menu mceNoIcons',max_width:150,max_height:150});m.onHideMenu.add(t.hideMenu,t);m.add({title:t.settings.title,'class':'mceMenuItemTitle',onclick:function(){if(t.settings.onselect('')!==false)t.select('');}});each(t.items,function(o){o.id=DOM.uniqueId();o.onclick=function(){if(t.settings.onselect(o.value)!==false)t.select(o.value);};m.add(o);});t.onRenderMenu.dispatch(t,m);t.menu=m;},postRender:function(){var t=this,cp=t.classPrefix;Event.add(t.id,'click',t.showMenu,t);Event.add(t.id+'_text','focus',function(e){if(!t._focused){t.keyDownHandler=Event.add(t.id+'_text','keydown',function(e){var idx=-1,v,kc=e.keyCode;each(t.items,function(v,i){if(t.selectedValue==v.value)idx=i;});if(kc==38)v=t.items[idx-1];else if(kc==40)v=t.items[idx+1];else if(kc==13){v=t.selectedValue;t.selectedValue=null;t.settings.onselect(v);return Event.cancel(e);}if(v){t.hideMenu();t.select(v.value);}});}t._focused=1;});Event.add(t.id+'_text','blur',function(){Event.remove(t.id+'_text','keydown',t.keyDownHandler);t._focused=0;});if(tinymce.isIE6||!DOM.boxModel){Event.add(t.id,'mouseover',function(){if(!DOM.hasClass(t.id,cp+'Disabled'))DOM.addClass(t.id,cp+'Hover');});Event.add(t.id,'mouseout',function(){if(!DOM.hasClass(t.id,cp+'Disabled'))DOM.removeClass(t.id,cp+'Hover');});}t.onPostRender.dispatch(t,DOM.get(t.id));},destroy:function(){this.parent();Event.clear(this.id+'_text');}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,each=tinymce.each,Dispatcher=tinymce.util.Dispatcher;tinymce.create('tinymce.ui.NativeListBox:tinymce.ui.ListBox',{NativeListBox:function(id,s){this.parent(id,s);this.classPrefix='mceNativeListBox';},setDisabled:function(s){DOM.get(this.id).disabled=s;},isDisabled:function(){return DOM.get(this.id).disabled;},select:function(v){var e=DOM.get(this.id),ol=e.options;v=''+(v||'');e.selectedIndex=0;each(ol,function(o,i){if(o.value==v){e.selectedIndex=i;return false;}});},add:function(n,v,a){var o,t=this;a=a||{};a.value=v;if(t.isRendered())DOM.add(DOM.get(this.id),'option',a,n);o={title:n,value:v,attribs:a};t.items.push(o);t.onAdd.dispatch(t,o);},getLength:function(){return DOM.get(this.id).options.length-1;},renderHTML:function(){var h,t=this;h=DOM.createHTML('option',{value:''},'-- '+t.settings.title+' --');each(t.items,function(it){h+=DOM.createHTML('option',{value:it.value},it.title);});h=DOM.createHTML('select',{id:t.id,'class':'mceNativeListBox'},h);return h;},postRender:function(){var t=this,ch;t.rendered=true;function onChange(e){var v=e.target.options[e.target.selectedIndex].value;t.onChange.dispatch(t,v);if(t.settings.onselect)t.settings.onselect(v);};Event.add(t.id,'change',onChange);Event.add(t.id,'keydown',function(e){var bf;Event.remove(t.id,'change',ch);bf=Event.add(t.id,'blur',function(){Event.add(t.id,'change',onChange);Event.remove(t.id,'blur',bf);});if(e.keyCode==13||e.keyCode==32){onChange(e);return Event.cancel(e);}});t.onPostRender.dispatch(t,DOM.get(t.id));}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,each=tinymce.each;tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button',{MenuButton:function(id,s){this.parent(id,s);this.onRenderMenu=new tinymce.util.Dispatcher(this);s.menu_container=s.menu_container||DOM.doc.body;},showMenu:function(){var t=this,p1,p2,e=DOM.get(t.id),m;if(t.isDisabled())return;if(!t.isMenuRendered){t.renderMenu();t.isMenuRendered=true;}if(t.isMenuVisible)return t.hideMenu();p1=DOM.getPos(t.settings.menu_container);p2=DOM.getPos(e);m=t.menu;m.settings.offset_x=p2.x;m.settings.offset_y=p2.y;m.settings.vp_offset_x=p2.x;m.settings.vp_offset_y=p2.y;m.settings.keyboard_focus=t._focused;m.showMenu(0,e.clientHeight);Event.add(DOM.doc,'mousedown',t.hideMenu,t);t.setState('Selected',1);t.isMenuVisible=1;},renderMenu:function(){var t=this,m;m=t.settings.control_manager.createDropMenu(t.id+'_menu',{menu_line:1,'class':this.classPrefix+'Menu',icons:t.settings.icons});m.onHideMenu.add(t.hideMenu,t);t.onRenderMenu.dispatch(t,m);t.menu=m;},hideMenu:function(e){var t=this;if(e&&e.type=="mousedown"&&DOM.getParent(e.target,function(e){return e.id===t.id||e.id===t.id+'_open';}))return;if(!e||!DOM.getParent(e.target,function(n){return DOM.hasClass(n,'mceMenu');})){t.setState('Selected',0);Event.remove(DOM.doc,'mousedown',t.hideMenu,t);if(t.menu)t.menu.hideMenu();}t.isMenuVisible=0;},postRender:function(){var t=this,s=t.settings;Event.add(t.id,'click',function(){if(!t.isDisabled()){if(s.onclick)s.onclick(t.value);t.showMenu();}});}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,each=tinymce.each;tinymce.create('tinymce.ui.SplitButton:tinymce.ui.MenuButton',{SplitButton:function(id,s){this.parent(id,s);this.classPrefix='mceSplitButton';},renderHTML:function(){var h,t=this,s=t.settings,h1;h='<tbody><tr>';if(s.image)h1=DOM.createHTML('img ',{src:s.image,'class':'mceAction '+s['class']});else h1=DOM.createHTML('span',{'class':'mceAction '+s['class']},'');h+='<td>'+DOM.createHTML('a',{id:t.id+'_action',href:'javascript:;','class':'mceAction '+s['class'],onclick:"return false;",onmousedown:'return false;',title:s.title},h1)+'</td>';h1=DOM.createHTML('span',{'class':'mceOpen '+s['class']});h+='<td>'+DOM.createHTML('a',{id:t.id+'_open',href:'javascript:;','class':'mceOpen '+s['class'],onclick:"return false;",onmousedown:'return false;',title:s.title},h1)+'</td>';h+='</tr></tbody>';return DOM.createHTML('table',{id:t.id,'class':'mceSplitButton mceSplitButtonEnabled '+s['class'],cellpadding:'0',cellspacing:'0',onmousedown:'return false;',title:s.title},h);},postRender:function(){var t=this,s=t.settings;if(s.onclick){Event.add(t.id+'_action','click',function(){if(!t.isDisabled())s.onclick(t.value);});}Event.add(t.id+'_open','click',t.showMenu,t);Event.add(t.id+'_open','focus',function(){t._focused=1;});Event.add(t.id+'_open','blur',function(){t._focused=0;});if(tinymce.isIE6||!DOM.boxModel){Event.add(t.id,'mouseover',function(){if(!DOM.hasClass(t.id,'mceSplitButtonDisabled'))DOM.addClass(t.id,'mceSplitButtonHover');});Event.add(t.id,'mouseout',function(){if(!DOM.hasClass(t.id,'mceSplitButtonDisabled'))DOM.removeClass(t.id,'mceSplitButtonHover');});}},destroy:function(){this.parent();Event.clear(this.id+'_action');Event.clear(this.id+'_open');}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,is=tinymce.is,each=tinymce.each;tinymce.create('tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton',{ColorSplitButton:function(id,s){var t=this;t.parent(id,s);t.settings=s=tinymce.extend({colors:'000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF',grid_width:8,default_color:'#888888'},t.settings);t.onShowMenu=new tinymce.util.Dispatcher(t);t.onHideMenu=new tinymce.util.Dispatcher(t);t.value=s.default_color;},showMenu:function(){var t=this,r,p,e,p2;if(t.isDisabled())return;if(!t.isMenuRendered){t.renderMenu();t.isMenuRendered=true;}if(t.isMenuVisible)return t.hideMenu();e=DOM.get(t.id);DOM.show(t.id+'_menu');DOM.addClass(e,'mceSplitButtonSelected');p2=DOM.getPos(e);DOM.setStyles(t.id+'_menu',{left:p2.x,top:p2.y+e.clientHeight,zIndex:200000});e=0;Event.add(DOM.doc,'mousedown',t.hideMenu,t);if(t._focused){t._keyHandler=Event.add(t.id+'_menu','keydown',function(e){if(e.keyCode==27)t.hideMenu();});DOM.select('a',t.id+'_menu')[0].focus();}t.onShowMenu.dispatch(t);t.isMenuVisible=1;},hideMenu:function(e){var t=this;if(e&&e.type=="mousedown"&&DOM.getParent(e.target,function(e){return e.id===t.id+'_open';}))return;if(!e||!DOM.getParent(e.target,function(n){return DOM.hasClass(n,'mceSplitButtonMenu');})){DOM.removeClass(t.id,'mceSplitButtonSelected');Event.remove(DOM.doc,'mousedown',t.hideMenu,t);Event.remove(t.id+'_menu','keydown',t._keyHandler);DOM.hide(t.id+'_menu');}t.onHideMenu.dispatch(t);t.isMenuVisible=0;},renderMenu:function(){var t=this,m,i=0,s=t.settings,n,tb,tr,w;w=DOM.add(s.menu_container,'div',{id:t.id+'_menu','class':s['menu_class']+' '+s['class'],style:'position:absolute;left:0;top:-1000px;'});m=DOM.add(w,'div',{'class':s['class']+' mceSplitButtonMenu'});DOM.add(m,'span',{'class':'mceMenuLine'});n=DOM.add(m,'table',{'class':'mceColorSplitMenu'});tb=DOM.add(n,'tbody');i=0;each(is(s.colors,'array')?s.colors:s.colors.split(','),function(c){c=c.replace(/^#/,'');if(!i--){tr=DOM.add(tb,'tr');i=s.grid_width-1;}n=DOM.add(tr,'td');n=DOM.add(n,'a',{href:'javascript:;',style:{backgroundColor:'#'+c},mce_color:'#'+c});});if(s.more_colors_func){n=DOM.add(tb,'tr');n=DOM.add(n,'td',{colspan:s.grid_width,'class':'mceMoreColors'});n=DOM.add(n,'a',{id:t.id+'_more',href:'javascript:;',onclick:'return false;','class':'mceMoreColors'},s.more_colors_title);Event.add(n,'click',function(e){s.more_colors_func.call(s.more_colors_scope||this);return Event.cancel(e);});}DOM.addClass(m,'mceColorSplitMenu');Event.add(t.id+'_menu','click',function(e){var c;e=e.target;if(e.nodeName=='A'&&(c=e.getAttribute('mce_color')))t.setColor(c);return Event.cancel(e);});return w;},setColor:function(c){var t=this;DOM.setStyle(t.id+'_preview','backgroundColor',c);t.value=c;t.hideMenu();t.settings.onselect(c);},postRender:function(){var t=this,id=t.id;t.parent();DOM.add(id+'_action','div',{id:id+'_preview','class':'mceColorPreview'});},destroy:function(){this.parent();Event.clear(this.id+'_menu');Event.clear(this.id+'_more');DOM.remove(this.id+'_menu');}});})();tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container',{renderHTML:function(){var t=this,h='',c,co,dom=tinymce.DOM,s=t.settings,i,pr,nx,cl;cl=t.controls;for(i=0;i<cl.length;i++){co=cl[i];pr=cl[i-1];nx=cl[i+1];if(i===0){c='mceToolbarStart';if(co.Button)c+=' mceToolbarStartButton';else if(co.SplitButton)c+=' mceToolbarStartSplitButton';else if(co.ListBox)c+=' mceToolbarStartListBox';h+=dom.createHTML('td',{'class':c},dom.createHTML('span',null,'<!-- IE -->'));}if(pr&&co.ListBox){if(pr.Button||pr.SplitButton)h+=dom.createHTML('td',{'class':'mceToolbarEnd'},dom.createHTML('span',null,'<!-- IE -->'));}if(dom.stdMode)h+='<td style="position: relative">'+co.renderHTML()+'</td>';else h+='<td>'+co.renderHTML()+'</td>';if(nx&&co.ListBox){if(nx.Button||nx.SplitButton)h+=dom.createHTML('td',{'class':'mceToolbarStart'},dom.createHTML('span',null,'<!-- IE -->'));}}c='mceToolbarEnd';if(co.Button)c+=' mceToolbarEndButton';else if(co.SplitButton)c+=' mceToolbarEndSplitButton';else if(co.ListBox)c+=' mceToolbarEndListBox';h+=dom.createHTML('td',{'class':c},dom.createHTML('span',null,'<!-- IE -->'));return dom.createHTML('table',{id:t.id,'class':'mceToolbar'+(s['class']?' '+s['class']:''),cellpadding:'0',cellspacing:'0',align:t.settings.align||''},'<tbody><tr>'+h+'</tr></tbody>');}});(function(){var Dispatcher=tinymce.util.Dispatcher,each=tinymce.each;tinymce.create('tinymce.AddOnManager',{items:[],urls:{},lookup:{},onAdd:new Dispatcher(this),get:function(n){return this.lookup[n];},requireLangPack:function(n){var u,s;if(tinymce.EditorManager.settings){u=this.urls[n]+'/langs/'+tinymce.EditorManager.settings.language+'.js';s=tinymce.EditorManager.settings;if(s){if(!tinymce.dom.Event.domLoaded&&!s.strict_mode)tinymce.ScriptLoader.load(u);else tinymce.ScriptLoader.add(u);}}},add:function(id,o){this.items.push(o);this.lookup[id]=o;this.onAdd.dispatch(this,id,o);return o;},load:function(n,u,cb,s){var t=this;if(t.urls[n])return;if(u.indexOf('/')!=0&&u.indexOf('://')==-1)u=tinymce.baseURL+'/'+u;t.urls[n]=u.substring(0,u.lastIndexOf('/'));tinymce.ScriptLoader.add(u,cb,s);}});tinymce.PluginManager=new tinymce.AddOnManager();tinymce.ThemeManager=new tinymce.AddOnManager();}());(function(){var each=tinymce.each,extend=tinymce.extend,DOM=tinymce.DOM,Event=tinymce.dom.Event,ThemeManager=tinymce.ThemeManager,PluginManager=tinymce.PluginManager,explode=tinymce.explode;tinymce.create('static tinymce.EditorManager',{editors:{},i18n:{},activeEditor:null,preInit:function(){var t=this,lo=window.location;tinymce.documentBaseURL=lo.href.replace(/[\?#].*$/,'').replace(/[\/\\][^\/]+$/,'');if(!/[\/\\]$/.test(tinymce.documentBaseURL))tinymce.documentBaseURL+='/';tinymce.baseURL=new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL);tinymce.EditorManager.baseURI=new tinymce.util.URI(tinymce.baseURL);if(tinymce.EditorManager.baseURI.host!=lo.hostname&&lo.hostname)document.domain=tinymce.relaxedDomain=lo.hostname.replace(/.*\.(.+\..+)$/,'$1');t.onBeforeUnload=new tinymce.util.Dispatcher(t);Event.add(window,'beforeunload',function(e){t.onBeforeUnload.dispatch(t,e);});},init:function(s){var t=this,pl,sl=tinymce.ScriptLoader,c,e;function execCallback(se,n,s){var f=se[n];if(!f)return;if(tinymce.is(f,'string')){s=f.replace(/\.\w+$/,'');s=s?tinymce.resolve(s):0;f=tinymce.resolve(f);}return f.apply(s||this,Array.prototype.slice.call(arguments,2));};s=extend({theme:"simple",language:"en",strict_loading_mode:document.contentType=='application/xhtml+xml'},s);t.settings=s;if(!Event.domLoaded&&!s.strict_loading_mode){if(s.language)sl.add(tinymce.baseURL+'/langs/'+s.language+'.js');if(s.theme&&s.theme.charAt(0)!='-'&&!ThemeManager.urls[s.theme])ThemeManager.load(s.theme,'themes/'+s.theme+'/editor_template'+tinymce.suffix+'.js');if(s.plugins){pl=explode(s.plugins);if(tinymce.inArray(pl,'compat2x')!=-1)PluginManager.load('compat2x','plugins/compat2x/editor_plugin'+tinymce.suffix+'.js');each(pl,function(v){if(v&&v.charAt(0)!='-'&&!PluginManager.urls[v]){if(!tinymce.isWebKit&&v=='safari')return;PluginManager.load(v,'plugins/'+v+'/editor_plugin'+tinymce.suffix+'.js');}});}sl.loadQueue();}Event.add(document,'init',function(){var l,co;execCallback(s,'onpageload');if(s.browsers){l=false;each(explode(s.browsers),function(v){switch(v){case'ie':case'msie':if(tinymce.isIE)l=true;break;case'gecko':if(tinymce.isGecko)l=true;break;case'safari':case'webkit':if(tinymce.isWebKit)l=true;break;case'opera':if(tinymce.isOpera)l=true;break;}});if(!l)return;}switch(s.mode){case"exact":l=s.elements||'';if(l.length>0){each(explode(l),function(v){if(DOM.get(v))new tinymce.Editor(v,s).render(1);else{c=0;each(document.forms,function(f){each(f.elements,function(e){if(e.name===v){v='mce_editor_'+c;DOM.setAttrib(e,'id',v);new tinymce.Editor(v,s).render(1);}});});}});}break;case"textareas":case"specific_textareas":function hasClass(n,c){return c.constructor===RegExp?c.test(n.className):DOM.hasClass(n,c);};each(DOM.select('textarea'),function(v){if(s.editor_deselector&&hasClass(v,s.editor_deselector))return;if(!s.editor_selector||hasClass(v,s.editor_selector)){e=DOM.get(v.name);if(!v.id&&!e)v.id=v.name;if(!v.id||t.get(v.id))v.id=DOM.uniqueId();new tinymce.Editor(v.id,s).render(1);}});break;}if(s.oninit){l=co=0;each(t.editors,function(ed){co++;if(!ed.initialized){ed.onInit.add(function(){l++;if(l==co)execCallback(s,'oninit');});}else l++;if(l==co)execCallback(s,'oninit');});}});},get:function(id){return this.editors[id];},getInstanceById:function(id){return this.get(id);},add:function(e){this.editors[e.id]=e;this._setActive(e);return e;},remove:function(e){var t=this;if(!t.editors[e.id])return null;delete t.editors[e.id];if(t.activeEditor==e){each(t.editors,function(e){t._setActive(e);return false;});}e.destroy();return e;},execCommand:function(c,u,v){var t=this,ed=t.get(v),w;switch(c){case"mceFocus":ed.focus();return true;case"mceAddEditor":case"mceAddControl":if(!t.get(v))new tinymce.Editor(v,t.settings).render();return true;case"mceAddFrameControl":w=v.window;w.tinyMCE=tinyMCE;w.tinymce=tinymce;tinymce.DOM.doc=w.document;tinymce.DOM.win=w;ed=new tinymce.Editor(v.element_id,v);ed.render();if(tinymce.isIE){function clr(){ed.destroy();w.detachEvent('onunload',clr);w=w.tinyMCE=w.tinymce=null;};w.attachEvent('onunload',clr);}v.page_window=null;return true;case"mceRemoveEditor":case"mceRemoveControl":ed.remove();return true;case'mceToggleEditor':if(!ed){t.execCommand('mceAddControl',0,v);return true;}if(ed.isHidden())ed.show();else ed.hide();return true;}if(t.activeEditor)return t.activeEditor.execCommand(c,u,v);return false;},execInstanceCommand:function(id,c,u,v){var ed=this.get(id);if(ed)return ed.execCommand(c,u,v);return false;},triggerSave:function(){each(this.editors,function(e){e.save();});},addI18n:function(p,o){var lo,i18n=this.i18n;if(!tinymce.is(p,'string')){each(p,function(o,lc){each(o,function(o,g){each(o,function(o,k){if(g==='common')i18n[lc+'.'+k]=o;else i18n[lc+'.'+g+'.'+k]=o;});});});}else{each(o,function(o,k){i18n[p+'.'+k]=o;});}},_setActive:function(e){this.selectedInstance=this.activeEditor=e;}});tinymce.EditorManager.preInit();})();var tinyMCE=window.tinyMCE=tinymce.EditorManager;(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,extend=tinymce.extend,Dispatcher=tinymce.util.Dispatcher;var each=tinymce.each,isGecko=tinymce.isGecko,isIE=tinymce.isIE,isWebKit=tinymce.isWebKit;var is=tinymce.is,ThemeManager=tinymce.ThemeManager,PluginManager=tinymce.PluginManager,EditorManager=tinymce.EditorManager;var inArray=tinymce.inArray,grep=tinymce.grep,explode=tinymce.explode;tinymce.create('tinymce.Editor',{Editor:function(id,s){var t=this;t.id=t.editorId=id;t.execCommands={};t.queryStateCommands={};t.queryValueCommands={};t.plugins={};each(['onPreInit','onBeforeRenderUI','onPostRender','onInit','onRemove','onActivate','onDeactivate','onClick','onEvent','onMouseUp','onMouseDown','onDblClick','onKeyDown','onKeyUp','onKeyPress','onContextMenu','onSubmit','onReset','onPaste','onPreProcess','onPostProcess','onBeforeSetContent','onBeforeGetContent','onSetContent','onGetContent','onLoadContent','onSaveContent','onNodeChange','onChange','onBeforeExecCommand','onExecCommand','onUndo','onRedo','onVisualAid','onSetProgressState'],function(e){t[e]=new Dispatcher(t);});t.settings=s=extend({id:id,language:'en',docs_language:'en',theme:'simple',skin:'default',delta_width:0,delta_height:0,popup_css:'',plugins:'',document_base_url:tinymce.documentBaseURL,add_form_submit_trigger:1,submit_patch:1,add_unload_trigger:1,convert_urls:1,relative_urls:1,remove_script_host:1,table_inline_editing:0,object_resizing:1,cleanup:1,accessibility_focus:1,custom_shortcuts:1,custom_undo_redo_keyboard_shortcuts:1,custom_undo_redo_restore_selection:1,custom_undo_redo:1,doctype:'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',visual_table_class:'mceItemTable',visual:1,inline_styles:true,convert_fonts_to_spans:true,font_size_style_values:'xx-small,x-small,small,medium,large,x-large,xx-large',apply_source_formatting:1,directionality:'ltr',forced_root_block:'p',valid_elements:'@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,#p[align],-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote[cite],-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value|tabindex|accesskey],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big',hidden_input:1,padd_empty_editor:1,render_ui:1,init_theme:1,force_p_newlines:1,indentation:'30px'},s);t.documentBaseURI=new tinymce.util.URI(s.document_base_url||tinymce.documentBaseURL,{base_uri:tinyMCE.baseURI});t.baseURI=EditorManager.baseURI;t.execCallback('setup',t);},render:function(nst){var t=this,s=t.settings,id=t.id,sl=tinymce.ScriptLoader;if(!Event.domLoaded){Event.add(document,'init',function(){t.render();});return;}if(!nst){s.strict_loading_mode=1;tinyMCE.settings=s;}if(!t.getElement())return;if(s.strict_loading_mode){sl.settings.strict_mode=s.strict_loading_mode;tinymce.DOM.settings.strict=1;}if(!/TEXTAREA|INPUT/i.test(t.getElement().nodeName)&&s.hidden_input&&DOM.getParent(id,'form'))DOM.insertAfter(DOM.create('input',{type:'hidden',name:id}),id);t.windowManager=new tinymce.WindowManager(t);if(s.encoding=='xml'){t.onGetContent.add(function(ed,o){if(o.save)o.content=DOM.encode(o.content);});}if(s.add_form_submit_trigger){t.onSubmit.addToTop(function(){if(t.initialized){t.save();t.isNotDirty=1;}});}if(s.add_unload_trigger&&!s.ask){t._beforeUnload=tinyMCE.onBeforeUnload.add(function(){if(t.initialized&&!t.destroyed&&!t.isHidden())t.save({format:'raw',no_events:true});});}tinymce.addUnload(t.destroy,t);if(s.submit_patch){t.onBeforeRenderUI.add(function(){var n=t.getElement().form;if(!n)return;if(n._mceOldSubmit)return;if(!n.submit.nodeType&&!n.submit.length){t.formElement=n;n._mceOldSubmit=n.submit;n.submit=function(){EditorManager.triggerSave();t.isNotDirty=1;return this._mceOldSubmit(this);};}n=null;});}function loadScripts(){if(s.language)sl.add(tinymce.baseURL+'/langs/'+s.language+'.js');if(s.theme.charAt(0)!='-'&&!ThemeManager.urls[s.theme])ThemeManager.load(s.theme,'themes/'+s.theme+'/editor_template'+tinymce.suffix+'.js');each(explode(s.plugins),function(p){if(p&&p.charAt(0)!='-'&&!PluginManager.urls[p]){if(!isWebKit&&p=='safari')return;PluginManager.load(p,'plugins/'+p+'/editor_plugin'+tinymce.suffix+'.js');}});sl.loadQueue(function(){if(s.ask){function ask(){window.setTimeout(function(){Event.remove(t.id,'focus',ask);t.windowManager.confirm(t.getLang('edit_confirm'),function(s){if(s)t.init();});},0);};Event.add(t.id,'focus',ask);return;}if(!t.removed)t.init();});};if(s.plugins.indexOf('compat2x')!=-1){PluginManager.load('compat2x','plugins/compat2x/editor_plugin'+tinymce.suffix+'.js');sl.loadQueue(loadScripts);}else loadScripts();},init:function(){var n,t=this,s=t.settings,w,h,e=t.getElement(),o,ti,u,bi,bc,re;EditorManager.add(t);s.theme=s.theme.replace(/-/,'');o=ThemeManager.get(s.theme);t.theme=new o();if(t.theme.init&&s.init_theme)t.theme.init(t,ThemeManager.urls[s.theme]||tinymce.documentBaseURL.replace(/\/$/,''));each(explode(s.plugins.replace(/\-/g,'')),function(p){var c=PluginManager.get(p),u=PluginManager.urls[p]||tinymce.documentBaseURL.replace(/\/$/,''),po;if(c){po=new c(t,u);t.plugins[p]=po;if(po.init)po.init(t,u);}});if(s.popup_css)s.popup_css=t.documentBaseURI.toAbsolute(s.popup_css);else s.popup_css=t.baseURI.toAbsolute("themes/"+s.theme+"/skins/"+s.skin+"/dialog.css");if(s.popup_css_add)s.popup_css+=','+t.documentBaseURI.toAbsolute(s.popup_css_add);t.controlManager=new tinymce.ControlManager(t);t.undoManager=new tinymce.UndoManager(t);t.undoManager.onAdd.add(function(um,l){if(!l.initial)return t.onChange.dispatch(t,l,um);});t.undoManager.onUndo.add(function(um,l){return t.onUndo.dispatch(t,l,um);});t.undoManager.onRedo.add(function(um,l){return t.onRedo.dispatch(t,l,um);});if(s.custom_undo_redo){t.onExecCommand.add(function(ed,cmd,ui,val,a){if(cmd!='Undo'&&cmd!='Redo'&&cmd!='mceRepaint'&&(!a||!a.skip_undo))t.undoManager.add();});}t.onExecCommand.add(function(ed,c){if(!/^(FontName|FontSize)$/.test(c))t.nodeChanged();});if(isGecko){function repaint(a,o){if(!o||!o.initial)t.execCommand('mceRepaint');};t.onUndo.add(repaint);t.onRedo.add(repaint);t.onSetContent.add(repaint);}t.onBeforeRenderUI.dispatch(t,t.controlManager);if(s.render_ui){w=s.width||e.style.width||e.offsetWidth;h=s.height||e.style.height||e.offsetHeight;t.orgDisplay=e.style.display;re=/^[0-9\.]+(|px)$/i;if(re.test(''+w))w=Math.max(parseInt(w)+(o.deltaWidth||0),100);if(re.test(''+h))h=Math.max(parseInt(h)+(o.deltaHeight||0),100);o=t.theme.renderUI({targetNode:e,width:w,height:h,deltaWidth:s.delta_width,deltaHeight:s.delta_height});t.editorContainer=o.editorContainer;}DOM.setStyles(o.sizeContainer||o.editorContainer,{width:w,height:h});h=(o.iframeHeight||h)+((h+'').indexOf('%')==-1?(o.deltaHeight||0):'');if(h<100)h=100;t.iframeHTML=s.doctype+'<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="'+t.documentBaseURI.getURI()+'" />';t.iframeHTML+='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';if(tinymce.relaxedDomain)t.iframeHTML+='<script type="text/javascript">document.domain = "'+tinymce.relaxedDomain+'";</script>';bi=s.body_id||'tinymce';if(bi.indexOf('=')!=-1){bi=t.getParam('body_id','','hash');bi=bi[t.id]||bi;}bc=s.body_class||'';if(bc.indexOf('=')!=-1){bc=t.getParam('body_class','','hash');bc=bc[t.id]||'';}t.iframeHTML+='</head><body id="'+bi+'" class="mceContentBody '+bc+'"></body></html>';if(tinymce.relaxedDomain){if(isIE||(tinymce.isOpera&&parseFloat(opera.version())>=9.5))u='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinyMCE.get("'+t.id+'");document.write(ed.iframeHTML);document.close();ed.setupIframe();})()';else if(tinymce.isOpera)u='javascript:(function(){document.open();document.domain="'+document.domain+'";document.close();ed.setupIframe();})()';}n=DOM.add(o.iframeContainer,'iframe',{id:t.id+"_ifr",src:u||'javascript:""',frameBorder:'0',style:{width:'100%',height:h}});t.contentAreaContainer=o.iframeContainer;DOM.get(o.editorContainer).style.display=t.orgDisplay;DOM.get(t.id).style.display='none';if(tinymce.isOldWebKit){Event.add(n,'load',t.setupIframe,t);n.src=tinymce.baseURL+'/plugins/safari/blank.htm';}else{if(!isIE||!tinymce.relaxedDomain)t.setupIframe();e=n=o=null;}},setupIframe:function(){var t=this,s=t.settings,e=DOM.get(t.id),d=t.getDoc(),h,b;if(!isIE||!tinymce.relaxedDomain){d.open();d.write(t.iframeHTML);d.close();}if(!isIE){try{d.designMode='On';}catch(ex){}}if(isIE){b=t.getBody();DOM.hide(b);b.contentEditable=true;DOM.show(b);}t.dom=new tinymce.DOM.DOMUtils(t.getDoc(),{keep_values:true,url_converter:t.convertURL,url_converter_scope:t,hex_colors:s.force_hex_style_colors,class_filter:s.class_filter,update_styles:1,fix_ie_paragraphs:1});t.serializer=new tinymce.dom.Serializer({entity_encoding:s.entity_encoding,entities:s.entities,valid_elements:s.verify_html===false?'*[*]':s.valid_elements,extended_valid_elements:s.extended_valid_elements,valid_child_elements:s.valid_child_elements,invalid_elements:s.invalid_elements,fix_table_elements:s.fix_table_elements,fix_list_elements:s.fix_list_elements,fix_content_duplication:s.fix_content_duplication,convert_fonts_to_spans:s.convert_fonts_to_spans,font_size_classes:s.font_size_classes,font_size_style_values:s.font_size_style_values,apply_source_formatting:s.apply_source_formatting,remove_linebreaks:s.remove_linebreaks,dom:t.dom});t.selection=new tinymce.dom.Selection(t.dom,t.getWin(),t.serializer);t.forceBlocks=new tinymce.ForceBlocks(t,{forced_root_block:s.forced_root_block});t.editorCommands=new tinymce.EditorCommands(t);t.serializer.onPreProcess.add(function(se,o){return t.onPreProcess.dispatch(t,o,se);});t.serializer.onPostProcess.add(function(se,o){return t.onPostProcess.dispatch(t,o,se);});t.onPreInit.dispatch(t);if(!s.gecko_spellcheck)t.getBody().spellcheck=0;t._addEvents();t.controlManager.onPostRender.dispatch(t,t.controlManager);t.onPostRender.dispatch(t);if(s.directionality)t.getBody().dir=s.directionality;if(s.nowrap)t.getBody().style.whiteSpace="nowrap";if(s.auto_resize)t.onNodeChange.add(t.resizeToContent,t);if(s.custom_elements){function handleCustom(ed,o){each(explode(s.custom_elements),function(v){var n;if(v.indexOf('~')===0){v=v.substring(1);n='span';}else n='div';o.content=o.content.replace(new RegExp('<('+v+')([^>]*)>','g'),'<'+n+' mce_name="$1"$2>');o.content=o.content.replace(new RegExp('</('+v+')>','g'),'</'+n+'>');});};t.onBeforeSetContent.add(handleCustom);t.onPostProcess.add(function(ed,o){if(o.set)handleCustom(ed,o)});}if(s.handle_node_change_callback){t.onNodeChange.add(function(ed,cm,n){t.execCallback('handle_node_change_callback',t.id,n,-1,-1,true,t.selection.isCollapsed());});}if(s.save_callback){t.onSaveContent.add(function(ed,o){var h=t.execCallback('save_callback',t.id,o.content,t.getBody());if(h)o.content=h;});}if(s.onchange_callback){t.onChange.add(function(ed,l){t.execCallback('onchange_callback',t,l);});}if(s.convert_newlines_to_brs){t.onBeforeSetContent.add(function(ed,o){if(o.initial)o.content=o.content.replace(/\r?\n/g,'<br />');});}if(s.fix_nesting&&isIE){t.onBeforeSetContent.add(function(ed,o){o.content=t._fixNesting(o.content);});}if(s.preformatted){t.onPostProcess.add(function(ed,o){o.content=o.content.replace(/^\s*<pre.*?>/,'');o.content=o.content.replace(/<\/pre>\s*$/,'');if(o.set)o.content='<pre class="mceItemHidden">'+o.content+'</pre>';});}if(s.verify_css_classes){t.serializer.attribValueFilter=function(n,v){var s,cl;if(n=='class'){if(!t.classesRE){cl=t.dom.getClasses();if(cl.length>0){s='';each(cl,function(o){s+=(s?'|':'')+o['class'];});t.classesRE=new RegExp('('+s+')','gi');}}return!t.classesRE||/(\bmceItem\w+\b|\bmceTemp\w+\b)/g.test(v)||t.classesRE.test(v)?v:'';}return v;};}if(s.convert_fonts_to_spans)t._convertFonts();if(s.inline_styles)t._convertInlineElements();if(s.cleanup_callback){t.onBeforeSetContent.add(function(ed,o){o.content=t.execCallback('cleanup_callback','insert_to_editor',o.content,o);});t.onPreProcess.add(function(ed,o){if(o.set)t.execCallback('cleanup_callback','insert_to_editor_dom',o.node,o);if(o.get)t.execCallback('cleanup_callback','get_from_editor_dom',o.node,o);});t.onPostProcess.add(function(ed,o){if(o.set)o.content=t.execCallback('cleanup_callback','insert_to_editor',o.content,o);if(o.get)o.content=t.execCallback('cleanup_callback','get_from_editor',o.content,o);});}if(s.save_callback){t.onGetContent.add(function(ed,o){if(o.save)o.content=t.execCallback('save_callback',t.id,o.content,t.getBody());});}if(s.handle_event_callback){t.onEvent.add(function(ed,e,o){if(t.execCallback('handle_event_callback',e,ed,o)===false)Event.cancel(e);});}t.onSetContent.add(function(){t.addVisual(t.getBody());});if(s.padd_empty_editor){t.onPostProcess.add(function(ed,o){o.content=o.content.replace(/^(<p>( | |\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/,'');});}if(isGecko){try{d.designMode='Off';d.designMode='On';}catch(ex){}}setTimeout(function(){if(t.removed)return;t.load({initial:true,format:(s.cleanup_on_startup?'html':'raw')});t.startContent=t.getContent({format:'raw'});t.undoManager.add({initial:true});t.initialized=true;t.onInit.dispatch(t);t.execCallback('setupcontent_callback',t.id,t.getBody(),t.getDoc());t.execCallback('init_instance_callback',t);t.focus(true);t.nodeChanged({initial:1});if(s.content_css){tinymce.each(explode(s.content_css),function(u){t.dom.loadCSS(t.documentBaseURI.toAbsolute(u));});}if(s.auto_focus){setTimeout(function(){var ed=EditorManager.get(s.auto_focus);ed.selection.select(ed.getBody(),1);ed.selection.collapse(1);ed.getWin().focus();},100);}},1);e=null;},focus:function(sf){var oed,t=this,ce=t.settings.content_editable;if(!sf){if(!ce&&(!isIE||t.selection.getNode().ownerDocument!=t.getDoc()))t.getWin().focus();}if(EditorManager.activeEditor!=t){if((oed=EditorManager.activeEditor)!=null)oed.onDeactivate.dispatch(oed,t);t.onActivate.dispatch(t,oed);}EditorManager._setActive(t);},execCallback:function(n){var t=this,f=t.settings[n],s;if(!f)return;if(t.callbackLookup&&(s=t.callbackLookup[n])){f=s.func;s=s.scope;}if(is(f,'string')){s=f.replace(/\.\w+$/,'');s=s?tinymce.resolve(s):0;f=tinymce.resolve(f);t.callbackLookup=t.callbackLookup||{};t.callbackLookup[n]={func:f,scope:s};}return f.apply(s||t,Array.prototype.slice.call(arguments,1));},translate:function(s){var c=this.settings.language,i18n=EditorManager.i18n;if(!s)return'';return i18n[c+'.'+s]||s.replace(/{\#([^}]+)\}/g,function(a,b){return i18n[c+'.'+b]||'{#'+b+'}';});},getLang:function(n,dv){return EditorManager.i18n[this.settings.language+'.'+n]||(is(dv)?dv:'{#'+n+'}');},getParam:function(n,dv,ty){var tr=tinymce.trim,v=is(this.settings[n])?this.settings[n]:dv,o;if(ty==='hash'){o={};if(is(v,'string')){each(v.indexOf('=')>0?v.split(/[;,](?![^=;,]*(?:[;,]|$))/):v.split(','),function(v){v=v.split('=');if(v.length>1)o[tr(v[0])]=tr(v[1]);else o[tr(v[0])]=tr(v);});}else o=v;return o;}return v;},nodeChanged:function(o){var t=this,s=t.selection,n=s.getNode()||t.getBody();if(t.initialized){t.onNodeChange.dispatch(t,o?o.controlManager||t.controlManager:t.controlManager,isIE&&n.ownerDocument!=t.getDoc()?t.getBody():n,s.isCollapsed(),o);}},addButton:function(n,s){var t=this;t.buttons=t.buttons||{};t.buttons[n]=s;},addCommand:function(n,f,s){this.execCommands[n]={func:f,scope:s||this};},addQueryStateHandler:function(n,f,s){this.queryStateCommands[n]={func:f,scope:s||this};},addQueryValueHandler:function(n,f,s){this.queryValueCommands[n]={func:f,scope:s||this};},addShortcut:function(pa,desc,cmd_func,sc){var t=this,c;if(!t.settings.custom_shortcuts)return false;t.shortcuts=t.shortcuts||{};if(is(cmd_func,'string')){c=cmd_func;cmd_func=function(){t.execCommand(c,false,null);};}if(is(cmd_func,'object')){c=cmd_func;cmd_func=function(){t.execCommand(c[0],c[1],c[2]);};}each(explode(pa),function(pa){var o={func:cmd_func,scope:sc||this,desc:desc,alt:false,ctrl:false,shift:false};each(explode(pa,'+'),function(v){switch(v){case'alt':case'ctrl':case'shift':o[v]=true;break;default:o.charCode=v.charCodeAt(0);o.keyCode=v.toUpperCase().charCodeAt(0);}});t.shortcuts[(o.ctrl?'ctrl':'')+','+(o.alt?'alt':'')+','+(o.shift?'shift':'')+','+o.keyCode]=o;});return true;},execCommand:function(cmd,ui,val,a){var t=this,s=0,o,st;if(!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd)&&(!a||!a.skip_focus))t.focus();o={};t.onBeforeExecCommand.dispatch(t,cmd,ui,val,o);if(o.terminate)return false;if(t.execCallback('execcommand_callback',t.id,t.selection.getNode(),cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}if(o=t.execCommands[cmd]){st=o.func.call(o.scope,ui,val);if(st!==true){t.onExecCommand.dispatch(t,cmd,ui,val,a);return st;}}each(t.plugins,function(p){if(p.execCommand&&p.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);s=1;return false;}});if(s)return true;if(t.theme.execCommand&&t.theme.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}if(t.editorCommands.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}t.getDoc().execCommand(cmd,ui,val);t.onExecCommand.dispatch(t,cmd,ui,val,a);},queryCommandState:function(c){var t=this,o,s;if(t._isHidden())return;if(o=t.queryStateCommands[c]){s=o.func.call(o.scope);if(s!==true)return s;}o=t.editorCommands.queryCommandState(c);if(o!==-1)return o;try{return this.getDoc().queryCommandState(c);}catch(ex){}},queryCommandValue:function(c){var t=this,o,s;if(t._isHidden())return;if(o=t.queryValueCommands[c]){s=o.func.call(o.scope);if(s!==true)return s;}o=t.editorCommands.queryCommandValue(c);if(is(o))return o;try{return this.getDoc().queryCommandValue(c);}catch(ex){}},show:function(){var t=this;DOM.show(t.getContainer());DOM.hide(t.id);t.load();},hide:function(){var t=this,d=t.getDoc();if(isIE&&d)d.execCommand('SelectAll');t.save();DOM.hide(t.getContainer());DOM.setStyle(t.id,'display',t.orgDisplay);},isHidden:function(){return!DOM.isHidden(this.id);},setProgressState:function(b,ti,o){this.onSetProgressState.dispatch(this,b,ti,o);return b;},resizeToContent:function(){var t=this;DOM.setStyle(t.id+"_ifr",'height',t.getBody().scrollHeight);},load:function(o){var t=this,e=t.getElement(),h;o=o||{};o.load=true;h=t.setContent(is(e.value)?e.value:e.innerHTML,o);o.element=e;if(!o.no_events)t.onLoadContent.dispatch(t,o);o.element=e=null;return h;},save:function(o){var t=this,e=t.getElement(),h,f;if(!t.initialized)return;o=o||{};o.save=true;if(!o.no_events){t.undoManager.typing=0;t.undoManager.add();}o.element=e;h=o.content=t.getContent(o);if(!o.no_events)t.onSaveContent.dispatch(t,o);h=o.content;if(!/TEXTAREA|INPUT/i.test(e.nodeName)){e.innerHTML=h;if(f=DOM.getParent(t.id,'form')){each(f.elements,function(e){if(e.name==t.id){e.value=h;return false;}});}}else e.value=h;o.element=e=null;return h;},setContent:function(h,o){var t=this;o=o||{};o.format=o.format||'html';o.set=true;o.content=h;if(!o.no_events)t.onBeforeSetContent.dispatch(t,o);if(!tinymce.isIE&&(h.length===0||/^\s+$/.test(h))){o.content=t.dom.setHTML(t.getBody(),'<br mce_bogus="1" />');o.format='raw';}o.content=t.dom.setHTML(t.getBody(),tinymce.trim(o.content));if(o.format!='raw'&&t.settings.cleanup){o.getInner=true;o.content=t.dom.setHTML(t.getBody(),t.serializer.serialize(t.getBody(),o));}if(!o.no_events)t.onSetContent.dispatch(t,o);return o.content;},getContent:function(o){var t=this,h;o=o||{};o.format=o.format||'html';o.get=true;if(!o.no_events)t.onBeforeGetContent.dispatch(t,o);if(o.format!='raw'&&t.settings.cleanup){o.getInner=true;h=t.serializer.serialize(t.getBody(),o);}else h=t.getBody().innerHTML;h=h.replace(/^\s*|\s*$/g,'');o.content=h;if(!o.no_events)t.onGetContent.dispatch(t,o);return o.content;},isDirty:function(){var t=this;return tinymce.trim(t.startContent)!=tinymce.trim(t.getContent({format:'raw',no_events:1}))&&!t.isNotDirty;},getContainer:function(){var t=this;if(!t.container)t.container=DOM.get(t.editorContainer||t.id+'_parent');return t.container;},getContentAreaContainer:function(){return this.contentAreaContainer;},getElement:function(){return DOM.get(this.settings.content_element||this.id);},getWin:function(){var t=this,e;if(!t.contentWindow){e=DOM.get(t.id+"_ifr");if(e)t.contentWindow=e.contentWindow;}return t.contentWindow;},getDoc:function(){var t=this,w;if(!t.contentDocument){w=t.getWin();if(w)t.contentDocument=w.document;}return t.contentDocument;},getBody:function(){return this.bodyElement||this.getDoc().body;},convertURL:function(u,n,e){var t=this,s=t.settings;if(s.urlconverter_callback)return t.execCallback('urlconverter_callback',u,e,true,n);if(!s.convert_urls||(e&&e.nodeName=='LINK')||u.indexOf('file:')===0)return u;if(s.relative_urls)return t.documentBaseURI.toRelative(u);u=t.documentBaseURI.toAbsolute(u,s.remove_script_host);return u;},addVisual:function(e){var t=this,s=t.settings;e=e||t.getBody();if(!is(t.hasVisual))t.hasVisual=s.visual;each(t.dom.select('table,a',e),function(e){var v;switch(e.nodeName){case'TABLE':v=t.dom.getAttrib(e,'border');if(!v||v=='0'){if(t.hasVisual)t.dom.addClass(e,s.visual_table_class);else t.dom.removeClass(e,s.visual_table_class);}return;case'A':v=t.dom.getAttrib(e,'name');if(v){if(t.hasVisual)t.dom.addClass(e,'mceItemAnchor');else t.dom.removeClass(e,'mceItemAnchor');}return;}});t.onVisualAid.dispatch(t,e,t.hasVisual);},remove:function(){var t=this,e=t.getContainer();t.removed=1;t.hide();t.execCallback('remove_instance_callback',t);t.onRemove.dispatch(t);t.onExecCommand.listeners=[];EditorManager.remove(t);DOM.remove(e);},destroy:function(s){var t=this;if(t.destroyed)return;if(!s){tinymce.removeUnload(t.destroy);tinyMCE.onBeforeUnload.remove(t._beforeUnload);if(t.theme.destroy)t.theme.destroy();t.controlManager.destroy();t.selection.destroy();t.dom.destroy();if(!t.settings.content_editable){Event.clear(t.getWin());Event.clear(t.getDoc());}Event.clear(t.getBody());Event.clear(t.formElement);}if(t.formElement){t.formElement.submit=t.formElement._mceOldSubmit;t.formElement._mceOldSubmit=null;}t.contentAreaContainer=t.formElement=t.container=t.settings.content_element=t.bodyElement=t.contentDocument=t.contentWindow=null;if(t.selection)t.selection=t.selection.win=t.selection.dom=t.selection.dom.doc=null;t.destroyed=1;},_addEvents:function(){var t=this,i,s=t.settings,lo={mouseup:'onMouseUp',mousedown:'onMouseDown',click:'onClick',keyup:'onKeyUp',keydown:'onKeyDown',keypress:'onKeyPress',submit:'onSubmit',reset:'onReset',contextmenu:'onContextMenu',dblclick:'onDblClick',paste:'onPaste'};function eventHandler(e,o){var ty=e.type;if(t.removed)return;if(t.onEvent.dispatch(t,e,o)!==false){t[lo[e.fakeType||e.type]].dispatch(t,e,o);}};each(lo,function(v,k){switch(k){case'contextmenu':if(tinymce.isOpera){Event.add(t.getBody(),'mousedown',function(e){if(e.ctrlKey){e.fakeType='contextmenu';eventHandler(e);}});}else Event.add(t.getBody(),k,eventHandler);break;case'paste':Event.add(t.getBody(),k,function(e){var tx,h,el,r;if(e.clipboardData)tx=e.clipboardData.getData('text/plain');else if(tinymce.isIE)tx=t.getWin().clipboardData.getData('Text');eventHandler(e,{text:tx,html:h});});break;case'submit':case'reset':Event.add(t.getElement().form||DOM.getParent(t.id,'form'),k,eventHandler);break;default:Event.add(s.content_editable?t.getBody():t.getDoc(),k,eventHandler);}});Event.add(s.content_editable?t.getBody():(isGecko?t.getDoc():t.getWin()),'focus',function(e){t.focus(true);});if(tinymce.isGecko){Event.add(t.getDoc(),'DOMNodeInserted',function(e){var v;e=e.target;if(e.nodeType===1&&e.nodeName==='IMG'&&(v=e.getAttribute('mce_src')))e.src=t.documentBaseURI.toAbsolute(v);});}if(isGecko){function setOpts(){var t=this,d=t.getDoc(),s=t.settings;if(isGecko){if(t._isHidden()){try{if(!s.content_editable)d.designMode='On';}catch(ex){}}try{d.execCommand("styleWithCSS",0,false);}catch(ex){if(!t._isHidden())try{d.execCommand("useCSS",0,true);}catch(ex){}}if(!s.table_inline_editing)try{d.execCommand('enableInlineTableEditing',false,false);}catch(ex){}if(!s.object_resizing)try{d.execCommand('enableObjectResizing',false,false);}catch(ex){}}};t.onBeforeExecCommand.add(setOpts);t.onMouseDown.add(setOpts);}t.onMouseUp.add(t.nodeChanged);t.onClick.add(t.nodeChanged);t.onKeyUp.add(function(ed,e){if((e.keyCode>=33&&e.keyCode<=36)||(e.keyCode>=37&&e.keyCode<=40)||e.keyCode==13||e.keyCode==45||e.keyCode==46||e.keyCode==8||e.ctrlKey)t.nodeChanged();});t.onReset.add(function(){t.setContent(t.startContent,{format:'raw'});});if(t.getParam('tab_focus')){function tabCancel(ed,e){if(e.keyCode===9)return Event.cancel(e);};function tabHandler(ed,e){var x,i,f,el,v;function find(d){f=DOM.getParent(ed.id,'form');el=f.elements;if(f){each(el,function(e,i){if(e.id==ed.id){x=i;return false;}});if(d>0){for(i=x+1;i<el.length;i++){if(el[i].type!='hidden')return el[i];}}else{for(i=x-1;i>=0;i--){if(el[i].type!='hidden')return el[i];}}}return null;};if(e.keyCode===9){v=explode(ed.getParam('tab_focus'));if(v.length==1){v[1]=v[0];v[0]=':prev';}if(e.shiftKey){if(v[0]==':prev')el=find(-1);else el=DOM.get(v[0]);}else{if(v[1]==':next')el=find(1);else el=DOM.get(v[1]);}if(el){if(ed=EditorManager.get(el.id||el.name))ed.focus();else window.setTimeout(function(){window.focus();el.focus();},10);return Event.cancel(e);}}};t.onKeyUp.add(tabCancel);if(isGecko){t.onKeyPress.add(tabHandler);t.onKeyDown.add(tabCancel);}else t.onKeyDown.add(tabHandler);}if(s.custom_shortcuts){if(s.custom_undo_redo_keyboard_shortcuts){t.addShortcut('ctrl+z',t.getLang('undo_desc'),'Undo');t.addShortcut('ctrl+y',t.getLang('redo_desc'),'Redo');}if(isGecko){t.addShortcut('ctrl+b',t.getLang('bold_desc'),'Bold');t.addShortcut('ctrl+i',t.getLang('italic_desc'),'Italic');t.addShortcut('ctrl+u',t.getLang('underline_desc'),'Underline');}for(i=1;i<=6;i++)t.addShortcut('ctrl+'+i,'',['FormatBlock',false,'<h'+i+'>']);t.addShortcut('ctrl+7','',['FormatBlock',false,'<p>']);t.addShortcut('ctrl+8','',['FormatBlock',false,'<div>']);t.addShortcut('ctrl+9','',['FormatBlock',false,'<address>']);function find(e){var v=null;if(!e.altKey&&!e.ctrlKey&&!e.metaKey)return v;each(t.shortcuts,function(o){if(o.ctrl!=e.ctrlKey&&(!tinymce.isMac||o.ctrl==e.metaKey))return;if(o.alt!=e.altKey)return;if(o.shift!=e.shiftKey)return;if(e.keyCode==o.keyCode||(e.charCode&&e.charCode==o.charCode)){v=o;return false;}});return v;};t.onKeyUp.add(function(ed,e){var o=find(e);if(o)return Event.cancel(e);});t.onKeyPress.add(function(ed,e){var o=find(e);if(o)return Event.cancel(e);});t.onKeyDown.add(function(ed,e){var o=find(e);if(o){o.func.call(o.scope);return Event.cancel(e);}});}if(tinymce.isIE){Event.add(t.getDoc(),'controlselect',function(e){var re=t.resizeInfo,cb;e=e.target;if(e.nodeName!=='IMG')return;if(re)Event.remove(re.node,re.ev,re.cb);if(!t.dom.hasClass(e,'mceItemNoResize')){ev='resizeend';cb=Event.add(e,ev,function(e){var v;e=e.target;if(v=t.dom.getStyle(e,'width')){t.dom.setAttrib(e,'width',v.replace(/[^0-9%]+/g,''));t.dom.setStyle(e,'width','');}if(v=t.dom.getStyle(e,'height')){t.dom.setAttrib(e,'height',v.replace(/[^0-9%]+/g,''));t.dom.setStyle(e,'height','');}});}else{ev='resizestart';cb=Event.add(e,'resizestart',Event.cancel,Event);}re=t.resizeInfo={node:e,ev:ev,cb:cb};});t.onKeyDown.add(function(ed,e){switch(e.keyCode){case 8:if(t.selection.getRng().item){t.selection.getRng().item(0).removeNode();return Event.cancel(e);}}});}if(tinymce.isOpera){t.onClick.add(function(ed,e){Event.prevent(e);});}if(s.custom_undo_redo){function addUndo(){t.undoManager.typing=0;t.undoManager.add();};if(tinymce.isIE){Event.add(t.getWin(),'blur',function(e){var n;if(t.selection){n=t.selection.getNode();if(!t.removed&&n.ownerDocument&&n.ownerDocument!=t.getDoc())addUndo();}});}else{Event.add(t.getDoc(),'blur',function(){if(t.selection&&!t.removed)addUndo();});}t.onMouseDown.add(addUndo);t.onKeyUp.add(function(ed,e){if((e.keyCode>=33&&e.keyCode<=36)||(e.keyCode>=37&&e.keyCode<=40)||e.keyCode==13||e.keyCode==45||e.ctrlKey){t.undoManager.typing=0;t.undoManager.add();}});t.onKeyDown.add(function(ed,e){if((e.keyCode>=33&&e.keyCode<=36)||(e.keyCode>=37&&e.keyCode<=40)||e.keyCode==13||e.keyCode==45){if(t.undoManager.typing){t.undoManager.add();t.undoManager.typing=0;}return;}if(!t.undoManager.typing){t.undoManager.add();t.undoManager.typing=1;}});}},_convertInlineElements:function(){var t=this,s=t.settings,dom=t.dom,v,e,na,st,sp;function convert(ed,o){if(!s.inline_styles)return;if(o.get){each(t.dom.select('table,u,strike',o.node),function(n){switch(n.nodeName){case'TABLE':if(v=dom.getAttrib(n,'height')){dom.setStyle(n,'height',v);dom.setAttrib(n,'height','');}break;case'U':case'STRIKE':n.style.textDecoration=n.nodeName=='U'?'underline':'line-through';dom.setAttrib(n,'mce_style','');dom.setAttrib(n,'mce_name','span');break;}});}else if(o.set){each(t.dom.select('table,span',o.node).reverse(),function(n){if(n.nodeName=='TABLE'){if(v=dom.getStyle(n,'height'))dom.setAttrib(n,'height',v.replace(/[^0-9%]+/g,''));}else{if(n.style.textDecoration=='underline')na='u';else if(n.style.textDecoration=='line-through')na='strike';else na='';if(na){n.style.textDecoration='';dom.setAttrib(n,'mce_style','');e=dom.create(na,{style:dom.getAttrib(n,'style')});dom.replace(e,n,1);}}});}};t.onPreProcess.add(convert);if(!s.cleanup_on_startup){t.onSetContent.add(function(ed,o){if(o.initial)convert(t,{node:t.getBody(),set:1});});}},_convertFonts:function(){var t=this,s=t.settings,dom=t.dom,fz,fzn,sl,cl;if(!s.inline_styles)return;fz=[8,10,12,14,18,24,36];fzn=['xx-small','x-small','small','medium','large','x-large','xx-large'];if(sl=s.font_size_style_values)sl=explode(sl);if(cl=s.font_size_classes)cl=explode(cl);function convertToFonts(no){var n,f,nl,x,i,v,st;if(tinymce.isWebKit||!s.inline_styles)return;nl=t.dom.select('span',no);for(x=nl.length-1;x>=0;x--){n=nl[x];f=dom.create('font',{color:dom.toHex(dom.getStyle(n,'color')),face:dom.getStyle(n,'fontFamily'),style:dom.getAttrib(n,'style'),'class':dom.getAttrib(n,'class')});st=f.style;if(st.color||st.fontFamily){st.color=st.fontFamily='';dom.setAttrib(f,'mce_style','');}if(sl){i=inArray(sl,dom.getStyle(n,'fontSize'));if(i!=-1){dom.setAttrib(f,'size',''+(i+1||1));}}else if(cl){i=inArray(cl,dom.getAttrib(n,'class'));v=dom.getStyle(n,'fontSize');if(i==-1&&v.indexOf('pt')>0)i=inArray(fz,parseInt(v));if(i==-1)i=inArray(fzn,v);if(i!=-1){dom.setAttrib(f,'size',''+(i+1||1));f.style.fontSize='';}}if(f.color||f.face||f.size){f.style.fontFamily='';dom.setAttrib(f,'mce_style','');dom.replace(f,n,1);}f=n=null;}};t.onSetContent.add(function(ed,o){convertToFonts(ed.getBody());});t.onPreProcess.add(function(ed,o){var n,sp,nl,x;if(!s.inline_styles)return;if(o.get){nl=t.dom.select('font',o.node);for(x=nl.length-1;x>=0;x--){n=nl[x];sp=dom.create('span',{style:dom.getAttrib(n,'style'),'class':dom.getAttrib(n,'class')});dom.setStyles(sp,{fontFamily:dom.getAttrib(n,'face'),color:dom.getAttrib(n,'color'),backgroundColor:n.style.backgroundColor});if(n.size){if(sl)dom.setStyle(sp,'fontSize',sl[parseInt(n.size)-1]);else dom.setAttrib(sp,'class',cl[parseInt(n.size)-1]);}dom.setAttrib(sp,'mce_style','');dom.replace(sp,n,1);}}});},_isHidden:function(){var s;if(!isGecko)return 0;s=this.selection.getSel();return(!s||!s.rangeCount||s.rangeCount==0);},_fixNesting:function(s){var d=[],i;s=s.replace(/<(\/)?([^\s>]+)[^>]*?>/g,function(a,b,c){var e;if(b==='/'){if(!d.length)return'';if(c!==d[d.length-1].tag){for(i=d.length-1;i>=0;i--){if(d[i].tag===c){d[i].close=1;break;}}return'';}else{d.pop();if(d.length&&d[d.length-1].close){a=a+'</'+d[d.length-1].tag+'>';d.pop();}}}else{if(/^(br|hr|input|meta|img|link|param)$/i.test(c))return a;if(/\/>$/.test(a))return a;d.push({tag:c});}return a;});for(i=d.length-1;i>=0;i--)s+='</'+d[i].tag+'>';return s;}});})();(function(){var each=tinymce.each,isIE=tinymce.isIE,isGecko=tinymce.isGecko,isOpera=tinymce.isOpera,isWebKit=tinymce.isWebKit;tinymce.create('tinymce.EditorCommands',{EditorCommands:function(ed){this.editor=ed;},execCommand:function(cmd,ui,val){var t=this,ed=t.editor,f;switch(cmd){case'Cut':case'Copy':case'Paste':try{ed.getDoc().execCommand(cmd,ui,val);}catch(ex){if(isGecko){ed.windowManager.confirm(ed.getLang('clipboard_msg'),function(s){if(s)window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html','mceExternal');});}else ed.windowManager.alert(ed.getLang('clipboard_no_support'));}return true;case'mceResetDesignMode':case'mceBeginUndoLevel':return true;case'unlink':t.UnLink();return true;case'JustifyLeft':case'JustifyCenter':case'JustifyRight':case'JustifyFull':t.mceJustify(cmd,cmd.substring(7).toLowerCase());return true;case'mceEndUndoLevel':case'mceAddUndoLevel':ed.undoManager.add();return true;default:f=this[cmd];if(f){f.call(this,ui,val);return true;}}return false;},Indent:function(){var ed=this.editor,d=ed.dom,s=ed.selection,e,iv,iu;iv=ed.settings.indentation;iu=/[a-z%]+$/i.exec(iv);iv=parseInt(iv);if(ed.settings.inline_styles&&(!this.queryStateInsertUnorderedList()&&!this.queryStateInsertOrderedList())){each(this._getSelectedBlocks(),function(e){d.setStyle(e,'paddingLeft',(parseInt(e.style.paddingLeft||0)+iv)+iu);});return;}ed.getDoc().execCommand('Indent',false,null);if(isIE){d.getParent(s.getNode(),function(n){if(n.nodeName=='BLOCKQUOTE'){n.dir=n.style.cssText='';}});}},Outdent:function(){var ed=this.editor,d=ed.dom,s=ed.selection,e,v,iv,iu;iv=ed.settings.indentation;iu=/[a-z%]+$/i.exec(iv);iv=parseInt(iv);if(ed.settings.inline_styles&&(!this.queryStateInsertUnorderedList()&&!this.queryStateInsertOrderedList())){each(this._getSelectedBlocks(),function(e){v=Math.max(0,parseInt(e.style.paddingLeft||0)-iv);d.setStyle(e,'paddingLeft',v?v+iu:'');});return;}ed.getDoc().execCommand('Outdent',false,null);},mceSetAttribute:function(u,v){var ed=this.editor,d=ed.dom,e;if(e=d.getParent(ed.selection.getNode(),d.isBlock))d.setAttrib(e,v.name,v.value);},mceSetContent:function(u,v){this.editor.setContent(v);},mceToggleVisualAid:function(){var ed=this.editor;ed.hasVisual=!ed.hasVisual;ed.addVisual();},mceReplaceContent:function(u,v){var s=this.editor.selection;s.setContent(v.replace(/\{\$selection\}/g,s.getContent({format:'text'})));},mceInsertLink:function(u,v){var ed=this.editor,s=ed.selection,e=ed.dom.getParent(s.getNode(),'A');if(tinymce.is(v,'string'))v={href:v};function set(e){each(v,function(v,k){ed.dom.setAttrib(e,k,v);});};if(!e){ed.execCommand('CreateLink',false,'javascript:mctmp(0);');each(ed.dom.select('a'),function(e){if(e.href=='javascript:mctmp(0);')set(e);});}else{if(v.href)set(e);else ed.dom.remove(e,1);}},UnLink:function(){var ed=this.editor,s=ed.selection;if(s.isCollapsed())s.select(s.getNode());ed.getDoc().execCommand('unlink',false,null);s.collapse(0);},FontName:function(u,v){var t=this,ed=t.editor,s=ed.selection,e;if(!v){if(s.isCollapsed())s.select(s.getNode());t.RemoveFormat();}else ed.getDoc().execCommand('FontName',false,v);},FontSize:function(u,v){var ed=this.editor,s=ed.settings,fz=tinymce.explode(s.font_size_style_values),fzc=tinymce.explode(s.font_size_classes),h,bm;each(ed.dom.select('font'),function(e){e.style.fontSize='';});ed.getDoc().execCommand('FontSize',false,v);if(s.inline_styles){each(ed.dom.select('font'),function(e){if(e.parentNode.nodeName=='FONT'&&e.size==e.parentNode.size){if(!bm)bm=ed.selection.getBookmark();ed.dom.remove(e,1);return;}if(v=e.size){if(fzc&&fzc.length>0)ed.dom.setAttrib(e,'class',fzc[parseInt(v)-1]);else ed.dom.setStyle(e,'fontSize',fz[parseInt(v)-1]);}});}ed.selection.moveToBookmark(bm);},queryCommandValue:function(c){var f=this['queryValue'+c];if(f)return f.call(this,c);return false;},queryCommandState:function(cmd){var f;switch(cmd){case'JustifyLeft':case'JustifyCenter':case'JustifyRight':case'JustifyFull':return this.queryStateJustify(cmd,cmd.substring(7).toLowerCase());default:if(f=this['queryState'+cmd])return f.call(this,cmd);}return-1;},_queryState:function(c){try{return this.editor.getDoc().queryCommandState(c);}catch(ex){}},_queryVal:function(c){try{return this.editor.getDoc().queryCommandValue(c);}catch(ex){}},queryValueFontSize:function(){var ed=this.editor,v=0,p;if(isOpera||isWebKit){if(p=ed.dom.getParent(ed.selection.getNode(),'FONT'))v=p.size;return v;}return this._queryVal('FontSize');},queryValueFontName:function(){var ed=this.editor,v=0,p;if(p=ed.dom.getParent(ed.selection.getNode(),'FONT'))v=p.face;if(!v)v=this._queryVal('FontName');return v;},mceJustify:function(c,v){var ed=this.editor,se=ed.selection,n=se.getNode(),nn=n.nodeName,bl,nb,dom=ed.dom,rm;if(ed.settings.inline_styles&&this.queryStateJustify(c,v))rm=1;bl=dom.getParent(n,ed.dom.isBlock);if(nn=='IMG'){if(v=='full')return;if(rm){if(v=='center')dom.setStyle(bl||n.parentNode,'textAlign','');dom.setStyle(n,'float','');this.mceRepaint();return;}if(v=='center'){if(bl&&/^(TD|TH)$/.test(bl.nodeName))bl=0;if(!bl||bl.childNodes.length>1){nb=dom.create('p');nb.appendChild(n.cloneNode(false));if(bl)dom.insertAfter(nb,bl);else dom.insertAfter(nb,n);dom.remove(n);n=nb.firstChild;bl=nb;}dom.setStyle(bl,'textAlign',v);dom.setStyle(n,'float','');}else{dom.setStyle(n,'float',v);dom.setStyle(bl||n.parentNode,'textAlign','');}this.mceRepaint();return;}if(ed.settings.inline_styles&&ed.settings.forced_root_block){if(rm)v='';each(this._getSelectedBlocks(dom.getParent(se.getStart(),dom.isBlock),dom.getParent(se.getEnd(),dom.isBlock)),function(e){dom.setAttrib(e,'align','');dom.setStyle(e,'textAlign',v=='full'?'justify':v);});return;}else if(!rm)ed.getDoc().execCommand(c,false,null);if(ed.settings.inline_styles){if(rm){dom.getParent(ed.selection.getNode(),function(n){if(n.style&&n.style.textAlign)dom.setStyle(n,'textAlign','');});return;}each(dom.select('*'),function(n){var v=n.align;if(v){if(v=='full')v='justify';dom.setStyle(n,'textAlign',v);dom.setAttrib(n,'align','');}});}},mceSetCSSClass:function(u,v){this.mceSetStyleInfo(0,{command:'setattrib',name:'class',value:v});},getSelectedElement:function(){var t=this,ed=t.editor,dom=ed.dom,se=ed.selection,r=se.getRng(),r1,r2,sc,ec,so,eo,e,sp,ep,re;if(se.isCollapsed()||r.item)return se.getNode();re=ed.settings.merge_styles_invalid_parents;if(tinymce.is(re,'string'))re=new RegExp(re,'i');if(isIE){r1=r.duplicate();r1.collapse(true);sc=r1.parentElement();r2=r.duplicate();r2.collapse(false);ec=r2.parentElement();if(sc!=ec){r1.move('character',1);sc=r1.parentElement();}if(sc==ec){r1=r.duplicate();r1.moveToElementText(sc);if(r1.compareEndPoints('StartToStart',r)==0&&r1.compareEndPoints('EndToEnd',r)==0)return re&&re.test(sc.nodeName)?null:sc;}}else{function getParent(n){return dom.getParent(n,function(n){return n.nodeType==1;});};sc=r.startContainer;ec=r.endContainer;so=r.startOffset;eo=r.endOffset;if(!r.collapsed){if(sc==ec){if(so-eo<2){if(sc.hasChildNodes()){sp=sc.childNodes[so];return re&&re.test(sp.nodeName)?null:sp;}}}}if(sc.nodeType!=3||ec.nodeType!=3)return null;if(so==0){sp=getParent(sc);if(sp&&sp.firstChild!=sc)sp=null;}if(so==sc.nodeValue.length){e=sc.nextSibling;if(e&&e.nodeType==1)sp=sc.nextSibling;}if(eo==0){e=ec.previousSibling;if(e&&e.nodeType==1)ep=e;}if(eo==ec.nodeValue.length){ep=getParent(ec);if(ep&&ep.lastChild!=ec)ep=null;}if(sp==ep)return re&&sp&&re.test(sp.nodeName)?null:sp;}return null;},InsertHorizontalRule:function(){if(isGecko||isIE)this.editor.selection.setContent('<hr />');else this.editor.getDoc().execCommand('InsertHorizontalRule',false,'');},RemoveFormat:function(){var t=this,ed=t.editor,s=ed.selection,b;if(isWebKit)s.setContent(s.getContent({format:'raw'}).replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g,''),{format:'raw'});else ed.getDoc().execCommand('RemoveFormat',false,null);t.mceSetStyleInfo(0,{command:'removeformat'});ed.addVisual();},mceSetStyleInfo:function(u,v){var t=this,ed=t.editor,d=ed.getDoc(),dom=ed.dom,e,b,s=ed.selection,nn=v.wrapper||'span',b=s.getBookmark(),re;function set(n,e){if(n.nodeType==1){switch(v.command){case'setattrib':return dom.setAttrib(n,v.name,v.value);case'setstyle':return dom.setStyle(n,v.name,v.value);case'removeformat':return dom.setAttrib(n,'class','');}}};re=ed.settings.merge_styles_invalid_parents;if(tinymce.is(re,'string'))re=new RegExp(re,'i');if(e=t.getSelectedElement())set(e,1);else{d.execCommand('FontName',false,'__');each(isWebKit?dom.select('span'):dom.select('font'),function(n){var sp,e;if(dom.getAttrib(n,'face')=='__'||n.style.fontFamily==='__'){sp=dom.create(nn,{mce_new:'1'});set(sp);each(n.childNodes,function(n){sp.appendChild(n.cloneNode(true));});dom.replace(sp,n);}});}each(dom.select(nn).reverse(),function(n){var p=n.parentNode;if(!dom.getAttrib(n,'mce_new')){p=dom.getParent(n,function(n){return n.nodeType==1&&dom.getAttrib(n,'mce_new');});if(p)dom.remove(n,1);}});each(dom.select(nn).reverse(),function(n){var p=n.parentNode;if(!p||!dom.getAttrib(n,'mce_new'))return;if(p.nodeName==nn.toUpperCase()&&p.childNodes.length==1)return dom.remove(p,1);if(n.nodeType==1&&(!re||!re.test(p.nodeName))&&p.childNodes.length==1){set(p);dom.setAttrib(n,'class','');}});each(dom.select(nn).reverse(),function(n){if(dom.getAttrib(n,'mce_new')||(dom.getAttribs(n).length<=1&&n.className==='')){if(!dom.getAttrib(n,'class')&&!dom.getAttrib(n,'style'))return dom.remove(n,1);dom.setAttrib(n,'mce_new','');}});s.moveToBookmark(b);},queryStateJustify:function(c,v){var ed=this.editor,n=ed.selection.getNode(),dom=ed.dom;if(n&&n.nodeName=='IMG'){if(dom.getStyle(n,'float')==v)return 1;return n.parentNode.style.textAlign==v;}n=dom.getParent(ed.selection.getStart(),function(n){return n.nodeType==1&&n.style.textAlign;});if(v=='full')v='justify';if(ed.settings.inline_styles)return(n&&n.style.textAlign==v);return this._queryState(c);},HiliteColor:function(ui,val){var t=this,ed=t.editor,d=ed.getDoc();function set(s){if(!isGecko)return;try{d.execCommand("styleWithCSS",0,s);}catch(ex){d.execCommand("useCSS",0,!s);}};if(isGecko||isOpera){set(true);d.execCommand('hilitecolor',false,val);set(false);}else d.execCommand('BackColor',false,val);},Undo:function(){var ed=this.editor;if(ed.settings.custom_undo_redo){ed.undoManager.undo();ed.nodeChanged();}else ed.getDoc().execCommand('Undo',false,null);},Redo:function(){var ed=this.editor;if(ed.settings.custom_undo_redo){ed.undoManager.redo();ed.nodeChanged();}else ed.getDoc().execCommand('Redo',false,null);},FormatBlock:function(ui,val){var t=this,ed=t.editor,s=ed.selection,dom=ed.dom,bl,nb,b;function isBlock(n){return/^(P|DIV|H[1-6]|ADDRESS|BLOCKQUOTE|PRE)$/.test(n.nodeName);};bl=dom.getParent(s.getNode(),function(n){return isBlock(n);});if(bl){if((isIE&&isBlock(bl.parentNode))||bl.nodeName=='DIV'){nb=ed.dom.create(val);each(dom.getAttribs(bl),function(v){dom.setAttrib(nb,v.nodeName,dom.getAttrib(bl,v.nodeName));});b=s.getBookmark();dom.replace(nb,bl,1);s.moveToBookmark(b);ed.nodeChanged();return;}}val=ed.settings.forced_root_block?(val||'<p>'):val;if(val.indexOf('<')==-1)val='<'+val+'>';if(tinymce.isGecko)val=val.replace(/<(div|blockquote|code|dt|dd|dl|samp)>/gi,'$1');ed.getDoc().execCommand('FormatBlock',false,val);},mceCleanup:function(){var ed=this.editor,s=ed.selection,b=s.getBookmark();ed.setContent(ed.getContent());s.moveToBookmark(b);},mceRemoveNode:function(ui,val){var ed=this.editor,s=ed.selection,b,n=val||s.getNode();if(n==ed.getBody())return;b=s.getBookmark();ed.dom.remove(n,1);s.moveToBookmark(b);ed.nodeChanged();},mceSelectNodeDepth:function(ui,val){var ed=this.editor,s=ed.selection,c=0;ed.dom.getParent(s.getNode(),function(n){if(n.nodeType==1&&c++==val){s.select(n);ed.nodeChanged();return false;}},ed.getBody());},mceSelectNode:function(u,v){this.editor.selection.select(v);},mceInsertContent:function(ui,val){this.editor.selection.setContent(val);},mceInsertRawHTML:function(ui,val){var ed=this.editor;ed.selection.setContent('tiny_mce_marker');ed.setContent(ed.getContent().replace(/tiny_mce_marker/g,val));},mceRepaint:function(){var s,b,e=this.editor;if(tinymce.isGecko){try{s=e.selection;b=s.getBookmark(true);if(s.getSel())s.getSel().selectAllChildren(e.getBody());s.collapse(true);s.moveToBookmark(b);}catch(ex){}}},queryStateUnderline:function(){var ed=this.editor,n=ed.selection.getNode();if(n&&n.nodeName=='A')return false;return this._queryState('Underline');},queryStateOutdent:function(){var ed=this.editor,n;if(ed.settings.inline_styles){if((n=ed.dom.getParent(ed.selection.getStart(),ed.dom.isBlock))&&parseInt(n.style.paddingLeft)>0)return true;if((n=ed.dom.getParent(ed.selection.getEnd(),ed.dom.isBlock))&&parseInt(n.style.paddingLeft)>0)return true;}else return!!ed.dom.getParent(ed.selection.getNode(),'BLOCKQUOTE');return this.queryStateInsertUnorderedList()||this.queryStateInsertOrderedList();},queryStateInsertUnorderedList:function(){return this.editor.dom.getParent(this.editor.selection.getNode(),'UL');},queryStateInsertOrderedList:function(){return this.editor.dom.getParent(this.editor.selection.getNode(),'OL');},queryStatemceBlockQuote:function(){return!!this.editor.dom.getParent(this.editor.selection.getStart(),function(n){return n.nodeName==='BLOCKQUOTE';});},mceBlockQuote:function(){var t=this,ed=t.editor,s=ed.selection,dom=ed.dom,sb,eb,n,bm,bq,r,bq2,i,nl;function getBQ(e){return dom.getParent(e,function(n){return n.nodeName==='BLOCKQUOTE';});};sb=dom.getParent(s.getStart(),dom.isBlock);eb=dom.getParent(s.getEnd(),dom.isBlock);if(bq=getBQ(sb)){if(sb!=eb||sb.childNodes.length>1||(sb.childNodes.length==1&&sb.firstChild.nodeName!='BR'))bm=s.getBookmark();if(getBQ(eb)){bq2=bq.cloneNode(false);while(n=eb.nextSibling)bq2.appendChild(n.parentNode.removeChild(n));}if(bq2)dom.insertAfter(bq2,bq);nl=t._getSelectedBlocks(sb,eb);for(i=nl.length-1;i>=0;i--){dom.insertAfter(nl[i],bq);}if(/^\s*$/.test(bq.innerHTML))dom.remove(bq,1);if(bq2&&/^\s*$/.test(bq2.innerHTML))dom.remove(bq2,1);if(!bm){if(!isIE){r=ed.getDoc().createRange();r.setStart(sb,0);r.setEnd(sb,0);s.setRng(r);}else{s.select(sb);s.collapse(0);if(dom.getParent(s.getStart(),dom.isBlock)!=sb){r=s.getRng();r.move('character',-1);r.select();}}}else t.editor.selection.moveToBookmark(bm);return;}if(isIE&&!sb&&!eb){t.editor.getDoc().execCommand('Indent');n=getBQ(s.getNode());n.style.margin=n.dir='';return;}if(!sb||!eb)return;if(sb!=eb||sb.childNodes.length>1||(sb.childNodes.length==1&&sb.firstChild.nodeName!='BR'))bm=s.getBookmark();each(t._getSelectedBlocks(getBQ(s.getStart()),getBQ(s.getEnd())),function(e){if(e.nodeName=='BLOCKQUOTE'&&!bq){bq=e;return;}if(!bq){bq=dom.create('blockquote');e.parentNode.insertBefore(bq,e);}if(e.nodeName=='BLOCKQUOTE'&&bq){n=e.firstChild;while(n){bq.appendChild(n.cloneNode(true));n=n.nextSibling;}dom.remove(e);return;}bq.appendChild(dom.remove(e));});if(!bm){if(!isIE){r=ed.getDoc().createRange();r.setStart(sb,0);r.setEnd(sb,0);s.setRng(r);}else{s.select(sb);s.collapse(1);}}else s.moveToBookmark(bm);},_getSelectedBlocks:function(st,en){var ed=this.editor,dom=ed.dom,s=ed.selection,sb,eb,n,bl=[];sb=dom.getParent(st||s.getStart(),dom.isBlock);eb=dom.getParent(en||s.getEnd(),dom.isBlock);if(sb)bl.push(sb);if(sb&&eb&&sb!=eb){n=sb;while((n=n.nextSibling)&&n!=eb){if(dom.isBlock(n))bl.push(n);}}if(eb&&sb!=eb)bl.push(eb);return bl;}});})();tinymce.create('tinymce.UndoManager',{index:0,data:null,typing:0,UndoManager:function(ed){var t=this,Dispatcher=tinymce.util.Dispatcher;t.editor=ed;t.data=[];t.onAdd=new Dispatcher(this);t.onUndo=new Dispatcher(this);t.onRedo=new Dispatcher(this);},add:function(l){var t=this,i,ed=t.editor,b,s=ed.settings,la;l=l||{};l.content=l.content||ed.getContent({format:'raw',no_events:1});l.content=l.content.replace(/^\s*|\s*$/g,'');la=t.data[t.index>0&&(t.index==0||t.index==t.data.length)?t.index-1:t.index];if(!l.initial&&la&&l.content==la.content)return null;if(s.custom_undo_redo_levels){if(t.data.length>s.custom_undo_redo_levels){for(i=0;i<t.data.length-1;i++)t.data[i]=t.data[i+1];t.data.length--;t.index=t.data.length;}}if(s.custom_undo_redo_restore_selection&&!l.initial)l.bookmark=b=l.bookmark||ed.selection.getBookmark();if(t.index<t.data.length)t.index++;if(t.data.length===0&&!l.initial)return null;t.data.length=t.index+1;t.data[t.index++]=l;if(l.initial)t.index=0;if(t.data.length==2&&t.data[0].initial)t.data[0].bookmark=b;t.onAdd.dispatch(t,l);ed.isNotDirty=0;return l;},undo:function(){var t=this,ed=t.editor,l=l,i;if(t.typing){t.add();t.typing=0;}if(t.index>0){if(t.index==t.data.length&&t.index>1){i=t.index;t.typing=0;if(!t.add())t.index=i;--t.index;}l=t.data[--t.index];ed.setContent(l.content,{format:'raw'});ed.selection.moveToBookmark(l.bookmark);t.onUndo.dispatch(t,l);}return l;},redo:function(){var t=this,ed=t.editor,l=null;if(t.index<t.data.length-1){l=t.data[++t.index];ed.setContent(l.content,{format:'raw'});ed.selection.moveToBookmark(l.bookmark);t.onRedo.dispatch(t,l);}return l;},clear:function(){var t=this;t.data=[];t.index=0;t.typing=0;t.add({initial:true});},hasUndo:function(){return this.index!=0||this.typing;},hasRedo:function(){return this.index<this.data.length-1;}});(function(){var Event,isIE,isGecko,isOpera,each,extend;Event=tinymce.dom.Event;isIE=tinymce.isIE;isGecko=tinymce.isGecko;isOpera=tinymce.isOpera;each=tinymce.each;extend=tinymce.extend;tinymce.create('tinymce.ForceBlocks',{ForceBlocks:function(ed){var t=this,s=ed.settings,elm;t.editor=ed;t.dom=ed.dom;elm=(s.forced_root_block||'p').toLowerCase();s.element=elm.toUpperCase();ed.onPreInit.add(t.setup,t);t.reOpera=new RegExp('(\\u00a0| | )<\/'+elm+'>','gi');t.rePadd=new RegExp('<p( )([^>]+)><\\\/p>|<p( )([^>]+)\\\/>|<p( )([^>]+)>\\s+<\\\/p>|<p><\\\/p>|<p\\\/>|<p>\\s+<\\\/p>'.replace(/p/g,elm),'gi');t.reNbsp2BR1=new RegExp('<p( )([^>]+)>[\\s\\u00a0]+<\\\/p>|<p>[\\s\\u00a0]+<\\\/p>'.replace(/p/g,elm),'gi');t.reNbsp2BR2=new RegExp('<p( )([^>]+)>( | )<\\\/p>|<p>( | )<\\\/p>'.replace(/p/g,elm),'gi');t.reBR2Nbsp=new RegExp('<p( )([^>]+)>\\s*<br \\\/>\\s*<\\\/p>|<p>\\s*<br \\\/>\\s*<\\\/p>'.replace(/p/g,elm),'gi');t.reTrailBr=new RegExp('\\s*<br \\/>\\s*<\\\/p>'.replace(/p/g,elm),'gi');function padd(ed,o){if(isOpera)o.content=o.content.replace(t.reOpera,'</'+elm+'>');o.content=o.content.replace(t.rePadd,'<'+elm+'$1$2$3$4$5$6>\u00a0</'+elm+'>');if(!isIE&&!isOpera&&o.set){o.content=o.content.replace(t.reNbsp2BR1,'<'+elm+'$1$2><br /></'+elm+'>');o.content=o.content.replace(t.reNbsp2BR2,'<'+elm+'$1$2><br /></'+elm+'>');}else{o.content=o.content.replace(t.reBR2Nbsp,'<'+elm+'$1$2>\u00a0</'+elm+'>');o.content=o.content.replace(t.reTrailBr,'</'+elm+'>');}};ed.onBeforeSetContent.add(padd);ed.onPostProcess.add(padd);if(s.forced_root_block){ed.onInit.add(t.forceRoots,t);ed.onSetContent.add(t.forceRoots,t);ed.onBeforeGetContent.add(t.forceRoots,t);}},setup:function(){var t=this,ed=t.editor,s=ed.settings;if(s.forced_root_block){ed.onKeyUp.add(t.forceRoots,t);ed.onPreProcess.add(t.forceRoots,t);}if(s.force_br_newlines){if(isIE){ed.onKeyPress.add(function(ed,e){var n,s=ed.selection;if(e.keyCode==13&&s.getNode().nodeName!='LI'){s.setContent('<br id="__" /> ',{format:'raw'});n=ed.dom.get('__');n.removeAttribute('id');s.select(n);s.collapse();return Event.cancel(e);}});}return;}if(!isIE&&s.force_p_newlines){ed.onKeyPress.add(function(ed,e){if(e.keyCode==13&&!e.shiftKey){if(!t.insertPara(e))Event.cancel(e);}});if(isGecko){ed.onKeyDown.add(function(ed,e){if((e.keyCode==8||e.keyCode==46)&&!e.shiftKey)t.backspaceDelete(e,e.keyCode==8);});}}function ren(rn,na){var ne=ed.dom.create(na);each(rn.attributes,function(a){if(a.specified&&a.nodeValue)ne.setAttribute(a.nodeName.toLowerCase(),a.nodeValue);});each(rn.childNodes,function(n){ne.appendChild(n.cloneNode(true));});rn.parentNode.replaceChild(ne,rn);return ne;};if(isIE&&s.element!='P'){ed.onKeyPress.add(function(ed,e){t.lastElm=ed.selection.getNode().nodeName;});ed.onKeyUp.add(function(ed,e){var bl,sel=ed.selection,n=sel.getNode(),b=ed.getBody();if(b.childNodes.length===1&&n.nodeName=='P'){n=ren(n,s.element);sel.select(n);sel.collapse();ed.nodeChanged();}else if(e.keyCode==13&&!e.shiftKey&&t.lastElm!='P'){bl=ed.dom.getParent(n,'P');if(bl){ren(bl,s.element);ed.nodeChanged();}}});}},find:function(n,t,s){var ed=this.editor,w=ed.getDoc().createTreeWalker(n,4,null,false),c=-1;while(n=w.nextNode()){c++;if(t==0&&n==s)return c;if(t==1&&c==s)return n;}return-1;},forceRoots:function(ed,e){var t=this,ed=t.editor,b=ed.getBody(),d=ed.getDoc(),se=ed.selection,s=se.getSel(),r=se.getRng(),si=-2,ei,so,eo,tr,c=-0xFFFFFF;var nx,bl,bp,sp,le,nl=b.childNodes,i;if(e&&e.keyCode==13)return true;for(i=nl.length-1;i>=0;i--){nx=nl[i];if(nx.nodeType==3||(!t.dom.isBlock(nx)&&nx.nodeType!=8)){if(!bl){if(nx.nodeType!=3||/[^\s]/g.test(nx.nodeValue)){if(si==-2&&r){if(!isIE){if(ed.dom.getParent(r.startContainer,function(e){return e===b;})){so=r.startOffset;eo=r.endOffset;si=t.find(b,0,r.startContainer);ei=t.find(b,0,r.endContainer);}}else{tr=d.body.createTextRange();tr.moveToElementText(b);tr.collapse(1);bp=tr.move('character',c)*-1;tr=r.duplicate();tr.collapse(1);sp=tr.move('character',c)*-1;tr=r.duplicate();tr.collapse(0);le=(tr.move('character',c)*-1)-sp;si=sp-bp;ei=le;}}bl=ed.dom.create(ed.settings.forced_root_block);bl.appendChild(nx.cloneNode(1));nx.parentNode.replaceChild(bl,nx);}}else{if(bl.hasChildNodes())bl.insertBefore(nx,bl.firstChild);else bl.appendChild(nx);}}else bl=null;}if(si!=-2){if(!isIE){bl=b.getElementsByTagName(ed.settings.element)[0];r=d.createRange();if(si!=-1)r.setStart(t.find(b,1,si),so);else r.setStart(bl,0);if(ei!=-1)r.setEnd(t.find(b,1,ei),eo);else r.setEnd(bl,0);if(s){s.removeAllRanges();s.addRange(r);}}else{try{r=s.createRange();r.moveToElementText(b);r.collapse(1);r.moveStart('character',si);r.moveEnd('character',ei);r.select();}catch(ex){}}}},getParentBlock:function(n){var d=this.dom;return d.getParent(n,d.isBlock);},insertPara:function(e){var t=this,ed=t.editor,dom=ed.dom,d=ed.getDoc(),se=ed.settings,s=ed.selection.getSel(),r=s.getRangeAt(0),b=d.body;var rb,ra,dir,sn,so,en,eo,sb,eb,bn,bef,aft,sc,ec,n,vp=dom.getViewPort(ed.getWin()),y,ch;function isEmpty(n){n=n.innerHTML;n=n.replace(/<(img|hr|table)/gi,'-');n=n.replace(/<[^>]+>/g,'');return n.replace(/[ \t\r\n]+/g,'')=='';};rb=d.createRange();rb.setStart(s.anchorNode,s.anchorOffset);rb.collapse(true);ra=d.createRange();ra.setStart(s.focusNode,s.focusOffset);ra.collapse(true);dir=rb.compareBoundaryPoints(rb.START_TO_END,ra)<0;sn=dir?s.anchorNode:s.focusNode;so=dir?s.anchorOffset:s.focusOffset;en=dir?s.focusNode:s.anchorNode;eo=dir?s.focusOffset:s.anchorOffset;if(sn===en&&/^(TD|TH)$/.test(sn.nodeName)){dom.remove(sn.firstChild);ed.dom.add(sn,se.element,null,'<br />');aft=ed.dom.add(sn,se.element,null,'<br />');r=d.createRange();r.selectNodeContents(aft);r.collapse(1);ed.selection.setRng(r);return false;}if(sn==b&&en==b&&b.firstChild&&ed.dom.isBlock(b.firstChild)){sn=en=sn.firstChild;so=eo=0;rb=d.createRange();rb.setStart(sn,0);ra=d.createRange();ra.setStart(en,0);}sn=sn.nodeName=="HTML"?d.body:sn;sn=sn.nodeName=="BODY"?sn.firstChild:sn;en=en.nodeName=="HTML"?d.body:en;en=en.nodeName=="BODY"?en.firstChild:en;sb=t.getParentBlock(sn);eb=t.getParentBlock(en);bn=sb?sb.nodeName:se.element;if(t.dom.getParent(sb,function(n){return/OL|UL|PRE/.test(n.nodeName);}))return true;if(sb&&(sb.nodeName=='CAPTION'||/absolute|relative|static/gi.test(sb.style.position))){bn=se.element;sb=null;}if(eb&&(eb.nodeName=='CAPTION'||/absolute|relative|static/gi.test(eb.style.position))){bn=se.element;eb=null;}if(/(TD|TABLE|TH|CAPTION)/.test(bn)||(sb&&bn=="DIV"&&/left|right/gi.test(sb.style.cssFloat))){bn=se.element;sb=eb=null;}bef=(sb&&sb.nodeName==bn)?sb.cloneNode(0):ed.dom.create(bn);aft=(eb&&eb.nodeName==bn)?eb.cloneNode(0):ed.dom.create(bn);aft.removeAttribute('id');if(/^(H[1-6])$/.test(bn)&&sn.nodeValue&&so==sn.nodeValue.length)aft=ed.dom.create(se.element);n=sc=sn;do{if(n==b||n.nodeType==9||t.dom.isBlock(n)||/(TD|TABLE|TH|CAPTION)/.test(n.nodeName))break;sc=n;}while((n=n.previousSibling?n.previousSibling:n.parentNode));n=ec=en;do{if(n==b||n.nodeType==9||t.dom.isBlock(n)||/(TD|TABLE|TH|CAPTION)/.test(n.nodeName))break;ec=n;}while((n=n.nextSibling?n.nextSibling:n.parentNode));if(sc.nodeName==bn)rb.setStart(sc,0);else rb.setStartBefore(sc);rb.setEnd(sn,so);bef.appendChild(rb.cloneContents()||d.createTextNode(''));try{ra.setEndAfter(ec);}catch(ex){}ra.setStart(en,eo);aft.appendChild(ra.cloneContents()||d.createTextNode(''));r=d.createRange();if(!sc.previousSibling&&sc.parentNode.nodeName==bn){r.setStartBefore(sc.parentNode);}else{if(rb.startContainer.nodeName==bn&&rb.startOffset==0)r.setStartBefore(rb.startContainer);else r.setStart(rb.startContainer,rb.startOffset);}if(!ec.nextSibling&&ec.parentNode.nodeName==bn)r.setEndAfter(ec.parentNode);else r.setEnd(ra.endContainer,ra.endOffset);r.deleteContents();if(isOpera)ed.getWin().scrollTo(0,vp.y);if(bef.firstChild&&bef.firstChild.nodeName==bn)bef.innerHTML=bef.firstChild.innerHTML;if(aft.firstChild&&aft.firstChild.nodeName==bn)aft.innerHTML=aft.firstChild.innerHTML;if(isEmpty(bef))bef.innerHTML='<br />';if(isEmpty(aft))aft.innerHTML=isOpera?' ':'<br />';if(isOpera&&parseFloat(opera.version())<9.5){r.insertNode(bef);r.insertNode(aft);}else{r.insertNode(aft);r.insertNode(bef);}aft.normalize();bef.normalize();function first(n){return d.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,false).nextNode()||n;};r=d.createRange();r.selectNodeContents(isGecko?first(aft):aft);r.collapse(1);s.removeAllRanges();s.addRange(r);y=ed.dom.getPos(aft).y;ch=aft.clientHeight;if(y<vp.y||y+ch>vp.y+vp.h){ed.getWin().scrollTo(0,y<vp.y?y:y-vp.h+ch);}return false;},backspaceDelete:function(e,bs){var t=this,ed=t.editor,b=ed.getBody(),n,se=ed.selection,r=se.getRng(),sc=r.startContainer,n,w,tn;if(sc&&ed.dom.isBlock(sc)&&!/^(TD|TH)$/.test(sc.nodeName)&&bs){if(sc.childNodes.length==0||(sc.childNodes.length==1&&sc.firstChild.nodeName=='BR')){n=sc;while((n=n.previousSibling)&&!ed.dom.isBlock(n));if(n){if(sc!=b.firstChild){w=ed.dom.doc.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,false);while(tn=w.nextNode())n=tn;r=ed.getDoc().createRange();r.setStart(n,n.nodeValue?n.nodeValue.length:0);r.setEnd(n,n.nodeValue?n.nodeValue.length:0);se.setRng(r);ed.dom.remove(sc);}return Event.cancel(e);}}}function handler(e){e=e.target;if(e&&e.parentNode&&e.nodeName=='BR'&&(n=t.getParentBlock(e))){Event.remove(b,'DOMNodeInserted',handler);if(e.previousSibling||e.nextSibling)ed.dom.remove(e);}};Event._add(b,'DOMNodeInserted',handler);window.setTimeout(function(){Event._remove(b,'DOMNodeInserted',handler);},1);}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,each=tinymce.each,extend=tinymce.extend;tinymce.create('tinymce.ControlManager',{ControlManager:function(ed,s){var t=this,i;s=s||{};t.editor=ed;t.controls={};t.onAdd=new tinymce.util.Dispatcher(t);t.onPostRender=new tinymce.util.Dispatcher(t);t.prefix=s.prefix||ed.id+'_';t._cls={};t.onPostRender.add(function(){each(t.controls,function(c){c.postRender();});});},get:function(id){return this.controls[this.prefix+id]||this.controls[id];},setActive:function(id,s){var c=null;if(c=this.get(id))c.setActive(s);return c;},setDisabled:function(id,s){var c=null;if(c=this.get(id))c.setDisabled(s);return c;},add:function(c){var t=this;if(c){t.controls[c.id]=c;t.onAdd.dispatch(c,t);}return c;},createControl:function(n){var c,t=this,ed=t.editor;each(ed.plugins,function(p){if(p.createControl){c=p.createControl(n,t);if(c)return false;}});switch(n){case"|":case"separator":return t.createSeparator();}if(!c&&ed.buttons&&(c=ed.buttons[n]))return t.createButton(n,c);return t.add(c);},createDropMenu:function(id,s,cc){var t=this,ed=t.editor,c,bm,v,cls;s=extend({'class':'mceDropDown',constrain:ed.settings.constrain_menus},s);s['class']=s['class']+' '+ed.getParam('skin')+'Skin';if(v=ed.getParam('skin_variant'))s['class']+=' '+ed.getParam('skin')+'Skin'+v.substring(0,1).toUpperCase()+v.substring(1);id=t.prefix+id;cls=cc||t._cls.dropmenu||tinymce.ui.DropMenu;c=t.controls[id]=new cls(id,s);c.onAddItem.add(function(c,o){var s=o.settings;s.title=ed.getLang(s.title,s.title);if(!s.onclick){s.onclick=function(v){ed.execCommand(s.cmd,s.ui||false,s.value);};}});ed.onRemove.add(function(){c.destroy();});if(tinymce.isIE){c.onShowMenu.add(function(){bm=ed.selection.getBookmark(1);});c.onHideMenu.add(function(){if(bm)ed.selection.moveToBookmark(bm);});}return t.add(c);},createListBox:function(id,s,cc){var t=this,ed=t.editor,cmd,c,cls;if(t.get(id))return null;s.title=ed.translate(s.title);s.scope=s.scope||ed;if(!s.onselect){s.onselect=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};}s=extend({title:s.title,'class':'mce_'+id,scope:s.scope,control_manager:t},s);id=t.prefix+id;if(ed.settings.use_native_selects)c=new tinymce.ui.NativeListBox(id,s);else{cls=cc||t._cls.listbox||tinymce.ui.ListBox;c=new cls(id,s);}t.controls[id]=c;if(tinymce.isWebKit){c.onPostRender.add(function(c,n){Event.add(n,'mousedown',function(){ed.bookmark=ed.selection.getBookmark('simple');});Event.add(n,'focus',function(){ed.selection.moveToBookmark(ed.bookmark);ed.bookmark=null;});});}if(c.hideMenu)ed.onMouseDown.add(c.hideMenu,c);return t.add(c);},createButton:function(id,s,cc){var t=this,ed=t.editor,o,c,cls;if(t.get(id))return null;s.title=ed.translate(s.title);s.label=ed.translate(s.label);s.scope=s.scope||ed;if(!s.onclick&&!s.menu_button){s.onclick=function(){ed.execCommand(s.cmd,s.ui||false,s.value);};}s=extend({title:s.title,'class':'mce_'+id,unavailable_prefix:ed.getLang('unavailable',''),scope:s.scope,control_manager:t},s);id=t.prefix+id;if(s.menu_button){cls=cc||t._cls.menubutton||tinymce.ui.MenuButton;c=new cls(id,s);ed.onMouseDown.add(c.hideMenu,c);}else{cls=t._cls.button||tinymce.ui.Button;c=new cls(id,s);}return t.add(c);},createMenuButton:function(id,s){s=s||{};s.menu_button=1;return this.createButton(id,s);},createSplitButton:function(id,s,cc){var t=this,ed=t.editor,cmd,c,cls;if(t.get(id))return null;s.title=ed.translate(s.title);s.scope=s.scope||ed;if(!s.onclick){s.onclick=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};}if(!s.onselect){s.onselect=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};}s=extend({title:s.title,'class':'mce_'+id,scope:s.scope,control_manager:t},s);id=t.prefix+id;cls=cc||t._cls.splitbutton||tinymce.ui.SplitButton;c=t.add(new cls(id,s));ed.onMouseDown.add(c.hideMenu,c);return c;},createColorSplitButton:function(id,s,cc){var t=this,ed=t.editor,cmd,c,cls,bm;if(t.get(id))return null;s.title=ed.translate(s.title);s.scope=s.scope||ed;if(!s.onclick){s.onclick=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};}if(!s.onselect){s.onselect=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};}s=extend({title:s.title,'class':'mce_'+id,'menu_class':ed.getParam('skin')+'Skin',scope:s.scope,more_colors_title:ed.getLang('more_colors')},s);id=t.prefix+id;cls=cc||t._cls.colorsplitbutton||tinymce.ui.ColorSplitButton;c=new cls(id,s);ed.onMouseDown.add(c.hideMenu,c);ed.onRemove.add(function(){c.destroy();});if(tinymce.isIE){c.onShowMenu.add(function(){bm=ed.selection.getBookmark(1);});c.onHideMenu.add(function(){if(bm){ed.selection.moveToBookmark(bm);bm=0;}});}return t.add(c);},createToolbar:function(id,s,cc){var c,t=this,cls;id=t.prefix+id;cls=cc||t._cls.toolbar||tinymce.ui.Toolbar;c=new cls(id,s);if(t.get(id))return null;return t.add(c);},createSeparator:function(cc){var cls=cc||this._cls.separator||tinymce.ui.Separator;return new cls();},setControlType:function(n,c){return this._cls[n.toLowerCase()]=c;},destroy:function(){each(this.controls,function(c){c.destroy();});this.controls=null;}});})();(function(){var Dispatcher=tinymce.util.Dispatcher,each=tinymce.each,isIE=tinymce.isIE,isOpera=tinymce.isOpera;tinymce.create('tinymce.WindowManager',{WindowManager:function(ed){var t=this;t.editor=ed;t.onOpen=new Dispatcher(t);t.onClose=new Dispatcher(t);t.params={};t.features={};},open:function(s,p){var t=this,f='',x,y,mo=t.editor.settings.dialog_type=='modal',w,sw,sh,vp=tinymce.DOM.getViewPort(),u;s=s||{};p=p||{};sw=isOpera?vp.w:screen.width;sh=isOpera?vp.h:screen.height;s.name=s.name||'mc_'+new Date().getTime();s.width=parseInt(s.width||320);s.height=parseInt(s.height||240);s.resizable=true;s.left=s.left||parseInt(sw/ 2.0) - (s.width /2.0);s.top=s.top||parseInt(sh/ 2.0) - (s.height /2.0);p.inline=false;p.mce_width=s.width;p.mce_height=s.height;p.mce_auto_focus=s.auto_focus;if(mo){if(isIE){s.center=true;s.help=false;s.dialogWidth=s.width+'px';s.dialogHeight=s.height+'px';s.scroll=s.scrollbars||false;}}each(s,function(v,k){if(tinymce.is(v,'boolean'))v=v?'yes':'no';if(!/^(name|url)$/.test(k)){if(isIE&&mo)f+=(f?';':'')+k+':'+v;else f+=(f?',':'')+k+'='+v;}});t.features=s;t.params=p;t.onOpen.dispatch(t,s,p);u=s.url||s.file;if(tinymce.relaxedDomain)u+=(u.indexOf('?')==-1?'?':'&')+'mce_rdomain='+tinymce.relaxedDomain;u=tinymce._addVer(u);try{if(isIE&&mo){w=1;window.showModalDialog(u,window,f);}else w=window.open(u,s.name,f);}catch(ex){}if(!w)alert(t.editor.getLang('popup_blocked'));},close:function(w){w.close();this.onClose.dispatch(this);},createInstance:function(cl,a,b,c,d,e){var f=tinymce.resolve(cl);return new f(a,b,c,d,e);},confirm:function(t,cb,s){cb.call(s||this,confirm(this._decode(this.editor.getLang(t,t))));},alert:function(tx,cb,s){var t=this;alert(t._decode(t.editor.getLang(tx,tx)));if(cb)cb.call(s||t);},_decode:function(s){return tinymce.DOM.decode(s).replace(/\\n/g,'\n');}});}());
\ No newline at end of file
+var tinymce={majorVersion:'3',minorVersion:'2.1.1',releaseDate:'2008-11-27',_init:function(){var t=this,d=document,w=window,na=navigator,ua=na.userAgent,i,nl,n,base,p,v;t.isOpera=w.opera&&opera.buildNumber;t.isWebKit=/WebKit/.test(ua);t.isOldWebKit=t.isWebKit&&!w.getSelection().getRangeAt;t.isIE=!t.isWebKit&&!t.isOpera&&(/MSIE/gi).test(ua)&&(/Explorer/gi).test(na.appName);t.isIE6=t.isIE&&/MSIE [56]/.test(ua);t.isGecko=!t.isWebKit&&/Gecko/.test(ua);t.isMac=ua.indexOf('Mac')!=-1;t.isAir=/adobeair/i.test(ua);if(w.tinyMCEPreInit){t.suffix=tinyMCEPreInit.suffix;t.baseURL=tinyMCEPreInit.base;t.query=tinyMCEPreInit.query;return;}t.suffix='';nl=d.getElementsByTagName('base');for(i=0;i<nl.length;i++){if(v=nl[i].href){if(/^https?:\/\/[^\/]+$/.test(v))v+='/';base=v?v.match(/.*\//)[0]:'';}}function getBase(n){if(n.src&&/tiny_mce(|_dev|_src|_gzip|_jquery|_prototype).js/.test(n.src)){if(/_(src|dev)\.js/g.test(n.src))t.suffix='_src';if((p=n.src.indexOf('?'))!=-1)t.query=n.src.substring(p+1);t.baseURL=n.src.substring(0,n.src.lastIndexOf('/'));if(base&&t.baseURL.indexOf('://')==-1)t.baseURL=base+t.baseURL;return t.baseURL;}return null;};nl=d.getElementsByTagName('script');for(i=0;i<nl.length;i++){if(getBase(nl[i]))return;}n=d.getElementsByTagName('head')[0];if(n){nl=n.getElementsByTagName('script');for(i=0;i<nl.length;i++){if(getBase(nl[i]))return;}}return;},is:function(o,t){var n=typeof(o);if(!t)return n!='undefined';if(t=='array'&&(o instanceof Array))return true;return n==t;},each:function(o,cb,s){var n,l;if(!o)return 0;s=s||o;if(typeof(o.length)!='undefined'){for(n=0,l=o.length;n<l;n++){if(cb.call(s,o[n],n,o)===false)return 0;}}else{for(n in o){if(o.hasOwnProperty(n)){if(cb.call(s,o[n],n,o)===false)return 0;}}}return 1;},map:function(a,f){var o=[];tinymce.each(a,function(v){o.push(f(v));});return o;},grep:function(a,f){var o=[];tinymce.each(a,function(v){if(!f||f(v))o.push(v);});return o;},inArray:function(a,v){var i,l;if(a){for(i=0,l=a.length;i<l;i++){if(a[i]===v)return i;}}return-1;},extend:function(o,e){var i,a=arguments;for(i=1;i<a.length;i++){e=a[i];tinymce.each(e,function(v,n){if(typeof(v)!=='undefined')o[n]=v;});}return o;},trim:function(s){return(s?''+s:'').replace(/^\s*|\s*$/g,'');},create:function(s,p){var t=this,sp,ns,cn,scn,c,de=0;s=/^((static) )?([\w.]+)(:([\w.]+))?/.exec(s);cn=s[3].match(/(^|\.)(\w+)$/i)[2];ns=t.createNS(s[3].replace(/\.\w+$/,''));if(ns[cn])return;if(s[2]=='static'){ns[cn]=p;if(this.onCreate)this.onCreate(s[2],s[3],ns[cn]);return;}if(!p[cn]){p[cn]=function(){};de=1;}ns[cn]=p[cn];t.extend(ns[cn].prototype,p);if(s[5]){sp=t.resolve(s[5]).prototype;scn=s[5].match(/\.(\w+)$/i)[1];c=ns[cn];if(de){ns[cn]=function(){return sp[scn].apply(this,arguments);};}else{ns[cn]=function(){this.parent=sp[scn];return c.apply(this,arguments);};}ns[cn].prototype[cn]=ns[cn];t.each(sp,function(f,n){ns[cn].prototype[n]=sp[n];});t.each(p,function(f,n){if(sp[n]){ns[cn].prototype[n]=function(){this.parent=sp[n];return f.apply(this,arguments);};}else{if(n!=cn)ns[cn].prototype[n]=f;}});}t.each(p['static'],function(f,n){ns[cn][n]=f;});if(this.onCreate)this.onCreate(s[2],s[3],ns[cn].prototype);},walk:function(o,f,n,s){s=s||this;if(o){if(n)o=o[n];tinymce.each(o,function(o,i){if(f.call(s,o,i,n)===false)return false;tinymce.walk(o,f,n,s);});}},createNS:function(n,o){var i,v;o=o||window;n=n.split('.');for(i=0;i<n.length;i++){v=n[i];if(!o[v])o[v]={};o=o[v];}return o;},resolve:function(n,o){var i,l;o=o||window;n=n.split('.');for(i=0,l=n.length;i<l;i++){o=o[n[i]];if(!o)break;}return o;},addUnload:function(f,s){var t=this,w=window;f={func:f,scope:s||this};if(!t.unloads){function unload(){var li=t.unloads,o,n;if(li){for(n in li){o=li[n];if(o&&o.func)o.func.call(o.scope,1);}if(w.detachEvent){w.detachEvent('onbeforeunload',fakeUnload);w.detachEvent('onunload',unload);}else if(w.removeEventListener)w.removeEventListener('unload',unload,false);t.unloads=o=li=w=unload=null;if(window.CollectGarbage)window.CollectGarbage();}};function fakeUnload(){var d=document;if(d.readyState=='interactive'){function stop(){d.detachEvent('onstop',stop);unload();d=null;};d.attachEvent('onstop',stop);window.setTimeout(function(){d.detachEvent('onstop',stop);},0);}};if(w.attachEvent){w.attachEvent('onunload',unload);w.attachEvent('onbeforeunload',fakeUnload);}else if(w.addEventListener)w.addEventListener('unload',unload,false);t.unloads=[f];}else t.unloads.push(f);return f;},removeUnload:function(f){var u=this.unloads,r=null;tinymce.each(u,function(o,i){if(o&&o.func==f){u.splice(i,1);r=f;return false;}});return r;},explode:function(s,d){return s?tinymce.map(s.split(d||','),tinymce.trim):s;},_addVer:function(u){var v;if(!this.query)return u;v=(u.indexOf('?')==-1?'?':'&')+this.query;if(u.indexOf('#')==-1)return u+v;return u.replace('#',v+'#');}};window.tinymce=tinymce;tinymce._init();tinymce.create('tinymce.util.Dispatcher',{scope:null,listeners:null,Dispatcher:function(s){this.scope=s||this;this.listeners=[];},add:function(cb,s){this.listeners.push({cb:cb,scope:s||this.scope});return cb;},addToTop:function(cb,s){this.listeners.unshift({cb:cb,scope:s||this.scope});return cb;},remove:function(cb){var l=this.listeners,o=null;tinymce.each(l,function(c,i){if(cb==c.cb){o=cb;l.splice(i,1);return false;}});return o;},dispatch:function(){var s,a=arguments,i,li=this.listeners,c;for(i=0;i<li.length;i++){c=li[i];s=c.cb.apply(c.scope,a);if(s===false)break;}return s;}});(function(){var each=tinymce.each;tinymce.create('tinymce.util.URI',{URI:function(u,s){var t=this,o,a,b;s=t.settings=s||{};if(/^(mailto|news|javascript|about):/i.test(u)||/^\s*#/.test(u)){t.source=u;return;}if(u.indexOf('/')===0&&u.indexOf('//')!==0)u=(s.base_uri?s.base_uri.protocol||'http':'http')+'://mce_host'+u;if(u.indexOf(':/')===-1&&u.indexOf('//')!==0)u=(s.base_uri.protocol||'http')+'://mce_host'+t.toAbsPath(s.base_uri.path,u);u=u.replace(/@@/g,'(mce_at)');u=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(u);each(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],function(v,i){var s=u[i];if(s)s=s.replace(/\(mce_at\)/g,'@@');t[v]=s;});if(b=s.base_uri){if(!t.protocol)t.protocol=b.protocol;if(!t.userInfo)t.userInfo=b.userInfo;if(!t.port&&t.host=='mce_host')t.port=b.port;if(!t.host||t.host=='mce_host')t.host=b.host;t.source='';}},setPath:function(p){var t=this;p=/^(.*?)\/?(\w+)?$/.exec(p);t.path=p[0];t.directory=p[1];t.file=p[2];t.source='';t.getURI();},toRelative:function(u){var t=this,o;if(u==="./")return u;u=new tinymce.util.URI(u,{base_uri:t});if((u.host!='mce_host'&&t.host!=u.host&&u.host)||t.port!=u.port||t.protocol!=u.protocol)return u.getURI();o=t.toRelPath(t.path,u.path);if(u.query)o+='?'+u.query;if(u.anchor)o+='#'+u.anchor;return o;},toAbsolute:function(u,nh){var u=new tinymce.util.URI(u,{base_uri:this});return u.getURI(this.host==u.host?nh:0);},toRelPath:function(base,path){var items,bp=0,out='',i,l;base=base.substring(0,base.lastIndexOf('/'));base=base.split('/');items=path.split('/');if(base.length>=items.length){for(i=0,l=base.length;i<l;i++){if(i>=items.length||base[i]!=items[i]){bp=i+1;break;}}}if(base.length<items.length){for(i=0,l=items.length;i<l;i++){if(i>=base.length||base[i]!=items[i]){bp=i+1;break;}}}if(bp==1)return path;for(i=0,l=base.length-(bp-1);i<l;i++)out+="../";for(i=bp-1,l=items.length;i<l;i++){if(i!=bp-1)out+="/"+items[i];else out+=items[i];}return out;},toAbsPath:function(base,path){var i,nb=0,o=[];base=base.split('/');path=path.split('/');each(base,function(k){if(k)o.push(k);});base=o;for(i=path.length-1,o=[];i>=0;i--){if(path[i].length==0||path[i]==".")continue;if(path[i]=='..'){nb++;continue;}if(nb>0){nb--;continue;}o.push(path[i]);}i=base.length-nb;if(i<=0)return'/'+o.reverse().join('/');return'/'+base.slice(0,i).join('/')+'/'+o.reverse().join('/');},getURI:function(nh){var s,t=this;if(!t.source||nh){s='';if(!nh){if(t.protocol)s+=t.protocol+'://';if(t.userInfo)s+=t.userInfo+'@';if(t.host)s+=t.host;if(t.port)s+=':'+t.port;}if(t.path)s+=t.path;if(t.query)s+='?'+t.query;if(t.anchor)s+='#'+t.anchor;t.source=s;}return t.source;}});})();(function(){var each=tinymce.each;tinymce.create('static tinymce.util.Cookie',{getHash:function(n){var v=this.get(n),h;if(v){each(v.split('&'),function(v){v=v.split('=');h=h||{};h[unescape(v[0])]=unescape(v[1]);});}return h;},setHash:function(n,v,e,p,d,s){var o='';each(v,function(v,k){o+=(!o?'':'&')+escape(k)+'='+escape(v);});this.set(n,o,e,p,d,s);},get:function(n){var c=document.cookie,e,p=n+"=",b;if(!c)return;b=c.indexOf("; "+p);if(b==-1){b=c.indexOf(p);if(b!=0)return null;}else b+=2;e=c.indexOf(";",b);if(e==-1)e=c.length;return unescape(c.substring(b+p.length,e));},set:function(n,v,e,p,d,s){document.cookie=n+"="+escape(v)+((e)?"; expires="+e.toGMTString():"")+((p)?"; path="+escape(p):"")+((d)?"; domain="+d:"")+((s)?"; secure":"");},remove:function(n,p){var d=new Date();d.setTime(d.getTime()-1000);this.set(n,'',d,p,d);}});})();tinymce.create('static tinymce.util.JSON',{serialize:function(o){var i,v,s=tinymce.util.JSON.serialize,t;if(o==null)return'null';t=typeof o;if(t=='string'){v='\bb\tt\nn\ff\rr\""\'\'\\\\';return'"'+o.replace(/([\u0080-\uFFFF\x00-\x1f\"])/g,function(a,b){i=v.indexOf(b);if(i+1)return'\\'+v.charAt(i+1);a=b.charCodeAt().toString(16);return'\\u'+'0000'.substring(a.length)+a;})+'"';}if(t=='object'){if(o instanceof Array){for(i=0,v='[';i<o.length;i++)v+=(i>0?',':'')+s(o[i]);return v+']';}v='{';for(i in o)v+=typeof o[i]!='function'?(v.length>1?',"':'"')+i+'":'+s(o[i]):'';return v+'}';}return''+o;},parse:function(s){try{return eval('('+s+')');}catch(ex){}}});tinymce.create('static tinymce.util.XHR',{send:function(o){var x,t,w=window,c=0;o.scope=o.scope||this;o.success_scope=o.success_scope||o.scope;o.error_scope=o.error_scope||o.scope;o.async=o.async===false?false:true;o.data=o.data||'';function get(s){x=0;try{x=new ActiveXObject(s);}catch(ex){}return x;};x=w.XMLHttpRequest?new XMLHttpRequest():get('Microsoft.XMLHTTP')||get('Msxml2.XMLHTTP');if(x){if(x.overrideMimeType)x.overrideMimeType(o.content_type);x.open(o.type||(o.data?'POST':'GET'),o.url,o.async);if(o.content_type)x.setRequestHeader('Content-Type',o.content_type);x.send(o.data);function ready(){if(!o.async||x.readyState==4||c++>10000){if(o.success&&c<10000&&x.status==200)o.success.call(o.success_scope,''+x.responseText,x,o);else if(o.error)o.error.call(o.error_scope,c>10000?'TIMED_OUT':'GENERAL',x,o);x=null;}else w.setTimeout(ready,10);};if(!o.async)return ready();t=w.setTimeout(ready,10);}}});(function(){var extend=tinymce.extend,JSON=tinymce.util.JSON,XHR=tinymce.util.XHR;tinymce.create('tinymce.util.JSONRequest',{JSONRequest:function(s){this.settings=extend({},s);this.count=0;},send:function(o){var ecb=o.error,scb=o.success;o=extend(this.settings,o);o.success=function(c,x){c=JSON.parse(c);if(typeof(c)=='undefined'){c={error:'JSON Parse error.'};}if(c.error)ecb.call(o.error_scope||o.scope,c.error,x);else scb.call(o.success_scope||o.scope,c.result);};o.error=function(ty,x){ecb.call(o.error_scope||o.scope,ty,x);};o.data=JSON.serialize({id:o.id||'c'+(this.count++),method:o.method,params:o.params});o.content_type='application/json';XHR.send(o);},'static':{sendRPC:function(o){return new tinymce.util.JSONRequest().send(o);}}});}());(function(){var each=tinymce.each,is=tinymce.is;var isWebKit=tinymce.isWebKit,isIE=tinymce.isIE;tinymce.create('tinymce.dom.DOMUtils',{doc:null,root:null,files:null,listeners:{},pixelStyles:/^(top|left|bottom|right|width|height|borderWidth)$/,cache:{},idPattern:/^#[\w]+$/,elmPattern:/^[\w_*]+$/,elmClassPattern:/^([\w_]*)\.([\w_]+)$/,props:{"for":"htmlFor","class":"className",className:"className",checked:"checked",disabled:"disabled",maxlength:"maxLength",readonly:"readOnly",selected:"selected",value:"value",id:"id",name:"name",type:"type"},DOMUtils:function(d,s){var t=this;t.doc=d;t.win=window;t.files={};t.cssFlicker=false;t.counter=0;t.boxModel=!tinymce.isIE||d.compatMode=="CSS1Compat";t.stdMode=d.documentMode===8;this.settings=s=tinymce.extend({keep_values:false,hex_colors:1,process_html:1},s);if(tinymce.isIE6){try{d.execCommand('BackgroundImageCache',false,true);}catch(e){t.cssFlicker=true;}}tinymce.addUnload(t.destroy,t);},getRoot:function(){var t=this,s=t.settings;return(s&&t.get(s.root_element))||t.doc.body;},getViewPort:function(w){var d,b;w=!w?this.win:w;d=w.document;b=this.boxModel?d.documentElement:d.body;return{x:w.pageXOffset||b.scrollLeft,y:w.pageYOffset||b.scrollTop,w:w.innerWidth||b.clientWidth,h:w.innerHeight||b.clientHeight};},getRect:function(e){var p,t=this,sr;e=t.get(e);p=t.getPos(e);sr=t.getSize(e);return{x:p.x,y:p.y,w:sr.w,h:sr.h};},getSize:function(e){var t=this,w,h;e=t.get(e);w=t.getStyle(e,'width');h=t.getStyle(e,'height');if(w.indexOf('px')===-1)w=0;if(h.indexOf('px')===-1)h=0;return{w:parseInt(w)||e.offsetWidth||e.clientWidth,h:parseInt(h)||e.offsetHeight||e.clientHeight};},getParent:function(n,f,r){var na,se=this.settings;n=this.get(n);if(se.strict_root)r=r||this.getRoot();if(is(f,'string')){na=f.toUpperCase();f=function(n){var s=false;if(n.nodeType==1&&na==='*'){s=true;return false;}each(na.split(','),function(v){if(n.nodeType==1&&((se.strict&&n.nodeName.toUpperCase()==v)||n.nodeName.toUpperCase()==v)){s=true;return false;}});return s;};}while(n){if(n==r)return null;if(f(n))return n;n=n.parentNode;}return null;},get:function(e){var n;if(e&&this.doc&&typeof(e)=='string'){n=e;e=this.doc.getElementById(e);if(e&&e.id!==n)return this.doc.getElementsByName(n)[1];}return e;},select:function(pa,s){var t=this,cs,c,pl,o=[],x,i,l,n,xp;s=t.get(s)||t.doc;if(s.querySelectorAll){if(s!=t.doc){i=s.id;s.id='_mc_tmp';pa='#_mc_tmp '+pa;}l=tinymce.grep(s.querySelectorAll(pa));s.id=i;return l;}if(!t.selectorRe)t.selectorRe=/^([\w\\*]+)?(?:#([\w\\]+))?(?:\.([\w\\\.]+))?(?:\[\@([\w\\]+)([\^\$\*!]?=)([\w\\]+)\])?(?:\:([\w\\]+))?/i;;if(tinymce.isAir){each(tinymce.explode(pa),function(v){if(!(xp=t.cache[v])){xp='';each(v.split(' '),function(v){v=t.selectorRe.exec(v);xp+=v[1]?'//'+v[1]:'//*';if(v[2])xp+="[@id='"+v[2]+"']";if(v[3]){each(v[3].split('.'),function(n){xp+="[@class = '"+n+"' or contains(concat(' ', @class, ' '), ' "+n+" ')]";});}});t.cache[v]=xp;}xp=t.doc.evaluate(xp,s,null,4,null);while(n=xp.iterateNext())o.push(n);});return o;}if(t.settings.strict){function get(s,n){return s.getElementsByTagName(n.toLowerCase());};}else{function get(s,n){return s.getElementsByTagName(n);};}if(t.elmPattern.test(pa)){x=get(s,pa);for(i=0,l=x.length;i<l;i++)o.push(x[i]);return o;}if(t.elmClassPattern.test(pa)){pl=t.elmClassPattern.exec(pa);x=get(s,pl[1]||'*');c=' '+pl[2]+' ';for(i=0,l=x.length;i<l;i++){n=x[i];if(n.className&&(' '+n.className+' ').indexOf(c)!==-1)o.push(n);}return o;}function collect(n){if(!n.mce_save){n.mce_save=1;o.push(n);}};function collectIE(n){if(!n.getAttribute('mce_save')){n.setAttribute('mce_save','1');o.push(n);}};function find(n,f,r){var i,l,nl=get(r,n);for(i=0,l=nl.length;i<l;i++)f(nl[i]);};each(pa.split(','),function(v,i){v=tinymce.trim(v);if(t.elmPattern.test(v)){each(get(s,v),function(n){collect(n);});return;}if(t.elmClassPattern.test(v)){x=t.elmClassPattern.exec(v);each(get(s,x[1]),function(n){if(t.hasClass(n,x[2]))collect(n);});return;}if(!(cs=t.cache[pa])){cs='x=(function(cf, s) {';pl=v.split(' ');each(pl,function(v){var p=t.selectorRe.exec(v);p[1]=p[1]||'*';cs+='find("'+p[1]+'", function(n) {';if(p[2])cs+='if (n.id !== "'+p[2]+'") return;';if(p[3]){cs+='var c = " " + n.className + " ";';cs+='if (';c='';each(p[3].split('.'),function(v){if(v)c+=(c?'||':'')+'c.indexOf(" '+v+' ") === -1';});cs+=c+') return;';}});cs+='cf(n);';for(i=pl.length-1;i>=0;i--)cs+='}, '+(i?'n':'s')+');';cs+='})';t.cache[pa]=cs=eval(cs);}cs(isIE?collectIE:collect,s);});each(o,function(n){if(isIE)n.removeAttribute('mce_save');else delete n.mce_save;});return o;},add:function(p,n,a,h,c){var t=this;return this.run(p,function(p){var e,k;e=is(n,'string')?t.doc.createElement(n):n;t.setAttribs(e,a);if(h){if(h.nodeType)e.appendChild(h);else t.setHTML(e,h);}return!c?p.appendChild(e):e;});},create:function(n,a,h){return this.add(this.doc.createElement(n),n,a,h,1);},createHTML:function(n,a,h){var o='',t=this,k;o+='<'+n;for(k in a){if(a.hasOwnProperty(k))o+=' '+k+'="'+t.encode(a[k])+'"';}if(tinymce.is(h))return o+'>'+h+'</'+n+'>';return o+' />';},remove:function(n,k){return this.run(n,function(n){var p,g;p=n.parentNode;if(!p)return null;if(k){each(n.childNodes,function(c){p.insertBefore(c.cloneNode(true),n);});}return p.removeChild(n);});},setStyle:function(n,na,v){var t=this;return t.run(n,function(e){var s,i;s=e.style;na=na.replace(/-(\D)/g,function(a,b){return b.toUpperCase();});if(t.pixelStyles.test(na)&&(tinymce.is(v,'number')||/^[\-0-9\.]+$/.test(v)))v+='px';switch(na){case'opacity':if(isIE){s.filter=v===''?'':"alpha(opacity="+(v*100)+")";if(!n.currentStyle||!n.currentStyle.hasLayout)s.display='inline-block';}s[na]=s['-moz-opacity']=s['-khtml-opacity']=v||'';break;case'float':isIE?s.styleFloat=v:s.cssFloat=v;break;default:s[na]=v||'';}if(t.settings.update_styles)t.setAttrib(e,'mce_style');});},getStyle:function(n,na,c){n=this.get(n);if(!n)return false;if(this.doc.defaultView&&c){na=na.replace(/[A-Z]/g,function(a){return'-'+a;});try{return this.doc.defaultView.getComputedStyle(n,null).getPropertyValue(na);}catch(ex){return null;}}na=na.replace(/-(\D)/g,function(a,b){return b.toUpperCase();});if(na=='float')na=isIE?'styleFloat':'cssFloat';if(n.currentStyle&&c)return n.currentStyle[na];return n.style[na];},setStyles:function(e,o){var t=this,s=t.settings,ol;ol=s.update_styles;s.update_styles=0;each(o,function(v,n){t.setStyle(e,n,v);});s.update_styles=ol;if(s.update_styles)t.setAttrib(e,s.cssText);},setAttrib:function(e,n,v){var t=this;if(!e||!n)return;if(t.settings.strict)n=n.toLowerCase();return this.run(e,function(e){var s=t.settings;switch(n){case"style":if(!is(v,'string')){each(v,function(v,n){t.setStyle(e,n,v);});return;}if(s.keep_values){if(v&&!t._isRes(v))e.setAttribute('mce_style',v,2);else e.removeAttribute('mce_style',2);}e.style.cssText=v;break;case"class":e.className=v||'';break;case"src":case"href":if(s.keep_values){if(s.url_converter)v=s.url_converter.call(s.url_converter_scope||t,v,n,e);t.setAttrib(e,'mce_'+n,v,2);}break;case"shape":e.setAttribute('mce_style',v);break;}if(is(v)&&v!==null&&v.length!==0)e.setAttribute(n,''+v,2);else e.removeAttribute(n,2);});},setAttribs:function(e,o){var t=this;return this.run(e,function(e){each(o,function(v,n){t.setAttrib(e,n,v);});});},getAttrib:function(e,n,dv){var v,t=this;e=t.get(e);if(!e||e.nodeType!==1)return false;if(!is(dv))dv='';if(/^(src|href|style|coords|shape)$/.test(n)){v=e.getAttribute("mce_"+n);if(v)return v;}if(isIE&&t.props[n]){v=e[t.props[n]];v=v&&v.nodeValue?v.nodeValue:v;}if(!v)v=e.getAttribute(n,2);if(n==='style'){v=v||e.style.cssText;if(v){v=t.serializeStyle(t.parseStyle(v));if(t.settings.keep_values&&!t._isRes(v))e.setAttribute('mce_style',v);}}if(isWebKit&&n==="class"&&v)v=v.replace(/(apple|webkit)\-[a-z\-]+/gi,'');if(isIE){switch(n){case'rowspan':case'colspan':if(v===1)v='';break;case'size':if(v==='+0'||v===20)v='';break;case'width':case'height':case'vspace':case'checked':case'disabled':case'readonly':if(v===0)v='';break;case'hspace':if(v===-1)v='';break;case'maxlength':case'tabindex':if(v===32768||v===2147483647||v==='32768')v='';break;case'compact':case'noshade':case'nowrap':if(v===65535)return n;return dv;case'shape':v=v.toLowerCase();break;default:if(n.indexOf('on')===0&&v)v=(''+v).replace(/^function\s+anonymous\(\)\s+\{\s+(.*)\s+\}$/,'$1');}}return(v!==undefined&&v!==null&&v!=='')?''+v:dv;},getPos:function(n){var t=this,x=0,y=0,e,d=t.doc,r;n=t.get(n);if(n&&isIE){n=n.getBoundingClientRect();e=t.boxModel?d.documentElement:d.body;x=t.getStyle(t.select('html')[0],'borderWidth');x=(x=='medium'||t.boxModel&&!t.isIE6)&&2||x;n.top+=t.win.self!=t.win.top?2:0;return{x:n.left+e.scrollLeft-x,y:n.top+e.scrollTop-x};}r=n;while(r){x+=r.offsetLeft||0;y+=r.offsetTop||0;r=r.offsetParent;}r=n;while(r){if(!/^table-row|inline.*/i.test(t.getStyle(r,"display",1))){x-=r.scrollLeft||0;y-=r.scrollTop||0;}r=r.parentNode;if(r==d.body)break;}return{x:x,y:y};},parseStyle:function(st){var t=this,s=t.settings,o={};if(!st)return o;function compress(p,s,ot){var t,r,b,l;t=o[p+'-top'+s];if(!t)return;r=o[p+'-right'+s];if(t!=r)return;b=o[p+'-bottom'+s];if(r!=b)return;l=o[p+'-left'+s];if(b!=l)return;o[ot]=l;delete o[p+'-top'+s];delete o[p+'-right'+s];delete o[p+'-bottom'+s];delete o[p+'-left'+s];};function compress2(ta,a,b,c){var t;t=o[a];if(!t)return;t=o[b];if(!t)return;t=o[c];if(!t)return;o[ta]=o[a]+' '+o[b]+' '+o[c];delete o[a];delete o[b];delete o[c];};st=st.replace(/&(#?[a-z0-9]+);/g,'&$1_MCE_SEMI_');each(st.split(';'),function(v){var sv,ur=[];if(v){v=v.replace(/_MCE_SEMI_/g,';');v=v.replace(/url\([^\)]+\)/g,function(v){ur.push(v);return'url('+ur.length+')';});v=v.split(':');sv=tinymce.trim(v[1]);sv=sv.replace(/url\(([^\)]+)\)/g,function(a,b){return ur[parseInt(b)-1];});sv=sv.replace(/rgb\([^\)]+\)/g,function(v){return t.toHex(v);});if(s.url_converter){sv=sv.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g,function(x,c){return'url('+s.url_converter.call(s.url_converter_scope||t,t.decode(c),'style',null)+')';});}o[tinymce.trim(v[0]).toLowerCase()]=sv;}});compress("border","","border");compress("border","-width","border-width");compress("border","-color","border-color");compress("border","-style","border-style");compress("padding","","padding");compress("margin","","margin");compress2('border','border-width','border-style','border-color');if(isIE){if(o.border=='medium none')o.border='';}return o;},serializeStyle:function(o){var s='';each(o,function(v,k){if(k&&v){if(tinymce.isGecko&&k.indexOf('-moz-')===0)return;switch(k){case'color':case'background-color':v=v.toLowerCase();break;}s+=(s?' ':'')+k+': '+v+';';}});return s;},loadCSS:function(u){var t=this,d=t.doc;if(!u)u='';each(u.split(','),function(u){if(t.files[u])return;t.files[u]=true;t.add(t.select('head')[0],'link',{rel:'stylesheet',href:tinymce._addVer(u)});});},addClass:function(e,c){return this.run(e,function(e){var o;if(!c)return 0;if(this.hasClass(e,c))return e.className;o=this.removeClass(e,c);return e.className=(o!=''?(o+' '):'')+c;});},removeClass:function(e,c){var t=this,re;return t.run(e,function(e){var v;if(t.hasClass(e,c)){if(!re)re=new RegExp("(^|\\s+)"+c+"(\\s+|$)","g");v=e.className.replace(re,' ');return e.className=tinymce.trim(v!=' '?v:'');}return e.className;});},hasClass:function(n,c){n=this.get(n);if(!n||!c)return false;return(' '+n.className+' ').indexOf(' '+c+' ')!==-1;},show:function(e){return this.setStyle(e,'display','block');},hide:function(e){return this.setStyle(e,'display','none');},isHidden:function(e){e=this.get(e);return!e||e.style.display=='none'||this.getStyle(e,'display')=='none';},uniqueId:function(p){return(!p?'mce_':p)+(this.counter++);},setHTML:function(e,h){var t=this;return this.run(e,function(e){var x,i,nl,n,p,x;h=t.processHTML(h);if(isIE){function set(){try{e.innerHTML='<br />'+h;e.removeChild(e.firstChild);}catch(ex){while(e.firstChild)e.firstChild.removeNode();x=t.create('div');x.innerHTML='<br />'+h;each(x.childNodes,function(n,i){if(i)e.appendChild(n);});}};if(t.settings.fix_ie_paragraphs)h=h.replace(/<p><\/p>|<p([^>]+)><\/p>|<p[^\/+]\/>/gi,'<p$1 mce_keep="true"> </p>');set();if(t.settings.fix_ie_paragraphs){nl=e.getElementsByTagName("p");for(i=nl.length-1,x=0;i>=0;i--){n=nl[i];if(!n.hasChildNodes()){if(!n.mce_keep){x=1;break;}n.removeAttribute('mce_keep');}}}if(x){h=h.replace(/<p ([^>]+)>|<p>/g,'<div $1 mce_tmp="1">');h=h.replace(/<\/p>/g,'</div>');set();if(t.settings.fix_ie_paragraphs){nl=e.getElementsByTagName("DIV");for(i=nl.length-1;i>=0;i--){n=nl[i];if(n.mce_tmp){p=t.doc.createElement('p');n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi,function(a,b){var v;if(b!=='mce_tmp'){v=n.getAttribute(b);if(!v&&b==='class')v=n.className;p.setAttribute(b,v);}});for(x=0;x<n.childNodes.length;x++)p.appendChild(n.childNodes[x].cloneNode(true));n.swapNode(p);}}}}}else e.innerHTML=h;return h;});},processHTML:function(h){var t=this,s=t.settings;if(!s.process_html)return h;if(tinymce.isGecko){h=h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi,'<$1b$2>');h=h.replace(/<(\/?)em>|<em( [^>]+)>/gi,'<$1i$2>');}else if(isIE){h=h.replace(/'/g,''');h=h.replace(/\s+(disabled|checked|readonly|selected)\s*=\s*[\"\']?(false|0)[\"\']?/gi,'');}h=h.replace(/<a( )([^>]+)\/>|<a\/>/gi,'<a$1$2></a>');if(s.keep_values){if(/<script|style/.test(h)){function trim(s){s=s.replace(/(<!--\[CDATA\[|\]\]-->)/g,'\n');s=s.replace(/^[\r\n]*|[\r\n]*$/g,'');s=s.replace(/^\s*(\/\/\s*<!--|\/\/\s*<!\[CDATA\[|<!--|<!\[CDATA\[)[\r\n]*/g,'');s=s.replace(/\s*(\/\/\s*\]\]>|\/\/\s*-->|\]\]>|-->|\]\]-->)\s*$/g,'');return s;};h=h.replace(/<script([^>]+|)>([\s\S]*?)<\/script>/g,function(v,a,b){b=trim(b);if(!a)a=' type="text/javascript"';if(b)b='<!--\n'+b+'\n// -->';return'<mce:script'+a+'>'+b+'</mce:script>';});h=h.replace(/<style([^>]+|)>([\s\S]*?)<\/style>/g,function(v,a,b){b=trim(b);return'<mce:style'+a+'><!--\n'+b+'\n--></mce:style><style'+a+' mce_bogus="1">'+b+'</style>';});}h=h.replace(/<!\[CDATA\[([\s\S]+)\]\]>/g,'<!--[CDATA[$1]]-->');h=h.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi,function(a,n){function handle(m,b,c){var u=c;if(a.indexOf('mce_'+b)!=-1)return m;if(b=='style'){if(t._isRes(c))return m;if(s.hex_colors){u=u.replace(/rgb\([^\)]+\)/g,function(v){return t.toHex(v);});}if(s.url_converter){u=u.replace(/url\([\'\"]?([^\)\'\"]+)\)/g,function(x,c){return'url('+t.encode(s.url_converter.call(s.url_converter_scope||t,t.decode(c),b,n))+')';});}}else if(b!='coords'&&b!='shape'){if(s.url_converter)u=t.encode(s.url_converter.call(s.url_converter_scope||t,t.decode(c),b,n));}return' '+b+'="'+c+'" mce_'+b+'="'+u+'"';};a=a.replace(/ (src|href|style|coords|shape)=[\"]([^\"]+)[\"]/gi,handle);a=a.replace(/ (src|href|style|coords|shape)=[\']([^\']+)[\']/gi,handle);return a.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi,handle);});}return h;},getOuterHTML:function(e){var d;e=this.get(e);if(!e)return null;if(isIE)return e.outerHTML;d=(e.ownerDocument||this.doc).createElement("body");d.appendChild(e.cloneNode(true));return d.innerHTML;},setOuterHTML:function(e,h,d){var t=this;return this.run(e,function(e){var n,tp;e=t.get(e);d=d||e.ownerDocument||t.doc;if(isIE&&e.nodeType==1)e.outerHTML=h;else{tp=d.createElement("body");tp.innerHTML=h;n=tp.lastChild;while(n){t.insertAfter(n.cloneNode(true),e);n=n.previousSibling;}t.remove(e);}});},decode:function(s){var e,n,v;if(/&[^;]+;/.test(s)){e=this.doc.createElement("div");e.innerHTML=s;n=e.firstChild;v='';if(n){do{v+=n.nodeValue;}while(n.nextSibling);}return v||s;}return s;},encode:function(s){return s?(''+s).replace(/[<>&\"]/g,function(c,b){switch(c){case'&':return'&';case'"':return'"';case'<':return'<';case'>':return'>';}return c;}):s;},insertAfter:function(n,r){var t=this;r=t.get(r);return this.run(n,function(n){var p,ns;p=r.parentNode;ns=r.nextSibling;if(ns)p.insertBefore(n,ns);else p.appendChild(n);return n;});},isBlock:function(n){if(n.nodeType&&n.nodeType!==1)return false;n=n.nodeName||n;return/^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n);},replace:function(n,o,k){if(is(o,'array'))n=n.cloneNode(true);return this.run(o,function(o){if(k){each(o.childNodes,function(c){n.appendChild(c.cloneNode(true));});}return o.parentNode.replaceChild(n,o);});},toHex:function(s){var c=/^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(s);function hex(s){s=parseInt(s).toString(16);return s.length>1?s:'0'+s;};if(c){s='#'+hex(c[1])+hex(c[2])+hex(c[3]);return s;}return s;},getClasses:function(){var t=this,cl=[],i,lo={},f=t.settings.class_filter,ov;if(t.classes)return t.classes;function addClasses(s){each(s.imports,function(r){addClasses(r);});each(s.cssRules||s.rules,function(r){switch(r.type||1){case 1:if(r.selectorText){each(r.selectorText.split(','),function(v){v=v.replace(/^\s*|\s*$|^\s\./g,"");if(/\.mce/.test(v)||!/\.[\w\-]+$/.test(v))return;ov=v;v=v.replace(/.*\.([a-z0-9_\-]+).*/i,'$1');if(f&&!(v=f(v,ov)))return;if(!lo[v]){cl.push({'class':v});lo[v]=1;}});}break;case 3:addClasses(r.styleSheet);break;}});};try{each(t.doc.styleSheets,addClasses);}catch(ex){}if(cl.length>0)t.classes=cl;return cl;},run:function(e,f,s){var t=this,o;if(t.doc&&typeof(e)==='string')e=t.get(e);if(!e)return false;s=s||this;if(!e.nodeType&&(e.length||e.length===0)){o=[];each(e,function(e,i){if(e){if(typeof(e)=='string')e=t.doc.getElementById(e);o.push(f.call(s,e,i));}});return o;}return f.call(s,e);},getAttribs:function(n){var o;n=this.get(n);if(!n)return[];if(isIE){o=[];if(n.nodeName=='OBJECT')return n.attributes;n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi,function(a,b){o.push({specified:1,nodeName:b});});return o;}return n.attributes;},destroy:function(s){var t=this;t.win=t.doc=t.root=null;if(!s)tinymce.removeUnload(t.destroy);},_isRes:function(c){return/^(top|left|bottom|right|width|height)/i.test(c)||/;\s*(top|left|bottom|right|width|height)/i.test(c);}});tinymce.DOM=new tinymce.dom.DOMUtils(document,{process_html:0});})();(function(){var each=tinymce.each,DOM=tinymce.DOM,isIE=tinymce.isIE,isWebKit=tinymce.isWebKit,Event;tinymce.create('static tinymce.dom.Event',{inits:[],events:[],add:function(o,n,f,s){var cb,t=this,el=t.events,r;if(o&&o instanceof Array){r=[];each(o,function(o){o=DOM.get(o);r.push(t.add(o,n,f,s));});return r;}o=DOM.get(o);if(!o)return;cb=function(e){e=e||window.event;if(e&&!e.target&&isIE)e.target=e.srcElement;if(!s)return f(e);return f.call(s,e);};if(n=='unload'){tinymce.unloads.unshift({func:cb});return cb;}if(n=='init'){if(t.domLoaded)cb();else t.inits.push(cb);return cb;}el.push({obj:o,name:n,func:f,cfunc:cb,scope:s});t._add(o,n,cb);return f;},remove:function(o,n,f){var t=this,a=t.events,s=false,r;if(o&&o instanceof Array){r=[];each(o,function(o){o=DOM.get(o);r.push(t.remove(o,n,f));});return r;}o=DOM.get(o);each(a,function(e,i){if(e.obj==o&&e.name==n&&(!f||(e.func==f||e.cfunc==f))){a.splice(i,1);t._remove(o,n,e.cfunc);s=true;return false;}});return s;},clear:function(o){var t=this,a=t.events,i,e;if(o){o=DOM.get(o);for(i=a.length-1;i>=0;i--){e=a[i];if(e.obj===o){t._remove(e.obj,e.name,e.cfunc);e.obj=e.cfunc=null;a.splice(i,1);}}}},cancel:function(e){if(!e)return false;this.stop(e);return this.prevent(e);},stop:function(e){if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true;return false;},prevent:function(e){if(e.preventDefault)e.preventDefault();else e.returnValue=false;return false;},_unload:function(){var t=Event;each(t.events,function(e,i){t._remove(e.obj,e.name,e.cfunc);e.obj=e.cfunc=null;});t.events=[];t=null;},_add:function(o,n,f){if(o.attachEvent)o.attachEvent('on'+n,f);else if(o.addEventListener)o.addEventListener(n,f,false);else o['on'+n]=f;},_remove:function(o,n,f){if(o){try{if(o.detachEvent)o.detachEvent('on'+n,f);else if(o.removeEventListener)o.removeEventListener(n,f,false);else o['on'+n]=null;}catch(ex){}}},_pageInit:function(){var e=Event;if(e.domLoaded)return;e._remove(window,'DOMContentLoaded',e._pageInit);e.domLoaded=true;each(e.inits,function(c){c();});e.inits=[];},_wait:function(){var t;if(window.tinyMCE_GZ&&tinyMCE_GZ.loaded){Event.domLoaded=1;return;}if(isIE&&document.location.protocol!='https:'){document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');DOM.get("__ie_onload").onreadystatechange=function(){if(this.readyState=="complete"){Event._pageInit();DOM.get("__ie_onload").onreadystatechange=null;}};}else{Event._add(window,'DOMContentLoaded',Event._pageInit,Event);if(isIE||isWebKit){t=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(t);Event._pageInit();}},10);}}}});Event=tinymce.dom.Event;Event._wait();tinymce.addUnload(Event._unload);})();(function(){var each=tinymce.each;tinymce.create('tinymce.dom.Element',{Element:function(id,s){var t=this,dom,el;s=s||{};t.id=id;t.dom=dom=s.dom||tinymce.DOM;t.settings=s;if(!tinymce.isIE)el=t.dom.get(t.id);each(['getPos','getRect','getParent','add','setStyle','getStyle','setStyles','setAttrib','setAttribs','getAttrib','addClass','removeClass','hasClass','getOuterHTML','setOuterHTML','remove','show','hide','isHidden','setHTML','get'],function(k){t[k]=function(){var a=arguments,o;if(tinymce.isOpera){a=[id];each(arguments,function(v){a.push(v);});}else Array.prototype.unshift.call(a,el||id);o=dom[k].apply(dom,a);t.update(k);return o;};});},on:function(n,f,s){return tinymce.dom.Event.add(this.id,n,f,s);},getXY:function(){return{x:parseInt(this.getStyle('left')),y:parseInt(this.getStyle('top'))};},getSize:function(){var n=this.dom.get(this.id);return{w:parseInt(this.getStyle('width')||n.clientWidth),h:parseInt(this.getStyle('height')||n.clientHeight)};},moveTo:function(x,y){this.setStyles({left:x,top:y});},moveBy:function(x,y){var p=this.getXY();this.moveTo(p.x+x,p.y+y);},resizeTo:function(w,h){this.setStyles({width:w,height:h});},resizeBy:function(w,h){var s=this.getSize();this.resizeTo(s.w+w,s.h+h);},update:function(k){var t=this,b,dom=t.dom;if(tinymce.isIE6&&t.settings.blocker){k=k||'';if(k.indexOf('get')===0||k.indexOf('has')===0||k.indexOf('is')===0)return;if(k=='remove'){dom.remove(t.blocker);return;}if(!t.blocker){t.blocker=dom.uniqueId();b=dom.add(t.settings.container||dom.getRoot(),'iframe',{id:t.blocker,style:'position:absolute;',frameBorder:0,src:'javascript:""'});dom.setStyle(b,'opacity',0);}else b=dom.get(t.blocker);dom.setStyle(b,'left',t.getStyle('left',1));dom.setStyle(b,'top',t.getStyle('top',1));dom.setStyle(b,'width',t.getStyle('width',1));dom.setStyle(b,'height',t.getStyle('height',1));dom.setStyle(b,'display',t.getStyle('display',1));dom.setStyle(b,'zIndex',parseInt(t.getStyle('zIndex',1)||0)-1);}}});})();(function(){function trimNl(s){return s.replace(/[\n\r]+/g,'');};var is=tinymce.is,isIE=tinymce.isIE,each=tinymce.each;tinymce.create('tinymce.dom.Selection',{Selection:function(dom,win,serializer){var t=this;t.dom=dom;t.win=win;t.serializer=serializer;each(['onBeforeSetContent','onBeforeGetContent','onSetContent','onGetContent'],function(e){t[e]=new tinymce.util.Dispatcher(t);});tinymce.addUnload(t.destroy,t);},getContent:function(s){var t=this,r=t.getRng(),e=t.dom.create("body"),se=t.getSel(),wb,wa,n;s=s||{};wb=wa='';s.get=true;s.format=s.format||'html';t.onBeforeGetContent.dispatch(t,s);if(s.format=='text')return t.isCollapsed()?'':(r.text||(se.toString?se.toString():''));if(r.cloneContents){n=r.cloneContents();if(n)e.appendChild(n);}else if(is(r.item)||is(r.htmlText))e.innerHTML=r.item?r.item(0).outerHTML:r.htmlText;else e.innerHTML=r.toString();if(/^\s/.test(e.innerHTML))wb=' ';if(/\s+$/.test(e.innerHTML))wa=' ';s.getInner=true;s.content=t.isCollapsed()?'':wb+t.serializer.serialize(e,s)+wa;t.onGetContent.dispatch(t,s);return s.content;},setContent:function(h,s){var t=this,r=t.getRng(),c,d=t.win.document;s=s||{format:'html'};s.set=true;h=s.content=t.dom.processHTML(h);t.onBeforeSetContent.dispatch(t,s);h=s.content;if(r.insertNode){h+='<span id="__caret">_</span>';r.deleteContents();r.insertNode(t.getRng().createContextualFragment(h));c=t.dom.get('__caret');r=d.createRange();r.setStartBefore(c);r.setEndAfter(c);t.setRng(r);d.execCommand('Delete',false,null);t.dom.remove('__caret');}else{if(r.item){d.execCommand('Delete',false,null);r=t.getRng();}r.pasteHTML(h);}t.onSetContent.dispatch(t,s);},getStart:function(){var t=this,r=t.getRng(),e;if(isIE){if(r.item)return r.item(0);r=r.duplicate();r.collapse(1);e=r.parentElement();if(e&&e.nodeName=='BODY')return e.firstChild;return e;}else{e=r.startContainer;if(e.nodeName=='BODY')return e.firstChild;return t.dom.getParent(e,function(n){return n.nodeType==1;});}},getEnd:function(){var t=this,r=t.getRng(),e;if(isIE){if(r.item)return r.item(0);r=r.duplicate();r.collapse(0);e=r.parentElement();if(e&&e.nodeName=='BODY')return e.lastChild;return e;}else{e=r.endContainer;if(e.nodeName=='BODY')return e.lastChild;return t.dom.getParent(e,function(n){return n.nodeType==1;});}},getBookmark:function(si){var t=this,r=t.getRng(),tr,sx,sy,vp=t.dom.getViewPort(t.win),e,sp,bp,le,c=-0xFFFFFF,s,ro=t.dom.getRoot(),wb=0,wa=0,nv;sx=vp.x;sy=vp.y;if(si=='simple')return{rng:r,scrollX:sx,scrollY:sy};if(isIE){if(r.item){e=r.item(0);each(t.dom.select(e.nodeName),function(n,i){if(e==n){sp=i;return false;}});return{tag:e.nodeName,index:sp,scrollX:sx,scrollY:sy};}tr=t.dom.doc.body.createTextRange();tr.moveToElementText(ro);tr.collapse(true);bp=Math.abs(tr.move('character',c));tr=r.duplicate();tr.collapse(true);sp=Math.abs(tr.move('character',c));tr=r.duplicate();tr.collapse(false);le=Math.abs(tr.move('character',c))-sp;return{start:sp-bp,length:le,scrollX:sx,scrollY:sy};}e=t.getNode();s=t.getSel();if(!s)return null;if(e&&e.nodeName=='IMG'){return{scrollX:sx,scrollY:sy};}function getPos(r,sn,en){var w=t.dom.doc.createTreeWalker(r,NodeFilter.SHOW_TEXT,null,false),n,p=0,d={};while((n=w.nextNode())!=null){if(n==sn)d.start=p;if(n==en){d.end=p;return d;}p+=trimNl(n.nodeValue||'').length;}return null;};if(s.anchorNode==s.focusNode&&s.anchorOffset==s.focusOffset){e=getPos(ro,s.anchorNode,s.focusNode);if(!e)return{scrollX:sx,scrollY:sy};trimNl(s.anchorNode.nodeValue||'').replace(/^\s+/,function(a){wb=a.length;});return{start:Math.max(e.start+s.anchorOffset-wb,0),end:Math.max(e.end+s.focusOffset-wb,0),scrollX:sx,scrollY:sy,beg:s.anchorOffset-wb==0};}else{e=getPos(ro,r.startContainer,r.endContainer);if(!e)return{scrollX:sx,scrollY:sy};return{start:Math.max(e.start+r.startOffset-wb,0),end:Math.max(e.end+r.endOffset-wa,0),scrollX:sx,scrollY:sy,beg:r.startOffset-wb==0};}},moveToBookmark:function(b){var t=this,r=t.getRng(),s=t.getSel(),ro=t.dom.getRoot(),sd,nvl,nv;function getPos(r,sp,ep){var w=t.dom.doc.createTreeWalker(r,NodeFilter.SHOW_TEXT,null,false),n,p=0,d={},o,v,wa,wb;while((n=w.nextNode())!=null){wa=wb=0;nv=n.nodeValue||'';nvl=trimNl(nv).length;p+=nvl;if(p>=sp&&!d.startNode){o=sp-(p-nvl);if(b.beg&&o>=nvl)continue;d.startNode=n;d.startOffset=o+wb;}if(p>=ep){d.endNode=n;d.endOffset=ep-(p-nvl)+wb;return d;}}return null;};if(!b)return false;t.win.scrollTo(b.scrollX,b.scrollY);if(isIE){if(r=b.rng){try{r.select();}catch(ex){}return true;}t.win.focus();if(b.tag){r=ro.createControlRange();each(t.dom.select(b.tag),function(n,i){if(i==b.index)r.addElement(n);});}else{try{if(b.start<0)return true;r=s.createRange();r.moveToElementText(ro);r.collapse(true);r.moveStart('character',b.start);r.moveEnd('character',b.length);}catch(ex2){return true;}}try{r.select();}catch(ex){}return true;}if(!s)return false;if(b.rng){s.removeAllRanges();s.addRange(b.rng);}else{if(is(b.start)&&is(b.end)){try{sd=getPos(ro,b.start,b.end);if(sd){r=t.dom.doc.createRange();r.setStart(sd.startNode,sd.startOffset);r.setEnd(sd.endNode,sd.endOffset);s.removeAllRanges();s.addRange(r);}if(!tinymce.isOpera)t.win.focus();}catch(ex){}}}},select:function(n,c){var t=this,r=t.getRng(),s=t.getSel(),b,fn,ln,d=t.win.document;function first(n){return n?d.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,false).nextNode():null;};function last(n){var c,o,w;if(!n)return null;w=d.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,false);while(c=w.nextNode())o=c;return o;};if(isIE){try{b=d.body;if(/^(IMG|TABLE)$/.test(n.nodeName)){r=b.createControlRange();r.addElement(n);}else{r=b.createTextRange();r.moveToElementText(n);}r.select();}catch(ex){}}else{if(c){fn=first(n);ln=last(n);if(fn&&ln){r=d.createRange();r.setStart(fn,0);r.setEnd(ln,ln.nodeValue.length);}else r.selectNode(n);}else r.selectNode(n);t.setRng(r);}return n;},isCollapsed:function(){var t=this,r=t.getRng(),s=t.getSel();if(!r||r.item)return false;return!s||r.boundingWidth==0||r.collapsed;},collapse:function(b){var t=this,r=t.getRng(),n;if(r.item){n=r.item(0);r=this.win.document.body.createTextRange();r.moveToElementText(n);}r.collapse(!!b);t.setRng(r);},getSel:function(){var t=this,w=this.win;return w.getSelection?w.getSelection():w.document.selection;},getRng:function(){var t=this,s=t.getSel(),r;try{if(s)r=s.rangeCount>0?s.getRangeAt(0):(s.createRange?s.createRange():t.win.document.createRange());}catch(ex){}if(!r)r=isIE?t.win.document.body.createTextRange():t.win.document.createRange();return r;},setRng:function(r){var s;if(!isIE){s=this.getSel();if(s){s.removeAllRanges();s.addRange(r);}}else{try{r.select();}catch(ex){}}},setNode:function(n){var t=this;t.setContent(t.dom.getOuterHTML(n));return n;},getNode:function(){var t=this,r=t.getRng(),s=t.getSel(),e;if(!isIE){if(!r)return t.dom.getRoot();e=r.commonAncestorContainer;if(!r.collapsed){if(tinymce.isWebKit&&s.anchorNode&&s.anchorNode.nodeType==1)return s.anchorNode.childNodes[s.anchorOffset];if(r.startContainer==r.endContainer){if(r.startOffset-r.endOffset<2){if(r.startContainer.hasChildNodes())e=r.startContainer.childNodes[r.startOffset];}}}return t.dom.getParent(e,function(n){return n.nodeType==1;});}return r.item?r.item(0):r.parentElement();},destroy:function(s){var t=this;t.win=null;if(!s)tinymce.removeUnload(t.destroy);}});})();(function(){tinymce.create('tinymce.dom.XMLWriter',{node:null,XMLWriter:function(s){function getXML(){var i=document.implementation;if(!i||!i.createDocument){try{return new ActiveXObject('MSXML2.DOMDocument');}catch(ex){}try{return new ActiveXObject('Microsoft.XmlDom');}catch(ex){}}else return i.createDocument('','',null);};this.doc=getXML();this.valid=tinymce.isOpera||tinymce.isWebKit;this.reset();},reset:function(){var t=this,d=t.doc;if(d.firstChild)d.removeChild(d.firstChild);t.node=d.appendChild(d.createElement("html"));},writeStartElement:function(n){var t=this;t.node=t.node.appendChild(t.doc.createElement(n));},writeAttribute:function(n,v){if(this.valid)v=v.replace(/>/g,'%MCGT%');this.node.setAttribute(n,v);},writeEndElement:function(){this.node=this.node.parentNode;},writeFullEndElement:function(){var t=this,n=t.node;n.appendChild(t.doc.createTextNode(""));t.node=n.parentNode;},writeText:function(v){if(this.valid)v=v.replace(/>/g,'%MCGT%');this.node.appendChild(this.doc.createTextNode(v));},writeCDATA:function(v){this.node.appendChild(this.doc.createCDATA(v));},writeComment:function(v){if(tinymce.isIE)v=v.replace(/^\-|\-$/g,' ');this.node.appendChild(this.doc.createComment(v.replace(/\-\-/g,' ')));},getContent:function(){var h;h=this.doc.xml||new XMLSerializer().serializeToString(this.doc);h=h.replace(/<\?[^?]+\?>|<html>|<\/html>|<html\/>|<!DOCTYPE[^>]+>/g,'');h=h.replace(/ ?\/>/g,' />');if(this.valid)h=h.replace(/\%MCGT%/g,'>');return h;}});})();(function(){tinymce.create('tinymce.dom.StringWriter',{str:null,tags:null,count:0,settings:null,indent:null,StringWriter:function(s){this.settings=tinymce.extend({indent_char:' ',indentation:1},s);this.reset();},reset:function(){this.indent='';this.str="";this.tags=[];this.count=0;},writeStartElement:function(n){this._writeAttributesEnd();this.writeRaw('<'+n);this.tags.push(n);this.inAttr=true;this.count++;this.elementCount=this.count;},writeAttribute:function(n,v){var t=this;t.writeRaw(" "+t.encode(n)+'="'+t.encode(v)+'"');},writeEndElement:function(){var n;if(this.tags.length>0){n=this.tags.pop();if(this._writeAttributesEnd(1))this.writeRaw('</'+n+'>');if(this.settings.indentation>0)this.writeRaw('\n');}},writeFullEndElement:function(){if(this.tags.length>0){this._writeAttributesEnd();this.writeRaw('</'+this.tags.pop()+'>');if(this.settings.indentation>0)this.writeRaw('\n');}},writeText:function(v){this._writeAttributesEnd();this.writeRaw(this.encode(v));this.count++;},writeCDATA:function(v){this._writeAttributesEnd();this.writeRaw('<![CDATA['+v+']]>');this.count++;},writeComment:function(v){this._writeAttributesEnd();this.writeRaw('<!-- '+v+'-->');this.count++;},writeRaw:function(v){this.str+=v;},encode:function(s){return s.replace(/[<>&"]/g,function(v){switch(v){case'<':return'<';case'>':return'>';case'&':return'&';case'"':return'"';}return v;});},getContent:function(){return this.str;},_writeAttributesEnd:function(s){if(!this.inAttr)return;this.inAttr=false;if(s&&this.elementCount==this.count){this.writeRaw(' />');return false;}this.writeRaw('>');return true;}});})();(function(){var extend=tinymce.extend,each=tinymce.each,Dispatcher=tinymce.util.Dispatcher,isIE=tinymce.isIE,isGecko=tinymce.isGecko;function getIEAtts(n){var o=[];if(n.nodeName=='OBJECT')return n.attributes;n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi,function(a,b){o.push({specified:1,nodeName:b});});return o;};function wildcardToRE(s){return s.replace(/([?+*])/g,'.$1');};tinymce.create('tinymce.dom.Serializer',{Serializer:function(s){var t=this;t.key=0;t.onPreProcess=new Dispatcher(t);t.onPostProcess=new Dispatcher(t);if(tinymce.relaxedDomain&&tinymce.isGecko){t.writer=new tinymce.dom.StringWriter();}else{try{t.writer=new tinymce.dom.XMLWriter();}catch(ex){t.writer=new tinymce.dom.StringWriter();}}t.settings=s=extend({dom:tinymce.DOM,valid_nodes:0,node_filter:0,attr_filter:0,invalid_attrs:/^(mce_|_moz_)/,closed:/(br|hr|input|meta|img|link|param)/,entity_encoding:'named',entities:'160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro',bool_attrs:/(checked|disabled|readonly|selected|nowrap)/,valid_elements:'*[*]',extended_valid_elements:0,valid_child_elements:0,invalid_elements:0,fix_table_elements:0,fix_list_elements:true,fix_content_duplication:true,convert_fonts_to_spans:false,font_size_classes:0,font_size_style_values:0,apply_source_formatting:0,indent_mode:'simple',indent_char:'\t',indent_levels:1,remove_linebreaks:1,remove_redundant_brs:1,element_format:'xhtml'},s);t.dom=s.dom;if(s.remove_redundant_brs){t.onPostProcess.add(function(se,o){o.content=o.content.replace(/<br \/>(\s*<\/li>)/g,'$1');});}if(s.element_format=='html'){t.onPostProcess.add(function(se,o){o.content=o.content.replace(/<([^>]+) \/>/g,'<$1>');});}if(s.fix_list_elements){t.onPreProcess.add(function(se,o){var nl,x,a=['ol','ul'],i,n,p,r=/^(OL|UL)$/,np;function prevNode(e,n){var a=n.split(','),i;while((e=e.previousSibling)!=null){for(i=0;i<a.length;i++){if(e.nodeName==a[i])return e;}}return null;};for(x=0;x<a.length;x++){nl=t.dom.select(a[x],o.node);for(i=0;i<nl.length;i++){n=nl[i];p=n.parentNode;if(r.test(p.nodeName)){np=prevNode(n,'LI');if(!np){np=t.dom.create('li');np.innerHTML=' ';np.appendChild(n);p.insertBefore(np,p.firstChild);}else np.appendChild(n);}}}});}if(s.fix_table_elements){t.onPreProcess.add(function(se,o){each(t.dom.select('table',o.node),function(e){var pa=t.dom.getParent(e,'H1,H2,H3,H4,H5,H6,P'),pa2,n,tm,pl=[],i,ns;if(pa){pa2=pa.cloneNode(false);pl.push(e);for(n=e;n=n.parentNode;){pl.push(n);if(n==pa)break;}tm=pa2;for(i=pl.length-1;i>=0;i--){if(i==pl.length-1){while(ns=pl[i-1].nextSibling)tm.appendChild(ns.parentNode.removeChild(ns));}else{n=pl[i].cloneNode(false);if(i!=0){while(ns=pl[i-1].nextSibling)n.appendChild(ns.parentNode.removeChild(ns));}tm=tm.appendChild(n);}}e=t.dom.insertAfter(e.parentNode.removeChild(e),pa);t.dom.insertAfter(e,pa);t.dom.insertAfter(pa2,e);}});});}},setEntities:function(s){var t=this,a,i,l={},re='',v;if(t.entityLookup)return;a=s.split(',');for(i=0;i<a.length;i+=2){v=a[i];if(v==34||v==38||v==60||v==62)continue;l[String.fromCharCode(a[i])]=a[i+1];v=parseInt(a[i]).toString(16);re+='\\u'+'0000'.substring(v.length)+v;}if(!re){t.settings.entity_encoding='raw';return;}t.entitiesRE=new RegExp('['+re+']','g');t.entityLookup=l;},setValidChildRules:function(s){this.childRules=null;this.addValidChildRules(s);},addValidChildRules:function(s){var t=this,inst,intr,bloc;if(!s)return;inst='A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment';intr='A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment';bloc='H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP';each(s.split(','),function(s){var p=s.split(/\[|\]/),re;s='';each(p[1].split('|'),function(v){if(s)s+='|';switch(v){case'%itrans':v=intr;break;case'%itrans_na':v=intr.substring(2);break;case'%istrict':v=inst;break;case'%istrict_na':v=inst.substring(2);break;case'%btrans':v=bloc;break;case'%bstrict':v=bloc;break;}s+=v;});re=new RegExp('^('+s.toLowerCase()+')$','i');each(p[0].split('/'),function(s){t.childRules=t.childRules||{};t.childRules[s]=re;});});s='';each(t.childRules,function(v,k){if(s)s+='|';s+=k;});t.parentElementsRE=new RegExp('^('+s.toLowerCase()+')$','i');},setRules:function(s){var t=this;t._setup();t.rules={};t.wildRules=[];t.validElements={};return t.addRules(s);},addRules:function(s){var t=this,dr;if(!s)return;t._setup();each(s.split(','),function(s){var p=s.split(/\[|\]/),tn=p[0].split('/'),ra,at,wat,va=[];if(dr)at=tinymce.extend([],dr.attribs);if(p.length>1){each(p[1].split('|'),function(s){var ar={},i;at=at||[];s=s.replace(/::/g,'~');s=/^([!\-])?([\w*.?~_\-]+|)([=:<])?(.+)?$/.exec(s);s[2]=s[2].replace(/~/g,':');if(s[1]=='!'){ra=ra||[];ra.push(s[2]);}if(s[1]=='-'){for(i=0;i<at.length;i++){if(at[i].name==s[2]){at.splice(i,1);return;}}}switch(s[3]){case'=':ar.defaultVal=s[4]||'';break;case':':ar.forcedVal=s[4];break;case'<':ar.validVals=s[4].split('?');break;}if(/[*.?]/.test(s[2])){wat=wat||[];ar.nameRE=new RegExp('^'+wildcardToRE(s[2])+'$');wat.push(ar);}else{ar.name=s[2];at.push(ar);}va.push(s[2]);});}each(tn,function(s,i){var pr=s.charAt(0),x=1,ru={};if(dr){if(dr.noEmpty)ru.noEmpty=dr.noEmpty;if(dr.fullEnd)ru.fullEnd=dr.fullEnd;if(dr.padd)ru.padd=dr.padd;}switch(pr){case'-':ru.noEmpty=true;break;case'+':ru.fullEnd=true;break;case'#':ru.padd=true;break;default:x=0;}tn[i]=s=s.substring(x);t.validElements[s]=1;if(/[*.?]/.test(tn[0])){ru.nameRE=new RegExp('^'+wildcardToRE(tn[0])+'$');t.wildRules=t.wildRules||{};t.wildRules.push(ru);}else{ru.name=tn[0];if(tn[0]=='@')dr=ru;t.rules[s]=ru;}ru.attribs=at;if(ra)ru.requiredAttribs=ra;if(wat){s='';each(va,function(v){if(s)s+='|';s+='('+wildcardToRE(v)+')';});ru.validAttribsRE=new RegExp('^'+s.toLowerCase()+'$');ru.wildAttribs=wat;}});});s='';each(t.validElements,function(v,k){if(s)s+='|';if(k!='@')s+=k;});t.validElementsRE=new RegExp('^('+wildcardToRE(s.toLowerCase())+')$');},findRule:function(n){var t=this,rl=t.rules,i,r;t._setup();r=rl[n];if(r)return r;rl=t.wildRules;for(i=0;i<rl.length;i++){if(rl[i].nameRE.test(n))return rl[i];}return null;},findAttribRule:function(ru,n){var i,wa=ru.wildAttribs;for(i=0;i<wa.length;i++){if(wa[i].nameRE.test(n))return wa[i];}return null;},serialize:function(n,o){var h,t=this;t._setup();o=o||{};o.format=o.format||'html';t.processObj=o;n=n.cloneNode(true);t.key=''+(parseInt(t.key)+1);if(!o.no_events){o.node=n;t.onPreProcess.dispatch(t,o);}t.writer.reset();t._serializeNode(n,o.getInner);o.content=t.writer.getContent();if(!o.no_events)t.onPostProcess.dispatch(t,o);t._postProcess(o);o.node=null;return tinymce.trim(o.content);},_postProcess:function(o){var t=this,s=t.settings,h=o.content,sc=[],p;if(o.format=='html'){p=t._protect({content:h,patterns:[{pattern:/(<script[^>]*>)(.*?)(<\/script>)/g},{pattern:/(<style[^>]*>)(.*?)(<\/style>)/g},{pattern:/(<pre[^>]*>)(.*?)(<\/pre>)/g,encode:1},{pattern:/(<!--\[CDATA\[)(.*?)(\]\]-->)/g}]});h=p.content;if(s.entity_encoding!=='raw')h=t._encode(h);if(!o.set){h=h.replace(/<p>\s+<\/p>|<p([^>]+)>\s+<\/p>/g,s.entity_encoding=='numeric'?'<p$1> </p>':'<p$1> </p>');if(s.remove_linebreaks){h=h.replace(/\r?\n|\r/g,' ');h=h.replace(/(<[^>]+>)\s+/g,'$1 ');h=h.replace(/\s+(<\/[^>]+>)/g,' $1');h=h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object) ([^>]+)>\s+/g,'<$1 $2>');h=h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>\s+/g,'<$1>');h=h.replace(/\s+<\/(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>/g,'</$1>');}if(s.apply_source_formatting&&s.indent_mode=='simple'){h=h.replace(/<(\/?)(ul|hr|table|meta|link|tbody|tr|object|body|head|html|map)(|[^>]+)>\s*/g,'\n<$1$2$3>\n');h=h.replace(/\s*<(p|h[1-6]|blockquote|div|title|style|pre|script|td|li|area)(|[^>]+)>/g,'\n<$1$2>');h=h.replace(/<\/(p|h[1-6]|blockquote|div|title|style|pre|script|td|li)>\s*/g,'</$1>\n');h=h.replace(/\n\n/g,'\n');}}h=t._unprotect(h,p);h=h.replace(/<!--\[CDATA\[([\s\S]+)\]\]-->/g,'<![CDATA[$1]]>');if(s.entity_encoding=='raw')h=h.replace(/<p> <\/p>|<p([^>]+)> <\/p>/g,'<p$1>\u00a0</p>');}o.content=h;},_serializeNode:function(n,inn){var t=this,s=t.settings,w=t.writer,hc,el,cn,i,l,a,at,no,v,nn,ru,ar,iv;if(!s.node_filter||s.node_filter(n)){switch(n.nodeType){case 1:if(n.hasAttribute?n.hasAttribute('mce_bogus'):n.getAttribute('mce_bogus'))return;iv=false;hc=n.hasChildNodes();nn=n.getAttribute('mce_name')||n.nodeName.toLowerCase();if(isIE){if(n.scopeName!=='HTML'&&n.scopeName!=='html')nn=n.scopeName+':'+nn;}if(nn.indexOf('mce:')===0)nn=nn.substring(4);if(!t.validElementsRE.test(nn)||(t.invalidElementsRE&&t.invalidElementsRE.test(nn))||inn){iv=true;break;}if(isIE){if(s.fix_content_duplication){if(n.mce_serialized==t.key)return;n.mce_serialized=t.key;}if(nn.charAt(0)=='/')nn=nn.substring(1);}else if(isGecko){if(n.nodeName==='BR'&&n.getAttribute('type')=='_moz')return;}if(t.childRules){if(t.parentElementsRE.test(t.elementName)){if(!t.childRules[t.elementName].test(nn)){iv=true;break;}}t.elementName=nn;}ru=t.findRule(nn);nn=ru.name||nn;if((!hc&&ru.noEmpty)||(isIE&&!nn)){iv=true;break;}if(ru.requiredAttribs){a=ru.requiredAttribs;for(i=a.length-1;i>=0;i--){if(this.dom.getAttrib(n,a[i])!=='')break;}if(i==-1){iv=true;break;}}w.writeStartElement(nn);if(ru.attribs){for(i=0,at=ru.attribs,l=at.length;i<l;i++){a=at[i];v=t._getAttrib(n,a);if(v!==null)w.writeAttribute(a.name,v);}}if(ru.validAttribsRE){at=isIE?getIEAtts(n):n.attributes;for(i=at.length-1;i>-1;i--){no=at[i];if(no.specified){a=no.nodeName.toLowerCase();if(s.invalid_attrs.test(a)||!ru.validAttribsRE.test(a))continue;ar=t.findAttribRule(ru,a);v=t._getAttrib(n,ar,a);if(v!==null)w.writeAttribute(a,v);}}}if(ru.padd){if(hc&&(cn=n.firstChild)&&cn.nodeType===1&&n.childNodes.length===1){if(cn.hasAttribute?cn.hasAttribute('mce_bogus'):cn.getAttribute('mce_bogus'))w.writeText('\u00a0');}else if(!hc)w.writeText('\u00a0');}break;case 3:if(t.childRules&&t.parentElementsRE.test(t.elementName)){if(!t.childRules[t.elementName].test(n.nodeName))return;}return w.writeText(n.nodeValue);case 4:return w.writeCDATA(n.nodeValue);case 8:return w.writeComment(n.nodeValue);}}else if(n.nodeType==1)hc=n.hasChildNodes();if(hc){cn=n.firstChild;while(cn){t._serializeNode(cn);t.elementName=nn;cn=cn.nextSibling;}}if(!iv){if(hc||!s.closed.test(nn))w.writeFullEndElement();else w.writeEndElement();}},_protect:function(o){var t=this;o.items=o.items||[];function enc(s){return s.replace(/[\r\n\\]/g,function(c){if(c==='\n')return'\\n';else if(c==='\\')return'\\\\';return'\\r';});};function dec(s){return s.replace(/\\[\\rn]/g,function(c){if(c==='\\n')return'\n';else if(c==='\\\\')return'\\';return'\r';});};each(o.patterns,function(p){o.content=dec(enc(o.content).replace(p.pattern,function(x,a,b,c){b=dec(b);if(p.encode)b=t._encode(b);o.items.push(b);return a+'<!--mce:'+(o.items.length-1)+'-->'+c;}));});return o;},_unprotect:function(h,o){h=h.replace(/\<!--mce:([0-9]+)--\>/g,function(a,b){return o.items[parseInt(b)];});o.items=[];return h;},_encode:function(h){var t=this,s=t.settings,l;if(s.entity_encoding!=='raw'){if(s.entity_encoding.indexOf('named')!=-1){t.setEntities(s.entities);l=t.entityLookup;h=h.replace(t.entitiesRE,function(a){var v;if(v=l[a])a='&'+v+';';return a;});}if(s.entity_encoding.indexOf('numeric')!=-1){h=h.replace(/[\u007E-\uFFFF]/g,function(a){return'&#'+a.charCodeAt(0)+';';});}}return h;},_setup:function(){var t=this,s=this.settings;if(t.done)return;t.done=1;t.setRules(s.valid_elements);t.addRules(s.extended_valid_elements);t.addValidChildRules(s.valid_child_elements);if(s.invalid_elements)t.invalidElementsRE=new RegExp('^('+wildcardToRE(s.invalid_elements.replace(/,/g,'|').toLowerCase())+')$');if(s.attrib_value_filter)t.attribValueFilter=s.attribValueFilter;},_getAttrib:function(n,a,na){var i,v;na=na||a.name;if(a.forcedVal&&(v=a.forcedVal)){if(v==='{$uid}')return this.dom.uniqueId();return v;}v=this.dom.getAttrib(n,na);if(this.settings.bool_attrs.test(na)&&v){v=(''+v).toLowerCase();if(v==='false'||v==='0')return null;v=na;}switch(na){case'rowspan':case'colspan':if(v=='1')v='';break;}if(this.attribValueFilter)v=this.attribValueFilter(na,v,n);if(a.validVals){for(i=a.validVals.length-1;i>=0;i--){if(v==a.validVals[i])break;}if(i==-1)return null;}if(v===''&&typeof(a.defaultVal)!='undefined'){v=a.defaultVal;if(v==='{$uid}')return this.dom.uniqueId();return v;}else{if(na=='class'&&this.processObj.get)v=v.replace(/\s?mceItem\w+\s?/g,'');}if(v==='')return null;return v;}});})();(function(){var each=tinymce.each,Event=tinymce.dom.Event;tinymce.create('tinymce.dom.ScriptLoader',{ScriptLoader:function(s){this.settings=s||{};this.queue=[];this.lookup={};},isDone:function(u){return this.lookup[u]?this.lookup[u].state==2:0;},markDone:function(u){this.lookup[u]={state:2,url:u};},add:function(u,cb,s,pr){var t=this,lo=t.lookup,o;if(o=lo[u]){if(cb&&o.state==2)cb.call(s||this);return o;}o={state:0,url:u,func:cb,scope:s||this};if(pr)t.queue.unshift(o);else t.queue.push(o);lo[u]=o;return o;},load:function(u,cb,s){var t=this,o;if(o=t.lookup[u]){if(cb&&o.state==2)cb.call(s||t);return o;}function loadScript(u){if(Event.domLoaded||t.settings.strict_mode){tinymce.util.XHR.send({url:tinymce._addVer(u),error:t.settings.error,async:false,success:function(co){t.eval(co);}});}else document.write('<script type="text/javascript" src="'+tinymce._addVer(u)+'"></script>');};if(!tinymce.is(u,'string')){each(u,function(u){loadScript(u);});if(cb)cb.call(s||t);}else{loadScript(u);if(cb)cb.call(s||t);}},loadQueue:function(cb,s){var t=this;if(!t.queueLoading){t.queueLoading=1;t.queueCallbacks=[];t.loadScripts(t.queue,function(){t.queueLoading=0;if(cb)cb.call(s||t);each(t.queueCallbacks,function(o){o.func.call(o.scope);});});}else if(cb)t.queueCallbacks.push({func:cb,scope:s||t});},eval:function(co){var w=window;if(!w.execScript){try{eval.call(w,co);}catch(ex){eval(co,w);}}else w.execScript(co);},loadScripts:function(sc,cb,s){var t=this,lo=t.lookup;function done(o){o.state=2;if(o.func)o.func.call(o.scope||t);};function allDone(){var l;l=sc.length;each(sc,function(o){o=lo[o.url];if(o.state===2){done(o);l--;}else load(o);});if(l===0&&cb){cb.call(s||t);cb=0;}};function load(o){if(o.state>0)return;o.state=1;tinymce.dom.ScriptLoader.loadScript(o.url,function(){done(o);allDone();});};each(sc,function(o){var u=o.url;if(!lo[u]){lo[u]=o;t.queue.push(o);}else o=lo[u];if(o.state>0)return;if(!Event.domLoaded&&!t.settings.strict_mode){var ix,ol='';if(cb||o.func){o.state=1;ix=tinymce.dom.ScriptLoader._addOnLoad(function(){done(o);allDone();});if(tinymce.isIE)ol=' onreadystatechange="';else ol=' onload="';ol+='tinymce.dom.ScriptLoader._onLoad(this,\''+u+'\','+ix+');"';}document.write('<script type="text/javascript" src="'+tinymce._addVer(u)+'"'+ol+'></script>');if(!o.func)done(o);}else load(o);});allDone();},'static':{_addOnLoad:function(f){var t=this;t._funcs=t._funcs||[];t._funcs.push(f);return t._funcs.length-1;},_onLoad:function(e,u,ix){if(!tinymce.isIE||e.readyState=='complete')this._funcs[ix].call(this);},loadScript:function(u,cb){var id=tinymce.DOM.uniqueId(),e;function done(){Event.clear(id);tinymce.DOM.remove(id);if(cb){cb.call(document,u);cb=0;}};if(tinymce.isIE){tinymce.util.XHR.send({url:tinymce._addVer(u),async:false,success:function(co){window.execScript(co);done();}});}else{e=tinymce.DOM.create('script',{id:id,type:'text/javascript',src:tinymce._addVer(u)});Event.add(e,'load',done);(document.getElementsByTagName('head')[0]||document.body).appendChild(e);}}}});tinymce.ScriptLoader=new tinymce.dom.ScriptLoader();})();(function(){var DOM=tinymce.DOM,is=tinymce.is;tinymce.create('tinymce.ui.Control',{Control:function(id,s){this.id=id;this.settings=s=s||{};this.rendered=false;this.onRender=new tinymce.util.Dispatcher(this);this.classPrefix='';this.scope=s.scope||this;this.disabled=0;this.active=0;},setDisabled:function(s){var e;if(s!=this.disabled){e=DOM.get(this.id);if(e&&this.settings.unavailable_prefix){if(s){this.prevTitle=e.title;e.title=this.settings.unavailable_prefix+": "+e.title;}else e.title=this.prevTitle;}this.setState('Disabled',s);this.setState('Enabled',!s);this.disabled=s;}},isDisabled:function(){return this.disabled;},setActive:function(s){if(s!=this.active){this.setState('Active',s);this.active=s;}},isActive:function(){return this.active;},setState:function(c,s){var n=DOM.get(this.id);c=this.classPrefix+c;if(s)DOM.addClass(n,c);else DOM.removeClass(n,c);},isRendered:function(){return this.rendered;},renderHTML:function(){},renderTo:function(n){DOM.setHTML(n,this.renderHTML());},postRender:function(){var t=this,b;if(is(t.disabled)){b=t.disabled;t.disabled=-1;t.setDisabled(b);}if(is(t.active)){b=t.active;t.active=-1;t.setActive(b);}},remove:function(){DOM.remove(this.id);this.destroy();},destroy:function(){tinymce.dom.Event.clear(this.id);}});})();tinymce.create('tinymce.ui.Container:tinymce.ui.Control',{Container:function(id,s){this.parent(id,s);this.controls=[];this.lookup={};},add:function(c){this.lookup[c.id]=c;this.controls.push(c);return c;},get:function(n){return this.lookup[n];}});tinymce.create('tinymce.ui.Separator:tinymce.ui.Control',{Separator:function(id,s){this.parent(id,s);this.classPrefix='mceSeparator';},renderHTML:function(){return tinymce.DOM.createHTML('span',{'class':this.classPrefix});}});(function(){var is=tinymce.is,DOM=tinymce.DOM,each=tinymce.each,walk=tinymce.walk;tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control',{MenuItem:function(id,s){this.parent(id,s);this.classPrefix='mceMenuItem';},setSelected:function(s){this.setState('Selected',s);this.selected=s;},isSelected:function(){return this.selected;},postRender:function(){var t=this;t.parent();if(is(t.selected))t.setSelected(t.selected);}});})();(function(){var is=tinymce.is,DOM=tinymce.DOM,each=tinymce.each,walk=tinymce.walk;tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem',{Menu:function(id,s){var t=this;t.parent(id,s);t.items={};t.collapsed=false;t.menuCount=0;t.onAddItem=new tinymce.util.Dispatcher(this);},expand:function(d){var t=this;if(d){walk(t,function(o){if(o.expand)o.expand();},'items',t);}t.collapsed=false;},collapse:function(d){var t=this;if(d){walk(t,function(o){if(o.collapse)o.collapse();},'items',t);}t.collapsed=true;},isCollapsed:function(){return this.collapsed;},add:function(o){if(!o.settings)o=new tinymce.ui.MenuItem(o.id||DOM.uniqueId(),o);this.onAddItem.dispatch(this,o);return this.items[o.id]=o;},addSeparator:function(){return this.add({separator:true});},addMenu:function(o){if(!o.collapse)o=this.createMenu(o);this.menuCount++;return this.add(o);},hasMenus:function(){return this.menuCount!==0;},remove:function(o){delete this.items[o.id];},removeAll:function(){var t=this;walk(t,function(o){if(o.removeAll)o.removeAll();else o.remove();o.destroy();},'items',t);t.items={};},createMenu:function(o){var m=new tinymce.ui.Menu(o.id||DOM.uniqueId(),o);m.onAddItem.add(this.onAddItem.dispatch,this.onAddItem);return m;}});})();(function(){var is=tinymce.is,DOM=tinymce.DOM,each=tinymce.each,Event=tinymce.dom.Event,Element=tinymce.dom.Element;tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu',{DropMenu:function(id,s){s=s||{};s.container=s.container||DOM.doc.body;s.offset_x=s.offset_x||0;s.offset_y=s.offset_y||0;s.vp_offset_x=s.vp_offset_x||0;s.vp_offset_y=s.vp_offset_y||0;if(is(s.icons)&&!s.icons)s['class']+=' mceNoIcons';this.parent(id,s);this.onShowMenu=new tinymce.util.Dispatcher(this);this.onHideMenu=new tinymce.util.Dispatcher(this);this.classPrefix='mceMenu';},createMenu:function(s){var t=this,cs=t.settings,m;s.container=s.container||cs.container;s.parent=t;s.constrain=s.constrain||cs.constrain;s['class']=s['class']||cs['class'];s.vp_offset_x=s.vp_offset_x||cs.vp_offset_x;s.vp_offset_y=s.vp_offset_y||cs.vp_offset_y;m=new tinymce.ui.DropMenu(s.id||DOM.uniqueId(),s);m.onAddItem.add(t.onAddItem.dispatch,t.onAddItem);return m;},update:function(){var t=this,s=t.settings,tb=DOM.get('menu_'+t.id+'_tbl'),co=DOM.get('menu_'+t.id+'_co'),tw,th;tw=s.max_width?Math.min(tb.clientWidth,s.max_width):tb.clientWidth;th=s.max_height?Math.min(tb.clientHeight,s.max_height):tb.clientHeight;if(!DOM.boxModel)t.element.setStyles({width:tw+2,height:th+2});else t.element.setStyles({width:tw,height:th});if(s.max_width)DOM.setStyle(co,'width',tw);if(s.max_height){DOM.setStyle(co,'height',th);if(tb.clientHeight<s.max_height)DOM.setStyle(co,'overflow','hidden');}},showMenu:function(x,y,px){var t=this,s=t.settings,co,vp=DOM.getViewPort(),w,h,mx,my,ot=2,dm,tb,cp=t.classPrefix;t.collapse(1);if(t.isMenuVisible)return;if(!t.rendered){co=DOM.add(t.settings.container,t.renderNode());each(t.items,function(o){o.postRender();});t.element=new Element('menu_'+t.id,{blocker:1,container:s.container});}else co=DOM.get('menu_'+t.id);if(!tinymce.isOpera)DOM.setStyles(co,{left:-0xFFFF,top:-0xFFFF});DOM.show(co);t.update();x+=s.offset_x||0;y+=s.offset_y||0;vp.w-=4;vp.h-=4;if(s.constrain){w=co.clientWidth-ot;h=co.clientHeight-ot;mx=vp.x+vp.w;my=vp.y+vp.h;if((x+s.vp_offset_x+w)>mx)x=px?px-w:Math.max(0,(mx-s.vp_offset_x)-w);if((y+s.vp_offset_y+h)>my)y=Math.max(0,(my-s.vp_offset_y)-h);}DOM.setStyles(co,{left:x,top:y});t.element.update();t.isMenuVisible=1;t.mouseClickFunc=Event.add(co,'click',function(e){var m;e=e.target;if(e&&(e=DOM.getParent(e,'TR'))&&!DOM.hasClass(e,cp+'ItemSub')){m=t.items[e.id];if(m.isDisabled())return;dm=t;while(dm){if(dm.hideMenu)dm.hideMenu();dm=dm.settings.parent;}if(m.settings.onclick)m.settings.onclick(e);return Event.cancel(e);}});if(t.hasMenus()){t.mouseOverFunc=Event.add(co,'mouseover',function(e){var m,r,mi;e=e.target;if(e&&(e=DOM.getParent(e,'TR'))){m=t.items[e.id];if(t.lastMenu)t.lastMenu.collapse(1);if(m.isDisabled())return;if(e&&DOM.hasClass(e,cp+'ItemSub')){r=DOM.getRect(e);m.showMenu((r.x+r.w-ot),r.y-ot,r.x);t.lastMenu=m;DOM.addClass(DOM.get(m.id).firstChild,cp+'ItemActive');}}});}t.onShowMenu.dispatch(t);if(s.keyboard_focus){Event.add(co,'keydown',t._keyHandler,t);DOM.select('a','menu_'+t.id)[0].focus();t._focusIdx=0;}},hideMenu:function(c){var t=this,co=DOM.get('menu_'+t.id),e;if(!t.isMenuVisible)return;Event.remove(co,'mouseover',t.mouseOverFunc);Event.remove(co,'click',t.mouseClickFunc);Event.remove(co,'keydown',t._keyHandler);DOM.hide(co);t.isMenuVisible=0;if(!c)t.collapse(1);if(t.element)t.element.hide();if(e=DOM.get(t.id))DOM.removeClass(e.firstChild,t.classPrefix+'ItemActive');t.onHideMenu.dispatch(t);},add:function(o){var t=this,co;o=t.parent(o);if(t.isRendered&&(co=DOM.get('menu_'+t.id)))t._add(DOM.select('tbody',co)[0],o);return o;},collapse:function(d){this.parent(d);this.hideMenu(1);},remove:function(o){DOM.remove(o.id);this.destroy();return this.parent(o);},destroy:function(){var t=this,co=DOM.get('menu_'+t.id);Event.remove(co,'mouseover',t.mouseOverFunc);Event.remove(co,'click',t.mouseClickFunc);if(t.element)t.element.remove();DOM.remove(co);},renderNode:function(){var t=this,s=t.settings,n,tb,co,w;w=DOM.create('div',{id:'menu_'+t.id,'class':s['class'],'style':'position:absolute;left:0;top:0;z-index:200000'});co=DOM.add(w,'div',{id:'menu_'+t.id+'_co','class':t.classPrefix+(s['class']?' '+s['class']:'')});t.element=new Element('menu_'+t.id,{blocker:1,container:s.container});if(s.menu_line)DOM.add(co,'span',{'class':t.classPrefix+'Line'});n=DOM.add(co,'table',{id:'menu_'+t.id+'_tbl',border:0,cellPadding:0,cellSpacing:0});tb=DOM.add(n,'tbody');each(t.items,function(o){t._add(tb,o);});t.rendered=true;return w;},_keyHandler:function(e){var t=this,kc=e.keyCode;function focus(d){var i=t._focusIdx+d,e=DOM.select('a','menu_'+t.id)[i];if(e){t._focusIdx=i;e.focus();}};switch(kc){case 38:focus(-1);return;case 40:focus(1);return;case 13:return;case 27:return this.hideMenu();}},_add:function(tb,o){var n,s=o.settings,a,ro,it,cp=this.classPrefix,ic;if(s.separator){ro=DOM.add(tb,'tr',{id:o.id,'class':cp+'ItemSeparator'});DOM.add(ro,'td',{'class':cp+'ItemSeparator'});if(n=ro.previousSibling)DOM.addClass(n,'mceLast');return;}n=ro=DOM.add(tb,'tr',{id:o.id,'class':cp+'Item '+cp+'ItemEnabled'});n=it=DOM.add(n,'td');n=a=DOM.add(n,'a',{href:'javascript:;',onclick:"return false;",onmousedown:'return false;'});DOM.addClass(it,s['class']);ic=DOM.add(n,'span',{'class':'mceIcon'+(s.icon?' mce_'+s.icon:'')});if(s.icon_src)DOM.add(ic,'img',{src:s.icon_src});n=DOM.add(n,s.element||'span',{'class':'mceText',title:o.settings.title},o.settings.title);if(o.settings.style)DOM.setAttrib(n,'style',o.settings.style);if(tb.childNodes.length==1)DOM.addClass(ro,'mceFirst');if((n=ro.previousSibling)&&DOM.hasClass(n,cp+'ItemSeparator'))DOM.addClass(ro,'mceFirst');if(o.collapse)DOM.addClass(ro,cp+'ItemSub');if(n=ro.previousSibling)DOM.removeClass(n,'mceLast');DOM.addClass(ro,'mceLast');}});})();(function(){var DOM=tinymce.DOM;tinymce.create('tinymce.ui.Button:tinymce.ui.Control',{Button:function(id,s){this.parent(id,s);this.classPrefix='mceButton';},renderHTML:function(){var cp=this.classPrefix,s=this.settings,h,l;l=DOM.encode(s.label||'');h='<a id="'+this.id+'" href="javascript:;" class="'+cp+' '+cp+'Enabled '+s['class']+(l?' '+cp+'Labeled':'')+'" onmousedown="return false;" onclick="return false;" title="'+DOM.encode(s.title)+'">';if(s.image)h+='<img class="mceIcon" src="'+s.image+'" />'+l+'</a>';else h+='<span class="mceIcon '+s['class']+'"></span>'+(l?'<span class="'+cp+'Label">'+l+'</span>':'')+'</a>';return h;},postRender:function(){var t=this,s=t.settings;tinymce.dom.Event.add(t.id,'click',function(e){if(!t.isDisabled())return s.onclick.call(s.scope,e);});}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,each=tinymce.each,Dispatcher=tinymce.util.Dispatcher;tinymce.create('tinymce.ui.ListBox:tinymce.ui.Control',{ListBox:function(id,s){var t=this;t.parent(id,s);t.items=[];t.onChange=new Dispatcher(t);t.onPostRender=new Dispatcher(t);t.onAdd=new Dispatcher(t);t.onRenderMenu=new tinymce.util.Dispatcher(this);t.classPrefix='mceListBox';},select:function(va){var t=this,fv,f;if(va==undefined)return t.selectByIndex(-1);if(va&&va.call)f=va;else{f=function(v){return v==va;};}if(va!=t.selectedValue){each(t.items,function(o,i){if(f(o.value)){fv=1;t.selectByIndex(i);return false;}});if(!fv)t.selectByIndex(-1);}},selectByIndex:function(idx){var t=this,e,o;if(idx!=t.selectedIndex){e=DOM.get(t.id+'_text');o=t.items[idx];if(o){t.selectedValue=o.value;t.selectedIndex=idx;DOM.setHTML(e,DOM.encode(o.title));DOM.removeClass(e,'mceTitle');}else{DOM.setHTML(e,DOM.encode(t.settings.title));DOM.addClass(e,'mceTitle');t.selectedValue=t.selectedIndex=null;}e=0;}else t.selectedValue=t.selectedIndex=null;},add:function(n,v,o){var t=this;o=o||{};o=tinymce.extend(o,{title:n,value:v});t.items.push(o);t.onAdd.dispatch(t,o);},getLength:function(){return this.items.length;},renderHTML:function(){var h='',t=this,s=t.settings,cp=t.classPrefix;h='<table id="'+t.id+'" cellpadding="0" cellspacing="0" class="'+cp+' '+cp+'Enabled'+(s['class']?(' '+s['class']):'')+'"><tbody><tr>';h+='<td>'+DOM.createHTML('a',{id:t.id+'_text',href:'javascript:;','class':'mceText',onclick:"return false;",onmousedown:'return false;'},DOM.encode(t.settings.title))+'</td>';h+='<td>'+DOM.createHTML('a',{id:t.id+'_open',tabindex:-1,href:'javascript:;','class':'mceOpen',onclick:"return false;",onmousedown:'return false;'},'<span></span>')+'</td>';h+='</tr></tbody></table>';return h;},showMenu:function(){var t=this,p1,p2,e=DOM.get(this.id),m;if(t.isDisabled()||t.items.length==0)return;if(t.menu&&t.menu.isMenuVisible)return t.hideMenu();if(!t.isMenuRendered){t.renderMenu();t.isMenuRendered=true;}p1=DOM.getPos(this.settings.menu_container);p2=DOM.getPos(e);m=t.menu;m.settings.offset_x=p2.x;m.settings.offset_y=p2.y;m.settings.keyboard_focus=!tinymce.isOpera;if(t.oldID)m.items[t.oldID].setSelected(0);each(t.items,function(o){if(o.value===t.selectedValue){m.items[o.id].setSelected(1);t.oldID=o.id;}});m.showMenu(0,e.clientHeight);Event.add(DOM.doc,'mousedown',t.hideMenu,t);DOM.addClass(t.id,t.classPrefix+'Selected');},hideMenu:function(e){var t=this;if(e&&e.type=="mousedown"&&(e.target.id==t.id+'_text'||e.target.id==t.id+'_open'))return;if(!e||!DOM.getParent(e.target,function(n){return DOM.hasClass(n,'mceMenu');})){DOM.removeClass(t.id,t.classPrefix+'Selected');Event.remove(DOM.doc,'mousedown',t.hideMenu,t);if(t.menu)t.menu.hideMenu();}},renderMenu:function(){var t=this,m;m=t.settings.control_manager.createDropMenu(t.id+'_menu',{menu_line:1,'class':t.classPrefix+'Menu mceNoIcons',max_width:150,max_height:150});m.onHideMenu.add(t.hideMenu,t);m.add({title:t.settings.title,'class':'mceMenuItemTitle',onclick:function(){if(t.settings.onselect('')!==false)t.select('');}});each(t.items,function(o){o.id=DOM.uniqueId();o.onclick=function(){if(t.settings.onselect(o.value)!==false)t.select(o.value);};m.add(o);});t.onRenderMenu.dispatch(t,m);t.menu=m;},postRender:function(){var t=this,cp=t.classPrefix;Event.add(t.id,'click',t.showMenu,t);Event.add(t.id+'_text','focus',function(e){if(!t._focused){t.keyDownHandler=Event.add(t.id+'_text','keydown',function(e){var idx=-1,v,kc=e.keyCode;each(t.items,function(v,i){if(t.selectedValue==v.value)idx=i;});if(kc==38)v=t.items[idx-1];else if(kc==40)v=t.items[idx+1];else if(kc==13){v=t.selectedValue;t.selectedValue=null;t.settings.onselect(v);return Event.cancel(e);}if(v){t.hideMenu();t.select(v.value);}});}t._focused=1;});Event.add(t.id+'_text','blur',function(){Event.remove(t.id+'_text','keydown',t.keyDownHandler);t._focused=0;});if(tinymce.isIE6||!DOM.boxModel){Event.add(t.id,'mouseover',function(){if(!DOM.hasClass(t.id,cp+'Disabled'))DOM.addClass(t.id,cp+'Hover');});Event.add(t.id,'mouseout',function(){if(!DOM.hasClass(t.id,cp+'Disabled'))DOM.removeClass(t.id,cp+'Hover');});}t.onPostRender.dispatch(t,DOM.get(t.id));},destroy:function(){this.parent();Event.clear(this.id+'_text');}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,each=tinymce.each,Dispatcher=tinymce.util.Dispatcher;tinymce.create('tinymce.ui.NativeListBox:tinymce.ui.ListBox',{NativeListBox:function(id,s){this.parent(id,s);this.classPrefix='mceNativeListBox';},setDisabled:function(s){DOM.get(this.id).disabled=s;},isDisabled:function(){return DOM.get(this.id).disabled;},select:function(va){var t=this,fv,f;if(va==undefined)return t.selectByIndex(-1);if(va&&va.call)f=va;else{f=function(v){return v==va;};}if(va!=t.selectedValue){each(t.items,function(o,i){if(f(o.value)){fv=1;t.selectByIndex(i);return false;}});if(!fv)t.selectByIndex(-1);}},selectByIndex:function(idx){DOM.get(this.id).selectedIndex=idx+1;this.selectedValue=this.items[idx]?this.items[idx].value:null;},add:function(n,v,a){var o,t=this;a=a||{};a.value=v;if(t.isRendered())DOM.add(DOM.get(this.id),'option',a,n);o={title:n,value:v,attribs:a};t.items.push(o);t.onAdd.dispatch(t,o);},getLength:function(){return DOM.get(this.id).options.length-1;},renderHTML:function(){var h,t=this;h=DOM.createHTML('option',{value:''},'-- '+t.settings.title+' --');each(t.items,function(it){h+=DOM.createHTML('option',{value:it.value},it.title);});h=DOM.createHTML('select',{id:t.id,'class':'mceNativeListBox'},h);return h;},postRender:function(){var t=this,ch;t.rendered=true;function onChange(e){var v=t.items[e.target.selectedIndex-1];if(v&&(v=v.value)){t.onChange.dispatch(t,v);if(t.settings.onselect)t.settings.onselect(v);}};Event.add(t.id,'change',onChange);Event.add(t.id,'keydown',function(e){var bf;Event.remove(t.id,'change',ch);bf=Event.add(t.id,'blur',function(){Event.add(t.id,'change',onChange);Event.remove(t.id,'blur',bf);});if(e.keyCode==13||e.keyCode==32){onChange(e);return Event.cancel(e);}});t.onPostRender.dispatch(t,DOM.get(t.id));}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,each=tinymce.each;tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button',{MenuButton:function(id,s){this.parent(id,s);this.onRenderMenu=new tinymce.util.Dispatcher(this);s.menu_container=s.menu_container||DOM.doc.body;},showMenu:function(){var t=this,p1,p2,e=DOM.get(t.id),m;if(t.isDisabled())return;if(!t.isMenuRendered){t.renderMenu();t.isMenuRendered=true;}if(t.isMenuVisible)return t.hideMenu();p1=DOM.getPos(t.settings.menu_container);p2=DOM.getPos(e);m=t.menu;m.settings.offset_x=p2.x;m.settings.offset_y=p2.y;m.settings.vp_offset_x=p2.x;m.settings.vp_offset_y=p2.y;m.settings.keyboard_focus=t._focused;m.showMenu(0,e.clientHeight);Event.add(DOM.doc,'mousedown',t.hideMenu,t);t.setState('Selected',1);t.isMenuVisible=1;},renderMenu:function(){var t=this,m;m=t.settings.control_manager.createDropMenu(t.id+'_menu',{menu_line:1,'class':this.classPrefix+'Menu',icons:t.settings.icons});m.onHideMenu.add(t.hideMenu,t);t.onRenderMenu.dispatch(t,m);t.menu=m;},hideMenu:function(e){var t=this;if(e&&e.type=="mousedown"&&DOM.getParent(e.target,function(e){return e.id===t.id||e.id===t.id+'_open';}))return;if(!e||!DOM.getParent(e.target,function(n){return DOM.hasClass(n,'mceMenu');})){t.setState('Selected',0);Event.remove(DOM.doc,'mousedown',t.hideMenu,t);if(t.menu)t.menu.hideMenu();}t.isMenuVisible=0;},postRender:function(){var t=this,s=t.settings;Event.add(t.id,'click',function(){if(!t.isDisabled()){if(s.onclick)s.onclick(t.value);t.showMenu();}});}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,each=tinymce.each;tinymce.create('tinymce.ui.SplitButton:tinymce.ui.MenuButton',{SplitButton:function(id,s){this.parent(id,s);this.classPrefix='mceSplitButton';},renderHTML:function(){var h,t=this,s=t.settings,h1;h='<tbody><tr>';if(s.image)h1=DOM.createHTML('img ',{src:s.image,'class':'mceAction '+s['class']});else h1=DOM.createHTML('span',{'class':'mceAction '+s['class']},'');h+='<td>'+DOM.createHTML('a',{id:t.id+'_action',href:'javascript:;','class':'mceAction '+s['class'],onclick:"return false;",onmousedown:'return false;',title:s.title},h1)+'</td>';h1=DOM.createHTML('span',{'class':'mceOpen '+s['class']});h+='<td>'+DOM.createHTML('a',{id:t.id+'_open',href:'javascript:;','class':'mceOpen '+s['class'],onclick:"return false;",onmousedown:'return false;',title:s.title},h1)+'</td>';h+='</tr></tbody>';return DOM.createHTML('table',{id:t.id,'class':'mceSplitButton mceSplitButtonEnabled '+s['class'],cellpadding:'0',cellspacing:'0',onmousedown:'return false;',title:s.title},h);},postRender:function(){var t=this,s=t.settings;if(s.onclick){Event.add(t.id+'_action','click',function(){if(!t.isDisabled())s.onclick(t.value);});}Event.add(t.id+'_open','click',t.showMenu,t);Event.add(t.id+'_open','focus',function(){t._focused=1;});Event.add(t.id+'_open','blur',function(){t._focused=0;});if(tinymce.isIE6||!DOM.boxModel){Event.add(t.id,'mouseover',function(){if(!DOM.hasClass(t.id,'mceSplitButtonDisabled'))DOM.addClass(t.id,'mceSplitButtonHover');});Event.add(t.id,'mouseout',function(){if(!DOM.hasClass(t.id,'mceSplitButtonDisabled'))DOM.removeClass(t.id,'mceSplitButtonHover');});}},destroy:function(){this.parent();Event.clear(this.id+'_action');Event.clear(this.id+'_open');}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,is=tinymce.is,each=tinymce.each;tinymce.create('tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton',{ColorSplitButton:function(id,s){var t=this;t.parent(id,s);t.settings=s=tinymce.extend({colors:'000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF',grid_width:8,default_color:'#888888'},t.settings);t.onShowMenu=new tinymce.util.Dispatcher(t);t.onHideMenu=new tinymce.util.Dispatcher(t);t.value=s.default_color;},showMenu:function(){var t=this,r,p,e,p2;if(t.isDisabled())return;if(!t.isMenuRendered){t.renderMenu();t.isMenuRendered=true;}if(t.isMenuVisible)return t.hideMenu();e=DOM.get(t.id);DOM.show(t.id+'_menu');DOM.addClass(e,'mceSplitButtonSelected');p2=DOM.getPos(e);DOM.setStyles(t.id+'_menu',{left:p2.x,top:p2.y+e.clientHeight,zIndex:200000});e=0;Event.add(DOM.doc,'mousedown',t.hideMenu,t);if(t._focused){t._keyHandler=Event.add(t.id+'_menu','keydown',function(e){if(e.keyCode==27)t.hideMenu();});DOM.select('a',t.id+'_menu')[0].focus();}t.onShowMenu.dispatch(t);t.isMenuVisible=1;},hideMenu:function(e){var t=this;if(e&&e.type=="mousedown"&&DOM.getParent(e.target,function(e){return e.id===t.id+'_open';}))return;if(!e||!DOM.getParent(e.target,function(n){return DOM.hasClass(n,'mceSplitButtonMenu');})){DOM.removeClass(t.id,'mceSplitButtonSelected');Event.remove(DOM.doc,'mousedown',t.hideMenu,t);Event.remove(t.id+'_menu','keydown',t._keyHandler);DOM.hide(t.id+'_menu');}t.onHideMenu.dispatch(t);t.isMenuVisible=0;},renderMenu:function(){var t=this,m,i=0,s=t.settings,n,tb,tr,w;w=DOM.add(s.menu_container,'div',{id:t.id+'_menu','class':s['menu_class']+' '+s['class'],style:'position:absolute;left:0;top:-1000px;'});m=DOM.add(w,'div',{'class':s['class']+' mceSplitButtonMenu'});DOM.add(m,'span',{'class':'mceMenuLine'});n=DOM.add(m,'table',{'class':'mceColorSplitMenu'});tb=DOM.add(n,'tbody');i=0;each(is(s.colors,'array')?s.colors:s.colors.split(','),function(c){c=c.replace(/^#/,'');if(!i--){tr=DOM.add(tb,'tr');i=s.grid_width-1;}n=DOM.add(tr,'td');n=DOM.add(n,'a',{href:'javascript:;',style:{backgroundColor:'#'+c},mce_color:'#'+c});});if(s.more_colors_func){n=DOM.add(tb,'tr');n=DOM.add(n,'td',{colspan:s.grid_width,'class':'mceMoreColors'});n=DOM.add(n,'a',{id:t.id+'_more',href:'javascript:;',onclick:'return false;','class':'mceMoreColors'},s.more_colors_title);Event.add(n,'click',function(e){s.more_colors_func.call(s.more_colors_scope||this);return Event.cancel(e);});}DOM.addClass(m,'mceColorSplitMenu');Event.add(t.id+'_menu','click',function(e){var c;e=e.target;if(e.nodeName=='A'&&(c=e.getAttribute('mce_color')))t.setColor(c);return Event.cancel(e);});return w;},setColor:function(c){var t=this;DOM.setStyle(t.id+'_preview','backgroundColor',c);t.value=c;t.hideMenu();t.settings.onselect(c);},postRender:function(){var t=this,id=t.id;t.parent();DOM.add(id+'_action','div',{id:id+'_preview','class':'mceColorPreview'});DOM.setStyle(t.id+'_preview','backgroundColor',t.value);},destroy:function(){this.parent();Event.clear(this.id+'_menu');Event.clear(this.id+'_more');DOM.remove(this.id+'_menu');}});})();tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container',{renderHTML:function(){var t=this,h='',c,co,dom=tinymce.DOM,s=t.settings,i,pr,nx,cl;cl=t.controls;for(i=0;i<cl.length;i++){co=cl[i];pr=cl[i-1];nx=cl[i+1];if(i===0){c='mceToolbarStart';if(co.Button)c+=' mceToolbarStartButton';else if(co.SplitButton)c+=' mceToolbarStartSplitButton';else if(co.ListBox)c+=' mceToolbarStartListBox';h+=dom.createHTML('td',{'class':c},dom.createHTML('span',null,'<!-- IE -->'));}if(pr&&co.ListBox){if(pr.Button||pr.SplitButton)h+=dom.createHTML('td',{'class':'mceToolbarEnd'},dom.createHTML('span',null,'<!-- IE -->'));}if(dom.stdMode)h+='<td style="position: relative">'+co.renderHTML()+'</td>';else h+='<td>'+co.renderHTML()+'</td>';if(nx&&co.ListBox){if(nx.Button||nx.SplitButton)h+=dom.createHTML('td',{'class':'mceToolbarStart'},dom.createHTML('span',null,'<!-- IE -->'));}}c='mceToolbarEnd';if(co.Button)c+=' mceToolbarEndButton';else if(co.SplitButton)c+=' mceToolbarEndSplitButton';else if(co.ListBox)c+=' mceToolbarEndListBox';h+=dom.createHTML('td',{'class':c},dom.createHTML('span',null,'<!-- IE -->'));return dom.createHTML('table',{id:t.id,'class':'mceToolbar'+(s['class']?' '+s['class']:''),cellpadding:'0',cellspacing:'0',align:t.settings.align||''},'<tbody><tr>'+h+'</tr></tbody>');}});(function(){var Dispatcher=tinymce.util.Dispatcher,each=tinymce.each;tinymce.create('tinymce.AddOnManager',{items:[],urls:{},lookup:{},onAdd:new Dispatcher(this),get:function(n){return this.lookup[n];},requireLangPack:function(n){var u,s=tinymce.EditorManager.settings;if(s&&s.language){u=this.urls[n]+'/langs/'+s.language+'.js';if(!tinymce.dom.Event.domLoaded&&!s.strict_mode)tinymce.ScriptLoader.load(u);else tinymce.ScriptLoader.add(u);}},add:function(id,o){this.items.push(o);this.lookup[id]=o;this.onAdd.dispatch(this,id,o);return o;},load:function(n,u,cb,s){var t=this;if(t.urls[n])return;if(u.indexOf('/')!=0&&u.indexOf('://')==-1)u=tinymce.baseURL+'/'+u;t.urls[n]=u.substring(0,u.lastIndexOf('/'));tinymce.ScriptLoader.add(u,cb,s);}});tinymce.PluginManager=new tinymce.AddOnManager();tinymce.ThemeManager=new tinymce.AddOnManager();}());(function(){var each=tinymce.each,extend=tinymce.extend,DOM=tinymce.DOM,Event=tinymce.dom.Event,ThemeManager=tinymce.ThemeManager,PluginManager=tinymce.PluginManager,explode=tinymce.explode;tinymce.create('static tinymce.EditorManager',{editors:{},i18n:{},activeEditor:null,preInit:function(){var t=this,lo=window.location;tinymce.documentBaseURL=lo.href.replace(/[\?#].*$/,'').replace(/[\/\\][^\/]+$/,'');if(!/[\/\\]$/.test(tinymce.documentBaseURL))tinymce.documentBaseURL+='/';tinymce.baseURL=new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL);tinymce.EditorManager.baseURI=new tinymce.util.URI(tinymce.baseURL);if(document.domain&&lo.hostname!=document.domain)tinymce.relaxedDomain=document.domain;if(!tinymce.relaxedDomain&&tinymce.EditorManager.baseURI.host!=lo.hostname&&lo.hostname)document.domain=tinymce.relaxedDomain=lo.hostname.replace(/.*\.(.+\..+)$/,'$1');t.onBeforeUnload=new tinymce.util.Dispatcher(t);Event.add(window,'beforeunload',function(e){t.onBeforeUnload.dispatch(t,e);});},init:function(s){var t=this,pl,sl=tinymce.ScriptLoader,c,e,el=[],ed;function execCallback(se,n,s){var f=se[n];if(!f)return;if(tinymce.is(f,'string')){s=f.replace(/\.\w+$/,'');s=s?tinymce.resolve(s):0;f=tinymce.resolve(f);}return f.apply(s||this,Array.prototype.slice.call(arguments,2));};s=extend({theme:"simple",language:"en",strict_loading_mode:document.contentType=='application/xhtml+xml'},s);t.settings=s;if(!Event.domLoaded&&!s.strict_loading_mode){if(s.language)sl.add(tinymce.baseURL+'/langs/'+s.language+'.js');if(s.theme&&s.theme.charAt(0)!='-'&&!ThemeManager.urls[s.theme])ThemeManager.load(s.theme,'themes/'+s.theme+'/editor_template'+tinymce.suffix+'.js');if(s.plugins){pl=explode(s.plugins);if(tinymce.inArray(pl,'compat2x')!=-1)PluginManager.load('compat2x','plugins/compat2x/editor_plugin'+tinymce.suffix+'.js');each(pl,function(v){if(v&&v.charAt(0)!='-'&&!PluginManager.urls[v]){if(!tinymce.isWebKit&&v=='safari')return;PluginManager.load(v,'plugins/'+v+'/editor_plugin'+tinymce.suffix+'.js');}});}sl.loadQueue();}Event.add(document,'init',function(){var l,co;execCallback(s,'onpageload');if(s.browsers){l=false;each(explode(s.browsers),function(v){switch(v){case'ie':case'msie':if(tinymce.isIE)l=true;break;case'gecko':if(tinymce.isGecko)l=true;break;case'safari':case'webkit':if(tinymce.isWebKit)l=true;break;case'opera':if(tinymce.isOpera)l=true;break;}});if(!l)return;}switch(s.mode){case"exact":l=s.elements||'';if(l.length>0){each(explode(l),function(v){if(DOM.get(v)){ed=new tinymce.Editor(v,s);el.push(ed);ed.render(1);}else{c=0;each(document.forms,function(f){each(f.elements,function(e){if(e.name===v){v='mce_editor_'+c;DOM.setAttrib(e,'id',v);ed=new tinymce.Editor(v,s);el.push(ed);ed.render(1);}});});}});}break;case"textareas":case"specific_textareas":function hasClass(n,c){return c.constructor===RegExp?c.test(n.className):DOM.hasClass(n,c);};each(DOM.select('textarea'),function(v){if(s.editor_deselector&&hasClass(v,s.editor_deselector))return;if(!s.editor_selector||hasClass(v,s.editor_selector)){e=DOM.get(v.name);if(!v.id&&!e)v.id=v.name;if(!v.id||t.get(v.id))v.id=DOM.uniqueId();ed=new tinymce.Editor(v.id,s);el.push(ed);ed.render(1);}});break;}if(s.oninit){l=co=0;each(el,function(ed){co++;if(!ed.initialized){ed.onInit.add(function(){l++;if(l==co)execCallback(s,'oninit');});}else l++;if(l==co)execCallback(s,'oninit');});}});},get:function(id){return this.editors[id];},getInstanceById:function(id){return this.get(id);},add:function(e){this.editors[e.id]=e;this._setActive(e);return e;},remove:function(e){var t=this;if(!t.editors[e.id])return null;delete t.editors[e.id];if(t.activeEditor==e){each(t.editors,function(e){t._setActive(e);return false;});}e.destroy();return e;},execCommand:function(c,u,v){var t=this,ed=t.get(v),w;switch(c){case"mceFocus":ed.focus();return true;case"mceAddEditor":case"mceAddControl":if(!t.get(v))new tinymce.Editor(v,t.settings).render();return true;case"mceAddFrameControl":w=v.window;w.tinyMCE=tinyMCE;w.tinymce=tinymce;tinymce.DOM.doc=w.document;tinymce.DOM.win=w;ed=new tinymce.Editor(v.element_id,v);ed.render();if(tinymce.isIE){function clr(){ed.destroy();w.detachEvent('onunload',clr);w=w.tinyMCE=w.tinymce=null;};w.attachEvent('onunload',clr);}v.page_window=null;return true;case"mceRemoveEditor":case"mceRemoveControl":if(ed)ed.remove();return true;case'mceToggleEditor':if(!ed){t.execCommand('mceAddControl',0,v);return true;}if(ed.isHidden())ed.show();else ed.hide();return true;}if(t.activeEditor)return t.activeEditor.execCommand(c,u,v);return false;},execInstanceCommand:function(id,c,u,v){var ed=this.get(id);if(ed)return ed.execCommand(c,u,v);return false;},triggerSave:function(){each(this.editors,function(e){e.save();});},addI18n:function(p,o){var lo,i18n=this.i18n;if(!tinymce.is(p,'string')){each(p,function(o,lc){each(o,function(o,g){each(o,function(o,k){if(g==='common')i18n[lc+'.'+k]=o;else i18n[lc+'.'+g+'.'+k]=o;});});});}else{each(o,function(o,k){i18n[p+'.'+k]=o;});}},_setActive:function(e){this.selectedInstance=this.activeEditor=e;}});tinymce.EditorManager.preInit();})();var tinyMCE=window.tinyMCE=tinymce.EditorManager;(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,extend=tinymce.extend,Dispatcher=tinymce.util.Dispatcher;var each=tinymce.each,isGecko=tinymce.isGecko,isIE=tinymce.isIE,isWebKit=tinymce.isWebKit;var is=tinymce.is,ThemeManager=tinymce.ThemeManager,PluginManager=tinymce.PluginManager,EditorManager=tinymce.EditorManager;var inArray=tinymce.inArray,grep=tinymce.grep,explode=tinymce.explode;tinymce.create('tinymce.Editor',{Editor:function(id,s){var t=this;t.id=t.editorId=id;t.execCommands={};t.queryStateCommands={};t.queryValueCommands={};t.plugins={};each(['onPreInit','onBeforeRenderUI','onPostRender','onInit','onRemove','onActivate','onDeactivate','onClick','onEvent','onMouseUp','onMouseDown','onDblClick','onKeyDown','onKeyUp','onKeyPress','onContextMenu','onSubmit','onReset','onPaste','onPreProcess','onPostProcess','onBeforeSetContent','onBeforeGetContent','onSetContent','onGetContent','onLoadContent','onSaveContent','onNodeChange','onChange','onBeforeExecCommand','onExecCommand','onUndo','onRedo','onVisualAid','onSetProgressState'],function(e){t[e]=new Dispatcher(t);});t.settings=s=extend({id:id,language:'en',docs_language:'en',theme:'simple',skin:'default',delta_width:0,delta_height:0,popup_css:'',plugins:'',document_base_url:tinymce.documentBaseURL,add_form_submit_trigger:1,submit_patch:1,add_unload_trigger:1,convert_urls:1,relative_urls:1,remove_script_host:1,table_inline_editing:0,object_resizing:1,cleanup:1,accessibility_focus:1,custom_shortcuts:1,custom_undo_redo_keyboard_shortcuts:1,custom_undo_redo_restore_selection:1,custom_undo_redo:1,doctype:'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',visual_table_class:'mceItemTable',visual:1,inline_styles:true,convert_fonts_to_spans:true,font_size_style_values:'xx-small,x-small,small,medium,large,x-large,xx-large',apply_source_formatting:1,directionality:'ltr',forced_root_block:'p',valid_elements:'@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,#p[align],-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote[cite],-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value|tabindex|accesskey],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big',hidden_input:1,padd_empty_editor:1,render_ui:1,init_theme:1,force_p_newlines:1,indentation:'30px',keep_styles:1},s);t.documentBaseURI=new tinymce.util.URI(s.document_base_url||tinymce.documentBaseURL,{base_uri:tinyMCE.baseURI});t.baseURI=EditorManager.baseURI;t.execCallback('setup',t);},render:function(nst){var t=this,s=t.settings,id=t.id,sl=tinymce.ScriptLoader;if(!Event.domLoaded){Event.add(document,'init',function(){t.render();});return;}if(!nst){s.strict_loading_mode=1;tinyMCE.settings=s;}if(!t.getElement())return;if(s.strict_loading_mode){sl.settings.strict_mode=s.strict_loading_mode;tinymce.DOM.settings.strict=1;}if(!/TEXTAREA|INPUT/i.test(t.getElement().nodeName)&&s.hidden_input&&DOM.getParent(id,'form'))DOM.insertAfter(DOM.create('input',{type:'hidden',name:id}),id);t.windowManager=new tinymce.WindowManager(t);if(s.encoding=='xml'){t.onGetContent.add(function(ed,o){if(o.save)o.content=DOM.encode(o.content);});}if(s.add_form_submit_trigger){t.onSubmit.addToTop(function(){if(t.initialized){t.save();t.isNotDirty=1;}});}if(s.add_unload_trigger&&!s.ask){t._beforeUnload=tinyMCE.onBeforeUnload.add(function(){if(t.initialized&&!t.destroyed&&!t.isHidden())t.save({format:'raw',no_events:true});});}tinymce.addUnload(t.destroy,t);if(s.submit_patch){t.onBeforeRenderUI.add(function(){var n=t.getElement().form;if(!n)return;if(n._mceOldSubmit)return;if(!n.submit.nodeType&&!n.submit.length){t.formElement=n;n._mceOldSubmit=n.submit;n.submit=function(){EditorManager.triggerSave();t.isNotDirty=1;return this._mceOldSubmit(this);};}n=null;});}function loadScripts(){if(s.language)sl.add(tinymce.baseURL+'/langs/'+s.language+'.js');if(s.theme.charAt(0)!='-'&&!ThemeManager.urls[s.theme])ThemeManager.load(s.theme,'themes/'+s.theme+'/editor_template'+tinymce.suffix+'.js');each(explode(s.plugins),function(p){if(p&&p.charAt(0)!='-'&&!PluginManager.urls[p]){if(!isWebKit&&p=='safari')return;PluginManager.load(p,'plugins/'+p+'/editor_plugin'+tinymce.suffix+'.js');}});sl.loadQueue(function(){if(s.ask){function ask(){window.setTimeout(function(){Event.remove(t.id,'focus',ask);t.windowManager.confirm(t.getLang('edit_confirm'),function(s){if(s)t.init();});},0);};Event.add(t.id,'focus',ask);return;}if(!t.removed)t.init();});};if(s.plugins.indexOf('compat2x')!=-1){PluginManager.load('compat2x','plugins/compat2x/editor_plugin'+tinymce.suffix+'.js');sl.loadQueue(loadScripts);}else loadScripts();},init:function(){var n,t=this,s=t.settings,w,h,e=t.getElement(),o,ti,u,bi,bc,re;EditorManager.add(t);s.theme=s.theme.replace(/-/,'');o=ThemeManager.get(s.theme);t.theme=new o();if(t.theme.init&&s.init_theme)t.theme.init(t,ThemeManager.urls[s.theme]||tinymce.documentBaseURL.replace(/\/$/,''));each(explode(s.plugins.replace(/\-/g,'')),function(p){var c=PluginManager.get(p),u=PluginManager.urls[p]||tinymce.documentBaseURL.replace(/\/$/,''),po;if(c){po=new c(t,u);t.plugins[p]=po;if(po.init)po.init(t,u);}});if(s.popup_css!==false){if(s.popup_css)s.popup_css=t.documentBaseURI.toAbsolute(s.popup_css);else s.popup_css=t.baseURI.toAbsolute("themes/"+s.theme+"/skins/"+s.skin+"/dialog.css");}if(s.popup_css_add)s.popup_css+=','+t.documentBaseURI.toAbsolute(s.popup_css_add);t.controlManager=new tinymce.ControlManager(t);t.undoManager=new tinymce.UndoManager(t);t.undoManager.onAdd.add(function(um,l){if(!l.initial)return t.onChange.dispatch(t,l,um);});t.undoManager.onUndo.add(function(um,l){return t.onUndo.dispatch(t,l,um);});t.undoManager.onRedo.add(function(um,l){return t.onRedo.dispatch(t,l,um);});if(s.custom_undo_redo){t.onExecCommand.add(function(ed,cmd,ui,val,a){if(cmd!='Undo'&&cmd!='Redo'&&cmd!='mceRepaint'&&(!a||!a.skip_undo))t.undoManager.add();});}t.onExecCommand.add(function(ed,c){if(!/^(FontName|FontSize)$/.test(c))t.nodeChanged();});if(isGecko){function repaint(a,o){if(!o||!o.initial)t.execCommand('mceRepaint');};t.onUndo.add(repaint);t.onRedo.add(repaint);t.onSetContent.add(repaint);}t.onBeforeRenderUI.dispatch(t,t.controlManager);if(s.render_ui){w=s.width||e.style.width||e.offsetWidth;h=s.height||e.style.height||e.offsetHeight;t.orgDisplay=e.style.display;re=/^[0-9\.]+(|px)$/i;if(re.test(''+w))w=Math.max(parseInt(w)+(o.deltaWidth||0),100);if(re.test(''+h))h=Math.max(parseInt(h)+(o.deltaHeight||0),100);o=t.theme.renderUI({targetNode:e,width:w,height:h,deltaWidth:s.delta_width,deltaHeight:s.delta_height});t.editorContainer=o.editorContainer;}DOM.setStyles(o.sizeContainer||o.editorContainer,{width:w,height:h});h=(o.iframeHeight||h)+(typeof(h)=='number'?(o.deltaHeight||0):'');if(h<100)h=100;t.iframeHTML=s.doctype+'<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="'+t.documentBaseURI.getURI()+'" />';t.iframeHTML+='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';if(tinymce.relaxedDomain)t.iframeHTML+='<script type="text/javascript">document.domain = "'+tinymce.relaxedDomain+'";</script>';bi=s.body_id||'tinymce';if(bi.indexOf('=')!=-1){bi=t.getParam('body_id','','hash');bi=bi[t.id]||bi;}bc=s.body_class||'';if(bc.indexOf('=')!=-1){bc=t.getParam('body_class','','hash');bc=bc[t.id]||'';}t.iframeHTML+='</head><body id="'+bi+'" class="mceContentBody '+bc+'"></body></html>';if(tinymce.relaxedDomain){if(isIE||(tinymce.isOpera&&parseFloat(opera.version())>=9.5))u='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinyMCE.get("'+t.id+'");document.write(ed.iframeHTML);document.close();ed.setupIframe();})()';else if(tinymce.isOpera)u='javascript:(function(){document.open();document.domain="'+document.domain+'";document.close();ed.setupIframe();})()';}n=DOM.add(o.iframeContainer,'iframe',{id:t.id+"_ifr",src:u||'javascript:""',frameBorder:'0',style:{width:'100%',height:h}});t.contentAreaContainer=o.iframeContainer;DOM.get(o.editorContainer).style.display=t.orgDisplay;DOM.get(t.id).style.display='none';if(tinymce.isOldWebKit){Event.add(n,'load',t.setupIframe,t);n.src=tinymce.baseURL+'/plugins/safari/blank.htm';}else{if(!isIE||!tinymce.relaxedDomain)t.setupIframe();e=n=o=null;}},setupIframe:function(){var t=this,s=t.settings,e=DOM.get(t.id),d=t.getDoc(),h,b;if(!isIE||!tinymce.relaxedDomain){d.open();d.write(t.iframeHTML);d.close();}if(!isIE){try{if(!s.readonly)d.designMode='On';}catch(ex){}}if(isIE){b=t.getBody();DOM.hide(b);if(!s.readonly)b.contentEditable=true;DOM.show(b);}t.dom=new tinymce.DOM.DOMUtils(t.getDoc(),{keep_values:true,url_converter:t.convertURL,url_converter_scope:t,hex_colors:s.force_hex_style_colors,class_filter:s.class_filter,update_styles:1,fix_ie_paragraphs:1});t.serializer=new tinymce.dom.Serializer({entity_encoding:s.entity_encoding,entities:s.entities,valid_elements:s.verify_html===false?'*[*]':s.valid_elements,extended_valid_elements:s.extended_valid_elements,valid_child_elements:s.valid_child_elements,invalid_elements:s.invalid_elements,fix_table_elements:s.fix_table_elements,fix_list_elements:s.fix_list_elements,fix_content_duplication:s.fix_content_duplication,convert_fonts_to_spans:s.convert_fonts_to_spans,font_size_classes:s.font_size_classes,font_size_style_values:s.font_size_style_values,apply_source_formatting:s.apply_source_formatting,remove_linebreaks:s.remove_linebreaks,element_format:s.element_format,dom:t.dom});t.selection=new tinymce.dom.Selection(t.dom,t.getWin(),t.serializer);t.forceBlocks=new tinymce.ForceBlocks(t,{forced_root_block:s.forced_root_block});t.editorCommands=new tinymce.EditorCommands(t);t.serializer.onPreProcess.add(function(se,o){return t.onPreProcess.dispatch(t,o,se);});t.serializer.onPostProcess.add(function(se,o){return t.onPostProcess.dispatch(t,o,se);});t.onPreInit.dispatch(t);if(!s.gecko_spellcheck)t.getBody().spellcheck=0;if(!s.readonly)t._addEvents();t.controlManager.onPostRender.dispatch(t,t.controlManager);t.onPostRender.dispatch(t);if(s.directionality)t.getBody().dir=s.directionality;if(s.nowrap)t.getBody().style.whiteSpace="nowrap";if(s.auto_resize)t.onNodeChange.add(t.resizeToContent,t);if(s.custom_elements){function handleCustom(ed,o){each(explode(s.custom_elements),function(v){var n;if(v.indexOf('~')===0){v=v.substring(1);n='span';}else n='div';o.content=o.content.replace(new RegExp('<('+v+')([^>]*)>','g'),'<'+n+' mce_name="$1"$2>');o.content=o.content.replace(new RegExp('</('+v+')>','g'),'</'+n+'>');});};t.onBeforeSetContent.add(handleCustom);t.onPostProcess.add(function(ed,o){if(o.set)handleCustom(ed,o)});}if(s.handle_node_change_callback){t.onNodeChange.add(function(ed,cm,n){t.execCallback('handle_node_change_callback',t.id,n,-1,-1,true,t.selection.isCollapsed());});}if(s.save_callback){t.onSaveContent.add(function(ed,o){var h=t.execCallback('save_callback',t.id,o.content,t.getBody());if(h)o.content=h;});}if(s.onchange_callback){t.onChange.add(function(ed,l){t.execCallback('onchange_callback',t,l);});}if(s.convert_newlines_to_brs){t.onBeforeSetContent.add(function(ed,o){if(o.initial)o.content=o.content.replace(/\r?\n/g,'<br />');});}if(s.fix_nesting&&isIE){t.onBeforeSetContent.add(function(ed,o){o.content=t._fixNesting(o.content);});}if(s.preformatted){t.onPostProcess.add(function(ed,o){o.content=o.content.replace(/^\s*<pre.*?>/,'');o.content=o.content.replace(/<\/pre>\s*$/,'');if(o.set)o.content='<pre class="mceItemHidden">'+o.content+'</pre>';});}if(s.verify_css_classes){t.serializer.attribValueFilter=function(n,v){var s,cl;if(n=='class'){if(!t.classesRE){cl=t.dom.getClasses();if(cl.length>0){s='';each(cl,function(o){s+=(s?'|':'')+o['class'];});t.classesRE=new RegExp('('+s+')','gi');}}return!t.classesRE||/(\bmceItem\w+\b|\bmceTemp\w+\b)/g.test(v)||t.classesRE.test(v)?v:'';}return v;};}if(s.convert_fonts_to_spans)t._convertFonts();if(s.inline_styles)t._convertInlineElements();if(s.cleanup_callback){t.onBeforeSetContent.add(function(ed,o){o.content=t.execCallback('cleanup_callback','insert_to_editor',o.content,o);});t.onPreProcess.add(function(ed,o){if(o.set)t.execCallback('cleanup_callback','insert_to_editor_dom',o.node,o);if(o.get)t.execCallback('cleanup_callback','get_from_editor_dom',o.node,o);});t.onPostProcess.add(function(ed,o){if(o.set)o.content=t.execCallback('cleanup_callback','insert_to_editor',o.content,o);if(o.get)o.content=t.execCallback('cleanup_callback','get_from_editor',o.content,o);});}if(s.save_callback){t.onGetContent.add(function(ed,o){if(o.save)o.content=t.execCallback('save_callback',t.id,o.content,t.getBody());});}if(s.handle_event_callback){t.onEvent.add(function(ed,e,o){if(t.execCallback('handle_event_callback',e,ed,o)===false)Event.cancel(e);});}t.onSetContent.add(function(){t.addVisual(t.getBody());});if(s.padd_empty_editor){t.onPostProcess.add(function(ed,o){o.content=o.content.replace(/^(<p[^>]*>( | |\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/,'');});}if(isGecko&&!s.readonly){try{d.designMode='Off';d.designMode='On';}catch(ex){}}setTimeout(function(){if(t.removed)return;t.load({initial:true,format:(s.cleanup_on_startup?'html':'raw')});t.startContent=t.getContent({format:'raw'});t.undoManager.add({initial:true});t.initialized=true;t.onInit.dispatch(t);t.execCallback('setupcontent_callback',t.id,t.getBody(),t.getDoc());t.execCallback('init_instance_callback',t);t.focus(true);t.nodeChanged({initial:1});if(s.content_css){tinymce.each(explode(s.content_css),function(u){t.dom.loadCSS(t.documentBaseURI.toAbsolute(u));});}if(s.auto_focus){setTimeout(function(){var ed=EditorManager.get(s.auto_focus);ed.selection.select(ed.getBody(),1);ed.selection.collapse(1);ed.getWin().focus();},100);}},1);e=null;},focus:function(sf){var oed,t=this,ce=t.settings.content_editable;if(!sf){if(!ce&&(!isIE||t.selection.getNode().ownerDocument!=t.getDoc()))t.getWin().focus();}if(EditorManager.activeEditor!=t){if((oed=EditorManager.activeEditor)!=null)oed.onDeactivate.dispatch(oed,t);t.onActivate.dispatch(t,oed);}EditorManager._setActive(t);},execCallback:function(n){var t=this,f=t.settings[n],s;if(!f)return;if(t.callbackLookup&&(s=t.callbackLookup[n])){f=s.func;s=s.scope;}if(is(f,'string')){s=f.replace(/\.\w+$/,'');s=s?tinymce.resolve(s):0;f=tinymce.resolve(f);t.callbackLookup=t.callbackLookup||{};t.callbackLookup[n]={func:f,scope:s};}return f.apply(s||t,Array.prototype.slice.call(arguments,1));},translate:function(s){var c=this.settings.language||'en',i18n=EditorManager.i18n;if(!s)return'';return i18n[c+'.'+s]||s.replace(/{\#([^}]+)\}/g,function(a,b){return i18n[c+'.'+b]||'{#'+b+'}';});},getLang:function(n,dv){return EditorManager.i18n[(this.settings.language||'en')+'.'+n]||(is(dv)?dv:'{#'+n+'}');},getParam:function(n,dv,ty){var tr=tinymce.trim,v=is(this.settings[n])?this.settings[n]:dv,o;if(ty==='hash'){o={};if(is(v,'string')){each(v.indexOf('=')>0?v.split(/[;,](?![^=;,]*(?:[;,]|$))/):v.split(','),function(v){v=v.split('=');if(v.length>1)o[tr(v[0])]=tr(v[1]);else o[tr(v[0])]=tr(v);});}else o=v;return o;}return v;},nodeChanged:function(o){var t=this,s=t.selection,n=s.getNode()||t.getBody();if(t.initialized){t.onNodeChange.dispatch(t,o?o.controlManager||t.controlManager:t.controlManager,isIE&&n.ownerDocument!=t.getDoc()?t.getBody():n,s.isCollapsed(),o);}},addButton:function(n,s){var t=this;t.buttons=t.buttons||{};t.buttons[n]=s;},addCommand:function(n,f,s){this.execCommands[n]={func:f,scope:s||this};},addQueryStateHandler:function(n,f,s){this.queryStateCommands[n]={func:f,scope:s||this};},addQueryValueHandler:function(n,f,s){this.queryValueCommands[n]={func:f,scope:s||this};},addShortcut:function(pa,desc,cmd_func,sc){var t=this,c;if(!t.settings.custom_shortcuts)return false;t.shortcuts=t.shortcuts||{};if(is(cmd_func,'string')){c=cmd_func;cmd_func=function(){t.execCommand(c,false,null);};}if(is(cmd_func,'object')){c=cmd_func;cmd_func=function(){t.execCommand(c[0],c[1],c[2]);};}each(explode(pa),function(pa){var o={func:cmd_func,scope:sc||this,desc:desc,alt:false,ctrl:false,shift:false};each(explode(pa,'+'),function(v){switch(v){case'alt':case'ctrl':case'shift':o[v]=true;break;default:o.charCode=v.charCodeAt(0);o.keyCode=v.toUpperCase().charCodeAt(0);}});t.shortcuts[(o.ctrl?'ctrl':'')+','+(o.alt?'alt':'')+','+(o.shift?'shift':'')+','+o.keyCode]=o;});return true;},execCommand:function(cmd,ui,val,a){var t=this,s=0,o,st;if(!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd)&&(!a||!a.skip_focus))t.focus();o={};t.onBeforeExecCommand.dispatch(t,cmd,ui,val,o);if(o.terminate)return false;if(t.execCallback('execcommand_callback',t.id,t.selection.getNode(),cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}if(o=t.execCommands[cmd]){st=o.func.call(o.scope,ui,val);if(st!==true){t.onExecCommand.dispatch(t,cmd,ui,val,a);return st;}}each(t.plugins,function(p){if(p.execCommand&&p.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);s=1;return false;}});if(s)return true;if(t.theme.execCommand&&t.theme.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}if(t.editorCommands.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}t.getDoc().execCommand(cmd,ui,val);t.onExecCommand.dispatch(t,cmd,ui,val,a);},queryCommandState:function(c){var t=this,o,s;if(t._isHidden())return;if(o=t.queryStateCommands[c]){s=o.func.call(o.scope);if(s!==true)return s;}o=t.editorCommands.queryCommandState(c);if(o!==-1)return o;try{return this.getDoc().queryCommandState(c);}catch(ex){}},queryCommandValue:function(c){var t=this,o,s;if(t._isHidden())return;if(o=t.queryValueCommands[c]){s=o.func.call(o.scope);if(s!==true)return s;}o=t.editorCommands.queryCommandValue(c);if(is(o))return o;try{return this.getDoc().queryCommandValue(c);}catch(ex){}},show:function(){var t=this;DOM.show(t.getContainer());DOM.hide(t.id);t.load();},hide:function(){var t=this,d=t.getDoc();if(isIE&&d)d.execCommand('SelectAll');t.save();DOM.hide(t.getContainer());DOM.setStyle(t.id,'display',t.orgDisplay);},isHidden:function(){return!DOM.isHidden(this.id);},setProgressState:function(b,ti,o){this.onSetProgressState.dispatch(this,b,ti,o);return b;},resizeToContent:function(){var t=this;DOM.setStyle(t.id+"_ifr",'height',t.getBody().scrollHeight);},load:function(o){var t=this,e=t.getElement(),h;if(e){o=o||{};o.load=true;h=t.setContent(is(e.value)?e.value:e.innerHTML,o);o.element=e;if(!o.no_events)t.onLoadContent.dispatch(t,o);o.element=e=null;return h;}},save:function(o){var t=this,e=t.getElement(),h,f;if(!e||!t.initialized)return;o=o||{};o.save=true;if(!o.no_events){t.undoManager.typing=0;t.undoManager.add();}o.element=e;h=o.content=t.getContent(o);if(!o.no_events)t.onSaveContent.dispatch(t,o);h=o.content;if(!/TEXTAREA|INPUT/i.test(e.nodeName)){e.innerHTML=h;if(f=DOM.getParent(t.id,'form')){each(f.elements,function(e){if(e.name==t.id){e.value=h;return false;}});}}else e.value=h;o.element=e=null;return h;},setContent:function(h,o){var t=this;o=o||{};o.format=o.format||'html';o.set=true;o.content=h;if(!o.no_events)t.onBeforeSetContent.dispatch(t,o);if(!tinymce.isIE&&(h.length===0||/^\s+$/.test(h))){o.content=t.dom.setHTML(t.getBody(),'<br mce_bogus="1" />');o.format='raw';}o.content=t.dom.setHTML(t.getBody(),tinymce.trim(o.content));if(o.format!='raw'&&t.settings.cleanup){o.getInner=true;o.content=t.dom.setHTML(t.getBody(),t.serializer.serialize(t.getBody(),o));}if(!o.no_events)t.onSetContent.dispatch(t,o);return o.content;},getContent:function(o){var t=this,h;o=o||{};o.format=o.format||'html';o.get=true;if(!o.no_events)t.onBeforeGetContent.dispatch(t,o);if(o.format!='raw'&&t.settings.cleanup){o.getInner=true;h=t.serializer.serialize(t.getBody(),o);}else h=t.getBody().innerHTML;h=h.replace(/^\s*|\s*$/g,'');o.content=h;if(!o.no_events)t.onGetContent.dispatch(t,o);return o.content;},isDirty:function(){var t=this;return tinymce.trim(t.startContent)!=tinymce.trim(t.getContent({format:'raw',no_events:1}))&&!t.isNotDirty;},getContainer:function(){var t=this;if(!t.container)t.container=DOM.get(t.editorContainer||t.id+'_parent');return t.container;},getContentAreaContainer:function(){return this.contentAreaContainer;},getElement:function(){return DOM.get(this.settings.content_element||this.id);},getWin:function(){var t=this,e;if(!t.contentWindow){e=DOM.get(t.id+"_ifr");if(e)t.contentWindow=e.contentWindow;}return t.contentWindow;},getDoc:function(){var t=this,w;if(!t.contentDocument){w=t.getWin();if(w)t.contentDocument=w.document;}return t.contentDocument;},getBody:function(){return this.bodyElement||this.getDoc().body;},convertURL:function(u,n,e){var t=this,s=t.settings;if(s.urlconverter_callback)return t.execCallback('urlconverter_callback',u,e,true,n);if(!s.convert_urls||(e&&e.nodeName=='LINK')||u.indexOf('file:')===0)return u;if(s.relative_urls)return t.documentBaseURI.toRelative(u);u=t.documentBaseURI.toAbsolute(u,s.remove_script_host);return u;},addVisual:function(e){var t=this,s=t.settings;e=e||t.getBody();if(!is(t.hasVisual))t.hasVisual=s.visual;each(t.dom.select('table,a',e),function(e){var v;switch(e.nodeName){case'TABLE':v=t.dom.getAttrib(e,'border');if(!v||v=='0'){if(t.hasVisual)t.dom.addClass(e,s.visual_table_class);else t.dom.removeClass(e,s.visual_table_class);}return;case'A':v=t.dom.getAttrib(e,'name');if(v){if(t.hasVisual)t.dom.addClass(e,'mceItemAnchor');else t.dom.removeClass(e,'mceItemAnchor');}return;}});t.onVisualAid.dispatch(t,e,t.hasVisual);},remove:function(){var t=this,e=t.getContainer();t.removed=1;t.hide();t.execCallback('remove_instance_callback',t);t.onRemove.dispatch(t);t.onExecCommand.listeners=[];EditorManager.remove(t);DOM.remove(e);},destroy:function(s){var t=this;if(t.destroyed)return;if(!s){tinymce.removeUnload(t.destroy);tinyMCE.onBeforeUnload.remove(t._beforeUnload);if(t.theme.destroy)t.theme.destroy();t.controlManager.destroy();t.selection.destroy();t.dom.destroy();if(!t.settings.content_editable){Event.clear(t.getWin());Event.clear(t.getDoc());}Event.clear(t.getBody());Event.clear(t.formElement);}if(t.formElement){t.formElement.submit=t.formElement._mceOldSubmit;t.formElement._mceOldSubmit=null;}t.contentAreaContainer=t.formElement=t.container=t.settings.content_element=t.bodyElement=t.contentDocument=t.contentWindow=null;if(t.selection)t.selection=t.selection.win=t.selection.dom=t.selection.dom.doc=null;t.destroyed=1;},_addEvents:function(){var t=this,i,s=t.settings,lo={mouseup:'onMouseUp',mousedown:'onMouseDown',click:'onClick',keyup:'onKeyUp',keydown:'onKeyDown',keypress:'onKeyPress',submit:'onSubmit',reset:'onReset',contextmenu:'onContextMenu',dblclick:'onDblClick',paste:'onPaste'};function eventHandler(e,o){var ty=e.type;if(t.removed)return;if(t.onEvent.dispatch(t,e,o)!==false){t[lo[e.fakeType||e.type]].dispatch(t,e,o);}};each(lo,function(v,k){switch(k){case'contextmenu':if(tinymce.isOpera){Event.add(t.getBody(),'mousedown',function(e){if(e.ctrlKey){e.fakeType='contextmenu';eventHandler(e);}});}else Event.add(t.getBody(),k,eventHandler);break;case'paste':Event.add(t.getBody(),k,function(e){var tx,h,el,r;if(e.clipboardData)tx=e.clipboardData.getData('text/plain');else if(tinymce.isIE)tx=t.getWin().clipboardData.getData('Text');eventHandler(e,{text:tx,html:h});});break;case'submit':case'reset':Event.add(t.getElement().form||DOM.getParent(t.id,'form'),k,eventHandler);break;default:Event.add(s.content_editable?t.getBody():t.getDoc(),k,eventHandler);}});Event.add(s.content_editable?t.getBody():(isGecko?t.getDoc():t.getWin()),'focus',function(e){t.focus(true);});if(tinymce.isGecko){Event.add(t.getDoc(),'DOMNodeInserted',function(e){var v;e=e.target;if(e.nodeType===1&&e.nodeName==='IMG'&&(v=e.getAttribute('mce_src')))e.src=t.documentBaseURI.toAbsolute(v);});}if(isGecko){function setOpts(){var t=this,d=t.getDoc(),s=t.settings;if(isGecko&&!s.readonly){if(t._isHidden()){try{if(!s.content_editable)d.designMode='On';}catch(ex){}}try{d.execCommand("styleWithCSS",0,false);}catch(ex){if(!t._isHidden())try{d.execCommand("useCSS",0,true);}catch(ex){}}if(!s.table_inline_editing)try{d.execCommand('enableInlineTableEditing',false,false);}catch(ex){}if(!s.object_resizing)try{d.execCommand('enableObjectResizing',false,false);}catch(ex){}}};t.onBeforeExecCommand.add(setOpts);t.onMouseDown.add(setOpts);}t.onMouseUp.add(t.nodeChanged);t.onClick.add(t.nodeChanged);t.onKeyUp.add(function(ed,e){var c=e.keyCode;if((c>=33&&c<=36)||(c>=37&&c<=40)||c==13||c==45||c==46||c==8||(tinymce.isMac&&(c==91||c==93))||e.ctrlKey)t.nodeChanged();});t.onReset.add(function(){t.setContent(t.startContent,{format:'raw'});});if(t.getParam('tab_focus')){function tabCancel(ed,e){if(e.keyCode===9)return Event.cancel(e);};function tabHandler(ed,e){var x,i,f,el,v;function find(d){f=DOM.getParent(ed.id,'form');el=f.elements;if(f){each(el,function(e,i){if(e.id==ed.id){x=i;return false;}});if(d>0){for(i=x+1;i<el.length;i++){if(el[i].type!='hidden')return el[i];}}else{for(i=x-1;i>=0;i--){if(el[i].type!='hidden')return el[i];}}}return null;};if(e.keyCode===9){v=explode(ed.getParam('tab_focus'));if(v.length==1){v[1]=v[0];v[0]=':prev';}if(e.shiftKey){if(v[0]==':prev')el=find(-1);else el=DOM.get(v[0]);}else{if(v[1]==':next')el=find(1);else el=DOM.get(v[1]);}if(el){if(ed=EditorManager.get(el.id||el.name))ed.focus();else window.setTimeout(function(){window.focus();el.focus();},10);return Event.cancel(e);}}};t.onKeyUp.add(tabCancel);if(isGecko){t.onKeyPress.add(tabHandler);t.onKeyDown.add(tabCancel);}else t.onKeyDown.add(tabHandler);}if(s.custom_shortcuts){if(s.custom_undo_redo_keyboard_shortcuts){t.addShortcut('ctrl+z',t.getLang('undo_desc'),'Undo');t.addShortcut('ctrl+y',t.getLang('redo_desc'),'Redo');}if(isGecko){t.addShortcut('ctrl+b',t.getLang('bold_desc'),'Bold');t.addShortcut('ctrl+i',t.getLang('italic_desc'),'Italic');t.addShortcut('ctrl+u',t.getLang('underline_desc'),'Underline');}for(i=1;i<=6;i++)t.addShortcut('ctrl+'+i,'',['FormatBlock',false,'<h'+i+'>']);t.addShortcut('ctrl+7','',['FormatBlock',false,'<p>']);t.addShortcut('ctrl+8','',['FormatBlock',false,'<div>']);t.addShortcut('ctrl+9','',['FormatBlock',false,'<address>']);function find(e){var v=null;if(!e.altKey&&!e.ctrlKey&&!e.metaKey)return v;each(t.shortcuts,function(o){if(tinymce.isMac&&o.ctrl!=e.metaKey)return;else if(!tinymce.isMac&&o.ctrl!=e.ctrlKey)return;if(o.alt!=e.altKey)return;if(o.shift!=e.shiftKey)return;if(e.keyCode==o.keyCode||(e.charCode&&e.charCode==o.charCode)){v=o;return false;}});return v;};t.onKeyUp.add(function(ed,e){var o=find(e);if(o)return Event.cancel(e);});t.onKeyPress.add(function(ed,e){var o=find(e);if(o)return Event.cancel(e);});t.onKeyDown.add(function(ed,e){var o=find(e);if(o){o.func.call(o.scope);return Event.cancel(e);}});}if(tinymce.isIE){Event.add(t.getDoc(),'controlselect',function(e){var re=t.resizeInfo,cb;e=e.target;if(e.nodeName!=='IMG')return;if(re)Event.remove(re.node,re.ev,re.cb);if(!t.dom.hasClass(e,'mceItemNoResize')){ev='resizeend';cb=Event.add(e,ev,function(e){var v;e=e.target;if(v=t.dom.getStyle(e,'width')){t.dom.setAttrib(e,'width',v.replace(/[^0-9%]+/g,''));t.dom.setStyle(e,'width','');}if(v=t.dom.getStyle(e,'height')){t.dom.setAttrib(e,'height',v.replace(/[^0-9%]+/g,''));t.dom.setStyle(e,'height','');}});}else{ev='resizestart';cb=Event.add(e,'resizestart',Event.cancel,Event);}re=t.resizeInfo={node:e,ev:ev,cb:cb};});t.onKeyDown.add(function(ed,e){switch(e.keyCode){case 8:if(t.selection.getRng().item){t.selection.getRng().item(0).removeNode();return Event.cancel(e);}}});}if(tinymce.isOpera){t.onClick.add(function(ed,e){Event.prevent(e);});}if(s.custom_undo_redo){function addUndo(){t.undoManager.typing=0;t.undoManager.add();};if(tinymce.isIE){Event.add(t.getWin(),'blur',function(e){var n;if(t.selection){n=t.selection.getNode();if(!t.removed&&n.ownerDocument&&n.ownerDocument!=t.getDoc())addUndo();}});}else{Event.add(t.getDoc(),'blur',function(){if(t.selection&&!t.removed)addUndo();});}t.onMouseDown.add(addUndo);t.onKeyUp.add(function(ed,e){if((e.keyCode>=33&&e.keyCode<=36)||(e.keyCode>=37&&e.keyCode<=40)||e.keyCode==13||e.keyCode==45||e.ctrlKey){t.undoManager.typing=0;t.undoManager.add();}});t.onKeyDown.add(function(ed,e){if((e.keyCode>=33&&e.keyCode<=36)||(e.keyCode>=37&&e.keyCode<=40)||e.keyCode==13||e.keyCode==45){if(t.undoManager.typing){t.undoManager.add();t.undoManager.typing=0;}return;}if(!t.undoManager.typing){t.undoManager.add();t.undoManager.typing=1;}});}},_convertInlineElements:function(){var t=this,s=t.settings,dom=t.dom,v,e,na,st,sp;function convert(ed,o){if(!s.inline_styles)return;if(o.get){each(t.dom.select('table,u,strike',o.node),function(n){switch(n.nodeName){case'TABLE':if(v=dom.getAttrib(n,'height')){dom.setStyle(n,'height',v);dom.setAttrib(n,'height','');}break;case'U':case'STRIKE':n.style.textDecoration=n.nodeName=='U'?'underline':'line-through';dom.setAttrib(n,'mce_style','');dom.setAttrib(n,'mce_name','span');break;}});}else if(o.set){each(t.dom.select('table,span',o.node).reverse(),function(n){if(n.nodeName=='TABLE'){if(v=dom.getStyle(n,'height'))dom.setAttrib(n,'height',v.replace(/[^0-9%]+/g,''));}else{if(n.style.textDecoration=='underline')na='u';else if(n.style.textDecoration=='line-through')na='strike';else na='';if(na){n.style.textDecoration='';dom.setAttrib(n,'mce_style','');e=dom.create(na,{style:dom.getAttrib(n,'style')});dom.replace(e,n,1);}}});}};t.onPreProcess.add(convert);if(!s.cleanup_on_startup){t.onSetContent.add(function(ed,o){if(o.initial)convert(t,{node:t.getBody(),set:1});});}},_convertFonts:function(){var t=this,s=t.settings,dom=t.dom,fz,fzn,sl,cl;if(!s.inline_styles)return;fz=[8,10,12,14,18,24,36];fzn=['xx-small','x-small','small','medium','large','x-large','xx-large'];if(sl=s.font_size_style_values)sl=explode(sl);if(cl=s.font_size_classes)cl=explode(cl);function process(no){var n,sp,nl,x;if(!s.inline_styles)return;nl=t.dom.select('font',no);for(x=nl.length-1;x>=0;x--){n=nl[x];sp=dom.create('span',{style:dom.getAttrib(n,'style'),'class':dom.getAttrib(n,'class')});dom.setStyles(sp,{fontFamily:dom.getAttrib(n,'face'),color:dom.getAttrib(n,'color'),backgroundColor:n.style.backgroundColor});if(n.size){if(sl)dom.setStyle(sp,'fontSize',sl[parseInt(n.size)-1]);else dom.setAttrib(sp,'class',cl[parseInt(n.size)-1]);}dom.setAttrib(sp,'mce_style','');dom.replace(sp,n,1);}};t.onPreProcess.add(function(ed,o){if(o.get)process(o.node);});t.onSetContent.add(function(ed,o){if(o.initial)process(o.node);});},_isHidden:function(){var s;if(!isGecko)return 0;s=this.selection.getSel();return(!s||!s.rangeCount||s.rangeCount==0);},_fixNesting:function(s){var d=[],i;s=s.replace(/<(\/)?([^\s>]+)[^>]*?>/g,function(a,b,c){var e;if(b==='/'){if(!d.length)return'';if(c!==d[d.length-1].tag){for(i=d.length-1;i>=0;i--){if(d[i].tag===c){d[i].close=1;break;}}return'';}else{d.pop();if(d.length&&d[d.length-1].close){a=a+'</'+d[d.length-1].tag+'>';d.pop();}}}else{if(/^(br|hr|input|meta|img|link|param)$/i.test(c))return a;if(/\/>$/.test(a))return a;d.push({tag:c});}return a;});for(i=d.length-1;i>=0;i--)s+='</'+d[i].tag+'>';return s;}});})();(function(){var each=tinymce.each,isIE=tinymce.isIE,isGecko=tinymce.isGecko,isOpera=tinymce.isOpera,isWebKit=tinymce.isWebKit;function isBlock(n){return/^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n.nodeName);};tinymce.create('tinymce.EditorCommands',{EditorCommands:function(ed){this.editor=ed;},execCommand:function(cmd,ui,val){var t=this,ed=t.editor,f;switch(cmd){case'Cut':case'Copy':case'Paste':try{ed.getDoc().execCommand(cmd,ui,val);}catch(ex){if(isGecko){ed.windowManager.confirm(ed.getLang('clipboard_msg'),function(s){if(s)window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html','mceExternal');});}else ed.windowManager.alert(ed.getLang('clipboard_no_support'));}return true;case'mceResetDesignMode':case'mceBeginUndoLevel':return true;case'unlink':t.UnLink();return true;case'JustifyLeft':case'JustifyCenter':case'JustifyRight':case'JustifyFull':t.mceJustify(cmd,cmd.substring(7).toLowerCase());return true;case'mceEndUndoLevel':case'mceAddUndoLevel':ed.undoManager.add();return true;default:f=this[cmd];if(f){f.call(this,ui,val);return true;}}return false;},Indent:function(){var ed=this.editor,d=ed.dom,s=ed.selection,e,iv,iu;iv=ed.settings.indentation;iu=/[a-z%]+$/i.exec(iv);iv=parseInt(iv);if(ed.settings.inline_styles&&(!this.queryStateInsertUnorderedList()&&!this.queryStateInsertOrderedList())){each(this._getSelectedBlocks(),function(e){d.setStyle(e,'paddingLeft',(parseInt(e.style.paddingLeft||0)+iv)+iu);});return;}ed.getDoc().execCommand('Indent',false,null);if(isIE){d.getParent(s.getNode(),function(n){if(n.nodeName=='BLOCKQUOTE'){n.dir=n.style.cssText='';}});}},Outdent:function(){var ed=this.editor,d=ed.dom,s=ed.selection,e,v,iv,iu;iv=ed.settings.indentation;iu=/[a-z%]+$/i.exec(iv);iv=parseInt(iv);if(ed.settings.inline_styles&&(!this.queryStateInsertUnorderedList()&&!this.queryStateInsertOrderedList())){each(this._getSelectedBlocks(),function(e){v=Math.max(0,parseInt(e.style.paddingLeft||0)-iv);d.setStyle(e,'paddingLeft',v?v+iu:'');});return;}ed.getDoc().execCommand('Outdent',false,null);},mceSetAttribute:function(u,v){var ed=this.editor,d=ed.dom,e;if(e=d.getParent(ed.selection.getNode(),d.isBlock))d.setAttrib(e,v.name,v.value);},mceSetContent:function(u,v){this.editor.setContent(v);},mceToggleVisualAid:function(){var ed=this.editor;ed.hasVisual=!ed.hasVisual;ed.addVisual();},mceReplaceContent:function(u,v){var s=this.editor.selection;s.setContent(v.replace(/\{\$selection\}/g,s.getContent({format:'text'})));},mceInsertLink:function(u,v){var ed=this.editor,s=ed.selection,e=ed.dom.getParent(s.getNode(),'A');if(tinymce.is(v,'string'))v={href:v};function set(e){each(v,function(v,k){ed.dom.setAttrib(e,k,v);});};if(!e){ed.execCommand('CreateLink',false,'javascript:mctmp(0);');each(ed.dom.select('a'),function(e){if(e.href=='javascript:mctmp(0);')set(e);});}else{if(v.href)set(e);else ed.dom.remove(e,1);}},UnLink:function(){var ed=this.editor,s=ed.selection;if(s.isCollapsed())s.select(s.getNode());ed.getDoc().execCommand('unlink',false,null);s.collapse(0);},FontName:function(u,v){var t=this,ed=t.editor,s=ed.selection,e;if(!v){if(s.isCollapsed())s.select(s.getNode());t.RemoveFormat();}else{if(ed.settings.convert_fonts_to_spans)t._applyInlineStyle('span',{style:{fontFamily:v}});else ed.getDoc().execCommand('FontName',false,v);}},FontSize:function(u,v){var ed=this.editor,s=ed.settings,fc,fs;if(s.convert_fonts_to_spans&&v>=1&&v<=7){fs=tinymce.explode(s.font_size_style_values);fc=tinymce.explode(s.font_size_classes);if(fc)v=fc[v-1]||v;else v=fs[v-1]||v;}if(v>=1&&v<=7)ed.getDoc().execCommand('FontSize',false,v);else this._applyInlineStyle('span',{style:{fontSize:v}});},queryCommandValue:function(c){var f=this['queryValue'+c];if(f)return f.call(this,c);return false;},queryCommandState:function(cmd){var f;switch(cmd){case'JustifyLeft':case'JustifyCenter':case'JustifyRight':case'JustifyFull':return this.queryStateJustify(cmd,cmd.substring(7).toLowerCase());default:if(f=this['queryState'+cmd])return f.call(this,cmd);}return-1;},_queryState:function(c){try{return this.editor.getDoc().queryCommandState(c);}catch(ex){}},_queryVal:function(c){try{return this.editor.getDoc().queryCommandValue(c);}catch(ex){}},queryValueFontSize:function(){var ed=this.editor,v=0,p;if(p=ed.dom.getParent(ed.selection.getNode(),'SPAN'))v=p.style.fontSize;if(!v&&(isOpera||isWebKit)){if(p=ed.dom.getParent(ed.selection.getNode(),'FONT'))v=p.size;return v;}return v||this._queryVal('FontSize');},queryValueFontName:function(){var ed=this.editor,v=0,p;if(p=ed.dom.getParent(ed.selection.getNode(),'FONT'))v=p.face;if(p=ed.dom.getParent(ed.selection.getNode(),'SPAN'))v=p.style.fontFamily.replace(/, /g,',').replace(/[\'\"]/g,'').toLowerCase();if(!v)v=this._queryVal('FontName');return v;},mceJustify:function(c,v){var ed=this.editor,se=ed.selection,n=se.getNode(),nn=n.nodeName,bl,nb,dom=ed.dom,rm;if(ed.settings.inline_styles&&this.queryStateJustify(c,v))rm=1;bl=dom.getParent(n,ed.dom.isBlock);if(nn=='IMG'){if(v=='full')return;if(rm){if(v=='center')dom.setStyle(bl||n.parentNode,'textAlign','');dom.setStyle(n,'float','');this.mceRepaint();return;}if(v=='center'){if(bl&&/^(TD|TH)$/.test(bl.nodeName))bl=0;if(!bl||bl.childNodes.length>1){nb=dom.create('p');nb.appendChild(n.cloneNode(false));if(bl)dom.insertAfter(nb,bl);else dom.insertAfter(nb,n);dom.remove(n);n=nb.firstChild;bl=nb;}dom.setStyle(bl,'textAlign',v);dom.setStyle(n,'float','');}else{dom.setStyle(n,'float',v);dom.setStyle(bl||n.parentNode,'textAlign','');}this.mceRepaint();return;}if(ed.settings.inline_styles&&ed.settings.forced_root_block){if(rm)v='';each(this._getSelectedBlocks(dom.getParent(se.getStart(),dom.isBlock),dom.getParent(se.getEnd(),dom.isBlock)),function(e){dom.setAttrib(e,'align','');dom.setStyle(e,'textAlign',v=='full'?'justify':v);});return;}else if(!rm)ed.getDoc().execCommand(c,false,null);if(ed.settings.inline_styles){if(rm){dom.getParent(ed.selection.getNode(),function(n){if(n.style&&n.style.textAlign)dom.setStyle(n,'textAlign','');});return;}each(dom.select('*'),function(n){var v=n.align;if(v){if(v=='full')v='justify';dom.setStyle(n,'textAlign',v);dom.setAttrib(n,'align','');}});}},mceSetCSSClass:function(u,v){this.mceSetStyleInfo(0,{command:'setattrib',name:'class',value:v});},getSelectedElement:function(){var t=this,ed=t.editor,dom=ed.dom,se=ed.selection,r=se.getRng(),r1,r2,sc,ec,so,eo,e,sp,ep,re;if(se.isCollapsed()||r.item)return se.getNode();re=ed.settings.merge_styles_invalid_parents;if(tinymce.is(re,'string'))re=new RegExp(re,'i');if(isIE){r1=r.duplicate();r1.collapse(true);sc=r1.parentElement();r2=r.duplicate();r2.collapse(false);ec=r2.parentElement();if(sc!=ec){r1.move('character',1);sc=r1.parentElement();}if(sc==ec){r1=r.duplicate();r1.moveToElementText(sc);if(r1.compareEndPoints('StartToStart',r)==0&&r1.compareEndPoints('EndToEnd',r)==0)return re&&re.test(sc.nodeName)?null:sc;}}else{function getParent(n){return dom.getParent(n,function(n){return n.nodeType==1;});};sc=r.startContainer;ec=r.endContainer;so=r.startOffset;eo=r.endOffset;if(!r.collapsed){if(sc==ec){if(so-eo<2){if(sc.hasChildNodes()){sp=sc.childNodes[so];return re&&re.test(sp.nodeName)?null:sp;}}}}if(sc.nodeType!=3||ec.nodeType!=3)return null;if(so==0){sp=getParent(sc);if(sp&&sp.firstChild!=sc)sp=null;}if(so==sc.nodeValue.length){e=sc.nextSibling;if(e&&e.nodeType==1)sp=sc.nextSibling;}if(eo==0){e=ec.previousSibling;if(e&&e.nodeType==1)ep=e;}if(eo==ec.nodeValue.length){ep=getParent(ec);if(ep&&ep.lastChild!=ec)ep=null;}if(sp==ep)return re&&sp&&re.test(sp.nodeName)?null:sp;}return null;},InsertHorizontalRule:function(){if(isGecko||isIE)this.editor.selection.setContent('<hr />');else this.editor.getDoc().execCommand('InsertHorizontalRule',false,'');},RemoveFormat:function(){var t=this,ed=t.editor,s=ed.selection,b;if(isWebKit)s.setContent(s.getContent({format:'raw'}).replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g,''),{format:'raw'});else ed.getDoc().execCommand('RemoveFormat',false,null);t.mceSetStyleInfo(0,{command:'removeformat'});ed.addVisual();},mceSetStyleInfo:function(u,v){var t=this,ed=t.editor,d=ed.getDoc(),dom=ed.dom,e,b,s=ed.selection,nn=v.wrapper||'span',b=s.getBookmark(),re;function set(n,e){if(n.nodeType==1){switch(v.command){case'setattrib':return dom.setAttrib(n,v.name,v.value);case'setstyle':return dom.setStyle(n,v.name,v.value);case'removeformat':return dom.setAttrib(n,'class','');}}};re=ed.settings.merge_styles_invalid_parents;if(tinymce.is(re,'string'))re=new RegExp(re,'i');if((e=t.getSelectedElement())&&!ed.settings.force_span_wrappers)set(e,1);else{d.execCommand('FontName',false,'__');each(isWebKit?dom.select('span'):dom.select('font'),function(n){var sp,e;if(dom.getAttrib(n,'face')=='__'||n.style.fontFamily==='__'){sp=dom.create(nn,{mce_new:'1'});set(sp);each(n.childNodes,function(n){sp.appendChild(n.cloneNode(true));});dom.replace(sp,n);}});}each(dom.select(nn).reverse(),function(n){var p=n.parentNode;if(!dom.getAttrib(n,'mce_new')){p=dom.getParent(n,function(n){return n.nodeType==1&&dom.getAttrib(n,'mce_new');});if(p)dom.remove(n,1);}});each(dom.select(nn).reverse(),function(n){var p=n.parentNode;if(!p||!dom.getAttrib(n,'mce_new'))return;if(ed.settings.force_span_wrappers&&p.nodeName!='SPAN')return;if(p.nodeName==nn.toUpperCase()&&p.childNodes.length==1)return dom.remove(p,1);if(n.nodeType==1&&(!re||!re.test(p.nodeName))&&p.childNodes.length==1){set(p);dom.setAttrib(n,'class','');}});each(dom.select(nn).reverse(),function(n){if(dom.getAttrib(n,'mce_new')||(dom.getAttribs(n).length<=1&&n.className==='')){if(!dom.getAttrib(n,'class')&&!dom.getAttrib(n,'style'))return dom.remove(n,1);dom.setAttrib(n,'mce_new','');}});s.moveToBookmark(b);},queryStateJustify:function(c,v){var ed=this.editor,n=ed.selection.getNode(),dom=ed.dom;if(n&&n.nodeName=='IMG'){if(dom.getStyle(n,'float')==v)return 1;return n.parentNode.style.textAlign==v;}n=dom.getParent(ed.selection.getStart(),function(n){return n.nodeType==1&&n.style.textAlign;});if(v=='full')v='justify';if(ed.settings.inline_styles)return(n&&n.style.textAlign==v);return this._queryState(c);},ForeColor:function(ui,v){var ed=this.editor;if(ed.settings.convert_fonts_to_spans){this._applyInlineStyle('span',{style:{color:v}});return;}else ed.getDoc().execCommand('ForeColor',false,v);},HiliteColor:function(ui,val){var t=this,ed=t.editor,d=ed.getDoc();if(ed.settings.convert_fonts_to_spans){this._applyInlineStyle('span',{style:{backgroundColor:val}});return;}function set(s){if(!isGecko)return;try{d.execCommand("styleWithCSS",0,s);}catch(ex){d.execCommand("useCSS",0,!s);}};if(isGecko||isOpera){set(true);d.execCommand('hilitecolor',false,val);set(false);}else d.execCommand('BackColor',false,val);},Undo:function(){var ed=this.editor;if(ed.settings.custom_undo_redo){ed.undoManager.undo();ed.nodeChanged();}else ed.getDoc().execCommand('Undo',false,null);},Redo:function(){var ed=this.editor;if(ed.settings.custom_undo_redo){ed.undoManager.redo();ed.nodeChanged();}else ed.getDoc().execCommand('Redo',false,null);},FormatBlock:function(ui,val){var t=this,ed=t.editor,s=ed.selection,dom=ed.dom,bl,nb,b;function isBlock(n){return/^(P|DIV|H[1-6]|ADDRESS|BLOCKQUOTE|PRE)$/.test(n.nodeName);};bl=dom.getParent(s.getNode(),function(n){return isBlock(n);});if(bl){if((isIE&&isBlock(bl.parentNode))||bl.nodeName=='DIV'){nb=ed.dom.create(val);each(dom.getAttribs(bl),function(v){dom.setAttrib(nb,v.nodeName,dom.getAttrib(bl,v.nodeName));});b=s.getBookmark();dom.replace(nb,bl,1);s.moveToBookmark(b);ed.nodeChanged();return;}}val=ed.settings.forced_root_block?(val||'<p>'):val;if(val.indexOf('<')==-1)val='<'+val+'>';if(tinymce.isGecko)val=val.replace(/<(div|blockquote|code|dt|dd|dl|samp)>/gi,'$1');ed.getDoc().execCommand('FormatBlock',false,val);},mceCleanup:function(){var ed=this.editor,s=ed.selection,b=s.getBookmark();ed.setContent(ed.getContent());s.moveToBookmark(b);},mceRemoveNode:function(ui,val){var ed=this.editor,s=ed.selection,b,n=val||s.getNode();if(n==ed.getBody())return;b=s.getBookmark();ed.dom.remove(n,1);s.moveToBookmark(b);ed.nodeChanged();},mceSelectNodeDepth:function(ui,val){var ed=this.editor,s=ed.selection,c=0;ed.dom.getParent(s.getNode(),function(n){if(n.nodeType==1&&c++==val){s.select(n);ed.nodeChanged();return false;}},ed.getBody());},mceSelectNode:function(u,v){this.editor.selection.select(v);},mceInsertContent:function(ui,val){this.editor.selection.setContent(val);},mceInsertRawHTML:function(ui,val){var ed=this.editor;ed.selection.setContent('tiny_mce_marker');ed.setContent(ed.getContent().replace(/tiny_mce_marker/g,val));},mceRepaint:function(){var s,b,e=this.editor;if(tinymce.isGecko){try{s=e.selection;b=s.getBookmark(true);if(s.getSel())s.getSel().selectAllChildren(e.getBody());s.collapse(true);s.moveToBookmark(b);}catch(ex){}}},queryStateUnderline:function(){var ed=this.editor,n=ed.selection.getNode();if(n&&n.nodeName=='A')return false;return this._queryState('Underline');},queryStateOutdent:function(){var ed=this.editor,n;if(ed.settings.inline_styles){if((n=ed.dom.getParent(ed.selection.getStart(),ed.dom.isBlock))&&parseInt(n.style.paddingLeft)>0)return true;if((n=ed.dom.getParent(ed.selection.getEnd(),ed.dom.isBlock))&&parseInt(n.style.paddingLeft)>0)return true;}return this.queryStateInsertUnorderedList()||this.queryStateInsertOrderedList()||(!ed.settings.inline_styles&&!!ed.dom.getParent(ed.selection.getNode(),'BLOCKQUOTE'));},queryStateInsertUnorderedList:function(){return this.editor.dom.getParent(this.editor.selection.getNode(),'UL');},queryStateInsertOrderedList:function(){return this.editor.dom.getParent(this.editor.selection.getNode(),'OL');},queryStatemceBlockQuote:function(){return!!this.editor.dom.getParent(this.editor.selection.getStart(),function(n){return n.nodeName==='BLOCKQUOTE';});},mceBlockQuote:function(){var t=this,ed=t.editor,s=ed.selection,dom=ed.dom,sb,eb,n,bm,bq,r,bq2,i,nl;function getBQ(e){return dom.getParent(e,function(n){return n.nodeName==='BLOCKQUOTE';});};sb=dom.getParent(s.getStart(),isBlock);eb=dom.getParent(s.getEnd(),isBlock);if(bq=getBQ(sb)){if(sb!=eb||sb.childNodes.length>1||(sb.childNodes.length==1&&sb.firstChild.nodeName!='BR'))bm=s.getBookmark();if(getBQ(eb)){bq2=bq.cloneNode(false);while(n=eb.nextSibling)bq2.appendChild(n.parentNode.removeChild(n));}if(bq2)dom.insertAfter(bq2,bq);nl=t._getSelectedBlocks(sb,eb);for(i=nl.length-1;i>=0;i--){dom.insertAfter(nl[i],bq);}if(/^\s*$/.test(bq.innerHTML))dom.remove(bq,1);if(bq2&&/^\s*$/.test(bq2.innerHTML))dom.remove(bq2,1);if(!bm){if(!isIE){r=ed.getDoc().createRange();r.setStart(sb,0);r.setEnd(sb,0);s.setRng(r);}else{s.select(sb);s.collapse(0);if(dom.getParent(s.getStart(),isBlock)!=sb){r=s.getRng();r.move('character',-1);r.select();}}}else t.editor.selection.moveToBookmark(bm);return;}if(isIE&&!sb&&!eb){t.editor.getDoc().execCommand('Indent');n=getBQ(s.getNode());n.style.margin=n.dir='';return;}if(!sb||!eb)return;if(sb!=eb||sb.childNodes.length>1||(sb.childNodes.length==1&&sb.firstChild.nodeName!='BR'))bm=s.getBookmark();each(t._getSelectedBlocks(getBQ(s.getStart()),getBQ(s.getEnd())),function(e){if(e.nodeName=='BLOCKQUOTE'&&!bq){bq=e;return;}if(!bq){bq=dom.create('blockquote');e.parentNode.insertBefore(bq,e);}if(e.nodeName=='BLOCKQUOTE'&&bq){n=e.firstChild;while(n){bq.appendChild(n.cloneNode(true));n=n.nextSibling;}dom.remove(e);return;}bq.appendChild(dom.remove(e));});if(!bm){if(!isIE){r=ed.getDoc().createRange();r.setStart(sb,0);r.setEnd(sb,0);s.setRng(r);}else{s.select(sb);s.collapse(1);}}else s.moveToBookmark(bm);},_applyInlineStyle:function(na,at,op){var t=this,ed=t.editor,dom=ed.dom,bm,lo={},kh;na=na.toUpperCase();if(op&&op.check_classes&&at['class'])op.check_classes.push(at['class']);function replaceFonts(){var bm;each(dom.select(tinymce.isWebKit&&!tinymce.isAir?'span':'font'),function(n){if(n.style.fontFamily=='mceinline'||n.face=='mceinline'){if(!bm)bm=ed.selection.getBookmark();at._mce_new='1';dom.replace(dom.create(na,at),n,1);}});each(dom.select(na),function(n){if(n.getAttribute('_mce_new')){function removeStyle(n){if(n.nodeType==1){each(at.style,function(v,k){dom.setStyle(n,k,'');});if(at['class']&&n.className&&op){each(op.check_classes,function(c){if(dom.hasClass(n,c))dom.removeClass(n,c);});}}};each(dom.select(na,n),removeStyle);if(n.parentNode&&n.parentNode.nodeType==1&&n.parentNode.childNodes.length==1)removeStyle(n.parentNode);dom.getParent(n.parentNode,function(pn){if(pn.nodeType==1){if(at.style){each(at.style,function(v,k){var sv;if(!lo[k]&&(sv=dom.getStyle(pn,k))){if(sv===v)dom.setStyle(n,k,'');lo[k]=1;}});}if(at['class']&&pn.className&&op){each(op.check_classes,function(c){if(dom.hasClass(pn,c))dom.removeClass(n,c);});}}return false;});n.removeAttribute('_mce_new');}});each(dom.select(na).reverse(),function(n){var c=0;each(dom.getAttribs(n),function(an){if(an.nodeName.substring(0,1)!='_'&&dom.getAttrib(n,an.nodeName)!=''){c++;}});if(c==0)dom.remove(n,1);});ed.selection.moveToBookmark(bm);return!!bm;};ed.focus();ed.getDoc().execCommand('FontName',false,'mceinline');replaceFonts();if(kh=t._applyInlineStyle.keyhandler){ed.onKeyUp.remove(kh);ed.onKeyPress.remove(kh);ed.onKeyDown.remove(kh);ed.onSetContent.remove(t._applyInlineStyle.chandler);}if(ed.selection.isCollapsed()){t._pendingStyles=tinymce.extend(t._pendingStyles||{},at.style);t._applyInlineStyle.chandler=ed.onSetContent.add(function(){delete t._pendingStyles;});t._applyInlineStyle.keyhandler=kh=function(e){if(t._pendingStyles){at.style=t._pendingStyles;delete t._pendingStyles;}if(replaceFonts()){ed.onKeyDown.remove(t._applyInlineStyle.keyhandler);ed.onKeyPress.remove(t._applyInlineStyle.keyhandler);}if(e.type=='keyup')ed.onKeyUp.remove(t._applyInlineStyle.keyhandler);};ed.onKeyDown.add(kh);ed.onKeyPress.add(kh);ed.onKeyUp.add(kh);}else t._pendingStyles=0;},_getSelectedBlocks:function(st,en){var ed=this.editor,dom=ed.dom,s=ed.selection,sb,eb,n,bl=[];sb=dom.getParent(st||s.getStart(),isBlock);eb=dom.getParent(en||s.getEnd(),isBlock);if(sb)bl.push(sb);if(sb&&eb&&sb!=eb){n=sb;while((n=n.nextSibling)&&n!=eb){if(isBlock(n))bl.push(n);}}if(eb&&sb!=eb)bl.push(eb);return bl;}});})();tinymce.create('tinymce.UndoManager',{index:0,data:null,typing:0,UndoManager:function(ed){var t=this,Dispatcher=tinymce.util.Dispatcher;t.editor=ed;t.data=[];t.onAdd=new Dispatcher(this);t.onUndo=new Dispatcher(this);t.onRedo=new Dispatcher(this);},add:function(l){var t=this,i,ed=t.editor,b,s=ed.settings,la;l=l||{};l.content=l.content||ed.getContent({format:'raw',no_events:1});l.content=l.content.replace(/^\s*|\s*$/g,'');la=t.data[t.index>0&&(t.index==0||t.index==t.data.length)?t.index-1:t.index];if(!l.initial&&la&&l.content==la.content)return null;if(s.custom_undo_redo_levels){if(t.data.length>s.custom_undo_redo_levels){for(i=0;i<t.data.length-1;i++)t.data[i]=t.data[i+1];t.data.length--;t.index=t.data.length;}}if(s.custom_undo_redo_restore_selection&&!l.initial)l.bookmark=b=l.bookmark||ed.selection.getBookmark();if(t.index<t.data.length)t.index++;if(t.data.length===0&&!l.initial)return null;t.data.length=t.index+1;t.data[t.index++]=l;if(l.initial)t.index=0;if(t.data.length==2&&t.data[0].initial)t.data[0].bookmark=b;t.onAdd.dispatch(t,l);ed.isNotDirty=0;return l;},undo:function(){var t=this,ed=t.editor,l=l,i;if(t.typing){t.add();t.typing=0;}if(t.index>0){if(t.index==t.data.length&&t.index>1){i=t.index;t.typing=0;if(!t.add())t.index=i;--t.index;}l=t.data[--t.index];ed.setContent(l.content,{format:'raw'});ed.selection.moveToBookmark(l.bookmark);t.onUndo.dispatch(t,l);}return l;},redo:function(){var t=this,ed=t.editor,l=null;if(t.index<t.data.length-1){l=t.data[++t.index];ed.setContent(l.content,{format:'raw'});ed.selection.moveToBookmark(l.bookmark);t.onRedo.dispatch(t,l);}return l;},clear:function(){var t=this;t.data=[];t.index=0;t.typing=0;t.add({initial:true});},hasUndo:function(){return this.index!=0||this.typing;},hasRedo:function(){return this.index<this.data.length-1;}});(function(){var Event,isIE,isGecko,isOpera,each,extend;Event=tinymce.dom.Event;isIE=tinymce.isIE;isGecko=tinymce.isGecko;isOpera=tinymce.isOpera;each=tinymce.each;extend=tinymce.extend;tinymce.create('tinymce.ForceBlocks',{ForceBlocks:function(ed){var t=this,s=ed.settings,elm;t.editor=ed;t.dom=ed.dom;elm=(s.forced_root_block||'p').toLowerCase();s.element=elm.toUpperCase();ed.onPreInit.add(t.setup,t);t.reOpera=new RegExp('(\\u00a0| | )<\/'+elm+'>','gi');t.rePadd=new RegExp('<p( )([^>]+)><\\\/p>|<p( )([^>]+)\\\/>|<p( )([^>]+)>\\s+<\\\/p>|<p><\\\/p>|<p\\\/>|<p>\\s+<\\\/p>'.replace(/p/g,elm),'gi');t.reNbsp2BR1=new RegExp('<p( )([^>]+)>[\\s\\u00a0]+<\\\/p>|<p>[\\s\\u00a0]+<\\\/p>'.replace(/p/g,elm),'gi');t.reNbsp2BR2=new RegExp('<p( )([^>]+)>( | )<\\\/p>|<p>( | )<\\\/p>'.replace(/p/g,elm),'gi');t.reBR2Nbsp=new RegExp('<p( )([^>]+)>\\s*<br \\\/>\\s*<\\\/p>|<p>\\s*<br \\\/>\\s*<\\\/p>'.replace(/p/g,elm),'gi');t.reTrailBr=new RegExp('\\s*<br \\/>\\s*<\\\/p>'.replace(/p/g,elm),'gi');function padd(ed,o){if(isOpera)o.content=o.content.replace(t.reOpera,'</'+elm+'>');o.content=o.content.replace(t.rePadd,'<'+elm+'$1$2$3$4$5$6>\u00a0</'+elm+'>');if(!isIE&&!isOpera&&o.set){o.content=o.content.replace(t.reNbsp2BR1,'<'+elm+'$1$2><br /></'+elm+'>');o.content=o.content.replace(t.reNbsp2BR2,'<'+elm+'$1$2><br /></'+elm+'>');}else{o.content=o.content.replace(t.reBR2Nbsp,'<'+elm+'$1$2>\u00a0</'+elm+'>');o.content=o.content.replace(t.reTrailBr,'</'+elm+'>');}};ed.onBeforeSetContent.add(padd);ed.onPostProcess.add(padd);if(s.forced_root_block){ed.onInit.add(t.forceRoots,t);ed.onSetContent.add(t.forceRoots,t);ed.onBeforeGetContent.add(t.forceRoots,t);}},setup:function(){var t=this,ed=t.editor,s=ed.settings;if(s.forced_root_block){ed.onKeyUp.add(t.forceRoots,t);ed.onPreProcess.add(t.forceRoots,t);}if(s.force_br_newlines){if(isIE){ed.onKeyPress.add(function(ed,e){var n,s=ed.selection;if(e.keyCode==13&&s.getNode().nodeName!='LI'){s.setContent('<br id="__" /> ',{format:'raw'});n=ed.dom.get('__');n.removeAttribute('id');s.select(n);s.collapse();return Event.cancel(e);}});}return;}if(!isIE&&s.force_p_newlines){ed.onKeyPress.add(function(ed,e){if(e.keyCode==13&&!e.shiftKey){if(!t.insertPara(e))Event.cancel(e);}});if(isGecko){ed.onKeyDown.add(function(ed,e){if((e.keyCode==8||e.keyCode==46)&&!e.shiftKey)t.backspaceDelete(e,e.keyCode==8);});}}function ren(rn,na){var ne=ed.dom.create(na);each(rn.attributes,function(a){if(a.specified&&a.nodeValue)ne.setAttribute(a.nodeName.toLowerCase(),a.nodeValue);});each(rn.childNodes,function(n){ne.appendChild(n.cloneNode(true));});rn.parentNode.replaceChild(ne,rn);return ne;};if(isIE&&s.element!='P'){ed.onKeyPress.add(function(ed,e){t.lastElm=ed.selection.getNode().nodeName;});ed.onKeyUp.add(function(ed,e){var bl,sel=ed.selection,n=sel.getNode(),b=ed.getBody();if(b.childNodes.length===1&&n.nodeName=='P'){n=ren(n,s.element);sel.select(n);sel.collapse();ed.nodeChanged();}else if(e.keyCode==13&&!e.shiftKey&&t.lastElm!='P'){bl=ed.dom.getParent(n,'P');if(bl){ren(bl,s.element);ed.nodeChanged();}}});}},find:function(n,t,s){var ed=this.editor,w=ed.getDoc().createTreeWalker(n,4,null,false),c=-1;while(n=w.nextNode()){c++;if(t==0&&n==s)return c;if(t==1&&c==s)return n;}return-1;},forceRoots:function(ed,e){var t=this,ed=t.editor,b=ed.getBody(),d=ed.getDoc(),se=ed.selection,s=se.getSel(),r=se.getRng(),si=-2,ei,so,eo,tr,c=-0xFFFFFF;var nx,bl,bp,sp,le,nl=b.childNodes,i,n,eid;for(i=nl.length-1;i>=0;i--){nx=nl[i];if(nx.nodeType==3||(!t.dom.isBlock(nx)&&nx.nodeType!=8)){if(!bl){if(nx.nodeType!=3||/[^\s]/g.test(nx.nodeValue)){if(si==-2&&r){if(!isIE){if(r.startContainer.nodeType==1&&(n=r.startContainer.childNodes[r.startOffset])&&n.nodeType==1){eid=n.getAttribute("id");n.setAttribute("id","__mce");}else{if(ed.dom.getParent(r.startContainer,function(e){return e===b;})){so=r.startOffset;eo=r.endOffset;si=t.find(b,0,r.startContainer);ei=t.find(b,0,r.endContainer);}}}else{tr=d.body.createTextRange();tr.moveToElementText(b);tr.collapse(1);bp=tr.move('character',c)*-1;tr=r.duplicate();tr.collapse(1);sp=tr.move('character',c)*-1;tr=r.duplicate();tr.collapse(0);le=(tr.move('character',c)*-1)-sp;si=sp-bp;ei=le;}}bl=ed.dom.create(ed.settings.forced_root_block);bl.appendChild(nx.cloneNode(1));nx.parentNode.replaceChild(bl,nx);}}else{if(bl.hasChildNodes())bl.insertBefore(nx,bl.firstChild);else bl.appendChild(nx);}}else bl=null;}if(si!=-2){if(!isIE){bl=b.getElementsByTagName(ed.settings.element)[0];r=d.createRange();if(si!=-1)r.setStart(t.find(b,1,si),so);else r.setStart(bl,0);if(ei!=-1)r.setEnd(t.find(b,1,ei),eo);else r.setEnd(bl,0);if(s){s.removeAllRanges();s.addRange(r);}}else{try{r=s.createRange();r.moveToElementText(b);r.collapse(1);r.moveStart('character',si);r.moveEnd('character',ei);r.select();}catch(ex){}}}else if(!isIE&&(n=ed.dom.get('__mce'))){if(eid)n.setAttribute('id',eid);else n.removeAttribute('id');r=d.createRange();r.setStartBefore(n);r.setEndBefore(n);se.setRng(r);}},getParentBlock:function(n){var d=this.dom;return d.getParent(n,d.isBlock);},insertPara:function(e){var t=this,ed=t.editor,dom=ed.dom,d=ed.getDoc(),se=ed.settings,s=ed.selection.getSel(),r=s.getRangeAt(0),b=d.body;var rb,ra,dir,sn,so,en,eo,sb,eb,bn,bef,aft,sc,ec,n,vp=dom.getViewPort(ed.getWin()),y,ch,car;function isEmpty(n){n=n.innerHTML;n=n.replace(/<(img|hr|table)/gi,'-');n=n.replace(/<[^>]+>/g,'');return n.replace(/[ \t\r\n]+/g,'')=='';};rb=d.createRange();rb.setStart(s.anchorNode,s.anchorOffset);rb.collapse(true);ra=d.createRange();ra.setStart(s.focusNode,s.focusOffset);ra.collapse(true);dir=rb.compareBoundaryPoints(rb.START_TO_END,ra)<0;sn=dir?s.anchorNode:s.focusNode;so=dir?s.anchorOffset:s.focusOffset;en=dir?s.focusNode:s.anchorNode;eo=dir?s.focusOffset:s.anchorOffset;if(sn===en&&/^(TD|TH)$/.test(sn.nodeName)){dom.remove(sn.firstChild);ed.dom.add(sn,se.element,null,'<br />');aft=ed.dom.add(sn,se.element,null,'<br />');r=d.createRange();r.selectNodeContents(aft);r.collapse(1);ed.selection.setRng(r);return false;}if(sn==b&&en==b&&b.firstChild&&ed.dom.isBlock(b.firstChild)){sn=en=sn.firstChild;so=eo=0;rb=d.createRange();rb.setStart(sn,0);ra=d.createRange();ra.setStart(en,0);}sn=sn.nodeName=="HTML"?d.body:sn;sn=sn.nodeName=="BODY"?sn.firstChild:sn;en=en.nodeName=="HTML"?d.body:en;en=en.nodeName=="BODY"?en.firstChild:en;sb=t.getParentBlock(sn);eb=t.getParentBlock(en);bn=sb?sb.nodeName:se.element;if(t.dom.getParent(sb,function(n){return/OL|UL|PRE/.test(n.nodeName);}))return true;if(sb&&(sb.nodeName=='CAPTION'||/absolute|relative|static/gi.test(sb.style.position))){bn=se.element;sb=null;}if(eb&&(eb.nodeName=='CAPTION'||/absolute|relative|static/gi.test(eb.style.position))){bn=se.element;eb=null;}if(/(TD|TABLE|TH|CAPTION)/.test(bn)||(sb&&bn=="DIV"&&/left|right/gi.test(sb.style.cssFloat))){bn=se.element;sb=eb=null;}bef=(sb&&sb.nodeName==bn)?sb.cloneNode(0):ed.dom.create(bn);aft=(eb&&eb.nodeName==bn)?eb.cloneNode(0):ed.dom.create(bn);aft.removeAttribute('id');if(/^(H[1-6])$/.test(bn)&&sn.nodeValue&&so==sn.nodeValue.length)aft=ed.dom.create(se.element);n=sc=sn;do{if(n==b||n.nodeType==9||t.dom.isBlock(n)||/(TD|TABLE|TH|CAPTION)/.test(n.nodeName))break;sc=n;}while((n=n.previousSibling?n.previousSibling:n.parentNode));n=ec=en;do{if(n==b||n.nodeType==9||t.dom.isBlock(n)||/(TD|TABLE|TH|CAPTION)/.test(n.nodeName))break;ec=n;}while((n=n.nextSibling?n.nextSibling:n.parentNode));if(sc.nodeName==bn)rb.setStart(sc,0);else rb.setStartBefore(sc);rb.setEnd(sn,so);bef.appendChild(rb.cloneContents()||d.createTextNode(''));try{ra.setEndAfter(ec);}catch(ex){}ra.setStart(en,eo);aft.appendChild(ra.cloneContents()||d.createTextNode(''));r=d.createRange();if(!sc.previousSibling&&sc.parentNode.nodeName==bn){r.setStartBefore(sc.parentNode);}else{if(rb.startContainer.nodeName==bn&&rb.startOffset==0)r.setStartBefore(rb.startContainer);else r.setStart(rb.startContainer,rb.startOffset);}if(!ec.nextSibling&&ec.parentNode.nodeName==bn)r.setEndAfter(ec.parentNode);else r.setEnd(ra.endContainer,ra.endOffset);r.deleteContents();if(isOpera)ed.getWin().scrollTo(0,vp.y);if(bef.firstChild&&bef.firstChild.nodeName==bn)bef.innerHTML=bef.firstChild.innerHTML;if(aft.firstChild&&aft.firstChild.nodeName==bn)aft.innerHTML=aft.firstChild.innerHTML;if(isEmpty(bef))bef.innerHTML='<br />';function appendStyles(e,en){var nl=[],nn,n,i;e.innerHTML='';if(se.keep_styles){n=en;do{if(/^(SPAN|STRONG|B|EM|I|FONT|STRIKE|U)$/.test(n.nodeName)){nn=n.cloneNode(false);dom.setAttrib(nn,'id','');nl.push(nn);}}while(n=n.parentNode);}if(nl.length>0){for(i=nl.length-1,nn=e;i>=0;i--)nn=nn.appendChild(nl[i]);nl[0].innerHTML=isOpera?' ':'<br />';return nl[0];}else e.innerHTML=isOpera?' ':'<br />';};if(isEmpty(aft))car=appendStyles(aft,en);if(isOpera&&parseFloat(opera.version())<9.5){r.insertNode(bef);r.insertNode(aft);}else{r.insertNode(aft);r.insertNode(bef);}aft.normalize();bef.normalize();function first(n){return d.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,false).nextNode()||n;};r=d.createRange();r.selectNodeContents(isGecko?first(car||aft):car||aft);r.collapse(1);s.removeAllRanges();s.addRange(r);y=ed.dom.getPos(aft).y;ch=aft.clientHeight;if(y<vp.y||y+ch>vp.y+vp.h){ed.getWin().scrollTo(0,y<vp.y?y:y-vp.h+25);}return false;},backspaceDelete:function(e,bs){var t=this,ed=t.editor,b=ed.getBody(),n,se=ed.selection,r=se.getRng(),sc=r.startContainer,n,w,tn;if(sc&&ed.dom.isBlock(sc)&&!/^(TD|TH)$/.test(sc.nodeName)&&bs){if(sc.childNodes.length==0||(sc.childNodes.length==1&&sc.firstChild.nodeName=='BR')){n=sc;while((n=n.previousSibling)&&!ed.dom.isBlock(n));if(n){if(sc!=b.firstChild){w=ed.dom.doc.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,false);while(tn=w.nextNode())n=tn;r=ed.getDoc().createRange();r.setStart(n,n.nodeValue?n.nodeValue.length:0);r.setEnd(n,n.nodeValue?n.nodeValue.length:0);se.setRng(r);ed.dom.remove(sc);}return Event.cancel(e);}}}function handler(e){var pr;e=e.target;if(e&&e.parentNode&&e.nodeName=='BR'&&(n=t.getParentBlock(e))){pr=e.previousSibling;Event.remove(b,'DOMNodeInserted',handler);if(pr&&pr.nodeType==3&&/\s+$/.test(pr.nodeValue))return;if(e.previousSibling||e.nextSibling)ed.dom.remove(e);}};Event._add(b,'DOMNodeInserted',handler);window.setTimeout(function(){Event._remove(b,'DOMNodeInserted',handler);},1);}});})();(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,each=tinymce.each,extend=tinymce.extend;tinymce.create('tinymce.ControlManager',{ControlManager:function(ed,s){var t=this,i;s=s||{};t.editor=ed;t.controls={};t.onAdd=new tinymce.util.Dispatcher(t);t.onPostRender=new tinymce.util.Dispatcher(t);t.prefix=s.prefix||ed.id+'_';t._cls={};t.onPostRender.add(function(){each(t.controls,function(c){c.postRender();});});},get:function(id){return this.controls[this.prefix+id]||this.controls[id];},setActive:function(id,s){var c=null;if(c=this.get(id))c.setActive(s);return c;},setDisabled:function(id,s){var c=null;if(c=this.get(id))c.setDisabled(s);return c;},add:function(c){var t=this;if(c){t.controls[c.id]=c;t.onAdd.dispatch(c,t);}return c;},createControl:function(n){var c,t=this,ed=t.editor;each(ed.plugins,function(p){if(p.createControl){c=p.createControl(n,t);if(c)return false;}});switch(n){case"|":case"separator":return t.createSeparator();}if(!c&&ed.buttons&&(c=ed.buttons[n]))return t.createButton(n,c);return t.add(c);},createDropMenu:function(id,s,cc){var t=this,ed=t.editor,c,bm,v,cls;s=extend({'class':'mceDropDown',constrain:ed.settings.constrain_menus},s);s['class']=s['class']+' '+ed.getParam('skin')+'Skin';if(v=ed.getParam('skin_variant'))s['class']+=' '+ed.getParam('skin')+'Skin'+v.substring(0,1).toUpperCase()+v.substring(1);id=t.prefix+id;cls=cc||t._cls.dropmenu||tinymce.ui.DropMenu;c=t.controls[id]=new cls(id,s);c.onAddItem.add(function(c,o){var s=o.settings;s.title=ed.getLang(s.title,s.title);if(!s.onclick){s.onclick=function(v){ed.execCommand(s.cmd,s.ui||false,s.value);};}});ed.onRemove.add(function(){c.destroy();});if(tinymce.isIE){c.onShowMenu.add(function(){bm=ed.selection.getBookmark(1);});c.onHideMenu.add(function(){if(bm)ed.selection.moveToBookmark(bm);});}return t.add(c);},createListBox:function(id,s,cc){var t=this,ed=t.editor,cmd,c,cls;if(t.get(id))return null;s.title=ed.translate(s.title);s.scope=s.scope||ed;if(!s.onselect){s.onselect=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};}s=extend({title:s.title,'class':'mce_'+id,scope:s.scope,control_manager:t},s);id=t.prefix+id;if(ed.settings.use_native_selects)c=new tinymce.ui.NativeListBox(id,s);else{cls=cc||t._cls.listbox||tinymce.ui.ListBox;c=new cls(id,s);}t.controls[id]=c;if(tinymce.isWebKit){c.onPostRender.add(function(c,n){Event.add(n,'mousedown',function(){ed.bookmark=ed.selection.getBookmark('simple');});Event.add(n,'focus',function(){ed.selection.moveToBookmark(ed.bookmark);ed.bookmark=null;});});}if(c.hideMenu)ed.onMouseDown.add(c.hideMenu,c);return t.add(c);},createButton:function(id,s,cc){var t=this,ed=t.editor,o,c,cls;if(t.get(id))return null;s.title=ed.translate(s.title);s.label=ed.translate(s.label);s.scope=s.scope||ed;if(!s.onclick&&!s.menu_button){s.onclick=function(){ed.execCommand(s.cmd,s.ui||false,s.value);};}s=extend({title:s.title,'class':'mce_'+id,unavailable_prefix:ed.getLang('unavailable',''),scope:s.scope,control_manager:t},s);id=t.prefix+id;if(s.menu_button){cls=cc||t._cls.menubutton||tinymce.ui.MenuButton;c=new cls(id,s);ed.onMouseDown.add(c.hideMenu,c);}else{cls=t._cls.button||tinymce.ui.Button;c=new cls(id,s);}return t.add(c);},createMenuButton:function(id,s,cc){s=s||{};s.menu_button=1;return this.createButton(id,s,cc);},createSplitButton:function(id,s,cc){var t=this,ed=t.editor,cmd,c,cls;if(t.get(id))return null;s.title=ed.translate(s.title);s.scope=s.scope||ed;if(!s.onclick){s.onclick=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};}if(!s.onselect){s.onselect=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};}s=extend({title:s.title,'class':'mce_'+id,scope:s.scope,control_manager:t},s);id=t.prefix+id;cls=cc||t._cls.splitbutton||tinymce.ui.SplitButton;c=t.add(new cls(id,s));ed.onMouseDown.add(c.hideMenu,c);return c;},createColorSplitButton:function(id,s,cc){var t=this,ed=t.editor,cmd,c,cls,bm;if(t.get(id))return null;s.title=ed.translate(s.title);s.scope=s.scope||ed;if(!s.onclick){s.onclick=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};}if(!s.onselect){s.onselect=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};}s=extend({title:s.title,'class':'mce_'+id,'menu_class':ed.getParam('skin')+'Skin',scope:s.scope,more_colors_title:ed.getLang('more_colors')},s);id=t.prefix+id;cls=cc||t._cls.colorsplitbutton||tinymce.ui.ColorSplitButton;c=new cls(id,s);ed.onMouseDown.add(c.hideMenu,c);ed.onRemove.add(function(){c.destroy();});if(tinymce.isIE){c.onShowMenu.add(function(){bm=ed.selection.getBookmark(1);});c.onHideMenu.add(function(){if(bm){ed.selection.moveToBookmark(bm);bm=0;}});}return t.add(c);},createToolbar:function(id,s,cc){var c,t=this,cls;id=t.prefix+id;cls=cc||t._cls.toolbar||tinymce.ui.Toolbar;c=new cls(id,s);if(t.get(id))return null;return t.add(c);},createSeparator:function(cc){var cls=cc||this._cls.separator||tinymce.ui.Separator;return new cls();},setControlType:function(n,c){return this._cls[n.toLowerCase()]=c;},destroy:function(){each(this.controls,function(c){c.destroy();});this.controls=null;}});})();(function(){var Dispatcher=tinymce.util.Dispatcher,each=tinymce.each,isIE=tinymce.isIE,isOpera=tinymce.isOpera;tinymce.create('tinymce.WindowManager',{WindowManager:function(ed){var t=this;t.editor=ed;t.onOpen=new Dispatcher(t);t.onClose=new Dispatcher(t);t.params={};t.features={};},open:function(s,p){var t=this,f='',x,y,mo=t.editor.settings.dialog_type=='modal',w,sw,sh,vp=tinymce.DOM.getViewPort(),u;s=s||{};p=p||{};sw=isOpera?vp.w:screen.width;sh=isOpera?vp.h:screen.height;s.name=s.name||'mc_'+new Date().getTime();s.width=parseInt(s.width||320);s.height=parseInt(s.height||240);s.resizable=true;s.left=s.left||parseInt(sw/ 2.0) - (s.width /2.0);s.top=s.top||parseInt(sh/ 2.0) - (s.height /2.0);p.inline=false;p.mce_width=s.width;p.mce_height=s.height;p.mce_auto_focus=s.auto_focus;if(mo){if(isIE){s.center=true;s.help=false;s.dialogWidth=s.width+'px';s.dialogHeight=s.height+'px';s.scroll=s.scrollbars||false;}}each(s,function(v,k){if(tinymce.is(v,'boolean'))v=v?'yes':'no';if(!/^(name|url)$/.test(k)){if(isIE&&mo)f+=(f?';':'')+k+':'+v;else f+=(f?',':'')+k+'='+v;}});t.features=s;t.params=p;t.onOpen.dispatch(t,s,p);u=s.url||s.file;if(tinymce.relaxedDomain)u+=(u.indexOf('?')==-1?'?':'&')+'mce_rdomain='+tinymce.relaxedDomain;u=tinymce._addVer(u);try{if(isIE&&mo){w=1;window.showModalDialog(u,window,f);}else w=window.open(u,s.name,f);}catch(ex){}if(!w)alert(t.editor.getLang('popup_blocked'));},close:function(w){w.close();this.onClose.dispatch(this);},createInstance:function(cl,a,b,c,d,e){var f=tinymce.resolve(cl);return new f(a,b,c,d,e);},confirm:function(t,cb,s,w){w=w||window;cb.call(s||this,w.confirm(this._decode(this.editor.getLang(t,t))));},alert:function(tx,cb,s,w){var t=this;w=w||window;w.alert(t._decode(t.editor.getLang(tx,tx)));if(cb)cb.call(s||t);},_decode:function(s){return tinymce.DOM.decode(s).replace(/\\n/g,'\n');}});}());
\ No newline at end of file
+++ /dev/null
-<?php
-// some code below is from:
-/**
- * $Id: tiny_mce_gzip.php 315 2007-10-25 14:03:43Z spocke $
- *
- * @author Moxiecode
- * @copyright Copyright © 2005-2006, Moxiecode Systems AB, All rights reserved.
- *
- * This file compresses the TinyMCE JavaScript using GZip.
- **/
-
-// Discard any buffers
-while ( @ob_end_clean() );
-
-@ require('../../../wp-load.php');
-
-function getFileContents($path) {
-
- if ( function_exists('realpath') )
- $path = realpath($path);
-
- if ( ! $path || ! @is_file($path) )
- return '';
-
- if ( function_exists('file_get_contents') )
- return @file_get_contents($path);
-
- $content = '';
- $fp = @fopen($path, 'r');
- if ( ! $fp )
- return '';
-
- while ( ! feof($fp) )
- $content .= fgets($fp);
-
- fclose($fp);
- return $content;
-}
-
-function putFileContents( $path, $content ) {
- if ( function_exists('file_put_contents') )
- return @file_put_contents( $path, $content );
-
- $newfile = false;
- $fp = @fopen( $path, 'wb' );
- if ($fp) {
- $newfile = fwrite( $fp, $content );
- fclose($fp);
- }
- return $newfile;
-}
-
-// Set up init variables
-$baseurl = includes_url('js/tinymce');
-
-$mce_css = $baseurl . '/wordpress.css';
-$mce_css = apply_filters('mce_css', $mce_css);
-
-$mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1
-
-/*
-The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
-By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
-The + sign marks the default language. More information:
-http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
-*/
-$mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
-
-$plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage' );
-
-/*
-The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'.
-It adds the plugin's name to TinyMCE's plugins init and the call to PluginManager to load the plugin.
-The url should be absolute and should include the js file name to be loaded. Example:
-array( 'myplugin' => 'http://my-site.com/wp-content/plugins/myfolder/mce_plugin.js' )
-If the plugin uses a button, it should be added with one of the "$mce_buttons" filters.
-*/
-$mce_external_plugins = apply_filters('mce_external_plugins', array());
-
-$ext_plugins = "\n";
-if ( ! empty($mce_external_plugins) ) {
-
- /*
- The following filter loads external language files for TinyMCE plugins.
- It takes an associative array 'plugin_name' => 'path', where path is the
- include path to the file. The language file should follow the same format as
- /tinymce/langs/wp-langs.php and should define a variable $strings that
- holds all translated strings. Example:
- $strings = 'tinyMCE.addI18n("' . $mce_locale . '.mypluginname_dlg",{tab_general:"General", ... })';
- */
- $mce_external_languages = apply_filters('mce_external_languages', array());
-
- $loaded_langs = array();
- $strings = '';
-
- if ( ! empty($mce_external_languages) ) {
- foreach ( $mce_external_languages as $name => $path ) {
- if ( is_file($path) && is_readable($path) ) {
- include_once($path);
- $ext_plugins .= $strings;
- $loaded_langs[] = $name;
- }
- }
- }
-
- foreach ( $mce_external_plugins as $name => $url ) {
-
- if ( is_ssl() ) $url = str_replace('http://', 'https://', $url);
-
- $plugins[] = '-' . $name;
-
- if ( in_array($name, $loaded_langs) ) {
- $plugurl = dirname($url);
- $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
- }
- $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
- }
-}
-$plugins = implode($plugins, ',');
-
-$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ));
-$mce_buttons = implode($mce_buttons, ',');
-
-$mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' ));
-$mce_buttons_2 = implode($mce_buttons_2, ',');
-
-$mce_buttons_3 = apply_filters('mce_buttons_3', array());
-$mce_buttons_3 = implode($mce_buttons_3, ',');
-
-$mce_buttons_4 = apply_filters('mce_buttons_4', array());
-$mce_buttons_4 = implode($mce_buttons_4, ',');
-
-$no_captions = ( apply_filters( 'disable_captions', '' ) ) ? true : false;
-
-// TinyMCE init settings
-$initArray = array (
- 'mode' => 'none',
- 'onpageload' => 'wpEditorInit',
- 'width' => '100%',
- 'theme' => 'advanced',
- 'skin' => 'wp_theme',
- 'theme_advanced_buttons1' => "$mce_buttons",
- 'theme_advanced_buttons2' => "$mce_buttons_2",
- 'theme_advanced_buttons3' => "$mce_buttons_3",
- 'theme_advanced_buttons4' => "$mce_buttons_4",
- 'language' => "$mce_locale",
- 'spellchecker_languages' => "$mce_spellchecker_languages",
- 'theme_advanced_toolbar_location' => 'top',
- 'theme_advanced_toolbar_align' => 'left',
- 'theme_advanced_statusbar_location' => 'bottom',
- 'theme_advanced_resizing' => true,
- 'theme_advanced_resize_horizontal' => false,
- 'dialog_type' => 'modal',
- 'relative_urls' => false,
- 'remove_script_host' => false,
- 'convert_urls' => false,
- 'apply_source_formatting' => false,
- 'remove_linebreaks' => true,
- 'paste_convert_middot_lists' => true,
- 'paste_remove_spans' => true,
- 'paste_remove_styles' => true,
- 'gecko_spellcheck' => true,
- 'entities' => '38,amp,60,lt,62,gt',
- 'accessibility_focus' => false,
- 'tab_focus' => ':next',
- 'content_css' => "$mce_css",
- 'save_callback' => 'switchEditors.saveCallback',
- 'wpeditimage_disable_captions' => $no_captions,
- 'plugins' => "$plugins",
- // pass-through the settings for compression and caching, so they can be changed with "tiny_mce_before_init"
- 'disk_cache' => true,
- 'compress' => true,
- 'old_cache_max' => '1' // number of cache files to keep
-);
-
-// For people who really REALLY know what they're doing with TinyMCE
-// You can modify initArray to add, remove, change elements of the config before tinyMCE.init (changed from action to filter)
-$initArray = apply_filters('tiny_mce_before_init', $initArray);
-
-// Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through "tiny_mce_before_init".
-// Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0.
-
-// support for deprecated actions
-ob_start();
-do_action('mce_options');
-$mce_deprecated = ob_get_contents();
-ob_end_clean();
-
-$mce_deprecated = (string) $mce_deprecated;
-if ( strlen( $mce_deprecated ) < 10 || ! strpos( $mce_deprecated, ':' ) || ! strpos( $mce_deprecated, ',' ) )
- $mce_deprecated = '';
-
-// Settings for the gzip compression and cache
-$disk_cache = ( ! isset($initArray['disk_cache']) || false == $initArray['disk_cache'] ) ? false : true;
-$compress = ( ! isset($initArray['compress']) || false == $initArray['compress'] ) ? false : true;
-$old_cache_max = ( isset($initArray['old_cache_max']) ) ? (int) $initArray['old_cache_max'] : 0;
-
-$initArray['disk_cache'] = $initArray['compress'] = $initArray['old_cache_max'] = null;
-unset( $initArray['disk_cache'], $initArray['compress'], $initArray['old_cache_max'] );
-
-// Anybody still using IE5/5.5? It can't handle gzip compressed js well.
-if ( $msie = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) {
- $ie_ver = (int) substr( $_SERVER['HTTP_USER_AGENT'] , $msie + 5, 3 );
- if ( $ie_ver && $ie_ver < 6 ) $compress = false;
-}
-
-// Cache path, this is where the .gz files will be stored
-$cache_path = WP_CONTENT_DIR . '/uploads/js_cache';
-if ( $disk_cache && ! is_dir($cache_path) )
- $disk_cache = wp_mkdir_p($cache_path);
-
-$cache_ext = '.js';
-$plugins = explode( ',', $initArray['plugins'] );
-$theme = ( 'simple' == $initArray['theme'] ) ? 'simple' : 'advanced';
-$language = ( isset($initArray['language']) && ! empty($initArray['language']) ) ? substr( $initArray['language'], 0, 2 ) : 'en';
-$cacheKey = $mce_options = '';
-
-// Check if browser supports gzip
-if ( $compress && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
- if ( ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') || isset($_SERVER['---------------']) ) && function_exists('gzencode') && ! ini_get('zlib.output_compression') ) {
- $cache_ext = '.gz';
- }
-}
-
-// Setup cache info
-if ( $disk_cache ) {
-
- $cacheKey = apply_filters('tiny_mce_version', '20080810');
-
- foreach ( $initArray as $v )
- $cacheKey .= $v;
-
- if ( ! empty($mce_external_plugins) ) {
- foreach ( $mce_external_plugins as $n => $v )
- $cacheKey .= $n;
- }
-
- $cacheKey = md5( $cacheKey );
- $cache_file = $cache_path . '/tinymce_' . $cacheKey . $cache_ext;
-}
-
-$expiresOffset = 864000; // 10 days
-header( 'Content-Type: application/x-javascript; charset=UTF-8' );
-header( 'Vary: Accept-Encoding' ); // Handle proxies
-header( 'Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . ' GMT' );
-
-// Use cached file if exists
-if ( $disk_cache && is_file($cache_file) && is_readable($cache_file) ) {
-
- $mtime = gmdate("D, d M Y H:i:s", filemtime($cache_file)) . " GMT";
-
- if ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $mtime ) {
- header('HTTP/1.1 304 Not Modified');
- exit;
- }
- header("Last-Modified: " . $mtime);
- header("Cache-Control: must-revalidate", false);
-
- $content = getFileContents( $cache_file );
-
- if ( '.gz' == $cache_ext )
- header( 'Content-Encoding: gzip' );
-
- echo $content;
- exit;
-}
-
-foreach ( $initArray as $k => $v )
- $mce_options .= $k . ':"' . $v . '",';
-
-if ( $mce_deprecated ) $mce_options .= $mce_deprecated;
-
-$mce_options = rtrim( trim($mce_options), '\n\r,' );
-
-$content = 'var tinyMCEPreInit = { settings : { themes : "' . $theme . '", plugins : "' . $initArray['plugins'] . '", languages : "' . $language . '", debug : false }, base : "' . $baseurl . '", suffix : "", query : "ver=311" };';
-
-// Load patch
-$content .= getFileContents( 'tiny_mce_ext.js' );
-
-// Add core
-$content .= getFileContents( 'tiny_mce.js' );
-
-// Patch loading functions
-$content .= 'tinyMCEPreInit.start();';
-
-// Add all languages (WP)
-include_once( dirname(__FILE__).'/langs/wp-langs.php' );
-$content .= $strings;
-
-// Add themes
-$content .= getFileContents( 'themes/' . $theme . '/editor_template.js' );
-
-// Add plugins
-foreach ( $plugins as $plugin )
- $content .= getFileContents( 'plugins/' . $plugin . '/editor_plugin.js' );
-
-// Add external plugins and init
-$content .= $ext_plugins . 'tinyMCE.init({' . $mce_options . '});';
-
-// Generate GZIP'd content
-if ( '.gz' == $cache_ext ) {
- header('Content-Encoding: gzip');
- $content = gzencode( $content, 9, FORCE_GZIP );
-}
-
-// Stream to client
-echo $content;
-
-// Write file
-if ( '' != $cacheKey && is_dir($cache_path) && is_readable($cache_path) ) {
-
- $old_cache = array();
- $handle = opendir($cache_path);
- while ( false !== ( $file = readdir($handle) ) ) {
- if ( $file == '.' || $file == '..' ) continue;
- $saved = filectime("$cache_path/$file");
- if ( strpos($file, 'tinymce_') !== false && substr($file, -3) == $cache_ext ) $old_cache["$saved"] = $file;
- }
- closedir($handle);
-
- krsort($old_cache);
- if ( 1 >= $old_cache_max ) $del_cache = $old_cache;
- else $del_cache = array_slice( $old_cache, ($old_cache_max - 1) );
-
- foreach ( $del_cache as $key )
- @unlink("$cache_path/$key");
-
- putFileContents( $cache_file, $content );
-}
-
-?>
\ No newline at end of file
+++ /dev/null
-tinyMCEPreInit.start = function() {
- var t = this, each = tinymce.each, s = t.settings, sl = tinymce.ScriptLoader, ln = s.languages, th = s.themes;
-
- function load(u, sp) {
- var o;
-
- if (!sp)
- u = t.base + u;
-
- o = {url : u, state : 2};
- sl.queue.push(o);
- sl.lookup[o.url] = o;
- };
-
- sl.markDone(t.base + '/langs/' + ln + '.js');
-
- load('/themes/' + th + '/editor_template' + t.suffix + '.js');
- sl.markDone(t.base + '/themes/' + th + '/langs/' + ln + '.js');
- sl.markDone(t.base + '/themes/' + th + '/langs/' + ln + '_dlg.js');
-
- each(s.plugins.split(','), function(n) {
- if (n && n.charAt(0) != '-') {
- load('/plugins/' + n + '/editor_plugin' + t.suffix + '.js');
-
- sl.markDone(t.base + '/plugins/' + n + '/langs/' + ln + '.js');
- sl.markDone(t.base + '/plugins/' + n + '/langs/' + ln + '_dlg.js');
- }
- });
-};
-tinyMCEPreInit.load_ext = function(url,lang) {
- var sl = tinymce.ScriptLoader;
-
- sl.markDone(url + '/langs/' + lang + '.js');
- sl.markDone(url + '/langs/' + lang + '_dlg.js');
-};
tinyMCE = w.tinyMCE;
t.editor = tinymce.EditorManager.activeEditor;
t.params = t.editor.windowManager.params;
+ t.features = t.editor.windowManager.features;
// Setup local DOM
t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
- t.dom.loadCSS(t.editor.settings.popup_css);
+
+ // Enables you to skip loading the default css
+ if (t.features.popup_css !== false)
+ t.dom.loadCSS(t.features.popup_css || t.editor.settings.popup_css);
// Setup on init listeners
t.listeners = [];
this.editor.execCallback('file_browser_callback', element_id, document.getElementById(element_id).value, type, window);
},
+ confirm : function(t, cb, s) {
+ this.editor.windowManager.confirm(t, cb, s, window);
+ },
+
+ alert : function(tx, cb, s) {
+ this.editor.windowManager.alert(tx, cb, s, window);
+ },
+
close : function() {
var t = this;
},*/
_onDOMLoaded : function() {
- var t = this, ti = document.title, bm, h;
+ var t = this, ti = document.title, bm, h, nv;
// Translate page
- h = document.body.innerHTML;
+ if (t.features.translate_i18n !== false) {
+ h = document.body.innerHTML;
- // Replace a=x with a="x" in IE
- if (tinymce.isIE)
- h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
+ // Replace a=x with a="x" in IE
+ if (tinymce.isIE)
+ h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
+
+ document.dir = t.editor.getParam('directionality','');
+
+ if ((nv = t.editor.translate(h)) && nv != h)
+ document.body.innerHTML = nv;
+
+ if ((nv = t.editor.translate(ti)) && nv != ti)
+ document.title = ti = nv;
+ }
- document.dir = t.editor.getParam('directionality','');
- document.body.innerHTML = t.editor.translate(h);
- document.title = ti = t.editor.translate(ti);
document.body.style.display = '';
// Restore selection in IE when focus is placed on a non textarea or input element of the type text
/* This file contains the CSS data for the editable area(iframe) of TinyMCE */
+html {
+ background-color: #fff;
+}
.aligncenter,
dl.aligncenter {
margin: 0;
}
+img.wpGallery {
+ border: 1px dotted #cc0000;
+ background: #ffffcc url("plugins/wpgallery/img/gallery.png") no-repeat scroll center center;
+ width: 99%;
+ height: 250px;
+}
+
body.mceContentBody {
- background: #fff;
- color: #000;
- font: 13px/19px "Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;
+ font: 13px/19px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
padding: 0.6em;
margin: 0;
}
-<?php require_once('../../../wp-load.php');
+<?php
+/**
+ * @package TinyMCE
+ * @author Moxiecode
+ * @copyright Copyright © 2005-2006, Moxiecode Systems AB, All rights reserved.
+ */
+
+/** @ignore */
+require_once('../../../wp-load.php');
header('Content-Type: text/html; charset=' . get_bloginfo('charset'));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php _e('Rich Editor Help') ?></title>
-<script type="text/javascript" src="tiny_mce_popup.js?ver=311"></script>
-<?php
+<script type="text/javascript" src="tiny_mce_popup.js?ver=321"></script>
+<?php
wp_admin_css( 'global', true );
wp_admin_css( 'wp-admin', true );
?>
#wphead {
font-size: 80%;
border-top: 0;
- color:#555;
- background-color: #e4f2fd;
+ color: #555;
+ background-color: #f1f1f1;
}
#wphead h1 {
- font-size: 32px;
+ font-size: 24px;
color: #555;
margin: 0;
padding: 10px;
}
- #adminmenu {
- padding-top: 2px;
- padding-left: 15px;
- background-color: #e4f2fd;
- border-color: #C6D9E9;
+ #tabs {
+ padding: 15px 15px 3px;
+ background-color: #f1f1f1;
+ border-bottom: 1px solid #dfdfdf;
+ }
+ #tabs li {
+ display: inline;
}
- #adminmenu a.current {
+ #tabs a.current {
background-color: #fff;
- border-color: #c6d9e9;
+ border-color: #dfdfdf;
border-bottom-color: #fff;
color: #d54e21;
}
- #adminmenu a {
+ #tabs a {
color: #2583AD;
padding: 6px;
- border-width: 1px;
+ border-width: 1px 1px 0;
border-style: solid solid none;
- border-color: #E4F2FD;
+ border-color: #f1f1f1;
+ text-decoration: none;
}
- #adminmenu a:hover {
+ #tabs a:hover {
color: #d54e21;
}
.wrap h2 {
- border-bottom-color:#DADADA;
- color:#666666;
- margin: 12px 0;
+ border-bottom-color: #dfdfdf;
+ color: #555;
+ margin: 5px 0;
padding: 0;
+ font-size: 18px;
}
#user_info {
right: 5%;
}
h3 {
font-size: 1.1em;
- margin-top: 20px;
+ margin-top: 10px;
margin-bottom: 0px;
}
#flipper {
margin: 0;
padding: 5px 20px 10px;
background-color: #fff;
- border-left: 1px solid #c6d9e9;
- border-bottom: 1px solid #c6d9e9;
+ border-left: 1px solid #dfdfdf;
+ border-bottom: 1px solid #dfdfdf;
}
* html {
overflow-x: hidden;
}
.top .key {
text-align: center;
- width: 36px;
+ width: 5em;
}
.top .action {
text-align: left;
</style>
<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
<style type="text/css">
- #wphead, #adminmenu {
+ #wphead, #tabs {
padding-left: auto;
padding-right: 15px;
}
</script>
</head>
<body>
-<div class="zerosize"></div>
+
<div id="wphead"><h1><?php echo get_bloginfo('blogtitle'); ?></h1></div>
-<ul id="adminmenu">
+<ul id="tabs">
<li><a id="tab1" href="javascript:flipTab(1)" title="<?php _e('Basics of Rich Editing') ?>" accesskey="1" tabindex="1" class="current"><?php _e('Basics') ?></a></li>
<li><a id="tab2" href="javascript:flipTab(2)" title="<?php _e('Advanced use of the Rich Editor') ?>" accesskey="2" tabindex="2"><?php _e('Advanced') ?></a></li>
<li><a id="tab3" href="javascript:flipTab(3)" title="<?php _e('Hotkeys') ?>" accesskey="3" tabindex="3"><?php _e('Hotkeys') ?></a></li>
"<tr><th>6</th><td><?php _e('Header 6') ?></td><th>9</th><td><?php _e('Address') ?></td></tr>")
</script>
</table>
-
+
<p><?php _e('The following shortcuts use different access keys: Alt + Shift + letter.') ?></p>
<table class="keys" width="100%" style="border: 0 none;">
<tr class="top"><th class="key center"><?php _e('Letter') ?></th><th class="left"><?php _e('Action') ?></th><th class="key center"><?php _e('Letter') ?></th><th class="left"><?php _e('Action') ?></th></tr>
-wpAjax = jQuery.extend( {
+var wpAjax = jQuery.extend( {
unserialize: function( s ) {
var r = {}; if ( !s ) { return r; }
var q = s.split('?'); if ( q[1] ) { s = q[1]; }
var c = [], cl;
try {
cl = $(e).attr('class') || '';
- cl = cl.match(new RegExp(t+':[A-Za-z0-9:_=-]+'));
+ cl = cl.match(new RegExp(t+':[\\S]+'));
if ( cl ) { c = cl[0].split(':'); }
} catch(r) {}
return c;
},
ajaxDim: function( e, s ) {
+ if ( $(e).parent().css('display') == 'none' ) // Prevent hidden links from being clicked by hotkeys
+ return false;
var list = this; e = $(e); s = s || {};
var cls = wpList.parseClass(e,'dim');
s = wpList.pre.call( list, e, s, 'dim' );
*/
/**
- * You can override this in your my-hacks.php file
- * You can also override this in a plugin file. The
- * my-hacks.php is deprecated in its usage.
+ * You can override this in your my-hacks.php file You can also override this
+ * in a plugin file. The my-hacks.php is deprecated in its usage.
*
* @since 1.2.0
*/
if (!CUSTOM_TAGS) {
/**
- * Kses global for default allowable HTML tags
+ * Kses global for default allowable HTML tags.
+ *
+ * Can be override by using CUSTOM_TAGS constant.
*
- * Can be override by using CUSTOM_TAGS constant
* @global array $allowedposttags
* @since 2.0.0
*/
'u' => array(),
'ul' => array (
'class' => array (),
- 'style' => array (),
+ 'style' => array (),
'type' => array ()),
'ol' => array (
'class' => array (),
'start' => array (),
- 'style' => array (),
+ 'style' => array (),
'type' => array ()),
'var' => array ());
+
/**
- * Kses allowed HTML elements
+ * Kses allowed HTML elements.
*
* @global array $allowedtags
* @since 1.0.0
}
/**
- * wp_kses() - Filters content and keeps only allowable HTML elements.
+ * Filters content and keeps only allowable HTML elements.
*
- * This function makes sure that only the allowed HTML element names,
- * attribute names and attribute values plus only sane HTML entities
- * will occur in $string. You have to remove any slashes from PHP's
- * magic quotes before you call this function.
+ * This function makes sure that only the allowed HTML element names, attribute
+ * names and attribute values plus only sane HTML entities will occur in
+ * $string. You have to remove any slashes from PHP's magic quotes before you
+ * call this function.
*
- * The default allowed protocols are 'http', 'https', 'ftp', 'mailto',
- * 'news', 'irc', 'gopher', 'nntp', 'feed', and finally 'telnet. This
- * covers all common link protocols, except for 'javascript' which
- * should not be allowed for untrusted users.
+ * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news',
+ * 'irc', 'gopher', 'nntp', 'feed', and finally 'telnet. This covers all common
+ * link protocols, except for 'javascript' which should not be allowed for
+ * untrusted users.
*
* @since 1.0.0
*
}
/**
- * wp_kses_hook() - You add any kses hooks here.
+ * You add any kses hooks here.
*
- * There is currently only one kses WordPress hook and it is
- * called here. All parameters are passed to the hooks and
- * expected to recieve a string.
+ * There is currently only one kses WordPress hook and it is called here. All
+ * parameters are passed to the hooks and expected to recieve a string.
*
* @since 1.0.0
*
}
/**
- * wp_kses_version() - This function returns kses' version number.
+ * This function returns kses' version number.
*
* @since 1.0.0
*
- * @return string Version Number
+ * @return string KSES Version Number
*/
function wp_kses_version() {
return '0.2.2';
}
/**
- * wp_kses_split() - Searches for HTML tags, no matter how malformed
+ * Searches for HTML tags, no matter how malformed.
*
* It also matches stray ">" characters.
*
* @return string Content with fixed HTML tags
*/
function wp_kses_split($string, $allowed_html, $allowed_protocols) {
- return preg_replace('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%e',
- "wp_kses_split2('\\1', \$allowed_html, ".'$allowed_protocols)', $string);
+ global $pass_allowed_html, $pass_allowed_protocols;
+ $pass_allowed_html = $allowed_html;
+ $pass_allowed_protocols = $allowed_protocols;
+ return preg_replace_callback('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%',
+ create_function('$match', 'global $pass_allowed_html, $pass_allowed_protocols; return wp_kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols);'), $string);
}
/**
- * wp_kses_split2() - Callback for wp_kses_split for fixing malformed HTML tags
+ * Callback for wp_kses_split for fixing malformed HTML tags.
*
- * This function does a lot of work. It rejects some very malformed things
- * like <:::>. It returns an empty string, if the element isn't allowed (look
- * ma, no strip_tags()!). Otherwise it splits the tag into an element and an
- * attribute list.
+ * This function does a lot of work. It rejects some very malformed things like
+ * <:::>. It returns an empty string, if the element isn't allowed (look ma, no
+ * strip_tags()!). Otherwise it splits the tag into an element and an attribute
+ * list.
*
* After the tag is split into an element and an attribute list, it is run
- * through another filter which will remove illegal attributes and once
- * that is completed, will be returned.
+ * through another filter which will remove illegal attributes and once that is
+ * completed, will be returned.
*
+ * @access private
* @since 1.0.0
* @uses wp_kses_attr()
*
}
/**
- * wp_kses_attr() - Removes all attributes, if none are allowed for this element
+ * Removes all attributes, if none are allowed for this element.
*
* If some are allowed it calls wp_kses_hair() to split them further, and then
* it builds up new HTML code from the data that kses_hair() returns. It also
- * removes "<" and ">" characters, if there are any left. One more thing it
- * does is to check if the tag has a closing XHTML slash, and if it does, it
- * puts one in the returned code as well.
+ * removes "<" and ">" characters, if there are any left. One more thing it does
+ * is to check if the tag has a closing XHTML slash, and if it does, it puts one
+ * in the returned code as well.
*
* @since 1.0.0
*
}
/**
- * wp_kses_hair() - Builds an attribute list from string containing attributes.
+ * Builds an attribute list from string containing attributes.
*
* This function does a lot of work. It parses an attribute list into an array
* with attribute data, and tries to do the right thing even if it gets weird
$attrarr = array ();
$mode = 0;
$attrname = '';
+ $uris = array('xmlns', 'profile', 'href', 'src', 'cite', 'classid', 'codebase', 'data', 'usemap', 'longdesc', 'action');
# Loop through the whole attribute list
if (preg_match('/^"([^"]*)"(\s+|$)/', $attr, $match))
# "value"
{
- $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
+ $thisval = $match[1];
+ if ( in_array($attrname, $uris) )
+ $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
if(FALSE === array_key_exists($attrname, $attrarr)) {
$attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
if (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match))
# 'value'
{
- $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
+ $thisval = $match[1];
+ if ( in_array($attrname, $uris) )
+ $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
if(FALSE === array_key_exists($attrname, $attrarr)) {
$attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n');
if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match))
# value
{
- $thisval = wp_kses_bad_protocol($match[1], $allowed_protocols);
+ $thisval = $match[1];
+ if ( in_array($attrname, $uris) )
+ $thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
if(FALSE === array_key_exists($attrname, $attrarr)) {
$attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
}
/**
- * wp_kses_check_attr_val() - Performs different checks for attribute values.
+ * Performs different checks for attribute values.
*
* The currently implemented checks are "maxlen", "minlen", "maxval", "minval"
* and "valueless" with even more checks to come soon.
}
/**
- * wp_kses_bad_protocol() - Sanitize string from bad protocols
+ * Sanitize string from bad protocols.
*
- * This function removes all non-allowed protocols from the beginning
- * of $string. It ignores whitespace and the case of the letters, and
- * it does understand HTML entities. It does its work in a while loop,
- * so it won't be fooled by a string like "javascript:javascript:alert(57)".
+ * This function removes all non-allowed protocols from the beginning of
+ * $string. It ignores whitespace and the case of the letters, and it does
+ * understand HTML entities. It does its work in a while loop, so it won't be
+ * fooled by a string like "javascript:javascript:alert(57)".
*
* @since 1.0.0
*
}
/**
- * wp_kses_no_null() - Removes any NULL characters in $string.
+ * Removes any NULL characters in $string.
*
* @since 1.0.0
*
}
/**
- * wp_kses_stripslashes() - Strips slashes from in front of quotes
+ * Strips slashes from in front of quotes.
*
- * This function changes the character sequence \" to just "
- * It leaves all other slashes alone. It's really weird, but the
- * quoting from preg_replace(//e) seems to require this.
+ * This function changes the character sequence \" to just ". It leaves all
+ * other slashes alone. It's really weird, but the quoting from
+ * preg_replace(//e) seems to require this.
*
* @since 1.0.0
*
}
/**
- * wp_kses_array_lc() - Goes through an array and changes the keys to all lower case.
+ * Goes through an array and changes the keys to all lower case.
*
* @since 1.0.0
*
function wp_kses_array_lc($inarray) {
$outarray = array ();
- foreach ($inarray as $inkey => $inval) {
+ foreach ( (array) $inarray as $inkey => $inval) {
$outkey = strtolower($inkey);
$outarray[$outkey] = array ();
- foreach ($inval as $inkey2 => $inval2) {
+ foreach ( (array) $inval as $inkey2 => $inval2) {
$outkey2 = strtolower($inkey2);
$outarray[$outkey][$outkey2] = $inval2;
} # foreach $inval
}
/**
- * wp_kses_js_entities() - Removes the HTML JavaScript entities found in early versions of Netscape 4.
+ * Removes the HTML JavaScript entities found in early versions of Netscape 4.
*
* @since 1.0.0
*
}
/**
- * wp_kses_html_error() - Handles parsing errors in wp_kses_hair()
+ * Handles parsing errors in wp_kses_hair().
*
- * The general plan is to remove everything to and including some
- * whitespace, but it deals with quotes and apostrophes as well.
+ * The general plan is to remove everything to and including some whitespace,
+ * but it deals with quotes and apostrophes as well.
*
* @since 1.0.0
*
}
/**
- * wp_kses_bad_protocol_once() - Sanitizes content from bad protocols and other characters
+ * Sanitizes content from bad protocols and other characters.
*
- * This function searches for URL protocols at the beginning of $string,
- * while handling whitespace and HTML entities.
+ * This function searches for URL protocols at the beginning of $string, while
+ * handling whitespace and HTML entities.
*
* @since 1.0.0
*
$string2 = preg_split('/:|:|:/i', $string, 2);
if ( isset($string2[1]) && !preg_match('%/\?%', $string2[0]) )
- $string = wp_kses_bad_protocol_once2($string2[0], $allowed_protocols) . trim($string2[1]);
+ $string = wp_kses_bad_protocol_once2($string2[0]) . trim($string2[1]);
else
- $string = preg_replace_callback('/^((&[^;]*;|[\sA-Za-z0-9])*)'.'(:|:|&#[Xx]3[Aa];)\s*/', create_function('$matches', 'global $_kses_allowed_protocols; return wp_kses_bad_protocol_once2($matches[1], $_kses_allowed_protocols);'), $string);
+ $string = preg_replace_callback('/^((&[^;]*;|[\sA-Za-z0-9])*)'.'(:|:|&#[Xx]3[Aa];)\s*/', 'wp_kses_bad_protocol_once2', $string);
return $string;
}
/**
- * wp_kses_bad_protocol_once2() - Callback for wp_kses_bad_protocol_once() regular expression.
+ * Callback for wp_kses_bad_protocol_once() regular expression.
*
* This function processes URL protocols, checks to see if they're in the
* white-list or not, and returns different data depending on the answer.
*
+ * @access private
* @since 1.0.0
*
- * @param string $string Content to check for bad protocols
- * @param array $allowed_protocols Allowed protocols
+ * @param mixed $matches string or preg_replace_callback() matches array to check for bad protocols
* @return string Sanitized content
*/
-function wp_kses_bad_protocol_once2($string, $allowed_protocols) {
+function wp_kses_bad_protocol_once2($matches) {
+ global $_kses_allowed_protocols;
+
+ if ( is_array($matches) ) {
+ if ( ! isset($matches[1]) || empty($matches[1]) )
+ return '';
+
+ $string = $matches[1];
+ } else {
+ $string = $matches;
+ }
+
$string2 = wp_kses_decode_entities($string);
$string2 = preg_replace('/\s/', '', $string2);
$string2 = wp_kses_no_null($string2);
$string2 = strtolower($string2);
$allowed = false;
- foreach ($allowed_protocols as $one_protocol)
+ foreach ( (array) $_kses_allowed_protocols as $one_protocol)
if (strtolower($one_protocol) == $string2) {
$allowed = true;
break;
}
/**
- * wp_kses_normalize_entities() - Converts and fixes HTML entities
+ * Converts and fixes HTML entities.
*
- * This function normalizes HTML entities. It will convert "AT&T" to the
- * correct "AT&T", ":" to ":", "&#XYZZY;" to "&#XYZZY;"
- * and so on.
+ * This function normalizes HTML entities. It will convert "AT&T" to the correct
+ * "AT&T", ":" to ":", "&#XYZZY;" to "&#XYZZY;" and so on.
*
* @since 1.0.0
*
# Change back the allowed entities in our entity whitelist
$string = preg_replace('/&([A-Za-z][A-Za-z0-9]{0,19});/', '&\\1;', $string);
- $string = preg_replace_callback('/&#0*([0-9]{1,5});/', create_function('$matches', 'return wp_kses_normalize_entities2($matches[1]);'), $string);
- $string = preg_replace('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', '&#\\1\\2;', $string);
+ $string = preg_replace_callback('/&#0*([0-9]{1,5});/', 'wp_kses_normalize_entities2', $string);
+ $string = preg_replace_callback('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', 'wp_kses_normalize_entities3', $string);
return $string;
}
/**
- * wp_kses_normalize_entities2() - Callback for wp_kses_normalize_entities() regular expression
+ * Callback for wp_kses_normalize_entities() regular expression.
*
- * This function helps wp_kses_normalize_entities() to only accept 16 bit
- * values and nothing more for &#number; entities.
+ * This function helps wp_kses_normalize_entities() to only accept 16 bit values
+ * and nothing more for &#number; entities.
*
+ * @access private
* @since 1.0.0
*
- * @param int $i Number encoded entity
+ * @param array $matches preg_replace_callback() matches array
* @return string Correctly encoded entity
*/
-function wp_kses_normalize_entities2($i) {
- return (($i > 65535) ? "&#$i;" : "&#$i;");
+function wp_kses_normalize_entities2($matches) {
+ if ( ! isset($matches[1]) || empty($matches[1]) )
+ return '';
+
+ $i = $matches[1];
+ return ( ( ! valid_unicode($i) ) || ($i > 65535) ? "&#$i;" : "&#$i;" );
}
/**
- * wp_kses_decode_entities() - Convert all entities to their character counterparts.
+ * Callback for wp_kses_normalize_entities() for regular expression.
+ *
+ * This function helps wp_kses_normalize_entities() to only accept valid Unicode
+ * numeric entities in hex form.
*
- * This function decodes numeric HTML entities (A and A). It
- * doesn't do anything with other entities like ä, but we don't need
- * them in the URL protocol whitelisting system anyway.
+ * @access private
+ *
+ * @param array $matches preg_replace_callback() matches array
+ * @return string Correctly encoded entity
+ */
+function wp_kses_normalize_entities3($matches) {
+ if ( ! isset($matches[2]) || empty($matches[2]) )
+ return '';
+
+ $hexchars = $matches[2];
+ return ( ( ! valid_unicode(hexdec($hexchars)) ) ? "&#x$hexchars;" : "&#x$hexchars;" );
+}
+
+/**
+ * Helper function to determine if a Unicode value is valid.
+ *
+ * @param int $i Unicode value
+ * @return bool true if the value was a valid Unicode number
+ */
+function valid_unicode($i) {
+ return ( $i == 0x9 || $i == 0xa || $i == 0xd ||
+ ($i >= 0x20 && $i <= 0xd7ff) ||
+ ($i >= 0xe000 && $i <= 0xfffd) ||
+ ($i >= 0x10000 && $i <= 0x10ffff) );
+}
+
+/**
+ * Convert all entities to their character counterparts.
+ *
+ * This function decodes numeric HTML entities (A and A). It doesn't do
+ * anything with other entities like ä, but we don't need them in the URL
+ * protocol whitelisting system anyway.
*
* @since 1.0.0
*
* @return string Content after decoded entities
*/
function wp_kses_decode_entities($string) {
- $string = preg_replace('/&#([0-9]+);/e', 'chr("\\1")', $string);
- $string = preg_replace('/&#[Xx]([0-9A-Fa-f]+);/e', 'chr(hexdec("\\1"))', $string);
+ $string = preg_replace_callback('/&#([0-9]+);/', create_function('$match', 'return chr($match[1]);'), $string);
+ $string = preg_replace_callback('/&#[Xx]([0-9A-Fa-f]+);/', create_function('$match', 'return chr(hexdec($match[1]));'), $string);
return $string;
}
/**
- * wp_filter_kses() - Sanitize content with allowed HTML Kses rules
+ * Sanitize content with allowed HTML Kses rules.
*
* @since 1.0.0
* @uses $allowedtags
}
/**
- * wp_filter_post_kses() - Sanitize content for allowed HTML tags for post content
+ * Sanitize content for allowed HTML tags for post content.
*
- * Post content refers to the page contents of the 'post' type and not
- * $_POST data from forms.
+ * Post content refers to the page contents of the 'post' type and not $_POST
+ * data from forms.
*
* @since 2.0.0
* @uses $allowedposttags
}
/**
- * wp_filter_nohtml_kses() - Strips all of the HTML in the content
+ * Strips all of the HTML in the content.
*
* @since 2.1.0
*
}
/**
- * kses_init_filters() - Adds all Kses input form content filters
+ * Adds all Kses input form content filters.
+ *
+ * All hooks have default priority. The wp_filter_kses() function is added to
+ * the 'pre_comment_content' and 'title_save_pre' hooks.
*
- * All hooks have default priority. The wp_filter_kses() fucntion
- * is added to the 'pre_comment_content' and 'title_save_pre'
- * hooks. The wp_filter_post_kses() function is added to the
- * 'content_save_pre', 'excerpt_save_pre', and 'content_filtered_save_pre'
- * hooks.
+ * The wp_filter_post_kses() function is added to the 'content_save_pre',
+ * 'excerpt_save_pre', and 'content_filtered_save_pre' hooks.
*
* @since 2.0.0
* @uses add_filter() See description for what functions are added to what hooks.
}
/**
- * kses_remove_filters() - Removes all Kses input form content filters
+ * Removes all Kses input form content filters.
*
- * A quick procedural method to removing all of the filters
- * that kses uses for content in WordPress Loop.
+ * A quick procedural method to removing all of the filters that kses uses for
+ * content in WordPress Loop.
*
- * Does not remove the kses_init() function from 'init' hook
- * (priority is default). Also does not remove kses_init()
- * function from 'set_current_user' hook (priority is also
- * default).
+ * Does not remove the kses_init() function from 'init' hook (priority is
+ * default). Also does not remove kses_init() function from 'set_current_user'
+ * hook (priority is also default).
*
* @since 2.0.6
*/
}
/**
- * kses_init() - Sets up most of the Kses filters for input form content
+ * Sets up most of the Kses filters for input form content.
*
* If you remove the kses_init() function from 'init' hook and
- * 'set_current_user' (priority is default), then none of the
- * Kses filter hooks will be added.
+ * 'set_current_user' (priority is default), then none of the Kses filter hooks
+ * will be added.
*
- * First removes all of the Kses filters in case the current user
- * does not need to have Kses filter the content. If the user does
- * not have unfiltered html capability, then Kses filters are added.
+ * First removes all of the Kses filters in case the current user does not need
+ * to have Kses filter the content. If the user does not have unfiltered html
+ * capability, then Kses filters are added.
*
* @uses kses_remove_filters() Removes the Kses filters
* @uses kses_init_filters() Adds the Kses filters back if the user
*/
/**
- * get_locale() - Gets the current locale
+ * Gets the current locale.
*
- * If the locale is set, then it will filter the locale
- * in the 'locale' filter hook and return the value.
+ * If the locale is set, then it will filter the locale in the 'locale' filter
+ * hook and return the value.
*
- * If the locale is not set already, then the WPLANG
- * constant is used if it is defined. Then it is filtered
- * through the 'locale' filter hook and the value for the
- * locale global set and the locale is returned.
+ * If the locale is not set already, then the WPLANG constant is used if it is
+ * defined. Then it is filtered through the 'locale' filter hook and the value
+ * for the locale global set and the locale is returned.
*
- * The process to get the locale should only be done once
- * but the locale will always be filtered using the
- * 'locale' hook.
+ * The process to get the locale should only be done once but the locale will
+ * always be filtered using the 'locale' hook.
*
* @since 1.5.0
- * @uses apply_filters() Calls 'locale' hook on locale value
- * @uses $locale Gets the locale stored in the global
+ * @uses apply_filters() Calls 'locale' hook on locale value.
+ * @uses $locale Gets the locale stored in the global.
*
- * @return string The locale of the blog or from the 'locale' hook
+ * @return string The locale of the blog or from the 'locale' hook.
*/
function get_locale() {
global $locale;
}
/**
- * translate() - Retrieve the translated text
+ * Retrieve the translated text.
*
- * If the domain is set in the $l10n global, then the text is run
- * through the domain's translate method. After it is passed to
- * the 'gettext' filter hook, along with the untranslated text as
- * the second parameter.
+ * If the domain is set in the $l10n global, then the text is run through the
+ * domain's translate method. After it is passed to the 'gettext' filter hook,
+ * along with the untranslated text as the second parameter.
*
* If the domain is not set, the $text is just returned.
*
* @since 2.2.0
- * @uses $l10n Gets list of domain translated string (gettext_reader) objects
+ * @uses $l10n Gets list of domain translated string (gettext_reader) objects.
* @uses apply_filters() Calls 'gettext' on domain translated text
- * with the untranslated text as second parameter
+ * with the untranslated text as second parameter.
*
- * @param string $text Text to translate
- * @param string $domain Domain to retrieve the translated text
+ * @param string $text Text to translate.
+ * @param string $domain Domain to retrieve the translated text.
* @return string Translated text
*/
function translate($text, $domain = 'default') {
global $l10n;
if (isset($l10n[$domain]))
- return apply_filters('gettext', $l10n[$domain]->translate($text), $text);
+ return apply_filters('gettext', $l10n[$domain]->translate($text), $text, $domain);
else
- return $text;
+ return apply_filters('gettext', $text, $text, $domain);
+}
+
+function before_last_bar( $string ) {
+ $last_bar = strrpos( $string, '|' );
+ if ( false == $last_bar )
+ return $string;
+ else
+ return substr( $string, 0, $last_bar );
}
/**
- * translate_with_context() - Retrieve the translated text and strip context
+ * Retrieve the translated text and strip context.
*
- * If the domain is set in the $l10n global, then the text is run
- * through the domain's translate method. After it is passed to
- * the 'gettext' filter hook, along with the untranslated text as
- * the second parameter.
+ * If the domain is set in the $l10n global, then the text is run through the
+ * domain's translate method. After it is passed to the 'gettext' filter hook,
+ * along with the untranslated text as the second parameter.
*
* If the domain is not set, the $text is just returned.
*
* @param string $domain Domain to retrieve the translated text
* @return string Translated text
*/
-function translate_with_context($text, $domain = 'default') {
- $whole = translate($text, $domain);
- $last_bar = strrpos($whole, '|');
- if ( false == $last_bar ) {
- return $whole;
- } else {
- return substr($whole, 0, $last_bar);
- }
+function translate_with_context( $text, $domain = 'default' ) {
+ return before_last_bar( translate( $text, $domain ) );
+
}
/**
- * __() - Retrieve a translated string
- *
- * __() is a convenience function which retrieves the translated
- * string from the translate().
+ * Retrieves the translated string from the translate().
*
* @see translate() An alias of translate()
* @since 2.1.0
return translate($text, $domain);
}
-// .
/**
- * _e() - Display a translated string
- *
- * _e() is a convenience function which displays the returned
- * translated text from translate().
+ * Displays the returned translated text from translate().
*
* @see translate() Echos returned translate() string
* @since 1.2.0
}
/**
- * _c() - Retrieve context translated string
+ * Retrieve context translated string.
*
- * Quite a few times, there will be collisions with similar
- * translatable text found in more than two places but with
- * different translated context.
+ * Quite a few times, there will be collisions with similar translatable text
+ * found in more than two places but with different translated context.
*
- * In order to use the separate contexts, the _c() function
- * is used and the translatable string uses a pipe ('|')
- * which has the context the string is in.
+ * In order to use the separate contexts, the _c() function is used and the
+ * translatable string uses a pipe ('|') which has the context the string is in.
*
- * When the translated string is returned, it is everything
- * before the pipe, not including the pipe character. If
- * there is no pipe in the translated text then everything
- * is returned.
+ * When the translated string is returned, it is everything before the pipe, not
+ * including the pipe character. If there is no pipe in the translated text then
+ * everything is returned.
*
* @since 2.2.0
*
}
/**
- * __ngettext() - Retrieve the plural or single form based on the amount
+ * Retrieve the plural or single form based on the amount.
*
- * If the domain is not set in the $l10n list, then a comparsion
- * will be made and either $plural or $single parameters returned.
+ * If the domain is not set in the $l10n list, then a comparsion will be made
+ * and either $plural or $single parameters returned.
*
- * If the domain does exist, then the parameters $single, $plural,
- * and $number will first be passed to the domain's ngettext method.
- * Then it will be passed to the 'ngettext' filter hook along with
- * the same parameters. The expected type will be a string.
+ * If the domain does exist, then the parameters $single, $plural, and $number
+ * will first be passed to the domain's ngettext method. Then it will be passed
+ * to the 'ngettext' filter hook along with the same parameters. The expected
+ * type will be a string.
*
* @since 1.2.0
* @uses $l10n Gets list of domain translated string (gettext_reader) objects
}
/**
- * __ngettext_noop() - register plural strings in POT file, but don't translate them
+ * @see __ngettext() An alias of __ngettext
+ *
+ */
+function _n() {
+ $args = func_get_args();
+ return call_user_func_array('__ngettext', $args);
+}
+
+/**
+ * @see _n() A version of _n(), which supports contexts --
+ * strips everything from the translation after the last bar
+ *
+ */
+function _nc( $single, $plural, $number, $domain = 'default' ) {
+ return before_last_bar( __ngettext( $single, $plural, $number, $domain ) );
+}
+
+/**
+ * Register plural strings in POT file, but don't translate them.
*
* Used when you want do keep structures with translatable plural strings and
* use them later.
}
/**
- * load_textdomain() - Loads MO file into the list of domains
+ * @see __ngettext_noop() An alias of __ngettext_noop()
*
- * If the domain already exists, the inclusion will fail. If the
- * MO file is not readable, the inclusion will fail.
+ */
+function _n_noop() {
+ $args = func_get_args();
+ return call_user_func_array('__ngettext_noop', $args);
+}
+
+/**
+ * Loads MO file into the list of domains.
*
- * On success, the mofile will be placed in the $l10n global by
- * $domain and will be an gettext_reader object.
+ * If the domain already exists, the inclusion will fail. If the MO file is not
+ * readable, the inclusion will fail.
+ *
+ * On success, the mofile will be placed in the $l10n global by $domain and will
+ * be an gettext_reader object.
*
* @since 1.5.0
* @uses $l10n Gets list of domain translated string (gettext_reader) objects
}
/**
- * load_default_textdomain() - Loads default translated strings based on locale
+ * Loads default translated strings based on locale.
*
- * Loads the .mo file in WP_LANG_DIR constant path from WordPress root.
- * The translated (.mo) file is named based off of the locale.
+ * Loads the .mo file in WP_LANG_DIR constant path from WordPress root. The
+ * translated (.mo) file is named based off of the locale.
*
* @since 1.5.0
*/
}
/**
- * load_plugin_textdomain() - Loads the plugin's translated strings
+ * Loads the plugin's translated strings.
*
- * If the path is not given then it will be the root of the plugin
- * directory. The .mo file should be named based on the domain with a
- * dash followed by a dash, and then the locale exactly.
+ * If the path is not given then it will be the root of the plugin directory.
+ * The .mo file should be named based on the domain with a dash followed by a
+ * dash, and then the locale exactly.
*
* @since 1.5.0
*
*/
function load_plugin_textdomain($domain, $abs_rel_path = false, $plugin_rel_path = false) {
$locale = get_locale();
-
+
if ( false !== $plugin_rel_path )
$path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/');
else if ( false !== $abs_rel_path)
}
/**
- * load_theme_textdomain() - Includes theme's translated strings for the theme
+ * Loads the theme's translated strings.
*
* If the current locale exists as a .mo file in the theme's root directory, it
* will be included in the translated strings by the $domain.
*
* @param string $domain Unique identifier for retrieving translated strings
*/
-function load_theme_textdomain($domain) {
+function load_theme_textdomain($domain, $path = false) {
$locale = get_locale();
- $mofile = get_template_directory() . "/$locale.mo";
+ $path = ( empty( $path ) ) ? get_template_directory() : $path;
+
+ $mofile = "$path/$locale.mo";
load_textdomain($domain, $mofile);
}
<?php
+/**
+ * WordPress Link Template Functions
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
-
+/**
+ * Display the permalink for the current post.
+ *
+ * @since 1.2.0
+ * @uses apply_filters() Calls 'the_permalink' filter on the permalink string.
+ */
function the_permalink() {
echo apply_filters('the_permalink', get_permalink());
}
-
/**
- * Conditionally adds a trailing slash if the permalink structure
- * has a trailing slash, strips the trailing slash if not
- * @global object Uses $wp_rewrite
- * @param $string string a URL with or without a trailing slash
- * @param $type_of_url string the type of URL being considered (e.g. single, category, etc) for use in the filter
+ * Retrieve trailing slash string, if blog set for adding trailing slashes.
+ *
+ * Conditionally adds a trailing slash if the permalink structure has a trailing
+ * slash, strips the trailing slash if not. The string is passed through the
+ * 'user_trailingslashit' filter. Will remove trailing slash from string, if
+ * blog is not set to have them.
+ *
+ * @since 2.2.0
+ * @uses $wp_rewrite
+ *
+ * @param $string String a URL with or without a trailing slash.
+ * @param $type_of_url String the type of URL being considered (e.g. single, category, etc) for use in the filter.
* @return string
*/
function user_trailingslashit($string, $type_of_url = '') {
return $string;
}
-
+/**
+ * Display permalink anchor for current post.
+ *
+ * The permalink mode title will use the post title for the 'a' element 'id'
+ * attribute. The id mode uses 'post-' with the post ID for the 'id' attribute.
+ *
+ * @since 0.71
+ *
+ * @param string $mode Permalink mode can be either 'title', 'id', or default, which is 'id'.
+ */
function permalink_anchor($mode = 'id') {
global $post;
switch ( strtolower($mode) ) {
}
}
-
-function get_permalink($id = 0, $leavename=false) {
+/**
+ * Retrieve full permalink for current post or post ID.
+ *
+ * @since 1.0.0
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $leavename Optional, defaults to false. Whether to keep post name or page name.
+ * @return string
+ */
+function get_permalink($id = 0, $leavename = false) {
$rewritecode = array(
'%year%',
'%monthnum%',
$leavename? '' : '%pagename%',
);
- $post = &get_post($id);
+ if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter )
+ $post = $id;
+ else
+ $post = &get_post($id);
- if ( empty($post->ID) ) return FALSE;
+ if ( empty($post->ID) ) return false;
if ( $post->post_type == 'page' )
return get_page_link($post->ID, $leavename);
$category = '';
if ( strpos($permalink, '%category%') !== false ) {
$cats = get_the_category($post->ID);
- if ( $cats )
+ if ( $cats ) {
usort($cats, '_usort_terms_by_ID'); // order by ID
- $category = $cats[0]->slug;
- if ( $parent=$cats[0]->parent )
- $category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
-
+ $category = $cats[0]->slug;
+ if ( $parent = $cats[0]->parent )
+ $category = get_category_parents($parent, false, '/', true) . $category;
+ }
// show default category in permalinks, without
// having to assign it explicitly
if ( empty($category) ) {
$default_category = get_category( get_option( 'default_category' ) );
- $category = is_wp_error( $default_category ) ? '' : $default_category->slug;
+ $category = is_wp_error( $default_category ) ? '' : $default_category->slug;
}
}
);
$permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink);
$permalink = user_trailingslashit($permalink, 'single');
- return apply_filters('post_link', $permalink, $post);
+ return apply_filters('post_link', $permalink, $post, $leavename);
} else { // if they're not using the fancy permalink option
$permalink = get_option('home') . '/?p=' . $post->ID;
- return apply_filters('post_link', $permalink, $post);
+ return apply_filters('post_link', $permalink, $post, $leavename);
}
}
-// get permalink from post ID
+/**
+ * Retrieve permalink from post ID.
+ *
+ * @since 1.0.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @param mixed $deprecated Not used.
+ * @return string
+ */
function post_permalink($post_id = 0, $deprecated = '') {
return get_permalink($post_id);
}
-// Respects page_on_front. Use this one.
+/**
+ * Retrieve the permalink for current page or page ID.
+ *
+ * Respects page_on_front. Use this one.
+ *
+ * @since 1.5.0
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $leavename Optional, defaults to false. Whether to keep post name or page name.
+ * @return string
+ */
function get_page_link($id = false, $leavename = false) {
global $post;
return apply_filters('page_link', $link, $id);
}
-// Ignores page_on_front. Internal use only.
+/**
+ * Retrieve the page permalink.
+ *
+ * Ignores page_on_front. Internal use only.
+ *
+ * @since 2.1.0
+ * @access private
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $leavename Optional. Leave name.
+ * @return string
+ */
function _get_page_link( $id = false, $leavename = false ) {
global $post, $wp_rewrite;
return apply_filters( '_get_page_link', $link, $id );
}
+/**
+ * Retrieve permalink for attachment.
+ *
+ * This can be used in the WordPress Loop or outside of it.
+ *
+ * @since 2.0.0
+ *
+ * @param int $id Optional. Post ID.
+ * @return string
+ */
function get_attachment_link($id = false) {
global $post, $wp_rewrite;
return apply_filters('attachment_link', $link, $id);
}
+/**
+ * Retrieve the permalink for the year archives.
+ *
+ * @since 1.5.0
+ *
+ * @param int|bool $year False for current year or year for permalink.
+ * @return string
+ */
function get_year_link($year) {
global $wp_rewrite;
if ( !$year )
}
}
+/**
+ * Retrieve the permalink for the month archives with year.
+ *
+ * @since 1.0.0
+ *
+ * @param bool|int $year False for current year. Integer of year.
+ * @param bool|int $month False for current month. Integer of month.
+ * @return string
+ */
function get_month_link($year, $month) {
global $wp_rewrite;
if ( !$year )
}
}
+/**
+ * Retrieve the permalink for the day archives with year and month.
+ *
+ * @since 1.0.0
+ *
+ * @param bool|int $year False for current year. Integer of year.
+ * @param bool|int $month False for current month. Integer of month.
+ * @param bool|int $day False for current day. Integer of day.
+ * @return string
+ */
function get_day_link($year, $month, $day) {
global $wp_rewrite;
if ( !$year )
}
}
+/**
+ * Retrieve the permalink for the feed type.
+ *
+ * @since 1.5.0
+ *
+ * @param string $feed Optional, defaults to default feed. Feed type.
+ * @return string
+ */
function get_feed_link($feed = '') {
global $wp_rewrite;
return apply_filters('feed_link', $output, $feed);
}
+/**
+ * Retrieve the permalink for the post comments feed.
+ *
+ * @since 2.2.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @param string $feed Optional. Feed type.
+ * @return string
+ */
function get_post_comments_feed_link($post_id = '', $feed = '') {
global $id;
return apply_filters('post_comments_feed_link', $url);
}
-/** post_comments_feed_link() - Output the comment feed link for a post.
+/**
+ * Display the comment feed link for a post.
*
- * Prints out the comment feed link for a post. Link text is placed in the
- * anchor. If no link text is specified, default text is used. If no post ID
- * is specified, the current post is used.
+ * Prints out the comment feed link for a post. Link text is placed in the
+ * anchor. If no link text is specified, default text is used. If no post ID is
+ * specified, the current post is used.
*
* @package WordPress
* @subpackage Feed
- * @since 2.5
+ * @since 2.5.0
*
- * @param string Descriptive text
- * @param int Optional post ID. Default to current post.
- * @return string Link to the comment feed for the current post
+ * @param string $link_text Descriptive text.
+ * @param int $post_id Optional post ID. Default to current post.
+ * @param string $feed Optional. Feed format.
+ * @return string Link to the comment feed for the current post.
*/
function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) {
$url = get_post_comments_feed_link($post_id, $feed);
echo "<a href='$url'>$link_text</a>";
}
+/**
+ * Retrieve the feed link for a given author.
+ *
+ * Returns a link to the feed for all posts by a given author. A specific feed
+ * can be requested or left blank to get the default feed.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.5.0
+ *
+ * @param int $author_id ID of an author.
+ * @param string $feed Optional. Feed type.
+ * @return string Link to the feed for the author specified by $author_id.
+*/
function get_author_feed_link( $author_id, $feed = '' ) {
$author_id = (int) $author_id;
$permalink_structure = get_option('permalink_structure');
$feed = get_default_feed();
if ( '' == $permalink_structure ) {
- $link = get_option('home') . '?feed=rss2&author=' . $author_id;
+ $link = get_option('home') . "?feed=$feed&author=" . $author_id;
} else {
$link = get_author_posts_url($author_id);
- $link = trailingslashit($link) . user_trailingslashit('feed', 'feed');
+ if ( $feed == get_default_feed() )
+ $feed_link = 'feed';
+ else
+ $feed_link = "feed/$feed";
+
+ $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed');
}
- $link = apply_filters('author_feed_link', $link);
+ $link = apply_filters('author_feed_link', $link, $feed);
return $link;
}
-/** get_category_feed_link() - Get the feed link for a given category
+/**
+ * Retrieve the feed link for a category.
*
- * Returns a link to the feed for all post in a given category. A specific feed can be requested
- * or left blank to get the default feed.
+ * Returns a link to the feed for all post in a given category. A specific feed
+ * can be requested or left blank to get the default feed.
*
* @package WordPress
* @subpackage Feed
- * @since 2.5
+ * @since 2.5.0
*
- * @param int $cat_id ID of a category
- * @param string $feed Feed type
- * @return string Link to the feed for the category specified by $cat_id
+ * @param int $cat_id ID of a category.
+ * @param string $feed Optional. Feed type.
+ * @return string Link to the feed for the category specified by $cat_id.
*/
function get_category_feed_link($cat_id, $feed = '') {
$cat_id = (int) $cat_id;
return $link;
}
+/**
+ * Retrieve permalink for feed of tag.
+ *
+ * @since 2.3.0
+ *
+ * @param int $tag_id Tag ID.
+ * @param string $feed Optional. Feed type.
+ * @return string
+ */
function get_tag_feed_link($tag_id, $feed = '') {
$tag_id = (int) $tag_id;
return $link;
}
+/**
+ * Retrieve edit tag link.
+ *
+ * @since 2.7.0
+ *
+ * @param int $tag_id Tag ID
+ * @return string
+ */
+function get_edit_tag_link( $tag_id = 0 ) {
+ $tag = get_term($tag_id, 'post_tag');
+
+ if ( !current_user_can('manage_categories') )
+ return;
+
+ $location = admin_url('edit-tags.php?action=edit&tag_ID=') . $tag->term_id;
+ return apply_filters( 'get_edit_tag_link', $location );
+}
+
+/**
+ * Display or retrieve edit tag link with formatting.
+ *
+ * @since 2.7.0
+ *
+ * @param string $link Optional. Anchor text.
+ * @param string $before Optional. Display before edit link.
+ * @param string $after Optional. Display after edit link.
+ * @param int|object $tag Tag object or ID
+ * @return string|null HTML content, if $echo is set to false.
+ */
+function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) {
+ $tag = get_term($tag, 'post_tag');
+
+ if ( !current_user_can('manage_categories') )
+ return;
+
+ if ( empty($link) )
+ $link = __('Edit This');
+
+ $link = '<a href="' . get_edit_tag_link( $tag->term_id ) . '" title="' . __( 'Edit tag' ) . '">' . $link . '</a>';
+ echo $before . apply_filters( 'edit_tag_link', $link, $tag->term_id ) . $after;
+}
+
+/**
+ * Retrieve the permalink for the feed of the search results.
+ *
+ * @since 2.5.0
+ *
+ * @param string $search_query Optional. Search query.
+ * @param string $feed Optional. Feed type.
+ * @return string
+ */
function get_search_feed_link($search_query = '', $feed = '') {
if ( empty($search_query) )
$search = attribute_escape(get_search_query());
return $link;
}
+/**
+ * Retrieve the permalink for the comments feed of the search results.
+ *
+ * @since 2.5.0
+ *
+ * @param string $search_query Optional. Search query.
+ * @param string $feed Optional. Feed type.
+ * @return string
+ */
function get_search_comments_feed_link($search_query = '', $feed = '') {
if ( empty($search_query) )
$search = attribute_escape(get_search_query());
return $link;
}
+/**
+ * Retrieve edit posts link for post.
+ *
+ * Can be used within the WordPress loop or outside of it. Can be used with
+ * pages, posts, attachments, and revisions.
+ *
+ * @since 2.3.0
+ *
+ * @param int $id Optional. Post ID.
+ * @param string $context Optional, default to display. How to write the '&', defaults to '&'.
+ * @return string
+ */
function get_edit_post_link( $id = 0, $context = 'display' ) {
if ( !$post = &get_post( $id ) )
return;
$var = 'post';
break;
endswitch;
-
+
return apply_filters( 'get_edit_post_link', admin_url("$file.php?{$action}$var=$post->ID"), $post->ID, $context );
}
+/**
+ * Retrieve edit posts link for post.
+ *
+ * @since 1.0.0
+ *
+ * @param string $link Optional. Anchor text.
+ * @param string $before Optional. Display before edit link.
+ * @param string $after Optional. Display after edit link.
+ */
function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) {
global $post;
return;
}
- $link = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . __( 'Edit post' ) . '">' . $link . '</a>';
+ $link = '<a class="post-edit-link" href="' . get_edit_post_link( $post->ID ) . '" title="' . attribute_escape( __( 'Edit post' ) ) . '">' . $link . '</a>';
echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
}
+/**
+ * Retrieve edit comment link.
+ *
+ * @since 2.3.0
+ *
+ * @param int $comment_id Optional. Comment ID.
+ * @return string
+ */
function get_edit_comment_link( $comment_id = 0 ) {
$comment = &get_comment( $comment_id );
$post = &get_post( $comment->comment_post_ID );
return apply_filters( 'get_edit_comment_link', $location );
}
+/**
+ * Display or retrieve edit comment link with formatting.
+ *
+ * @since 1.0.0
+ *
+ * @param string $link Optional. Anchor text.
+ * @param string $before Optional. Display before edit link.
+ * @param string $after Optional. Display after edit link.
+ * @return string|null HTML content, if $echo is set to false.
+ */
function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
global $comment, $post;
return;
}
- $link = '<a href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
+ $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
}
+/**
+ * Display edit bookmark (literally a URL external to blog) link.
+ *
+ * @since 2.7.0
+ *
+ * @param int $link Optional. Bookmark ID.
+ * @return string
+ */
+function get_edit_bookmark_link( $link = 0 ) {
+ $link = get_bookmark( $link );
+
+ if ( !current_user_can('manage_links') )
+ return;
+
+ $location = admin_url('link.php?action=edit&link_id=') . $link->link_id;
+ return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id );
+}
+
+/**
+ * Display edit bookmark (literally a URL external to blog) link anchor content.
+ *
+ * @since 2.7.0
+ *
+ * @param string $link Optional. Anchor text.
+ * @param string $before Optional. Display before edit link.
+ * @param string $after Optional. Display after edit link.
+ * @param int $bookmark Optional. Bookmark ID.
+ */
+function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) {
+ $bookmark = get_bookmark($bookmark);
+
+ if ( !current_user_can('manage_links') )
+ return;
+
+ if ( empty($link) )
+ $link = __('Edit This');
+
+ $link = '<a href="' . get_edit_bookmark_link( $link ) . '" title="' . __( 'Edit link' ) . '">' . $link . '</a>';
+ echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after;
+}
+
// Navigation links
+/**
+ * Retrieve previous post link that is adjacent to current post.
+ *
+ * @since 1.5.0
+ *
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @return string
+ */
function get_previous_post($in_same_cat = false, $excluded_categories = '') {
return get_adjacent_post($in_same_cat, $excluded_categories);
}
+/**
+ * Retrieve next post link that is adjacent to current post.
+ *
+ * @since 1.5.0
+ *
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @return string
+ */
function get_next_post($in_same_cat = false, $excluded_categories = '') {
return get_adjacent_post($in_same_cat, $excluded_categories, false);
}
+/**
+ * Retrieve adjacent post link.
+ *
+ * Can either be next or previous post link.
+ *
+ * @since 2.5.0
+ *
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @param bool $previous Optional. Whether to retrieve previous post.
+ * @return string
+ */
function get_adjacent_post($in_same_cat = false, $excluded_categories = '', $previous = true) {
global $post, $wpdb;
if ( $in_same_cat ) {
$cat_array = wp_get_object_terms($post->ID, 'category', 'fields=ids');
- $join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode($cat_array, ',') . ')';
+ $join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")";
}
$posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'";
return $wpdb->get_row("SELECT p.* FROM $wpdb->posts AS p $join $where $sort");
}
+/**
+ * Display previous post link that is adjacent to the current post.
+ *
+ * @since 1.5.0
+ *
+ * @param string $format Optional. Link anchor format.
+ * @param string $link Optional. Link permalink format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ */
function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
}
+/**
+ * Display next post link that is adjacent to the current post.
+ *
+ * @since 1.5.0
+ *
+ * @param string $format Optional. Link anchor format.
+ * @param string $link Optional. Link permalink format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ */
function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') {
adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
}
+/**
+ * Display adjacent post link.
+ *
+ * Can be either next post link or previous.
+ *
+ * @since 2.5.0
+ *
+ * @param string $format Link anchor format.
+ * @param string $link Link permalink format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @param bool $previous Optional, default is true. Whether display link to previous post.
+ */
function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
if ( $previous && is_attachment() )
$post = & get_post($GLOBALS['post']->post_parent);
$title = $previous ? __('Previous Post') : __('Next Post');
$title = apply_filters('the_title', $title, $post);
+ $date = mysql2date(get_option('date_format'), $post->post_date);
+
$string = '<a href="'.get_permalink($post).'">';
$link = str_replace('%title', $title, $link);
+ $link = str_replace('%date', $date, $link);
$link = $string . $link . '</a>';
$format = str_replace('%link', $link, $format);
echo apply_filters( "{$adjacent}_post_link", $format, $link );
}
+/**
+ * Retrieve get links for page numbers.
+ *
+ * @since 1.5.0
+ *
+ * @param int $pagenum Optional. Page ID.
+ * @return string
+ */
function get_pagenum_link($pagenum = 1) {
global $wp_rewrite;
return $result;
}
+/**
+ * Retrieve next posts pages link.
+ *
+ * Backported from 2.1.3 to 2.0.10.
+ *
+ * @since 2.0.10
+ *
+ * @param int $max_page Optional. Max pages.
+ * @return string
+ */
function get_next_posts_page_link($max_page = 0) {
global $paged;
}
}
-function next_posts($max_page = 0) {
- echo clean_url(get_next_posts_page_link($max_page));
+/**
+ * Display or return the next posts pages link.
+ *
+ * @since 0.71
+ *
+ * @param int $max_page Optional. Max pages.
+ * @param boolean $echo Optional. Echo or return;
+ */
+function next_posts( $max_page = 0, $echo = true ) {
+ $output = clean_url( get_next_posts_page_link( $max_page ) );
+
+ if ( $echo )
+ echo $output;
+ else
+ return $output;
}
-function next_posts_link($label='Next Page »', $max_page=0) {
+/**
+ * Return the next posts pages link.
+ *
+ * @since 2.7.0
+ *
+ * @param string $label Content for link text.
+ * @param int $max_page Optional. Max pages.
+ * @return string|null
+ */
+function get_next_posts_link( $label = 'Next Page »', $max_page = 0 ) {
global $paged, $wp_query;
+
if ( !$max_page ) {
$max_page = $wp_query->max_num_pages;
}
+
if ( !$paged )
$paged = 1;
+
$nextpage = intval($paged) + 1;
- if ( (! is_single()) && (empty($paged) || $nextpage <= $max_page) ) {
- echo '<a href="';
- next_posts($max_page);
- echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
+
+ if ( !is_single() && ( empty($paged) || $nextpage <= $max_page) ) {
+ $attr = apply_filters( 'next_posts_link_attributes', '' );
+ return '<a href="' . next_posts( $max_page, false ) . "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
}
}
+/**
+ * Display the next posts pages link.
+ *
+ * @since 0.71
+ * @uses get_next_posts_link()
+ *
+ * @param string $label Content for link text.
+ * @param int $max_page Optional. Max pages.
+ */
+function next_posts_link( $label = 'Next Page »', $max_page = 0 ) {
+ echo get_next_posts_link( $label, $max_page );
+}
+
+/**
+ * Retrieve previous post pages link.
+ *
+ * Will only return string, if not on a single page or post.
+ *
+ * Backported to 2.0.10 from 2.1.3.
+ *
+ * @since 2.0.10
+ *
+ * @return string|null
+ */
function get_previous_posts_page_link() {
global $paged;
}
}
-function previous_posts() {
- echo clean_url(get_previous_posts_page_link());
+/**
+ * Display or return the previous posts pages link.
+ *
+ * @since 0.71
+ *
+ * @param boolean $echo Optional. Echo or return;
+ */
+function previous_posts( $echo = true ) {
+ $output = clean_url( get_previous_posts_page_link() );
+
+ if ( $echo )
+ echo $output;
+ else
+ return $output;
}
-function previous_posts_link($label='« Previous Page') {
+/**
+ * Return the previous posts pages link.
+ *
+ * @since 2.7.0
+ *
+ * @param string $label Optional. Previous page link text.
+ * @return string|null
+ */
+function get_previous_posts_link( $label = '« Previous Page' ) {
global $paged;
- if ( (!is_single()) && ($paged > 1) ) {
- echo '<a href="';
- previous_posts();
- echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
+
+ if ( !is_single() && $paged > 1 ) {
+ $attr = apply_filters( 'previous_posts_link_attributes', '' );
+ return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/', '&$1', $label ) .'</a>';
}
}
-function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') {
+/**
+ * Display the previous posts page link.
+ *
+ * @since 0.71
+ * @uses get_previous_posts_link()
+ *
+ * @param string $label Optional. Previous page link text.
+ */
+function previous_posts_link( $label = '« Previous Page' ) {
+ echo get_previous_posts_link( $label );
+}
+
+/**
+ * Display post pages link navigation for previous and next pages.
+ *
+ * @since 0.71
+ *
+ * @param string $sep Optional. Separator for posts navigation links.
+ * @param string $prelabel Optional. Label for previous pages.
+ * @param string $nxtlabel Optional Label for next pages.
+ */
+function posts_nav_link( $sep = ' — ', $prelabel = '« Previous Page', $nxtlabel = 'Next Page »' ) {
global $wp_query;
if ( !is_singular() ) {
$max_num_pages = $wp_query->max_num_pages;
}
}
+/**
+ * Retrieve page numbers links.
+ *
+ * @since 2.7.0
+ *
+ * @param int $pagenum Optional. Page number.
+ * @return string
+ */
+function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
+ global $post, $wp_rewrite;
+
+ $pagenum = (int) $pagenum;
+
+ $result = get_permalink( $post->ID );
+
+ if ( 'newest' == get_option('default_comments_page') ) {
+ if ( $pagenum != $max_page ) {
+ if ( $wp_rewrite->using_permalinks() )
+ $result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
+ else
+ $result = add_query_arg( 'cpage', $pagenum, $result );
+ }
+ } elseif ( $pagenum > 1 ) {
+ if ( $wp_rewrite->using_permalinks() )
+ $result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
+ else
+ $result = add_query_arg( 'cpage', $pagenum, $result );
+ }
+
+ $result .= '#comments';
+
+ $result = apply_filters('get_comments_pagenum_link', $result);
+
+ return $result;
+}
+
+/**
+ * Return the link to next comments pages.
+ *
+ * @since 2.7.1
+ *
+ * @param string $label Optional. Label for link text.
+ * @param int $max_page Optional. Max page.
+ * @return string|null
+ */
+function get_next_comments_link( $label = '', $max_page = 0 ) {
+ global $wp_query;
+
+ if ( !is_singular() )
+ return;
+
+ $page = get_query_var('cpage');
+
+ $nextpage = intval($page) + 1;
+
+ if ( empty($max_page) )
+ $max_page = $wp_query->max_num_comment_pages;
+
+ if ( empty($max_page) )
+ $max_page = get_comment_pages_count();
+
+ if ( $nextpage > $max_page )
+ return;
+
+ if ( empty($label) )
+ $label = __('Newer Comments »');
+
+ return '<a href="' . clean_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
+}
+
+/**
+ * Display the link to next comments pages.
+ *
+ * @since 2.7.0
+ *
+ * @param string $label Optional. Label for link text.
+ * @param int $max_page Optional. Max page.
+ */
+function next_comments_link( $label = '', $max_page = 0 ) {
+ echo get_next_comments_link( $label, $max_page );
+}
+
+/**
+ * Return the previous comments page link.
+ *
+ * @since 2.7.1
+ *
+ * @param string $label Optional. Label for comments link text.
+ * @return string|null
+ */
+function get_previous_comments_link( $label = '' ) {
+ if ( !is_singular() )
+ return;
+
+ $page = get_query_var('cpage');
+
+ if ( intval($page) <= 1 )
+ return;
+
+ $prevpage = intval($page) - 1;
+
+ if ( empty($label) )
+ $label = __('« Older Comments');
+
+ return '<a href="' . clean_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
+}
+
+/**
+ * Display the previous comments page link.
+ *
+ * @since 2.7.0
+ *
+ * @param string $label Optional. Label for comments link text.
+ */
+function previous_comments_link( $label = '' ) {
+ echo get_previous_comments_link( $label );
+}
+
+/**
+ * Create pagination links for the comments on the current post.
+ *
+ * @see paginate_links()
+ * @since 2.7.0
+ *
+ * @param string|array $args Optional args. See paginate_links.
+ * @return string Markup for pagination links.
+*/
+function paginate_comments_links($args = array()) {
+ global $wp_query, $wp_rewrite;
+
+ if ( !is_singular() )
+ return;
+
+ $page = get_query_var('cpage');
+ if ( !$page )
+ $page = 1;
+ $max_page = get_comment_pages_count();
+ $defaults = array(
+ 'base' => add_query_arg( 'cpage', '%#%' ),
+ 'format' => '',
+ 'total' => $max_page,
+ 'current' => $page,
+ 'echo' => true,
+ 'add_fragment' => '#comments'
+ );
+ if ( $wp_rewrite->using_permalinks() )
+ $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . 'comment-page-%#%', 'commentpaged');
+
+ $args = wp_parse_args( $args, $defaults );
+ $page_links = paginate_links( $args );
+
+ if ( $args['echo'] )
+ echo $page_links;
+ else
+ return $page_links;
+}
+
+/**
+ * Retrieve shortcut link.
+ *
+ * Use this in 'a' element 'href' attribute.
+ *
+ * @since 2.6.0
+ *
+ * @return string
+ */
function get_shortcut_link() {
$link = "javascript:
var d=document,
e=encodeURIComponent,
g=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=2';
function a(){
- if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=700,height=500')){
+ if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=720,height=570')){
l.href=g;
}
}";
return apply_filters('shortcut_link', $link);
}
-/** Return the site url
+/**
+ * Retrieve the site url.
*
+ * Returns the 'site_url' option with the appropriate protocol, 'https' if
+ * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
+ * overridden.
*
* @package WordPress
- * @since 2.6
- *
- * Returns the 'site_url' option with the appropriate protocol, 'https' if is_ssl() and 'http' otherwise.
- * If $scheme is 'http' or 'https', is_ssl() is overridden.
+ * @since 2.6.0
*
- * @param string $path Optional path relative to the site url
- * @param string $scheme Optional scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'
- * @return string Site url link with optional path appended
+ * @param string $path Optional. Path relative to the site url.
+ * @param string $scheme Optional. Scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'.
+ * @return string Site url link with optional path appended.
*/
function site_url($path = '', $scheme = null) {
// should the list of allowed schemes be maintained elsewhere?
+ $orig_scheme = $scheme;
if ( !in_array($scheme, array('http', 'https')) ) {
if ( ('login_post' == $scheme) && ( force_ssl_login() || force_ssl_admin() ) )
$scheme = 'https';
if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
$url .= '/' . ltrim($path, '/');
- return $url;
+ return apply_filters('site_url', $url, $path, $orig_scheme);
}
-/** Return the admin url
- *
+/**
+ * Retrieve the url to the admin area.
*
* @package WordPress
- * @since 2.6
- *
- * Returns the url to the admin area
+ * @since 2.6.0
*
* @param string $path Optional path relative to the admin url
* @return string Admin url link with optional path appended
return $url;
}
-/** Return the includes url
- *
+/**
+ * Retrieve the url to the includes directory.
*
* @package WordPress
- * @since 2.6
+ * @since 2.6.0
*
- * Returns the url to the includes directory
- *
- * @param string $path Optional path relative to the includes url
- * @return string Includes url link with optional path appended
+ * @param string $path Optional. Path relative to the includes url.
+ * @return string Includes url link with optional path appended.
*/
function includes_url($path = '') {
$url = site_url() . '/' . WPINC . '/';
return $url;
}
-/** Return the content url
- *
+/**
+ * Retrieve the url to the content directory.
*
* @package WordPress
- * @since 2.6
- *
- * Returns the url to the content directory
+ * @since 2.6.0
*
- * @param string $path Optional path relative to the content url
- * @return string Content url link with optional path appended
+ * @param string $path Optional. Path relative to the content url.
+ * @return string Content url link with optional path appended.
*/
function content_url($path = '') {
$scheme = ( is_ssl() ? 'https' : 'http' );
return $url;
}
-/** Return the plugins url
- *
+/**
+ * Retrieve the url to the plugins directory.
*
* @package WordPress
- * @since 2.6
- *
- * Returns the url to the plugins directory
+ * @since 2.6.0
*
- * @param string $path Optional path relative to the plugins url
- * @return string Plugins url link with optional path appended
+ * @param string $path Optional. Path relative to the plugins url.
+ * @return string Plugins url link with optional path appended.
*/
function plugins_url($path = '') {
$scheme = ( is_ssl() ? 'https' : 'http' );
*/
/**
- * {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
+ * Class that loads the calendar locale.
*
* @since 2.1.0
*/
$this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
// Import global locale vars set during inclusion of $locale.php.
- foreach ( $this->locale_vars as $var ) {
+ foreach ( (array) $this->locale_vars as $var ) {
if ( isset($GLOBALS[$var]) )
$this->$var = $GLOBALS[$var];
}
<?php
+/**
+ * WordPress API for media display.
+ *
+ * @package WordPress
+ */
-// functions for media display
-
-// scale down the default size of an image so it's a better fit for the editor and theme
+/**
+ * Scale down the default size of an image.
+ *
+ * This is so that the image is a better fit for the editor and theme.
+ *
+ * The $size parameter accepts either an array or a string. The supported string
+ * values are 'thumb' or 'thumbnail' for the given thumbnail size or defaults at
+ * 128 width and 96 height in pixels. Also supported for the string value is
+ * 'medium' and 'full'. The 'full' isn't actually supported, but any value other
+ * than the supported will result in the content_width size or 500 if that is
+ * not set.
+ *
+ * Finally, there is a filter named, 'editor_max_image_size' that will be called
+ * on the calculated array for width and height, respectively. The second
+ * parameter will be the value that was in the $size parameter. The returned
+ * type for the hook is an array with the width as the first element and the
+ * height as the second element.
+ *
+ * @since 2.5.0
+ * @uses wp_constrain_dimensions() This function passes the widths and the heights.
+ *
+ * @param int $width Width of the image
+ * @param int $height Height of the image
+ * @param string|array $size Size of what the result image should be.
+ * @return array Width and height of what the result image should resize to.
+ */
function image_constrain_size_for_editor($width, $height, $size = 'medium') {
+ global $content_width;
if ( is_array($size) ) {
$max_width = $size[0];
$max_height = intval(get_option('medium_size_h'));
// if no width is set, default to the theme content width if available
}
- else { // $size == 'full'
- // we're inserting a full size image into the editor. if it's a really big image we'll scale it down to fit reasonably
- // within the editor itself, and within the theme's content width if it's known. the user can resize it in the editor
- // if they wish.
- if ( !empty($GLOBALS['content_width']) ) {
- $max_width = $GLOBALS['content_width'];
- }
- else
- $max_width = 500;
+ elseif ( $size == 'large' ) {
+ // we're inserting a large size image into the editor. if it's a really
+ // big image we'll scale it down to fit reasonably within the editor
+ // itself, and within the theme's content width if it's known. the user
+ // can resize it in the editor if they wish.
+ $max_width = intval(get_option('large_size_w'));
+ $max_height = intval(get_option('large_size_h'));
+ if ( intval($content_width) > 0 )
+ $max_width = min( intval($content_width), $max_width );
+ }
+ // $size == 'full' has no constraint
+ else {
+ $max_width = $width;
+ $max_height = $height;
}
list( $max_width, $max_height ) = apply_filters( 'editor_max_image_size', array( $max_width, $max_height ), $size );
return wp_constrain_dimensions( $width, $height, $max_width, $max_height );
}
-// return a width/height string for use in an <img /> tag. Empty values will be omitted.
+/**
+ * Retrieve width and height attributes using given width and height values.
+ *
+ * Both attributes are required in the sense that both parameters must have a
+ * value, but are optional in that if you set them to false or null, then they
+ * will not be added to the returned string.
+ *
+ * You can set the value using a string, but it will only take numeric values.
+ * If you wish to put 'px' after the numbers, then it will be stripped out of
+ * the return.
+ *
+ * @since 2.5.0
+ *
+ * @param int|string $width Optional. Width attribute value.
+ * @param int|string $height Optional. Height attribute value.
+ * @return string HTML attributes for width and, or height.
+ */
function image_hwstring($width, $height) {
$out = '';
if ($width)
return $out;
}
-// Scale an image to fit a particular size (such as 'thumb' or 'medium'), and return an image URL, height and width.
-// The URL might be the original image, or it might be a resized version. This function won't create a new resized copy, it will just return an already resized one if it exists.
-// returns an array($url, $width, $height)
+/**
+ * Scale an image to fit a particular size (such as 'thumb' or 'medium').
+ *
+ * Array with image url, width, height, and whether is intermediate size, in
+ * that order is returned on success is returned. $is_intermediate is true if
+ * $url is a resized image, false if it is the original.
+ *
+ * The URL might be the original image, or it might be a resized version. This
+ * function won't create a new resized copy, it will just return an already
+ * resized one if it exists.
+ *
+ * A plugin may use the 'image_downsize' filter to hook into and offer image
+ * resizing services for images. The hook must return an array with the same
+ * elements that are returned in the function. The first element being the URL
+ * to the new image that was resized.
+ *
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'image_downsize' on $id and $size to provide
+ * resize services.
+ *
+ * @param int $id Attachment ID for image.
+ * @param string $size Optional, default is 'medium'. Size of image, can be 'thumbnail'.
+ * @return bool|array False on failure, array on success.
+ */
function image_downsize($id, $size = 'medium') {
if ( !wp_attachment_is_image($id) )
$img_url = wp_get_attachment_url($id);
$meta = wp_get_attachment_metadata($id);
$width = $height = 0;
+ $is_intermediate = false;
// plugins can use this to provide resize services
if ( $out = apply_filters('image_downsize', false, $id, $size) )
$img_url = str_replace(basename($img_url), $intermediate['file'], $img_url);
$width = $intermediate['width'];
$height = $intermediate['height'];
+ $is_intermediate = true;
}
elseif ( $size == 'thumbnail' ) {
// fall back to the old thumbnail
$img_url = str_replace(basename($img_url), basename($thumb_file), $img_url);
$width = $info[0];
$height = $info[1];
+ $is_intermediate = true;
}
}
if ( !$width && !$height && isset($meta['width'], $meta['height']) ) {
- // any other type: use the real image and constrain it
- list( $width, $height ) = image_constrain_size_for_editor( $meta['width'], $meta['height'], $size );
+ // any other type: use the real image
+ $width = $meta['width'];
+ $height = $meta['height'];
}
- if ( $img_url)
- return array( $img_url, $width, $height );
+ if ( $img_url) {
+ // we have the actual image size, but might need to further constrain it if content_width is narrower
+ list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size );
+
+ return array( $img_url, $width, $height, $is_intermediate );
+ }
return false;
}
/**
* An <img src /> tag for an image attachment, scaling it down if requested.
*
- * {@internal Missing Long Description}}
+ * The filter 'get_image_tag_class' allows for changing the class name for the
+ * image without having to use regular expressions on the HTML content. The
+ * parameters are: what WordPress will use for the class, the Attachment ID,
+ * image align value, and the size the image should be.
+ *
+ * The second filter 'get_image_tag' has the HTML content, which can then be
+ * further manipulated by a plugin to change all attribute values and even HTML
+ * content.
+ *
+ * @since 2.5.0
*
* @uses apply_filters() The 'get_image_tag_class' filter is the IMG element
* class attribute.
return $html;
}
-// same as wp_shrink_dimensions, except the max parameters are optional.
-// if either width or height are empty, no constraint is applied on that dimension.
+/**
+ * Calculates the new dimentions for a downsampled image.
+ *
+ * Same as {@link wp_shrink_dimensions()}, except the max parameters are
+ * optional. If either width or height are empty, no constraint is applied on
+ * that dimension.
+ *
+ * @since 2.5.0
+ *
+ * @param int $current_width Current width of the image.
+ * @param int $current_height Current height of the image.
+ * @param int $max_width Optional. Maximum wanted width.
+ * @param int $max_height Optional. Maximum wanted height.
+ * @return array First item is the width, the second item is the height.
+ */
function wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 ) {
if ( !$max_width and !$max_height )
return array( $current_width, $current_height );
return array( intval($current_width * $ratio), intval($current_height * $ratio) );
}
-// calculate dimensions and coordinates for a resized image that fits within a specified width and height
-// if $crop is true, the largest matching central portion of the image will be cropped out and resized to the required size
+/**
+ * Retrieve calculated resized dimensions for use in imagecopyresampled().
+ *
+ * Calculate dimensions and coordinates for a resized image that fits within a
+ * specified width and height. If $crop is true, the largest matching central
+ * portion of the image will be cropped out and resized to the required size.
+ *
+ * @since 2.5.0
+ *
+ * @param int $orig_w Original width.
+ * @param int $orig_h Original height.
+ * @param int $dest_w New width.
+ * @param int $dest_h New height.
+ * @param bool $crop Optional, default is false. Whether to crop image or resize.
+ * @return bool|array False, on failure. Returned array matches parameters for imagecopyresampled() PHP function.
+ */
function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop=false) {
if ($orig_w <= 0 || $orig_h <= 0)
}
-// Scale down an image to fit a particular size and save a new copy of the image
+/**
+ * Scale down an image to fit a particular size and save a new copy of the image.
+ *
+ * The PNG transparency will be preserved using the function, as well as the
+ * image type. If the file going in is PNG, then the resized image is going to
+ * be PNG. The only supported image types are PNG, GIF, and JPEG.
+ *
+ * Some functionality requires API to exist, so some PHP version may lose out
+ * support. This is not the fault of WordPress (where functionality is
+ * downgraded, not actual defects), but of your PHP version.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Image file path.
+ * @param int $max_w Maximum width to resize to.
+ * @param int $max_h Maximum height to resize to.
+ * @param bool $crop Optional. Whether to crop image or resize.
+ * @param string $suffix Optional. File Suffix.
+ * @param string $dest_path Optional. New image file path.
+ * @param int $jpeg_quality Optional, default is 90. Image quality percentage.
+ * @return mixed WP_Error on failure. String with new destination path. Array of dimensions from {@link image_resize_dimensions()}
+ */
function image_resize( $file, $max_w, $max_h, $crop=false, $suffix=null, $dest_path=null, $jpeg_quality=90) {
$image = wp_load_image( $file );
return $destfilename;
}
-// resize an image to make a thumbnail or intermediate size, and return metadata describing the new copy
-// returns false if no image was created
+/**
+ * Resize an image to make a thumbnail or intermediate size.
+ *
+ * The returned array has the file size, the image width, and image height. The
+ * filter 'image_make_intermediate_size' can be used to hook in and change the
+ * values of the returned array. The only parameter is the resized file path.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file File path.
+ * @param int $width Image width.
+ * @param int $height Image height.
+ * @param bool $crop Optional, default is false. Whether to crop image to specified height and width or resize.
+ * @return bool|array False, if no image was created. Metadata array on success.
+ */
function image_make_intermediate_size($file, $width, $height, $crop=false) {
if ( $width || $height ) {
$resized_file = image_resize($file, $width, $height, $crop);
return false;
}
+/**
+ * Retrieve the image's intermediate size (resized) path, width, and height.
+ *
+ * The $size parameter can be an array with the width and height respectively.
+ * If the size matches the 'sizes' metadata array for width and height, then it
+ * will be used. If there is no direct match, then the nearest image size larger
+ * than the specified size will be used. If nothing is found, then the function
+ * will break out and return false.
+ *
+ * The metadata 'sizes' is used for compatible sizes that can be used for the
+ * parameter $size value.
+ *
+ * The url path will be given, when the $size parameter is a string.
+ *
+ * @since 2.5.0
+ *
+ * @param int $post_id Attachment ID for image.
+ * @param array|string $size Optional, default is 'thumbnail'. Size of image, either array or string.
+ * @return bool|array False on failure or array of file path, width, and height on success.
+ */
function image_get_intermediate_size($post_id, $size='thumbnail') {
if ( !is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) )
return false;
if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) )
return false;
-
+
$data = $imagedata['sizes'][$size];
// include the full filesystem path of the intermediate file
if ( empty($data['path']) && !empty($data['file']) ) {
return $data;
}
-// get an image to represent an attachment - a mime icon for files, thumbnail or intermediate size for images
-// returns an array (url, width, height), or false if no image is available
+/**
+ * Retrieve an image to represent an attachment.
+ *
+ * A mime icon for files, thumbnail or intermediate size for images.
+ *
+ * @since 2.5.0
+ *
+ * @param int $attachment_id Image attachment ID.
+ * @param string $size Optional, default is 'thumbnail'.
+ * @param bool $icon Optional, default is false. Whether it is an icon.
+ * @return bool|array Returns an array (url, width, height), or false, if no image is available.
+ */
function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) {
-
+
// get a thumbnail or intermediate image if there is one
if ( $image = image_downsize($attachment_id, $size) )
return $image;
if ( $icon && $src = wp_mime_type_icon($attachment_id) ) {
- $icon_dir = apply_filters( 'icon_dir', includes_url('images/crystal') );
+ $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' );
$src_file = $icon_dir . '/' . basename($src);
@list($width, $height) = getimagesize($src_file);
}
return false;
}
-// as per wp_get_attachment_image_src, but returns an <img> tag
-function wp_get_attachment_image($attachment_id, $size='thumbnail', $icon = false) {
+/**
+ * Retrieve img HTML content for an image to represent an attachment.
+ *
+ * @see wp_get_attachment_image_src() Returns img HTML element based on array.
+ * @since 2.5.0
+ *
+ * @param int $attachment_id Image attachment ID.
+ * @param string $size Optional, default is 'thumbnail'.
+ * @param bool $icon Optional, default is false. Whether it is an icon.
+ * @return string HTML img element or empty string on failure.
+ */
+function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false) {
$html = '';
$image = wp_get_attachment_image_src($attachment_id, $size, $icon);
$size = join('x', $size);
$html = '<img src="'.attribute_escape($src).'" '.$hwstring.'class="attachment-'.attribute_escape($size).'" alt="" />';
}
-
+
return $html;
}
add_shortcode('wp_caption', 'img_caption_shortcode');
add_shortcode('caption', 'img_caption_shortcode');
+/**
+ * The Caption shortcode.
+ *
+ * Allows a plugin to replace the content that would otherwise be returned. The
+ * filter is 'img_caption_shortcode' and passes an empty string, the attr
+ * parameter and the content parameter values.
+ *
+ * The supported attributes for the shortcode are 'id', 'align', 'width', and
+ * 'caption'.
+ *
+ * @since 2.6.0
+ *
+ * @param array $attr Attributes attributed to the shortcode.
+ * @param string $content Optional. Shortcode content.
+ * @return string
+ */
function img_caption_shortcode($attr, $content = null) {
// Allow plugins/themes to override the default caption template.
'width' => '',
'caption' => ''
), $attr));
-
+
if ( 1 > (int) $width || empty($caption) )
return $content;
-
+
if ( $id ) $id = 'id="' . $id . '" ';
-
+
return '<div ' . $id . 'class="wp-caption ' . $align . '" style="width: ' . (10 + (int) $width) . 'px">'
. $content . '<p class="wp-caption-text">' . $caption . '</p></div>';
}
add_shortcode('gallery', 'gallery_shortcode');
+/**
+ * The Gallery shortcode.
+ *
+ * This implements the functionality of the Gallery Shortcode for displaying
+ * WordPress images on a post.
+ *
+ * @since 2.5.0
+ *
+ * @param array $attr Attributes attributed to the shortcode.
+ * @return string HTML content to display gallery.
+ */
function gallery_shortcode($attr) {
global $post;
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
- 'size' => 'thumbnail',
+ 'size' => 'thumbnail'
), $attr));
$id = intval($id);
return $output;
}
- $listtag = tag_escape($listtag);
$itemtag = tag_escape($itemtag);
$captiontag = tag_escape($captiontag);
$columns = intval($columns);
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
-
+
$output = apply_filters('gallery_style', "
<style type='text/css'>
.gallery {
<!-- see gallery_shortcode() in wp-includes/media.php -->
<div class='gallery'>");
+ $i = 0;
foreach ( $attachments as $id => $attachment ) {
- $link = wp_get_attachment_link($id, $size, true);
+ $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
+
$output .= "<{$itemtag} class='gallery-item'>";
$output .= "
<{$icontag} class='gallery-icon'>
return $output;
}
+/**
+ * Display previous image link that has the same post parent.
+ *
+ * @since 2.5.0
+ */
function previous_image_link() {
adjacent_image_link(true);
}
+/**
+ * Display next image link that has the same post parent.
+ *
+ * @since 2.5.0
+ */
function next_image_link() {
adjacent_image_link(false);
}
+/**
+ * Display next or previous image link that has the same post parent.
+ *
+ * Retrieves the current attachment object from the $post global.
+ *
+ * @since 2.5.0
+ *
+ * @param bool $prev Optional. Default is true to display previous link, true for next.
+ */
function adjacent_image_link($prev = true) {
global $post;
$post = get_post($post);
echo wp_get_attachment_link($attachments[$k]->ID, 'thumbnail', true);
}
+/**
+ * Retrieve taxonomies attached to the attachment.
+ *
+ * @since 2.5.0
+ *
+ * @param int|array|object $attachment Attachment ID, Attachment data array, or Attachment data object.
+ * @return array Empty array on failure. List of taxonomies on success.
+ */
function get_attachment_taxonomies($attachment) {
if ( is_int( $attachment ) )
$attachment = get_post($attachment);
* @param string $subject Email subject
* @param string $message Message contents
* @param string|array $headers Optional. Additional headers.
+ * @param string|array $attachments Optional. Files to attach.
* @return bool Whether the email contents were sent successfully.
*/
-function wp_mail( $to, $subject, $message, $headers = '' ) {
+function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
// Compact the input, apply the filters, and extract them back out
- extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers' ) ) );
+ extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
+
+ if ( !is_array($attachments) )
+ $attachments = explode( "\n", $attachments );
global $phpmailer;
// If it's actually got contents
if ( !empty( $tempheaders ) ) {
// Iterate through the raw headers
- foreach ( $tempheaders as $header ) {
+ foreach ( (array) $tempheaders as $header ) {
if ( strpos($header, ':') === false )
continue;
// Explode them out
// Add any CC and BCC recipients
if ( !empty($cc) ) {
- foreach ($cc as $recipient) {
+ foreach ( (array) $cc as $recipient ) {
$phpmailer->AddCc( trim($recipient) );
}
}
if ( !empty($bcc) ) {
- foreach ($bcc as $recipient) {
+ foreach ( (array) $bcc as $recipient) {
$phpmailer->AddBcc( trim($recipient) );
}
}
// Set custom headers
if ( !empty( $headers ) ) {
- foreach ( $headers as $name => $content ) {
+ foreach( (array) $headers as $name => $content ) {
$phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
}
}
+ if ( !empty( $attachments ) ) {
+ foreach ( $attachments as $attachment ) {
+ $phpmailer->AddAttachment($attachment);
+ }
+ }
+
do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
// Send!
}
endif;
+if ( !function_exists('wp_authenticate') ) :
/**
* Checks a user's login information and logs them in if it checks out.
*
- * @since 2.5
+ * @since 2.5.0
*
* @param string $username User's username
* @param string $password User's password
* @return WP_Error|WP_User WP_User object if login successful, otherwise WP_Error object.
*/
-if ( !function_exists('wp_authenticate') ) :
function wp_authenticate($username, $password) {
$username = sanitize_user($username);
}
endif;
+if ( !function_exists('wp_logout') ) :
/**
* Log the current user out.
*
- * @since 2.5
+ * @since 2.5.0
*/
-if ( !function_exists('wp_logout') ) :
function wp_logout() {
wp_clear_auth_cookie();
do_action('wp_logout');
* @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
* @return bool|int False if invalid cookie, User ID if valid.
*/
-function wp_validate_auth_cookie($cookie = '', $scheme = 'auth') {
- if ( empty($cookie) ) {
- if ( is_ssl() ) {
- $cookie_name = SECURE_AUTH_COOKIE;
- $scheme = 'secure_auth';
- } else {
- $cookie_name = AUTH_COOKIE;
- $scheme = 'auth';
- }
-
- if ( empty($_COOKIE[$cookie_name]) )
- return false;
- $cookie = $_COOKIE[$cookie_name];
- }
-
- $cookie_elements = explode('|', $cookie);
- if ( count($cookie_elements) != 3 )
+function wp_validate_auth_cookie($cookie = '', $scheme = '') {
+ if ( ! $cookie_elements = wp_parse_auth_cookie($cookie, $scheme) ) {
+ do_action('auth_cookie_malformed', $cookie, $scheme);
return false;
+ }
- list($username, $expiration, $hmac) = $cookie_elements;
+ extract($cookie_elements, EXTR_OVERWRITE);
$expired = $expiration;
$expired += 3600;
// Quick check to see if an honest cookie has expired
- if ( $expired < time() )
+ if ( $expired < time() ) {
+ do_action('auth_cookie_expired', $cookie_elements);
return false;
+ }
$key = wp_hash($username . '|' . $expiration, $scheme);
$hash = hash_hmac('md5', $username . '|' . $expiration, $key);
- if ( $hmac != $hash )
+ if ( $hmac != $hash ) {
+ do_action('auth_cookie_bad_hash', $cookie_elements);
return false;
+ }
$user = get_userdatabylogin($username);
- if ( ! $user )
+ if ( ! $user ) {
+ do_action('auth_cookie_bad_username', $cookie_elements);
return false;
+ }
+
+ do_action('auth_cookie_valid', $cookie_elements, $user);
return $user->ID;
}
}
endif;
+if ( !function_exists('wp_parse_auth_cookie') ) :
+/**
+ * Parse a cookie into its components
+ *
+ * @since 2.7
+ *
+ * @param string $cookie
+ * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
+ * @return array Authentication cookie components
+ */
+function wp_parse_auth_cookie($cookie = '', $scheme = '') {
+ if ( empty($cookie) ) {
+ switch ($scheme){
+ case 'auth':
+ $cookie_name = AUTH_COOKIE;
+ break;
+ case 'secure_auth':
+ $cookie_name = SECURE_AUTH_COOKIE;
+ break;
+ case "logged_in":
+ $cookie_name = LOGGED_IN_COOKIE;
+ break;
+ default:
+ if ( is_ssl() ) {
+ $cookie_name = SECURE_AUTH_COOKIE;
+ $scheme = 'secure_auth';
+ } else {
+ $cookie_name = AUTH_COOKIE;
+ $scheme = 'auth';
+ }
+ }
+
+ if ( empty($_COOKIE[$cookie_name]) )
+ return false;
+ $cookie = $_COOKIE[$cookie_name];
+ }
+
+ $cookie_elements = explode('|', $cookie);
+ if ( count($cookie_elements) != 3 )
+ return false;
+
+ list($username, $expiration, $hmac) = $cookie_elements;
+
+ return compact('username', 'expiration', 'hmac', 'scheme');
+}
+endif;
+
if ( !function_exists('wp_set_auth_cookie') ) :
/**
* Sets the authentication cookies based User ID.
do_action('set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme);
do_action('set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in');
- setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure);
- setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure);
- setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN);
- if ( COOKIEPATH != SITECOOKIEPATH )
- setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN);
+ // Set httponly if the php version is >= 5.2.0
+ if ( version_compare(phpversion(), '5.2.0', 'ge') ) {
+ setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
+ setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
+ setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, false, true);
+ if ( COOKIEPATH != SITECOOKIEPATH )
+ setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, false, true);
+ } else {
+ $cookie_domain = COOKIE_DOMAIN;
+ if ( !empty($cookie_domain) )
+ $cookie_domain .= '; HttpOnly';
+ setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, $cookie_domain, $secure);
+ setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, $cookie_domain, $secure);
+ setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, $cookie_domain);
+ if ( COOKIEPATH != SITECOOKIEPATH )
+ setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, $cookie_domain);
+ }
}
endif;
* @since 2.5
*/
function wp_clear_auth_cookie() {
+ do_action('clear_auth_cookie');
+
setcookie(AUTH_COOKIE, ' ', time() - 31536000, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
setcookie(AUTH_COOKIE, ' ', time() - 31536000, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
$secure = false;
// If https is required and request is http, redirect
- if ( $secure && !is_ssl() ) {
+ if ( $secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
exit();
} else {
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
- exit();
+ exit();
}
}
- if ( wp_validate_auth_cookie() )
+ if ( $user_id = wp_validate_auth_cookie() ) {
+ // If the user wants ssl but the session is not ssl, redirect.
+ if ( !$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
+ if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
+ wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
+ exit();
+ } else {
+ wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+ exit();
+ }
+ }
+
return; // The cookie is good so we're done
+ }
// The cookie is no good so force login
nocache_headers();
else
$proto = 'http://';
- $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode($proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']), 'login' );
+ $redirect = ( strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer() ) ? wp_get_referer() : $proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+
+ $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode( $redirect ), 'login' );
wp_redirect($login_url);
exit();
function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
$adminurl = strtolower(admin_url());
$referer = strtolower(wp_get_referer());
- $result = wp_verify_nonce($_REQUEST[$query_arg], $action);
+ $result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false;
if ( !$result && !(-1 == $action && strpos($referer, $adminurl) !== false) ) {
wp_nonce_ays($action);
die();
$location = apply_filters('wp_redirect', $location, $status);
$status = apply_filters('wp_redirect_status', $status, $location);
-
+
if ( !$location ) // allows the wp_redirect filter to cancel a redirect
return false;
$found = true;
while($found) {
$found = false;
- foreach($strip as $val) {
+ foreach( (array) $strip as $val ) {
while(strpos($location, $val) !== false) {
$found = true;
$location = str_replace($val, '', $location);
// In php 5 parse_url may fail if the URL query part contains http://, bug #38143
$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
-
+
$lp = parse_url($test);
$wpp = parse_url(get_option('home'));
$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=cdc&c=$comment_id") ) . "\r\n";
$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=cdc&dt=spam&c=$comment_id") ) . "\r\n";
- $notify_message .= sprintf( __ngettext('Currently %s comment is waiting for approval. Please visit the moderation panel:',
+ $notify_message .= sprintf( __ngettext('Currently %s comment is waiting for approval. Please visit the moderation panel:',
'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
$notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n";
}
endif;
+if ( !function_exists('wp_password_change_notification') ) :
+/**
+ * Notify the blog admin of a user changing password, normally via email.
+ *
+ * @since 2.7
+ *
+ * @param object $user User Object
+ */
+function wp_password_change_notification(&$user) {
+ // send a copy of password change notification to the admin
+ // but check to see if it's the admin whose password we're changing, and skip this
+ if ( $user->user_email != get_option('admin_email') ) {
+ $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
+ wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), get_option('blogname')), $message);
+ }
+}
+endif;
+
if ( !function_exists('wp_new_user_notification') ) :
/**
* Notify the blog admin of a new user, normally via email.
$i = wp_nonce_tick();
// Nonce generated 0-12 hours ago
- if ( substr(wp_hash($i . $action . $uid), -12, 10) == $nonce )
+ if ( substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10) == $nonce )
return 1;
// Nonce generated 12-24 hours ago
- if ( substr(wp_hash(($i - 1) . $action . $uid), -12, 10) == $nonce )
+ if ( substr(wp_hash(($i - 1) . $action . $uid, 'nonce'), -12, 10) == $nonce )
return 2;
// Invalid nonce
return false;
$i = wp_nonce_tick();
- return substr(wp_hash($i . $action . $uid), -12, 10);
+ return substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10);
}
endif;
* Below is an example of how the SECRET_KEY constant is defined with a value.
* You must not copy the below example and paste into your wp-config.php. If you
* need an example, then you can have a
- * {@link http://api.wordpress.org/secret-key/1.0/ secret key created} for you.
+ * {@link https://api.wordpress.org/secret-key/1.1/ secret key created} for you.
*
* <code>
* define('SECRET_KEY', 'mAry1HadA15|\/|b17w55w1t3asSn09w');
* salt string is not weak.
*
* @since 2.5
- * @link http://api.wordpress.org/secret-key/1.0/ Create a Secret Key for wp-config.php
+ * @link https://api.wordpress.org/secret-key/1.1/ Create a Secret Key for wp-config.php
*
* @return string Salt value from either 'SECRET_KEY' or 'secret' option
*/
update_option('logged_in_salt', $salt);
}
}
+ } elseif ( 'nonce' == $scheme ) {
+ if ( defined('NONCE_KEY') && ('' != NONCE_KEY) && ( $wp_default_secret_key != NONCE_KEY) )
+ $secret_key = NONCE_KEY;
+
+ if ( defined('NONCE_SALT') ) {
+ $salt = NONCE_SALT;
+ } else {
+ $salt = get_option('nonce_salt');
+ if ( empty($salt) ) {
+ $salt = wp_generate_password();
+ update_option('nonce_salt', $salt);
+ }
+ }
+ } else {
+ // ensure each auth scheme has its own unique salt
+ $salt = hash_hmac('md5', $scheme, $secret_key);
}
return apply_filters('salt', $secret_key . $salt, $scheme);
*
* @since 2.5
*
+ * @param int $length The length of password to generate
+ * @param bool $special_chars Whether to include standard special characters
* @return string The random password
**/
function wp_generate_password($length = 12, $special_chars = true) {
if ( $max != 0 )
$value = $min + (($max - $min + 1) * ($value / (4294967295 + 1)));
- return abs(intval($value));
+ return abs(intval($value));
}
endif;
* @param int|string|object $id_or_email A user ID, email address, or comment object
* @param int $size Size of the avatar image
* @param string $default URL to a default image to use if no avatar is available
+ * @param string $alt Alternate text to use in image tag. Defaults to blank
* @return string <img> tag for the user's avatar
*/
-function get_avatar( $id_or_email, $size = '96', $default = '' ) {
+function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) {
if ( ! get_option('show_avatars') )
return false;
+ if ( false === $alt)
+ $safe_alt = '';
+ else
+ $safe_alt = attribute_escape( $alt );
+
if ( !is_numeric($size) )
$size = '96';
if ( $user )
$email = $user->user_email;
} elseif ( is_object($id_or_email) ) {
+ if ( isset($id_or_email->comment_type) && '' != $id_or_email->comment_type && 'comment' != $id_or_email->comment_type )
+ return false; // No avatar for pingbacks or trackbacks
+
if ( !empty($id_or_email->user_id) ) {
$id = (int) $id_or_email->user_id;
$user = get_userdata($id);
$default = $avatar_default;
}
- if ( 'custom' == $default )
- $default = add_query_arg( 's', $size, $defaults[$avatar_default][1] );
- elseif ( 'mystery' == $default )
- $default = "http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
+ if ( is_ssl() )
+ $host = 'https://secure.gravatar.com';
+ else
+ $host = 'http://www.gravatar.com';
+
+ if ( 'mystery' == $default )
+ $default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
elseif ( 'blank' == $default )
$default = includes_url('images/blank.gif');
elseif ( !empty($email) && 'gravatar_default' == $default )
$default = '';
elseif ( 'gravatar_default' == $default )
- $default = "http://www.gravatar.com/avatar/s={$size}";
+ $default = "$host/avatar/s={$size}";
elseif ( empty($email) )
- $default = "http://www.gravatar.com/avatar/?d=$default&s={$size}";
+ $default = "$host/avatar/?d=$default&s={$size}";
+ elseif ( strpos($default, 'http://') === 0 )
+ $default = add_query_arg( 's', $size, $default );
if ( !empty($email) ) {
- $out = 'http://www.gravatar.com/avatar/';
+ $out = "$host/avatar/";
$out .= md5( strtolower( $email ) );
$out .= '?s='.$size;
$out .= '&d=' . urlencode( $default );
if ( !empty( $rating ) )
$out .= "&r={$rating}";
- $avatar = "<img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />";
+ $avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
} else {
- $avatar = "<img alt='' src='{$default}' class='avatar avatar-{$size} avatar-default' height='{$size}' width='{$size}' />";
+ $avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
}
- return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default);
+ return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
}
endif;
if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) )
require( ABSPATH . WPINC . '/wp-diff.php' );
- // Normalize whitespace
- $left_string = trim($left_string);
- $right_string = trim($right_string);
- $left_string = str_replace("\r", "\n", $left_string);
- $right_string = str_replace("\r", "\n", $right_string);
- $left_string = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $left_string );
- $right_string = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $right_string );
-
+ $left_string = normalize_whitespace($left_string);
+ $right_string = normalize_whitespace($right_string);
+
$left_lines = split("\n", $left_string);
$right_lines = split("\n", $right_string);
}
endif;
-?>
\ No newline at end of file
+?>
* {@link http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback 'callback'}
* type are valid.
*
- * Also see the {@link http://codex.wordpress.org/Plugin_API Plugin API} for more information
- * and examples on how to use a lot of these functions.
+ * Also see the {@link http://codex.wordpress.org/Plugin_API Plugin API} for
+ * more information and examples on how to use a lot of these functions.
*
* @package WordPress
* @subpackage Plugin
*/
/**
- * add_filter() - Hooks a function or method to a specific filter action.
+ * Hooks a function or method to a specific filter action.
*
* Filters are the hooks that WordPress launches to modify text of various types
* before adding it to the database or sending it to the browser screen. Plugins
* can specify that one or more of its PHP functions is executed to
* modify specific types of text at these times, using the Filter API.
*
- * To use the API, the following code should be used to bind a callback to the filter
+ * To use the API, the following code should be used to bind a callback to the
+ * filter.
+ *
* <code>
* function example_hook($example) { echo $example; }
- *
* add_filter('example_filter', 'example_hook');
* </code>
*
- * In WordPress 1.5.1+, hooked functions can take extra arguments that are set when
- * the matching do_action() or apply_filters() call is run. The <tt>$accepted_args
- * allow for calling functions only when the number of args match. Hooked functions
- * can take extra arguments that are set when the matching <tt>do_action()</tt> or
- * <tt>apply_filters()</tt> call is run. For example, the action <tt>comment_id_not_found</tt>
- * will pass any functions that hook onto it the ID of the requested comment.
+ * In WordPress 1.5.1+, hooked functions can take extra arguments that are set
+ * when the matching do_action() or apply_filters() call is run. The
+ * $accepted_args allow for calling functions only when the number of args
+ * match. Hooked functions can take extra arguments that are set when the
+ * matching do_action() or apply_filters() call is run. For example, the action
+ * comment_id_not_found will pass any functions that hook onto it the ID of the
+ * requested comment.
*
- * <strong>Note:</strong> the function will return true no matter if the function was hooked
- * fails or not. There are no checks for whether the function exists beforehand and no checks
- * to whether the <tt>$function_to_add is even a string. It is up to you to take care and
- * this is done for optimization purposes, so everything is as quick as possible.
+ * <strong>Note:</strong> the function will return true no matter if the
+ * function was hooked fails or not. There are no checks for whether the
+ * function exists beforehand and no checks to whether the <tt>$function_to_add
+ * is even a string. It is up to you to take care and this is done for
+ * optimization purposes, so everything is as quick as possible.
*
* @package WordPress
* @subpackage Plugin
* wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]']
* @global array $merged_filters Tracks the tags that need to be merged for later. If the hook is added, it doesn't need to run through that process.
*
- * @param string $tag The name of the filter to hook the <tt>$function_to_add</tt> to.
+ * @param string $tag The name of the filter to hook the $function_to_add to.
* @param callback $function_to_add The name of the function to be called when the filter is applied.
* @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
* @param int $accepted_args optional. The number of arguments the function accept (default 1).
}
/**
- * has_filter() - Check if any filter has been registered for a hook.
+ * Check if any filter has been registered for a hook.
*
* @package WordPress
* @subpackage Plugin
if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false) )
return false;
- foreach ( array_keys($wp_filter[$tag]) as $priority ) {
+ foreach ( (array) array_keys($wp_filter[$tag]) as $priority ) {
if ( isset($wp_filter[$tag][$priority][$idx]) )
return $priority;
}
}
/**
- * apply_filters() - Call the functions added to a filter hook.
+ * Call the functions added to a filter hook.
*
- * The callback functions attached to filter hook <tt>$tag</tt> are invoked by
- * calling this function. This function can be used to create a new filter hook
- * by simply calling this function with the name of the new hook specified using
- * the <tt>$tag</a> parameter.
+ * The callback functions attached to filter hook $tag are invoked by calling
+ * this function. This function can be used to create a new filter hook by
+ * simply calling this function with the name of the new hook specified using
+ * the $tag parameter.
*
* The function allows for additional arguments to be added and passed to hooks.
* <code>
* @subpackage Plugin
* @since 0.71
* @global array $wp_filter Stores all of the filters
- * @global array $merge_filters Merges the filter hooks using this function.
+ * @global array $merged_filters Merges the filter hooks using this function.
* @global array $wp_current_filter stores the list of current filters with the current one last
*
* @param string $tag The name of the filter hook.
}
/**
- * remove_filter() - Removes a function from a specified filter hook.
+ * Removes a function from a specified filter hook.
*
* This function removes a function attached to a specified filter hook. This
* method can be used to remove default functions attached to a specific filter
* hook and possibly replace them with a substitute.
*
- * To remove a hook, the <tt>$function_to_remove</tt> and <tt>$priority</tt> arguments
- * must match when the hook was added. This goes for both filters and actions. No warning
+ * To remove a hook, the $function_to_remove and $priority arguments must match
+ * when the hook was added. This goes for both filters and actions. No warning
* will be given on removal failure.
*
* @package WordPress
return $r;
}
+/**
+ * Remove all of the hooks from a filter.
+ *
+ * @since 2.7
+ *
+ * @param string $tag The filter to remove hooks from.
+ * @param int $priority The priority number to remove.
+ * @return bool True when finished.
+ */
+function remove_all_filters($tag, $priority = false) {
+ global $wp_filter, $merged_filters;
+
+ if( isset($wp_filter[$tag]) ) {
+ if( false !== $priority && isset($$wp_filter[$tag][$priority]) )
+ unset($wp_filter[$tag][$priority]);
+ else
+ unset($wp_filter[$tag]);
+ }
+
+ if( isset($merged_filters[$tag]) )
+ unset($merged_filters[$tag]);
+
+ return true;
+}
/**
- * current_filter() - Return the name of the current filter or action.
+ * Retrieve the name of the current filter or action.
*
* @package WordPress
* @subpackage Plugin
/**
- * add_action() - Hooks a function on to a specific action.
+ * Hooks a function on to a specific action.
*
* Actions are the hooks that the WordPress core launches at specific points
* during execution, or when specific events occur. Plugins can specify that
* @subpackage Plugin
* @since 1.2
*
- * @param string $tag The name of the action to which the <tt>$function_to-add</tt> is hooked.
+ * @param string $tag The name of the action to which the $function_to_add is hooked.
* @param callback $function_to_add The name of the function you wish to be called.
* @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
* @param int $accepted_args optional. The number of arguments the function accept (default 1).
/**
- * do_action() - Execute functions hooked on a specific action hook.
+ * Execute functions hooked on a specific action hook.
*
- * This function invokes all functions attached to action hook <tt>$tag</tt>.
- * It is possible to create new action hooks by simply calling this function,
+ * This function invokes all functions attached to action hook $tag. It is
+ * possible to create new action hooks by simply calling this function,
* specifying the name of the new hook using the <tt>$tag</tt> parameter.
*
- * You can pass extra arguments to the hooks, much like you can with apply_filters().
+ * You can pass extra arguments to the hooks, much like you can with
+ * apply_filters().
*
- * @see apply_filters() This function works similar with the exception that nothing is
- * returned and only the functions or methods are called.
+ * @see apply_filters() This function works similar with the exception that
+ * nothing is returned and only the functions or methods are called.
*
* @package WordPress
* @subpackage Plugin
}
/**
- * did_action() - Return the number times an action is fired.
+ * Retrieve the number times an action is fired.
*
* @package WordPress
* @subpackage Plugin
}
/**
- * do_action_ref_array() - Execute functions hooked on a specific action hook, specifying arguments in an array.
+ * Execute functions hooked on a specific action hook, specifying arguments in an array.
*
- * @see do_action() This function is identical, but the arguments passed to
- * the functions hooked to <tt>$tag</tt> are supplied using an array.
+ * @see do_action() This function is identical, but the arguments passed to the
+ * functions hooked to <tt>$tag</tt> are supplied using an array.
*
* @package WordPress
* @subpackage Plugin
}
/**
- * has_action() - Check if any action has been registered for a hook.
+ * Check if any action has been registered for a hook.
*
* @package WordPress
* @subpackage Plugin
}
/**
- * remove_action() - Removes a function from a specified action hook.
+ * Removes a function from a specified action hook.
*
* This function removes a function attached to a specified action hook. This
* method can be used to remove default functions attached to a specific filter
return remove_filter($tag, $function_to_remove, $priority, $accepted_args);
}
+/**
+ * Remove all of the hooks from an action.
+ *
+ * @since 2.7
+ *
+ * @param string $tag The action to remove hooks from.
+ * @param int $priority The priority number to remove them from.
+ * @return bool True when finished.
+ */
+function remove_all_actions($tag, $priority = false) {
+ return remove_all_filters($tag, $priority);
+}
+
//
// Functions for handling plugins.
//
/**
- * plugin_basename() - Gets the basename of a plugin.
+ * Gets the basename of a plugin.
*
* This method extracts the name of a plugin from its filename.
*
}
/**
- * register_activation_hook() - Hook a function on a plugin activation action hook.
+ * Set the activation hook for a plugin.
*
* When a plugin is activated, the action 'activate_PLUGINNAME' hook is
* activated. In the name of this hook, PLUGINNAME is replaced with the name of
* the plugin, including the optional subdirectory. For example, when the plugin
- * is located in <tt>wp-content/plugin/sampleplugin/sample.php</tt>, then the
- * name of this hook will become 'activate_sampleplugin/sample.php'
- * When the plugin consists of only one file and is (as by default) located at
- * <tt>wp-content/plugin/sample.php</tt> the name of this hook will be
+ * is located in wp-content/plugin/sampleplugin/sample.php, then the name of
+ * this hook will become 'activate_sampleplugin/sample.php'. When the plugin
+ * consists of only one file and is (as by default) located at
+ * wp-content/plugin/sample.php the name of this hook will be
* 'activate_sample.php'.
*
* @package WordPress
* @access private
*
* @param string $file The filename of the plugin including the path.
- * @param string $function the function hooked to the 'activate_PLUGIN' action.
+ * @param callback $function the function hooked to the 'activate_PLUGIN' action.
*/
function register_activation_hook($file, $function) {
$file = plugin_basename($file);
}
/**
- * register_deactivation_hook() - Hook a function on a plugin deactivation action hook.
+ * Set the deactivation hook for a plugin.
*
* When a plugin is deactivated, the action 'deactivate_PLUGINNAME' hook is
- * deactivated. In the name of this hook, PLUGINNAME is replaced with the name of
- * the plugin, including the optional subdirectory. For example, when the plugin
- * is located in <tt>wp-content/plugin/sampleplugin/sample.php</tt>, then the
- * name of this hook will become 'activate_sampleplugin/sample.php'.
+ * deactivated. In the name of this hook, PLUGINNAME is replaced with the name
+ * of the plugin, including the optional subdirectory. For example, when the
+ * plugin is located in wp-content/plugin/sampleplugin/sample.php, then
+ * the name of this hook will become 'activate_sampleplugin/sample.php'.
+ *
* When the plugin consists of only one file and is (as by default) located at
- * <tt>wp-content/plugin/sample.php</tt> the name of this hook will be
+ * wp-content/plugin/sample.php the name of this hook will be
* 'activate_sample.php'.
*
* @package WordPress
* @access private
*
* @param string $file The filename of the plugin including the path.
- * @param string $function the function hooked to the 'activate_PLUGIN' action.
+ * @param callback $function the function hooked to the 'activate_PLUGIN' action.
*/
function register_deactivation_hook($file, $function) {
$file = plugin_basename($file);
}
/**
- * _wp_call_all_hook() - Calls the 'all' hook, which will process the functions hooked into it.
+ * Set the uninstallation hook for a plugin.
+ *
+ * Registers the uninstall hook that will be called when the user clicks on the
+ * uninstall link that calls for the plugin to uninstall itself. The link won't
+ * be active unless the plugin hooks into the action.
*
- * The 'all' hook passes all of the arguments or parameters that were used for the
- * hook, which this function was called for.
+ * The plugin should not run arbitrary code outside of functions, when
+ * registering the uninstall hook. In order to run using the hook, the plugin
+ * will have to be included, which means that any code laying outside of a
+ * function will be run during the uninstall process. The plugin should not
+ * hinder the uninstall process.
*
- * This function is used internally for apply_filters(), do_action(), and do_action_ref_array()
- * and is not meant to be used from outside those functions. This function does not check for the
- * existence of the all hook, so it will fail unless the all hook exists prior to this function call.
+ * If the plugin can not be written without running code within the plugin, then
+ * the plugin should create a file named 'uninstall.php' in the base plugin
+ * folder. This file will be called, if it exists, during the uninstall process
+ * bypassing the uninstall hook. The plugin, when using the 'uninstall.php'
+ * should always check for the 'WP_UNINSTALL_PLUGIN' constant, before
+ * executing.
+ *
+ * @since 2.7
+ *
+ * @param string $file
+ * @param callback $callback The callback to run when the hook is called.
+ */
+function register_uninstall_hook($file, $callback) {
+ // The option should not be autoloaded, because it is not needed in most
+ // cases. Emphasis should be put on using the 'uninstall.php' way of
+ // uninstalling the plugin.
+ $uninstallable_plugins = (array) get_option('uninstall_plugins');
+ $uninstallable_plugins[plugin_basename($file)] = $callback;
+ update_option('uninstall_plugins', $uninstallable_plugins);
+}
+
+/**
+ * Calls the 'all' hook, which will process the functions hooked into it.
+ *
+ * The 'all' hook passes all of the arguments or parameters that were used for
+ * the hook, which this function was called for.
+ *
+ * This function is used internally for apply_filters(), do_action(), and
+ * do_action_ref_array() and is not meant to be used from outside those
+ * functions. This function does not check for the existence of the all hook, so
+ * it will fail unless the all hook exists prior to this function call.
*
* @package WordPress
* @subpackage Plugin
}
/**
- * _wp_filter_build_unique_id() - Build Unique ID for storage and retrieval
+ * Build Unique ID for storage and retrieval.
*
* The old way to serialize the callback caused issues and this function is the
* solution. It works by checking for objects and creating an a new property in
*
* It also allows for the removal of actions and filters for objects after they
* change class properties. It is possible to include the property $wp_filter_id
- * in your class and set it to "null" or a number to bypass the workaround. However
- * this will prevent you from adding new classes and any new classes will overwrite
- * the previous hook by the same class.
+ * in your class and set it to "null" or a number to bypass the workaround.
+ * However this will prevent you from adding new classes and any new classes
+ * will overwrite the previous hook by the same class.
*
- * Functions and static method callbacks are just returned as strings and shouldn't
- * have any speed penalty.
+ * Functions and static method callbacks are just returned as strings and
+ * shouldn't have any speed penalty.
*
* @package WordPress
* @subpackage Plugin
+ * @access private
* @since 2.2.3
- *
* @link http://trac.wordpress.org/ticket/3875
*
- * @access private
- *
* @global array $wp_filter Storage for all of the filters and actions
* @param string $tag Used in counting how many hooks were applied
* @param string|array $function Used for creating unique id
if ( !isset($function[0]->wp_filter_id) ) {
if ( false === $priority )
return false;
- $count = count((array)$wp_filter[$tag][$priority]);
+ $count = isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : 0;
$function[0]->wp_filter_id = $count;
$obj_idx .= $count;
unset($count);
<?php
+/**
+ * WordPress Post Template Functions.
+ *
+ * Gets content for the current post in the loop.
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
-//
-// "The Loop" post functions
-//
-
+/**
+ * Display the ID of the current item in the WordPress Loop.
+ *
+ * @since 0.71
+ * @uses $id
+ */
function the_ID() {
global $id;
echo $id;
}
-
+/**
+ * Retrieve the ID of the current item in the WordPress Loop.
+ *
+ * @since 2.1.0
+ * @uses $id
+ *
+ * @return unknown
+ */
function get_the_ID() {
global $id;
return $id;
}
-
+/**
+ * Display or retrieve the current post title with optional content.
+ *
+ * @since 0.71
+ *
+ * @param string $before Optional. Content to prepend to the title.
+ * @param string $after Optional. Content to append to the title.
+ * @param bool $echo Optional, default to true.Whether to display or return.
+ * @return null|string Null on no title. String if $echo parameter is false.
+ */
function the_title($before = '', $after = '', $echo = true) {
$title = get_the_title();
return $title;
}
+/**
+ * Sanitize the current title when retrieving or displaying.
+ *
+ * Works like {@link the_title()}, except the parameters can be in a string or
+ * an array. See the function for what can be override in the $args parameter.
+ *
+ * The title before it is displayed will have the tags stripped and {@link
+ * attribute_escape()} before it is passed to the user or displayed. The default
+ * as with {@link the_title()}, is to display the title.
+ *
+ * @since 2.3.0
+ *
+ * @param string|array $args Optional. Override the defaults.
+ * @return string|null Null on failure or display. String when echo is false.
+ */
function the_title_attribute( $args = '' ) {
$title = get_the_title();
return $title;
}
+/**
+ * Retrieve post title.
+ *
+ * If the post is protected and the visitor is not an admin, then "Protected"
+ * will be displayed before the post title. If the post is private, then
+ * "Private" will be located before the post title.
+ *
+ * @since 0.71
+ *
+ * @param int $id Optional. Post ID.
+ * @return string
+ */
function get_the_title( $id = 0 ) {
$post = &get_post($id);
return apply_filters( 'the_title', $title );
}
+/**
+ * Display the Post Global Unique Identifier (guid).
+ *
+ * The guid will appear to be a link, but should not be used as an link to the
+ * post. The reason you should not use it as a link, is because of moving the
+ * blog across domains.
+ *
+ * @since 1.5.0
+ *
+ * @param int $id Optional. Post ID.
+ */
function the_guid( $id = 0 ) {
echo get_the_guid($id);
}
+/**
+ * Retrieve the Post Global Unique Identifier (guid).
+ *
+ * The guid will appear to be a link, but should not be used as an link to the
+ * post. The reason you should not use it as a link, is because of moving the
+ * blog across domains.
+ *
+ * @since 1.5.0
+ *
+ * @param int $id Optional. Post ID.
+ * @return string
+ */
function get_the_guid( $id = 0 ) {
$post = &get_post($id);
return apply_filters('get_the_guid', $post->guid);
}
-function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
+/**
+ * Display the post content.
+ *
+ * @since 0.71
+ *
+ * @param string $more_link_text Optional. Content for when there is more text.
+ * @param string $stripteaser Optional. Teaser content before the more text.
+ * @param string $more_file Optional. Not used.
+ */
+function the_content($more_link_text = null, $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
}
-
-function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
+/**
+ * Retrieve the post content.
+ *
+ * @since 0.71
+ *
+ * @param string $more_link_text Optional. Content for when there is more text.
+ * @param string $stripteaser Optional. Teaser content before the more text.
+ * @param string $more_file Optional. Not used.
+ * @return string
+ */
+function get_the_content($more_link_text = null, $stripteaser = 0, $more_file = '') {
global $id, $post, $more, $page, $pages, $multipage, $preview, $pagenow;
+ if ( null === $more_link_text )
+ $more_link_text = __( '(more...)' );
+
$output = '';
- if ( !empty($post->post_password) ) { // if there's a password
- if ( !isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password ) { // and it doesn't match the cookie
- $output = get_the_password_form();
- return $output;
- }
+ // If post password required and it doesn't match the cookie.
+ if ( post_password_required($post) ) {
+ $output = get_the_password_form();
+ return $output;
}
if ( $more_file != '' )
}
if ( $preview ) // preview fix for javascript bug with foreign languages
- $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output);
+ $output = preg_replace_callback('/\%u([0-9A-F]{4})/', create_function('$match', 'return "&#" . base_convert($match[1], 16, 10) . ";";'), $output);
return $output;
}
-
+/**
+ * Display the post excerpt.
+ *
+ * @since 0.71
+ * @uses apply_filters() Calls 'the_excerpt' hook on post excerpt.
+ */
function the_excerpt() {
echo apply_filters('the_excerpt', get_the_excerpt());
}
-
+/**
+ * Retrieve the post excerpt.
+ *
+ * @since 0.71
+ *
+ * @param mixed $deprecated Not used.
+ * @return string
+ */
function get_the_excerpt($deprecated = '') {
global $post;
$output = '';
$output = $post->post_excerpt;
- if ( !empty($post->post_password) ) { // if there's a password
- if ( !isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password ) { // and it doesn't match the cookie
- $output = __('There is no excerpt because this is a protected post.');
- return $output;
- }
+ if ( post_password_required($post) ) {
+ $output = __('There is no excerpt because this is a protected post.');
+ return $output;
}
return apply_filters('get_the_excerpt', $output);
}
+/**
+ * Whether post has excerpt.
+ *
+ * @since 2.3.0
+ *
+ * @param int $id Optional. Post ID.
+ * @return bool
+ */
function has_excerpt( $id = 0 ) {
$post = &get_post( $id );
return ( !empty( $post->post_excerpt ) );
}
+/**
+ * Display the classes for the post div.
+ *
+ * @since 2.7.0
+ *
+ * @param string|array $class One or more classes to add to the class list.
+ * @param int $post_id An optional post ID.
+ */
+function post_class( $class = '', $post_id = null ) {
+ // Separates classes with a single space, collates classes for post DIV
+ echo 'class="' . join( ' ', get_post_class( $class, $post_id ) ) . '"';
+}
+
+/**
+ * Retrieve the classes for the post div as an array.
+ *
+ * The class names are add are many. If the post is a sticky, then the 'sticky'
+ * class name. The class 'hentry' is always added to each post. For each
+ * category, the class will be added with 'category-' with category slug is
+ * added. The tags are the same way as the categories with 'tag-' before the tag
+ * slug. All classes are passed through the filter, 'post_class' with the list
+ * of classes, followed by $class parameter value, with the post ID as the last
+ * parameter.
+ *
+ * @since 2.7.0
+ *
+ * @param string|array $class One or more classes to add to the class list.
+ * @param int $post_id An optional post ID.
+ * @return array Array of classes.
+ */
+function get_post_class( $class = '', $post_id = null ) {
+ $post = get_post($post_id);
+
+ $classes = array();
+
+ $classes[] = $post->post_type;
+
+ // sticky for Sticky Posts
+ if ( is_sticky($post->ID) && is_home())
+ $classes[] = 'sticky';
+
+ // hentry for hAtom compliace
+ $classes[] = 'hentry';
+
+ // Categories
+ foreach ( (array) get_the_category($post->ID) as $cat ) {
+ if ( empty($cat->slug ) )
+ continue;
+ $classes[] = 'category-' . $cat->slug;
+ }
+
+ // Tags
+ foreach ( (array) get_the_tags($post->ID) as $tag ) {
+ if ( empty($tag->slug ) )
+ continue;
+ $classes[] = 'tag-' . $tag->slug;
+ }
+
+ if ( !empty($class) ) {
+ if ( !is_array( $class ) )
+ $class = preg_split('#\s+#', $class);
+ $classes = array_merge($classes, $class);
+ }
+
+ return apply_filters('post_class', $classes, $class, $post_id);
+}
+
+/**
+ * Whether post requires password and correct password has been provided.
+ *
+ * @since 2.7.0
+ *
+ * @param int|object $post An optional post. Global $post used if not provided.
+ * @return bool false if a password is not required or the correct password cookie is present, true otherwise.
+ */
+function post_password_required( $post = null ) {
+ $post = get_post($post);
+
+ if ( empty($post->post_password) )
+ return false;
+
+ if ( !isset($_COOKIE['wp-postpass_' . COOKIEHASH]) )
+ return true;
+
+ if ( $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password )
+ return true;
+
+ return false;
+}
+
+/**
+ * Display "sticky" CSS class, if a post is sticky.
+ *
+ * @since 2.7.0
+ *
+ * @param int $post_id An optional post ID.
+ */
+function sticky_class( $post_id = null ) {
+ if ( !is_sticky($post_id) )
+ return;
+
+ echo " sticky";
+}
+
+/**
+ * Page Template Functions for usage in Themes
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * The formatted output of a list of pages.
+ *
+ * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.
+ * Quicktag one or more times). This tag must be within The Loop.
+ *
+ * The defaults for overwriting are:
+ * 'next_or_number' - Default is 'number' (string). Indicates whether page
+ * numbers should be used. Valid values are number and next.
+ * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page.
+ * of the bookmark.
+ * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to
+ * previous page, if available.
+ * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in
+ * the parameter string will be replaced with the page number, so Page %
+ * generates "Page 1", "Page 2", etc. Defaults to %, just the page number.
+ * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to
+ * each bookmarks.
+ * 'after' - Default is '</p>' (string). The html or text to append to each
+ * bookmarks.
+ * 'more_file' - Default is '' (string) Page the links should point to. Defaults
+ * to the current page.
+ * 'link_before' - Default is '' (string). The html or text to prepend to each
+ * Pages link inside the <a> tag.
+ * 'link_after' - Default is '' (string). The html or text to append to each
+ * Pages link inside the <a> tag.
+ *
+ * @since 1.2.0
+ * @access private
+ *
+ * @param string|array $args Optional. Overwrite the defaults.
+ * @return string Formatted output in HTML.
+ */
function wp_link_pages($args = '') {
$defaults = array(
'before' => '<p>' . __('Pages:'), 'after' => '</p>',
+ 'link_before' => '', 'link_after' => '',
'next_or_number' => 'number', 'nextpagelink' => __('Next page'),
'previouspagelink' => __('Previous page'), 'pagelink' => '%',
'more_file' => '', 'echo' => 1
else
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';
}
+
}
+ $output .= $link_before;
$output .= $j;
+ $output .= $link_after;
if ( ($i != $page) || ((!$more) && ($page==1)) )
$output .= '</a>';
}
$i = $page - 1;
if ( $i && $more ) {
if ( 1 == $i ) {
- $output .= '<a href="' . get_permalink() . '">' . $previouspagelink . '</a>';
+ $output .= '<a href="' . get_permalink() . '">' . $link_before. $previouspagelink . $link_after . '</a>';
} else {
if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
- $output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $previouspagelink . '</a>';
+ $output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $link_before. $previouspagelink . $link_after . '</a>';
else
- $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $previouspagelink . '</a>';
+ $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $link_before. $previouspagelink . $link_after . '</a>';
}
}
$i = $page + 1;
if ( $i <= $numpages && $more ) {
if ( 1 == $i ) {
- $output .= '<a href="' . get_permalink() . '">' . $nextpagelink . '</a>';
+ $output .= '<a href="' . get_permalink() . '">' . $link_before. $nextpagelink . $link_after . '</a>';
} else {
if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
- $output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $nextpagelink . '</a>';
+ $output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $link_before. $nextpagelink . $link_after . '</a>';
else
- $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $nextpagelink . '</a>';
+ $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $link_before. $nextpagelink . $link_after . '</a>';
}
}
$output .= $after;
// Post-meta: Custom per-post fields.
//
-
+/**
+ * Retrieve post custom meta data field.
+ *
+ * @since 1.5.0
+ *
+ * @param string $key Meta data key name.
+ * @return string|array Array of values or single value, if only one element exists.
+ */
function post_custom( $key = '' ) {
$custom = get_post_custom();
return $custom[$key];
}
-
-// this will probably change at some point...
+/**
+ * Display list of post custom fields.
+ *
+ * @internal This will probably change at some point...
+ * @since 1.2.0
+ * @uses apply_filters() Calls 'the_meta_key' on list item HTML content, with key and value as separate parameters.
+ */
function the_meta() {
if ( $keys = get_post_custom_keys() ) {
echo "<ul class='post-meta'>\n";
- foreach ( $keys as $key ) {
+ foreach ( (array) $keys as $key ) {
$keyt = trim($key);
if ( '_' == $keyt{0} )
continue;
}
}
-
//
// Pages
//
+/**
+ * Retrieve or display list of pages as a dropdown (select list).
+ *
+ * @since 2.1.0
+ *
+ * @param array|string $args Optional. Override default arguments.
+ * @return string HTML content, if not displaying.
+ */
function wp_dropdown_pages($args = '') {
$defaults = array(
'depth' => 0, 'child_of' => 0,
'selected' => 0, 'echo' => 1,
- 'name' => 'page_id', 'show_option_none' => ''
+ 'name' => 'page_id', 'show_option_none' => '', 'show_option_no_change' => '',
+ 'option_none_value' => ''
);
$r = wp_parse_args( $args, $defaults );
$output = '';
if ( ! empty($pages) ) {
- $output = "<select name='$name' id='$name'>\n";
+ $output = "<select name=\"$name\" id=\"$name\">\n";
+ if ( $show_option_no_change )
+ $output .= "\t<option value=\"-1\">$show_option_no_change</option>";
if ( $show_option_none )
- $output .= "\t<option value=''>$show_option_none</option>\n";
+ $output .= "\t<option value=\"$option_none_value\">$show_option_none</option>\n";
$output .= walk_page_dropdown_tree($pages, $depth, $r);
$output .= "</select>\n";
}
return $output;
}
+/**
+ * Retrieve or display list of pages in list (li) format.
+ *
+ * @since 1.5.0
+ *
+ * @param array|string $args Optional. Override default arguments.
+ * @return string HTML content, if not displaying.
+ */
function wp_list_pages($args = '') {
$defaults = array(
'depth' => 0, 'show_date' => '',
'date_format' => get_option('date_format'),
'child_of' => 0, 'exclude' => '',
'title_li' => __('Pages'), 'echo' => 1,
- 'authors' => '', 'sort_column' => 'menu_order, post_title'
+ 'authors' => '', 'sort_column' => 'menu_order, post_title',
+ 'link_before' => '', 'link_after' => ''
);
$r = wp_parse_args( $args, $defaults );
$current_page = 0;
// sanitize, mostly to keep spaces out
- $r['exclude'] = preg_replace('[^0-9,]', '', $r['exclude']);
+ $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
// Allow plugins to filter an array of excluded pages
$r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));
return $output;
}
+/**
+ * Display or retrieve list of pages with optional home link.
+ *
+ * The arguments are listed below and part of the arguments are for {@link
+ * wp_list_pages()} function. Check that function for more info on those
+ * arguments.
+ *
+ * <ul>
+ * <li><strong>sort_column</strong> - How to sort the list of pages. Defaults
+ * to page title. Use column for posts table.</li>
+ * <li><strong>menu_class</strong> - Class to use for the div ID which contains
+ * the page list. Defaults to 'menu'.</li>
+ * <li><strong>echo</strong> - Whether to echo list or return it. Defaults to
+ * echo.</li>
+ * <li><strong>link_before</strong> - Text before show_home argument text.</li>
+ * <li><strong>link_after</strong> - Text after show_home argument text.</li>
+ * <li><strong>show_home</strong> - If you set this argument, then it will
+ * display the link to the home page. The show_home argument really just needs
+ * to be set to the value of the text of the link.</li>
+ * </ul>
+ *
+ * @since 2.7.0
+ *
+ * @param array|string $args
+ */
+function wp_page_menu( $args = array() ) {
+ $defaults = array('sort_column' => 'post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
+ $args = wp_parse_args( $args, $defaults );
+ $args = apply_filters( 'wp_page_menu_args', $args );
+
+ $menu = '';
+
+ $list_args = $args;
+
+ // Show Home in the menu
+ if ( isset($args['show_home']) && ! empty($args['show_home']) ) {
+ if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )
+ $text = __('Home');
+ else
+ $text = $args['show_home'];
+ $class = '';
+ if ( is_front_page() && !is_paged() )
+ $class = 'class="current_page_item"';
+ $menu .= '<li ' . $class . '><a href="' . get_option('home') . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
+ // If the front page is a page, add it to the exclude list
+ if (get_option('show_on_front') == 'page') {
+ if ( !empty( $list_args['exclude'] ) ) {
+ $list_args['exclude'] .= ',';
+ } else {
+ $list_args['exclude'] = '';
+ }
+ $list_args['exclude'] .= get_option('page_on_front');
+ }
+ }
+
+ $list_args['echo'] = false;
+ $list_args['title_li'] = '';
+ $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) );
+
+ if ( $menu )
+ $menu = '<ul>' . $menu . '</ul>';
+
+ $menu = '<div class="' . $args['menu_class'] . '">' . $menu . "</div>\n";
+ $menu = apply_filters( 'wp_page_menu', $menu, $args );
+ if ( $args['echo'] )
+ echo $menu;
+ else
+ return $menu;
+}
+
//
// Page helpers
//
-function walk_page_tree() {
+/**
+ * Retrieve HTML list content for page list.
+ *
+ * @uses Walker_Page to create HTML list content.
+ * @since 2.1.0
+ * @see Walker_Page::walk() for parameters and return description.
+ */
+function walk_page_tree($pages, $depth, $current_page, $r) {
$walker = new Walker_Page;
- $args = func_get_args();
+ $args = array($pages, $depth, $r, $current_page);
return call_user_func_array(array(&$walker, 'walk'), $args);
}
+/**
+ * Retrieve HTML dropdown (select) content for page list.
+ *
+ * @uses Walker_PageDropdown to create HTML dropdown content.
+ * @since 2.1.0
+ * @see Walker_PageDropdown::walk() for parameters and return description.
+ */
function walk_page_dropdown_tree() {
$walker = new Walker_PageDropdown;
$args = func_get_args();
// Attachments
//
+/**
+ * Display an attachment page link using an image or icon.
+ *
+ * @since 2.0.0
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $fullsize Optional, default is false. Whether to use full size.
+ * @param bool $deprecated Deprecated. Not used.
+ * @param bool $permalink Optional, default is false. Whether to include permalink.
+ */
function the_attachment_link($id = 0, $fullsize = false, $deprecated = false, $permalink = false) {
if ( $fullsize )
echo wp_get_attachment_link($id, 'full', $permalink);
echo wp_get_attachment_link($id, 'thumbnail', $permalink);
}
-// get an attachment page link using an image or icon if possible
+/**
+ * Retrieve an attachment page link using an image or icon, if possible.
+ *
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'wp_get_attachment_link' filter on HTML content with same parameters as function.
+ *
+ * @param int $id Optional. Post ID.
+ * @param string $size Optional. Image size.
+ * @param bool $permalink Optional, default is false. Whether to add permalink to image.
+ * @param bool $icon Optional, default is false. Whether to include icon.
+ * @return string HTML content.
+ */
function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false) {
$id = intval($id);
$_post = & get_post( $id );
if ( !$link_text )
$link_text = $_post->post_title;
- return "<a href='$url' title='$post_title'>$link_text</a>";
-
+ return apply_filters( 'wp_get_attachment_link', "<a href='$url' title='$post_title'>$link_text</a>", $id, $size, $permalink, $icon );
}
-// deprecated - use wp_get_attachment_link()
+/**
+ * Retrieve HTML content of attachment image with link.
+ *
+ * @since 2.0.0
+ * @deprecated Use {@link wp_get_attachment_link()}
+ * @see wp_get_attachment_link() Use instead.
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $fullsize Optional, default is false. Whether to use full size image.
+ * @param array $max_dims Optional. Max image dimensions.
+ * @param bool $permalink Optional, default is false. Whether to include permalink to image.
+ * @return string
+ */
function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
$id = (int) $id;
$_post = & get_post($id);
return "<a href='$url' title='$post_title'>$innerHTML</a>";
}
-
-// deprecated: use wp_get_attachment_image_src()
+/**
+ * Retrieve icon URL and Path.
+ *
+ * @since 2.1.0
+ * @deprecated Use {@link wp_get_attachment_image_src()}
+ * @see wp_get_attachment_image_src() Use instead.
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $fullsize Optional, default to false. Whether to have full image.
+ * @return array Icon URL and full path to file, respectively.
+ */
function get_attachment_icon_src( $id = 0, $fullsize = false ) {
$id = (int) $id;
if ( !$post = & get_post($id) )
return array($src, $src_file);
}
-// deprecated: use wp_get_attachment_image()
+/**
+ * Retrieve HTML content of icon attachment image element.
+ *
+ * @since 2.0.0
+ * @deprecated Use {@link wp_get_attachment_image()}
+ * @see wp_get_attachment_image() Use instead of.
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $fullsize Optional, default to false. Whether to have full size image.
+ * @param array $max_dims Optional. Dimensions of image.
+ * @return string HTML content.
+ */
function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
$id = (int) $id;
if ( !$post = & get_post($id) )
return false;
-
+
if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
return false;
return apply_filters( 'attachment_icon', $icon, $post->ID );
}
-// deprecated: use wp_get_attachment_image()
+/**
+ * Retrieve HTML content of image element.
+ *
+ * @since 2.0.0
+ * @deprecated Use {@link wp_get_attachment_image()}
+ * @see wp_get_attachment_image() Use instead.
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $fullsize Optional, default to false. Whether to have full size image.
+ * @param array $max_dims Optional. Dimensions of image.
+ * @return string
+ */
function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
$id = (int) $id;
if ( !$post = & get_post($id) )
return apply_filters('attachment_innerHTML', $innerHTML, $post->ID);
}
+/**
+ * Wrap attachment in <<p>> element before content.
+ *
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'prepend_attachment' hook on HTML content.
+ *
+ * @param string $content
+ * @return string
+ */
function prepend_attachment($content) {
global $post;
// Misc
//
+/**
+ * Retrieve protected post password form content.
+ *
+ * @since 1.0.0
+ * @uses apply_filters() Calls 'the_password_form' filter on output.
+ *
+ * @return string HTML content for password form for password protected post.
+ */
function get_the_password_form() {
global $post;
$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
<p><label for="' . $label . '">' . __("Password:") . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . __("Submit") . '" /></p>
</form>
';
- return $output;
+ return apply_filters('the_password_form', $output);
}
/**
- * is_page_template() - Determine wether or not we are in a page template
+ * Whether currently in a page template.
+ *
+ * This template tag allows you to determine whether or not you are in a page
+ * template. You can optional provide a template name and then the check will be
+ * specific to that template.
*
- * This template tag allows you to determine wether or not you are in a page template.
- * You can optional provide a template name and then the check will be specific to
- * that template.
+ * @since 2.5.0
+ * @uses $wp_query
*
- * @package Template Tags
- * @global object $wp_query
- * @param string $template The specific template name if specific matching is required
+ * @param string $template The specific template name if specific matching is required.
+ * @return bool False on failure, true if success.
*/
function is_page_template($template = '') {
if (!is_page()) {
}
/**
- * wp_post_revision_title() - returns formatted datetimestamp of a revision (linked to that revisions's page)
+ * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
* @uses date_i18n()
*
- * @param int|object $revision revision ID or revision object
- * @param bool $link optional Link to revisions's page?
- * @return string i18n formatted datetimestamp or localized 'Corrent Revision'
+ * @param int|object $revision Revision ID or revision object.
+ * @param bool $link Optional, default is true. Link to revisions's page?
+ * @return string i18n formatted datetimestamp or localized 'Current Revision'.
*/
function wp_post_revision_title( $revision, $link = true ) {
if ( !$revision = get_post( $revision ) )
$autosavef = __( '%s [Autosave]' );
$currentf = __( '%s [Current Revision]' );
- $date = date_i18n( $datef, strtotime( $revision->post_modified_gmt . ' +0000' ) );
+ $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
$date = "<a href='$link'>$date</a>";
}
/**
- * wp_list_post_revisions() - echoes list of a post's revisions
+ * Display list of a post's revisions.
*
- * Can output either a UL with edit links or a TABLE with diff interface, and restore action links
+ * Can output either a UL with edit links or a TABLE with diff interface, and
+ * restore action links.
*
* Second argument controls parameters:
- * (bool) parent : include the parent (the "Current Revision") in the list
- * (string) format : 'list' or 'form-table'. 'list' outputs UL, 'form-table' outputs TABLE with UI
- * (int) right : what revision is currently being viewed - used in form-table format
- * (int) left : what revision is currently being diffed against right - used in form-table format
+ * (bool) parent : include the parent (the "Current Revision") in the list.
+ * (string) format : 'list' or 'form-table'. 'list' outputs UL, 'form-table'
+ * outputs TABLE with UI.
+ * (int) right : what revision is currently being viewed - used in
+ * form-table format.
+ * (int) left : what revision is currently being diffed against right -
+ * used in form-table format.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
* @uses wp_get_post_revisions()
* @uses wp_post_revision_title()
* @uses get_edit_post_link()
* @uses get_author_name()
*
- * @param int|object $post_id post ID or post object
- * @param string|array $args see description @see wp_parse_args()
+ * @todo split into two functions (list, form-table) ?
+ *
+ * @param int|object $post_id Post ID or post object.
+ * @param string|array $args See description {@link wp_parse_args()}.
+ * @return null
*/
-function wp_list_post_revisions( $post_id = 0, $args = null ) { // TODO? split into two functions (list, form-table) ?
+function wp_list_post_revisions( $post_id = 0, $args = null ) {
if ( !$post = get_post( $post_id ) )
return;
<br class="clear" />
-<table class="widefat post-revisions">
+<table class="widefat post-revisions" cellspacing="0">
<col />
<col style="width: 33%" />
<col style="width: 33%" />
/**
* Post functions and post utility function.
*
- * Warning: The inline documentation for the functions contained
- * in this file might be inaccurate, so the documentation is not
- * authoritative at the moment.
- *
* @package WordPress
* @subpackage Post
- * @since 1.5
+ * @since 1.5.0
*/
/**
* prevent looking up the meta name and provide a mechanism for sending the
* attached filename through a filter.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.0
- * @uses apply_filters() Calls 'get_attached_file' on file path and attachment ID
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'get_attached_file' on file path and attachment ID.
*
- * @param int $attachment_id Attachment ID
- * @param bool $unfiltered Whether to apply filters or not
+ * @param int $attachment_id Attachment ID.
+ * @param bool $unfiltered Whether to apply filters or not.
* @return string The file path to the attached file.
*/
function get_attached_file( $attachment_id, $unfiltered = false ) {
$file = get_post_meta( $attachment_id, '_wp_attached_file', true );
+ // If the file is relative, prepend upload dir
+ if ( 0 !== strpos($file, '/') && !preg_match('|^.:\\\|', $file) && ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) )
+ $file = $uploads['basedir'] . "/$file";
if ( $unfiltered )
return $file;
return apply_filters( 'get_attached_file', $file, $attachment_id );
* Used to update the file path of the attachment, which uses post meta name
* '_wp_attached_file' to store the path of the attachment.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.1
- * @uses apply_filters() Calls 'update_attached_file' on file path and attachment ID
+ * @since 2.1.0
+ * @uses apply_filters() Calls 'update_attached_file' on file path and attachment ID.
*
* @param int $attachment_id Attachment ID
* @param string $file File path for the attachment
$file = apply_filters( 'update_attached_file', $file, $attachment_id );
+ // Make the file path relative to the upload dir
+ if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { // Get upload directory
+ if ( 0 === strpos($file, $uploads['basedir']) ) {// Check that the upload base exists in the file path
+ $file = str_replace($uploads['basedir'], '', $file); // Remove upload dir from the file path
+ $file = ltrim($file, '/');
+ }
+ }
+
return update_post_meta( $attachment_id, '_wp_attached_file', $file );
}
* example of what is possible.
*
* The arguments listed as defaults are for this function and also of the
- * get_posts() function. The arguments are combined with the get_children
- * defaults and are then passed to the get_posts() function, which accepts
- * additional arguments. You can replace the defaults in this function, listed
- * below and the additional arguments listed in the get_posts() function.
+ * {@link get_posts()} function. The arguments are combined with the
+ * get_children defaults and are then passed to the {@link get_posts()}
+ * function, which accepts additional arguments. You can replace the defaults in
+ * this function, listed below and the additional arguments listed in the
+ * {@link get_posts()} function.
*
* The 'post_parent' is the most important argument and important attention
* needs to be paid to the $args parameter. If you pass either an object or an
* @see get_posts() Has additional arguments that can be replaced.
* @internal Claims made in the long description might be inaccurate.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.0
+ * @since 2.0.0
*
* @param mixed $args Optional. User defined arguments for replacing the defaults.
* @param string $output Optional. Constant for return type, either OBJECT (default), ARRAY_A, ARRAY_N.
}
$defaults = array(
- 'numberposts' => -1, 'post_type' => '',
- 'post_status' => '', 'post_parent' => 0
+ 'numberposts' => -1, 'post_type' => 'any',
+ 'post_status' => 'any', 'post_parent' => 0,
);
$r = wp_parse_args( $args, $defaults );
$children = get_posts( $r );
- if ( !$children )
- return false;
+ if ( !$children ) {
+ $kids = false;
+ return $kids;
+ }
update_post_cache($children);
if ( $output == OBJECT ) {
return $kids;
} elseif ( $output == ARRAY_A ) {
- foreach ( $kids as $kid )
+ foreach ( (array) $kids as $kid )
$weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
return $weeuns;
} elseif ( $output == ARRAY_N ) {
- foreach ( $kids as $kid )
+ foreach ( (array) $kids as $kid )
$babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
return $babes;
} else {
}
/**
- * get_extended() - Get extended entry info (<!--more-->)
+ * Get extended entry info (<!--more-->).
*
- * {@internal Missing Long Description}}
+ * There should not be any space after the second dash and before the word
+ * 'more'. There can be text or space(s) after the word 'more', but won't be
+ * referenced.
+ *
+ * The returned array has 'main' and 'extended' keys. Main has the text before
+ * the <code><!--more--></code>. The 'extended' key has the content after the
+ * <code><!--more--></code> comment.
*
- * @package WordPress
- * @subpackage Post
* @since 1.0.0
*
- * @param string $post {@internal Missing Description}}
- * @return array {@internal Missing Description}}
+ * @param string $post Post content.
+ * @return array Post before ('main') and after ('extended').
*/
function get_extended($post) {
//Match the new style more links
}
/**
- * get_post() - Retrieves post data given a post ID or post object.
+ * Retrieves post data given a post ID or post object.
*
- * {@internal Missing Long Description}}
+ * See {@link sanitize_post()} for optional $filter values. Also, the parameter
+ * $post, must be given as a variable, since it is passed by reference.
*
- * @package WordPress
- * @subpackage Post
* @since 1.5.1
* @uses $wpdb
* @link http://codex.wordpress.org/Function_Reference/get_post
*
- * @param int|object &$post post ID or post object
- * @param string $output {@internal Missing Description}}
- * @param string $filter {@internal Missing Description}}
- * @return mixed {@internal Missing Description}}
+ * @param int|object $post Post ID or post object.
+ * @param string $output Optional, default is Object. Either OBJECT, ARRAY_A, or ARRAY_N.
+ * @param string $filter Optional, default is raw.
+ * @return mixed Post data
*/
function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
global $wpdb;
$_post = & $GLOBALS['post'];
else
return $null;
- } elseif ( is_object($post) ) {
+ } elseif ( is_object($post) && empty($post->filter) ) {
_get_post_ancestors($post);
wp_cache_add($post->ID, $post, 'posts');
$_post = &$post;
} else {
+ if ( is_object($post) )
+ $post = $post->ID;
$post = (int) $post;
if ( ! $_post = wp_cache_get($post, 'posts') ) {
- $_post = & $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post));
+ $_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post));
if ( ! $_post )
return $null;
_get_post_ancestors($_post);
/**
* Retrieve ancestors of a post.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.5
+ * @since 2.5.0
*
* @param int|object $post Post ID or post object
* @return array Ancestor IDs or empty array if none are found.
* The context values are based off of the taxonomy filter functions and
* supported values are found within those functions.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.3
+ * @since 2.3.0
* @uses sanitize_post_field() See for possible $context values.
*
* @param string $field Post field name
* This function can be used with any post type, but it makes more sense with
* attachments.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.0
+ * @since 2.0.0
*
* @param int $ID Optional. Post ID.
* @return bool|string False on failure or returns the mime type
* If the post ID is of an attachment, then the parent post status will be given
* instead.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.0
+ * @since 2.0.0
*
* @param int $ID Post ID
* @return string|bool Post status or false on failure.
* Posts have a limited set of valid status values, this provides the
* post_status values and descriptions.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.5
+ * @since 2.5.0
*
* @return array List of post statuses.
*/
* Pages have a limited set of valid status values, this provides the
* post_status values and descriptions.
*
- * @package WordPress
- * @subpackage Page
- * @since 2.5
+ * @since 2.5.0
*
* @return array List of page statuses.
*/
}
/**
- * get_post_type() - Returns post type
- *
- * {@internal Missing Long Description}}
+ * Retrieve the post type of the current post or of a given post.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * @since 2.1.0
*
* @uses $wpdb
- * @uses $posts {@internal Missing Description}}
+ * @uses $posts The Loop post global
*
- * @param mixed $post post object or post ID
- * @return mixed post type or false
+ * @param mixed $post Optional. Post object or post ID.
+ * @return bool|string post type or false on failure.
*/
function get_post_type($post = false) {
global $posts;
}
/**
- * set_post_type() - Set post type
+ * Updates the post type for the post ID.
*
- * {@internal Missing Long Description}}
+ * The page or post cache will be cleaned for the post ID.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.5
+ * @since 2.5.0
*
* @uses $wpdb
- * @uses $posts {@internal Missing Description}}
*
- * @param mixed $post_id post ID
- * @param mixed post type
- * @return bool {@internal Missing Description}}
+ * @param int $post_id Post ID to change post type. Not actually optional.
+ * @param string $post_type Optional, default is post. Supported values are 'post' or 'page' to name a few.
+ * @return int Amount of rows changed. Should be 1 for success and 0 for failure.
*/
function set_post_type( $post_id = 0, $post_type = 'post' ) {
global $wpdb;
}
/**
- * get_posts() - Returns a number of posts
+ * Retrieve list of latest posts or posts matching criteria.
*
- * {@internal Missing Long Description}}
+ * The defaults are as follows:
+ * 'numberposts' - Default is 5. Total number of posts to retrieve.
+ * 'offset' - Default is 0. See {@link WP_Query::query()} for more.
+ * 'category' - What category to pull the posts from.
+ * 'orderby' - Default is 'post_date'. How to order the posts.
+ * 'order' - Default is 'DESC'. The order to retrieve the posts.
+ * 'include' - See {@link WP_Query::query()} for more.
+ * 'exclude' - See {@link WP_Query::query()} for more.
+ * 'meta_key' - See {@link WP_Query::query()} for more.
+ * 'meta_value' - See {@link WP_Query::query()} for more.
+ * 'post_type' - Default is 'post'. Can be 'page', or 'attachment' to name a few.
+ * 'post_parent' - The parent of the post or post type.
+ * 'post_status' - Default is 'published'. Post status to retrieve.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.2
+ * @since 1.2.0
* @uses $wpdb
+ * @uses WP_Query::query() See for more default arguments and information.
* @link http://codex.wordpress.org/Template_Tags/get_posts
*
- * @param array $args {@internal Missing Description}}
- * @return array {@internal Missing Description}}
+ * @param array $args Optional. Override defaults.
+ * @return array List of posts.
*/
function get_posts($args = null) {
$defaults = array(
'order' => 'DESC', 'include' => '',
'exclude' => '', 'meta_key' => '',
'meta_value' =>'', 'post_type' => 'post',
- 'post_parent' => 0, 'suppress_filters' => true
+ 'suppress_filters' => true
);
$r = wp_parse_args( $args, $defaults );
} elseif ( ! empty($r['exclude']) )
$r['post__not_in'] = preg_split('/[\s,]+/',$r['exclude']);
+ $r['caller_get_posts'] = true;
+
$get_posts = new WP_Query;
return $get_posts->query($r);
//
/**
- * add_post_meta() - adds metadata for post
+ * Add meta data field to a post.
*
- * {@internal Missing Long Description}}
+ * Post meta data is called "Custom Fields" on the Administration Panels.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.5
+ * @since 1.5.0
* @uses $wpdb
* @link http://codex.wordpress.org/Function_Reference/add_post_meta
*
- * @param int $post_id post ID
- * @param string $key {@internal Missing Description}}
- * @param mixed $value {@internal Missing Description}}
- * @param bool $unique whether to check for a value with the same key
- * @return bool {@internal Missing Description}}
+ * @param int $post_id Post ID.
+ * @param string $key Metadata name.
+ * @param mixed $value Metadata value.
+ * @param bool $unique Optional, default is false. Whether the same key should not be added.
+ * @return bool False for failure. True for success.
*/
function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) {
global $wpdb;
if ( $unique && $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->postmeta WHERE meta_key = %s AND post_id = %d", $meta_key, $post_id ) ) )
return false;
- $meta_value = maybe_serialize($meta_value);
+ $meta_value = maybe_serialize( stripslashes_deep($meta_value) );
$wpdb->insert( $wpdb->postmeta, compact( 'post_id', 'meta_key', 'meta_value' ) );
}
/**
- * delete_post_meta() - delete post metadata
+ * Remove metadata matching criteria from a post.
*
- * {@internal Missing Long Description}}
+ * You can match based on the key, or key and value. Removing based on key and
+ * value, will keep from removing duplicate metadata with the same key. It also
+ * allows removing all metadata matching key, if needed.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.5
+ * @since 1.5.0
* @uses $wpdb
* @link http://codex.wordpress.org/Function_Reference/delete_post_meta
*
* @param int $post_id post ID
- * @param string $key {@internal Missing Description}}
- * @param mixed $value {@internal Missing Description}}
- * @return bool {@internal Missing Description}}
+ * @param string $meta_key Metadata name.
+ * @param mixed $meta_value Optional. Metadata value.
+ * @return bool False for failure. True for success.
*/
-function delete_post_meta($post_id, $key, $value = '') {
+function delete_post_meta($post_id, $meta_key, $meta_value = '') {
global $wpdb;
- $post_id = absint( $post_id );
+ // make sure meta is added to the post, not a revision
+ if ( $the_post = wp_is_post_revision($post_id) )
+ $post_id = $the_post;
- // expected_slashed ($key, $value)
- $key = stripslashes( $key );
- $value = stripslashes( $value );
+ // expected_slashed ($meta_key, $meta_value)
+ $meta_key = stripslashes( $meta_key );
+ $meta_value = maybe_serialize( stripslashes_deep($meta_value) );
- if ( empty( $value ) )
- $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, $key ) );
+ if ( empty( $meta_value ) )
+ $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, $meta_key ) );
else
- $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s AND meta_value = %s", $post_id, $key, $value ) );
+ $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s AND meta_value = %s", $post_id, $meta_key, $meta_value ) );
if ( !$meta_id )
return false;
- if ( empty( $value ) )
- $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, $key ) );
+ if ( empty( $meta_value ) )
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, $meta_key ) );
else
- $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s AND meta_value = %s", $post_id, $key, $value ) );
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s AND meta_value = %s", $post_id, $meta_key, $meta_value ) );
wp_cache_delete($post_id, 'post_meta');
}
/**
- * get_post_meta() - Get a post meta field
- *
- * {@internal Missing Long Description}}
+ * Retrieve post meta field for a post.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.5
+ * @since 1.5.0
* @uses $wpdb
* @link http://codex.wordpress.org/Function_Reference/get_post_meta
*
- * @param int $post_id post ID
- * @param string $key The meta key to retrieve
- * @param bool $single Whether to return a single value
- * @return mixed {@internal Missing Description}}
+ * @param int $post_id Post ID.
+ * @param string $key The meta key to retrieve.
+ * @param bool $single Whether to return a single value.
+ * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true.
*/
function get_post_meta($post_id, $key, $single = false) {
$post_id = (int) $post_id;
}
/**
- * update_post_meta() - Update a post meta field
+ * Update post meta field based on post ID.
*
- * {@internal Missing Long Description}}
+ * Use the $prev_value parameter to differentiate between meta fields with the
+ * same key and post ID.
+ *
+ * If the meta field for the post does not exist, it will be added.
*
- * @package WordPress
- * @subpackage Post
* @since 1.5
* @uses $wpdb
* @link http://codex.wordpress.org/Function_Reference/update_post_meta
*
- * @param int $post_id post ID
- * @param string $key {@internal Missing Description}}
- * @param mixed $value {@internal Missing Description}}
- * @param mixed $prev_value previous value (for differentiating between meta fields with the same key and post ID)
- * @return bool {@internal Missing Description}}
+ * @param int $post_id Post ID.
+ * @param string $key Metadata key.
+ * @param mixed $value Metadata value.
+ * @param mixed $prev_value Optional. Previous value to check before removing.
+ * @return bool False on failure, true if success.
*/
function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') {
global $wpdb;
+ // make sure meta is added to the post, not a revision
+ if ( $the_post = wp_is_post_revision($post_id) )
+ $post_id = $the_post;
+
// expected_slashed ($meta_key)
$meta_key = stripslashes($meta_key);
return add_post_meta($post_id, $meta_key, $meta_value);
}
- $meta_value = maybe_serialize($meta_value);
+ $meta_value = maybe_serialize( stripslashes_deep($meta_value) );
$data = compact( 'meta_value' );
$where = compact( 'meta_key', 'post_id' );
}
/**
- * delete_post_meta_by_key() - Delete everything from post meta matching $post_meta_key
+ * Delete everything from post meta matching meta key.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.3
+ * @since 2.3.0
* @uses $wpdb
*
- * @param string $post_meta_key What to search for when deleting
+ * @param string $post_meta_key Key to search for when deleting.
* @return bool Whether the post meta key was deleted from the database
*/
function delete_post_meta_by_key($post_meta_key) {
}
/**
- * get_post_custom() - Retrieve post custom fields
+ * Retrieve post meta fields, based on post ID.
*
- * {@internal Missing Long Description}}
+ * The post meta fields are retrieved from the cache, so the function is
+ * optimized to be called more than once. It also applies to the functions, that
+ * use this function.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.2
+ * @since 1.2.0
* @link http://codex.wordpress.org/Function_Reference/get_post_custom
*
- * @uses $id
- * @uses $wpdb
+ * @uses $id Current Loop Post ID
*
* @param int $post_id post ID
- * @return array {@internal Missing Description}}
+ * @return array
*/
function get_post_custom($post_id = 0) {
global $id;
}
/**
- * get_post_custom_keys() - Retrieve post custom field names
+ * Retrieve meta field names for a post.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.2
+ * If there are no meta fields, then nothing (null) will be returned.
+ *
+ * @since 1.2.0
* @link http://codex.wordpress.org/Function_Reference/get_post_custom_keys
*
* @param int $post_id post ID
- * @return array|null Either array of the keys, or null if keys would not be retrieved
+ * @return array|null Either array of the keys, or null if keys could not be retrieved.
*/
function get_post_custom_keys( $post_id = 0 ) {
$custom = get_post_custom( $post_id );
}
/**
- * get_post_custom_values() - Retrieve values for a custom post field
+ * Retrieve values for a custom post field.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.2
+ * The parameters must not be considered optional. All of the post meta fields
+ * will be retrieved and only the meta field key values returned.
+ *
+ * @since 1.2.0
* @link http://codex.wordpress.org/Function_Reference/get_post_custom_values
*
- * @param string $key field name
- * @param int $post_id post ID
- * @return mixed {@internal Missing Description}}
+ * @param string $key Meta field key.
+ * @param int $post_id Post ID
+ * @return array Meta field values.
*/
function get_post_custom_values( $key = '', $post_id = 0 ) {
$custom = get_post_custom($post_id);
- return $custom[$key];
+ return isset($custom[$key]) ? $custom[$key] : null;
}
/**
- * sanitize_post() - Sanitize every post field
+ * Check if post is sticky.
*
- * {@internal Missing Long Description}}
+ * Sticky posts should remain at the top of The Loop. If the post ID is not
+ * given, then The Loop ID for the current post will be used.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.3
+ * @since 2.7.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @return bool Whether post is sticky (true) or not sticky (false).
+ */
+function is_sticky($post_id = null) {
+ global $id;
+
+ $post_id = absint($post_id);
+
+ if ( !$post_id )
+ $post_id = absint($id);
+
+ $stickies = get_option('sticky_posts');
+
+ if ( !is_array($stickies) )
+ return false;
+
+ if ( in_array($post_id, $stickies) )
+ return true;
+
+ return false;
+}
+
+/**
+ * Sanitize every post field.
+ *
+ * If the context is 'raw', then the post object or array will just be returned.
+ *
+ * @since 2.3.0
+ * @uses sanitize_post_field() Used to sanitize the fields.
*
* @param object|array $post The Post Object or Array
- * @param string $context How to sanitize post fields
+ * @param string $context Optional, default is 'display'. How to sanitize post fields.
* @return object|array The now sanitized Post Object or Array (will be the same type as $post)
*/
function sanitize_post($post, $context = 'display') {
if ( 'raw' == $context )
return $post;
if ( is_object($post) ) {
+ if ( !isset($post->ID) )
+ $post->ID = 0;
foreach ( array_keys(get_object_vars($post)) as $field )
$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
+ $post->filter = $context;
} else {
+ if ( !isset($post['ID']) )
+ $post['ID'] = 0;
foreach ( array_keys($post) as $field )
$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
+ $post['filter'] = $context;
}
+
return $post;
}
/**
- * sanitize_post_field() - Sanitize post field based on context
+ * Sanitize post field based on context.
*
- * {@internal Missing Long Description}}
+ * Possible context values are: raw, edit, db, attribute, js, and display. The
+ * display context is used by default.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.3
+ * @since 2.3.0
*
- * @param string $field The Post Object field name
- * @param string $value The Post Object value
- * @param int $postid Post ID
- * @param string $context How to sanitize post fields
- * @return string Sanitized value
+ * @param string $field The Post Object field name.
+ * @param mixed $value The Post Object value.
+ * @param int $post_id Post ID.
+ * @param string $context How to sanitize post fields.
+ * @return mixed Sanitized value.
*/
function sanitize_post_field($field, $value, $post_id, $context) {
$int_fields = array('ID', 'post_parent', 'menu_order');
return $value;
}
+/**
+ * Make a post sticky.
+ *
+ * Sticky posts should be displayed at the top of the front page.
+ *
+ * @since 2.7.0
+ *
+ * @param int $post_id Post ID.
+ */
+function stick_post($post_id) {
+ $stickies = get_option('sticky_posts');
+
+ if ( !is_array($stickies) )
+ $stickies = array($post_id);
+
+ if ( ! in_array($post_id, $stickies) )
+ $stickies[] = $post_id;
+
+ update_option('sticky_posts', $stickies);
+}
+
+/**
+ * Unstick a post.
+ *
+ * Sticky posts should be displayed at the top of the front page.
+ *
+ * @since 2.7.0
+ *
+ * @param int $post_id Post ID.
+ */
+function unstick_post($post_id) {
+ $stickies = get_option('sticky_posts');
+
+ if ( !is_array($stickies) )
+ return;
+
+ if ( ! in_array($post_id, $stickies) )
+ return;
+
+ $offset = array_search($post_id, $stickies);
+ if ( false === $offset )
+ return;
+
+ array_splice($stickies, $offset, 1);
+
+ update_option('sticky_posts', $stickies);
+}
+
/**
* Count number of posts of a post type and is user has permissions to view.
*
* The $perm parameter checks for 'readable' value and if the user can read
* private posts, it will display that for the user that is signed in.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.5
+ * @since 2.5.0
* @link http://codex.wordpress.org/Template_Tags/wp_count_posts
*
* @param string $type Optional. Post type to retrieve count
/**
- * wp_count_attachments() - Count number of attachments
+ * Count number of attachments for the mime type(s).
*
- * {@internal Missing Long Description}}
+ * If you set the optional mime_type parameter, then an array will still be
+ * returned, but will only have the item you are looking for. It does not give
+ * you the number of attachments that are children of a post. You can get that
+ * by counting the number of children that post has.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.5
+ * @since 2.5.0
*
- * @param string|array $post_mime_type Array or comma-separated list of MIME patterns
- * @return array Number of posts for each post_mime_type
+ * @param string|array $mime_type Optional. Array or comma-separated list of MIME patterns.
+ * @return array Number of posts for each mime type.
*/
-
function wp_count_attachments( $mime_type = '' ) {
global $wpdb;
}
/**
- * wp_match_mime_type() - Check a MIME-Type against a list
+ * Check a MIME-Type against a list.
*
- * {@internal Missing Long Description}}
+ * If the wildcard_mime_types parameter is a string, it must be comma separated
+ * list. If the real_mime_types is a string, it is also comma separated to
+ * create the list.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.5
+ * @since 2.5.0
*
* @param string|array $wildcard_mime_types e.g. audio/mpeg or image (same as image/*) or flash (same as *flash*)
* @param string|array $real_mime_types post_mime_type values
}
/**
- * wp_get_post_mime_type_where() - Convert MIME types into SQL
+ * Convert MIME types into SQL.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.5
+ * @since 2.5.0
*
- * @param string|array $mime_types MIME types
- * @return string SQL AND clause
+ * @param string|array $mime_types List of mime types or comma separated string of mime types.
+ * @return string The SQL AND clause for mime searching.
*/
function wp_post_mime_type_where($post_mime_types) {
$where = '';
}
/**
- * wp_delete_post() - Deletes a Post
+ * Removes a post, attachment, or page.
*
- * {@internal Missing Long Description}}
+ * When the post and page goes, everything that is tied to it is deleted also.
+ * This includes comments, post meta fields, and terms associated with the post.
*
- * @package WordPress
- * @subpackage Post
* @since 1.0.0
+ * @uses do_action() Calls 'deleted_post' hook on post ID.
*
- * @param int $postid post ID
- * @return mixed {@internal Missing Description}}
+ * @param int $postid Post ID.
+ * @return mixed
*/
function wp_delete_post($postid = 0) {
global $wpdb, $wp_rewrite;
}
/**
- * wp_get_post_categories() - Retrieve the list of categories for a post
+ * Retrieve the list of categories for a post.
*
* Compatibility layer for themes and plugins. Also an easy layer of abstraction
* away from the complexity of the taxonomy layer.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * @since 2.1.0
*
- * @uses wp_get_object_terms() Retrieves the categories. Args details can be found here
+ * @uses wp_get_object_terms() Retrieves the categories. Args details can be found here.
*
- * @param int $post_id Optional. The Post ID
- * @param array $args Optional. Overwrite the defaults
- * @return array {@internal Missing Description}}
+ * @param int $post_id Optional. The Post ID.
+ * @param array $args Optional. Overwrite the defaults.
+ * @return array
*/
function wp_get_post_categories( $post_id = 0, $args = array() ) {
$post_id = (int) $post_id;
}
/**
- * wp_get_post_tags() - Retrieve the post tags
+ * Retrieve the tags for a post.
+ *
+ * There is only one default for this function, called 'fields' and by default
+ * is set to 'all'. There are other defaults that can be override in
+ * {@link wp_get_object_terms()}.
*
* @package WordPress
* @subpackage Post
- * @since 2.3
+ * @since 2.3.0
*
* @uses wp_get_object_terms() Gets the tags for returning. Args can be found here
*
* @param int $post_id Optional. The Post ID
* @param array $args Optional. Overwrite the defaults
- * @return mixed The tags the post has currently
+ * @return array List of post tags.
*/
function wp_get_post_tags( $post_id = 0, $args = array() ) {
$post_id = (int) $post_id;
}
/**
- * wp_get_recent_posts() - Get the $num most recent posts
- *
- * {@internal Missing Long Description}}
+ * Retrieve number of recent posts.
*
- * @package WordPress
- * @subpackage Post
* @since 1.0.0
+ * @uses $wpdb
*
- * @param int $num number of posts to get
- * @return array {@internal Missing Description}}
+ * @param int $num Optional, default is 10. Number of posts to get.
+ * @return array List of posts.
*/
function wp_get_recent_posts($num = 10) {
global $wpdb;
$sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC $limit";
$result = $wpdb->get_results($sql,ARRAY_A);
- return $result?$result:array();
+ return $result ? $result : array();
}
/**
- * wp_get_single_post() - Get one post
+ * Retrieve a single post, based on post ID.
*
- * {@internal Missing Long Description}}
+ * Has categories in 'post_category' property or key. Has tags in 'tags_input'
+ * property or key.
*
- * @package WordPress
- * @subpackage Post
* @since 1.0.0
- * @uses $wpdb
*
- * @param int $postid post ID
- * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A
+ * @param int $postid Post ID.
+ * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A.
* @return object|array Post object or array holding post contents and information
*/
function wp_get_single_post($postid = 0, $mode = OBJECT) {
}
/**
- * wp_insert_post() - Insert a post
+ * Insert a post.
*
- * {@internal Missing Long Description}}
+ * If the $postarr parameter has 'ID' set to a value, then post will be updated.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.0.0
+ * You can set the post date manually, but setting the values for 'post_date'
+ * and 'post_date_gmt' keys. You can close the comments or open the comments by
+ * setting the value for 'comment_status' key.
*
+ * The defaults for the parameter $postarr are:
+ * 'post_status' - Default is 'draft'.
+ * 'post_type' - Default is 'post'.
+ * 'post_author' - Default is current user ID. The ID of the user, who added
+ * the post.
+ * 'ping_status' - Default is the value in default ping status option.
+ * Whether the attachment can accept pings.
+ * 'post_parent' - Default is 0. Set this for the post it belongs to, if
+ * any.
+ * 'menu_order' - Default is 0. The order it is displayed.
+ * 'to_ping' - Whether to ping.
+ * 'pinged' - Default is empty string.
+ * 'post_password' - Default is empty string. The password to access the
+ * attachment.
+ * 'guid' - Global Unique ID for referencing the attachment.
+ * 'post_content_filtered' - Post content filtered.
+ * 'post_excerpt' - Post excerpt.
+ *
+ * @since 1.0.0
* @uses $wpdb
* @uses $wp_rewrite
* @uses $user_ID
- * @uses $allowedtags
*
- * @param array $postarr post contents
- * @return int post ID or 0 on error
+ * @param array $postarr Optional. Override defaults.
+ * @param bool $wp_error Optional. Allow return of WP_Error on failure.
+ * @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success.
*/
function wp_insert_post($postarr = array(), $wp_error = false) {
global $wpdb, $wp_rewrite, $user_ID;
$defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '',
- 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '');
+ 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0);
$postarr = wp_parse_args($postarr, $defaults);
$postarr = sanitize_post($postarr, 'db');
}
// Make sure we set a valid category
- if (0 == count($post_category) || !is_array($post_category)) {
+ if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
$post_category = array(get_option('default_category'));
}
+ //Set the default tag list
+ if ( !isset($tags_input) )
+ $tags_input = array();
+
if ( empty($post_author) )
$post_author = $user_ID;
if ( empty($post_type) )
$post_type = 'post';
+ $post_ID = 0;
+
// Get the post ID and GUID
if ( $update ) {
$post_ID = (int) $ID;
$guid = get_post_field( 'guid', $post_ID );
}
- // Create a valid post name. Drafts are allowed to have an empty
+ // Don't allow contributors to set to set the post slug for pending review posts
+ if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) )
+ $post_name = '';
+
+ // Create a valid post name. Drafts and pending posts are allowed to have an empty
// post name.
if ( empty($post_name) ) {
- if ( 'draft' != $post_status )
+ if ( !in_array( $post_status, array( 'draft', 'pending' ) ) )
$post_name = sanitize_title($post_title);
} else {
$post_name = sanitize_title($post_name);
}
- // If the post date is empty (due to having been new or a draft) and status is not 'draft', set date to now
- if ( empty($post_date) || '0000-00-00 00:00:00' == $post_date ) {
- if ( !in_array($post_status, array('draft', 'pending')) )
- $post_date = current_time('mysql');
- else
- $post_date = '0000-00-00 00:00:00';
- }
+ // If the post date is empty (due to having been new or a draft) and status is not 'draft' or 'pending', set date to now
+ if ( empty($post_date) || '0000-00-00 00:00:00' == $post_date )
+ $post_date = current_time('mysql');
if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) {
- if ( !in_array($post_status, array('draft', 'pending')) )
+ if ( !in_array( $post_status, array( 'draft', 'pending' ) ) )
$post_date_gmt = get_gmt_from_date($post_date);
else
$post_date_gmt = '0000-00-00 00:00:00';
else
$post_parent = 0;
+ if ( !empty($post_ID) ) {
+ if ( $post_parent == $post_ID ) {
+ // Post can't be its own parent
+ $post_parent = 0;
+ } elseif ( !empty($post_parent) ) {
+ $parent_post = get_post($post_parent);
+ // Check for circular dependency
+ if ( $parent_post->post_parent == $post_ID )
+ $post_parent = 0;
+ }
+ }
+
if ( isset($menu_order) )
$menu_order = (int) $menu_order;
else
$menu_order = 0;
- if ( !isset($post_password) )
+ if ( !isset($post_password) || 'private' == $post_status )
$post_password = '';
- if ( 'draft' != $post_status ) {
+ if ( !in_array( $post_status, array( 'draft', 'pending' ) ) ) {
$post_name_check = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_parent = %d LIMIT 1", $post_name, $post_type, $post_ID, $post_parent));
if ($post_name_check || in_array($post_name, $wp_rewrite->feeds) ) {
// expected_slashed (everything!)
$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) );
+ $data = apply_filters('wp_insert_post_data', $data, $postarr);
$data = stripslashes_deep( $data );
$where = array( 'ID' => $post_ID );
return 0;
}
} else {
- $data['post_mime_type'] = stripslashes( $post_mime_type ); // This isn't in the update
+ if ( isset($post_mime_type) )
+ $data['post_mime_type'] = stripslashes( $post_mime_type ); // This isn't in the update
+ // If there is a suggested ID, use it if not already present
+ if ( !empty($import_id) ) {
+ $import_id = (int) $import_id;
+ if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {
+ $data['ID'] = $import_id;
+ }
+ }
if ( false === $wpdb->insert( $wpdb->posts, $data ) ) {
if ( $wp_error )
return new WP_Error('db_insert_error', __('Could not insert post into the database'), $wpdb->last_error);
else
- return 0;
+ return 0;
}
$post_ID = (int) $wpdb->insert_id;
$where = array( 'ID' => $post_ID );
}
- if ( empty($post_name) && 'draft' != $post_status ) {
+ if ( empty($post_name) && !in_array( $post_status, array( 'draft', 'pending' ) ) ) {
$post_name = sanitize_title($post_title, $post_ID);
$wpdb->update( $wpdb->posts, compact( 'post_name' ), $where );
}
}
/**
- * wp_update_post() - Update a post
+ * Update a post with new post data.
*
- * {@internal Missing Long Description}}
+ * The date does not have to be set for drafts. You can set the date and it will
+ * not be overridden.
*
- * @package WordPress
- * @subpackage Post
* @since 1.0.0
- * @uses $wpdb
*
- * @param array $postarr post data
- * @return int {@internal Missing Description}}
+ * @param array|object $postarr Post data.
+ * @return int 0 on failure, Post ID on success.
*/
function wp_update_post($postarr = array()) {
if ( is_object($postarr) )
$post_cats = $post['post_category'];
// Drafts shouldn't be assigned a date unless explicitly done so by the user
- if ( in_array($post['post_status'], array('draft', 'pending')) && empty($postarr['edit_date']) && empty($postarr['post_date']) &&
- ('0000-00-00 00:00:00' == $post['post_date']) )
+ if ( in_array($post['post_status'], array('draft', 'pending')) && empty($postarr['edit_date']) &&
+ ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
$clear_date = true;
else
$clear_date = false;
$postarr = array_merge($post, $postarr);
$postarr['post_category'] = $post_cats;
if ( $clear_date ) {
- $postarr['post_date'] = '';
+ $postarr['post_date'] = current_time('mysql');
$postarr['post_date_gmt'] = '';
}
}
/**
- * wp_publish_post() - Mark a post as "published"
- *
- * {@internal Missing Long Description}}
+ * Publish a post by transitioning the post status.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * @since 2.1.0
* @uses $wpdb
+ * @uses do_action() Calls 'edit_post', 'save_post', and 'wp_insert_post' on post_id and post data.
*
- * @param int $post_id Post ID
- * @return int|null {@internal Missing Description}}
+ * @param int $post_id Post ID.
+ * @return null
*/
function wp_publish_post($post_id) {
global $wpdb;
wp_transition_post_status('publish', $old_status, $post);
// Update counts for the post's terms.
- foreach ( get_object_taxonomies('post') as $taxonomy ) {
- $terms = wp_get_object_terms($post_id, $taxonomy, 'fields=tt_ids');
- wp_update_term_count($terms, $taxonomy);
+ foreach ( (array) get_object_taxonomies('post') as $taxonomy ) {
+ $tt_ids = wp_get_object_terms($post_id, $taxonomy, 'fields=tt_ids');
+ wp_update_term_count($tt_ids, $taxonomy);
}
do_action('edit_post', $post_id, $post);
}
/**
- * check_and_publish_future_post() - check to make sure post has correct status before
- * passing it on to be published. Invoked by cron 'publish_future_post' event
- * This safeguard prevents cron from publishing drafts, etc.
+ * Publish future post and make sure post ID has future post status.
*
- * {@internal Missing Long Description}}
+ * Invoked by cron 'publish_future_post' event. This safeguard prevents cron
+ * from publishing drafts, etc.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.5
- * @uses $wpdb
+ * @since 2.5.0
*
- * @param int $post_id Post ID
- * @return int|null {@internal Missing Description}}
+ * @param int $post_id Post ID.
+ * @return null Nothing is returned. Which can mean that no action is required or post was published.
*/
function check_and_publish_future_post($post_id) {
if ( 'future' != $post->post_status )
return;
+ $time = strtotime( $post->post_date_gmt . ' GMT' );
+
+ if ( $time > time() ) { // Uh oh, someone jumped the gun!
+ wp_clear_scheduled_hook( 'publish_future_post', $post_id ); // clear anything else in the system
+ wp_schedule_single_event( $time, 'publish_future_post', array( $post_id ) );
+ return;
+ }
+
return wp_publish_post($post_id);
}
/**
- * wp_add_post_tags() - Adds the tags to a post
+ * Adds tags to a post.
*
- * @uses wp_set_post_tags() Same first two paraeters, but the last parameter is always set to true.
+ * @uses wp_set_post_tags() Same first two parameters, but the last parameter is always set to true.
*
* @package WordPress
* @subpackage Post
- * @since 2.3
+ * @since 2.3.0
*
- * @param int $post_id Optional. Post ID
- * @param string $tags The tags to set for the post
+ * @param int $post_id Post ID
+ * @param string $tags The tags to set for the post, separated by commas.
* @return bool|null Will return false if $post_id is not an integer or is 0. Will return null otherwise
*/
function wp_add_post_tags($post_id = 0, $tags = '') {
return wp_set_post_tags($post_id, $tags, true);
}
+
/**
- * wp_set_post_tags() - Set the tags for a post
+ * Set the tags for a post.
*
- * {@internal Missing Long Description}}
+ * @since 2.3.0
+ * @uses wp_set_object_terms() Sets the tags for the post.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.3
- * @uses $wpdb
- *
- * @param int $post_id post ID
- * @param string $tags The tags to set for the post
+ * @param int $post_id Post ID.
+ * @param string $tags The tags to set for the post, separated by commas.
* @param bool $append If true, don't delete existing tags, just add on. If false, replace the tags with the new tags.
* @return bool|null Will return false if $post_id is not an integer or is 0. Will return null otherwise
*/
}
/**
- * wp_set_post_categories() - Set categories for a post
+ * Set categories for a post.
*
- * {@internal Missing Long Description}}
+ * If the post categories parameter is not set, then the default category is
+ * going used.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.1
- * @uses $wpdb
+ * @since 2.1.0
*
- * @param int $post_ID post ID
- * @param array $post_categories
- * @return bool|mixed {@internal Missing Description}}
+ * @param int $post_ID Post ID.
+ * @param array $post_categories Optional. List of categories.
+ * @return bool|mixed
*/
function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
$post_ID = (int) $post_ID;
$post_categories = array_unique($post_categories);
return wp_set_object_terms($post_ID, $post_categories, 'category');
-} // wp_set_post_categories()
+}
/**
- * wp_transition_post_status() - Change the post transition status
+ * Transition the post status of a post.
*
- * {@internal Missing Long Description}}
+ * Calls hooks to transition post status. If the new post status is not the same
+ * as the previous post status, then two hooks will be ran, the first is
+ * 'transition_post_status' with new status, old status, and post data. The
+ * next action called is 'OLDSTATUS_to_NEWSTATUS' the NEWSTATUS is the
+ * $new_status parameter and the OLDSTATUS is $old_status parameter; it has the
+ * post data.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.3
+ * The final action will run whether or not the post statuses are the same. The
+ * action is named 'NEWSTATUS_POSTTYPE', NEWSTATUS is from the $new_status
+ * parameter and POSTTYPE is post_type post data.
*
- * @param string $new_status {@internal Missing Description}}
- * @param string $old_status {@internal Missing Description}}
- * @param int $post {@internal Missing Description}}
+ * @since 2.3.0
+ *
+ * @param string $new_status Transition to this post status.
+ * @param string $old_status Previous post status.
+ * @param object $post Post data.
*/
function wp_transition_post_status($new_status, $old_status, $post) {
if ( $new_status != $old_status ) {
//
/**
- * add_ping() - Add a URL to those already pung
- *
- * {@internal Missing Long Description}}
+ * Add a URL to those already pung.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.5
+ * @since 1.5.0
* @uses $wpdb
*
- * @param int $post_id post ID
- * @param string $uri {@internal Missing Description}}
- * @return mixed {@internal Missing Description}}
+ * @param int $post_id Post ID.
+ * @param string $uri Ping URI.
+ * @return int How many rows were updated.
*/
function add_ping($post_id, $uri) {
global $wpdb;
}
/**
- * get_enclosed() - Get enclosures already enclosed for a post
+ * Retrieve enclosures already enclosed for a post.
*
- * {@internal Missing Long Description}}
- *
- * @package WordPress
- * @subpackage Post
- * @since 1.5
+ * @since 1.5.0
* @uses $wpdb
*
- * @param int $post_id post ID
- * @return array {@internal Missing Description}}
+ * @param int $post_id Post ID.
+ * @return array List of enclosures
*/
function get_enclosed($post_id) {
$custom_fields = get_post_custom( $post_id );
}
/**
- * get_pung() - Get URLs already pinged for a post
- *
- * {@internal Missing Long Description}}
+ * Retrieve URLs already pinged for a post.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.5
+ * @since 1.5.0
* @uses $wpdb
*
- * @param int $post_id post ID
- * @return array {@internal Missing Description}}
+ * @param int $post_id Post ID.
+ * @return array
*/
function get_pung($post_id) {
global $wpdb;
}
/**
- * get_to_ping() - Get any URLs in the todo list
- *
- * {@internal Missing Long Description}}
+ * Retrieve URLs that need to be pinged.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.5
+ * @since 1.5.0
* @uses $wpdb
*
- * @param int $post_id post ID
- * @return array {@internal Missing Description}}
+ * @param int $post_id Post ID
+ * @return array
*/
function get_to_ping($post_id) {
global $wpdb;
}
/**
- * trackback_url_list() - Do trackbacks for a list of urls
- *
- * {@internal Missing Long Description}}
+ * Do trackbacks for a list of URLs.
*
- * @package WordPress
- * @subpackage Post
* @since 1.0.0
*
- * @param string $tb_list comma separated list of URLs
- * @param int $post_id post ID
+ * @param string $tb_list Comma separated list of URLs
+ * @param int $post_id Post ID
*/
function trackback_url_list($tb_list, $post_id) {
- if (!empty($tb_list)) {
+ if ( ! empty( $tb_list ) ) {
// get post data
$postdata = wp_get_single_post($post_id, ARRAY_A);
extract($postdata, EXTR_SKIP);
// form an excerpt
- $excerpt = strip_tags($post_excerpt?$post_excerpt:$post_content);
+ $excerpt = strip_tags($post_excerpt ? $post_excerpt : $post_content);
if (strlen($excerpt) > 255) {
$excerpt = substr($excerpt,0,252) . '...';
}
$trackback_urls = explode(',', $tb_list);
- foreach($trackback_urls as $tb_url) {
- $tb_url = trim($tb_url);
- trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
- }
+ foreach( (array) $trackback_urls as $tb_url) {
+ $tb_url = trim($tb_url);
+ trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
}
+ }
}
//
//
/**
- * get_all_page_ids() - Get a list of page IDs
- *
- * {@internal Missing Long Description}}
+ * Get a list of page IDs.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.0
+ * @since 2.0.0
* @uses $wpdb
*
- * @return array {@internal Missing Description}}
+ * @return array List of page IDs.
*/
function get_all_page_ids() {
global $wpdb;
}
/**
- * get_page() - Retrieves page data given a page ID or page object
- *
- * {@internal Missing Long Description}}
+ * Retrieves page data given a page ID or page object.
*
- * @package WordPress
- * @subpackage Post
* @since 1.5.1
*
- * @param mixed &$page page object or page ID
- * @param string $output what to output
+ * @param mixed $page Page object or page ID. Passed by reference.
+ * @param string $output What to output. OBJECT, ARRAY_A, or ARRAY_N.
* @param string $filter How the return value should be filtered.
- * @return mixed {@internal Missing Description}}
+ * @return mixed Page data.
*/
function &get_page(&$page, $output = OBJECT, $filter = 'raw') {
if ( empty($page) ) {
- if ( isset( $GLOBALS['page'] ) && isset( $GLOBALS['page']->ID ) )
+ if ( isset( $GLOBALS['page'] ) && isset( $GLOBALS['page']->ID ) ) {
return get_post($GLOBALS['page'], $output, $filter);
- else
- return null;
+ } else {
+ $page = null;
+ return $page;
+ }
}
- return get_post($page, $output, $filter);
+ $the_page = get_post($page, $output, $filter);
+ return $the_page;
}
/**
- * get_page_by_path() - Retrieves a page given its path
- *
- * {@internal Missing Long Description}}
+ * Retrieves a page given its path.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * @since 2.1.0
* @uses $wpdb
*
- * @param string $page_path page path
- * @param string $output output type
- * @return mixed {@internal Missing Description}}
+ * @param string $page_path Page path
+ * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A.
+ * @return mixed Null when complete.
*/
function get_page_by_path($page_path, $output = OBJECT) {
global $wpdb;
$page_paths = '/' . trim($page_path, '/');
$leaf_path = sanitize_title(basename($page_paths));
$page_paths = explode('/', $page_paths);
- foreach($page_paths as $pathdir)
+ $full_path = '';
+ foreach( (array) $page_paths as $pathdir)
$full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
$pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = %s AND (post_type = 'page' OR post_type = 'attachment')", $leaf_path ));
if ( empty($pages) )
- return NULL;
+ return null;
foreach ($pages as $page) {
$path = '/' . $leaf_path;
return get_page($page->ID, $output);
}
- return NULL;
+ return null;
}
/**
- * get_page_by_title() - Retrieve a page given its title
+ * Retrieve a page given its title.
*
- * {@internal Missing Long Description}}
- *
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * @since 2.1.0
* @uses $wpdb
*
- * @param string $page_title page title
- * @param string $output output type
- * @return mixed {@internal Missing Description}}
+ * @param string $page_title Page title
+ * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A.
+ * @return mixed
*/
function get_page_by_title($page_title, $output = OBJECT) {
global $wpdb;
if ( $page )
return get_page($page, $output);
- return NULL;
+ return null;
}
/**
- * get_page_children() - Retrieve child pages
+ * Retrieve child pages from list of pages matching page ID.
*
- * {@internal Missing Long Description}}
+ * Matches against the pages parameter against the page ID. Also matches all
+ * children for the same to retrieve all children of a page. Does not make any
+ * SQL queries to get the children.
*
- * @package WordPress
- * @subpackage Post
* @since 1.5.1
*
- * @param int $page_id page ID
- * @param array $pages list of pages
- * @return array {@internal Missing Description}}
+ * @param int $page_id Page ID.
+ * @param array $pages List of pages' objects.
+ * @return array
*/
function &get_page_children($page_id, $pages) {
$page_list = array();
- foreach ( $pages as $page ) {
+ foreach ( (array) $pages as $page ) {
if ( $page->post_parent == $page_id ) {
$page_list[] = $page;
if ( $children = get_page_children($page->ID, $pages) )
}
/**
- * get_page_hierarchy() - {@internal Missing Short Description}}
+ * Order the pages with children under parents in a flat list.
*
- * Fetches the pages returned as a FLAT list, but arranged in order of their hierarchy,
- * i.e., child parents immediately follow their parents.
+ * Fetches the pages returned as a FLAT list, but arranged in order of their
+ * hierarchy, i.e., child parents immediately follow their parents.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.0
+ * @since 2.0.0
*
- * @param array $posts posts array
- * @param int $parent parent page ID
- * @return array {@internal Missing Description}}
+ * @param array $posts Posts array.
+ * @param int $parent Parent page ID.
+ * @return array
*/
function get_page_hierarchy($posts, $parent = 0) {
$result = array ( );
- if ($posts) { foreach ($posts as $post) {
+ if ($posts) { foreach ( (array) $posts as $post) {
if ($post->post_parent == $parent) {
$result[$post->ID] = $post->post_name;
$children = get_page_hierarchy($posts, $post->ID);
}
/**
- * get_page_uri() - Builds a page URI
+ * Builds URI for a page.
*
- * {@internal Missing Long Description}}
+ * Sub pages will be in the "directory" under the parent page post name.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.5
+ * @since 1.5.0
*
- * @param int $page_id page ID
- * @return string {@internal Missing Description}}
+ * @param int $page_id Page ID.
+ * @return string Page URI.
*/
function get_page_uri($page_id) {
$page = get_page($page_id);
}
/**
- * get_pages() - Retrieve a list of pages
+ * Retrieve a list of pages.
*
- * {@internal Missing Long Description}}
+ * The defaults that can be overridden are the following: 'child_of',
+ * 'sort_order', 'sort_column', 'post_title', 'hierarchical', 'exclude',
+ * 'include', 'meta_key', 'meta_value', and 'authors'.
*
- * @package WordPress
- * @subpackage Post
- * @since 1.5
+ * @since 1.5.0
* @uses $wpdb
*
- * @param mixed $args Optional. Array or string of options
+ * @param mixed $args Optional. Array or string of options that overrides defaults.
* @return array List of pages matching defaults or $args
*/
function &get_pages($args = '') {
'sort_column' => 'post_title', 'hierarchical' => 1,
'exclude' => '', 'include' => '',
'meta_key' => '', 'meta_value' => '',
- 'authors' => ''
+ 'authors' => '', 'parent' => -1, 'exclude_tree' => ''
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
- $key = md5( serialize( $r ) );
- if ( $cache = wp_cache_get( 'get_pages', 'posts' ) )
- if ( isset( $cache[ $key ] ) )
- return apply_filters('get_pages', $cache[ $key ], $r );
+ $key = md5( serialize( compact(array_keys($defaults)) ) );
+ if ( $cache = wp_cache_get( 'get_pages', 'posts' ) ) {
+ if ( isset( $cache[ $key ] ) ) {
+ $pages = apply_filters('get_pages', $cache[ $key ], $r );
+ return $pages;
+ }
+ }
$inclusions = '';
if ( !empty($include) ) {
- $child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include
+ $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
+ $parent = -1;
$exclude = '';
$meta_key = '';
$meta_value = '';
$where = "$exclusions $inclusions ";
if ( ! empty( $meta_key ) || ! empty( $meta_value ) ) {
$join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";
-
- // meta_key and met_value might be slashed
+
+ // meta_key and meta_value might be slashed
$meta_key = stripslashes($meta_key);
$meta_value = stripslashes($meta_value);
if ( ! empty( $meta_key ) )
$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_value = %s", $meta_value);
}
+
+ if ( $parent >= 0 )
+ $where .= $wpdb->prepare(' AND post_parent = %d ', $parent);
+
$query = "SELECT * FROM $wpdb->posts $join WHERE (post_type = 'page' AND post_status = 'publish') $where ";
$query .= $author_query;
$query .= " ORDER BY " . $sort_column . " " . $sort_order ;
$pages = $wpdb->get_results($query);
- if ( empty($pages) )
- return apply_filters('get_pages', array(), $r);
+ if ( empty($pages) ) {
+ $pages = apply_filters('get_pages', array(), $r);
+ return $pages;
+ }
// Update cache.
update_page_cache($pages);
if ( $child_of || $hierarchical )
$pages = & get_page_children($child_of, $pages);
+ if ( !empty($exclude_tree) ) {
+ $exclude = array();
+
+ $exclude = (int) $exclude_tree;
+ $children = get_page_children($exclude, $pages);
+ $excludes = array();
+ foreach ( $children as $child )
+ $excludes[] = $child->ID;
+ $excludes[] = $exclude;
+ $total = count($pages);
+ for ( $i = 0; $i < $total; $i++ ) {
+ if ( in_array($pages[$i]->ID, $excludes) )
+ unset($pages[$i]);
+ }
+ }
+
$cache[ $key ] = $pages;
wp_cache_set( 'get_pages', $cache, 'posts' );
//
/**
- * is_local_attachment() - Check if the attachment URI is local one and is really an attachment.
+ * Check if the attachment URI is local one and is really an attachment.
*
- * {@internal Missing Long Description}}
- *
- * @package WordPress
- * @subpackage Post
- * @since 2.0
+ * @since 2.0.0
*
* @param string $url URL to check
- * @return bool {@internal Missing Description}}
+ * @return bool True on success, false on failure.
*/
function is_local_attachment($url) {
if (strpos($url, get_bloginfo('url')) === false)
}
/**
- * wp_insert_attachment() - Insert an attachment
- *
- * {@internal Missing Long Description}}
- *
- * @package WordPress
- * @subpackage Post
- * @since 2.0
- *
+ * Insert an attachment.
+ *
+ * If you set the 'ID' in the $object parameter, it will mean that you are
+ * updating and attempt to update the attachment. You can also set the
+ * attachment name or title by setting the key 'post_name' or 'post_title'.
+ *
+ * You can set the dates for the attachment manually by setting the 'post_date'
+ * and 'post_date_gmt' keys' values.
+ *
+ * By default, the comments will use the default settings for whether the
+ * comments are allowed. You can close them manually or keep them open by
+ * setting the value for the 'comment_status' key.
+ *
+ * The $object parameter can have the following:
+ * 'post_status' - Default is 'draft'. Can not be override, set the same as
+ * parent post.
+ * 'post_type' - Default is 'post', will be set to attachment. Can not
+ * override.
+ * 'post_author' - Default is current user ID. The ID of the user, who added
+ * the attachment.
+ * 'ping_status' - Default is the value in default ping status option.
+ * Whether the attachment can accept pings.
+ * 'post_parent' - Default is 0. Can use $parent parameter or set this for
+ * the post it belongs to, if any.
+ * 'menu_order' - Default is 0. The order it is displayed.
+ * 'to_ping' - Whether to ping.
+ * 'pinged' - Default is empty string.
+ * 'post_password' - Default is empty string. The password to access the
+ * attachment.
+ * 'guid' - Global Unique ID for referencing the attachment.
+ * 'post_content_filtered' - Attachment post content filtered.
+ * 'post_excerpt' - Attachment excerpt.
+ *
+ * @since 2.0.0
* @uses $wpdb
* @uses $user_ID
*
- * @param object $object attachment object
- * @param string $file filename
- * @param int $post_parent parent post ID
- * @return int {@internal Missing Description}}
+ * @param string|array $object Arguments to override defaults.
+ * @param string $file Optional filename.
+ * @param int $post_parent Parent post ID.
+ * @return int Attachment ID.
*/
function wp_insert_attachment($object, $file = false, $parent = 0) {
global $wpdb, $user_ID;
$defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '',
- 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '');
+ 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0);
$object = wp_parse_args($object, $defaults);
if ( !empty($parent) )
extract($object, EXTR_SKIP);
// Make sure we set a valid category
- if (0 == count($post_category) || !is_array($post_category)) {
+ if ( !isset($post_category) || 0 == count($post_category) || !is_array($post_category)) {
$post_category = array(get_option('default_category'));
}
$post_status = 'inherit';
// Are we updating or creating?
- $update = false;
if ( !empty($ID) ) {
$update = true;
$post_ID = (int) $ID;
+ } else {
+ $update = false;
+ $post_ID = 0;
}
// Create a valid post name.
$post_name = sanitize_title($post_name);
// expected_slashed ($post_name)
- $post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'inherit' AND ID != %d LIMIT 1", $post_ID));
+ $post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_status = 'inherit' AND ID != %d LIMIT 1", $post_name, $post_ID));
if ($post_name_check) {
$suffix = 2;
while ($post_name_check) {
$alt_post_name = $post_name . "-$suffix";
// expected_slashed ($alt_post_name, $post_name)
- $post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'inherit' AND ID != %d AND post_parent = %d LIMIT 1", $post_ID, $post_parent));
+ $post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_status = 'inherit' AND ID != %d AND post_parent = %d LIMIT 1", $alt_post_name, $post_ID, $post_parent));
$suffix++;
}
$post_name = $alt_post_name;
$post_date_gmt = current_time('mysql', 1);
if ( empty($post_modified) )
- $post_modified = $post_date;
+ $post_modified = $post_date;
if ( empty($post_modified_gmt) )
- $post_modified_gmt = $post_date_gmt;
+ $post_modified_gmt = $post_date_gmt;
if ( empty($comment_status) ) {
if ( $update )
if ( $update ) {
$wpdb->update( $wpdb->posts, $data, array( 'ID' => $post_ID ) );
} else {
+ // If there is a suggested ID, use it if not already present
+ if ( !empty($import_id) ) {
+ $import_id = (int) $import_id;
+ if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {
+ $data['ID'] = $import_id;
+ }
+ }
+
$wpdb->insert( $wpdb->posts, $data );
$post_ID = (int) $wpdb->insert_id;
}
if ( $file )
update_attached_file( $post_ID, $file );
-
+
clean_post_cache($post_ID);
if ( $update) {
}
/**
- * wp_delete_attachment() - Delete an attachment
+ * Delete an attachment.
*
- * {@internal Missing Long Description}}
+ * Will remove the file also, when the attachment is removed. Removes all post
+ * meta fields, taxonomy, comments, etc associated with the attachment (except
+ * the main post).
*
- * @package WordPress
- * @subpackage Post
- * @since 2.0
+ * @since 2.0.0
* @uses $wpdb
+ * @uses do_action() Calls 'delete_attachment' hook on Attachment ID.
*
- * @param int $postid attachment Id
- * @return mixed {@internal Missing Description}}
+ * @param int $postid Attachment ID.
+ * @return mixed False on failure. Post data on success.
*/
function wp_delete_attachment($postid) {
global $wpdb;
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
+ $uploadPath = wp_upload_dir();
+
if ( ! empty($meta['thumb']) ) {
// Don't delete the thumb if another attachment uses it
if (! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%'.$meta['thumb'].'%', $postid)) ) {
$thumbfile = str_replace(basename($file), $meta['thumb'], $file);
$thumbfile = apply_filters('wp_delete_file', $thumbfile);
- @ unlink($thumbfile);
+ @ unlink( path_join($uploadPath['basedir'], $thumbfile) );
}
}
// remove intermediate images if there are any
- $sizes = apply_filters('intermediate_image_sizes', array('thumbnail', 'medium'));
+ $sizes = apply_filters('intermediate_image_sizes', array('thumbnail', 'medium', 'large'));
foreach ( $sizes as $size ) {
if ( $intermediate = image_get_intermediate_size($postid, $size) ) {
$intermediate_file = apply_filters('wp_delete_file', $intermediate['path']);
- @ unlink($intermediate_file);
+ @ unlink( path_join($uploadPath['basedir'], $intermediate_file) );
}
}
}
/**
- * wp_get_attachment_metadata() - Retrieve metadata for an attachment
+ * Retrieve attachment meta field for attachment ID.
*
- * {@internal Missing Long Description}}
+ * @since 2.1.0
*
- * @package WordPress
- * @subpackage Post
- * @since 2.1
- *
- * @param int $post_id attachment ID
- * @param bool $unfiltered Optional, default is false. If true, filters are not run
- * @return array {@internal Missing Description}}
+ * @param int $post_id Attachment ID
+ * @param bool $unfiltered Optional, default is false. If true, filters are not run.
+ * @return string|bool Attachment meta field. False on failure.
*/
function wp_get_attachment_metadata( $post_id, $unfiltered = false ) {
$post_id = (int) $post_id;
}
/**
- * wp_update_attachment_metadata() - Update metadata for an attachment
+ * Update metadata for an attachment.
*
- * {@internal Missing Long Description}}
- *
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * @since 2.1.0
*
- * @param int $post_id attachment ID
- * @param array $data attachment data
- * @return int {@internal Missing Description}}
+ * @param int $post_id Attachment ID.
+ * @param array $data Attachment data.
+ * @return int
*/
function wp_update_attachment_metadata( $post_id, $data ) {
$post_id = (int) $post_id;
}
/**
- * wp_get_attachment_url() - Retrieve the URL for an attachment
- *
- * {@internal Missing Long Description}}
+ * Retrieve the URL for an attachment.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * @since 2.1.0
*
- * @param int $post_id attachment ID
- * @return string {@internal Missing Description}}
+ * @param int $post_id Attachment ID.
+ * @return string
*/
function wp_get_attachment_url( $post_id = 0 ) {
$post_id = (int) $post_id;
if ( !$post =& get_post( $post_id ) )
return false;
- $url = get_the_guid( $post->ID );
+ $url = '';
+ if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true) ) { //Get attached file
+ if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { //Get upload directory
+ if ( 0 === strpos($file, $uploads['basedir']) ) //Check that the upload base exists in the file location
+ $url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); //replace file location with url location
+ elseif ( false !== strpos($file, 'wp-content/uploads') )
+ $url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );
+ else
+ $url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir.
+ }
+ }
+
+ if ( empty($url) ) //If any of the above options failed, Fallback on the GUID as used pre-2.7, not recomended to rely upon this.
+ $url = get_the_guid( $post->ID );
- if ( 'attachment' != $post->post_type || !$url )
+ if ( 'attachment' != $post->post_type || empty($url) )
return false;
return apply_filters( 'wp_get_attachment_url', $url, $post->ID );
}
/**
- * wp_get_attachment_thumb_file() - Retrieve thumbnail for an attachment
- *
- * {@internal Missing Long Description}}
+ * Retrieve thumbnail for an attachment.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * @since 2.1.0
*
- * @param int $post_id attachment ID
- * @return mixed {@internal Missing Description}}
+ * @param int $post_id Attachment ID.
+ * @return mixed False on failure. Thumbnail file path on success.
*/
function wp_get_attachment_thumb_file( $post_id = 0 ) {
$post_id = (int) $post_id;
}
/**
- * wp_get_attachment_thumb_url() - Retrieve URL for an attachment thumbnail
- *
- * {@internal Missing Long Description}}
+ * Retrieve URL for an attachment thumbnail.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * @since 2.1.0
*
- * @param int $post_id attachment ID
- * @return string {@internal Missing Description}}
+ * @param int $post_id Attachment ID
+ * @return string|bool False on failure. Thumbnail URL on success.
*/
function wp_get_attachment_thumb_url( $post_id = 0 ) {
$post_id = (int) $post_id;
return false;
if ( !$url = wp_get_attachment_url( $post->ID ) )
return false;
-
+
$sized = image_downsize( $post_id, 'thumbnail' );
if ( $sized )
return $sized[0];
}
/**
- * wp_attachment_is_image() - Check if the attachment is an image
+ * Check if the attachment is an image.
*
- * {@internal Missing Long Description}}
- *
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * @since 2.1.0
*
- * @param int $post_id attachment ID
- * @return bool {@internal Missing Description}}
+ * @param int $post_id Attachment ID
+ * @return bool
*/
function wp_attachment_is_image( $post_id = 0 ) {
$post_id = (int) $post_id;
}
/**
- * wp_mime_type_icon() - Retrieve the icon for a MIME type
+ * Retrieve the icon for a MIME type.
*
- * {@internal Missing Long Description}}
- *
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * @since 2.1.0
*
* @param string $mime MIME type
- * @return string|bool {@internal Missing Description}}
+ * @return string|bool
*/
function wp_mime_type_icon( $mime = 0 ) {
if ( !is_numeric($mime) )
}
/**
- * wp_check_for_changed_slugs() - {@internal Missing Short Description}}
+ * Checked for changed slugs for published posts and save old slug.
*
- * {@internal Missing Long Description}}
+ * The function is used along with form POST data. It checks for the wp-old-slug
+ * POST field. Will only be concerned with published posts and the slug actually
+ * changing.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.1
+ * If the slug was changed and not already part of the old slugs then it will be
+ * added to the post meta field ('_wp_old_slug') for storing old slugs for that
+ * post.
+ *
+ * The most logically usage of this function is redirecting changed posts, so
+ * that those that linked to an changed post will be redirected to the new post.
*
- * @param int $post_id The Post ID
+ * @since 2.1.0
+ *
+ * @param int $post_id Post ID.
* @return int Same as $post_id
*/
function wp_check_for_changed_slugs($post_id) {
}
/**
- * get_private_posts_cap_sql() - {@internal Missing Short Description}}
+ * Retrieve the private post SQL based on capability.
*
- * This function provides a standardized way to appropriately select on
- * the post_status of posts/pages. The function will return a piece of
- * SQL code that can be added to a WHERE clause; this SQL is constructed
- * to allow all published posts, and all private posts to which the user
- * has access.
+ * This function provides a standardized way to appropriately select on the
+ * post_status of posts/pages. The function will return a piece of SQL code that
+ * can be added to a WHERE clause; this SQL is constructed to allow all
+ * published posts, and all private posts to which the user has access.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.2
+ * It also allows plugins that define their own post type to control the cap by
+ * using the hook 'pub_priv_sql_capability'. The plugin is expected to return
+ * the capability the user must have to read the private post type.
+ *
+ * @since 2.2.0
*
* @uses $user_ID
- * @uses apply_filters() Call 'pub_priv_sql_capability' filter for plugins with different post types
+ * @uses apply_filters() Call 'pub_priv_sql_capability' filter for plugins with different post types.
*
* @param string $post_type currently only supports 'post' or 'page'.
* @return string SQL code that can be added to a where clause.
}
/**
- * get_lastpostdate() - {@internal Missing Short Description}}
+ * Retrieve the date the the last post was published.
*
- * {@internal Missing Long Description}}
+ * The server timezone is the default and is the difference between GMT and
+ * server time. The 'blog' value is the date when the last post was posted. The
+ * 'gmt' is when the last post was posted in GMT formatted date.
*
- * @package WordPress
- * @subpackage Post
* @since 0.71
*
* @uses $wpdb
}
/**
- * get_lastpostmodified() - {@internal Missing Short Description}}
+ * Retrieve last post modified date depending on timezone.
*
- * {@internal Missing Long Description}}
- *
- * @package WordPress
- * @subpackage Post
- * @since 1.2
+ * The server timezone is the default and is the difference between GMT and
+ * server time. The 'blog' value is just when the last post was modified. The
+ * 'gmt' is when the last post was modified in GMT time.
*
+ * @since 1.2.0
* @uses $wpdb
* @uses $blog_id
* @uses apply_filters() Calls 'get_lastpostmodified' filter
*
* @global mixed $cache_lastpostmodified Stores the date the last post was modified
- * @global mixed $pagenow The current page being viewed
*
* @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
* @return string The date the post was last modified.
}
/**
- * update_post_cache() - Updates posts in cache
+ * Updates posts in cache.
*
- * @usedby update_page_cache() update_page_cache() aliased by this function.
+ * @usedby update_page_cache() Aliased by this function.
*
* @package WordPress
* @subpackage Cache
}
/**
- * clean_post_cache() - Will clean the post in the cache
+ * Will clean the post in the cache.
*
- * Cleaning means delete from the cache of the post. Will call to clean
- * the term object cache associated with the post ID.
+ * Cleaning means delete from the cache of the post. Will call to clean the term
+ * object cache associated with the post ID.
*
* @package WordPress
* @subpackage Cache
- * @since 2.0
+ * @since 2.0.0
*
* @uses do_action() Will call the 'clean_post_cache' hook action.
*
* @param int $id The Post ID in the cache to clean
*/
function clean_post_cache($id) {
- global $wpdb;
+ global $_wp_suspend_cache_invalidation, $wpdb;
+
+ if ( !empty($_wp_suspend_cache_invalidation) )
+ return;
+
$id = (int) $id;
wp_cache_delete($id, 'posts');
}
/**
- * update_page_cache() - Alias of update_post_cache()
+ * Alias of update_post_cache().
*
* @see update_post_cache() Posts and pages are the same, alias is intentional
*
}
/**
- * clean_page_cache() - Will clean the page in the cache
+ * Will clean the page in the cache.
*
- * Clean (read: delete) page from cache that matches $id. Will also clean
- * cache associated with 'all_page_ids' and 'get_pages'.
+ * Clean (read: delete) page from cache that matches $id. Will also clean cache
+ * associated with 'all_page_ids' and 'get_pages'.
*
* @package WordPress
* @subpackage Cache
- * @since 2.0
+ * @since 2.0.0
*
* @uses do_action() Will call the 'clean_page_cache' hook action.
*
}
/**
- * update_post_caches() - Call major cache updating functions for list of Post objects.
+ * Call major cache updating functions for list of Post objects.
*
* @package WordPress
* @subpackage Cache
- * @since 1.5
+ * @since 1.5.0
*
* @uses $wpdb
* @uses update_post_cache()
}
/**
- * update_postmeta_cache() - {@internal Missing Short Description}}
+ * Updates metadata cache for list of post IDs.
*
- * {@internal Missing Long Description}}
+ * Performs SQL query to retrieve the metadata for the post IDs and updates the
+ * metadata cache for the posts. Therefore, the functions, which call this
+ * function, do not need to perform SQL queries on their own.
*
* @package WordPress
* @subpackage Cache
- * @since 2.1
+ * @since 2.1.0
*
* @uses $wpdb
*
- * @param array $post_ids {@internal Missing Description}}
- * @return bool|array Returns false if there is nothing to update or an array of metadata
+ * @param array $post_ids List of post IDs.
+ * @return bool|array Returns false if there is nothing to update or an array of metadata.
*/
function update_postmeta_cache($post_ids) {
global $wpdb;
// Get post-meta info
$id_list = join(',', $ids);
$cache = array();
- if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN ($id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
+ if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN ($id_list)", ARRAY_A) ) {
foreach ( (array) $meta_list as $metarow) {
$mpid = (int) $metarow['post_id'];
$mkey = $metarow['meta_key'];
$cache[$id] = array();
}
- foreach ( array_keys($cache) as $post)
+ foreach ( (array) array_keys($cache) as $post)
wp_cache_set($post, $cache[$post], 'post_meta');
return $cache;
//
/**
- * _transition_post_status() - Hook {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
- *
- * @package WordPress
- * @subpackage Post
- * @since 2.3
+ * Hook for managing future post transitions to published.
*
+ * @since 2.3.0
+ * @access private
* @uses $wpdb
*
- * @param string $new_status {@internal Missing Description}}
- * @param string $old_status {@internal Missing Description}}
+ * @param string $new_status New post status
+ * @param string $old_status Previous post status
* @param object $post Object type containing the post information
*/
function _transition_post_status($new_status, $old_status, $post) {
}
/**
- * _future_post_hook() - Hook used to schedule publication for a post marked for the future.
+ * Hook used to schedule publication for a post marked for the future.
*
* The $post properties used and must exist are 'ID' and 'post_date_gmt'.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.3
+ * @since 2.3.0
*
- * @param int $post_id Not Used. Can be set to null.
+ * @param int $deprecated Not Used. Can be set to null.
* @param object $post Object type containing the post information
*/
function _future_post_hook($deprecated = '', $post) {
}
/**
- * _publish_post_hook() - Hook {@internal Missing Short Description}}
- *
- * {@internal Missing Long Description}}
- *
- * @package WordPress
- * @subpackage Post
- * @since 2.3
+ * Hook to schedule pings and enclosures when a post is published.
*
+ * @since 2.3.0
* @uses $wpdb
* @uses XMLRPC_REQUEST
* @uses APP_REQUEST
}
/**
- * _save_post_hook() - Hook used to prevent page/post cache and rewrite rules from staying dirty
- *
- * Does two things. If the post is a page and has a template then it will update/add that
- * template to the meta. For both pages and posts, it will clean the post cache to make sure
- * that the cache updates to the changes done recently. For pages, the rewrite rules of
- * WordPress are flushed to allow for any changes.
+ * Hook used to prevent page/post cache and rewrite rules from staying dirty.
*
- * The $post parameter, only uses 'post_type' property and 'page_template' property.
+ * Does two things. If the post is a page and has a template then it will
+ * update/add that template to the meta. For both pages and posts, it will clean
+ * the post cache to make sure that the cache updates to the changes done
+ * recently. For pages, the rewrite rules of WordPress are flushed to allow for
+ * any changes.
*
- * @package WordPress
- * @subpackage Post
- * @since 2.3
+ * The $post parameter, only uses 'post_type' property and 'page_template'
+ * property.
*
+ * @since 2.3.0
* @uses $wp_rewrite Flushes Rewrite Rules.
*
* @param int $post_id The ID in the database table for the $post
function _save_post_hook($post_id, $post) {
if ( $post->post_type == 'page' ) {
clean_page_cache($post_id);
- global $wp_rewrite;
- $wp_rewrite->flush_rules();
+ // Avoid flushing rules for every post during import.
+ if ( !defined('WP_IMPORTING') ) {
+ global $wp_rewrite;
+ $wp_rewrite->flush_rules();
+ }
} else {
clean_post_cache($post_id);
}
}
-//
-// Private
-//
-
+/**
+ * Retrieve post ancestors and append to post ancestors property.
+ *
+ * Will only retrieve ancestors once, if property is already set, then nothing
+ * will be done. If there is not a parent post, or post ID and post parent ID
+ * are the same then nothing will be done.
+ *
+ * The parameter is passed by reference, so nothing needs to be returned. The
+ * property will be updated and can be referenced after the function is
+ * complete. The post parent will be an ancestor and the parent of the post
+ * parent will be an ancestor. There will only be two ancestors at the most.
+ *
+ * @access private
+ * @since unknown
+ * @uses $wpdb
+ *
+ * @param object $_post Post data.
+ * @return null When nothing needs to be done.
+ */
function _get_post_ancestors(&$_post) {
global $wpdb;
}
}
-/* Post Revisions */
-
/**
- * _wp_post_revision_fields() - determines which fields of posts are to be saved in revisions
+ * Determines which fields of posts are to be saved in revisions.
*
- * Does two things. If passed a post *array*, it will return a post array ready to be
- * insterted into the posts table as a post revision.
- * Otherwise, returns an array whose keys are the post fields to be saved for post revisions.
+ * Does two things. If passed a post *array*, it will return a post array ready
+ * to be insterted into the posts table as a post revision. Otherwise, returns
+ * an array whose keys are the post fields to be saved for post revisions.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ * @access private
*
- * @param array $post optional a post array to be processed for insertion as a post revision
+ * @param array $post Optional a post array to be processed for insertion as a post revision.
* @param bool $autosave optional Is the revision an autosave?
- * @return array post array ready to be inserted as a post revision or array of fields that can be versioned
+ * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned.
*/
function _wp_post_revision_fields( $post = null, $autosave = false ) {
static $fields = false;
$return['post_status'] = 'inherit';
$return['post_type'] = 'revision';
$return['post_name'] = $autosave ? "$post[ID]-autosave" : "$post[ID]-revision";
- $return['post_date'] = $post['post_modified'];
- $return['post_date_gmt'] = $post['post_modified_gmt'];
+ $return['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : '';
+ $return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : '';
return $return;
}
/**
- * wp_save_post_revision() - Saves an already existing post as a post revision. Typically used immediately prior to post updates.
+ * Saves an already existing post as a post revision.
+ *
+ * Typically used immediately prior to post updates.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
* @uses _wp_put_post_revision()
*
- * @param int $post_id The ID of the post to save as a revision
- * @return mixed null or 0 if error, new revision ID if success
+ * @param int $post_id The ID of the post to save as a revision.
+ * @return mixed Null or 0 if error, new revision ID, if success.
*/
function wp_save_post_revision( $post_id ) {
// We do autosaves manually with wp_create_post_autosave()
}
/**
- * wp_get_post_autosave() - returns the autosaved data of the specified post.
+ * Retrieve the autosaved data of the specified post.
*
- * Returns a post object containing the information that was autosaved for the specified post.
+ * Returns a post object containing the information that was autosaved for the
+ * specified post.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
- * @param int $post_id The post ID
- * @return object|bool the autosaved data or false on failure or when no autosave exists
+ * @param int $post_id The post ID.
+ * @return object|bool The autosaved data or false on failure or when no autosave exists.
*/
function wp_get_post_autosave( $post_id ) {
- global $wpdb;
+
if ( !$post = get_post( $post_id ) )
return false;
return false;
}
-// Internally used to hack WP_Query into submission
+/**
+ * Internally used to hack WP_Query into submission.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @param object $query WP_Query object
+ */
function _wp_get_post_autosave_hack( $query ) {
$query->is_single = false;
}
-
/**
- * wp_is_post_revision() - Determines if the specified post is a revision.
+ * Determines if the specified post is a revision.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
- * @param int|object $post post ID or post object
- * @return bool|int false if not a revision, ID of revision's parent otherwise
+ * @param int|object $post Post ID or post object.
+ * @return bool|int False if not a revision, ID of revision's parent otherwise.
*/
function wp_is_post_revision( $post ) {
if ( !$post = wp_get_post_revision( $post ) )
}
/**
- * wp_is_post_autosave() - Determines if the specified post is an autosave.
+ * Determines if the specified post is an autosave.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
- * @param int|object $post post ID or post object
- * @return bool|int false if not a revision, ID of autosave's parent otherwise
+ * @param int|object $post Post ID or post object.
+ * @return bool|int False if not a revision, ID of autosave's parent otherwise
*/
function wp_is_post_autosave( $post ) {
if ( !$post = wp_get_post_revision( $post ) )
}
/**
- * _wp_put_post_revision() - Inserts post data into the posts table as a post revision
+ * Inserts post data into the posts table as a post revision.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
* @uses wp_insert_post()
*
- * @param int|object|array $post post ID, post object OR post array
- * @param bool $autosave optional Is the revision an autosave?
- * @return mixed null or 0 if error, new revision ID if success
+ * @param int|object|array $post Post ID, post object OR post array.
+ * @param bool $autosave Optional. Is the revision an autosave?
+ * @return mixed Null or 0 if error, new revision ID if success.
*/
function _wp_put_post_revision( $post = null, $autosave = false ) {
if ( is_object($post) )
}
/**
- * wp_get_post_revision() - Gets a post revision
+ * Gets a post revision.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
* @uses get_post()
*
- * @param int|object $post post ID or post object
- * @param $output optional OBJECT, ARRAY_A, or ARRAY_N
- * @param string $filter optional sanitation filter. @see sanitize_post()
- * @return mixed null if error or post object if success
+ * @param int|object $post Post ID or post object
+ * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N.
+ * @param string $filter Optional sanitation filter. @see sanitize_post()
+ * @return mixed Null if error or post object if success
*/
function &wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') {
$null = null;
}
/**
- * wp_restore_post_revision() - Restores a post to the specified revision
+ * Restores a post to the specified revision.
*
- * Can restore a past using all fields of the post revision, or only selected fields.
+ * Can restore a past using all fields of the post revision, or only selected
+ * fields.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
* @uses wp_get_post_revision()
* @uses wp_update_post()
*
- * @param int|object $revision_id revision ID or revision object
- * @param array $fields optional What fields to restore from. Defaults to all.
- * @return mixed null if error, false if no fields to restore, (int) post ID if success
+ * @param int|object $revision_id Revision ID or revision object.
+ * @param array $fields Optional. What fields to restore from. Defaults to all.
+ * @return mixed Null if error, false if no fields to restore, (int) post ID if success.
*/
function wp_restore_post_revision( $revision_id, $fields = null ) {
if ( !$revision = wp_get_post_revision( $revision_id, ARRAY_A ) )
}
/**
- * wp_delete_post_revision() - Deletes a revision.
+ * Deletes a revision.
*
- * Deletes the row from the posts table corresponding to the specified revision
+ * Deletes the row from the posts table corresponding to the specified revision.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
* @uses wp_get_post_revision()
* @uses wp_delete_post()
*
- * @param int|object $revision_id revision ID or revision object
- * @param array $fields optional What fields to restore from. Defaults to all.
- * @return mixed null if error, false if no fields to restore, (int) post ID if success
+ * @param int|object $revision_id Revision ID or revision object.
+ * @param array $fields Optional. What fields to restore from. Defaults to all.
+ * @return mixed Null if error, false if no fields to restore, (int) post ID if success.
*/
function wp_delete_post_revision( $revision_id ) {
if ( !$revision = wp_get_post_revision( $revision_id ) )
}
/**
- * wp_get_post_revisions() - Returns all revisions of specified post
+ * Returns all revisions of specified post.
*
* @package WordPress
- * @subpackage Post Revisions
- * @since 2.6
+ * @subpackage Post_Revisions
+ * @since 2.6.0
*
* @uses get_children()
*
- * @param int|object $post_id post ID or post object
+ * @param int|object $post_id Post ID or post object
* @return array empty if no revisions
*/
function wp_get_post_revisions( $post_id = 0, $args = null ) {
return array();
return $revisions;
}
+
+function _set_preview($post) {
+
+ if ( ! is_object($post) )
+ return $post;
+
+ $preview = wp_get_post_autosave($post->ID);
+
+ if ( ! is_object($preview) )
+ return $post;
+
+ $preview = sanitize_post($preview);
+
+ $post->post_content = $preview->post_content;
+ $post->post_title = $preview->post_title;
+ $post->post_excerpt = $preview->post_excerpt;
+
+ return $post;
+}
+
+function _show_post_preview() {
+
+ if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) {
+ $id = (int) $_GET['preview_id'];
+
+ if ( false == wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) )
+ wp_die( __('You do not have permission to preview drafts.') );
+
+ add_filter('the_preview', '_set_preview');
+ }
+}
<?php
-
-/*
- * The Big Query.
+/**
+ * WordPress Query API
+ *
+ * The query API attempts to get which part of WordPress to the user is on. It
+ * also provides functionality to getting URL query information.
+ *
+ * @link http://codex.wordpress.org/The_Loop More information on The Loop.
+ *
+ * @package WordPress
+ * @subpackage Query
*/
+/**
+ * Retrieve variable in the WP_Query class.
+ *
+ * @see WP_Query::get()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param string $var The variable key to retrieve.
+ * @return mixed
+ */
function get_query_var($var) {
global $wp_query;
return $wp_query->get($var);
}
+/**
+ * Set query variable.
+ *
+ * @see WP_Query::set()
+ * @since 2.2.0
+ * @uses $wp_query
+ *
+ * @param string $var Query variable key.
+ * @param mixed $value
+ * @return null
+ */
function set_query_var($var, $value) {
global $wp_query;
return $wp_query->set($var, $value);
}
+/**
+ * Setup The Loop with query parameters.
+ *
+ * This will override the current WordPress Loop and shouldn't be used more than
+ * once. This must not be used within the WordPress Loop.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param string $query
+ * @return array List of posts
+ */
function &query_posts($query) {
unset($GLOBALS['wp_query']);
$GLOBALS['wp_query'] =& new WP_Query();
return $GLOBALS['wp_query']->query($query);
}
+/**
+ * Destroy the previous query and setup a new query.
+ *
+ * This should be used after {@link query_posts()} and before another {@link
+ * query_posts()}. This will remove obscure bugs that occur when the previous
+ * wp_query object is not destroyed properly before another is setup.
+ *
+ * @since 2.3.0
+ * @uses $wp_query
+ */
function wp_reset_query() {
unset($GLOBALS['wp_query']);
$GLOBALS['wp_query'] =& $GLOBALS['wp_the_query'];
* Query type checks.
*/
+/**
+ * Whether the current request is in WordPress admin Panel
+ *
+ * Does not inform on whether the user is an admin! Use capability checks to
+ * tell if the user should be accessing a section or not.
+ *
+ * @since 1.5.1
+ *
+ * @return bool True if inside WordPress administration pages.
+ */
function is_admin () {
if ( defined('WP_ADMIN') )
return WP_ADMIN;
return false;
}
+/**
+ * Is query requesting an archive page.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool True if page is archive.
+ */
function is_archive () {
global $wp_query;
return $wp_query->is_archive;
}
+/**
+ * Is query requesting an attachment page.
+ *
+ * @since 2.0.0
+ * @uses $wp_query
+ *
+ * @return bool True if page is attachment.
+ */
function is_attachment () {
global $wp_query;
return $wp_query->is_attachment;
}
+/**
+ * Is query requesting an author page.
+ *
+ * If the $author parameter is specified then the check will be expanded to
+ * include whether the queried author matches the one given in the parameter.
+ * You can match against integers and against strings.
+ *
+ * If matching against an integer, the ID should be used of the author for the
+ * test. If the $author is an ID and matches the author page user ID, then
+ * 'true' will be returned.
+ *
+ * If matching against strings, then the test will be matched against both the
+ * nickname and user nicename and will return true on success.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param string|int $author Optional. Is current page this author.
+ * @return bool True if page is author or $author (if set).
+ */
function is_author ($author = '') {
global $wp_query;
return false;
}
+/**
+ * Whether current page query contains a category name or given category name.
+ *
+ * The category list can contain category IDs, names, or category slugs. If any
+ * of them are part of the query, then it will return true.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param string|array $category Optional.
+ * @return bool
+ */
function is_category ($category = '') {
global $wp_query;
return false;
}
+/**
+ * Whether the current page query has the given tag slug or contains tag.
+ *
+ * @since 2.3.0
+ * @uses $wp_query
+ *
+ * @param string|array $slug Optional. Single tag or list of tags to check for.
+ * @return bool
+ */
function is_tag( $slug = '' ) {
global $wp_query;
return false;
}
+/**
+ * Whether the current page query has the given taxonomy slug or contains taxonomy.
+ *
+ * @since 2.5.0
+ * @uses $wp_query
+ *
+ * @param string|array $slug Optional. Slug or slugs to check in current query.
+ * @return bool
+ */
function is_tax( $slug = '' ) {
global $wp_query;
-
+
if ( !$wp_query->is_tax )
return false;
return false;
}
+/**
+ * Whether the current URL is within the comments popup window.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_comments_popup () {
global $wp_query;
return $wp_query->is_comments_popup;
}
+/**
+ * Whether current URL is based on a date.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_date () {
global $wp_query;
return $wp_query->is_date;
}
+/**
+ * Whether current blog URL contains a day.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_day () {
global $wp_query;
return $wp_query->is_day;
}
+/**
+ * Whether current page query is feed URL.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_feed () {
global $wp_query;
}
/**
- * is_front_page() - Is it the front of the site, whether blog view or a WP Page?
+ * Whether current page query is the front of the site.
*
- * @since 2.5
- * @uses is_home
- * @uses get_option
+ * @since 2.5.0
+ * @uses is_home()
+ * @uses get_option()
*
- * @return bool True if front of site
+ * @return bool True, if front of site.
*/
function is_front_page () {
// most likely case
}
/**
- * is_home() - Is it the blog view homepage?
+ * Whether current page view is the blog homepage.
*
- * @since 2.1
- * @global object $wp_query
+ * @since 1.5.0
+ * @uses $wp_query
*
- * @return bool True if blog view homepage
+ * @return bool True if blog view homepage.
*/
function is_home () {
global $wp_query;
return $wp_query->is_home;
}
+/**
+ * Whether current page query contains a month.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_month () {
global $wp_query;
return $wp_query->is_month;
}
+/**
+ * Whether query is page or contains given page(s).
+ *
+ * Calls the function without any parameters will only test whether the current
+ * query is of the page type. Either a list or a single item can be tested
+ * against for whether the query is a page and also is the value or one of the
+ * values in the page parameter.
+ *
+ * The parameter can contain the page ID, page title, or page name. The
+ * parameter can also be an array of those three values.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param mixed $page Either page or list of pages to test against.
+ * @return bool
+ */
function is_page ($page = '') {
global $wp_query;
$page = (array) $page;
- if ( in_array( $page_obj->ID, $page ) )
+ if ( in_array( $page_obj->ID, $page ) )
return true;
elseif ( in_array( $page_obj->post_title, $page ) )
return true;
return false;
}
+/**
+ * Whether query contains multiple pages for the results.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_paged () {
global $wp_query;
return $wp_query->is_paged;
}
+/**
+ * Whether the current page was created by a plugin.
+ *
+ * The plugin can set this by using the global $plugin_page and setting it to
+ * true.
+ *
+ * @since 1.5.0
+ * @global bool $plugin_page Used by plugins to tell the query that current is a plugin page.
+ *
+ * @return bool
+ */
function is_plugin_page() {
global $plugin_page;
return false;
}
+/**
+ * Whether the current query is preview of post or page.
+ *
+ * @since 2.0.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_preview() {
global $wp_query;
return $wp_query->is_preview;
}
+/**
+ * Whether the current query post is robots.
+ *
+ * @since 2.1.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_robots() {
global $wp_query;
return $wp_query->is_robots;
}
+/**
+ * Whether current query is the result of a user search.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_search () {
global $wp_query;
return $wp_query->is_search;
}
+/**
+ * Whether the current page query is single page.
+ *
+ * The parameter can contain the post ID, post title, or post name. The
+ * parameter can also be an array of those three values.
+ *
+ * This applies to other post types, attachments, pages, posts. Just means that
+ * the current query has only a single object.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param mixed $post Either post or list of posts to test against.
+ * @return bool
+ */
function is_single ($post = '') {
global $wp_query;
return false;
}
+/**
+ * Whether is single post, is a page, or is an attachment.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_singular() {
global $wp_query;
return $wp_query->is_singular;
}
+/**
+ * Whether the query contains a time.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_time () {
global $wp_query;
return $wp_query->is_time;
}
+/**
+ * Whether the query is a trackback.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_trackback () {
global $wp_query;
return $wp_query->is_trackback;
}
+/**
+ * Whether the query contains a year.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function is_year () {
global $wp_query;
return $wp_query->is_year;
}
+/**
+ * Whether current page query is a 404 and no results for WordPress query.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool True, if nothing is found matching WordPress Query.
+ */
function is_404 () {
global $wp_query;
* The Loop. Post loop control.
*/
+/**
+ * Whether current WordPress query has results to loop over.
+ *
+ * @see WP_Query::have_posts()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function have_posts() {
global $wp_query;
return $wp_query->have_posts();
}
+/**
+ * Whether the caller is in the Loop.
+ *
+ * @since 2.0.0
+ * @uses $wp_query
+ *
+ * @return bool True if caller is within loop, false if loop hasn't started or ended.
+ */
function in_the_loop() {
global $wp_query;
return $wp_query->in_the_loop;
}
+/**
+ * Rewind the loop posts.
+ *
+ * @see WP_Query::rewind_posts()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return null
+ */
function rewind_posts() {
global $wp_query;
return $wp_query->rewind_posts();
}
+/**
+ * Iterate the post index in the loop.
+ *
+ * @see WP_Query::the_post()
+ * @since 1.5.0
+ * @uses $wp_query
+ */
function the_post() {
global $wp_query;
* Comments loop.
*/
+/**
+ * Whether there are comments to loop over.
+ *
+ * @see WP_Query::have_comments()
+ * @since 2.2.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
function have_comments() {
global $wp_query;
return $wp_query->have_comments();
}
+/**
+ * Iterate comment index in the comment loop.
+ *
+ * @see WP_Query::the_comment()
+ * @since 2.2.0
+ * @uses $wp_query
+ *
+ * @return object
+ */
function the_comment() {
global $wp_query;
return $wp_query->the_comment();
* WP_Query
*/
+/**
+ * The WordPress Query class.
+ *
+ * @link http://codex.wordpress.org/Function_Reference/WP_Query Codex page.
+ *
+ * @since 1.5.0
+ */
class WP_Query {
+
+ /**
+ * Query string
+ *
+ * @since 1.5.0
+ * @access public
+ * @var string
+ */
var $query;
+
+ /**
+ * Query search variables set by the user.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var array
+ */
var $query_vars = array();
+
+ /**
+ * Holds the data for a single object that is queried.
+ *
+ * Holds the contents of a post, page, category, attachment.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var object|array
+ */
var $queried_object;
+
+ /**
+ * The ID of the queried object.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var int
+ */
var $queried_object_id;
+
+ /**
+ * Get post database query.
+ *
+ * @since 2.0.1
+ * @access public
+ * @var string
+ */
var $request;
+ /**
+ * List of posts.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var array
+ */
var $posts;
+
+ /**
+ * The amount of posts for the current query.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var int
+ */
var $post_count = 0;
+
+ /**
+ * Index of the current item in the loop.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var int
+ */
var $current_post = -1;
+
+ /**
+ * Whether the loop has started and the caller is in the loop.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var bool
+ */
var $in_the_loop = false;
+
+ /**
+ * The current post ID.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var int
+ */
var $post;
+ /**
+ * The list of comments for current post.
+ *
+ * @since 2.2.0
+ * @access public
+ * @var array
+ */
var $comments;
+
+ /**
+ * The amount of comments for the posts.
+ *
+ * @since 2.2.0
+ * @access public
+ * @var int
+ */
var $comment_count = 0;
+
+ /**
+ * The index of the comment in the comment loop.
+ *
+ * @since 2.2.0
+ * @access public
+ * @var int
+ */
var $current_comment = -1;
+
+ /**
+ * Current comment ID.
+ *
+ * @since 2.2.0
+ * @access public
+ * @var int
+ */
var $comment;
+ /**
+ * Amount of posts if limit clause was not used.
+ *
+ * @since 2.1.0
+ * @access public
+ * @var int
+ */
var $found_posts = 0;
+
+ /**
+ * The amount of pages.
+ *
+ * @since 2.1.0
+ * @access public
+ * @var int
+ */
var $max_num_pages = 0;
+ /**
+ * The amount of comment pages.
+ *
+ * @since 2.7.0
+ * @access public
+ * @var int
+ */
+ var $max_num_comment_pages = 0;
+
+ /**
+ * Set if query is single post.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_single = false;
+
+ /**
+ * Set if query is preview of blog.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var bool
+ */
var $is_preview = false;
+
+ /**
+ * Set if query returns a page.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_page = false;
+
+ /**
+ * Set if query is an archive list.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_archive = false;
+
+ /**
+ * Set if query is part of a date.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_date = false;
+
+ /**
+ * Set if query contains a year.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_year = false;
+
+ /**
+ * Set if query contains a month.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_month = false;
+
+ /**
+ * Set if query contains a day.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_day = false;
+
+ /**
+ * Set if query contains time.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_time = false;
+
+ /**
+ * Set if query contains an author.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_author = false;
+
+ /**
+ * Set if query contains category.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_category = false;
+
+ /**
+ * Set if query contains tag.
+ *
+ * @since 2.3.0
+ * @access public
+ * @var bool
+ */
var $is_tag = false;
+
+ /**
+ * Set if query contains taxonomy.
+ *
+ * @since 2.5.0
+ * @access public
+ * @var bool
+ */
var $is_tax = false;
+
+ /**
+ * Set if query was part of a search result.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_search = false;
+
+ /**
+ * Set if query is feed display.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_feed = false;
+
+ /**
+ * Set if query is comment feed display.
+ *
+ * @since 2.2.0
+ * @access public
+ * @var bool
+ */
var $is_comment_feed = false;
+
+ /**
+ * Set if query is trackback.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_trackback = false;
+
+ /**
+ * Set if query is blog homepage.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_home = false;
+
+ /**
+ * Set if query couldn't found anything.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_404 = false;
+
+ /**
+ * Set if query is within comments popup window.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_comments_popup = false;
+
+ /**
+ * Set if query is part of administration page.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var bool
+ */
var $is_admin = false;
+
+ /**
+ * Set if query is an attachment.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var bool
+ */
var $is_attachment = false;
+
+ /**
+ * Set if is single, is a page, or is an attachment.
+ *
+ * @since 2.1.0
+ * @access public
+ * @var bool
+ */
var $is_singular = false;
+
+ /**
+ * Set if query is for robots.
+ *
+ * @since 2.1.0
+ * @access public
+ * @var bool
+ */
var $is_robots = false;
+
+ /**
+ * Set if query contains posts.
+ *
+ * Basically, the homepage if the option isn't set for the static homepage.
+ *
+ * @since 2.1.0
+ * @access public
+ * @var bool
+ */
var $is_posts_page = false;
+ /**
+ * Resets query flags to false.
+ *
+ * The query flags are what page info WordPress was able to figure out.
+ *
+ * @since 2.0.0
+ * @access private
+ */
function init_query_flags() {
$this->is_single = false;
$this->is_page = false;
$this->is_posts_page = false;
}
+ /**
+ * Initiates object properties and sets default values.
+ *
+ * @since 1.5.0
+ * @access public
+ */
function init () {
unset($this->posts);
unset($this->query);
$this->init_query_flags();
}
- // Reparse the query vars.
+ /**
+ * Reparse the query vars.
+ *
+ * @since 1.5.0
+ * @access public
+ */
function parse_query_vars() {
$this->parse_query('');
}
+ /**
+ * Fills in the query variables, which do not exist within the parameter.
+ *
+ * @since 2.1.0
+ * @access public
+ *
+ * @param array $array Defined query variables.
+ * @return array Complete query variables with undefined ones filled in empty.
+ */
function fill_query_vars($array) {
$keys = array(
'error'
, 'w'
, 'category_name'
, 'tag'
+ , 'cat'
, 'tag_id'
, 'author_name'
, 'feed'
return $array;
}
- // Parse a query string and set query type booleans.
+ /**
+ * Parse a query string and set query type booleans.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @param string|array $query
+ */
function parse_query ($query) {
if ( !empty($query) || !isset($this->query) ) {
$this->init();
$qv['w'] = absint($qv['w']);
$qv['m'] = absint($qv['m']);
$qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // comma separated list of positive or negative integers
+ $qv['pagename'] = trim( $qv['pagename'] );
+ $qv['name'] = trim( $qv['name'] );
if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']);
if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']);
if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']);
if ( empty($qv['taxonomy']) || empty($qv['term']) ) {
$this->is_tax = false;
foreach ( $GLOBALS['wp_taxonomies'] as $t ) {
- if ( isset($t->query_var) && '' != $qv[$t->query_var] ) {
+ if ( isset($t->query_var) && isset($qv[$t->query_var]) && '' != $qv[$t->query_var] ) {
$this->is_tax = true;
break;
}
$this->is_author = true;
}
- if ( ($this->is_date || $this->is_author || $this->is_category || $this->is_tag ) )
+ if ( ($this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax) )
$this->is_archive = true;
}
do_action_ref_array('parse_query', array(&$this));
}
+ /**
+ * Sets the 404 property and saves whether query is feed.
+ *
+ * @since 2.0.0
+ * @access public
+ */
function set_404() {
$is_feed = $this->is_feed;
$this->is_feed = $is_feed;
}
+ /**
+ * Retrieve query variable.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @param string $query_var Query variable key.
+ * @return mixed
+ */
function get($query_var) {
if (isset($this->query_vars[$query_var])) {
return $this->query_vars[$query_var];
return '';
}
+ /**
+ * Set query variable.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @param string $query_var Query variable key.
+ * @param mixed $value Query variable value.
+ */
function set($query_var, $value) {
$this->query_vars[$query_var] = $value;
}
+ /**
+ * Retrieve the posts based on query variables.
+ *
+ * There are a few filters and actions that can be used to modify the post
+ * database query.
+ *
+ * @since 1.5.0
+ * @access public
+ * @uses do_action_ref_array() Calls 'pre_get_posts' hook before retrieving posts.
+ *
+ * @return array List of posts.
+ */
function &get_posts() {
global $wpdb, $user_ID;
$post_status_join = false;
$page = 1;
+ if ( !isset($q['caller_get_posts']) )
+ $q['caller_get_posts'] = false;
+
if ( !isset($q['suppress_filters']) )
$q['suppress_filters'] = false;
else if ( $q['posts_per_page'] == 0 )
$q['posts_per_page'] = 1;
+ if ( !isset($q['comments_per_page']) || $q['comments_per_page'] == 0 )
+ $q['comments_per_page'] = get_option('comments_per_page');
+
if ( $this->is_home && (empty($this->query) || $q['preview'] == 'true') && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) {
$this->is_page = true;
$this->is_home = false;
$q['name'] = $q['pagename'];
$where .= " AND ($wpdb->posts.ID = '$reqpage')";
$reqpage_obj = get_page($reqpage);
- if ( 'attachment' == $reqpage_obj->post_type ) {
+ if ( is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type ) {
$this->is_attachment = true;
$this->is_page = true;
$q['attachment_id'] = $reqpage;
$where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)";
}
- if ( $q['post_parent'] )
+ if ( is_numeric($q['post_parent']) )
$where .= $wpdb->prepare( " AND $wpdb->posts.post_parent = %d ", $q['post_parent'] );
if ( $q['page_id'] ) {
if ( !empty($q['s']) ) {
// added slashes screw with quote grouping when done early, so done later
$q['s'] = stripslashes($q['s']);
- if ($q['sentence']) {
+ if ( !empty($q['sentence']) ) {
$q['search_terms'] = array($q['s']);
} else {
- preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q[s], $matches);
+ preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q['s'], $matches);
$q['search_terms'] = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
}
- $n = ($q['exact']) ? '' : '%';
+ $n = !empty($q['exact']) ? '' : '%';
$searchand = '';
- foreach((array)$q['search_terms'] as $term) {
+ foreach( (array) $q['search_terms'] as $term) {
$term = addslashes_gpc($term);
$search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))";
$searchand = ' AND ';
}
$term = $wpdb->escape($q['s']);
- if (!$q['sentence'] && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] )
+ if (empty($q['sentence']) && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] )
$search .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')";
if ( !empty($search) )
$cat_array = preg_split('/[,\s]+/', $q['cat']);
$q['cat'] = '';
$req_cats = array();
- foreach ( $cat_array as $cat ) {
+ foreach ( (array) $cat_array as $cat ) {
$cat = intval($cat);
$req_cats[] = $cat;
$in = ($cat > 0);
$q['cat'] = implode(',', $req_cats);
}
- if ( !empty($q['category__in']) || !empty($q['category__not_in']) || !empty($q['category__and']) ) {
+ if ( !empty($q['category__in']) ) {
$groupby = "{$wpdb->posts}.ID";
}
}
if ( !empty($q['category__not_in']) ) {
- $ids = get_objects_in_term($q['category__not_in'], 'category');
- if ( is_wp_error( $ids ) )
- return $ids;
- if ( is_array($ids) && count($ids > 0) ) {
- $out_posts = "'" . implode("', '", $ids) . "'";
- $whichcat .= " AND $wpdb->posts.ID NOT IN ($out_posts)";
+ if ( $wpdb->has_cap( 'subqueries' ) ) {
+ $cat_string = "'" . implode("', '", $q['category__not_in']) . "'";
+ $whichcat .= " AND $wpdb->posts.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id IN ($cat_string) )";
+ } else {
+ $ids = get_objects_in_term($q['category__not_in'], 'category');
+ if ( is_wp_error( $ids ) )
+ $ids = array();
+ if ( is_array($ids) && count($ids > 0) ) {
+ $out_posts = "'" . implode("', '", $ids) . "'";
+ $whichcat .= " AND $wpdb->posts.ID NOT IN ($out_posts)";
+ }
}
}
}
}
- if ( !empty($q['tag__in']) || !empty($q['tag__not_in']) || !empty($q['tag__and']) ||
- !empty($q['tag_slug__in']) || !empty($q['tag_slug__and']) ) {
+ if ( !empty($q['tag__in']) || !empty($q['tag_slug__in']) ) {
$groupby = "{$wpdb->posts}.ID";
}
}
if ( !empty($q['tag__not_in']) ) {
- $ids = get_objects_in_term($q['tag__not_in'], 'post_tag');
- if ( is_array($ids) && count($ids > 0) ) {
- $out_posts = "'" . implode("', '", $ids) . "'";
- $whichcat .= " AND $wpdb->posts.ID NOT IN ($out_posts)";
+ if ( $wpdb->has_cap( 'subqueries' ) ) {
+ $tag_string = "'" . implode("', '", $q['tag__not_in']) . "'";
+ $whichcat .= " AND $wpdb->posts.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'post_tag' AND tt.term_id IN ($tag_string) )";
+ } else {
+ $ids = get_objects_in_term($q['tag__not_in'], 'post_tag');
+ if ( is_wp_error( $ids ) )
+ $ids = array();
+ if ( is_array($ids) && count($ids > 0) ) {
+ $out_posts = "'" . implode("', '", $ids) . "'";
+ $whichcat .= " AND $wpdb->posts.ID NOT IN ($out_posts)";
+ }
}
}
} else {
// Used to filter values
$allowed_keys = array('author', 'date', 'category', 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand');
+ if ( !empty($q['meta_key']) ) {
+ $allowed_keys[] = $q['meta_key'];
+ $allowed_keys[] = 'meta_value';
+ }
$q['orderby'] = urldecode($q['orderby']);
$q['orderby'] = addslashes_gpc($q['orderby']);
$orderby_array = explode(' ',$q['orderby']);
case 'rand':
$orderby = 'RAND()';
break;
+ case $q['meta_key']:
+ case 'meta_value':
+ $orderby = "$wpdb->postmeta.meta_value";
+ break;
default:
$orderby = "$wpdb->posts.post_" . $orderby;
}
// postmeta queries
if ( ! empty($q['meta_key']) || ! empty($q['meta_value']) )
$join .= " LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) ";
- if ( ! empty($q['meta_key']) )
- $where .= $wpdb->prepare("AND $wpdb->postmeta.meta_key = %s ", $q['meta_key']);
- if ( ! empty($q['meta_value']) )
- $where .= $wpdb->prepare("AND $wpdb->postmeta.meta_value = %s ", $q['meta_value']);
+ if ( ! empty($q['meta_key']) )
+ $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s ", $q['meta_key']);
+ if ( ! empty($q['meta_value']) ) {
+ if ( ! isset($q['meta_compare']) || empty($q['meta_compare']) || ! in_array($q['meta_compare'], array('=', '!=', '>', '>=', '<', '<=')) )
+ $q['meta_compare'] = '=';
+
+ $where .= $wpdb->prepare("AND $wpdb->postmeta.meta_value {$q['meta_compare']} %s ", $q['meta_value']);
+ }
// Apply filters on where and join prior to paging so that any
// manipulations to them are reflected in the paging by day queries.
$join = apply_filters('posts_join_paged', $join);
$orderby = apply_filters('posts_orderby', $orderby);
$distinct = apply_filters('posts_distinct', $distinct);
- $fields = apply_filters('posts_fields', $fields);
$limits = apply_filters( 'post_limits', $limits );
+
+ if ( ! empty($q['meta_key']) )
+ $fields = "$fields, $wpdb->postmeta.meta_value";
+
+ $fields = apply_filters('posts_fields', $fields);
}
// Announce current selection parameters. For use by caching plugins.
}
}
}
+
+ if ( $this->is_preview && current_user_can( "edit_{$post_type}", $this->posts[0]->ID ) )
+ $this->posts[0] = apply_filters('the_preview', $this->posts[0]);
+ }
+
+ // Put sticky posts at the top of the posts array
+ $sticky_posts = get_option('sticky_posts');
+ if ( $this->is_home && $page <= 1 && !empty($sticky_posts) && !$q['caller_get_posts'] ) {
+ $num_posts = count($this->posts);
+ $sticky_offset = 0;
+ // Loop over posts and relocate stickies to the front.
+ for ( $i = 0; $i < $num_posts; $i++ ) {
+ if ( in_array($this->posts[$i]->ID, $sticky_posts) ) {
+ $sticky_post = $this->posts[$i];
+ // Remove sticky from current position
+ array_splice($this->posts, $i, 1);
+ // Move to front, after other stickies
+ array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
+ // Increment the sticky offset. The next sticky will be placed at this offset.
+ $sticky_offset++;
+ // Remove post from sticky posts array
+ $offset = array_search($sticky_post->ID, $sticky_posts);
+ array_splice($sticky_posts, $offset, 1);
+ }
+ }
+
+ // Fetch sticky posts that weren't in the query results
+ if ( !empty($sticky_posts) ) {
+ $stickies__in = implode(',', array_map( 'absint', $sticky_posts ));
+ $stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in)" );
+ /** @todo Make sure post is published or viewable by the current user */
+ foreach ( $stickies as $sticky_post ) {
+ if ( 'publish' != $sticky_post->post_status )
+ continue;
+ array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
+ $sticky_offset++;
+ }
+ }
}
if ( !$q['suppress_filters'] )
return $this->posts;
}
+ /**
+ * Setup the next post and iterate current post index.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return object Next post.
+ */
function next_post() {
$this->current_post++;
return $this->post;
}
+ /**
+ * Sets up the current post.
+ *
+ * Retrieves the next post, sets up the post, sets the 'in the loop'
+ * property to true.
+ *
+ * @since 1.5.0
+ * @access public
+ * @uses $post
+ * @uses do_action() Calls 'loop_start' if loop has just started
+ */
function the_post() {
global $post;
$this->in_the_loop = true;
do_action('loop_start');
}
+ /**
+ * Whether there are more posts available in the loop.
+ *
+ * Calls action 'loop_end', when the loop is complete.
+ *
+ * @since 1.5.0
+ * @access public
+ * @uses do_action() Calls 'loop_start' if loop has just started
+ *
+ * @return bool True if posts are available, false if end of loop.
+ */
function have_posts() {
if ($this->current_post + 1 < $this->post_count) {
return true;
return false;
}
+ /**
+ * Rewind the posts and reset post index.
+ *
+ * @since 1.5.0
+ * @access public
+ */
function rewind_posts() {
$this->current_post = -1;
if ($this->post_count > 0) {
}
}
+ /**
+ * Iterate current comment index and return comment object.
+ *
+ * @since 2.2.0
+ * @access public
+ *
+ * @return object Comment object.
+ */
function next_comment() {
$this->current_comment++;
return $this->comment;
}
+ /**
+ * Sets up the current comment.
+ *
+ * @since 2.2.0
+ * @access public
+ * @global object $comment Current comment.
+ * @uses do_action() Calls 'comment_loop_start' hook when first comment is processed.
+ */
function the_comment() {
global $comment;
}
}
+ /**
+ * Whether there are more comments available.
+ *
+ * Automatically rewinds comments when finished.
+ *
+ * @since 2.2.0
+ * @access public
+ *
+ * @return bool True, if more comments. False, if no more posts.
+ */
function have_comments() {
if ($this->current_comment + 1 < $this->comment_count) {
return true;
return false;
}
+ /**
+ * Rewind the comments, resets the comment index and comment to first.
+ *
+ * @since 2.2.0
+ * @access public
+ */
function rewind_comments() {
$this->current_comment = -1;
if ($this->comment_count > 0) {
}
}
+ /**
+ * Sets up the WordPress query by parsing query string.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @param string $query URL query string.
+ * @return array List of posts.
+ */
function &query($query) {
$this->parse_query($query);
return $this->get_posts();
}
+ /**
+ * Retrieve queried object.
+ *
+ * If queried object is not set, then the queried object will be set from
+ * the category, tag, taxonomy, posts page, single post, page, or author
+ * query variable. After it is set up, it will be returned.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return object
+ */
function get_queried_object() {
if (isset($this->queried_object)) {
return $this->queried_object;
if ($this->is_category) {
$cat = $this->get('cat');
$category = &get_category($cat);
+ if ( is_wp_error( $category ) )
+ return NULL;
$this->queried_object = &$category;
$this->queried_object_id = (int) $cat;
} else if ($this->is_tag) {
$tag_id = $this->get('tag_id');
$tag = &get_term($tag_id, 'post_tag');
if ( is_wp_error( $tag ) )
- return $tag;
+ return NULL;
$this->queried_object = &$tag;
$this->queried_object_id = (int) $tag_id;
} else if ($this->is_tax) {
$slug = $this->get('term');
$term = &get_terms($tax, array('slug'=>$slug));
if ( is_wp_error($term) || empty($term) )
- return $term;
+ return NULL;
$term = $term[0];
$this->queried_object = $term;
$this->queried_object_id = $term->term_id;
return $this->queried_object;
}
+ /**
+ * Retrieve ID of the current queried object.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return int
+ */
function get_queried_object_id() {
$this->get_queried_object();
return 0;
}
+ /**
+ * PHP4 type constructor.
+ *
+ * Sets up the WordPress query, if parameter is not empty.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @param string $query URL query string.
+ * @return WP_Query
+ */
function WP_Query ($query = '') {
if (! empty($query)) {
$this->query($query);
}
}
-
-// Redirect old slugs
+/**
+ * Redirect old slugs to the correct permalink.
+ *
+ * Attempts to find the current slug from the past slugs.
+ *
+ * @since 2.1.0
+ * @uses $wp_query
+ * @uses $wpdb
+ *
+ * @return null If no link is found, null is returned.
+ */
function wp_old_slug_redirect () {
global $wp_query;
if ( is_404() && '' != $wp_query->query_vars['name'] ) :
endif;
}
-
-//
-// Private helper functions
-//
-
-// Setup global post data.
+/**
+ * Setup global post data.
+ *
+ * @since 1.5.0
+ *
+ * @param object $post Post data.
+ * @return bool True when finished.
+ */
function setup_postdata($post) {
global $id, $authordata, $day, $currentmonth, $page, $pages, $multipage, $more, $numpages;
if ( is_single() || is_page() || is_feed() )
$more = 1;
$content = $post->post_content;
- if ( preg_match('/<!--nextpage-->/', $content) ) {
+ if ( strpos( $content, '<!--nextpage-->' ) ) {
if ( $page > 1 )
$more = 1;
$multipage = 1;
return true;
}
-?>
+?>
\ No newline at end of file
*/
/**
- * username_exists() - Checks whether the given username exists.
+ * Checks whether the given username exists.
*
* @since 2.0.0
*
}
/**
- * email_exists() - Checks whether the given email exists.
+ * Checks whether the given email exists.
*
* @since 2.1.0
* @uses $wpdb
}
/**
- * validate_username() - Checks whether an username is valid.
+ * Checks whether an username is valid.
*
* @since 2.0.1
* @uses apply_filters() Calls 'validate_username' hook on $valid check and $username as parameters
}
/**
- * wp_insert_user() - Insert an user into the database.
+ * Insert an user into the database.
*
- * Can update a current user or insert a new user based on whether
- * the user's ID is present.
+ * Can update a current user or insert a new user based on whether the user's ID
+ * is present.
*
- * Can be used to update the user's info (see below), set the user's
- * role, and set the user's preference on whether they want the rich
- * editor on.
+ * Can be used to update the user's info (see below), set the user's role, and
+ * set the user's preference on whether they want the rich editor on.
*
- * Most of the $userdata array fields have filters associated with
- * the values. The exceptions are 'rich_editing', 'role', 'jabber',
- * 'aim', 'yim', 'user_registered', and 'ID'. The filters have the
- * prefix 'pre_user_' followed by the field name. An example using
- * 'description' would have the filter called, 'pre_user_description'
- * that can be hooked into.
+ * Most of the $userdata array fields have filters associated with the values.
+ * The exceptions are 'rich_editing', 'role', 'jabber', 'aim', 'yim',
+ * 'user_registered', and 'ID'. The filters have the prefix 'pre_user_' followed
+ * by the field name. An example using 'description' would have the filter
+ * called, 'pre_user_description' that can be hooked into.
*
* The $userdata array can contain the following fields:
* 'ID' - An integer that will be used for updating an existing user.
* The default is the user's username.
* 'user_url' - A string containing the user's URL for the user's web site.
* 'user_email' - A string containing the user's email address.
- * 'display_name' - A string that will be shown on the site. Defaults to user's username.
- * It is likely that you will want to change this, for both appearance and security
- * through obscurity (that is if you don't use and delete the default 'admin' user).
+ * 'display_name' - A string that will be shown on the site. Defaults to user's
+ * username. It is likely that you will want to change this, for both
+ * appearance and security through obscurity (that is if you don't use and
+ * delete the default 'admin' user).
* 'nickname' - The user's nickname, defaults to the user's username.
* 'first_name' - The user's first name.
* 'last_name' - The user's last name.
* 'description' - A string containing content about the user.
- * 'rich_editing' - A string for whether to enable the rich editor or not. False if not
- * empty.
+ * 'rich_editing' - A string for whether to enable the rich editor or not. False
+ * if not empty.
* 'user_registered' - The date the user registered. Format is 'Y-m-d H:i:s'.
* 'role' - A string used to set the user's role.
* 'jabber' - User's Jabber account.
if ( !empty($ID) ) {
$ID = (int) $ID;
$update = true;
+ $old_user_data = get_userdata($ID);
} else {
$update = false;
// Hash the password
if ( empty($rich_editing) )
$rich_editing = 'true';
+ if ( empty($comment_shortcuts) )
+ $comment_shortcuts = 'false';
+
if ( empty($admin_color) )
$admin_color = 'fresh';
$admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color);
+ if ( empty($use_ssl) )
+ $use_ssl = 0;
+
+ if ( empty($jabber) )
+ $jabber = '';
+
+ if ( empty($aim) )
+ $aim = '';
+
+ if ( empty($yim) )
+ $yim = '';
+
if ( empty($user_registered) )
$user_registered = gmdate('Y-m-d H:i:s');
update_usermeta( $user_id, 'aim', $aim );
update_usermeta( $user_id, 'yim', $yim );
update_usermeta( $user_id, 'rich_editing', $rich_editing);
+ update_usermeta( $user_id, 'comment_shortcuts', $comment_shortcuts);
update_usermeta( $user_id, 'admin_color', $admin_color);
+ update_usermeta( $user_id, 'use_ssl', $use_ssl);
if ( $update && isset($role) ) {
$user = new WP_User($user_id);
wp_cache_delete($user_login, 'userlogins');
if ( $update )
- do_action('profile_update', $user_id);
+ do_action('profile_update', $user_id, $old_user_data);
else
do_action('user_register', $user_id);
}
/**
- * wp_update_user() - Update an user in the database
+ * Update an user in the database.
*
- * It is possible to update a user's password by specifying the
- * 'user_pass' value in the $userdata parameter array.
+ * It is possible to update a user's password by specifying the 'user_pass'
+ * value in the $userdata parameter array.
*
- * If $userdata does not contain an 'ID' key, then a new user
- * will be created and the new user's ID will be returned.
+ * If $userdata does not contain an 'ID' key, then a new user will be created
+ * and the new user's ID will be returned.
*
- * If current user's password is being updated, then the cookies
- * will be cleared.
+ * If current user's password is being updated, then the cookies will be
+ * cleared.
*
* @since 2.0.0
* @see wp_insert_user() For what fields can be set in $userdata
}
/**
- * wp_create_user() - A simpler way of inserting an user into the database.
+ * A simpler way of inserting an user into the database.
*
* Creates a new user with just the username, password, and email. For a more
* detail creation of a user, use wp_insert_user() to specify more infomation.
<?php
+/**
+ * WordPress Rewrite API
+ *
+ * @package WordPress
+ * @subpackage Rewrite
+ */
-/* WP_Rewrite API
-*******************************************************************************/
-
-//Add a straight rewrite rule
+/**
+ * Add a straight rewrite rule.
+ *
+ * @see WP_Rewrite::add_rule() for long description.
+ * @since 2.1.0
+ *
+ * @param string $regex Regular Expression to match request against.
+ * @param string $redirect Page to redirect to.
+ * @param string $after Optional, default is 'bottom'. Where to add rule, can also be 'top'.
+ */
function add_rewrite_rule($regex, $redirect, $after = 'bottom') {
global $wp_rewrite;
$wp_rewrite->add_rule($regex, $redirect, $after);
}
-//Add a new tag (like %postname%)
-//warning: you must call this on init or earlier, otherwise the query var addition stuff won't work
+/**
+ * Add a new tag (like %postname%).
+ *
+ * Warning: you must call this on init or earlier, otherwise the query var
+ * addition stuff won't work.
+ *
+ * @since 2.1.0
+ *
+ * @param string $tagname
+ * @param string $regex
+ */
function add_rewrite_tag($tagname, $regex) {
//validation
if (strlen($tagname) < 3 || $tagname{0} != '%' || $tagname{strlen($tagname)-1} != '%') {
$wp_rewrite->add_rewrite_tag($tagname, $regex, $qv . '=');
}
-//Add a new feed type like /atom1/
+/**
+ * Add a new feed type like /atom1/.
+ *
+ * @since 2.1.0
+ *
+ * @param string $feedname
+ * @param callback $function Callback to run on feed display.
+ * @return string Feed action name.
+ */
function add_feed($feedname, $function) {
global $wp_rewrite;
if (!in_array($feedname, $wp_rewrite->feeds)) { //override the file if it is
return $hook;
}
-define('EP_PERMALINK', 1 );
-define('EP_ATTACHMENT', 2 );
-define('EP_DATE', 4 );
-define('EP_YEAR', 8 );
-define('EP_MONTH', 16 );
-define('EP_DAY', 32 );
-define('EP_ROOT', 64 );
-define('EP_COMMENTS', 128 );
-define('EP_SEARCH', 256 );
-define('EP_CATEGORIES', 512 );
-define('EP_TAGS', 1024 );
-define('EP_AUTHORS', 2048);
-define('EP_PAGES', 4096);
+/**
+ * Endpoint Mask for Permalink.
+ *
+ * @since 2.1.0
+ */
+define('EP_PERMALINK', 1);
+
+/**
+ * Endpoint Mask for Attachment.
+ *
+ * @since 2.1.0
+ */
+define('EP_ATTACHMENT', 2);
+
+/**
+ * Endpoint Mask for date.
+ *
+ * @since 2.1.0
+ */
+define('EP_DATE', 4);
+
+/**
+ * Endpoint Mask for year
+ *
+ * @since 2.1.0
+ */
+define('EP_YEAR', 8);
+
+/**
+ * Endpoint Mask for month.
+ *
+ * @since 2.1.0
+ */
+define('EP_MONTH', 16);
+
+/**
+ * Endpoint Mask for day.
+ *
+ * @since 2.1.0
+ */
+define('EP_DAY', 32);
+
+/**
+ * Endpoint Mask for root.
+ *
+ * @since 2.1.0
+ */
+define('EP_ROOT', 64);
+
+/**
+ * Endpoint Mask for comments.
+ *
+ * @since 2.1.0
+ */
+define('EP_COMMENTS', 128);
+
+/**
+ * Endpoint Mask for searches.
+ *
+ * @since 2.1.0
+ */
+define('EP_SEARCH', 256);
+
+/**
+ * Endpoint Mask for categories.
+ *
+ * @since 2.1.0
+ */
+define('EP_CATEGORIES', 512);
+
+/**
+ * Endpoint Mask for tags.
+ *
+ * @since 2.3.0
+ */
+define('EP_TAGS', 1024);
+
+/**
+ * Endpoint Mask for authors.
+ *
+ * @since 2.1.0
+ */
+define('EP_AUTHORS', 2048);
+
+/**
+ * Endpoint Mask for pages.
+ *
+ * @since 2.1.0
+ */
+define('EP_PAGES', 4096);
+
//pseudo-places
-define('EP_NONE', 0 );
-define('EP_ALL', 8191);
+/**
+ * Endpoint Mask for default, which is nothing.
+ *
+ * @since 2.1.0
+ */
+define('EP_NONE', 0);
+
+/**
+ * Endpoint Mask for everything.
+ *
+ * @since 2.1.0
+ */
+define('EP_ALL', 8191);
-//and an endpoint, like /trackback/
+/**
+ * Add an endpoint, like /trackback/.
+ *
+ * The endpoints are added to the end of the request. So a request matching
+ * "/2008/10/14/my_post/myep/", the endpoint will be "/myep/".
+ *
+ * @since 2.1.0
+ * @see WP_Rewrite::add_endpoint() Parameters and more description.
+ * @uses $wp_rewrite
+ *
+ * @param unknown_type $name
+ * @param unknown_type $places
+ */
function add_rewrite_endpoint($name, $places) {
global $wp_rewrite;
$wp_rewrite->add_endpoint($name, $places);
}
/**
- * _wp_filter_taxonomy_base() - filter the URL base for taxonomies, to remove any manually prepended /index.php/
- * @param string $base the taxonomy base that we're going to filter
- * @return string
- * @author Mark Jaquith
- */
+ * Filter the URL base for taxonomies.
+ *
+ * To remove any manually prepended /index.php/.
+ *
+ * @access private
+ * @since 2.6.0
+ * @author Mark Jaquith
+ *
+ * @param string $base The taxonomy base that we're going to filter
+ * @return string
+ */
function _wp_filter_taxonomy_base( $base ) {
if ( !empty( $base ) ) {
$base = preg_replace( '|^/index\.php/|', '', $base );
return $base;
}
-// examine a url (supposedly from this blog) and try to
-// determine the post ID it represents.
+/**
+ * Examine a url and try to determine the post ID it represents.
+ *
+ * Checks are supposedly from the hosted site blog.
+ *
+ * @since 1.0.0
+ *
+ * @param string $url Permalink to check.
+ * @return int Post ID, or 0 on failure.
+ */
function url_to_postid($url) {
global $wp_rewrite;
global $wp;
parse_str($query, $query_vars);
$query = array();
- foreach ( $query_vars as $key => $value ) {
+ foreach ( (array) $query_vars as $key => $value ) {
if ( in_array($key, $wp->public_query_vars) )
$query[$key] = $value;
}
return 0;
}
-/* WP_Rewrite class
-*******************************************************************************/
-
+/**
+ * WordPress Rewrite Component.
+ *
+ * The WordPress Rewrite class writes the rewrite module rules to the .htaccess
+ * file. It also handles parsing the request to get the correct setup for the
+ * WordPress Query class.
+ *
+ * The Rewrite along with WP class function as a front controller for WordPress.
+ * You can add rules to trigger your page view and processing using this
+ * component. The full functionality of a front controller does not exist,
+ * meaning you can't define how the template files load based on the rewrite
+ * rules.
+ *
+ * @since 1.5.0
+ */
class WP_Rewrite {
+ /**
+ * Default permalink structure for WordPress.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $permalink_structure;
+
+ /**
+ * Whether to add trailing slashes.
+ *
+ * @since 2.2.0
+ * @access private
+ * @var bool
+ */
var $use_trailing_slashes;
+
+ /**
+ * Customized or default category permalink base ( example.com/xx/tagname ).
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $category_base;
+
+ /**
+ * Customized or default tag permalink base ( example.com/xx/tagname ).
+ *
+ * @since 2.3.0
+ * @access private
+ * @var string
+ */
var $tag_base;
+
+ /**
+ * Permalink request structure for categories.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $category_structure;
+
+ /**
+ * Permalink request structure for tags.
+ *
+ * @since 2.3.0
+ * @access private
+ * @var string
+ */
var $tag_structure;
+
+ /**
+ * Permalink author request base ( example.com/author/authorname ).
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $author_base = 'author';
+
+ /**
+ * Permalink request structure for author pages.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $author_structure;
+
+ /**
+ * Permalink request structure for dates.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $date_structure;
+
+ /**
+ * Permalink request structure for pages.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $page_structure;
+
+ /**
+ * Search permalink base ( example.com/search/query ).
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $search_base = 'search';
+
+ /**
+ * Permalink request structure for searches.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $search_structure;
+
+ /**
+ * Comments permalink base.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $comments_base = 'comments';
+
+ /**
+ * Feed permalink base.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $feed_base = 'feed';
+
+ /**
+ * Comments feed request structure permalink.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $comments_feed_structure;
+
+ /**
+ * Feed request structure permalink.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $feed_structure;
+
+ /**
+ * Front URL path.
+ *
+ * The difference between the root property is that WordPress might be
+ * located at example/WordPress/index.php, if permalinks are turned off. The
+ * WordPress/index.php will be the front portion. If permalinks are turned
+ * on, this will most likely be empty or not set.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $front;
+
+ /**
+ * Root URL path to WordPress (without domain).
+ *
+ * The difference between front property is that WordPress might be located
+ * at example.com/WordPress/. The root is the 'WordPress/' portion.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $root = '';
+
+ /**
+ * Permalink to the home page.
+ *
+ * @since 1.5.0
+ * @access public
+ * @var string
+ */
var $index = 'index.php';
+
+ /**
+ * Request match string.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var string
+ */
var $matches = '';
+
+ /**
+ * Rewrite rules to match against the request to find the redirect or query.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var array
+ */
var $rules;
- var $extra_rules = array(); //those not generated by the class, see add_rewrite_rule()
- var $extra_rules_top = array(); //those not generated by the class, see add_rewrite_rule()
- var $non_wp_rules = array(); //rules that don't redirect to WP's index.php
+
+ /**
+ * Additional rules added external to the rewrite class.
+ *
+ * Those not generated by the class, see add_rewrite_rule().
+ *
+ * @since 2.1.0
+ * @access private
+ * @var array
+ */
+ var $extra_rules = array(); //
+
+ /**
+ * Additional rules that belong at the beginning to match first.
+ *
+ * Those not generated by the class, see add_rewrite_rule().
+ *
+ * @since 2.3.0
+ * @access private
+ * @var array
+ */
+ var $extra_rules_top = array(); //
+
+ /**
+ * Rules that don't redirect to WP's index.php.
+ *
+ * These rules are written to the mod_rewrite portion of the .htaccess.
+ *
+ * @since 2.1.0
+ * @access private
+ * @var array
+ */
+ var $non_wp_rules = array(); //
+
+ /**
+ * Extra permalink structures.
+ *
+ * @since 2.1.0
+ * @access private
+ * @var array
+ */
var $extra_permastructs = array();
+
+ /**
+ * Endpoints permalinks
+ *
+ * @since unknown
+ * @access private
+ * @var array
+ */
var $endpoints;
+
+ /**
+ * Whether to write every mod_rewrite rule for WordPress.
+ *
+ * This is off by default, turning it on might print a lot of rewrite rules
+ * to the .htaccess file.
+ *
+ * @since 2.0.0
+ * @access public
+ * @var bool
+ */
var $use_verbose_rules = false;
+
+ /**
+ * Whether to write every mod_rewrite rule for WordPress pages.
+ *
+ * @since 2.5.0
+ * @access public
+ * @var bool
+ */
var $use_verbose_page_rules = true;
+
+ /**
+ * Permalink structure search for preg_replace.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var array
+ */
var $rewritecode =
array(
'%year%',
'%search%'
);
+ /**
+ * Preg_replace values for the search, see {@link WP_Rewrite::$rewritecode}.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var array
+ */
var $rewritereplace =
array(
'([0-9]{4})',
'(.+)'
);
+ /**
+ * Search for the query to look for replacing.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var array
+ */
var $queryreplace =
array (
'year=',
's='
);
+ /**
+ * Supported default feeds.
+ *
+ * @since 1.5.0
+ * @access private
+ * @var array
+ */
var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
+ /**
+ * Whether permalinks are being used.
+ *
+ * This can be either rewrite module or permalink in the HTTP query string.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return bool True, if permalinks are enabled.
+ */
function using_permalinks() {
if (empty($this->permalink_structure))
return false;
return true;
}
+ /**
+ * Whether permalinks are being used and rewrite module is not enabled.
+ *
+ * Means that permalink links are enabled and index.php is in the URL.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return bool
+ */
function using_index_permalinks() {
if (empty($this->permalink_structure)) {
return false;
return false;
}
+ /**
+ * Whether permalinks are being used and rewrite module is enabled.
+ *
+ * Using permalinks and index.php is not in the URL.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return bool
+ */
function using_mod_rewrite_permalinks() {
if ( $this->using_permalinks() && ! $this->using_index_permalinks())
return true;
return false;
}
+ /**
+ * Index for matches for usage in preg_*() functions.
+ *
+ * The format of the string is, with empty matches property value, '$NUM'.
+ * The 'NUM' will be replaced with the value in the $number parameter. With
+ * the matches property not empty, the value of the returned string will
+ * contain that value of the matches property. The format then will be
+ * '$MATCHES[NUM]', with MATCHES as the value in the property and NUM the
+ * value of the $number parameter.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @param int $number Index number.
+ * @return string
+ */
function preg_index($number) {
$match_prefix = '$';
$match_suffix = '';
- if (! empty($this->matches)) {
+ if ( ! empty($this->matches) ) {
$match_prefix = '$' . $this->matches . '[';
$match_suffix = ']';
}
return "$match_prefix$number$match_suffix";
}
+ /**
+ * Retrieve all page and attachments for pages URIs.
+ *
+ * The attachments are for those that have pages as parents and will be
+ * retrieved.
+ *
+ * @since 2.5.0
+ * @access public
+ *
+ * @return array Array of page URIs as first element and attachment URIs as second element.
+ */
function page_uri_index() {
global $wpdb;
if ( !$posts )
return array( array(), array() );
-
foreach ($posts as $id => $post) {
// URL => page name
$uri = get_page_uri($id);
return array( $page_uris, $page_attachment_uris );
}
+ /**
+ * Retrieve all of the rewrite rules for pages.
+ *
+ * If the 'use_verbose_page_rules' property is false, then there will only
+ * be a single rewrite rule for pages for those matching '%pagename%'. With
+ * the property set to true, the attachments and the pages will be added for
+ * each individual attachment URI and page URI, respectively.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return array
+ */
function page_rewrite_rules() {
$rewrite_rules = array();
$page_structure = $this->get_page_permastruct();
$uris = $page_uris[0];
$attachment_uris = $page_uris[1];
-
if( is_array( $attachment_uris ) ) {
foreach ($attachment_uris as $uri => $pagename) {
$this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
return $rewrite_rules;
}
+ /**
+ * Retrieve date permalink structure, with year, month, and day.
+ *
+ * The permalink structure for the date, if not set already depends on the
+ * permalink structure. It can be one of three formats. The first is year,
+ * month, day; the second is day, month, year; and the last format is month,
+ * day, year. These are matched against the permalink structure for which
+ * one is used. If none matches, then the default will be used, which is
+ * year, month, day.
+ *
+ * Prevents post ID and date permalinks from overlapping. In the case of
+ * post_id, the date permalink will be prepended with front permalink with
+ * 'date/' before the actual permalink to form the complete date permalink
+ * structure.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return bool|string False on no permalink structure. Date permalink structure.
+ */
function get_date_permastruct() {
if (isset($this->date_structure)) {
return $this->date_structure;
$front = $this->front;
preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
$tok_index = 1;
- foreach ($tokens[0] as $token) {
+ foreach ( (array) $tokens[0] as $token) {
if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
$front = $front . 'date/';
break;
return $this->date_structure;
}
+ /**
+ * Retrieve the year permalink structure without month and day.
+ *
+ * Gets the date permalink structure and strips out the month and day
+ * permalink structures.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return bool|string False on failure. Year structure on success.
+ */
function get_year_permastruct() {
$structure = $this->get_date_permastruct($this->permalink_structure);
return $structure;
}
+ /**
+ * Retrieve the month permalink structure without day and with year.
+ *
+ * Gets the date permalink structure and strips out the day permalink
+ * structures. Keeps the year permalink structure.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return bool|string False on failure. Year/Month structure on success.
+ */
function get_month_permastruct() {
$structure = $this->get_date_permastruct($this->permalink_structure);
return $structure;
}
+ /**
+ * Retrieve the day permalink structure with month and year.
+ *
+ * Keeps date permalink structure with all year, month, and day.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return bool|string False on failure. Year/Month/Day structure on success.
+ */
function get_day_permastruct() {
return $this->get_date_permastruct($this->permalink_structure);
}
+ /**
+ * Retrieve the permalink structure for categories.
+ *
+ * If the category_base property has no value, then the category structure
+ * will have the front property value, followed by 'category', and finally
+ * '%category%'. If it does, then the root property will be used, along with
+ * the category_base property value.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return bool|string False on failure. Category permalink structure.
+ */
function get_category_permastruct() {
if (isset($this->category_structure)) {
return $this->category_structure;
return $this->category_structure;
}
+ /**
+ * Retrieve the permalink structure for tags.
+ *
+ * If the tag_base property has no value, then the tag structure will have
+ * the front property value, followed by 'tag', and finally '%tag%'. If it
+ * does, then the root property will be used, along with the tag_base
+ * property value.
+ *
+ * @since 2.3.0
+ * @access public
+ *
+ * @return bool|string False on failure. Tag permalink structure.
+ */
function get_tag_permastruct() {
if (isset($this->tag_structure)) {
return $this->tag_structure;
return $this->tag_structure;
}
+ /**
+ * Retrieve extra permalink structure by name.
+ *
+ * @since unknown
+ * @access public
+ *
+ * @param string $name Permalink structure name.
+ * @return string|bool False if not found. Permalink structure string.
+ */
function get_extra_permastruct($name) {
if ( isset($this->extra_permastructs[$name]) )
return $this->extra_permastructs[$name];
return false;
}
+ /**
+ * Retrieve the author permalink structure.
+ *
+ * The permalink structure is front property, author base, and finally
+ * '/%author%'. Will set the author_structure property and then return it
+ * without attempting to set the value again.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return string|bool False if not found. Permalink structure string.
+ */
function get_author_permastruct() {
if (isset($this->author_structure)) {
return $this->author_structure;
return $this->author_structure;
}
+ /**
+ * Retrieve the search permalink structure.
+ *
+ * The permalink structure is root property, search base, and finally
+ * '/%search%'. Will set the search_structure property and then return it
+ * without attempting to set the value again.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return string|bool False if not found. Permalink structure string.
+ */
function get_search_permastruct() {
if (isset($this->search_structure)) {
return $this->search_structure;
return $this->search_structure;
}
+ /**
+ * Retrieve the page permalink structure.
+ *
+ * The permalink structure is root property, and '%pagename%'. Will set the
+ * page_structure property and then return it without attempting to set the
+ * value again.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return string|bool False if not found. Permalink structure string.
+ */
function get_page_permastruct() {
if (isset($this->page_structure)) {
return $this->page_structure;
return $this->page_structure;
}
+ /**
+ * Retrieve the feed permalink structure.
+ *
+ * The permalink structure is root property, feed base, and finally
+ * '/%feed%'. Will set the feed_structure property and then return it
+ * without attempting to set the value again.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return string|bool False if not found. Permalink structure string.
+ */
function get_feed_permastruct() {
if (isset($this->feed_structure)) {
return $this->feed_structure;
return $this->feed_structure;
}
+ /**
+ * Retrieve the comment feed permalink structure.
+ *
+ * The permalink structure is root property, comment base property, feed
+ * base and finally '/%feed%'. Will set the comment_feed_structure property
+ * and then return it without attempting to set the value again.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return string|bool False if not found. Permalink structure string.
+ */
function get_comment_feed_permastruct() {
if (isset($this->comment_feed_structure)) {
return $this->comment_feed_structure;
return $this->comment_feed_structure;
}
+ /**
+ * Append or update tag, pattern, and query for replacement.
+ *
+ * If the tag already exists, replace the existing pattern and query for
+ * that tag, otherwise add the new tag, pattern, and query to the end of the
+ * arrays.
+ *
+ * @internal What is the purpose of this function again? Need to finish long
+ * description.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @param string $tag Append tag to rewritecode property array.
+ * @param string $pattern Append pattern to rewritereplace property array.
+ * @param string $query Append query to queryreplace property array.
+ */
function add_rewrite_tag($tag, $pattern, $query) {
- // If the tag already exists, replace the existing pattern and query for
- // that tag, otherwise add the new tag, pattern, and query to the end of
- // the arrays.
$position = array_search($tag, $this->rewritecode);
- if (FALSE !== $position && NULL !== $position) {
+ if ( false !== $position && null !== $position ) {
$this->rewritereplace[$position] = $pattern;
$this->queryreplace[$position] = $query;
} else {
}
}
- //the main WP_Rewrite function. generate the rules from permalink structure
+ /**
+ * Generate the rules from permalink structure.
+ *
+ * The main WP_Rewrite function for building the rewrite rule list. The
+ * contents of the function is a mix of black magic and regular expressions,
+ * so best just ignore the contents and move to the parameters.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @param string $permalink_structure The permalink structure.
+ * @param int $ep_mask Optional, default is EP_NONE. Endpoint constant, see EP_* constants.
+ * @param bool $paged Optional, default is true. Whether permalink request is paged.
+ * @param bool $feed Optional, default is true. Whether for feed.
+ * @param bool $forcomments Optional, default is false. Whether for comments.
+ * @param bool $walk_dirs Optional, default is true. Whether to create list of directories to walk over.
+ * @param bool $endpoints Optional, default is true. Whether endpoints are enabled.
+ * @return array Rewrite rule list.
+ */
function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
//build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
$feedregex2 = '';
- foreach ($this->feeds as $feed_name) {
+ foreach ( (array) $this->feeds as $feed_name) {
$feedregex2 .= $feed_name . '|';
}
$feedregex2 = '(' . trim($feedregex2, '|') . ')/?$';
//build a regex to match the trackback and page/xx parts of URLs
$trackbackregex = 'trackback/?$';
$pageregex = 'page/?([0-9]{1,})/?$';
+ $commentregex = 'comment-page-([0-9]{1,})/?$';
//build up an array of endpoint regexes to append => queries to append
if ($endpoints) {
$ep_query_append = array ();
- foreach ($this->endpoints as $endpoint) {
+ foreach ( (array) $this->endpoints as $endpoint) {
//match everything after the endpoint name, but allow for nothing to appear there
$epmatch = $endpoint[1] . '(/(.*))?/?$';
//this will be appended on to the rest of the query for each dir
$pagematch = $match . $pageregex;
$pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1);
+ //create query for /comment-page-xx
+ $commentmatch = $match . $commentregex;
+ $commentquery = $index . '?' . $query . '&cpage=' . $this->preg_index($num_toks + 1);
+
//create query for /feed/(feed|atom|rss|rss2|rdf)
$feedmatch = $match . $feedregex;
$feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
if ($paged) //...and /page/xx ones
$rewrite = array_merge($rewrite, array($pagematch => $pagequery));
+ //only on pages with comments add ../comment-page-xx/
+ if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask || EP_NONE & $ep_mask )
+ $rewrite = array_merge($rewrite, array($commentmatch => $commentquery));
+
//do endpoints
if ($endpoints) {
- foreach ($ep_query_append as $regex => $ep) {
+ foreach ( (array) $ep_query_append as $regex => $ep) {
//add the endpoints on if the mask fits
if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {
$rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
$sub1tb = $sub1 . $trackbackregex; //add trackback regex <permalink>/trackback/...
$sub1feed = $sub1 . $feedregex; //and <permalink>/feed/(atom|...)
$sub1feed2 = $sub1 . $feedregex2; //and <permalink>/(feed|atom...)
+ $sub1comment = $sub1 . $commentregex; //and <permalink>/comment-page-xx
//add an ? as we don't have to match that last slash, and finally a $ so we
//match to the end of the URL
$sub2tb = $sub2 . $trackbackregex; //and add trackbacks <permalink>/attachment/trackback
$sub2feed = $sub2 . $feedregex; //feeds, <permalink>/attachment/feed/(atom|...)
$sub2feed2 = $sub2 . $feedregex2; //and feeds again on to this <permalink>/attachment/(feed|atom...)
+ $sub2comment = $sub2 . $commentregex; //and <permalink>/comment-page-xx
//create queries for these extra tag-ons we've just dealt with
$subquery = $index . '?attachment=' . $this->preg_index(1);
$subtbquery = $subquery . '&tb=1';
$subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
+ $subcommentquery = $subquery . '&cpage=' . $this->preg_index(2);
//do endpoints for attachments
- if (! empty($endpoint) ) { foreach ($ep_query_append as $regex => $ep) {
+ if ( !empty($endpoint) ) { foreach ( (array) $ep_query_append as $regex => $ep ) {
if ($ep[0] & EP_ATTACHMENT) {
$rewrite[$sub1 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
$rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
//add regexes/queries for attachments, attachment trackbacks and so on
if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
- $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery));
- $rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery), $rewrite);
+ $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery, $sub1comment => $subcommentquery));
+ $rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery), $rewrite);
}
} //if($num_toks)
//add the rules for this dir to the accumulating $post_rewrite
return $post_rewrite; //the finished rules. phew!
}
+ /**
+ * Generate Rewrite rules with permalink structure and walking directory only.
+ *
+ * Shorten version of {@link WP_Rewrite::generate_rewrite_rules()} that
+ * allows for shorter list of parameters. See the method for longer
+ * description of what generating rewrite rules does.
+ *
+ * @uses WP_Rewrite::generate_rewrite_rules() See for long description and rest of parameters.
+ * @since 1.5.0
+ * @access public
+ *
+ * @param string $permalink_structure The permalink structure to generate rules.
+ * @param bool $walk_dirs Optional, default is false. Whether to create list of directories to walk over.
+ * @return array
+ */
function generate_rewrite_rule($permalink_structure, $walk_dirs = false) {
return $this->generate_rewrite_rules($permalink_structure, EP_NONE, false, false, false, $walk_dirs);
}
- /* rewrite_rules
+ /**
* Construct rewrite matches and queries from permalink structure.
- * Returns an associate array of matches and queries.
+ *
+ * Runs the action 'generate_rewrite_rules' with the parameter that is an
+ * reference to the current WP_Rewrite instance to further manipulate the
+ * permalink structures and rewrite rules. Runs the 'rewrite_rules_array'
+ * filter on the full rewrite rule array.
+ *
+ * There are two ways to manipulate the rewrite rules, one by hooking into
+ * the 'generate_rewrite_rules' action and gaining full control of the
+ * object or just manipulating the rewrite rule array before it is passed
+ * from the function.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return array An associate array of matches and queries.
*/
function rewrite_rules() {
$rewrite = array();
}
// robots.txt
- $robots_rewrite = array('robots.txt$' => $this->index . '?robots=1');
+ $robots_rewrite = array('robots\.txt$' => $this->index . '?robots=1');
//Default Feed rules - These are require to allow for the direct access files to work with permalink structure starting with %category%
$default_feeds = array( '.*wp-atom.php$' => $this->index .'?feed=atom',
return $this->rules;
}
+ /**
+ * Retrieve the rewrite rules.
+ *
+ * The difference between this method and {@link
+ * WP_Rewrite::rewrite_rules()} is that this method stores the rewrite rules
+ * in the 'rewrite_rules' option and retrieves it. This prevents having to
+ * process all of the permalinks to get the rewrite rules in the form of
+ * caching.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return array Rewrite rules.
+ */
function wp_rewrite_rules() {
$this->rules = get_option('rewrite_rules');
if ( empty($this->rules) ) {
return $this->rules;
}
+ /**
+ * Retrieve mod_rewrite formatted rewrite rules to write to .htaccess.
+ *
+ * Does not actually write to the .htaccess file, but creates the rules for
+ * the process that will.
+ *
+ * Will add the non_wp_rules property rules to the .htaccess file before
+ * the WordPress rewrite rules one.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return string
+ */
function mod_rewrite_rules() {
if ( ! $this->using_permalinks()) {
return '';
}
$site_root = parse_url(get_option('siteurl'));
- $site_root = trailingslashit($site_root['path']);
+ if ( isset( $site_root['path'] ) ) {
+ $site_root = trailingslashit($site_root['path']);
+ }
$home_root = parse_url(get_option('home'));
- $home_root = trailingslashit($home_root['path']);
+ if ( isset( $home_root['path'] ) ) {
+ $home_root = trailingslashit($home_root['path']);
+ } else {
+ $home_root = '/';
+ }
$rules = "<IfModule mod_rewrite.c>\n";
$rules .= "RewriteEngine On\n";
$rules .= "RewriteBase $home_root\n";
//add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
- foreach ($this->non_wp_rules as $match => $query) {
+ foreach ( (array) $this->non_wp_rules as $match => $query) {
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
$match = str_replace('.+?', '.+', $match);
"RewriteCond %{REQUEST_FILENAME} -d\n" .
"RewriteRule ^.*$ - [S=$num_rules]\n";
- foreach ($rewrite as $match => $query) {
+ foreach ( (array) $rewrite as $match => $query) {
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
$match = str_replace('.+?', '.+', $match);
return $rules;
}
- //Add a straight rewrite rule
+ /**
+ * Add a straight rewrite rule.
+ *
+ * Any value in the $after parameter that isn't 'bottom' will be placed at
+ * the top of the rules.
+ *
+ * @since 2.1.0
+ * @access public
+ *
+ * @param string $regex Regular expression to match against request.
+ * @param string $redirect URL regex redirects to when regex matches request.
+ * @param string $after Optional, default is bottom. Location to place rule.
+ */
function add_rule($regex, $redirect, $after = 'bottom') {
//get everything up to the first ?
$index = (strpos($redirect, '?') == false ? strlen($redirect) : strpos($redirect, '?'));
}
}
- //add a rule that doesn't redirect to index.php
+ /**
+ * Add a rule that doesn't redirect to index.php.
+ *
+ * Can redirect to any place.
+ *
+ * @since 2.1.0
+ * @access public
+ *
+ * @param string $regex Regular expression to match against request.
+ * @param string $redirect URL regex redirects to when regex matches request.
+ */
function add_external_rule($regex, $redirect) {
$this->non_wp_rules[$regex] = $redirect;
}
- //add an endpoint, like /trackback/, to be inserted after certain URL types (specified in $places)
+ /**
+ * Add an endpoint, like /trackback/.
+ *
+ * To be inserted after certain URL types (specified in $places).
+ *
+ * @since 2.1.0
+ * @access public
+ *
+ * @param string $name Name of endpoint.
+ * @param array $places URL types that endpoint can be used.
+ */
function add_endpoint($name, $places) {
global $wp;
$this->endpoints[] = array ( $places, $name );
$wp->add_query_var($name);
}
+ /**
+ * Add permalink structure.
+ *
+ * These are added along with the extra rewrite rules that are merged to the
+ * top.
+ *
+ * @since unknown
+ * @access public
+ *
+ * @param string $name Name for permalink structure.
+ * @param string $struct Permalink structure.
+ * @param bool $with_front Prepend front base to permalink structure.
+ */
function add_permastruct($name, $struct, $with_front = true) {
if ( $with_front )
$struct = $this->front . $struct;
$this->extra_permastructs[$name] = $struct;
}
+ /**
+ * Remove rewrite rules and then recreate rewrite rules.
+ *
+ * Calls {@link WP_Rewrite::wp_rewrite_rules()} after removing the
+ * 'rewrite_rules' option. If the function named 'save_mod_rewrite_rules'
+ * exists, it will be called.
+ *
+ * @since 2.0.1
+ * @access public
+ */
function flush_rules() {
delete_option('rewrite_rules');
$this->wp_rewrite_rules();
save_mod_rewrite_rules();
}
+ /**
+ * Sets up the object's properties.
+ *
+ * The 'use_verbose_page_rules' object property will be turned on, if the
+ * permalink structure includes the following: '%postname%', '%category%',
+ * '%tag%', or '%author%'.
+ *
+ * @since 1.5.0
+ * @access public
+ */
function init() {
$this->extra_rules = $this->non_wp_rules = $this->endpoints = array();
$this->permalink_structure = get_option('permalink_structure');
$this->use_verbose_page_rules = false;
}
+ /**
+ * Set the main permalink structure for the blog.
+ *
+ * Will update the 'permalink_structure' option, if there is a difference
+ * between the current permalink structure and the parameter value. Calls
+ * {@link WP_Rewrite::init()} after the option is updated.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @param string $permalink_structure Permalink structure.
+ */
function set_permalink_structure($permalink_structure) {
if ($permalink_structure != $this->permalink_structure) {
update_option('permalink_structure', $permalink_structure);
}
}
+ /**
+ * Set the category base for the category permalink.
+ *
+ * Will update the 'category_base' option, if there is a difference between
+ * the current category base and the parameter value. Calls
+ * {@link WP_Rewrite::init()} after the option is updated.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @param string $category_base Category permalink structure base.
+ */
function set_category_base($category_base) {
if ($category_base != $this->category_base) {
update_option('category_base', $category_base);
}
}
+ /**
+ * Set the tag base for the tag permalink.
+ *
+ * Will update the 'tag_base' option, if there is a difference between the
+ * current tag base and the parameter value. Calls
+ * {@link WP_Rewrite::init()} after the option is updated.
+ *
+ * @since 2.3.0
+ * @access public
+ *
+ * @param string $tag_base Tag permalink structure base.
+ */
function set_tag_base( $tag_base ) {
if ( $tag_base != $this->tag_base ) {
update_option( 'tag_base', $tag_base );
}
}
+ /**
+ * PHP4 Constructor - Calls init(), which runs setup.
+ *
+ * @since 1.5.0
+ * @access public
+ *
+ * @return WP_Rewrite
+ */
function WP_Rewrite() {
$this->init();
}
*/
do_action('load_feed_engine');
-
+/** RSS feed constant. */
define('RSS', 'RSS');
define('ATOM', 'Atom');
define('MAGPIE_USER_AGENT', 'WordPress/' . $GLOBALS['wp_version']);
}
}
-require_once( dirname(__FILE__) . '/class-snoopy.php');
if ( !function_exists('fetch_rss') ) :
+/**
+ * Build Magpie object based on RSS from URL.
+ *
+ * @since unknown
+ * @package External
+ * @subpackage MagpieRSS
+ *
+ * @param string $url URL to retrieve feed
+ * @return bool|MagpieRSS false on failure or MagpieRSS object on success.
+ */
function fetch_rss ($url) {
// initialize constants
init();
// setup headers
if ( $cache_status == 'STALE' ) {
$rss = $cache->get( $url );
- if ( $rss->etag and $rss->last_modified ) {
+ if ( isset($rss->etag) and $rss->last_modified ) {
$request_headers['If-None-Match'] = $rss->etag;
$request_headers['If-Last-Modified'] = $rss->last_modified;
}
} // end fetch_rss()
endif;
+/**
+ * Retrieve URL headers and content using WP HTTP Request API.
+ *
+ * @since unknown
+ * @package External
+ * @subpackage MagpieRSS
+ *
+ * @param string $url URL to retrieve
+ * @param array $headers Optional. Headers to send to the URL.
+ * @return Snoopy style response
+ */
function _fetch_remote_file ($url, $headers = "" ) {
- // Snoopy is an HTTP client in PHP
- $client = new Snoopy();
- $client->agent = MAGPIE_USER_AGENT;
- $client->read_timeout = MAGPIE_FETCH_TIME_OUT;
- $client->use_gzip = MAGPIE_USE_GZIP;
- if (is_array($headers) ) {
- $client->rawheaders = $headers;
- }
-
- @$client->fetch($url);
- return $client;
-
+ $resp = wp_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT));
+ if ( is_wp_error($resp) ) {
+ $error = array_shift($resp->errors);
+
+ $resp = new stdClass;
+ $resp->status = 500;
+ $resp->response_code = 500;
+ $resp->error = $error[0] . "\n"; //\n = Snoopy compatibility
+ return $resp;
+ }
+ $response = new stdClass;
+ $response->status = $resp['response']['code'];
+ $response->response_code = $resp['response']['code'];
+ $response->headers = $resp['headers'];
+ $response->results = $resp['body'];
+
+ return $response;
}
+/**
+ * Retrieve
+ *
+ * @since unknown
+ * @package External
+ * @subpackage MagpieRSS
+ *
+ * @param unknown_type $resp
+ * @return unknown
+ */
function _response_to_rss ($resp) {
$rss = new MagpieRSS( $resp->results );
// if RSS parsed successfully
- if ( $rss and !$rss->ERROR) {
+ if ( $rss && (!isset($rss->ERROR) || !$rss->ERROR) ) {
// find Etag, and Last-Modified
- foreach($resp->headers as $h) {
+ foreach( (array) $resp->headers as $h) {
// 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
if (strpos($h, ": ")) {
list($field, $val) = explode(": ", $h, 2);
} // end if ($rss and !$rss->error)
}
-/*=======================================================================*\
- Function: init
- Purpose: setup constants with default values
- check for user overrides
-\*=======================================================================*/
+/**
+ * Setup constants with default values, unless user overrides.
+ *
+ * @since unknown
+ * @package External
+ * @subpackage MagpieRSS
+ */
function init () {
if ( defined('MAGPIE_INITALIZED') ) {
return;
endif;
if ( !function_exists('wp_rss') ) :
+/**
+ * Display all RSS items in a HTML ordered list.
+ *
+ * @since unknown
+ * @package External
+ * @subpackage MagpieRSS
+ *
+ * @param string $url URL of feed to display. Will not auto sense feed URL.
+ * @param int $num_items Optional. Number of items to display, default is all.
+ */
function wp_rss( $url, $num_items = -1 ) {
if ( $rss = fetch_rss( $url ) ) {
echo '<ul>';
$rss->items = array_slice( $rss->items, 0, $num_items );
}
- foreach ( $rss->items as $item ) {
+ foreach ( (array) $rss->items as $item ) {
printf(
'<li><a href="%1$s" title="%2$s">%3$s</a></li>',
clean_url( $item['link'] ),
endif;
if ( !function_exists('get_rss') ) :
+/**
+ * Display RSS items in HTML list items.
+ *
+ * You have to specify which HTML list you want, either ordered or unordered
+ * before using the function. You also have to specify how many items you wish
+ * to display. You can't display all of them like you can with wp_rss()
+ * function.
+ *
+ * @since unknown
+ * @package External
+ * @subpackage MagpieRSS
+ *
+ * @param string $url URL of feed to display. Will not auto sense feed URL.
+ * @param int $num_items Optional. Number of items to display, default is all.
+ * @return bool False on failure.
+ */
function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS
$rss = fetch_rss($url);
if ( $rss ) {
$rss->items = array_slice($rss->items, 0, $num_items);
- foreach ($rss->items as $item ) {
+ foreach ( (array) $rss->items as $item ) {
echo "<li>\n";
echo "<a href='$item[link]' title='$item[description]'>";
echo htmlentities($item['title']);
}
endif;
-?>
\ No newline at end of file
+?>
<?php
-
+/**
+ * WordPress scripts and styles default loader.
+ *
+ * Most of the functionality that existed here was moved to
+ * {@link http://backpress.automattic.com/ BackPress}. WordPress themes and
+ * plugins will only be concerned about the filters and actions set in this
+ * file.
+ *
+ * @package WordPress
+ */
+
+/** BackPress: WordPress Dependencies Class */
require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
+
+/** BackPress: WordPress Scripts Class */
require( ABSPATH . WPINC . '/class.wp-scripts.php' );
+
+/** BackPress: WordPress Scripts Functions */
require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
+
+/** BackPress: WordPress Styles Class */
require( ABSPATH . WPINC . '/class.wp-styles.php' );
+
+/** BackPress: WordPress Styles Functions */
require( ABSPATH . WPINC . '/functions.wp-styles.php' );
+/**
+ * Setup WordPress scripts to load by default for Administration Panels.
+ *
+ * Localizes a few of the scripts.
+ *
+ * @since 2.6.0
+ *
+ * @param object $scripts WP_Scripts object.
+ */
function wp_default_scripts( &$scripts ) {
if (!$guessurl = site_url())
$guessurl = wp_guess_url();
+
$scripts->base_url = $guessurl;
$scripts->default_version = get_bloginfo( 'version' );
- $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery'), '20080318' );
+ $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery', 'hoverIntent'), '20081210' );
$scripts->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' );
- $scripts->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3958' );
+ $scripts->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '20081210' );
$scripts->localize( 'quicktags', 'quicktagsL10n', array(
'quickLinks' => __('(Quick Links)'),
'wordLookup' => __('Enter a word to look up:'),
'closeTags' => attribute_escape(__('close tags')),
'enterURL' => __('Enter the URL'),
'enterImageURL' => __('Enter the URL of the image'),
- 'enterImageDescription' => __('Enter a description of the image')
+ 'enterImageDescription' => __('Enter a description of the image'),
+ 'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};'
) );
$scripts->add( 'colorpicker', '/wp-includes/js/colorpicker.js', array('prototype'), '3517' );
- // Let a plugin replace the visual editor
- $visual_editor = apply_filters('visual_editor', array('tiny_mce'));
- $scripts->add( 'editor', false, $visual_editor, '20080321' );
-
- $scripts->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080710' );
-
// Modify this version when tinyMCE plugins are changed.
- $mce_version = apply_filters('tiny_mce_version', '20080810');
- $scripts->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version );
+ function mce_version() {
+ return '20081129';
+ }
+ add_filter( 'tiny_mce_version', 'mce_version' );
+
+ $scripts->add( 'editor', '/wp-admin/js/editor.js', false, mce_version() );
$scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
- $scripts->add( 'wp-ajax-response', '/wp-includes/js/wp-ajax-response.js', array('jquery'), '20080316' );
+ $scripts->add( 'wp-ajax-response', '/wp-includes/js/wp-ajax-response.js', array('jquery'), '20081210' );
$scripts->localize( 'wp-ajax-response', 'wpAjax', array(
'noPerm' => __('You do not have permission to do that.'),
- 'broken' => __('An unidentified error has occurred.')
+ 'broken' => __('An unidentified error has occurred.'),
+ 'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};'
) );
- $scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080622' );
+ $scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20081210' );
- $scripts->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20080729' );
+ $scripts->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20081210' );
$scripts->localize( 'wp-lists', 'wpListL10n', array(
'url' => admin_url('admin-ajax.php')
) );
- $scripts->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/scriptaculous.js', array('prototype'), '1.8.0');
+ $scripts->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.8.0');
$scripts->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.8.0');
$scripts->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.8.0');
$scripts->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.8.0');
$scripts->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2' );
$scripts->add( 'suggest', '/wp-includes/js/jquery/suggest.js', array('jquery'), '1.1b');
$scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20');
- $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1-20080430');
- $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.0.2-20080430');
- $scripts->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2');
+ $scripts->add( 'jquery-hotkeys', '/wp-includes/js/jquery/jquery.hotkeys.js', array('jquery'), '0.0.2' );
+ $scripts->add( 'jquery-table-hotkeys', '/wp-includes/js/jquery/jquery.table-hotkeys.js', array('jquery', 'jquery-hotkeys'), '20081128' );
+ $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1-20090123');
+ $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.2.0-20081031');
+ $scripts->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.2.0-20081031');
+ $scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload'), '2.2.0-20081031');
$scripts->localize( 'swfupload-degrade', 'uploadDegradeOptions', array(
'is_lighttpd_before_150' => is_lighttpd_before_150(),
) );
- $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2');
- $scripts->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080407');
+ $scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.2.0-20081031');
+ $scripts->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.2.0-20081201');
// these error messages came from the sample swfupload js, they might need changing.
$scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array(
'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
'dismiss' => __('Dismiss'),
'crunching' => __('Crunching…'),
'deleted' => __('Deleted'),
+ 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};'
) );
- $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui.core.js', array('jquery'), '1.5.1' );
- $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery-ui-core'), '1.5.1' );
- $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui.sortable.js', array('jquery-ui-core'), '1.5.1' );
+ $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui.core.js', array('jquery'), '1.5.2' );
+ $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery-ui-core'), '1.5.2' );
+ $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui.sortable.js', array('jquery-ui-core'), '1.5.2c' );
+ $scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui.draggable.js', array('jquery-ui-core'), '1.5.2' );
+ $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core'), '1.5.2' );
+ $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.5.2' );
+
+ $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20081210');
if ( is_admin() ) {
- $scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' );
+ $scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20081210' );
$scripts->localize( 'ajaxcat', 'catL10n', array(
'add' => attribute_escape(__('Add')),
- 'how' => __('Separate multiple categories with commas.')
+ 'how' => __('Separate multiple categories with commas.'),
+ 'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};'
) );
- $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20071031' );
- $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists'), '20071031' );
- $scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' );
- $scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20070405' );
+ $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20081210' );
+ $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists'), '20081210' );
+ $scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20081210' );
+ $scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20081210' );
$scripts->localize( 'password-strength-meter', 'pwsL10n', array(
- 'short' => __('Too short'),
- 'bad' => __('Bad'),
- 'good' => __('Good'),
- 'strong' => __('Strong')
+ 'empty' => __('Strength indicator'),
+ 'short' => __('Very weak'),
+ 'bad' => __('Weak'),
+ 'good' => _c('Medium|password strength'),
+ 'strong' => __('Strong'),
+ 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
) );
- $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists'), '20080311' );
+ $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081210' );
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
- 'pending' => __('%i% pending') // must look like: "# blah blah"
+ 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
+ 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last'])
) );
- $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20070823' );
- $scripts->add( 'admin-forms', '/wp-admin/js/forms.js', array('jquery'), '20080729');
+ $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20081210' );
$scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' );
- $scripts->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );
- $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery'), '20080128' );
+ $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery-ui-sortable'), '20081210' );
$scripts->localize( 'postbox', 'postboxL10n', array(
- 'requestFile' => admin_url('admin-ajax.php'),
+ 'requestFile' => admin_url('admin-ajax.php')
) );
- $scripts->add( 'slug', '/wp-admin/js/slug.js', array('jquery'), '20080208' );
+ $scripts->add( 'slug', '/wp-admin/js/slug.js', array('jquery'), '20081210' );
$scripts->localize( 'slug', 'slugL10n', array(
'requestFile' => admin_url('admin-ajax.php'),
'save' => __('Save'),
'cancel' => __('Cancel'),
+ 'l10n_print_after' => 'try{convertEntities(slugL10n);}catch(e){};'
) );
- $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080629' );
+ $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081210' );
$scripts->localize( 'post', 'postL10n', array(
'tagsUsed' => __('Tags used on this post:'),
'add' => attribute_escape(__('Add')),
'separate' => __('Separate tags with commas'),
'cancel' => __('Cancel'),
'edit' => __('Edit'),
+ 'publishOn' => __('Publish on:'),
+ 'publishOnFuture' => __('Schedule for:'),
+ 'publishOnPast' => __('Published on:'),
+ 'showcomm' => __('Show more comments'),
+ 'endcomm' => __('No more comments found.'),
+ 'publish' => __('Publish'),
+ 'schedule' => __('Schedule'),
+ 'update' => __('Update Post'),
+ 'savePending' => __('Save as Pending'),
+ 'saveDraft' => __('Save Draft'),
+ 'private' => __('Private'),
+ 'public' => __('Public'),
+ 'publicSticky' => __('Public, Sticky'),
+ 'password' => __('Password Protected'),
+ 'privatelyPublished' => __('Privately Published'),
+ 'published' => __('Published'),
+ 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'
) );
- $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'postbox'), '20080318' );
+ $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081210' );
$scripts->localize( 'page', 'postL10n', array(
'cancel' => __('Cancel'),
'edit' => __('Edit'),
+ 'publishOn' => __('Publish on:'),
+ 'publishOnFuture' => __('Schedule for:'),
+ 'publishOnPast' => __('Published on:'),
+ 'showcomm' => __('Show more comments'),
+ 'endcomm' => __('No more comments found.'),
+ 'publish' => __('Publish'),
+ 'schedule' => __('Schedule'),
+ 'update' => __('Update Page'),
+ 'savePending' => __('Save as Pending'),
+ 'saveDraft' => __('Save Draft'),
+ 'private' => __('Private'),
+ 'public' => __('Public'),
+ 'password' => __('Password Protected'),
+ 'privatelyPublished' => __('Privately Published'),
+ 'published' => __('Published'),
+ 'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'
) );
- $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20080131' );
- $scripts->add( 'comment', '/wp-admin/js/comment.js', array('postbox'), '20080219' );
+ $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20081210' );
+ $scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20081210' );
$scripts->localize( 'comment', 'commentL10n', array(
'cancel' => __('Cancel'),
'edit' => __('Edit'),
+ 'submittedOn' => __('Submitted on:'),
+ 'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};'
) );
- $scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20080709' );
- $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20080710' );
- $scripts->localize( 'upload', 'uploadL10n', array(
- 'browseTitle' => attribute_escape(__('Browse your files')),
- 'back' => __('« Back'),
- 'directTitle' => attribute_escape(__('Direct link to file')),
- 'edit' => __('Edit'),
- 'thumb' => __('Thumbnail'),
- 'full' => __('Full size'),
- 'icon' => __('Icon'),
- 'title' => __('Title'),
- 'show' => __('Show:'),
- 'link' => __('Link to:'),
- 'file' => __('File'),
- 'page' => __('Page'),
- 'none' => __('None'),
- 'editorText' => attribute_escape(__('Send to editor »')),
- 'insert' => __('Insert'),
- 'urlText' => __('URL'),
- 'desc' => __('Description'),
- 'deleteText' => attribute_escape(__('Delete File')),
- 'saveText' => attribute_escape(__('Save »')),
- 'confirmText' => __("Are you sure you want to delete the file '%title%'?\nClick ok to delete or cancel to go back.")
- ) );
- $scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20080503' );
+ $scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20081210' );
+ $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20081210' );
+
+ $scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20081210' );
$scripts->localize( 'admin-widgets', 'widgetsL10n', array(
'add' => __('Add'),
'edit' => __('Edit'),
'cancel' => __('Cancel'),
+ 'lameReminder' => __('Remember to click the "Save Changes" button at the bottom of the Current Widgets column after you\'re all done!'),
+ 'lamerReminder' => __("You're about to leave without having saved your changes!"),
+ 'l10n_print_after' => 'try{convertEntities(widgetsL10n);}catch(e){};'
));
- $scripts->add( 'word-count', '/wp-admin/js/word-count.js', array( 'jquery' ), '20080423' );
+ $scripts->add( 'word-count', '/wp-admin/js/word-count.js', array( 'jquery' ), '20081210' );
$scripts->localize( 'word-count', 'wordCountL10n', array(
- 'count' => __('Word count: %d')
+ 'count' => __('Word count: %d'),
+ 'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};'
));
-
- $scripts->add( 'wp-gears', '/wp-admin/js/wp-gears.js', false, '20080721' );
+
+ $scripts->add( 'wp-gears', '/wp-admin/js/wp-gears.js', false, '20081210' );
$scripts->localize( 'wp-gears', 'wpGearsL10n', array(
'updateCompleted' => __('Update completed.'),
- 'error' => __('Error:')
+ 'error' => __('Error:'),
+ 'l10n_print_after' => 'try{convertEntities(wpGearsL10n);}catch(e){};'
));
-
- $scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20080625' );
+
+ $scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20081210' );
+
+ $scripts->add( 'inline-edit-post', '/wp-admin/js/inline-edit-post.js', array( 'jquery', 'jquery-form', 'suggest' ), '20081210' );
+ $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
+ 'error' => __('Error while saving the changes.'),
+ 'ntdeltitle' => __('Remove From Bulk Edit'),
+ 'notitle' => __('(no title)'),
+ 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
+ ) );
+
+ $scripts->add( 'inline-edit-tax', '/wp-admin/js/inline-edit-tax.js', array( 'jquery', 'jquery-form' ), '20081210' );
+ $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
+ 'error' => __('Error while saving the changes.'),
+ 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
+ ) );
+
+ $scripts->add( 'plugin-install', '/wp-admin/js/plugin-install.js', array( 'thickbox', 'jquery' ), '20081210' );
+ $scripts->localize( 'plugin-install', 'plugininstallL10n', array(
+ 'plugin_information' => __('Plugin Information:'),
+ 'l10n_print_after' => 'try{convertEntities(plugininstallL10n);}catch(e){};'
+ ) );
+
+ $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
+
+ $scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox' ), '20081210' );
+
+ $scripts->add( 'hoverIntent', '/wp-includes/js/hoverIntent.js', array('jquery'), '20081210' );
+
}
}
+/**
+ * Assign default styles to $styles object.
+ *
+ * Nothing is returned, because the $styles parameter is passed by reference.
+ * Meaning that whatever object is passed will be updated without having to
+ * reassign the variable that was passed back to the same value. This saves
+ * memory.
+ *
+ * Adding default styles is not the only task, it also assigns the base_url
+ * property, the default version, and text direction for the object.
+ *
+ * @since 2.6.0
+ *
+ * @param object $styles
+ */
function wp_default_styles( &$styles ) {
- if (!$guessurl = site_url())
+ // This checks to see if site_url() returns something and if it does not
+ // then it assigns $guess_url to wp_guess_url(). Strange format, but it works.
+ if ( ! $guessurl = site_url() )
$guessurl = wp_guess_url();
$styles->base_url = $guessurl;
$styles->default_version = get_bloginfo( 'version' );
$styles->text_direction = 'rtl' == get_bloginfo( 'text_direction' ) ? 'rtl' : 'ltr';
- $rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'press-this-ie' );
+ $rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'farbtastic' );
- $styles->add( 'wp-admin', '/wp-admin/wp-admin.css' );
+ $styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20081210' );
$styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' );
- $styles->add( 'ie', '/wp-admin/css/ie.css' );
+ $styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20081210' );
$styles->add_data( 'ie', 'conditional', 'gte IE 6' );
- $styles->add( 'colors', true ); // Register "meta" stylesheet for admin colors
- $styles->add( 'colors-fresh', '/wp-admin/css/colors-fresh.css' ); // for login.php. Is there a better way?
+ $styles->add( 'colors', true, array(), '20081210' ); // Register "meta" stylesheet for admin colors
+ $styles->add( 'colors-fresh', '/wp-admin/css/colors-fresh.css', array(), '20081210'); // for login.php. Is there a better way?
$styles->add_data( 'colors-fresh', 'rtl', true );
-
- $styles->add( 'global', '/wp-admin/css/global.css' );
- $styles->add( 'media', '/wp-admin/css/media.css', array(), '20080709' );
- $styles->add( 'widgets', '/wp-admin/css/widgets.css' );
- $styles->add( 'dashboard', '/wp-admin/css/dashboard.css' );
- $styles->add( 'install', '/wp-admin/css/install.css', array(), '20080708' );
- $styles->add( 'theme-editor', '/wp-admin/css/theme-editor.css' );
- $styles->add( 'press-this', '/wp-admin/css/press-this.css', array(), '20080710' );
- $styles->add( 'press-this-ie', '/wp-admin/css/press-this-ie.css', array(), '20080710' );
- $styles->add_data( 'press-this-ie', 'conditional', 'gte IE 6' );
- $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array(), '20080613' );
- $styles->add( 'login', '/wp-admin/css/login.css' );
+ $styles->add( 'colors-classic', '/wp-admin/css/colors-classic.css', array(), '20081210');
+ $styles->add_data( 'colors-classic', 'rtl', true );
+
+ $styles->add( 'global', '/wp-admin/css/global.css', array(), '20081210' );
+ $styles->add( 'media', '/wp-admin/css/media.css', array(), '20081210' );
+ $styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20081210' );
+ $styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20081210' );
+ $styles->add( 'install', '/wp-admin/css/install.css', array(), '20081210' );
+ $styles->add( 'theme-editor', '/wp-admin/css/theme-editor.css', array(), '20081210' );
+ $styles->add( 'press-this', '/wp-admin/css/press-this.css', array(), '20081210' );
+ $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array(), '20081210' );
+ $styles->add( 'login', '/wp-admin/css/login.css', array(), '20081210' );
+ $styles->add( 'plugin-install', '/wp-admin/css/plugin-install.css', array(), '20081210' );
+ $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.2' );
foreach ( $rtl_styles as $rtl_style )
$styles->add_data( $rtl_style, 'rtl', true );
}
+/**
+ * Reorder JavaScript scripts array to place prototype before jQuery.
+ *
+ * @since 2.3.1
+ *
+ * @param array $js_array JavaScript scripst array
+ * @return array Reordered array, if needed.
+ */
function wp_prototype_before_jquery( $js_array ) {
if ( false === $jquery = array_search( 'jquery', $js_array ) )
return $js_array;
return $js_array;
}
-// These localizations require information that may not be loaded even by init
+/**
+ * Load localized script just in time for MCE.
+ *
+ * These localizations require information that may not be loaded even by init.
+ *
+ * @since 2.5.0
+ */
function wp_just_in_time_script_localization() {
- wp_localize_script( 'tiny_mce', 'wpTinyMCEConfig', array( 'defaultEditor' => wp_default_editor() ) );
+ global $current_user;
+
wp_localize_script( 'autosave', 'autosaveL10n', array(
'autosaveInterval' => AUTOSAVE_INTERVAL,
'previewPageText' => __('Preview this Page'),
'previewPostText' => __('Preview this Post'),
'requestFile' => admin_url('admin-ajax.php'),
- 'savingText' => __('Saving Draft…')
+ 'savingText' => __('Saving Draft…'),
+ 'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};'
+ ) );
+
+ $userid = isset($current_user) ? $current_user->ID : 0;
+ wp_localize_script( 'common', 'userSettings', array(
+ 'url' => SITECOOKIEPATH,
+ 'uid' => $userid,
+ 'time' => time()
) );
}
+/**
+ * Administration Panel CSS for changing the styles.
+ *
+ * If installing the 'wp-admin/' directory will be replaced with './'.
+ *
+ * The $_wp_admin_css_colors global manages the Administration Panels CSS
+ * stylesheet that is loaded. The option that is set is 'admin_color' and is the
+ * color and key for the array. The value for the color key is an object with
+ * a 'url' parameter that has the URL path to the CSS file.
+ *
+ * The query from $src parameter will be appended to the URL that is given from
+ * the $_wp_admin_css_colors array value URL.
+ *
+ * @since 2.6.0
+ * @uses $_wp_admin_css_colors
+ *
+ * @param string $src Source URL.
+ * @param string $handle Either 'colors' or 'colors-rtl'.
+ * @return string URL path to CSS stylesheet for Administration Panels.
+ */
function wp_style_loader_src( $src, $handle ) {
if ( defined('WP_INSTALLING') )
return preg_replace( '#^wp-admin/#', './', $src );
* There can only be one hook for each shortcode. Which means that if another
* plugin has a similar shortcode, it will override yours or yours will override
* theirs depending on which order the plugins are included and/or ran.
- *
+ *
* Simplest example of a shortcode tag using the API:
*
* <code>
if ( isset($m[4]) ) {
// enclosing tag - extra parameter
- return call_user_func($shortcode_tags[$tag], $attr, $m[4]);
+ return call_user_func($shortcode_tags[$tag], $attr, $m[4], $tag);
} else {
// self-closing tag
- return call_user_func($shortcode_tags[$tag], $attr);
+ return call_user_func($shortcode_tags[$tag], $attr, NULL, $tag);
}
}
*
* @since 2.5
*
- * @param string $text
+ * @param string $text
* @return array List of attributes and their value.
*/
function shortcode_parse_atts($text) {
return preg_replace('/'.$pattern.'/s', '', $content);
}
-add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()
+add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()
?>
\ No newline at end of file
<?php
/**
+ * Taxonomy API
+ *
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*/
//
/**
* Default Taxonomy Objects
- * @since 2.3
+ * @since 2.3.0
* @global array $wp_taxonomies
*/
$wp_taxonomies = array();
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wp_taxonomies
*
$object = (array) $object;
$taxonomies = array();
- foreach ( $wp_taxonomies as $taxonomy ) {
+ foreach ( (array) $wp_taxonomies as $taxonomy ) {
if ( array_intersect($object, (array) $taxonomy->object_type) )
$taxonomies[] = $taxonomy->name;
}
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wp_taxonomies
* @uses is_taxonomy() Checks whether taxonomy exists
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wp_taxonomies
*
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses is_taxonomy() Checks whether taxonomy exists
* @uses get_taxonomy() Used to get the taxonomy object
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
* @uses $wp_taxonomies Inserts new taxonomy object into the list
* @uses $wp_rewrite Adds rewrite tags and permastructs
* @uses $wp Adds query vars
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wpdb
* @uses wp_parse_args() Creates an array from string $args.
if ( !is_array($taxonomies) )
$taxonomies = array($taxonomies);
- foreach ( $taxonomies as $taxonomy ) {
+ foreach ( (array) $taxonomies as $taxonomy ) {
if ( ! is_taxonomy($taxonomy) )
return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
}
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wpdb
* @uses sanitize_term() Cleanses the term based on $filter context before returning.
function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
global $wpdb;
- if ( empty($term) )
- return null;
+ if ( empty($term) ) {
+ $error = new WP_Error('invalid_term', __('Empty Term'));
+ return $error;
+ }
- if ( ! is_taxonomy($taxonomy) )
- return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
+ if ( ! is_taxonomy($taxonomy) ) {
+ $error = new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
+ return $error;
+ }
- if ( is_object($term) ) {
+ if ( is_object($term) && empty($term->filter) ) {
wp_cache_add($term->term_id, $term, $taxonomy);
$_term = $term;
} else {
+ if ( is_object($term) )
+ $term = $term->term_id;
$term = (int) $term;
if ( ! $_term = wp_cache_get($term, $taxonomy) ) {
$_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %s LIMIT 1", $taxonomy, $term) );
if ( $output == OBJECT ) {
return $_term;
} elseif ( $output == ARRAY_A ) {
- return get_object_vars($_term);
+ $__term = get_object_vars($_term);
+ return $__term;
} elseif ( $output == ARRAY_N ) {
- return array_values(get_object_vars($_term));
+ $__term = array_values(get_object_vars($_term));
+ return $__term;
} else {
return $_term;
}
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wpdb
* @uses sanitize_term() Cleanses the term based on $filter context before returning.
return false;
} else if ( 'name' == $field ) {
// Assume already escaped
+ $value = stripslashes($value);
$field = 't.name';
} else {
$field = 't.term_id';
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wpdb
* @uses _get_term_hierarchy()
$children = $terms[$term];
- foreach ( $terms[$term] as $child ) {
+ foreach ( (array) $terms[$term] as $child ) {
if ( isset($terms[$child]) )
$children = array_merge($children, get_term_children($child, $taxonomy));
}
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses sanitize_term_field() Passes the return value in sanitize_term_field on success.
*
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses sanitize_term() Passes the return value on success
*
}
/**
- * Retrieve the terms in taxonomy or list of taxonomies.
+ * Retrieve the terms in a given taxonomy or list of taxonomies.
*
* You can fully inject any customizations to the query before it is sent, as
* well as control the output with a filter.
* The 'list_terms_exclusions' filter passes the compiled exclusions along with
* the $args.
*
- * The list that $args can contain, which will overwrite the defaults.
+ * The list of arguments that $args can contain, which will overwrite the defaults:
*
* orderby - Default is 'name'. Can be name, count, or nothing (will use
* term_id).
*
* order - Default is ASC. Can use DESC.
- * hide_empty - Default is true. Will not return empty $terms.
- * fields - Default is all.
- * slug - Any terms that has this value. Default is empty string.
- * hierarchical - Whether to return hierarchical taxonomy. Default is true.
- * name__like - Default is empty string.
*
- * The argument 'pad_counts' will count all of the children along with the
- * $terms.
+ * hide_empty - Default is true. Will not return empty terms, which means
+ * terms whose count is 0 according to the given taxonomy.
+ *
+ * exclude - Default is an empty string. A comma- or space-delimited string
+ * of term ids to exclude from the return array. If 'include' is non-empty,
+ * 'exclude' is ignored.
+ *
+ * exclude_tree - A comma- or space-delimited string of term ids to exclude
+ * from the return array, along with all of their descendant terms according to
+ * the primary taxonomy. If 'include' is non-empty, 'exclude_tree' is ignored.
+ *
+ * include - Default is an empty string. A comma- or space-delimited string
+ * of term ids to include in the return array.
+ *
+ * number - The maximum number of terms to return. Default is empty.
+ *
+ * offset - The number by which to offset the terms query.
+ *
+ * fields - Default is 'all', which returns an array of term objects.
+ * If 'fields' is 'ids' or 'names', returns an array of
+ * integers or strings, respectively.
+ *
+ * slug - Returns terms whose "slug" matches this value. Default is empty string.
+ *
+ * hierarchical - Whether to include terms that have non-empty descendants
+ * (even if 'hide_empty' is set to true).
+ *
+ * search - Returned terms' names will contain the value of 'search',
+ * case-insensitive. Default is an empty string.
+ *
+ * name__like - Returned terms' names will begin with the value of 'name__like',
+ * case-insensitive. Default is empty string.
+ *
+ * The argument 'pad_counts', if set to true will include the quantity of a term's
+ * children in the quantity of each term's "count" object variable.
*
- * The 'get' argument allows for overwriting 'hide_empty' and 'child_of', which
- * can be done by setting the value to 'all', instead of its default empty
- * string value.
+ * The 'get' argument, if set to 'all' instead of its default empty string,
+ * returns terms regardless of ancestry or whether the terms are empty.
*
- * The 'child_of' argument will be used if you use multiple taxonomy or the
- * first $taxonomy isn't hierarchical or 'parent' isn't used. The default is 0,
- * which will be translated to a false value. If 'child_of' is set, then
- * 'child_of' value will be tested against $taxonomy to see if 'child_of' is
- * contained within. Will return an empty array if test fails.
+ * The 'child_of' argument, when used, should be set to the integer of a term ID. Its default
+ * is 0. If set to a non-zero value, all returned terms will be descendants
+ * of that term according to the given taxonomy. Hence 'child_of' is set to 0
+ * if more than one taxonomy is passed in $taxonomies, because multiple taxonomies
+ * make term ancestry ambiguous.
*
- * If 'parent' is set, then it will be used to test against the first taxonomy.
- * Much like 'child_of'. Will return an empty array if the test fails.
+ * The 'parent' argument, when used, should be set to the integer of a term ID. Its default is
+ * the empty string '', which has a different meaning from the integer 0.
+ * If set to an integer value, all returned terms will have as an immediate
+ * ancestor the term whose ID is specified by that integer according to the given taxonomy.
+ * The 'parent' argument is different from 'child_of' in that a term X is considered a 'parent'
+ * of term Y only if term X is the father of term Y, not its grandfather or great-grandfather, etc.
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wpdb
* @uses wp_parse_args() Merges the defaults with those defined by $args and allows for strings.
$taxonomies = array($taxonomies);
}
- foreach ( $taxonomies as $taxonomy ) {
+ foreach ( (array) $taxonomies as $taxonomy ) {
if ( ! is_taxonomy($taxonomy) )
return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
}
$in_taxonomies = "'" . implode("', '", $taxonomies) . "'";
$defaults = array('orderby' => 'name', 'order' => 'ASC',
- 'hide_empty' => true, 'exclude' => '', 'include' => '',
+ 'hide_empty' => true, 'exclude' => '', 'exclude_tree' => '', 'include' => '',
'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
'pad_counts' => false, 'offset' => '', 'search' => '');
// $args can be whatever, only use the args defined in defaults to compute the key
$filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : '';
$key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );
+ $last_changed = wp_cache_get('last_changed', 'terms');
+ if ( !$last_changed ) {
+ $last_changed = time();
+ wp_cache_set('last_changed', $last_changed, 'terms');
+ }
+ $cache_key = "get_terms:$key:$last_changed";
- if ( $cache = wp_cache_get( 'get_terms', 'terms' ) ) {
- if ( isset( $cache[ $key ] ) )
- return apply_filters('get_terms', $cache[$key], $taxonomies, $args);
+ if ( $cache = wp_cache_get( $cache_key, 'terms' ) ) {
+ $terms = apply_filters('get_terms', $cache, $taxonomies, $args);
+ return $terms;
}
if ( 'count' == $orderby )
$inclusions = '';
if ( !empty($include) ) {
$exclude = '';
+ $exclude_tree = '';
$interms = preg_split('/[\s,]+/',$include);
if ( count($interms) ) {
- foreach ( $interms as $interm ) {
+ foreach ( (array) $interms as $interm ) {
if (empty($inclusions))
$inclusions = ' AND ( t.term_id = ' . intval($interm) . ' ';
else
$where .= $inclusions;
$exclusions = '';
+ if ( ! empty( $exclude_tree ) ) {
+ $excluded_trunks = preg_split('/[\s,]+/',$exclude_tree);
+ foreach( (array) $excluded_trunks as $extrunk ) {
+ $excluded_children = (array) get_terms($taxonomies[0], array('child_of' => intval($extrunk), 'fields' => 'ids'));
+ $excluded_children[] = $extrunk;
+ foreach( (array) $excluded_children as $exterm ) {
+ if ( empty($exclusions) )
+ $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
+ else
+ $exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' ';
+
+ }
+ }
+ }
if ( !empty($exclude) ) {
$exterms = preg_split('/[\s,]+/',$exclude);
if ( count($exterms) ) {
- foreach ( $exterms as $exterm ) {
- if (empty($exclusions))
+ foreach ( (array) $exterms as $exterm ) {
+ if ( empty($exclusions) )
$exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
else
$exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' ';
if ( $hide_empty && !$hierarchical )
$where .= ' AND tt.count > 0';
- if ( !empty($number) ) {
+ // don't limit the query results when we have to descend the family tree
+ if ( ! empty($number) && ! $hierarchical && empty( $child_of ) && '' == $parent ) {
if( $offset )
- $number = 'LIMIT ' . $offset . ',' . $number;
+ $limit = 'LIMIT ' . $offset . ',' . $number;
else
- $number = 'LIMIT ' . $number;
+ $limit = 'LIMIT ' . $number;
} else
- $number = '';
+ $limit = '';
if ( !empty($search) ) {
$search = like_escape($search);
if ( 'all' == $fields )
$select_this = 't.*, tt.*';
else if ( 'ids' == $fields )
- $select_this = 't.term_id';
+ $select_this = 't.term_id, tt.parent, tt.count';
else if ( 'names' == $fields )
- $select_this = 't.name';
+ $select_this = 't.term_id, tt.parent, tt.count, t.name';
- $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $number";
+ $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $limit";
+ $terms = $wpdb->get_results($query);
if ( 'all' == $fields ) {
- $terms = $wpdb->get_results($query);
update_term_cache($terms);
- } else if ( ('ids' == $fields) || ('names' == $fields) ) {
- $terms = $wpdb->get_col($query);
}
if ( empty($terms) ) {
$cache[ $key ] = array();
wp_cache_set( 'get_terms', $cache, 'terms' );
- return apply_filters('get_terms', array(), $taxonomies, $args);
+ $terms = apply_filters('get_terms', array(), $taxonomies, $args);
+ return $terms;
}
- if ( $child_of || $hierarchical ) {
+ if ( $child_of ) {
$children = _get_term_hierarchy($taxonomies[0]);
if ( ! empty($children) )
$terms = & _get_term_children($child_of, $terms, $taxonomies[0]);
}
// Update term counts to include children.
- if ( $pad_counts )
+ if ( $pad_counts && 'all' == $fields )
_pad_term_counts($terms, $taxonomies[0]);
// Make sure we show empty categories that have children.
- if ( $hierarchical && $hide_empty ) {
+ if ( $hierarchical && $hide_empty && is_array($terms) ) {
foreach ( $terms as $k => $term ) {
if ( ! $term->count ) {
$children = _get_term_children($term->term_id, $terms, $taxonomies[0]);
- foreach ( $children as $child )
- if ( $child->count )
- continue 2;
+ if( is_array($children) )
+ foreach ( $children as $child )
+ if ( $child->count )
+ continue 2;
// It really is empty
unset($terms[$k]);
}
reset ( $terms );
- $cache[ $key ] = $terms;
- wp_cache_set( 'get_terms', $cache, 'terms' );
+ $_terms = array();
+ if ( 'ids' == $fields ) {
+ while ( $term = array_shift($terms) )
+ $_terms[] = $term->term_id;
+ $terms = $_terms;
+ } elseif ( 'names' == $fields ) {
+ while ( $term = array_shift($terms) )
+ $_terms[] = $term->name;
+ $terms = $_terms;
+ }
+
+ if ( 0 < $number && intval(@count($terms)) > $number ) {
+ $terms = array_slice($terms, $offset, $number);
+ }
+
+ wp_cache_add( $cache_key, $terms, 'terms' );
$terms = apply_filters('get_terms', $terms, $taxonomies, $args);
return $terms;
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wpdb
*
if ( !empty($taxonomy) ) {
if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $slug, $taxonomy), ARRAY_A) )
return $result;
-
+
return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
}
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses sanitize_term_field Used to sanitize all fields in a term
*
if ( is_object($term) )
$do_object = true;
- foreach ( $fields as $field ) {
- if ( $do_object )
- $term->$field = sanitize_term_field($field, $term->$field, $term->term_id, $taxonomy, $context);
- else
- $term[$field] = sanitize_term_field($field, $term[$field], $term['term_id'], $taxonomy, $context);
+ $term_id = $do_object ? $term->term_id : (isset($term['term_id']) ? $term['term_id'] : 0);
+
+ foreach ( (array) $fields as $field ) {
+ if ( $do_object ) {
+ if ( isset($term->$field) )
+ $term->$field = sanitize_term_field($field, $term->$field, $term_id, $taxonomy, $context);
+ } else {
+ if ( isset($term[$field]) )
+ $term[$field] = sanitize_term_field($field, $term[$field], $term_id, $taxonomy, $context);
+ }
}
+ if ( $do_object )
+ $term->filter = $context;
+ else
+ $term['filter'] = $context;
+
return $term;
}
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wpdb
*
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wpdb
* @uses wp_parse_args() Turns strings into arrays and merges defaults into an array.
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
* @uses $wpdb
*
* @param int $object_id The term Object Id that refers to the term
if ( !is_array($taxonomies) )
$taxonomies = array($taxonomies);
- foreach ( $taxonomies as $taxonomy ) {
- $terms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
- $in_terms = "'" . implode("', '", $terms) . "'";
- $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_terms)", $object_id) );
- wp_update_term_count($terms, $taxonomy);
+ foreach ( (array) $taxonomies as $taxonomy ) {
+ $tt_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
+ $in_tt_ids = "'" . implode("', '", $tt_ids) . "'";
+ $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id) );
+ wp_update_term_count($tt_ids, $taxonomy);
}
}
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wpdb
* @uses do_action() Calls both 'delete_term' and 'delete_$taxonomy' action
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
* @uses $wpdb
*
* @param int|array $object_id The id of the object(s) to retrieve.
if ( !is_array($taxonomies) )
$taxonomies = array($taxonomies);
- foreach ( $taxonomies as $taxonomy ) {
+ foreach ( (array) $taxonomies as $taxonomy ) {
if ( ! is_taxonomy($taxonomy) )
return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
}
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
* @uses $wpdb
*
* @uses do_action() Calls 'create_term' hook with the term id and taxonomy id as parameters.
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
* @uses $wpdb
*
* @param int $object_id The object to relate to.
$terms = array($terms);
if ( ! $append )
- $old_terms = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
+ $old_tt_ids = wp_get_object_terms($object_id, $taxonomy, 'fields=tt_ids');
$tt_ids = array();
$term_ids = array();
- foreach ($terms as $term) {
+ foreach ( (array) $terms as $term) {
if ( !strlen(trim($term)) )
continue;
- if ( !$id = is_term($term, $taxonomy) )
- $id = wp_insert_term($term, $taxonomy);
- if ( is_wp_error($id) )
- return $id;
- $term_ids[] = $id['term_id'];
- $id = $id['term_taxonomy_id'];
- $tt_ids[] = $id;
+ if ( !$term_info = is_term($term, $taxonomy) )
+ $term_info = wp_insert_term($term, $taxonomy);
+ if ( is_wp_error($term_info) )
+ return $term_info;
+ $term_ids[] = $term_info['term_id'];
+ $tt_id = $term_info['term_taxonomy_id'];
+ $tt_ids[] = $tt_id;
- if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $id ) ) )
+ if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) )
continue;
- $wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $id ) );
+ $wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $tt_id ) );
}
wp_update_term_count($tt_ids, $taxonomy);
if ( ! $append ) {
- $delete_terms = array_diff($old_terms, $tt_ids);
+ $delete_terms = array_diff($old_tt_ids, $tt_ids);
if ( $delete_terms ) {
$in_delete_terms = "'" . implode("', '", $delete_terms) . "'";
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_delete_terms)", $object_id) );
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
* @uses $wpdb
*
* @param string $slug The string that will be tried for a unique slug
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses $wpdb
* @uses do_action() Will call both 'edit_term' and 'edit_$taxonomy' twice.
/**
* Enable or disable term counting.
*
- * @since 2.6
+ * @since 2.5.0
*
- * @param bool $defer Optional.
- * @return bool
+ * @param bool $defer Optional. Enable if true, disable if false.
+ * @return bool Whether term counting is enabled or disabled.
*/
-function wp_defer_term_counting($defer=NULL) {
+function wp_defer_term_counting($defer=null) {
static $_defer = false;
if ( is_bool($defer) ) {
$_defer = $defer;
// flush any deferred counts
if ( !$defer )
- wp_update_term_count( NULL, NULL, true );
+ wp_update_term_count( null, null, true );
}
return $_defer;
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
* @uses $wpdb
*
- * @param int|array $terms The ID of the terms
+ * @param int|array $terms The term_taxonomy_id of the terms
* @param string $taxonomy The context of the term.
* @return bool If no terms will return false, and if successful will return true.
*/
static $_deferred = array();
if ( $do_deferred ) {
- foreach ( array_keys($_deferred) as $tax ) {
+ foreach ( (array) array_keys($_deferred) as $tax ) {
wp_update_term_count_now( $_deferred[$tax], $tax );
unset( $_deferred[$tax] );
}
/**
* Perform term count update immediately.
*
- * @since 2.6
+ * @since 2.5.0
*
- * @param array $terms IDs of Terms to update.
+ * @param array $terms The term_taxonomy_id of terms to update.
* @param string $taxonomy The context of the term.
* @return bool Always true when complete.
*/
call_user_func($taxonomy->update_count_callback, $terms);
} else {
// Default count updater
- foreach ($terms as $term) {
+ foreach ( (array) $terms as $term) {
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) );
$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
}
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @see get_object_taxonomies() for more on $object_type
* @uses do_action() Will call action hook named, 'clean_object_term_cache' after completion.
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
* @uses $wpdb
*
* @param int|array $ids Single or list of Term IDs
*/
function clean_term_cache($ids, $taxonomy = '') {
global $wpdb;
+ static $cleaned = array();
if ( !is_array($ids) )
$ids = array($ids);
}
foreach ( $taxonomies as $taxonomy ) {
+ if ( isset($cleaned[$taxonomy]) )
+ continue;
+ $cleaned[$taxonomy] = true;
wp_cache_delete('all_ids', $taxonomy);
wp_cache_delete('get', $taxonomy);
delete_option("{$taxonomy}_children");
}
- wp_cache_delete('get_terms', 'terms');
+ wp_cache_set('last_changed', time(), 'terms');
do_action('clean_term_cache', $ids, $taxonomy);
}
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @uses wp_cache_get() Retrieves taxonomy relationship from cache
*
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
* @uses wp_get_object_terms() Used to get terms from the database to update
*
* @param string|array $object_ids Single or list of term object ID(s)
*
* @package WordPress
* @subpackage Taxonomy
- * @since 2.3
+ * @since 2.3.0
*
* @param array $terms List of Term objects to change
* @param string $taxonomy Optional. Update Term to this taxonomy in cache
*/
function update_term_cache($terms, $taxonomy = '') {
- foreach ( $terms as $term ) {
+ foreach ( (array) $terms as $term ) {
$term_taxonomy = $taxonomy;
if ( empty($term_taxonomy) )
$term_taxonomy = $term->taxonomy;
* @package WordPress
* @subpackage Taxonomy
* @access private
- * @since 2.3
+ * @since 2.3.0
*
* @uses update_option() Stores all of the children in "$taxonomy_children"
* option. That is the name of the taxonomy, immediately followed by '_children'.
/**
- * Get array of child terms.
+ * Get the subset of $terms that are descendants of $term_id.
*
- * If $terms is an array of objects, then objects will returned from the
- * function. If $terms is an array of IDs, then an array of ids of children will
- * be returned.
+ * If $terms is an array of objects, then _get_term_children returns an array of objects.
+ * If $terms is an array of IDs, then _get_term_children returns an array of IDs.
*
* @package WordPress
* @subpackage Taxonomy
* @access private
- * @since 2.3
+ * @since 2.3.0
*
- * @param int $term_id Look for this Term ID in $terms
- * @param array $terms List of Term IDs
- * @param string $taxonomy Term Context
- * @return array Empty if $terms is empty else returns full list of child terms.
+ * @param int $term_id The ancestor term: all returned terms should be descendants of $term_id.
+ * @param array $terms The set of terms---either an array of term objects or term IDs---from which those that are descendants of $term_id will be chosen.
+ * @param string $taxonomy The taxonomy which determines the hierarchy of the terms.
+ * @return array The subset of $terms that are descendants of $term_id.
*/
function &_get_term_children($term_id, $terms, $taxonomy) {
$empty_array = array();
if ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) )
return $empty_array;
- foreach ( $terms as $term ) {
+ foreach ( (array) $terms as $term ) {
$use_id = false;
if ( !is_object($term) ) {
$term = get_term($term, $taxonomy);
* @package WordPress
* @subpackage Taxonomy
* @access private
- * @since 2.3
+ * @since 2.3.0
* @uses $wpdb
*
* @param array $terms List of Term IDs
$term_items = array();
- foreach ( $terms as $key => $term ) {
+ foreach ( (array) $terms as $key => $term ) {
$terms_by_id[$term->term_id] = & $terms[$key];
$term_ids[$term->term_taxonomy_id] = $term->term_id;
}
$results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (".join(',', array_keys($term_ids)).") AND post_type = 'post' AND post_status = 'publish'");
foreach ( $results as $row ) {
$id = $term_ids[$row->term_taxonomy_id];
- ++$term_items[$id][$row->object_id];
+ $term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1;
}
// Touch every ancestor's lookup row for each post in each term
$child = $term_id;
while ( $parent = $terms_by_id[$child]->parent ) {
if ( !empty($term_items[$term_id]) )
- foreach ( $term_items[$term_id] as $item_id => $touches )
- ++$term_items[$parent][$item_id];
+ foreach ( $term_items[$term_id] as $item_id => $touches ) {
+ $term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id]: 1;
+ }
$child = $parent;
}
}
* @package WordPress
* @subpackage Taxonomy
* @access private
- * @since 2.3
+ * @since 2.3.0
* @uses $wpdb
*
- * @param array $terms List of Term IDs
+ * @param array $terms List of Term taxonomy IDs
*/
function _update_post_term_count( $terms ) {
global $wpdb;
- foreach ( $terms as $term ) {
+ foreach ( (array) $terms as $term ) {
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term ) );
$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
}
/**
* Generates a permalink for a taxonomy term archive.
*
- * @since 2.6
+ * @since 2.5.0
*
* @param object|int|string $term
* @param string $taxonomy
* 'sep' : default is empty string. Separate every taxonomy with value in this.
* 'after' : default is empty string. Display this after the taxonomies list.
*
- * @since 2.6
+ * @since 2.5.0
* @uses get_the_taxonomies()
*
* @param array $args Override the defaults.
* This function can be used within the loop. It will also return an array of
* the taxonomies with links to the taxonomy and name.
*
- * @since 2.6
+ * @since 2.5.0
*
* @param int $post Optional. Post ID or will use Global Post ID (in loop).
* @return array
/**
* Retrieve all taxonomies of a post with just the names.
*
- * @since 2.6
+ * @since 2.5.0
* @uses get_object_taxonomies()
*
* @param int $post Optional. Post ID
return get_object_taxonomies($post);
}
-?>
\ No newline at end of file
+/**
+ * Determine if the given object is associated with any of the given terms.
+ *
+ * The given terms are checked against the object's terms' term_ids, names and slugs.
+ * Terms given as integers will only be checked against the object's terms' term_ids.
+ * If no terms are given, determines if object is associated with any terms in the given taxonomy.
+ *
+ * @since 2.7.0
+ * @uses get_object_term_cache()
+ * @uses wp_get_object_terms()
+ *
+ * @param int $object_id. ID of the object (post ID, link ID, ...)
+ * @param string $taxonomy. Single taxonomy name
+ * @param int|string|array $terms Optional. Term term_id, name, slug or array of said
+ * @return bool|WP_Error. WP_Error on input error.
+ */
+function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
+ if ( !$object_id = (int) $object_id )
+ return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) );
+
+ $object_terms = get_object_term_cache( $object_id, $taxonomy );
+ if ( empty( $object_terms ) )
+ $object_terms = wp_get_object_terms( $object_id, $taxonomy );
+
+ if ( is_wp_error( $object_terms ) )
+ return $object_terms;
+ if ( empty( $object_terms ) )
+ return false;
+ if ( empty( $terms ) )
+ return ( !empty( $object_terms ) );
+
+ $terms = (array) $terms;
+
+ if ( $ints = array_filter( $terms, 'is_int' ) )
+ $strs = array_diff( $terms, $ints );
+ else
+ $strs =& $terms;
+
+ foreach ( $object_terms as $object_term ) {
+ if ( $ints && in_array( $object_term->term_id, $ints ) ) return true; // If int, check against term_id
+ if ( $strs ) {
+ if ( in_array( $object_term->term_id, $strs ) ) return true;
+ if ( in_array( $object_term->name, $strs ) ) return true;
+ if ( in_array( $object_term->slug, $strs ) ) return true;
+ }
+ }
+
+ return false;
+}
+
+?>
<?php
-/*
- * Theme/template/stylesheet functions.
+/**
+ * Theme, template, and stylesheet functions.
+ *
+ * @package WordPress
+ * @subpackage Template
*/
+/**
+ * Retrieve name of the current stylesheet.
+ *
+ * The theme name that the administrator has currently set the front end theme
+ * as.
+ *
+ * For all extensive purposes, the template name and the stylesheet name are
+ * going to be the same for most cases.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'stylesheet' filter on stylesheet name.
+ *
+ * @return string Stylesheet name.
+ */
function get_stylesheet() {
return apply_filters('stylesheet', get_option('stylesheet'));
}
+/**
+ * Retrieve stylesheet directory path for current theme.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'stylesheet_directory' filter on stylesheet directory and theme name.
+ *
+ * @return string Path to current theme directory.
+ */
function get_stylesheet_directory() {
$stylesheet = get_stylesheet();
$stylesheet_dir = get_theme_root() . "/$stylesheet";
return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet);
}
+/**
+ * Retrieve stylesheet directory URI.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
function get_stylesheet_directory_uri() {
$stylesheet = get_stylesheet();
$stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet";
return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet);
}
+/**
+ * Retrieve URI of current theme stylesheet.
+ *
+ * The stylesheet file name is 'style.css' which is appended to {@link
+ * get_stylesheet_directory_uri() stylesheet directory URI} path.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI.
+ *
+ * @return string
+ */
function get_stylesheet_uri() {
$stylesheet_dir_uri = get_stylesheet_directory_uri();
$stylesheet_uri = $stylesheet_dir_uri . "/style.css";
return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
}
+/**
+ * Retrieve localized stylesheet URI.
+ *
+ * The stylesheet directory for the localized stylesheet files are located, by
+ * default, in the base theme directory. The name of the locale file will be the
+ * locale followed by '.css'. If that does not exist, then the text direction
+ * stylesheet will be checked for existence, for example 'ltr.css'.
+ *
+ * The theme may change the location of the stylesheet directory by either using
+ * the 'stylesheet_directory_uri' filter or the 'locale_stylesheet_uri' filter.
+ * If you want to change the location of the stylesheet files for the entire
+ * WordPress workflow, then change the former. If you just have the locale in a
+ * separate folder, then change the latter.
+ *
+ * @since 2.1.0
+ * @uses apply_filters() Calls 'locale_stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI.
+ *
+ * @return string
+ */
function get_locale_stylesheet_uri() {
global $wp_locale;
$stylesheet_dir_uri = get_stylesheet_directory_uri();
return apply_filters('locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
}
+/**
+ * Retrieve name of the current theme.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'template' filter on template option.
+ *
+ * @return string Template name.
+ */
function get_template() {
return apply_filters('template', get_option('template'));
}
+/**
+ * Retrieve current theme directory.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'template_directory' filter on template directory path and template name.
+ *
+ * @return string Template directory path.
+ */
function get_template_directory() {
$template = get_template();
$template_dir = get_theme_root() . "/$template";
return apply_filters('template_directory', $template_dir, $template);
}
+/**
+ * Retrieve theme directory URI.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'template_directory_uri' filter on template directory URI path and template name.
+ *
+ * @return string Template directory URI.
+ */
function get_template_directory_uri() {
$template = get_template();
$template_dir_uri = get_theme_root_uri() . "/$template";
return apply_filters('template_directory_uri', $template_dir_uri, $template);
}
+/**
+ * Retrieve theme data from parsed theme file.
+ *
+ * The description will have the tags filtered with the following HTML elements
+ * whitelisted. The <b>'a'</b> element with the <em>href</em> and <em>title</em>
+ * attributes. The <b>abbr</b> element with the <em>title</em> attribute. The
+ * <b>acronym<b> element with the <em>title</em> attribute allowed. The
+ * <b>code</b>, <b>em</b>, and <b>strong</b> elements also allowed.
+ *
+ * The style.css file must contain theme name, theme URI, and description. The
+ * data can also contain author URI, author, template (parent template),
+ * version, status, and finally tags. Some of these are not used by WordPress
+ * administration panels, but are used by theme directory web sites which list
+ * the theme.
+ *
+ * @since 1.5.0
+ *
+ * @param string $theme_file Theme file path.
+ * @return array Theme data.
+ */
function get_theme_data( $theme_file ) {
$themes_allowed_tags = array(
'a' => array(
if ( preg_match( '|Author URI:(.*)$|mi', $theme_data, $author_uri ) )
$author_uri = clean_url( trim( $author_uri[1]) );
else
- $author_uti = '';
+ $author_uri = '';
if ( preg_match( '|Template:(.*)$|mi', $theme_data, $template ) )
$template = wp_kses( trim( $template[1] ), $themes_allowed_tags );
return array( 'Name' => $name, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Status' => $status, 'Tags' => $tags );
}
+/**
+ * Retrieve list of themes with theme data in theme directory.
+ *
+ * The theme is broken, if it doesn't have a parent theme and is missing either
+ * style.css and, or index.php. If the theme has a parent theme then it is
+ * broken, if it is missing style.css; index.php is optional. The broken theme
+ * list is saved in the {@link $wp_broken_themes} global, which is displayed on
+ * the theme list in the administration panels.
+ *
+ * @since 1.5.0
+ * @global array $wp_broken_themes Stores the broken themes.
+ * @global array $wp_themes Stores the working themes.
+ *
+ * @return array Theme list with theme data.
+ */
function get_themes() {
global $wp_themes, $wp_broken_themes;
}
$stylesheet_files = array();
+ $template_files = array();
+
$stylesheet_dir = @ dir("$theme_root/$stylesheet");
if ( $stylesheet_dir ) {
while ( ($file = $stylesheet_dir->read()) !== false ) {
- if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) )
- $stylesheet_files[] = "$theme_loc/$stylesheet/$file";
+ if ( !preg_match('|^\.+$|', $file) ) {
+ if ( preg_match('|\.css$|', $file) )
+ $stylesheet_files[] = "$theme_loc/$stylesheet/$file";
+ elseif ( preg_match('|\.php$|', $file) )
+ $template_files[] = "$theme_loc/$stylesheet/$file";
+ }
}
}
- $template_files = array();
$template_dir = @ dir("$theme_root/$template");
if ( $template_dir ) {
while(($file = $template_dir->read()) !== false) {
return $themes;
}
+/**
+ * Retrieve theme data.
+ *
+ * @since 1.5.0
+ *
+ * @param string $theme Theme name.
+ * @return array|null Null, if theme name does not exist. Theme data, if exists.
+ */
function get_theme($theme) {
$themes = get_themes();
if ( array_key_exists($theme, $themes) )
return $themes[$theme];
- return NULL;
+ return null;
}
+/**
+ * Retrieve current theme display name.
+ *
+ * If the 'current_theme' option has already been set, then it will be returned
+ * instead. If it is not set, then each theme will be iterated over until both
+ * the current stylesheet and current template name.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
function get_current_theme() {
if ( $theme = get_option('current_theme') )
return $theme;
return $current_theme;
}
+/**
+ * Retrieve path to themes directory.
+ *
+ * Does not have trailing slash.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'theme_root' filter on path.
+ *
+ * @return string Theme path.
+ */
function get_theme_root() {
return apply_filters('theme_root', WP_CONTENT_DIR . "/themes");
}
+/**
+ * Retrieve URI for themes directory.
+ *
+ * Does not have trailing slash.
+ *
+ * @since 1.5.0
+ *
+ * @return string Themes URI.
+ */
function get_theme_root_uri() {
return apply_filters('theme_root_uri', content_url('themes'), get_option('siteurl'));
}
+/**
+ * Retrieve path to file without the use of extension.
+ *
+ * Used to quickly retrieve the path of file without including the file
+ * extension. It will also check the parent template, if the file exists, with
+ * the use of {@link locate_template()}. Allows for more generic file location
+ * without the use of the other get_*_template() functions.
+ *
+ * Can be used with include() or require() to retrieve path.
+ * <code>
+ * if( '' != get_query_template( '404' ) )
+ * include( get_query_template( '404' ) );
+ * </code>
+ * or the same can be accomplished with
+ * <code>
+ * if( '' != get_404_template() )
+ * include( get_404_template() );
+ * </code>
+ *
+ * @since 1.5.0
+ *
+ * @param string $type Filename without extension.
+ * @return string Full path to file.
+ */
function get_query_template($type) {
- $template = '';
$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
- if ( file_exists(TEMPLATEPATH . "/{$type}.php") )
- $template = TEMPLATEPATH . "/{$type}.php";
-
- return apply_filters("{$type}_template", $template);
+ return apply_filters("{$type}_template", locate_template(array("{$type}.php")));
}
+/**
+ * Retrieve path of 404 template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
function get_404_template() {
return get_query_template('404');
}
+/**
+ * Retrieve path of archive template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
function get_archive_template() {
return get_query_template('archive');
}
+/**
+ * Retrieve path of author template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
function get_author_template() {
return get_query_template('author');
}
+/**
+ * Retrieve path of category template in current or parent template.
+ *
+ * Works by retrieving the current category ID, for example 'category-1.php' and
+ * will fallback to category.php template, if the ID category file doesn't
+ * exist.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'category_template' on file path of category template.
+ *
+ * @return string
+ */
function get_category_template() {
- $template = '';
- if ( file_exists(TEMPLATEPATH . "/category-" . absint( get_query_var('cat') ) . '.php') )
- $template = TEMPLATEPATH . "/category-" . absint( get_query_var('cat') ) . '.php';
- elseif ( file_exists(TEMPLATEPATH . "/category.php") )
- $template = TEMPLATEPATH . "/category.php";
-
+ $template = locate_template(array("category-" . absint( get_query_var('cat') ) . '.php', 'category.php'));
return apply_filters('category_template', $template);
}
+/**
+ * Retrieve path of tag template in current or parent template.
+ *
+ * Works by retrieving the current tag name, for example 'tag-wordpress.php' and will
+ * fallback to tag.php template, if the name tag file doesn't exist.
+ *
+ * @since 2.3.0
+ * @uses apply_filters() Calls 'tag_template' on file path of tag template.
+ *
+ * @return string
+ */
function get_tag_template() {
- $template = '';
- if ( file_exists(TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php') )
- $template = TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php';
- elseif ( file_exists(TEMPLATEPATH . "/tag.php") )
- $template = TEMPLATEPATH . "/tag.php";
-
+ $template = locate_template(array("tag-" . get_query_var('tag') . '.php', 'tag.php'));
return apply_filters('tag_template', $template);
}
+/**
+ * Retrieve path of taxonomy template in current or parent template.
+ *
+ * Retrieves the taxonomy and term, if term is available. The template is
+ * prepended with 'taxonomy-' and followed by both the taxonomy string and
+ * the taxonomy string followed by a dash and then followed by the term.
+ *
+ * The taxonomy and term template is checked and used first, if it exists.
+ * Second, just the taxonomy template is checked, and then finally, taxonomy.php
+ * template is used. If none of the files exist, then it will fall back on to
+ * index.php.
+ *
+ * @since unknown (2.6.0 most likely)
+ * @uses apply_filters() Calls 'taxonomy_template' filter on found path.
+ *
+ * @return string
+ */
function get_taxonomy_template() {
- $template = '';
$taxonomy = get_query_var('taxonomy');
$term = get_query_var('term');
- if ( $taxonomy && $term && file_exists(TEMPLATEPATH . "/taxonomy-$taxonomy-$term.php") )
- $template = TEMPLATEPATH . "/taxonomy-$taxonomy-$term.php";
- elseif ( $taxonomy && file_exists(TEMPLATEPATH . "/taxonomy-$taxonomy.php") )
- $template = TEMPLATEPATH . "/taxonomy-$taxonomy.php";
- elseif ( file_exists(TEMPLATEPATH . "/taxonomy.php") )
- $template = TEMPLATEPATH . "/taxonomy.php";
+ $templates = array();
+ if ( $taxonomy && $term )
+ $templates[] = "taxonomy-$taxonomy-$term.php";
+ if ( $taxonomy )
+ $templates[] = "taxonomy-$taxonomy.php";
+
+ $templates[] = "taxonomy.php";
+
+ $template = locate_template($templates);
return apply_filters('taxonomy_template', $template);
}
+/**
+ * Retrieve path of date template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
function get_date_template() {
return get_query_template('date');
}
+/**
+ * Retrieve path of home template in current or parent template.
+ *
+ * Attempts to locate 'home.php' first before falling back to 'index.php'.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'home_template' on file path of home template.
+ *
+ * @return string
+ */
function get_home_template() {
- $template = '';
-
- if ( file_exists(TEMPLATEPATH . "/home.php") )
- $template = TEMPLATEPATH . "/home.php";
- elseif ( file_exists(TEMPLATEPATH . "/index.php") )
- $template = TEMPLATEPATH . "/index.php";
-
+ $template = locate_template(array('home.php', 'index.php'));
return apply_filters('home_template', $template);
}
+/**
+ * Retrieve path of page template in current or parent template.
+ *
+ * First attempt is to look for the file in the '_wp_page_template' page meta
+ * data. The second attempt, if the first has a file and is not empty, is to
+ * look for 'page.php'.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
function get_page_template() {
global $wp_query;
if ( 'default' == $template )
$template = '';
- if ( !empty($template) && !validate_file($template) && file_exists(TEMPLATEPATH . "/$template") )
- $template = TEMPLATEPATH . "/$template";
- elseif ( file_exists(TEMPLATEPATH . "/page.php") )
- $template = TEMPLATEPATH . "/page.php";
- else
- $template = '';
+ $templates = array();
+ if ( !empty($template) && !validate_file($template) )
+ $templates[] = $template;
- return apply_filters('page_template', $template);
+ $templates[] = "page.php";
+
+ return apply_filters('page_template', locate_template($templates));
}
+/**
+ * Retrieve path of paged template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
function get_paged_template() {
return get_query_template('paged');
}
+/**
+ * Retrieve path of search template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
function get_search_template() {
return get_query_template('search');
}
+/**
+ * Retrieve path of single template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
function get_single_template() {
return get_query_template('single');
}
+/**
+ * Retrieve path of attachment template in current or parent template.
+ *
+ * The attachment path first checks if the first part of the mime type exists.
+ * The second check is for the second part of the mime type. The last check is
+ * for both types separated by an underscore. If neither are found then the file
+ * 'attachment.php' is checked and returned.
+ *
+ * Some examples for the 'text/plain' mime type are 'text.php', 'plain.php', and
+ * finally 'text_plain.php'.
+ *
+ * @since 2.0.0
+ *
+ * @return string
+ */
function get_attachment_template() {
global $posts;
$type = explode('/', $posts[0]->post_mime_type);
return get_query_template('attachment');
}
+/**
+ * Retrieve path of comment popup template in current or parent template.
+ *
+ * Checks for comment popup template in current template, if it exists or in the
+ * parent template. If it doesn't exist, then it retrieves the comment-popup.php
+ * file from the default theme. The default theme must then exist for it to
+ * work.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'comments_popup_template' filter on path.
+ *
+ * @return string
+ */
function get_comments_popup_template() {
- if ( file_exists( TEMPLATEPATH . '/comments-popup.php') )
- $template = TEMPLATEPATH . '/comments-popup.php';
- else
+ $template = locate_template(array("comments-popup.php"));
+ if ('' == $template)
$template = get_theme_root() . '/default/comments-popup.php';
return apply_filters('comments_popup_template', $template);
}
+/**
+ * Retrieve the name of the highest priority template file that exists.
+ *
+ * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which
+ * inherit from a parent theme can just overload one file.
+ *
+ * @since 2.7.0
+ *
+ * @param array $template_names Array of template files to search for in priority order.
+ * @param bool $load If true the template file will be loaded if it is found.
+ * @return string The template filename if one is located.
+ */
+function locate_template($template_names, $load = false) {
+ if (!is_array($template_names))
+ return '';
+
+ $located = '';
+ foreach($template_names as $template_name) {
+ if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
+ $located = STYLESHEETPATH . '/' . $template_name;
+ break;
+ } else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
+ $located = TEMPLATEPATH . '/' . $template_name;
+ break;
+ }
+ }
+
+ if ($load && '' != $located)
+ load_template($located);
+
+ return $located;
+}
+
+/**
+ * Require once the template file with WordPress environment.
+ *
+ * The globals are set up for the template file to ensure that the WordPress
+ * environment is available from within the function. The query variables are
+ * also available.
+ *
+ * @since 1.5.0
+ *
+ * @param string $_template_file Path to template file.
+ */
function load_template($_template_file) {
global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
require_once($_template_file);
}
+/**
+ * Display localized stylesheet link element.
+ *
+ * @since 2.1.0
+ */
function locale_stylesheet() {
$stylesheet = get_locale_stylesheet_uri();
if ( empty($stylesheet) )
echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />';
}
+/**
+ * Start preview theme output buffer.
+ *
+ * Will only preform task if the user has permissions and template and preview
+ * query variables exist.
+ *
+ * @since 2.5.0
+ */
function preview_theme() {
if ( ! (isset($_GET['template']) && isset($_GET['preview'])) )
return;
if ( !current_user_can( 'switch_themes' ) )
return;
- $_GET[template] = preg_replace('|[^a-z0-9_.-]|i', '', $_GET[template]);
+ $_GET['template'] = preg_replace('|[^a-z0-9_.-/]|i', '', $_GET['template']);
- if ( validate_file($_GET[template]) )
+ if ( validate_file($_GET['template']) )
return;
- add_filter('template', create_function('', "return '$_GET[template]';") );
+ add_filter('template', create_function('', "return '{$_GET['template']}';") );
if ( isset($_GET['stylesheet']) ) {
- $_GET[stylesheet] = preg_replace('|[^a-z0-9_.-]|i', '', $_GET[stylesheet]);
- if ( validate_file($_GET[stylesheet]) )
+ $_GET['stylesheet'] = preg_replace('|[^a-z0-9_.-/]|i', '', $_GET['stylesheet']);
+ if ( validate_file($_GET['stylesheet']) )
return;
- add_filter('stylesheet', create_function('', "return '$_GET[stylesheet]';") );
+ add_filter('stylesheet', create_function('', "return '{$_GET['stylesheet']}';") );
}
ob_start( 'preview_theme_ob_filter' );
}
add_action('setup_theme', 'preview_theme');
+/**
+ * Callback function for ob_start() to capture all links in the theme.
+ *
+ * @since unknown
+ * @access private
+ *
+ * @param string $content
+ * @return string
+ */
function preview_theme_ob_filter( $content ) {
return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );
}
+/**
+ * Manipulates preview theme links in order to control and maintain location.
+ *
+ * Callback function for preg_replace_callback() to accept and filter matches.
+ *
+ * @since unknown
+ * @access private
+ *
+ * @param array $matches
+ * @return string
+ */
function preview_theme_ob_filter_callback( $matches ) {
+ if ( strpos($matches[4], 'onclick') !== false )
+ $matches[4] = preg_replace('#onclick=([\'"]).*?(?<!\\\)\\1#i', '', $matches[4]); //Strip out any onclicks from rest of <a>. (?<!\\\) means to ignore the '" if its escaped by \ to prevent breaking mid-attribute.
if (
( false !== strpos($matches[3], '/wp-admin/') )
||
return $matches[1] . attribute_escape( $link ) . $matches[4];
}
+/**
+ * Switches current theme to new template and stylesheet names.
+ *
+ * @since unknown
+ * @uses do_action() Calls 'switch_theme' action on updated theme display name.
+ *
+ * @param string $template Template name
+ * @param string $stylesheet Stylesheet name.
+ */
function switch_theme($template, $stylesheet) {
update_option('template', $template);
update_option('stylesheet', $stylesheet);
do_action('switch_theme', $theme);
}
+/**
+ * Checks that current theme files 'index.php' and 'style.css' exists.
+ *
+ * Does not check the 'default' theme. The 'default' theme should always exist
+ * or should have another theme renamed to that template name and directory
+ * path. Will switch theme to default if current theme does not validate.
+ * You can use the 'validate_current_theme' filter to return FALSE to
+ * disable this functionality.
+ *
+ * @since 1.5.0
+ *
+ * @return bool
+ */
function validate_current_theme() {
// Don't validate during an install/upgrade.
- if ( defined('WP_INSTALLING') )
+ if ( defined('WP_INSTALLING') || !apply_filters( 'validate_current_theme', true ) )
return true;
if ( get_template() != 'default' && !file_exists(get_template_directory() . '/index.php') ) {
return true;
}
+/**
+ * Retrieve theme modification value for the current theme.
+ *
+ * If the modification name does not exist, then the $default will be passed
+ * through {@link http://php.net/sprintf sprintf()} PHP function with the first
+ * string the template directory URI and the second string the stylesheet
+ * directory URI.
+ *
+ * @since 2.1.0
+ * @uses apply_filters() Calls 'theme_mod_$name' filter on the value.
+ *
+ * @param string $name Theme modification name.
+ * @param bool|string $default
+ * @return string
+ */
function get_theme_mod($name, $default = false) {
$theme = get_current_theme();
return apply_filters( "theme_mod_$name", sprintf($default, get_template_directory_uri(), get_stylesheet_directory_uri()) );
}
+/**
+ * Update theme modification value for the current theme.
+ *
+ * @since 2.1.0
+ *
+ * @param string $name Theme modification name.
+ * @param string $value theme modification value.
+ */
function set_theme_mod($name, $value) {
$theme = get_current_theme();
wp_cache_delete("mods_$theme", 'options');
}
+/**
+ * Remove theme modification name from current theme list.
+ *
+ * If removing the name also removes all elements, then the entire option will
+ * be removed.
+ *
+ * @since 2.1.0
+ *
+ * @param string $name Theme modification name.
+ * @return null
+ */
function remove_theme_mod( $name ) {
$theme = get_current_theme();
wp_cache_delete("mods_$theme", 'options');
}
+/**
+ * Remove theme modifications option for current theme.
+ *
+ * @since 2.1.0
+ */
function remove_theme_mods() {
$theme = get_current_theme();
delete_option("mods_$theme");
}
+/**
+ * Retrieve text color for custom header.
+ *
+ * @since 2.1.0
+ * @uses HEADER_TEXTCOLOR
+ *
+ * @return string
+ */
function get_header_textcolor() {
return get_theme_mod('header_textcolor', HEADER_TEXTCOLOR);
}
+/**
+ * Display text color for custom header.
+ *
+ * @since 2.1.0
+ */
function header_textcolor() {
echo get_header_textcolor();
}
+/**
+ * Retrieve header image for custom header.
+ *
+ * @since 2.1.0
+ * @uses HEADER_IMAGE
+ *
+ * @return string
+ */
function get_header_image() {
return get_theme_mod('header_image', HEADER_IMAGE);
}
+/**
+ * Display header image path.
+ *
+ * @since 2.1.0
+ */
function header_image() {
echo get_header_image();
}
+/**
+ * Add callbacks for image header display.
+ *
+ * The parameter $header_callback callback will be required to display the
+ * content for the 'wp_head' action. The parameter $admin_header_callback
+ * callback will be added to Custom_Image_Header class and that will be added
+ * to the 'admin_menu' action.
+ *
+ * @since 2.1.0
+ * @uses Custom_Image_Header Sets up for $admin_header_callback for administration panel display.
+ *
+ * @param callback $header_callback Call on 'wp_head' action.
+ * @param callback $admin_header_callback Call on administration panels.
+ */
function add_custom_image_header($header_callback, $admin_header_callback) {
if ( ! empty($header_callback) )
add_action('wp_head', $header_callback);
<?php
/**
- * A simple set of functions to check our version 1.0 update service
+ * A simple set of functions to check our version 1.0 update service.
*
* @package WordPress
- * @since 2.3
+ * @since 2.3.0
*/
/**
- * wp_version_check() - Check WordPress version against the newest version.
+ * Check WordPress version against the newest version.
*
- * The WordPress version, PHP version, and Locale is sent. Checks against the WordPress server at
- * api.wordpress.org. Will only check if PHP has fsockopen enabled and WordPress isn't installing.
+ * The WordPress version, PHP version, and Locale is sent. Checks against the
+ * WordPress server at api.wordpress.org server. Will only check if WordPress
+ * isn't installing.
*
* @package WordPress
- * @since 2.3
+ * @since 2.3.0
* @uses $wp_version Used to check against the newest WordPress version.
*
* @return mixed Returns null if update is unsupported. Returns false if check is too soon.
*/
function wp_version_check() {
- if ( !function_exists('fsockopen') || defined('WP_INSTALLING') )
+ if ( defined('WP_INSTALLING') )
return;
- global $wp_version;
+ global $wp_version, $wpdb, $wp_local_package;
$php_version = phpversion();
$current = get_option( 'update_core' );
- $locale = get_locale();
+ if ( ! is_object($current) )
+ $current = new stdClass;
+ $locale = get_locale();
if (
isset( $current->last_checked ) &&
43200 > ( time() - $current->last_checked ) &&
)
return false;
- $new_option = '';
- $new_option->last_checked = time(); // this gets set whether we get a response or not, so if something is down or misconfigured it won't delay the page load for more than 3 seconds, twice a day
- $new_option->version_checked = $wp_version;
+ // Update last_checked for current to prevent multiple blocking requests if request hangs
+ $current->last_checked = time();
+ update_option( 'update_core', $current );
- $http_request = "GET /core/version-check/1.1/?version=$wp_version&php=$php_version&locale=$locale HTTP/1.0\r\n";
- $http_request .= "Host: api.wordpress.org\r\n";
- $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
- $http_request .= 'User-Agent: WordPress/' . $wp_version . '; ' . get_bloginfo('url') . "\r\n";
- $http_request .= "\r\n";
+ if ( method_exists( $wpdb, 'db_version' ) )
+ $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version($wpdb->users));
+ else
+ $mysql_version = 'N/A';
+ $local_package = isset( $wp_local_package )? $wp_local_package : '';
+ $url = "http://api.wordpress.org/core/version-check/1.3/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package";
- $response = '';
- if ( false !== ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3 ) ) && is_resource($fs) ) {
- fwrite( $fs, $http_request );
- while ( !feof( $fs ) )
- $response .= fgets( $fs, 1160 ); // One TCP-IP packet
- fclose( $fs );
+ $options = array('timeout' => 3);
+ $options['headers'] = array(
+ 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'),
+ 'User-Agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')
+ );
- $response = explode("\r\n\r\n", $response, 2);
- if ( !preg_match( '|HTTP/.*? 200|', $response[0] ) )
- return false;
+ $response = wp_remote_request($url, $options);
- $body = trim( $response[1] );
- $body = str_replace(array("\r\n", "\r"), "\n", $body);
+ if ( is_wp_error( $response ) )
+ return false;
- $returns = explode("\n", $body);
+ if ( 200 != $response['response']['code'] )
+ return false;
+ $body = trim( $response['body'] );
+ $body = str_replace(array("\r\n", "\r"), "\n", $body);
+ $new_options = array();
+ foreach( explode( "\n\n", $body ) as $entry) {
+ $returns = explode("\n", $entry);
+ $new_option = new stdClass();
$new_option->response = attribute_escape( $returns[0] );
if ( isset( $returns[1] ) )
$new_option->url = clean_url( $returns[1] );
if ( isset( $returns[2] ) )
- $new_option->current = attribute_escape( $returns[2] );
+ $new_option->package = clean_url( $returns[2] );
+ if ( isset( $returns[3] ) )
+ $new_option->current = attribute_escape( $returns[3] );
+ if ( isset( $returns[4] ) )
+ $new_option->locale = attribute_escape( $returns[4] );
+ $new_options[] = $new_option;
}
- update_option( 'update_core', $new_option );
+
+ $updates = new stdClass();
+ $updates->updates = $new_options;
+ $updates->last_checked = time();
+ $updates->version_checked = $wp_version;
+ update_option( 'update_core', $updates);
}
add_action( 'init', 'wp_version_check' );
/**
- * wp_update_plugins() - Check plugin versions against the latest versions hosted on WordPress.org.
+ * Check plugin versions against the latest versions hosted on WordPress.org.
*
- * The WordPress version, PHP version, and Locale is sent along with a list of all plugins installed.
- * Checks against the WordPress server at api.wordpress.org.
- * Will only check if PHP has fsockopen enabled and WordPress isn't installing.
+ * The WordPress version, PHP version, and Locale is sent along with a list of
+ * all plugins installed. Checks against the WordPress server at
+ * api.wordpress.org. Will only check if WordPress isn't installing.
*
* @package WordPress
- * @since 2.3
+ * @since 2.3.0
* @uses $wp_version Used to notidy the WordPress version.
*
* @return mixed Returns null if update is unsupported. Returns false if check is too soon.
function wp_update_plugins() {
global $wp_version;
- if ( !function_exists('fsockopen') || defined('WP_INSTALLING') )
+ if ( defined('WP_INSTALLING') )
return false;
// If running blog-side, bail unless we've not checked in the last 12 hours
$plugins = get_plugins();
$active = get_option( 'active_plugins' );
$current = get_option( 'update_plugins' );
+ if ( ! is_object($current) )
+ $current = new stdClass;
$new_option = '';
$new_option->last_checked = time();
$plugin_changed = true;
}
- foreach ( (array) $current->response as $plugin_file => $update_details ) {
- if ( ! isset($plugins[ $plugin_file ]) ) {
- $plugin_changed = true;
+ if ( isset ( $current->response ) && is_array( $current->response ) ) {
+ foreach ( $current->response as $plugin_file => $update_details ) {
+ if ( ! isset($plugins[ $plugin_file ]) ) {
+ $plugin_changed = true;
+ }
}
}
if ( $time_not_changed && !$plugin_changed )
return false;
+ // Update last_checked for current to prevent multiple blocking requests if request hangs
+ $current->last_checked = time();
+ update_option( 'update_plugins', $current );
+
$to_send->plugins = $plugins;
$to_send->active = $active;
$send = serialize( $to_send );
+ $body = 'plugins=' . urlencode( $send );
+
+ $options = array('method' => 'POST', 'timeout' => 3, 'body' => $body);
+ $options['headers'] = array(
+ 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'),
+ 'Content-Length' => strlen($body),
+ 'User-Agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')
+ );
+
+ $raw_response = wp_remote_request('http://api.wordpress.org/plugins/update-check/1.0/', $options);
+
+ if ( is_wp_error( $raw_response ) )
+ return false;
- $request = 'plugins=' . urlencode( $send );
- $http_request = "POST /plugins/update-check/1.0/ HTTP/1.0\r\n";
- $http_request .= "Host: api.wordpress.org\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 . '; ' . get_bloginfo('url') . "\r\n";
- $http_request .= "\r\n";
- $http_request .= $request;
-
- $response = '';
- if( false != ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3) ) && is_resource($fs) ) {
- 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);
+ if( 200 != $raw_response['response']['code'] ) {
+ return false;
}
- $response = unserialize( $response[1] );
+ $response = unserialize( $raw_response['body'] );
- if ( $response )
+ if ( false !== $response )
$new_option->response = $response;
+ else
+ $new_option->response = array();
update_option( 'update_plugins', $new_option );
}
+/**
+ * Check theme versions against the latest versions hosted on WordPress.org.
+ *
+ * A list of all themes installed in sent to WP. Checks against the
+ * WordPress server at api.wordpress.org. Will only check if WordPress isn't
+ * installing.
+ *
+ * @package WordPress
+ * @since 2.7.0
+ * @uses $wp_version Used to notidy the WordPress version.
+ *
+ * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
+ */
+function wp_update_themes( ) {
+ global $wp_version;
+
+ if( defined( 'WP_INSTALLING' ) )
+ return false;
+
+ if( !function_exists( 'get_themes' ) )
+ require_once( ABSPATH . 'wp-includes/theme.php' );
+
+ $installed_themes = get_themes( );
+ $current_theme = get_option( 'update_themes' );
+ if ( ! is_object($current_theme) )
+ $current_theme = new stdClass;
+
+ $new_option = '';
+ $new_option->last_checked = time( );
+ $time_not_changed = isset( $current_theme->last_checked ) && 43200 > ( time( ) - $current_theme->last_checked );
+
+ if( $time_not_changed )
+ return false;
+
+ // Update last_checked for current to prevent multiple blocking requests if request hangs
+ $current_theme->last_checked = time();
+ update_option( 'update_themes', $current_theme );
+
+ $themes = array( );
+ $themes['current_theme'] = $current_theme;
+ foreach( (array) $installed_themes as $theme_title => $theme ) {
+ $themes[$theme['Template']] = array( );
+
+ foreach( (array) $theme as $key => $value ) {
+ $themes[$theme['Template']][$key] = $value;
+ }
+ }
+
+ $options = array(
+ 'method' => 'POST',
+ 'timeout' => 3,
+ 'body' => 'themes=' . urlencode( serialize( $themes ) )
+ );
+ $options['headers'] = array(
+ 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ),
+ 'Content-Length' => strlen( $options['body'] ),
+ 'User-Agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
+ );
+
+ $raw_response = wp_remote_request( 'http://api.wordpress.org/themes/update-check/1.0/', $options );
+
+ if( is_wp_error( $raw_response ) )
+ return false;
+
+ if( 200 != $raw_response['response']['code'] )
+ return false;
+
+ $response = unserialize( $raw_response['body'] );
+ if( $response )
+ $new_option->response = $response;
+
+ update_option( 'update_themes', $new_option );
+}
+
+/**
+ * Check the last time plugins were run before checking plugin versions.
+ *
+ * This might have been backported to WordPress 2.6.1 for performance reasons.
+ * This is used for the wp-admin to check only so often instead of every page
+ * load.
+ *
+ * @since 2.7.0
+ * @access private
+ */
function _maybe_update_plugins() {
$current = get_option( 'update_plugins' );
if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) )
wp_update_plugins();
}
+/**
+ * Check themes versions only after a duration of time.
+ *
+ * This is for performance reasons to make sure that on the theme version
+ * checker is not run on every page load.
+ *
+ * @since 2.7.0
+ * @access private
+ */
+function _maybe_update_themes( ) {
+ $current = get_option( 'update_themes' );
+ if( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) )
+ return;
+
+ wp_update_themes( );
+}
+
add_action( 'load-plugins.php', 'wp_update_plugins' );
+add_action( 'load-update.php', 'wp_update_plugins' );
add_action( 'admin_init', '_maybe_update_plugins' );
add_action( 'wp_update_plugins', 'wp_update_plugins' );
-if ( !wp_next_scheduled('wp_update_plugins') )
+add_action( 'admin_init', '_maybe_update_themes' );
+add_action( 'wp_update_themes', 'wp_update_themes' );
+
+if ( !wp_next_scheduled('wp_update_plugins') && !defined('WP_INSTALLING') )
wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins');
+
+if ( !wp_next_scheduled('wp_update_themes') && !defined('WP_INSTALLING') )
+ wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
+
?>
<?php
-
+/**
+ * WordPress User API
+ *
+ * @package WordPress
+ */
+
+/**
+ * Authenticate user with remember capability.
+ *
+ * The credentials is an array that has 'user_login', 'user_password', and
+ * 'remember' indices. If the credentials is not given, then the log in form
+ * will be assumed and used if set.
+ *
+ * The various authentication cookies will be set by this function and will be
+ * set for a longer period depending on if the 'remember' credential is set to
+ * true.
+ *
+ * @since 2.5.0
+ *
+ * @param array $credentials Optional. User info in order to sign on.
+ * @param bool $secure_cookie Optional. Whether to use secure cookie.
+ * @return object Either WP_Error on failure, or WP_User on success.
+ */
function wp_signon( $credentials = '', $secure_cookie = '' ) {
if ( empty($credentials) ) {
if ( ! empty($_POST['log']) )
if ( '' === $secure_cookie )
$secure_cookie = is_ssl() ? true : false;
-
+
// If no credential info provided, check cookie.
if ( empty($credentials['user_login']) && empty($credentials['user_password']) ) {
- $user = wp_validate_auth_cookie();
- if ( $user )
- return new WP_User($user);
+ $user = wp_validate_auth_cookie();
+ if ( $user )
+ return new WP_User($user);
- if ( $secure_cookie )
- $auth_cookie = SECURE_AUTH_COOKIE;
- else
- $auth_cookie = AUTH_COOKIE;
+ if ( $secure_cookie )
+ $auth_cookie = SECURE_AUTH_COOKIE;
+ else
+ $auth_cookie = AUTH_COOKIE;
- if ( !empty($_COOKIE[$auth_cookie]) )
- return new WP_Error('expired_session', __('Please log in again.'));
+ if ( !empty($_COOKIE[$auth_cookie]) )
+ return new WP_Error('expired_session', __('Please log in again.'));
- // If the cookie is not set, be silent.
- return new WP_Error();
+ // If the cookie is not set, be silent.
+ return new WP_Error();
}
if ( empty($credentials['user_login']) || empty($credentials['user_password']) ) {
return $user;
}
+/**
+ * Retrieve user data based on field.
+ *
+ * Use get_profile() will make a database query to get the value of the table
+ * column. The value might be cached using the query cache, but care should be
+ * taken when using the function to not make a lot of queries for retrieving
+ * user profile information.
+ *
+ * If the $user parameter is not used, then the user will be retrieved from a
+ * cookie of the user. Therefore, if the cookie does not exist, then no value
+ * might be returned. Sanity checking must be done to ensure that when using
+ * get_profile() that empty/null/false values are handled and that something is
+ * at least displayed.
+ *
+ * @since 1.5.0
+ * @uses $wpdb WordPress database object to create queries.
+ *
+ * @param string $field User field to retrieve.
+ * @param string $user Optional. User username.
+ * @return string The value in the field.
+ */
function get_profile($field, $user = false) {
global $wpdb;
if ( !$user )
return $wpdb->get_var( $wpdb->prepare("SELECT $field FROM $wpdb->users WHERE user_login = %s", $user) );
}
+/**
+ * Number of posts user has written.
+ *
+ * @since 0.71
+ * @uses $wpdb WordPress database object for queries.
+ *
+ * @param int $userid User ID.
+ * @return int Amount of posts user has written.
+ */
function get_usernumposts($userid) {
global $wpdb;
$userid = (int) $userid;
- return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = %d AND post_type = 'post' AND ", $userid) . get_private_posts_cap_sql('post'));
+ $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = %d AND post_type = 'post' AND ", $userid) . get_private_posts_cap_sql('post'));
+ return apply_filters('get_usernumposts', $count, $userid);
}
-// TODO: xmlrpc only. Maybe move to xmlrpc.php.
-function user_pass_ok($user_login,$user_pass) {
+/**
+ * Check that the user login name and password is correct.
+ *
+ * @since 0.71
+ * @todo xmlrpc only. Maybe move to xmlrpc.php.
+ *
+ * @param string $user_login User name.
+ * @param string $user_pass User password.
+ * @return bool False if does not authenticate, true if username and password authenticates.
+ */
+function user_pass_ok($user_login, $user_pass) {
$user = wp_authenticate($user_login, $user_pass);
if ( is_wp_error($user) )
return false;
// User option functions
//
-function get_user_option( $option, $user = 0 ) {
+/**
+ * Retrieve user option that can be either global, user, or blog.
+ *
+ * If the user ID is not given, then the current user will be used instead. If
+ * the user ID is given, then the user data will be retrieved. The filter for
+ * the result, will also pass the original option name and finally the user data
+ * object as the third parameter.
+ *
+ * The option will first check for the non-global name, then the global name,
+ * and if it still doesn't find it, it will try the blog option. The option can
+ * either be modified or set by a plugin.
+ *
+ * @since 2.0.0
+ * @uses $wpdb WordPress database object for queries.
+ * @uses apply_filters() Calls 'get_user_option_$option' hook with result,
+ * option parameter, and user data object.
+ *
+ * @param string $option User option name.
+ * @param int $user Optional. User ID.
+ * @param bool $check_blog_options Whether to check for an option in the options table if a per-user option does not exist. Default is true.
+ * @return mixed
+ */
+function get_user_option( $option, $user = 0, $check_blog_options = true ) {
global $wpdb;
$option = preg_replace('|[^a-z0-9_]|i', '', $option);
$result = $user->{$wpdb->prefix . $option};
elseif ( isset( $user->{$option} ) ) // User specific and cross-blog
$result = $user->{$option};
- else // Blog global
+ elseif ( $check_blog_options ) // Blog global
$result = get_option( $option );
-
+ else
+ $result = false;
+
return apply_filters("get_user_option_{$option}", $result, $option, $user);
}
+/**
+ * Update user option with global blog capability.
+ *
+ * User options are just like user metadata except that they have support for
+ * global blog options. If the 'global' parameter is false, which it is by false
+ * it will prepend the WordPress table prefix to the option name.
+ *
+ * @since 2.0.0
+ * @uses $wpdb WordPress database object for queries
+ *
+ * @param int $user_id User ID
+ * @param string $option_name User option name.
+ * @param mixed $newvalue User option value.
+ * @param bool $global Optional. Whether option name is blog specific or not.
+ * @return unknown
+ */
function update_user_option( $user_id, $option_name, $newvalue, $global = false ) {
global $wpdb;
if ( !$global )
return update_usermeta( $user_id, $option_name, $newvalue );
}
-// Get users with capabilities for the current blog.
-// For setups that use the multi-blog feature.
+/**
+ * Get users for the blog.
+ *
+ * For setups that use the multi-blog feature. Can be used outside of the
+ * multi-blog feature.
+ *
+ * @since 2.2.0
+ * @uses $wpdb WordPress database object for queries
+ * @uses $blog_id The Blog id of the blog for those that use more than one blog
+ *
+ * @param int $id Blog ID.
+ * @return array List of users that are part of that Blog ID
+ */
function get_users_of_blog( $id = '' ) {
global $wpdb, $blog_id;
if ( empty($id) )
// User meta functions
//
+/**
+ * Remove user meta data.
+ *
+ * @since 2.0.0
+ * @uses $wpdb WordPress database object for queries.
+ *
+ * @param int $user_id User ID.
+ * @param string $meta_key Metadata key.
+ * @param mixed $meta_value Metadata value.
+ * @return bool True deletion completed and false if user_id is not a number.
+ */
function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) {
global $wpdb;
if ( !is_numeric( $user_id ) )
$meta_value = trim( $meta_value );
if ( ! empty($meta_value) )
- $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $userid, $meta_key, $meta_value) );
+ $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) );
else
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
return true;
}
+/**
+ * Retrieve user metadata.
+ *
+ * If $user_id is not a number, then the function will fail over with a 'false'
+ * boolean return value. Other returned values depend on whether there is only
+ * one item to be returned, which be that single item type. If there is more
+ * than one metadata value, then it will be list of metadata values.
+ *
+ * @since 2.0.0
+ * @uses $wpdb WordPress database object for queries.
+ *
+ * @param int $user_id User ID
+ * @param string $meta_key Optional. Metadata key.
+ * @return mixed
+ */
function get_usermeta( $user_id, $meta_key = '') {
global $wpdb;
$user_id = (int) $user_id;
return $metas;
}
+/**
+ * Update metadata of user.
+ *
+ * There is no need to serialize values, they will be serialized if it is
+ * needed. The metadata key can only be a string with underscores. All else will
+ * be removed.
+ *
+ * Will remove the metadata, if the meta value is empty.
+ *
+ * @since 2.0.0
+ * @uses $wpdb WordPress database object for queries
+ *
+ * @param int $user_id User ID
+ * @param string $meta_key Metadata key.
+ * @param mixed $meta_value Metadata value.
+ * @return bool True on successful update, false on failure.
+ */
function update_usermeta( $user_id, $meta_key, $meta_value ) {
global $wpdb;
if ( !is_numeric( $user_id ) )
return false;
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
- // FIXME: usermeta data is assumed to be already escaped
+ /** @todo Might need fix because usermeta data is assumed to be already escaped */
if ( is_string($meta_value) )
$meta_value = stripslashes($meta_value);
$meta_value = maybe_serialize($meta_value);
// Private helper functions
//
-// Setup global user vars. Used by set_current_user() for back compat.
+/**
+ * Setup global user vars.
+ *
+ * Used by set_current_user() for back compat. Might be deprecated in the
+ * future.
+ *
+ * @since 2.0.4
+ * @global string $userdata User description.
+ * @global string $user_login The user username for logging in
+ * @global int $user_level The level of the user
+ * @global int $user_ID The ID of the user
+ * @global string $user_email The email address of the user
+ * @global string $user_url The url in the user's profile
+ * @global string $user_pass_md5 MD5 of the user's password
+ * @global string $user_identity The display name of the user
+ *
+ * @param int $user_id Optional. User ID to setup global data.
+ */
function setup_userdata($user_id = '') {
global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity;
$user_identity = $user->display_name;
}
+/**
+ * Create dropdown HTML content of users.
+ *
+ * The content can either be displayed, which it is by default or retrieved by
+ * setting the 'echo' argument. The 'include' and 'exclude' arguments do not
+ * need to be used; all users will be displayed in that case. Only one can be
+ * used, either 'include' or 'exclude', but not both.
+ *
+ * The available arguments are as follows:
+ * <ol>
+ * <li>show_option_all - Text to show all and whether HTML option exists.</li>
+ * <li>show_option_none - Text for show none and whether HTML option exists.
+ * </li>
+ * <li>orderby - SQL order by clause for what order the users appear. Default is
+ * 'display_name'.</li>
+ * <li>order - Default is 'ASC'. Can also be 'DESC'.</li>
+ * <li>include - User IDs to include.</li>
+ * <li>exclude - User IDs to exclude.</li>
+ * <li>multi - Default is 'false'. Whether to skip the ID attribute on the 'select' element.</li>
+ * <li>show - Default is 'display_name'. User table column to display. If the selected item is empty then the user_login will be displayed in parentesis</li>
+ * <li>echo - Default is '1'. Whether to display or retrieve content.</li>
+ * <li>selected - Which User ID is selected.</li>
+ * <li>name - Default is 'user'. Name attribute of select element.</li>
+ * <li>class - Class attribute of select element.</li>
+ * </ol>
+ *
+ * @since 2.3.0
+ * @uses $wpdb WordPress database object for queries
+ *
+ * @param string|array $args Optional. Override defaults.
+ * @return string|null Null on display. String of HTML content on retrieve.
+ */
function wp_dropdown_users( $args = '' ) {
global $wpdb;
$defaults = array(
'show_option_all' => '', 'show_option_none' => '',
'orderby' => 'display_name', 'order' => 'ASC',
- 'include' => '', 'exclude' => '',
+ 'include' => '', 'exclude' => '', 'multi' => 0,
'show' => 'display_name', 'echo' => 1,
'selected' => 0, 'name' => 'user', 'class' => ''
);
$output = '';
if ( !empty($users) ) {
- $output = "<select name='$name' id='$name' class='$class'>\n";
+ $id = $multi ? "" : "id='$name'";
+
+ $output = "<select name='$name' $id class='$class'>\n";
if ( $show_option_all )
$output .= "\t<option value='0'>$show_option_all</option>\n";
if ( $show_option_none )
$output .= "\t<option value='-1'>$show_option_none</option>\n";
- foreach ( $users as $user ) {
+ foreach ( (array) $users as $user ) {
$user->ID = (int) $user->ID;
$_selected = $user->ID == $selected ? " selected='selected'" : '';
- $output .= "\t<option value='$user->ID'$_selected>" . wp_specialchars($user->$show) . "</option>\n";
+ $display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
+ $output .= "\t<option value='$user->ID'$_selected>" . wp_specialchars($display) . "</option>\n";
}
$output .= "</select>";
return $output;
}
+/**
+ * Add user meta data as properties to given user object.
+ *
+ * The finished user data is cached, but the cache is not used to fill in the
+ * user data for the given object. Once the function has been used, the cache
+ * should be used to retrieve user data. The purpose seems then to be to ensure
+ * that the data in the object is always fresh.
+ *
+ * @access private
+ * @since 2.5.0
+ * @uses $wpdb WordPress database object for queries
+ *
+ * @param object $user The user data object.
+ */
function _fill_user( &$user ) {
global $wpdb;
$wpdb->show_errors($show);
if ( $metavalues ) {
- foreach ( $metavalues as $meta ) {
+ foreach ( (array) $metavalues as $meta ) {
$value = maybe_unserialize($meta->meta_value);
$user->{$meta->meta_key} = $value;
}
}
// Simple browser detection
-$is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = false;
+$is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false;
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false) {
$is_lynx = true;
-} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') !== false ) {
+} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chrome') !== false ) {
+ $is_chrome = true;
+} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false ) {
$is_safari = true;
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false) {
$is_gecko = true;
$is_NS4 = true;
}
+if ( $is_safari && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile') !== false )
+ $is_iphone = true;
+
$is_IE = ( $is_macIE || $is_winIE );
// Server detection
*/
$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false;
-?>
+?>
\ No newline at end of file
*
* @global string $wp_version
*/
-$wp_version = '2.6.2';
+$wp_version = '2.7.1';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
*
* @global int $wp_db_version
*/
-$wp_db_version = 8204;
+$wp_db_version = 9872;
?>
<?php
+/**
+ * API for creating dynamic sidebar without hardcoding functionality into
+ * themes. Includes both internal WordPress routines and theme use routines.
+ *
+ * This functionality was found in a plugin before WordPress 2.2 release which
+ * included it in the core from that point on.
+ *
+ * @link http://codex.wordpress.org/Plugins/WordPress_Widgets WordPress Widgets
+ * @link http://codex.wordpress.org/Plugins/WordPress_Widgets_Api Widgets API
+ *
+ * @package WordPress
+ * @subpackage Widgets
+ */
/* Global Variables */
+/** @ignore */
global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls;
+/**
+ * Stores the sidebars, since many themes can have more than one.
+ *
+ * @global array $wp_registered_sidebars
+ * @since 2.2.0
+ */
$wp_registered_sidebars = array();
+
+/**
+ * Stores the registered widgets.
+ *
+ * @global array $wp_registered_widgets
+ * @since 2.2.0
+ */
$wp_registered_widgets = array();
+
+/**
+ * Stores the registered widget control (options).
+ *
+ * @global array $wp_registered_widget_controls
+ * @since 2.2.0
+ */
$wp_registered_widget_controls = array();
/* Template tags & API functions */
+/**
+ * Creates multiple sidebars.
+ *
+ * If you wanted to quickly create multiple sidebars for a theme or internally.
+ * This function will allow you to do so. If you don't pass the 'name' and/or
+ * 'id' in $args, then they will be built for you.
+ *
+ * The default for the name is "Sidebar #", with '#' being replaced with the
+ * number the sidebar is currently when greater than one. If first sidebar, the
+ * name will be just "Sidebar". The default for id is "sidebar-" followed by the
+ * number the sidebar creation is currently at.
+ *
+ * @since 2.2.0
+ *
+ * @see register_sidebar() The second parameter is documented by register_sidebar() and is the same here.
+ * @uses parse_str() Converts a string to an array to be used in the rest of the function.
+ * @uses register_sidebar() Sends single sidebar information [name, id] to this
+ * function to handle building the sidebar.
+ *
+ * @param int $number Number of sidebars to create.
+ * @param string|array $args Builds Sidebar based off of 'name' and 'id' values.
+ */
function register_sidebars($number = 1, $args = array()) {
global $wp_registered_sidebars;
$number = (int) $number;
}
}
+/**
+ * Builds the definition for a single sidebar and returns the ID.
+ *
+ * The $args parameter takes either a string or an array with 'name' and 'id'
+ * contained in either usage. It will be noted that the values will be applied
+ * to all sidebars, so if creating more than one, it will be advised to allow
+ * for WordPress to create the defaults for you.
+ *
+ * Example for string would be <code>'name=whatever;id=whatever1'</code> and for
+ * the array it would be <code>array(
+ * 'name' => 'whatever',
+ * 'id' => 'whatever1')</code>.
+ *
+ * name - The name of the sidebar, which presumably the title which will be
+ * displayed.
+ * id - The unique identifier by which the sidebar will be called by.
+ * before_widget - The content that will prepended to the widgets when they are
+ * displayed.
+ * after_widget - The content that will be appended to the widgets when they are
+ * displayed.
+ * before_title - The content that will be prepended to the title when displayed.
+ * after_title - the content that will be appended to the title when displayed.
+ *
+ * <em>Content</em> is assumed to be HTML and should be formatted as such, but
+ * doesn't have to be.
+ *
+ * @since 2.2.0
+ * @uses $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
+ * @uses parse_str() Converts a string to an array to be used in the rest of the function.
+ * @usedby register_sidebars()
+ *
+ * @param string|array $args Builds Sidebar based off of 'name' and 'id' values
+ * @return string The sidebar id that was added.
+ */
function register_sidebar($args = array()) {
global $wp_registered_sidebars;
return $sidebar['id'];
}
+/**
+ * Removes a sidebar from the list.
+ *
+ * @since 2.2.0
+ *
+ * @uses $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
+ *
+ * @param string $name The ID of the sidebar when it was added.
+ */
function unregister_sidebar( $name ) {
global $wp_registered_sidebars;
unset( $wp_registered_sidebars[$name] );
}
+/**
+ * Register widget for sidebar with backwards compatibility.
+ *
+ * Allows $name to be an array that accepts either three elements to grab the
+ * first element and the third for the name or just uses the first element of
+ * the array for the name.
+ *
+ * Passes to {@link wp_register_sidebar_widget()} after argument list and
+ * backwards compatibility is complete.
+ *
+ * @since 2.2.0
+ * @uses wp_register_sidebar_widget() Passes the compiled arguments.
+ *
+ * @param string|int $name Widget ID.
+ * @param callback $output_callback Run when widget is called.
+ * @param string $classname Classname widget option.
+ * @param mixed $params,... Widget parameters.
+ */
function register_sidebar_widget($name, $output_callback, $classname = '') {
// Compat
if ( is_array($name) ) {
call_user_func_array('wp_register_sidebar_widget', $args);
}
+/**
+ * Register widget for use in sidebars.
+ *
+ * The default widget option is 'classname' that can be override.
+ *
+ * The function can also be used to unregister widgets when $output_callback
+ * parameter is an empty string.
+ *
+ * @since 2.2.0
+ *
+ * @uses $wp_registered_widgets Uses stored registered widgets.
+ * @uses $wp_register_widget_defaults Retrieves widget defaults.
+ *
+ * @param int|string $id Widget ID.
+ * @param string $name Widget display title.
+ * @param callback $output_callback Run when widget is called.
+ * @param array|string Optional. $options Widget Options.
+ * @param mixed $params,... Widget parameters to add to widget.
+ * @return null Will return if $output_callback is empty after removing widget.
+ */
function wp_register_sidebar_widget($id, $name, $output_callback, $options = array()) {
global $wp_registered_widgets;
$wp_registered_widgets[$id] = $widget;
}
+/**
+ * Retrieve description for widget.
+ *
+ * When registering widgets, the options can also include 'description' that
+ * describes the widget for display on the widget administration panel or
+ * in the theme.
+ *
+ * @since 2.5.0
+ *
+ * @param int|string $id Widget ID.
+ * @return string Widget description, if available. Null on failure to retrieve description.
+ */
function wp_widget_description( $id ) {
if ( !is_scalar($id) )
return;
return wp_specialchars( $wp_registered_widgets[$id]['description'] );
}
+/**
+ * Alias of {@link wp_unregister_sidebar_widget()}.
+ *
+ * @see wp_unregister_sidebar_widget()
+ *
+ * @since 2.2.0
+ *
+ * @param int|string $id Widget ID.
+ */
function unregister_sidebar_widget($id) {
return wp_unregister_sidebar_widget($id);
}
+/**
+ * Remove widget from sidebar.
+ *
+ * @since 2.2.0
+ *
+ * @param int|string $id Widget ID.
+ */
function wp_unregister_sidebar_widget($id) {
wp_register_sidebar_widget($id, '', '');
wp_unregister_widget_control($id);
}
+/**
+ * Registers widget control callback for customizing options.
+ *
+ * Allows $name to be an array that accepts either three elements to grab the
+ * first element and the third for the name or just uses the first element of
+ * the array for the name.
+ *
+ * Passes to {@link wp_register_widget_control()} after the argument list has
+ * been compiled.
+ *
+ * @since 2.2.0
+ *
+ * @param int|string $name Sidebar ID.
+ * @param callback $control_callback Widget control callback to display and process form.
+ * @param int $width Widget width.
+ * @param int $height Widget height.
+ */
function register_widget_control($name, $control_callback, $width = '', $height = '') {
// Compat
if ( is_array($name) ) {
call_user_func_array('wp_register_widget_control', $args);
}
-/* $options: height, width, id_base
- * height: never used
- * width: width of fully expanded control form. Try hard to use the default width.
- * id_base: for multi-widgets (widgets which allow multiple instances such as the text widget), an id_base must be provided.
- * the widget id will ennd up looking like {$id_base}-{$unique_number}
+/**
+ * Registers widget control callback for customizing options.
+ *
+ * The options contains the 'height', 'width', and 'id_base' keys. The 'height'
+ * option is never used. The 'width' option is the width of the fully expanded
+ * control form, but try hard to use the default width. The 'id_base' is for
+ * multi-widgets (widgets which allow multiple instances such as the text
+ * widget), an id_base must be provided. The widget id will end up looking like
+ * {$id_base}-{$unique_number}.
+ *
+ * @since 2.2.0
+ *
+ * @param int|string $id Sidebar ID.
+ * @param string $name Sidebar display name.
+ * @param callback $control_callback Run when sidebar is displayed.
+ * @param array|string $options Optional. Widget options. See above long description.
+ * @param mixed $params,... Optional. Additional parameters to add to widget.
*/
function wp_register_widget_control($id, $name, $control_callback, $options = array()) {
global $wp_registered_widget_controls;
-
+
$id = strtolower($id);
if ( empty($control_callback) ) {
$wp_registered_widget_controls[$id] = $widget;
}
+/**
+ * Alias of {@link wp_unregister_widget_control()}.
+ *
+ * @since 2.2.0
+ * @see wp_unregister_widget_control()
+ *
+ * @param int|string $id Widget ID.
+ */
function unregister_widget_control($id) {
return wp_unregister_widget_control($id);
}
+/**
+ * Remove control callback for widget.
+ *
+ * @since 2.2.0
+ * @uses wp_register_widget_control() Unregisters by using empty callback.
+ *
+ * @param int|string $id Widget ID.
+ */
function wp_unregister_widget_control($id) {
return wp_register_widget_control($id, '', '');
}
+/**
+ * Display dynamic sidebar.
+ *
+ * By default it displays the default sidebar or 'sidebar-1'. The 'sidebar-1' is
+ * not named by the theme, the actual name is '1', but 'sidebar-' is added to
+ * the registered sidebars for the name. If you named your sidebar 'after-post',
+ * then the parameter $index will still be 'after-post', but the lookup will be
+ * for 'sidebar-after-post'.
+ *
+ * It is confusing for the $index parameter, but just know that it should just
+ * work. When you register the sidebar in the theme, you will use the same name
+ * for this function or "Pay no heed to the man behind the curtain." Just accept
+ * it as an oddity of WordPress sidebar register and display.
+ *
+ * @since 2.2.0
+ *
+ * @param int|string $index Optional, default is 1. Name or ID of dynamic sidebar.
+ * @return bool True, if widget sidebar was found and called. False if not found or not called.
+ */
function dynamic_sidebar($index = 1) {
global $wp_registered_sidebars, $wp_registered_widgets;
$index = "sidebar-$index";
} else {
$index = sanitize_title($index);
- foreach ( $wp_registered_sidebars as $key => $value ) {
+ foreach ( (array) $wp_registered_sidebars as $key => $value ) {
if ( sanitize_title($value['name']) == $index ) {
$index = $key;
break;
$sidebar = $wp_registered_sidebars[$index];
$did_one = false;
- foreach ( $sidebars_widgets[$index] as $id ) {
+ foreach ( (array) $sidebars_widgets[$index] as $id ) {
$params = array_merge(
array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ),
(array) $wp_registered_widgets[$id]['params']
return $did_one;
}
-/* @return mixed false if widget is not active or id of sidebar in which the widget is active
+/**
+ * Whether widget is registered using callback with widget ID.
+ *
+ * Will only check if both parameters are used. Used to find which sidebar the
+ * widget is located in, but requires that both the callback and the widget ID
+ * be known.
+ *
+ * @since 2.2.0
+ *
+ * @param callback $callback Widget callback to check.
+ * @param int $widget_id Optional, but needed for checking. Widget ID.
+/* @return mixed false if widget is not active or id of sidebar in which the widget is active.
*/
function is_active_widget($callback, $widget_id = false) {
global $wp_registered_widgets;
return false;
}
+/**
+ * Whether the dynamic sidebar is enabled and used by theme.
+ *
+ * @since 2.2.0
+ *
+ * @return bool True, if using widgets. False, if not using widgets.
+ */
function is_dynamic_sidebar() {
global $wp_registered_widgets, $wp_registered_sidebars;
$sidebars_widgets = get_option('sidebars_widgets');
- foreach ( $wp_registered_sidebars as $index => $sidebar ) {
+ foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) {
if ( count($sidebars_widgets[$index]) ) {
- foreach ( $sidebars_widgets[$index] as $widget )
+ foreach ( (array) $sidebars_widgets[$index] as $widget )
if ( array_key_exists($widget, $wp_registered_widgets) )
return true;
}
/* Internal Functions */
+/**
+ * Retrieve full list of sidebars and their widgets.
+ *
+ * Will upgrade sidebar widget list, if needed. Will also save updated list, if
+ * needed.
+ *
+ * @since 2.2.0
+ * @access private
+ *
+ * @param bool $update Optional, default is true. Whether to save upgrade of widget array list.
+ * @return array Upgraded list of widgets to version 2 array format.
+ */
function wp_get_sidebars_widgets($update = true) {
global $wp_registered_widgets, $wp_registered_sidebars;
- $sidebars_widgets = get_option('sidebars_widgets');
+ $sidebars_widgets = get_option('sidebars_widgets', array());
$_sidebars_widgets = array();
if ( !isset($sidebars_widgets['array_version']) )
switch ( $sidebars_widgets['array_version'] ) {
case 1 :
- foreach ( $sidebars_widgets as $index => $sidebar )
+ foreach ( (array) $sidebars_widgets as $index => $sidebar )
if ( is_array($sidebar) )
- foreach ( $sidebar as $i => $name ) {
+ foreach ( (array) $sidebar as $i => $name ) {
$id = strtolower($name);
if ( isset($wp_registered_widgets[$id]) ) {
$_sidebars_widgets[$index][$i] = $id;
$sidebars = array_keys( $wp_registered_sidebars );
if ( !empty( $sidebars ) ) {
// Move the known-good ones first
- foreach ( $sidebars as $id ) {
+ foreach ( (array) $sidebars as $id ) {
if ( array_key_exists( $id, $sidebars_widgets ) ) {
$_sidebars_widgets[$id] = $sidebars_widgets[$id];
unset($sidebars_widgets[$id], $sidebars[$id]);
update_option('sidebars_widgets', $sidebars_widgets);
}
- unset($sidebars_widgets['array_version']);
+ if ( isset($sidebars_widgets['array_version']) )
+ unset($sidebars_widgets['array_version']);
+ $sidebars_widgets = apply_filters('sidebars_widgets', $sidebars_widgets);
return $sidebars_widgets;
}
+/**
+ * Set the sidebar widget option to update sidebars.
+ *
+ * @since 2.2.0
+ * @access private
+ *
+ * @param array $sidebars_widgets Sidebar widgets and their settings.
+ */
function wp_set_sidebars_widgets( $sidebars_widgets ) {
+ if ( !isset( $sidebars_widgets['array_version'] ) )
+ $sidebars_widgets['array_version'] = 3;
update_option( 'sidebars_widgets', $sidebars_widgets );
}
+/**
+ * Retrieve default registered sidebars list.
+ *
+ * @since 2.2.0
+ * @access private
+ *
+ * @return array
+ */
function wp_get_widget_defaults() {
global $wp_registered_sidebars;
$defaults = array();
- foreach ( $wp_registered_sidebars as $index => $sidebar )
+ foreach ( (array) $wp_registered_sidebars as $index => $sidebar )
$defaults[$index] = array();
return $defaults;
/* Default Widgets */
+/**
+ * Display pages widget.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Widget arguments.
+ */
function wp_widget_pages( $args ) {
extract( $args );
$options = get_option( 'widget_pages' );
}
}
+/**
+ * Display and process pages widget options form.
+ *
+ * @since 2.2.0
+ */
function wp_widget_pages_control() {
$options = $newoptions = get_option('widget_pages');
- if ( $_POST['pages-submit'] ) {
+ if ( isset($_POST['pages-submit']) ) {
$newoptions['title'] = strip_tags(stripslashes($_POST['pages-title']));
$sortby = stripslashes( $_POST['pages-sortby'] );
<?php
}
+/**
+ * Display links widget.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Widget arguments.
+ */
function wp_widget_links($args) {
extract($args, EXTR_SKIP);
)));
}
+/**
+ * Display search widget.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Widget arguments.
+ */
function wp_widget_search($args) {
extract($args);
- $searchform_template = get_template_directory() . '/searchform.php';
-
echo $before_widget;
-
+
// Use current theme search form if it exists
- if ( file_exists($searchform_template) ) {
- include_once($searchform_template);
- } else { ?>
- <form id="searchform" method="get" action="<?php bloginfo('url'); ?>/"><div>
- <label class="hidden" for="s"><?php _e('Search for:'); ?></label>
- <input type="text" name="s" id="s" size="15" value="<?php the_search_query(); ?>" />
- <input type="submit" value="<?php echo attribute_escape(__('Search')); ?>" />
- </div></form>
- <?php }
-
+ get_search_form();
+
echo $after_widget;
}
+/**
+ * Display archives widget.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Widget arguments.
+ */
function wp_widget_archives($args) {
extract($args);
$options = get_option('widget_archives');
echo $after_widget;
}
+/**
+ * Display and process archives widget options form.
+ *
+ * @since 2.2.0
+ */
function wp_widget_archives_control() {
$options = $newoptions = get_option('widget_archives');
- if ( $_POST["archives-submit"] ) {
+ if ( isset($_POST["archives-submit"]) ) {
$newoptions['count'] = isset($_POST['archives-count']);
$newoptions['dropdown'] = isset($_POST['archives-dropdown']);
$newoptions['title'] = strip_tags(stripslashes($_POST["archives-title"]));
<?php
}
+/**
+ * Display meta widget.
+ *
+ * Displays log in/out, RSS feed links, etc.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Widget arguments.
+ */
function wp_widget_meta($args) {
extract($args);
$options = get_option('widget_meta');
<?php echo $after_widget; ?>
<?php
}
+
+/**
+ * Display and process meta widget options form.
+ *
+ * @since 2.2.0
+ */
function wp_widget_meta_control() {
$options = $newoptions = get_option('widget_meta');
- if ( $_POST["meta-submit"] ) {
+ if ( isset($_POST["meta-submit"]) ) {
$newoptions['title'] = strip_tags(stripslashes($_POST["meta-title"]));
}
if ( $options != $newoptions ) {
<?php
}
+/**
+ * Display calendar widget.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Widget arguments.
+ */
function wp_widget_calendar($args) {
extract($args);
$options = get_option('widget_calendar');
echo '</div>';
echo $after_widget;
}
+
+/**
+ * Display and process calendar widget options form.
+ *
+ * @since 2.2.0
+ */
function wp_widget_calendar_control() {
$options = $newoptions = get_option('widget_calendar');
- if ( $_POST["calendar-submit"] ) {
+ if ( isset($_POST["calendar-submit"]) ) {
$newoptions['title'] = strip_tags(stripslashes($_POST["calendar-title"]));
}
if ( $options != $newoptions ) {
<?php
}
-// See large comment section at end of this file
+/**
+ * Display the Text widget, depending on the widget number.
+ *
+ * Supports multiple text widgets and keeps track of the widget number by using
+ * the $widget_args parameter. The option 'widget_text' is used to store the
+ * content for the widgets. The content and title are passed through the
+ * 'widget_text' and 'widget_title' filters respectively.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Widget arguments.
+ * @param int $number Widget number.
+ */
function wp_widget_text($args, $widget_args = 1) {
extract( $args, EXTR_SKIP );
if ( is_numeric($widget_args) )
<?php
}
+/**
+ * Display and process text widget options form.
+ *
+ * @since 2.2.0
+ *
+ * @param int $widget_args Widget number.
+ */
function wp_widget_text_control($widget_args) {
global $wp_registered_widgets;
static $updated = false;
else
$this_sidebar = array();
- foreach ( $this_sidebar as $_widget_id ) {
+ foreach ( (array) $this_sidebar as $_widget_id ) {
if ( 'wp_widget_text' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
if ( !in_array( "text-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed.
<?php
}
+/**
+ * Register text widget on startup.
+ *
+ * @since 2.2.0
+ */
function wp_widget_text_register() {
if ( !$options = get_option('widget_text') )
$options = array();
$name = __('Text');
$id = false;
- foreach ( array_keys($options) as $o ) {
+ foreach ( (array) array_keys($options) as $o ) {
// Old widgets can have null values for some reason
if ( !isset($options[$o]['title']) || !isset($options[$o]['text']) )
continue;
}
}
-// See large comment section at end of this file
+/**
+ * Display categories widget.
+ *
+ * Allows multiple category widgets.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Widget arguments.
+ * @param int $number Widget number.
+ */
function wp_widget_categories($args, $widget_args = 1) {
extract($args, EXTR_SKIP);
if ( is_numeric($widget_args) )
<script type='text/javascript'>
/* <![CDATA[ */
- var dropdown = document.getElementById("cat");
- function onCatChange() {
+ var dropdown = document.getElementById("cat");
+ function onCatChange() {
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
}
- }
- dropdown.onchange = onCatChange;
+ }
+ dropdown.onchange = onCatChange;
/* ]]> */
</script>
} else {
?>
<ul>
- <?php
+ <?php
$cat_args['title_li'] = '';
- wp_list_categories($cat_args);
+ wp_list_categories($cat_args);
?>
</ul>
<?php
echo $after_widget;
}
+/**
+ * Display and process categories widget options form.
+ *
+ * @since 2.2.0
+ *
+ * @param int $widget_args Widget number.
+ */
function wp_widget_categories_control( $widget_args ) {
global $wp_registered_widgets;
static $updated = false;
else
$this_sidebar = array();
- foreach ( $this_sidebar as $_widget_id ) {
+ foreach ( (array) $this_sidebar as $_widget_id ) {
if ( 'wp_widget_categories' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
if ( !in_array( "categories-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed.
<?php
}
+/**
+ * Register categories widget on startup.
+ *
+ * @since 2.3.0
+ */
function wp_widget_categories_register() {
if ( !$options = get_option( 'widget_categories' ) )
$options = array();
$name = __( 'Categories' );
$id = false;
- foreach ( array_keys($options) as $o ) {
+ foreach ( (array) array_keys($options) as $o ) {
// Old widgets can have null values for some reason
if ( !isset($options[$o]['title']) )
continue;
}
}
+/**
+ * Upgrade previous category widget to current version.
+ *
+ * @since 2.3.0
+ *
+ * @return array
+ */
function wp_widget_categories_upgrade() {
$options = get_option( 'widget_categories' );
return $newoptions;
}
+/**
+ * Display recent entries widget.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Widget arguments.
+ * @return int Displayed cache.
+ */
function wp_widget_recent_entries($args) {
if ( '%BEG_OF_TITLE%' != $args['before_title'] ) {
if ( $output = wp_cache_get('widget_recent_entries', 'widget') )
else if ( $number > 15 )
$number = 15;
- $r = new WP_Query(array('showposts' => $number, 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish'));
+ $r = new WP_Query(array('showposts' => $number, 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1));
if ($r->have_posts()) :
?>
<?php echo $before_widget; ?>
wp_cache_add('widget_recent_entries', ob_get_flush(), 'widget');
}
+/**
+ * Remove recent entries widget items cache.
+ *
+ * @since 2.2.0
+ */
function wp_flush_widget_recent_entries() {
wp_cache_delete('widget_recent_entries', 'widget');
}
add_action('deleted_post', 'wp_flush_widget_recent_entries');
add_action('switch_theme', 'wp_flush_widget_recent_entries');
+/**
+ * Display and process recent entries widget options form.
+ *
+ * @since 2.2.0
+ */
function wp_widget_recent_entries_control() {
$options = $newoptions = get_option('widget_recent_entries');
- if ( $_POST["recent-entries-submit"] ) {
+ if ( isset($_POST["recent-entries-submit"]) ) {
$newoptions['title'] = strip_tags(stripslashes($_POST["recent-entries-title"]));
$newoptions['number'] = (int) $_POST["recent-entries-number"];
}
<?php
}
+/**
+ * Display recent comments widget.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Widget arguments.
+ */
function wp_widget_recent_comments($args) {
global $wpdb, $comments, $comment;
extract($args, EXTR_SKIP);
$number = 15;
if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) {
- $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");
+ $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");
wp_cache_add( 'recent_comments', $comments, 'widget' );
}
?>
<?php echo $before_widget; ?>
<?php echo $before_title . $title . $after_title; ?>
<ul id="recentcomments"><?php
- if ( $comments ) : foreach ($comments as $comment) :
- echo '<li class="recentcomments">' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
+ if ( $comments ) : foreach ( (array) $comments as $comment) :
+ echo '<li class="recentcomments">' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="' . clean_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
endforeach; endif;?></ul>
<?php echo $after_widget; ?>
<?php
}
+/**
+ * Remove the cache for recent comments widget.
+ *
+ * @since 2.2.0
+ */
function wp_delete_recent_comments_cache() {
wp_cache_delete( 'recent_comments', 'widget' );
}
add_action( 'comment_post', 'wp_delete_recent_comments_cache' );
add_action( 'wp_set_comment_status', 'wp_delete_recent_comments_cache' );
+/**
+ * Display and process recent comments widget options form.
+ *
+ * @since 2.2.0
+ */
function wp_widget_recent_comments_control() {
$options = $newoptions = get_option('widget_recent_comments');
- if ( $_POST["recent-comments-submit"] ) {
+ if ( isset($_POST["recent-comments-submit"]) ) {
$newoptions['title'] = strip_tags(stripslashes($_POST["recent-comments-title"]));
$newoptions['number'] = (int) $_POST["recent-comments-number"];
}
<?php
}
+/**
+ * Display the style for recent comments widget.
+ *
+ * @since 2.2.0
+ */
function wp_widget_recent_comments_style() {
?>
<style type="text/css">.recentcomments a{display:inline !important;padding: 0 !important;margin: 0 !important;}</style>
<?php
}
+/**
+ * Register recent comments with control and hook for 'wp_head' action.
+ *
+ * @since 2.2.0
+ */
function wp_widget_recent_comments_register() {
$widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'The most recent comments' ) );
wp_register_sidebar_widget('recent-comments', __('Recent Comments'), 'wp_widget_recent_comments', $widget_ops);
add_action('wp_head', 'wp_widget_recent_comments_style');
}
-// See large comment section at end of this file
+/**
+ * Display RSS widget.
+ *
+ * Allows for multiple widgets to be displayed.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Widget arguments.
+ * @param int $number Widget number.
+ */
function wp_widget_rss($args, $widget_args = 1) {
extract($args, EXTR_SKIP);
if ( is_numeric($widget_args) )
echo $after_widget;
}
+/**
+ * Display the RSS entries in a list.
+ *
+ * @since 2.5.0
+ *
+ * @param string|array|object $rss RSS url.
+ * @param array $args Widget arguments.
+ */
function wp_widget_rss_output( $rss, $args = array() ) {
if ( is_string( $rss ) ) {
require_once(ABSPATH . WPINC . '/rss.php');
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 ( is_array( $rss->items ) && !empty( $rss->items ) ) {
$rss->items = array_slice($rss->items, 0, $items);
echo '<ul>';
- foreach ($rss->items as $item ) {
+ foreach ( (array) $rss->items as $item ) {
while ( strstr($item['link'], 'http') != $item['link'] )
$item['link'] = substr($item['link'], 1);
$link = clean_url(strip_tags($item['link']));
if ( empty($title) )
$title = __('Untitled');
$desc = '';
- $summary = '';
if ( isset( $item['description'] ) && is_string( $item['description'] ) )
- $desc = $summary = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
+ $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
elseif ( isset( $item['summary'] ) && is_string( $item['summary'] ) )
- $desc = $summary = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['summary'], ENT_QUOTES))));
+ $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['summary'], ENT_QUOTES))));
+ if ( 360 < strlen( $desc ) )
+ $desc = wp_html_excerpt( $desc, 360 ) . ' […]';
+ $summary = $desc;
if ( $show_summary ) {
$desc = '';
}
if ( $link == '' ) {
- echo "<li>$title{$date}{$summary}{$author}</li>";
+ echo "<li>$title{$date}{$summary}{$author}</li>";
} else {
- echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
+ echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
}
}
echo '</ul>';
}
}
+/**
+ * Display and process RSS widget control form.
+ *
+ * @since 2.2.0
+ *
+ * @param int $widget_args Widget number.
+ */
function wp_widget_rss_control($widget_args) {
global $wp_registered_widgets;
static $updated = false;
$options = array();
$urls = array();
- foreach ( $options as $option )
+ foreach ( (array) $options as $option )
if ( isset($option['url']) )
$urls[$option['url']] = true;
else
$this_sidebar = array();
- foreach ( $this_sidebar as $_widget_id ) {
+ foreach ( (array) $this_sidebar as $_widget_id ) {
if ( 'wp_widget_rss' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
if ( !in_array( "rss-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed.
wp_widget_rss_form( compact( 'number', 'title', 'url', 'items', 'error', 'show_summary', 'show_author', 'show_date' ) );
}
+/**
+ * Display RSS widget options form.
+ *
+ * The options for what fields are displayed for the RSS form are all booleans
+ * and are as follows: 'url', 'title', 'items', 'show_summary', 'show_author',
+ * 'show_date'.
+ *
+ * @since 2.5.0
+ *
+ * @param array|string $args Values for input fields.
+ * @param array $inputs Override default display options.
+ */
function wp_widget_rss_form( $args, $inputs = null ) {
+
$default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
$inputs = wp_parse_args( $inputs, $default_inputs );
extract( $args );
+ extract( $inputs, EXTR_SKIP);
+
$number = attribute_escape( $number );
$title = attribute_escape( $title );
$url = attribute_escape( $url );
endforeach;
}
-// Expects unescaped data
+/**
+ * Process RSS feed widget data and optionally retrieve feed items.
+ *
+ * The feed widget can not have more than 20 items or it will reset back to the
+ * default, which is 10.
+ *
+ * The resulting array has the feed title, feed url, feed link (from channel),
+ * feed items, error (if any), and whether to show summary, author, and date.
+ * All respectively in the order of the array elements.
+ *
+ * @since 2.5.0
+ *
+ * @param array $widget_rss RSS widget feed data. Expects unescaped data.
+ * @param bool $check_feed Optional, default is true. Whether to check feed for errors.
+ * @return array
+ */
function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
$items = (int) $widget_rss['items'];
if ( $items < 1 || 20 < $items )
return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' );
}
+/**
+ * Register RSS widget to allow multiple RSS widgets on startup.
+ *
+ * @since 2.2.0
+ */
function wp_widget_rss_register() {
if ( !$options = get_option('widget_rss') )
$options = array();
$name = __('RSS');
$id = false;
- foreach ( array_keys($options) as $o ) {
+ foreach ( (array) array_keys($options) as $o ) {
// Old widgets can have null values for some reason
if ( !isset($options[$o]['url']) || !isset($options[$o]['title']) || !isset($options[$o]['items']) )
continue;
}
}
+/**
+ * Display tag cloud widget.
+ *
+ * @since 2.3.0
+ *
+ * @param array $args Widget arguments.
+ */
function wp_widget_tag_cloud($args) {
extract($args);
$options = get_option('widget_tag_cloud');
echo $after_widget;
}
+/**
+ * Manage WordPress Tag Cloud widget options.
+ *
+ * Displays management form for changing the tag cloud widget title.
+ *
+ * @since 2.3.0
+ */
function wp_widget_tag_cloud_control() {
$options = $newoptions = get_option('widget_tag_cloud');
- if ( $_POST['tag-cloud-submit'] ) {
+ if ( isset($_POST['tag-cloud-submit']) ) {
$newoptions['title'] = strip_tags(stripslashes($_POST['tag-cloud-title']));
}
<?php
}
+/**
+ * Register all of the default WordPress widgets on startup.
+ *
+ * Calls 'widgets_init' action after all of the WordPress widgets have been
+ * registered.
+ *
+ * @since 2.2.0
+ */
function wp_widgets_init() {
if ( !is_blog_installed() )
return;
add_action('init', 'wp_widgets_init', 1);
-/* Pattern for multi-widget (allows multiple instances such as the text widget).
-
-// Displays widget on blag
-// $widget_args: number
-// number: which of the several widgets of this type do we mean
+/*
+ * Pattern for multi-widget (allows multiple instances such as the text widget).
+ *
+ * Make sure to close the comments after copying.
+
+/**
+ * Displays widget.
+ *
+ * Supports multiple widgets.
+ *
+ * @param array $args Widget arguments.
+ * @param array|int $widget_args Widget number. Which of the several widgets of this type do we mean.
+ * /
function widget_many( $args, $widget_args = 1 ) {
extract( $args, EXTR_SKIP );
if ( is_numeric($widget_args) )
echo $after_widget;
}
-// Displays form for a particular instance of the widget. Also updates the data after a POST submit
-// $widget_args: number
-// number: which of the several widgets of this type do we mean
+/**
+ * Displays form for a particular instance of the widget.
+ *
+ * Also updates the data after a POST submit.
+ *
+ * @param array|int $widget_args Widget number. Which of the several widgets of this type do we mean.
+ * /
function widget_many_control( $widget_args = 1 ) {
global $wp_registered_widgets;
static $updated = false; // Whether or not we have already updated the data after a POST submit
<?php
}
-// Registers each instance of our widget on startup
+/**
+ * Registers each instance of our widget on startup.
+ * /
function widget_many_register() {
if ( !$options = get_option('widget_many') )
$options = array();
}
// This is important
-add_action( 'widgets_init', 'widget_many_register' )
+add_action( 'widgets_init', 'widget_many_register' );
*/
<options>
<clientType>WordPress</clientType>
<supportsKeywords>Yes</supportsKeywords>
+ <supportsGetTags>Yes</supportsGetTags>
</options>
<weblog>
* WordPress Database Access Abstraction Object
*
* It is possible to replace this class with your own
- * by setting the $wpdb global variable in wp-content/wpdb.php
+ * by setting the $wpdb global variable in wp-content/db.php
* file with your class. You can name it wpdb also, since
* this file will not be included, if the other file is
* available.
$this->ready = true;
- if ( $this->supports_collation() ) {
+ if ( $this->has_cap( 'collation' ) ) {
$collation_query = '';
if ( !empty($this->charset) ) {
$collation_query = "SET NAMES '{$this->charset}'";
if (!empty($this->collate) )
$collation_query .= " COLLATE '{$this->collate}'";
}
-
+
if ( !empty($collation_query) )
$this->query($collation_query);
-
+
}
-
+
$this->select($dbname);
}
$old_prefix = $this->prefix;
$this->prefix = $prefix;
- foreach ( $this->tables as $table )
+ foreach ( (array) $this->tables as $table )
$this->$table = $this->prefix . $table;
if ( defined('CUSTOM_USER_TABLE') )
<ul>
<li>Are you sure it exists?</li>
<li>Does the user <code>%2$s</code> have permission to use the <code>%1$s</code> database?</li>
-<li>On some systems the name of your database is prefixed with your username, so it would be like username_wordpress. Could that be the problem?</li>
+<li>On some systems the name of your database is prefixed with your username, so it would be like <code>username_%1$s</code>. Could that be the problem?</li>
</ul>
<p>If you don\'t know how to setup a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href="http://wordpress.org/support/">WordPress Support Forums</a>.</p>'/*/WP_I18N_DB_SELECT_DB*/, $db, DB_USER));
return;
$log_error = false;
$log_file = @ini_get('error_log');
- if ( !empty($log_file) && ('syslog' != $log_file) && !is_writable($log_file) )
+ if ( !empty($log_file) && ('syslog' != $log_file) && !@is_writable($log_file) )
$log_error = false;
if ( $log_error )
return false;
}
- if ( preg_match("/^\\s*(insert|delete|update|replace) /i",$query) ) {
+ if ( preg_match("/^\\s*(insert|delete|update|replace|alter) /i",$query) ) {
$this->rows_affected = mysql_affected_rows($this->dbh);
// Take note of the insert_id
if ( preg_match("/^\\s*(insert|replace) /i",$query) ) {
function update($table, $data, $where){
$data = add_magic_quotes($data);
$bits = $wheres = array();
- foreach ( array_keys($data) as $k )
+ foreach ( (array) array_keys($data) as $k )
$bits[] = "`$k` = '$data[$k]'";
if ( is_array( $where ) )
$wheres[] = "$c = '" . $this->escape( $v ) . "'";
else
return false;
-
+
return $this->query( "UPDATE $table SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres ) );
}
// Return an integer-keyed array of...
if ( $this->last_result ) {
$i = 0;
- foreach( $this->last_result as $row ) {
+ foreach( (array) $this->last_result as $row ) {
if ( $output == ARRAY_N ) {
// ...integer-keyed row arrays
$new_array[$i] = array_values( get_object_vars( $row ) );
if ( $this->col_info ) {
if ( $col_offset == -1 ) {
$i = 0;
- foreach($this->col_info as $col ) {
+ foreach( (array) $this->col_info as $col ) {
$new_array[$i] = $col->{$info_type};
$i++;
}
{
global $wp_version;
// Make sure the server has MySQL 4.0
- $mysql_version = preg_replace('|[^0-9\.]|', '', @mysql_get_server_info($this->dbh));
- if ( version_compare($mysql_version, '4.0.0', '<') )
+ if ( version_compare($this->db_version(), '4.0.0', '<') )
return new WP_Error('database_version',sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version));
}
*/
function supports_collation()
{
- return ( version_compare(mysql_get_server_info($this->dbh), '4.1.0', '>=') );
+ return $this->has_cap( 'collation' );
+ }
+
+ /**
+ * Generic function to determine if a database supports a particular feature
+ * @param string $db_cap the feature
+ * @param false|string|resource $dbh_or_table the databaese (the current database, the database housing the specified table, or the database of the mysql resource)
+ * @return bool
+ */
+ function has_cap( $db_cap ) {
+ $version = $this->db_version();
+
+ switch ( strtolower( $db_cap ) ) :
+ case 'collation' : // @since 2.5.0
+ case 'group_concat' : // @since 2.7
+ case 'subqueries' : // @since 2.7
+ return version_compare($version, '4.1', '>=');
+ break;
+ endswitch;
+
+ return false;
}
/**
return '';
$bt = debug_backtrace();
- $caller = '';
+ $caller = array();
- foreach ( $bt as $trace ) {
- if ( @$trace['class'] == __CLASS__ )
- continue;
- elseif ( strtolower(@$trace['function']) == 'call_user_func_array' )
- continue;
- elseif ( strtolower(@$trace['function']) == 'apply_filters' )
+ $bt = array_reverse( $bt );
+ foreach ( (array) $bt as $call ) {
+ if ( @$call['class'] == __CLASS__ )
continue;
- elseif ( strtolower(@$trace['function']) == 'do_action' )
- continue;
-
- $caller = $trace['function'];
- break;
+ $function = $call['function'];
+ if ( isset( $call['class'] ) )
+ $function = $call['class'] . "->$function";
+ $caller[] = $function;
}
+ $caller = join( ', ', $caller );
+
return $caller;
}
+ /**
+ * The database version number
+ * @return false|string false on failure, version number on success
+ */
+ function db_version() {
+ return preg_replace('/[^0-9.].*/', '', mysql_get_server_info( $this->dbh ));
+ }
}
if ( ! isset($wpdb) ) {
/**
- * WordPress Database Object, if it isn't set already in wp-content/wpdb.php
+ * WordPress Database Object, if it isn't set already in wp-content/db.php
* @global object $wpdb Creates a new wpdb object based on wp-config.php Constants for the database
* @since 0.71
*/
<?php
+/**
+ * WordPress Diff bastard child of old MediaWiki Diff Formatter.
+ *
+ * Basically all that remains is the table structure and some method names.
+ *
+ * @package WordPress
+ * @subpackage Diff
+ */
if ( !class_exists( 'Text_Diff' ) ) {
+ /** Text_Diff class */
require( dirname(__FILE__).'/Text/Diff.php' );
+ /** Text_Diff_Renderer class */
require( dirname(__FILE__).'/Text/Diff/Renderer.php' );
+ /** Text_Diff_Renderer_inline class */
require( dirname(__FILE__).'/Text/Diff/Renderer/inline.php' );
}
-
-/* Descendent of a bastard child of piece of an old MediaWiki Diff Formatter
+/**
+ * Table renderer to display the diff lines.
*
- * Basically all that remains is the table structure and some method names.
+ * @since 2.6.0
+ * @uses Text_Diff_Renderer Extends
*/
-
class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
+
+ /**
+ * @see Text_Diff_Renderer::_leading_context_lines
+ * @var int
+ * @access protected
+ * @since 2.6.0
+ */
var $_leading_context_lines = 10000;
+
+ /**
+ * @see Text_Diff_Renderer::_trailing_context_lines
+ * @var int
+ * @access protected
+ * @since 2.6.0
+ */
var $_trailing_context_lines = 10000;
+
+ /**
+ * {@internal Missing Description}}
+ *
+ * @var float
+ * @access protected
+ * @since 2.6.0
+ */
var $_diff_threshold = 0.6;
+ /**
+ * Inline display helper object name.
+ *
+ * @var string
+ * @access protected
+ * @since 2.6.0
+ */
var $inline_diff_renderer = 'WP_Text_Diff_Renderer_inline';
+ /**
+ * PHP4 Constructor - Call parent constructor with params array.
+ *
+ * This will set class properties based on the key value pairs in the array.
+ *
+ * @since unknown
+ *
+ * @param array $params
+ */
function Text_Diff_Renderer_Table( $params = array() ) {
$parent = get_parent_class($this);
$this->$parent( $params );
}
+ /**
+ * @ignore
+ *
+ * @param string $header
+ * @return string
+ */
function _startBlock( $header ) {
return '';
}
+ /**
+ * @ignore
+ *
+ * @param array $lines
+ * @param string $prefix
+ */
function _lines( $lines, $prefix=' ' ) {
}
- // HTML-escape parameter before calling this
+ /**
+ * @ignore
+ *
+ * @param string $line HTML-escape the value.
+ * @return string
+ */
function addedLine( $line ) {
return "<td>+</td><td class='diff-addedline'>{$line}</td>";
}
- // HTML-escape parameter before calling this
+ /**
+ * @ignore
+ *
+ * @param string $line HTML-escape the value.
+ * @return string
+ */
function deletedLine( $line ) {
return "<td>-</td><td class='diff-deletedline'>{$line}</td>";
}
- // HTML-escape parameter before calling this
+ /**
+ * @ignore
+ *
+ * @param string $line HTML-escape the value.
+ * @return string
+ */
function contextLine( $line ) {
return "<td> </td><td class='diff-context'>{$line}</td>";
}
+ /**
+ * @ignore
+ *
+ * @return string
+ */
function emptyLine() {
return '<td colspan="2"> </td>';
}
+ /**
+ * @ignore
+ * @access private
+ *
+ * @param array $lines
+ * @param bool $encode
+ * @return string
+ */
function _added( $lines, $encode = true ) {
$r = '';
foreach ($lines as $line) {
return $r;
}
+ /**
+ * @ignore
+ * @access private
+ *
+ * @param array $lines
+ * @param bool $encode
+ * @return string
+ */
function _deleted( $lines, $encode = true ) {
$r = '';
foreach ($lines as $line) {
return $r;
}
+ /**
+ * @ignore
+ * @access private
+ *
+ * @param array $lines
+ * @param bool $encode
+ * @return string
+ */
function _context( $lines, $encode = true ) {
$r = '';
foreach ($lines as $line) {
return $r;
}
- // Process changed lines to do word-by-word diffs for extra highlighting (TRAC style)
- // sometimes these lines can actually be deleted or added rows - we do additional processing
- // to figure that out
+ /**
+ * Process changed lines to do word-by-word diffs for extra highlighting.
+ *
+ * (TRAC style) sometimes these lines can actually be deleted or added rows.
+ * We do additional processing to figure that out
+ *
+ * @access private
+ * @since 2.6.0
+ *
+ * @param array $orig
+ * @param array $final
+ * @return string
+ */
function _changed( $orig, $final ) {
$r = '';
return $r;
}
- // Takes changed blocks and matches which rows in orig turned into which rows in final.
- // Returns
- // *_matches ( which rows match with which )
- // *_rows ( order of rows in each column interleaved with blank rows as necessary )
+ /**
+ * Takes changed blocks and matches which rows in orig turned into which rows in final.
+ *
+ * Returns
+ * *_matches ( which rows match with which )
+ * *_rows ( order of rows in each column interleaved with blank rows as
+ * necessary )
+ *
+ * @since 2.6.0
+ *
+ * @param unknown_type $orig
+ * @param unknown_type $final
+ * @return unknown
+ */
function interleave_changed_lines( $orig, $final ) {
// Contains all pairwise string comparisons. Keys are such that this need only be a one dimensional array.
*/
}
-
- // Computes a number that is intended to reflect the "distance" between two strings.
+ /**
+ * Computes a number that is intended to reflect the "distance" between two strings.
+ *
+ * @since 2.6.0
+ *
+ * @param string $string1
+ * @param string $string2
+ * @return int
+ */
function compute_string_distance( $string1, $string2 ) {
// Vectors containing character frequency for all chars in each string
$chars1 = count_chars($string1);
return $difference / strlen($string1);
}
+ /**
+ * @ignore
+ * @since 2.6.0
+ *
+ * @param int $a
+ * @param int $b
+ * @return int
+ */
function difference( $a, $b ) {
return abs( $a - $b );
}
}
-// Better word splitting than the PEAR package provides
+/**
+ * Better word splitting than the PEAR package provides.
+ *
+ * @since 2.6.0
+ * @uses Text_Diff_Renderer_inline Extends
+ */
class WP_Text_Diff_Renderer_inline extends Text_Diff_Renderer_inline {
+ /**
+ * @ignore
+ * @since 2.6.0
+ *
+ * @param string $string
+ * @param string $newlineEscape
+ * @return string
+ */
function _splitOnWords($string, $newlineEscape = "\n") {
$string = str_replace("\0", '', $string);
$words = preg_split( '/([^\w])/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
/** The config file resides in ABSPATH */
require_once( ABSPATH . 'wp-config.php' );
-} elseif ( file_exists( dirname(ABSPATH) . '/wp-config.php' ) ) {
+} elseif ( file_exists( dirname(ABSPATH) . '/wp-config.php' ) && ! file_exists( dirname(ABSPATH) . '/wp-load.php' ) ) {
/** The config file resides one level below ABSPATH */
require_once( dirname(ABSPATH) . '/wp-config.php' );
exit();
} else {
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
- exit();
+ exit();
}
}
/**
- * login_header() - Outputs the header for the login page
+ * Outputs the header for the login page.
*
- * @package WordPress
- * @uses do_action() Calls the 'login_head' for outputting HTML in the Login
+ * @uses do_action() Calls the 'login_head' for outputting HTML in the Log In
* header.
* @uses apply_filters() Calls 'login_headerurl' for the top login link.
* @uses apply_filters() Calls 'login_headertitle' for the top login title.
* header.
* @uses $error The error global, which is checked for displaying errors.
*
- * @param string $title Optional. WordPress Login Page title to display in
+ * @param string $title Optional. WordPress Log In Page title to display in
* <title/> element.
* @param string $message Optional. Message to display in header.
* @param WP_Error $wp_error Optional. WordPress Error Object
*/
-function login_header($title = 'Login', $message = '', $wp_error = '') {
+function login_header($title = 'Log In', $message = '', $wp_error = '') {
global $error;
if ( empty($wp_error) )
} // End of login_header()
/**
- * retrieve_password() - Handles sending password retrieval email to user
- *
- * {@internal Missing Long Description}}
+ * Handles sending password retrieval email to user.
*
* @uses $wpdb WordPress Database object
*
if ( empty( $_POST['user_login'] ) && empty( $_POST['user_email'] ) )
$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
- if ( strstr($_POST['user_login'], '@') ) {
+ if ( strpos($_POST['user_login'], '@') ) {
$user_data = get_user_by_email(trim($_POST['user_login']));
if ( empty($user_data) )
$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
else if ( is_wp_error($allow) )
return $allow;
-
+
$key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login));
if ( empty($key) ) {
// Generate something random for a key...
}
/**
- * reset_password() - Handles resetting the user's password
- *
- * {@internal Missing Long Description}}
+ * Handles resetting the user's password.
*
* @uses $wpdb WordPress Database object
*
if ( !wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_option('blogname')), $message) )
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
- // send a copy of password change notification to the admin
- // but check to see if it's the admin whose password we're changing, and skip this
- if ( $user->user_email != get_option('admin_email') ) {
- $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
- wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), get_option('blogname')), $message);
- }
+ wp_password_change_notification($user);
return true;
}
/**
- * register_new_user() - Handles registering a new user
- *
- * {@internal Missing Long Description}}
+ * Handles registering a new user.
*
* @param string $user_login User's username for logging in
* @param string $user_email User's email address to send password and add
switch ($action) {
case 'logout' :
-
+ check_admin_referer('log-out');
wp_logout();
$redirect_to = 'wp-login.php?loggedout=true';
}
}
- if ( 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.'));
+ if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.'));
do_action('lost_password');
login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or e-mail address. You will receive a new password via e-mail.') . '</p>', $errors);
+
+ $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
+
?>
<form name="lostpasswordform" id="lostpasswordform" action="<?php echo site_url('wp-login.php?action=lostpassword', 'login_post') ?>" method="post">
<p>
<label><?php _e('Username or E-mail:') ?><br />
- <input type="text" name="user_login" id="user_login" class="input" value="<?php echo attribute_escape(stripslashes($_POST['user_login'])); ?>" size="20" tabindex="10" /></label>
+ <input type="text" name="user_login" id="user_login" class="input" value="<?php echo attribute_escape($user_login); ?>" size="20" tabindex="10" /></label>
</p>
<?php do_action('lostpassword_form'); ?>
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Get New Password'); ?>" tabindex="100" /></p>
</div>
-<p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('« Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
+<p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
<script type="text/javascript">
try{document.getElementById('user_login').focus();}catch(e){}
</div>
-<p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('« Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
+<p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
<script type="text/javascript">
try{document.getElementById('user_login').focus();}catch(e){}
case 'login' :
default:
- if ( isset( $_REQUEST['redirect_to'] ) )
+ $secure_cookie = '';
+
+ // If the user wants ssl but the session is not ssl, force a secure cookie.
+ if ( !empty($_POST['log']) && !force_ssl_admin() ) {
+ $user_name = sanitize_user($_POST['log']);
+ if ( $user = get_userdatabylogin($user_name) ) {
+ if ( get_user_option('use_ssl', $user->ID) ) {
+ $secure_cookie = true;
+ force_ssl_admin(true);
+ }
+ }
+ }
+
+ if ( isset( $_REQUEST['redirect_to'] ) ) {
$redirect_to = $_REQUEST['redirect_to'];
- else
+ // Redirect to https if user wants ssl
+ if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') )
+ $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
+ } else {
$redirect_to = admin_url();
+ }
- if ( is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
+ if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
$secure_cookie = false;
- else
- $secure_cookie = '';
$user = wp_signon('', $secure_cookie);
// Some parts of this script use the main login form to display a message
if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] ) $errors->add('loggedout', __('You are now logged out.'), 'message');
- elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) $errors->add('registerdiabled', __('User registration is currently not allowed.'));
+ elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) $errors->add('registerdisabled', __('User registration is currently not allowed.'));
elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) $errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
- login_header(__('Login'), '', $errors);
+ login_header(__('Log In'), '', $errors);
+
+ if ( isset($_POST['log']) )
+ $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? attribute_escape(stripslashes($_POST['log'])) : '';
?>
-<form name="loginform" id="loginform" action="<?php echo site_url('wp-login.php', 'login_post') ?>" method="post">
<?php if ( !isset($_GET['checkemail']) || !in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?>
+<form name="loginform" id="loginform" action="<?php echo site_url('wp-login.php', 'login_post') ?>" method="post">
<p>
<label><?php _e('Username') ?><br />
- <input type="text" name="log" id="user_login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" size="20" tabindex="10" /></label>
+ <input type="text" name="log" id="user_login" class="input" value="<?php echo $user_login; ?>" size="20" tabindex="10" /></label>
</p>
<p>
<label><?php _e('Password') ?><br />
<input type="hidden" name="redirect_to" value="<?php echo attribute_escape($redirect_to); ?>" />
<input type="hidden" name="testcookie" value="1" />
</p>
-<?php else : ?>
- <p> </p>
-<?php endif; ?>
</form>
+<?php endif; ?>
<p id="nav">
<?php if ( isset($_GET['checkemail']) && in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?>
</div>
-<p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('« Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
+<p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
<script type="text/javascript">
+<?php if ( $user_login ) { ?>
+setTimeout( function(){ try{
+d = document.getElementById('user_pass');
+d.value = '';
+d.focus();
+} catch(e){}
+}, 200);
+<?php } else { ?>
try{document.getElementById('user_login').focus();}catch(e){}
+<?php } ?>
</script>
</body>
</html>
break;
} // end action switch
-?>
\ No newline at end of file
+?>
<?php
/**
* Gets the email message from the user's mailbox to add as
- * a WordPress post. Will only run if this is setup and enabled.
+ * a WordPress post. Mailbox connection information must be
+ * configured under Settings > Writing
*
* @package WordPress
*/
-/** Make sure that the WordPress bootstrap has ran before continuing. */
+/** Make sure that the WordPress bootstrap has run before continuing. */
require(dirname(__FILE__) . '/wp-load.php');
-/** Get the POP3 class for which to access the mailbox. */
-require_once(ABSPATH.WPINC.'/class-pop3.php');
+/** Get the POP3 class with which to access the mailbox. */
+require_once( ABSPATH . WPINC . '/class-pop3.php' );
-// WTF is this? Use constants instead.
-error_reporting(2037);
-
-$time_difference = get_option('gmt_offset') * 3600;
+$time_difference = absint(get_option('gmt_offset')) * 3600;
$phone_delim = '::';
$pop3 = new POP3();
-if (!$pop3->connect(get_option('mailserver_url'), get_option('mailserver_port')))
- wp_die(wp_specialchars($pop3->ERROR));
-
-if (!$pop3->user(get_option('mailserver_login')))
- wp_die(wp_specialchars($pop3->ERROR));
+if ( ! $pop3->connect(get_option('mailserver_url'), get_option('mailserver_port') ) ||
+ ! $pop3->user(get_option('mailserver_login')) ||
+ ( ! $count = $pop3->pass(get_option('mailserver_pass')) ) ) {
+ $pop3->quit();
+ wp_die( ( 0 === $count ) ? __("There doesn't seem to be any new mail.") : wp_specialchars($pop3->ERROR) );
+}
-$count = $pop3->pass(get_option('mailserver_pass'));
-if (false === $count)
- wp_die(wp_specialchars($pop3->ERROR));
-if (0 == $count)
- echo "<p>There doesn't seem to be any new mail.</p>\n"; // will fall-through to end of for loop
-
-for ($i=1; $i <= $count; $i++) :
+for ( $i = 1; $i <= $count; $i++ ) {
$message = $pop3->get($i);
+ $bodysignal = false;
+ $boundary = '';
+ $charset = '';
$content = '';
$content_type = '';
$content_transfer_encoding = '';
- $boundary = '';
- $bodysignal = 0;
$post_author = 1;
$author_found = false;
$dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
- foreach ($message as $line) :
- if (strlen($line) < 3) $bodysignal = 1;
-
- if ($bodysignal) {
+ foreach ($message as $line) {
+ // body signal
+ if ( strlen($line) < 3 )
+ $bodysignal = true;
+ if ( $bodysignal ) {
$content .= $line;
} else {
- if (preg_match('/Content-Type: /i', $line)) {
+ if ( preg_match('/Content-Type: /i', $line) ) {
$content_type = trim($line);
- $content_type = substr($content_type, 14, strlen($content_type)-14);
+ $content_type = substr($content_type, 14, strlen($content_type) - 14);
$content_type = explode(';', $content_type);
+ if ( ! empty( $content_type[1] ) ) {
+ $charset = explode('=', $content_type[1]);
+ $charset = ( ! empty( $charset[1] ) ) ? trim($charset[1]) : '';
+ }
$content_type = $content_type[0];
}
- if (preg_match('/Content-Transfer-Encoding: /i', $line)) {
+ if ( preg_match('/Content-Transfer-Encoding: /i', $line) ) {
$content_transfer_encoding = trim($line);
- $content_transfer_encoding = substr($content_transfer_encoding, 27, strlen($content_transfer_encoding)-14);
+ $content_transfer_encoding = substr($content_transfer_encoding, 27, strlen($content_transfer_encoding) - 27);
$content_transfer_encoding = explode(';', $content_transfer_encoding);
$content_transfer_encoding = $content_transfer_encoding[0];
}
- if (($content_type == 'multipart/alternative') && (preg_match('/boundary="/', $line)) && ($boundary == '')) {
+ if ( ( $content_type == 'multipart/alternative' ) && ( false !== strpos($line, 'boundary="') ) && ( '' == $boundary ) ) {
$boundary = trim($line);
$boundary = explode('"', $boundary);
$boundary = $boundary[1];
}
if (preg_match('/Subject: /i', $line)) {
$subject = trim($line);
- $subject = substr($subject, 9, strlen($subject)-9);
- $subject = wp_iso_descrambler($subject);
+ $subject = substr($subject, 9, strlen($subject) - 9);
// Captures any text in the subject before $phone_delim as the subject
+ if ( function_exists('iconv_mime_decode') ) {
+ $subject = iconv_mime_decode($subject, 2, get_option('blog_charset'));
+ } else {
+ $subject = wp_iso_descrambler($subject);
+ }
$subject = explode($phone_delim, $subject);
$subject = $subject[0];
}
$author = trim($line);
$author = sanitize_email($author);
if ( is_email($author) ) {
- echo "Author = {$author} <p>";
+ echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>';
$userdata = get_user_by_email($author);
- if (!$userdata) {
- $post_author = 1;
+ if ( empty($userdata) ) {
$author_found = false;
} else {
$post_author = $userdata->ID;
$author_found = true;
}
} else {
- $post_author = 1;
$author_found = false;
}
}
$ddate = trim($line);
$ddate = str_replace('Date: ', '', $ddate);
if (strpos($ddate, ',')) {
- $ddate = trim(substr($ddate, strpos($ddate, ',')+1, strlen($ddate)));
+ $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));
}
$date_arr = explode(' ', $ddate);
$date_time = explode(':', $date_arr[3]);
$ddate_m = $date_arr[1];
$ddate_d = $date_arr[0];
$ddate_Y = $date_arr[2];
- for ($j=0; $j<12; $j++) {
- if ($ddate_m == $dmonths[$j]) {
+ for ( $j = 0; $j < 12; $j++ ) {
+ if ( $ddate_m == $dmonths[$j] ) {
$ddate_m = $j+1;
}
}
$post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U);
}
}
- endforeach;
+ }
// Set $post_status based on $author_found and on author's publish_posts capability
- if ($author_found) {
+ if ( $author_found ) {
$user = new WP_User($post_author);
- if ($user->has_cap('publish_posts'))
- $post_status = 'publish';
- else
- $post_status = 'pending';
+ $post_status = ( $user->has_cap('publish_posts') ) ? 'publish' : 'pending';
} else {
// Author not found in DB, set status to pending. Author already set to admin.
$post_status = 'pending';
$subject = trim($subject);
- if ($content_type == 'multipart/alternative') {
+ if ( $content_type == 'multipart/alternative' ) {
$content = explode('--'.$boundary, $content);
$content = $content[2];
- $content = explode('Content-Transfer-Encoding: quoted-printable', $content);
- $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div>');
+ // match case-insensitive content-transfer-encoding
+ if ( preg_match( '/Content-Transfer-Encoding: quoted-printable/i', $content, $delim) ) {
+ $content = explode($delim[0], $content);
+ $content = $content[1];
+ }
+ $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div>');
}
$content = trim($content);
- if (stripos($content_transfer_encoding, "quoted-printable") !== false) {
+ if ( false !== stripos($content_transfer_encoding, "quoted-printable") ) {
$content = quoted_printable_decode($content);
}
+ if ( function_exists('iconv') && ! empty( $charset ) ) {
+ $content = iconv($charset, get_option('blog_charset'), $content);
+ }
+
// Captures any text in the body after $phone_delim as the body
$content = explode($phone_delim, $content);
- $content[1] ? $content = $content[1] : $content = $content[0];
+ $content = empty( $content[1] ) ? $content[0] : $content[1];
$content = trim($content);
if ($post_title == '') $post_title = $subject;
- if (empty($post_categories)) $post_categories[] = get_option('default_email_category');
-
- $post_category = $post_categories;
+ $post_category = array(get_option('default_email_category'));
$post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status');
$post_data = add_magic_quotes($post_data);
if ( is_wp_error( $post_ID ) )
echo "\n" . $post_ID->get_error_message();
- if (!$post_ID) {
- // we couldn't post, for whatever reason. better move forward to the next email
+ // We couldn't post, for whatever reason. Better move forward to the next email.
+ if ( empty( $post_ID ) )
continue;
- }
do_action('publish_phone', $post_ID);
- echo "\n<p><b>Author:</b> " . wp_specialchars($post_author) . "</p>";
- echo "\n<p><b>Posted title:</b> " . wp_specialchars($post_title) . "<br />";
+ echo "\n<p>" . sprintf(__('<strong>Author:</strong> %s'), wp_specialchars($post_author)) . '</p>';
+ echo "\n<p>" . sprintf(__('<strong>Posted title:</strong> %s'), wp_specialchars($post_title)) . '</p>';
if(!$pop3->delete($i)) {
- echo '<p>Oops '.wp_specialchars($pop3->ERROR).'</p></div>';
+ echo '<p>' . sprintf(__('Oops: %s'), wp_specialchars($pop3->ERROR)) . '</p>';
$pop3->reset();
exit;
} else {
- echo "<p>Mission complete, message <strong>$i</strong> deleted.</p>";
+ echo '<p>' . sprintf(__('Mission complete. Message <strong>%s</strong> deleted.'), $i) . '</p>';
}
-endfor;
+}
$pop3->quit();
-?>
\ No newline at end of file
+?>
<?php
/**
- * Outputs the RDF feed using the feed-rdf.php
- * file in wp-includes folder.
- *
- * This file only sets the feed format and includes the
- * feed-rdf.php.
- *
- * This file is no longer used in WordPress and while it is
- * not deprecated now. This file will most likely be
- * deprecated or removed in a later version.
+ * Redirects to the RDF feed
+ * This file is deprecated and only exists for backwards compatibility
*
* @package WordPress
*/
-if (empty($wp)) {
- require_once('./wp-load.php');
- wp('feed=rdf');
-}
-
-require (ABSPATH . WPINC . '/feed-rdf.php');
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( 'rdf_url' ), 301 );
?>
\ No newline at end of file
<?php
/**
- * Outputs the RSS feed RDF format using the feed-rss.php
- * file in wp-includes folder.
- *
- * This file only sets the feed format and includes the
- * feed-rss.php.
- *
- * This file is no longer used in WordPress and while it is
- * not deprecated now. This file will most likely be
- * deprecated or removed in a later version.
+ * Redirects to the RSS feed
+ * This file is deprecated and only exists for backwards compatibility
*
* @package WordPress
*/
-if (empty($wp)) {
- require_once('./wp-load.php');
- wp('feed=rss');
-}
-
-require (ABSPATH . WPINC . '/feed-rss.php');
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( 'rss_url' ), 301 );
?>
\ No newline at end of file
<?php
/**
- * Outputs the RSS2 feed XML format using the feed-rss2.php file in wp-includes
- * folder. This file only sets the feed format and includes the feed-rss2.php.
- *
- * This file is no longer used in WordPress and while it is not deprecated now.
- * This file will most likely be deprecated or removed in a later version.
- *
- * The link for the rss2 feed is /index.php?feed=rss2 with permalinks off.
+ * Redirects to the RSS2 feed
+ * This file is deprecated and only exists for backwards compatibility
*
* @package WordPress
*/
-if (empty($wp)) {
- require_once('./wp-load.php');
- wp('feed=rss2');
-}
-
-require (ABSPATH . WPINC . '/feed-rss2.php');
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( 'rss2_url' ), 301 );
?>
\ No newline at end of file
if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
@ini_set('memory_limit', WP_MEMORY_LIMIT);
+set_magic_quotes_runtime(0);
+@ini_set('magic_quotes_sybase', 0);
/**
- * wp_unregister_GLOBALS() - Turn register globals off
+ * Turn register globals off.
*
* @access private
* @since 2.1.0
if ( !defined('WP_CONTENT_DIR') )
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
+if ( file_exists(ABSPATH . '.maintenance') && !defined('WP_INSTALLING') ) {
+ include(ABSPATH . '.maintenance');
+ // If the $upgrading timestamp is older than 10 minutes, don't die.
+ if ( ( time() - $upgrading ) < 600 ) {
+ if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
+ require_once( WP_CONTENT_DIR . '/maintenance.php' );
+ die();
+ }
+
+ $protocol = $_SERVER["SERVER_PROTOCOL"];
+ if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
+ $protocol = 'HTTP/1.0';
+ header( "$protocol 503 Service Unavailable", true, 503 );
+ header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>Maintenance</title>
+
+</head>
+<body>
+ <h1>Briefly unavailable for scheduled maintenance. Check back in a minute.</h1>
+</body>
+</html>
+<?php
+ die();
+ }
+}
+
if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') )
die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ );
/**
- * timer_start() - PHP 4 standard microtime start capture
+ * PHP 4 standard microtime start capture.
*
* @access private
* @since 0.71
- * @global int $timestart Seconds and Microseconds added together from when function is called
- * @return bool Always returns true
+ * @global int $timestart Seconds and Microseconds added together from when function is called.
+ * @return bool Always returns true.
*/
function timer_start() {
global $timestart;
}
/**
- * timer_stop() - Return and/or display the time from the page start to when function is called.
+ * Return and/or display the time from the page start to when function is called.
*
* You can get the results and print them by doing:
* <code>
if (defined('WP_DEBUG') and WP_DEBUG == true) {
error_reporting(E_ALL);
} else {
- error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE);
+ // Unicode Extension is in PHP 6.0 only or do version check when this changes.
+ if ( function_exists('unicode_decode') )
+ error_reporting( E_ALL ^ E_DEPRECATED ^ E_NOTICE ^ E_USER_NOTICE ^ E_STRICT );
+ else if ( defined( 'E_DEPRECATED' ) ) // Introduced in PHP 5.3
+ error_reporting( E_ALL ^ E_DEPRECATED ^ E_NOTICE ^ E_USER_NOTICE );
+ else
+ error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE);
}
// For an advanced caching plugin to use, static because you would only want one
require (ABSPATH . WPINC . '/canonical.php');
require (ABSPATH . WPINC . '/shortcodes.php');
require (ABSPATH . WPINC . '/media.php');
+require (ABSPATH . WPINC . '/http.php');
if ( !defined('WP_CONTENT_URL') )
define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
/**
* Allows for the plugins directory to be moved from the default location.
*
- * @since 2.6
+ * @since 2.6.0
*/
if ( !defined('WP_PLUGIN_DIR') )
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
+
+/**
+ * Allows for the plugins directory to be moved from the default location.
+ *
+ * @since 2.6.0
+ */
if ( !defined('WP_PLUGIN_URL') )
define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
+
+/**
+ * Allows for the plugins directory to be moved from the default location.
+ *
+ * @since 2.1.0
+ */
if ( !defined('PLUGINDIR') )
define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat.
-if ( ! defined('WP_INSTALLING') ) {
- // Used to guarantee unique hash cookies
- $cookiehash = md5(get_option('siteurl'));
- /**
- * Used to guarantee unique hash cookies
- * @since 1.5
- */
- define('COOKIEHASH', $cookiehash);
-}
+/**
+ * Used to guarantee unique hash cookies
+ * @since 1.5
+ */
+define('COOKIEHASH', md5(get_option('siteurl')));
/**
* Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php
- * @since 2.5
+ * @since 2.5.0
*/
$wp_default_secret_key = 'put your unique phrase here';
/**
* It is possible to define this in wp-config.php
- * @since 2.5
+ * @since 2.5.0
*/
if ( !defined('AUTH_COOKIE') )
define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
/**
* It is possible to define this in wp-config.php
- * @since 2.6
+ * @since 2.6.0
*/
if ( !defined('SECURE_AUTH_COOKIE') )
define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
/**
* It is possible to define this in wp-config.php
- * @since 2.6
+ * @since 2.6.0
*/
if ( !defined('LOGGED_IN_COOKIE') )
define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
/**
* It is possible to define this in wp-config.php
- * @since 2.6
+ * @since 2.6.0
*/
if ( !defined('ADMIN_COOKIE_PATH') )
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
/**
* It is possible to define this in wp-config.php
- * @since 2.6
+ * @since 2.6.0
*/
if ( !defined('PLUGINS_COOKIE_PATH') )
define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL) );
/**
* It is possible to define this in wp-config.php
- * @since 2.6
+ * @since 2.6.0
*/
if ( !defined('FORCE_SSL_ADMIN') )
define('FORCE_SSL_ADMIN', false);
/**
* It is possible to define this in wp-config.php
- * @since 2.6
+ * @since 2.6.0
*/
if ( !defined('FORCE_SSL_LOGIN') )
define('FORCE_SSL_LOGIN', false);
*/
if ( !defined( 'AUTOSAVE_INTERVAL' ) )
define( 'AUTOSAVE_INTERVAL', 60 );
-
+
require (ABSPATH . WPINC . '/vars.php');
require(ABSPATH . 'my-hacks.php');
}
-if ( get_option('active_plugins') ) {
+if ( get_option('active_plugins') && !defined('WP_INSTALLING') ) {
$current_plugins = get_option('active_plugins');
if ( is_array($current_plugins) ) {
foreach ($current_plugins as $plugin) {
/**
* Web Path to the current active template directory
- * @since 1.5
+ * @since 1.5.0
*/
define('TEMPLATEPATH', get_template_directory());
/**
* Web Path to the current active template stylesheet directory
- * @since 2.1
+ * @since 2.1.0
*/
define('STYLESHEETPATH', get_stylesheet_directory());
include(TEMPLATEPATH . '/functions.php');
/**
- * shutdown_action_hook() - Runs just before PHP shuts down execution.
+ * Runs just before PHP shuts down execution.
*
* @access private
- * @since 1.2
+ * @since 1.2.0
*/
function shutdown_action_hook() {
do_action('shutdown');
logIO("I", $HTTP_RAW_POST_DATA);
/**
- * @internal
- * Left undocumented to work on later. If you want to finish, then please do so.
+ * WordPress XMLRPC server implementation.
+ *
+ * Implements compatability for Blogger API, MetaWeblog API, MovableType, and
+ * pingback. Additional WordPress API for managing comments, pages, posts,
+ * options, etc.
+ *
+ * Since WordPress 2.6.0, WordPress XMLRPC server can be disabled in the
+ * administration panels.
*
* @package WordPress
* @subpackage Publishing
+ * @since 1.5.0
*/
class wp_xmlrpc_server extends IXR_Server {
+ /**
+ * Register all of the XMLRPC methods that XMLRPC server understands.
+ *
+ * PHP4 constructor and sets up server and method property. Passes XMLRPC
+ * methods through the 'xmlrpc_methods' filter to allow plugins to extend
+ * or replace XMLRPC methods.
+ *
+ * @since 1.5.0
+ *
+ * @return wp_xmlrpc_server
+ */
function wp_xmlrpc_server() {
$this->methods = array(
// WordPress API
'wp.getPageList' => 'this:wp_getPageList',
'wp.getAuthors' => 'this:wp_getAuthors',
'wp.getCategories' => 'this:mw_getCategories', // Alias
+ 'wp.getTags' => 'this:wp_getTags',
'wp.newCategory' => 'this:wp_newCategory',
'wp.deleteCategory' => 'this:wp_deleteCategory',
'wp.suggestCategories' => 'this:wp_suggestCategories',
'wp.getPageTemplates' => 'this:wp_getPageTemplates',
'wp.getOptions' => 'this:wp_getOptions',
'wp.setOptions' => 'this:wp_setOptions',
+ 'wp.getComment' => 'this:wp_getComment',
+ 'wp.getComments' => 'this:wp_getComments',
+ 'wp.deleteComment' => 'this:wp_deleteComment',
+ 'wp.editComment' => 'this:wp_editComment',
+ 'wp.newComment' => 'this:wp_newComment',
+ 'wp.getCommentStatusList' => 'this:wp_getCommentStatusList',
// Blogger API
'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
$this->IXR_Server($this->methods);
}
+ /**
+ * Test XMLRPC API by saying, "Hello!" to client.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method Parameters.
+ * @return string
+ */
function sayHello($args) {
return 'Hello!';
}
+ /**
+ * Test XMLRPC API by adding two numbers for client.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method Parameters.
+ * @return int
+ */
function addTwoNumbers($args) {
$number1 = $args[0];
$number2 = $args[1];
return $number1 + $number2;
}
+ /**
+ * Check user's credentials.
+ *
+ * @since 1.5.0
+ *
+ * @param string $user_login User's username.
+ * @param string $user_pass User's password.
+ * @return bool Whether authentication passed.
+ */
function login_pass_ok($user_login, $user_pass) {
if ( !get_option( 'enable_xmlrpc' ) ) {
$this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this blog. An admin user can enable them at %s'), admin_url('options-writing.php') ) );
return true;
}
+ /**
+ * Sanitize string or array of strings for database.
+ *
+ * @since 1.5.2
+ *
+ * @param string|array $array Sanitize single string or array of strings.
+ * @return string|array Type matches $array and sanitized for the database.
+ */
function escape(&$array) {
global $wpdb;
}
}
+ /**
+ * Retrieve custom fields for post.
+ *
+ * @since 2.5.0
+ *
+ * @param int $post_id Post ID.
+ * @return array Custom fields, if exist.
+ */
function get_custom_fields($post_id) {
$post_id = (int) $post_id;
return $custom_fields;
}
+ /**
+ * Set custom fields for post.
+ *
+ * @since 2.5.0
+ *
+ * @param int $post_id Post ID.
+ * @param array $fields Custom fields.
+ */
function set_custom_fields($post_id, $fields) {
$post_id = (int) $post_id;
}
}
+ /**
+ * Setup blog options property.
+ *
+ * Passes property through 'xmlrpc_blog_options' filter.
+ *
+ * @since 2.6.0
+ */
function initialise_blog_option_info( ) {
global $wp_version;
}
/**
- * WordPress XML-RPC API
- * wp_getUsersBlogs
+ * Retrieve the blogs of the user.
+ *
+ * @since 2.6.0
+ *
+ * @param array $args Method parameters.
+ * @return array
*/
function wp_getUsersBlogs( $args ) {
// If this isn't on WPMU then just use blogger_getUsersBlogs
foreach( $blogs as $blog ) {
// Don't include blogs that aren't hosted at this site
- if( $blog->site_id != 1 )
+ if( $blog->site_id != $current_site->id )
continue;
$blog_id = $blog->userblog_id;
'blogName' => get_option( 'blogname' ),
'xmlrpc' => get_option( 'home' ) . '/xmlrpc.php'
);
+
+ restore_current_blog( );
}
return $struct;
}
/**
- * WordPress XML-RPC API
- * wp_getPage
+ * Retrieve page.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Method parameters.
+ * @return array
*/
function wp_getPage($args) {
$this->escape($args);
}
/**
- * WordPress XML-RPC API
- * wp_getPages
+ * Retrieve Pages.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Method parameters.
+ * @return array
*/
function wp_getPages($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
+ $num_pages = (int) $args[3];
if(!$this->login_pass_ok($username, $password)) {
return($this->error);
do_action('xmlrpc_call', 'wp.getPages');
- // Lookup info on pages.
- $pages = get_pages();
+ $page_limit = 10;
+ if( isset( $num_pages ) ) {
+ $page_limit = $num_pages;
+ }
+
+ $pages = get_posts( "post_type=page&post_status=all&numberposts={$page_limit}" );
$num_pages = count($pages);
// If we have pages, put together their info.
}
/**
- * WordPress XML-RPC API
- * wp_newPage
+ * Create new page.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Method parameters.
+ * @return unknown
*/
function wp_newPage($args) {
// Items not escaped here will be escaped in newPost.
}
/**
- * WordPress XML-RPC API
- * wp_deletePage
+ * Delete page.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Method parameters.
+ * @return bool True, if success.
*/
function wp_deletePage($args) {
$this->escape($args);
}
/**
- * WordPress XML-RPC API
- * wp_editPage
+ * Edit page.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Method parameters.
+ * @return unknown
*/
function wp_editPage($args) {
// Items not escaped here will be escaped in editPost.
}
/**
- * WordPress XML-RPC API
- * wp_getPageList
+ * Retrieve page list.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Method parameters.
+ * @return unknown
*/
function wp_getPageList($args) {
global $wpdb;
}
/**
- * WordPress XML-RPC API
- * wp_getAuthors
+ * Retrieve authors list.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Method parameters.
+ * @return array
*/
function wp_getAuthors($args) {
set_current_user(0, $username);
if(!current_user_can("edit_posts")) {
return(new IXR_Error(401, __("Sorry, you can not edit posts on this blog.")));
- }
+ }
do_action('xmlrpc_call', 'wp.getAuthors');
}
/**
- * WordPress XML-RPC API
- * wp_newCategory
+ * Get list of all tags
+ *
+ * @since 2.7
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
+ function wp_getTags( $args ) {
+ $this->escape( $args );
+
+ $blog_id = (int) $args[0];
+ $username = $args[1];
+ $password = $args[2];
+
+ if( !$this->login_pass_ok( $username, $password ) ) {
+ return $this->error;
+ }
+
+ set_current_user( 0, $username );
+ if( !current_user_can( 'edit_posts' ) ) {
+ return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view tags.' ) );
+ }
+
+ do_action( 'xmlrpc_call', 'wp.getKeywords' );
+
+ $tags = array( );
+
+ if( $all_tags = get_tags( ) ) {
+ foreach( (array) $all_tags as $tag ) {
+ $struct['tag_id'] = $tag->term_id;
+ $struct['name'] = $tag->name;
+ $struct['count'] = $tag->count;
+ $struct['slug'] = $tag->slug;
+ $struct['html_url'] = wp_specialchars( get_tag_link( $tag->term_id ) );
+ $struct['rss_url'] = wp_specialchars( get_tag_feed_link( $tag->term_id ) );
+
+ $tags[] = $struct;
+ }
+ }
+
+ return $tags;
+ }
+
+ /**
+ * Create new category.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Method parameters.
+ * @return int Category ID.
*/
function wp_newCategory($args) {
$this->escape($args);
}
/**
- * WordPress XML-RPC API
- * wp_deleteCategory
+ * Remove category.
+ *
+ * @since 2.5.0
+ *
+ * @param array $args Method parameters.
+ * @return mixed See {@link wp_delete_category()} for return info.
*/
function wp_deleteCategory($args) {
$this->escape($args);
return wp_delete_category( $category_id );
}
-
/**
- * WordPress XML-RPC API
- * wp_suggestCategories
+ * Retrieve category list.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Method parameters.
+ * @return array
*/
function wp_suggestCategories($args) {
$this->escape($args);
return($category_suggestions);
}
+ /**
+ * Retrieve comment.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
+ function wp_getComment($args) {
+ $this->escape($args);
+
+ $blog_id = (int) $args[0];
+ $username = $args[1];
+ $password = $args[2];
+ $comment_id = (int) $args[3];
+
+ if ( !$this->login_pass_ok( $username, $password ) )
+ return $this->error;
+
+ set_current_user( 0, $username );
+ if ( !current_user_can( 'moderate_comments' ) )
+ return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) );
+
+ do_action('xmlrpc_call', 'wp.getComment');
+
+ if ( ! $comment = get_comment($comment_id) )
+ return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
+
+ // Format page date.
+ $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date);
+ $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt);
+
+ if ( 0 == $comment->comment_approved )
+ $comment_status = 'hold';
+ else if ( 'spam' == $comment->comment_approved )
+ $comment_status = 'spam';
+ else if ( 1 == $comment->comment_approved )
+ $comment_status = 'approve';
+ else
+ $comment_status = $comment->comment_approved;
+
+ $link = get_comment_link($comment);
+
+ $comment_struct = array(
+ "date_created_gmt" => new IXR_Date($comment_date_gmt),
+ "user_id" => $comment->user_id,
+ "comment_id" => $comment->comment_ID,
+ "parent" => $comment->comment_parent,
+ "status" => $comment_status,
+ "content" => $comment->comment_content,
+ "link" => $link,
+ "post_id" => $comment->comment_post_ID,
+ "post_title" => get_the_title($comment->comment_post_ID),
+ "author" => $comment->comment_author,
+ "author_url" => $comment->comment_author_url,
+ "author_email" => $comment->comment_author_email,
+ "author_ip" => $comment->comment_author_IP,
+ "type" => $comment->comment_type,
+ );
+
+ return $comment_struct;
+ }
+
+ /**
+ * Retrieve comments.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
+ function wp_getComments($args) {
+ $this->escape($args);
+
+ $blog_id = (int) $args[0];
+ $username = $args[1];
+ $password = $args[2];
+ $struct = $args[3];
+
+ if ( !$this->login_pass_ok($username, $password) )
+ return($this->error);
+
+ set_current_user( 0, $username );
+ if ( !current_user_can( 'moderate_comments' ) )
+ return new IXR_Error( 401, __( 'Sorry, you can not edit comments.' ) );
+
+ do_action('xmlrpc_call', 'wp.getComments');
+
+ if ( isset($struct['status']) )
+ $status = $struct['status'];
+ else
+ $status = '';
+
+ $post_id = '';
+ if ( isset($struct['post_id']) )
+ $post_id = absint($struct['post_id']);
+
+ $offset = 0;
+ if ( isset($struct['offset']) )
+ $offset = absint($struct['offset']);
+
+ $number = 10;
+ if ( isset($struct['number']) )
+ $number = absint($struct['number']);
+
+ $comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
+ $num_comments = count($comments);
+
+ if ( ! $num_comments )
+ return array();
+
+ $comments_struct = array();
+
+ for ( $i = 0; $i < $num_comments; $i++ ) {
+ $comment = wp_xmlrpc_server::wp_getComment(array(
+ $blog_id, $username, $password, $comments[$i]->comment_ID,
+ ));
+ $comments_struct[] = $comment;
+ }
+
+ return $comments_struct;
+ }
+
+ /**
+ * Remove comment.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args Method parameters.
+ * @return mixed {@link wp_delete_comment()}
+ */
+ function wp_deleteComment($args) {
+ $this->escape($args);
+
+ $blog_id = (int) $args[0];
+ $username = $args[1];
+ $password = $args[2];
+ $comment_ID = (int) $args[3];
+
+ if ( !$this->login_pass_ok( $username, $password ) )
+ return $this->error;
+
+ set_current_user( 0, $username );
+ if ( !current_user_can( 'moderate_comments' ) )
+ return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) );
+
+ do_action('xmlrpc_call', 'wp.deleteComment');
+
+ if ( ! get_comment($comment_ID) )
+ return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
+
+ return wp_delete_comment($comment_ID);
+ }
+
+ /**
+ * Edit comment.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args Method parameters.
+ * @return bool True, on success.
+ */
+ function wp_editComment($args) {
+ $this->escape($args);
+
+ $blog_id = (int) $args[0];
+ $username = $args[1];
+ $password = $args[2];
+ $comment_ID = (int) $args[3];
+ $content_struct = $args[4];
+
+ if ( !$this->login_pass_ok( $username, $password ) )
+ return $this->error;
+
+ set_current_user( 0, $username );
+ if ( !current_user_can( 'moderate_comments' ) )
+ return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) );
+
+ do_action('xmlrpc_call', 'wp.editComment');
+
+ if ( ! get_comment($comment_ID) )
+ return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
+
+ if ( isset($content_struct['status']) ) {
+ $statuses = get_comment_statuses();
+ $statuses = array_keys($statuses);
+
+ if ( ! in_array($content_struct['status'], $statuses) )
+ return new IXR_Error( 401, __( 'Invalid comment status.' ) );
+ $comment_approved = $content_struct['status'];
+ }
+
+ // Do some timestamp voodoo
+ if ( !empty( $content_struct['date_created_gmt'] ) ) {
+ $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force
+ $comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
+ $comment_date_gmt = iso8601_to_datetime($dateCreated, GMT);
+ }
+
+ if ( isset($content_struct['content']) )
+ $comment_content = $content_struct['content'];
+
+ if ( isset($content_struct['author']) )
+ $comment_author = $content_struct['author'];
+
+ if ( isset($content_struct['author_url']) )
+ $comment_author_url = $content_struct['author_url'];
+
+ if ( isset($content_struct['author_email']) )
+ $comment_author_email = $content_struct['author_email'];
+
+ // We've got all the data -- post it:
+ $comment = compact('comment_ID', 'comment_content', 'comment_approved', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url');
+
+ $result = wp_update_comment($comment);
+ if ( is_wp_error( $result ) )
+ return new IXR_Error(500, $result->get_error_message());
+
+ if ( !$result )
+ return new IXR_Error(500, __('Sorry, the comment could not be edited. Something wrong happened.'));
+
+ return true;
+ }
+
+ /**
+ * Create new comment.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args Method parameters.
+ * @return mixed {@link wp_new_comment()}
+ */
+ function wp_newComment($args) {
+ global $wpdb;
+
+ $this->escape($args);
+
+ $blog_id = (int) $args[0];
+ $username = $args[1];
+ $password = $args[2];
+ $post = $args[3];
+ $content_struct = $args[4];
+
+ $allow_anon = apply_filters('xmlrpc_allow_anonymous_comments', false);
+
+ if ( !$this->login_pass_ok( $username, $password ) ) {
+ $logged_in = false;
+ if ( $allow_anon && get_option('comment_registration') )
+ return new IXR_Error( 403, __( 'You must be registered to comment' ) );
+ else if ( !$allow_anon )
+ return $this->error;
+ } else {
+ $logged_in = true;
+ set_current_user( 0, $username );
+ }
+
+ if ( is_numeric($post) )
+ $post_id = absint($post);
+ else
+ $post_id = url_to_postid($post);
+
+ if ( ! $post_id )
+ return new IXR_Error( 404, __( 'Invalid post ID.' ) );
+
+ if ( ! get_post($post_id) )
+ return new IXR_Error( 404, __( 'Invalid post ID.' ) );
+
+ $comment['comment_post_ID'] = $post_id;
+
+ if ( $logged_in ) {
+ $user = wp_get_current_user();
+ $comment['comment_author'] = $wpdb->escape( $user->display_name );
+ $comment['comment_author_email'] = $wpdb->escape( $user->user_email );
+ $comment['comment_author_url'] = $wpdb->escape( $user->user_url );
+ $comment['user_ID'] = $user->ID;
+ } else {
+ $comment['comment_author'] = '';
+ if ( isset($content_struct['author']) )
+ $comment['comment_author'] = $content_struct['author'];
+
+ $comment['comment_author_email'] = '';
+ if ( isset($content_struct['author_email']) )
+ $comment['comment_author_email'] = $content_struct['author_email'];
+
+ $comment['comment_author_url'] = '';
+ if ( isset($content_struct['author_url']) )
+ $comment['comment_author_url'] = $content_struct['author_url'];
+
+ $comment['user_ID'] = 0;
+
+ if ( get_option('require_name_email') ) {
+ if ( 6 > strlen($comment['comment_author_email']) || '' == $comment['comment_author'] )
+ return new IXR_Error( 403, __( 'Comment author name and email are required' ) );
+ elseif ( !is_email($comment['comment_author_email']) )
+ return new IXR_Error( 403, __( 'A valid email address is required' ) );
+ }
+ }
+
+ $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0;
+
+ $comment['comment_content'] = $content_struct['content'];
+
+ do_action('xmlrpc_call', 'wp.newComment');
+
+ return wp_new_comment($comment);
+ }
+
+ /**
+ * Retrieve all of the comment status.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
+ function wp_getCommentStatusList($args) {
+ $this->escape( $args );
+
+ $blog_id = (int) $args[0];
+ $username = $args[1];
+ $password = $args[2];
+
+ if ( !$this->login_pass_ok( $username, $password ) )
+ return $this->error;
+
+ set_current_user( 0, $username );
+ if ( !current_user_can( 'moderate_comments' ) )
+ return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) );
+
+ do_action('xmlrpc_call', 'wp.getCommentStatusList');
+
+ return get_comment_statuses( );
+ }
+
+ /**
+ * Retrieve comment count.
+ *
+ * @since 2.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function wp_getCommentCount( $args ) {
$this->escape($args);
);
}
-
+ /**
+ * Retrieve post statuses.
+ *
+ * @since 2.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function wp_getPostStatusList( $args ) {
$this->escape( $args );
return get_post_statuses( );
}
-
+ /**
+ * Retrieve page statuses.
+ *
+ * @since 2.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function wp_getPageStatusList( $args ) {
$this->escape( $args );
return get_page_statuses( );
}
+ /**
+ * Retrieve page templates.
+ *
+ * @since 2.6.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function wp_getPageTemplates( $args ) {
$this->escape( $args );
return $templates;
}
+ /**
+ * Retrieve blog options.
+ *
+ * @since 2.6.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function wp_getOptions( $args ) {
$this->escape( $args );
return $this->_getOptions($options);
}
+ /**
+ * Retrieve blog options value from list.
+ *
+ * @since 2.6.0
+ *
+ * @param array $options Options to retrieve.
+ * @return array
+ */
function _getOptions($options)
{
$data = array( );
return $data;
}
+ /**
+ * Update blog options.
+ *
+ * @since 2.6.0
+ *
+ * @param array $args Method parameters.
+ * @return unknown
+ */
function wp_setOptions( $args ) {
$this->escape( $args );
return $this->_getOptions($option_names);
}
- /* Blogger API functions
+ /* Blogger API functions.
* specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
*/
-
- /* blogger.getUsersBlogs will make more sense once we support multiple blogs */
+ /**
+ * Retrieve blogs that user owns.
+ *
+ * Will make more sense once we support multiple blogs.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function blogger_getUsersBlogs($args) {
$this->escape($args);
return array($struct);
}
-
- /* blogger.getUsersInfo gives your client some info about you, so you don't have to */
+ /**
+ * Retrieve user's data.
+ *
+ * Gives your client some info about you, so you don't have to.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function blogger_getUserInfo($args) {
$this->escape($args);
return $struct;
}
-
- /* blogger.getPost ...gets a post */
+ /**
+ * Retrieve post.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function blogger_getPost($args) {
$this->escape($args);
return $struct;
}
-
- /* blogger.getRecentPosts ...gets recent posts */
+ /**
+ * Retrieve list of recent posts.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function blogger_getRecentPosts($args) {
$this->escape($args);
return $recent_posts;
}
-
- /* blogger.getTemplate returns your blog_filename */
+ /**
+ * Retrieve blog_filename content.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return string
+ */
function blogger_getTemplate($args) {
$this->escape($args);
- $blog_ID = (int) $args[1];
- $user_login = $args[2];
- $user_pass = $args[3];
- $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */
+ $blog_ID = (int) $args[1];
+ $user_login = $args[2];
+ $user_pass = $args[3];
+ $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */
- if (!$this->login_pass_ok($user_login, $user_pass)) {
- return $this->error;
- }
+ if (!$this->login_pass_ok($user_login, $user_pass)) {
+ return $this->error;
+ }
- do_action('xmlrpc_call', 'blogger.getTemplate');
+ do_action('xmlrpc_call', 'blogger.getTemplate');
- set_current_user(0, $user_login);
- if ( !current_user_can('edit_themes') ) {
- return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
- }
+ set_current_user(0, $user_login);
+ if ( !current_user_can('edit_themes') ) {
+ return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
+ }
- /* warning: here we make the assumption that the blog's URL is on the same server */
- $filename = get_option('home') . '/';
- $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
+ /* warning: here we make the assumption that the blog's URL is on the same server */
+ $filename = get_option('home') . '/';
+ $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
- $f = fopen($filename, 'r');
- $content = fread($f, filesize($filename));
- fclose($f);
+ $f = fopen($filename, 'r');
+ $content = fread($f, filesize($filename));
+ fclose($f);
- /* so it is actually editable with a windows/mac client */
- // FIXME: (or delete me) do we really want to cater to bad clients at the expense of good ones by BEEPing up their line breaks? commented. $content = str_replace("\n", "\r\n", $content);
+ /* so it is actually editable with a windows/mac client */
+ // FIXME: (or delete me) do we really want to cater to bad clients at the expense of good ones by BEEPing up their line breaks? commented. $content = str_replace("\n", "\r\n", $content);
- return $content;
+ return $content;
}
-
- /* blogger.setTemplate updates the content of blog_filename */
+ /**
+ * Updates the content of blog_filename.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return bool True when done.
+ */
function blogger_setTemplate($args) {
$this->escape($args);
return true;
}
-
- /* blogger.newPost ...creates a new post */
+ /**
+ * Create new post.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return int
+ */
function blogger_newPost($args) {
$this->escape($args);
return $post_ID;
}
- /* blogger.editPost ...edits a post */
+ /**
+ * Edit a post.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return bool true when done.
+ */
function blogger_editPost($args) {
$this->escape($args);
$actual_post = wp_get_single_post($post_ID,ARRAY_A);
- if (!$actual_post) {
+ if (!$actual_post || $actual_post['post_type'] != 'post') {
return new IXR_Error(404, __('Sorry, no such post.'));
}
return true;
}
-
- /* blogger.deletePost ...deletes a post */
+ /**
+ * Remove a post.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return bool True when post is deleted.
+ */
function blogger_deletePost($args) {
$this->escape($args);
$actual_post = wp_get_single_post($post_ID,ARRAY_A);
- if (!$actual_post) {
+ if (!$actual_post || $actual_post['post_type'] != 'post') {
return new IXR_Error(404, __('Sorry, no such post.'));
}
return true;
}
-
-
/* MetaWeblog API functions
* specs on wherever Dave Winer wants them to be
*/
- /* metaweblog.newPost creates a post */
+ /**
+ * Create a new post.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return int
+ */
function mw_newPost($args) {
$this->escape($args);
$this->set_custom_fields($post_ID, $content_struct['custom_fields']);
}
- // Handle enclosures
- $enclosure = $content_struct['enclosure'];
- if( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
+ // Handle enclosures
+ $enclosure = $content_struct['enclosure'];
+ if( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
add_post_meta( $post_ID, 'enclosure', $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] );
- }
+ }
$this->attach_uploads( $post_ID, $post_content );
return strval($post_ID);
}
+ /**
+ * Attach upload to a post.
+ *
+ * @since 2.1.0
+ *
+ * @param int $post_ID Post ID.
+ * @param string $post_content Post Content for attachment.
+ */
function attach_uploads( $post_ID, $post_content ) {
global $wpdb;
}
}
- /* metaweblog.editPost ...edits a post */
+ /**
+ * Edit a post.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return bool True on success.
+ */
function mw_editPost($args) {
$this->escape($args);
$this->set_custom_fields($post_ID, $content_struct['custom_fields']);
}
- // Handle enclosures
- $enclosure = $content_struct['enclosure'];
- if( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
+ // Handle enclosures
+ $enclosure = $content_struct['enclosure'];
+ if( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
add_post_meta( $post_ID, 'enclosure', $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] );
- }
+ }
$this->attach_uploads( $ID, $post_content );
return true;
}
-
- /* metaweblog.getPost ...returns a post */
+ /**
+ * Retrieve post.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function mw_getPost($args) {
$this->escape($args);
$postdata['post_status'] = 'publish';
}
+ $enclosure = array();
+ foreach ( (array) get_post_custom($post_ID) as $key => $val) {
+ if ($key == 'enclosure') {
+ foreach ( (array) $val as $enc ) {
+ $encdata = split("\n", $enc);
+ $enclosure['url'] = trim(htmlspecialchars($encdata[0]));
+ $enclosure['length'] = trim($encdata[1]);
+ $enclosure['type'] = trim($encdata[2]);
+ break 2;
+ }
+ }
+ }
+
$resp = array(
'dateCreated' => new IXR_Date($post_date),
'userid' => $postdata['post_author'],
'custom_fields' => $this->get_custom_fields($post_ID)
);
+ if (!empty($enclosure)) $resp['enclosure'] = $enclosure;
+
return $resp;
} else {
return new IXR_Error(404, __('Sorry, no such post.'));
}
}
-
- /* metaweblog.getRecentPosts ...returns recent posts */
+ /**
+ * Retrieve list of recent posts.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function mw_getRecentPosts($args) {
$this->escape($args);
$posts_list = wp_get_recent_posts($num_posts);
if (!$posts_list) {
- $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.'));
- return $this->error;
+ return array( );
}
set_current_user( 0, $user_login );
'title' => $entry['post_title'],
'link' => $link,
'permaLink' => $link,
-// commented out because no other tool seems to use this
-// 'content' => $entry['post_content'],
+ // commented out because no other tool seems to use this
+ // 'content' => $entry['post_content'],
'categories' => $categories,
'mt_excerpt' => $entry['post_excerpt'],
'mt_text_more' => $post['extended'],
return $recent_posts;
}
-
- /* metaweblog.getCategories ...returns the list of categories on a given blog */
+ /**
+ * Retrieve the list of categories on a given blog.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function mw_getCategories($args) {
$this->escape($args);
$struct['categoryId'] = $cat->term_id;
$struct['parentId'] = $cat->parent;
$struct['description'] = $cat->name;
+ $struct['categoryDescription'] = $cat->description;
$struct['categoryName'] = $cat->name;
$struct['htmlUrl'] = wp_specialchars(get_category_link($cat->term_id));
- $struct['rssUrl'] = wp_specialchars(get_category_rss_link(false, $cat->term_id, $cat->name));
+ $struct['rssUrl'] = wp_specialchars(get_category_feed_link($cat->term_id, 'rss2'));
$categories_struct[] = $struct;
}
return $categories_struct;
}
-
- /* metaweblog.newMediaObject uploads a file, following your settings */
+ /**
+ * Uploads a file, following your settings.
+ *
+ * Adapted from a patch by Johann Richard.
+ *
+ * @link http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function mw_newMediaObject($args) {
- // adapted from a patch by Johann Richard
- // http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/
-
global $wpdb;
$blog_ID = (int) $args[0];
return apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type ) );
}
-
/* MovableType API functions
* specs on http://www.movabletype.org/docs/mtmanual_programmatic.html
*/
- /* mt.getRecentPostTitles ...returns recent posts' titles */
+ /**
+ * Retrieve the post titles of recent posts.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function mt_getRecentPostTitles($args) {
$this->escape($args);
return $recent_posts;
}
-
- /* mt.getCategoryList ...returns the list of categories on a given blog */
+ /**
+ * Retrieve list of all categories on blog.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function mt_getCategoryList($args) {
$this->escape($args);
return $categories_struct;
}
-
- /* mt.getPostCategories ...returns a post's categories */
+ /**
+ * Retrieve post categories.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function mt_getPostCategories($args) {
$this->escape($args);
return $categories;
}
-
- /* mt.setPostCategories ...sets a post's categories */
+ /**
+ * Sets categories for a post.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return bool True on success.
+ */
function mt_setPostCategories($args) {
$this->escape($args);
return true;
}
-
- /* mt.supportedMethods ...returns an array of methods supported by this server */
+ /**
+ * Retrieve an array of methods supported by this server.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function mt_supportedMethods($args) {
do_action('xmlrpc_call', 'mt.supportedMethods');
return $supported_methods;
}
-
- /* mt.supportedTextFilters ...returns an empty array because we don't
- support per-post text filters yet */
+ /**
+ * Retrieve an empty array because we don't support per-post text filters.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ */
function mt_supportedTextFilters($args) {
do_action('xmlrpc_call', 'mt.supportedTextFilters');
return apply_filters('xmlrpc_text_filters', array());
}
-
- /* mt.getTrackbackPings ...returns trackbacks sent to a given post */
+ /**
+ * Retrieve trackbacks sent to a given post.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return mixed
+ */
function mt_getTrackbackPings($args) {
global $wpdb;
return $trackback_pings;
}
-
- /* mt.publishPost ...sets a post's publish status to 'publish' */
+ /**
+ * Sets a post's publish status to 'publish'.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return int
+ */
function mt_publishPost($args) {
$this->escape($args);
return $result;
}
-
-
/* PingBack functions
* specs on www.hixie.ch/specs/pingback/pingback
*/
- /* pingback.ping gets a pingback and registers it */
+ /**
+ * Retrieves a pingback and registers it.
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function pingback_ping($args) {
global $wpdb;
return new IXR_Error(0, __('The source URL and the target URL cannot both point to the same resource.'));
// Check if pings are on
- if ( 'closed' == $post->ping_status )
+ if ( !pings_open($post) )
return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.'));
// Let's check that the remote site didn't already pingback this entry
return sprintf(__('Pingback from %1$s to %2$s registered. Keep the web talking! :-)'), $pagelinkedfrom, $pagelinkedto);
}
-
- /* pingback.extensions.getPingbacks returns an array of URLs
- that pingbacked the given URL
- specs on http://www.aquarionics.com/misc/archives/blogite/0198.html */
+ /**
+ * Retrieve array of URLs that pingbacked the given URL.
+ *
+ * Specs on http://www.aquarionics.com/misc/archives/blogite/0198.html
+ *
+ * @since 1.5.0
+ *
+ * @param array $args Method parameters.
+ * @return array
+ */
function pingback_extensions_getPingbacks($args) {
global $wpdb;
}
}
-
$wp_xmlrpc_server = new wp_xmlrpc_server();
?>