Skip to content

Commit

Permalink
Snippets are no longer public
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaydsouza committed Dec 30, 2024
1 parent 44bc848 commit a283ee7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion add-to-all.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @wordpress-plugin
* Plugin Name: WebberZone Snippetz
* Version: 2.1.0-beta1
* Version: 2.1.0-RC1
* Plugin URI: https://webberzone.com/plugins/add-to-all/
* Description: A simple yet powerful plugin that allows you to insert any code snippet or script into WordPress.
* Author: Ajay D'Souza
Expand Down
19 changes: 13 additions & 6 deletions includes/snippets/class-snippets.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,16 @@ public function register_post_type() {
'supports' => array( 'title', 'editor', 'revisions', 'custom-fields' ),
'taxonomies' => array( 'ata_snippets_category' ),
'hierarchical' => false,
'public' => true,
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-editor-code',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'show_in_nav_menus' => false,
'can_export' => true,
'has_archive' => true,
'has_archive' => false,
'exclude_from_search' => true,
'publicly_queryable' => true,
'publicly_queryable' => false,
'rewrite' => $rewrite,
'capabilities' => array(
'publish_posts' => 'manage_options',
Expand All @@ -193,7 +192,15 @@ public function register_post_type() {
'rest_namespace' => 'webberzone/v1',
'rest_meta_fields' => array( '_ata_snippet_type' ),
'rest_permissions_callback' => function () {
return current_user_can( 'manage_options' );
// Block access if user is not logged in or not an admin.
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
return new \WP_Error(
'rest_forbidden',
esc_html__( 'You are not allowed to access this resource.', 'add-to-all' ),
array( 'status' => rest_authorization_required_code() )
);
}
return true;
},
);

Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ WebberZone Snippetz is one of the many plugins developed by WebberZone. Check ou
* New block to select and display any snippet in the block or site editor.
* New On/Off toggle button in the snippet screen to enable/disable a snippet.

* Modifications:
* Snippets are no longer public or visible on the frontend. They are only visible in the snippet screen.

= 2.0.1 =

* Bug fixes:
Expand Down

0 comments on commit a283ee7

Please sign in to comment.