| @@ -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,15 +352,16 @@ | ||
| 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 | |
| @@ -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; |
| @@ -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. |
| @@ -1258,9 +1256,19 @@ | ||
| 1258 | 1256 | } |
| 1259 | 1257 | |
| 1260 | 1258 | $addon = self::get_addon( $plugin ); |
| 1261 | 1259 | $upgrade_link = FrmAppHelper::admin_upgrade_link( $upgrade_link_args ); |
| 1262 | - self::addon_upgrade_link( $addon, $upgrade_link ); | |
| 1260 | + | |
| 1261 | + if ( ! is_array( $upgrade_link_args ) ) { | |
| 1262 | + // A string $upgrade_link_args is used for the utm-medium value when calling | |
| 1263 | + // FrmAppHelper::admin_upgrade_link above. | |
| 1264 | + // For self::addon_upgrade_link, we'll pass just an empty array with the link key (set below). | |
| 1265 | + $upgrade_link_args = array(); | |
| 1266 | + } | |
| 1267 | + | |
| 1268 | + $upgrade_link_args['link'] = $upgrade_link; | |
| 1269 | + | |
| 1270 | + self::addon_upgrade_link( $addon, $upgrade_link_args ); | |
| 1263 | 1271 | } |
| 1264 | 1272 | |
| 1265 | 1273 | /** |
| 1266 | 1274 | * Render a conditional action button for an add on |
| @@ -1282,13 +1290,17 @@ | ||
| 1282 | 1290 | |
| 1283 | 1291 | /** |
| 1284 | 1292 | * @since 4.09.01 |
| 1285 | 1293 | * |
| 1286 | - * @param array|false $addon | |
| 1294 | + * @param array|false $addon | |
| 1295 | + * @param string|array $upgrade_link | |
| 1287 | 1296 | * |
| 1288 | 1297 | * @return void |
| 1289 | 1298 | */ |
| 1290 | 1299 | protected static function addon_upgrade_link( $addon, $upgrade_link ) { |
| 1300 | + $atts = is_array( $upgrade_link ) ? $upgrade_link : array(); | |
| 1301 | + $upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link; | |
| 1302 | + | |
| 1291 | 1303 | if ( $addon ) { |
| 1292 | 1304 | $upgrade_link .= '&utm_content=' . $addon['slug']; |
| 1293 | 1305 | } |
| 1294 | 1306 | |
| @@ -1295,10 +1307,15 @@ | ||
| 1295 | 1307 | if ( $addon && isset( $addon['categories'] ) && in_array( 'Solution', $addon['categories'], true ) ) { |
| 1296 | 1308 | // Solutions will go to a separate page. |
| 1297 | 1309 | $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] ); |
| 1298 | 1310 | } |
| 1311 | + | |
| 1312 | + $class = ! empty( $atts['class'] ) ? $atts['class'] : ''; | |
| 1313 | + if ( strpos( $class, 'frm-button' ) === false ) { | |
| 1314 | + $class .= ' frm-button-secondary frm-button-sm'; | |
| 1315 | + } | |
| 1299 | 1316 | ?> |
| 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' ); ?>"> | |
| 1317 | + <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 | 1318 | <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?> |
| 1302 | 1319 | </a> |
| 1303 | 1320 | <?php |
| 1304 | 1321 | } |
| @@ -1350,8 +1367,31 @@ | ||
| 1350 | 1367 | return array(); |
| 1351 | 1368 | } |
| 1352 | 1369 | |
| 1353 | 1370 | return $allowed_url_list; |
| 1371 | + } | |
| 1372 | + | |
| 1373 | + /** | |
| 1374 | + * Gets required plan for an addon. | |
| 1375 | + * | |
| 1376 | + * @since 6.4.2 | |
| 1377 | + * | |
| 1378 | + * @return string Empty string if no plan is required for active license. | |
| 1379 | + */ | |
| 1380 | + public static function get_addon_required_plan( $addon_id ) { | |
| 1381 | + $api = new FrmFormApi(); | |
| 1382 | + $addons = $api->get_api_info(); | |
| 1383 | + | |
| 1384 | + if ( is_array( $addons ) && array_key_exists( $addon_id, $addons ) ) { | |
| 1385 | + $dates = $addons[ $addon_id ]; | |
| 1386 | + $requires = FrmFormsHelper::get_plan_required( $dates ); | |
| 1387 | + } | |
| 1388 | + | |
| 1389 | + if ( ! isset( $requires ) || ! is_string( $requires ) ) { | |
| 1390 | + $requires = ''; | |
| 1391 | + } | |
| 1392 | + | |
| 1393 | + return $requires; | |
| 1354 | 1394 | } |
| 1355 | 1395 | |
| 1356 | 1396 | /** |
| 1357 | 1397 | * @since 4.06.02 |