| @@ -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() ) { |
| @@ -351,15 +351,16 @@ | ||
| 351 | 351 | // don't show an update if the plugin isn't installed |
| 352 | 352 | continue; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array(); | |
| 356 | - $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0'; | |
| 355 | + $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array(); | |
| 356 | + $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0'; | |
| 357 | + $plugin->slug = explode( '/', $folder )[0]; | |
| 357 | 358 | |
| 358 | 359 | if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) { |
| 359 | - $slug = explode( '/', $folder ); | |
| 360 | - $plugin->slug = $slug[0]; | |
| 361 | 360 | $transient->response[ $folder ] = $plugin; |
| 361 | + } else { | |
| 362 | + $transient->no_update[ $folder ] = $plugin; | |
| 362 | 363 | } |
| 363 | 364 | |
| 364 | 365 | $transient->checked[ $folder ] = $wp_version; |
| 365 | 366 | |
| @@ -1012,10 +1013,9 @@ | ||
| 1012 | 1013 | * @return bool |
| 1013 | 1014 | */ |
| 1014 | 1015 | public static function url_is_allowed( $download_url ) { |
| 1015 | 1016 | 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 ) | |
| 1017 | + FrmAppHelper::validate_url_is_in_s3_bucket( $download_url, 'zip' ) || in_array( $download_url, self::allowed_external_urls(), true ) | |
| 1018 | 1018 | ); |
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | /** |
| @@ -1076,10 +1076,12 @@ | ||
| 1076 | 1076 | */ |
| 1077 | 1077 | private static function get_addon_activation_response() { |
| 1078 | 1078 | $activating_page = self::get_activating_page(); |
| 1079 | 1079 | |
| 1080 | + $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' ); | |
| 1081 | + | |
| 1080 | 1082 | $response = array( |
| 1081 | - 'message' => __( 'Your plugin has been activated. Would you like to save and reload the page now?', 'formidable' ), | |
| 1083 | + 'message' => $message, | |
| 1082 | 1084 | 'saveAndReload' => $activating_page, |
| 1083 | 1085 | ); |
| 1084 | 1086 | |
| 1085 | 1087 | return $response; |
| @@ -1180,9 +1182,9 @@ | ||
| 1180 | 1182 | // Verify params present (auth & download link). |
| 1181 | 1183 | $post_auth = FrmAppHelper::get_param( 'token', '', 'request', 'sanitize_text_field' ); |
| 1182 | 1184 | $post_url = FrmAppHelper::get_param( 'file_url', '', 'request', 'sanitize_text_field' ); |
| 1183 | 1185 | |
| 1184 | - if ( empty( $post_auth ) || empty( $post_url ) ) { | |
| 1186 | + if ( ! $post_auth || ! $post_url ) { | |
| 1185 | 1187 | return false; |
| 1186 | 1188 | } |
| 1187 | 1189 | |
| 1188 | 1190 | // Verify auth. |
| @@ -1253,9 +1255,11 @@ | ||
| 1253 | 1255 | } |
| 1254 | 1256 | |
| 1255 | 1257 | $addon = self::get_addon( $plugin ); |
| 1256 | 1258 | $upgrade_link = FrmAppHelper::admin_upgrade_link( $upgrade_link_args ); |
| 1257 | - self::addon_upgrade_link( $addon, $upgrade_link ); | |
| 1259 | + | |
| 1260 | + $upgrade_link_args['link'] = $upgrade_link; | |
| 1261 | + self::addon_upgrade_link( $addon, $upgrade_link_args ); | |
| 1258 | 1262 | } |
| 1259 | 1263 | |
| 1260 | 1264 | /** |
| 1261 | 1265 | * Render a conditional action button for an add on |
| @@ -1277,13 +1281,17 @@ | ||
| 1277 | 1281 | |
| 1278 | 1282 | /** |
| 1279 | 1283 | * @since 4.09.01 |
| 1280 | 1284 | * |
| 1281 | - * @param array|false $addon | |
| 1285 | + * @param array|false $addon | |
| 1286 | + * @param string|array $upgrade_link | |
| 1282 | 1287 | * |
| 1283 | 1288 | * @return void |
| 1284 | 1289 | */ |
| 1285 | 1290 | protected static function addon_upgrade_link( $addon, $upgrade_link ) { |
| 1291 | + $atts = is_array( $upgrade_link ) ? $upgrade_link : array(); | |
| 1292 | + $upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link; | |
| 1293 | + | |
| 1286 | 1294 | if ( $addon ) { |
| 1287 | 1295 | $upgrade_link .= '&utm_content=' . $addon['slug']; |
| 1288 | 1296 | } |
| 1289 | 1297 | |
| @@ -1290,10 +1298,15 @@ | ||
| 1290 | 1298 | if ( $addon && isset( $addon['categories'] ) && in_array( 'Solution', $addon['categories'], true ) ) { |
| 1291 | 1299 | // Solutions will go to a separate page. |
| 1292 | 1300 | $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] ); |
| 1293 | 1301 | } |
| 1302 | + | |
| 1303 | + $class = ! empty( $atts['class'] ) ? $atts['class'] : ''; | |
| 1304 | + if ( strpos( $class, 'frm-button' ) === false ) { | |
| 1305 | + $class .= ' frm-button-secondary frm-button-sm'; | |
| 1306 | + } | |
| 1294 | 1307 | ?> |
| 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' ); ?>"> | |
| 1308 | + <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 | 1309 | <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?> |
| 1297 | 1310 | </a> |
| 1298 | 1311 | <?php |
| 1299 | 1312 | } |
| @@ -1313,8 +1326,63 @@ | ||
| 1313 | 1326 | } |
| 1314 | 1327 | |
| 1315 | 1328 | echo json_encode( self::get_addon_activation_response() ); |
| 1316 | 1329 | wp_die(); |
| 1330 | + } | |
| 1331 | + | |
| 1332 | + /** | |
| 1333 | + * Allowed URLs used for internal source of plugins installation. | |
| 1334 | + * | |
| 1335 | + * @since 6.3.1 | |
| 1336 | + * | |
| 1337 | + * @return array | |
| 1338 | + */ | |
| 1339 | + private static function allowed_external_urls() { | |
| 1340 | + $allowed_url_list = array( | |
| 1341 | + 'https://downloads.wordpress.org/plugin/formidable-gravity-forms-importer.zip', | |
| 1342 | + 'https://downloads.wordpress.org/plugin/formidable-import-pirate-forms.zip', | |
| 1343 | + 'https://downloads.wordpress.org/plugin/wp-mail-smtp.zip', | |
| 1344 | + ); | |
| 1345 | + | |
| 1346 | + /** | |
| 1347 | + * List of URLs used in plugin formidable internal installation. | |
| 1348 | + * | |
| 1349 | + * @since 6.3.1 | |
| 1350 | + * | |
| 1351 | + * @param array $allowed_url_list List of URLs. | |
| 1352 | + */ | |
| 1353 | + $allowed_url_list = apply_filters( 'frm_allowed_external_urls', $allowed_url_list ); | |
| 1354 | + | |
| 1355 | + if ( ! is_array( $allowed_url_list ) ) { | |
| 1356 | + _doing_it_wrong( __METHOD__, 'Only an array of URLs could be used within this filter.', '6.3.1' ); | |
| 1357 | + | |
| 1358 | + return array(); | |
| 1359 | + } | |
| 1360 | + | |
| 1361 | + return $allowed_url_list; | |
| 1362 | + } | |
| 1363 | + | |
| 1364 | + /** | |
| 1365 | + * Gets required plan for an addon. | |
| 1366 | + * | |
| 1367 | + * @since 6.4.2 | |
| 1368 | + * | |
| 1369 | + * @return string Empty string if no plan is required for active license. | |
| 1370 | + */ | |
| 1371 | + public static function get_addon_required_plan( $addon_id ) { | |
| 1372 | + $api = new FrmFormApi(); | |
| 1373 | + $addons = $api->get_api_info(); | |
| 1374 | + | |
| 1375 | + if ( is_array( $addons ) && array_key_exists( $addon_id, $addons ) ) { | |
| 1376 | + $dates = $addons[ $addon_id ]; | |
| 1377 | + $requires = FrmFormsHelper::get_plan_required( $dates ); | |
| 1378 | + } | |
| 1379 | + | |
| 1380 | + if ( ! isset( $requires ) || ! is_string( $requires ) ) { | |
| 1381 | + $requires = ''; | |
| 1382 | + } | |
| 1383 | + | |
| 1384 | + return $requires; | |
| 1317 | 1385 | } |
| 1318 | 1386 | |
| 1319 | 1387 | /** |
| 1320 | 1388 | * @since 4.06.02 |