class-login-attempts.php
1 day ago
class-methods-wizards-trait.php
1 day ago
class-provider-trait.php
1 day ago
class-settings-trait.php
1 day ago
class-validation-trait.php
1 day ago
class-white-label-trait.php
1 day ago
index.php
1 day ago
class-settings-trait.php
77 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Responsible for the plugin settings |
| 4 | * |
| 5 | * @package wp2fa |
| 6 | * @subpackage traits |
| 7 | * @copyright 2026 Melapress |
| 8 | * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 |
| 9 | * @link https://wordpress.org/plugins/wp-2fa/ |
| 10 | */ |
| 11 | |
| 12 | namespace WP2FA\Admin\Methods\Traits; |
| 13 | |
| 14 | use WP2FA\Utils\Settings_Utils; |
| 15 | |
| 16 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 17 | |
| 18 | if ( ! class_exists( '\WP2FA\Admin\Methods\Traits\Settings_Trait' ) ) { |
| 19 | /** |
| 20 | * Responsible for the settings |
| 21 | * |
| 22 | * @since 2.9.2 |
| 23 | */ |
| 24 | trait Settings_Trait { |
| 25 | |
| 26 | /** |
| 27 | * Adds method-specific settings to the loop. |
| 28 | * |
| 29 | * @param array $settings - The array with settings. |
| 30 | * |
| 31 | * @return array |
| 32 | * |
| 33 | * @since 3.1.1 |
| 34 | */ |
| 35 | public static function settings_loop( array $settings ): array { |
| 36 | $settings[ static::POLICY_SETTINGS_NAME ] = Settings_Utils::get_option( static::POLICY_SETTINGS_NAME, static::get_settings_default_value() ); |
| 37 | |
| 38 | return $settings; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Adds default settings for the method. |
| 43 | * |
| 44 | * @param array $default_settings - The array with default settings. |
| 45 | * |
| 46 | * @return array |
| 47 | * |
| 48 | * @since 3.1.1 |
| 49 | */ |
| 50 | public static function add_default_settings( array $default_settings ): array { |
| 51 | |
| 52 | if ( \method_exists( static::class, 'get_settings_default_value' ) ) { |
| 53 | $default_settings[ static::POLICY_SETTINGS_NAME ] = static::get_settings_default_value(); |
| 54 | } else { |
| 55 | $default_settings[ static::POLICY_SETTINGS_NAME ] = static::POLICY_SETTINGS_NAME; |
| 56 | } |
| 57 | |
| 58 | return $default_settings; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Adds translated provider name. |
| 63 | * |
| 64 | * @param array $providers - Array with all currently supported providers and their translated names. |
| 65 | * |
| 66 | * @return array |
| 67 | * |
| 68 | * @since 3.1.1 |
| 69 | */ |
| 70 | public static function provider_name_translated( array $providers ): array { |
| 71 | $providers[ static::METHOD_NAME ] = static::get_translated_name(); |
| 72 | |
| 73 | return $providers; |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 |