PluginProbe
Texty – SMS Notification for WordPress, WooCommerce, Dokan and more / 0.2
Texty – SMS Notification for WordPress, WooCommerce, Dokan and more v0.2
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 0.2, at includes/Settings.php

66 lines 1.2 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
50 if ( isset( $settings[ $key ] ) ) {
51 return $settings[ $key ];
52 }
53
54 return false;
55 }
56
57 /**
58 * Get the active gateway name
59 *
60 * @return string|false
61 */
62 public function gateway() {
63 return $this->get( 'gateway' );
64 }
65 }
66