$saved === false ? ['pcwp_details', 'pcwp_rsvp_settings', 'pcwp_cost_settings', 'pcwp_links_settings'] : $saved); add_filter('get_user_option_closedpostboxes_pcwp_series', static fn (mixed $saved): mixed => $saved === false ? ['pcwp_details', 'pcwp_rsvp_settings', 'pcwp_cost_settings', 'pcwp_links_settings'] : $saved); } public function addSeries(): void { if (get_current_screen()?->is_block_editor()) { return; } foreach (['details' => __('Event details', 'proeventswp'), 'rsvp' => __('RSVP', 'proeventswp'), 'cost' => __('Cost', 'proeventswp'), 'links' => __('Links & map', 'proeventswp')] as $method => $title) { add_meta_box($method === 'details' ? 'pcwp_details' : 'pcwp_' . $method . '_settings', $title, [$this, $method], 'pcwp_series', 'normal', 'default'); } add_meta_box('pcwp_schedule', __('Schedule', 'proeventswp'), static function (): void { echo '
'; }, 'pcwp_series', 'normal', 'high'); add_meta_box('pcwp_series_entities', __('Venues and organizers', 'proeventswp'), static function (): void { echo ''; }, 'pcwp_series', 'side', 'default'); } public function add(): void { $screen = get_current_screen(); if ($screen === null || ! $screen->is_block_editor()) { add_meta_box('pcwp_schedule', __('Event schedule', 'proeventswp'), [$this, 'schedule'], 'pcwp_event', 'normal', 'high'); add_meta_box('pcwp_details', __('Event details', 'proeventswp'), [$this, 'details'], 'pcwp_event', 'normal', 'default'); add_meta_box('pcwp_rsvp_settings', __('RSVP', 'proeventswp'), [$this, 'rsvp'], 'pcwp_event', 'normal', 'default'); add_meta_box('pcwp_cost_settings', __('Cost', 'proeventswp'), [$this, 'cost'], 'pcwp_event', 'normal', 'default'); add_meta_box('pcwp_links_settings', __('Links & map', 'proeventswp'), [$this, 'links'], 'pcwp_event', 'normal', 'default'); } add_meta_box('pcwp_entities', __('Venues and organizers', 'proeventswp'), [$this, 'entities'], 'pcwp_event', 'side', 'default'); } public function editorAssets(): void { $screen = get_current_screen(); if (! in_array($screen?->post_type, ['pcwp_event', 'pcwp_series'], true)) { return; } $this->scheduleAssets(); wp_enqueue_script( 'pcwp-event-editor', PCWP_URL . 'assets/event-editor.js', ['pcwp-schedule-editor', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins'], (string) filemtime(PCWP_PATH . 'assets/event-editor.js'), true, ); } public function scheduleAssets(): void { if (! in_array(get_current_screen()?->post_type, ['pcwp_event', 'pcwp_series'], true)) { return; } wp_enqueue_script('pcwp-schedule-editor', PCWP_URL . 'assets/schedule-editor.js', ['wp-components', 'wp-element', 'wp-i18n', 'wp-dom-ready'], (string) filemtime(PCWP_PATH . 'assets/schedule-editor.js'), true); global $post; wp_localize_script('pcwp-schedule-editor', 'pcwpScheduleData', [ 'timezone' => wp_timezone_string(), 'timezones' => timezone_identifiers_list(), 'isNew' => $post instanceof \WP_Post && $post->post_status === 'auto-draft', ]); wp_enqueue_style('wp-components'); wp_enqueue_style('pcwp-schedule-editor', PCWP_URL . 'assets/schedule-editor.css', [], (string) filemtime(PCWP_PATH . 'assets/schedule-editor.css')); wp_enqueue_script('pcwp-classic-details', PCWP_URL . 'assets/classic-details.js', ['wp-dom-ready'], (string) filemtime(PCWP_PATH . 'assets/classic-details.js'), true); } public function schedule(\WP_Post $post): void { wp_nonce_field('pcwp_save_event', 'pcwp_event_nonce'); $timezone = (string) get_post_meta($post->ID, '_pcwp_timezone', true) ?: wp_timezone_string(); $schedule = get_post_meta($post->ID, '_pcwp_schedule', true) ?: ['type' => 'continuous']; $meta = ['_pcwp_schedule' => $schedule, '_pcwp_timezone' => (string) get_post_meta($post->ID, '_pcwp_timezone', true), '_pcwp_start' => get_post_meta($post->ID, '_pcwp_start', true), '_pcwp_end' => get_post_meta($post->ID, '_pcwp_end', true), '_pcwp_all_day' => (bool) get_post_meta($post->ID, '_pcwp_all_day', true)]; echo ''; echo ''; ?>
' . esc_html__('Set the event start and end before publishing.', 'proeventswp') . '