| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.13 Free | |
| 4 | + * @version 2.1.4 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2024 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FireBox\Core\Controllers; |
| @@ -15,89 +15,18 @@ | ||
| 15 | 15 | { |
| 16 | 16 | exit; // Exit if accessed directly. |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | +use \FireBox\Core\Helpers\Form\Form; | |
| 20 | + | |
| 19 | 21 | class Campaigns extends BaseController |
| 20 | 22 | { |
| 21 | 23 | /** |
| 22 | - * The minimum WordPress version required to render the DataViews Campaigns page. | |
| 23 | - * Below this, the classic WP_List_Table fallback (CampaignsList) is used instead. | |
| 24 | - * See docs/plans/campaigns-dataviews-migration.md §3.1. | |
| 25 | - * | |
| 26 | - * Pinned to 7.0: @wordpress/dataviews depends on @wordpress/ui, whose ThemeProvider | |
| 27 | - * opts into WordPress's private/unstable APIs identifying itself as "@wordpress/theme". | |
| 28 | - * That module name is only on WordPress core's allow-list for private-API consumers | |
| 29 | - * starting WP 7.0 (it's also only WP 7.0+ that registers a `wp-theme` script handle | |
| 30 | - * at all) - on earlier WP the call throws at runtime and the whole bundle fails to | |
| 31 | - * mount, leaving the page stuck on the server-rendered loading skeleton. | |
| 32 | - */ | |
| 33 | - const DATAVIEWS_MIN_WP_VERSION = '7.0'; | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * Render Campaigns page. | |
| 37 | - * | |
| 24 | + * Render Submissions page. | |
| 25 | + * | |
| 38 | 26 | * @return void |
| 39 | 27 | */ |
| 40 | 28 | public function render() |
| 41 | 29 | { |
| 42 | 30 | firebox()->renderer->admin->render('pages/campaigns'); |
| 43 | - } | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * Enqueues the DataViews React app on WP >= self::DATAVIEWS_MIN_WP_VERSION. | |
| 47 | - * On older WP, the classic list table (CampaignsList) is used and needs no extra assets. | |
| 48 | - * | |
| 49 | - * @return void | |
| 50 | - */ | |
| 51 | - public function addMedia() | |
| 52 | - { | |
| 53 | - if (!self::useDataViews()) | |
| 54 | - { | |
| 55 | - return; | |
| 56 | - } | |
| 57 | - | |
| 58 | - // Build artifact, committed and shipped in every tier - always present. | |
| 59 | - $asset = include FBOX_PLUGIN_DIR . 'media/admin/js/blocks/campaigns-dataviews.asset.php'; | |
| 60 | - | |
| 61 | - wp_register_script( | |
| 62 | - 'firebox-campaigns-dataviews', | |
| 63 | - FBOX_MEDIA_ADMIN_URL . 'js/blocks/campaigns-dataviews.js', | |
| 64 | - $asset['dependencies'], | |
| 65 | - $asset['version'], | |
| 66 | - true | |
| 67 | - ); | |
| 68 | - | |
| 69 | - wp_localize_script('firebox-campaigns-dataviews', 'fboxCampaignsData', [ | |
| 70 | - 'capabilities' => [ | |
| 71 | - 'edit' => current_user_can('edit_fireboxes'), | |
| 72 | - 'delete' => current_user_can('delete_fireboxes'), | |
| 73 | - ], | |
| 74 | - 'urls' => [ | |
| 75 | - 'newCampaign' => admin_url('post-new.php?post_type=firebox'), | |
| 76 | - 'import' => admin_url('admin.php?page=firebox-import'), | |
| 77 | - ], | |
| 78 | - ]); | |
| 79 | - | |
| 80 | - wp_set_script_translations('firebox-campaigns-dataviews', 'firebox', FBOX_PLUGIN_DIR . 'languages'); | |
| 81 | - | |
| 82 | - wp_enqueue_script('firebox-campaigns-dataviews'); | |
| 83 | - | |
| 84 | - // The bundle emits one stylesheet: the @wordpress/dataviews styles followed | |
| 85 | - // by our own overrides (see the import order in campaigns/index.js). | |
| 86 | - wp_enqueue_style( | |
| 87 | - 'firebox-campaigns-dataviews', | |
| 88 | - FBOX_MEDIA_ADMIN_URL . 'js/blocks/style-campaigns-dataviews.css', | |
| 89 | - ['wp-components'], | |
| 90 | - $asset['version'] | |
| 91 | - ); | |
| 92 | - } | |
| 93 | - | |
| 94 | - /** | |
| 95 | - * Whether the current WordPress version can render the DataViews Campaigns page. | |
| 96 | - * | |
| 97 | - * @return bool | |
| 98 | - */ | |
| 99 | - public static function useDataViews() | |
| 100 | - { | |
| 101 | - return version_compare(get_bloginfo('version'), self::DATAVIEWS_MIN_WP_VERSION, '>='); | |
| 102 | 31 | } |
| 103 | 32 | } |