Changeset 3310392
- Timestamp:
- 06/12/2025 09:48:00 AM (10 months ago)
- Location:
- sharable-password-protected-posts
- Files:
-
- 2 edited
- 1 copied
-
tags/1.1.1 (copied) (copied from sharable-password-protected-posts/trunk)
-
tags/1.1.1/sharable-password-protected-posts.php (modified) (3 diffs)
-
trunk/sharable-password-protected-posts.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sharable-password-protected-posts/tags/1.1.1/sharable-password-protected-posts.php
r3145331 r3310392 6 6 * Requires at least: 6.0 7 7 * Requires PHP: 7.4 8 * Version: 1.1. 08 * Version: 1.1.1 9 9 * Author: Fabian Todt 10 10 * Author URI: https://fabiantodt.at/en/ … … 84 84 { 85 85 $enabledMetaField = [ 86 'show_in_rest' => true, 86 'show_in_rest' => [ 87 'schema' => [ 88 'context' => ['edit'] // Only show when editing. 89 ], 90 // Additionally, hide value when user is not allowed to edit the post. 91 'prepare_callback' => function ($value, $request, $args) { 92 global $post; 93 // WP_REST_Posts_Controller set global post instance. 94 $postId = $post ? $post->ID : $request['id']; 95 96 $allowed = $postId ? current_user_can('edit_post', $postId) : current_user_can('edit_posts'); 97 return $allowed ? $value : null; 98 } 99 ], 87 100 'single' => true, 88 101 'type' => 'boolean', … … 101 114 } 102 115 return $value; 103 } 116 }, 104 117 ]; 105 118 106 119 $keyMetaField = [ 107 'show_in_rest' => true, 120 'show_in_rest' => [ 121 'schema' => [ 122 'context' => ['edit'] // Only show when editing. 123 ], 124 // Additionally, hide value when user is not allowed to edit the post. 125 'prepare_callback' => function ($value, $request, $args) { 126 global $post; 127 // WP_REST_Posts_Controller set global post instance. 128 $postId = $post ? $post->ID : $request['id']; 129 130 $allowed = $postId ? current_user_can('edit_post', $postId) : current_user_can('edit_posts'); 131 return $allowed ? $value : null; 132 } 133 ], 108 134 'single' => true, 109 135 'type' => 'string', -
sharable-password-protected-posts/trunk/sharable-password-protected-posts.php
r3145331 r3310392 6 6 * Requires at least: 6.0 7 7 * Requires PHP: 7.4 8 * Version: 1.1. 08 * Version: 1.1.1 9 9 * Author: Fabian Todt 10 10 * Author URI: https://fabiantodt.at/en/ … … 84 84 { 85 85 $enabledMetaField = [ 86 'show_in_rest' => true, 86 'show_in_rest' => [ 87 'schema' => [ 88 'context' => ['edit'] // Only show when editing. 89 ], 90 // Additionally, hide value when user is not allowed to edit the post. 91 'prepare_callback' => function ($value, $request, $args) { 92 global $post; 93 // WP_REST_Posts_Controller set global post instance. 94 $postId = $post ? $post->ID : $request['id']; 95 96 $allowed = $postId ? current_user_can('edit_post', $postId) : current_user_can('edit_posts'); 97 return $allowed ? $value : null; 98 } 99 ], 87 100 'single' => true, 88 101 'type' => 'boolean', … … 101 114 } 102 115 return $value; 103 } 116 }, 104 117 ]; 105 118 106 119 $keyMetaField = [ 107 'show_in_rest' => true, 120 'show_in_rest' => [ 121 'schema' => [ 122 'context' => ['edit'] // Only show when editing. 123 ], 124 // Additionally, hide value when user is not allowed to edit the post. 125 'prepare_callback' => function ($value, $request, $args) { 126 global $post; 127 // WP_REST_Posts_Controller set global post instance. 128 $postId = $post ? $post->ID : $request['id']; 129 130 $allowed = $postId ? current_user_can('edit_post', $postId) : current_user_can('edit_posts'); 131 return $allowed ? $value : null; 132 } 133 ], 108 134 'single' => true, 109 135 'type' => 'string',
Note: See TracChangeset
for help on using the changeset viewer.