From 7783cbe6e1631e2ec5572ba2c40e166e6ec08d41 Mon Sep 17 00:00:00 2001 From: Roshani Date: Mon, 30 Sep 2024 15:22:34 +0530 Subject: [PATCH] #1516 Enhacement : default content tab in settings --- admin/wp-event-manager-settings.php | 25 ++++++++---- admin/wp-event-manager-writepanels.php | 43 +++++++++++++++----- forms/wp-event-manager-form-submit-event.php | 17 ++++++-- templates/form-fields/multiselect-field.php | 12 ++++-- templates/form-fields/text-field.php | 15 ++++++- 5 files changed, 84 insertions(+), 28 deletions(-) diff --git a/admin/wp-event-manager-settings.php b/admin/wp-event-manager-settings.php index 7f78d803..fa5e55b0 100755 --- a/admin/wp-event-manager-settings.php +++ b/admin/wp-event-manager-settings.php @@ -480,34 +480,41 @@ protected function init_settings() { array( 'name' => 'event_manager_timezone_setting', 'std' => 'site_timezone', - 'label' => __('Event Timezone', 'wp-event-manager'), - 'desc' => __('In case while submitting an event, if the timezone for each event is not selected, the WP Event Manager will take the default WordPress (website) timezone.', 'wp-event-manager'), + 'label' => __( 'Event Timezone', 'wp-event-manager' ), + 'desc' => __( 'In case while submitting an event, if the timezone for each event is not selected, the WP Event Manager will take the default WordPress (website) timezone.', 'wp-event-manager' ), 'type' => 'radio', 'options' => array( - 'site_timezone' => __('Use website timezone.', 'wp-event-manager'), - 'each_event' => __('Select a timezone on each event.', 'wp-event-manager'), + 'site_timezone' => __( 'Use website timezone.', 'wp-event-manager' ), + 'each_event' => __( 'Select a timezone on each event.', 'wp-event-manager' ), ), ), ), ), 'event_default_content' => array( - __('Default Content', 'wp-event-manager'), + __( 'Default Content', 'wp-event-manager' ), array( array( 'name' => 'default_organizer', 'std' => 'no_default', - 'label' => __('Default Organizer', 'wp-event-manager'), + 'label' => __( 'Default Organizer', 'wp-event-manager' ), 'type' => 'select', 'options' => $organizer_options, - 'desc' => __('The current default organizer is: No default set', 'wp-event-manager'), + 'desc' => __( 'You can choose default organizer from here.', 'wp-event-manager' ), ), array( 'name' => 'default_venue', 'std' => 'no_default', - 'label' => __('Default Venue', 'wp-event-manager'), + 'label' => __( 'Default Venue', 'wp-event-manager' ), 'type' => 'select', 'options' => $venue_options, - 'desc' => __('The current default venue is: No default set', 'wp-event-manager'), + 'desc' => __( 'You can choose default venue from here.', 'wp-event-manager' ), + ), + array( + 'name' => 'default_address', + 'std' => '', + 'label' => __( 'Default Address', 'wp-event-manager' ), + 'type' => 'text', + 'desc' => __( 'You can set the default address from here.', 'wp-event-manager' ), ), ), ), diff --git a/admin/wp-event-manager-writepanels.php b/admin/wp-event-manager-writepanels.php index 0c9da336..8f1994fb 100755 --- a/admin/wp-event-manager-writepanels.php +++ b/admin/wp-event-manager-writepanels.php @@ -407,28 +407,41 @@ public static function input_file($key, $field) { * @param mixed $key * @param mixed $field */ - public static function input_text($key, $field) { + public static function input_text($key, $field) { global $post_id; - if(!isset($field['value']) || empty($field['value'])) { - $field['value'] = esc_attr(get_post_meta($post_id, stripslashes($key), true)); + + // Get the default address from options + $default_address = get_option('default_address'); + + // Set the field value: prioritize post meta value, then default address, then empty + if (!isset($field['value']) || empty($field['value'])) { + $field['value'] = esc_attr(get_post_meta($post_id, stripslashes($key), true)) ?: esc_attr($default_address); } - if(!empty($field['name'])) { + + // Determine the name for the input field + if (!empty($field['name'])) { $name = $field['name']; } else { $name = $key; - } ?> - + } + ?> +

-

- " > diff --git a/forms/wp-event-manager-form-submit-event.php b/forms/wp-event-manager-form-submit-event.php index 2886ba6d..b474f036 100755 --- a/forms/wp-event-manager-form-submit-event.php +++ b/forms/wp-event-manager-form-submit-event.php @@ -149,7 +149,17 @@ public function get_default_event_fields( ) { $organizer_description = is_admin() ? __('
If it doesn\'t show organizer(s). Manage your organizer(s) from here
','wp-event-manager') : __('
If it doesn\'t show organizer(s). Manage your organizer(s) from here
','wp-event-manager'); $venue_description = is_admin() ? __('
If it doesn\'t show venue(s). Manage your venue(s) from here
','wp-event-manager') : __('
If it doesn\'t show venue(s). Manage your venue(s) from here
','wp-event-manager'); - + + // Get default organizer + $default_organizer = get_option('default_organizer'); + $default_organizer = is_array($default_organizer) ? $default_organizer : array($default_organizer); + + // Get default venue + $default_venue = get_option('default_venue'); + + // Get default address + $default_address = get_option('default_address'); + return apply_filters( 'submit_event_form_fields', array( 'event' => array( 'event_title' => array( @@ -208,6 +218,7 @@ public function get_default_event_fields( ) { 'event_location' => array( 'label' => __( 'Event Location', 'wp-event-manager' ), 'type' => 'text', + 'default' => $default_address, 'required' => true, 'placeholder' => __( 'Location for google map', 'wp-event-manager' ), 'priority' => 6, @@ -351,7 +362,7 @@ public function get_default_event_fields( ) { 'event_organizer_ids' => array( 'label' => __( 'Organizer', 'wp-event-manager' ), 'type' => 'multiselect', - 'default' => '', + 'default' => $default_organizer, 'options' =>apply_filters('wpem_set_organizer_ids', ($current_user_id) ? get_all_organizer_array($current_user_id) : []), 'description' => $organizer_description, 'priority' => 20, @@ -364,7 +375,7 @@ public function get_default_event_fields( ) { 'event_venue_ids' => array( 'label' => __( 'Venues', 'wp-event-manager' ), 'type' => 'select', - 'default' => '', + 'default' => $default_venue, 'options' => apply_filters('wpem_set_venue_ids', ($current_user_id) ? get_all_venue_array($current_user_id, '', true) : ['' => __( 'Select Venue', 'wp-event-manager')]), 'description' => $venue_description, 'priority' => 21, diff --git a/templates/form-fields/multiselect-field.php b/templates/form-fields/multiselect-field.php index fd528789..36895cb6 100755 --- a/templates/form-fields/multiselect-field.php +++ b/templates/form-fields/multiselect-field.php @@ -5,9 +5,15 @@ wp_enqueue_style( 'chosen', EVENT_MANAGER_PLUGIN_URL . '/assets/css/chosen.css' ); ?> diff --git a/templates/form-fields/text-field.php b/templates/form-fields/text-field.php index 7848b6c9..e2e9f7a3 100755 --- a/templates/form-fields/text-field.php +++ b/templates/form-fields/text-field.php @@ -11,9 +11,20 @@ * @version 1.8 */ ?> - /> + + +/> + - \ No newline at end of file +