Custom post type support
-
I love you plugin, it works great on posts and pages. However, I would love to see support for custom post types. I’ve changed some of your code and added filters for the post-type checks and that seems to work. This kind of breaks your plugin as it no longed listens to the checkboxes on the settings page. A better solution would be to add checkbox lists for post types to show the css editor and another checkbox list for using code highlighting per post type.
Changes made in post-page-specific-custom-css.php
// line 113 $post_types = apply_filters( 'ppsccss-post-types', array( 'post', 'page' ) ); if ( in_array( $screen->id, $post_types ) && in_array( $screen->post_type, $post_types ) ) { $field = self::POST_ENABLE_HIGHLIGHTING; } // line 606 $post_types = apply_filters( 'ppsccss-post-types', array( 'post', 'page' ) ); if ( !in_array( $_POST['post_type'], $post_types ) ) { return; } // line 562 public function add_meta_boxes() { $post_types = apply_filters( 'ppsccss-post-types', array( 'post', 'page' ) ); if ( $this->allowedToView() ) { add_meta_box( 'phylax_ppsccss', __( 'Custom CSS', 'postpage-specific-custom-css' ), [ $this, 'render_phylax_ppsccss', ], $post_types, 'advanced', 'high' ); } } // line 637, remove the switch statement and replaced if with this $post_types = apply_filters( 'ppsccss-post-types', array( 'post', 'page' ) ); if ( in_array( $post->post_type, $post_types ) ) { $theField = self::POST_ENABLE_HIGHLIGHTING; // Opted for post, could also be page $defaultField = self::OPT_DEFAULT_POST_CSS; // No need to specify post / page $screen = __( 'Custom stylesheet', 'postpage-specific-custom-css' ); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Custom post type support’ is closed to new replies.