Skip to content

Commit

Permalink
Only register the post type if you can view it
Browse files Browse the repository at this point in the history
see #31
  • Loading branch information
markjaquith committed Nov 8, 2019
1 parent 0ae551f commit 658c418
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions classes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ public function init() {
// add_filter( 'the_title', function( $title, $post_id ) { $post = get_post( $post_id ); return $title . ' [' . $post->menu_order . ']'; }, 10, 2 );

// Register the wp-help post type
if ( current_user_can( $this->view_cap( 'read_posts' ) ) ) {
$this->register_post_type();
}

// Check for API requests
if ( isset( $_REQUEST['wp-help-key'] ) && $this->get_option( 'key' ) === $_REQUEST['wp-help-key'] )
$this->api_request();

// Debug:
// $this->api_slurp();
}

protected function register_post_type() {
register_post_type( self::POST_TYPE,
array(
'label' => _x( 'Publishing Help', 'post type label', 'wp-help' ),
Expand Down Expand Up @@ -117,13 +130,6 @@ public function init() {
)
)
);

// Check for API requests
if ( isset( $_REQUEST['wp-help-key'] ) && $this->get_option( 'key' ) === $_REQUEST['wp-help-key'] )
$this->api_request();

// Debug:
// $this->api_slurp();
}

protected function view_cap( $original_cap ) {
Expand Down

0 comments on commit 658c418

Please sign in to comment.