Conversation
inc/class-shortcode-ui.php
Outdated
| 'thumbnailImage' => wp_create_nonce( 'shortcode-ui-get-thumbnail-image' ), | ||
| ), | ||
| 'urls' => array( | ||
| 'preview' => home_url( '/wp-json/shortcode-ui/v1/preview' ), |
There was a problem hiding this comment.
We should use rest_url() here, to accommodate non-pretty permalinks as well.
|
Looks pretty good!
Modernization is the key benefit, I think. Also, when batch
Given we aren't performing a write operation, I think we should be using |
inc/shortcode-ui.php
Outdated
| add_action( 'wp_enqueue_editor', 'shortcode_ui_action_wp_enqueue_editor' ); | ||
| add_action( 'media_buttons', 'shortcode_ui_action_media_buttons' ); | ||
| add_action( 'wp_ajax_bulk_do_shortcode', 'shortcode_ui_handle_ajax_bulk_do_shortcode' ); | ||
| add_filter( 'wp_editor_settings', 'shortcode_ui_filter_wp_editor_settings', 10, 2 ); |
There was a problem hiding this comment.
Are we removing the singleton then?
There was a problem hiding this comment.
We discussed this somewhere... but this is for a separate PR ;)
|
Removed some stuff I committed by accident. Updated PR to use |
Yeah that would be really neat |
inc/class-shortcode-ui.php
Outdated
| @@ -68,9 +68,34 @@ private function setup_actions() { | |||
| add_action( 'admin_enqueue_scripts', array( $this, 'action_admin_enqueue_scripts' ) ); | |||
| add_action( 'wp_enqueue_editor', array( $this, 'action_wp_enqueue_editor' ) ); | |||
| add_action( 'wp_ajax_bulk_do_shortcode', array( $this, 'handle_ajax_bulk_do_shortcode' ) ); | |||
There was a problem hiding this comment.
We can remove this registration, right?
|
@mattheu Can you fix the failed build? Looks good to me otherwise. |
inc/class-shortcode-ui.php
Outdated
|
|
||
| $responses = array(); | ||
| public function handle_shortcode_preview( WP_REST_Request $request ) { | ||
| return $this->get_shortcode_preview( $request->get_param( 'query' ) ); |
There was a problem hiding this comment.
I'm not sure what this function is doing, but we don't currently have a get_shortcode_preview() method here...
I think this functionality might be vestigial anyways, currently all previews are bulk requests even if they're only for one shortcode.
|
This looks much cleaner than before. I like all the changes here, and doing this through the REST API makes it potentially discoverable for other uses. |
|
Added a permission callback to the requests to check the user has the cap to edit the post. |
|
TODO
|
|
I've added some tests for this. Should be good to go. @danielbachhuber would be good if you could give this a once over. |
|
I have a concern about using the REST API for this. Namely, shortcodes may render differently depending on the URL that the shortcode appears on. In the Customizer, the Selective Refresh API makes requests to render partials by making an Ajax request to the actual URL that the partial (e.g. widget) appears on, and a |
|
Hmm thats a good point - and sounds like a good workaround. This would affect the current implementation too. |
|
Lets push this to a future release. Too big for 0.7.0 |
How about using the rest API infrastructure in core for previews?
get previewdoes feel a bit odd. Any issues using GET instead?Also deleted the legacy 'fetch' code which is no longer used - including tests. Becomes apparent that we don't have tests for the fetcher which we probably should - but this can be handled separately.