diff --git a/inc/fields/class-shortcode-ui-field-post-select.php b/inc/fields/class-shortcode-ui-field-post-select.php index b49d3b23..c720e7f3 100644 --- a/inc/fields/class-shortcode-ui-field-post-select.php +++ b/inc/fields/class-shortcode-ui-field-post-select.php @@ -85,6 +85,7 @@ public function action_wp_ajax_shortcode_ui_post_field() { $nonce = isset( $_GET['nonce'] ) ? sanitize_text_field( $_GET['nonce'] ) : null; $requested_shortcode = isset( $_GET['shortcode'] ) ? sanitize_text_field( $_GET['shortcode'] ) : null; $requested_attr = isset( $_GET['attr'] ) ? sanitize_text_field( $_GET['attr'] ) : null; + $postid = isset( $_GET['postid'] ) ? absint( $_GET['postid'] ) : 0; $response = array( 'items' => array(), @@ -135,6 +136,8 @@ public function action_wp_ajax_shortcode_ui_post_field() { $query_args['ignore_sticky_posts'] = true; } + $query_args = apply_filters( 'shortcode_ui_post_field_query_args', $query_args, $postid ); + $query = new WP_Query( $query_args ); foreach ( $query->posts as $post_id ) { diff --git a/js/build/shortcode-ui.js b/js/build/shortcode-ui.js index 1b50d79c..a67779f6 100644 --- a/js/build/shortcode-ui.js +++ b/js/build/shortcode-ui.js @@ -1072,7 +1072,7 @@ sui.views.editAttributeFieldPostSelect = sui.views.editAttributeSelect2Field.ext ajaxData: { action : 'shortcode_ui_post_field', - nonce : shortcodeUiPostFieldData.nonce, + nonce : shortcodeUiPostFieldData.nonce }, events: { @@ -1847,7 +1847,8 @@ sui.views.editAttributeSelect2Field = sui.views.editAttributeField.extend( { s : params.term, // search term page : params.page, shortcode : self.shortcode.get( 'shortcode_tag'), - attr : self.model.get( 'attr' ) + attr : self.model.get( 'attr' ), + postid : $( '#post_ID' ).val() }, self.ajaxData ); }, processResults: function (response, params) { diff --git a/js/src/views/edit-attribute-field-post-select.js b/js/src/views/edit-attribute-field-post-select.js index 60eb0100..bf881b70 100644 --- a/js/src/views/edit-attribute-field-post-select.js +++ b/js/src/views/edit-attribute-field-post-select.js @@ -9,7 +9,7 @@ sui.views.editAttributeFieldPostSelect = sui.views.editAttributeSelect2Field.ext ajaxData: { action : 'shortcode_ui_post_field', - nonce : shortcodeUiPostFieldData.nonce, + nonce : shortcodeUiPostFieldData.nonce }, events: { diff --git a/js/src/views/select2-field.js b/js/src/views/select2-field.js index 5ef5c860..b433bedd 100644 --- a/js/src/views/select2-field.js +++ b/js/src/views/select2-field.js @@ -116,7 +116,8 @@ sui.views.editAttributeSelect2Field = sui.views.editAttributeField.extend( { s : params.term, // search term page : params.page, shortcode : self.shortcode.get( 'shortcode_tag'), - attr : self.model.get( 'attr' ) + attr : self.model.get( 'attr' ), + postid : $( '#post_ID' ).val() }, self.ajaxData ); }, processResults: function (response, params) {