@@ -267,9 +267,8 @@ protected static function set_categories( &$addon ) {
267267 public static function license_settings () {
268268 $ plugins = apply_filters ( 'frm_installed_addons ' , array () );
269269
270- if ( empty ( $ plugins ) ) {
270+ if ( ! $ plugins ) {
271271 esc_html_e ( 'There are no plugins on your site that require a license ' , 'formidable ' );
272-
273272 return ;
274273 }
275274
@@ -285,7 +284,7 @@ protected static function get_api_addons() {
285284 $ api = new FrmFormApi ();
286285 $ addons = $ api ->get_api_info ();
287286
288- if ( empty ( $ addons ) ) {
287+ if ( ! $ addons ) {
289288 $ addons = self ::fallback_plugin_list ();
290289 } else {
291290 foreach ( $ addons as $ k => $ addon ) {
@@ -307,7 +306,6 @@ protected static function get_api_addons() {
307306 */
308307 public static function get_addons_count () {
309308 $ addons = self ::get_api_addons ();
310-
311309 return count ( $ addons );
312310 }
313311
@@ -407,6 +405,7 @@ protected static function fallback_plugin_list() {
407405 $ info ['slug ' ] = $ k ;
408406 $ list [ $ k ] = array_merge ( $ defaults , $ info );
409407 }
408+
410409 return $ list ;
411410 }
412411
@@ -447,14 +446,15 @@ public static function get_pro_license() {
447446
448447 $ license = $ creds ['license ' ];
449448
450- if ( empty ( $ license ) ) {
449+ if ( ! $ license ) {
451450 return '' ;
452451 }
453452
454- if ( strpos ( $ license , '- ' ) ) {
453+ if ( str_contains ( $ license , '- ' ) ) {
455454 // this is a fix for licenses saved in the past
456455 $ license = strtoupper ( $ license );
457456 }
457+
458458 return $ license ;
459459 }
460460
@@ -496,7 +496,7 @@ public static function is_license_expired() {
496496
497497 $ expires = $ version_info ['error ' ]['expires ' ] ?? 0 ;
498498
499- if ( empty ( $ expires ) || $ expires > time () ) {
499+ if ( ! $ expires || $ expires > time () ) {
500500 return false ;
501501 }
502502
@@ -519,7 +519,7 @@ public static function is_license_expired() {
519519 public static function get_primary_license_info () {
520520 $ installed_addons = apply_filters ( 'frm_installed_addons ' , array () );
521521
522- if ( empty ( $ installed_addons ) || ! isset ( $ installed_addons ['formidable_pro ' ] ) ) {
522+ if ( ! $ installed_addons || ! isset ( $ installed_addons ['formidable_pro ' ] ) ) {
523523 return false ;
524524 }
525525
@@ -549,7 +549,7 @@ public static function check_update( $transient ) {
549549
550550 $ installed_addons = apply_filters ( 'frm_installed_addons ' , array () );
551551
552- if ( empty ( $ installed_addons ) ) {
552+ if ( ! $ installed_addons ) {
553553 return $ transient ;
554554 }
555555
@@ -566,7 +566,7 @@ public static function check_update( $transient ) {
566566
567567 $ folder = $ plugin ->plugin ;
568568
569- if ( empty ( $ folder ) ) {
569+ if ( ! $ folder ) {
570570 continue ;
571571 }
572572
@@ -641,13 +641,12 @@ protected static function fill_update_addon_info( $installed_addons ) {
641641
642642 $ new_license = $ addon ->license ;
643643
644- if ( empty ( $ new_license ) || in_array ( $ new_license , $ checked_licenses ) ) {
644+ if ( ! $ new_license || in_array ( $ new_license , $ checked_licenses, true ) ) {
645645 continue ;
646646 }
647647
648648 $ checked_licenses [] = $ new_license ;
649-
650- $ api = new FrmFormApi ( $ new_license );
649+ $ api = new FrmFormApi ( $ new_license );
651650
652651 if ( empty ( $ version_info ) ) {
653652 $ version_info = $ api ->get_api_info ();
@@ -656,13 +655,13 @@ protected static function fill_update_addon_info( $installed_addons ) {
656655
657656 $ plugin = $ api ->get_addon_for_license ( $ addon , $ version_info );
658657
659- if ( empty ( $ plugin ) ) {
658+ if ( ! $ plugin ) {
660659 continue ;
661660 }
662661
663662 $ download_id = $ plugin ['id ' ] ?? 0 ;
664663
665- if ( ! empty ( $ download_id ) && ! isset ( $ version_info [ $ download_id ]['package ' ] ) ) {
664+ if ( $ download_id && ! isset ( $ version_info [ $ download_id ]['package ' ] ) ) {
666665 // if this addon is using its own license, get the update url
667666 $ addon_info = $ api ->get_api_info ();
668667
@@ -710,7 +709,7 @@ public static function install_link( $plugin ) {
710709 );
711710 }
712711
713- if ( ! empty ( $ link ) ) {
712+ if ( $ link ) {
714713 $ link ['status ' ] = $ addon ['status ' ]['type ' ];
715714 }
716715 } elseif ( current_user_can ( 'activate_plugins ' ) && self ::is_installed ( 'formidable- ' . $ plugin . '/formidable- ' . $ plugin . '.php ' ) ) {
@@ -741,6 +740,7 @@ public static function get_addon( $plugin ) {
741740 return $ addon ;
742741 }
743742 }
743+
744744 return false ;
745745 }
746746
@@ -756,6 +756,7 @@ protected static function get_license_type() {
756756 if ( isset ( $ addons ['error ' ] ) && isset ( $ addons ['error ' ]['type ' ] ) ) {
757757 $ license_type = $ addons ['error ' ]['type ' ];
758758 }
759+
759760 return $ license_type ;
760761 }
761762
@@ -771,7 +772,7 @@ public static function get_addon_for_license( $addons, $license ) {
771772 $ download_id = $ license ->download_id ;
772773 $ plugin = array ();
773774
774- if ( empty ( $ download_id ) && ! empty ( $ addons ) ) {
775+ if ( ! $ download_id && ! empty ( $ addons ) ) {
775776 foreach ( $ addons as $ addon ) {
776777 if ( strtolower ( $ license ->plugin_name ) === strtolower ( $ addon ['title ' ] ) ) {
777778 return $ addon ;
@@ -790,6 +791,9 @@ public static function get_addon_for_license( $addons, $license ) {
790791 * @return void
791792 */
792793 protected static function prepare_addons ( &$ addons ) {
794+ // Reset categories to prevent count accumulation across multiple calls.
795+ self ::$ categories = array ();
796+
793797 $ activate_url = '' ;
794798
795799 if ( current_user_can ( 'activate_plugins ' ) ) {
@@ -803,10 +807,8 @@ protected static function prepare_addons( &$addons ) {
803807 $ slug = str_replace ( array ( '-wordpress-plugin ' , '-wordpress ' ), '' , $ addon ['slug ' ] );
804808 $ file_name = $ addon ['plugin ' ];
805809 } else {
806- $ slug = $ id ;
807-
810+ $ slug = $ id ;
808811 $ base_file = $ addon ['file ' ] ?? 'formidable- ' . $ slug ;
809-
810812 $ file_name = $ base_file . '/ ' . $ base_file . '.php ' ;
811813
812814 if ( ! isset ( $ addon ['plugin ' ] ) ) {
@@ -826,7 +828,7 @@ protected static function prepare_addons( &$addons ) {
826828
827829 $ addon ['activate_url ' ] = '' ;
828830
829- if ( $ addon ['installed ' ] && ! empty ( $ activate_url ) && ! self ::is_plugin_active ( $ file_name , $ slug ) ) {
831+ if ( $ addon ['installed ' ] && $ activate_url && ! self ::is_plugin_active ( $ file_name , $ slug ) ) {
830832 $ addon ['activate_url ' ] = add_query_arg (
831833 array (
832834 '_wpnonce ' => wp_create_nonce ( 'activate-plugin_ ' . $ file_name ),
@@ -984,11 +986,7 @@ protected static function uninstall_plugin( $plugin ) {
984986 self ::deactivate_plugin ( $ plugin , true );
985987 $ result = delete_plugins ( array ( $ plugin ) );
986988
987- if ( is_wp_error ( $ result ) ) {
988- return $ result ;
989- }
990-
991- return true ;
989+ return is_wp_error ( $ result ) ? $ result : true ;
992990 }
993991
994992 /**
@@ -1112,6 +1110,7 @@ protected static function install_addon() {
11121110 'success ' => false ,
11131111 );
11141112 }
1113+
11151114 return $ plugin ;
11161115 }
11171116
@@ -1229,6 +1228,7 @@ protected static function handle_addon_action( $installed, $action ) {
12291228 if ( wp_doing_ajax () ) {
12301229 wp_send_json_error ( array ( 'error ' => $ result ->get_error_message () ) );
12311230 }
1231+
12321232 return array (
12331233 'message ' => $ result ->get_error_message (),
12341234 'success ' => false ,
@@ -1244,8 +1244,7 @@ protected static function handle_addon_action( $installed, $action ) {
12441244 */
12451245 private static function get_addon_activation_response () {
12461246 $ activating_page = self ::get_activating_page ();
1247-
1248- $ message = $ activating_page ? __ ( 'Your plugin has been activated. Would you like to save and reload the page now? ' , 'formidable ' ) : __ ( 'Your plugin has been activated. ' , 'formidable ' );
1247+ $ message = $ activating_page ? __ ( 'Your plugin has been activated. Would you like to save and reload the page now? ' , 'formidable ' ) : __ ( 'Your plugin has been activated. ' , 'formidable ' );
12491248
12501249 return array (
12511250 'message ' => $ message ,
@@ -1266,11 +1265,7 @@ private static function get_activating_page() {
12661265 return 'settings ' ;
12671266 }
12681267
1269- if ( str_contains ( $ referer , 'frm_action=edit ' ) ) {
1270- return 'form_builder ' ;
1271- }
1272-
1273- return '' ;
1268+ return str_contains ( $ referer , 'frm_action=edit ' ) ? 'form_builder ' : '' ;
12741269 }
12751270
12761271 /**
@@ -1297,7 +1292,7 @@ protected static function install_addon_permissions() {
12971292 public static function connect_link () {
12981293 $ auth = get_option ( 'frm_connect_token ' );
12991294
1300- if ( empty ( $ auth ) ) {
1295+ if ( ! $ auth ) {
13011296 $ auth = hash ( 'sha512 ' , wp_rand () );
13021297 update_option ( 'frm_connect_token ' , $ auth , 'no ' );
13031298 }
@@ -1331,15 +1326,15 @@ public static function can_install_addon_api() {
13311326
13321327 // The download link is not required if already installed.
13331328 $ is_installed = FrmAppHelper::pro_is_included ();
1334- $ file_missing = ! $ is_installed && empty ( $ post_url ) ;
1329+ $ file_missing = ! $ is_installed && ! $ post_url ;
13351330
13361331 if ( ! $ post_auth || $ file_missing ) {
13371332 return false ;
13381333 }
13391334
13401335 // Verify auth.
13411336 $ auth = get_option ( 'frm_connect_token ' );
1342- return ! empty ( $ auth ) && hash_equals ( $ auth , $ post_auth );
1337+ return $ auth && hash_equals ( $ auth , $ post_auth );
13431338 }
13441339
13451340 /**
@@ -1550,7 +1545,6 @@ private static function allowed_external_urls() {
15501545
15511546 if ( ! is_array ( $ allowed_url_list ) ) {
15521547 _doing_it_wrong ( __METHOD__ , 'Only an array of URLs could be used within this filter. ' , '6.3.1 ' );
1553-
15541548 return array ();
15551549 }
15561550
0 commit comments