PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7.2
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 +119 -33 6.36.7.2 View file →
@@ -18,9 +18,9 @@
18 18 return;
19 19 }
20 20
21 21 $label = __( 'Add-Ons', 'formidable' );
22 - $label = '<span style="color:#fe5a1d">' . $label . '</span>';
22 + $label = '<span style="color:#1da867">' . $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() ) {
@@ -297,12 +297,13 @@
297 297 }
298 298
299 299 /**
300 300 * @since 4.08
301 + * @since 6.7 This is public.
301 302 *
302 303 * @return array|false
303 304 */
304 - protected static function get_primary_license_info() {
305 + public static function get_primary_license_info() {
305 306 $installed_addons = apply_filters( 'frm_installed_addons', array() );
306 307 if ( empty( $installed_addons ) || ! isset( $installed_addons['formidable_pro'] ) ) {
307 308 return false;
308 309 }
@@ -351,20 +352,21 @@
351 352 // don't show an update if the plugin isn't installed
352 353 continue;
353 354 }
354 355
355 - $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array();
356 - $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0';
356 + $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array();
357 + $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0';
358 + $plugin->slug = explode( '/', $folder )[0];
357 359
358 360 if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) {
359 - $slug = explode( '/', $folder );
360 - $plugin->slug = $slug[0];
361 361 $transient->response[ $folder ] = $plugin;
362 + } else {
363 + $transient->no_update[ $folder ] = $plugin;
362 364 }
363 365
364 366 $transient->checked[ $folder ] = $wp_version;
365 367
366 - }
368 + }//end foreach
367 369
368 370 return $transient;
369 371 }
370 372
@@ -387,9 +389,9 @@
387 389 * Check if a plugin is installed before showing an update for it
388 390 *
389 391 * @since 3.05
390 392 *
391 - * @param string $plugin - the folder/filename.php for a plugin
393 + * @param string $plugin The folder/filename.php for a plugin.
392 394 *
393 395 * @return bool - True if installed
394 396 */
395 397 protected static function is_installed( $plugin ) {
@@ -444,9 +446,9 @@
444 446 'code' => $addon_info['error']['code'],
445 447 );
446 448 }
447 449 }
448 - }
450 + }//end foreach
449 451
450 452 return $version_info;
451 453 }
452 454
@@ -453,9 +455,9 @@
453 455 /**
454 456 * Get the action link for an addon that isn't active.
455 457 *
456 458 * @since 3.06.03
457 - * @param string $plugin The plugin slug
459 + * @param string $plugin The plugin slug.
458 460 * @return array
459 461 */
460 462 public static function install_link( $plugin ) {
461 463 $link = array();
@@ -485,9 +487,9 @@
485 487 $link = array(
486 488 'url' => 'formidable-' . $plugin . '/formidable-' . $plugin . '.php',
487 489 'class' => 'frm-activate-addon',
488 490 );
489 - }
491 + }//end if
490 492
491 493 return $link;
492 494 }
493 495
@@ -492,9 +494,9 @@
492 494 }
493 495
494 496 /**
495 497 * @since 4.09
496 - * @param string $plugin The plugin slug
498 + * @param string $plugin The plugin slug.
497 499 * @return array|false
498 500 */
499 501 protected static function get_addon( $plugin ) {
500 502 $addons = self::get_api_addons();
@@ -523,10 +525,10 @@
523 525
524 526 /**
525 527 * @since 3.04.03
526 528 *
527 - * @param array $addons
528 - * @param object $license The FrmAddon object
529 + * @param array $addons
530 + * @param object $license The FrmAddon object.
529 531 *
530 532 * @return array
531 533 */
532 534 public static function get_addon_for_license( $addons, $license ) {
@@ -603,9 +605,9 @@
603 605 self::prepare_addon_link( $addon['link'] );
604 606
605 607 self::set_addon_status( $addon );
606 608 $addons[ $id ] = $addon;
607 - }
609 + }//end foreach
608 610 }
609 611
610 612 /**
611 613 * @return bool
@@ -937,9 +939,9 @@
937 939 *
938 940 * @return string
939 941 */
940 942 protected static function get_current_plugin() {
941 - if ( ! isset( self::$plugin ) ) {
943 + if ( empty( self::$plugin ) ) {
942 944 self::$plugin = FrmAppHelper::get_param( 'plugin', '', 'post', 'esc_url_raw' );
943 945 }
944 946 return self::$plugin;
945 947 }
@@ -1012,10 +1014,9 @@
1012 1014 * @return bool
1013 1015 */
1014 1016 public static function url_is_allowed( $download_url ) {
1015 1017 return (
1016 - FrmAppHelper::validate_url_is_in_s3_bucket( $download_url, 'zip' ) ||
1017 - ( strpos( $download_url, 'https://downloads.wordpress.org/plugin' ) === 0 && substr_compare( $download_url, '.zip', -4 ) === 0 )
1018 + FrmAppHelper::validate_url_is_in_s3_bucket( $download_url, 'zip' ) || in_array( $download_url, self::allowed_external_urls(), true )
1018 1019 );
1019 1020 }
1020 1021
1021 1022 /**
@@ -1076,10 +1077,12 @@
1076 1077 */
1077 1078 private static function get_addon_activation_response() {
1078 1079 $activating_page = self::get_activating_page();
1079 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 +
1080 1083 $response = array(
1081 - 'message' => __( 'Your plugin has been activated. Would you like to save and reload the page now?', 'formidable' ),
1084 + 'message' => $message,
1082 1085 'saveAndReload' => $activating_page,
1083 1086 );
1084 1087
1085 1088 return $response;
@@ -1106,9 +1109,9 @@
1106 1109
1107 1110 /**
1108 1111 * @since 3.04.02
1109 1112 *
1110 - * @param string $installed The plugin folder name with file name
1113 + * @param string $installed The plugin folder name with file name.
1111 1114 */
1112 1115 protected static function maybe_activate_addon( $installed ) {
1113 1116 if ( ! $installed ) {
1114 1117 return;
@@ -1180,9 +1183,9 @@
1180 1183 // Verify params present (auth & download link).
1181 1184 $post_auth = FrmAppHelper::get_param( 'token', '', 'request', 'sanitize_text_field' );
1182 1185 $post_url = FrmAppHelper::get_param( 'file_url', '', 'request', 'sanitize_text_field' );
1183 1186
1184 - if ( empty( $post_auth ) || empty( $post_url ) ) {
1187 + if ( ! $post_auth || ! $post_url ) {
1185 1188 return false;
1186 1189 }
1187 1190
1188 1191 // Verify auth.
@@ -1242,20 +1245,33 @@
1242 1245
1243 1246 /**
1244 1247 * Render a conditional action button for a specified plugin
1245 1248 *
1246 - * @param string $plugin
1249 + * @since 4.09
1250 + *
1251 + * @param string $plugin
1247 1252 * @param array|string $upgrade_link_args
1248 - * @since 4.09
1253 + * @return void
1249 1254 */
1250 1255 public static function conditional_action_button( $plugin, $upgrade_link_args ) {
1251 1256 if ( is_callable( 'FrmProAddonsController::conditional_action_button' ) ) {
1252 - return FrmProAddonsController::conditional_action_button( $plugin, $upgrade_link_args );
1257 + FrmProAddonsController::conditional_action_button( $plugin, $upgrade_link_args );
1258 + return;
1253 1259 }
1254 1260
1255 1261 $addon = self::get_addon( $plugin );
1256 1262 $upgrade_link = FrmAppHelper::admin_upgrade_link( $upgrade_link_args );
1257 - self::addon_upgrade_link( $addon, $upgrade_link );
1263 +
1264 + if ( ! is_array( $upgrade_link_args ) ) {
1265 + // A string $upgrade_link_args is used for the utm-medium value when calling
1266 + // FrmAppHelper::admin_upgrade_link above.
1267 + // For self::addon_upgrade_link, we'll pass just an empty array with the link key (set below).
1268 + $upgrade_link_args = array();
1269 + }
1270 +
1271 + $upgrade_link_args['link'] = $upgrade_link;
1272 +
1273 + self::addon_upgrade_link( $addon, $upgrade_link_args );
1258 1274 }
1259 1275
1260 1276 /**
1261 1277 * Render a conditional action button for an add on
@@ -1261,16 +1277,22 @@
1261 1277 * Render a conditional action button for an add on
1262 1278 *
1263 1279 * @since 4.09.01
1264 1280 *
1265 - * @param array $addon
1266 - * @param string|false $license_type
1267 - * @param string $plan_required
1268 - * @param string $upgrade_link
1281 + * @param array $atts {
1282 + * Button attributes.
1283 + *
1284 + * @type array $addon
1285 + * @type string|false $license_type
1286 + * @type string $plan_required
1287 + * @type string $upgrade_link
1288 + * }
1289 + * @return void
1269 1290 */
1270 1291 public static function show_conditional_action_button( $atts ) {
1271 1292 if ( is_callable( 'FrmProAddonsController::show_conditional_action_button' ) ) {
1272 - return FrmProAddonsController::show_conditional_action_button( $atts );
1293 + FrmProAddonsController::show_conditional_action_button( $atts );
1294 + return;
1273 1295 }
1274 1296
1275 1297 self::addon_upgrade_link( $atts['addon'], $atts['upgrade_link'] );
1276 1298 }
@@ -1277,13 +1299,17 @@
1277 1299
1278 1300 /**
1279 1301 * @since 4.09.01
1280 1302 *
1281 - * @param array|false $addon
1303 + * @param array|false $addon
1304 + * @param string|array $upgrade_link
1282 1305 *
1283 1306 * @return void
1284 1307 */
1285 1308 protected static function addon_upgrade_link( $addon, $upgrade_link ) {
1309 + $atts = is_array( $upgrade_link ) ? $upgrade_link : array();
1310 + $upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link;
1311 +
1286 1312 if ( $addon ) {
1287 1313 $upgrade_link .= '&utm_content=' . $addon['slug'];
1288 1314 }
1289 1315
@@ -1290,10 +1316,15 @@
1290 1316 if ( $addon && isset( $addon['categories'] ) && in_array( 'Solution', $addon['categories'], true ) ) {
1291 1317 // Solutions will go to a separate page.
1292 1318 $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] );
1293 1319 }
1320 +
1321 + $class = ! empty( $atts['class'] ) ? $atts['class'] : '';
1322 + if ( strpos( $class, 'frm-button' ) === false ) {
1323 + $class .= ' frm-button-secondary frm-button-sm';
1324 + }
1294 1325 ?>
1295 - <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' ); ?>">
1326 + <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' ); ?>">
1296 1327 <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?>
1297 1328 </a>
1298 1329 <?php
1299 1330 }
@@ -1316,8 +1347,63 @@
1316 1347 wp_die();
1317 1348 }
1318 1349
1319 1350 /**
1351 + * Allowed URLs used for internal source of plugins installation.
1352 + *
1353 + * @since 6.3.1
1354 + *
1355 + * @return array
1356 + */
1357 + private static function allowed_external_urls() {
1358 + $allowed_url_list = array(
1359 + 'https://downloads.wordpress.org/plugin/formidable-gravity-forms-importer.zip',
1360 + 'https://downloads.wordpress.org/plugin/formidable-import-pirate-forms.zip',
1361 + 'https://downloads.wordpress.org/plugin/wp-mail-smtp.zip',
1362 + );
1363 +
1364 + /**
1365 + * List of URLs used in plugin formidable internal installation.
1366 + *
1367 + * @since 6.3.1
1368 + *
1369 + * @param array $allowed_url_list List of URLs.
1370 + */
1371 + $allowed_url_list = apply_filters( 'frm_allowed_external_urls', $allowed_url_list );
1372 +
1373 + if ( ! is_array( $allowed_url_list ) ) {
1374 + _doing_it_wrong( __METHOD__, 'Only an array of URLs could be used within this filter.', '6.3.1' );
1375 +
1376 + return array();
1377 + }
1378 +
1379 + return $allowed_url_list;
1380 + }
1381 +
1382 + /**
1383 + * Gets required plan for an addon.
1384 + *
1385 + * @since 6.4.2
1386 + *
1387 + * @return string Empty string if no plan is required for active license.
1388 + */
1389 + public static function get_addon_required_plan( $addon_id ) {
1390 + $api = new FrmFormApi();
1391 + $addons = $api->get_api_info();
1392 +
1393 + if ( is_array( $addons ) && array_key_exists( $addon_id, $addons ) ) {
1394 + $dates = $addons[ $addon_id ];
1395 + $requires = FrmFormsHelper::get_plan_required( $dates );
1396 + }
1397 +
1398 + if ( ! isset( $requires ) || ! is_string( $requires ) ) {
1399 + $requires = '';
1400 + }
1401 +
1402 + return $requires;
1403 + }
1404 +
1405 + /**
1320 1406 * @since 4.06.02
1321 1407 *
1322 1408 * @deprecated 4.09.01
1323 1409 *
@@ -1386,9 +1472,9 @@
1386 1472 * @deprecated 3.04.03
1387 1473 * @codeCoverageIgnore
1388 1474 *
1389 1475 * @param boolean $return
1390 - * @param string $package
1476 + * @param string $package
1391 1477 *
1392 1478 * @return boolean
1393 1479 */
1394 1480 public static function add_shorten_edd_filename_filter( $return, $package ) {