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 +86 -37 6.46.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 }
@@ -1023,10 +1025,8 @@
1023 1025 *
1024 1026 * @since 3.04.02
1025 1027 */
1026 1028 protected static function install_addon() {
1027 - FrmAppHelper::permission_check( 'install_plugins' );
1028 -
1029 1029 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1030 1030
1031 1031 $download_url = self::get_current_plugin();
1032 1032
@@ -1077,10 +1077,12 @@
1077 1077 */
1078 1078 private static function get_addon_activation_response() {
1079 1079 $activating_page = self::get_activating_page();
1080 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 +
1081 1083 $response = array(
1082 - 'message' => __( 'Your plugin has been activated. Would you like to save and reload the page now?', 'formidable' ),
1084 + 'message' => $message,
1083 1085 'saveAndReload' => $activating_page,
1084 1086 );
1085 1087
1086 1088 return $response;
@@ -1107,9 +1109,9 @@
1107 1109
1108 1110 /**
1109 1111 * @since 3.04.02
1110 1112 *
1111 - * @param string $installed The plugin folder name with file name
1113 + * @param string $installed The plugin folder name with file name.
1112 1114 */
1113 1115 protected static function maybe_activate_addon( $installed ) {
1114 1116 if ( ! $installed ) {
1115 1117 return;
@@ -1177,17 +1179,13 @@
1177 1179 *
1178 1180 * @return bool
1179 1181 */
1180 1182 public static function can_install_addon_api() {
1181 - if ( ! current_user_can( 'activate_plugins' ) ) {
1182 - return false;
1183 - }
1184 -
1185 1183 // Verify params present (auth & download link).
1186 1184 $post_auth = FrmAppHelper::get_param( 'token', '', 'request', 'sanitize_text_field' );
1187 1185 $post_url = FrmAppHelper::get_param( 'file_url', '', 'request', 'sanitize_text_field' );
1188 1186
1189 - if ( empty( $post_auth ) || empty( $post_url ) ) {
1187 + if ( ! $post_auth || ! $post_url ) {
1190 1188 return false;
1191 1189 }
1192 1190
1193 1191 // Verify auth.
@@ -1247,20 +1245,33 @@
1247 1245
1248 1246 /**
1249 1247 * Render a conditional action button for a specified plugin
1250 1248 *
1251 - * @param string $plugin
1249 + * @since 4.09
1250 + *
1251 + * @param string $plugin
1252 1252 * @param array|string $upgrade_link_args
1253 - * @since 4.09
1253 + * @return void
1254 1254 */
1255 1255 public static function conditional_action_button( $plugin, $upgrade_link_args ) {
1256 1256 if ( is_callable( 'FrmProAddonsController::conditional_action_button' ) ) {
1257 - return FrmProAddonsController::conditional_action_button( $plugin, $upgrade_link_args );
1257 + FrmProAddonsController::conditional_action_button( $plugin, $upgrade_link_args );
1258 + return;
1258 1259 }
1259 1260
1260 1261 $addon = self::get_addon( $plugin );
1261 1262 $upgrade_link = FrmAppHelper::admin_upgrade_link( $upgrade_link_args );
1262 - 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 );
1263 1274 }
1264 1275
1265 1276 /**
1266 1277 * Render a conditional action button for an add on
@@ -1266,16 +1277,22 @@
1266 1277 * Render a conditional action button for an add on
1267 1278 *
1268 1279 * @since 4.09.01
1269 1280 *
1270 - * @param array $addon
1271 - * @param string|false $license_type
1272 - * @param string $plan_required
1273 - * @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
1274 1290 */
1275 1291 public static function show_conditional_action_button( $atts ) {
1276 1292 if ( is_callable( 'FrmProAddonsController::show_conditional_action_button' ) ) {
1277 - return FrmProAddonsController::show_conditional_action_button( $atts );
1293 + FrmProAddonsController::show_conditional_action_button( $atts );
1294 + return;
1278 1295 }
1279 1296
1280 1297 self::addon_upgrade_link( $atts['addon'], $atts['upgrade_link'] );
1281 1298 }
@@ -1282,13 +1299,17 @@
1282 1299
1283 1300 /**
1284 1301 * @since 4.09.01
1285 1302 *
1286 - * @param array|false $addon
1303 + * @param array|false $addon
1304 + * @param string|array $upgrade_link
1287 1305 *
1288 1306 * @return void
1289 1307 */
1290 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 +
1291 1312 if ( $addon ) {
1292 1313 $upgrade_link .= '&utm_content=' . $addon['slug'];
1293 1314 }
1294 1315
@@ -1295,10 +1316,15 @@
1295 1316 if ( $addon && isset( $addon['categories'] ) && in_array( 'Solution', $addon['categories'], true ) ) {
1296 1317 // Solutions will go to a separate page.
1297 1318 $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] );
1298 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 + }
1299 1325 ?>
1300 - <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' ); ?>">
1301 1327 <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?>
1302 1328 </a>
1303 1329 <?php
1304 1330 }
@@ -1353,8 +1379,31 @@
1353 1379 return $allowed_url_list;
1354 1380 }
1355 1381
1356 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 + /**
1357 1406 * @since 4.06.02
1358 1407 *
1359 1408 * @deprecated 4.09.01
1360 1409 *
@@ -1423,9 +1472,9 @@
1423 1472 * @deprecated 3.04.03
1424 1473 * @codeCoverageIgnore
1425 1474 *
1426 1475 * @param boolean $return
1427 - * @param string $package
1476 + * @param string $package
1428 1477 *
1429 1478 * @return boolean
1430 1479 */
1431 1480 public static function add_shorten_edd_filename_filter( $return, $package ) {