Making WordPress.org


Ignore:
Timestamp:
03/14/2024 05:40:44 AM (21 months ago)
Author:
tellyworth
Message:

Plugin directory: prompt plugin developers to create a blueprint for previews

This adds a notice, visible only to a plugin's developers, prompting them to test and create a blueprint.json file so users can run a Live Preview of their plugin in the WordPress Playground. The notice can be dismissed.

See #7487.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-self-toggle-preview.php

    r13037 r13335  
    6464        header( 'Location: ' . $result['location'] );
    6565
     66        if ( $request->get_param('dismiss') ) {
     67            return $this->self_dismiss( $request, $plugin );
     68        }
     69
    6670        // Toggle the postmeta value. Note that there is a race condition here.
    6771        $did = '';
     
    8387    }
    8488
     89    /**
     90     * Endpoint special case to dismiss the missing blueprint notice.
     91     *
     92     * @param \WP_REST_Request $request The Rest API Request.
     93     * @param object $plugin The plugin post.
     94     * @return bool True if the toggle was successful.
     95     */
     96    public function self_dismiss( $request, $plugin ) {
     97        $result = [
     98            'location' => wp_get_referer() ?: get_permalink( $plugin ),
     99        ];
     100
     101        // Change the value from 1 to 0. This will persist and prevent it from being added again.
     102        update_post_meta( $plugin->ID, '_missing_blueprint_notice', 0, 1 );
     103
     104        return $result;
     105    }
    85106}
Note: See TracChangeset for help on using the changeset viewer.