Skip to content

Commit a283ee7

Browse files
committed
Snippets are no longer public
1 parent 44bc848 commit a283ee7

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

add-to-all.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* @wordpress-plugin
1616
* Plugin Name: WebberZone Snippetz
17-
* Version: 2.1.0-beta1
17+
* Version: 2.1.0-RC1
1818
* Plugin URI: https://webberzone.com/plugins/add-to-all/
1919
* Description: A simple yet powerful plugin that allows you to insert any code snippet or script into WordPress.
2020
* Author: Ajay D'Souza

includes/snippets/class-snippets.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,16 @@ public function register_post_type() {
161161
'supports' => array( 'title', 'editor', 'revisions', 'custom-fields' ),
162162
'taxonomies' => array( 'ata_snippets_category' ),
163163
'hierarchical' => false,
164-
'public' => true,
164+
'public' => false,
165165
'show_ui' => true,
166-
'show_in_menu' => true,
167166
'menu_position' => 5,
168167
'menu_icon' => 'dashicons-editor-code',
169168
'show_in_admin_bar' => true,
170-
'show_in_nav_menus' => true,
169+
'show_in_nav_menus' => false,
171170
'can_export' => true,
172-
'has_archive' => true,
171+
'has_archive' => false,
173172
'exclude_from_search' => true,
174-
'publicly_queryable' => true,
173+
'publicly_queryable' => false,
175174
'rewrite' => $rewrite,
176175
'capabilities' => array(
177176
'publish_posts' => 'manage_options',
@@ -193,7 +192,15 @@ public function register_post_type() {
193192
'rest_namespace' => 'webberzone/v1',
194193
'rest_meta_fields' => array( '_ata_snippet_type' ),
195194
'rest_permissions_callback' => function () {
196-
return current_user_can( 'manage_options' );
195+
// Block access if user is not logged in or not an admin.
196+
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
197+
return new \WP_Error(
198+
'rest_forbidden',
199+
esc_html__( 'You are not allowed to access this resource.', 'add-to-all' ),
200+
array( 'status' => rest_authorization_required_code() )
201+
);
202+
}
203+
return true;
197204
},
198205
);
199206

readme.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ WebberZone Snippetz is one of the many plugins developed by WebberZone. Check ou
108108
* New block to select and display any snippet in the block or site editor.
109109
* New On/Off toggle button in the snippet screen to enable/disable a snippet.
110110

111+
* Modifications:
112+
* Snippets are no longer public or visible on the frontend. They are only visible in the snippet screen.
113+
111114
= 2.0.1 =
112115

113116
* Bug fixes:

0 commit comments

Comments
 (0)