@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | * @package Event Espresso |
8 | 8 | * @subpackage core, capabilities |
9 | 9 | */ |
10 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
11 | - exit( 'No direct script access allowed' ); |
|
10 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
11 | + exit('No direct script access allowed'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public static function instance() { |
73 | 73 | //check if instantiated, and if not do so. |
74 | - if ( ! self::$_instance instanceof EE_Capabilities ) { |
|
74 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
75 | 75 | self::$_instance = new self(); |
76 | 76 | } |
77 | 77 | return self::$_instance; |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | * @since 4.5.0 |
101 | 101 | * @return void |
102 | 102 | */ |
103 | - public function init_caps( $reset = false ) { |
|
104 | - if ( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
103 | + public function init_caps($reset = false) { |
|
104 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
105 | 105 | $this->_caps_map = $this->_init_caps_map(); |
106 | - $this->init_role_caps( $reset ); |
|
106 | + $this->init_role_caps($reset); |
|
107 | 107 | $this->_set_meta_caps(); |
108 | 108 | } |
109 | 109 | } |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
123 | 123 | $this->_meta_caps = $this->_get_default_meta_caps_array(); |
124 | 124 | |
125 | - $this->_meta_caps = apply_filters( 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps ); |
|
125 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
126 | 126 | |
127 | 127 | //add filter for map_meta_caps but only if models can query. |
128 | - if ( EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ) ) ) { |
|
129 | - add_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10, 4 ); |
|
128 | + if (EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
129 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
@@ -139,37 +139,37 @@ discard block |
||
139 | 139 | */ |
140 | 140 | private function _get_default_meta_caps_array() { |
141 | 141 | static $default_meta_caps = array(); |
142 | - if ( empty( $default_meta_caps ) ) { |
|
142 | + if (empty($default_meta_caps)) { |
|
143 | 143 | $default_meta_caps = array( |
144 | 144 | //edits |
145 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_event', array( 'Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events' ) ), |
|
146 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_venue', array( 'Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues' ) ), |
|
147 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_registration', array( 'Registration', '', 'ee_edit_others_registrations', '' ) ), |
|
148 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_checkin', array( 'Registration', '', 'ee_edit_others_checkins', '' ) ), |
|
149 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_edit_message', array( 'Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages' ) ), |
|
150 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_default_ticket', array( 'Ticket', '', 'ee_edit_others_default_tickets', '' ) ), |
|
151 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question', array( 'Question', '', '', 'ee_edit_system_questions' ) ), |
|
152 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question_group', array( 'Question_Group', '', '', 'ee_edit_system_question_groups' ) ), |
|
153 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_payment_method', array( 'Payment_Method', '', 'ee_edit_others_payment_methods', '' ) ), |
|
145 | + new EE_Meta_Capability_Map_Edit('ee_edit_event', array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')), |
|
146 | + new EE_Meta_Capability_Map_Edit('ee_edit_venue', array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')), |
|
147 | + new EE_Meta_Capability_Map_Edit('ee_edit_registration', array('Registration', '', 'ee_edit_others_registrations', '')), |
|
148 | + new EE_Meta_Capability_Map_Edit('ee_edit_checkin', array('Registration', '', 'ee_edit_others_checkins', '')), |
|
149 | + new EE_Meta_Capability_Map_Messages_Cap('ee_edit_message', array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')), |
|
150 | + new EE_Meta_Capability_Map_Edit('ee_edit_default_ticket', array('Ticket', '', 'ee_edit_others_default_tickets', '')), |
|
151 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question', array('Question', '', '', 'ee_edit_system_questions')), |
|
152 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question_group', array('Question_Group', '', '', 'ee_edit_system_question_groups')), |
|
153 | + new EE_Meta_Capability_Map_Edit('ee_edit_payment_method', array('Payment_Method', '', 'ee_edit_others_payment_methods', '')), |
|
154 | 154 | //reads |
155 | - new EE_Meta_Capability_Map_Read( 'ee_read_event', array( 'Event', '', 'ee_read_others_events', 'ee_read_private_events' ) ), |
|
156 | - new EE_Meta_Capability_Map_Read( 'ee_read_venue', array( 'Venue', '', 'ee_read_others_venues', 'ee_read_private_venues' ) ), |
|
157 | - new EE_Meta_Capability_Map_Read( 'ee_read_registration', array( 'Registration', '', '', 'ee_edit_others_registrations' ) ), |
|
158 | - new EE_Meta_Capability_Map_Read( 'ee_read_checkin', array( 'Registration', '', '', 'ee_read_others_checkins' ) ), |
|
159 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_read_message', array( 'Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages' ) ), |
|
160 | - new EE_Meta_Capability_Map_Read( 'ee_read_default_ticket', array( 'Ticket', '', '', 'ee_read_others_default_tickets' ) ), |
|
161 | - new EE_Meta_Capability_Map_Read( 'ee_read_payment_method', array( 'Payment_Method', '', '', 'ee_read_others_payment_methods' ) ), |
|
155 | + new EE_Meta_Capability_Map_Read('ee_read_event', array('Event', '', 'ee_read_others_events', 'ee_read_private_events')), |
|
156 | + new EE_Meta_Capability_Map_Read('ee_read_venue', array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')), |
|
157 | + new EE_Meta_Capability_Map_Read('ee_read_registration', array('Registration', '', '', 'ee_edit_others_registrations')), |
|
158 | + new EE_Meta_Capability_Map_Read('ee_read_checkin', array('Registration', '', '', 'ee_read_others_checkins')), |
|
159 | + new EE_Meta_Capability_Map_Messages_Cap('ee_read_message', array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')), |
|
160 | + new EE_Meta_Capability_Map_Read('ee_read_default_ticket', array('Ticket', '', '', 'ee_read_others_default_tickets')), |
|
161 | + new EE_Meta_Capability_Map_Read('ee_read_payment_method', array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
162 | 162 | |
163 | 163 | //deletes |
164 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_event', array( 'Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events' ) ), |
|
165 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_venue', array( 'Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues' ) ), |
|
166 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_registration', array( 'Registration', '', 'ee_delete_others_registrations', '' ) ), |
|
167 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_checkin', array( 'Registration', '', 'ee_delete_others_checkins', '' ) ), |
|
168 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_delete_message', array( 'Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages' ) ), |
|
169 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_default_ticket', array( 'Ticket', '', 'ee_delete_others_default_tickets', '' ) ), |
|
170 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question', array( 'Question', '', '', 'delete_system_questions' ) ), |
|
171 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question_group', array( 'Question_Group', '', '', 'delete_system_question_groups' ) ), |
|
172 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_payment_method', array( 'Payment_Method', '', 'ee_delete_others_payment_methods', '' ) ), |
|
164 | + new EE_Meta_Capability_Map_Delete('ee_delete_event', array('Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events')), |
|
165 | + new EE_Meta_Capability_Map_Delete('ee_delete_venue', array('Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues')), |
|
166 | + new EE_Meta_Capability_Map_Delete('ee_delete_registration', array('Registration', '', 'ee_delete_others_registrations', '')), |
|
167 | + new EE_Meta_Capability_Map_Delete('ee_delete_checkin', array('Registration', '', 'ee_delete_others_checkins', '')), |
|
168 | + new EE_Meta_Capability_Map_Messages_Cap('ee_delete_message', array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')), |
|
169 | + new EE_Meta_Capability_Map_Delete('ee_delete_default_ticket', array('Ticket', '', 'ee_delete_others_default_tickets', '')), |
|
170 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question', array('Question', '', '', 'delete_system_questions')), |
|
171 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question_group', array('Question_Group', '', '', 'delete_system_question_groups')), |
|
172 | + new EE_Meta_Capability_Map_Delete('ee_delete_payment_method', array('Payment_Method', '', 'ee_delete_others_payment_methods', '')), |
|
173 | 173 | ); |
174 | 174 | } |
175 | 175 | return $default_meta_caps; |
@@ -193,15 +193,15 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @return array actual users capabilities |
195 | 195 | */ |
196 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
196 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
197 | 197 | //loop through our _meta_caps array |
198 | - foreach ( $this->_meta_caps as $meta_map ) { |
|
199 | - if ( ! $meta_map instanceof EE_Meta_Capability_Map ) { |
|
198 | + foreach ($this->_meta_caps as $meta_map) { |
|
199 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
200 | 200 | continue; |
201 | 201 | } |
202 | 202 | $meta_map->ensure_is_model(); |
203 | 203 | |
204 | - $caps = $meta_map->map_meta_caps( $caps, $cap, $user_id, $args ); |
|
204 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
205 | 205 | } |
206 | 206 | return $caps; |
207 | 207 | } |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | ) |
528 | 528 | ); |
529 | 529 | |
530 | - $caps = apply_filters( 'FHEE__EE_Capabilities__init_caps_map__caps', $caps ); |
|
530 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
531 | 531 | return $caps; |
532 | 532 | } |
533 | 533 | |
@@ -544,27 +544,27 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - public function init_role_caps( $reset = false, $custom_map = array() ) { |
|
547 | + public function init_role_caps($reset = false, $custom_map = array()) { |
|
548 | 548 | |
549 | - $caps_map = empty( $custom_map ) ? $this->_caps_map : $custom_map; |
|
549 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
550 | 550 | |
551 | 551 | //first let's determine if these caps have already been set. |
552 | - $caps_set_before = get_option( self::option_name, array() ); |
|
552 | + $caps_set_before = get_option(self::option_name, array()); |
|
553 | 553 | //if not reset, see what caps are new for each role. if they're new, add them. |
554 | - foreach ( $caps_map as $role => $caps_for_role ) { |
|
555 | - foreach ( $caps_for_role as $cap ) { |
|
554 | + foreach ($caps_map as $role => $caps_for_role) { |
|
555 | + foreach ($caps_for_role as $cap) { |
|
556 | 556 | //first check we haven't already added this cap before, or it's a reset |
557 | - if ( $reset || ! isset( $caps_set_before[ $role ] ) || ! in_array( $cap, $caps_set_before[ $role ] ) ) { |
|
558 | - if ( $this->add_cap_to_role( $role, $cap ) ) { |
|
559 | - $caps_set_before[ $role ][] = $cap; |
|
557 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
558 | + if ($this->add_cap_to_role($role, $cap)) { |
|
559 | + $caps_set_before[$role][] = $cap; |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | } |
563 | 563 | } |
564 | 564 | |
565 | 565 | //now let's just save the cap that has been set. |
566 | - update_option( self::option_name, $caps_set_before ); |
|
567 | - do_action( 'AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before ); |
|
566 | + update_option(self::option_name, $caps_set_before); |
|
567 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | |
@@ -583,20 +583,20 @@ discard block |
||
583 | 583 | * @param bool $grant Whether to grant access to this cap on this role. |
584 | 584 | * @return bool |
585 | 585 | */ |
586 | - public function add_cap_to_role( $role, $cap, $grant = true ) { |
|
587 | - $role_object = get_role( $role ); |
|
586 | + public function add_cap_to_role($role, $cap, $grant = true) { |
|
587 | + $role_object = get_role($role); |
|
588 | 588 | //if the role isn't available then we create it. |
589 | - if ( ! $role_object instanceof WP_Role ) { |
|
589 | + if ( ! $role_object instanceof WP_Role) { |
|
590 | 590 | //if a plugin wants to create a specific role name then they should create the role before |
591 | 591 | //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
592 | 592 | // - removes any `ee_` namespacing from the start of the slug. |
593 | 593 | // - replaces `_` with ` ` (empty space). |
594 | 594 | // - sentence case on the resulting string. |
595 | - $role_label = ucwords( str_replace( '_', ' ', str_replace( 'ee_', '', $role ) ) ); |
|
596 | - $role_object = add_role( $role, $role_label ); |
|
595 | + $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
596 | + $role_object = add_role($role, $role_label); |
|
597 | 597 | } |
598 | - if ( $role_object instanceof WP_Role ) { |
|
599 | - $role_object->add_cap( $cap, $grant ); |
|
598 | + if ($role_object instanceof WP_Role) { |
|
599 | + $role_object->add_cap($cap, $grant); |
|
600 | 600 | return true; |
601 | 601 | } |
602 | 602 | return false; |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @return void |
620 | 620 | */ |
621 | - public function remove_cap_from_role( $role, $cap ) { |
|
622 | - $role = get_role( $role ); |
|
623 | - if ( $role instanceof WP_Role ) { |
|
624 | - $role->remove_cap( $cap ); |
|
621 | + public function remove_cap_from_role($role, $cap) { |
|
622 | + $role = get_role($role); |
|
623 | + if ($role instanceof WP_Role) { |
|
624 | + $role->remove_cap($cap); |
|
625 | 625 | } |
626 | 626 | } |
627 | 627 | |
@@ -642,11 +642,11 @@ discard block |
||
642 | 642 | * |
643 | 643 | * @return bool Whether user can or not. |
644 | 644 | */ |
645 | - public function current_user_can( $cap, $context, $id = 0 ) { |
|
645 | + public function current_user_can($cap, $context, $id = 0) { |
|
646 | 646 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
647 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id ); |
|
648 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id ); |
|
649 | - return ! empty( $id ) ? current_user_can( $filtered_cap, $id ) : current_user_can( $filtered_cap ); |
|
647 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
648 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id); |
|
649 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | |
@@ -663,11 +663,11 @@ discard block |
||
663 | 663 | * |
664 | 664 | * @return bool Whether user can or not. |
665 | 665 | */ |
666 | - public function user_can( $user, $cap, $context, $id = 0 ) { |
|
666 | + public function user_can($user, $cap, $context, $id = 0) { |
|
667 | 667 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
668 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id ); |
|
669 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id ); |
|
670 | - return ! empty( $id ) ? user_can( $user, $filtered_cap, $id ) : user_can( $user, $filtered_cap ); |
|
668 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
669 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id); |
|
670 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | |
@@ -687,12 +687,12 @@ discard block |
||
687 | 687 | * |
688 | 688 | * @return bool Whether user can or not. |
689 | 689 | */ |
690 | - public function current_user_can_for_blog( $blog_id, $cap, $context, $id = 0 ) { |
|
691 | - $user_can = ! empty( $id ) ? current_user_can_for_blog( $blog_id, $cap, $id ) : current_user_can( $blog_id, $cap ); |
|
690 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) { |
|
691 | + $user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap); |
|
692 | 692 | |
693 | 693 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
694 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can, $blog_id, $cap, $id ); |
|
695 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id ); |
|
694 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, $user_can, $blog_id, $cap, $id); |
|
695 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id); |
|
696 | 696 | return $user_can; |
697 | 697 | } |
698 | 698 | |
@@ -708,12 +708,12 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @return array |
710 | 710 | */ |
711 | - public function get_ee_capabilities( $role = 'administrator' ) { |
|
711 | + public function get_ee_capabilities($role = 'administrator') { |
|
712 | 712 | $capabilities = $this->_init_caps_map(); |
713 | - if ( empty( $role ) ) { |
|
713 | + if (empty($role)) { |
|
714 | 714 | return $capabilities; |
715 | 715 | } |
716 | - return isset( $capabilities[ $role ] ) ? $capabilities[ $role ] : array(); |
|
716 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
717 | 717 | } |
718 | 718 | } |
719 | 719 | |
@@ -761,11 +761,11 @@ discard block |
||
761 | 761 | * } |
762 | 762 | * @throws EE_Error |
763 | 763 | */ |
764 | - public function __construct( $meta_cap, $map_values ) { |
|
764 | + public function __construct($meta_cap, $map_values) { |
|
765 | 765 | $this->meta_cap = $meta_cap; |
766 | 766 | //verify there are four args in the $map_values array; |
767 | - if ( count( $map_values ) !== 4 ) { |
|
768 | - throw new EE_Error( sprintf( __( 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso' ), '<br>' . print_r( $map_values, true ) ) ); |
|
767 | + if (count($map_values) !== 4) { |
|
768 | + throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso'), '<br>'.print_r($map_values, true))); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | //set properties |
@@ -779,8 +779,8 @@ discard block |
||
779 | 779 | /** |
780 | 780 | * Makes it so this object stops filtering caps |
781 | 781 | */ |
782 | - public function remove_filters(){ |
|
783 | - remove_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10 ); |
|
782 | + public function remove_filters() { |
|
783 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | |
@@ -795,19 +795,19 @@ discard block |
||
795 | 795 | */ |
796 | 796 | public function ensure_is_model() { |
797 | 797 | //is it already instantiated? |
798 | - if ( $this->_model instanceof EEM_Base ) { |
|
798 | + if ($this->_model instanceof EEM_Base) { |
|
799 | 799 | return; |
800 | 800 | } |
801 | 801 | |
802 | 802 | //ensure model name is string |
803 | 803 | $this->_model_name = (string) $this->_model_name; |
804 | 804 | //error proof if the name has EEM in it |
805 | - $this->_model_name = str_replace( 'EEM', '', $this->_model_name ); |
|
805 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
806 | 806 | |
807 | - $this->_model = EE_Registry::instance()->load_model( $this->_model_name ); |
|
807 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
808 | 808 | |
809 | - if ( ! $this->_model instanceof EEM_Base ) { |
|
810 | - throw new EE_Error( sprintf( __( 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso' ), get_class( $this ), $this->_model ) ); |
|
809 | + if ( ! $this->_model instanceof EEM_Base) { |
|
810 | + throw new EE_Error(sprintf(__('This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso'), get_class($this), $this->_model)); |
|
811 | 811 | } |
812 | 812 | } |
813 | 813 | |
@@ -823,8 +823,8 @@ discard block |
||
823 | 823 | * |
824 | 824 | * @return array |
825 | 825 | */ |
826 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
827 | - return $this->_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
826 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
827 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
828 | 828 | } |
829 | 829 | |
830 | 830 | |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | * |
843 | 843 | * @return array actual users capabilities |
844 | 844 | */ |
845 | - abstract protected function _map_meta_caps( $caps, $cap, $user_id, $args ); |
|
845 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | |
@@ -874,28 +874,28 @@ discard block |
||
874 | 874 | * |
875 | 875 | * @return array actual users capabilities |
876 | 876 | */ |
877 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
877 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
878 | 878 | //only process if we're checking our mapped_cap |
879 | - if ( $cap !== $this->meta_cap ) { |
|
879 | + if ($cap !== $this->meta_cap) { |
|
880 | 880 | return $caps; |
881 | 881 | } |
882 | 882 | |
883 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
883 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
884 | 884 | |
885 | 885 | //if no obj then let's just do cap |
886 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
886 | + if ( ! $obj instanceof EE_Base_Class) { |
|
887 | 887 | $caps[] = $cap; |
888 | 888 | return $caps; |
889 | 889 | } |
890 | 890 | |
891 | - if ( $obj instanceof EE_CPT_Base ) { |
|
891 | + if ($obj instanceof EE_CPT_Base) { |
|
892 | 892 | //if the item author is set and the user is the author... |
893 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
894 | - if ( empty( $this->published_cap ) ) { |
|
893 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
894 | + if (empty($this->published_cap)) { |
|
895 | 895 | $caps[] = $cap; |
896 | 896 | } else { |
897 | 897 | //if obj is published... |
898 | - if ( $obj->status() == 'publish' ) { |
|
898 | + if ($obj->status() == 'publish') { |
|
899 | 899 | $caps[] = $this->published_cap; |
900 | 900 | } else { |
901 | 901 | $caps[] = $cap; |
@@ -903,21 +903,21 @@ discard block |
||
903 | 903 | } |
904 | 904 | } else { |
905 | 905 | //the user is trying to edit someone else's obj |
906 | - if ( ! empty( $this->others_cap ) ) { |
|
906 | + if ( ! empty($this->others_cap)) { |
|
907 | 907 | $caps[] = $this->others_cap; |
908 | 908 | } |
909 | - if ( ! empty( $this->published_cap ) && $obj->status() == 'publish' ) { |
|
909 | + if ( ! empty($this->published_cap) && $obj->status() == 'publish') { |
|
910 | 910 | $caps[] = $this->published_cap; |
911 | - } elseif ( ! empty( $this->private_cap ) && $obj->status() == 'private' ) { |
|
911 | + } elseif ( ! empty($this->private_cap) && $obj->status() == 'private') { |
|
912 | 912 | $caps[] = $this->private_cap; |
913 | 913 | } |
914 | 914 | } |
915 | 915 | } else { |
916 | 916 | //not a cpt object so handled differently |
917 | - if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
917 | + if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) { |
|
918 | 918 | $caps[] = $cap; |
919 | 919 | } else { |
920 | - if ( ! empty( $this->others_cap ) ) { |
|
920 | + if ( ! empty($this->others_cap)) { |
|
921 | 921 | $caps[] = $this->others_cap; |
922 | 922 | } |
923 | 923 | } |
@@ -954,8 +954,8 @@ discard block |
||
954 | 954 | * |
955 | 955 | * @return array actual users capabilities |
956 | 956 | */ |
957 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
958 | - return parent::_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
957 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
958 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
959 | 959 | } |
960 | 960 | } |
961 | 961 | |
@@ -987,45 +987,45 @@ discard block |
||
987 | 987 | * |
988 | 988 | * @return array actual users capabilities |
989 | 989 | */ |
990 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
990 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
991 | 991 | //only process if we're checking our mapped cap; |
992 | - if ( $cap !== $this->meta_cap ) { |
|
992 | + if ($cap !== $this->meta_cap) { |
|
993 | 993 | return $caps; |
994 | 994 | } |
995 | 995 | |
996 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
996 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
997 | 997 | |
998 | 998 | //if no obj then let's just do cap |
999 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
999 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1000 | 1000 | $caps[] = $cap; |
1001 | 1001 | return $caps; |
1002 | 1002 | } |
1003 | 1003 | |
1004 | - if ( $obj instanceof EE_CPT_Base ) { |
|
1005 | - $status_obj = get_post_status_object( $obj->status() ); |
|
1006 | - if ( $status_obj->public ) { |
|
1004 | + if ($obj instanceof EE_CPT_Base) { |
|
1005 | + $status_obj = get_post_status_object($obj->status()); |
|
1006 | + if ($status_obj->public) { |
|
1007 | 1007 | $caps[] = $cap; |
1008 | 1008 | return $caps; |
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | //if the item author is set and the user is the author... |
1012 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
1012 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
1013 | 1013 | $caps[] = $cap; |
1014 | - } elseif ( $status_obj->private && ! empty( $this->private_cap ) ) { |
|
1014 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1015 | 1015 | //the user is trying to view someone else's obj |
1016 | 1016 | $caps[] = $this->private_cap; |
1017 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
1017 | + } elseif ( ! empty($this->others_cap)) { |
|
1018 | 1018 | $caps[] = $this->others_cap; |
1019 | 1019 | } else { |
1020 | 1020 | $caps[] = $cap; |
1021 | 1021 | } |
1022 | 1022 | } else { |
1023 | 1023 | //not a cpt object so handled differently |
1024 | - if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
1024 | + if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) { |
|
1025 | 1025 | $caps[] = $cap; |
1026 | - } elseif ( ! empty( $this->private_cap ) ) { |
|
1026 | + } elseif ( ! empty($this->private_cap)) { |
|
1027 | 1027 | $caps[] = $this->private_cap; |
1028 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
1028 | + } elseif ( ! empty($this->others_cap)) { |
|
1029 | 1029 | $caps[] = $this->others_cap; |
1030 | 1030 | } else { |
1031 | 1031 | $caps[] = $cap; |
@@ -1062,30 +1062,30 @@ discard block |
||
1062 | 1062 | * |
1063 | 1063 | * @return array actual users capabilities |
1064 | 1064 | */ |
1065 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
1065 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
1066 | 1066 | //only process if we're checking our mapped_cap |
1067 | - if ( $cap !== $this->meta_cap ) { |
|
1067 | + if ($cap !== $this->meta_cap) { |
|
1068 | 1068 | return $caps; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
1071 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1072 | 1072 | |
1073 | 1073 | //if no obj then let's just do cap |
1074 | - if ( ! $obj instanceof EE_Message_Template_Group ) { |
|
1074 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
1075 | 1075 | $caps[] = $cap; |
1076 | 1076 | return $caps; |
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | $is_global = $obj->is_global(); |
1080 | 1080 | |
1081 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
1082 | - if ( $is_global ) { |
|
1083 | - $caps[] = $this->private_cap; |
|
1081 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
1082 | + if ($is_global) { |
|
1083 | + $caps[] = $this->private_cap; |
|
1084 | 1084 | } else { |
1085 | 1085 | $caps[] = $cap; |
1086 | 1086 | } |
1087 | 1087 | } else { |
1088 | - if ( $is_global ) { |
|
1088 | + if ($is_global) { |
|
1089 | 1089 | $caps[] = $this->private_cap; |
1090 | 1090 | } else { |
1091 | 1091 | $caps[] = $this->others_cap; |
@@ -1123,16 +1123,16 @@ discard block |
||
1123 | 1123 | * |
1124 | 1124 | * @return array actual users capabilities |
1125 | 1125 | */ |
1126 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
1126 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
1127 | 1127 | //only process if we're checking our mapped_cap |
1128 | - if ( $cap !== $this->meta_cap ) { |
|
1128 | + if ($cap !== $this->meta_cap) { |
|
1129 | 1129 | return $caps; |
1130 | 1130 | } |
1131 | 1131 | |
1132 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
1132 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1133 | 1133 | |
1134 | 1134 | //if no obj then let's just do cap |
1135 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
1135 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1136 | 1136 | $caps[] = $cap; |
1137 | 1137 | return $caps; |
1138 | 1138 | } |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
1141 | 1141 | $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
1142 | 1142 | |
1143 | - if ( $is_system ) { |
|
1143 | + if ($is_system) { |
|
1144 | 1144 | $caps[] = $this->private_cap; |
1145 | 1145 | } else { |
1146 | 1146 | $caps[] = $cap; |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('ABSPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | */ |
43 | 43 | |
44 | -if ( function_exists( 'espresso_version' ) ) { |
|
44 | +if (function_exists('espresso_version')) { |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * espresso_duplicate_plugin_error |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | function espresso_duplicate_plugin_error() { |
51 | 51 | ?> |
52 | 52 | <div class="error"> |
53 | - <p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p> |
|
53 | + <p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p> |
|
54 | 54 | </div> |
55 | 55 | <?php |
56 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
56 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
57 | 57 | } |
58 | - add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 ); |
|
58 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | 59 | |
60 | 60 | } else { |
61 | 61 | |
@@ -66,103 +66,103 @@ discard block |
||
66 | 66 | * @return string |
67 | 67 | */ |
68 | 68 | function espresso_version() { |
69 | - return apply_filters( 'FHEE__espresso__espresso_version', '4.9.8.rc.013' ); |
|
69 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.8.rc.013'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | // define versions |
73 | - define( 'EVENT_ESPRESSO_VERSION', espresso_version() ); |
|
74 | - define( 'EE_MIN_WP_VER_REQUIRED', '4.1' ); |
|
75 | - define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' ); |
|
76 | - define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' ); |
|
77 | - define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' ); |
|
78 | - define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION ); |
|
79 | - define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ ); |
|
73 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
74 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
75 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
76 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.0'); |
|
77 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
78 | + define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION); |
|
79 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
80 | 80 | //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
81 | - if ( ! defined( 'DS' ) ) { |
|
82 | - define( 'DS', '/' ); |
|
81 | + if ( ! defined('DS')) { |
|
82 | + define('DS', '/'); |
|
83 | 83 | } |
84 | - if ( ! defined( 'PS' ) ) { |
|
85 | - define( 'PS', PATH_SEPARATOR ); |
|
84 | + if ( ! defined('PS')) { |
|
85 | + define('PS', PATH_SEPARATOR); |
|
86 | 86 | } |
87 | - if ( ! defined( 'SP' ) ) { |
|
88 | - define( 'SP', ' ' ); |
|
87 | + if ( ! defined('SP')) { |
|
88 | + define('SP', ' '); |
|
89 | 89 | } |
90 | - if ( ! defined( 'EENL' ) ) { |
|
91 | - define( 'EENL', "\n" ); |
|
90 | + if ( ! defined('EENL')) { |
|
91 | + define('EENL', "\n"); |
|
92 | 92 | } |
93 | - define( 'EE_SUPPORT_EMAIL', '[email protected]' ); |
|
93 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
94 | 94 | // define the plugin directory and URL |
95 | - define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
96 | - define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
97 | - define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
95 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
96 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
97 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
98 | 98 | // main root folder paths |
99 | - define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS ); |
|
100 | - define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS ); |
|
101 | - define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS ); |
|
102 | - define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS ); |
|
103 | - define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS ); |
|
104 | - define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS ); |
|
105 | - define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS ); |
|
106 | - define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS ); |
|
99 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
100 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
101 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
102 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
103 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
104 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
105 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
106 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
107 | 107 | // core system paths |
108 | - define( 'EE_ADMIN', EE_CORE . 'admin' . DS ); |
|
109 | - define( 'EE_CPTS', EE_CORE . 'CPTs' . DS ); |
|
110 | - define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS ); |
|
111 | - define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS ); |
|
112 | - define( 'EE_BUSINESS', EE_CORE . 'business' . DS ); |
|
113 | - define( 'EE_MODELS', EE_CORE . 'db_models' . DS ); |
|
114 | - define( 'EE_HELPERS', EE_CORE . 'helpers' . DS ); |
|
115 | - define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS ); |
|
116 | - define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS ); |
|
117 | - define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS ); |
|
118 | - define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS ); |
|
119 | - define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS ); |
|
108 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
109 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
110 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
111 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
112 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
113 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
114 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
115 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
116 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
117 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
118 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
119 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
120 | 120 | // gateways |
121 | - define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS ); |
|
122 | - define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS ); |
|
121 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
122 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
123 | 123 | // asset URL paths |
124 | - define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS ); |
|
125 | - define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS ); |
|
126 | - define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS ); |
|
127 | - define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS ); |
|
128 | - define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' ); |
|
129 | - define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' ); |
|
124 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
125 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
126 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
127 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
128 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
129 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
130 | 130 | // define upload paths |
131 | 131 | $uploads = wp_upload_dir(); |
132 | 132 | // define the uploads directory and URL |
133 | - define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS ); |
|
134 | - define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS ); |
|
133 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
134 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
135 | 135 | // define the templates directory and URL |
136 | - define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
137 | - define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
136 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
137 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
138 | 138 | // define the gateway directory and URL |
139 | - define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
140 | - define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
139 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
140 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
141 | 141 | // languages folder/path |
142 | - define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS ); |
|
143 | - define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS ); |
|
142 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
143 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
144 | 144 | //check for dompdf fonts in uploads |
145 | - if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) { |
|
146 | - define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ); |
|
145 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
146 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
147 | 147 | } |
148 | 148 | //ajax constants |
149 | - define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false ); |
|
150 | - define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false ); |
|
149 | + define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false); |
|
150 | + define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false); |
|
151 | 151 | //just a handy constant occasionally needed for finding values representing infinity in the DB |
152 | 152 | //you're better to use this than its straight value (currently -1) in case you ever |
153 | 153 | //want to change its default value! or find when -1 means infinity |
154 | - define( 'EE_INF_IN_DB', -1 ); |
|
155 | - define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX ); |
|
156 | - define( 'EE_DEBUG', false ); |
|
154 | + define('EE_INF_IN_DB', -1); |
|
155 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
156 | + define('EE_DEBUG', false); |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * espresso_plugin_activation |
160 | 160 | * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
161 | 161 | */ |
162 | 162 | function espresso_plugin_activation() { |
163 | - update_option( 'ee_espresso_activation', true ); |
|
163 | + update_option('ee_espresso_activation', true); |
|
164 | 164 | } |
165 | - register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' ); |
|
165 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | // } |
177 | 177 | // |
178 | 178 | } |
179 | - register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' ); |
|
179 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
180 | 180 | |
181 | 181 | |
182 | 182 | |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | */ |
187 | 187 | function espresso_load_error_handling() { |
188 | 188 | // load debugging tools |
189 | - if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) { |
|
190 | - require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ); |
|
189 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
190 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
191 | 191 | EEH_Debug_Tools::instance(); |
192 | 192 | } |
193 | 193 | // load error handling |
194 | - if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) { |
|
195 | - require_once( EE_CORE . 'EE_Error.core.php' ); |
|
194 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
195 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
196 | 196 | } else { |
197 | - wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) ); |
|
197 | + wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -208,25 +208,25 @@ discard block |
||
208 | 208 | * @param string $full_path_to_file |
209 | 209 | * @throws EE_Error |
210 | 210 | */ |
211 | - function espresso_load_required( $classname, $full_path_to_file ) { |
|
211 | + function espresso_load_required($classname, $full_path_to_file) { |
|
212 | 212 | static $error_handling_loaded = false; |
213 | - if ( ! $error_handling_loaded ) { |
|
213 | + if ( ! $error_handling_loaded) { |
|
214 | 214 | espresso_load_error_handling(); |
215 | 215 | $error_handling_loaded = true; |
216 | 216 | } |
217 | - if ( is_readable( $full_path_to_file ) ) { |
|
218 | - require_once( $full_path_to_file ); |
|
217 | + if (is_readable($full_path_to_file)) { |
|
218 | + require_once($full_path_to_file); |
|
219 | 219 | } else { |
220 | - throw new EE_Error ( sprintf( |
|
221 | - __( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ), |
|
220 | + throw new EE_Error(sprintf( |
|
221 | + __('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'), |
|
222 | 222 | $classname |
223 | - ) ); |
|
223 | + )); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' ); |
|
228 | - espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' ); |
|
229 | - espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' ); |
|
227 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
228 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
229 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
230 | 230 | new EE_Bootstrap(); |
231 | 231 | |
232 | 232 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | |
237 | 237 | |
238 | -if ( ! function_exists( 'espresso_deactivate_plugin' ) ) { |
|
238 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
239 | 239 | /** |
240 | 240 | * deactivate_plugin |
241 | 241 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
245 | 245 | * @return void |
246 | 246 | */ |
247 | - function espresso_deactivate_plugin( $plugin_basename = '' ) { |
|
248 | - if ( ! function_exists( 'deactivate_plugins' ) ) { |
|
249 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
247 | + function espresso_deactivate_plugin($plugin_basename = '') { |
|
248 | + if ( ! function_exists('deactivate_plugins')) { |
|
249 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
250 | 250 | } |
251 | - unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] ); |
|
252 | - deactivate_plugins( $plugin_basename ); |
|
251 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
252 | + deactivate_plugins($plugin_basename); |
|
253 | 253 | } |
254 | 254 | } |