Skip to content

Commit 844af67

Browse files
authored
Backport: Update SCF to include all 6.4.3 fixes. (#207)
* Land the PHP stuff * Backport field-group and input * Added dompurify * Update acf.min.js * Update pro js * Fix more PHP backports * Fix indent * Use a better composer approach * Remove not needed utf function
1 parent 60cad18 commit 844af67

23 files changed

+465
-202
lines changed

assets/src/js/_acf-condition-types.js

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
const template = function ( selection ) {
7272
return (
7373
`<span class="acf-${ typeAttr }-select-name acf-conditional-select-name">` +
74-
acf.escHtml( selection.text ) +
74+
acf.strEscape( selection.text ) +
7575
'</span>'
7676
);
7777
};
@@ -84,7 +84,7 @@
8484
'<span class="' +
8585
classes +
8686
'">' +
87-
acf.escHtml( results.text ) +
87+
acf.strEscape( results.text ) +
8888
'</span>' +
8989
`<span class="acf-${ typeAttr }-select-id acf-conditional-select-id">` +
9090
( results.id ? results.id : '' ) +
@@ -558,16 +558,14 @@
558558
type: 'hasPostObject',
559559
operator: '==',
560560
label: __( 'Post is equal to' ),
561-
fieldTypes: [
562-
'post_object',
563-
],
561+
fieldTypes: [ 'post_object' ],
564562
match: function ( rule, field ) {
565563
return isEqualToNumber( rule.value, field.val() );
566564
},
567565
choices: function ( fieldObject ) {
568566
return conditionalSelect2( fieldObject, 'post_object' );
569567
},
570-
});
568+
} );
571569

572570
acf.registerConditionType( HasPostObject );
573571

@@ -580,16 +578,14 @@
580578
type: 'hasPostObjectNotEqual',
581579
operator: '!==',
582580
label: __( 'Post is not equal to' ),
583-
fieldTypes: [
584-
'post_object',
585-
],
581+
fieldTypes: [ 'post_object' ],
586582
match: function ( rule, field ) {
587583
return ! isEqualToNumber( rule.value, field.val() );
588584
},
589585
choices: function ( fieldObject ) {
590586
return conditionalSelect2( fieldObject, 'post_object' );
591587
},
592-
});
588+
} );
593589

594590
acf.registerConditionType( HasPostObjectNotEqual );
595591

@@ -602,9 +598,7 @@
602598
type: 'containsPostObject',
603599
operator: '==contains',
604600
label: __( 'Posts contain' ),
605-
fieldTypes: [
606-
'post_object',
607-
],
601+
fieldTypes: [ 'post_object' ],
608602
match: function ( rule, field ) {
609603
const val = field.val();
610604
const ruleVal = rule.value;
@@ -620,7 +614,7 @@
620614
choices: function ( fieldObject ) {
621615
return conditionalSelect2( fieldObject, 'post_object' );
622616
},
623-
});
617+
} );
624618

625619
acf.registerConditionType( containsPostObject );
626620

@@ -633,16 +627,14 @@
633627
type: 'containsNotPostObject',
634628
operator: '!=contains',
635629
label: __( 'Posts do not contain' ),
636-
fieldTypes: [
637-
'post_object',
638-
],
630+
fieldTypes: [ 'post_object' ],
639631
match: function ( rule, field ) {
640632
const val = field.val();
641633
const ruleVal = rule.value;
642634

643635
let match = true;
644636
if ( val instanceof Array ) {
645-
match = ! val.includes( ruleVal );
637+
match = ! val.includes( ruleVal );
646638
} else {
647639
match = val !== ruleVal;
648640
}
@@ -651,7 +643,7 @@
651643
choices: function ( fieldObject ) {
652644
return conditionalSelect2( fieldObject, 'post_object' );
653645
},
654-
});
646+
} );
655647

656648
acf.registerConditionType( containsNotPostObject );
657649

@@ -664,20 +656,18 @@
664656
type: 'hasAnyPostObject',
665657
operator: '!=empty',
666658
label: __( 'Has any post selected' ),
667-
fieldTypes: [
668-
'post_object',
669-
],
659+
fieldTypes: [ 'post_object' ],
670660
match: function ( rule, field ) {
671661
let val = field.val();
672662
if ( val instanceof Array ) {
673663
val = val.length;
674664
}
675-
return !!val;
665+
return !! val;
676666
},
677667
choices: function () {
678668
return '<input type="text" disabled />';
679669
},
680-
});
670+
} );
681671

682672
acf.registerConditionType( HasAnyPostObject );
683673

