*/ public $settings_modal_toggles = []; /** @var array */ public $props = []; #[\Override] public function init(): void { $this->name = __( 'WebCalendar', 'agenticdaisy-calendar' ); $this->icon = ''; $this->settings_modal_toggles = [ 'general' => [ 'toggles' => [ 'main_content' => __( 'Calendar Settings', 'agenticdaisy-calendar' ), ], ], ]; } /** * @return array> */ #[\Override] public function get_fields(): array { return [ 'view' => [ 'label' => __( 'Default View', 'agenticdaisy-calendar' ), 'type' => 'select', 'default' => 'month', 'options' => [ 'month' => __( 'Month', 'agenticdaisy-calendar' ), 'week' => __( 'Week', 'agenticdaisy-calendar' ), 'day' => __( 'Day', 'agenticdaisy-calendar' ), 'list' => __( 'List', 'agenticdaisy-calendar' ), ], 'toggle_slug' => 'main_content', ], 'category' => [ 'label' => __( 'Category ID', 'agenticdaisy-calendar' ), 'type' => 'text', 'default' => '', 'description' => __( 'Filter to a specific category ID. Leave empty for all.', 'agenticdaisy-calendar' ), 'toggle_slug' => 'main_content', ], 'initial_month' => [ 'label' => __( 'Initial Month', 'agenticdaisy-calendar' ), 'type' => 'text', 'default' => '', 'description' => __( 'Start on a specific month (YYYY-MM). Leave empty for current month.', 'agenticdaisy-calendar' ), 'toggle_slug' => 'main_content', ], 'users' => [ 'label' => __( 'Users', 'agenticdaisy-calendar' ), 'type' => 'text', 'default' => '', 'description' => __( 'Comma-separated user logins to filter. Leave empty for all.', 'agenticdaisy-calendar' ), 'toggle_slug' => 'main_content', ], 'show_categories' => [ 'label' => __( 'Show Category Legend', 'agenticdaisy-calendar' ), 'type' => 'yes_no_button', 'default' => 'on', 'options' => [ 'on' => __( 'Yes', 'agenticdaisy-calendar' ), 'off' => __( 'No', 'agenticdaisy-calendar' ), ], 'toggle_slug' => 'main_content', ], 'show_filters' => [ 'label' => __( 'Show Filter Bar', 'agenticdaisy-calendar' ), 'type' => 'yes_no_button', 'default' => 'on', 'options' => [ 'on' => __( 'Yes', 'agenticdaisy-calendar' ), 'off' => __( 'No', 'agenticdaisy-calendar' ), ], 'toggle_slug' => 'main_content', ], ]; } /** * @param array|string $attrs * @param string|null $content * @param string $render_slug * @return string */ #[\Override] public function render( $attrs, $content, $render_slug ): string { $raw_view = $this->props['view'] ?? ''; $raw_category = $this->props['category'] ?? ''; $raw_month = $this->props['initial_month'] ?? ''; $raw_users = $this->props['users'] ?? ''; $view = is_string( $raw_view ) && $raw_view !== '' ? sanitize_text_field( $raw_view ) : 'month'; $category = is_string( $raw_category ) && $raw_category !== '' ? sanitize_text_field( $raw_category ) : ''; $initial_month = is_string( $raw_month ) && $raw_month !== '' ? sanitize_text_field( $raw_month ) : ''; $users = is_string( $raw_users ) && $raw_users !== '' ? sanitize_text_field( $raw_users ) : ''; $show_cats = ( $this->props['show_categories'] ?? 'on' ) === 'on' ? 'true' : 'false'; $show_filters = ( $this->props['show_filters'] ?? 'on' ) === 'on' ? 'true' : 'false'; return sprintf( '
', esc_attr( $view ), esc_attr( $category ), esc_attr( $initial_month ), esc_attr( $users ), esc_attr( $show_cats ), esc_attr( $show_filters ) ); } }