Completed
Branch FET/allow-prices-to-be-more-pr... (276f1f)
by
unknown
17:02 queued 13:56
created
core/services/validators/JsonValidator.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function isValid($file, $func, $line)
34 34
     {
35
-        if (! defined('JSON_ERROR_RECURSION')) {
35
+        if ( ! defined('JSON_ERROR_RECURSION')) {
36 36
             define('JSON_ERROR_RECURSION', 6);
37 37
         }
38
-        if (! defined('JSON_ERROR_INF_OR_NAN')) {
38
+        if ( ! defined('JSON_ERROR_INF_OR_NAN')) {
39 39
             define('JSON_ERROR_INF_OR_NAN', 7);
40 40
         }
41
-        if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
41
+        if ( ! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
42 42
             define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
43 43
         }
44
-        if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
44
+        if ( ! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
45 45
             define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
46 46
         }
47
-        if (! defined('JSON_ERROR_UTF16')) {
47
+        if ( ! defined('JSON_ERROR_UTF16')) {
48 48
             define('JSON_ERROR_UTF16', 10);
49 49
         }
50 50
         switch (json_last_error()) {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 $error = ': Unknown error';
85 85
                 break;
86 86
         }
87
-        EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
87
+        EE_Error::add_error('JSON decoding failed'.$error, $file, $func, $line);
88 88
         return false;
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -17,76 +17,76 @@
 block discarded – undo
17 17
  */
18 18
 class JsonValidator
19 19
 {
20
-    /**
21
-     * Call this method IMMEDIATELY after json_decode() and
22
-     * it will will return true if the decoded JSON was valid,
23
-     * or return false after adding an error if not valid.
24
-     * The actual JSON file does not need to be supplied,
25
-     * but details re: code execution location are required.
26
-     * ex:
27
-     * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__)
28
-     *
29
-     * @param string $file
30
-     * @param string $func
31
-     * @param string $line
32
-     * @return boolean
33
-     * @since 4.9.70.p
34
-     */
35
-    public function isValid($file, $func, $line)
36
-    {
37
-        if (! defined('JSON_ERROR_RECURSION')) {
38
-            define('JSON_ERROR_RECURSION', 6);
39
-        }
40
-        if (! defined('JSON_ERROR_INF_OR_NAN')) {
41
-            define('JSON_ERROR_INF_OR_NAN', 7);
42
-        }
43
-        if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
44
-            define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
45
-        }
46
-        if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
47
-            define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
48
-        }
49
-        if (! defined('JSON_ERROR_UTF16')) {
50
-            define('JSON_ERROR_UTF16', 10);
51
-        }
52
-        switch (json_last_error()) {
53
-            case JSON_ERROR_NONE:
54
-                return true;
55
-            case JSON_ERROR_DEPTH:
56
-                $error = ': Maximum stack depth exceeded';
57
-                break;
58
-            case JSON_ERROR_STATE_MISMATCH:
59
-                $error = ': Invalid or malformed JSON';
60
-                break;
61
-            case JSON_ERROR_CTRL_CHAR:
62
-                $error = ': Control character error, possible malformed JSON';
63
-                break;
64
-            case JSON_ERROR_SYNTAX:
65
-                $error = ': Syntax error, malformed JSON';
66
-                break;
67
-            case JSON_ERROR_UTF8:
68
-                $error = ': Malformed UTF-8 characters, possible malformed JSON';
69
-                break;
70
-            case JSON_ERROR_RECURSION:
71
-                $error = ': One or more recursive references in the value to be encoded';
72
-                break;
73
-            case JSON_ERROR_INF_OR_NAN:
74
-                $error = ': One or more NAN or INF values in the value to be encoded';
75
-                break;
76
-            case JSON_ERROR_UNSUPPORTED_TYPE:
77
-                $error = ': A value of a type that cannot be encoded was given';
78
-                break;
79
-            case JSON_ERROR_INVALID_PROPERTY_NAME:
80
-                $error = ': A property name that cannot be encoded was given';
81
-                break;
82
-            case JSON_ERROR_UTF16:
83
-                $error = ': Malformed UTF-16 characters, possibly incorrectly encoded';
84
-                break;
85
-            default:
86
-                $error = ': Unknown error';
87
-                break;
88
-        }
89
-        EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
90
-        return false;
91
-    }
20
+	/**
21
+	 * Call this method IMMEDIATELY after json_decode() and
22
+	 * it will will return true if the decoded JSON was valid,
23
+	 * or return false after adding an error if not valid.
24
+	 * The actual JSON file does not need to be supplied,
25
+	 * but details re: code execution location are required.
26
+	 * ex:
27
+	 * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__)
28
+	 *
29
+	 * @param string $file
30
+	 * @param string $func
31
+	 * @param string $line
32
+	 * @return boolean
33
+	 * @since 4.9.70.p
34
+	 */
35
+	public function isValid($file, $func, $line)
36
+	{
37
+		if (! defined('JSON_ERROR_RECURSION')) {
38
+			define('JSON_ERROR_RECURSION', 6);
39
+		}
40
+		if (! defined('JSON_ERROR_INF_OR_NAN')) {
41
+			define('JSON_ERROR_INF_OR_NAN', 7);
42
+		}
43
+		if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
44
+			define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
45
+		}
46
+		if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
47
+			define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
48
+		}
49
+		if (! defined('JSON_ERROR_UTF16')) {
50
+			define('JSON_ERROR_UTF16', 10);
51
+		}
52
+		switch (json_last_error()) {
53
+			case JSON_ERROR_NONE:
54
+				return true;
55
+			case JSON_ERROR_DEPTH:
56
+				$error = ': Maximum stack depth exceeded';
57
+				break;
58
+			case JSON_ERROR_STATE_MISMATCH:
59
+				$error = ': Invalid or malformed JSON';
60
+				break;
61
+			case JSON_ERROR_CTRL_CHAR:
62
+				$error = ': Control character error, possible malformed JSON';
63
+				break;
64
+			case JSON_ERROR_SYNTAX:
65
+				$error = ': Syntax error, malformed JSON';
66
+				break;
67
+			case JSON_ERROR_UTF8:
68
+				$error = ': Malformed UTF-8 characters, possible malformed JSON';
69
+				break;
70
+			case JSON_ERROR_RECURSION:
71
+				$error = ': One or more recursive references in the value to be encoded';
72
+				break;
73
+			case JSON_ERROR_INF_OR_NAN:
74
+				$error = ': One or more NAN or INF values in the value to be encoded';
75
+				break;
76
+			case JSON_ERROR_UNSUPPORTED_TYPE:
77
+				$error = ': A value of a type that cannot be encoded was given';
78
+				break;
79
+			case JSON_ERROR_INVALID_PROPERTY_NAME:
80
+				$error = ': A property name that cannot be encoded was given';
81
+				break;
82
+			case JSON_ERROR_UTF16:
83
+				$error = ': Malformed UTF-16 characters, possibly incorrectly encoded';
84
+				break;
85
+			default:
86
+				$error = ': Unknown error';
87
+				break;
88
+		}
89
+		EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
90
+		return false;
91
+	}
92 92
 }