@@ -690,20 +680,18 @@
690680
type: 'hasNoPostObject',
691681
operator: '==empty',
692682
label: __( 'Has no post selected' ),
693-
fieldTypes: [
694-
'post_object',
695-
],
683+
fieldTypes: [ 'post_object' ],
696684
match: function ( rule, field ) {
697685
let val = field.val();
698686
if ( val instanceof Array ) {
699687
val = val.length;
700688
}
701-
return !val;
689+
return ! val;
702690
},
703691
choices: function () {
704692
return '<input type="text" disabled />';
705693
},
706-
});
694+
} );
707695

708696
acf.registerConditionType( HasNoPostObject );
709697

assets/src/js/_acf-screen.js

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -298,36 +298,23 @@
298298

299299
// Create postbox if doesn't exist.
300300
if ( ! postbox ) {
301-
var wpMinorVersion = parseFloat( acf.get( 'wp_version' ) );
302-
if ( wpMinorVersion >= 5.5 ) {
303-
var postboxHeader = [
304-
'<div class="postbox-header">',
305-
'<h2 class="hndle ui-sortable-handle">',
306-
'<span>' + acf.escHtml( result.title ) + '</span>',
307-
'</h2>',
308-
'<div class="handle-actions hide-if-no-js">',
309-
'<button type="button" class="handlediv" aria-expanded="true">',
310-
'<span class="screen-reader-text">Toggle panel: ' +
311-
acf.escHtml( result.title ) +
312-
'</span>',
313-
'<span class="toggle-indicator" aria-hidden="true"></span>',
314-
'</button>',
315-
'</div>',
316-
'</div>',
317-
].join( '' );
318-
} else {
319-
var postboxHeader = [
320-
'<button type="button" class="handlediv" aria-expanded="true">',
321-
'<span class="screen-reader-text">Toggle panel: ' +
322-
acf.escHtml( result.title ) +
323-
'</span>',
324-
'<span class="toggle-indicator" aria-hidden="true"></span>',
325-
'</button>',
326-
'<h2 class="hndle ui-sortable-handle">',
327-
'<span>' + acf.escHtml( result.title ) + '</span>',
328-
'</h2>',
329-
].join( '' );
330-
}
301+
var postboxHeader = [
302+
'<div class="postbox-header">',
303+
'<h2 class="hndle ui-sortable-handle">',
304+
'<span>' + result.title + '</span>',
305+
'</h2>',
306+
'<div class="handle-actions hide-if-no-js">',
307+
'<button type="button" class="handlediv" aria-expanded="true">',
308+
'<span class="screen-reader-text">' +
309+
acf.__( 'Toggle panel' ) +
310+
': ' +
311+
result.title +
312+
'</span>',
313+
'<span class="toggle-indicator" aria-hidden="true"></span>',
314+
'</button>',
315+
'</div>',
316+
'</div>',
317+
].join( '' );
331318

332319
// Ensure result.classes is set.
333320
if ( ! result.classes ) result.classes = '';
@@ -515,13 +502,7 @@
515502
acf.unload.disable();
516503

517504
// Refresh metaboxes since WP 5.3.
518-
var wpMinorVersion = parseFloat( acf.get( 'wp_version' ) );
519-
if ( wpMinorVersion >= 5.3 ) {
520-
this.addAction(
521-
'refresh_post_screen',
522-
this.onRefreshPostScreen
523-
);
524-
}
505+
this.addAction( 'refresh_post_screen', this.onRefreshPostScreen );
525506

526507
// Trigger "refresh" after WP has moved metaboxes into place.
527508
wp.domReady( acf.refresh );
@@ -532,11 +513,11 @@
532513
var attributes = [ 'template', 'parent', 'format' ];
533514

534515
// Append taxonomy attribute names to this list.
535-
( wp.data.select( 'core' ).getTaxonomies() || [] ).map( function (
536-
taxonomy
537-
) {
538-
attributes.push( taxonomy.rest_base );
539-
} );
516+
( wp.data.select( 'core' ).getTaxonomies() || [] ).map(
517+
function ( taxonomy ) {
518+
attributes.push( taxonomy.rest_base );
519+
}
520+
);
540521

541522
// Get relevant current post edits.
542523
var _postEdits = wp.data.select( 'core/editor' ).getPostEdits();
@@ -614,17 +595,15 @@
614595
* @return void
615596
*/
616597
onRefreshPostScreen: function ( data ) {
617-
618598
// Extract vars.
619599
var select = wp.data.select( 'core/edit-post' );
620600
var dispatch = wp.data.dispatch( 'core/edit-post' );
621601

622602
// Load current metabox locations and data.
623603
var locations = {};
624604
select.getActiveMetaBoxLocations().map( function ( location ) {
625-
locations[ location ] = select.getMetaBoxesPerLocation(
626-
location
627-
);
605+
locations[ location ] =
606+
select.getMetaBoxesPerLocation( location );
628607
} );
629608

630609
// Generate flat array of existing ids.

0 commit comments

Comments
 (0)