WordPress.org

Make WordPress Core

Ticket #12702: Enable sticky post checkbox for custom post type.patch

File Enable sticky post checkbox for custom post type.patch, 3.7 KB (added by azizur, 5 years ago)

Enable sticky post checkbox for custom post type

  • wp-admin/includes/meta-boxes.php

     
    1515        $post_type = $post->post_type; 
    1616        $post_type_object = get_post_type_object($post_type); 
    1717        $can_publish = current_user_can($post_type_object->cap->publish_posts); 
     18        $post_type_supports_stickies = ( $post_type == 'post' || post_type_supports( $post_type, 'sticky') ); 
    1819?> 
    1920<div class="submitbox" id="submitpost"> 
    2021 
     
    116117} elseif ( !empty( $post->post_password ) ) { 
    117118        $visibility = 'password'; 
    118119        $visibility_trans = __('Password protected'); 
    119 } elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) { 
     120} elseif ( $post_type_supports_stickies && is_sticky( $post->ID ) ) { 
    120121        $visibility = 'public'; 
    121122        $visibility_trans = __('Public, Sticky'); 
    122123} else { 
     
    130131 
    131132<div id="post-visibility-select" class="hide-if-js"> 
    132133<input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" /> 
    133 <?php if ($post_type == 'post'): ?> 
     134<?php if ( $post_type_supports_stickies ): ?> 
    134135<input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> /> 
    135136<?php endif; ?> 
    136137<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" /> 
    137138 
    138139 
    139140<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br /> 
    140 <?php if ($post_type == 'post'): ?> 
    141 <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID)); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page') ?></label><br /></span> 
     141<?php if ( $post_type_supports_stickies ): ?> 
     142<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID)); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this '. $post->post_type .' to the front page') ?></label><br /></span> 
    142143<?php endif; ?> 
    143144<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br /> 
    144145<span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span> 
  • wp-admin/includes/template.php

     
    11111111                                </select> 
    11121112                        </label> 
    11131113 
    1114 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> 
     1114<?php if ( ('post' == $screen->post_type || post_type_supports( $screen->post_type, 'sticky') )&& $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> 
    11151115 
    11161116<?php   if ( $bulk ) : ?> 
    11171117 
     
    11281128 
    11291129                        <label class="alignleft"> 
    11301130                                <input type="checkbox" name="sticky" value="sticky" /> 
    1131                                 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> 
     1131                                <span class="checkbox-title"><?php _e( 'Make this '.$screen->post_type.' sticky' ); ?></span> 
    11321132                        </label> 
    11331133 
    11341134<?php   endif; // $bulk ?>