| @@ -296,6 +296,91 @@ | ||
| 296 | 296 | } |
| 297 | 297 | wpforo_update_option( 'wpforo_excluded_cache', trim( (string) $excluded, ',' ) ); |
| 298 | 298 | exit(); |
| 299 | 299 | } |
| 300 | - | |
| 300 | + | |
| 301 | + /** | |
| 302 | + * Addons Store Promo Box | |
| 303 | + * Shows a dismissible info box promoting the new Addons Store page | |
| 304 | + * where users can browse, purchase, and manage wpForo addons directly. | |
| 305 | + * | |
| 306 | + * @since 3.1.8 | |
| 307 | + */ | |
| 308 | + public function addonsStorePromo() { | |
| 309 | + if( ! current_user_can( 'manage_options' ) ) return; | |
| 310 | + | |
| 311 | + // Don't show on the addons page itself (they're already there) | |
| 312 | + if( function_exists( 'get_current_screen' ) ) { | |
| 313 | + $screen = get_current_screen(); | |
| 314 | + if( $screen && strpos( $screen->id, 'wpforo-addons' ) !== false ) return; | |
| 315 | + } | |
| 316 | + | |
| 317 | + // Check if user has already dismissed this promo version | |
| 318 | + $promo_version = '3.2.0'; | |
| 319 | + $dismissed = get_user_meta( get_current_user_id(), 'wpforo_addons_store_promo_dismissed', true ); | |
| 320 | + if( $dismissed === $promo_version ) return; | |
| 321 | + | |
| 322 | + $addons_url = admin_url( 'admin.php?page=wpforo-addons' ); | |
| 323 | + $addons = wpforo_get_addons_info(); | |
| 324 | + $addon_thumbs = array_slice( array_column( $addons, 'thumb' ), 0, 10 ); | |
| 325 | + ?> | |
| 326 | + <div class="notice notice-info wpforo-addons-store-promo is-dismissible" style="padding: 15px 12px; border-left-color: #00a0d2;"> | |
| 327 | + <div style="display: flex; align-items: flex-start; gap: 15px;"> | |
| 328 | + <div style="flex-shrink: 0;"> | |
| 329 | + <span class="dashicons dashicons-store" style="font-size: 50px; width: 50px; height: 50px; color: #00a0d2;"></span> | |
| 330 | + </div> | |
| 331 | + <div style="flex: 1;"> | |
| 332 | + <p style="font-size: 16px; font-weight: 600; margin: 0 0 6px 0; color: #1d2327;"> | |
| 333 | + <?php | |
| 334 | + printf( | |
| 335 | + __( 'Get Your wpForo Addon Licenses %s', 'wpforo' ), | |
| 336 | + '<span style="background: linear-gradient(90deg, #1d2327, #ff6d00); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;">' . __( 'Directly in Your Dashboard', 'wpforo' ) . '</span>' | |
| 337 | + ); | |
| 338 | + ?> | |
| 339 | + </p> | |
| 340 | + <p style="font-size: 15px; margin: 0 0 12px 0; color: #50575e;"> | |
| 341 | + <?php _e( 'You can now purchase, install, and manage all wpForo addons directly from the Addons page in your WordPress dashboard, no need to visit the gVectors Store. Activate licenses, get automatic updates, and extend your forum with just a few clicks.', 'wpforo' ); ?> | |
| 342 | + </p> | |
| 343 | + <div style="display: flex; align-items: center; gap: 6px; flex-wrap: wrap;"> | |
| 344 | + <?php foreach( $addon_thumbs as $thumb ) : ?> | |
| 345 | + <img src="<?php echo esc_url( $thumb ); ?>" alt="" style="width: 30px; height: 30px; border-radius: 3px; object-fit: cover;" /> | |
| 346 | + <?php endforeach; ?> | |
| 347 | + <a href="<?php echo esc_url( $addons_url ); ?>" class="button" style="height: 30px; line-height: 28px; padding: 0 22px; font-size: 13px; min-height: 30px; border-color: #0283aa; color: #0283aa;"> | |
| 348 | + <?php _e( 'Browse All', 'wpforo' ); ?> → | |
| 349 | + </a> | |
| 350 | + </div> | |
| 351 | + </div> | |
| 352 | + </div> | |
| 353 | + </div> | |
| 354 | + <script> | |
| 355 | + jQuery(document).on('click', '.wpforo-addons-store-promo .notice-dismiss', function() { | |
| 356 | + jQuery.ajax({ | |
| 357 | + url: ajaxurl, | |
| 358 | + data: { | |
| 359 | + action: 'wpforo_dismiss_addons_store_promo', | |
| 360 | + _wpnonce: '<?php echo wp_create_nonce( 'wpforo_dismiss_addons_store_promo' ); ?>' | |
| 361 | + } | |
| 362 | + }); | |
| 363 | + }); | |
| 364 | + </script> | |
| 365 | + <?php | |
| 366 | + } | |
| 367 | + | |
| 368 | + /** | |
| 369 | + * AJAX handler: dismiss the addons store promo for the current user. | |
| 370 | + * | |
| 371 | + * @since 3.1.8 | |
| 372 | + */ | |
| 373 | + public function dismissAddonsStorePromo() { | |
| 374 | + check_ajax_referer( 'wpforo_dismiss_addons_store_promo', '_wpnonce' ); | |
| 375 | + | |
| 376 | + if( ! current_user_can( 'manage_options' ) ) { | |
| 377 | + wp_send_json_error( 'Unauthorized', 403 ); | |
| 378 | + } | |
| 379 | + | |
| 380 | + $promo_version = '3.2.0'; | |
| 381 | + update_user_meta( get_current_user_id(), 'wpforo_addons_store_promo_dismissed', $promo_version ); | |
| 382 | + | |
| 383 | + wp_send_json_success(); | |
| 384 | + } | |
| 385 | + | |
| 301 | 386 | } |