WordPress.org

Make WordPress Core

Ticket #9674: 9674.10.diff

File 9674.10.diff, 58.4 KB (added by ryan, 6 years ago)

Menu parenting fix for edit-tags.php. Add is_object_in_taxonomy().

  • wp-includes/taxonomy.php

     
    180180                $wp->add_query_var($args['query_var']); 
    181181        } 
    182182 
    183         if ( false !== $args['rewrite'] && !empty($wp_rewrite) ) { 
     183        if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) { 
    184184                if ( !is_array($args['rewrite']) ) 
    185185                        $args['rewrite'] = array(); 
    186186                if ( !isset($args['rewrite']['slug']) ) 
    187187                        $args['rewrite']['slug'] = sanitize_title_with_dashes($taxonomy); 
    188188                $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%"); 
    190190        } 
    191191 
    192192        $args['name'] = $taxonomy; 
    193         $args['object_type'] = $object_type; 
     193        $args['object_type'] = (array) $object_type; 
    194194        $wp_taxonomies[$taxonomy] = (object) $args; 
    195195} 
    196196 
     197/** 
     198 * Add an already registered taxonomy to an object type. 
     199 * 
     200 * @package WordPress 
     201 * @subpackage Taxonomy 
     202 * @since 3.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 object type 
     207 * @return bool True if successful, false if not 
     208 */ 
     209function register_taxonomy_for_object_type( $taxonomy, $object_type) { 
     210        global $wp_taxonomies; 
     211 
     212        if ( !isset($wp_taxonomies[$taxonomy]) ) 
     213                return false; 
     214 
     215        if ( ! get_post_type_object($object_type) ) 
     216                return false; 
     217 
     218        $wp_taxonomies[$taxonomy]->object_type[] = $object_type; 
     219 
     220        return true; 
     221} 
     222 
    197223// 
    198224// Term API 
    199225// 
     
    23782404        return false; 
    23792405} 
    23802406 
     2407/** 
     2408 * Determine if the given object type is associated with the given taxonomy. 
     2409 * 
     2410 * @since 3.0 
     2411 * @uses get_object_taxonomies() 
     2412 * 
     2413 * @param string $object_type Object type string 
     2414 * @param string $taxonomy.  Single taxonomy name 
     2415 * @return bool True if object is associated with the taxonomy, otherwise false. 
     2416 */ 
     2417function is_object_in_taxonomy($object_type, $taxonomy) { 
     2418        $taxonomies = get_object_taxonomies($object_type); 
     2419 
     2420        if ( empty($taxonomies) ) 
     2421                return false; 
     2422 
     2423        if ( in_array($taxonomy, $taxonomies) ) 
     2424                return true; 
     2425 
     2426        return false; 
     2427} 
     2428 
    23812429?> 
  • wp-includes/post.php

     
    1515 * Creates the initial post types when 'init' action is fired. 
    1616 */ 
    1717function 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) ); 
    2222} 
    2323add_action( 'init', 'create_initial_post_types', 0 ); // highest priority 
    2424 
     
    442442} 
    443443 
    444444/** 
     445 * Retrieve a post type object by name 
     446 * 
     447 * @package WordPress 
     448 * @subpackage Post 
     449 * @since 3.0 
     450 * @uses $wp_post_types 
     451 * @see register_post_type 
     452 * @see get_post_types 
     453 * 
     454 * @param string $post_type The name of a registered post type 
     455 * @return object A post type object 
     456 */ 
     457function get_post_type_object( $post_type ) { 
     458        global $wp_post_types; 
     459 
     460        if ( empty($wp_post_types[$post_type]) ) 
     461                return null; 
     462 
     463        return $wp_post_types[$post_type]; 
     464} 
     465 
     466/** 
    445467 * Get a list of all registered post type objects. 
    446468 * 
    447469 * @package WordPress 
     
    491513 * 
    492514 * Optional $args contents: 
    493515 * 
     516 * label - A descriptive name for the post type marked for translation. Defaults to $post_type. 
     517 * public - Whether posts of this type should be shown in the admin UI. Defaults to true. 
    494518 * exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true. 
     519 * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none. 
     520 * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". 
     521 * hierarchical - Whether the post type is hierarchical. Defaults to false. 
    495522 * 
    496523 * @package WordPress 
    497524 * @subpackage Post 
     
    507534        if (!is_array($wp_post_types)) 
    508535                $wp_post_types = array(); 
    509536 
    510         $defaults = array('exclude_from_search' => true); 
     537        // Args prefixed with an underscore are reserved for internal use. 
     538        $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); 
    511539        $args = wp_parse_args($args, $defaults); 
     540        $args = (object) $args; 
    512541 
    513542        $post_type = sanitize_user($post_type, true); 
    514         $args['name'] = $post_type; 
    515         $wp_post_types[$post_type] = (object) $args; 
     543        $args->name = $post_type; 
     544 
     545        if ( false === $args->label ) 
     546                $args->label = $post_type; 
     547 
     548        if ( empty($args->capability_type) ) { 
     549                $args->edit_cap = ''; 
     550                $args->read_cap = ''; 
     551        } else { 
     552                $args->edit_cap = 'edit_' . $args->capability_type; 
     553                $args->read_cap = 'read_' . $args->capability_type; 
     554        } 
     555 
     556        if ( !$args->_builtin && $args->public ) 
     557                $args->_show = true; 
     558 
     559        $wp_post_types[$post_type] = $args; 
     560 
     561        return $args; 
    516562} 
    517563 
    518564/** 
     
    10181064 
    10191065        $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 
    10201066        if ( 'readable' == $perm && is_user_logged_in() ) { 
    1021                 if ( !current_user_can("read_private_{$type}s") ) { 
     1067                $post_type_object = get_post_type_object($type); 
     1068                if ( !current_user_can("read_private_{$post_type_object->capability_type}s") ) { 
    10221069                        $cache_key .= '_' . $perm . '_' . $user->ID; 
    10231070                        $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))"; 
    10241071                } 
  • wp-includes/query.php

     
    20622062 
    20632063                if ( is_array($post_type) ) 
    20642064                        $post_type_cap = 'multiple_post_type'; 
    2065                 else 
    2066                         $post_type_cap = $post_type; 
     2065                else { 
     2066                        $post_type_object = get_post_type_object ( $post_type ); 
     2067                        if ( !empty($post_type_object) ) 
     2068                                $post_type_cap = $post_type_object->capability_type;  
     2069                        else 
     2070                                $post_type_cap = $post_type; 
     2071                } 
    20672072 
    20682073                $exclude_post_types = ''; 
    20692074                foreach ( get_post_types( array('exclude_from_search' => true) ) as $_wp_post_type ) 
  • wp-includes/link-template.php

     
    678678                return; 
    679679 
    680680        if ( 'display' == $context ) 
    681                 $action = 'action=edit&'; 
     681                $action = '&action=edit'; 
    682682        else 
    683                 $action = 'action=edit&'; 
     683                $action = '&action=edit'; 
    684684 
    685         switch ( $post->post_type ) : 
    686         case 'page' : 
    687                 if ( !current_user_can( 'edit_page', $post->ID ) ) 
    688                         return; 
    689                 $file = 'page'; 
    690                 $var  = 'post'; 
    691                 break; 
    692         case 'attachment' : 
    693                 if ( !current_user_can( 'edit_post', $post->ID ) ) 
    694                         return; 
    695                 $file = 'media'; 
    696                 $var  = 'attachment_id'; 
    697                 break; 
    698         case 'revision' : 
    699                 if ( !current_user_can( 'edit_post', $post->ID ) ) 
    700                         return; 
    701                 $file = 'revision'; 
    702                 $var  = 'revision'; 
    703                 $action = ''; 
    704                 break; 
    705         default : 
    706                 if ( !current_user_can( 'edit_post', $post->ID ) ) 
    707                         return apply_filters( 'get_edit_post_link', '', $post->ID, $context ); 
    708                 $file = 'post'; 
    709                 $var  = 'post'; 
    710                 break; 
    711         endswitch; 
     685        $post_type_object = get_post_type_object( $post->post_type );  
     686        if ( !$post_type_object ) 
     687                return; 
    712688 
    713         return apply_filters( 'get_edit_post_link', admin_url("$file.php?{$action}$var=$post->ID"), $post->ID, $context ); 
     689        if ( !current_user_can( $post_type_object->edit_cap, $post->ID ) ) 
     690                return; 
     691 
     692        return apply_filters( 'get_edit_post_link', admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), $post->ID, $context ); 
    714693} 
    715694 
    716695/** 
  • wp-includes/capabilities.php

     
    779779                $author_data = get_userdata( $user_id ); 
    780780                //echo "post ID: {$args[0]}<br />"; 
    781781                $post = get_post( $args[0] ); 
    782                 if ( 'page' == $post->post_type ) { 
    783                         $args = array_merge( array( 'delete_page', $user_id ), $args ); 
     782                $post_type = get_post_type_object( $post->post_type ); 
     783                if ( $post_type && 'post' != $post_type->capability_type ) { 
     784                        $args = array_merge( array( 'delete_' . $post_type->capability_type, $user_id ), $args ); 
    784785                        return call_user_func_array( 'map_meta_cap', $args ); 
    785786                } 
    786787 
     
    855856                $author_data = get_userdata( $user_id ); 
    856857                //echo "post ID: {$args[0]}<br />"; 
    857858                $post = get_post( $args[0] ); 
    858                 if ( 'page' == $post->post_type ) { 
    859                         $args = array_merge( array( 'edit_page', $user_id ), $args ); 
     859                $post_type = get_post_type_object( $post->post_type ); 
     860                if ( $post_type && 'post' != $post_type->capability_type ) { 
     861                        $args = array_merge( array( 'edit_' . $post_type->capability_type, $user_id ), $args ); 
    860862                        return call_user_func_array( 'map_meta_cap', $args ); 
    861863                } 
    862864                $post_author_data = get_userdata( $post->post_author ); 
     
    913915                break; 
    914916        case 'read_post': 
    915917                $post = get_post( $args[0] ); 
    916                 if ( 'page' == $post->post_type ) { 
    917                         $args = array_merge( array( 'read_page', $user_id ), $args ); 
     918                $post_type = get_post_type_object( $post->post_type ); 
     919                if ( $post_type && 'post' != $post_type->capability_type ) { 
     920                        $args = array_merge( array( 'read_' . $post_type->capability_type, $user_id ), $args ); 
    918921                        return call_user_func_array( 'map_meta_cap', $args ); 
    919922                } 
    920923 
  • wp-admin/menu-header.php

     
    4545                if ( !empty($submenu[$item[2]]) ) 
    4646                        $class[] = 'wp-has-submenu'; 
    4747 
    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 ) ) { 
    4949                        if ( !empty($submenu[$item[2]]) ) 
    5050                                $class[] = 'wp-has-current-submenu wp-menu-open'; 
    5151                        else 
  • wp-admin/admin-ajax.php

     
    11351135        if ( 'page' == $_POST['post_type'] ) { 
    11361136                $post[] = get_post($_POST['post_ID']); 
    11371137                page_rows($post); 
    1138         } elseif ( 'post' == $_POST['post_type'] ) { 
     1138        } elseif ( 'post' == $_POST['post_type'] || in_array($_POST['post_type'], get_post_types( array('_show' => true) ) ) ) { 
    11391139                $mode = $_POST['post_view']; 
    11401140                $post[] = get_post($_POST['post_ID']); 
    11411141                post_rows($post); 
  • wp-admin/post-new.php

     
    88 
    99/** Load WordPress Administration Bootstrap */ 
    1010require_once('admin.php'); 
    11 $title = __('Add New Post'); 
    12 $parent_file = 'edit.php'; 
     11 
     12if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) ) 
     13        $post_type = $_GET['post_type']; 
     14else 
     15        $post_type = 'post'; 
     16 
     17if ( '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 
    1329$editing = true; 
    1430wp_enqueue_script('autosave'); 
    1531wp_enqueue_script('post'); 
     
    3450 
    3551// Show post form. 
    3652$post = get_default_post_to_edit(); 
     53$post->post_type = $post_type; 
    3754include('edit-form-advanced.php'); 
    3855 
    3956include('admin-footer.php'); 
  • wp-admin/includes/plugin.php

     
    745745                        $parent = $_wp_real_parent_file[$parent]; 
    746746                return $parent; 
    747747        } 
    748 /* 
     748 
     749        /* 
    749750        if ( !empty ( $parent_file ) ) { 
    750751                if ( isset( $_wp_real_parent_file[$parent_file] ) ) 
    751752                        $parent_file = $_wp_real_parent_file[$parent_file]; 
    752753 
    753754                return $parent_file; 
    754755        } 
    755 */ 
     756        */ 
    756757 
    757758        if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) { 
    758759                foreach ( (array)$menu as $parent_menu ) { 
     
    782783                foreach ( $submenu[$parent] as $submenu_array ) { 
    783784                        if ( isset( $_wp_real_parent_file[$parent] ) ) 
    784785                                $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, '?') ) ) { 
    786787                                $parent_file = $parent; 
    787788                                return $parent; 
    788789                        } else 
  • wp-admin/includes/post.php

     
    846846                $orderby = 'date'; 
    847847        } 
    848848 
     849        $post_type_q = 'post_type=post'; 
     850        if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types( array('_show' => true) ) ) ) 
     851                $post_type_q = 'post_type=' . $q['post_type']; 
     852 
     853 
    849854        $posts_per_page = (int) get_user_option( 'edit_per_page', 0, false ); 
    850855        if ( empty( $posts_per_page ) || $posts_per_page < 1 ) 
    851856                $posts_per_page = 15; 
    852857        $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page ); 
    853858 
    854         wp("post_type=post&$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby"); 
     859        wp("$post_type_q&$post_status_q&posts_per_page=$posts_per_page&order=$order&orderby=$orderby"); 
    855860 
    856861        return array($post_stati, $avail_post_stati); 
    857862} 
  • wp-admin/includes/meta-boxes.php

     
    1313        global $action; 
    1414 
    1515        $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"); 
    1719?> 
    1820<div class="submitbox" id="submitpost"> 
    1921 
     
    184186<?php do_action('post_submitbox_start'); ?> 
    185187<div id="delete-action"> 
    186188<?php 
    187 if ( current_user_can( "delete_${post_type}", $post->ID ) ) { 
     189if ( current_user_can( "delete_${type_cap}", $post->ID ) ) { 
    188190        if ( !EMPTY_TRASH_DAYS ) { 
    189191                $delete_url = wp_nonce_url( add_query_arg( array('action' => 'delete', 'post' => $post->ID) ), "delete-${post_type}_{$post->ID}" ); 
    190192                $delete_text = __('Delete Permanently'); 
  • wp-admin/includes/template.php

     
    34823482} 
    34833483 
    34843484function screen_meta($screen) { 
    3485         global $wp_meta_boxes, $_wp_contextual_help; 
     3485        global $wp_meta_boxes, $_wp_contextual_help, $typenow; 
    34863486 
    34873487        $screen = str_replace('.php', '', $screen); 
    34883488        $screen = str_replace('-new', '', $screen); 
     
    34923492        $column_screens = get_column_headers($screen); 
    34933493        $meta_screens = array('index' => 'dashboard'); 
    34943494 
     3495        // Give post_type pages their own screen 
     3496        if ( 'post' == $screen ) { 
     3497                if ( !empty($typenow) ) 
     3498                        $screen = $typenow; 
     3499        } 
     3500 
    34953501        if ( isset($meta_screens[$screen]) ) 
    34963502                $screen = $meta_screens[$screen]; 
    34973503        $show_screen = false; 
     
    36753681        global $screen_layout_columns; 
    36763682 
    36773683        $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2); 
     3684 
     3685        // Add custom post types 
     3686        foreach ( get_post_types( array('_show' => true) ) as $post_type ) 
     3687                $columns[$post_type] = 2; 
     3688 
    36783689        $columns = apply_filters('screen_layout_columns', $columns, $screen); 
    36793690 
    36803691        if ( !isset($columns[$screen]) ) { 
     
    37543765        global $parent_file, $hook_suffix; 
    37553766 
    37563767        if ( empty($name) ) { 
    3757                 if ( isset($parent_file) && !empty($parent_file) ) 
    3758                         $name = substr($parent_file, 0, -4); 
     3768                if ( isset($parent_file) && !empty($parent_file) ) { 
     3769                        $name = $parent_file; 
     3770                        if ( false !== $pos = strpos($name, '?post_type=') ) 
     3771                                $name = substr($name, 0, $pos); 
     3772                        $name = substr($name, 0, -4); 
     3773                } 
    37593774                else 
    37603775                        $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix); 
    37613776        } 
  • wp-admin/edit-tags.php

     
    1919if ( !is_taxonomy($taxonomy) ) 
    2020        wp_die(__('Invalid taxonomy')); 
    2121 
    22 $parent_file = 'edit.php'; 
    23 $submenu_file = "edit-tags.php?taxonomy=$taxonomy"; 
     22if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) ) 
     23        $post_type = $_GET['post_type']; 
     24else 
     25        $post_type = 'post'; 
    2426 
     27if ( 'post' != $post_type ) { 
     28        $parent_file = "edit.php?post_type=$post_type"; 
     29        $submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type"; 
     30} else { 
     31        $parent_file = 'edit.php'; 
     32        $submenu_file = "edit-tags.php?taxonomy=$taxonomy";      
     33} 
     34 
    2535if ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) ) 
    2636        $action = 'bulk-delete'; 
    2737 
  • wp-admin/post.php

     
    126126        } 
    127127        $post_ID = $p = (int) $_GET['post']; 
    128128        $post = get_post($post_ID); 
     129        $post_type_object = get_post_type_object($post->post_type); 
    129130 
    130131        if ( empty($post->ID) ) 
    131132                wp_die( __('You attempted to edit a post that doesn&#8217;t exist. Perhaps it was deleted?') ); 
     
    136137        if ( 'trash' == $post->post_status ) 
    137138                wp_die( __('You can&#8217;t edit this post because it is in the Trash. Please restore it and try again.') ); 
    138139 
    139         if ( 'post' != $post->post_type ) { 
     140        if ( null == $post_type_object ) 
     141                wp_die( __('Unknown post type.') ); 
     142 
     143        if ( 'post' != $post->post_type && $post_type_object->_builtin ) { 
    140144                wp_redirect( get_edit_post_link( $post->ID, 'url' ) ); 
    141145                exit(); 
    142146        } 
    143147 
     148        $post_type = $post->post_type; 
     149        if ( 'post' != $post_type ) { 
     150                $parent_file = "edit.php?post_type=$post_type"; 
     151                $submenu_file = "edit.php?post_type=$post_type"; 
     152        } 
     153 
    144154        wp_enqueue_script('post'); 
    145155        if ( user_can_richedit() ) 
    146156                wp_enqueue_script('editor'); 
     
    157167                wp_enqueue_script('autosave'); 
    158168        } 
    159169 
    160         $title = __('Edit Post'); 
     170        $title = sprintf(__('Edit %s'), $post_type_object->label); 
    161171        $post = get_post_to_edit($post_ID); 
    162172 
    163173        include('edit-form-advanced.php'); 
  • wp-admin/js/post.dev.js

     
    231231        var catAddAfter, stamp, visibility, sticky = '', post = 'post' == pagenow || 'post-new' == pagenow, page = 'page' == pagenow || 'page-new' == pagenow; 
    232232 
    233233        // 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 ) { 
    237240                postboxes.add_postbox_toggles('page'); 
     241        } 
    238242 
    239243        // multi-taxonomies 
    240244        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>&nbsp;'+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"==typeof(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","#postimagediv").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 q,r,k,t,s=f("#post_status"),l=f("option[value=publish]",s),j=f("#aa").val(),o=f("#mm").val(),p=f("#jj").val(),n=f("#hh").val(),m=f("#mn").val();q=new Date(j,o-1,p,n,m);r=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(q.getFullYear()!=j||(1+q.getMonth())!=o||q.getDate()!=p||q.getMinutes()!=m){f(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{f(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}if(q>k&&f("#original_post_status").val()!="future"){t=postL10n.publishOnFuture;f("#publish").val(postL10n.schedule)}else{if(q<=k&&f("#original_post_status").val()!="publish"){t=postL10n.publishOn;f("#publish").val(postL10n.publish)}else{t=postL10n.publishOnPast;if(g){f("#publish").val(postL10n.updatePage)}else{f("#publish").val(postL10n.updatePost)}}}if(r.toUTCString()==q.toUTCString()){f("#timestamp").html(a)}else{f("#timestamp").html(t+" <b>"+f("option[value="+f("#mm").val()+"]","#mm").text()+" "+p+", "+j+" @ "+n+":"+m+"</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(l.length==0){s.append('<option value="publish">'+postL10n.privatelyPublished+"</option>")}else{l.html(postL10n.privatelyPublished)}f("option[value=publish]",s).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(l.length){l.remove();s.val(f("#hidden_post_status").val())}}else{l.html(postL10n.published)}if(s.is(":hidden")){f(".edit-post-status","#misc-publishing-actions").show()}}f("#post-status-display").html(f("option:selected",s).text());if(f("option:selected",s).val()=="private"||f("option:selected",s).val()=="publish"){f("#save-post").hide()}else{f("#save-post").show();if(f("option:selected",s).val()=="pending"){f("#save-post").show().val(postL10n.savePending)}else{f("#save-post").show().val(postL10n.saveDraft)}}return true}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(){if(c()){f("#timestampdiv").slideUp("normal");f("#timestampdiv").siblings("a.edit-timestamp").show()}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 
     1var 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>&nbsp;'+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"==typeof(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","#postimagediv").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){type="post";if(typenow){type=typenow}postboxes.add_postbox_toggles(type)}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 q,r,k,t,s=f("#post_status"),l=f("option[value=publish]",s),j=f("#aa").val(),o=f("#mm").val(),p=f("#jj").val(),n=f("#hh").val(),m=f("#mn").val();q=new Date(j,o-1,p,n,m);r=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(q.getFullYear()!=j||(1+q.getMonth())!=o||q.getDate()!=p||q.getMinutes()!=m){f(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{f(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}if(q>k&&f("#original_post_status").val()!="future"){t=postL10n.publishOnFuture;f("#publish").val(postL10n.schedule)}else{if(q<=k&&f("#original_post_status").val()!="publish"){t=postL10n.publishOn;f("#publish").val(postL10n.publish)}else{t=postL10n.publishOnPast;if(g){f("#publish").val(postL10n.updatePage)}else{f("#publish").val(postL10n.updatePost)}}}if(r.toUTCString()==q.toUTCString()){f("#timestamp").html(a)}else{f("#timestamp").html(t+" <b>"+f("option[value="+f("#mm").val()+"]","#mm").text()+" "+p+", "+j+" @ "+n+":"+m+"</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(l.length==0){s.append('<option value="publish">'+postL10n.privatelyPublished+"</option>")}else{l.html(postL10n.privatelyPublished)}f("option[value=publish]",s).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(l.length){l.remove();s.val(f("#hidden_post_status").val())}}else{l.html(postL10n.published)}if(s.is(":hidden")){f(".edit-post-status","#misc-publishing-actions").show()}}f("#post-status-display").html(f("option:selected",s).text());if(f("option:selected",s).val()=="private"||f("option:selected",s).val()=="publish"){f("#save-post").hide()}else{f("#save-post").show();if(f("option:selected",s).val()=="pending"){f("#save-post").show().val(postL10n.savePending)}else{f("#save-post").show().val(postL10n.saveDraft)}}return true}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(){if(c()){f("#timestampdiv").slideUp("normal");f("#timestampdiv").siblings("a.edit-timestamp").show()}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 
  • wp-admin/edit-form-advanced.php

     
    8585// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). 
    8686require_once('includes/meta-boxes.php'); 
    8787 
    88 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'post', 'side', 'core'); 
     88add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core'); 
    8989 
    9090// all tag-style post taxonomies 
    91 foreach ( get_object_taxonomies('post') as $tax_name ) { 
     91foreach ( get_object_taxonomies($post_type) as $tax_name ) { 
    9292        if ( !is_taxonomy_hierarchical($tax_name) ) { 
    9393                $taxonomy = get_taxonomy($tax_name); 
    9494                $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name; 
    9595 
    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'); 
    9797        } 
    9898} 
    9999 
    100 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core'); 
    101 if ( current_theme_supports( 'post-thumbnails', 'post' ) ) 
    102         add_meta_box('postimagediv', __('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'); 
     100if ( is_object_in_taxonomy($post_type, 'category') ) 
     101        add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', $post_type, 'side', 'core'); 
     102if ( current_theme_supports( 'post-thumbnails', $post_type ) ) 
     103        add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', $post_type, 'side', 'low'); 
     104add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core'); 
     105add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', $post_type, 'normal', 'core'); 
     106add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core'); 
    106107do_action('dbx_post_advanced'); 
    107 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core'); 
     108add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core'); 
    108109 
    109110if ( 'publish' == $post->post_status || 'private' == $post->post_status ) 
    110         add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', 'post', 'normal', 'core'); 
     111        add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core'); 
    111112 
    112113if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) ) 
    113         add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core'); 
     114        add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core'); 
    114115 
    115116$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM 
    116117if ( $post->post_author && !in_array($post->post_author, $authors) ) 
    117118        $authors[] = $post->post_author; 
    118119if ( $authors && count( $authors ) > 1 ) 
    119         add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'normal', 'core'); 
     120        add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', $post_type, 'normal', 'core'); 
    120121 
    121122if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) 
    122         add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core'); 
     123        add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core'); 
    123124 
    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); 
     125do_action('do_meta_boxes', $post_type, 'normal', $post); 
     126do_action('do_meta_boxes', $post_type, 'advanced', $post); 
     127do_action('do_meta_boxes', $post_type, 'side', $post); 
    127128 
    128129require_once('admin-header.php'); 
    129130 
     
    152153<input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr($form_action) ?>" /> 
    153154<input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr($form_action) ?>" /> 
    154155<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) ?>" /> 
     156<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr($post_type) ?>" /> 
    156157<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr($post->post_status) ?>" /> 
    157158<input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" /> 
    158159<?php 
     
    166167 
    167168<?php do_action('submitpost_box'); ?> 
    168169 
    169 <?php $side_meta_boxes = do_meta_boxes('post', 'side', $post); ?> 
     170<?php $side_meta_boxes = do_meta_boxes($post_type, 'side', $post); ?> 
    170171</div> 
    171172 
    172173<div id="post-body"> 
     
    223224 
    224225<?php 
    225226 
    226 do_meta_boxes('post', 'normal', $post); 
     227do_meta_boxes($post_type, 'normal', $post); 
    227228 
    228229do_action('edit_form_advanced'); 
    229230 
    230 do_meta_boxes('post', 'advanced', $post); 
     231do_meta_boxes($post_type, 'advanced', $post); 
    231232 
    232233do_action('dbx_post_sidebar'); ?> 
    233234 
  • wp-admin/menu.php

     
    6565 
    6666$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group 
    6767 
     68foreach ( (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&amp;post_type=$ptype" ); 
     82                ++$i; 
     83        } 
     84} 
     85unset($ptype, $ptype_obj); 
     86 
    6887$menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' ); 
    6988 
    7089$menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top', 'menu-appearance', 'div' ); 
  • wp-admin/admin-header.php

     
    3535else if ( isset($pagenow) ) 
    3636        $hook_suffix = $pagenow; 
    3737 
     38if ( isset($submenu_file) && (false !== $pos = strpos($submenu_file, 'post_type=')) ) 
     39        $typenow = substr($submenu_file, $pos + 10); 
     40elseif ( isset($parent_file) && (false !== $pos = strpos($parent_file, 'post_type=')) ) 
     41        $typenow = substr($parent_file, $pos + 10); 
     42else 
     43        $typenow = ''; 
     44 
    3845$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); 
    3946?> 
    4047<script type="text/javascript"> 
    4148//<![CDATA[ 
    4249addLoadEvent = 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();}}}; 
    4350var 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']; ?>'; 
     51var 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']; ?>'; 
    4552//]]> 
    4653</script> 
    4754<?php 
  • wp-admin/edit.php

     
    2020        unset( $_redirect ); 
    2121} 
    2222 
     23if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) ) 
     24        $post_type = $_GET['post_type']; 
     25else 
     26        $post_type = 'post'; 
     27 
     28$post_type_object = get_post_type_object($post_type); 
     29 
     30if ( '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 
    2340// Handle bulk actions 
    2441if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) { 
    2542        check_admin_referer('bulk-posts'); 
    2643        $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() ); 
    2744 
    2845        if ( strpos($sendback, 'post.php') !== false ) 
    29                 $sendback = admin_url('post-new.php'); 
     46                $sendback = admin_url($post_new_file); 
    3047 
    3148        if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { 
    3249                $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 ) ); 
    3451                $doaction = 'delete'; 
    3552        } elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['post']) || isset($_GET['ids']) ) ) { 
    3653                $post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']); 
     
    107124         exit; 
    108125} 
    109126 
    110 if ( empty($title) ) 
    111         $title = __('Edit Posts'); 
    112 $parent_file = 'edit.php'; 
     127$title = sprintf(__('Edit %s'), $post_type_object->label); 
     128 
    113129wp_enqueue_script('inline-edit-post'); 
    114130 
    115131$user_posts = false; 
    116132if ( !current_user_can('edit_others_posts') ) { 
    117         $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = 'post' 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 = '%s' AND post_status != 'trash' AND post_author = %d", $post_type, $current_user->ID) ); 
    118134        $user_posts = true; 
    119135        if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) ) 
    120136                $_GET['author'] = $current_user->ID; 
     
    134150 
    135151<div class="wrap"> 
    136152<?php screen_icon(); ?> 
    137 <h2><?php echo esc_html( $title ); ?> <a href="post-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'post'); ?></a> <?php 
     153<h2><?php echo esc_html( $title ); ?> <a href="<?php echo $post_new_file ?>" class="button add-new-h2"><?php echo esc_html_x('Add New', 'post'); ?></a> <?php 
    138154if ( isset($_GET['s']) && $_GET['s'] ) 
    139155        printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?> 
    140156</h2> 
     
    188204<?php 
    189205if ( empty($locked_post_status) ) : 
    190206$status_links = array(); 
    191 $num_posts = wp_count_posts( 'post', 'readable' ); 
     207$num_posts = wp_count_posts( $post_type, 'readable' ); 
    192208$class = ''; 
    193209$allposts = ''; 
    194210 
     
    215231        if ( isset($_GET['post_status']) && $status == $_GET['post_status'] ) 
    216232                $class = ' class="current"'; 
    217233 
    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&amp;post_type=$post_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>'; 
    219235} 
    220236echo implode( " |</li>\n", $status_links ) . '</li>'; 
    221237unset( $status_links ); 
     
    230246</p> 
    231247 
    232248<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; ?>" /> 
    233250<input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" /> 
    234251 
    235252<?php if ( have_posts() ) { ?> 
     
    267284 
    268285<?php // view filters 
    269286if ( !is_singular() ) { 
    270 $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"; 
     287$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); 
    271288 
    272289$arc_result = $wpdb->get_results( $arc_query ); 
    273290