Please login to merge, or discard this patch.
core/domain/services/blocks/EventAttendeesBlockRenderer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
         $template_args['attributes'] = $attributes;
47 47
         $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes));
48 48
         return EEH_Template::display_template(
49
-            $this->templateRootPath() . 'event-attendees.php',
49
+            $this->templateRootPath().'event-attendees.php',
50 50
             $template_args,
51 51
             true
52 52
         );
Please login to merge, or discard this patch.
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -19,104 +19,104 @@
 block discarded – undo
19 19
  */
20 20
 class EventAttendeesBlockRenderer extends BlockRenderer
21 21
 {
22
-    /**
23
-     * @var EEM_Attendee
24
-     */
25
-    private $attendee_model;
22
+	/**
23
+	 * @var EEM_Attendee
24
+	 */
25
+	private $attendee_model;
26 26
 
27
-    public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model)
28
-    {
29
-        $this->attendee_model = $attendee_model;
30
-        parent::__construct($domain);
31
-    }
27
+	public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model)
28
+	{
29
+		$this->attendee_model = $attendee_model;
30
+		parent::__construct($domain);
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * Renders the block.
36
-     *
37
-     * @param array $attributes  Expect already validated and sanitized array of attributes for use in generating the
38
-     *                           query and the template output.
39
-     * @return string
40
-     * @throws DomainException
41
-     * @throws EE_Error
42
-     */
43
-    public function render(array $attributes)
44
-    {
45
-        $template_args['attributes'] = $attributes;
46
-        $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes));
47
-        return EEH_Template::display_template(
48
-            $this->templateRootPath() . 'event-attendees.php',
49
-            $template_args,
50
-            true
51
-        );
52
-    }
34
+	/**
35
+	 * Renders the block.
36
+	 *
37
+	 * @param array $attributes  Expect already validated and sanitized array of attributes for use in generating the
38
+	 *                           query and the template output.
39
+	 * @return string
40
+	 * @throws DomainException
41
+	 * @throws EE_Error
42
+	 */
43
+	public function render(array $attributes)
44
+	{
45
+		$template_args['attributes'] = $attributes;
46
+		$template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes));
47
+		return EEH_Template::display_template(
48
+			$this->templateRootPath() . 'event-attendees.php',
49
+			$template_args,
50
+			true
51
+		);
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Get query parameters for model query.
57
-     *
58
-     * @param array $attributes
59
-     * @return array
60
-     */
61
-    private function getQueryParams(array $attributes)
62
-    {
63
-        return array(
64
-            0 => $this->getWhereQueryPart($attributes),
65
-            'default_where_conditions' => 'this_model_only',
66
-            'limit' => $attributes['limit'],
67
-            'group_by' => array('ATT_ID'),
68
-            'order_by' => $this->getOrderByQueryPart($attributes)
69
-        );
70
-    }
55
+	/**
56
+	 * Get query parameters for model query.
57
+	 *
58
+	 * @param array $attributes
59
+	 * @return array
60
+	 */
61
+	private function getQueryParams(array $attributes)
62
+	{
63
+		return array(
64
+			0 => $this->getWhereQueryPart($attributes),
65
+			'default_where_conditions' => 'this_model_only',
66
+			'limit' => $attributes['limit'],
67
+			'group_by' => array('ATT_ID'),
68
+			'order_by' => $this->getOrderByQueryPart($attributes)
69
+		);
70
+	}
71 71
 
