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