Plugin Directory

Changeset 3310392


Ignore:
Timestamp:
06/12/2025 09:48:00 AM (10 months ago)
Author:
gaambo
Message:

Update to version 1.1.1 from GitHub

Location:
sharable-password-protected-posts
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sharable-password-protected-posts/tags/1.1.1/sharable-password-protected-posts.php

    r3145331 r3310392  
    66 * Requires at least: 6.0
    77 * Requires PHP:      7.4
    8  * Version:           1.1.0
     8 * Version:           1.1.1
    99 * Author:            Fabian Todt
    1010 * Author URI:        https://fabiantodt.at/en/
     
    8484{
    8585    $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        ],
    87100        'single' => true,
    88101        'type' => 'boolean',
     
    101114            }
    102115            return $value;
    103         }
     116        },
    104117    ];
    105118
    106119    $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        ],
    108134        'single' => true,
    109135        'type' => 'string',
  • sharable-password-protected-posts/trunk/sharable-password-protected-posts.php

    r3145331 r3310392  
    66 * Requires at least: 6.0
    77 * Requires PHP:      7.4
    8  * Version:           1.1.0
     8 * Version:           1.1.1
    99 * Author:            Fabian Todt
    1010 * Author URI:        https://fabiantodt.at/en/
     
    8484{
    8585    $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        ],
    87100        'single' => true,
    88101        'type' => 'boolean',
     
    101114            }
    102115            return $value;
    103         }
     116        },
    104117    ];
    105118
    106119    $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        ],
    108134        'single' => true,
    109135        'type' => 'string',
Note: See TracChangeset for help on using the changeset viewer.