Smart Custom Fields - Version 4.1.5

Version Description

  • Fix ajax bug.
Download this release

Release Info

Developer inc2734
Plugin Icon wp plugin Smart Custom Fields
Version 4.1.5
Comparing to
See all releases

Code changes from version 4.1.4 to 4.1.5

classes/class.rest-api.php CHANGED
@@ -22,7 +22,7 @@ class Smart_Custom_Fields_Rest_API {
22
  */
23
  public function register_rest_api_routes() {
24
  register_rest_route(
25
- SCF_Config::PREFIX . 'api',
26
  '/search/posts',
27
  array(
28
  'methods' => 'GET',
22
  */
23
  public function register_rest_api_routes() {
24
  register_rest_route(
25
+ SCF_Config::PREFIX . 'api/v2',
26
  '/search/posts',
27
  array(
28
  'methods' => 'GET',
classes/controller/class.settings.php CHANGED
@@ -143,7 +143,8 @@ class Smart_Custom_Fields_Controller_Settings {
143
  'autocomplete_placeholder' => esc_html__( 'Type to search a post or page', 'smart-custom-fields' ),
144
  'loading' => esc_html__( 'Loading...', 'smart-custom-fields' ),
145
  'load_more' => esc_html__( 'Load more', 'smart-custom-fields' ),
146
- 'rest_api_url' => rest_url( SCF_Config::PREFIX . 'api/search/posts' ),
 
147
  )
148
  );
149
 
143
  'autocomplete_placeholder' => esc_html__( 'Type to search a post or page', 'smart-custom-fields' ),
144
  'loading' => esc_html__( 'Loading...', 'smart-custom-fields' ),
145
  'load_more' => esc_html__( 'Load more', 'smart-custom-fields' ),
146
+ 'rest_api_url' => rest_url( SCF_Config::PREFIX . 'api/v2/search/posts' ),
147
+ 'nonce' => wp_create_nonce( 'wp_rest' ),
148
  )
149
  );
150
 
js/settings.js CHANGED
@@ -214,20 +214,20 @@ jQuery( function( $ ) {
214
  function string_to_slug(str) {
215
  str = str.replace(/^\s+|\s+$/g, ""); // trim
216
  str = str.toLowerCase();
217
-
218
  // remove accents, swap ñ for n, etc
219
  var from = "åàáãäâèéëêìíïîòóöôùúüûñç·/-,:;";
220
  var to = "aaaaaaeeeeiiiioooouuuunc______";
221
-
222
  for (var i = 0, l = from.length; i < l; i++) {
223
  str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i));
224
  }
225
-
226
  str = str
227
  .replace(/[^a-z0-9 -]/g, "") // remove invalid chars
228
  .replace(/\s+/g, "_") // collapse whitespace and replace by -
229
  .replace(/-+/g, "_"); // collapse dashes
230
-
231
  return str;
232
  }
233
 
@@ -243,7 +243,7 @@ jQuery( function( $ ) {
243
  }
244
  } );
245
  } );
246
-
247
  /**
248
  * Add autocomplete (selectivity plguin) in posts condition field
249
  * https://github.com/arendjr/selectivity
@@ -254,7 +254,12 @@ jQuery( function( $ ) {
254
  placeholder: smart_cf_settings.autocomplete_placeholder,
255
  ajax: {
256
  url: smart_cf_settings.rest_api_url,
257
- quietMillis:200
 
 
 
 
 
258
  },
259
  templates: {
260
  multipleSelectInput: function(options) {
@@ -299,7 +304,7 @@ jQuery( function( $ ) {
299
  '>' +
300
  '</div>';
301
  }
302
-
303
  return (
304
  '<div class="selectivity-dropdown' +
305
  extraClass +
@@ -316,17 +321,17 @@ jQuery( function( $ ) {
316
  return '<div class="selectivity-load-more">' + smart_cf_settings.load_more + '</div>';
317
  },
318
  }
319
- });
320
  $('#smart-cf-autocomplete-condition-post').on('change', function() {
321
  var data = $(this).selectivity('value');
322
  $('[name="smart-cf-condition-post-ids"]').val(data);
323
- });
324
-
325
  /**
326
  * Add IOS style for checkboxes
327
  */
328
  $('.smart-cf-group .smart-cf-group-repeat label, #smart-cf-meta-box-condition-post, #smart-cf-meta-box-condition-profile, #smart-cf-meta-box-condition-taxonomy, #smart-cf-meta-box-condition-options-page')
329
  .find('input[type=checkbox]')
330
  .iosCheckbox();
331
-
332
- } );
214
  function string_to_slug(str) {
215
  str = str.replace(/^\s+|\s+$/g, ""); // trim
216
  str = str.toLowerCase();
217
+
218
  // remove accents, swap ñ for n, etc
219
  var from = "åàáãäâèéëêìíïîòóöôùúüûñç·/-,:;";
220
  var to = "aaaaaaeeeeiiiioooouuuunc______";
221
+
222
  for (var i = 0, l = from.length; i < l; i++) {
223
  str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i));
