@@ -118,37 +118,37 @@ |
||
| 118 | 118 | * @return EE_Template_Config |
| 119 | 119 | */ |
| 120 | 120 | public static function update_template_settings( $CFG, $REQ ) { |
| 121 | - $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
|
| 122 | - ? $CFG->EED_Event_Single->display_order_event |
|
| 123 | - : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
| 121 | + $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
|
| 122 | + ? $CFG->EED_Event_Single->display_order_event |
|
| 123 | + : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
| 124 | 124 | $display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null |
| 125 | - ? $CFG->EED_Event_Single->display_order_datetimes |
|
| 126 | - : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
| 127 | - $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null |
|
| 128 | - ? $CFG->EED_Event_Single->display_order_tickets |
|
| 129 | - : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
| 125 | + ? $CFG->EED_Event_Single->display_order_datetimes |
|
| 126 | + : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
| 127 | + $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null |
|
| 128 | + ? $CFG->EED_Event_Single->display_order_tickets |
|
| 129 | + : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
| 130 | 130 | $display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null |
| 131 | - ? $CFG->EED_Event_Single->display_order_venue |
|
| 132 | - : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
| 131 | + ? $CFG->EED_Event_Single->display_order_venue |
|
| 132 | + : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
| 133 | 133 | $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
| 134 | 134 | $CFG->EED_Event_Single->display_status_banner_single = ! empty( $REQ['display_status_banner_single'] ) |
| 135 | - && $REQ['display_status_banner_single']; |
|
| 135 | + && $REQ['display_status_banner_single']; |
|
| 136 | 136 | $CFG->EED_Event_Single->display_venue = ! empty( $REQ['display_venue'] ) && $REQ['display_venue']; |
| 137 | 137 | $CFG->EED_Event_Single->use_sortable_display_order = ! empty( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) |
| 138 | - ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) |
|
| 139 | - : 0; |
|
| 138 | + ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) |
|
| 139 | + : 0; |
|
| 140 | 140 | $CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order |
| 141 | - ? $display_order_event |
|
| 142 | - : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
| 141 | + ? $display_order_event |
|
| 142 | + : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
| 143 | 143 | $CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order |
| 144 | - ? $display_order_datetimes |
|
| 145 | - : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
| 144 | + ? $display_order_datetimes |
|
| 145 | + : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
| 146 | 146 | $CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order |
| 147 | - ? $display_order_tickets |
|
| 148 | - : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
| 147 | + ? $display_order_tickets |
|
| 148 | + : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
| 149 | 149 | $CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order |
| 150 | - ? $display_order_venue |
|
| 151 | - : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
| 150 | + ? $display_order_venue |
|
| 151 | + : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
| 152 | 152 | do_action( 'AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ ); |
| 153 | 153 | return $CFG; |
| 154 | 154 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @return EED_Event_Single_Caff |
| 30 | 30 | */ |
| 31 | 31 | public static function instance() { |
| 32 | - return parent::get_instance( __CLASS__ ); |
|
| 32 | + return parent::get_instance(__CLASS__); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -50,34 +50,34 @@ discard block |
||
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | 52 | public static function set_hooks_admin() { |
| 53 | - define( 'EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS ); |
|
| 54 | - define( 'EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
| 53 | + define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS); |
|
| 54 | + define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
| 55 | 55 | add_action( |
| 56 | 56 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings', |
| 57 | - array( 'EED_Event_Single_Caff', 'load_scripts_styles' ), |
|
| 57 | + array('EED_Event_Single_Caff', 'load_scripts_styles'), |
|
| 58 | 58 | 10 |
| 59 | 59 | ); |
| 60 | - add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Event_Single_Caff', 'template_settings_form' ), 10 ); |
|
| 61 | - add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Event_Single_Caff', 'update_template_settings' ), 10, 2 ); |
|
| 60 | + add_action('AHEE__template_settings__template__before_settings_form', array('EED_Event_Single_Caff', 'template_settings_form'), 10); |
|
| 61 | + add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Event_Single_Caff', 'update_template_settings'), 10, 2); |
|
| 62 | 62 | // AJAX |
| 63 | - add_action( 'wp_ajax_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) ); |
|
| 64 | - add_action( 'wp_ajax_nopriv_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) ); |
|
| 63 | + add_action('wp_ajax_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order')); |
|
| 64 | + add_action('wp_ajax_nopriv_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order')); |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | public static function load_scripts_styles() { |
| 71 | - add_action( 'admin_enqueue_scripts', array( 'EED_Event_Single_Caff', 'enqueue_scripts_styles' ), 10 ); |
|
| 71 | + add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | |
| 76 | 76 | public static function enqueue_scripts_styles() { |
| 77 | - wp_register_style( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION ); |
|
| 78 | - wp_enqueue_style( 'eed-event-single-sortable' ); |
|
| 79 | - wp_register_script( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', array( 'jquery-ui-sortable' ), EVENT_ESPRESSO_VERSION, true ); |
|
| 80 | - wp_enqueue_script( 'eed-event-single-sortable' ); |
|
| 77 | + wp_register_style('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 78 | + wp_enqueue_style('eed-event-single-sortable'); |
|
| 79 | + wp_register_script('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
| 80 | + wp_enqueue_script('eed-event-single-sortable'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -91,21 +91,21 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public static function template_settings_form() { |
| 93 | 93 | $config = EE_Registry::instance()->CFG->template_settings; |
| 94 | - $config = isset( $config->EED_Event_Single ) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config(); |
|
| 95 | - $config->use_sortable_display_order = isset( $config->use_sortable_display_order ) ? $config->use_sortable_display_order : false; |
|
| 96 | - $config = apply_filters( 'FHEE__EED_Event_Single__template_settings_form__event_list_config', $config ); |
|
| 94 | + $config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config(); |
|
| 95 | + $config->use_sortable_display_order = isset($config->use_sortable_display_order) ? $config->use_sortable_display_order : false; |
|
| 96 | + $config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config); |
|
| 97 | 97 | |
| 98 | 98 | $event_single_order_array = array(); |
| 99 | - $event_single_order_array[ $config->display_order_tickets ] = 'tickets'; |
|
| 100 | - $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes'; |
|
| 101 | - $event_single_order_array[ $config->display_order_event ] = 'event'; |
|
| 102 | - $event_single_order_array[ $config->display_order_venue ] = 'venue'; |
|
| 99 | + $event_single_order_array[$config->display_order_tickets] = 'tickets'; |
|
| 100 | + $event_single_order_array[$config->display_order_datetimes] = 'datetimes'; |
|
| 101 | + $event_single_order_array[$config->display_order_event] = 'event'; |
|
| 102 | + $event_single_order_array[$config->display_order_venue] = 'venue'; |
|
| 103 | 103 | // get template parts |
| 104 | - $template_parts = EED_Event_Single::instance()->initialize_template_parts( $config ); |
|
| 104 | + $template_parts = EED_Event_Single::instance()->initialize_template_parts($config); |
|
| 105 | 105 | // convert to array so that we can add more properties |
| 106 | - $config = get_object_vars( $config ); |
|
| 107 | - $config[ 'event_single_display_order' ] = $template_parts->generate_sortable_list_of_template_parts( 'event-single-sortable-js', '', 'single-sortable-li single-sortable-js' ); |
|
| 108 | - EEH_Template::display_template( EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', $config ); |
|
| 106 | + $config = get_object_vars($config); |
|
| 107 | + $config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts('event-single-sortable-js', '', 'single-sortable-li single-sortable-js'); |
|
| 108 | + EEH_Template::display_template(EVENT_SINGLE_CAFF_TEMPLATES_PATH.'admin-event-single-settings.template.php', $config); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @param array $REQ |
| 118 | 118 | * @return EE_Template_Config |
| 119 | 119 | */ |
| 120 | - public static function update_template_settings( $CFG, $REQ ) { |
|
| 120 | + public static function update_template_settings($CFG, $REQ) { |
|
| 121 | 121 | $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
| 122 | 122 | ? $CFG->EED_Event_Single->display_order_event |
| 123 | 123 | : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | ? $CFG->EED_Event_Single->display_order_venue |
| 132 | 132 | : EED_Event_Single::EVENT_VENUES_PRIORITY; |
| 133 | 133 | $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
| 134 | - $CFG->EED_Event_Single->display_status_banner_single = ! empty( $REQ['display_status_banner_single'] ) |
|
| 134 | + $CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single']) |
|
| 135 | 135 | && $REQ['display_status_banner_single']; |
| 136 | - $CFG->EED_Event_Single->display_venue = ! empty( $REQ['display_venue'] ) && $REQ['display_venue']; |
|
| 137 | - $CFG->EED_Event_Single->use_sortable_display_order = ! empty( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) |
|
| 138 | - ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) |
|
| 136 | + $CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue']; |
|
| 137 | + $CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order']) |
|
| 138 | + ? absint($REQ['EED_Events_Single_use_sortable_display_order']) |
|
| 139 | 139 | : 0; |
| 140 | 140 | $CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order |
| 141 | 141 | ? $display_order_event |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order |
| 150 | 150 | ? $display_order_venue |
| 151 | 151 | : EED_Event_Single::EVENT_VENUES_PRIORITY; |
| 152 | - do_action( 'AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ ); |
|
| 152 | + do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ); |
|
| 153 | 153 | return $CFG; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -163,23 +163,23 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public static function update_event_single_order() { |
| 165 | 165 | $config_saved = false; |
| 166 | - $template_parts = sanitize_text_field( $_POST[ 'elements' ] ); |
|
| 167 | - if ( ! empty( $template_parts ) ) { |
|
| 168 | - $template_parts = explode( ',', trim( $template_parts, ',' ) ); |
|
| 169 | - foreach ( $template_parts as $key => $template_part ) { |
|
| 166 | + $template_parts = sanitize_text_field($_POST['elements']); |
|
| 167 | + if ( ! empty($template_parts)) { |
|
| 168 | + $template_parts = explode(',', trim($template_parts, ',')); |
|
| 169 | + foreach ($template_parts as $key => $template_part) { |
|
| 170 | 170 | $template_part = "display_order_$template_part"; |
| 171 | - $priority = ( $key * 10 ) + EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
| 171 | + $priority = ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
| 172 | 172 | EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority; |
| 173 | - do_action( "AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority ); |
|
| 173 | + do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority); |
|
| 174 | 174 | } |
| 175 | - $config_saved = EE_Registry::instance()->CFG->update_espresso_config( false, false ); |
|
| 175 | + $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false); |
|
| 176 | 176 | } |
| 177 | - if ( $config_saved ) { |
|
| 178 | - EE_Error::add_success( __( 'Display Order has been successfully updated.', 'event_espresso' ) ); |
|
| 177 | + if ($config_saved) { |
|
| 178 | + EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso')); |
|
| 179 | 179 | } else { |
| 180 | - EE_Error::add_error( __( 'Display Order was not updated.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 180 | + EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 181 | 181 | } |
| 182 | - echo wp_json_encode( EE_Error::get_notices( false )); |
|
| 182 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
| 183 | 183 | exit(); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param WP $WP |
| 193 | 193 | * @return void |
| 194 | 194 | */ |
| 195 | - public function run( $WP ) { |
|
| 195 | + public function run($WP) { |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | |
@@ -86,52 +86,52 @@ discard block |
||
| 86 | 86 | $gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object( 'general_settings' ); |
| 87 | 87 | if ( $gen_set_admin instanceof General_Settings_Admin_Page ) { |
| 88 | 88 | remove_action( |
| 89 | - 'AHEE__template_settings__template__before_settings_form', |
|
| 90 | - array( $gen_set_admin, 'template_settings_caff_features' ), |
|
| 91 | - 100 |
|
| 92 | - ); |
|
| 89 | + 'AHEE__template_settings__template__before_settings_form', |
|
| 90 | + array( $gen_set_admin, 'template_settings_caff_features' ), |
|
| 91 | + 100 |
|
| 92 | + ); |
|
| 93 | 93 | } |
| 94 | 94 | // first just grab the template settings |
| 95 | 95 | $config = EE_Registry::instance()->CFG->template_settings; |
| 96 | 96 | // then if the Event Archive config is valid, use that, else create a new one |
| 97 | 97 | $config = isset( $config->EED_Events_Archive ) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config |
| 98 | - ? $config->EED_Events_Archive |
|
| 99 | - : new EE_Events_Archive_Config(); |
|
| 98 | + ? $config->EED_Events_Archive |
|
| 99 | + : new EE_Events_Archive_Config(); |
|
| 100 | 100 | $config = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config ); |
| 101 | 101 | $config->display_status_banner = isset( $config->display_status_banner ) |
| 102 | - ? $config->display_status_banner |
|
| 103 | - : 0; |
|
| 102 | + ? $config->display_status_banner |
|
| 103 | + : 0; |
|
| 104 | 104 | $config->display_description = isset( $config->display_description ) |
| 105 | - ? $config->display_description |
|
| 106 | - : 1; |
|
| 105 | + ? $config->display_description |
|
| 106 | + : 1; |
|
| 107 | 107 | $config->display_ticket_selector = isset( $config->display_ticket_selector ) |
| 108 | - ? $config->display_ticket_selector |
|
| 109 | - : 0; |
|
| 108 | + ? $config->display_ticket_selector |
|
| 109 | + : 0; |
|
| 110 | 110 | $config->display_datetimes = isset( $config->display_datetimes ) |
| 111 | - ? $config->display_datetimes |
|
| 112 | - : 1; |
|
| 111 | + ? $config->display_datetimes |
|
| 112 | + : 1; |
|
| 113 | 113 | $config->display_venue = isset( $config->display_venue ) |
| 114 | - ? $config->display_venue |
|
| 115 | - : 0; |
|
| 114 | + ? $config->display_venue |
|
| 115 | + : 0; |
|
| 116 | 116 | $config->display_expired_events = isset( $config->display_expired_events ) |
| 117 | - ? $config->display_expired_events |
|
| 118 | - : 0; |
|
| 117 | + ? $config->display_expired_events |
|
| 118 | + : 0; |
|
| 119 | 119 | // display order options |
| 120 | 120 | $config->use_sortable_display_order = isset( $config->use_sortable_display_order ) |
| 121 | - ? $config->use_sortable_display_order |
|
| 122 | - : false; |
|
| 121 | + ? $config->use_sortable_display_order |
|
| 122 | + : false; |
|
| 123 | 123 | $config->display_order_tickets = isset( $config->display_order_tickets ) |
| 124 | - ? $config->display_order_tickets |
|
| 125 | - : 120; |
|
| 124 | + ? $config->display_order_tickets |
|
| 125 | + : 120; |
|
| 126 | 126 | $config->display_order_datetimes = isset( $config->display_order_datetimes ) |
| 127 | - ? $config->display_order_datetimes |
|
| 128 | - : 110; |
|
| 127 | + ? $config->display_order_datetimes |
|
| 128 | + : 110; |
|
| 129 | 129 | $config->display_order_event = isset( $config->display_order_event ) |
| 130 | - ? $config->display_order_event |
|
| 131 | - : 100; |
|
| 130 | + ? $config->display_order_event |
|
| 131 | + : 100; |
|
| 132 | 132 | $config->display_order_venue = isset( $config->display_order_venue ) |
| 133 | - ? $config->display_order_venue |
|
| 134 | - : 130; |
|
| 133 | + ? $config->display_order_venue |
|
| 134 | + : 130; |
|
| 135 | 135 | // get template parts |
| 136 | 136 | $template_parts = EED_Events_Archive::instance()->initialize_template_parts( $config ); |
| 137 | 137 | // convert to array so that we can add more properties |
@@ -165,17 +165,17 @@ discard block |
||
| 165 | 165 | $config->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; |
| 166 | 166 | $config->use_sortable_display_order = isset( $REQ['EED_Events_Archive_use_sortable_display_order'] ) ? absint( $REQ['EED_Events_Archive_use_sortable_display_order'] ) : 0; |
| 167 | 167 | $config->display_order_event = isset( $CFG->EED_Events_Archive->display_order_event ) && $config->use_sortable_display_order |
| 168 | - ? $CFG->EED_Events_Archive->display_order_event |
|
| 169 | - : EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
| 168 | + ? $CFG->EED_Events_Archive->display_order_event |
|
| 169 | + : EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
| 170 | 170 | $config->display_order_datetimes = isset( $CFG->EED_Events_Archive->display_order_datetimes ) && $config->use_sortable_display_order |
| 171 | - ? $CFG->EED_Events_Archive->display_order_datetimes |
|
| 172 | - : EED_Events_Archive::EVENT_DATETIMES_PRIORITY; |
|
| 171 | + ? $CFG->EED_Events_Archive->display_order_datetimes |
|
| 172 | + : EED_Events_Archive::EVENT_DATETIMES_PRIORITY; |
|
| 173 | 173 | $config->display_order_tickets = isset( $CFG->EED_Events_Archive->display_order_tickets ) && $config->use_sortable_display_order |
| 174 | - ? $CFG->EED_Events_Archive->display_order_tickets |
|
| 175 | - : EED_Events_Archive::EVENT_TICKETS_PRIORITY; |
|
| 174 | + ? $CFG->EED_Events_Archive->display_order_tickets |
|
| 175 | + : EED_Events_Archive::EVENT_TICKETS_PRIORITY; |
|
| 176 | 176 | $config->display_order_venue = isset( $CFG->EED_Events_Archive->display_order_venue ) && $config->use_sortable_display_order |
| 177 | - ? $CFG->EED_Events_Archive->display_order_venue |
|
| 178 | - : EED_Events_Archive::EVENT_VENUES_PRIORITY; |
|
| 177 | + ? $CFG->EED_Events_Archive->display_order_venue |
|
| 178 | + : EED_Events_Archive::EVENT_VENUES_PRIORITY; |
|
| 179 | 179 | } |
| 180 | 180 | $CFG->EED_Events_Archive = $config; |
| 181 | 181 | do_action( 'AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ ); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @return EED_Events_Archive_Caff |
| 29 | 29 | */ |
| 30 | 30 | public static function instance() { |
| 31 | - return parent::get_instance( __CLASS__ ); |
|
| 31 | + return parent::get_instance(__CLASS__); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | * @return void |
| 50 | 50 | */ |
| 51 | 51 | public static function set_hooks_admin() { |
| 52 | - define( 'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
| 53 | - define( 'EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
| 54 | - add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Events_Archive_Caff', 'template_settings_form' ), 10 ); |
|
| 55 | - add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Events_Archive_Caff', 'update_template_settings' ), 10, 2 ); |
|
| 52 | + define('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
| 53 | + define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
| 54 | + add_action('AHEE__template_settings__template__before_settings_form', array('EED_Events_Archive_Caff', 'template_settings_form'), 10); |
|
| 55 | + add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Events_Archive_Caff', 'update_template_settings'), 10, 2); |
|
| 56 | 56 | // AJAX |
| 57 | - add_action( 'wp_ajax_espresso_update_event_archive_order', array( 'EED_Events_Archive_Caff', 'update_event_archive_order' ) ); |
|
| 58 | - add_action( 'wp_ajax_nopriv_espresso_update_event_archive_order', array( 'EED_Events_Archive_Caff', 'update_event_archive_order' ) ); |
|
| 57 | + add_action('wp_ajax_espresso_update_event_archive_order', array('EED_Events_Archive_Caff', 'update_event_archive_order')); |
|
| 58 | + add_action('wp_ajax_nopriv_espresso_update_event_archive_order', array('EED_Events_Archive_Caff', 'update_event_archive_order')); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param WP $WP |
| 69 | 69 | * @return void |
| 70 | 70 | */ |
| 71 | - public function run( $WP ) { |
|
| 71 | + public function run($WP) { |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
@@ -83,61 +83,61 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public static function template_settings_form() { |
| 85 | 85 | // grab general settings admin page and remove the existing hook callback |
| 86 | - $gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object( 'general_settings' ); |
|
| 87 | - if ( $gen_set_admin instanceof General_Settings_Admin_Page ) { |
|
| 86 | + $gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object('general_settings'); |
|
| 87 | + if ($gen_set_admin instanceof General_Settings_Admin_Page) { |
|
| 88 | 88 | remove_action( |
| 89 | 89 | 'AHEE__template_settings__template__before_settings_form', |
| 90 | - array( $gen_set_admin, 'template_settings_caff_features' ), |
|
| 90 | + array($gen_set_admin, 'template_settings_caff_features'), |
|
| 91 | 91 | 100 |
| 92 | 92 | ); |
| 93 | 93 | } |
| 94 | 94 | // first just grab the template settings |
| 95 | 95 | $config = EE_Registry::instance()->CFG->template_settings; |
| 96 | 96 | // then if the Event Archive config is valid, use that, else create a new one |
| 97 | - $config = isset( $config->EED_Events_Archive ) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
| 97 | + $config = isset($config->EED_Events_Archive) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
| 98 | 98 | ? $config->EED_Events_Archive |
| 99 | 99 | : new EE_Events_Archive_Config(); |
| 100 | - $config = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config ); |
|
| 101 | - $config->display_status_banner = isset( $config->display_status_banner ) |
|
| 100 | + $config = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config); |
|
| 101 | + $config->display_status_banner = isset($config->display_status_banner) |
|
| 102 | 102 | ? $config->display_status_banner |
| 103 | 103 | : 0; |
| 104 | - $config->display_description = isset( $config->display_description ) |
|
| 104 | + $config->display_description = isset($config->display_description) |
|
| 105 | 105 | ? $config->display_description |
| 106 | 106 | : 1; |
| 107 | - $config->display_ticket_selector = isset( $config->display_ticket_selector ) |
|
| 107 | + $config->display_ticket_selector = isset($config->display_ticket_selector) |
|
| 108 | 108 | ? $config->display_ticket_selector |
| 109 | 109 | : 0; |
| 110 | - $config->display_datetimes = isset( $config->display_datetimes ) |
|
| 110 | + $config->display_datetimes = isset($config->display_datetimes) |
|
| 111 | 111 | ? $config->display_datetimes |
| 112 | 112 | : 1; |
| 113 | - $config->display_venue = isset( $config->display_venue ) |
|
| 113 | + $config->display_venue = isset($config->display_venue) |
|
| 114 | 114 | ? $config->display_venue |
| 115 | 115 | : 0; |
| 116 | - $config->display_expired_events = isset( $config->display_expired_events ) |
|
| 116 | + $config->display_expired_events = isset($config->display_expired_events) |
|
| 117 | 117 | ? $config->display_expired_events |
| 118 | 118 | : 0; |
| 119 | 119 | // display order options |
| 120 | - $config->use_sortable_display_order = isset( $config->use_sortable_display_order ) |
|
| 120 | + $config->use_sortable_display_order = isset($config->use_sortable_display_order) |
|
| 121 | 121 | ? $config->use_sortable_display_order |
| 122 | 122 | : false; |
| 123 | - $config->display_order_tickets = isset( $config->display_order_tickets ) |
|
| 123 | + $config->display_order_tickets = isset($config->display_order_tickets) |
|
| 124 | 124 | ? $config->display_order_tickets |
| 125 | 125 | : 120; |
| 126 | - $config->display_order_datetimes = isset( $config->display_order_datetimes ) |
|
| 126 | + $config->display_order_datetimes = isset($config->display_order_datetimes) |
|
| 127 | 127 | ? $config->display_order_datetimes |
| 128 | 128 | : 110; |
| 129 | - $config->display_order_event = isset( $config->display_order_event ) |
|
| 129 | + $config->display_order_event = isset($config->display_order_event) |
|
| 130 | 130 | ? $config->display_order_event |
| 131 | 131 | : 100; |
| 132 | - $config->display_order_venue = isset( $config->display_order_venue ) |
|
| 132 | + $config->display_order_venue = isset($config->display_order_venue) |
|
| 133 | 133 | ? $config->display_order_venue |
| 134 | 134 | : 130; |
| 135 | 135 | // get template parts |
| 136 | - $template_parts = EED_Events_Archive::instance()->initialize_template_parts( $config ); |
|
| 136 | + $template_parts = EED_Events_Archive::instance()->initialize_template_parts($config); |
|
| 137 | 137 | // convert to array so that we can add more properties |
| 138 | - $config = get_object_vars( $config ); |
|
| 139 | - $config[ 'event_archive_display_order' ] = $template_parts->generate_sortable_list_of_template_parts( 'event-archive-sortable-js', '', 'archive-sortable-li archive-sortable-js' ); |
|
| 140 | - EEH_Template::display_template( EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $config ); |
|
| 138 | + $config = get_object_vars($config); |
|
| 139 | + $config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts('event-archive-sortable-js', '', 'archive-sortable-li archive-sortable-js'); |
|
| 140 | + EEH_Template::display_template(EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH.'admin-event-list-settings.template.php', $config); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | |
@@ -153,32 +153,32 @@ discard block |
||
| 153 | 153 | * @param array $REQ |
| 154 | 154 | * @return EE_Events_Archive_Config |
| 155 | 155 | */ |
| 156 | - public static function update_template_settings( $CFG, $REQ ) { |
|
| 156 | + public static function update_template_settings($CFG, $REQ) { |
|
| 157 | 157 | $config = new EE_Events_Archive_Config(); |
| 158 | 158 | // unless we are resetting the config... |
| 159 | - if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) { |
|
| 160 | - $config->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0; |
|
| 161 | - $config->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1; |
|
| 162 | - $config->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0; |
|
| 163 | - $config->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1; |
|
| 164 | - $config->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0; |
|
| 165 | - $config->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; |
|
| 166 | - $config->use_sortable_display_order = isset( $REQ['EED_Events_Archive_use_sortable_display_order'] ) ? absint( $REQ['EED_Events_Archive_use_sortable_display_order'] ) : 0; |
|
| 167 | - $config->display_order_event = isset( $CFG->EED_Events_Archive->display_order_event ) && $config->use_sortable_display_order |
|
| 159 | + if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) { |
|
| 160 | + $config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
| 161 | + $config->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
| 162 | + $config->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
| 163 | + $config->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1; |
|
| 164 | + $config->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0; |
|
| 165 | + $config->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; |
|
| 166 | + $config->use_sortable_display_order = isset($REQ['EED_Events_Archive_use_sortable_display_order']) ? absint($REQ['EED_Events_Archive_use_sortable_display_order']) : 0; |
|
| 167 | + $config->display_order_event = isset($CFG->EED_Events_Archive->display_order_event) && $config->use_sortable_display_order |
|
| 168 | 168 | ? $CFG->EED_Events_Archive->display_order_event |
| 169 | 169 | : EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
| 170 | - $config->display_order_datetimes = isset( $CFG->EED_Events_Archive->display_order_datetimes ) && $config->use_sortable_display_order |
|
| 170 | + $config->display_order_datetimes = isset($CFG->EED_Events_Archive->display_order_datetimes) && $config->use_sortable_display_order |
|
| 171 | 171 | ? $CFG->EED_Events_Archive->display_order_datetimes |
| 172 | 172 | : EED_Events_Archive::EVENT_DATETIMES_PRIORITY; |
| 173 | - $config->display_order_tickets = isset( $CFG->EED_Events_Archive->display_order_tickets ) && $config->use_sortable_display_order |
|
| 173 | + $config->display_order_tickets = isset($CFG->EED_Events_Archive->display_order_tickets) && $config->use_sortable_display_order |
|
| 174 | 174 | ? $CFG->EED_Events_Archive->display_order_tickets |
| 175 | 175 | : EED_Events_Archive::EVENT_TICKETS_PRIORITY; |
| 176 | - $config->display_order_venue = isset( $CFG->EED_Events_Archive->display_order_venue ) && $config->use_sortable_display_order |
|
| 176 | + $config->display_order_venue = isset($CFG->EED_Events_Archive->display_order_venue) && $config->use_sortable_display_order |
|
| 177 | 177 | ? $CFG->EED_Events_Archive->display_order_venue |
| 178 | 178 | : EED_Events_Archive::EVENT_VENUES_PRIORITY; |
| 179 | 179 | } |
| 180 | 180 | $CFG->EED_Events_Archive = $config; |
| 181 | - do_action( 'AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ ); |
|
| 181 | + do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ); |
|
| 182 | 182 | return $CFG; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -192,12 +192,12 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public static function update_event_archive_order() { |
| 194 | 194 | $config_saved = false; |
| 195 | - $template_parts = sanitize_text_field( $_POST[ 'elements' ] ); |
|
| 196 | - if ( ! empty( $template_parts ) ) { |
|
| 197 | - $template_parts = explode( ',', trim( $template_parts, ',' ) ); |
|
| 198 | - foreach ( $template_parts as $key => $template_part ) { |
|
| 195 | + $template_parts = sanitize_text_field($_POST['elements']); |
|
| 196 | + if ( ! empty($template_parts)) { |
|
| 197 | + $template_parts = explode(',', trim($template_parts, ',')); |
|
| 198 | + foreach ($template_parts as $key => $template_part) { |
|
| 199 | 199 | $template_part = "display_order_$template_part"; |
| 200 | - $priority = ( $key * 10 ) + EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
| 200 | + $priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
| 201 | 201 | if ( |
| 202 | 202 | property_exists( |
| 203 | 203 | EE_Registry::instance()->CFG->template_settings->EED_Events_Archive, |
@@ -206,16 +206,16 @@ discard block |
||
| 206 | 206 | ) { |
| 207 | 207 | EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->{$template_part} = $priority; |
| 208 | 208 | } |
| 209 | - do_action( "AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority ); |
|
| 209 | + do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority); |
|
| 210 | 210 | } |
| 211 | - $config_saved = EE_Registry::instance()->CFG->update_espresso_config( false, false ); |
|
| 211 | + $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false); |
|
| 212 | 212 | } |
| 213 | - if ( $config_saved ) { |
|
| 214 | - EE_Error::add_success( __( 'Display Order has been successfully updated.', 'event_espresso' ) ); |
|
| 213 | + if ($config_saved) { |
|
| 214 | + EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso')); |
|
| 215 | 215 | } else { |
| 216 | - EE_Error::add_error( __( 'Display Order was not updated.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 216 | + EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 217 | 217 | } |
| 218 | - echo wp_json_encode( EE_Error::get_notices( false ) ); |
|
| 218 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
| 219 | 219 | exit(); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | //namespace EventEspresso\core\libraries\templates; |
| 3 | 3 | if (!defined('EVENT_ESPRESSO_VERSION')) { |
| 4 | - exit('No direct script access allowed'); |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | |
@@ -19,198 +19,198 @@ discard block |
||
| 19 | 19 | class EE_Template_Part_Manager |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @param EE_Template_Part_PriorityQueue $template_parts |
|
| 24 | - */ |
|
| 25 | - protected $template_parts; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @param array $priorities |
|
| 29 | - */ |
|
| 30 | - protected $priorities = array(); |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @param int $event_desc_priority |
|
| 34 | - */ |
|
| 35 | - protected $event_desc_priority; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @param string $before_event_content |
|
| 39 | - */ |
|
| 40 | - protected $before_event_content; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @param string $event_content |
|
| 44 | - */ |
|
| 45 | - protected $event_content; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @param string $after_event_content |
|
| 49 | - */ |
|
| 50 | - protected $after_event_content; |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * class constructor |
|
| 55 | - */ |
|
| 56 | - public function __construct() |
|
| 57 | - { |
|
| 58 | - $this->template_parts = new EE_Template_Part_PriorityQueue(); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * add_template_part |
|
| 64 | - * |
|
| 65 | - * used for setting the details about a particular template part |
|
| 66 | - * |
|
| 67 | - * @param string $name - just a simple string identifier - do NOT use 'event' |
|
| 68 | - * @param string $label - template part label displayed in admin |
|
| 69 | - * @param string $template - name or path of template to be used by EEH_Template::locate_template() |
|
| 70 | - * @param int $priority - order in which template parts should be applied |
|
| 71 | - */ |
|
| 72 | - public function add_template_part($name, $label, $template, $priority) |
|
| 73 | - { |
|
| 74 | - // SplPriorityQueue doesn't play nice with multiple items having the same priority |
|
| 75 | - // so if the incoming priority is already occupied, then let's increment it by one, |
|
| 76 | - // and then pass everything back into this method and try again with the new priority |
|
| 77 | - if (isset($this->priorities[$priority])) { |
|
| 78 | - $priority++; |
|
| 79 | - $this->add_template_part($name, $label, $template, $priority); |
|
| 80 | - return; |
|
| 81 | - } |
|
| 82 | - // kk now we can mark this priority as being occupied |
|
| 83 | - $this->priorities[$priority] = true; |
|
| 84 | - // create the template part and add to the queue |
|
| 85 | - $this->template_parts->insert( |
|
| 86 | - new EE_Template_Part($name, $label, $template, $priority), |
|
| 87 | - $priority |
|
| 88 | - ); |
|
| 89 | - if ($name === 'event') { |
|
| 90 | - $this->event_desc_priority = $priority; |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * apply_template_part_filters |
|
| 97 | - * |
|
| 98 | - * adds template parts to the supplied content |
|
| 99 | - * according to the details set when the template parts were added |
|
| 100 | - * |
|
| 101 | - * @access public |
|
| 102 | - * @param string $content |
|
| 103 | - * @return string |
|
| 104 | - */ |
|
| 105 | - public function apply_template_part_filters($content = '') |
|
| 106 | - { |
|
| 107 | - $this->template_parts->rewind(); |
|
| 108 | - // loop through template parts and position content |
|
| 109 | - while ($this->template_parts->valid()) { |
|
| 110 | - $this->_position_template_part( |
|
| 111 | - $content, |
|
| 112 | - $this->template_parts->current()->template(), |
|
| 113 | - $this->template_parts->current()->priority() |
|
| 114 | - ); |
|
| 115 | - $this->template_parts->next(); |
|
| 116 | - } |
|
| 117 | - // now simply add our three strings of content together |
|
| 118 | - return $this->before_event_content . $this->event_content . $this->after_event_content; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * position_template_part |
|
| 124 | - * |
|
| 125 | - * based on the priority of the incoming template part |
|
| 126 | - * relative to the known event description template part priority, |
|
| 127 | - * this method will assign template parts to one of the following: |
|
| 128 | - * $this->before_event_content |
|
| 129 | - * $this->event_content |
|
| 130 | - * $this->after_event_content |
|
| 131 | - * |
|
| 132 | - * @access protected |
|
| 133 | - * @param string $content |
|
| 134 | - * @param string $template |
|
| 135 | - * @param int $priority |
|
| 136 | - * @return void |
|
| 137 | - */ |
|
| 138 | - protected function _position_template_part($content, $template, $priority) |
|
| 139 | - { |
|
| 140 | - // Event Description content is the actual incoming content itself |
|
| 141 | - if ($priority === $this->event_desc_priority) { |
|
| 142 | - $this->event_content = $content; |
|
| 143 | - } else if ($priority < $this->event_desc_priority) { |
|
| 144 | - // everything BEFORE the Event Description |
|
| 145 | - $this->before_event_content .= EEH_Template::locate_template($template); |
|
| 146 | - } else if ($priority > $this->event_desc_priority) { |
|
| 147 | - // everything AFTER the Event Description |
|
| 148 | - $this->after_event_content .= EEH_Template::locate_template($template); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * generate_sortable_list_of_template_parts |
|
| 155 | - * |
|
| 156 | - * creates an HTML list (<ul>) with list items (<li>) for each template part, |
|
| 157 | - * in a format that can be used as a sortable list in the admin |
|
| 158 | - * |
|
| 159 | - * @access public |
|
| 160 | - * @param string $list_css_id |
|
| 161 | - * @param string $list_css_class |
|
| 162 | - * @param string $list_item_css_class |
|
| 163 | - * @param string $list_item_css_id_prefix |
|
| 164 | - * @return string |
|
| 165 | - */ |
|
| 166 | - public function generate_sortable_list_of_template_parts( |
|
| 167 | - $list_css_id = '', |
|
| 168 | - $list_css_class = '', |
|
| 169 | - $list_item_css_class = '', |
|
| 170 | - $list_item_css_id_prefix = '' |
|
| 171 | - ) |
|
| 172 | - { |
|
| 173 | - $event_archive_display_order = EEH_HTML::ul($list_css_id, $list_css_class); |
|
| 174 | - $this->template_parts->rewind(); |
|
| 175 | - // loop through template parts and add template content |
|
| 176 | - while ($this->template_parts->valid()) { |
|
| 177 | - $event_archive_display_order .= EEH_HTML::li( |
|
| 178 | - EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') . |
|
| 179 | - EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') . |
|
| 180 | - $this->template_parts->current()->label(), |
|
| 181 | - $list_item_css_id_prefix . $this->template_parts->current()->name(), |
|
| 182 | - $list_item_css_class |
|
| 183 | - ); |
|
| 184 | - $this->template_parts->next(); |
|
| 185 | - } |
|
| 186 | - $event_archive_display_order .= EEH_HTML::ulx(); |
|
| 187 | - return $event_archive_display_order; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * display_template_parts |
|
| 193 | - * |
|
| 194 | - * just for debugging purposes |
|
| 195 | - * |
|
| 196 | - * @access public |
|
| 197 | - * @return void |
|
| 198 | - */ |
|
| 199 | - public function display_template_parts() |
|
| 200 | - { |
|
| 201 | - if (WP_DEBUG) { |
|
| 202 | - $this->template_parts->rewind(); |
|
| 203 | - while ($this->template_parts->valid()) { |
|
| 204 | - EEH_Debug_Tools::printr( |
|
| 205 | - $this->template_parts->current(), |
|
| 206 | - 'template_part', |
|
| 207 | - __FILE__, |
|
| 208 | - __LINE__ |
|
| 209 | - ); |
|
| 210 | - $this->template_parts->next(); |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - } |
|
| 22 | + /** |
|
| 23 | + * @param EE_Template_Part_PriorityQueue $template_parts |
|
| 24 | + */ |
|
| 25 | + protected $template_parts; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @param array $priorities |
|
| 29 | + */ |
|
| 30 | + protected $priorities = array(); |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @param int $event_desc_priority |
|
| 34 | + */ |
|
| 35 | + protected $event_desc_priority; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @param string $before_event_content |
|
| 39 | + */ |
|
| 40 | + protected $before_event_content; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @param string $event_content |
|
| 44 | + */ |
|
| 45 | + protected $event_content; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @param string $after_event_content |
|
| 49 | + */ |
|
| 50 | + protected $after_event_content; |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * class constructor |
|
| 55 | + */ |
|
| 56 | + public function __construct() |
|
| 57 | + { |
|
| 58 | + $this->template_parts = new EE_Template_Part_PriorityQueue(); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * add_template_part |
|
| 64 | + * |
|
| 65 | + * used for setting the details about a particular template part |
|
| 66 | + * |
|
| 67 | + * @param string $name - just a simple string identifier - do NOT use 'event' |
|
| 68 | + * @param string $label - template part label displayed in admin |
|
| 69 | + * @param string $template - name or path of template to be used by EEH_Template::locate_template() |
|
| 70 | + * @param int $priority - order in which template parts should be applied |
|
| 71 | + */ |
|
| 72 | + public function add_template_part($name, $label, $template, $priority) |
|
| 73 | + { |
|
| 74 | + // SplPriorityQueue doesn't play nice with multiple items having the same priority |
|
| 75 | + // so if the incoming priority is already occupied, then let's increment it by one, |
|
| 76 | + // and then pass everything back into this method and try again with the new priority |
|
| 77 | + if (isset($this->priorities[$priority])) { |
|
| 78 | + $priority++; |
|
| 79 | + $this->add_template_part($name, $label, $template, $priority); |
|
| 80 | + return; |
|
| 81 | + } |
|
| 82 | + // kk now we can mark this priority as being occupied |
|
| 83 | + $this->priorities[$priority] = true; |
|
| 84 | + // create the template part and add to the queue |
|
| 85 | + $this->template_parts->insert( |
|
| 86 | + new EE_Template_Part($name, $label, $template, $priority), |
|
| 87 | + $priority |
|
| 88 | + ); |
|
| 89 | + if ($name === 'event') { |
|
| 90 | + $this->event_desc_priority = $priority; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * apply_template_part_filters |
|
| 97 | + * |
|
| 98 | + * adds template parts to the supplied content |
|
| 99 | + * according to the details set when the template parts were added |
|
| 100 | + * |
|
| 101 | + * @access public |
|
| 102 | + * @param string $content |
|
| 103 | + * @return string |
|
| 104 | + */ |
|
| 105 | + public function apply_template_part_filters($content = '') |
|
| 106 | + { |
|
| 107 | + $this->template_parts->rewind(); |
|
| 108 | + // loop through template parts and position content |
|
| 109 | + while ($this->template_parts->valid()) { |
|
| 110 | + $this->_position_template_part( |
|
| 111 | + $content, |
|
| 112 | + $this->template_parts->current()->template(), |
|
| 113 | + $this->template_parts->current()->priority() |
|
| 114 | + ); |
|
| 115 | + $this->template_parts->next(); |
|
| 116 | + } |
|
| 117 | + // now simply add our three strings of content together |
|
| 118 | + return $this->before_event_content . $this->event_content . $this->after_event_content; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * position_template_part |
|
| 124 | + * |
|
| 125 | + * based on the priority of the incoming template part |
|
| 126 | + * relative to the known event description template part priority, |
|
| 127 | + * this method will assign template parts to one of the following: |
|
| 128 | + * $this->before_event_content |
|
| 129 | + * $this->event_content |
|
| 130 | + * $this->after_event_content |
|
| 131 | + * |
|
| 132 | + * @access protected |
|
| 133 | + * @param string $content |
|
| 134 | + * @param string $template |
|
| 135 | + * @param int $priority |
|
| 136 | + * @return void |
|
| 137 | + */ |
|
| 138 | + protected function _position_template_part($content, $template, $priority) |
|
| 139 | + { |
|
| 140 | + // Event Description content is the actual incoming content itself |
|
| 141 | + if ($priority === $this->event_desc_priority) { |
|
| 142 | + $this->event_content = $content; |
|
| 143 | + } else if ($priority < $this->event_desc_priority) { |
|
| 144 | + // everything BEFORE the Event Description |
|
| 145 | + $this->before_event_content .= EEH_Template::locate_template($template); |
|
| 146 | + } else if ($priority > $this->event_desc_priority) { |
|
| 147 | + // everything AFTER the Event Description |
|
| 148 | + $this->after_event_content .= EEH_Template::locate_template($template); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * generate_sortable_list_of_template_parts |
|
| 155 | + * |
|
| 156 | + * creates an HTML list (<ul>) with list items (<li>) for each template part, |
|
| 157 | + * in a format that can be used as a sortable list in the admin |
|
| 158 | + * |
|
| 159 | + * @access public |
|
| 160 | + * @param string $list_css_id |
|
| 161 | + * @param string $list_css_class |
|
| 162 | + * @param string $list_item_css_class |
|
| 163 | + * @param string $list_item_css_id_prefix |
|
| 164 | + * @return string |
|
| 165 | + */ |
|
| 166 | + public function generate_sortable_list_of_template_parts( |
|
| 167 | + $list_css_id = '', |
|
| 168 | + $list_css_class = '', |
|
| 169 | + $list_item_css_class = '', |
|
| 170 | + $list_item_css_id_prefix = '' |
|
| 171 | + ) |
|
| 172 | + { |
|
| 173 | + $event_archive_display_order = EEH_HTML::ul($list_css_id, $list_css_class); |
|
| 174 | + $this->template_parts->rewind(); |
|
| 175 | + // loop through template parts and add template content |
|
| 176 | + while ($this->template_parts->valid()) { |
|
| 177 | + $event_archive_display_order .= EEH_HTML::li( |
|
| 178 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') . |
|
| 179 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') . |
|
| 180 | + $this->template_parts->current()->label(), |
|
| 181 | + $list_item_css_id_prefix . $this->template_parts->current()->name(), |
|
| 182 | + $list_item_css_class |
|
| 183 | + ); |
|
| 184 | + $this->template_parts->next(); |
|
| 185 | + } |
|
| 186 | + $event_archive_display_order .= EEH_HTML::ulx(); |
|
| 187 | + return $event_archive_display_order; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * display_template_parts |
|
| 193 | + * |
|
| 194 | + * just for debugging purposes |
|
| 195 | + * |
|
| 196 | + * @access public |
|
| 197 | + * @return void |
|
| 198 | + */ |
|
| 199 | + public function display_template_parts() |
|
| 200 | + { |
|
| 201 | + if (WP_DEBUG) { |
|
| 202 | + $this->template_parts->rewind(); |
|
| 203 | + while ($this->template_parts->valid()) { |
|
| 204 | + EEH_Debug_Tools::printr( |
|
| 205 | + $this->template_parts->current(), |
|
| 206 | + 'template_part', |
|
| 207 | + __FILE__, |
|
| 208 | + __LINE__ |
|
| 209 | + ); |
|
| 210 | + $this->template_parts->next(); |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | 214 | } |
| 215 | 215 | // End of file EE_Template_Part_Manager.class.php |
| 216 | 216 | // Location: /EE_Template_Part_Manager.class.php |
| 217 | 217 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | //namespace EventEspresso\core\libraries\templates; |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $this->template_parts->next(); |
| 116 | 116 | } |
| 117 | 117 | // now simply add our three strings of content together |
| 118 | - return $this->before_event_content . $this->event_content . $this->after_event_content; |
|
| 118 | + return $this->before_event_content.$this->event_content.$this->after_event_content; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | // loop through template parts and add template content |
| 176 | 176 | while ($this->template_parts->valid()) { |
| 177 | 177 | $event_archive_display_order .= EEH_HTML::li( |
| 178 | - EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') . |
|
| 179 | - EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') . |
|
| 178 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2'). |
|
| 179 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2'). |
|
| 180 | 180 | $this->template_parts->current()->label(), |
| 181 | - $list_item_css_id_prefix . $this->template_parts->current()->name(), |
|
| 181 | + $list_item_css_id_prefix.$this->template_parts->current()->name(), |
|
| 182 | 182 | $list_item_css_class |
| 183 | 183 | ); |
| 184 | 184 | $this->template_parts->next(); |
@@ -12,145 +12,145 @@ |
||
| 12 | 12 | abstract class EE_Configurable extends EE_Base |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var $_config |
|
| 17 | - * @type EE_Config_Base |
|
| 18 | - */ |
|
| 19 | - protected $_config; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @var $_config_section |
|
| 23 | - * @type string |
|
| 24 | - */ |
|
| 25 | - protected $_config_section = ''; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var $_config_class |
|
| 29 | - * @type string |
|
| 30 | - */ |
|
| 31 | - protected $_config_class = ''; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var $_config_name |
|
| 35 | - * @type string |
|
| 36 | - */ |
|
| 37 | - protected $_config_name = ''; |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @param string $config_section |
|
| 42 | - */ |
|
| 43 | - public function set_config_section($config_section = '') |
|
| 44 | - { |
|
| 45 | - $this->_config_section = !empty($config_section) ? $config_section : 'modules'; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @return mixed |
|
| 51 | - */ |
|
| 52 | - public function config_section() |
|
| 53 | - { |
|
| 54 | - return $this->_config_section; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @param string $config_class |
|
| 60 | - */ |
|
| 61 | - public function set_config_class($config_class = '') |
|
| 62 | - { |
|
| 63 | - $this->_config_class = $config_class; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @return mixed |
|
| 69 | - */ |
|
| 70 | - public function config_class() |
|
| 71 | - { |
|
| 72 | - return $this->_config_class; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param mixed $config_name |
|
| 78 | - */ |
|
| 79 | - public function set_config_name($config_name) |
|
| 80 | - { |
|
| 81 | - $this->_config_name = !empty($config_name) ? $config_name : get_called_class(); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @return mixed |
|
| 87 | - */ |
|
| 88 | - public function config_name() |
|
| 89 | - { |
|
| 90 | - return $this->_config_name; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * set_config |
|
| 96 | - * this method integrates directly with EE_Config to set up the config object for this class |
|
| 97 | - * |
|
| 98 | - * @access protected |
|
| 99 | - * @param EE_Config_Base $config_obj |
|
| 100 | - * @return mixed EE_Config_Base | NULL |
|
| 101 | - */ |
|
| 102 | - protected function _set_config(EE_Config_Base $config_obj = null) |
|
| 103 | - { |
|
| 104 | - return EE_Config::instance()->set_config( |
|
| 105 | - $this->config_section(), |
|
| 106 | - $this->config_name(), |
|
| 107 | - $this->config_class(), |
|
| 108 | - $config_obj |
|
| 109 | - ); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * _update_config |
|
| 115 | - * this method integrates directly with EE_Config to update an existing config object for this class |
|
| 116 | - * |
|
| 117 | - * @access protected |
|
| 118 | - * @param EE_Config_Base $config_obj |
|
| 119 | - * @throws \EE_Error |
|
| 120 | - * @return mixed EE_Config_Base | NULL |
|
| 121 | - */ |
|
| 122 | - public function _update_config(EE_Config_Base $config_obj = null) |
|
| 123 | - { |
|
| 124 | - $config_class = $this->config_class(); |
|
| 125 | - if (!$config_obj instanceof $config_class) { |
|
| 126 | - throw new EE_Error( |
|
| 127 | - sprintf( |
|
| 128 | - __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
|
| 129 | - print_r($config_obj, true), |
|
| 130 | - $config_class |
|
| 131 | - ) |
|
| 132 | - ); |
|
| 133 | - } |
|
| 134 | - return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * gets the class's config object |
|
| 140 | - * |
|
| 141 | - * @return EE_Config_Base |
|
| 142 | - */ |
|
| 143 | - public function config() |
|
| 144 | - { |
|
| 145 | - if (empty($this->_config)) { |
|
| 146 | - $this->_config = EE_Config::instance()->get_config( |
|
| 147 | - $this->config_section(), |
|
| 148 | - $this->config_name(), |
|
| 149 | - $this->config_class() |
|
| 150 | - ); |
|
| 151 | - } |
|
| 152 | - return $this->_config; |
|
| 153 | - } |
|
| 15 | + /** |
|
| 16 | + * @var $_config |
|
| 17 | + * @type EE_Config_Base |
|
| 18 | + */ |
|
| 19 | + protected $_config; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @var $_config_section |
|
| 23 | + * @type string |
|
| 24 | + */ |
|
| 25 | + protected $_config_section = ''; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var $_config_class |
|
| 29 | + * @type string |
|
| 30 | + */ |
|
| 31 | + protected $_config_class = ''; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var $_config_name |
|
| 35 | + * @type string |
|
| 36 | + */ |
|
| 37 | + protected $_config_name = ''; |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @param string $config_section |
|
| 42 | + */ |
|
| 43 | + public function set_config_section($config_section = '') |
|
| 44 | + { |
|
| 45 | + $this->_config_section = !empty($config_section) ? $config_section : 'modules'; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @return mixed |
|
| 51 | + */ |
|
| 52 | + public function config_section() |
|
| 53 | + { |
|
| 54 | + return $this->_config_section; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @param string $config_class |
|
| 60 | + */ |
|
| 61 | + public function set_config_class($config_class = '') |
|
| 62 | + { |
|
| 63 | + $this->_config_class = $config_class; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @return mixed |
|
| 69 | + */ |
|
| 70 | + public function config_class() |
|
| 71 | + { |
|
| 72 | + return $this->_config_class; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @param mixed $config_name |
|
| 78 | + */ |
|
| 79 | + public function set_config_name($config_name) |
|
| 80 | + { |
|
| 81 | + $this->_config_name = !empty($config_name) ? $config_name : get_called_class(); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @return mixed |
|
| 87 | + */ |
|
| 88 | + public function config_name() |
|
| 89 | + { |
|
| 90 | + return $this->_config_name; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * set_config |
|
| 96 | + * this method integrates directly with EE_Config to set up the config object for this class |
|
| 97 | + * |
|
| 98 | + * @access protected |
|
| 99 | + * @param EE_Config_Base $config_obj |
|
| 100 | + * @return mixed EE_Config_Base | NULL |
|
| 101 | + */ |
|
| 102 | + protected function _set_config(EE_Config_Base $config_obj = null) |
|
| 103 | + { |
|
| 104 | + return EE_Config::instance()->set_config( |
|
| 105 | + $this->config_section(), |
|
| 106 | + $this->config_name(), |
|
| 107 | + $this->config_class(), |
|
| 108 | + $config_obj |
|
| 109 | + ); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * _update_config |
|
| 115 | + * this method integrates directly with EE_Config to update an existing config object for this class |
|
| 116 | + * |
|
| 117 | + * @access protected |
|
| 118 | + * @param EE_Config_Base $config_obj |
|
| 119 | + * @throws \EE_Error |
|
| 120 | + * @return mixed EE_Config_Base | NULL |
|
| 121 | + */ |
|
| 122 | + public function _update_config(EE_Config_Base $config_obj = null) |
|
| 123 | + { |
|
| 124 | + $config_class = $this->config_class(); |
|
| 125 | + if (!$config_obj instanceof $config_class) { |
|
| 126 | + throw new EE_Error( |
|
| 127 | + sprintf( |
|
| 128 | + __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
|
| 129 | + print_r($config_obj, true), |
|
| 130 | + $config_class |
|
| 131 | + ) |
|
| 132 | + ); |
|
| 133 | + } |
|
| 134 | + return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * gets the class's config object |
|
| 140 | + * |
|
| 141 | + * @return EE_Config_Base |
|
| 142 | + */ |
|
| 143 | + public function config() |
|
| 144 | + { |
|
| 145 | + if (empty($this->_config)) { |
|
| 146 | + $this->_config = EE_Config::instance()->get_config( |
|
| 147 | + $this->config_section(), |
|
| 148 | + $this->config_name(), |
|
| 149 | + $this->config_class() |
|
| 150 | + ); |
|
| 151 | + } |
|
| 152 | + return $this->_config; |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | 155 | |
| 156 | 156 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function set_config_section($config_section = '') |
| 44 | 44 | { |
| 45 | - $this->_config_section = !empty($config_section) ? $config_section : 'modules'; |
|
| 45 | + $this->_config_section = ! empty($config_section) ? $config_section : 'modules'; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function set_config_name($config_name) |
| 80 | 80 | { |
| 81 | - $this->_config_name = !empty($config_name) ? $config_name : get_called_class(); |
|
| 81 | + $this->_config_name = ! empty($config_name) ? $config_name : get_called_class(); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | public function _update_config(EE_Config_Base $config_obj = null) |
| 123 | 123 | { |
| 124 | 124 | $config_class = $this->config_class(); |
| 125 | - if (!$config_obj instanceof $config_class) { |
|
| 125 | + if ( ! $config_obj instanceof $config_class) { |
|
| 126 | 126 | throw new EE_Error( |
| 127 | 127 | sprintf( |
| 128 | 128 | __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
@@ -13,462 +13,462 @@ discard block |
||
| 13 | 13 | class EED_Event_Single extends EED_Module |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - const EVENT_DETAILS_PRIORITY = 100; |
|
| 17 | - const EVENT_DATETIMES_PRIORITY = 110; |
|
| 18 | - const EVENT_TICKETS_PRIORITY = 120; |
|
| 19 | - const EVENT_VENUES_PRIORITY = 130; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @type bool $using_get_the_excerpt |
|
| 23 | - */ |
|
| 24 | - protected static $using_get_the_excerpt = false; |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @type EE_Template_Part_Manager $template_parts |
|
| 29 | - */ |
|
| 30 | - protected $template_parts; |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @return EED_Module|EED_Event_Single |
|
| 35 | - */ |
|
| 36 | - public static function instance() |
|
| 37 | - { |
|
| 38 | - return parent::get_instance(__CLASS__); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 44 | - * |
|
| 45 | - * @return void |
|
| 46 | - */ |
|
| 47 | - public static function set_hooks() |
|
| 48 | - { |
|
| 49 | - add_filter('FHEE_run_EE_wp', '__return_true'); |
|
| 50 | - add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 51 | - EE_Config::register_route(__('event', 'event_espresso'), 'Event_Single', 'run'); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 56 | - * |
|
| 57 | - * @return void |
|
| 58 | - */ |
|
| 59 | - public static function set_hooks_admin() |
|
| 60 | - { |
|
| 61 | - add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * set_definitions |
|
| 67 | - * |
|
| 68 | - * @static |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - public static function set_definitions() |
|
| 72 | - { |
|
| 73 | - define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
| 74 | - define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * set_config |
|
| 80 | - * |
|
| 81 | - * @void |
|
| 82 | - */ |
|
| 83 | - protected function set_config() |
|
| 84 | - { |
|
| 85 | - $this->set_config_section('template_settings'); |
|
| 86 | - $this->set_config_class('EE_Event_Single_Config'); |
|
| 87 | - $this->set_config_name('EED_Event_Single'); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * initialize_template_parts |
|
| 93 | - * |
|
| 94 | - * @param EE_Config_Base|EE_Event_Single_Config $config |
|
| 95 | - * @return EE_Template_Part_Manager |
|
| 96 | - */ |
|
| 97 | - public function initialize_template_parts(EE_Event_Single_Config $config = null) |
|
| 98 | - { |
|
| 99 | - /** @type EE_Event_Single_Config $config */ |
|
| 100 | - $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
|
| 101 | - EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
| 102 | - $template_parts = new EE_Template_Part_Manager(); |
|
| 103 | - $template_parts->add_template_part( |
|
| 104 | - 'tickets', |
|
| 105 | - __('Ticket Selector', 'event_espresso'), |
|
| 106 | - 'content-espresso_events-tickets.php', |
|
| 107 | - $config->display_order_tickets |
|
| 108 | - ); |
|
| 109 | - $template_parts->add_template_part( |
|
| 110 | - 'datetimes', |
|
| 111 | - __('Dates and Times', 'event_espresso'), |
|
| 112 | - 'content-espresso_events-datetimes.php', |
|
| 113 | - $config->display_order_datetimes |
|
| 114 | - ); |
|
| 115 | - $template_parts->add_template_part( |
|
| 116 | - 'event', |
|
| 117 | - __('Event Description', 'event_espresso'), |
|
| 118 | - 'content-espresso_events-details.php', |
|
| 119 | - $config->display_order_event |
|
| 120 | - ); |
|
| 121 | - $template_parts->add_template_part( |
|
| 122 | - 'venue', |
|
| 123 | - __('Venue Information', 'event_espresso'), |
|
| 124 | - 'content-espresso_events-venues.php', |
|
| 125 | - $config->display_order_venue |
|
| 126 | - ); |
|
| 127 | - do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
| 128 | - return $template_parts; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * run - initial module setup |
|
| 134 | - * |
|
| 135 | - * @param WP $WP |
|
| 136 | - * @return void |
|
| 137 | - */ |
|
| 138 | - public function run($WP) |
|
| 139 | - { |
|
| 140 | - // ensure valid EE_Events_Single_Config() object exists |
|
| 141 | - $this->set_config(); |
|
| 142 | - // check what template is loaded |
|
| 143 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 144 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 145 | - // load css |
|
| 146 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * template_include |
|
| 152 | - * |
|
| 153 | - * @param string $template |
|
| 154 | - * @return string |
|
| 155 | - */ |
|
| 156 | - public function template_include($template) |
|
| 157 | - { |
|
| 158 | - global $post; |
|
| 159 | - /** @type EE_Event_Single_Config $config */ |
|
| 160 | - $config = $this->config(); |
|
| 161 | - if ($config->display_status_banner_single) { |
|
| 162 | - add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
| 163 | - } |
|
| 164 | - // not a custom template? |
|
| 165 | - if ( |
|
| 166 | - !post_password_required($post) |
|
| 167 | - && ( |
|
| 168 | - apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
| 169 | - || EE_Registry::instance() |
|
| 170 | - ->load_core('Front_Controller') |
|
| 171 | - ->get_selected_template() !== 'single-espresso_events.php' |
|
| 172 | - ) |
|
| 173 | - |
|
| 174 | - ) { |
|
| 175 | - EEH_Template::load_espresso_theme_functions(); |
|
| 176 | - // then add extra event data via hooks |
|
| 177 | - add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
| 178 | - add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
| 179 | - add_filter( |
|
| 180 | - 'the_content', |
|
| 181 | - array('EED_Event_Single', 'event_details'), |
|
| 182 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 183 | - ); |
|
| 184 | - add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
| 185 | - // don't display entry meta because the existing theme will take car of that |
|
| 186 | - add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 187 | - } |
|
| 188 | - return $template; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * loop_start |
|
| 194 | - * |
|
| 195 | - * @param array $wp_query_array an array containing the WP_Query object |
|
| 196 | - * @return void |
|
| 197 | - */ |
|
| 198 | - public static function loop_start($wp_query_array) |
|
| 199 | - { |
|
| 200 | - global $post; |
|
| 201 | - do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * the_title |
|
| 207 | - * |
|
| 208 | - * @param string $title |
|
| 209 | - * @param int $id |
|
| 210 | - * @return string |
|
| 211 | - */ |
|
| 212 | - public static function the_title($title = '', $id = 0) |
|
| 213 | - { |
|
| 214 | - global $post; |
|
| 215 | - return in_the_loop() && $post->ID === (int)$id |
|
| 216 | - ? espresso_event_status_banner($post->ID) . $title |
|
| 217 | - : $title; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * get_the_excerpt |
|
| 223 | - * kinda hacky, but if a theme is using get_the_excerpt(), |
|
| 224 | - * then we need to remove our filters on the_content() |
|
| 225 | - * |
|
| 226 | - * @param string $excerpt |
|
| 227 | - * @return string |
|
| 228 | - */ |
|
| 229 | - public static function get_the_excerpt($excerpt = '') |
|
| 230 | - { |
|
| 231 | - EED_Event_Single::$using_get_the_excerpt = true; |
|
| 232 | - add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
| 233 | - return $excerpt; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * end_get_the_excerpt |
|
| 239 | - * |
|
| 240 | - * @param string $text |
|
| 241 | - * @return string |
|
| 242 | - */ |
|
| 243 | - public static function end_get_the_excerpt($text = '') |
|
| 244 | - { |
|
| 245 | - EED_Event_Single::$using_get_the_excerpt = false; |
|
| 246 | - return $text; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * event_details |
|
| 252 | - * |
|
| 253 | - * @param string $content |
|
| 254 | - * @return string |
|
| 255 | - */ |
|
| 256 | - public static function event_details($content) |
|
| 257 | - { |
|
| 258 | - global $post; |
|
| 259 | - static $current_post_ID = 0; |
|
| 260 | - if ( |
|
| 261 | - $current_post_ID !== $post->ID |
|
| 262 | - && $post->post_type === 'espresso_events' |
|
| 263 | - && !EED_Event_Single::$using_get_the_excerpt |
|
| 264 | - && !post_password_required() |
|
| 265 | - ) { |
|
| 266 | - // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
| 267 | - // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
| 268 | - // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
| 269 | - // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
| 270 | - // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
| 271 | - // so the following allows this filter to be applied multiple times, but only once for real |
|
| 272 | - $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
| 273 | - if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
| 274 | - // we need to first remove this callback from being applied to the_content() |
|
| 275 | - // (otherwise it will recurse and blow up the interweb) |
|
| 276 | - remove_filter( |
|
| 277 | - 'the_content', |
|
| 278 | - array('EED_Event_Single', 'event_details'), |
|
| 279 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 280 | - ); |
|
| 281 | - EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(); |
|
| 282 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 283 | - $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
| 284 | - add_filter( |
|
| 285 | - 'the_content', |
|
| 286 | - array('EED_Event_Single', 'event_details'), |
|
| 287 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 288 | - ); |
|
| 289 | - } else { |
|
| 290 | - $content = EED_Event_Single::use_filterable_display_order(); |
|
| 291 | - } |
|
| 292 | - } |
|
| 293 | - return $content; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * use_filterable_display_order |
|
| 299 | - * |
|
| 300 | - * @return string |
|
| 301 | - */ |
|
| 302 | - protected static function use_filterable_display_order() |
|
| 303 | - { |
|
| 304 | - // since the 'content-espresso_events-details.php' template might be used directly from within a theme, |
|
| 305 | - // it uses the_content() for displaying the $post->post_content |
|
| 306 | - // so in order to load a template that uses the_content() |
|
| 307 | - // from within a callback being used to filter the_content(), |
|
| 308 | - // we need to first remove this callback from being applied to the_content() |
|
| 309 | - // (otherwise it will recurse and blow up the interweb) |
|
| 310 | - remove_filter( |
|
| 311 | - 'the_content', |
|
| 312 | - array('EED_Event_Single', 'event_details'), |
|
| 313 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 314 | - ); |
|
| 315 | - //now add additional content |
|
| 316 | - add_filter( |
|
| 317 | - 'the_content', |
|
| 318 | - array('EED_Event_Single', 'event_datetimes'), |
|
| 319 | - EED_Event_Single::EVENT_DATETIMES_PRIORITY, |
|
| 320 | - 1 |
|
| 321 | - ); |
|
| 322 | - add_filter( |
|
| 323 | - 'the_content', |
|
| 324 | - array('EED_Event_Single', 'event_tickets'), |
|
| 325 | - EED_Event_Single::EVENT_TICKETS_PRIORITY, |
|
| 326 | - 1 |
|
| 327 | - ); |
|
| 328 | - add_filter( |
|
| 329 | - 'the_content', |
|
| 330 | - array('EED_Event_Single', 'event_venues'), |
|
| 331 | - EED_Event_Single::EVENT_VENUES_PRIORITY, |
|
| 332 | - 1 |
|
| 333 | - ); |
|
| 334 | - do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
| 335 | - // now load our template |
|
| 336 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 337 | - //now add our filter back in, plus some others |
|
| 338 | - add_filter( |
|
| 339 | - 'the_content', |
|
| 340 | - array('EED_Event_Single', 'event_details'), |
|
| 341 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 342 | - ); |
|
| 343 | - remove_filter( |
|
| 344 | - 'the_content', |
|
| 345 | - array('EED_Event_Single', 'event_datetimes'), |
|
| 346 | - EED_Event_Single::EVENT_DATETIMES_PRIORITY |
|
| 347 | - ); |
|
| 348 | - remove_filter( |
|
| 349 | - 'the_content', |
|
| 350 | - array('EED_Event_Single', 'event_tickets'), |
|
| 351 | - EED_Event_Single::EVENT_TICKETS_PRIORITY |
|
| 352 | - ); |
|
| 353 | - remove_filter( |
|
| 354 | - 'the_content', |
|
| 355 | - array('EED_Event_Single', 'event_venues'), |
|
| 356 | - EED_Event_Single::EVENT_VENUES_PRIORITY |
|
| 357 | - ); |
|
| 358 | - do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters'); |
|
| 359 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
| 360 | - return $content; |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * event_datetimes - adds datetimes ABOVE content |
|
| 366 | - * |
|
| 367 | - * @param string $content |
|
| 368 | - * @return string |
|
| 369 | - */ |
|
| 370 | - public static function event_datetimes($content) |
|
| 371 | - { |
|
| 372 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
| 378 | - * |
|
| 379 | - * @param string $content |
|
| 380 | - * @return string |
|
| 381 | - */ |
|
| 382 | - public static function event_tickets($content) |
|
| 383 | - { |
|
| 384 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * event_venues |
|
| 390 | - * |
|
| 391 | - * @param string $content |
|
| 392 | - * @return string |
|
| 393 | - */ |
|
| 394 | - public static function event_venue($content) |
|
| 395 | - { |
|
| 396 | - return EED_Event_Single::event_venues($content); |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * event_venues - adds venues BELOW content |
|
| 402 | - * |
|
| 403 | - * @param string $content |
|
| 404 | - * @return string |
|
| 405 | - */ |
|
| 406 | - public static function event_venues($content) |
|
| 407 | - { |
|
| 408 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - |
|
| 412 | - /** |
|
| 413 | - * loop_end |
|
| 414 | - * |
|
| 415 | - * @param array $wp_query_array an array containing the WP_Query object |
|
| 416 | - * @return void |
|
| 417 | - */ |
|
| 418 | - public static function loop_end($wp_query_array) |
|
| 419 | - { |
|
| 420 | - global $post; |
|
| 421 | - do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * wp_enqueue_scripts |
|
| 427 | - * |
|
| 428 | - * @return void |
|
| 429 | - */ |
|
| 430 | - public function wp_enqueue_scripts() |
|
| 431 | - { |
|
| 432 | - // get some style |
|
| 433 | - if ( |
|
| 434 | - apply_filters('FHEE_enable_default_espresso_css', TRUE) |
|
| 435 | - && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE) |
|
| 436 | - ) { |
|
| 437 | - // first check uploads folder |
|
| 438 | - if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
| 439 | - wp_register_style( |
|
| 440 | - $this->theme, |
|
| 441 | - get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
| 442 | - array('dashicons', 'espresso_default') |
|
| 443 | - ); |
|
| 444 | - } else { |
|
| 445 | - wp_register_style( |
|
| 446 | - $this->theme, |
|
| 447 | - EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
| 448 | - array('dashicons', 'espresso_default') |
|
| 449 | - ); |
|
| 450 | - } |
|
| 451 | - wp_enqueue_script($this->theme); |
|
| 452 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 453 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 454 | - } |
|
| 455 | - } |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - |
|
| 459 | - /** |
|
| 460 | - * display_venue |
|
| 461 | - * |
|
| 462 | - * @return bool |
|
| 463 | - */ |
|
| 464 | - public static function display_venue() |
|
| 465 | - { |
|
| 466 | - /** @type EE_Event_Single_Config $config */ |
|
| 467 | - $config = EED_Event_Single::instance()->config(); |
|
| 468 | - $display_venue = $config->display_venue === null ? true : $config->display_venue; |
|
| 469 | - $venue_name = EEH_Venue_View::venue_name(); |
|
| 470 | - return $display_venue && !empty($venue_name); |
|
| 471 | - } |
|
| 16 | + const EVENT_DETAILS_PRIORITY = 100; |
|
| 17 | + const EVENT_DATETIMES_PRIORITY = 110; |
|
| 18 | + const EVENT_TICKETS_PRIORITY = 120; |
|
| 19 | + const EVENT_VENUES_PRIORITY = 130; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @type bool $using_get_the_excerpt |
|
| 23 | + */ |
|
| 24 | + protected static $using_get_the_excerpt = false; |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @type EE_Template_Part_Manager $template_parts |
|
| 29 | + */ |
|
| 30 | + protected $template_parts; |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @return EED_Module|EED_Event_Single |
|
| 35 | + */ |
|
| 36 | + public static function instance() |
|
| 37 | + { |
|
| 38 | + return parent::get_instance(__CLASS__); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 44 | + * |
|
| 45 | + * @return void |
|
| 46 | + */ |
|
| 47 | + public static function set_hooks() |
|
| 48 | + { |
|
| 49 | + add_filter('FHEE_run_EE_wp', '__return_true'); |
|
| 50 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 51 | + EE_Config::register_route(__('event', 'event_espresso'), 'Event_Single', 'run'); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 56 | + * |
|
| 57 | + * @return void |
|
| 58 | + */ |
|
| 59 | + public static function set_hooks_admin() |
|
| 60 | + { |
|
| 61 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * set_definitions |
|
| 67 | + * |
|
| 68 | + * @static |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + public static function set_definitions() |
|
| 72 | + { |
|
| 73 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
| 74 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * set_config |
|
| 80 | + * |
|
| 81 | + * @void |
|
| 82 | + */ |
|
| 83 | + protected function set_config() |
|
| 84 | + { |
|
| 85 | + $this->set_config_section('template_settings'); |
|
| 86 | + $this->set_config_class('EE_Event_Single_Config'); |
|
| 87 | + $this->set_config_name('EED_Event_Single'); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * initialize_template_parts |
|
| 93 | + * |
|
| 94 | + * @param EE_Config_Base|EE_Event_Single_Config $config |
|
| 95 | + * @return EE_Template_Part_Manager |
|
| 96 | + */ |
|
| 97 | + public function initialize_template_parts(EE_Event_Single_Config $config = null) |
|
| 98 | + { |
|
| 99 | + /** @type EE_Event_Single_Config $config */ |
|
| 100 | + $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
|
| 101 | + EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
| 102 | + $template_parts = new EE_Template_Part_Manager(); |
|
| 103 | + $template_parts->add_template_part( |
|
| 104 | + 'tickets', |
|
| 105 | + __('Ticket Selector', 'event_espresso'), |
|
| 106 | + 'content-espresso_events-tickets.php', |
|
| 107 | + $config->display_order_tickets |
|
| 108 | + ); |
|
| 109 | + $template_parts->add_template_part( |
|
| 110 | + 'datetimes', |
|
| 111 | + __('Dates and Times', 'event_espresso'), |
|
| 112 | + 'content-espresso_events-datetimes.php', |
|
| 113 | + $config->display_order_datetimes |
|
| 114 | + ); |
|
| 115 | + $template_parts->add_template_part( |
|
| 116 | + 'event', |
|
| 117 | + __('Event Description', 'event_espresso'), |
|
| 118 | + 'content-espresso_events-details.php', |
|
| 119 | + $config->display_order_event |
|
| 120 | + ); |
|
| 121 | + $template_parts->add_template_part( |
|
| 122 | + 'venue', |
|
| 123 | + __('Venue Information', 'event_espresso'), |
|
| 124 | + 'content-espresso_events-venues.php', |
|
| 125 | + $config->display_order_venue |
|
| 126 | + ); |
|
| 127 | + do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
| 128 | + return $template_parts; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * run - initial module setup |
|
| 134 | + * |
|
| 135 | + * @param WP $WP |
|
| 136 | + * @return void |
|
| 137 | + */ |
|
| 138 | + public function run($WP) |
|
| 139 | + { |
|
| 140 | + // ensure valid EE_Events_Single_Config() object exists |
|
| 141 | + $this->set_config(); |
|
| 142 | + // check what template is loaded |
|
| 143 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 144 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 145 | + // load css |
|
| 146 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * template_include |
|
| 152 | + * |
|
| 153 | + * @param string $template |
|
| 154 | + * @return string |
|
| 155 | + */ |
|
| 156 | + public function template_include($template) |
|
| 157 | + { |
|
| 158 | + global $post; |
|
| 159 | + /** @type EE_Event_Single_Config $config */ |
|
| 160 | + $config = $this->config(); |
|
| 161 | + if ($config->display_status_banner_single) { |
|
| 162 | + add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
| 163 | + } |
|
| 164 | + // not a custom template? |
|
| 165 | + if ( |
|
| 166 | + !post_password_required($post) |
|
| 167 | + && ( |
|
| 168 | + apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
| 169 | + || EE_Registry::instance() |
|
| 170 | + ->load_core('Front_Controller') |
|
| 171 | + ->get_selected_template() !== 'single-espresso_events.php' |
|
| 172 | + ) |
|
| 173 | + |
|
| 174 | + ) { |
|
| 175 | + EEH_Template::load_espresso_theme_functions(); |
|
| 176 | + // then add extra event data via hooks |
|
| 177 | + add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
| 178 | + add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
| 179 | + add_filter( |
|
| 180 | + 'the_content', |
|
| 181 | + array('EED_Event_Single', 'event_details'), |
|
| 182 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 183 | + ); |
|
| 184 | + add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
| 185 | + // don't display entry meta because the existing theme will take car of that |
|
| 186 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 187 | + } |
|
| 188 | + return $template; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * loop_start |
|
| 194 | + * |
|
| 195 | + * @param array $wp_query_array an array containing the WP_Query object |
|
| 196 | + * @return void |
|
| 197 | + */ |
|
| 198 | + public static function loop_start($wp_query_array) |
|
| 199 | + { |
|
| 200 | + global $post; |
|
| 201 | + do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * the_title |
|
| 207 | + * |
|
| 208 | + * @param string $title |
|
| 209 | + * @param int $id |
|
| 210 | + * @return string |
|
| 211 | + */ |
|
| 212 | + public static function the_title($title = '', $id = 0) |
|
| 213 | + { |
|
| 214 | + global $post; |
|
| 215 | + return in_the_loop() && $post->ID === (int)$id |
|
| 216 | + ? espresso_event_status_banner($post->ID) . $title |
|
| 217 | + : $title; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * get_the_excerpt |
|
| 223 | + * kinda hacky, but if a theme is using get_the_excerpt(), |
|
| 224 | + * then we need to remove our filters on the_content() |
|
| 225 | + * |
|
| 226 | + * @param string $excerpt |
|
| 227 | + * @return string |
|
| 228 | + */ |
|
| 229 | + public static function get_the_excerpt($excerpt = '') |
|
| 230 | + { |
|
| 231 | + EED_Event_Single::$using_get_the_excerpt = true; |
|
| 232 | + add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
| 233 | + return $excerpt; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * end_get_the_excerpt |
|
| 239 | + * |
|
| 240 | + * @param string $text |
|
| 241 | + * @return string |
|
| 242 | + */ |
|
| 243 | + public static function end_get_the_excerpt($text = '') |
|
| 244 | + { |
|
| 245 | + EED_Event_Single::$using_get_the_excerpt = false; |
|
| 246 | + return $text; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * event_details |
|
| 252 | + * |
|
| 253 | + * @param string $content |
|
| 254 | + * @return string |
|
| 255 | + */ |
|
| 256 | + public static function event_details($content) |
|
| 257 | + { |
|
| 258 | + global $post; |
|
| 259 | + static $current_post_ID = 0; |
|
| 260 | + if ( |
|
| 261 | + $current_post_ID !== $post->ID |
|
| 262 | + && $post->post_type === 'espresso_events' |
|
| 263 | + && !EED_Event_Single::$using_get_the_excerpt |
|
| 264 | + && !post_password_required() |
|
| 265 | + ) { |
|
| 266 | + // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
| 267 | + // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
| 268 | + // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
| 269 | + // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
| 270 | + // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
| 271 | + // so the following allows this filter to be applied multiple times, but only once for real |
|
| 272 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
| 273 | + if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
| 274 | + // we need to first remove this callback from being applied to the_content() |
|
| 275 | + // (otherwise it will recurse and blow up the interweb) |
|
| 276 | + remove_filter( |
|
| 277 | + 'the_content', |
|
| 278 | + array('EED_Event_Single', 'event_details'), |
|
| 279 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 280 | + ); |
|
| 281 | + EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(); |
|
| 282 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 283 | + $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
| 284 | + add_filter( |
|
| 285 | + 'the_content', |
|
| 286 | + array('EED_Event_Single', 'event_details'), |
|
| 287 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 288 | + ); |
|
| 289 | + } else { |
|
| 290 | + $content = EED_Event_Single::use_filterable_display_order(); |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + return $content; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * use_filterable_display_order |
|
| 299 | + * |
|
| 300 | + * @return string |
|
| 301 | + */ |
|
| 302 | + protected static function use_filterable_display_order() |
|
| 303 | + { |
|
| 304 | + // since the 'content-espresso_events-details.php' template might be used directly from within a theme, |
|
| 305 | + // it uses the_content() for displaying the $post->post_content |
|
| 306 | + // so in order to load a template that uses the_content() |
|
| 307 | + // from within a callback being used to filter the_content(), |
|
| 308 | + // we need to first remove this callback from being applied to the_content() |
|
| 309 | + // (otherwise it will recurse and blow up the interweb) |
|
| 310 | + remove_filter( |
|
| 311 | + 'the_content', |
|
| 312 | + array('EED_Event_Single', 'event_details'), |
|
| 313 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 314 | + ); |
|
| 315 | + //now add additional content |
|
| 316 | + add_filter( |
|
| 317 | + 'the_content', |
|
| 318 | + array('EED_Event_Single', 'event_datetimes'), |
|
| 319 | + EED_Event_Single::EVENT_DATETIMES_PRIORITY, |
|
| 320 | + 1 |
|
| 321 | + ); |
|
| 322 | + add_filter( |
|
| 323 | + 'the_content', |
|
| 324 | + array('EED_Event_Single', 'event_tickets'), |
|
| 325 | + EED_Event_Single::EVENT_TICKETS_PRIORITY, |
|
| 326 | + 1 |
|
| 327 | + ); |
|
| 328 | + add_filter( |
|
| 329 | + 'the_content', |
|
| 330 | + array('EED_Event_Single', 'event_venues'), |
|
| 331 | + EED_Event_Single::EVENT_VENUES_PRIORITY, |
|
| 332 | + 1 |
|
| 333 | + ); |
|
| 334 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
| 335 | + // now load our template |
|
| 336 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 337 | + //now add our filter back in, plus some others |
|
| 338 | + add_filter( |
|
| 339 | + 'the_content', |
|
| 340 | + array('EED_Event_Single', 'event_details'), |
|
| 341 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 342 | + ); |
|
| 343 | + remove_filter( |
|
| 344 | + 'the_content', |
|
| 345 | + array('EED_Event_Single', 'event_datetimes'), |
|
| 346 | + EED_Event_Single::EVENT_DATETIMES_PRIORITY |
|
| 347 | + ); |
|
| 348 | + remove_filter( |
|
| 349 | + 'the_content', |
|
| 350 | + array('EED_Event_Single', 'event_tickets'), |
|
| 351 | + EED_Event_Single::EVENT_TICKETS_PRIORITY |
|
| 352 | + ); |
|
| 353 | + remove_filter( |
|
| 354 | + 'the_content', |
|
| 355 | + array('EED_Event_Single', 'event_venues'), |
|
| 356 | + EED_Event_Single::EVENT_VENUES_PRIORITY |
|
| 357 | + ); |
|
| 358 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters'); |
|
| 359 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
| 360 | + return $content; |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * event_datetimes - adds datetimes ABOVE content |
|
| 366 | + * |
|
| 367 | + * @param string $content |
|
| 368 | + * @return string |
|
| 369 | + */ |
|
| 370 | + public static function event_datetimes($content) |
|
| 371 | + { |
|
| 372 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
| 378 | + * |
|
| 379 | + * @param string $content |
|
| 380 | + * @return string |
|
| 381 | + */ |
|
| 382 | + public static function event_tickets($content) |
|
| 383 | + { |
|
| 384 | + return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * event_venues |
|
| 390 | + * |
|
| 391 | + * @param string $content |
|
| 392 | + * @return string |
|
| 393 | + */ |
|
| 394 | + public static function event_venue($content) |
|
| 395 | + { |
|
| 396 | + return EED_Event_Single::event_venues($content); |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * event_venues - adds venues BELOW content |
|
| 402 | + * |
|
| 403 | + * @param string $content |
|
| 404 | + * @return string |
|
| 405 | + */ |
|
| 406 | + public static function event_venues($content) |
|
| 407 | + { |
|
| 408 | + return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + |
|
| 412 | + /** |
|
| 413 | + * loop_end |
|
| 414 | + * |
|
| 415 | + * @param array $wp_query_array an array containing the WP_Query object |
|
| 416 | + * @return void |
|
| 417 | + */ |
|
| 418 | + public static function loop_end($wp_query_array) |
|
| 419 | + { |
|
| 420 | + global $post; |
|
| 421 | + do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * wp_enqueue_scripts |
|
| 427 | + * |
|
| 428 | + * @return void |
|
| 429 | + */ |
|
| 430 | + public function wp_enqueue_scripts() |
|
| 431 | + { |
|
| 432 | + // get some style |
|
| 433 | + if ( |
|
| 434 | + apply_filters('FHEE_enable_default_espresso_css', TRUE) |
|
| 435 | + && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE) |
|
| 436 | + ) { |
|
| 437 | + // first check uploads folder |
|
| 438 | + if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
| 439 | + wp_register_style( |
|
| 440 | + $this->theme, |
|
| 441 | + get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
| 442 | + array('dashicons', 'espresso_default') |
|
| 443 | + ); |
|
| 444 | + } else { |
|
| 445 | + wp_register_style( |
|
| 446 | + $this->theme, |
|
| 447 | + EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
| 448 | + array('dashicons', 'espresso_default') |
|
| 449 | + ); |
|
| 450 | + } |
|
| 451 | + wp_enqueue_script($this->theme); |
|
| 452 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 453 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 454 | + } |
|
| 455 | + } |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + |
|
| 459 | + /** |
|
| 460 | + * display_venue |
|
| 461 | + * |
|
| 462 | + * @return bool |
|
| 463 | + */ |
|
| 464 | + public static function display_venue() |
|
| 465 | + { |
|
| 466 | + /** @type EE_Event_Single_Config $config */ |
|
| 467 | + $config = EED_Event_Single::instance()->config(); |
|
| 468 | + $display_venue = $config->display_venue === null ? true : $config->display_venue; |
|
| 469 | + $venue_name = EEH_Venue_View::venue_name(); |
|
| 470 | + return $display_venue && !empty($venue_name); |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | 473 | |
| 474 | 474 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | */ |
| 483 | 483 | function espresso_display_venue_in_event_details() |
| 484 | 484 | { |
| 485 | - return EED_Event_Single::display_venue(); |
|
| 485 | + return EED_Event_Single::display_venue(); |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public static function set_definitions() |
| 72 | 72 | { |
| 73 | - define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
| 74 | - define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS); |
|
| 73 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
| 74 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | // not a custom template? |
| 165 | 165 | if ( |
| 166 | - !post_password_required($post) |
|
| 166 | + ! post_password_required($post) |
|
| 167 | 167 | && ( |
| 168 | 168 | apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
| 169 | 169 | || EE_Registry::instance() |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | public static function the_title($title = '', $id = 0) |
| 213 | 213 | { |
| 214 | 214 | global $post; |
| 215 | - return in_the_loop() && $post->ID === (int)$id |
|
| 216 | - ? espresso_event_status_banner($post->ID) . $title |
|
| 215 | + return in_the_loop() && $post->ID === (int) $id |
|
| 216 | + ? espresso_event_status_banner($post->ID).$title |
|
| 217 | 217 | : $title; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | if ( |
| 261 | 261 | $current_post_ID !== $post->ID |
| 262 | 262 | && $post->post_type === 'espresso_events' |
| 263 | - && !EED_Event_Single::$using_get_the_excerpt |
|
| 264 | - && !post_password_required() |
|
| 263 | + && ! EED_Event_Single::$using_get_the_excerpt |
|
| 264 | + && ! post_password_required() |
|
| 265 | 265 | ) { |
| 266 | 266 | // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
| 267 | 267 | // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | public static function event_datetimes($content) |
| 371 | 371 | { |
| 372 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
| 372 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | */ |
| 382 | 382 | public static function event_tickets($content) |
| 383 | 383 | { |
| 384 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
| 384 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | public static function event_venues($content) |
| 407 | 407 | { |
| 408 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 408 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | |
@@ -435,16 +435,16 @@ discard block |
||
| 435 | 435 | && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE) |
| 436 | 436 | ) { |
| 437 | 437 | // first check uploads folder |
| 438 | - if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
| 438 | + if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
| 439 | 439 | wp_register_style( |
| 440 | 440 | $this->theme, |
| 441 | - get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
| 441 | + get_stylesheet_directory_uri().$this->theme.DS.'style.css', |
|
| 442 | 442 | array('dashicons', 'espresso_default') |
| 443 | 443 | ); |
| 444 | 444 | } else { |
| 445 | 445 | wp_register_style( |
| 446 | 446 | $this->theme, |
| 447 | - EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
| 447 | + EE_TEMPLATES_URL.$this->theme.DS.'style.css', |
|
| 448 | 448 | array('dashicons', 'espresso_default') |
| 449 | 449 | ); |
| 450 | 450 | } |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | $config = EED_Event_Single::instance()->config(); |
| 468 | 468 | $display_venue = $config->display_venue === null ? true : $config->display_venue; |
| 469 | 469 | $venue_name = EEH_Venue_View::venue_name(); |
| 470 | - return $display_venue && !empty($venue_name); |
|
| 470 | + return $display_venue && ! empty($venue_name); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('ABSPATH')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /* |
| 5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
| 40 | 40 | * @since 4.0 |
| 41 | 41 | */ |
| 42 | 42 | if (function_exists('espresso_version')) { |
| 43 | - /** |
|
| 44 | - * espresso_duplicate_plugin_error |
|
| 45 | - * displays if more than one version of EE is activated at the same time |
|
| 46 | - */ |
|
| 47 | - function espresso_duplicate_plugin_error() |
|
| 48 | - { |
|
| 49 | - ?> |
|
| 43 | + /** |
|
| 44 | + * espresso_duplicate_plugin_error |
|
| 45 | + * displays if more than one version of EE is activated at the same time |
|
| 46 | + */ |
|
| 47 | + function espresso_duplicate_plugin_error() |
|
| 48 | + { |
|
| 49 | + ?> |
|
| 50 | 50 | <div class="error"> |
| 51 | 51 | <p> |
| 52 | 52 | <?php echo esc_html__( |
| 53 | - '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.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 53 | + '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.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - /** |
|
| 97 | - * espresso_version |
|
| 98 | - * Returns the plugin version |
|
| 99 | - * |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - function espresso_version() |
|
| 103 | - { |
|
| 104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.39.rc.046'); |
|
| 105 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + /** |
|
| 97 | + * espresso_version |
|
| 98 | + * Returns the plugin version |
|
| 99 | + * |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + function espresso_version() |
|
| 103 | + { |
|
| 104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.39.rc.046'); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - // define versions |
|
| 108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | - if ( ! defined('DS')) { |
|
| 115 | - define('DS', '/'); |
|
| 116 | - } |
|
| 117 | - if ( ! defined('PS')) { |
|
| 118 | - define('PS', PATH_SEPARATOR); |
|
| 119 | - } |
|
| 120 | - if ( ! defined('SP')) { |
|
| 121 | - define('SP', ' '); |
|
| 122 | - } |
|
| 123 | - if ( ! defined('EENL')) { |
|
| 124 | - define('EENL', "\n"); |
|
| 125 | - } |
|
| 126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | - // define the plugin directory and URL |
|
| 128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | - // main root folder paths |
|
| 132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | - // core system paths |
|
| 141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | - // gateways |
|
| 154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | - // asset URL paths |
|
| 157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | - // define upload paths |
|
| 164 | - $uploads = wp_upload_dir(); |
|
| 165 | - // define the uploads directory and URL |
|
| 166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | - // define the templates directory and URL |
|
| 169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | - // define the gateway directory and URL |
|
| 172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | - // languages folder/path |
|
| 175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | - //check for dompdf fonts in uploads |
|
| 178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | - } |
|
| 181 | - //ajax constants |
|
| 182 | - define( |
|
| 183 | - 'EE_FRONT_AJAX', |
|
| 184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | - ); |
|
| 186 | - define( |
|
| 187 | - 'EE_ADMIN_AJAX', |
|
| 188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | - ); |
|
| 190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | - //want to change its default value! or find when -1 means infinity |
|
| 193 | - define('EE_INF_IN_DB', -1); |
|
| 194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | - define('EE_DEBUG', false); |
|
| 196 | - // for older WP versions |
|
| 197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | - } |
|
| 200 | - /** |
|
| 201 | - * espresso_plugin_activation |
|
| 202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | - */ |
|
| 204 | - function espresso_plugin_activation() |
|
| 205 | - { |
|
| 206 | - update_option('ee_espresso_activation', true); |
|
| 207 | - } |
|
| 107 | + // define versions |
|
| 108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | + if ( ! defined('DS')) { |
|
| 115 | + define('DS', '/'); |
|
| 116 | + } |
|
| 117 | + if ( ! defined('PS')) { |
|
| 118 | + define('PS', PATH_SEPARATOR); |
|
| 119 | + } |
|
| 120 | + if ( ! defined('SP')) { |
|
| 121 | + define('SP', ' '); |
|
| 122 | + } |
|
| 123 | + if ( ! defined('EENL')) { |
|
| 124 | + define('EENL', "\n"); |
|
| 125 | + } |
|
| 126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | + // define the plugin directory and URL |
|
| 128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | + // main root folder paths |
|
| 132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | + // core system paths |
|
| 141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | + // gateways |
|
| 154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | + // asset URL paths |
|
| 157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | + // define upload paths |
|
| 164 | + $uploads = wp_upload_dir(); |
|
| 165 | + // define the uploads directory and URL |
|
| 166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | + // define the templates directory and URL |
|
| 169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | + // define the gateway directory and URL |
|
| 172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | + // languages folder/path |
|
| 175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | + //check for dompdf fonts in uploads |
|
| 178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | + } |
|
| 181 | + //ajax constants |
|
| 182 | + define( |
|
| 183 | + 'EE_FRONT_AJAX', |
|
| 184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | + ); |
|
| 186 | + define( |
|
| 187 | + 'EE_ADMIN_AJAX', |
|
| 188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | + ); |
|
| 190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | + //want to change its default value! or find when -1 means infinity |
|
| 193 | + define('EE_INF_IN_DB', -1); |
|
| 194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | + define('EE_DEBUG', false); |
|
| 196 | + // for older WP versions |
|
| 197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | + } |
|
| 200 | + /** |
|
| 201 | + * espresso_plugin_activation |
|
| 202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | + */ |
|
| 204 | + function espresso_plugin_activation() |
|
| 205 | + { |
|
| 206 | + update_option('ee_espresso_activation', true); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | - /** |
|
| 211 | - * espresso_load_error_handling |
|
| 212 | - * this function loads EE's class for handling exceptions and errors |
|
| 213 | - */ |
|
| 214 | - function espresso_load_error_handling() |
|
| 215 | - { |
|
| 216 | - // load debugging tools |
|
| 217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | - EEH_Debug_Tools::instance(); |
|
| 220 | - } |
|
| 221 | - // load error handling |
|
| 222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | - } else { |
|
| 225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | - } |
|
| 227 | - } |
|
| 209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | + /** |
|
| 211 | + * espresso_load_error_handling |
|
| 212 | + * this function loads EE's class for handling exceptions and errors |
|
| 213 | + */ |
|
| 214 | + function espresso_load_error_handling() |
|
| 215 | + { |
|
| 216 | + // load debugging tools |
|
| 217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | + EEH_Debug_Tools::instance(); |
|
| 220 | + } |
|
| 221 | + // load error handling |
|
| 222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | + } else { |
|
| 225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * espresso_load_required |
|
| 231 | - * given a class name and path, this function will load that file or throw an exception |
|
| 232 | - * |
|
| 233 | - * @param string $classname |
|
| 234 | - * @param string $full_path_to_file |
|
| 235 | - * @throws EE_Error |
|
| 236 | - */ |
|
| 237 | - function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | - { |
|
| 239 | - static $error_handling_loaded = false; |
|
| 240 | - if ( ! $error_handling_loaded) { |
|
| 241 | - espresso_load_error_handling(); |
|
| 242 | - $error_handling_loaded = true; |
|
| 243 | - } |
|
| 244 | - if (is_readable($full_path_to_file)) { |
|
| 245 | - require_once($full_path_to_file); |
|
| 246 | - } else { |
|
| 247 | - throw new EE_Error ( |
|
| 248 | - sprintf( |
|
| 249 | - esc_html__( |
|
| 250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | - 'event_espresso' |
|
| 252 | - ), |
|
| 253 | - $classname |
|
| 254 | - ) |
|
| 255 | - ); |
|
| 256 | - } |
|
| 257 | - } |
|
| 229 | + /** |
|
| 230 | + * espresso_load_required |
|
| 231 | + * given a class name and path, this function will load that file or throw an exception |
|
| 232 | + * |
|
| 233 | + * @param string $classname |
|
| 234 | + * @param string $full_path_to_file |
|
| 235 | + * @throws EE_Error |
|
| 236 | + */ |
|
| 237 | + function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | + { |
|
| 239 | + static $error_handling_loaded = false; |
|
| 240 | + if ( ! $error_handling_loaded) { |
|
| 241 | + espresso_load_error_handling(); |
|
| 242 | + $error_handling_loaded = true; |
|
| 243 | + } |
|
| 244 | + if (is_readable($full_path_to_file)) { |
|
| 245 | + require_once($full_path_to_file); |
|
| 246 | + } else { |
|
| 247 | + throw new EE_Error ( |
|
| 248 | + sprintf( |
|
| 249 | + esc_html__( |
|
| 250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | + 'event_espresso' |
|
| 252 | + ), |
|
| 253 | + $classname |
|
| 254 | + ) |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | - new EE_Bootstrap(); |
|
| 263 | - } |
|
| 259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | + new EE_Bootstrap(); |
|
| 263 | + } |
|
| 264 | 264 | } |
| 265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
| 266 | - /** |
|
| 267 | - * deactivate_plugin |
|
| 268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | - * |
|
| 270 | - * @access public |
|
| 271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | - * @return void |
|
| 273 | - */ |
|
| 274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | - { |
|
| 276 | - if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | - } |
|
| 279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | - deactivate_plugins($plugin_basename); |
|
| 281 | - } |
|
| 266 | + /** |
|
| 267 | + * deactivate_plugin |
|
| 268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | + * |
|
| 270 | + * @access public |
|
| 271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | + * @return void |
|
| 273 | + */ |
|
| 274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | + { |
|
| 276 | + if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | + } |
|
| 279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | + deactivate_plugins($plugin_basename); |
|
| 281 | + } |
|
| 282 | 282 | } |
| 283 | 283 | \ No newline at end of file |