mirror of
				https://github.com/dwaxweiler/connector-mobilizon
				synced 2025-06-05 21:59:25 +02:00 
			
		
		
		
	remove unneeded option
This commit is contained in:
		| @@ -9,6 +9,7 @@ | ||||
| - Use date and time formats from general site settings  | ||||
| #### Deprecated | ||||
| #### Removed | ||||
| - Removed option "Display named offset" | ||||
| #### Fixed | ||||
| - Show group not found error message in block | ||||
| #### Security | ||||
|   | ||||
| @@ -74,11 +74,11 @@ final class Mobilizon_Connector { | ||||
|  | ||||
|   public function enable_activation() { | ||||
|     MobilizonConnector\Settings::setDefaultOptions(); | ||||
|     MobilizonConnector\Settings::removeObsoleteOptionsIfNeeded(); | ||||
|   } | ||||
|  | ||||
|   private function load_settings_globally_before_script($scriptName) { | ||||
|     $settings = array( | ||||
|       'isShortOffsetNameShown' => MobilizonConnector\Settings::isShortOffsetNameShown(), | ||||
|       'locale' => str_replace('_', '-', get_locale()), | ||||
|       'timeZone' => wp_timezone_string(), | ||||
|       'url' => MobilizonConnector\Settings::getUrl() | ||||
|   | ||||
| @@ -10,7 +10,7 @@ export function displayEvents({ events, document, container, maxEventsCount }) { | ||||
|   hideLoadingIndicator(container) | ||||
|  | ||||
|   const isShortOffsetNameShown = | ||||
|     window.MOBILIZON_CONNECTOR.isShortOffsetNameShown | ||||
|     window.MOBILIZON_CONNECTOR.isShortOffsetNameShown || false // TODO remove | ||||
|   const locale = window.MOBILIZON_CONNECTOR.locale | ||||
|   const timeZone = window.MOBILIZON_CONNECTOR.timeZone | ||||
|  | ||||
|   | ||||
| @@ -8,6 +8,7 @@ export default class Formatter { | ||||
|   } | ||||
|  | ||||
|   static formatDate({ locale, timeZone, start, end, isShortOffsetNameShown }) { | ||||
|     // TODO also use WP general site settings | ||||
|     const startDateTime = new DateTimeWrapper({ | ||||
|       locale, | ||||
|       text: start, | ||||
|   | ||||
| @@ -4,3 +4,4 @@ namespace MobilizonConnector; | ||||
| const DEFAULT_EVENTS_COUNT = 5; | ||||
| const NAME = '<wordpress-name>'; | ||||
| const NICE_NAME = '<wordpress-nice-name>'; | ||||
| const PLUGIN_VERSION = '<wordpress-version>'; | ||||
|   | ||||
| @@ -4,12 +4,11 @@ namespace MobilizonConnector; | ||||
| class Settings { | ||||
|  | ||||
|   private static $DEFAULT_OPTION_URL = 'https://mobilizon.fr'; | ||||
|   private static $DEFAULT_IS_SHORT_OFFSET_NAME_SHOWN = false; | ||||
|   private static $PAGE_NAME = 'wordpress_mobilizon'; | ||||
|   private static $OPTIONS_GROUP_NAME = 'wordpress_mobilizon'; | ||||
|   private static $OPTION_NAME_IS_SHORT_OFFSET_NAME_SHOWN = 'wordpress_mobilizon_is_short_offset_name_shown'; | ||||
|   private static $OPTION_NAME_PLUGIN_VERSION = 'wordpress_mobilizon_plugin_version'; | ||||
|   private static $OPTION_NAME_URL = 'wordpress_mobilizon_url'; | ||||
|   private static $SETTING_FIELD_NAME_IS_SHORT_OFFSET_NAME_SHOWN = 'wordpress_mobilizon_field_is_short_offset_name_shown'; | ||||
|   private static $SETTING_FIELD_NAME_URL = 'wordpress_mobilizon_field_url'; | ||||
|   private static $SETTINGS_SECTION_NAME = 'wordpress_mobilizon_section_general'; | ||||
|  | ||||
| @@ -19,10 +18,6 @@ class Settings { | ||||
|   } | ||||
|  | ||||
|   public static function init_settings() { | ||||
|     register_setting( | ||||
|       self::$OPTIONS_GROUP_NAME, | ||||
|       self::$OPTION_NAME_IS_SHORT_OFFSET_NAME_SHOWN | ||||
|     ); | ||||
|     register_setting( | ||||
|       self::$OPTIONS_GROUP_NAME, | ||||
|       self::$OPTION_NAME_URL, | ||||
| @@ -46,21 +41,6 @@ class Settings { | ||||
|         'label_for' => self::$SETTING_FIELD_NAME_URL | ||||
|       ) | ||||
|     ); | ||||
|     add_settings_field( // TODO remove | ||||
|       self::$SETTING_FIELD_NAME_IS_SHORT_OFFSET_NAME_SHOWN, | ||||
|       esc_html__('Display named offset', 'connector-mobilizon'), | ||||
|       'MobilizonConnector\Settings::output_field_is_short_offset_name_shown', | ||||
|       self::$PAGE_NAME, | ||||
|       self::$SETTINGS_SECTION_NAME, | ||||
|       array( | ||||
|         'label_for' => self::$SETTING_FIELD_NAME_IS_SHORT_OFFSET_NAME_SHOWN | ||||
|       ) | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   public static function output_field_is_short_offset_name_shown($args) { | ||||
|     $isShortOffsetNameShown = self::isShortOffsetNameShown(); | ||||
|     require dirname(__DIR__) . '/view/settings/is-short-offset-name-shown-field.php'; | ||||
|   } | ||||
|  | ||||
|   public static function output_field_url($args) { | ||||
| @@ -101,22 +81,26 @@ class Settings { | ||||
|     require dirname(__DIR__) . '/view/settings/page.php'; | ||||
|   } | ||||
|  | ||||
|   public static function isShortOffsetNameShown() { | ||||
|     return get_option(self::$OPTION_NAME_IS_SHORT_OFFSET_NAME_SHOWN); | ||||
|   } | ||||
|  | ||||
|   public static function getUrl() { | ||||
|     return get_option(self::$OPTION_NAME_URL); | ||||
|   } | ||||
|  | ||||
|   public static function setDefaultOptions() { | ||||
|     add_option(self::$OPTION_NAME_IS_SHORT_OFFSET_NAME_SHOWN, self::$DEFAULT_IS_SHORT_OFFSET_NAME_SHOWN); | ||||
|     add_option(self::$OPTION_NAME_URL, self::$DEFAULT_OPTION_URL); | ||||
|   } | ||||
|  | ||||
|   public static function deleteAllOptions() { | ||||
|     delete_option(self::$OPTION_NAME_IS_SHORT_OFFSET_NAME_SHOWN); | ||||
|     delete_option(self::$OPTION_NAME_URL); | ||||
|   } | ||||
|  | ||||
|   public static function removeObsoleteOptionsIfNeeded() { | ||||
|     $storedPluginVersion = get_option(self::$OPTION_NAME_PLUGIN_VERSION); | ||||
|     if ($storedPluginVersion !== PLUGIN_VERSION) { | ||||
|       if (version_compare($storedPluginVersion, '1.5.0', '<') ) { | ||||
|         delete_option(self::$OPTION_NAME_IS_SHORT_OFFSET_NAME_SHOWN); | ||||
|       } | ||||
|       update_option(self::$OPTION_NAME_PLUGIN_VERSION, PLUGIN_VERSION); | ||||
|     }     | ||||
|   } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,15 +0,0 @@ | ||||
| <?php | ||||
| namespace MobilizonConnector; | ||||
|  | ||||
| // Exit if this file is called directly. | ||||
| if (!defined('ABSPATH')) { | ||||
|   exit; | ||||
| } | ||||
| ?> | ||||
| <input id="<?php echo esc_attr($args['label_for']); ?>" | ||||
|   name="<?php echo esc_attr(self::$OPTION_NAME_IS_SHORT_OFFSET_NAME_SHOWN); ?>" | ||||
|   type="checkbox" | ||||
|   <?php echo $isShortOffsetNameShown == true ? 'checked' : ''; ?>> | ||||
| <p class="description"> | ||||
|   <?php esc_html_e('The time zone of this WordPress installation is used. Whether the current offset should be displayed in brackets after the time, e.g. 10:00 (UTC)', 'connector-mobilizon'); ?> | ||||
| </p> | ||||
		Reference in New Issue
	
	Block a user