Ticket #1508: private-content.patch
File private-content.patch, 6.6 KB (added by , 9 years ago) |
---|
-
inc/explanations.php
37 37 38 38 // Setup. 39 39 add_action( 'init', array( $this, 'register_post_type' ), 0 ); 40 add_action( 'init', array( $this, 'remove_editor_support' ), 100 );41 40 add_action( 'edit_form_after_title', array( $this, 'post_to_expl_controls' ) ); 42 41 add_action( 'edit_form_top', array( $this, 'expl_to_post_controls' ) ); 43 42 … … 81 80 } 82 81 83 82 /** 84 * Remove 'editor' support for the function, hook, class, and method post types.85 *86 * @access public87 */88 public function remove_editor_support() {89 foreach ( $this->post_types as $type ) {90 remove_post_type_support( $type, 'editor' );91 }92 }93 94 /**95 83 * Output the Post-to-Explanation controls in the post editor for functions, 96 84 * hooks, classes, and methods. 97 85 * -
inc/formatting.php
28 28 add_filter( 'the_content', array( __CLASS__, 'remove_inline_internal' ) ); 29 29 30 30 add_action( 'the_content', array( __CLASS__, 'fix_unintended_markdown' ) ); 31 32 add_action( 'init', array( __CLASS__, 'replace_autop' ) ); 31 33 } 32 34 33 35 /** … … 224 226 return $text; 225 227 } 226 228 229 /** 230 * Replaces the normal content autop with a custom version to skip parser types. 231 * 232 * By running this filter replacement late on the wp hook, plugins are given ample 233 * time to remove autop themselves. If they have removed autop, then the maybe_autop 234 * filter is not added. There are potentially conflicting edge cases, but this 235 * should catch at least some of them. 236 * 237 * Other plugins can also remove this functionality fairly easily by removing the wp 238 * hook and stopping this process if needed. 239 */ 240 public static function replace_autop() { 241 if ( has_filter( 'the_content', 'wpautop' ) ) { 242 remove_filter( 'the_content', 'wpautop' ); 243 add_filter( 'the_content', array( __CLASS__, 'maybe_autop' ) ); 244 } 245 } 246 247 /** 248 * Autop's all post content except for wp-parser types. 249 * 250 * @param string $content The content to filter. 251 * @return string The filtered content, conditionally with autop run. 252 */ 253 public static function maybe_autop( $content ) { 254 return ( \DevHub\is_parsed_post_type( get_post_type() ) ) ? $content : wpautop( $content ); 255 } 256 227 257 } // DevHub_Formatting 228 258 229 259 DevHub_Formatting::init(); -
inc/parsed-content.php
32 32 // Data. 33 33 add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); 34 34 add_action( 'save_post', array( $this, 'save_post' ) ); 35 add_filter( 'wp_insert_post_data', array( $this, 'autop_post_content' ) ); 35 36 36 37 // Script and styles. 37 38 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); … … 54 55 public function add_meta_boxes() { 55 56 if ( in_array( $screen = get_current_screen()->id, $this->post_types ) ) { 56 57 remove_meta_box( 'postexcerpt', $screen, 'normal' ); 57 add_meta_box( 'wporg_parsed_content', __( 'Parsed Content', 'wporg' ), array( $this, 'parsed_meta_box_cb' ), $screen, 'normal' );58 add_meta_box( 'wporg_parsed_content', __( 'Parsed Content', 'wporg' ), array( $this, 'parsed_meta_box_cb' ), $screen, 'normal', 'high' ); 58 59 } 59 60 } 60 61 … … 87 88 <label for="excerpt"><?php _e( 'Parsed Summary:', 'wporg' ); ?></label> 88 89 </th> 89 90 <td> 90 <div class="wporg_parsed_readonly <?php echo $ticket ? 'hidden' : ''; ?>"><?php echo apply_filters( 'the_content', $post->post_excerpt); ?></div>91 <div class="wporg_parsed_readonly <?php echo $ticket ? 'hidden' : ''; ?>"><?php echo apply_filters( 'the_content', wpautop( $post->post_excerpt ) ); ?></div> 91 92 <textarea rows="2" cols="40" name="excerpt" class="wporg_parsed_content <?php echo $ticket ? '' : 'hidden'; ?>"><?php echo $post->post_excerpt; ?></textarea> 92 93 </td> 93 94 </tr><!-- .wporg_parsed_content --> … … 96 97 <label for="wporg_parsed_content"><?php _e( 'Parsed Description:', 'wporg' ); ?></label> 97 98 </th> 98 99 <td> 99 <div class="wporg_parsed_readonly <?php echo $ticket ? 'hidden' : ''; ?>"><?php echo apply_filters( 'the_content',$content ); ?></div>100 <div class="wporg_parsed_readonly <?php echo $ticket ? 'hidden' : ''; ?>"><?php echo wp_kses_post( $content ); ?></div> 100 101 <div class="wporg_parsed_content <?php echo $ticket ? '' : 'hidden'; ?>"> 101 102 <?php wp_editor( $content, 'content', array( 102 103 'media_buttons' => false, … … 156 157 } 157 158 158 159 /** 160 * Checks to see if paragraph tags are missing from parsed content and pre-runs autop if not. 161 * 162 * @param array $data The array of post data to be inserted. 163 * @return array The updated array of post data, content run through autop if needed. 164 */ 165 public function autop_post_content( $data ) { 166 if ( \DevHub\is_parsed_post_type( $data['post_type'] ) && false === strpos( $data['post_content'], '<p>' ) ) { 167 $data['post_content'] = wpautop( $data['post_content'] ); 168 } 169 170 return $data; 171 } 172 173 /** 159 174 * Enqueue JS and CSS on the edit screens for all four post types. 160 175 * 161 176 * @access public -
inc/registrations.php
38 38 $supports = array( 39 39 'comments', 40 40 'custom-fields', 41 'editor',42 41 'excerpt', 43 42 'revisions', 44 43 'title', -
scss/admin.scss
79 79 /* Parsed Content Meta Box */ 80 80 .wporg_parsed_content { 81 81 width: 100%; 82 } 83 84 .form-table .wporg_parsed_readonly { 85 pre > code { 86 display: block; 87 } 88 89 p ~ p { 90 margin-top: 20px; 91 } 82 92 } 93 No newline at end of file -
stylesheets/admin.css
75 75 .wporg_parsed_content { 76 76 width: 100%; 77 77 } 78 79 .form-table .wporg_parsed_readonly pre > code { 80 display: block; 81 } 82 .form-table .wporg_parsed_readonly p ~ p { 83 margin-top: 20px; 84 } 85 86 /*# sourceMappingURL=admin.css.map */