Plugin Directory

Changeset 3043795


Ignore:
Timestamp:
03/01/2024 07:36:13 PM (2 years ago)
Author:
happyprime
Message:

Update to version 1.2.0 from GitHub

Location:
shadow-terms
Files:
2 added
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • shadow-terms/tags/1.2.0/includes/api.php

    r2966107 r3043795  
    111111    $supports = get_all_post_type_supports( $post_type );
    112112
    113     if ( is_array( $supports['shadow-terms'] ) && is_array( $supports['shadow-terms'][0] ) ) {
     113    if ( isset( $supports['shadow-terms'] ) && is_array( $supports['shadow-terms'] ) && is_array( $supports['shadow-terms'][0] ) ) {
    114114        return $supports['shadow-terms'][0];
    115115    }
  • shadow-terms/tags/1.2.0/includes/sync.php

    r2966107 r3043795  
    103103 * @param \WP_Post $post    The post object.
    104104 */
    105 function delete_term( int $post_id, \WP_Post $post ): void {
     105function delete_term( $post_id, \WP_Post $post ): void {
    106106    if ( ! post_type_supports( $post->post_type, 'shadow-terms' ) ) {
    107107        return;
  • shadow-terms/tags/1.2.0/includes/taxonomy.php

    r2966107 r3043795  
    6868        'rewrite'            => false,
    6969        'hierarchical'       => true,
     70        'capabilities'       => array(
     71            'manage_terms' => 'override_shadow_terms',
     72            'edit_terms'   => 'override_shadow_terms',
     73            'delete_terms' => 'override_shadow_terms',
     74        ),
    7075        'show_ui'            => true,
    7176        'show_in_menu'       => false,
     
    7479        'show_admin_column'  => true,
    7580    );
     81
     82    // If a post type is not publicly queryable and not visible in the REST API,
     83    // we should not expose that post type's shadow terms to unauthorized users.
     84    if ( false === $post_type_object->publicly_queryable && false === $post_type_object->show_in_rest && ! is_user_logged_in() ) {
     85        $args['show_in_rest'] = false;
     86    }
    7687
    7788    /**
     
    108119 * @since 1.0.0
    109120 *
    110  * @param \WP_REST_Request $request The vote submission request.
     121 * @param \WP_REST_Request $request The request to associate posts.
    111122 * @return \WP_REST_Response The response data.
    112123 */
  • shadow-terms/tags/1.2.0/plugin.php

    r2966107 r3043795  
    33 * Plugin Name:  Shadow Terms
    44 * Description:  Use terms from generated taxonomies to associate related content.
    5  * Version:      1.1.0
     5 * Version:      1.2.0
    66 * Plugin URI:   https://github.com/happyprime/shadow-terms/
    77 * Author:       Happy Prime
  • shadow-terms/tags/1.2.0/readme.txt

    r2966107 r3043795  
    33Tags: terms, related, content
    44Requires at least: 5.9
    5 Tested up to: 6.3
    6 Stable tag: 1.1.0
     5Tested up to: 6.4
     6Stable tag: 1.2.0
    77License: GPLv2 or later
    88Requires PHP: 7.4
     
    4141## Changelog
    4242
     43### 1.2.0
     44
     45* Do not show "Add New" term option for shadow taxonomies, which are automatically managed. Thanks [@s3rgiosan](https://profiles.wordpress.org/s3rgiosan/)!
     46* Do not show shadow terms in REST API to unauthenticated users if their original post type is not publicly available via REST endpoint.
     47
    4348### 1.1.0
    4449
  • shadow-terms/trunk/includes/api.php

    r2966107 r3043795  
    111111    $supports = get_all_post_type_supports( $post_type );
    112112
    113     if ( is_array( $supports['shadow-terms'] ) && is_array( $supports['shadow-terms'][0] ) ) {
     113    if ( isset( $supports['shadow-terms'] ) && is_array( $supports['shadow-terms'] ) && is_array( $supports['shadow-terms'][0] ) ) {
    114114        return $supports['shadow-terms'][0];
    115115    }
  • shadow-terms/trunk/includes/sync.php

    r2966107 r3043795  
    103103 * @param \WP_Post $post    The post object.
    104104 */
    105 function delete_term( int $post_id, \WP_Post $post ): void {
     105function delete_term( $post_id, \WP_Post $post ): void {
    106106    if ( ! post_type_supports( $post->post_type, 'shadow-terms' ) ) {
    107107        return;
  • shadow-terms/trunk/includes/taxonomy.php

    r2966107 r3043795  
    6868        'rewrite'            => false,
    6969        'hierarchical'       => true,
     70        'capabilities'       => array(
     71            'manage_terms' => 'override_shadow_terms',
     72            'edit_terms'   => 'override_shadow_terms',
     73            'delete_terms' => 'override_shadow_terms',
     74        ),
    7075        'show_ui'            => true,
    7176        'show_in_menu'       => false,
     
    7479        'show_admin_column'  => true,
    7580    );
     81
     82    // If a post type is not publicly queryable and not visible in the REST API,
     83    // we should not expose that post type's shadow terms to unauthorized users.
     84    if ( false === $post_type_object->publicly_queryable && false === $post_type_object->show_in_rest && ! is_user_logged_in() ) {
     85        $args['show_in_rest'] = false;
     86    }
    7687
    7788    /**
     
    108119 * @since 1.0.0
    109120 *
    110  * @param \WP_REST_Request $request The vote submission request.
     121 * @param \WP_REST_Request $request The request to associate posts.
    111122 * @return \WP_REST_Response The response data.
    112123 */
  • shadow-terms/trunk/plugin.php

    r2966107 r3043795  
    33 * Plugin Name:  Shadow Terms
    44 * Description:  Use terms from generated taxonomies to associate related content.
    5  * Version:      1.1.0
     5 * Version:      1.2.0
    66 * Plugin URI:   https://github.com/happyprime/shadow-terms/
    77 * Author:       Happy Prime
  • shadow-terms/trunk/readme.txt

    r2966107 r3043795  
    33Tags: terms, related, content
    44Requires at least: 5.9
    5 Tested up to: 6.3
    6 Stable tag: 1.1.0
     5Tested up to: 6.4
     6Stable tag: 1.2.0
    77License: GPLv2 or later
    88Requires PHP: 7.4
     
    4141## Changelog
    4242
     43### 1.2.0
     44
     45* Do not show "Add New" term option for shadow taxonomies, which are automatically managed. Thanks [@s3rgiosan](https://profiles.wordpress.org/s3rgiosan/)!
     46* Do not show shadow terms in REST API to unauthenticated users if their original post type is not publicly available via REST endpoint.
     47
    4348### 1.1.0
    4449
Note: See TracChangeset for help on using the changeset viewer.