72 72
 
73
-    /**
74
-     * Get where query part for query parameters for model query.
75
-     *
76
-     * @param array $attributes
77
-     * @return array
78
-     */
79
-    private function getWhereQueryPart(array $attributes)
80
-    {
81
-        $where = array();
82
-        if ($attributes['ticketId'] > 0) {
83
-            $where['Registration.TKT_ID'] = $attributes['ticketId'];
84
-        } elseif ($attributes['datetimeId'] > 0) {
85
-            $where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId'];
86
-        } else {
87
-            $where['Registration.EVT_ID'] = $attributes['eventId'];
88
-        }
89
-        $where['Registration.STS_ID'] = $attributes['status'];
90
-        return $where;
91
-    }
73
+	/**
74
+	 * Get where query part for query parameters for model query.
75
+	 *
76
+	 * @param array $attributes
77
+	 * @return array
78
+	 */
79
+	private function getWhereQueryPart(array $attributes)
80
+	{
81
+		$where = array();
82
+		if ($attributes['ticketId'] > 0) {
83
+			$where['Registration.TKT_ID'] = $attributes['ticketId'];
84
+		} elseif ($attributes['datetimeId'] > 0) {
85
+			$where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId'];
86
+		} else {
87
+			$where['Registration.EVT_ID'] = $attributes['eventId'];
88
+		}
89
+		$where['Registration.STS_ID'] = $attributes['status'];
90
+		return $where;
91
+	}
92 92
 
93 93
 
