@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * ------------------------------------------------------------------------ |
26 | 26 | */ |
27 | -abstract class EE_Onsite_Gateway extends EE_Gateway{ |
|
27 | +abstract class EE_Onsite_Gateway extends EE_Gateway { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @return EE_Onsite_Gateway |
@@ -53,5 +53,5 @@ discard block |
||
53 | 53 | * } unless a child class specifies these array keys are NOT present |
54 | 54 | * @return EE_Payment updated |
55 | 55 | */ |
56 | - public abstract function do_direct_payment($payment,$billing_info = null); |
|
56 | + public abstract function do_direct_payment($payment, $billing_info = null); |
|
57 | 57 | } |
@@ -2,10 +2,10 @@ |
||
2 | 2 | if (!defined('EVENT_ESPRESSO_VERSION')) |
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | - * payment_details_content |
|
6 | - * @var EE_Payment $payment |
|
7 | - * @var EE_Payment_Method $payment_method |
|
8 | - */ |
|
5 | + * payment_details_content |
|
6 | + * @var EE_Payment $payment |
|
7 | + * @var EE_Payment_Method $payment_method |
|
8 | + */ |
|
9 | 9 | $gateway_response = $payment->gateway_response(); |
10 | 10 | if ( ! empty( $gateway_response )) { |
11 | 11 | echo '<span class="error payment-problem">' . $gateway_response . '</span>'; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | 5 | * payment_details_content |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @var EE_Payment_Method $payment_method |
8 | 8 | */ |
9 | 9 | $gateway_response = $payment->gateway_response(); |
10 | -if ( ! empty( $gateway_response )) { |
|
11 | - echo '<span class="error payment-problem">' . $gateway_response . '</span>'; |
|
10 | +if ( ! empty($gateway_response)) { |
|
11 | + echo '<span class="error payment-problem">'.$gateway_response.'</span>'; |
|
12 | 12 | } |
13 | 13 | // End of file payment_details_content.template.php |
14 | 14 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | /** |
6 | 7 | * Event Espresso |
7 | 8 | * |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param array $setup_args an array of key value pairs of info for registering the component |
35 | 35 | * @return void |
36 | 36 | */ |
37 | - public static function register( $ID = NULL, $setup_args = array() ); |
|
37 | + public static function register($ID = NULL, $setup_args = array()); |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
@@ -45,5 +45,5 @@ discard block |
||
45 | 45 | * @param string $ID a unique name or ID for the component being registered |
46 | 46 | * @return void |
47 | 47 | */ |
48 | - public static function deregister( $ID = NULL ); |
|
48 | + public static function deregister($ID = NULL); |
|
49 | 49 | } |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * @subpackage plugin api, messages |
6 | 6 | * @since 4.5.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new message template pack variation for the EE messages system. |
@@ -18,30 +18,30 @@ discard block |
||
18 | 18 | class EE_Register_Admin_Page implements EEI_Plugin_API { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * Holds registered EE_Admin_Pages |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected static $_ee_admin_page_registry = array(); |
|
21 | + /** |
|
22 | + * Holds registered EE_Admin_Pages |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected static $_ee_admin_page_registry = array(); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE Admin Page loader system). |
|
32 | - * |
|
33 | - * @since 4.3.0 |
|
34 | - * |
|
30 | + /** |
|
31 | + * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE Admin Page loader system). |
|
32 | + * |
|
33 | + * @since 4.3.0 |
|
34 | + * |
|
35 | 35 | * @param string $page_basename This string represents the basename of the Admin Page init. |
36 | 36 | * The init file must use this basename in its name and class (i.e. {page_basename}_Admin_Page_Init.core.php). |
37 | - * @param array $config { An array of configuration options that will be used in different circumstances |
|
37 | + * @param array $config { An array of configuration options that will be used in different circumstances |
|
38 | 38 | * |
39 | 39 | * @type string $page_path This is the path where the registered admin pages reside ( used to setup autoloaders). |
40 | 40 | * |
41 | 41 | * } |
42 | - * @return void |
|
43 | - */ |
|
44 | - public static function register( $page_basename = NULL, $config = array() ) { |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public static function register( $page_basename = NULL, $config = array() ) { |
|
45 | 45 | |
46 | 46 | // check that an admin_page has not already been registered with that name |
47 | 47 | if ( isset(self::$_ee_admin_page_registry[ $page_basename ] )) { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_Admin__loaded' )) { |
62 | - EE_Error::doing_it_wrong( |
|
62 | + EE_Error::doing_it_wrong( |
|
63 | 63 | __METHOD__, |
64 | 64 | sprintf( |
65 | 65 | __('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time. Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.','event_espresso'), |
@@ -67,36 +67,36 @@ discard block |
||
67 | 67 | ), |
68 | 68 | '4.3' |
69 | 69 | ); |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | - //add incoming stuff to our registry property |
|
73 | - self::$_ee_admin_page_registry[ $page_basename ] = array( |
|
74 | - 'page_path' => $config['page_path'], |
|
75 | - 'config' => $config |
|
76 | - ); |
|
72 | + //add incoming stuff to our registry property |
|
73 | + self::$_ee_admin_page_registry[ $page_basename ] = array( |
|
74 | + 'page_path' => $config['page_path'], |
|
75 | + 'config' => $config |
|
76 | + ); |
|
77 | 77 | |
78 | - //add filters |
|
78 | + //add filters |
|
79 | 79 | |
80 | - add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 ); |
|
81 | - add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 ); |
|
80 | + add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 ); |
|
81 | + add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 ); |
|
82 | 82 | |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * This deregisters a EE_Admin page that is already registered. Note, this MUST be loaded after the |
|
89 | - * page being deregistered is loaded. |
|
90 | - * |
|
91 | - * @since 4.3.0 |
|
92 | - * |
|
93 | - * @param string $page_basename Use whatever string was used to register the admin page. |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - public static function deregister( $page_basename = NULL ) { |
|
97 | - if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | - unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
99 | - } |
|
87 | + /** |
|
88 | + * This deregisters a EE_Admin page that is already registered. Note, this MUST be loaded after the |
|
89 | + * page being deregistered is loaded. |
|
90 | + * |
|
91 | + * @since 4.3.0 |
|
92 | + * |
|
93 | + * @param string $page_basename Use whatever string was used to register the admin page. |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + public static function deregister( $page_basename = NULL ) { |
|
97 | + if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | + unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | 102 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | $installed_refs[ $basename ] = $args['page_path']; |
113 | 113 | } |
114 | 114 | } |
115 | - return $installed_refs; |
|
116 | - } |
|
115 | + return $installed_refs; |
|
116 | + } |
|
117 | 117 | |
118 | 118 | |
119 | 119 | |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | * @return mixed |
125 | 125 | */ |
126 | 126 | public static function set_page_path( $paths ) { |
127 | - foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
128 | - $paths[ $basename ] = $args['page_path']; |
|
129 | - } |
|
130 | - return $paths; |
|
131 | - } |
|
127 | + foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
128 | + $paths[ $basename ] = $args['page_path']; |
|
129 | + } |
|
130 | + return $paths; |
|
131 | + } |
|
132 | 132 | } |
@@ -41,28 +41,28 @@ discard block |
||
41 | 41 | * } |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - public static function register( $page_basename = NULL, $config = array() ) { |
|
44 | + public static function register($page_basename = NULL, $config = array()) { |
|
45 | 45 | |
46 | 46 | // check that an admin_page has not already been registered with that name |
47 | - if ( isset(self::$_ee_admin_page_registry[ $page_basename ] )) { |
|
48 | - throw new EE_Error( sprintf( __( 'An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', 'event_espresso' ), $page_basename )); |
|
47 | + if (isset(self::$_ee_admin_page_registry[$page_basename])) { |
|
48 | + throw new EE_Error(sprintf(__('An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', 'event_espresso'), $page_basename)); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // required fields MUST be present, so let's make sure they are. |
52 | - if ( empty( $page_basename ) || ! is_array( $config ) || empty( $config['page_path'] )) { |
|
53 | - throw new EE_Error( __( 'In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', 'event_espresso' )); |
|
52 | + if (empty($page_basename) || ! is_array($config) || empty($config['page_path'])) { |
|
53 | + throw new EE_Error(__('In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', 'event_espresso')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | //make sure we don't register twice |
57 | - if( isset( self::$_ee_admin_page_registry[ $page_basename ] ) ){ |
|
57 | + if (isset(self::$_ee_admin_page_registry[$page_basename])) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_Admin__loaded' )) { |
|
61 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
62 | 62 | EE_Error::doing_it_wrong( |
63 | 63 | __METHOD__, |
64 | 64 | sprintf( |
65 | - __('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time. Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.','event_espresso'), |
|
65 | + __('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time. Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.', 'event_espresso'), |
|
66 | 66 | $page_basename |
67 | 67 | ), |
68 | 68 | '4.3' |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | //add incoming stuff to our registry property |
73 | - self::$_ee_admin_page_registry[ $page_basename ] = array( |
|
73 | + self::$_ee_admin_page_registry[$page_basename] = array( |
|
74 | 74 | 'page_path' => $config['page_path'], |
75 | 75 | 'config' => $config |
76 | 76 | ); |
77 | 77 | |
78 | 78 | //add filters |
79 | 79 | |
80 | - add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 ); |
|
81 | - add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 ); |
|
80 | + add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array('EE_Register_Admin_Page', 'set_page_basename'), 10); |
|
81 | + add_filter('FHEE__EEH_Autoloader__load_admin_core', array('EE_Register_Admin_Page', 'set_page_path'), 10); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | * @param string $page_basename Use whatever string was used to register the admin page. |
94 | 94 | * @return void |
95 | 95 | */ |
96 | - public static function deregister( $page_basename = NULL ) { |
|
97 | - if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | - unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
96 | + public static function deregister($page_basename = NULL) { |
|
97 | + if ( ! empty(self::$_ee_admin_page_registry[$page_basename])) |
|
98 | + unset(self::$_ee_admin_page_registry[$page_basename]); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * @param $installed_refs |
107 | 107 | * @return mixed |
108 | 108 | */ |
109 | - public static function set_page_basename( $installed_refs ) { |
|
110 | - if ( ! empty( self::$_ee_admin_page_registry )) { |
|
111 | - foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
112 | - $installed_refs[ $basename ] = $args['page_path']; |
|
109 | + public static function set_page_basename($installed_refs) { |
|
110 | + if ( ! empty(self::$_ee_admin_page_registry)) { |
|
111 | + foreach (self::$_ee_admin_page_registry as $basename => $args) { |
|
112 | + $installed_refs[$basename] = $args['page_path']; |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | return $installed_refs; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | * @param $paths |
124 | 124 | * @return mixed |
125 | 125 | */ |
126 | - public static function set_page_path( $paths ) { |
|
127 | - foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
128 | - $paths[ $basename ] = $args['page_path']; |
|
126 | + public static function set_page_path($paths) { |
|
127 | + foreach (self::$_ee_admin_page_registry as $basename => $args) { |
|
128 | + $paths[$basename] = $args['page_path']; |
|
129 | 129 | } |
130 | 130 | return $paths; |
131 | 131 | } |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | * @subpackage helpers |
6 | 6 | * @since 4.3.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister an EE Admin Page. |
@@ -94,8 +96,9 @@ discard block |
||
94 | 96 | * @return void |
95 | 97 | */ |
96 | 98 | public static function deregister( $page_basename = NULL ) { |
97 | - if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | - unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
99 | + if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) { |
|
100 | + unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
101 | + } |
|
99 | 102 | } |
100 | 103 | |
101 | 104 |
@@ -66,33 +66,33 @@ discard block |
||
66 | 66 | * @throws EE_Error |
67 | 67 | * @return void |
68 | 68 | */ |
69 | - public static function register( $cpt_ref = NULL, $setup_args = array() ) { |
|
69 | + public static function register($cpt_ref = NULL, $setup_args = array()) { |
|
70 | 70 | |
71 | 71 | //check for requred params |
72 | - if ( empty( $cpt_ref ) ) { |
|
72 | + if (empty($cpt_ref)) { |
|
73 | 73 | throw new EE_Error( |
74 | - __('In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', 'event_espresso' ) |
|
74 | + __('In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', 'event_espresso') |
|
75 | 75 | ); |
76 | 76 | } |
77 | 77 | |
78 | - if ( ! is_array( $setup_args ) || ( empty( $setup_args['cpts'] ) && empty( $setup_args['cts'] ) ) ) { |
|
78 | + if ( ! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) { |
|
79 | 79 | throw new EE_Error( |
80 | - __( 'In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', 'event_espresso' ) |
|
80 | + __('In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', 'event_espresso') |
|
81 | 81 | ); |
82 | 82 | } |
83 | 83 | |
84 | 84 | //make sure we don't register twice |
85 | - if( isset( self::$_registry[ $cpt_ref ] ) ){ |
|
85 | + if (isset(self::$_registry[$cpt_ref])) { |
|
86 | 86 | return; |
87 | 87 | } |
88 | 88 | |
89 | 89 | //make sure cpt ref is unique. |
90 | - if ( isset( self::$_registry[$cpt_ref] ) ) { |
|
91 | - $cpt_ref = uniqid() . '_' . $cpt_ref; |
|
90 | + if (isset(self::$_registry[$cpt_ref])) { |
|
91 | + $cpt_ref = uniqid().'_'.$cpt_ref; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | //make sure this was called in the right place! |
95 | - if ( did_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ) ) { |
|
95 | + if (did_action('AHEE__EE_System__load_CPTs_and_session__complete')) { |
|
96 | 96 | EE_Error::doing_it_wrong( |
97 | 97 | __METHOD__, |
98 | 98 | sprintf( |
@@ -105,17 +105,17 @@ discard block |
||
105 | 105 | |
106 | 106 | //validate incoming args |
107 | 107 | $validated = array( |
108 | - 'cpts' => isset( $setup_args['cpts'] ) ? (array) $setup_args['cpts'] : array(), |
|
109 | - 'cts' => isset( $setup_args['cts'] ) ? (array) $setup_args['cts'] : array(), |
|
110 | - 'default_terms' => isset( $setup_args['default_terms'] ) ? (array) $setup_args['default_terms'] : array() |
|
108 | + 'cpts' => isset($setup_args['cpts']) ? (array) $setup_args['cpts'] : array(), |
|
109 | + 'cts' => isset($setup_args['cts']) ? (array) $setup_args['cts'] : array(), |
|
110 | + 'default_terms' => isset($setup_args['default_terms']) ? (array) $setup_args['default_terms'] : array() |
|
111 | 111 | ); |
112 | 112 | |
113 | 113 | self::$_registry[$cpt_ref] = $validated; |
114 | 114 | |
115 | 115 | //hook into to cpt system |
116 | - add_filter( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', array( __CLASS__, 'filter_cpts' ), 5 ); |
|
117 | - add_filter( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( __CLASS__, 'filter_cts' ), 5 ); |
|
118 | - add_action( 'AHEE__EE_Register_CPTs__construct_end', array( __CLASS__, 'default_terms'), 5 ); |
|
116 | + add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array(__CLASS__, 'filter_cpts'), 5); |
|
117 | + add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array(__CLASS__, 'filter_cts'), 5); |
|
118 | + add_action('AHEE__EE_Register_CPTs__construct_end', array(__CLASS__, 'default_terms'), 5); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array new array of cpts and their registration information |
131 | 131 | */ |
132 | - public static function filter_cpts( $cpts ) { |
|
133 | - foreach( self::$_registry as $registries ) { |
|
134 | - foreach ( $registries['cpts'] as $cpt_name => $cpt_settings ) { |
|
132 | + public static function filter_cpts($cpts) { |
|
133 | + foreach (self::$_registry as $registries) { |
|
134 | + foreach ($registries['cpts'] as $cpt_name => $cpt_settings) { |
|
135 | 135 | $cpts[$cpt_name] = $cpt_settings; |
136 | 136 | } |
137 | 137 | } |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return array new array of cts and their registration information. |
150 | 150 | */ |
151 | - public static function filter_cts( $cts ) { |
|
152 | - foreach( self::$_registry as $registries ) { |
|
153 | - foreach( $registries['cts'] as $ct_name => $ct_settings ) { |
|
151 | + public static function filter_cts($cts) { |
|
152 | + foreach (self::$_registry as $registries) { |
|
153 | + foreach ($registries['cts'] as $ct_name => $ct_settings) { |
|
154 | 154 | $cts[$ct_name] = $ct_settings; |
155 | 155 | } |
156 | 156 | } |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return void |
169 | 169 | */ |
170 | - public static function default_terms( EE_Register_CPTs $cpt_class ) { |
|
171 | - foreach( self::$_registry as $registries ) { |
|
172 | - foreach( $registries['default_terms'] as $taxonomy => $terms ) { |
|
173 | - foreach ( $terms as $term => $cpts ) { |
|
174 | - $cpt_class->set_default_term( $taxonomy, $term, $cpts ); |
|
170 | + public static function default_terms(EE_Register_CPTs $cpt_class) { |
|
171 | + foreach (self::$_registry as $registries) { |
|
172 | + foreach ($registries['default_terms'] as $taxonomy => $terms) { |
|
173 | + foreach ($terms as $term => $cpts) { |
|
174 | + $cpt_class->set_default_term($taxonomy, $term, $cpts); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | } |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @return void |
190 | 190 | */ |
191 | - public static function deregister( $cpt_ref = null ) { |
|
192 | - if ( !empty( self::$_registry[$cpt_ref] ) ) { |
|
193 | - unset( self::$_registry[$cpt_ref] ); |
|
191 | + public static function deregister($cpt_ref = null) { |
|
192 | + if ( ! empty(self::$_registry[$cpt_ref])) { |
|
193 | + unset(self::$_registry[$cpt_ref]); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } //end class EE_Register_CPT |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * @subpackage plugin api, messages |
6 | 6 | * @since 4.5.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new message template pack variation for the EE messages system. |
@@ -47,33 +47,33 @@ discard block |
||
47 | 47 | * @throws EE_Error |
48 | 48 | * @return void |
49 | 49 | */ |
50 | - public static function register( $cap_reference = NULL, $setup_args = array() ) { |
|
50 | + public static function register($cap_reference = NULL, $setup_args = array()) { |
|
51 | 51 | //required fields MUST be present, so let's make sure they are. |
52 | - if ( ! isset( $cap_reference ) || ! is_array( $setup_args ) || empty( $setup_args['capabilities'] ) ) { |
|
52 | + if ( ! isset($cap_reference) || ! is_array($setup_args) || empty($setup_args['capabilities'])) { |
|
53 | 53 | throw new EE_Error( |
54 | - __( 'In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', 'event_espresso' ) |
|
54 | + __('In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', 'event_espresso') |
|
55 | 55 | ); |
56 | 56 | } |
57 | 57 | //make sure we don't register twice |
58 | - if( isset( self::$_registry[ $cap_reference ] ) ){ |
|
58 | + if (isset(self::$_registry[$cap_reference])) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | //make sure this is not registered too late or too early. |
62 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' ) ) { |
|
63 | - EE_Error::doing_it_wrong( __METHOD__, sprintf( __('%s has been registered too late. Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', 'event_espresso'), $cap_reference ), '4.5.0' ); |
|
62 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) { |
|
63 | + EE_Error::doing_it_wrong(__METHOD__, sprintf(__('%s has been registered too late. Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', 'event_espresso'), $cap_reference), '4.5.0'); |
|
64 | 64 | } |
65 | 65 | //some preliminary sanitization and setting to the $_registry property |
66 | 66 | self::$_registry[$cap_reference] = array( |
67 | - 'caps' => isset( $setup_args['capabilities'] ) && is_array( $setup_args['capabilities'] ) ? $setup_args['capabilities'] : array(), |
|
68 | - 'cap_maps' => isset( $setup_args['capability_maps'] ) ? $setup_args['capability_maps'] : array() |
|
67 | + 'caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) ? $setup_args['capabilities'] : array(), |
|
68 | + 'cap_maps' => isset($setup_args['capability_maps']) ? $setup_args['capability_maps'] : array() |
|
69 | 69 | ); |
70 | 70 | //set initial caps (note that EE_Capabilities takes care of making sure that the caps get added only once) |
71 | - add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( 'EE_Register_Capabilities', 'register_capabilities' ), 10 ); |
|
71 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array('EE_Register_Capabilities', 'register_capabilities'), 10); |
|
72 | 72 | //add filter for cap maps |
73 | - add_filter( 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', array( 'EE_Register_Capabilities', 'register_cap_maps' ), 10 ); |
|
73 | + add_filter('FHEE__EE_Capabilities___set_meta_caps__meta_caps', array('EE_Register_Capabilities', 'register_cap_maps'), 10); |
|
74 | 74 | //init_role_caps to register new capabilities |
75 | - if ( is_admin() ) { |
|
76 | - EE_Registry::instance()->load_core( 'Capabilities' ); |
|
75 | + if (is_admin()) { |
|
76 | + EE_Registry::instance()->load_core('Capabilities'); |
|
77 | 77 | EE_Capabilities::instance()->init_caps(); |
78 | 78 | } |
79 | 79 | } |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return array merged in new caps. |
90 | 90 | */ |
91 | - public static function register_capabilities( $incoming_caps ) { |
|
92 | - foreach ( self::$_registry as $ref => $caps_and_cap_map ) { |
|
93 | - $incoming_caps = array_merge_recursive( $incoming_caps, $caps_and_cap_map[ 'caps' ] ); |
|
91 | + public static function register_capabilities($incoming_caps) { |
|
92 | + foreach (self::$_registry as $ref => $caps_and_cap_map) { |
|
93 | + $incoming_caps = array_merge_recursive($incoming_caps, $caps_and_cap_map['caps']); |
|
94 | 94 | } |
95 | 95 | return $incoming_caps; |
96 | 96 | } |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | * @return EE_Meta_Capability_Map[] |
106 | 106 | * @throws EE_Error |
107 | 107 | */ |
108 | - public static function register_cap_maps( $cap_maps ) { |
|
108 | + public static function register_cap_maps($cap_maps) { |
|
109 | 109 | //loop through and instantiate cap maps. |
110 | - foreach ( self::$_registry as $cap_reference => $setup ) { |
|
111 | - if ( ! isset( $setup['cap_maps'] ) ) { |
|
110 | + foreach (self::$_registry as $cap_reference => $setup) { |
|
111 | + if ( ! isset($setup['cap_maps'])) { |
|
112 | 112 | continue; |
113 | 113 | } |
114 | - foreach ( $setup['cap_maps'] as $cap_class => $args ) { |
|
114 | + foreach ($setup['cap_maps'] as $cap_class => $args) { |
|
115 | 115 | |
116 | 116 | /** |
117 | 117 | * account for cases where capability maps may be indexed |
@@ -138,19 +138,19 @@ discard block |
||
138 | 138 | * ... |
139 | 139 | * ) |
140 | 140 | */ |
141 | - if ( is_numeric( $cap_class ) ) { |
|
142 | - $cap_class = key( $args ); |
|
141 | + if (is_numeric($cap_class)) { |
|
142 | + $cap_class = key($args); |
|
143 | 143 | $args = $args[$cap_class]; |
144 | 144 | } |
145 | 145 | |
146 | - if ( ! class_exists( $cap_class ) ) { |
|
147 | - throw new EE_Error( sprintf( __( 'An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments', 'event_espresso' ), $cap_reference ) ); |
|
146 | + if ( ! class_exists($cap_class)) { |
|
147 | + throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments', 'event_espresso'), $cap_reference)); |
|
148 | 148 | } |
149 | 149 | |
150 | - if ( count( $args ) !== 2 ) { |
|
151 | - throw new EE_Error( sprintf( __('An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments. The array should have two values the first being a string and the second an array.', 'event_espresso' ), $cap_reference ) ); |
|
150 | + if (count($args) !== 2) { |
|
151 | + throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments. The array should have two values the first being a string and the second an array.', 'event_espresso'), $cap_reference)); |
|
152 | 152 | } |
153 | - $cap_maps[] = new $cap_class( $args[0], $args[1] ); |
|
153 | + $cap_maps[] = new $cap_class($args[0], $args[1]); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | return $cap_maps; |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | |
160 | 160 | |
161 | 161 | |
162 | - public static function deregister( $cap_reference = NULL ) { |
|
163 | - if ( !empty( self::$_registry[$cap_reference] ) ) { |
|
164 | - unset( self::$_registry[ $cap_reference ] ); |
|
162 | + public static function deregister($cap_reference = NULL) { |
|
163 | + if ( ! empty(self::$_registry[$cap_reference])) { |
|
164 | + unset(self::$_registry[$cap_reference]); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | //re init caps to grab the changes due to removed caps. |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * @subpackage plugin api, messages |
6 | 6 | * @since 4.5.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new message template pack variation for the EE messages system. |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | * @subpackage helpers |
6 | 6 | * @since 4.3.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new config with the EE_Registry::instance->CFG property. |
@@ -111,7 +113,8 @@ discard block |
||
111 | 113 | * @param mixed $config_class_name |
112 | 114 | */ |
113 | 115 | public static function deregister( $config_class_name = NULL ) { |
114 | - if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) |
|
115 | - unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
116 | + if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) { |
|
117 | + unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
118 | + } |
|
116 | 119 | } |
117 | 120 | } |
@@ -42,24 +42,24 @@ discard block |
||
42 | 42 | * } |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - public static function register( $config_class = NULL, $setup_args = array() ) { |
|
45 | + public static function register($config_class = NULL, $setup_args = array()) { |
|
46 | 46 | |
47 | - $setup_args['config_name'] = isset( $setup_args['config_name'] ) && ! empty( $setup_args['config_name'] ) ? $setup_args['config_name'] : $config_class; |
|
48 | - $setup_args['config_section'] = isset( $setup_args['config_section'] ) && ! empty( $setup_args['config_section'] ) ? $setup_args['config_section'] : 'addons'; |
|
47 | + $setup_args['config_name'] = isset($setup_args['config_name']) && ! empty($setup_args['config_name']) ? $setup_args['config_name'] : $config_class; |
|
48 | + $setup_args['config_section'] = isset($setup_args['config_section']) && ! empty($setup_args['config_section']) ? $setup_args['config_section'] : 'addons'; |
|
49 | 49 | |
50 | 50 | //required fields MUST be present, so let's make sure they are. |
51 | - if ( empty( $config_class ) || ! is_array( $setup_args ) || empty( $setup_args['config_name'] )) { |
|
52 | - throw new EE_Error( __( 'In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso' )); |
|
51 | + if (empty($config_class) || ! is_array($setup_args) || empty($setup_args['config_name'])) { |
|
52 | + throw new EE_Error(__('In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso')); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | //make sure we don't register twice |
56 | - if( isset( self::$_ee_config_registry[ $config_class ] ) ){ |
|
56 | + if (isset(self::$_ee_config_registry[$config_class])) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | //first find out if this happened too late. |
62 | - if ( did_action( 'AHEE__EE_System__load_core_configuration__begin' ) ) { |
|
62 | + if (did_action('AHEE__EE_System__load_core_configuration__begin')) { |
|
63 | 63 | EE_Error::doing_it_wrong( |
64 | 64 | __METHOD__, |
65 | 65 | sprintf( |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | ); |
71 | 71 | } |
72 | 72 | //add incoming stuff to our registry property |
73 | - self::$_ee_config_registry[ $config_class ] = array( |
|
73 | + self::$_ee_config_registry[$config_class] = array( |
|
74 | 74 | 'section' => $setup_args['config_section'], |
75 | 75 | 'name' => $setup_args['config_name'] |
76 | 76 | ); |
77 | 77 | |
78 | - add_action( 'AHEE__EE_Config___load_core_config__end', array( 'EE_Register_Config', 'set_config' ), 15, 1 ); |
|
79 | - add_action( 'AHEE__EE_Config__update_espresso_config__end', array( 'EE_Register_Config', 'set_config' ), 15, 1 ); |
|
78 | + add_action('AHEE__EE_Config___load_core_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
79 | + add_action('AHEE__EE_Config__update_espresso_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | * @param \EE_Config $EE_Config |
91 | 91 | * @return \StdClass |
92 | 92 | */ |
93 | - public static function set_config( EE_Config $EE_Config ) { |
|
94 | - foreach ( self::$_ee_config_registry as $config_class => $settings ) { |
|
93 | + public static function set_config(EE_Config $EE_Config) { |
|
94 | + foreach (self::$_ee_config_registry as $config_class => $settings) { |
|
95 | 95 | //first some validation of our incoming class_name. We'll throw an error early if its' not registered correctly |
96 | - if ( ! class_exists( $config_class )) { |
|
96 | + if ( ! class_exists($config_class)) { |
|
97 | 97 | throw new EE_Error( |
98 | 98 | sprintf( |
99 | - __( 'The "%s" config class can not be registered with EE_Config because it does not exist. Verify that an autoloader has been set for this class', 'event_espresso' ), |
|
99 | + __('The "%s" config class can not be registered with EE_Config because it does not exist. Verify that an autoloader has been set for this class', 'event_espresso'), |
|
100 | 100 | $config_class |
101 | 101 | ) |
102 | 102 | ); |
103 | 103 | } |
104 | - $EE_Config->get_config( $settings['section'], $settings['name'], $config_class ); |
|
104 | + $EE_Config->get_config($settings['section'], $settings['name'], $config_class); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * @param mixed $config_class_name |
113 | 113 | */ |
114 | - public static function deregister( $config_class_name = NULL ) { |
|
115 | - if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) |
|
116 | - unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
114 | + public static function deregister($config_class_name = NULL) { |
|
115 | + if ( ! empty(self::$_ee_config_registry[$config_class_name])) |
|
116 | + unset(self::$_ee_config_registry[$config_class_name]); |
|
117 | 117 | } |
118 | 118 | } |
@@ -113,6 +113,6 @@ |
||
113 | 113 | */ |
114 | 114 | public static function deregister( $config_class_name = NULL ) { |
115 | 115 | if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) |
116 | - unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
116 | + unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
117 | 117 | } |
118 | 118 | } |
@@ -45,32 +45,32 @@ discard block |
||
45 | 45 | * @throws EE_Error |
46 | 46 | * @return void |
47 | 47 | */ |
48 | - public static function register( $dms_id = NULL, $setup_args = array() ) { |
|
48 | + public static function register($dms_id = NULL, $setup_args = array()) { |
|
49 | 49 | |
50 | 50 | //required fields MUST be present, so let's make sure they are. |
51 | - if ( empty( $dms_id ) || ! is_array( $setup_args ) || empty( $setup_args['dms_paths'] )) { |
|
52 | - throw new EE_Error( __( 'In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include a "dms_id" (a unique identifier for this set of data migration scripts), and an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)', 'event_espresso' )); |
|
51 | + if (empty($dms_id) || ! is_array($setup_args) || empty($setup_args['dms_paths'])) { |
|
52 | + throw new EE_Error(__('In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include a "dms_id" (a unique identifier for this set of data migration scripts), and an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)', 'event_espresso')); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | //make sure we don't register twice |
56 | - if( isset( self::$_settings[ $dms_id ] ) ){ |
|
56 | + if (isset(self::$_settings[$dms_id])) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | 60 | //make sure this was called in the right place! |
61 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' )) { |
|
61 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) { |
|
62 | 62 | EE_Error::doing_it_wrong( |
63 | 63 | __METHOD__, |
64 | - __( 'An attempt to register Data Migration Scripts has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.','event_espresso'), |
|
64 | + __('An attempt to register Data Migration Scripts has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.', 'event_espresso'), |
|
65 | 65 | '4.3.0' |
66 | 66 | ); |
67 | 67 | } |
68 | 68 | //setup $_settings array from incoming values. |
69 | - self::$_settings[ $dms_id ] = array( |
|
70 | - 'dms_paths' =>isset( $setup_args['dms_paths'] ) ? (array)$setup_args['dms_paths'] : array() |
|
69 | + self::$_settings[$dms_id] = array( |
|
70 | + 'dms_paths' =>isset($setup_args['dms_paths']) ? (array) $setup_args['dms_paths'] : array() |
|
71 | 71 | ); |
72 | 72 | // setup DMS |
73 | - add_filter( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array( 'EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders' )); |
|
73 | + add_filter('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array('EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @param array $dms_paths |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - public static function add_data_migration_script_folders( $dms_paths = array() ){ |
|
84 | - foreach( self::$_settings as $settings ) { |
|
85 | - $dms_paths = array_merge( $dms_paths, $settings['dms_paths'] ); |
|
83 | + public static function add_data_migration_script_folders($dms_paths = array()) { |
|
84 | + foreach (self::$_settings as $settings) { |
|
85 | + $dms_paths = array_merge($dms_paths, $settings['dms_paths']); |
|
86 | 86 | } |
87 | 87 | return $dms_paths; |
88 | 88 | } |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * @param mixed $dms_id unique identifier for the set of Data Migration Scripts that were previously registered |
98 | 98 | * @return void |
99 | 99 | */ |
100 | - public static function deregister( $dms_id = NULL ) { |
|
101 | - if ( isset( self::$_settings[ $dms_id ] )) { |
|
102 | - unset( self::$_settings[ $dms_id ] ); |
|
100 | + public static function deregister($dms_id = NULL) { |
|
101 | + if (isset(self::$_settings[$dms_id])) { |
|
102 | + unset(self::$_settings[$dms_id]); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 |
@@ -62,44 +62,44 @@ discard block |
||
62 | 62 | * } |
63 | 63 | * @return void |
64 | 64 | */ |
65 | - public static function register( $name = NULL, $setup_args = array() ) { |
|
65 | + public static function register($name = NULL, $setup_args = array()) { |
|
66 | 66 | |
67 | 67 | //required fields MUST be present, so let's make sure they are. |
68 | - if ( empty( $name ) || ! is_array( $setup_args ) || empty( $setup_args['autoloadpaths'] ) ) { |
|
69 | - throw new EE_Error( __( 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso' ) ); |
|
68 | + if (empty($name) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) { |
|
69 | + throw new EE_Error(__('In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso')); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | //make sure we don't register twice |
73 | - if( isset( self::$_ee_messages_shortcode_registry[ $name ] ) ){ |
|
73 | + if (isset(self::$_ee_messages_shortcode_registry[$name])) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | 77 | //make sure this was called in the right place! |
78 | - if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) { |
|
79 | - EE_Error::doing_it_wrong(__METHOD__, sprintf( __('Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).','event_espresso'), $name ), '4.3.0' ); |
|
78 | + if ( ! did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) { |
|
79 | + EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).', 'event_espresso'), $name), '4.3.0'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | $name = (string) $name; |
83 | 83 | self::$_ee_messages_shortcode_registry[$name] = array( |
84 | 84 | 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
85 | - 'list_type_shortcodes' => !empty( $setup_args['list_type_shortcodes'] ) ? (array) $setup_args['list_type_shortcodes'] : array() |
|
85 | + 'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) ? (array) $setup_args['list_type_shortcodes'] : array() |
|
86 | 86 | ); |
87 | 87 | |
88 | 88 | //add filters |
89 | - add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 ); |
|
89 | + add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array('EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10); |
|
90 | 90 | |
91 | 91 | //add below filters if the required callback is provided. |
92 | - if ( !empty( $setup_args['msgr_validator_callback'] ) ) |
|
93 | - add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 ); |
|
92 | + if ( ! empty($setup_args['msgr_validator_callback'])) |
|
93 | + add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2); |
|
94 | 94 | |
95 | - if ( !empty( $setup_args['msgr_template_fields_callback'] ) ) |
|
96 | - add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 ); |
|
95 | + if ( ! empty($setup_args['msgr_template_fields_callback'])) |
|
96 | + add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2); |
|
97 | 97 | |
98 | - if ( !empty( $setup_args['valid_shortcodes_callback'] ) ) |
|
99 | - add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 ); |
|
98 | + if ( ! empty($setup_args['valid_shortcodes_callback'])) |
|
99 | + add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2); |
|
100 | 100 | |
101 | - if ( !empty( $setup_args['list_type_shortcodes'] ) ) |
|
102 | - add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 ); |
|
101 | + if ( ! empty($setup_args['list_type_shortcodes'])) |
|
102 | + add_filter('FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array('EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * @param string $name name used to register the shortcode library. |
113 | 113 | * @return void |
114 | 114 | */ |
115 | - public static function deregister( $name = NULL ) { |
|
116 | - if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) ) |
|
117 | - unset( self::$_ee_messages_shortcode_registry[$name] ); |
|
115 | + public static function deregister($name = NULL) { |
|
116 | + if ( ! empty(self::$_ee_messages_shortcode_registry[$name])) |
|
117 | + unset(self::$_ee_messages_shortcode_registry[$name]); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | * @param array $paths array of paths to be checked by EE_messages autoloader. |
128 | 128 | * @return array |
129 | 129 | */ |
130 | - public static function register_msgs_autoload_paths( $paths ) { |
|
130 | + public static function register_msgs_autoload_paths($paths) { |
|
131 | 131 | |
132 | - if ( !empty( self::$_ee_messages_shortcode_registry ) ) { |
|
133 | - foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) { |
|
134 | - if ( empty( $st_reg['autoloadpaths'] ) ) |
|
132 | + if ( ! empty(self::$_ee_messages_shortcode_registry)) { |
|
133 | + foreach (self::$_ee_messages_shortcode_registry as $st_reg) { |
|
134 | + if (empty($st_reg['autoloadpaths'])) |
|
135 | 135 | continue; |
136 | - $paths = array_merge( $paths, $st_reg['autoloadpaths'] ); |
|
136 | + $paths = array_merge($paths, $st_reg['autoloadpaths']); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | * @param array $original_shortcodes |
152 | 152 | * @return array Modifications to original shortcodes. |
153 | 153 | */ |
154 | - public static function register_list_type_shortcodes( $original_shortcodes ) { |
|
155 | - if ( empty( self::$_ee_messages_shortcode_registry ) ) |
|
154 | + public static function register_list_type_shortcodes($original_shortcodes) { |
|
155 | + if (empty(self::$_ee_messages_shortcode_registry)) |
|
156 | 156 | return $original_shortcodes; |
157 | 157 | |
158 | - foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) { |
|
159 | - if ( !empty( $sc_reg['list_type_shortcodes'] ) ) |
|
160 | - $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] ); |
|
158 | + foreach (self::$_ee_messages_shortcode_registry as $sc_reg) { |
|
159 | + if ( ! empty($sc_reg['list_type_shortcodes'])) |
|
160 | + $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | return $original_shortcodes; |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | * @subpackage plugin api, messages |
6 | 6 | * @since 4.3.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new shortcode library for the EE messages system. |
@@ -89,17 +91,21 @@ discard block |
||
89 | 91 | add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 ); |
90 | 92 | |
91 | 93 | //add below filters if the required callback is provided. |
92 | - if ( !empty( $setup_args['msgr_validator_callback'] ) ) |
|
93 | - add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 ); |
|
94 | + if ( !empty( $setup_args['msgr_validator_callback'] ) ) { |
|
95 | + add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 ); |
|
96 | + } |
|
94 | 97 | |
95 | - if ( !empty( $setup_args['msgr_template_fields_callback'] ) ) |
|
96 | - add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 ); |
|
98 | + if ( !empty( $setup_args['msgr_template_fields_callback'] ) ) { |
|
99 | + add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 ); |
|
100 | + } |
|
97 | 101 | |
98 | - if ( !empty( $setup_args['valid_shortcodes_callback'] ) ) |
|
99 | - add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 ); |
|
102 | + if ( !empty( $setup_args['valid_shortcodes_callback'] ) ) { |
|
103 | + add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 ); |
|
104 | + } |
|
100 | 105 | |
101 | - if ( !empty( $setup_args['list_type_shortcodes'] ) ) |
|
102 | - add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 ); |
|
106 | + if ( !empty( $setup_args['list_type_shortcodes'] ) ) { |
|
107 | + add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 ); |
|
108 | + } |
|
103 | 109 | } |
104 | 110 | |
105 | 111 | |
@@ -113,8 +119,9 @@ discard block |
||
113 | 119 | * @return void |
114 | 120 | */ |
115 | 121 | public static function deregister( $name = NULL ) { |
116 | - if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) ) |
|
117 | - unset( self::$_ee_messages_shortcode_registry[$name] ); |
|
122 | + if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) ) { |
|
123 | + unset( self::$_ee_messages_shortcode_registry[$name] ); |
|
124 | + } |
|
118 | 125 | } |
119 | 126 | |
120 | 127 | |
@@ -131,8 +138,9 @@ discard block |
||
131 | 138 | |
132 | 139 | if ( !empty( self::$_ee_messages_shortcode_registry ) ) { |
133 | 140 | foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) { |
134 | - if ( empty( $st_reg['autoloadpaths'] ) ) |
|
135 | - continue; |
|
141 | + if ( empty( $st_reg['autoloadpaths'] ) ) { |
|
142 | + continue; |
|
143 | + } |
|
136 | 144 | $paths = array_merge( $paths, $st_reg['autoloadpaths'] ); |
137 | 145 | } |
138 | 146 | } |
@@ -152,12 +160,14 @@ discard block |
||
152 | 160 | * @return array Modifications to original shortcodes. |
153 | 161 | */ |
154 | 162 | public static function register_list_type_shortcodes( $original_shortcodes ) { |
155 | - if ( empty( self::$_ee_messages_shortcode_registry ) ) |
|
156 | - return $original_shortcodes; |
|
163 | + if ( empty( self::$_ee_messages_shortcode_registry ) ) { |
|
164 | + return $original_shortcodes; |
|
165 | + } |
|
157 | 166 | |
158 | 167 | foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) { |
159 | - if ( !empty( $sc_reg['list_type_shortcodes'] ) ) |
|
160 | - $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] ); |
|
168 | + if ( !empty( $sc_reg['list_type_shortcodes'] ) ) { |
|
169 | + $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] ); |
|
170 | + } |
|
161 | 171 | } |
162 | 172 | |
163 | 173 | return $original_shortcodes; |
@@ -18,56 +18,56 @@ discard block |
||
18 | 18 | class EE_Register_Messages_Shortcode_Library implements EEI_Plugin_API { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * holds values for registered messages shortcode libraries |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected static $_ee_messages_shortcode_registry = array(); |
|
26 | - |
|
27 | - |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * Helper method for registring a new shortcodes library class for the messages system. |
|
32 | - * |
|
33 | - * Note this is not used for adding shortcodes to existing libraries. It's for registering anything |
|
34 | - * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class. |
|
35 | - * |
|
36 | - * @since 4.3.0 |
|
37 | - * |
|
38 | - * @param array $setup_args { |
|
39 | - * An array of arguments provided for registering the new messages shortcode library. |
|
40 | - * |
|
41 | - * @type string $name What is the name of this shortcode library |
|
42 | - * (e.g. 'question_list'); |
|
43 | - * @type array $autoloadpaths An array of paths to add to the messages |
|
44 | - * autoloader for the new shortcode library |
|
45 | - * class file. |
|
46 | - * @type string $msgr_validator_callback Callback for a method that will register the |
|
47 | - * library with the messenger |
|
48 | - * _validator_config. Optional. |
|
49 | - * @type string $msgr_template_fields_callback Callback for changing adding the |
|
50 | - * _template_fields property for messenger. |
|
51 | - * For example, the shortcode library may add |
|
52 | - * a new field to the message templates. |
|
53 | - * Optional. |
|
54 | - * @type string $valid_shortcodes_callback Callback for message types |
|
55 | - * _valid_shortcodes array setup. Optional. |
|
56 | - * @type array $list_type_shortcodes If there are any specific shortcodes with this |
|
57 | - * message shortcode library that should be |
|
58 | - * considered "list type" then include them in an |
|
59 | - * array. List Type shortcodes are shortcodes that |
|
60 | - * have a corresponding field that indicates how |
|
61 | - * they are parsed. Optional. |
|
62 | - * } |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - public static function register( $name = NULL, $setup_args = array() ) { |
|
66 | - |
|
67 | - //required fields MUST be present, so let's make sure they are. |
|
68 | - if ( empty( $name ) || ! is_array( $setup_args ) || empty( $setup_args['autoloadpaths'] ) ) { |
|
69 | - throw new EE_Error( __( 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso' ) ); |
|
70 | - } |
|
21 | + /** |
|
22 | + * holds values for registered messages shortcode libraries |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected static $_ee_messages_shortcode_registry = array(); |
|
26 | + |
|
27 | + |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * Helper method for registring a new shortcodes library class for the messages system. |
|
32 | + * |
|
33 | + * Note this is not used for adding shortcodes to existing libraries. It's for registering anything |
|
34 | + * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class. |
|
35 | + * |
|
36 | + * @since 4.3.0 |
|
37 | + * |
|
38 | + * @param array $setup_args { |
|
39 | + * An array of arguments provided for registering the new messages shortcode library. |
|
40 | + * |
|
41 | + * @type string $name What is the name of this shortcode library |
|
42 | + * (e.g. 'question_list'); |
|
43 | + * @type array $autoloadpaths An array of paths to add to the messages |
|
44 | + * autoloader for the new shortcode library |
|
45 | + * class file. |
|
46 | + * @type string $msgr_validator_callback Callback for a method that will register the |
|
47 | + * library with the messenger |
|
48 | + * _validator_config. Optional. |
|
49 | + * @type string $msgr_template_fields_callback Callback for changing adding the |
|
50 | + * _template_fields property for messenger. |
|
51 | + * For example, the shortcode library may add |
|
52 | + * a new field to the message templates. |
|
53 | + * Optional. |
|
54 | + * @type string $valid_shortcodes_callback Callback for message types |
|
55 | + * _valid_shortcodes array setup. Optional. |
|
56 | + * @type array $list_type_shortcodes If there are any specific shortcodes with this |
|
57 | + * message shortcode library that should be |
|
58 | + * considered "list type" then include them in an |
|
59 | + * array. List Type shortcodes are shortcodes that |
|
60 | + * have a corresponding field that indicates how |
|
61 | + * they are parsed. Optional. |
|
62 | + * } |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + public static function register( $name = NULL, $setup_args = array() ) { |
|
66 | + |
|
67 | + //required fields MUST be present, so let's make sure they are. |
|
68 | + if ( empty( $name ) || ! is_array( $setup_args ) || empty( $setup_args['autoloadpaths'] ) ) { |
|
69 | + throw new EE_Error( __( 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso' ) ); |
|
70 | + } |
|
71 | 71 | |
72 | 72 | //make sure we don't register twice |
73 | 73 | if( isset( self::$_ee_messages_shortcode_registry[ $name ] ) ){ |
@@ -79,88 +79,88 @@ discard block |
||
79 | 79 | EE_Error::doing_it_wrong(__METHOD__, sprintf( __('Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).','event_espresso'), $name ), '4.3.0' ); |
80 | 80 | } |
81 | 81 | |
82 | - $name = (string) $name; |
|
83 | - self::$_ee_messages_shortcode_registry[$name] = array( |
|
84 | - 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
85 | - 'list_type_shortcodes' => !empty( $setup_args['list_type_shortcodes'] ) ? (array) $setup_args['list_type_shortcodes'] : array() |
|
86 | - ); |
|
87 | - |
|
88 | - //add filters |
|
89 | - add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 ); |
|
90 | - |
|
91 | - //add below filters if the required callback is provided. |
|
92 | - if ( !empty( $setup_args['msgr_validator_callback'] ) ) |
|
93 | - add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 ); |
|
94 | - |
|
95 | - if ( !empty( $setup_args['msgr_template_fields_callback'] ) ) |
|
96 | - add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 ); |
|
97 | - |
|
98 | - if ( !empty( $setup_args['valid_shortcodes_callback'] ) ) |
|
99 | - add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 ); |
|
100 | - |
|
101 | - if ( !empty( $setup_args['list_type_shortcodes'] ) ) |
|
102 | - add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 ); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * This deregisters any messages shortcode library previously registered with the given name. |
|
110 | - * |
|
111 | - * @since 4.3.0 |
|
112 | - * @param string $name name used to register the shortcode library. |
|
113 | - * @return void |
|
114 | - */ |
|
115 | - public static function deregister( $name = NULL ) { |
|
116 | - if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) ) |
|
117 | - unset( self::$_ee_messages_shortcode_registry[$name] ); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
124 | - * |
|
125 | - * @since 4.3.0 |
|
126 | - * |
|
127 | - * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
128 | - * @return array |
|
129 | - */ |
|
130 | - public static function register_msgs_autoload_paths( $paths ) { |
|
131 | - |
|
132 | - if ( !empty( self::$_ee_messages_shortcode_registry ) ) { |
|
133 | - foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) { |
|
134 | - if ( empty( $st_reg['autoloadpaths'] ) ) |
|
135 | - continue; |
|
136 | - $paths = array_merge( $paths, $st_reg['autoloadpaths'] ); |
|
137 | - } |
|
138 | - } |
|
139 | - |
|
140 | - return $paths; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes |
|
147 | - * filter which is used to add additional list type shortcodes. |
|
148 | - * |
|
149 | - * @since 4.3.0 |
|
150 | - * |
|
151 | - * @param array $original_shortcodes |
|
152 | - * @return array Modifications to original shortcodes. |
|
153 | - */ |
|
154 | - public static function register_list_type_shortcodes( $original_shortcodes ) { |
|
155 | - if ( empty( self::$_ee_messages_shortcode_registry ) ) |
|
156 | - return $original_shortcodes; |
|
157 | - |
|
158 | - foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) { |
|
159 | - if ( !empty( $sc_reg['list_type_shortcodes'] ) ) |
|
160 | - $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] ); |
|
161 | - } |
|
162 | - |
|
163 | - return $original_shortcodes; |
|
164 | - } |
|
82 | + $name = (string) $name; |
|
83 | + self::$_ee_messages_shortcode_registry[$name] = array( |
|
84 | + 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
85 | + 'list_type_shortcodes' => !empty( $setup_args['list_type_shortcodes'] ) ? (array) $setup_args['list_type_shortcodes'] : array() |
|
86 | + ); |
|
87 | + |
|
88 | + //add filters |
|
89 | + add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 ); |
|
90 | + |
|
91 | + //add below filters if the required callback is provided. |
|
92 | + if ( !empty( $setup_args['msgr_validator_callback'] ) ) |
|
93 | + add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 ); |
|
94 | + |
|
95 | + if ( !empty( $setup_args['msgr_template_fields_callback'] ) ) |
|
96 | + add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 ); |
|
97 | + |
|
98 | + if ( !empty( $setup_args['valid_shortcodes_callback'] ) ) |
|
99 | + add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 ); |
|
100 | + |
|
101 | + if ( !empty( $setup_args['list_type_shortcodes'] ) ) |
|
102 | + add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 ); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * This deregisters any messages shortcode library previously registered with the given name. |
|
110 | + * |
|
111 | + * @since 4.3.0 |
|
112 | + * @param string $name name used to register the shortcode library. |
|
113 | + * @return void |
|
114 | + */ |
|
115 | + public static function deregister( $name = NULL ) { |
|
116 | + if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) ) |
|
117 | + unset( self::$_ee_messages_shortcode_registry[$name] ); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
124 | + * |
|
125 | + * @since 4.3.0 |
|
126 | + * |
|
127 | + * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
128 | + * @return array |
|
129 | + */ |
|
130 | + public static function register_msgs_autoload_paths( $paths ) { |
|
131 | + |
|
132 | + if ( !empty( self::$_ee_messages_shortcode_registry ) ) { |
|
133 | + foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) { |
|
134 | + if ( empty( $st_reg['autoloadpaths'] ) ) |
|
135 | + continue; |
|
136 | + $paths = array_merge( $paths, $st_reg['autoloadpaths'] ); |
|
137 | + } |
|
138 | + } |
|
139 | + |
|
140 | + return $paths; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes |
|
147 | + * filter which is used to add additional list type shortcodes. |
|
148 | + * |
|
149 | + * @since 4.3.0 |
|
150 | + * |
|
151 | + * @param array $original_shortcodes |
|
152 | + * @return array Modifications to original shortcodes. |
|
153 | + */ |
|
154 | + public static function register_list_type_shortcodes( $original_shortcodes ) { |
|
155 | + if ( empty( self::$_ee_messages_shortcode_registry ) ) |
|
156 | + return $original_shortcodes; |
|
157 | + |
|
158 | + foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) { |
|
159 | + if ( !empty( $sc_reg['list_type_shortcodes'] ) ) |
|
160 | + $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] ); |
|
161 | + } |
|
162 | + |
|
163 | + return $original_shortcodes; |
|
164 | + } |
|
165 | 165 | |
166 | 166 | } |