PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.7.1
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.7.1
2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 All 28 releases
← All changes | includes/class.rest.php +4 -23 2.7.72.7.1 View file →
@@ -172,9 +172,9 @@
172 172 },
173 173 ],
174 174 ],
175 175 'permission_callback' => function () {
176 - return current_user_can( 'manage_options' );
176 + return current_user_can( 'edit_posts' );
177 177 },
178 178 'callback' => [ $this, 'sync_snippet' ],
179 179 ],
180 180 ]
@@ -307,15 +307,8 @@
307 307 );
308 308 }
309 309
310 310 foreach ( $data as $key => $value ) {
311 - if ( false === $value ) {
312 - // update_option() short-circuits when storing `false` over a
313 - // missing option (both compare equal), so a default-enabled
314 - // checkbox could never be persisted as disabled.
315 - $value = '';
316 - }
317 -
318 311 update_option( 'wbcr_inp_' . $key, $value );
319 312 }
320 313
321 314 return new \WP_REST_Response(
@@ -591,9 +584,9 @@
591 584 $conditions['meta_query'] = $meta_query_conditions;
592 585 }
593 586
594 587 if ( ! empty( $tax_query_conditions ) ) {
595 - $conditions['tax_query'] = $tax_query_conditions;
588 + $conditions['tax_query'] = $tax_query_conditions; // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
596 589 }
597 590
598 591 // Query snippets.
599 592 $snippets = get_posts( $conditions );
@@ -636,14 +629,13 @@
636 629
637 630 /**
638 631 * Handle snippet sync to cloud.
639 632 *
640 - * @param \WP_REST_Request $request Rest request.
641 - * @phpstan-param \WP_REST_Request<array<string, mixed>> $request
633 + * @param \WP_REST_Request<array<string, mixed>> $request Rest request.
642 634 *
643 635 * @return \WP_REST_Response
644 636 */
645 - public function sync_snippet( \WP_REST_Request $request ) {
637 + public function sync_snippet( \WP_REST_Request $request ) { // phpcs:ignore Squiz.Commenting.FunctionComment.IncorrectTypeHint
646 638 $title = $request->get_param( 'title' );
647 639 $snippet_id = absint( $request->get_param( 'id' ) );
648 640
649 641 // Verify the snippet exists.
@@ -654,19 +646,8 @@
654 646 'message' => __( 'Snippet not found. It may have been deleted or moved.', 'insert-php' ),
655 647 'success' => false,
656 648 ],
657 649 404
658 - );
659 - }
660 -
661 - // Verify the current user has permission to edit this specific snippet.
662 - if ( ! current_user_can( 'edit_post', $snippet_id ) ) {
663 - return new \WP_REST_Response(
664 - [
665 - 'message' => __( 'You do not have permission to sync this snippet.', 'insert-php' ),
666 - 'success' => false,
667 - ],
668 - 403
669 650 );
670 651 }
671 652
672 653 // Sync snippet using the API object.