94
-    /**
95
-     * Get order by query part for query parameters for model query.
96
-     *
97
-     * @param array $attributes
98
-     * @return array
99
-     */
100
-    private function getOrderByQueryPart(array $attributes)
101
-    {
102
-        $order = $attributes['order'];
103
-        switch ($attributes['orderBy']) {
104
-            case 'id':
105
-                $order_by = array('ATT_ID' => $order);
106
-                break;
107
-            case 'lastNameOnly':
108
-                $order_by = array('ATT_lname' => $order);
109
-                break;
110
-            case 'firstNameOnly':
111
-                $order_by = array('ATT_fname' => $order);
112
-                break;
113
-            case 'firstThenLastName':
114
-                $order_by = array('ATT_fname' => $order, 'ATT_lname' => $order);
115
-                break;
116
-            default:
117
-                $order_by = array('ATT_lname' => $order, 'ATT_fname' => $order);
118
-                break;
119
-        }
120
-        return $order_by;
121
-    }
94
+	/**
95
+	 * Get order by query part for query parameters for model query.
96
+	 *
97
+	 * @param array $attributes
98
+	 * @return array
99
+	 */
100
+	private function getOrderByQueryPart(array $attributes)
101
+	{
102
+		$order = $attributes['order'];
103
+		switch ($attributes['orderBy']) {
104
+			case 'id':
105
+				$order_by = array('ATT_ID' => $order);
106
+				break;
107
+			case 'lastNameOnly':
108
+				$order_by = array('ATT_lname' => $order);
109
+				break;
110
+			case 'firstNameOnly':
111
+				$order_by = array('ATT_fname' => $order);
112
+				break;
113
+			case 'firstThenLastName':
114
+				$order_by = array('ATT_fname' => $order, 'ATT_lname' => $order);
115
+				break;
116
+			default:
117
+				$order_by = array('ATT_lname' => $order, 'ATT_fname' => $order);
118
+				break;
119
+		}
120
+		return $order_by;
121
+	}
122 122
 }
Please login to merge, or discard this patch.
core/services/blocks/BlockRenderer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
      */
43 43
     private function setTemplateRootPath()
44 44
     {
45
-        $this->template_root_path = $this->domain->pluginPath() . 'ui/blocks/';
45
+        $this->template_root_path = $this->domain->pluginPath().'ui/blocks/';
46 46
     }
47 47
 
48 48
 
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -14,44 +14,44 @@
 block discarded – undo
14 14
  */
15 15
 abstract class BlockRenderer implements BlockRendererInterface
16 16
 {
17
-    /**
18
-     * @var DomainInterface
19
-     */
20
-    protected $domain;
21
-
22
-    /**
23
-     * @var string
24
-     */
25
-    private $template_root_path;
26
-
27
-
28
-    /**
29
-     * BlockRenderer constructor.
30
-     *
31
-     * @param DomainInterface $domain
32
-     */
33
-    public function __construct(DomainInterface $domain)
34
-    {
35
-        $this->domain = $domain;
36
-        $this->setTemplateRootPath();
37
-    }
38
-
39
-
40
-    /**
41
-     * Sets the root path to the main block template.
42
-     */
43
-    private function setTemplateRootPath()
44
-    {
45
-        $this->template_root_path = $this->domain->pluginPath() . 'ui/blocks/';
46
-    }
47
-
48
-
49
-    /**
50
-     * Exposes the root path for the main block template.
51
-     * @return string
52
-     */
53
-    public function templateRootPath()
54
-    {
55
-        return $this->template_root_path;
56
-    }
17
+	/**
18
+	 * @var DomainInterface
19
+	 */
20
+	protected $domain;
21
+
22
+	/**
23
+	 * @var string
24
+	 */
25
+	private $template_root_path;
26
+
27
+
28
+	/**
29
+	 * BlockRenderer constructor.
30
+	 *
31
+	 * @param DomainInterface $domain
32
+	 */
33
+	public function __construct(DomainInterface $domain)
34
+	{
35
+		$this->domain = $domain;
36
+		$this->setTemplateRootPath();
37
+	}
38
+
39
+
40
+	/**
41
+	 * Sets the root path to the main block template.
42
+	 */
43
+	private function setTemplateRootPath()
44
+	{
45
+		$this->template_root_path = $this->domain->pluginPath() . 'ui/blocks/';
46
+	}
47
+
48
+
49
+	/**
50
+	 * Exposes the root path for the main block template.
51
+	 * @return string
52
+	 */
53
+	public function templateRootPath()
54
+	{
55
+		return $this->template_root_path;
56
+	}
57 57
 }
