| @@ -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 | |
| @@ -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'] ) ) { |
| @@ -544,11 +530,8 @@ | ||
| 544 | 530 | |
| 545 | 531 | return $plugin; |
| 546 | 532 | } |
| 547 | 533 | |
| 548 | - /** | |
| 549 | - * @return void | |
| 550 | - */ | |
| 551 | 534 | protected static function prepare_addons( &$addons ) { |
| 552 | 535 | $activate_url = ''; |
| 553 | 536 | if ( current_user_can( 'activate_plugins' ) ) { |
| 554 | 537 | $activate_url = add_query_arg( array( 'action' => 'activate' ), admin_url( 'plugins.php' ) ); |
| @@ -606,11 +589,8 @@ | ||
| 606 | 589 | $addons[ $id ] = $addon; |
| 607 | 590 | } |
| 608 | 591 | } |
| 609 | 592 | |
| 610 | - /** | |
| 611 | - * @return bool | |
| 612 | - */ | |
| 613 | 593 | private static function is_plugin_active( $file_name, $slug ) { |
| 614 | 594 | if ( 'formidable-views/formidable-views.php' === $file_name ) { |
| 615 | 595 | return self::get_active_views_version() === $slug; |
| 616 | 596 | } |
| @@ -629,10 +609,8 @@ | ||
| 629 | 609 | } |
| 630 | 610 | |
| 631 | 611 | /** |
| 632 | 612 | * @since 3.04.02 |
| 633 | - * | |
| 634 | - * @return void | |
| 635 | 613 | */ |
| 636 | 614 | protected static function prepare_addon_link( &$link ) { |
| 637 | 615 | $site_url = 'https://formidableforms.com/'; |
| 638 | 616 | if ( strpos( $link, 'http' ) !== 0 ) { |
| @@ -651,10 +629,8 @@ | ||
| 651 | 629 | * Add the status to the addon array. Status options are: |
| 652 | 630 | * installed, active, not installed |
| 653 | 631 | * |
| 654 | 632 | * @since 3.04.02 |
| 655 | - * | |
| 656 | - * @return void | |
| 657 | 633 | */ |
| 658 | 634 | protected static function set_addon_status( &$addon ) { |
| 659 | 635 | if ( ! empty( $addon['activate_url'] ) ) { |
| 660 | 636 | $addon['status'] = array( |
| @@ -673,11 +649,8 @@ | ||
| 673 | 649 | ); |
| 674 | 650 | } |
| 675 | 651 | } |
| 676 | 652 | |
| 677 | - /** | |
| 678 | - * @return void | |
| 679 | - */ | |
| 680 | 653 | public static function upgrade_to_pro() { |
| 681 | 654 | FrmAppHelper::include_svg(); |
| 682 | 655 | |
| 683 | 656 | $link_parts = array( |
| @@ -887,10 +860,8 @@ | ||
| 887 | 860 | /** |
| 888 | 861 | * Install Pro after connection with Formidable. |
| 889 | 862 | * |
| 890 | 863 | * @since 4.02.05 |
| 891 | - * | |
| 892 | - * @return void | |
| 893 | 864 | */ |
| 894 | 865 | public static function connect_pro() { |
| 895 | 866 | FrmAppHelper::permission_check( 'install_plugins' ); |
| 896 | 867 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| @@ -962,10 +933,8 @@ | ||
| 962 | 933 | } |
| 963 | 934 | |
| 964 | 935 | /** |
| 965 | 936 | * @since 3.04.02 |
| 966 | - * | |
| 967 | - * @return void | |
| 968 | 937 | */ |
| 969 | 938 | protected static function maybe_show_cred_form() { |
| 970 | 939 | if ( ! function_exists( 'request_filesystem_credentials' ) ) { |
| 971 | 940 | include_once( ABSPATH . 'wp-admin/includes/file.php' ); |
| @@ -1002,23 +971,8 @@ | ||
| 1002 | 971 | ob_end_clean(); |
| 1003 | 972 | } |
| 1004 | 973 | |
| 1005 | 974 | /** |
| 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 | 975 | * We do not need any extra credentials if we have gotten this far, |
| 1022 | 976 | * so let's install the plugin. |
| 1023 | 977 | * |
| 1024 | 978 | * @since 3.04.02 |
| @@ -1023,15 +977,13 @@ | ||
| 1023 | 977 | * |
| 1024 | 978 | * @since 3.04.02 |
| 1025 | 979 | */ |
| 1026 | 980 | protected static function install_addon() { |
| 1027 | - FrmAppHelper::permission_check( 'install_plugins' ); | |
| 1028 | - | |
| 1029 | 981 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 1030 | 982 | |
| 1031 | 983 | $download_url = self::get_current_plugin(); |
| 1032 | 984 | |
| 1033 | - if ( ! self::url_is_allowed( $download_url ) ) { | |
| 985 | + if ( ! FrmAppHelper::validate_url_is_in_s3_bucket( $download_url, 'zip' ) ) { | |
| 1034 | 986 | return array( |
| 1035 | 987 | 'message' => 'Plugin URL is not valid', |
| 1036 | 988 | 'success' => false, |
| 1037 | 989 | ); |
| @@ -1055,10 +1007,8 @@ | ||
| 1055 | 1007 | } |
| 1056 | 1008 | |
| 1057 | 1009 | /** |
| 1058 | 1010 | * @since 3.06.03 |
| 1059 | - * | |
| 1060 | - * @return void | |
| 1061 | 1011 | */ |
| 1062 | 1012 | public static function ajax_activate_addon() { |
| 1063 | 1013 | |
| 1064 | 1014 | self::install_addon_permissions(); |
| @@ -1072,17 +1022,15 @@ | ||
| 1072 | 1022 | wp_die(); |
| 1073 | 1023 | } |
| 1074 | 1024 | |
| 1075 | 1025 | /** |
| 1076 | - * @return array | |
| 1026 | + * @return array|string | |
| 1077 | 1027 | */ |
| 1078 | 1028 | private static function get_addon_activation_response() { |
| 1079 | 1029 | $activating_page = self::get_activating_page(); |
| 1080 | 1030 | |
| 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 | 1031 | $response = array( |
| 1084 | - 'message' => $message, | |
| 1032 | + 'message' => __( 'Your plugin has been activated. Would you like to save and reload the page now?', 'formidable' ), | |
| 1085 | 1033 | 'saveAndReload' => $activating_page, |
| 1086 | 1034 | ); |
| 1087 | 1035 | |
| 1088 | 1036 | return $response; |
| @@ -1108,9 +1056,8 @@ | ||
| 1108 | 1056 | } |
| 1109 | 1057 | |
| 1110 | 1058 | /** |
| 1111 | 1059 | * @since 3.04.02 |
| 1112 | - * | |
| 1113 | 1060 | * @param string $installed The plugin folder name with file name |
| 1114 | 1061 | */ |
| 1115 | 1062 | protected static function maybe_activate_addon( $installed ) { |
| 1116 | 1063 | if ( ! $installed ) { |
| @@ -1136,10 +1083,8 @@ | ||
| 1136 | 1083 | /** |
| 1137 | 1084 | * Run security checks before installing |
| 1138 | 1085 | * |
| 1139 | 1086 | * @since 3.04.02 |
| 1140 | - * | |
| 1141 | - * @return void | |
| 1142 | 1087 | */ |
| 1143 | 1088 | protected static function install_addon_permissions() { |
| 1144 | 1089 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 1145 | 1090 | |
| @@ -1150,10 +1095,8 @@ | ||
| 1150 | 1095 | } |
| 1151 | 1096 | |
| 1152 | 1097 | /** |
| 1153 | 1098 | * @since 4.08 |
| 1154 | - * | |
| 1155 | - * @return string | |
| 1156 | 1099 | */ |
| 1157 | 1100 | public static function connect_link() { |
| 1158 | 1101 | $auth = get_option( 'frm_connect_token' ); |
| 1159 | 1102 | if ( empty( $auth ) ) { |
| @@ -1179,12 +1122,8 @@ | ||
| 1179 | 1122 | * |
| 1180 | 1123 | * @return bool |
| 1181 | 1124 | */ |
| 1182 | 1125 | public static function can_install_addon_api() { |
| 1183 | - if ( ! current_user_can( 'activate_plugins' ) ) { | |
| 1184 | - return false; | |
| 1185 | - } | |
| 1186 | - | |
| 1187 | 1126 | // Verify params present (auth & download link). |
| 1188 | 1127 | $post_auth = FrmAppHelper::get_param( 'token', '', 'request', 'sanitize_text_field' ); |
| 1189 | 1128 | $post_url = FrmAppHelper::get_param( 'file_url', '', 'request', 'sanitize_text_field' ); |
| 1190 | 1129 | |
| @@ -1260,11 +1199,9 @@ | ||
| 1260 | 1199 | } |
| 1261 | 1200 | |
| 1262 | 1201 | $addon = self::get_addon( $plugin ); |
| 1263 | 1202 | $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 ); | |
| 1203 | + self::addon_upgrade_link( $addon, $upgrade_link ); | |
| 1267 | 1204 | } |
| 1268 | 1205 | |
| 1269 | 1206 | /** |
| 1270 | 1207 | * Render a conditional action button for an add on |
| @@ -1269,9 +1206,8 @@ | ||
| 1269 | 1206 | /** |
| 1270 | 1207 | * Render a conditional action button for an add on |
| 1271 | 1208 | * |
| 1272 | 1209 | * @since 4.09.01 |
| 1273 | - * | |
| 1274 | 1210 | * @param array $addon |
| 1275 | 1211 | * @param string|false $license_type |
| 1276 | 1212 | * @param string $plan_required |
| 1277 | 1213 | * @param string $upgrade_link |
| @@ -1285,18 +1221,10 @@ | ||
| 1285 | 1221 | } |
| 1286 | 1222 | |
| 1287 | 1223 | /** |
| 1288 | 1224 | * @since 4.09.01 |
| 1289 | - * | |
| 1290 | - * @param array|false $addon | |
| 1291 | - * @param string|array $upgrade_link | |
| 1292 | - * | |
| 1293 | - * @return void | |
| 1294 | 1225 | */ |
| 1295 | 1226 | 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 | 1227 | if ( $addon ) { |
| 1300 | 1228 | $upgrade_link .= '&utm_content=' . $addon['slug']; |
| 1301 | 1229 | } |
| 1302 | 1230 | |
| @@ -1303,15 +1231,10 @@ | ||
| 1303 | 1231 | if ( $addon && isset( $addon['categories'] ) && in_array( 'Solution', $addon['categories'], true ) ) { |
| 1304 | 1232 | // Solutions will go to a separate page. |
| 1305 | 1233 | $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] ); |
| 1306 | 1234 | } |
| 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 | 1235 | ?> |
| 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' ); ?>"> | |
| 1236 | + <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 | 1237 | <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?> |
| 1315 | 1238 | </a> |
| 1316 | 1239 | <?php |
| 1317 | 1240 | } |
| @@ -1317,10 +1240,8 @@ | ||
| 1317 | 1240 | } |
| 1318 | 1241 | |
| 1319 | 1242 | /** |
| 1320 | 1243 | * @since 3.04.02 |
| 1321 | - * | |
| 1322 | - * @return void | |
| 1323 | 1244 | */ |
| 1324 | 1245 | public static function ajax_install_addon() { |
| 1325 | 1246 | self::install_addon_permissions(); |
| 1326 | 1247 | |
| @@ -1334,68 +1255,10 @@ | ||
| 1334 | 1255 | wp_die(); |
| 1335 | 1256 | } |
| 1336 | 1257 | |
| 1337 | 1258 | /** |
| 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 | 1259 | * @since 4.06.02 |
| 1394 | - * | |
| 1395 | 1260 | * @deprecated 4.09.01 |
| 1396 | - * | |
| 1397 | - * @return void | |
| 1398 | 1261 | */ |
| 1399 | 1262 | public static function ajax_multiple_addons() { |
| 1400 | 1263 | FrmDeprecated::ajax_multiple_addons(); |
| 1401 | 1264 | } |
| @@ -1442,14 +1305,10 @@ | ||
| 1442 | 1305 | } |
| 1443 | 1306 | |
| 1444 | 1307 | /** |
| 1445 | 1308 | * @since 3.04.03 |
| 1446 | - * | |
| 1447 | 1309 | * @deprecated 3.06 |
| 1448 | - * | |
| 1449 | 1310 | * @codeCoverageIgnore |
| 1450 | - * | |
| 1451 | - * @return void | |
| 1452 | 1311 | */ |
| 1453 | 1312 | public static function reset_cached_addons( $license = '' ) { |
| 1454 | 1313 | FrmDeprecated::reset_cached_addons( $license ); |
| 1455 | 1314 | } |
| @@ -1483,12 +1342,9 @@ | ||
| 1483 | 1342 | } |
| 1484 | 1343 | |
| 1485 | 1344 | /** |
| 1486 | 1345 | * @deprecated 3.04.03 |
| 1487 | - * | |
| 1488 | 1346 | * @codeCoverageIgnore |
| 1489 | - * | |
| 1490 | - * @return void | |
| 1491 | 1347 | */ |
| 1492 | 1348 | public static function get_licenses() { |
| 1493 | 1349 | FrmDeprecated::get_licenses(); |
| 1494 | 1350 | } |