224
  }
225
+
226
  str = str
227
  .replace(/[^a-z0-9 -]/g, "") // remove invalid chars
228
  .replace(/\s+/g, "_") // collapse whitespace and replace by -
229
  .replace(/-+/g, "_"); // collapse dashes
230
+
231
  return str;
232
  }
233
 
243
  }
244
  } );
245
  } );
246
+
247
  /**
248
  * Add autocomplete (selectivity plguin) in posts condition field
249
  * https://github.com/arendjr/selectivity
254
  placeholder: smart_cf_settings.autocomplete_placeholder,
255
  ajax: {
256
  url: smart_cf_settings.rest_api_url,
257
+ quietMillis: 200,
258
+ params: function(term, offset) {
259
+ return {
260
+ _wpnonce: smart_cf_settings.nonce,
261
+ };
262
+ },
263
  },
264
  templates: {
265
  multipleSelectInput: function(options) {
304
  '>' +
305
  '</div>';
306
  }
307
+
308
  return (
309
  '<div class="selectivity-dropdown' +
310
  extraClass +
321
  return '<div class="selectivity-load-more">' + smart_cf_settings.load_more + '</div>';
322
  },
323
  }
324
+ });
325
  $('#smart-cf-autocomplete-condition-post').on('change', function() {
326
  var data = $(this).selectivity('value');
327
  $('[name="smart-cf-condition-post-ids"]').val(data);
328
+ });
329
+
330
  /**
331
  * Add IOS style for checkboxes
332
  */
333
  $('.smart-cf-group .smart-cf-group-repeat label, #smart-cf-meta-box-condition-post, #smart-cf-meta-box-condition-profile, #smart-cf-meta-box-condition-taxonomy, #smart-cf-meta-box-condition-options-page')
334
  .find('input[type=checkbox]')
335
  .iosCheckbox();
336
+
337
+ } );
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40
4
  Tags: plugin, custom field, custom, field, meta, meta field, repeat, repeatable
5
  Requires at least: 3.9
6
  Tested up to: 5.5.0
7
- Stable tag: 4.1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -129,6 +129,9 @@ You can translate this plugin into your language by using [GlotPress](https://tr
129
 
130
  == Changelog ==
131
 
 
 
 
132
  = 4.1.4 =
133
  * WordPress 5.5 support
134
  * Changed so that the reusable block post type is not displayed in the conditional judgment.
4
  Tags: plugin, custom field, custom, field, meta, meta field, repeat, repeatable
5
  Requires at least: 3.9
6
  Tested up to: 5.5.0
7
+ Stable tag: 4.1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
129
 
130
  == Changelog ==
131
 
132
+ = 4.1.5 =
133
+ * Fix ajax bug.
134
+
135
  = 4.1.4 =
136
  * WordPress 5.5 support
137
  * Changed so that the reusable block post type is not displayed in the conditional judgment.
smart-custom-fields.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin name: Smart Custom Fields
4
  * Plugin URI: https://github.com/inc2734/smart-custom-fields/
5
  * Description: Smart Custom Fields is a simple plugin that management custom fields.
6
- * Version: 4.1.4
7
  * Author: inc2734
8
  * Author URI: https://2inc.org
9
  * Text Domain: smart-custom-fields
3
  * Plugin name: Smart Custom Fields
4
  * Plugin URI: https://github.com/inc2734/smart-custom-fields/
5
  * Description: Smart Custom Fields is a simple plugin that management custom fields.
6
+ * Version: 4.1.5
7
  * Author: inc2734
8
  * Author URI: https://2inc.org
9
  * Text Domain: smart-custom-fields