Please login to merge, or discard this patch.
core/EE_Network_Config.core.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     public static function instance()
40 40
     {
41 41
         // check if class object is instantiated, and instantiated properly
42
-        if (! self::$_instance instanceof EE_Network_Config) {
42
+        if ( ! self::$_instance instanceof EE_Network_Config) {
43 43
             self::$_instance = new self();
44 44
         }
45 45
         return self::$_instance;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         // need to bust cache for comparing original if this is a multisite install
137 137
         if (is_multisite()) {
138 138
             global $current_site;
139
-            $cache_key = $current_site->id . ':ee_network_config';
139
+            $cache_key = $current_site->id.':ee_network_config';
140 140
             wp_cache_delete($cache_key, 'site-options');
141 141
         }
142 142
 
Please login to merge, or discard this patch.
Indentation   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -15,180 +15,180 @@  discard block
 block discarded – undo
15 15
  */
16 16
 final class EE_Network_Config implements InterminableInterface
17 17
 {
18
-    /**
19
-     * @var EE_Network_Config $_instance
20
-     */
21
-    private static $_instance;
22
-
23
-    /**
24
-     * addons can add their specific network_config objects to this property
25
-     *
26
-     * @var EE_Config_Base[] $addons
27
-     */
28
-    public $addons;
29
-
30
-    /**
31
-     * @var EE_Network_Core_Config $core
32
-     */
33
-    public $core;
34
-
35
-
36
-    /**
37
-     * @singleton method used to instantiate class object
38
-     * @return EE_Network_Config instance
39
-     */
40
-    public static function instance()
41
-    {
42
-        // check if class object is instantiated, and instantiated properly
43
-        if (! self::$_instance instanceof EE_Network_Config) {
44
-            self::$_instance = new self();
45
-        }
46
-        return self::$_instance;
47
-    }
48
-
49
-
50
-    /**
51
-     * class constructor
52
-     */
53
-    private function __construct()
54
-    {
55
-        do_action('AHEE__EE_Network_Config__construct__begin', $this);
56
-        // set defaults
57
-        $this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config());
58
-        $this->addons = array();
59
-
60
-        $this->_load_config();
61
-
62
-        // construct__end hook
63
-        do_action('AHEE__EE_Network_Config__construct__end', $this);
64
-    }
65
-
66
-
67
-    /**
68
-     * load EE Network Config options
69
-     *
70
-     * @return void
71
-     */
72
-    private function _load_config()
73
-    {
74
-        // load network config start hook
75
-        do_action('AHEE__EE_Network_Config___load_config__start', $this);
76
-        $config = $this->get_config();
77
-        foreach ($config as $config_prop => $settings) {
78
-            if ($config_prop === 'core' && ! $settings instanceof EE_Network_Core_Config) {
79
-                $core = new EE_Network_Core_Config();
80
-                foreach ($settings as $prop => $setting) {
81
-                    if (property_exists($core, $prop)) {
82
-                        $core->{$prop} = $setting;
83
-                    }
84
-                }
85
-                $settings = $core;
86
-                add_filter('FHEE__EE_Network_Config___load_config__update_network_config', '__return_true');
87
-            }
88
-            if (is_object($settings) && property_exists($this, $config_prop)) {
89
-                $this->{$config_prop} = apply_filters(
90
-                    'FHEE__EE_Network_Config___load_config__config_settings',
91
-                    $settings,
92
-                    $config_prop,
93
-                    $this
94
-                );
95
-                if (method_exists($settings, 'populate')) {
96
-                    $this->{$config_prop}->populate();
97
-                }
98
-                if (method_exists($settings, 'do_hooks')) {
99
-                    $this->{$config_prop}->do_hooks();
100
-                }
101
-            }
102
-        }
103
-        if (apply_filters('FHEE__EE_Network_Config___load_config__update_network_config', false)) {
104
-            $this->update_config();
105
-        }
106
-
107
-        // load network config end hook
108
-        do_action('AHEE__EE_Network_Config___load_config__end', $this);
109
-    }
110
-
111
-
112
-    /**
113
-     * get_config
114
-     *
115
-     * @return array of network config stuff
116
-     */
117
-    public function get_config()
118
-    {
119
-        // grab network configuration
120
-        $CFG = get_site_option('ee_network_config', array());
121
-        $CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG);
122
-        return $CFG;
123
-    }
124
-
125
-
126
-    /**
127
-     * update_config
128
-     *
129
-     * @param bool $add_success
130
-     * @param bool $add_error
131
-     * @return bool success
132
-     */
133
-    public function update_config($add_success = false, $add_error = true)
134
-    {
135
-        do_action('AHEE__EE_Network_Config__update_config__begin', $this);
136
-
137
-        // need to bust cache for comparing original if this is a multisite install
138
-        if (is_multisite()) {
139
-            global $current_site;
140
-            $cache_key = $current_site->id . ':ee_network_config';
141
-            wp_cache_delete($cache_key, 'site-options');
142
-        }
143
-
144
-        // we have to compare existing saved config with config in memory because if there is no difference that means
145
-        // that the method executed fine but there just was no update.  WordPress doesn't distinguish between false because
146
-        // there were 0 records updated because of no change vs false because some error produced problems with the update.
147
-        $original = get_site_option('ee_network_config');
148
-
149
-        if ($original == $this) {
150
-            return true;
151
-        }
152
-        // update
153
-        $saved = update_site_option('ee_network_config', $this);
154
-
155
-        do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved);
156
-        // if config remains the same or was updated successfully
157
-        if ($saved) {
158
-            if ($add_success) {
159
-                $msg = is_multisite() ? esc_html__(
160
-                    'The Event Espresso Network Configuration Settings have been successfully updated.',
161
-                    'event_espresso'
162
-                ) : esc_html__('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso');
163
-                EE_Error::add_success($msg);
164
-            }
165
-            return true;
166
-        }
167
-        if ($add_error) {
168
-            $msg = is_multisite() ? esc_html__(
169
-                'The Event Espresso Network Configuration Settings were not updated.',
170
-                'event_espresso'
171
-            ) : esc_html__('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso');
172
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
173
-        }
174
-        return false;
175
-    }
176
-
177
-
178
-    /**
179
-     * __sleep
180
-     *
181
-     * @return array
182
-     */
183
-    public function __sleep()
184
-    {
185
-        return apply_filters(
186
-            'FHEE__EE_Network_Config__sleep',
187
-            array(
188
-                'core',
189
-            )
190
-        );
191
-    }
18
+	/**
19
+	 * @var EE_Network_Config $_instance
20
+	 */
21
+	private static $_instance;
22
+
23
+	/**
24
+	 * addons can add their specific network_config objects to this property
25
+	 *
26
+	 * @var EE_Config_Base[] $addons
27
+	 */
28
+	public $addons;
29
+
30
+	/**
31
+	 * @var EE_Network_Core_Config $core
32
+	 */
33
+	public $core;
34
+
35
+
36
+	/**
37
+	 * @singleton method used to instantiate class object
38
+	 * @return EE_Network_Config instance
39
+	 */
40
+	public static function instance()
41
+	{
42
+		// check if class object is instantiated, and instantiated properly
43
+		if (! self::$_instance instanceof EE_Network_Config) {
44
+			self::$_instance = new self();
45
+		}
46
+		return self::$_instance;
47
+	}
48
+
49
+
50
+	/**
51
+	 * class constructor
52
+	 */
53
+	private function __construct()
54
+	{
55
+		do_action('AHEE__EE_Network_Config__construct__begin', $this);
56
+		// set defaults
57
+		$this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config());
58
+		$this->addons = array();
59
+
60
+		$this->_load_config();
61
+
62
+		// construct__end hook
63
+		do_action('AHEE__EE_Network_Config__construct__end', $this);
64
+	}
65
+
66
+
67
+	/**
68
+	 * load EE Network Config options
69
+	 *
70
+	 * @return void
71
+	 */
72
+	private function _load_config()
73
+	{
74
+		// load network config start hook
75
+		do_action('AHEE__EE_Network_Config___load_config__start', $this);
76
+		$config = $this->get_config();
77
+		foreach ($config as $config_prop => $settings) {
78
+			if ($config_prop === 'core' && ! $settings instanceof EE_Network_Core_Config) {
79
+				$core = new EE_Network_Core_Config();
80
+				foreach ($settings as $prop => $setting) {
81
+					if (property_exists($core, $prop)) {
82
+						$core->{$prop} = $setting;
83
+					}
84
+				}
85
+				$settings = $core;
86
+				add_filter('FHEE__EE_Network_Config___load_config__update_network_config', '__return_true');
87
+			}
88
+			if (is_object($settings) && property_exists($this, $config_prop)) {
89
+				$this->{$config_prop} = apply_filters(
90
+					'FHEE__EE_Network_Config___load_config__config_settings',
91
+					$settings,
92
+					$config_prop,
93
+					$this
94
+				);
95
+				if (method_exists($settings, 'populate')) {
96
+					$this->{$config_prop}->populate();
97
+				}
98
+				if (method_exists($settings, 'do_hooks')) {
99
+					$this->{$config_prop}->do_hooks();
100
+				}
101
+			}
102
+		}
103
+		if (apply_filters('FHEE__EE_Network_Config___load_config__update_network_config', false)) {
104
+			$this->update_config();
105
+		}
106
+
107
+		// load network config end hook
108
+		do_action('AHEE__EE_Network_Config___load_config__end', $this);
109
+	}
110
+
111
+
112
+	/**
113
+	 * get_config
114
+	 *
115
+	 * @return array of network config stuff
116
+	 */
117
+	public function get_config()
118
+	{
119
+		// grab network configuration
120
+		$CFG = get_site_option('ee_network_config', array());
121
+		$CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG);
122
+		return $CFG;
123
+	}
124
+
125
+
126
+	/**
127
+	 * update_config
128
+	 *
129
+	 * @param bool $add_success
130
+	 * @param bool $add_error
131
+	 * @return bool success
132
+	 */
133
+	public function update_config($add_success = false, $add_error = true)
134
+	{
135
+		do_action('AHEE__EE_Network_Config__update_config__begin', $this);
136
+
137
+		// need to bust cache for comparing original if this is a multisite install
138
+		if (is_multisite()) {
139
+			global $current_site;
140
+			$cache_key = $current_site->id . ':ee_network_config';
141
+			wp_cache_delete($cache_key, 'site-options');
142
+		}
143
+
144
+		// we have to compare existing saved config with config in memory because if there is no difference that means
145
+		// that the method executed fine but there just was no update.  WordPress doesn't distinguish between false because
146
+		// there were 0 records updated because of no change vs false because some error produced problems with the update.
147
+		$original = get_site_option('ee_network_config');
148
+
149
+		if ($original == $this) {
150
+			return true;
151
+		}
152
+		// update
153
+		$saved = update_site_option('ee_network_config', $this);
154
+
155
+		do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved);
156
+		// if config remains the same or was updated successfully
157
+		if ($saved) {
158
+			if ($add_success) {
159
+				$msg = is_multisite() ? esc_html__(
160
+					'The Event Espresso Network Configuration Settings have been successfully updated.',
161
+					'event_espresso'
162
+				) : esc_html__('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso');
163
+				EE_Error::add_success($msg);
164
+			}
165
+			return true;
166
+		}
167
+		if ($add_error) {
168
+			$msg = is_multisite() ? esc_html__(
169
+				'The Event Espresso Network Configuration Settings were not updated.',
170
+				'event_espresso'
171
+			) : esc_html__('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso');
172
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
173
+		}
174
+		return false;
175
+	}
176
+
177
+
178
+	/**
179
+	 * __sleep
180
+	 *
181
+	 * @return array
182
+	 */
183
+	public function __sleep()
184
+	{
185
+		return apply_filters(
186
+			'FHEE__EE_Network_Config__sleep',
187
+			array(
188
+				'core',
189
+			)
190
+		);
191
+	}
192 192
 }
