PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.3
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 +34 -221 6.5.25.3 View file →
@@ -18,9 +18,9 @@
18 18 return;
19 19 }
20 20
21 21 $label = __( 'Add-Ons', 'formidable' );
22 - $label = '<span style="color:#1da867">' . $label . '</span>';
22 + $label = '<span style="color:#fe5a1d">' . $label . '</span>';
23 23
24 24 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Add-Ons', 'formidable' ), $label, 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
25 25
26 26 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -37,11 +37,8 @@
37 37 exit;
38 38 }
39 39 }
40 40
41 - /**
42 - * @return void
43 - */
44 41 public static function list_addons() {
45 42 FrmAppHelper::include_svg();
46 43 $installed_addons = apply_filters( 'frm_installed_addons', array() );
47 44 $license_type = '';
@@ -72,11 +69,8 @@
72 69
73 70 include( FrmAppHelper::plugin_path() . '/classes/views/addons/list.php' );
74 71 }
75 72
76 - /**
77 - * @return void
78 - */
79 73 public static function license_settings() {
80 74 $plugins = apply_filters( 'frm_installed_addons', array() );
81 75 if ( empty( $plugins ) ) {
82 76 esc_html_e( 'There are no plugins on your site that require a license', 'formidable' );
@@ -88,11 +82,8 @@
88 82
89 83 include( FrmAppHelper::plugin_path() . '/classes/views/addons/settings.php' );
90 84 }
91 85
92 - /**
93 - * @return array
94 - */
95 86 protected static function get_api_addons() {
96 87 $api = new FrmFormApi();
97 88 $addons = $api->get_api_info();
98 89
@@ -123,10 +114,10 @@
123 114 'docs' => '',
124 115 '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 116 ),
126 117 '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.',
118 + 'title' => 'MailChimp Forms',
119 + '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 120 ),
130 121 'registration' => array(
131 122 'title' => 'User Registration Forms',
132 123 'link' => 'downloads/user-registration/',
@@ -251,11 +242,8 @@
251 242 }
252 243
253 244 /**
254 245 * @since 4.08
255 - *
256 - * @param array $addons
257 - * @return array
258 246 */
259 247 protected static function get_pro_from_addons( $addons ) {
260 248 return isset( $addons['93790'] ) ? $addons['93790'] : array();
261 249 }
@@ -297,10 +285,8 @@
297 285 }
298 286
299 287 /**
300 288 * @since 4.08
301 - *
302 - * @return array|false
303 289 */
304 290 protected static function get_primary_license_info() {
305 291 $installed_addons = apply_filters( 'frm_installed_addons', array() );
306 292 if ( empty( $installed_addons ) || ! isset( $installed_addons['formidable_pro'] ) ) {
@@ -330,12 +316,17 @@
330 316 if ( empty( $installed_addons ) ) {
331 317 return $transient;
332 318 }
333 319
334 - $version_info = self::fill_update_addon_info( $installed_addons );
320 + $version_info = self::fill_update_addon_info( $installed_addons );
321 +
335 322 $transient->last_checked = time();
336 - $wp_plugins = self::get_plugins();
337 323
324 + if ( ! function_exists( 'get_plugins' ) ) {
325 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
326 + }
327 + $wp_plugins = get_plugins();
328 +
338 329 foreach ( $version_info as $id => $plugin ) {
339 330 $plugin = (object) $plugin;
340 331
341 332 if ( ! isset( $plugin->new_version ) || ! isset( $plugin->package ) ) {
@@ -368,23 +359,8 @@
368 359 return $transient;
369 360 }
370 361
371 362 /**
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 363 * Check if a plugin is installed before showing an update for it
388 364 *
389 365 * @since 3.05
390 366 *
@@ -392,9 +368,14 @@
392 368 *
393 369 * @return bool - True if installed
394 370 */
395 371 protected static function is_installed( $plugin ) {
396 - $all_plugins = self::get_plugins();
372 + if ( ! function_exists( 'get_plugins' ) ) {
373 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
374 + }
375 +
376 + $all_plugins = get_plugins();
377 +
397 378 return isset( $all_plugins[ $plugin ] );
398 379 }
399 380
400 381 /**
@@ -544,11 +525,8 @@
544 525
545 526 return $plugin;
546 527 }
547 528
548 - /**
549 - * @return void
550 - */
551 529 protected static function prepare_addons( &$addons ) {
552 530 $activate_url = '';
553 531 if ( current_user_can( 'activate_plugins' ) ) {
554 532 $activate_url = add_query_arg( array( 'action' => 'activate' ), admin_url( 'plugins.php' ) );
@@ -606,11 +584,8 @@
606 584 $addons[ $id ] = $addon;
607 585 }
608 586 }
609 587
610 - /**
611 - * @return bool
612 - */
613 588 private static function is_plugin_active( $file_name, $slug ) {
614 589 if ( 'formidable-views/formidable-views.php' === $file_name ) {
615 590 return self::get_active_views_version() === $slug;
616 591 }
@@ -629,10 +604,8 @@
629 604 }
630 605
631 606 /**
632 607 * @since 3.04.02
633 - *
634 - * @return void
635 608 */
636 609 protected static function prepare_addon_link( &$link ) {
637 610 $site_url = 'https://formidableforms.com/';
638 611 if ( strpos( $link, 'http' ) !== 0 ) {
@@ -651,10 +624,8 @@
651 624 * Add the status to the addon array. Status options are:
652 625 * installed, active, not installed
653 626 *
654 627 * @since 3.04.02
655 - *
656 - * @return void
657 628 */
658 629 protected static function set_addon_status( &$addon ) {
659 630 if ( ! empty( $addon['activate_url'] ) ) {
660 631 $addon['status'] = array(
@@ -673,11 +644,8 @@
673 644 );
674 645 }
675 646 }
676 647
677 - /**
678 - * @return void
679 - */
680 648 public static function upgrade_to_pro() {
681 649 FrmAppHelper::include_svg();
682 650
683 651 $link_parts = array(
@@ -887,10 +855,8 @@
887 855 /**
888 856 * Install Pro after connection with Formidable.
889 857 *
890 858 * @since 4.02.05
891 - *
892 - * @return void
893 859 */
894 860 public static function connect_pro() {
895 861 FrmAppHelper::permission_check( 'install_plugins' );
896 862 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -902,9 +868,9 @@
902 868
903 869 $response = array();
904 870
905 871 // It's already installed and active.
906 - $active = self::activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
872 + $active = activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
907 873 if ( is_wp_error( $active ) ) {
908 874 // The plugin was installed, but not active. Download it now.
909 875 self::ajax_install_addon();
910 876 } else {
@@ -916,24 +882,8 @@
916 882 wp_die();
917 883 }
918 884
919 885 /**
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 886 * @since 5.0.10
937 887 *
938 888 * @return string
939 889 */
@@ -962,10 +912,8 @@
962 912 }
963 913
964 914 /**
965 915 * @since 3.04.02
966 - *
967 - * @return void
968 916 */
969 917 protected static function maybe_show_cred_form() {
970 918 if ( ! function_exists( 'request_filesystem_credentials' ) ) {
971 919 include_once( ABSPATH . 'wp-admin/includes/file.php' );
@@ -1002,23 +950,8 @@
1002 950 ob_end_clean();
1003 951 }
1004 952
1005 953 /**
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 954 * We do not need any extra credentials if we have gotten this far,
1022 955 * so let's install the plugin.
1023 956 *
1024 957 * @since 3.04.02
@@ -1023,21 +956,12 @@
1023 956 *
1024 957 * @since 3.04.02
1025 958 */
1026 959 protected static function install_addon() {
1027 - FrmAppHelper::permission_check( 'install_plugins' );
1028 -
1029 960 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1030 961
1031 962 $download_url = self::get_current_plugin();
1032 963
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 964 // Create the plugin upgrader with our custom skin.
1041 965 $installer = new Plugin_Upgrader( new FrmInstallerSkin() );
1042 966 $installer->install( $download_url );
1043 967
@@ -1055,10 +979,8 @@
1055 979 }
1056 980
1057 981 /**
1058 982 * @since 3.06.03
1059 - *
1060 - * @return void
1061 983 */
1062 984 public static function ajax_activate_addon() {
1063 985
1064 986 self::install_addon_permissions();
@@ -1072,45 +994,31 @@
1072 994 wp_die();
1073 995 }
1074 996
1075 997 /**
1076 - * @return array
998 + * @return array|string
1077 999 */
1078 1000 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 -
1001 + if ( self::activating_from_settings_page() ) {
1002 + $response = array(
1003 + 'message' => __( 'Your plugin has been activated. Would you like to save and reload the page now?', 'formidable' ),
1004 + 'saveAndReload' => 'settings',
1005 + );
1006 + } else {
1007 + $response = __( 'Your plugin has been activated. Please reload the page to see more options.', 'formidable' );
1008 + }
1088 1009 return $response;
1089 1010 }
1090 1011
1091 1012 /**
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
1013 + * @return bool
1096 1014 */
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 '';
1015 + private static function activating_from_settings_page() {
1016 + return false !== strpos( FrmAppHelper::get_server_value( 'HTTP_REFERER' ), 'frm_action=settings' );
1108 1017 }
1109 1018
1110 1019 /**
1111 1020 * @since 3.04.02
1112 - *
1113 1021 * @param string $installed The plugin folder name with file name
1114 1022 */
1115 1023 protected static function maybe_activate_addon( $installed ) {
1116 1024 if ( ! $installed ) {
@@ -1116,9 +1024,9 @@
1116 1024 if ( ! $installed ) {
1117 1025 return;
1118 1026 }
1119 1027
1120 - $activate = self::activate_plugin( $installed );
1028 + $activate = activate_plugin( $installed );
1121 1029 if ( is_wp_error( $activate ) ) {
1122 1030 // Ignore the invalid header message that shows with nested plugins.
1123 1031 if ( $activate->get_error_code() !== 'no_plugin_header' ) {
1124 1032 if ( wp_doing_ajax() ) {
@@ -1136,10 +1044,8 @@
1136 1044 /**
1137 1045 * Run security checks before installing
1138 1046 *
1139 1047 * @since 3.04.02
1140 - *
1141 - * @return void
1142 1048 */
1143 1049 protected static function install_addon_permissions() {
1144 1050 check_ajax_referer( 'frm_ajax', 'nonce' );
1145 1051
@@ -1150,10 +1056,8 @@
1150 1056 }
1151 1057
1152 1058 /**
1153 1059 * @since 4.08
1154 - *
1155 - * @return string
1156 1060 */
1157 1061 public static function connect_link() {
1158 1062 $auth = get_option( 'frm_connect_token' );
1159 1063 if ( empty( $auth ) ) {
@@ -1179,12 +1083,8 @@
1179 1083 *
1180 1084 * @return bool
1181 1085 */
1182 1086 public static function can_install_addon_api() {
1183 - if ( ! current_user_can( 'activate_plugins' ) ) {
1184 - return false;
1185 - }
1186 -
1187 1087 // Verify params present (auth & download link).
1188 1088 $post_auth = FrmAppHelper::get_param( 'token', '', 'request', 'sanitize_text_field' );
1189 1089 $post_url = FrmAppHelper::get_param( 'file_url', '', 'request', 'sanitize_text_field' );
1190 1090
@@ -1214,9 +1114,9 @@
1214 1114 // Delete so cannot replay.
1215 1115 delete_option( 'frm_connect_token' );
1216 1116
1217 1117 // It's already installed and active.
1218 - $active = self::activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
1118 + $active = activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
1219 1119 if ( is_wp_error( $active ) ) {
1220 1120 // Download plugin now.
1221 1121 $response = self::download_and_activate();
1222 1122 if ( is_array( $response ) && isset( $response['success'] ) ) {
@@ -1260,11 +1160,9 @@
1260 1160 }
1261 1161
1262 1162 $addon = self::get_addon( $plugin );
1263 1163 $upgrade_link = FrmAppHelper::admin_upgrade_link( $upgrade_link_args );
1264 -
1265 - $upgrade_link_args['link'] = $upgrade_link;
1266 - self::addon_upgrade_link( $addon, $upgrade_link_args );
1164 + self::addon_upgrade_link( $addon, $upgrade_link );
1267 1165 }
1268 1166
1269 1167 /**
1270 1168 * Render a conditional action button for an add on
@@ -1269,9 +1167,8 @@
1269 1167 /**
1270 1168 * Render a conditional action button for an add on
1271 1169 *
1272 1170 * @since 4.09.01
1273 - *
1274 1171 * @param array $addon
1275 1172 * @param string|false $license_type
1276 1173 * @param string $plan_required
1277 1174 * @param string $upgrade_link
@@ -1285,18 +1182,10 @@
1285 1182 }
1286 1183
1287 1184 /**
1288 1185 * @since 4.09.01
1289 - *
1290 - * @param array|false $addon
1291 - * @param string|array $upgrade_link
1292 - *
1293 - * @return void
1294 1186 */
1295 1187 protected static function addon_upgrade_link( $addon, $upgrade_link ) {
1296 - $atts = is_array( $upgrade_link ) ? $upgrade_link : array();
1297 - $upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link;
1298 -
1299 1188 if ( $addon ) {
1300 1189 $upgrade_link .= '&utm_content=' . $addon['slug'];
1301 1190 }
1302 1191
@@ -1303,15 +1192,10 @@
1303 1192 if ( $addon && isset( $addon['categories'] ) && in_array( 'Solution', $addon['categories'], true ) ) {
1304 1193 // Solutions will go to a separate page.
1305 1194 $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] );
1306 1195 }
1307 -
1308 - $class = ! empty( $atts['class'] ) ? $atts['class'] : '';
1309 - if ( strpos( $class, 'frm-button' ) === false ) {
1310 - $class .= ' frm-button-secondary frm-button-sm';
1311 - }
1312 1196 ?>
1313 - <a class="install-now button <?php echo esc_attr( $class ); ?>" href="<?php echo esc_url( $upgrade_link ); ?>" target="_blank" rel="noopener" aria-label="<?php esc_attr_e( 'Upgrade Now', 'formidable' ); ?>">
1197 + <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' ); ?>">
1314 1198 <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?>
1315 1199 </a>
1316 1200 <?php
1317 1201 }
@@ -1317,19 +1201,13 @@
1317 1201 }
1318 1202
1319 1203 /**
1320 1204 * @since 3.04.02
1321 - *
1322 - * @return void
1323 1205 */
1324 1206 public static function ajax_install_addon() {
1325 1207 self::install_addon_permissions();
1326 1208
1327 - $result = self::download_and_activate();
1328 - if ( isset( $result['success'] ) && ! $result['success'] ) {
1329 - echo json_encode( $result );
1330 - wp_die();
1331 - }
1209 + self::download_and_activate();
1332 1210
1333 1211 echo json_encode( self::get_addon_activation_response() );
1334 1212 wp_die();
1335 1213 }
@@ -1334,68 +1212,10 @@
1334 1212 wp_die();
1335 1213 }
1336 1214
1337 1215 /**
1338 - * Allowed URLs used for internal source of plugins installation.
1339 - *
1340 - * @since 6.3.1
1341 - *
1342 - * @return array
1343 - */
1344 - private static function allowed_external_urls() {
1345 - $allowed_url_list = array(
1346 - 'https://downloads.wordpress.org/plugin/formidable-gravity-forms-importer.zip',
1347 - 'https://downloads.wordpress.org/plugin/formidable-import-pirate-forms.zip',
1348 - 'https://downloads.wordpress.org/plugin/wp-mail-smtp.zip',
1349 - );
1350 -
1351 - /**
1352 - * List of URLs used in plugin formidable internal installation.
1353 - *
1354 - * @since 6.3.1
1355 - *
1356 - * @param array $allowed_url_list List of URLs.
1357 - */
1358 - $allowed_url_list = apply_filters( 'frm_allowed_external_urls', $allowed_url_list );
1359 -
1360 - if ( ! is_array( $allowed_url_list ) ) {
1361 - _doing_it_wrong( __METHOD__, 'Only an array of URLs could be used within this filter.', '6.3.1' );
1362 -
1363 - return array();
1364 - }
1365 -
1366 - return $allowed_url_list;
1367 - }
1368 -
1369 - /**
1370 - * Gets required plan for an addon.
1371 - *
1372 - * @since 6.4.2
1373 - *
1374 - * @return string Empty string if no plan is required for active license.
1375 - */
1376 - public static function get_addon_required_plan( $addon_id ) {
1377 - $api = new FrmFormApi();
1378 - $addons = $api->get_api_info();
1379 -
1380 - if ( is_array( $addons ) && array_key_exists( $addon_id, $addons ) ) {
1381 - $dates = $addons[ $addon_id ];
1382 - $requires = FrmFormsHelper::get_plan_required( $dates );
1383 - }
1384 -
1385 - if ( ! isset( $requires ) || ! is_string( $requires ) ) {
1386 - $requires = '';
1387 - }
1388 -
1389 - return $requires;
1390 - }
1391 -
1392 - /**
1393 1216 * @since 4.06.02
1394 - *
1395 1217 * @deprecated 4.09.01
1396 - *
1397 - * @return void
1398 1218 */
1399 1219 public static function ajax_multiple_addons() {
1400 1220 FrmDeprecated::ajax_multiple_addons();
1401 1221 }
@@ -1442,14 +1262,10 @@
1442 1262 }
1443 1263
1444 1264 /**
1445 1265 * @since 3.04.03
1446 - *
1447 1266 * @deprecated 3.06
1448 - *
1449 1267 * @codeCoverageIgnore
1450 - *
1451 - * @return void
1452 1268 */
1453 1269 public static function reset_cached_addons( $license = '' ) {
1454 1270 FrmDeprecated::reset_cached_addons( $license );
1455 1271 }
@@ -1483,12 +1299,9 @@
1483 1299 }
1484 1300
1485 1301 /**
1486 1302 * @deprecated 3.04.03
1487 - *
1488 1303 * @codeCoverageIgnore
1489 - *
1490 - * @return void
1491 1304 */
1492 1305 public static function get_licenses() {
1493 1306 FrmDeprecated::get_licenses();
1494 1307 }