| @@ -7,93 +7,13 @@ | ||
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * @var string |
| 10 | 10 | */ |
| 11 | - const SCRIPT_HANDLE = 'frm-addons-page'; | |
| 12 | - | |
| 13 | - /** | |
| 14 | - * @var array | |
| 15 | - */ | |
| 16 | - private static $categories = array(); | |
| 17 | - | |
| 18 | - /** | |
| 19 | - * @var string | |
| 20 | - */ | |
| 21 | - private static $request_addon_url; | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * @var string | |
| 25 | - */ | |
| 26 | 11 | protected static $plugin; |
| 27 | 12 | |
| 28 | 13 | /** |
| 29 | - * @since 6.15 | |
| 30 | - * | |
| 31 | 14 | * @return void |
| 32 | 15 | */ |
| 33 | - public static function load_admin_hooks() { | |
| 34 | - add_action( 'admin_menu', self::class . '::menu', 100 ); | |
| 35 | - add_filter( 'pre_set_site_transient_update_plugins', self::class . '::check_update' ); | |
| 36 | - | |
| 37 | - if ( FrmAppHelper::is_admin_page( 'formidable-addons' ) ) { | |
| 38 | - self::$request_addon_url = 'https://connect.formidableforms.com/add-on-request/'; | |
| 39 | - | |
| 40 | - add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 ); | |
| 41 | - add_filter( 'frm_show_footer_links', '__return_false' ); | |
| 42 | - } | |
| 43 | - } | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * Enqueues the Add-Ons page scripts and styles. | |
| 47 | - * | |
| 48 | - * @since 6.15 | |
| 49 | - * | |
| 50 | - * @return void | |
| 51 | - */ | |
| 52 | - public static function enqueue_assets() { | |
| 53 | - $plugin_url = FrmAppHelper::plugin_url(); | |
| 54 | - $version = FrmAppHelper::plugin_version(); | |
| 55 | - $js_dependencies = array( | |
| 56 | - 'wp-i18n', | |
| 57 | - // This prevents a console error "wp.hooks is undefined" in WP versions older than 5.7. | |
| 58 | - 'wp-hooks', | |
| 59 | - 'formidable_dom', | |
| 60 | - ); | |
| 61 | - | |
| 62 | - // Enqueue styles that needed. | |
| 63 | - wp_enqueue_style( 'formidable-admin' ); | |
| 64 | - wp_enqueue_style( 'formidable-grids' ); | |
| 65 | - | |
| 66 | - // Register and enqueue Add-Ons page style. | |
| 67 | - wp_register_style( self::SCRIPT_HANDLE, $plugin_url . '/css/admin/addons-page.css', array(), $version ); | |
| 68 | - wp_enqueue_style( self::SCRIPT_HANDLE ); | |
| 69 | - | |
| 70 | - // Register and enqueue Add-Ons page script. | |
| 71 | - wp_register_script( self::SCRIPT_HANDLE, $plugin_url . '/js/addons-page.js', $js_dependencies, $version, true ); | |
| 72 | - wp_localize_script( self::SCRIPT_HANDLE, 'frmAddonsVars', self::get_js_variables() ); | |
| 73 | - wp_enqueue_script( self::SCRIPT_HANDLE ); | |
| 74 | - wp_set_script_translations( self::SCRIPT_HANDLE, 'formidable' ); | |
| 75 | - | |
| 76 | - FrmAppHelper::dequeue_extra_global_scripts(); | |
| 77 | - } | |
| 78 | - | |
| 79 | - /** | |
| 80 | - * Get the Add-Ons page JS variables as an array. | |
| 81 | - * | |
| 82 | - * @since 6.15 | |
| 83 | - * | |
| 84 | - * @return array | |
| 85 | - */ | |
| 86 | - private static function get_js_variables() { | |
| 87 | - return array( | |
| 88 | - 'proIsIncluded' => FrmAppHelper::pro_is_included(), | |
| 89 | - 'addonRequestURL' => self::$request_addon_url, | |
| 90 | - ); | |
| 91 | - } | |
| 92 | - | |
| 93 | - /** | |
| 94 | - * @return void | |
| 95 | - */ | |
| 96 | 16 | public static function menu() { |
| 97 | 17 | if ( ! current_user_can( 'activate_plugins' ) ) { |
| 98 | 18 | return; |
| 99 | 19 | } |
| @@ -98,9 +18,9 @@ | ||
| 98 | 18 | return; |
| 99 | 19 | } |
| 100 | 20 | |
| 101 | 21 | $label = __( 'Add-Ons', 'formidable' ); |
| 102 | - $label = '<span style="color:#3FCA89">' . esc_html( $label ) . '</span>'; | |
| 22 | + $label = '<span style="color:#1da867">' . $label . '</span>'; | |
| 103 | 23 | |
| 104 | 24 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Add-Ons', 'formidable' ), $label, 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' ); |
| 105 | 25 | |
| 106 | 26 | // remove default created subpage, make the page with highest priority as default. |
| @@ -106,29 +26,20 @@ | ||
| 106 | 26 | // remove default created subpage, make the page with highest priority as default. |
| 107 | 27 | remove_submenu_page( 'formidable', 'formidable' ); |
| 108 | 28 | |
| 109 | 29 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 110 | - $cta_text = FrmSalesApi::get_best_sale_value( 'menu_cta_text' ); | |
| 111 | - | |
| 112 | - if ( ! $cta_text ) { | |
| 113 | - $cta_text = __( 'Upgrade', 'formidable' ); | |
| 114 | - } | |
| 115 | - | |
| 116 | 30 | add_submenu_page( |
| 117 | 31 | 'formidable', |
| 118 | 32 | 'Formidable | ' . __( 'Upgrade', 'formidable' ), |
| 119 | - '<span class="frm-upgrade-submenu">' . esc_html( $cta_text ) . '</span>', | |
| 33 | + '<span class="frm-upgrade-submenu">' . __( 'Upgrade', 'formidable' ) . '</span>', | |
| 120 | 34 | 'frm_view_forms', |
| 121 | 35 | 'formidable-pro-upgrade', |
| 122 | - function () { | |
| 123 | - // This function doesn't need to do anything. | |
| 124 | - // The redirect is handled earlier to avoid issues with the headers being sent. | |
| 125 | - } | |
| 36 | + 'FrmAddonsController::upgrade_to_pro' | |
| 126 | 37 | ); |
| 127 | 38 | } elseif ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) ) { |
| 128 | 39 | wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) ); |
| 129 | 40 | exit; |
| 130 | - }//end if | |
| 41 | + } | |
| 131 | 42 | } |
| 132 | 43 | |
| 133 | 44 | /** |
| 134 | 45 | * @return void |
| @@ -134,31 +45,28 @@ | ||
| 134 | 45 | * @return void |
| 135 | 46 | */ |
| 136 | 47 | public static function list_addons() { |
| 137 | 48 | FrmAppHelper::include_svg(); |
| 49 | + $installed_addons = apply_filters( 'frm_installed_addons', array() ); | |
| 50 | + $license_type = ''; | |
| 138 | 51 | |
| 139 | - $view_path = FrmAppHelper::plugin_path() . '/classes/views/addons/'; | |
| 140 | - $installed_addons = apply_filters( 'frm_installed_addons', array() ); | |
| 141 | - $addons = self::get_api_addons(); | |
| 142 | - $errors = array(); | |
| 143 | - $license_type = ''; | |
| 144 | - $request_addon_url = self::$request_addon_url; | |
| 52 | + $addons = self::get_api_addons(); | |
| 53 | + $errors = array(); | |
| 145 | 54 | |
| 146 | 55 | if ( isset( $addons['error'] ) ) { |
| 147 | 56 | $api = new FrmFormApi(); |
| 148 | 57 | $errors = $api->get_error_from_response( $addons ); |
| 149 | - $license_type = $addons['error']['type'] ?? ''; | |
| 58 | + $license_type = isset( $addons['error']['type'] ) ? $addons['error']['type'] : ''; | |
| 150 | 59 | unset( $addons['error'] ); |
| 151 | 60 | } |
| 152 | 61 | |
| 153 | 62 | $pro = array( |
| 154 | 63 | 'pro' => array( |
| 155 | - 'title' => 'Formidable Forms Pro', | |
| 156 | - 'slug' => 'formidable-pro', | |
| 157 | - 'released' => '2011-02-05', | |
| 158 | - 'docs' => 'knowledgebase/', | |
| 159 | - 'categories' => array( 'basic', 'plus', 'business', 'elite' ), | |
| 160 | - 'excerpt' => 'Create calculators, surveys, smart forms, and data-driven applications. Build directories, real estate listings, job boards, and much more.', | |
| 64 | + 'title' => 'Formidable Forms Pro', | |
| 65 | + 'slug' => 'formidable-pro', | |
| 66 | + 'released' => '2011-02-05', | |
| 67 | + 'docs' => 'knowledgebase/', | |
| 68 | + 'excerpt' => 'Create calculators, surveys, smart forms, and data-driven applications. Build directories, real estate listings, job boards, and much more.', | |
| 161 | 69 | ), |
| 162 | 70 | ); |
| 163 | 71 | $addons = $pro + $addons; |
| 164 | 72 | self::prepare_addons( $addons ); |
| @@ -164,110 +72,16 @@ | ||
| 164 | 72 | self::prepare_addons( $addons ); |
| 165 | 73 | |
| 166 | 74 | $pricing = FrmAppHelper::admin_upgrade_link( 'addons' ); |
| 167 | 75 | |
| 168 | - self::organize_and_get_categories(); | |
| 169 | - $categories = self::$categories; | |
| 170 | - | |
| 171 | - include $view_path . 'index.php'; | |
| 76 | + include FrmAppHelper::plugin_path() . '/classes/views/addons/list.php'; | |
| 172 | 77 | } |
| 173 | 78 | |
| 174 | 79 | /** |
| 175 | - * Organize and set categories. | |
| 176 | - * | |
| 177 | - * @since 6.15 | |
| 178 | - * | |
| 179 | 80 | * @return void |
| 180 | 81 | */ |
| 181 | - protected static function organize_and_get_categories() { | |
| 182 | - unset( self::$categories['strategy11'] ); | |
| 183 | - ksort( self::$categories ); | |
| 184 | - | |
| 185 | - $bottom_categories = array(); | |
| 186 | - $plans = FrmFormsHelper::get_license_types( | |
| 187 | - array( | |
| 188 | - 'include_all' => false, | |
| 189 | - 'case_lower' => true, | |
| 190 | - ) | |
| 191 | - ); | |
| 192 | - | |
| 193 | - // Extract the elements to move | |
| 194 | - foreach ( $plans as $plan ) { | |
| 195 | - if ( isset( self::$categories[ $plan ] ) ) { | |
| 196 | - $bottom_categories[ $plan ] = self::$categories[ $plan ]; | |
| 197 | - unset( self::$categories[ $plan ] ); | |
| 198 | - } | |
| 199 | - } | |
| 200 | - | |
| 201 | - $special_categories = array(); | |
| 202 | - | |
| 203 | - if ( 'elite' !== self::license_type() ) { | |
| 204 | - $special_categories['available-addons'] = array( | |
| 205 | - 'name' => __( 'Available', 'formidable' ), | |
| 206 | - // To be assigned via JavaScript. | |
| 207 | - 'count' => 0, | |
| 208 | - ); | |
| 209 | - } | |
| 210 | - | |
| 211 | - $special_categories['active-addons'] = array( | |
| 212 | - 'name' => __( 'Active', 'formidable' ), | |
| 213 | - // To be assigned via JavaScript. | |
| 214 | - 'count' => 0, | |
| 215 | - ); | |
| 216 | - | |
| 217 | - $special_categories['all-items'] = array( | |
| 218 | - 'name' => __( 'All Add-Ons', 'formidable' ), | |
| 219 | - // To be assigned via JavaScript. | |
| 220 | - 'count' => 0, | |
| 221 | - ); | |
| 222 | - | |
| 223 | - self::$categories = array_merge( | |
| 224 | - $special_categories, | |
| 225 | - self::$categories, | |
| 226 | - $bottom_categories | |
| 227 | - ); | |
| 228 | - } | |
| 229 | - | |
| 230 | - /** | |
| 231 | - * Organize and set categories. | |
| 232 | - * | |
| 233 | - * @since 6.15 | |
| 234 | - * | |
| 235 | - * @param array $addon The addon array that will be modified by reference. | |
| 236 | - * | |
| 237 | - * @return void | |
| 238 | - */ | |
| 239 | - protected static function set_categories( &$addon ) { | |
| 240 | - if ( ! isset( $addon['categories'] ) ) { | |
| 241 | - return; | |
| 242 | - } | |
| 243 | - | |
| 244 | - $addon['category-slugs'] = array(); | |
| 245 | - | |
| 246 | - foreach ( $addon['categories'] as $category ) { | |
| 247 | - $category = FrmFormsHelper::convert_legacy_package_names( $category ); | |
| 248 | - $category_slug = sanitize_title( $category ); | |
| 249 | - | |
| 250 | - // Add the slug to the new array. | |
| 251 | - $addon['category-slugs'][] = $category_slug; | |
| 252 | - | |
| 253 | - if ( ! isset( self::$categories[ $category_slug ] ) ) { | |
| 254 | - self::$categories[ $category_slug ] = array( | |
| 255 | - 'name' => $category, | |
| 256 | - 'count' => 0, | |
| 257 | - ); | |
| 258 | - } | |
| 259 | - | |
| 260 | - ++self::$categories[ $category_slug ]['count']; | |
| 261 | - } | |
| 262 | - } | |
| 263 | - | |
| 264 | - /** | |
| 265 | - * @return void | |
| 266 | - */ | |
| 267 | 82 | public static function license_settings() { |
| 268 | 83 | $plugins = apply_filters( 'frm_installed_addons', array() ); |
| 269 | - | |
| 270 | 84 | if ( empty( $plugins ) ) { |
| 271 | 85 | esc_html_e( 'There are no plugins on your site that require a license', 'formidable' ); |
| 272 | 86 | |
| 273 | 87 | return; |
| @@ -314,9 +128,8 @@ | ||
| 314 | 128 | /** |
| 315 | 129 | * If the API is unable to connect, show something on the addons page |
| 316 | 130 | * |
| 317 | 131 | * @since 3.04.03 |
| 318 | - * | |
| 319 | 132 | * @return array |
| 320 | 133 | */ |
| 321 | 134 | protected static function fallback_plugin_list() { |
| 322 | 135 | $list = array( |
| @@ -413,9 +226,8 @@ | ||
| 413 | 226 | /** |
| 414 | 227 | * If Pro is missing but has been authenticated, include a download URL |
| 415 | 228 | * |
| 416 | 229 | * @since 3.04.03 |
| 417 | - * | |
| 418 | 230 | * @return string |
| 419 | 231 | */ |
| 420 | 232 | public static function get_pro_download_url() { |
| 421 | 233 | $license = self::get_pro_license(); |
| @@ -422,20 +234,17 @@ | ||
| 422 | 234 | $api = new FrmFormApi( $license ); |
| 423 | 235 | $downloads = $api->get_api_info(); |
| 424 | 236 | $pro = self::get_pro_from_addons( $downloads ); |
| 425 | 237 | |
| 426 | - return $pro['url'] ?? ''; | |
| 238 | + return isset( $pro['url'] ) ? $pro['url'] : ''; | |
| 427 | 239 | } |
| 428 | 240 | |
| 429 | 241 | /** |
| 430 | 242 | * @since 4.08 |
| 431 | - * | |
| 432 | - * @return string | |
| 433 | 243 | */ |
| 434 | 244 | public static function get_pro_license() { |
| 435 | 245 | $pro_cred_store = 'frmpro-credentials'; |
| 436 | 246 | $pro_wpmu_store = 'frmpro-wpmu-sitewide'; |
| 437 | - | |
| 438 | 247 | if ( is_multisite() && get_site_option( $pro_wpmu_store ) ) { |
| 439 | 248 | $creds = get_site_option( $pro_cred_store ); |
| 440 | 249 | } else { |
| 441 | 250 | $creds = get_option( $pro_cred_store ); |
| @@ -445,9 +254,8 @@ | ||
| 445 | 254 | return ''; |
| 446 | 255 | } |
| 447 | 256 | |
| 448 | 257 | $license = $creds['license']; |
| 449 | - | |
| 450 | 258 | if ( empty( $license ) ) { |
| 451 | 259 | return ''; |
| 452 | 260 | } |
| 453 | 261 | |
| @@ -461,19 +269,16 @@ | ||
| 461 | 269 | /** |
| 462 | 270 | * @since 4.08 |
| 463 | 271 | * |
| 464 | 272 | * @param array $addons |
| 465 | - * | |
| 466 | 273 | * @return array |
| 467 | 274 | */ |
| 468 | 275 | protected static function get_pro_from_addons( $addons ) { |
| 469 | - return $addons['93790'] ?? array(); | |
| 276 | + return isset( $addons['93790'] ) ? $addons['93790'] : array(); | |
| 470 | 277 | } |
| 471 | 278 | |
| 472 | 279 | /** |
| 473 | 280 | * @since 4.06 |
| 474 | - * | |
| 475 | - * @return string | |
| 476 | 281 | */ |
| 477 | 282 | public static function license_type() { |
| 478 | 283 | if ( is_callable( 'FrmProAddonsController::license_type' ) ) { |
| 479 | 284 | return FrmProAddonsController::license_type(); |
| @@ -488,21 +293,18 @@ | ||
| 488 | 293 | * @return bool |
| 489 | 294 | */ |
| 490 | 295 | public static function is_license_expired() { |
| 491 | 296 | $version_info = self::get_primary_license_info(); |
| 492 | - | |
| 493 | 297 | if ( ! isset( $version_info['error'] ) ) { |
| 494 | 298 | return false; |
| 495 | 299 | } |
| 496 | 300 | |
| 497 | - $expires = $version_info['error']['expires'] ?? 0; | |
| 498 | - | |
| 301 | + $expires = isset( $version_info['error']['expires'] ) ? $version_info['error']['expires'] : 0; | |
| 499 | 302 | if ( empty( $expires ) || $expires > time() ) { |
| 500 | 303 | return false; |
| 501 | 304 | } |
| 502 | 305 | |
| 503 | 306 | $rate_limited = ! empty( $version_info['response_code'] ) && 429 === (int) $version_info['response_code']; |
| 504 | - | |
| 505 | 307 | if ( $rate_limited ) { |
| 506 | 308 | // Do not return false positives for rate limited responses. |
| 507 | 309 | return false; |
| 508 | 310 | } |
| @@ -511,8 +313,21 @@ | ||
| 511 | 313 | } |
| 512 | 314 | |
| 513 | 315 | /** |
| 514 | 316 | * @since 4.08 |
| 317 | + * | |
| 318 | + * @return bool|int false or the number of days until expiration. | |
| 319 | + */ | |
| 320 | + public static function is_license_expiring() { | |
| 321 | + if ( is_callable( 'FrmProAddonsController::is_license_expiring' ) ) { | |
| 322 | + return FrmProAddonsController::is_license_expiring(); | |
| 323 | + } | |
| 324 | + | |
| 325 | + return false; | |
| 326 | + } | |
| 327 | + | |
| 328 | + /** | |
| 329 | + * @since 4.08 | |
| 515 | 330 | * @since 6.7 This is public. |
| 516 | 331 | * |
| 517 | 332 | * @return array|false |
| 518 | 333 | */ |
| @@ -517,13 +332,11 @@ | ||
| 517 | 332 | * @return array|false |
| 518 | 333 | */ |
| 519 | 334 | public static function get_primary_license_info() { |
| 520 | 335 | $installed_addons = apply_filters( 'frm_installed_addons', array() ); |
| 521 | - | |
| 522 | 336 | if ( empty( $installed_addons ) || ! isset( $installed_addons['formidable_pro'] ) ) { |
| 523 | 337 | return false; |
| 524 | 338 | } |
| 525 | - | |
| 526 | 339 | $installed_addons = array( |
| 527 | 340 | 'formidable_pro' => $installed_addons['formidable_pro'], |
| 528 | 341 | ); |
| 529 | 342 | |
| @@ -531,12 +344,8 @@ | ||
| 531 | 344 | } |
| 532 | 345 | |
| 533 | 346 | /** |
| 534 | 347 | * @since 3.04.03 |
| 535 | - * | |
| 536 | - * @param mixed $transient | |
| 537 | - * | |
| 538 | - * @return object | |
| 539 | 348 | */ |
| 540 | 349 | public static function check_update( $transient ) { |
| 541 | 350 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 542 | 351 | // Don't make any changes if only Lite is installed. |
| @@ -547,9 +356,8 @@ | ||
| 547 | 356 | $transient = new stdClass(); |
| 548 | 357 | } |
| 549 | 358 | |
| 550 | 359 | $installed_addons = apply_filters( 'frm_installed_addons', array() ); |
| 551 | - | |
| 552 | 360 | if ( empty( $installed_addons ) ) { |
| 553 | 361 | return $transient; |
| 554 | 362 | } |
| 555 | 363 | |
| @@ -564,9 +372,8 @@ | ||
| 564 | 372 | continue; |
| 565 | 373 | } |
| 566 | 374 | |
| 567 | 375 | $folder = $plugin->plugin; |
| 568 | - | |
| 569 | 376 | if ( empty( $folder ) ) { |
| 570 | 377 | continue; |
| 571 | 378 | } |
| 572 | 379 | |
| @@ -574,10 +381,10 @@ | ||
| 574 | 381 | // don't show an update if the plugin isn't installed |
| 575 | 382 | continue; |
| 576 | 383 | } |
| 577 | 384 | |
| 578 | - $wp_plugin = $wp_plugins[ $folder ] ?? array(); | |
| 579 | - $wp_version = $wp_plugin['Version'] ?? '1.0'; | |
| 385 | + $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array(); | |
| 386 | + $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0'; | |
| 580 | 387 | $plugin->slug = explode( '/', $folder )[0]; |
| 581 | 388 | |
| 582 | 389 | if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) { |
| 583 | 390 | $transient->response[ $folder ] = $plugin; |
| @@ -597,9 +404,8 @@ | ||
| 597 | 404 | * Because this gets called on "pre_set_site_transient_update_plugins" an old version of FrmAppHelper may be loaded on plugin update. |
| 598 | 405 | * This means that trying to access FrmAppHelper::get_plugins when upgrading from a Lite version before v5.5 results in a one-off error. |
| 599 | 406 | * |
| 600 | 407 | * @since 5.5.2 |
| 601 | - * | |
| 602 | 408 | * @return array |
| 603 | 409 | */ |
| 604 | 410 | protected static function get_plugins() { |
| 605 | 411 | if ( ! function_exists( 'get_plugins' ) ) { |
| @@ -639,9 +445,8 @@ | ||
| 639 | 445 | continue; |
| 640 | 446 | } |
| 641 | 447 | |
| 642 | 448 | $new_license = $addon->license; |
| 643 | - | |
| 644 | 449 | if ( empty( $new_license ) || in_array( $new_license, $checked_licenses ) ) { |
| 645 | 450 | continue; |
| 646 | 451 | } |
| 647 | 452 | |
| @@ -647,9 +452,8 @@ | ||
| 647 | 452 | |
| 648 | 453 | $checked_licenses[] = $new_license; |
| 649 | 454 | |
| 650 | 455 | $api = new FrmFormApi( $new_license ); |
| 651 | - | |
| 652 | 456 | if ( empty( $version_info ) ) { |
| 653 | 457 | $version_info = $api->get_api_info(); |
| 654 | 458 | continue; |
| 655 | 459 | } |
| @@ -654,21 +458,18 @@ | ||
| 654 | 458 | continue; |
| 655 | 459 | } |
| 656 | 460 | |
| 657 | 461 | $plugin = $api->get_addon_for_license( $addon, $version_info ); |
| 658 | - | |
| 659 | 462 | if ( empty( $plugin ) ) { |
| 660 | 463 | continue; |
| 661 | 464 | } |
| 662 | 465 | |
| 663 | - $download_id = $plugin['id'] ?? 0; | |
| 664 | - | |
| 466 | + $download_id = isset( $plugin['id'] ) ? $plugin['id'] : 0; | |
| 665 | 467 | if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) { |
| 666 | 468 | // if this addon is using its own license, get the update url |
| 667 | 469 | $addon_info = $api->get_api_info(); |
| 668 | 470 | |
| 669 | 471 | $version_info[ $download_id ] = $addon_info[ $download_id ]; |
| 670 | - | |
| 671 | 472 | if ( isset( $addon_info['error'] ) ) { |
| 672 | 473 | $version_info[ $download_id ]['error'] = array( |
| 673 | 474 | 'message' => $addon_info['error']['message'], |
| 674 | 475 | 'code' => $addon_info['error']['code'], |
| @@ -683,11 +484,9 @@ | ||
| 683 | 484 | /** |
| 684 | 485 | * Get the action link for an addon that isn't active. |
| 685 | 486 | * |
| 686 | 487 | * @since 3.06.03 |
| 687 | - * | |
| 688 | 488 | * @param string $plugin The plugin slug. |
| 689 | - * | |
| 690 | 489 | * @return array |
| 691 | 490 | */ |
| 692 | 491 | public static function install_link( $plugin ) { |
| 693 | 492 | $link = array(); |
| @@ -724,20 +523,16 @@ | ||
| 724 | 523 | } |
| 725 | 524 | |
| 726 | 525 | /** |
| 727 | 526 | * @since 4.09 |
| 728 | - * | |
| 729 | 527 | * @param string $plugin The plugin slug. |
| 730 | - * | |
| 731 | 528 | * @return array|false |
| 732 | 529 | */ |
| 733 | 530 | public static function get_addon( $plugin ) { |
| 734 | 531 | $addons = self::get_api_addons(); |
| 735 | 532 | self::prepare_addons( $addons ); |
| 736 | - | |
| 737 | 533 | foreach ( $addons as $addon ) { |
| 738 | 534 | $slug = explode( '/', $addon['plugin'] ); |
| 739 | - | |
| 740 | 535 | if ( $slug[0] === 'formidable-' . $plugin ) { |
| 741 | 536 | return $addon; |
| 742 | 537 | } |
| 743 | 538 | } |
| @@ -745,15 +540,13 @@ | ||
| 745 | 540 | } |
| 746 | 541 | |
| 747 | 542 | /** |
| 748 | 543 | * @since 4.09 |
| 749 | - * | |
| 750 | 544 | * @return string |
| 751 | 545 | */ |
| 752 | 546 | protected static function get_license_type() { |
| 753 | 547 | $license_type = ''; |
| 754 | 548 | $addons = self::get_api_addons(); |
| 755 | - | |
| 756 | 549 | if ( isset( $addons['error'] ) && isset( $addons['error']['type'] ) ) { |
| 757 | 550 | $license_type = $addons['error']['type']; |
| 758 | 551 | } |
| 759 | 552 | return $license_type; |
| @@ -769,9 +562,8 @@ | ||
| 769 | 562 | */ |
| 770 | 563 | public static function get_addon_for_license( $addons, $license ) { |
| 771 | 564 | $download_id = $license->download_id; |
| 772 | 565 | $plugin = array(); |
| 773 | - | |
| 774 | 566 | if ( empty( $download_id ) && ! empty( $addons ) ) { |
| 775 | 567 | foreach ( $addons as $addon ) { |
| 776 | 568 | if ( strtolower( $license->plugin_name ) === strtolower( $addon['title'] ) ) { |
| 777 | 569 | return $addon; |
| @@ -784,21 +576,17 @@ | ||
| 784 | 576 | return $plugin; |
| 785 | 577 | } |
| 786 | 578 | |
| 787 | 579 | /** |
| 788 | - * @param array $addons | |
| 789 | - * | |
| 790 | 580 | * @return void |
| 791 | 581 | */ |
| 792 | 582 | protected static function prepare_addons( &$addons ) { |
| 793 | 583 | $activate_url = ''; |
| 794 | - | |
| 795 | 584 | if ( current_user_can( 'activate_plugins' ) ) { |
| 796 | 585 | $activate_url = add_query_arg( array( 'action' => 'activate' ), admin_url( 'plugins.php' ) ); |
| 797 | 586 | } |
| 798 | 587 | |
| 799 | 588 | $loop_addons = $addons; |
| 800 | - | |
| 801 | 589 | foreach ( $loop_addons as $id => $addon ) { |
| 802 | 590 | if ( is_numeric( $id ) ) { |
| 803 | 591 | $slug = str_replace( array( '-wordpress-plugin', '-wordpress' ), '', $addon['slug'] ); |
| 804 | 592 | $file_name = $addon['plugin']; |
| @@ -803,17 +591,14 @@ | ||
| 803 | 591 | $slug = str_replace( array( '-wordpress-plugin', '-wordpress' ), '', $addon['slug'] ); |
| 804 | 592 | $file_name = $addon['plugin']; |
| 805 | 593 | } else { |
| 806 | 594 | $slug = $id; |
| 807 | - | |
| 808 | 595 | if ( isset( $addon['file'] ) ) { |
| 809 | 596 | $base_file = $addon['file']; |
| 810 | 597 | } else { |
| 811 | 598 | $base_file = 'formidable-' . $slug; |
| 812 | 599 | } |
| 813 | - | |
| 814 | 600 | $file_name = $base_file . '/' . $base_file . '.php'; |
| 815 | - | |
| 816 | 601 | if ( ! isset( $addon['plugin'] ) ) { |
| 817 | 602 | $addon['plugin'] = $file_name; |
| 818 | 603 | } |
| 819 | 604 | } |
| @@ -818,12 +603,10 @@ | ||
| 818 | 603 | } |
| 819 | 604 | } |
| 820 | 605 | |
| 821 | 606 | $addon['installed'] = self::is_installed( $file_name ); |
| 822 | - | |
| 823 | 607 | if ( $addon['installed'] && 'formidable-views/formidable-views.php' === $file_name ) { |
| 824 | 608 | $active_views_version = self::get_active_views_version(); |
| 825 | - | |
| 826 | 609 | if ( false !== $active_views_version && $slug !== $active_views_version ) { |
| 827 | 610 | $addon['installed'] = false; |
| 828 | 611 | } |
| 829 | 612 | } |
| @@ -847,21 +630,16 @@ | ||
| 847 | 630 | |
| 848 | 631 | if ( ! isset( $addon['link'] ) ) { |
| 849 | 632 | $addon['link'] = 'downloads/' . $slug . '/'; |
| 850 | 633 | } |
| 634 | + self::prepare_addon_link( $addon['link'] ); | |
| 851 | 635 | |
| 852 | - self::prepare_addon_link( $addon['link'] ); | |
| 853 | 636 | self::set_addon_status( $addon ); |
| 854 | - self::set_categories( $addon ); | |
| 855 | - | |
| 856 | 637 | $addons[ $id ] = $addon; |
| 857 | 638 | }//end foreach |
| 858 | 639 | } |
| 859 | 640 | |
| 860 | 641 | /** |
| 861 | - * @param string $file_name | |
| 862 | - * @param string $slug | |
| 863 | - * | |
| 864 | 642 | * @return bool |
| 865 | 643 | */ |
| 866 | 644 | private static function is_plugin_active( $file_name, $slug ) { |
| 867 | 645 | if ( 'formidable-views/formidable-views.php' === $file_name ) { |
| @@ -876,9 +654,8 @@ | ||
| 876 | 654 | private static function get_active_views_version() { |
| 877 | 655 | if ( ! is_callable( 'FrmViewsAppHelper::plugin_version' ) ) { |
| 878 | 656 | return false; |
| 879 | 657 | } |
| 880 | - | |
| 881 | 658 | $plugin_version = FrmViewsAppHelper::plugin_version(); |
| 882 | 659 | return version_compare( $plugin_version, '5.0', '>=' ) ? 'visual-views' : 'views'; |
| 883 | 660 | } |
| 884 | 661 | |
| @@ -884,25 +661,22 @@ | ||
| 884 | 661 | |
| 885 | 662 | /** |
| 886 | 663 | * @since 3.04.02 |
| 887 | 664 | * |
| 888 | - * @param string $link | |
| 889 | - * | |
| 890 | 665 | * @return void |
| 891 | 666 | */ |
| 892 | 667 | protected static function prepare_addon_link( &$link ) { |
| 893 | 668 | $site_url = 'https://formidableforms.com/'; |
| 894 | - | |
| 895 | 669 | if ( strpos( $link, 'http' ) !== 0 ) { |
| 896 | 670 | $link = $site_url . $link; |
| 897 | 671 | } |
| 898 | - | |
| 899 | 672 | $link = FrmAppHelper::make_affiliate_url( $link ); |
| 900 | - | |
| 901 | - $utm = array( | |
| 902 | - 'campaign' => 'addons', | |
| 673 | + $query_args = array( | |
| 674 | + 'utm_source' => 'WordPress', | |
| 675 | + 'utm_medium' => 'addons', | |
| 676 | + 'utm_campaign' => 'liteplugin', | |
| 903 | 677 | ); |
| 904 | - $link = FrmAppHelper::maybe_add_missing_utm( $link, $utm ); | |
| 678 | + $link = add_query_arg( $query_args, $link ); | |
| 905 | 679 | } |
| 906 | 680 | |
| 907 | 681 | /** |
| 908 | 682 | * Add the status to the addon array. Status options are: |
| @@ -909,10 +683,8 @@ | ||
| 909 | 683 | * installed, active, not installed |
| 910 | 684 | * |
| 911 | 685 | * @since 3.04.02 |
| 912 | 686 | * |
| 913 | - * @param array $addon | |
| 914 | - * | |
| 915 | 687 | * @return void |
| 916 | 688 | */ |
| 917 | 689 | protected static function set_addon_status( &$addon ) { |
| 918 | 690 | if ( ! empty( $addon['activate_url'] ) ) { |
| @@ -933,8 +705,218 @@ | ||
| 933 | 705 | } |
| 934 | 706 | } |
| 935 | 707 | |
| 936 | 708 | /** |
| 709 | + * @return void | |
| 710 | + */ | |
| 711 | + public static function upgrade_to_pro() { | |
| 712 | + FrmAppHelper::include_svg(); | |
| 713 | + | |
| 714 | + $link_parts = array( | |
| 715 | + 'medium' => 'upgrade', | |
| 716 | + 'content' => 'button', | |
| 717 | + ); | |
| 718 | + | |
| 719 | + $features = array( | |
| 720 | + 'Display Entries' => array( | |
| 721 | + array( | |
| 722 | + 'label' => 'Display form data with virtually limitless views', | |
| 723 | + 'link' => array( | |
| 724 | + 'content' => 'views', | |
| 725 | + 'param' => 'views-display-form-data', | |
| 726 | + ), | |
| 727 | + 'lite' => false, | |
| 728 | + ), | |
| 729 | + array( | |
| 730 | + 'label' => 'Generate graphs and stats based on your submitted data', | |
| 731 | + 'link' => array( | |
| 732 | + 'content' => 'graphs', | |
| 733 | + 'param' => 'statistics-graphs-wordpress-forms', | |
| 734 | + ), | |
| 735 | + 'lite' => false, | |
| 736 | + ), | |
| 737 | + ), | |
| 738 | + 'Entry Management' => array( | |
| 739 | + array( | |
| 740 | + 'label' => 'Import entries from a CSV', | |
| 741 | + 'link' => array( | |
| 742 | + 'content' => 'import-entries', | |
| 743 | + 'param' => 'importing-exporting-wordpress-forms', | |
| 744 | + ), | |
| 745 | + 'lite' => false, | |
| 746 | + ), | |
| 747 | + array( | |
| 748 | + 'label' => 'Logged-in users can save drafts and return later', | |
| 749 | + 'link' => array( | |
| 750 | + 'content' => 'save-drafts', | |
| 751 | + 'param' => 'save-drafts-wordpress-form', | |
| 752 | + ), | |
| 753 | + 'lite' => false, | |
| 754 | + ), | |
| 755 | + array( | |
| 756 | + 'label' => 'Flexibly and powerfully view, edit, and delete entries from anywhere on your site', | |
| 757 | + 'link' => array( | |
| 758 | + 'content' => 'front-edit', | |
| 759 | + 'param' => 'wordpress-front-end-editing', | |
| 760 | + ), | |
| 761 | + 'lite' => false, | |
| 762 | + ), | |
| 763 | + array( | |
| 764 | + 'label' => 'View form submissions from the back-end', | |
| 765 | + 'lite' => true, | |
| 766 | + ), | |
| 767 | + array( | |
| 768 | + 'label' => 'Export your entries to a CSV', | |
| 769 | + 'lite' => true, | |
| 770 | + ), | |
| 771 | + ), | |
| 772 | + 'Form Building' => array( | |
| 773 | + array( | |
| 774 | + 'label' => 'Save a calculated value into a field', | |
| 775 | + 'link' => array( | |
| 776 | + 'content' => 'calculations', | |
| 777 | + 'param' => 'field-calculations-wordpress-form', | |
| 778 | + ), | |
| 779 | + 'lite' => false, | |
| 780 | + ), | |
| 781 | + array( | |
| 782 | + 'label' => 'Allow multiple file uploads', | |
| 783 | + 'link' => array( | |
| 784 | + 'content' => 'file-uploads', | |
| 785 | + 'param' => 'wordpress-multi-file-upload-fields', | |
| 786 | + ), | |
| 787 | + 'lite' => false, | |
| 788 | + ), | |
| 789 | + array( | |
| 790 | + 'label' => 'Repeat sections of fields', | |
| 791 | + 'link' => array( | |
| 792 | + 'content' => 'repeaters', | |
| 793 | + 'param' => 'repeatable-sections-forms', | |
| 794 | + ), | |
| 795 | + 'lite' => false, | |
| 796 | + ), | |
| 797 | + array( | |
| 798 | + 'label' => 'Hide and show fields conditionally based on other fields or the user\'s role', | |
| 799 | + 'link' => array( | |
| 800 | + 'content' => 'conditional-logic', | |
| 801 | + 'param' => 'conditional-logic-wordpress-forms', | |
| 802 | + ), | |
| 803 | + 'lite' => false, | |
| 804 | + ), | |
| 805 | + array( | |
| 806 | + 'label' => 'Confirmation fields', | |
| 807 | + 'link' => array( | |
| 808 | + 'content' => 'confirmation-fields', | |
| 809 | + 'param' => 'confirmation-fields-wordpress-forms', | |
| 810 | + ), | |
| 811 | + 'lite' => false, | |
| 812 | + ), | |
| 813 | + array( | |
| 814 | + 'label' => 'Multi-paged forms', | |
| 815 | + 'link' => array( | |
| 816 | + 'content' => 'page-breaks', | |
| 817 | + 'param' => 'wordpress-multi-page-forms', | |
| 818 | + ), | |
| 819 | + 'lite' => false, | |
| 820 | + ), | |
| 821 | + array( | |
| 822 | + 'label' => 'Include section headings, page breaks, rich text, dates, times, scales, star ratings, sliders, toggles, dynamic fields populated from other forms, passwords, and tags in advanced forms.', | |
| 823 | + 'lite' => false, | |
| 824 | + ), | |
| 825 | + array( | |
| 826 | + 'label' => 'Include text, email, url, paragraph text, radio, checkbox, dropdown fields, hidden fields, user ID fields, and HTML blocks in your form.', | |
| 827 | + 'lite' => true, | |
| 828 | + ), | |
| 829 | + array( | |
| 830 | + 'label' => 'Drag & Drop Form building', | |
| 831 | + 'link' => array( | |
| 832 | + 'content' => 'drag-drop', | |
| 833 | + 'param' => 'drag-drop-forms', | |
| 834 | + ), | |
| 835 | + 'lite' => true, | |
| 836 | + ), | |
| 837 | + array( | |
| 838 | + 'label' => 'Create forms from Templates', | |
| 839 | + 'link' => array( | |
| 840 | + 'content' => 'form-templates', | |
| 841 | + 'param' => 'wordpress-form-templates', | |
| 842 | + ), | |
| 843 | + 'lite' => true, | |
| 844 | + ), | |
| 845 | + array( | |
| 846 | + 'label' => 'Import and export forms with XML', | |
| 847 | + 'link' => array( | |
| 848 | + 'content' => 'import', | |
| 849 | + 'param' => 'importing-exporting-wordpress-forms', | |
| 850 | + ), | |
| 851 | + 'lite' => true, | |
| 852 | + ), | |
| 853 | + array( | |
| 854 | + 'label' => 'Use input placeholder text in your fields that clear when typing starts.', | |
| 855 | + 'lite' => true, | |
| 856 | + ), | |
| 857 | + ), | |
| 858 | + 'Form Actions' => array( | |
| 859 | + array( | |
| 860 | + 'label' => 'Conditionally send your email notifications based on values in your form', | |
| 861 | + 'link' => array( | |
| 862 | + 'content' => 'conditional-emails', | |
| 863 | + ), | |
| 864 | + 'lite' => false, | |
| 865 | + ), | |
| 866 | + array( | |
| 867 | + 'label' => 'Create and edit WordPress posts or custom posts from the front-end', | |
| 868 | + 'link' => array( | |
| 869 | + 'content' => 'create-posts', | |
| 870 | + 'param' => 'create-posts-pages-wordpress-forms', | |
| 871 | + ), | |
| 872 | + 'lite' => false, | |
| 873 | + ), | |
| 874 | + array( | |
| 875 | + 'label' => 'Send multiple emails and autoresponders', | |
| 876 | + 'link' => array( | |
| 877 | + 'content' => 'multiple-emails', | |
| 878 | + 'param' => 'virtually-unlimited-emails', | |
| 879 | + ), | |
| 880 | + 'lite' => true, | |
| 881 | + ), | |
| 882 | + ), | |
| 883 | + 'Form Appearance' => array( | |
| 884 | + array( | |
| 885 | + 'label' => 'Create Multiple styles for different forms', | |
| 886 | + 'link' => array( | |
| 887 | + 'content' => 'multiple-styles', | |
| 888 | + 'param' => 'wordpress-visual-form-styler', | |
| 889 | + ), | |
| 890 | + 'lite' => false, | |
| 891 | + ), | |
| 892 | + array( | |
| 893 | + 'label' => 'Customizable layout with CSS classes', | |
| 894 | + 'link' => array( | |
| 895 | + 'content' => 'form-layout', | |
| 896 | + 'param' => 'wordpress-mobile-friendly-forms', | |
| 897 | + ), | |
| 898 | + 'lite' => true, | |
| 899 | + ), | |
| 900 | + array( | |
| 901 | + 'label' => 'Customize the HTML for your forms', | |
| 902 | + 'link' => array( | |
| 903 | + 'content' => 'custom-html', | |
| 904 | + 'param' => 'customizable-html-wordpress-form', | |
| 905 | + ), | |
| 906 | + 'lite' => true, | |
| 907 | + ), | |
| 908 | + array( | |
| 909 | + 'label' => 'Style your form with the Visual Form Styler', | |
| 910 | + 'lite' => true, | |
| 911 | + ), | |
| 912 | + ), | |
| 913 | + ); | |
| 914 | + | |
| 915 | + include FrmAppHelper::plugin_path() . '/classes/views/addons/upgrade_to_pro.php'; | |
| 916 | + } | |
| 917 | + | |
| 918 | + /** | |
| 937 | 919 | * @since 5.5.2 |
| 938 | 920 | * |
| 939 | 921 | * @param string $plugin |
| 940 | 922 | * @param string $redirect |
| @@ -939,9 +921,8 @@ | ||
| 939 | 921 | * @param string $plugin |
| 940 | 922 | * @param string $redirect |
| 941 | 923 | * @param bool $network_wide |
| 942 | 924 | * @param bool $silent |
| 943 | - * | |
| 944 | 925 | * @return WP_Error|null Null on success, WP_Error on invalid file. |
| 945 | 926 | */ |
| 946 | 927 | protected static function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) { |
| 947 | 928 | if ( ! function_exists( 'activate_plugin' ) ) { |
| @@ -956,9 +937,8 @@ | ||
| 956 | 937 | * @since 6.8 |
| 957 | 938 | * |
| 958 | 939 | * @param string $plugin |
| 959 | 940 | * @param bool $silent |
| 960 | - * | |
| 961 | 941 | * @return void |
| 962 | 942 | */ |
| 963 | 943 | protected static function deactivate_plugin( $plugin, $silent = false ) { |
| 964 | 944 | if ( ! function_exists( 'deactivate_plugins' ) ) { |
| @@ -972,9 +952,8 @@ | ||
| 972 | 952 | * |
| 973 | 953 | * @since 6.8 |
| 974 | 954 | * |
| 975 | 955 | * @param string $plugin |
| 976 | - * | |
| 977 | 956 | * @return true|WP_Error True on success, WP_Error on invalid file. |
| 978 | 957 | */ |
| 979 | 958 | protected static function uninstall_plugin( $plugin ) { |
| 980 | 959 | if ( ! current_user_can( 'delete_plugins' ) ) { |
| @@ -1019,9 +998,8 @@ | ||
| 1019 | 998 | |
| 1020 | 999 | self::maybe_show_cred_form(); |
| 1021 | 1000 | |
| 1022 | 1001 | $installed = self::install_addon(); |
| 1023 | - | |
| 1024 | 1002 | if ( is_array( $installed ) && isset( $installed['message'] ) ) { |
| 1025 | 1003 | return $installed; |
| 1026 | 1004 | } |
| 1027 | 1005 | self::handle_addon_action( $installed, 'activate' ); |
| @@ -1036,9 +1014,9 @@ | ||
| 1036 | 1014 | if ( ! function_exists( 'request_filesystem_credentials' ) ) { |
| 1037 | 1015 | include_once ABSPATH . 'wp-admin/includes/file.php'; |
| 1038 | 1016 | } |
| 1039 | 1017 | |
| 1040 | - // Start output buffering to catch the filesystem form if credentials are needed. | |
| 1018 | + // Start output bufferring to catch the filesystem form if credentials are needed. | |
| 1041 | 1019 | ob_start(); |
| 1042 | 1020 | |
| 1043 | 1021 | $show_form = false; |
| 1044 | 1022 | $method = ''; |
| @@ -1085,10 +1063,8 @@ | ||
| 1085 | 1063 | * We do not need any extra credentials if we have gotten this far, |
| 1086 | 1064 | * so let's install the plugin. |
| 1087 | 1065 | * |
| 1088 | 1066 | * @since 3.04.02 |
| 1089 | - * | |
| 1090 | - * @return array|string | |
| 1091 | 1067 | */ |
| 1092 | 1068 | protected static function install_addon() { |
| 1093 | 1069 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 1094 | 1070 | |
| @@ -1108,9 +1084,8 @@ | ||
| 1108 | 1084 | // Flush the cache and return the newly installed plugin basename. |
| 1109 | 1085 | wp_cache_flush(); |
| 1110 | 1086 | |
| 1111 | 1087 | $plugin = $installer->plugin_info(); |
| 1112 | - | |
| 1113 | 1088 | if ( ! $plugin ) { |
| 1114 | 1089 | return array( |
| 1115 | 1090 | 'message' => 'Plugin was not installed. ' . $installer->result, |
| 1116 | 1091 | 'success' => false, |
| @@ -1180,9 +1155,8 @@ | ||
| 1180 | 1155 | * @since 6.8 |
| 1181 | 1156 | * |
| 1182 | 1157 | * @param callable $action_callback The specific add-on action to be executed. |
| 1183 | 1158 | * @param callable|null $response_callback Optional. The response handling callback. Default null. |
| 1184 | - * | |
| 1185 | 1159 | * @return void |
| 1186 | 1160 | */ |
| 1187 | 1161 | private static function process_addon_action( $action_callback, $response_callback = null ) { |
| 1188 | 1162 | self::install_addon_permissions(); |
| @@ -1205,9 +1179,8 @@ | ||
| 1205 | 1179 | * @since 6.8 |
| 1206 | 1180 | * |
| 1207 | 1181 | * @param string $installed The plugin folder name with file name. |
| 1208 | 1182 | * @param string $action The action type ('activate', 'deactivate', 'uninstall'). |
| 1209 | - * | |
| 1210 | 1183 | * @return array|void |
| 1211 | 1184 | */ |
| 1212 | 1185 | protected static function handle_addon_action( $installed, $action ) { |
| 1213 | 1186 | if ( ! $installed || ! $action ) { |
| @@ -1266,9 +1239,8 @@ | ||
| 1266 | 1239 | * @return string |
| 1267 | 1240 | */ |
| 1268 | 1241 | private static function get_activating_page() { |
| 1269 | 1242 | $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' ); |
| 1270 | - | |
| 1271 | 1243 | if ( false !== strpos( $referer, 'frm_action=settings' ) ) { |
| 1272 | 1244 | return 'settings'; |
| 1273 | 1245 | } |
| 1274 | 1246 | |
| @@ -1301,14 +1273,12 @@ | ||
| 1301 | 1273 | * @return string |
| 1302 | 1274 | */ |
| 1303 | 1275 | public static function connect_link() { |
| 1304 | 1276 | $auth = get_option( 'frm_connect_token' ); |
| 1305 | - | |
| 1306 | 1277 | if ( empty( $auth ) ) { |
| 1307 | 1278 | $auth = hash( 'sha512', wp_rand() ); |
| 1308 | 1279 | update_option( 'frm_connect_token', $auth, 'no' ); |
| 1309 | 1280 | } |
| 1310 | - | |
| 1311 | 1281 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title', 'formidable-settings' ); |
| 1312 | 1282 | $link = 'https://formidableforms.com/api-connect/'; |
| 1313 | 1283 | $args = array( |
| 1314 | 1284 | 'v' => 2, |
| @@ -1337,9 +1307,8 @@ | ||
| 1337 | 1307 | |
| 1338 | 1308 | // The download link is not required if already installed. |
| 1339 | 1309 | $is_installed = FrmAppHelper::pro_is_included(); |
| 1340 | 1310 | $file_missing = ! $is_installed && empty( $post_url ); |
| 1341 | - | |
| 1342 | 1311 | if ( ! $post_auth || $file_missing ) { |
| 1343 | 1312 | return false; |
| 1344 | 1313 | } |
| 1345 | 1314 | |
| @@ -1344,9 +1313,8 @@ | ||
| 1344 | 1313 | } |
| 1345 | 1314 | |
| 1346 | 1315 | // Verify auth. |
| 1347 | 1316 | $auth = get_option( 'frm_connect_token' ); |
| 1348 | - | |
| 1349 | 1317 | if ( empty( $auth ) || ! hash_equals( $auth, $post_auth ) ) { |
| 1350 | 1318 | return false; |
| 1351 | 1319 | } |
| 1352 | 1320 | |
| @@ -1362,17 +1330,17 @@ | ||
| 1362 | 1330 | */ |
| 1363 | 1331 | public static function install_addon_api() { |
| 1364 | 1332 | self::$plugin = FrmAppHelper::get_param( 'file_url', '', 'request', 'esc_url_raw' ); |
| 1365 | 1333 | |
| 1334 | + $error = esc_html__( 'Could not install an upgrade. Please download from formidableforms.com and install manually.', 'formidable' ); | |
| 1335 | + | |
| 1366 | 1336 | // Delete so cannot replay. |
| 1367 | 1337 | delete_option( 'frm_connect_token' ); |
| 1368 | 1338 | |
| 1369 | 1339 | // It's already installed and active. |
| 1370 | 1340 | $active = self::activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true ); |
| 1371 | - | |
| 1372 | 1341 | if ( is_wp_error( $active ) ) { |
| 1373 | 1342 | $response = self::maybe_download_and_activate(); |
| 1374 | - | |
| 1375 | 1343 | if ( is_array( $response ) ) { |
| 1376 | 1344 | // The download failed. |
| 1377 | 1345 | return $response; |
| 1378 | 1346 | } |
| @@ -1381,9 +1349,8 @@ | ||
| 1381 | 1349 | // If empty license, save it now. |
| 1382 | 1350 | if ( empty( self::get_pro_license() ) && function_exists( 'load_formidable_pro' ) ) { |
| 1383 | 1351 | load_formidable_pro(); |
| 1384 | 1352 | $license = stripslashes( FrmAppHelper::get_param( 'key', '', 'request', 'sanitize_text_field' ) ); |
| 1385 | - | |
| 1386 | 1353 | if ( ! $license ) { |
| 1387 | 1354 | return array( |
| 1388 | 1355 | 'success' => false, |
| 1389 | 1356 | 'error' => 'That site does not have a valid license key.', |
| @@ -1390,9 +1357,8 @@ | ||
| 1390 | 1357 | ); |
| 1391 | 1358 | } |
| 1392 | 1359 | |
| 1393 | 1360 | $response = FrmAddon::activate_license_for_plugin( $license, 'formidable_pro' ); |
| 1394 | - | |
| 1395 | 1361 | if ( ! $response['success'] ) { |
| 1396 | 1362 | // Could not activate license. |
| 1397 | 1363 | return $response; |
| 1398 | 1364 | } |
| @@ -1417,9 +1383,8 @@ | ||
| 1417 | 1383 | } |
| 1418 | 1384 | |
| 1419 | 1385 | // Download plugin now. |
| 1420 | 1386 | $response = self::download_and_activate(); |
| 1421 | - | |
| 1422 | 1387 | if ( is_array( $response ) && isset( $response['success'] ) ) { |
| 1423 | 1388 | // The download failed. |
| 1424 | 1389 | return $response; |
| 1425 | 1390 | } |
| @@ -1433,9 +1398,8 @@ | ||
| 1433 | 1398 | * @since 4.09 |
| 1434 | 1399 | * |
| 1435 | 1400 | * @param string $plugin |
| 1436 | 1401 | * @param array|string $upgrade_link_args |
| 1437 | - * | |
| 1438 | 1402 | * @return void |
| 1439 | 1403 | */ |
| 1440 | 1404 | public static function conditional_action_button( $plugin, $upgrade_link_args ) { |
| 1441 | 1405 | if ( is_callable( 'FrmProAddonsController::conditional_action_button' ) ) { |
| @@ -1470,9 +1434,8 @@ | ||
| 1470 | 1434 | * @type false|string $license_type |
| 1471 | 1435 | * @type string $plan_required |
| 1472 | 1436 | * @type string $upgrade_link |
| 1473 | 1437 | * } |
| 1474 | - * | |
| 1475 | 1438 | * @return void |
| 1476 | 1439 | */ |
| 1477 | 1440 | public static function show_conditional_action_button( $atts ) { |
| 1478 | 1441 | if ( is_callable( 'FrmProAddonsController::show_conditional_action_button' ) ) { |
| @@ -1490,12 +1453,11 @@ | ||
| 1490 | 1453 | * @param array|string $upgrade_link |
| 1491 | 1454 | * |
| 1492 | 1455 | * @return void |
| 1493 | 1456 | */ |
| 1494 | - public static function addon_upgrade_link( $addon, $upgrade_link ) { | |
| 1457 | + protected static function addon_upgrade_link( $addon, $upgrade_link ) { | |
| 1495 | 1458 | $atts = is_array( $upgrade_link ) ? $upgrade_link : array(); |
| 1496 | 1459 | $upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link; |
| 1497 | - $text = ! empty( $atts['text'] ) ? $atts['text'] : __( 'Upgrade Now', 'formidable' ); | |
| 1498 | 1460 | |
| 1499 | 1461 | if ( $addon ) { |
| 1500 | 1462 | $upgrade_link .= '&utm_content=' . $addon['slug']; |
| 1501 | 1463 | } |
| @@ -1505,15 +1467,14 @@ | ||
| 1505 | 1467 | $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] ); |
| 1506 | 1468 | } |
| 1507 | 1469 | |
| 1508 | 1470 | $class = ! empty( $atts['class'] ) ? $atts['class'] : ''; |
| 1509 | - | |
| 1510 | 1471 | if ( strpos( $class, 'frm-button' ) === false ) { |
| 1511 | 1472 | $class .= ' frm-button-secondary frm-button-sm'; |
| 1512 | 1473 | } |
| 1513 | 1474 | ?> |
| 1514 | 1475 | <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' ); ?>"> |
| 1515 | - <?php echo esc_html( $text ); ?> | |
| 1476 | + <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?> | |
| 1516 | 1477 | </a> |
| 1517 | 1478 | <?php |
| 1518 | 1479 | } |
| 1519 | 1480 | |
| @@ -1525,9 +1486,8 @@ | ||
| 1525 | 1486 | public static function ajax_install_addon() { |
| 1526 | 1487 | self::install_addon_permissions(); |
| 1527 | 1488 | |
| 1528 | 1489 | $result = self::download_and_activate(); |
| 1529 | - | |
| 1530 | 1490 | if ( isset( $result['success'] ) && ! $result['success'] ) { |
| 1531 | 1491 | echo json_encode( $result ); |
| 1532 | 1492 | wp_die(); |
| 1533 | 1493 | } |
| @@ -1572,10 +1532,8 @@ | ||
| 1572 | 1532 | * Gets required plan for an addon. |
| 1573 | 1533 | * |
| 1574 | 1534 | * @since 6.4.2 |
| 1575 | 1535 | * |
| 1576 | - * @param int|string $addon_id | |
| 1577 | - * | |
| 1578 | 1536 | * @return string Empty string if no plan is required for active license. |
| 1579 | 1537 | */ |
| 1580 | 1538 | public static function get_addon_required_plan( $addon_id ) { |
| 1581 | 1539 | $api = new FrmFormApi(); |
| @@ -1590,6 +1548,18 @@ | ||
| 1590 | 1548 | $requires = ''; |
| 1591 | 1549 | } |
| 1592 | 1550 | |
| 1593 | 1551 | return $requires; |
| 1552 | + } | |
| 1553 | + | |
| 1554 | + /** | |
| 1555 | + * @since 4.02.05 | |
| 1556 | + * @deprecated 6.8.3 | |
| 1557 | + * | |
| 1558 | + * @codeCoverageIgnore | |
| 1559 | + * | |
| 1560 | + * @return void | |
| 1561 | + */ | |
| 1562 | + public static function connect_pro() { | |
| 1563 | + _deprecated_function( __METHOD__, '6.8.3' ); | |
| 1594 | 1564 | } |
| 1595 | 1565 | } |