193 193
 
194 194
 
@@ -197,27 +197,27 @@  discard block
 block discarded – undo
197 197
  */
198 198
 class EE_Network_Core_Config extends EE_Config_Base
199 199
 {
200
-    /**
201
-     * PUE site license key
202
-     *
203
-     * @var string $site_license_key
204
-     */
205
-    public $site_license_key;
206
-
207
-    /**
208
-     * This indicates whether messages system processing should be done on the same request or not.
209
-     *
210
-     * @var boolean $do_messages_on_same_request
211
-     */
212
-    public $do_messages_on_same_request;
213
-
214
-
215
-    /**
216
-     * EE_Network_Core_Config constructor.
217
-     */
218
-    public function __construct()
219
-    {
220
-        $this->site_license_key = '';
221
-        $this->do_messages_on_same_request = false;
222
-    }
200
+	/**
201
+	 * PUE site license key
202
+	 *
203
+	 * @var string $site_license_key
204
+	 */
205
+	public $site_license_key;
206
+
207
+	/**
208
+	 * This indicates whether messages system processing should be done on the same request or not.
209
+	 *
210
+	 * @var boolean $do_messages_on_same_request
211
+	 */
212
+	public $do_messages_on_same_request;
213
+
214
+
215
+	/**
216
+	 * EE_Network_Core_Config constructor.
217
+	 */
218
+	public function __construct()
219
+	{
220
+		$this->site_license_key = '';
221
+		$this->do_messages_on_same_request = false;
222
+	}
223 223
 }
