Ticket #9674: 9674.6.diff
File 9674.6.diff, 58.2 KB (added by , 15 years ago) |
---|
-
wp-includes/taxonomy.php
180 180 $wp->add_query_var($args['query_var']); 181 181 } 182 182 183 if ( false !== $args['rewrite'] && !empty($wp_rewrite) ) {183 if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) { 184 184 if ( !is_array($args['rewrite']) ) 185 185 $args['rewrite'] = array(); 186 186 if ( !isset($args['rewrite']['slug']) ) 187 187 $args['rewrite']['slug'] = sanitize_title_with_dashes($taxonomy); 188 188 $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=$term"); 189 $wp_rewrite->add_permastruct($taxonomy, " {$args['rewrite']['slug']}/%$taxonomy%");189 $wp_rewrite->add_permastruct($taxonomy, "/{$args['rewrite']['slug']}/%$taxonomy%"); 190 190 } 191 191 192 192 $args['name'] = $taxonomy; 193 $args['object_type'] = $object_type;193 $args['object_type'] = (array) $object_type; 194 194 $wp_taxonomies[$taxonomy] = (object) $args; 195 195 } 196 196 197 /** 198 * Add an already registered taxonomy to a post type. 199 * 200 * @package WordPress 201 * @subpackage Taxonomy 202 * @since 2.9.0 203 * @uses $wp_taxonomies Modifies taxonomy object 204 * 205 * @param string $taxonomy Name of taxonomy object 206 * @param array|string $object_type Name of the post type 207 * @return bool True if successful, false if not 208 */ 209 function register_taxonomy_for_post_type( $taxonomy, $post_type) { 210 global $wp_taxonomies; 211 212 if ( !isset($wp_taxonomies[$taxonomy]) ) 213 return false; 214 215 if ( ! get_post_type_object($post_type) ) 216 return false; 217 218 $wp_taxonomies[$taxonomy]->object_type[] = $post_type; 219 220 return true; 221 } 222 197 223 // 198 224 // Term API 199 225 // … … 2213 2239 $slug = $term->slug; 2214 2240 2215 2241 if ( empty($termlink) ) { 2216 $file = get_option('home') . '/';2242 $file = trailingslashit(get_option( 'home' )); 2217 2243 $t = get_taxonomy($taxonomy); 2218 2244 if ( $t->query_var ) 2219 2245 $termlink = "$file?$t->query_var=$slug"; -
wp-includes/post.php
15 15 * Creates the initial post types when 'init' action is fired. 16 16 */ 17 17 function create_initial_post_types() { 18 register_post_type( 'post', array(' exclude_from_search' => false) );19 register_post_type( 'page', array(' exclude_from_search' => false) );20 register_post_type( 'attachment', array(' exclude_from_search' => false) );21 register_post_type( 'revision', array(' exclude_from_search' => true) );18 register_post_type( 'post', array('label' => __('Posts'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false) ); 19 register_post_type( 'page', array('label' => __('Pages'),'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'page.php?post=%d', 'capability_type' => 'page', 'hierarchical' => true) ); 20 register_post_type( 'attachment', array('label' => __('Media'), 'exclude_from_search' => false, '_builtin' => true, '_edit_link' => 'media.php?attachment_id=%d', 'capability_type' => 'post', 'hierarchical' => false) ); 21 register_post_type( 'revision', array('label' => __('Revisions'),'exclude_from_search' => true, '_builtin' => true, '_edit_link' => 'revision.php?revision=%d', 'capability_type' => 'post', 'hierarchical' => false) ); 22 22 } 23 23 add_action( 'init', 'create_initial_post_types', 0 ); // highest priority 24 24 … … 425 425 } 426 426 427 427 /** 428 * Retrieve a post type object by name 429 * 430 * @package WordPress 431 * @subpackage Post 432 * @since 2.9.0 433 * @uses $wp_post_types 434 * @see register_post_type 435 * @see get_post_types 436 * 437 * @param string $post_type The name of a registered post type 438 * @return object A post type object 439 */ 440 function get_post_type_object( $post_type ) { 441 global $wp_post_types; 442 443 if ( empty($wp_post_types[$post_type]) ) 444 return null; 445 446 return $wp_post_types[$post_type]; 447 } 448 449 /** 428 450 * Get a list of all registered post type objects. 429 451 * 430 452 * @package WordPress … … 474 496 * 475 497 * Optional $args contents: 476 498 * 499 * label - A descriptibe name for the post type marked for translation. Defaults to $post_type. 500 * public - Whether posts of this type should be shown in the admin UI. Defaults to true. 477 501 * exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true. 502 * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none. 503 * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". 504 * hierarchical - Whether the post type is hierarchical. Defaults to false. 478 505 * 479 506 * @package WordPress 480 507 * @subpackage Post … … 490 517 if (!is_array($wp_post_types)) 491 518 $wp_post_types = array(); 492 519 493 $defaults = array('exclude_from_search' => true); 520 // Args prefixed with an underscore are reserved for internal use. 521 $defaults = array('label' => false, 'exclude_from_search' => true, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false); 494 522 $args = wp_parse_args($args, $defaults); 523 $args = (object) $args; 495 524 496 525 $post_type = sanitize_user($post_type, true); 497 $args['name'] = $post_type; 498 $wp_post_types[$post_type] = (object) $args; 526 $args->name = $post_type; 527 528 if ( false === $args->label ) 529 $args->label = $post_type; 530 531 if ( empty($args->capability_type) ) { 532 $args->edit_cap = ''; 533 $args->read_cap = ''; 534 } else { 535 $args->edit_cap = 'edit_' . $args->capability_type; 536 $args->read_cap = 'read_' . $args->capability_type; 537 } 538 539 if ( !$args->_builtin && $args->public ) 540 $args->_show = true; 541 542 $wp_post_types[$post_type] = $args; 543 544 return $args; 499 545 } 500 546 501 547 /** … … 1000 1046 1001 1047 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 1002 1048 if ( 'readable' == $perm && is_user_logged_in() ) { 1003 if ( !current_user_can("read_private_{$type}s") ) { 1049 $post_type_object = get_post_type_object($type); 1050 if ( !current_user_can("read_private_{$post_type_object->capability_type}s") ) { 1004 1051 $cache_key .= '_' . $perm . '_' . $user->ID; 1005 1052 $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))"; 1006 1053 } -
wp-includes/query.php
2079 2079 2080 2080 if ( is_array($post_type) ) 2081 2081 $post_type_cap = 'multiple_post_type'; 2082 else 2083 $post_type_cap = $post_type; 2082 else { 2083 $post_type_object = get_post_type_object ( $post_type ); 2084 if ( !empty($post_type_object) ) 2085 $post_type_cap = $post_type_object->capability_type; 2086 else 2087 $post_type_cap = $post_type; 2088 } 2084 2089 2085 2090 $exclude_post_types = ''; 2086 2091 foreach ( get_post_types( array('exclude_from_search' => true) ) as $_wp_post_type ) -
wp-includes/link-template.php
675 675 return; 676 676 677 677 if ( 'display' == $context ) 678 $action = ' action=edit&';678 $action = '&action=edit'; 679 679 else 680 $action = ' action=edit&';680 $action = '&action=edit'; 681 681 682 switch ( $post->post_type ) : 683 case 'page' : 684 if ( !current_user_can( 'edit_page', $post->ID ) ) 685 return; 686 $file = 'page'; 687 $var = 'post'; 688 break; 689 case 'attachment' : 690 if ( !current_user_can( 'edit_post', $post->ID ) ) 691 return; 692 $file = 'media'; 693 $var = 'attachment_id'; 694 break; 695 case 'revision' : 696 if ( !current_user_can( 'edit_post', $post->ID ) ) 697 return; 698 $file = 'revision'; 699 $var = 'revision'; 700 $action = ''; 701 break; 702 default : 703 if ( !current_user_can( 'edit_post', $post->ID ) ) 704 return apply_filters( 'get_edit_post_link', '', $post->ID, $context );; 705 $file = 'post'; 706 $var = 'post'; 707 break; 708 endswitch; 682 $post_type_object = get_post_type_object( $post->post_type ); 709 683 710 return apply_filters( 'get_edit_post_link', admin_url("$file.php?{$action}$var=$post->ID"), $post->ID, $context ); 684 if ( !$post_type_object ) 685 return; 686 687 if ( !current_user_can( $post_type_object->edit_cap, $post->ID ) ) 688 return; 689 690 return apply_filters( 'get_edit_post_link', admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), $post->ID, $context ); 711 691 } 712 692 713 693 /** -
wp-includes/capabilities.php
774 774 $author_data = get_userdata( $user_id ); 775 775 //echo "post ID: {$args[0]}<br />"; 776 776 $post = get_post( $args[0] ); 777 if ( 'page' == $post->post_type ) { 778 $args = array_merge( array( 'delete_page', $user_id ), $args ); 777 $post_type = get_post_type_object( $post->post_type ); 778 if ( $post_type && 'post' != $post_type->capability_type ) { 779 $args = array_merge( array( 'delete_' . $post_type->capability_type, $user_id ), $args ); 779 780 return call_user_func_array( 'map_meta_cap', $args ); 780 781 } 781 782 … … 842 843 $author_data = get_userdata( $user_id ); 843 844 //echo "post ID: {$args[0]}<br />"; 844 845 $post = get_post( $args[0] ); 845 if ( 'page' == $post->post_type ) { 846 $args = array_merge( array( 'edit_page', $user_id ), $args ); 846 $post_type = get_post_type_object( $post->post_type ); 847 if ( $post_type && 'post' != $post_type->capability_type ) { 848 $args = array_merge( array( 'edit_' . $post_type->capability_type, $user_id ), $args ); 847 849 return call_user_func_array( 'map_meta_cap', $args ); 848 850 } 849 851 $post_author_data = get_userdata( $post->post_author ); … … 900 902 break; 901 903 case 'read_post': 902 904 $post = get_post( $args[0] ); 903 if ( 'page' == $post->post_type ) { 904 $args = array_merge( array( 'read_page', $user_id ), $args ); 905 $post_type = get_post_type_object( $post->post_type ); 906 if ( $post_type && 'post' != $post_type->capability_type ) { 907 $args = array_merge( array( 'read_' . $post_type->capability_type, $user_id ), $args ); 905 908 return call_user_func_array( 'map_meta_cap', $args ); 906 909 } 907 910 -
wp-admin/menu-header.php
45 45 if ( !empty($submenu[$item[2]]) ) 46 46 $class[] = 'wp-has-submenu'; 47 47 48 if ( ( $parent_file && $item[2] == $parent_file ) || strcmp($self, $item[2]) == 0) {48 if ( ( $parent_file && $item[2] == $parent_file ) || ( false === strpos($parent_file, '?') && strcmp($self, $item[2]) == 0 ) ) { 49 49 if ( !empty($submenu[$item[2]]) ) 50 50 $class[] = 'wp-has-current-submenu wp-menu-open'; 51 51 else -
wp-admin/admin-ajax.php
1126 1126 if ( 'page' == $_POST['post_type'] ) { 1127 1127 $post[] = get_post($_POST['post_ID']); 1128 1128 page_rows($post); 1129 } elseif ( 'post' == $_POST['post_type'] ) {1129 } elseif ( 'post' == $_POST['post_type'] || in_array($_POST['post_type'], get_post_types( array('_show' => true) ) ) ) { 1130 1130 $mode = $_POST['post_view']; 1131 1131 $post[] = get_post($_POST['post_ID']); 1132 1132 post_rows($post); -
wp-admin/post-new.php
8 8 9 9 /** Load WordPress Administration Bootstrap */ 10 10 require_once('admin.php'); 11 $title = __('Add New Post'); 12 $parent_file = 'edit.php'; 11 12 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) ) 13 $post_type = $_GET['post_type']; 14 else 15 $post_type = 'post'; 16 17 if ( 'post' != $post_type ) { 18 $parent_file = "edit.php?post_type=$post_type"; 19 $submenu_file = "post-new.php?post_type=$post_type"; 20 } else { 21 $parent_file = 'edit.php'; 22 $submenu_file = 'post-new.php'; 23 } 24 25 $post_type_object = get_post_type_object($post_type); 26 27 $title = sprintf(__('Add New %s'), $post_type_object->label); 28 13 29 $editing = true; 14 30 wp_enqueue_script('autosave'); 15 31 wp_enqueue_script('post'); … … 34 50 35 51 // Show post form. 36 52 $post = get_default_post_to_edit(); 53 $post->post_type = $post_type; 37 54 include('edit-form-advanced.php'); 38 55 39 56 include('admin-footer.php'); -
wp-admin/includes/plugin.php
745 745 $parent = $_wp_real_parent_file[$parent]; 746 746 return $parent; 747 747 } 748 /* 748 749 /* 749 750 if ( !empty ( $parent_file ) ) { 750 751 if ( isset( $_wp_real_parent_file[$parent_file] ) ) 751 752 $parent_file = $_wp_real_parent_file[$parent_file]; 752 753 753 754 return $parent_file; 754 755 } 755 */756 */ 756 757 757 758 if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) { 758 759 foreach ( (array)$menu as $parent_menu ) { … … 782 783 foreach ( $submenu[$parent] as $submenu_array ) { 783 784 if ( isset( $_wp_real_parent_file[$parent] ) ) 784 785 $parent = $_wp_real_parent_file[$parent]; 785 if ( $submenu_array[2] == $pagenow ) {786 if ( $submenu_array[2] == $pagenow && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) { 786 787 $parent_file = $parent; 787 788 return $parent; 788 789 } else -
wp-admin/includes/post.php
826 826 $orderby = 'date'; 827 827 } 828 828 829 $post_type_q = 'post_type=post'; 830 831 if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types( array('_show' => true) ) ) ) 832 $post_type_q = 'post_type=' . $q['post_type']; 833 829 834 $posts_per_page = get_user_option('edit_per_page'); 830 835 if ( empty($posts_per_page) ) 831 836 $posts_per_page = 15; 832 837 $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page); 833 838 834 wp(" post_type=post&$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby");839 wp("$post_type_q$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby"); 835 840 836 841 return array($post_stati, $avail_post_stati); 837 842 } -
wp-admin/includes/meta-boxes.php
13 13 global $action; 14 14 15 15 $post_type = $post->post_type; 16 $can_publish = current_user_can("publish_${post_type}s"); 16 $post_type_object = get_post_type_object($post_type); 17 $type_cap = $post_type_object->capability_type; 18 $can_publish = current_user_can("publish_${type_cap}s"); 17 19 ?> 18 20 <div class="submitbox" id="submitpost"> 19 21 … … 184 186 <?php do_action('post_submitbox_start'); ?> 185 187 <div id="delete-action"> 186 188 <?php 187 if ( current_user_can("delete_${ post_type}", $post->ID) ) { ?>189 if ( current_user_can("delete_${type_cap}", $post->ID) ) { ?> 188 190 <?php $delete_url = add_query_arg( array('action'=>'trash', 'post'=>$post->ID) ); ?> 189 191 <a class="submitdelete deletion<?php if ( 'edit' != $action ) { echo " hidden"; } ?>" href="<?php echo wp_nonce_url($delete_url, "trash-${post_type}_" . $post->ID); ?>"><?php _e('Move to Trash'); ?></a> 190 192 <?php } ?> … … 275 277 276 278 <div id="categories-all" class="tabs-panel"> 277 279 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 278 <?php wp_category_checklist($post->ID, false, false, $popular_ids ) ?>280 <?php wp_category_checklist($post->ID, false, false, $popular_ids, null, false) ?> 279 281 </ul> 280 282 </div> 281 283 … … 291 293 </div> 292 294 <?php 293 295 endif; 294 295 296 } 296 297 297 298 -
wp-admin/includes/template.php
3460 3460 } 3461 3461 3462 3462 function screen_meta($screen) { 3463 global $wp_meta_boxes, $_wp_contextual_help ;3463 global $wp_meta_boxes, $_wp_contextual_help, $typenow; 3464 3464 3465 3465 $screen = str_replace('.php', '', $screen); 3466 3466 $screen = str_replace('-new', '', $screen); … … 3470 3470 $column_screens = get_column_headers($screen); 3471 3471 $meta_screens = array('index' => 'dashboard'); 3472 3472 3473 // Give post_type pages their own screen 3474 if ( 'post' == $screen ) { 3475 if ( !empty($typenow) ) 3476 $screen = $typenow; 3477 } 3478 3473 3479 if ( isset($meta_screens[$screen]) ) 3474 3480 $screen = $meta_screens[$screen]; 3475 3481 $show_screen = false; … … 3653 3659 global $screen_layout_columns; 3654 3660 3655 3661 $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2); 3662 3663 // Add custom post types 3664 foreach ( get_post_types( array('_show' => true) ) as $post_type ) 3665 $columns[$post_type] = 2; 3666 3656 3667 $columns = apply_filters('screen_layout_columns', $columns, $screen); 3657 3668 3658 3669 if ( !isset($columns[$screen]) ) { … … 3726 3737 global $parent_file, $hook_suffix; 3727 3738 3728 3739 if ( empty($name) ) { 3729 if ( isset($parent_file) && !empty($parent_file) ) 3730 $name = substr($parent_file, 0, -4); 3740 if ( isset($parent_file) && !empty($parent_file) ) { 3741 $name = $parent_file; 3742 if ( false !== $pos = strpos($name, '?post_type=') ) 3743 $name = substr($name, 0, $pos); 3744 $name = substr($name, 0, -4); 3745 } 3731 3746 else 3732 3747 $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix); 3733 3748 } -
wp-admin/post.php
120 120 } 121 121 $post_ID = $p = (int) $_GET['post']; 122 122 $post = get_post($post_ID); 123 $post_type_object = get_post_type_object($post->post_type); 123 124 124 125 if ( empty($post->ID) ) 125 126 wp_die( __('You attempted to edit a post that doesn’t exist. Perhaps it was deleted?') ); … … 130 131 if ( 'trash' == $post->post_status ) 131 132 wp_die( __('You can’t edit this post because it is in the Trash. Please restore it and try again.') ); 132 133 133 if ( 'post' != $post->post_type ) { 134 if ( null == $post_type_object ) 135 wp_die( __('Unknown post type.') ); 136 137 if ( 'post' != $post->post_type && $post_type_object->_builtin ) { 134 138 wp_redirect( get_edit_post_link( $post->ID, 'url' ) ); 135 139 exit(); 136 140 } 137 141 142 $post_type = $post->post_type; 143 if ( 'post' != $post_type ) { 144 $parent_file = "edit.php?post_type=$post_type"; 145 $submenu_file = "edit.php?post_type=$post_type"; 146 } 147 138 148 wp_enqueue_script('post'); 139 149 if ( user_can_richedit() ) 140 150 wp_enqueue_script('editor'); … … 151 161 wp_enqueue_script('autosave'); 152 162 } 153 163 154 $title = __('Edit Post');164 $title = sprintf(__('Edit %s'), $post_type_object->label); 155 165 $post = get_post_to_edit($post_ID); 156 166 157 167 include('edit-form-advanced.php'); -
wp-admin/js/post.dev.js
231 231 var catAddAfter, stamp, visibility, sticky = '', post = 'post' == pagenow || 'post-new' == pagenow, page = 'page' == pagenow || 'page-new' == pagenow; 232 232 233 233 // postboxes 234 if ( post ) 235 postboxes.add_postbox_toggles('post'); 236 else if ( page ) 234 if ( post ) { 235 type = 'post'; 236 if ( typenow ) 237 type = typenow; 238 postboxes.add_postbox_toggles(type); 239 } else if ( page ) { 237 240 postboxes.add_postbox_toggles('page'); 241 } 238 242 239 243 // multi-taxonomies 240 244 if ( $('#tagsdiv-post_tag').length ) { -
wp-admin/js/post.js
1 var tagBox,commentsBox,editPermalink,makeSlugeditClickable,WPSetThumbnailHTML,WPSetThumbnailID,WPRemoveThumbnail;function array_unique_noempty( b){var c=[];jQuery.each(b,function(a,d){d=jQuery.trim(d);if(d&&jQuery.inArray(d,c)==-1){c.push(d)}});return c}(function(a){tagBox={clean:function(b){return b.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,"")},parseTags:function(e){var h=e.id,b=h.split("-check-num-")[1],d=a(e).closest(".tagsdiv"),g=d.find(".the-tags"),c=g.val().split(","),f=[];delete c[b];a.each(c,function(i,j){j=a.trim(j);if(j){f.push(j)}});g.val(this.clean(f.join(",")));this.quickClicks(d);return false},quickClicks:function(c){var e=a(".the-tags",c),d=a(".tagchecklist",c),b;if(!e.length){return}b=e.val().split(",");d.empty();a.each(b,function(h,i){var f,g,j=a(c).attr("id");i=a.trim(i);if(!i.match(/^\s+$/)&&""!=i){g=j+"-check-num-"+h;f='<span><a id="'+g+'" class="ntdelbutton">X</a> '+i+"</span> ";d.append(f);a("#"+g).click(function(){tagBox.parseTags(this)})}})},flushTags:function(e,b,g){b=b||false;var i,c=a(".the-tags",e),h=a("input.newtag",e),d;i=b?a(b).text():h.val();tagsval=c.val();d=tagsval?tagsval+","+i:i;d=this.clean(d);d=array_unique_noempty(d.split(",")).join(",");c.val(d);this.quickClicks(e);if(!b){h.val("")}if("undefined"==g){h.focus()}return false},get:function(c){var b=c.substr(c.indexOf("-")+1);a.post(ajaxurl,{action:"get-tagcloud",tax:b},function(e,d){if(0==e||"success"!=d){e=wpAjax.broken}e=a('<p id="tagcloud-'+b+'" class="the-tagcloud">'+e+"</p>");a("a",e).click(function(){tagBox.flushTags(a(this).closest(".inside").children(".tagsdiv"),this);return false});a("#"+c).after(e)})},init:function(){var b=this,c=a("div.ajaxtag");a(".tagsdiv").each(function(){tagBox.quickClicks(this)});a("input.tagadd",c).click(function(){b.flushTags(a(this).closest(".tagsdiv"))});a("div.taghint",c).click(function(){a(this).css("visibility","hidden").siblings(".newtag").focus()});a("input.newtag",c).blur(function(){if(this.value==""){a(this).siblings(".taghint").css("visibility","")}}).focus(function(){a(this).siblings(".taghint").css("visibility","hidden")}).keyup(function(d){if(13==d.which){tagBox.flushTags(a(this).closest(".tagsdiv"));return false}}).keypress(function(d){if(13==d.which){d.preventDefault();return false}}).each(function(){var d=a(this).closest("div.tagsdiv").attr("id");a(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+d,{delay:500,minchars:2,multiple:true,multipleSep:", "})});a("#post").submit(function(){a("div.tagsdiv").each(function(){tagBox.flushTags(this,false,1)})});a("a.tagcloud-link").click(function(){tagBox.get(a(this).attr("id"));a(this).unbind().click(function(){a(this).siblings(".the-tagcloud").toggle();return false});return false})}};commentsBox={st:0,get:function(d,c){var b=this.st,e;if(!c){c=20}this.st+=c;this.total=d;a("#commentsdiv img.waiting").show();e={action:"get-comments",mode:"single",_ajax_nonce:a("#add_comment_nonce").val(),post_ID:a("#post_ID").val(),start:b,num:c};a.post(ajaxurl,e,function(f){f=wpAjax.parseAjaxResponse(f);a("#commentsdiv .widefat").show();a("#commentsdiv img.waiting").hide();if("object"==typeof f&&f.responses[0]){a("#the-comment-list").append(f.responses[0].data);theList=theExtraList=null;a("a[className*=':']").unbind();setCommentsList();if(commentsBox.st>commentsBox.total){a("#show-comments").hide()}else{a("#show-comments").html(postL10n.showcomm)}return}else{if(1==f){a("#show-comments").parent().html(postL10n.endcomm);return}}a("#the-comment-list").append('<tr><td colspan="2">'+wpAjax.broken+"</td></tr>")});return false}};WPSetThumbnailHTML=function(b){a(".inside","#postthumbnaildiv").html(b)};WPSetThumbnailID=function(c){var b=a("input[value=_thumbnail_id]","#list-table");if(b.size()>0){a("#meta\\["+b.attr("id").match(/[0-9]+/)+"\\]\\[value\\]").text(c)}};WPRemoveThumbnail=function(){a.post(ajaxurl,{action:"set-post-thumbnail",post_id:a("#post_ID").val(),thumbnail_id:-1,cookie:encodeURIComponent(document.cookie)},function(b){if(b=="0"){alert(setPostThumbnailL10n.error)}else{WPSetThumbnailHTML(b)}})}})(jQuery);jQuery(document).ready(function(f){var d,a,b,h="",i="post"==pagenow||"post-new"==pagenow,g="page"==pagenow||"page-new"==pagenow;if(i){postboxes.add_postbox_toggles("post")}else{if(g){postboxes.add_postbox_toggles("page")}}if(f("#tagsdiv-post_tag").length){tagBox.init()}else{f("#side-sortables, #normal-sortables, #advanced-sortables").children("div.postbox").each(function(){if(this.id.indexOf("tagsdiv-")===0){tagBox.init();return false}})}if(f("#categorydiv").length){f("a","#category-tabs").click(function(){var j=f(this).attr("href");f(this).parent().addClass("tabs").siblings("li").removeClass("tabs");f("#category-tabs").siblings(".tabs-panel").hide();f(j).show();if("#categories-all"==j){deleteUserSetting("cats")}else{setUserSetting("cats","pop")}return false});if(getUserSetting("cats")){f('a[href="#categories-pop"]',"#category-tabs").click()}f("#newcat").one("focus",function(){f(this).val("").removeClass("form-input-tip")});f("#category-add-sumbit").click(function(){f("#newcat").focus()});catAddBefore=function(j){if(!f("#newcat").val()){return false}j.data+="&"+f(":checked","#categorychecklist").serialize();return j};d=function(m,l){var k,j=f("#newcat_parent");if("undefined"!=l.parsed.responses[0]&&(k=l.parsed.responses[0].supplemental.newcat_parent)){j.before(k);j.remove()}};f("#categorychecklist").wpList({alt:"",response:"category-ajax-response",addBefore:catAddBefore,addAfter:d});f("#category-add-toggle").click(function(){f("#category-adder").toggleClass("wp-hidden-children");f('a[href="#categories-all"]',"#category-tabs").click();return false});f("#categorychecklist").children("li.popular-category").add(f("#categorychecklist-pop").children()).find(":checkbox").live("click",function(){var j=f(this),l=j.is(":checked"),k=j.val();f("#in-category-"+k+", #in-popular-category-"+k).attr("checked",l)})}if(f("#postcustom").length){f("#the-list").wpList({addAfter:function(j,k){f("table#list-table").show();if(typeof(autosave_update_post_ID)!="undefined"){autosave_update_post_ID(k.parsed.responses[0].supplemental.postid)}},addBefore:function(j){j.data+="&post_id="+f("#post_ID").val();return j}})}if(f("#submitdiv").length){a=f("#timestamp").html();b=f("#post-visibility-display").html();function e(){var j=f("#post-visibility-select");if(f("input:radio:checked",j).val()!="public"){f("#sticky").attr("checked",false);f("#sticky-span").hide()}else{f("#sticky-span").show()}if(f("input:radio:checked",j).val()!="password"){f("#password-span").hide()}else{f("#password-span").show()}}function c(){var j,m,k,o,l=f("#post_status"),n=f("option[value=publish]",l);j=new Date(f("#aa").val(),f("#mm").val()-1,f("#jj").val(),f("#hh").val(),f("#mn").val());m=new Date(f("#hidden_aa").val(),f("#hidden_mm").val()-1,f("#hidden_jj").val(),f("#hidden_hh").val(),f("#hidden_mn").val());k=new Date(f("#cur_aa").val(),f("#cur_mm").val()-1,f("#cur_jj").val(),f("#cur_hh").val(),f("#cur_mn").val());if(j>k&&f("#original_post_status").val()!="future"){o=postL10n.publishOnFuture;f("#publish").val(postL10n.schedule)}else{if(j<=k&&f("#original_post_status").val()!="publish"){o=postL10n.publishOn;f("#publish").val(postL10n.publish)}else{o=postL10n.publishOnPast;if(g){f("#publish").val(postL10n.updatePage)}else{f("#publish").val(postL10n.updatePost)}}}if(m.toUTCString()==j.toUTCString()){f("#timestamp").html(a)}else{f("#timestamp").html(o+" <b>"+f("option[value="+f("#mm").val()+"]","#mm").text()+" "+f("#jj").val()+", "+f("#aa").val()+" @ "+f("#hh").val()+":"+f("#mn").val()+"</b> ")}if(f("input:radio:checked","#post-visibility-select").val()=="private"){if(g){f("#publish").val(postL10n.updatePage)}else{f("#publish").val(postL10n.updatePost)}if(n.length==0){l.append('<option value="publish">'+postL10n.privatelyPublished+"</option>")}else{n.html(postL10n.privatelyPublished)}f("option[value=publish]",l).attr("selected",true);f(".edit-post-status","#misc-publishing-actions").hide()}else{if(f("#original_post_status").val()=="future"||f("#original_post_status").val()=="draft"){if(n.length){n.remove();l.val(f("#hidden_post_status").val())}}else{n.html(postL10n.published)}f(".edit-post-status","#misc-publishing-actions").show()}f("#post-status-display").html(f("option:selected",l).text());if(f("option:selected",l).val()=="private"||f("option:selected",l).val()=="publish"){f("#save-post").hide()}else{f("#save-post").show();if(f("option:selected",l).val()=="pending"){f("#save-post").show().val(postL10n.savePending)}else{f("#save-post").show().val(postL10n.saveDraft)}}}f(".edit-visibility","#visibility").click(function(){if(f("#post-visibility-select").is(":hidden")){e();f("#post-visibility-select").slideDown("normal");f(this).hide()}return false});f(".cancel-post-visibility","#post-visibility-select").click(function(){f("#post-visibility-select").slideUp("normal");f("#visibility-radio-"+f("#hidden-post-visibility").val()).attr("checked",true);f("#post_password").val(f("#hidden_post_password").val());f("#sticky").attr("checked",f("#hidden-post-sticky").attr("checked"));f("#post-visibility-display").html(b);f(".edit-visibility","#visibility").show();c();return false});f(".save-post-visibility","#post-visibility-select").click(function(){var j=f("#post-visibility-select");j.slideUp("normal");f(".edit-visibility","#visibility").show();c();if(f("input:radio:checked",j).val()!="public"){f("#sticky").attr("checked",false)}if(true==f("#sticky").attr("checked")){h="Sticky"}else{h=""}f("#post-visibility-display").html(postL10n[f("input:radio:checked",j).val()+h]);return false});f("input:radio","#post-visibility-select").change(function(){e()});f("#timestampdiv").siblings("a.edit-timestamp").click(function(){if(f("#timestampdiv").is(":hidden")){f("#timestampdiv").slideDown("normal");f(this).hide()}return false});f(".cancel-timestamp","#timestampdiv").click(function(){f("#timestampdiv").slideUp("normal");f("#mm").val(f("#hidden_mm").val());f("#jj").val(f("#hidden_jj").val());f("#aa").val(f("#hidden_aa").val());f("#hh").val(f("#hidden_hh").val());f("#mn").val(f("#hidden_mn").val());f("#timestampdiv").siblings("a.edit-timestamp").show();c();return false});f(".save-timestamp","#timestampdiv").click(function(){f("#timestampdiv").slideUp("normal");f("#timestampdiv").siblings("a.edit-timestamp").show();c();return false});f("#post-status-select").siblings("a.edit-post-status").click(function(){if(f("#post-status-select").is(":hidden")){f("#post-status-select").slideDown("normal");f(this).hide()}return false});f(".save-post-status","#post-status-select").click(function(){f("#post-status-select").slideUp("normal");f("#post-status-select").siblings("a.edit-post-status").show();c();return false});f(".cancel-post-status","#post-status-select").click(function(){f("#post-status-select").slideUp("normal");f("#post_status").val(f("#hidden_post_status").val());f("#post-status-select").siblings("a.edit-post-status").show();c();return false})}if(f("#edit-slug-box").length){editPermalink=function(j){var k,n=0,m=f("#editable-post-name"),o=m.html(),r=f("#post_name"),s=r.html(),p=f("#edit-slug-buttons"),q=p.html(),l=f("#editable-post-name-full").html();f("#view-post-btn").hide();p.html('<a href="#" class="save button">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+"</a>");p.children(".save").click(function(){var t=m.children("input").val();f.post(ajaxurl,{action:"sample-permalink",post_id:j,new_slug:t,new_title:f("#title").val(),samplepermalinknonce:f("#samplepermalinknonce").val()},function(u){f("#edit-slug-box").html(u);p.html(q);r.attr("value",t);makeSlugeditClickable();f("#view-post-btn").show()});return false});f(".cancel","#edit-slug-buttons").click(function(){f("#view-post-btn").show();m.html(o);p.html(q);r.attr("value",s);return false});for(k=0;k<l.length;++k){if("%"==l.charAt(k)){n++}}slug_value=(n>l.length/4)?"":l;m.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(u){var t=u.keyCode||0;if(13==t){p.children(".save").click();return false}if(27==t){p.children(".cancel").click();return false}r.attr("value",this.value)}).focus()};makeSlugeditClickable=function(){f("#editable-post-name").click(function(){f("#edit-slug-buttons").children(".edit-slug").click()})};makeSlugeditClickable()}});2 No newline at end of file 1 var tagBox,commentsBox,editPermalink,makeSlugeditClickable,WPSetThumbnailHTML,WPSetThumbnailID,WPRemoveThumbnail;function array_unique_noempty(a){var out=[];jQuery.each(a,function(key,val){val=jQuery.trim(val);if(val&&jQuery.inArray(val,out)==-1){out.push(val)}});return out}(function($){tagBox={clean:function(tags){return tags.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,"")},parseTags:function(el){var id=el.id,num=id.split("-check-num-")[1],taxbox=$(el).closest(".tagsdiv"),thetags=taxbox.find(".the-tags"),current_tags=thetags.val().split(","),new_tags=[];delete current_tags[num];$.each(current_tags,function(key,val){val=$.trim(val);if(val){new_tags.push(val)}});thetags.val(this.clean(new_tags.join(",")));this.quickClicks(taxbox);return false},quickClicks:function(el){var thetags=$(".the-tags",el),tagchecklist=$(".tagchecklist",el),current_tags;if(!thetags.length){return}current_tags=thetags.val().split(",");tagchecklist.empty();$.each(current_tags,function(key,val){var txt,button_id,id=$(el).attr("id");val=$.trim(val);if(!val.match(/^\s+$/)&&""!=val){button_id=id+"-check-num-"+key;txt='<span><a id="'+button_id+'" class="ntdelbutton">X</a> '+val+"</span> ";tagchecklist.append(txt);$("#"+button_id).click(function(){tagBox.parseTags(this)})}})},flushTags:function(el,a,f){a=a||false;var text,tags=$(".the-tags",el),newtag=$("input.newtag",el),newtags;text=a?$(a).text():newtag.val();tagsval=tags.val();newtags=tagsval?tagsval+","+text:text;newtags=this.clean(newtags);newtags=array_unique_noempty(newtags.split(",")).join(",");tags.val(newtags);this.quickClicks(el);if(!a){newtag.val("")}if("undefined"==f){newtag.focus()}return false},get:function(id){var tax=id.substr(id.indexOf("-")+1);$.post(ajaxurl,{action:"get-tagcloud",tax:tax},function(r,stat){if(0==r||"success"!=stat){r=wpAjax.broken}r=$('<p id="tagcloud-'+tax+'" class="the-tagcloud">'+r+"</p>");$("a",r).click(function(){tagBox.flushTags($(this).closest(".inside").children(".tagsdiv"),this);return false});$("#"+id).after(r)})},init:function(){var t=this,ajaxtag=$("div.ajaxtag");$(".tagsdiv").each(function(){tagBox.quickClicks(this)});$("input.tagadd",ajaxtag).click(function(){t.flushTags($(this).closest(".tagsdiv"))});$("div.taghint",ajaxtag).click(function(){$(this).css("visibility","hidden").siblings(".newtag").focus()});$("input.newtag",ajaxtag).blur(function(){if(this.value==""){$(this).siblings(".taghint").css("visibility","")}}).focus(function(){$(this).siblings(".taghint").css("visibility","hidden")}).keyup(function(e){if(13==e.which){tagBox.flushTags($(this).closest(".tagsdiv"));return false}}).keypress(function(e){if(13==e.which){e.preventDefault();return false}}).each(function(){var tax=$(this).closest("div.tagsdiv").attr("id");$(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+tax,{delay:500,minchars:2,multiple:true,multipleSep:", "})});$("#post").submit(function(){$("div.tagsdiv").each(function(){tagBox.flushTags(this,false,1)})});$("a.tagcloud-link").click(function(){tagBox.get($(this).attr("id"));$(this).unbind().click(function(){$(this).siblings(".the-tagcloud").toggle();return false});return false})}};commentsBox={st:0,get:function(total,num){var st=this.st,data;if(!num){num=20}this.st+=num;this.total=total;$("#commentsdiv img.waiting").show();data={action:"get-comments",mode:"single",_ajax_nonce:$("#add_comment_nonce").val(),post_ID:$("#post_ID").val(),start:st,num:num};$.post(ajaxurl,data,function(r){r=wpAjax.parseAjaxResponse(r);$("#commentsdiv .widefat").show();$("#commentsdiv img.waiting").hide();if("object"==typeof r&&r.responses[0]){$("#the-comment-list").append(r.responses[0].data);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="2">'+wpAjax.broken+"</td></tr>")});return false}};WPSetThumbnailHTML=function(html){$(".inside","#postthumbnaildiv").html(html)};WPSetThumbnailID=function(id){var field=$("input[value=_thumbnail_id]","#list-table");if(field.size()>0){$("#meta\\["+field.attr("id").match(/[0-9]+/)+"\\]\\[value\\]").text(id)}};WPRemoveThumbnail=function(){$.post(ajaxurl,{action:"set-post-thumbnail",post_id:$("#post_ID").val(),thumbnail_id:-1,cookie:encodeURIComponent(document.cookie)},function(str){if(str=="0"){alert(setPostThumbnailL10n.error)}else{WPSetThumbnailHTML(str)}})}})(jQuery);jQuery(document).ready(function($){var catAddAfter,stamp,visibility,sticky="",post="post"==pagenow||"post-new"==pagenow,page="page"==pagenow||"page-new"==pagenow;if(post){type="post";if(typenow){type=typenow}postboxes.add_postbox_toggles(type)}else{if(page){postboxes.add_postbox_toggles("page")}}if($("#tagsdiv-post_tag").length){tagBox.init()}else{$("#side-sortables, #normal-sortables, #advanced-sortables").children("div.postbox").each(function(){if(this.id.indexOf("tagsdiv-")===0){tagBox.init();return false}})}if($("#categorydiv").length){$("a","#category-tabs").click(function(){var t=$(this).attr("href");$(this).parent().addClass("tabs").siblings("li").removeClass("tabs");$("#category-tabs").siblings(".tabs-panel").hide();$(t).show();if("#categories-all"==t){deleteUserSetting("cats")}else{setUserSetting("cats","pop")}return false});if(getUserSetting("cats")){$('a[href="#categories-pop"]',"#category-tabs").click()}$("#newcat").one("focus",function(){$(this).val("").removeClass("form-input-tip")});$("#category-add-sumbit").click(function(){$("#newcat").focus()});catAddBefore=function(s){if(!$("#newcat").val()){return false}s.data+="&"+$(":checked","#categorychecklist").serialize();return s};catAddAfter=function(r,s){var sup,drop=$("#newcat_parent");if("undefined"!=s.parsed.responses[0]&&(sup=s.parsed.responses[0].supplemental.newcat_parent)){drop.before(sup);drop.remove()}};$("#categorychecklist").wpList({alt:"",response:"category-ajax-response",addBefore:catAddBefore,addAfter:catAddAfter});$("#category-add-toggle").click(function(){$("#category-adder").toggleClass("wp-hidden-children");$('a[href="#categories-all"]',"#category-tabs").click();return false});$("#categorychecklist").children("li.popular-category").add($("#categorychecklist-pop").children()).find(":checkbox").live("click",function(){var t=$(this),c=t.is(":checked"),id=t.val();$("#in-category-"+id+", #in-popular-category-"+id).attr("checked",c)})}if($("#postcustom").length){$("#the-list").wpList({addAfter:function(xml,s){$("table#list-table").show();if(typeof(autosave_update_post_ID)!="undefined"){autosave_update_post_ID(s.parsed.responses[0].supplemental.postid)}},addBefore:function(s){s.data+="&post_id="+$("#post_ID").val();return s}})}if($("#submitdiv").length){stamp=$("#timestamp").html();visibility=$("#post-visibility-display").html();function updateVisibility(){var pvSelect=$("#post-visibility-select");if($("input:radio:checked",pvSelect).val()!="public"){$("#sticky").attr("checked",false);$("#sticky-span").hide()}else{$("#sticky-span").show()}if($("input:radio:checked",pvSelect).val()!="password"){$("#password-span").hide()}else{$("#password-span").show()}}function updateText(){var attemptedDate,originalDate,currentDate,publishOn,postStatus=$("#post_status"),optPublish=$("option[value=publish]",postStatus);attemptedDate=new Date($("#aa").val(),$("#mm").val()-1,$("#jj").val(),$("#hh").val(),$("#mn").val());originalDate=new Date($("#hidden_aa").val(),$("#hidden_mm").val()-1,$("#hidden_jj").val(),$("#hidden_hh").val(),$("#hidden_mn").val());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"){publishOn=postL10n.publishOnFuture;$("#publish").val(postL10n.schedule)}else{if(attemptedDate<=currentDate&&$("#original_post_status").val()!="publish"){publishOn=postL10n.publishOn;$("#publish").val(postL10n.publish)}else{publishOn=postL10n.publishOnPast;if(page){$("#publish").val(postL10n.updatePage)}else{$("#publish").val(postL10n.updatePost)}}}if(originalDate.toUTCString()==attemptedDate.toUTCString()){$("#timestamp").html(stamp)}else{$("#timestamp").html(publishOn+" <b>"+$("option[value="+$("#mm").val()+"]","#mm").text()+" "+$("#jj").val()+", "+$("#aa").val()+" @ "+$("#hh").val()+":"+$("#mn").val()+"</b> ")}if($("input:radio:checked","#post-visibility-select").val()=="private"){if(page){$("#publish").val(postL10n.updatePage)}else{$("#publish").val(postL10n.updatePost)}if(optPublish.length==0){postStatus.append('<option value="publish">'+postL10n.privatelyPublished+"</option>")}else{optPublish.html(postL10n.privatelyPublished)}$("option[value=publish]",postStatus).attr("selected",true);$(".edit-post-status","#misc-publishing-actions").hide()}else{if($("#original_post_status").val()=="future"||$("#original_post_status").val()=="draft"){if(optPublish.length){optPublish.remove();postStatus.val($("#hidden_post_status").val())}}else{optPublish.html(postL10n.published)}$(".edit-post-status","#misc-publishing-actions").show()}$("#post-status-display").html($("option:selected",postStatus).text());if($("option:selected",postStatus).val()=="private"||$("option:selected",postStatus).val()=="publish"){$("#save-post").hide()}else{$("#save-post").show();if($("option:selected",postStatus).val()=="pending"){$("#save-post").show().val(postL10n.savePending)}else{$("#save-post").show().val(postL10n.saveDraft)}}}$(".edit-visibility","#visibility").click(function(){if($("#post-visibility-select").is(":hidden")){updateVisibility();$("#post-visibility-select").slideDown("normal");$(this).hide()}return false});$(".cancel-post-visibility","#post-visibility-select").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","#visibility").show();updateText();return false});$(".save-post-visibility","#post-visibility-select").click(function(){var pvSelect=$("#post-visibility-select");pvSelect.slideUp("normal");$(".edit-visibility","#visibility").show();updateText();if($("input:radio:checked",pvSelect).val()!="public"){$("#sticky").attr("checked",false)}if(true==$("#sticky").attr("checked")){sticky="Sticky"}else{sticky=""}$("#post-visibility-display").html(postL10n[$("input:radio:checked",pvSelect).val()+sticky]);return false});$("input:radio","#post-visibility-select").change(function(){updateVisibility()});$("#timestampdiv").siblings("a.edit-timestamp").click(function(){if($("#timestampdiv").is(":hidden")){$("#timestampdiv").slideDown("normal");$(this).hide()}return false});$(".cancel-timestamp","#timestampdiv").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());$("#timestampdiv").siblings("a.edit-timestamp").show();updateText();return false});$(".save-timestamp","#timestampdiv").click(function(){$("#timestampdiv").slideUp("normal");$("#timestampdiv").siblings("a.edit-timestamp").show();updateText();return false});$("#post-status-select").siblings("a.edit-post-status").click(function(){if($("#post-status-select").is(":hidden")){$("#post-status-select").slideDown("normal");$(this).hide()}return false});$(".save-post-status","#post-status-select").click(function(){$("#post-status-select").slideUp("normal");$("#post-status-select").siblings("a.edit-post-status").show();updateText();return false});$(".cancel-post-status","#post-status-select").click(function(){$("#post-status-select").slideUp("normal");$("#post_status").val($("#hidden_post_status").val());$("#post-status-select").siblings("a.edit-post-status").show();updateText();return false})}if($("#edit-slug-box").length){editPermalink=function(post_id){var i,c=0,e=$("#editable-post-name"),revert_e=e.html(),real_slug=$("#post_name"),revert_slug=real_slug.html(),b=$("#edit-slug-buttons"),revert_b=b.html(),full=$("#editable-post-name-full").html();$("#view-post-btn").hide();b.html('<a href="#" class="save button">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+"</a>");b.children(".save").click(function(){var new_slug=e.children("input").val();$.post(ajaxurl,{action:"sample-permalink",post_id:post_id,new_slug:new_slug,new_title:$("#title").val(),samplepermalinknonce:$("#samplepermalinknonce").val()},function(data){$("#edit-slug-box").html(data);b.html(revert_b);real_slug.attr("value",new_slug);makeSlugeditClickable();$("#view-post-btn").show()});return false});$(".cancel","#edit-slug-buttons").click(function(){$("#view-post-btn").show();e.html(revert_e);b.html(revert_b);real_slug.attr("value",revert_slug);return false});for(i=0;i<full.length;++i){if("%"==full.charAt(i)){c++}}slug_value=(c>full.length/4)?"":full;e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(e){var key=e.keyCode||0;if(13==key){b.children(".save").click();return false}if(27==key){b.children(".cancel").click();return false}real_slug.attr("value",this.value)}).focus()};makeSlugeditClickable=function(){$("#editable-post-name").click(function(){$("#edit-slug-buttons").children(".edit-slug").click()})};makeSlugeditClickable()}}); 2 No newline at end of file -
wp-admin/edit-form-advanced.php
85 85 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). 86 86 require_once('includes/meta-boxes.php'); 87 87 88 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'post', 'side', 'core');88 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core'); 89 89 90 90 // all tag-style post taxonomies 91 foreach ( get_object_taxonomies( 'post') as $tax_name ) {91 foreach ( get_object_taxonomies($post_type) as $tax_name ) { 92 92 if ( !is_taxonomy_hierarchical($tax_name) ) { 93 93 $taxonomy = get_taxonomy($tax_name); 94 94 $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name; 95 95 96 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', 'post', 'side', 'core');96 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', $post_type, 'side', 'core'); 97 97 } 98 98 } 99 99 100 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core'); 100 if ( 'post' == $post_type ) 101 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', $post_type, 'side', 'core'); 102 101 103 if ( current_theme_supports( 'post-thumbnails' ) ) 102 add_meta_box('postthumbnaildiv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low'); 103 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core'); 104 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core'); 105 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'normal', 'core'); 104 add_meta_box('postthumbnaildiv', __('Post Thumbnail'), 'post_thumbnail_meta_box', $post_type, 'side', 'low'); 105 106 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core'); 107 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', $post_type, 'normal', 'core'); 108 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core'); 106 109 do_action('dbx_post_advanced'); 107 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core');110 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core'); 108 111 109 112 if ( 'publish' == $post->post_status || 'private' == $post->post_status ) 110 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', 'post', 'normal', 'core');113 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core'); 111 114 112 115 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) ) 113 add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core');116 add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core'); 114 117 115 118 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM 116 119 if ( $post->post_author && !in_array($post->post_author, $authors) ) 117 120 $authors[] = $post->post_author; 118 121 if ( $authors && count( $authors ) > 1 ) 119 add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'normal', 'core');122 add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', $post_type, 'normal', 'core'); 120 123 121 124 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) 122 add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core');125 add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core'); 123 126 124 do_action('do_meta_boxes', 'post', 'normal', $post); 125 do_action('do_meta_boxes', 'post', 'advanced', $post); 126 do_action('do_meta_boxes', 'post', 'side', $post); 127 do_action('add_meta_boxes', $post_type); 127 128 129 do_action('do_meta_boxes', $post_type, 'normal', $post); 130 do_action('do_meta_boxes', $post_type, 'advanced', $post); 131 do_action('do_meta_boxes', $post_type, 'side', $post); 132 128 133 require_once('admin-header.php'); 129 134 130 135 ?> … … 152 157 <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" /> 153 158 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" /> 154 159 <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> 155 <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post ->post_type) ?>" />160 <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post_type) ?>" /> 156 161 <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status) ?>" /> 157 162 <input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" /> 158 163 <?php … … 166 171 167 172 <?php do_action('submitpost_box'); ?> 168 173 169 <?php $side_meta_boxes = do_meta_boxes( 'post', 'side', $post); ?>174 <?php $side_meta_boxes = do_meta_boxes($post_type, 'side', $post); ?> 170 175 </div> 171 176 172 177 <div id="post-body"> … … 223 228 224 229 <?php 225 230 226 do_meta_boxes( 'post', 'normal', $post);231 do_meta_boxes($post_type, 'normal', $post); 227 232 228 233 do_action('edit_form_advanced'); 229 234 230 do_meta_boxes( 'post', 'advanced', $post);235 do_meta_boxes($post_type, 'advanced', $post); 231 236 232 237 do_action('dbx_post_sidebar'); ?> 233 238 -
wp-admin/menu.php
65 65 66 66 $_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group 67 67 68 foreach ( (array) get_post_types( array('_show' => true) ) as $ptype ) { 69 $_wp_last_object_menu++; 70 $ptype_obj = get_post_type_object($ptype); 71 $menu[$_wp_last_object_menu] = array(esc_attr($ptype_obj->label), 'edit_' . $ptype_obj->capability_type . 's', "edit.php?post_type=$ptype", '', 'menu-top', 'menu-posts', 'div'); 72 $submenu["edit.php?post_type=$ptype"][5] = array( __('Edit'), 'edit_posts', "edit.php?post_type=$ptype"); 73 /* translators: add new custom post type */ 74 $submenu["edit.php?post_type=$ptype"][10] = array( _x('Add New', 'post'), 'edit_posts', "post-new.php?post_type=$ptype" ); 75 76 $i = 15; 77 foreach ( $wp_taxonomies as $tax ) { 78 if ( $tax->hierarchical || ! in_array($ptype, (array) $tax->object_type, true) ) 79 continue; 80 81 $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" ); 82 ++$i; 83 } 84 } 85 unset($ptype, $ptype_obj); 86 68 87 $menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' ); 69 88 70 89 $menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top', 'menu-appearance', 'div' ); -
wp-admin/admin-header.php
35 35 else if ( isset($pagenow) ) 36 36 $hook_suffix = "$pagenow"; 37 37 38 if ( isset($submenu_file) && (false !== $pos = strpos($submenu_file, 'post_type=')) ) 39 $typenow = substr($submenu_file, $pos + 10); 40 elseif ( isset($parent_file) && (false !== $pos = strpos($parent_file, 'post_type=')) ) 41 $typenow = substr($parent_file, $pos + 10); 42 else 43 $typenow = ''; 44 38 45 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); 39 46 ?> 40 47 <script type="text/javascript"> 41 48 //<![CDATA[ 42 49 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();}}}; 43 50 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'}; 44 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = '<?php echo substr($pagenow, 0, -4); ?>', adminpage = '<?php echo $admin_body_class; ?>', thousandsSeparator = '<?php echo $wp_locale->number_format['thousands_sep']; ?>', decimalPoint = '<?php echo $wp_locale->number_format['decimal_point']; ?>';51 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = '<?php echo substr($pagenow, 0, -4); ?>', typenow = '<?php echo $typenow; ?>', adminpage = '<?php echo $admin_body_class; ?>', thousandsSeparator = '<?php echo $wp_locale->number_format['thousands_sep']; ?>', decimalPoint = '<?php echo $wp_locale->number_format['decimal_point']; ?>'; 45 52 //]]> 46 53 </script> 47 54 <?php -
wp-admin/edit.php
20 20 unset( $_redirect ); 21 21 } 22 22 23 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) ) 24 $post_type = $_GET['post_type']; 25 else 26 $post_type = 'post'; 27 28 $post_type_object = get_post_type_object($post_type); 29 30 if ( 'post' != $post_type ) { 31 $parent_file = "edit.php?post_type=$post_type"; 32 $submenu_file = "edit.php?post_type=$post_type"; 33 $post_new_file = "post-new.php?post_type=$post_type"; 34 } else { 35 $parent_file = 'edit.php'; 36 $submenu_file = 'edit.php'; 37 $post_new_file = 'post-new.php'; 38 } 39 23 40 // Handle bulk actions 24 41 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) { 25 42 check_admin_referer('bulk-posts'); 26 43 $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() ); 27 44 28 45 if ( strpos($sendback, 'post.php') !== false ) 29 $sendback = admin_url( 'post-new.php');46 $sendback = admin_url($post_new_file); 30 47 31 48 if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { 32 49 $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']); 33 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type= 'post' AND post_status = %s", $post_status ) );50 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) ); 34 51 $doaction = 'delete'; 35 52 } elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['post']) || isset($_GET['ids']) ) ) { 36 53 $post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']); … … 107 124 exit; 108 125 } 109 126 110 if ( empty($title) ) 111 $title = __('Edit Posts'); 112 $parent_file = 'edit.php'; 127 $title = sprintf(__('Edit %s'), $post_type_object->label); 128 113 129 wp_enqueue_script('inline-edit-post'); 114 130 115 131 $user_posts = false; 116 132 if ( !current_user_can('edit_others_posts') ) { 117 $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = 'p ost' AND post_status != 'trash' AND post_author = %d", $current_user->ID) );133 $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = 'p%s' AND post_status != 'trash' AND post_author = %d", $post_type, $current_user->ID) ); 118 134 $user_posts = true; 119 135 if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) ) 120 136 $_GET['author'] = $current_user->ID; … … 134 150 135 151 <div class="wrap"> 136 152 <?php screen_icon(); ?> 137 <h2><?php echo esc_html( $title ); ?> <a href=" post-new.php" class="button add-new-h2"><?php esc_html_e('Add New'); ?></a> <?php153 <h2><?php echo esc_html( $title ); ?> <a href="<?php echo $post_new_file ?>" class="button add-new-h2"><?php esc_html_e('Add New'); ?></a> <?php 138 154 if ( isset($_GET['s']) && $_GET['s'] ) 139 155 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( get_search_query() ) ); ?> 140 156 </h2> … … 188 204 <?php 189 205 if ( empty($locked_post_status) ) : 190 206 $status_links = array(); 191 $num_posts = wp_count_posts( 'post', 'readable' );207 $num_posts = wp_count_posts( $post_type, 'readable' ); 192 208 $class = ''; 193 209 $allposts = ''; 194 210 … … 215 231 if ( isset($_GET['post_status']) && $status == $_GET['post_status'] ) 216 232 $class = ' class="current"'; 217 233 218 $status_links[] = "<li><a href='edit.php?post_status=$status '$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';234 $status_links[] = "<li><a href='edit.php?post_status=$status&post_type=$post_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>'; 219 235 } 220 236 echo implode( " |</li>\n", $status_links ) . '</li>'; 221 237 unset( $status_links ); … … 230 246 </p> 231 247 232 248 <input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_GET['post_status']) ? esc_attr($_GET['post_status']) : 'all'; ?>" /> 249 <input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" /> 233 250 <input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" /> 234 251 235 252 <?php if ( have_posts() ) { ?> … … 265 282 266 283 <?php // view filters 267 284 if ( !is_singular() ) { 268 $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";285 $arc_query = $wpdb->prepare("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = %s ORDER BY post_date DESC", $post_type); 269 286 270 287 $arc_result = $wpdb->get_results( $arc_query ); 271 288