11<?php
2-
32/**
43 * ACF Internal Post Type List class
54 *
1615
1716if ( ! class_exists ( 'ACF_Admin_Internal_Post_Type_List ' ) ) :
1817
18+ /**
19+ * Internal Post Type List class.
20+ *
21+ * Adds logic to the edit page for internal post types.
22+ */
1923 class ACF_Admin_Internal_Post_Type_List {
2024
2125
@@ -150,12 +154,12 @@ public function current_screen() {
150154 add_filter ( "bulk_actions-edit- {$ this ->post_type }" , array ( $ this , 'admin_table_bulk_actions ' ), 10 , 1 );
151155 add_action ( 'admin_footer ' , array ( $ this , 'admin_footer ' ), 1 );
152156
153- if ( $ this -> view !== ' trash ' ) {
157+ if ( ' trash ' !== $ this -> view ) {
154158 add_filter ( 'page_row_actions ' , array ( $ this , 'page_row_actions ' ), 10 , 2 );
155159 }
156160
157161 // Add hooks for "sync" view.
158- if ( $ this -> view === ' sync ' ) {
162+ if ( ' sync ' === $ this -> view ) {
159163 add_action ( 'admin_footer ' , array ( $ this , 'admin_footer__sync ' ), 1 );
160164 }
161165
@@ -185,7 +189,7 @@ public function setup_sync() {
185189 continue ;
186190
187191 // Ignore not local "json".
188- } elseif ( $ local !== ' json ' ) {
192+ } elseif ( ' json ' === $ local ) {
189193 continue ;
190194
191195 // Append to sync if not yet in database.
@@ -271,7 +275,7 @@ public function get_registration_error_state() {
271275 * @return array
272276 */
273277 public function display_post_states ( $ post_states , $ post ) {
274- if ( $ post -> post_status === ' acf-disabled ' ) {
278+ if ( ' acf-disabled ' === $ post -> post_status ) {
275279 $ post_states ['acf-disabled ' ] = $ this ->get_disabled_post_state ();
276280 }
277281
@@ -483,7 +487,7 @@ public function admin_table_bulk_actions( $actions ) {
483487 }
484488
485489 if ( $ this ->sync ) {
486- if ( $ this -> view === ' sync ' ) {
490+ if ( ' sync ' === $ this -> view ) {
487491 $ actions = array ();
488492 }
489493 $ actions ['acfsync ' ] = __ ( 'Sync changes ' , 'secure-custom-fields ' );
@@ -501,7 +505,7 @@ public function admin_table_bulk_actions( $actions ) {
501505 * @param integer $count The number of items the action was performed on.
502506 * @return string
503507 */
504- public function get_action_notice_text ( $ action , $ count = 1 ) {
508+ public function get_action_notice_text ( $ action , $ count = 1 ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- Keep it for awareness when extending.
505509 return '' ;
506510 }
507511
@@ -773,19 +777,12 @@ public function check_sync() {
773777 $ synced = array ();
774778
775779 foreach ( $ this ->sync as $ key => $ post ) {
776- if ( $ post ['key ' ] && in_array ( $ post ['key ' ], $ keys ) ) {
777- // Import.
778- } elseif ( $ post ['ID ' ] && in_array ( $ post ['ID ' ], $ keys ) ) {
779- // Import.
780- } else {
781- // Ignore.
782- continue ;
780+ if ( ( $ post ['key ' ] && in_array ( $ post ['key ' ], $ keys , true ) ) || ( $ post ['ID ' ] && in_array ( $ post ['ID ' ], $ keys , true ) ) ) {
781+ $ local_post = json_decode ( file_get_contents ( $ files [ $ key ] ), true );
782+ $ local_post ['ID ' ] = $ post ['ID ' ];
783+ $ result = acf_import_internal_post_type ( $ local_post , $ this ->post_type );
784+ $ synced [] = $ result ['ID ' ];
783785 }
784-
785- $ local_post = json_decode ( file_get_contents ( $ files [ $ key ] ), true );
786- $ local_post ['ID ' ] = $ post ['ID ' ];
787- $ result = acf_import_internal_post_type ( $ local_post , $ this ->post_type );
788- $ synced [] = $ result ['ID ' ];
789786 }
790787
791788 // Redirect.
@@ -813,15 +810,15 @@ public function admin_table_views( $views ) {
813810 if ( $ count ) {
814811 $ views ['sync ' ] = sprintf (
815812 '<a %s href="%s">%s <span class="count">(%s)</span></a> ' ,
816- ( $ this -> view === ' sync ' ? 'class="current" ' : '' ),
813+ ( ' sync ' === $ this -> view ? 'class="current" ' : '' ),
817814 esc_url ( $ this ->get_admin_url ( '&post_status=sync ' ) ),
818815 esc_html ( __ ( 'Sync available ' , 'secure-custom-fields ' ) ),
819816 $ count
820817 );
821818 }
822819
823820 // Modify table pagination args to match JSON data.
824- if ( $ this -> view === ' sync ' ) {
821+ if ( ' sync ' === $ this -> view ) {
825822 $ wp_list_table ->set_pagination_args (
826823 array (
827824 'total_items ' => $ count ,
@@ -903,11 +900,11 @@ public function admin_footer__sync() {
903900 echo '<tr> ' ;
904901 foreach ( $ columns as $ column_name => $ column_label ) {
905902 $ el = 'td ' ;
906- if ( $ column_name === ' cb ' ) {
903+ if ( ' cb ' === $ column_name ) {
907904 $ el = 'th ' ;
908905 $ classes = 'check-column ' ;
909906 $ column_label = '' ;
910- } elseif ( $ column_name === ' title ' ) {
907+ } elseif ( ' title ' === $ column_name ) {
911908 $ classes = "$ column_name column- $ column_name column-primary " ;
912909 } else {
913910 $ classes = "$ column_name column- $ column_name " ;
0 commit comments