Please login to merge, or discard this patch.
entities/route_match/specifications/admin/WordPressPageEditorAddNew.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
  */
15 15
 class WordPressPageEditorAddNew extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since 4.9.71.p
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return strpos($this->request->requestUri(), 'wp-admin/post-new.php') !== false
26
-            && $this->request->getRequestParam('post_type', 'post') === 'page';
27
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since 4.9.71.p
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return strpos($this->request->requestUri(), 'wp-admin/post-new.php') !== false
26
+			&& $this->request->getRequestParam('post_type', 'post') === 'page';
27
+	}
28 28
 }
Please login to merge, or discard this patch.
entities/route_match/specifications/admin/WordPressPostsEditorAddNew.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
  */
15 15
 class WordPressPostsEditorAddNew extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since 4.9.71.p
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return strpos($this->request->requestUri(), 'wp-admin/post-new.php') !== false
26
-            && $this->request->getRequestParam('post_type', 'post') === 'post';
27
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since 4.9.71.p
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return strpos($this->request->requestUri(), 'wp-admin/post-new.php') !== false
26
+			&& $this->request->getRequestParam('post_type', 'post') === 'post';
27
+	}
28 28
 }
Please login to merge, or discard this patch.
entities/route_match/specifications/admin/WordPressPostsListTable.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
  */
