@@ -44,43 +44,43 @@ discard block |
||
| 44 | 44 | ); |
| 45 | 45 | $this->_wp_core_model = true; |
| 46 | 46 | $path_to_tax_model = 'Term_Taxonomy'; |
| 47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
| 48 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
| 47 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
| 48 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
| 49 | 49 | $path_to_tax_model |
| 50 | 50 | ); |
| 51 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
| 52 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
| 53 | - $path_to_tax_model = $path_to_tax_model . '.'; |
|
| 51 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
|
| 52 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
|
| 53 | + $path_to_tax_model = $path_to_tax_model.'.'; |
|
| 54 | 54 | // add cap restrictions for editing relating to the "ee_edit_*" |
| 55 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
| 55 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
| 56 | 56 | array( |
| 57 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
| 57 | + $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
| 58 | 58 | ) |
| 59 | 59 | ); |
| 60 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
| 60 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
| 61 | 61 | array( |
| 62 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
| 62 | + $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
| 63 | 63 | ) |
| 64 | 64 | ); |
| 65 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
| 65 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
| 66 | 66 | array( |
| 67 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
| 67 | + $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
| 68 | 68 | ) |
| 69 | 69 | ); |
| 70 | 70 | // add cap restrictions for deleting relating to the "ee_deleting_*" |
| 71 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
| 71 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
| 72 | 72 | array( |
| 73 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
| 73 | + $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
| 74 | 74 | ) |
| 75 | 75 | ); |
| 76 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
| 76 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
| 77 | 77 | array( |
| 78 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
| 78 | + $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
| 79 | 79 | ) |
| 80 | 80 | ); |
| 81 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
| 81 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
| 82 | 82 | array( |
| 83 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
| 83 | + $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
| 84 | 84 | ) |
| 85 | 85 | ); |
| 86 | 86 | parent::__construct($timezone); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | $post_tag_row = reset($post_tag_results); |
| 187 | 187 | $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
| 188 | - if (! $post_tag instanceof EE_Term) { |
|
| 188 | + if ( ! $post_tag instanceof EE_Term) { |
|
| 189 | 189 | return null; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -216,10 +216,10 @@ discard block |
||
| 216 | 216 | ) |
| 217 | 217 | ); |
| 218 | 218 | foreach ($post_tags as $key => $post_tag) { |
| 219 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
| 220 | - $post_tags[ $key ]->post_type = array(); |
|
| 219 | + if ( ! isset($post_tags[$key]->post_type)) { |
|
| 220 | + $post_tags[$key]->post_type = array(); |
|
| 221 | 221 | } |
| 222 | - $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
| 222 | + $post_tags[$key]->post_type[] = 'espresso_events'; |
|
| 223 | 223 | } |
| 224 | 224 | return $post_tags; |
| 225 | 225 | } |
@@ -244,10 +244,10 @@ discard block |
||
| 244 | 244 | ) |
| 245 | 245 | ); |
| 246 | 246 | foreach ($post_tags as $key => $post_tag) { |
| 247 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
| 248 | - $post_tags[ $key ]->post_type = array(); |
|
| 247 | + if ( ! isset($post_tags[$key]->post_type)) { |
|
| 248 | + $post_tags[$key]->post_type = array(); |
|
| 249 | 249 | } |
| 250 | - $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
| 250 | + $post_tags[$key]->post_type[] = 'espresso_venues'; |
|
| 251 | 251 | } |
| 252 | 252 | return $post_tags; |
| 253 | 253 | } |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | { |
| 268 | 268 | if ($model === EEM_Term::instance()) { |
| 269 | 269 | $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
| 270 | - if (! empty($taxonomies)) { |
|
| 270 | + if ( ! empty($taxonomies)) { |
|
| 271 | 271 | $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
| 272 | 272 | } |
| 273 | 273 | } |
@@ -13,263 +13,263 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class EEM_Term extends EEM_Base |
| 15 | 15 | { |
| 16 | - // private instance of the Attendee object |
|
| 17 | - protected static $_instance = null; |
|
| 16 | + // private instance of the Attendee object |
|
| 17 | + protected static $_instance = null; |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - *__construct |
|
| 23 | - * |
|
| 24 | - * @param string $timezone |
|
| 25 | - */ |
|
| 26 | - protected function __construct($timezone = null) |
|
| 27 | - { |
|
| 28 | - $this->singular_item = esc_html__('Term', 'event_espresso'); |
|
| 29 | - $this->plural_item = esc_html__('Terms', 'event_espresso'); |
|
| 30 | - $this->_tables = array( |
|
| 31 | - 'Term' => new EE_Primary_Table('terms', 'term_id'), |
|
| 32 | - ); |
|
| 33 | - $this->_fields = array( |
|
| 34 | - 'Term' => array( |
|
| 35 | - 'term_id' => new EE_Primary_Key_Int_Field('term_id', esc_html__('Term ID', 'event_espresso')), |
|
| 36 | - 'name' => new EE_Plain_Text_Field('name', esc_html__('Term Name', 'event_espresso'), false, ''), |
|
| 37 | - 'slug' => new EE_Slug_Field('slug', esc_html__('Term Slug', 'event_espresso'), false), |
|
| 38 | - 'term_group' => new EE_Integer_Field('term_group', esc_html__("Term Group", "event_espresso"), false, 0), |
|
| 39 | - ), |
|
| 40 | - ); |
|
| 41 | - $this->_model_relations = array( |
|
| 42 | - 'Term_Taxonomy' => new EE_Has_Many_Relation(), |
|
| 43 | - ); |
|
| 44 | - $this->_wp_core_model = true; |
|
| 45 | - $path_to_tax_model = 'Term_Taxonomy'; |
|
| 46 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
| 47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
| 48 | - $path_to_tax_model |
|
| 49 | - ); |
|
| 50 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
| 51 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
| 52 | - $path_to_tax_model = $path_to_tax_model . '.'; |
|
| 53 | - // add cap restrictions for editing relating to the "ee_edit_*" |
|
| 54 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
| 55 | - array( |
|
| 56 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
| 57 | - ) |
|
| 58 | - ); |
|
| 59 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
| 60 | - array( |
|
| 61 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
| 62 | - ) |
|
| 63 | - ); |
|
| 64 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
| 65 | - array( |
|
| 66 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
| 67 | - ) |
|
| 68 | - ); |
|
| 69 | - // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
| 70 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
| 71 | - array( |
|
| 72 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
| 73 | - ) |
|
| 74 | - ); |
|
| 75 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
| 76 | - array( |
|
| 77 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
| 78 | - ) |
|
| 79 | - ); |
|
| 80 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
| 81 | - array( |
|
| 82 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
| 83 | - ) |
|
| 84 | - ); |
|
| 85 | - parent::__construct($timezone); |
|
| 86 | - add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3); |
|
| 87 | - } |
|
| 21 | + /** |
|
| 22 | + *__construct |
|
| 23 | + * |
|
| 24 | + * @param string $timezone |
|
| 25 | + */ |
|
| 26 | + protected function __construct($timezone = null) |
|
| 27 | + { |
|
| 28 | + $this->singular_item = esc_html__('Term', 'event_espresso'); |
|
| 29 | + $this->plural_item = esc_html__('Terms', 'event_espresso'); |
|
| 30 | + $this->_tables = array( |
|
| 31 | + 'Term' => new EE_Primary_Table('terms', 'term_id'), |
|
| 32 | + ); |
|
| 33 | + $this->_fields = array( |
|
| 34 | + 'Term' => array( |
|
| 35 | + 'term_id' => new EE_Primary_Key_Int_Field('term_id', esc_html__('Term ID', 'event_espresso')), |
|
| 36 | + 'name' => new EE_Plain_Text_Field('name', esc_html__('Term Name', 'event_espresso'), false, ''), |
|
| 37 | + 'slug' => new EE_Slug_Field('slug', esc_html__('Term Slug', 'event_espresso'), false), |
|
| 38 | + 'term_group' => new EE_Integer_Field('term_group', esc_html__("Term Group", "event_espresso"), false, 0), |
|
| 39 | + ), |
|
| 40 | + ); |
|
| 41 | + $this->_model_relations = array( |
|
| 42 | + 'Term_Taxonomy' => new EE_Has_Many_Relation(), |
|
| 43 | + ); |
|
| 44 | + $this->_wp_core_model = true; |
|
| 45 | + $path_to_tax_model = 'Term_Taxonomy'; |
|
| 46 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
| 47 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
| 48 | + $path_to_tax_model |
|
| 49 | + ); |
|
| 50 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
| 51 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
| 52 | + $path_to_tax_model = $path_to_tax_model . '.'; |
|
| 53 | + // add cap restrictions for editing relating to the "ee_edit_*" |
|
| 54 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
| 55 | + array( |
|
| 56 | + $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
| 57 | + ) |
|
| 58 | + ); |
|
| 59 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
| 60 | + array( |
|
| 61 | + $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
| 62 | + ) |
|
| 63 | + ); |
|
| 64 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
| 65 | + array( |
|
| 66 | + $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
| 67 | + ) |
|
| 68 | + ); |
|
| 69 | + // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
| 70 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
| 71 | + array( |
|
| 72 | + $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
| 73 | + ) |
|
| 74 | + ); |
|
| 75 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
| 76 | + array( |
|
| 77 | + $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
| 78 | + ) |
|
| 79 | + ); |
|
| 80 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
| 81 | + array( |
|
| 82 | + $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
| 83 | + ) |
|
| 84 | + ); |
|
| 85 | + parent::__construct($timezone); |
|
| 86 | + add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * retrieves a list of all EE event categories |
|
| 93 | - * |
|
| 94 | - * @access public |
|
| 95 | - * @param bool $show_uncategorized |
|
| 96 | - * @return \EE_Base_Class[] |
|
| 97 | - */ |
|
| 98 | - public function get_all_ee_categories($show_uncategorized = false) |
|
| 99 | - { |
|
| 100 | - $where_params = array( |
|
| 101 | - 'Term_Taxonomy.taxonomy' => 'espresso_event_categories', |
|
| 102 | - 'NOT' => array('name' => esc_html__('Uncategorized', 'event_espresso')), |
|
| 103 | - ); |
|
| 104 | - if ($show_uncategorized) { |
|
| 105 | - unset($where_params['NOT']); |
|
| 106 | - } |
|
| 107 | - return EEM_Term::instance()->get_all( |
|
| 108 | - array( |
|
| 109 | - $where_params, |
|
| 110 | - 'order_by' => array('name' => 'ASC'), |
|
| 111 | - ) |
|
| 112 | - ); |
|
| 113 | - } |
|
| 91 | + /** |
|
| 92 | + * retrieves a list of all EE event categories |
|
| 93 | + * |
|
| 94 | + * @access public |
|
| 95 | + * @param bool $show_uncategorized |
|
| 96 | + * @return \EE_Base_Class[] |
|
| 97 | + */ |
|
| 98 | + public function get_all_ee_categories($show_uncategorized = false) |
|
| 99 | + { |
|
| 100 | + $where_params = array( |
|
| 101 | + 'Term_Taxonomy.taxonomy' => 'espresso_event_categories', |
|
| 102 | + 'NOT' => array('name' => esc_html__('Uncategorized', 'event_espresso')), |
|
| 103 | + ); |
|
| 104 | + if ($show_uncategorized) { |
|
| 105 | + unset($where_params['NOT']); |
|
| 106 | + } |
|
| 107 | + return EEM_Term::instance()->get_all( |
|
| 108 | + array( |
|
| 109 | + $where_params, |
|
| 110 | + 'order_by' => array('name' => 'ASC'), |
|
| 111 | + ) |
|
| 112 | + ); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * retrieves a list of all post_tags associated with an EE CPT |
|
| 119 | - * |
|
| 120 | - * @access public |
|
| 121 | - * @param string $post_type |
|
| 122 | - * @return array |
|
| 123 | - */ |
|
| 124 | - public function get_all_CPT_post_tags($post_type = '') |
|
| 125 | - { |
|
| 126 | - switch ($post_type) { |
|
| 127 | - case 'espresso_events': |
|
| 128 | - return $this->get_all_event_post_tags(); |
|
| 129 | - break; |
|
| 130 | - case 'espresso_venues': |
|
| 131 | - return $this->get_all_venue_post_tags(); |
|
| 132 | - break; |
|
| 133 | - default: |
|
| 134 | - $event_tags = $this->get_all_event_post_tags(); |
|
| 135 | - $venue_tags = $this->get_all_venue_post_tags(); |
|
| 136 | - return array_merge($event_tags, $venue_tags); |
|
| 137 | - } |
|
| 138 | - } |
|
| 117 | + /** |
|
| 118 | + * retrieves a list of all post_tags associated with an EE CPT |
|
| 119 | + * |
|
| 120 | + * @access public |
|
| 121 | + * @param string $post_type |
|
| 122 | + * @return array |
|
| 123 | + */ |
|
| 124 | + public function get_all_CPT_post_tags($post_type = '') |
|
| 125 | + { |
|
| 126 | + switch ($post_type) { |
|
| 127 | + case 'espresso_events': |
|
| 128 | + return $this->get_all_event_post_tags(); |
|
| 129 | + break; |
|
| 130 | + case 'espresso_venues': |
|
| 131 | + return $this->get_all_venue_post_tags(); |
|
| 132 | + break; |
|
| 133 | + default: |
|
| 134 | + $event_tags = $this->get_all_event_post_tags(); |
|
| 135 | + $venue_tags = $this->get_all_venue_post_tags(); |
|
| 136 | + return array_merge($event_tags, $venue_tags); |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * returns an EE_Term object for the given tag |
|
| 143 | - * if it has been utilized by any EE_Events or EE_Venues |
|
| 144 | - * |
|
| 145 | - * @param string $tag |
|
| 146 | - * @return EE_Term|null |
|
| 147 | - * @throws EE_Error |
|
| 148 | - * @throws InvalidArgumentException |
|
| 149 | - * @throws InvalidDataTypeException |
|
| 150 | - * @throws InvalidInterfaceException |
|
| 151 | - */ |
|
| 152 | - public function get_post_tag_for_event_or_venue($tag) |
|
| 153 | - { |
|
| 154 | - $post_tag_results = $this->get_all_wpdb_results( |
|
| 155 | - array( |
|
| 156 | - array( |
|
| 157 | - 'slug' => $tag, |
|
| 158 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
| 159 | - 'OR' => array( |
|
| 160 | - 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
| 161 | - 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
| 162 | - ), |
|
| 163 | - ), |
|
| 164 | - 'default_where_conditions' => 'none', |
|
| 165 | - 'extra_selects' => array( |
|
| 166 | - 'event_post_type' => array('Term_Taxonomy___Event_CPT.post_type', '%s'), |
|
| 167 | - 'venue_post_type' => array('Term_Taxonomy___Venue_CPT.post_type', '%s') |
|
| 168 | - ), |
|
| 169 | - 'group_by' => array( |
|
| 170 | - 'event_post_type', |
|
| 171 | - 'venue_post_type', |
|
| 172 | - ), |
|
| 173 | - 'limit' => 2 |
|
| 174 | - ) |
|
| 175 | - ); |
|
| 141 | + /** |
|
| 142 | + * returns an EE_Term object for the given tag |
|
| 143 | + * if it has been utilized by any EE_Events or EE_Venues |
|
| 144 | + * |
|
| 145 | + * @param string $tag |
|
| 146 | + * @return EE_Term|null |
|
| 147 | + * @throws EE_Error |
|
| 148 | + * @throws InvalidArgumentException |
|
| 149 | + * @throws InvalidDataTypeException |
|
| 150 | + * @throws InvalidInterfaceException |
|
| 151 | + */ |
|
| 152 | + public function get_post_tag_for_event_or_venue($tag) |
|
| 153 | + { |
|
| 154 | + $post_tag_results = $this->get_all_wpdb_results( |
|
| 155 | + array( |
|
| 156 | + array( |
|
| 157 | + 'slug' => $tag, |
|
| 158 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
| 159 | + 'OR' => array( |
|
| 160 | + 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
| 161 | + 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
| 162 | + ), |
|
| 163 | + ), |
|
| 164 | + 'default_where_conditions' => 'none', |
|
| 165 | + 'extra_selects' => array( |
|
| 166 | + 'event_post_type' => array('Term_Taxonomy___Event_CPT.post_type', '%s'), |
|
| 167 | + 'venue_post_type' => array('Term_Taxonomy___Venue_CPT.post_type', '%s') |
|
| 168 | + ), |
|
| 169 | + 'group_by' => array( |
|
| 170 | + 'event_post_type', |
|
| 171 | + 'venue_post_type', |
|
| 172 | + ), |
|
| 173 | + 'limit' => 2 |
|
| 174 | + ) |
|
| 175 | + ); |
|
| 176 | 176 | |
| 177 | - $post_types = array(); |
|
| 178 | - foreach ((array) $post_tag_results as $row) { |
|
| 179 | - if ($row['event_post_type'] === 'espresso_events') { |
|
| 180 | - $post_types[] = EEM_Event::instance()->post_type(); |
|
| 181 | - } elseif ($row['venue_post_type'] === 'espresso_venues') { |
|
| 182 | - $post_types[] = EEM_Venue::instance()->post_type(); |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - $post_tag_row = reset($post_tag_results); |
|
| 186 | - $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
|
| 187 | - if (! $post_tag instanceof EE_Term) { |
|
| 188 | - return null; |
|
| 189 | - } |
|
| 177 | + $post_types = array(); |
|
| 178 | + foreach ((array) $post_tag_results as $row) { |
|
| 179 | + if ($row['event_post_type'] === 'espresso_events') { |
|
| 180 | + $post_types[] = EEM_Event::instance()->post_type(); |
|
| 181 | + } elseif ($row['venue_post_type'] === 'espresso_venues') { |
|
| 182 | + $post_types[] = EEM_Venue::instance()->post_type(); |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + $post_tag_row = reset($post_tag_results); |
|
| 186 | + $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
|
| 187 | + if (! $post_tag instanceof EE_Term) { |
|
| 188 | + return null; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - if ($post_tag->post_type === null) { |
|
| 192 | - $post_tag->post_type = array(); |
|
| 193 | - } |
|
| 194 | - $post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types)); |
|
| 195 | - return $post_tag; |
|
| 196 | - } |
|
| 191 | + if ($post_tag->post_type === null) { |
|
| 192 | + $post_tag->post_type = array(); |
|
| 193 | + } |
|
| 194 | + $post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types)); |
|
| 195 | + return $post_tag; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | |
| 200 | - /** |
|
| 201 | - * get_all_event_post_tags |
|
| 202 | - * |
|
| 203 | - * @return EE_Base_Class[] |
|
| 204 | - */ |
|
| 205 | - public function get_all_event_post_tags() |
|
| 206 | - { |
|
| 207 | - $post_tags = EEM_Term::instance()->get_all( |
|
| 208 | - array( |
|
| 209 | - array( |
|
| 210 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
| 211 | - 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
| 212 | - ), |
|
| 213 | - 'order_by' => array('name' => 'ASC'), |
|
| 214 | - 'force_join' => array('Term_Taxonomy.Event'), |
|
| 215 | - ) |
|
| 216 | - ); |
|
| 217 | - foreach ($post_tags as $key => $post_tag) { |
|
| 218 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
| 219 | - $post_tags[ $key ]->post_type = array(); |
|
| 220 | - } |
|
| 221 | - $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
| 222 | - } |
|
| 223 | - return $post_tags; |
|
| 224 | - } |
|
| 200 | + /** |
|
| 201 | + * get_all_event_post_tags |
|
| 202 | + * |
|
| 203 | + * @return EE_Base_Class[] |
|
| 204 | + */ |
|
| 205 | + public function get_all_event_post_tags() |
|
| 206 | + { |
|
| 207 | + $post_tags = EEM_Term::instance()->get_all( |
|
| 208 | + array( |
|
| 209 | + array( |
|
| 210 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
| 211 | + 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
| 212 | + ), |
|
| 213 | + 'order_by' => array('name' => 'ASC'), |
|
| 214 | + 'force_join' => array('Term_Taxonomy.Event'), |
|
| 215 | + ) |
|
| 216 | + ); |
|
| 217 | + foreach ($post_tags as $key => $post_tag) { |
|
| 218 | + if (! isset($post_tags[ $key ]->post_type)) { |
|
| 219 | + $post_tags[ $key ]->post_type = array(); |
|
| 220 | + } |
|
| 221 | + $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
| 222 | + } |
|
| 223 | + return $post_tags; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | 226 | |
| 227 | 227 | |
| 228 | - /** |
|
| 229 | - * get_all_venue_post_tags |
|
| 230 | - * |
|
| 231 | - * @return EE_Base_Class[] |
|
| 232 | - */ |
|
| 233 | - public function get_all_venue_post_tags() |
|
| 234 | - { |
|
| 235 | - $post_tags = EEM_Term::instance()->get_all( |
|
| 236 | - array( |
|
| 237 | - array( |
|
| 238 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
| 239 | - 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
| 240 | - ), |
|
| 241 | - 'order_by' => array('name' => 'ASC'), |
|
| 242 | - 'force_join' => array('Term_Taxonomy'), |
|
| 243 | - ) |
|
| 244 | - ); |
|
| 245 | - foreach ($post_tags as $key => $post_tag) { |
|
| 246 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
| 247 | - $post_tags[ $key ]->post_type = array(); |
|
| 248 | - } |
|
| 249 | - $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
| 250 | - } |
|
| 251 | - return $post_tags; |
|
| 252 | - } |
|
| 228 | + /** |
|
| 229 | + * get_all_venue_post_tags |
|
| 230 | + * |
|
| 231 | + * @return EE_Base_Class[] |
|
| 232 | + */ |
|
| 233 | + public function get_all_venue_post_tags() |
|
| 234 | + { |
|
| 235 | + $post_tags = EEM_Term::instance()->get_all( |
|
| 236 | + array( |
|
| 237 | + array( |
|
| 238 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
| 239 | + 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
| 240 | + ), |
|
| 241 | + 'order_by' => array('name' => 'ASC'), |
|
| 242 | + 'force_join' => array('Term_Taxonomy'), |
|
| 243 | + ) |
|
| 244 | + ); |
|
| 245 | + foreach ($post_tags as $key => $post_tag) { |
|
| 246 | + if (! isset($post_tags[ $key ]->post_type)) { |
|
| 247 | + $post_tags[ $key ]->post_type = array(); |
|
| 248 | + } |
|
| 249 | + $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
| 250 | + } |
|
| 251 | + return $post_tags; |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | 254 | |
| 255 | 255 | |
| 256 | - /** |
|
| 257 | - * Makes sure that during REST API queries, we only return terms |
|
| 258 | - * for term taxonomies which should be shown in the rest api |
|
| 259 | - * |
|
| 260 | - * @param array $model_query_params |
|
| 261 | - * @param array $querystring_query_params |
|
| 262 | - * @param EEM_Base $model |
|
| 263 | - * @return array |
|
| 264 | - */ |
|
| 265 | - public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
| 266 | - { |
|
| 267 | - if ($model === EEM_Term::instance()) { |
|
| 268 | - $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
| 269 | - if (! empty($taxonomies)) { |
|
| 270 | - $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
| 271 | - } |
|
| 272 | - } |
|
| 273 | - return $model_query_params; |
|
| 274 | - } |
|
| 256 | + /** |
|
| 257 | + * Makes sure that during REST API queries, we only return terms |
|
| 258 | + * for term taxonomies which should be shown in the rest api |
|
| 259 | + * |
|
| 260 | + * @param array $model_query_params |
|
| 261 | + * @param array $querystring_query_params |
|
| 262 | + * @param EEM_Base $model |
|
| 263 | + * @return array |
|
| 264 | + */ |
|
| 265 | + public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
| 266 | + { |
|
| 267 | + if ($model === EEM_Term::instance()) { |
|
| 268 | + $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
| 269 | + if (! empty($taxonomies)) { |
|
| 270 | + $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | + return $model_query_params; |
|
| 274 | + } |
|
| 275 | 275 | } |
@@ -14,80 +14,80 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class EE_Country_Select_Input extends EE_Select_Input |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * $input_settings key used for detecting the "get" option |
|
| 19 | - */ |
|
| 20 | - const OPTION_GET_KEY = 'get'; |
|
| 17 | + /** |
|
| 18 | + * $input_settings key used for detecting the "get" option |
|
| 19 | + */ |
|
| 20 | + const OPTION_GET_KEY = 'get'; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * indicates that ALL countries should be retrieved from the db for the input |
|
| 24 | - */ |
|
| 25 | - const OPTION_GET_ALL = 'all'; |
|
| 22 | + /** |
|
| 23 | + * indicates that ALL countries should be retrieved from the db for the input |
|
| 24 | + */ |
|
| 25 | + const OPTION_GET_ALL = 'all'; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * indicates that only ACTIVE countries should be retrieved from the db for the input |
|
| 29 | - */ |
|
| 30 | - const OPTION_GET_ACTIVE = 'active'; |
|
| 27 | + /** |
|
| 28 | + * indicates that only ACTIVE countries should be retrieved from the db for the input |
|
| 29 | + */ |
|
| 30 | + const OPTION_GET_ACTIVE = 'active'; |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param array $country_options |
|
| 35 | - * @param array $input_settings |
|
| 36 | - * @throws EE_Error |
|
| 37 | - * @throws InvalidArgumentException |
|
| 38 | - * @throws InvalidDataTypeException |
|
| 39 | - * @throws InvalidInterfaceException |
|
| 40 | - * @throws ReflectionException |
|
| 41 | - */ |
|
| 42 | - public function __construct($country_options = null, $input_settings = array()) |
|
| 43 | - { |
|
| 44 | - $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
| 45 | - ? $input_settings[ self::OPTION_GET_KEY ] |
|
| 46 | - : self::OPTION_GET_ACTIVE; |
|
| 47 | - $country_options = apply_filters( |
|
| 48 | - 'FHEE__EE_Country_Select_Input____construct__country_options', |
|
| 49 | - $this->get_country_answer_options($country_options, $get), |
|
| 50 | - $this, |
|
| 51 | - $get |
|
| 52 | - ); |
|
| 53 | - $input_settings['html_class'] = isset($input_settings['html_class']) |
|
| 54 | - ? $input_settings['html_class'] . ' ee-country-select-js' |
|
| 55 | - : 'ee-country-select-js'; |
|
| 56 | - parent::__construct($country_options, $input_settings); |
|
| 57 | - } |
|
| 33 | + /** |
|
| 34 | + * @param array $country_options |
|
| 35 | + * @param array $input_settings |
|
| 36 | + * @throws EE_Error |
|
| 37 | + * @throws InvalidArgumentException |
|
| 38 | + * @throws InvalidDataTypeException |
|
| 39 | + * @throws InvalidInterfaceException |
|
| 40 | + * @throws ReflectionException |
|
| 41 | + */ |
|
| 42 | + public function __construct($country_options = null, $input_settings = array()) |
|
| 43 | + { |
|
| 44 | + $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
| 45 | + ? $input_settings[ self::OPTION_GET_KEY ] |
|
| 46 | + : self::OPTION_GET_ACTIVE; |
|
| 47 | + $country_options = apply_filters( |
|
| 48 | + 'FHEE__EE_Country_Select_Input____construct__country_options', |
|
| 49 | + $this->get_country_answer_options($country_options, $get), |
|
| 50 | + $this, |
|
| 51 | + $get |
|
| 52 | + ); |
|
| 53 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
| 54 | + ? $input_settings['html_class'] . ' ee-country-select-js' |
|
| 55 | + : 'ee-country-select-js'; |
|
| 56 | + parent::__construct($country_options, $input_settings); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * get_country_answer_options |
|
| 62 | - * |
|
| 63 | - * @param array $country_options |
|
| 64 | - * @param string $get |
|
| 65 | - * @return array |
|
| 66 | - * @throws EE_Error |
|
| 67 | - * @throws InvalidArgumentException |
|
| 68 | - * @throws ReflectionException |
|
| 69 | - * @throws InvalidDataTypeException |
|
| 70 | - * @throws InvalidInterfaceException |
|
| 71 | - */ |
|
| 72 | - public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
|
| 73 | - { |
|
| 74 | - // if passed something that is NOT an array |
|
| 75 | - if (! is_array($country_options)) { |
|
| 76 | - // get possibly cached list of countries |
|
| 77 | - $countries = $get === self::OPTION_GET_ALL |
|
| 78 | - ? EEM_Country::instance()->get_all_countries() |
|
| 79 | - : EEM_Country::instance()->get_all_active_countries(); |
|
| 80 | - if (! empty($countries)) { |
|
| 81 | - $country_options[''] = ''; |
|
| 82 | - foreach ($countries as $country) { |
|
| 83 | - if ($country instanceof EE_Country) { |
|
| 84 | - $country_options[ $country->ID() ] = $country->name(); |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - } else { |
|
| 88 | - $country_options = array(); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - return $country_options; |
|
| 92 | - } |
|
| 60 | + /** |
|
| 61 | + * get_country_answer_options |
|
| 62 | + * |
|
| 63 | + * @param array $country_options |
|
| 64 | + * @param string $get |
|
| 65 | + * @return array |
|
| 66 | + * @throws EE_Error |
|
| 67 | + * @throws InvalidArgumentException |
|
| 68 | + * @throws ReflectionException |
|
| 69 | + * @throws InvalidDataTypeException |
|
| 70 | + * @throws InvalidInterfaceException |
|
| 71 | + */ |
|
| 72 | + public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
|
| 73 | + { |
|
| 74 | + // if passed something that is NOT an array |
|
| 75 | + if (! is_array($country_options)) { |
|
| 76 | + // get possibly cached list of countries |
|
| 77 | + $countries = $get === self::OPTION_GET_ALL |
|
| 78 | + ? EEM_Country::instance()->get_all_countries() |
|
| 79 | + : EEM_Country::instance()->get_all_active_countries(); |
|
| 80 | + if (! empty($countries)) { |
|
| 81 | + $country_options[''] = ''; |
|
| 82 | + foreach ($countries as $country) { |
|
| 83 | + if ($country instanceof EE_Country) { |
|
| 84 | + $country_options[ $country->ID() ] = $country->name(); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + } else { |
|
| 88 | + $country_options = array(); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + return $country_options; |
|
| 92 | + } |
|
| 93 | 93 | } |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function __construct($country_options = null, $input_settings = array()) |
| 43 | 43 | { |
| 44 | - $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
| 45 | - ? $input_settings[ self::OPTION_GET_KEY ] |
|
| 44 | + $get = isset($input_settings[self::OPTION_GET_KEY]) |
|
| 45 | + ? $input_settings[self::OPTION_GET_KEY] |
|
| 46 | 46 | : self::OPTION_GET_ACTIVE; |
| 47 | 47 | $country_options = apply_filters( |
| 48 | 48 | 'FHEE__EE_Country_Select_Input____construct__country_options', |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $get |
| 52 | 52 | ); |
| 53 | 53 | $input_settings['html_class'] = isset($input_settings['html_class']) |
| 54 | - ? $input_settings['html_class'] . ' ee-country-select-js' |
|
| 54 | + ? $input_settings['html_class'].' ee-country-select-js' |
|
| 55 | 55 | : 'ee-country-select-js'; |
| 56 | 56 | parent::__construct($country_options, $input_settings); |
| 57 | 57 | } |
@@ -72,16 +72,16 @@ discard block |
||
| 72 | 72 | public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
| 73 | 73 | { |
| 74 | 74 | // if passed something that is NOT an array |
| 75 | - if (! is_array($country_options)) { |
|
| 75 | + if ( ! is_array($country_options)) { |
|
| 76 | 76 | // get possibly cached list of countries |
| 77 | 77 | $countries = $get === self::OPTION_GET_ALL |
| 78 | 78 | ? EEM_Country::instance()->get_all_countries() |
| 79 | 79 | : EEM_Country::instance()->get_all_active_countries(); |
| 80 | - if (! empty($countries)) { |
|
| 80 | + if ( ! empty($countries)) { |
|
| 81 | 81 | $country_options[''] = ''; |
| 82 | 82 | foreach ($countries as $country) { |
| 83 | 83 | if ($country instanceof EE_Country) { |
| 84 | - $country_options[ $country->ID() ] = $country->name(); |
|
| 84 | + $country_options[$country->ID()] = $country->name(); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } else { |
@@ -14,8 +14,8 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class AnyFrontendRequest extends RouteMatchSpecification |
| 16 | 16 | { |
| 17 | - public function isMatchingRoute() |
|
| 18 | - { |
|
| 19 | - return $this->request->isFrontend(); |
|
| 20 | - } |
|
| 17 | + public function isMatchingRoute() |
|
| 18 | + { |
|
| 19 | + return $this->request->isFrontend(); |
|
| 20 | + } |
|
| 21 | 21 | } |
@@ -32,19 +32,19 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -17,76 +17,76 @@ |
||
| 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 | } |
@@ -46,7 +46,7 @@ |
||
| 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 | ); |
@@ -19,104 +19,104 @@ |
||
| 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 | } |
@@ -42,7 +42,7 @@ |
||
| 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 | |
@@ -14,44 +14,44 @@ |
||
| 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 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -13,180 +13,180 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | final class EE_Network_Config |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * @var EE_Network_Config $_instance |
|
| 18 | - */ |
|
| 19 | - private static $_instance; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * addons can add their specific network_config objects to this property |
|
| 23 | - * |
|
| 24 | - * @var EE_Config_Base[] $addons |
|
| 25 | - */ |
|
| 26 | - public $addons; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var EE_Network_Core_Config $core |
|
| 30 | - */ |
|
| 31 | - public $core; |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @singleton method used to instantiate class object |
|
| 36 | - * @return EE_Network_Config instance |
|
| 37 | - */ |
|
| 38 | - public static function instance() |
|
| 39 | - { |
|
| 40 | - // check if class object is instantiated, and instantiated properly |
|
| 41 | - if (! self::$_instance instanceof EE_Network_Config) { |
|
| 42 | - self::$_instance = new self(); |
|
| 43 | - } |
|
| 44 | - return self::$_instance; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * class constructor |
|
| 50 | - */ |
|
| 51 | - private function __construct() |
|
| 52 | - { |
|
| 53 | - do_action('AHEE__EE_Network_Config__construct__begin', $this); |
|
| 54 | - // set defaults |
|
| 55 | - $this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config()); |
|
| 56 | - $this->addons = array(); |
|
| 57 | - |
|
| 58 | - $this->_load_config(); |
|
| 59 | - |
|
| 60 | - // construct__end hook |
|
| 61 | - do_action('AHEE__EE_Network_Config__construct__end', $this); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * load EE Network Config options |
|
| 67 | - * |
|
| 68 | - * @return void |
|
| 69 | - */ |
|
| 70 | - private function _load_config() |
|
| 71 | - { |
|
| 72 | - // load network config start hook |
|
| 73 | - do_action('AHEE__EE_Network_Config___load_config__start', $this); |
|
| 74 | - $config = $this->get_config(); |
|
| 75 | - foreach ($config as $config_prop => $settings) { |
|
| 76 | - if ($config_prop === 'core' && ! $settings instanceof EE_Network_Core_Config) { |
|
| 77 | - $core = new EE_Network_Core_Config(); |
|
| 78 | - foreach ($settings as $prop => $setting) { |
|
| 79 | - if (property_exists($core, $prop)) { |
|
| 80 | - $core->{$prop} = $setting; |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - $settings = $core; |
|
| 84 | - add_filter('FHEE__EE_Network_Config___load_config__update_network_config', '__return_true'); |
|
| 85 | - } |
|
| 86 | - if (is_object($settings) && property_exists($this, $config_prop)) { |
|
| 87 | - $this->{$config_prop} = apply_filters( |
|
| 88 | - 'FHEE__EE_Network_Config___load_config__config_settings', |
|
| 89 | - $settings, |
|
| 90 | - $config_prop, |
|
| 91 | - $this |
|
| 92 | - ); |
|
| 93 | - if (method_exists($settings, 'populate')) { |
|
| 94 | - $this->{$config_prop}->populate(); |
|
| 95 | - } |
|
| 96 | - if (method_exists($settings, 'do_hooks')) { |
|
| 97 | - $this->{$config_prop}->do_hooks(); |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - if (apply_filters('FHEE__EE_Network_Config___load_config__update_network_config', false)) { |
|
| 102 | - $this->update_config(); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - // load network config end hook |
|
| 106 | - do_action('AHEE__EE_Network_Config___load_config__end', $this); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * get_config |
|
| 112 | - * |
|
| 113 | - * @return array of network config stuff |
|
| 114 | - */ |
|
| 115 | - public function get_config() |
|
| 116 | - { |
|
| 117 | - // grab network configuration |
|
| 118 | - $CFG = get_site_option('ee_network_config', array()); |
|
| 119 | - $CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG); |
|
| 120 | - return $CFG; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * update_config |
|
| 126 | - * |
|
| 127 | - * @param bool $add_success |
|
| 128 | - * @param bool $add_error |
|
| 129 | - * @return bool success |
|
| 130 | - */ |
|
| 131 | - public function update_config($add_success = false, $add_error = true) |
|
| 132 | - { |
|
| 133 | - do_action('AHEE__EE_Network_Config__update_config__begin', $this); |
|
| 134 | - |
|
| 135 | - // need to bust cache for comparing original if this is a multisite install |
|
| 136 | - if (is_multisite()) { |
|
| 137 | - global $current_site; |
|
| 138 | - $cache_key = $current_site->id . ':ee_network_config'; |
|
| 139 | - wp_cache_delete($cache_key, 'site-options'); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - // we have to compare existing saved config with config in memory because if there is no difference that means |
|
| 143 | - // that the method executed fine but there just was no update. WordPress doesn't distinguish between false because |
|
| 144 | - // there were 0 records updated because of no change vs false because some error produced problems with the update. |
|
| 145 | - $original = get_site_option('ee_network_config'); |
|
| 146 | - |
|
| 147 | - if ($original == $this) { |
|
| 148 | - return true; |
|
| 149 | - } |
|
| 150 | - // update |
|
| 151 | - $saved = update_site_option('ee_network_config', $this); |
|
| 152 | - |
|
| 153 | - do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved); |
|
| 154 | - // if config remains the same or was updated successfully |
|
| 155 | - if ($saved) { |
|
| 156 | - if ($add_success) { |
|
| 157 | - $msg = is_multisite() ? esc_html__( |
|
| 158 | - 'The Event Espresso Network Configuration Settings have been successfully updated.', |
|
| 159 | - 'event_espresso' |
|
| 160 | - ) : esc_html__('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso'); |
|
| 161 | - EE_Error::add_success($msg); |
|
| 162 | - } |
|
| 163 | - return true; |
|
| 164 | - } |
|
| 165 | - if ($add_error) { |
|
| 166 | - $msg = is_multisite() ? esc_html__( |
|
| 167 | - 'The Event Espresso Network Configuration Settings were not updated.', |
|
| 168 | - 'event_espresso' |
|
| 169 | - ) : esc_html__('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso'); |
|
| 170 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 171 | - } |
|
| 172 | - return false; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * __sleep |
|
| 178 | - * |
|
| 179 | - * @return array |
|
| 180 | - */ |
|
| 181 | - public function __sleep() |
|
| 182 | - { |
|
| 183 | - return apply_filters( |
|
| 184 | - 'FHEE__EE_Network_Config__sleep', |
|
| 185 | - array( |
|
| 186 | - 'core', |
|
| 187 | - ) |
|
| 188 | - ); |
|
| 189 | - } |
|
| 16 | + /** |
|
| 17 | + * @var EE_Network_Config $_instance |
|
| 18 | + */ |
|
| 19 | + private static $_instance; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * addons can add their specific network_config objects to this property |
|
| 23 | + * |
|
| 24 | + * @var EE_Config_Base[] $addons |
|
| 25 | + */ |
|
| 26 | + public $addons; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var EE_Network_Core_Config $core |
|
| 30 | + */ |
|
| 31 | + public $core; |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @singleton method used to instantiate class object |
|
| 36 | + * @return EE_Network_Config instance |
|
| 37 | + */ |
|
| 38 | + public static function instance() |
|
| 39 | + { |
|
| 40 | + // check if class object is instantiated, and instantiated properly |
|
| 41 | + if (! self::$_instance instanceof EE_Network_Config) { |
|
| 42 | + self::$_instance = new self(); |
|
| 43 | + } |
|
| 44 | + return self::$_instance; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * class constructor |
|
| 50 | + */ |
|
| 51 | + private function __construct() |
|
| 52 | + { |
|
| 53 | + do_action('AHEE__EE_Network_Config__construct__begin', $this); |
|
| 54 | + // set defaults |
|
| 55 | + $this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config()); |
|
| 56 | + $this->addons = array(); |
|
| 57 | + |
|
| 58 | + $this->_load_config(); |
|
| 59 | + |
|
| 60 | + // construct__end hook |
|
| 61 | + do_action('AHEE__EE_Network_Config__construct__end', $this); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * load EE Network Config options |
|
| 67 | + * |
|
| 68 | + * @return void |
|
| 69 | + */ |
|
| 70 | + private function _load_config() |
|
| 71 | + { |
|
| 72 | + // load network config start hook |
|
| 73 | + do_action('AHEE__EE_Network_Config___load_config__start', $this); |
|
| 74 | + $config = $this->get_config(); |
|
| 75 | + foreach ($config as $config_prop => $settings) { |
|
| 76 | + if ($config_prop === 'core' && ! $settings instanceof EE_Network_Core_Config) { |
|
| 77 | + $core = new EE_Network_Core_Config(); |
|
| 78 | + foreach ($settings as $prop => $setting) { |
|
| 79 | + if (property_exists($core, $prop)) { |
|
| 80 | + $core->{$prop} = $setting; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + $settings = $core; |
|
| 84 | + add_filter('FHEE__EE_Network_Config___load_config__update_network_config', '__return_true'); |
|
| 85 | + } |
|
| 86 | + if (is_object($settings) && property_exists($this, $config_prop)) { |
|
| 87 | + $this->{$config_prop} = apply_filters( |
|
| 88 | + 'FHEE__EE_Network_Config___load_config__config_settings', |
|
| 89 | + $settings, |
|
| 90 | + $config_prop, |
|
| 91 | + $this |
|
| 92 | + ); |
|
| 93 | + if (method_exists($settings, 'populate')) { |
|
| 94 | + $this->{$config_prop}->populate(); |
|
| 95 | + } |
|
| 96 | + if (method_exists($settings, 'do_hooks')) { |
|
| 97 | + $this->{$config_prop}->do_hooks(); |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + if (apply_filters('FHEE__EE_Network_Config___load_config__update_network_config', false)) { |
|
| 102 | + $this->update_config(); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + // load network config end hook |
|
| 106 | + do_action('AHEE__EE_Network_Config___load_config__end', $this); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * get_config |
|
| 112 | + * |
|
| 113 | + * @return array of network config stuff |
|
| 114 | + */ |
|
| 115 | + public function get_config() |
|
| 116 | + { |
|
| 117 | + // grab network configuration |
|
| 118 | + $CFG = get_site_option('ee_network_config', array()); |
|
| 119 | + $CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG); |
|
| 120 | + return $CFG; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * update_config |
|
| 126 | + * |
|
| 127 | + * @param bool $add_success |
|
| 128 | + * @param bool $add_error |
|
| 129 | + * @return bool success |
|
| 130 | + */ |
|
| 131 | + public function update_config($add_success = false, $add_error = true) |
|
| 132 | + { |
|
| 133 | + do_action('AHEE__EE_Network_Config__update_config__begin', $this); |
|
| 134 | + |
|
| 135 | + // need to bust cache for comparing original if this is a multisite install |
|
| 136 | + if (is_multisite()) { |
|
| 137 | + global $current_site; |
|
| 138 | + $cache_key = $current_site->id . ':ee_network_config'; |
|
| 139 | + wp_cache_delete($cache_key, 'site-options'); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + // we have to compare existing saved config with config in memory because if there is no difference that means |
|
| 143 | + // that the method executed fine but there just was no update. WordPress doesn't distinguish between false because |
|
| 144 | + // there were 0 records updated because of no change vs false because some error produced problems with the update. |
|
| 145 | + $original = get_site_option('ee_network_config'); |
|
| 146 | + |
|
| 147 | + if ($original == $this) { |
|
| 148 | + return true; |
|
| 149 | + } |
|
| 150 | + // update |
|
| 151 | + $saved = update_site_option('ee_network_config', $this); |
|
| 152 | + |
|
| 153 | + do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved); |
|
| 154 | + // if config remains the same or was updated successfully |
|
| 155 | + if ($saved) { |
|
| 156 | + if ($add_success) { |
|
| 157 | + $msg = is_multisite() ? esc_html__( |
|
| 158 | + 'The Event Espresso Network Configuration Settings have been successfully updated.', |
|
| 159 | + 'event_espresso' |
|
| 160 | + ) : esc_html__('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso'); |
|
| 161 | + EE_Error::add_success($msg); |
|
| 162 | + } |
|
| 163 | + return true; |
|
| 164 | + } |
|
| 165 | + if ($add_error) { |
|
| 166 | + $msg = is_multisite() ? esc_html__( |
|
| 167 | + 'The Event Espresso Network Configuration Settings were not updated.', |
|
| 168 | + 'event_espresso' |
|
| 169 | + ) : esc_html__('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso'); |
|
| 170 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 171 | + } |
|
| 172 | + return false; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * __sleep |
|
| 178 | + * |
|
| 179 | + * @return array |
|
| 180 | + */ |
|
| 181 | + public function __sleep() |
|
| 182 | + { |
|
| 183 | + return apply_filters( |
|
| 184 | + 'FHEE__EE_Network_Config__sleep', |
|
| 185 | + array( |
|
| 186 | + 'core', |
|
| 187 | + ) |
|
| 188 | + ); |
|
| 189 | + } |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | |
@@ -195,27 +195,27 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | class EE_Network_Core_Config extends EE_Config_Base |
| 197 | 197 | { |
| 198 | - /** |
|
| 199 | - * PUE site license key |
|
| 200 | - * |
|
| 201 | - * @var string $site_license_key |
|
| 202 | - */ |
|
| 203 | - public $site_license_key; |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * This indicates whether messages system processing should be done on the same request or not. |
|
| 207 | - * |
|
| 208 | - * @var boolean $do_messages_on_same_request |
|
| 209 | - */ |
|
| 210 | - public $do_messages_on_same_request; |
|
| 211 | - |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * EE_Network_Core_Config constructor. |
|
| 215 | - */ |
|
| 216 | - public function __construct() |
|
| 217 | - { |
|
| 218 | - $this->site_license_key = ''; |
|
| 219 | - $this->do_messages_on_same_request = false; |
|
| 220 | - } |
|
| 198 | + /** |
|
| 199 | + * PUE site license key |
|
| 200 | + * |
|
| 201 | + * @var string $site_license_key |
|
| 202 | + */ |
|
| 203 | + public $site_license_key; |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * This indicates whether messages system processing should be done on the same request or not. |
|
| 207 | + * |
|
| 208 | + * @var boolean $do_messages_on_same_request |
|
| 209 | + */ |
|
| 210 | + public $do_messages_on_same_request; |
|
| 211 | + |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * EE_Network_Core_Config constructor. |
|
| 215 | + */ |
|
| 216 | + public function __construct() |
|
| 217 | + { |
|
| 218 | + $this->site_license_key = ''; |
|
| 219 | + $this->do_messages_on_same_request = false; |
|
| 220 | + } |
|
| 221 | 221 | } |
@@ -14,15 +14,15 @@ |
||
| 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 | } |
@@ -14,15 +14,15 @@ |
||
| 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 | } |