PluginProbe
Texty – SMS Notification for WordPress, WooCommerce, Dokan and more / 2.0.0
Texty – SMS Notification for WordPress, WooCommerce, Dokan and more v2.0.0
2.0.2 trunk 0.2 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 2.0.0 2.0.1
texty / includes / Settings.php

Settings.php in Texty – SMS Notification for WordPress, WooCommerce, Dokan and more 2.0.0, at includes/Settings.php

76 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Texty;
4
5 /**
6 * Settings Class
7 */
8 class Settings {
9
10 /**
11 * Option key to hold the settings in database
12 */
13 const OPTION_KEY = 'texty_settings';
14
15 /**
16 * Return all the settings
17 *
18 * @return array
19 */
20 public function all() {
21 $default = apply_filters( 'texty_settings_default', [ // phpcs:ignore
22 'gateway' => '',
23 'twilio' => [
24 'sid' => '',
25 'token' => '',
26 'from' => '',
27 ],
28 'vonage' => [
29 'key' => '',
30 'secret' => '',
31 'from' => '',
32 ],
33 ] ); // phpcs:ignore
34
35 $settings = get_option( self::OPTION_KEY, [] );
36
37 return wp_parse_args( $settings, $default );
38 }
39
40 /**
41 * Get a settings value by key
42 *
43 * @param string $key
44 *
45 * @return mixed
46 */
47 public function get( $key ) {
48 $settings = $this->all();
49 $value = isset( $settings[ $key ] ) ? $settings[ $key ] : false;
50
51 /**
52 * Filter a setting value. Allows overriding from env vars or other sources.
53 *
54 * @param mixed $value The setting value
55 * @param string $key The setting key
56 */
57 return apply_filters( 'texty_setting', $value, $key );
58 }
59
60 /**
61 * Get the active gateway name
62 *
63 * @return string|false
64 */
65 public function gateway() {
66 $gateway = $this->get( 'gateway' );
67
68 /**
69 * Filter the active gateway name.
70 *
71 * @param string|false $gateway The active gateway identifier
72 */
73 return apply_filters( 'texty_active_gateway_name', $gateway );
74 }
75 }
76