self::PT, 'request_key' => 'daytidy', 'nonce_name' => self::NONCE, ]); } public function init(): void { parent::init(); (new Builder($this))->init(); (new ShortcodeMetabox($this))->init(); } public function args(): array { return apply_filters('DayTidy/F__DayTidy/Posts/View__args/args', [ 'labels' => $this->labels( esc_html__('View', 'daytidy'), esc_html__('Views', 'daytidy') ), 'public' => false, 'show_ui' => true, 'show_in_menu' => false, 'show_in_rest' => false, 'show_in_admin_bar' => false, 'has_archive' => false, 'exclude_from_search' => true, 'publicly_queryable' => false, 'supports' => ['title'], 'menu_icon' => 'dashicons-screenoptions', 'menu_position' => 27, 'capabilities' => Capabilities::postTypeCapabilities(Capabilities::MANAGE_OFFERINGS), 'map_meta_cap' => false, ]); } public function columns(array $columns): array { unset($columns['date']); $columns['shortcode'] = esc_html__('Shortcode', 'daytidy'); $columns['view'] = esc_html__('View', 'daytidy'); $columns['style'] = esc_html__('Style', 'daytidy'); $columns['status'] = esc_html__('Status', 'daytidy'); $columns['date'] = esc_html__('Date', 'daytidy'); return $columns; } public function content(string $column_name, int $post_id): void { $config = Config::get($post_id); // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- The generated shortcode control is passed through DayTidy Kses below. if ($column_name === 'shortcode') { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- DayTidy Kses sanitizes the generated control markup. echo Kses::form(Form::copyableCode([ 'value' => '[daytidy id="' . $post_id . '"]', ])); } // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped else if ($column_name === 'view') { echo esc_html(ucwords(str_replace('_', ' ', (string) $config['type']))); } else if ($column_name === 'style') { echo esc_html(ucwords(str_replace('_', ' ', (string) $config['style']))); } else if ($column_name === 'status') { $status = get_post_status($post_id); $object = $status ? get_post_status_object($status) : null; echo esc_html((string) ($object ? $object->label : $status)); } } public function store(Post $entity, array $data): void { $config = Config::normalize($data['view'] ?? []); update_post_meta($entity->id(), Config::META, $config); update_post_meta($entity->id(), Config::META_TYPE, $config['type']); update_post_meta($entity->id(), Config::META_STYLE, $config['style']); } public function entity(int $id): ViewEntity { return new ViewEntity($id); } }