15 15
 class WordPressPostsListTable extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since 4.9.71.p
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return strpos($this->request->requestUri(), 'wp-admin/edit.php') !== false
26
-            && $this->request->getRequestParam('post_type', 'post') === 'post';
27
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since 4.9.71.p
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return strpos($this->request->requestUri(), 'wp-admin/edit.php') !== false
26
+			&& $this->request->getRequestParam('post_type', 'post') === 'post';
27
+	}
28 28
 }
Please login to merge, or discard this patch.
entities/route_match/specifications/admin/WordPressPageEditorEdit.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -15,23 +15,23 @@
 block discarded – undo
15 15
  */
16 16
 class WordPressPageEditorEdit extends RouteMatchSpecification
17 17
 {
18
-    /**
19
-     * returns true if current request matches specification
20
-     *
21
-     * @since 4.9.71.p
22
-     * @return boolean
23
-     */
24
-    public function isMatchingRoute()
25
-    {
26
-        global $post;
27
-        return strpos($this->request->requestUri(), 'wp-admin/post.php') !== false
28
-            && (
29
-                $this->request->getRequestParam('post_type', 'post') === 'page'
30
-                || (
31
-                    $post instanceof WP_Post
32
-                    && $post->post_type === 'page'
33
-                )
34
-            )
35
-            && $this->request->getRequestParam('action') === 'edit';
36
-    }
18
+	/**
19
+	 * returns true if current request matches specification
20
+	 *
21
+	 * @since 4.9.71.p
22
+	 * @return boolean
23
+	 */
24
+	public function isMatchingRoute()
25
+	{
26
+		global $post;
27
+		return strpos($this->request->requestUri(), 'wp-admin/post.php') !== false
28
+			&& (
29
+				$this->request->getRequestParam('post_type', 'post') === 'page'
30
+				|| (
31
+					$post instanceof WP_Post
32
+					&& $post->post_type === 'page'
33
+				)
34
+			)
35
+			&& $this->request->getRequestParam('action') === 'edit';
36
+	}
37 37
 }
Please login to merge, or discard this patch.
entities/route_match/specifications/admin/EspressoEventEditorEdit.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
  */
15 15
 class EspressoEventEditorEdit extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since 4.9.71.p
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return $this->request->getRequestParam('page') === 'espresso_events'
26
-            && $this->request->getRequestParam('action') === 'edit';
27
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since 4.9.71.p
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return $this->request->getRequestParam('page') === 'espresso_events'
26
+			&& $this->request->getRequestParam('action') === 'edit';
27
+	}
28 28
 }
Please login to merge, or discard this patch.