bindings
6 months ago
commands
1 week ago
pro
1 week ago
_acf-compatibility.js
1 year ago
_acf-condition-types.js
7 months ago
_acf-condition.js
1 year ago
_acf-conditions.js
1 year ago
_acf-field-accordion.js
6 months ago
_acf-field-button-group.js
7 months ago
_acf-field-checkbox.js
1 month ago
_acf-field-color-picker.js
7 months ago
_acf-field-date-picker.js
1 month ago
_acf-field-date-time-picker.js
1 month ago
_acf-field-file.js
1 month ago
_acf-field-google-map.js
6 months ago
_acf-field-icon-picker.js
1 month ago
_acf-field-image.js
1 month ago
_acf-field-link.js
1 year ago
_acf-field-oembed.js
1 month ago
_acf-field-page-link.js
1 year ago
_acf-field-post-object.js
1 year ago
_acf-field-radio.js
1 month ago
_acf-field-range.js
1 year ago
_acf-field-relationship.js
1 month ago
_acf-field-select.js
1 month ago
_acf-field-tab.js
3 weeks ago
_acf-field-taxonomy.js
7 months ago
_acf-field-time-picker.js
1 month ago
_acf-field-true-false.js
1 month ago
_acf-field-url.js
1 year ago
_acf-field-user.js
1 year ago
_acf-field-wysiwyg.js
1 month ago
_acf-field.js
1 year ago
_acf-fields.js
1 year ago
_acf-helpers.js
1 year ago
_acf-hooks.js
1 year ago
_acf-internal-post-type.js
7 months ago
_acf-media.js
1 week ago
_acf-modal.js
1 year ago
_acf-model.js
1 year ago
_acf-notice.js
7 months ago
_acf-panel.js
1 year ago
_acf-popup.js
7 months ago
_acf-postbox.js
1 year ago
_acf-screen.js
10 months ago
_acf-select2.js
1 year ago
_acf-tinymce.js
6 months ago
_acf-tooltip.js
10 months ago
_acf-unload.js
1 year ago
_acf-validation.js
1 month ago
_acf.js
7 months ago
_browse-fields-modal.js
7 months ago
_field-group-compatibility.js
1 year ago
_field-group-conditions.js
1 year ago
_field-group-field.js
3 months ago
_field-group-fields.js
10 months ago
_field-group-locations.js
1 year ago
_field-group-settings.js
1 year ago
_field-group.js
10 months ago
acf-escaped-html-notice.js
1 year ago
acf-field-group.js
1 year ago
acf-input.js
1 year ago
acf-internal-post-type.js
1 year ago
acf.js
1 year ago
_acf-compatibility.js
724 lines
| 1 | ( function ( $, undefined ) { |
| 2 | /** |
| 3 | * acf.newCompatibility |
| 4 | * |
| 5 | * Inserts a new __proto__ object compatibility layer |
| 6 | * |
| 7 | * @date 15/2/18 |
| 8 | * @since ACF 5.6.9 |
| 9 | * |
| 10 | * @param object instance The object to modify. |
| 11 | * @param object compatibilty Optional. The compatibility layer. |
| 12 | * @return object compatibilty |
| 13 | */ |
| 14 | |
| 15 | acf.newCompatibility = function ( instance, compatibilty ) { |
| 16 | // defaults |
| 17 | compatibilty = compatibilty || {}; |
| 18 | |
| 19 | // inherit __proto_- |
| 20 | compatibilty.__proto__ = instance.__proto__; |
| 21 | |
| 22 | // inject |
| 23 | instance.__proto__ = compatibilty; |
| 24 | |
| 25 | // reference |
| 26 | instance.compatibility = compatibilty; |
| 27 | |
| 28 | // return |
| 29 | return compatibilty; |
| 30 | }; |
| 31 | |
| 32 | /** |
| 33 | * acf.getCompatibility |
| 34 | * |
| 35 | * Returns the compatibility layer for a given instance |
| 36 | * |
| 37 | * @date 13/3/18 |
| 38 | * @since ACF 5.6.9 |
| 39 | * |
| 40 | * @param object instance The object to look in. |
| 41 | * @return object|null compatibility The compatibility object or null on failure. |
| 42 | */ |
| 43 | |
| 44 | acf.getCompatibility = function ( instance ) { |
| 45 | return instance.compatibility || null; |
| 46 | }; |
| 47 | |
| 48 | /** |
| 49 | * acf (compatibility) |
| 50 | * |
| 51 | * Compatibility layer for the acf object |
| 52 | * |
| 53 | * @date 15/2/18 |
| 54 | * @since ACF 5.6.9 |
| 55 | * |
| 56 | * @param void |
| 57 | * @return void |
| 58 | */ |
| 59 | |
| 60 | var _acf = acf.newCompatibility( acf, { |
| 61 | // storage |
| 62 | l10n: {}, |
| 63 | o: {}, |
| 64 | fields: {}, |
| 65 | |
| 66 | // changed function names |
| 67 | update: acf.set, |
| 68 | add_action: acf.addAction, |
| 69 | remove_action: acf.removeAction, |
| 70 | do_action: acf.doAction, |
| 71 | add_filter: acf.addFilter, |
| 72 | remove_filter: acf.removeFilter, |
| 73 | apply_filters: acf.applyFilters, |
| 74 | parse_args: acf.parseArgs, |
| 75 | disable_el: acf.disable, |
| 76 | disable_form: acf.disable, |
| 77 | enable_el: acf.enable, |
| 78 | enable_form: acf.enable, |
| 79 | update_user_setting: acf.updateUserSetting, |
| 80 | prepare_for_ajax: acf.prepareForAjax, |
| 81 | is_ajax_success: acf.isAjaxSuccess, |
| 82 | remove_el: acf.remove, |
| 83 | remove_tr: acf.remove, |
| 84 | str_replace: acf.strReplace, |
| 85 | render_select: acf.renderSelect, |
| 86 | get_uniqid: acf.uniqid, |
| 87 | serialize_form: acf.serialize, |
| 88 | esc_html: acf.strEscape, |
| 89 | str_sanitize: acf.strSanitize, |
| 90 | } ); |
| 91 | |
| 92 | _acf._e = function ( k1, k2 ) { |
| 93 | // defaults |
| 94 | k1 = k1 || ''; |
| 95 | k2 = k2 || ''; |
| 96 | |
| 97 | // compatibility |
| 98 | var compatKey = k2 ? k1 + '.' + k2 : k1; |
| 99 | var compats = { |
| 100 | 'image.select': 'Select Image', |
| 101 | 'image.edit': 'Edit Image', |
| 102 | 'image.update': 'Update Image', |
| 103 | }; |
| 104 | if ( compats[ compatKey ] ) { |
| 105 | return acf.__( compats[ compatKey ] ); |
| 106 | } |
| 107 | |
| 108 | // try k1 |
| 109 | var string = this.l10n[ k1 ] || ''; |
| 110 | |
| 111 | // try k2 |
| 112 | if ( k2 ) { |
| 113 | string = string[ k2 ] || ''; |
| 114 | } |
| 115 | |
| 116 | // return |
| 117 | return string; |
| 118 | }; |
| 119 | |
| 120 | _acf.get_selector = function ( s ) { |
| 121 | // vars |
| 122 | var selector = '.acf-field'; |
| 123 | |
| 124 | // bail early if no search |
| 125 | if ( ! s ) { |
| 126 | return selector; |
| 127 | } |
| 128 | |
| 129 | // compatibility with object |
| 130 | if ( $.isPlainObject( s ) ) { |
| 131 | if ( $.isEmptyObject( s ) ) { |
| 132 | return selector; |
| 133 | } else { |
| 134 | for ( var k in s ) { |
| 135 | s = s[ k ]; |
| 136 | break; |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | // append |
| 142 | selector += '-' + s; |
| 143 | |
| 144 | // replace underscores (split/join replaces all and is faster than regex!) |
| 145 | selector = acf.strReplace( '_', '-', selector ); |
| 146 | |
| 147 | // remove potential double up |
| 148 | selector = acf.strReplace( 'field-field-', 'field-', selector ); |
| 149 | |
| 150 | // return |
| 151 | return selector; |
| 152 | }; |
| 153 | |
| 154 | _acf.get_fields = function ( s, $el, all ) { |
| 155 | // args |
| 156 | var args = { |
| 157 | is: s || '', |
| 158 | parent: $el || false, |
| 159 | suppressFilters: all || false, |
| 160 | }; |
| 161 | |
| 162 | // change 'field_123' to '.acf-field-123' |
| 163 | if ( args.is ) { |
| 164 | args.is = this.get_selector( args.is ); |
| 165 | } |
| 166 | |
| 167 | // return |
| 168 | return acf.findFields( args ); |
| 169 | }; |
| 170 | |
| 171 | _acf.get_field = function ( s, $el ) { |
| 172 | // get fields |
| 173 | var $fields = this.get_fields.apply( this, arguments ); |
| 174 | |
| 175 | // return |
| 176 | if ( $fields.length ) { |
| 177 | return $fields.first(); |
| 178 | } else { |
| 179 | return false; |
| 180 | } |
| 181 | }; |
| 182 | |
| 183 | _acf.get_closest_field = function ( $el, s ) { |
| 184 | return $el.closest( this.get_selector( s ) ); |
| 185 | }; |
| 186 | |
| 187 | _acf.get_field_wrap = function ( $el ) { |
| 188 | return $el.closest( this.get_selector() ); |
| 189 | }; |
| 190 | |
| 191 | _acf.get_field_key = function ( $field ) { |
| 192 | return $field.data( 'key' ); |
| 193 | }; |
| 194 | |
| 195 | _acf.get_field_type = function ( $field ) { |
| 196 | return $field.data( 'type' ); |
| 197 | }; |
| 198 | |
| 199 | _acf.get_data = function ( $el, defaults ) { |
| 200 | return acf.parseArgs( $el.data(), defaults ); |
| 201 | }; |
| 202 | |
| 203 | _acf.maybe_get = function ( obj, key, value ) { |
| 204 | // default |
| 205 | if ( value === undefined ) { |
| 206 | value = null; |
| 207 | } |
| 208 | |
| 209 | // get keys |
| 210 | keys = String( key ).split( '.' ); |
| 211 | |
| 212 | // acf.isget |
| 213 | for ( var i = 0; i < keys.length; i++ ) { |
| 214 | if ( ! obj.hasOwnProperty( keys[ i ] ) ) { |
| 215 | return value; |
| 216 | } |
| 217 | obj = obj[ keys[ i ] ]; |
| 218 | } |
| 219 | return obj; |
| 220 | }; |
| 221 | |
| 222 | /** |
| 223 | * hooks |
| 224 | * |
| 225 | * Modify add_action and add_filter functions to add compatibility with changed $field parameter |
| 226 | * Using the acf.add_action() or acf.add_filter() functions will interpret new field parameters as jQuery $field |
| 227 | * |
| 228 | * @date 12/5/18 |
| 229 | * @since ACF 5.6.9 |
| 230 | * |
| 231 | * @param void |
| 232 | * @return void |
| 233 | */ |
| 234 | |
| 235 | var compatibleArgument = function ( arg ) { |
| 236 | return arg instanceof acf.Field ? arg.$el : arg; |
| 237 | }; |
| 238 | |
| 239 | var compatibleArguments = function ( args ) { |
| 240 | return acf.arrayArgs( args ).map( compatibleArgument ); |
| 241 | }; |
| 242 | |
| 243 | var compatibleCallback = function ( origCallback ) { |
| 244 | return function () { |
| 245 | // convert to compatible arguments |
| 246 | if ( arguments.length ) { |
| 247 | var args = compatibleArguments( arguments ); |
| 248 | |
| 249 | // add default argument for 'ready', 'append' and 'load' events |
| 250 | } else { |
| 251 | var args = [ $( document ) ]; |
| 252 | } |
| 253 | |
| 254 | // return |
| 255 | return origCallback.apply( this, args ); |
| 256 | }; |
| 257 | }; |
| 258 | |
| 259 | _acf.add_action = function ( action, callback, priority, context ) { |
| 260 | // handle multiple actions |
| 261 | var actions = action.split( ' ' ); |
| 262 | var length = actions.length; |
| 263 | if ( length > 1 ) { |
| 264 | for ( var i = 0; i < length; i++ ) { |
| 265 | action = actions[ i ]; |
| 266 | _acf.add_action.apply( this, arguments ); |
| 267 | } |
| 268 | return this; |
| 269 | } |
| 270 | |
| 271 | // single |
| 272 | var callback = compatibleCallback( callback ); |
| 273 | return acf.addAction.apply( this, arguments ); |
| 274 | }; |
| 275 | |
| 276 | _acf.add_filter = function ( action, callback, priority, context ) { |
| 277 | var callback = compatibleCallback( callback ); |
| 278 | return acf.addFilter.apply( this, arguments ); |
| 279 | }; |
| 280 | |
| 281 | /* |
| 282 | * acf.model |
| 283 | * |
| 284 | * This model acts as a scaffold for action.event driven modules |
| 285 | * |
| 286 | * @type object |
| 287 | * @date 8/09/2014 |
| 288 | * @since ACF 5.0.0 |
| 289 | * |
| 290 | * @param (object) |
| 291 | * @return (object) |
| 292 | */ |
| 293 | |
| 294 | _acf.model = { |
| 295 | actions: {}, |
| 296 | filters: {}, |
| 297 | events: {}, |
| 298 | extend: function ( args ) { |
| 299 | // extend |
| 300 | var model = $.extend( {}, this, args ); |
| 301 | |
| 302 | // setup actions |
| 303 | $.each( model.actions, function ( name, callback ) { |
| 304 | model._add_action( name, callback ); |
| 305 | } ); |
| 306 | |
| 307 | // setup filters |
| 308 | $.each( model.filters, function ( name, callback ) { |
| 309 | model._add_filter( name, callback ); |
| 310 | } ); |
| 311 | |
| 312 | // setup events |
| 313 | $.each( model.events, function ( name, callback ) { |
| 314 | model._add_event( name, callback ); |
| 315 | } ); |
| 316 | |
| 317 | // return |
| 318 | return model; |
| 319 | }, |
| 320 | |
| 321 | _add_action: function ( name, callback ) { |
| 322 | // split |
| 323 | var model = this, |
| 324 | data = name.split( ' ' ); |
| 325 | |
| 326 | // add missing priority |
| 327 | var name = data[ 0 ] || '', |
| 328 | priority = data[ 1 ] || 10; |
| 329 | |
| 330 | // add action |
| 331 | acf.add_action( name, model[ callback ], priority, model ); |
| 332 | }, |
| 333 | |
| 334 | _add_filter: function ( name, callback ) { |
| 335 | // split |
| 336 | var model = this, |
| 337 | data = name.split( ' ' ); |
| 338 | |
| 339 | // add missing priority |
| 340 | var name = data[ 0 ] || '', |
| 341 | priority = data[ 1 ] || 10; |
| 342 | |
| 343 | // add action |
| 344 | acf.add_filter( name, model[ callback ], priority, model ); |
| 345 | }, |
| 346 | |
| 347 | _add_event: function ( name, callback ) { |
| 348 | // vars |
| 349 | var model = this, |
| 350 | i = name.indexOf( ' ' ), |
| 351 | event = i > 0 ? name.substr( 0, i ) : name, |
| 352 | selector = i > 0 ? name.substr( i + 1 ) : ''; |
| 353 | |
| 354 | // event |
| 355 | var fn = function ( e ) { |
| 356 | // append $el to event object |
| 357 | e.$el = $( this ); |
| 358 | |
| 359 | // append $field to event object (used in field group) |
| 360 | if ( acf.field_group ) { |
| 361 | e.$field = e.$el.closest( '.acf-field-object' ); |
| 362 | } |
| 363 | |
| 364 | // event |
| 365 | if ( typeof model.event === 'function' ) { |
| 366 | e = model.event( e ); |
| 367 | } |
| 368 | |
| 369 | // callback |
| 370 | model[ callback ].apply( model, arguments ); |
| 371 | }; |
| 372 | |
| 373 | // add event |
| 374 | if ( selector ) { |
| 375 | $( document ).on( event, selector, fn ); |
| 376 | } else { |
| 377 | $( document ).on( event, fn ); |
| 378 | } |
| 379 | }, |
| 380 | |
| 381 | get: function ( name, value ) { |
| 382 | // defaults |
| 383 | value = value || null; |
| 384 | |
| 385 | // get |
| 386 | if ( typeof this[ name ] !== 'undefined' ) { |
| 387 | value = this[ name ]; |
| 388 | } |
| 389 | |
| 390 | // return |
| 391 | return value; |
| 392 | }, |
| 393 | |
| 394 | set: function ( name, value ) { |
| 395 | // set |
| 396 | this[ name ] = value; |
| 397 | |
| 398 | // function for 3rd party |
| 399 | if ( typeof this[ '_set_' + name ] === 'function' ) { |
| 400 | this[ '_set_' + name ].apply( this ); |
| 401 | } |
| 402 | |
| 403 | // return for chaining |
| 404 | return this; |
| 405 | }, |
| 406 | }; |
| 407 | |
| 408 | /* |
| 409 | * field |
| 410 | * |
| 411 | * This model sets up many of the field's interactions |
| 412 | * |
| 413 | * @type function |
| 414 | * @date 21/02/2014 |
| 415 | * @since ACF 3.5.1 |
| 416 | * |
| 417 | * @param n/a |
| 418 | * @return n/a |
| 419 | */ |
| 420 | |
| 421 | _acf.field = acf.model.extend( { |
| 422 | type: '', |
| 423 | o: {}, |
| 424 | $field: null, |
| 425 | _add_action: function ( name, callback ) { |
| 426 | // vars |
| 427 | var model = this; |
| 428 | |
| 429 | // update name |
| 430 | name = name + '_field/type=' + model.type; |
| 431 | |
| 432 | // add action |
| 433 | acf.add_action( name, function ( $field ) { |
| 434 | // focus |
| 435 | model.set( '$field', $field ); |
| 436 | |
| 437 | // callback |
| 438 | model[ callback ].apply( model, arguments ); |
| 439 | } ); |
| 440 | }, |
| 441 | |
| 442 | _add_filter: function ( name, callback ) { |
| 443 | // vars |
| 444 | var model = this; |
| 445 | |
| 446 | // update name |
| 447 | name = name + '_field/type=' + model.type; |
| 448 | |
| 449 | // add action |
| 450 | acf.add_filter( name, function ( $field ) { |
| 451 | // focus |
| 452 | model.set( '$field', $field ); |
| 453 | |
| 454 | // callback |
| 455 | model[ callback ].apply( model, arguments ); |
| 456 | } ); |
| 457 | }, |
| 458 | |
| 459 | _add_event: function ( name, callback ) { |
| 460 | // vars |
| 461 | var model = this, |
| 462 | event = name.substr( 0, name.indexOf( ' ' ) ), |
| 463 | selector = name.substr( name.indexOf( ' ' ) + 1 ), |
| 464 | context = acf.get_selector( model.type ); |
| 465 | |
| 466 | // add event |
| 467 | $( document ).on( event, context + ' ' + selector, function ( e ) { |
| 468 | // vars |
| 469 | var $el = $( this ); |
| 470 | var $field = acf.get_closest_field( $el, model.type ); |
| 471 | |
| 472 | // bail early if no field |
| 473 | if ( ! $field.length ) return; |
| 474 | |
| 475 | // focus |
| 476 | if ( ! $field.is( model.$field ) ) { |
| 477 | model.set( '$field', $field ); |
| 478 | } |
| 479 | |
| 480 | // append to event |
| 481 | e.$el = $el; |
| 482 | e.$field = $field; |
| 483 | |
| 484 | // callback |
| 485 | model[ callback ].apply( model, [ e ] ); |
| 486 | } ); |
| 487 | }, |
| 488 | |
| 489 | _set_$field: function () { |
| 490 | // callback |
| 491 | if ( typeof this.focus === 'function' ) { |
| 492 | this.focus(); |
| 493 | } |
| 494 | }, |
| 495 | |
| 496 | // depreciated |
| 497 | doFocus: function ( $field ) { |
| 498 | return this.set( '$field', $field ); |
| 499 | }, |
| 500 | } ); |
| 501 | |
| 502 | /** |
| 503 | * validation |
| 504 | * |
| 505 | * description |
| 506 | * |
| 507 | * @date 15/2/18 |
| 508 | * @since ACF 5.6.9 |
| 509 | * |
| 510 | * @param type $var Description. Default. |
| 511 | * @return type Description. |
| 512 | */ |
| 513 | |
| 514 | var _validation = acf.newCompatibility( acf.validation, { |
| 515 | remove_error: function ( $field ) { |
| 516 | acf.getField( $field ).removeError(); |
| 517 | }, |
| 518 | add_warning: function ( $field, message ) { |
| 519 | acf.getField( $field ).showNotice( { |
| 520 | text: message, |
| 521 | type: 'warning', |
| 522 | timeout: 1000, |
| 523 | } ); |
| 524 | }, |
| 525 | fetch: acf.validateForm, |
| 526 | enableSubmit: acf.enableSubmit, |
| 527 | disableSubmit: acf.disableSubmit, |
| 528 | showSpinner: acf.showSpinner, |
| 529 | hideSpinner: acf.hideSpinner, |
| 530 | unlockForm: acf.unlockForm, |
| 531 | lockForm: acf.lockForm, |
| 532 | } ); |
| 533 | |
| 534 | /** |
| 535 | * tooltip |
| 536 | * |
| 537 | * description |
| 538 | * |
| 539 | * @date 15/2/18 |
| 540 | * @since ACF 5.6.9 |
| 541 | * |
| 542 | * @param type $var Description. Default. |
| 543 | * @return type Description. |
| 544 | */ |
| 545 | |
| 546 | _acf.tooltip = { |
| 547 | tooltip: function ( text, $el ) { |
| 548 | var tooltip = acf.newTooltip( { |
| 549 | text: text, |
| 550 | target: $el, |
| 551 | } ); |
| 552 | |
| 553 | // return |
| 554 | return tooltip.$el; |
| 555 | }, |
| 556 | |
| 557 | temp: function ( text, $el ) { |
| 558 | var tooltip = acf.newTooltip( { |
| 559 | text: text, |
| 560 | target: $el, |
| 561 | timeout: 250, |
| 562 | } ); |
| 563 | }, |
| 564 | |
| 565 | confirm: function ( $el, callback, text, button_y, button_n ) { |
| 566 | var tooltip = acf.newTooltip( { |
| 567 | confirm: true, |
| 568 | text: text, |
| 569 | target: $el, |
| 570 | confirm: function () { |
| 571 | callback( true ); |
| 572 | }, |
| 573 | cancel: function () { |
| 574 | callback( false ); |
| 575 | }, |
| 576 | } ); |
| 577 | }, |
| 578 | |
| 579 | confirm_remove: function ( $el, callback ) { |
| 580 | var tooltip = acf.newTooltip( { |
| 581 | confirmRemove: true, |
| 582 | target: $el, |
| 583 | confirm: function () { |
| 584 | callback( true ); |
| 585 | }, |
| 586 | cancel: function () { |
| 587 | callback( false ); |
| 588 | }, |
| 589 | } ); |
| 590 | }, |
| 591 | }; |
| 592 | |
| 593 | /** |
| 594 | * tooltip |
| 595 | * |
| 596 | * description |
| 597 | * |
| 598 | * @date 15/2/18 |
| 599 | * @since ACF 5.6.9 |
| 600 | * |
| 601 | * @param type $var Description. Default. |
| 602 | * @return type Description. |
| 603 | */ |
| 604 | |
| 605 | _acf.media = new acf.Model( { |
| 606 | activeFrame: false, |
| 607 | actions: { |
| 608 | new_media_popup: 'onNewMediaPopup', |
| 609 | }, |
| 610 | |
| 611 | frame: function () { |
| 612 | return this.activeFrame; |
| 613 | }, |
| 614 | |
| 615 | onNewMediaPopup: function ( popup ) { |
| 616 | this.activeFrame = popup.frame; |
| 617 | }, |
| 618 | |
| 619 | popup: function ( props ) { |
| 620 | // update props |
| 621 | if ( props.mime_types ) { |
| 622 | props.allowedTypes = props.mime_types; |
| 623 | } |
| 624 | if ( props.id ) { |
| 625 | props.attachment = props.id; |
| 626 | } |
| 627 | |
| 628 | // new |
| 629 | var popup = acf.newMediaPopup( props ); |
| 630 | |
| 631 | // append |
| 632 | /* |
| 633 | if( props.selected ) { |
| 634 | popup.selected = props.selected; |
| 635 | } |
| 636 | */ |
| 637 | |
| 638 | // return |
| 639 | return popup.frame; |
| 640 | }, |
| 641 | } ); |
| 642 | |
| 643 | /** |
| 644 | * Select2 |
| 645 | * |
| 646 | * description |
| 647 | * |
| 648 | * @date 11/6/18 |
| 649 | * @since ACF 5.6.9 |
| 650 | * |
| 651 | * @param type $var Description. Default. |
| 652 | * @return type Description. |
| 653 | */ |
| 654 | |
| 655 | _acf.select2 = { |
| 656 | init: function ( $select, args, $field ) { |
| 657 | // compatible args |
| 658 | if ( args.allow_null ) { |
| 659 | args.allowNull = args.allow_null; |
| 660 | } |
| 661 | if ( args.ajax_action ) { |
| 662 | args.ajaxAction = args.ajax_action; |
| 663 | } |
| 664 | if ( $field ) { |
| 665 | args.field = acf.getField( $field ); |
| 666 | } |
| 667 | |
| 668 | // return |
| 669 | return acf.newSelect2( $select, args ); |
| 670 | }, |
| 671 | |
| 672 | destroy: function ( $select ) { |
| 673 | return acf.getInstance( $select ).destroy(); |
| 674 | }, |
| 675 | }; |
| 676 | |
| 677 | /** |
| 678 | * postbox |
| 679 | * |
| 680 | * description |
| 681 | * |
| 682 | * @date 11/6/18 |
| 683 | * @since ACF 5.6.9 |
| 684 | * |
| 685 | * @param type $var Description. Default. |
| 686 | * @return type Description. |
| 687 | */ |
| 688 | |
| 689 | _acf.postbox = { |
| 690 | render: function ( args ) { |
| 691 | // compatible args |
| 692 | if ( args.edit_url ) { |
| 693 | args.editLink = args.edit_url; |
| 694 | } |
| 695 | if ( args.edit_title ) { |
| 696 | args.editTitle = args.edit_title; |
| 697 | } |
| 698 | |
| 699 | // return |
| 700 | return acf.newPostbox( args ); |
| 701 | }, |
| 702 | }; |
| 703 | |
| 704 | /** |
| 705 | * acf.screen |
| 706 | * |
| 707 | * description |
| 708 | * |
| 709 | * @date 11/6/18 |
| 710 | * @since ACF 5.6.9 |
| 711 | * |
| 712 | * @param type $var Description. Default. |
| 713 | * @return type Description. |
| 714 | */ |
| 715 | |
| 716 | acf.newCompatibility( acf.screen, { |
| 717 | update: function () { |
| 718 | return this.set.apply( this, arguments ); |
| 719 | }, |
| 720 | fetch: acf.screen.check, |
| 721 | } ); |
| 722 | _acf.ajax = acf.screen; |
| 723 | } )( jQuery ); |
| 724 |