PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.2.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.2.01
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmAddonsController.php +33 -217 6.55.2.01 View file →
@@ -9,11 +9,8 @@
9 9 * @var string $plugin
10 10 */
11 11 protected static $plugin;
12 12
13 - /**
14 - * @return void
15 - */
16 13 public static function menu() {
17 14 if ( ! current_user_can( 'activate_plugins' ) ) {
18 15 return;
19 16 }
@@ -18,9 +15,9 @@
18 15 return;
19 16 }
20 17
21 18 $label = __( 'Add-Ons', 'formidable' );
22 - $label = '<span style="color:#1da867">' . $label . '</span>';
19 + $label = '<span style="color:#fe5a1d">' . $label . '</span>';
23 20
24 21 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Add-Ons', 'formidable' ), $label, 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
25 22
26 23 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -37,11 +34,8 @@
37 34 exit;
38 35 }
39 36 }
40 37
41 - /**
42 - * @return void
43 - */
44 38 public static function list_addons() {
45 39 FrmAppHelper::include_svg();
46 40 $installed_addons = apply_filters( 'frm_installed_addons', array() );
47 41 $license_type = '';
@@ -72,11 +66,8 @@
72 66
73 67 include( FrmAppHelper::plugin_path() . '/classes/views/addons/list.php' );
74 68 }
75 69
76 - /**
77 - * @return void
78 - */
79 70 public static function license_settings() {
80 71 $plugins = apply_filters( 'frm_installed_addons', array() );
81 72 if ( empty( $plugins ) ) {
82 73 esc_html_e( 'There are no plugins on your site that require a license', 'formidable' );
@@ -88,11 +79,8 @@
88 79
89 80 include( FrmAppHelper::plugin_path() . '/classes/views/addons/settings.php' );
90 81 }
91 82
92 - /**
93 - * @return array
94 - */
95 83 protected static function get_api_addons() {
96 84 $api = new FrmFormApi();
97 85 $addons = $api->get_api_info();
98 86
@@ -123,10 +111,10 @@
123 111 'docs' => '',
124 112 'excerpt' => 'Enhance your basic Formidable forms with a plethora of Pro field types and features. Create advanced forms and data-driven applications in minutes.',
125 113 ),
126 114 'mailchimp' => array(
127 - 'title' => 'Mailchimp Forms',
128 - 'excerpt' => 'Get on the path to more sales and leads in a matter of minutes. Add leads to a Mailchimp mailing list when they submit forms and update their information along with the entry.',
115 + 'title' => 'MailChimp Forms',
116 + 'excerpt' => 'Get on the path to more sales and leads in a matter of minutes. Add leads to a MailChimp mailing list when they submit forms and update their information along with the entry.',
129 117 ),
130 118 'registration' => array(
131 119 'title' => 'User Registration Forms',
132 120 'link' => 'downloads/user-registration/',
@@ -188,13 +176,8 @@
188 176 'views' => array(
189 177 'title' => 'Formidable Views',
190 178 'excerpt' => 'Add the power of views to your Formidable Forms to display your form submissions in listings, tables, calendars, and more.',
191 179 ),
192 - 'quiz_maker' => array(
193 - 'title' => 'Quiz Maker',
194 - 'link' => 'downloads/quiz-maker/',
195 - 'excerpt' => 'Make quizzes, automatically score them and show user scores.',
196 - ),
197 180 );
198 181
199 182 $defaults = array(
200 183 'released' => '',
@@ -251,11 +234,8 @@
251 234 }
252 235
253 236 /**
254 237 * @since 4.08
255 - *
256 - * @param array $addons
257 - * @return array
258 238 */
259 239 protected static function get_pro_from_addons( $addons ) {
260 240 return isset( $addons['93790'] ) ? $addons['93790'] : array();
261 241 }
@@ -297,10 +277,8 @@
297 277 }
298 278
299 279 /**
300 280 * @since 4.08
301 - *
302 - * @return array|false
303 281 */
304 282 protected static function get_primary_license_info() {
305 283 $installed_addons = apply_filters( 'frm_installed_addons', array() );
306 284 if ( empty( $installed_addons ) || ! isset( $installed_addons['formidable_pro'] ) ) {
@@ -330,12 +308,17 @@
330 308 if ( empty( $installed_addons ) ) {
331 309 return $transient;
332 310 }
333 311
334 - $version_info = self::fill_update_addon_info( $installed_addons );
312 + $version_info = self::fill_update_addon_info( $installed_addons );
313 +
335 314 $transient->last_checked = time();
336 - $wp_plugins = self::get_plugins();
337 315
316 + if ( ! function_exists( 'get_plugins' ) ) {
317 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
318 + }
319 + $wp_plugins = get_plugins();
320 +
338 321 foreach ( $version_info as $id => $plugin ) {
339 322 $plugin = (object) $plugin;
340 323
341 324 if ( ! isset( $plugin->new_version ) || ! isset( $plugin->package ) ) {
@@ -368,23 +351,8 @@
368 351 return $transient;
369 352 }
370 353
371 354 /**
372 - * Copy of FrmAppHelper::get_plugins.
373 - * Because this gets called on "pre_set_site_transient_update_plugins" an old version of FrmAppHelper may be loaded on plugin update.
374 - * This means that trying to access FrmAppHelper::get_plugins when upgrading from a Lite version before v5.5 results in a one-off error.
375 - *
376 - * @since 5.5.2
377 - * @return array
378 - */
379 - protected static function get_plugins() {
380 - if ( ! function_exists( 'get_plugins' ) ) {
381 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
382 - }
383 - return get_plugins();
384 - }
385 -
386 - /**
387 355 * Check if a plugin is installed before showing an update for it
388 356 *
389 357 * @since 3.05
390 358 *
@@ -392,9 +360,14 @@
392 360 *
393 361 * @return bool - True if installed
394 362 */
395 363 protected static function is_installed( $plugin ) {
396 - $all_plugins = self::get_plugins();
364 + if ( ! function_exists( 'get_plugins' ) ) {
365 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
366 + }
367 +
368 + $all_plugins = get_plugins();
369 +
397 370 return isset( $all_plugins[ $plugin ] );
398 371 }
399 372
400 373 /**
@@ -544,11 +517,8 @@
544 517
545 518 return $plugin;
546 519 }
547 520
548 - /**
549 - * @return void
550 - */
551 521 protected static function prepare_addons( &$addons ) {
552 522 $activate_url = '';
553 523 if ( current_user_can( 'activate_plugins' ) ) {
554 524 $activate_url = add_query_arg( array( 'action' => 'activate' ), admin_url( 'plugins.php' ) );
@@ -606,11 +576,8 @@
606 576 $addons[ $id ] = $addon;
607 577 }
608 578 }
609 579
610 - /**
611 - * @return bool
612 - */
613 580 private static function is_plugin_active( $file_name, $slug ) {
614 581 if ( 'formidable-views/formidable-views.php' === $file_name ) {
615 582 return self::get_active_views_version() === $slug;
616 583 }
@@ -629,10 +596,8 @@
629 596 }
630 597
631 598 /**
632 599 * @since 3.04.02
633 - *
634 - * @return void
635 600 */
636 601 protected static function prepare_addon_link( &$link ) {
637 602 $site_url = 'https://formidableforms.com/';
638 603 if ( strpos( $link, 'http' ) !== 0 ) {
@@ -651,10 +616,8 @@
651 616 * Add the status to the addon array. Status options are:
652 617 * installed, active, not installed
653 618 *
654 619 * @since 3.04.02
655 - *
656 - * @return void
657 620 */
658 621 protected static function set_addon_status( &$addon ) {
659 622 if ( ! empty( $addon['activate_url'] ) ) {
660 623 $addon['status'] = array(
@@ -673,11 +636,8 @@
673 636 );
674 637 }
675 638 }
676 639
677 - /**
678 - * @return void
679 - */
680 640 public static function upgrade_to_pro() {
681 641 FrmAppHelper::include_svg();
682 642
683 643 $link_parts = array(
@@ -887,10 +847,8 @@
887 847 /**
888 848 * Install Pro after connection with Formidable.
889 849 *
890 850 * @since 4.02.05
891 - *
892 - * @return void
893 851 */
894 852 public static function connect_pro() {
895 853 FrmAppHelper::permission_check( 'install_plugins' );
896 854 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -902,9 +860,9 @@
902 860
903 861 $response = array();
904 862
905 863 // It's already installed and active.
906 - $active = self::activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
864 + $active = activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
907 865 if ( is_wp_error( $active ) ) {
908 866 // The plugin was installed, but not active. Download it now.
909 867 self::ajax_install_addon();
910 868 } else {
@@ -916,24 +874,8 @@
916 874 wp_die();
917 875 }
918 876
919 877 /**
920 - * @since 5.5.2
921 - *
922 - * @param string $plugin
923 - * @param string $redirect
924 - * @param bool $network_wide
925 - * @param bool $silent
926 - * @return null|WP_Error Null on success, WP_Error on invalid file.
927 - */
928 - protected static function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {
929 - if ( ! function_exists( 'activate_plugin' ) ) {
930 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
931 - }
932 - return activate_plugin( $plugin, $redirect, $network_wide, $silent );
933 - }
934 -
935 - /**
936 878 * @since 5.0.10
937 879 *
938 880 * @return string
939 881 */
@@ -962,10 +904,8 @@
962 904 }
963 905
964 906 /**
965 907 * @since 3.04.02
966 - *
967 - * @return void
968 908 */
969 909 protected static function maybe_show_cred_form() {
970 910 if ( ! function_exists( 'request_filesystem_credentials' ) ) {
971 911 include_once( ABSPATH . 'wp-admin/includes/file.php' );
@@ -1002,23 +942,8 @@
1002 942 ob_end_clean();
1003 943 }
1004 944
1005 945 /**
1006 - * Checks if an addon download url is allowed.
1007 - *
1008 - * @since 6.2
1009 - *
1010 - * @param string $download_url
1011 - *
1012 - * @return bool
1013 - */
1014 - public static function url_is_allowed( $download_url ) {
1015 - return (
1016 - FrmAppHelper::validate_url_is_in_s3_bucket( $download_url, 'zip' ) || in_array( $download_url, self::allowed_external_urls(), true )
1017 - );
1018 - }
1019 -
1020 - /**
1021 946 * We do not need any extra credentials if we have gotten this far,
1022 947 * so let's install the plugin.
1023 948 *
1024 949 * @since 3.04.02
@@ -1023,21 +948,12 @@
1023 948 *
1024 949 * @since 3.04.02
1025 950 */
1026 951 protected static function install_addon() {
1027 - FrmAppHelper::permission_check( 'install_plugins' );
1028 -
1029 952 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1030 953
1031 954 $download_url = self::get_current_plugin();
1032 955
1033 - if ( ! self::url_is_allowed( $download_url ) ) {
1034 - return array(
1035 - 'message' => 'Plugin URL is not valid',
1036 - 'success' => false,
1037 - );
1038 - }
1039 -
1040 956 // Create the plugin upgrader with our custom skin.
1041 957 $installer = new Plugin_Upgrader( new FrmInstallerSkin() );
1042 958 $installer->install( $download_url );
1043 959
@@ -1055,10 +971,8 @@
1055 971 }
1056 972
1057 973 /**
1058 974 * @since 3.06.03
1059 - *
1060 - * @return void
1061 975 */
1062 976 public static function ajax_activate_addon() {
1063 977
1064 978 self::install_addon_permissions();
@@ -1072,45 +986,31 @@
1072 986 wp_die();
1073 987 }
1074 988
1075 989 /**
1076 - * @return array
990 + * @return array|string
1077 991 */
1078 992 private static function get_addon_activation_response() {
1079 - $activating_page = self::get_activating_page();
1080 -
1081 - $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' );
1082 -
1083 - $response = array(
1084 - 'message' => $message,
1085 - 'saveAndReload' => $activating_page,
1086 - );
1087 -
993 + if ( self::activating_from_settings_page() ) {
994 + $response = array(
995 + 'message' => __( 'Your plugin has been activated. Would you like to save and reload the page now?', 'formidable' ),
996 + 'saveAndReload' => 'settings',
997 + );
998 + } else {
999 + $response = __( 'Your plugin has been activated. Please reload the page to see more options.', 'formidable' );
1000 + }
1088 1001 return $response;
1089 1002 }
1090 1003
1091 1004 /**
1092 - * Return a string that reflects the page from which the addon is being activated on,
1093 - * if it is from settings or form builder, otherwise return empty string.
1094 - *
1095 - * @return string
1005 + * @return bool
1096 1006 */
1097 - private static function get_activating_page() {
1098 - $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' );
1099 - if ( false !== strpos( $referer, 'frm_action=settings' ) ) {
1100 - return 'settings';
1101 - }
1102 -
1103 - if ( false !== strpos( $referer, 'frm_action=edit' ) ) {
1104 - return 'form_builder';
1105 - }
1106 -
1107 - return '';
1007 + private static function activating_from_settings_page() {
1008 + return false !== strpos( FrmAppHelper::get_server_value( 'HTTP_REFERER' ), 'frm_action=settings' );
1108 1009 }
1109 1010
1110 1011 /**
1111 1012 * @since 3.04.02
1112 - *
1113 1013 * @param string $installed The plugin folder name with file name
1114 1014 */
1115 1015 protected static function maybe_activate_addon( $installed ) {
1116 1016 if ( ! $installed ) {
@@ -1116,9 +1016,9 @@
1116 1016 if ( ! $installed ) {
1117 1017 return;
1118 1018 }
1119 1019
1120 - $activate = self::activate_plugin( $installed );
1020 + $activate = activate_plugin( $installed );
1121 1021 if ( is_wp_error( $activate ) ) {
1122 1022 // Ignore the invalid header message that shows with nested plugins.
1123 1023 if ( $activate->get_error_code() !== 'no_plugin_header' ) {
1124 1024 if ( wp_doing_ajax() ) {
@@ -1136,10 +1036,8 @@
1136 1036 /**
1137 1037 * Run security checks before installing
1138 1038 *
1139 1039 * @since 3.04.02
1140 - *
1141 - * @return void
1142 1040 */
1143 1041 protected static function install_addon_permissions() {
1144 1042 check_ajax_referer( 'frm_ajax', 'nonce' );
1145 1043
@@ -1150,10 +1048,8 @@
1150 1048 }
1151 1049
1152 1050 /**
1153 1051 * @since 4.08
1154 - *
1155 - * @return string
1156 1052 */
1157 1053 public static function connect_link() {
1158 1054 $auth = get_option( 'frm_connect_token' );
1159 1055 if ( empty( $auth ) ) {
@@ -1179,12 +1075,8 @@
1179 1075 *
1180 1076 * @return bool
1181 1077 */
1182 1078 public static function can_install_addon_api() {
1183 - if ( ! current_user_can( 'activate_plugins' ) ) {
1184 - return false;
1185 - }
1186 -
1187 1079 // Verify params present (auth & download link).
1188 1080 $post_auth = FrmAppHelper::get_param( 'token', '', 'request', 'sanitize_text_field' );
1189 1081 $post_url = FrmAppHelper::get_param( 'file_url', '', 'request', 'sanitize_text_field' );
1190 1082
@@ -1214,9 +1106,9 @@
1214 1106 // Delete so cannot replay.
1215 1107 delete_option( 'frm_connect_token' );
1216 1108
1217 1109 // It's already installed and active.
1218 - $active = self::activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
1110 + $active = activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
1219 1111 if ( is_wp_error( $active ) ) {
1220 1112 // Download plugin now.
1221 1113 $response = self::download_and_activate();
1222 1114 if ( is_array( $response ) && isset( $response['success'] ) ) {
@@ -1267,9 +1159,8 @@
1267 1159 /**
1268 1160 * Render a conditional action button for an add on
1269 1161 *
1270 1162 * @since 4.09.01
1271 - *
1272 1163 * @param array $addon
1273 1164 * @param string|false $license_type
1274 1165 * @param string $plan_required
1275 1166 * @param string $upgrade_link
@@ -1283,12 +1174,8 @@
1283 1174 }
1284 1175
1285 1176 /**
1286 1177 * @since 4.09.01
1287 - *
1288 - * @param array|false $addon
1289 - *
1290 - * @return void
1291 1178 */
1292 1179 protected static function addon_upgrade_link( $addon, $upgrade_link ) {
1293 1180 if ( $addon ) {
1294 1181 $upgrade_link .= '&utm_content=' . $addon['slug'];
@@ -1298,9 +1185,9 @@
1298 1185 // Solutions will go to a separate page.
1299 1186 $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] );
1300 1187 }
1301 1188 ?>
1302 - <a class="install-now button frm-button-secondary frm-button-sm" href="<?php echo esc_url( $upgrade_link ); ?>" target="_blank" rel="noopener" aria-label="<?php esc_attr_e( 'Upgrade Now', 'formidable' ); ?>">
1189 + <a class="install-now button button-secondary frm-button-secondary" href="<?php echo esc_url( $upgrade_link ); ?>" target="_blank" rel="noopener" aria-label="<?php esc_attr_e( 'Upgrade Now', 'formidable' ); ?>">
1303 1190 <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?>
1304 1191 </a>
1305 1192 <?php
1306 1193 }
@@ -1306,19 +1193,13 @@
1306 1193 }
1307 1194
1308 1195 /**
1309 1196 * @since 3.04.02
1310 - *
1311 - * @return void
1312 1197 */
1313 1198 public static function ajax_install_addon() {
1314 1199 self::install_addon_permissions();
1315 1200
1316 - $result = self::download_and_activate();
1317 - if ( isset( $result['success'] ) && ! $result['success'] ) {
1318 - echo json_encode( $result );
1319 - wp_die();
1320 - }
1201 + self::download_and_activate();
1321 1202
1322 1203 echo json_encode( self::get_addon_activation_response() );
1323 1204 wp_die();
1324 1205 }
@@ -1323,68 +1204,10 @@
1323 1204 wp_die();
1324 1205 }
1325 1206
1326 1207 /**
1327 - * Allowed URLs used for internal source of plugins installation.
1328 - *
1329 - * @since 6.3.1
1330 - *
1331 - * @return array
1332 - */
1333 - private static function allowed_external_urls() {
1334 - $allowed_url_list = array(
1335 - 'https://downloads.wordpress.org/plugin/formidable-gravity-forms-importer.zip',
1336 - 'https://downloads.wordpress.org/plugin/formidable-import-pirate-forms.zip',
1337 - 'https://downloads.wordpress.org/plugin/wp-mail-smtp.zip',
1338 - );
1339 -
1340 - /**
1341 - * List of URLs used in plugin formidable internal installation.
1342 - *
1343 - * @since 6.3.1
1344 - *
1345 - * @param array $allowed_url_list List of URLs.
1346 - */
1347 - $allowed_url_list = apply_filters( 'frm_allowed_external_urls', $allowed_url_list );
1348 -
1349 - if ( ! is_array( $allowed_url_list ) ) {
1350 - _doing_it_wrong( __METHOD__, 'Only an array of URLs could be used within this filter.', '6.3.1' );
1351 -
1352 - return array();
1353 - }
1354 -
1355 - return $allowed_url_list;
1356 - }
1357 -
1358 - /**
1359 - * Gets required plan for an addon.
1360 - *
1361 - * @since 6.4.2
1362 - *
1363 - * @return string Empty string if no plan is required for active license.
1364 - */
1365 - public static function get_addon_required_plan( $addon_id ) {
1366 - $api = new FrmFormApi();
1367 - $addons = $api->get_api_info();
1368 -
1369 - if ( is_array( $addons ) && array_key_exists( $addon_id, $addons ) ) {
1370 - $dates = $addons[ $addon_id ];
1371 - $requires = FrmFormsHelper::get_plan_required( $dates );
1372 - }
1373 -
1374 - if ( ! isset( $requires ) || ! is_string( $requires ) ) {
1375 - $requires = '';
1376 - }
1377 -
1378 - return $requires;
1379 - }
1380 -
1381 - /**
1382 1208 * @since 4.06.02
1383 - *
1384 1209 * @deprecated 4.09.01
1385 - *
1386 - * @return void
1387 1210 */
1388 1211 public static function ajax_multiple_addons() {
1389 1212 FrmDeprecated::ajax_multiple_addons();
1390 1213 }
@@ -1431,14 +1254,10 @@
1431 1254 }
1432 1255
1433 1256 /**
1434 1257 * @since 3.04.03
1435 - *
1436 1258 * @deprecated 3.06
1437 - *
1438 1259 * @codeCoverageIgnore
1439 - *
1440 - * @return void
1441 1260 */
1442 1261 public static function reset_cached_addons( $license = '' ) {
1443 1262 FrmDeprecated::reset_cached_addons( $license );
1444 1263 }
@@ -1472,12 +1291,9 @@
1472 1291 }
1473 1292
1474 1293 /**
1475 1294 * @deprecated 3.04.03
1476 - *
1477 1295 * @codeCoverageIgnore
1478 - *
1479 - * @return void
1480 1296 */
1481 1297 public static function get_licenses() {
1482 1298 FrmDeprecated::get_licenses();
1483 1299 }