Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Registering custom post status
- function dom_custom_post_status() {
- register_post_status( 'block', array(
- 'label' => _x( 'Blocked', 'post' ),
- 'public' => false,
- 'exclude_from_search' => false,
- 'show_in_admin_all_list' => true,
- 'show_in_admin_status_list' => true,
- 'show_in_metabox_dropdown' => true,
- 'show_in_inline_dropdown' => true,
- 'date_floating' => true,
- 'post_type' => array( 'w2dc_listing' ),
- 'label_count' => _n_noop( 'Blocked <span class="count">(%s)</span>', 'Blocked <span class="count">(%s)</span>' ),
- ) );
- }
- add_action( 'init', 'dom_custom_post_status' );
- // Using jQuery to add it to post status dropdown
- add_action( 'admin_print_footer_scripts', 'dom_append_post_status_list' );
- // add_action( 'admin_print_scripts-post-new.php', 'dom_append_post_status_list' );
- function dom_append_post_status_list() {
- global $post;
- $complete = '';
- $label = '';
- if ( $post->post_type == 'w2dc_listing' ) {
- if ( $post->post_status == 'block' ) {
- $complete = ' selected="selected"';
- $label = '<span id="post-status-display"> Blocked</span>';
- }
- echo '
- <script>
- jQuery(document).ready(function($){
- $("select#post_status").append("<option value=\"block\" ' . $complete . '>Blocked</option>");
- $(".misc-pub-section label").append("' . $label . '");
- });
- </script>';
- }
- }
Add Comment
Please, Sign In to add comment