@@ -12,8 +12,6 @@ discard block |
||
12 | 12 | KEY `group_id` (`group_id`), |
13 | 13 | KEY `question_id` (`question_id`) |
14 | 14 | ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8$$ |
15 | - |
|
16 | - |
|
17 | 15 | * 4.1 question group question model's tables and fields: |
18 | 16 | $this->_tables = array( |
19 | 17 | 'Question_Group_Question'=>new EE_Primary_Table('esp_question_group_question','QGQ_ID') |
@@ -29,113 +27,113 @@ discard block |
||
29 | 27 | */ |
30 | 28 | class EE_DMS_4_1_0_question_group_question extends EE_Data_Migration_Script_Stage |
31 | 29 | { |
32 | - private $_old_table; |
|
33 | - private $_new_table; |
|
34 | - public function _migration_step($num_items = 50) |
|
35 | - { |
|
30 | + private $_old_table; |
|
31 | + private $_new_table; |
|
32 | + public function _migration_step($num_items = 50) |
|
33 | + { |
|
36 | 34 | |
37 | - global $wpdb; |
|
38 | - $start_at_record = $this->count_records_migrated(); |
|
39 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
40 | - $items_actually_migrated = 0; |
|
41 | - foreach ($rows as $question_group_question) { |
|
42 | - $this->_insert_new_question_group_question($question_group_question); |
|
43 | - $items_actually_migrated++; |
|
44 | - } |
|
45 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
46 | - $this->set_completed(); |
|
47 | - } |
|
48 | - return $items_actually_migrated; |
|
49 | - } |
|
50 | - public function _count_records_to_migrate() |
|
51 | - { |
|
52 | - global $wpdb; |
|
53 | - $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
54 | - return $count; |
|
55 | - } |
|
56 | - public function __construct() |
|
57 | - { |
|
58 | - global $wpdb; |
|
59 | - $this->_old_table = $wpdb->prefix."events_qst_group_rel"; |
|
60 | - $this->_new_table = $wpdb->prefix."esp_question_group_question"; |
|
61 | - $this->_pretty_name = __("Question Group to Question Relations", "event_espresso"); |
|
62 | - parent::__construct(); |
|
63 | - } |
|
35 | + global $wpdb; |
|
36 | + $start_at_record = $this->count_records_migrated(); |
|
37 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
38 | + $items_actually_migrated = 0; |
|
39 | + foreach ($rows as $question_group_question) { |
|
40 | + $this->_insert_new_question_group_question($question_group_question); |
|
41 | + $items_actually_migrated++; |
|
42 | + } |
|
43 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
44 | + $this->set_completed(); |
|
45 | + } |
|
46 | + return $items_actually_migrated; |
|
47 | + } |
|
48 | + public function _count_records_to_migrate() |
|
49 | + { |
|
50 | + global $wpdb; |
|
51 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
52 | + return $count; |
|
53 | + } |
|
54 | + public function __construct() |
|
55 | + { |
|
56 | + global $wpdb; |
|
57 | + $this->_old_table = $wpdb->prefix."events_qst_group_rel"; |
|
58 | + $this->_new_table = $wpdb->prefix."esp_question_group_question"; |
|
59 | + $this->_pretty_name = __("Question Group to Question Relations", "event_espresso"); |
|
60 | + parent::__construct(); |
|
61 | + } |
|
64 | 62 | |
65 | - /** |
|
66 | - * Attempts to insert a new question group inthe new format given an old one |
|
67 | - * @global type $wpdb |
|
68 | - * @param array $old_question_group_question |
|
69 | - * @return int |
|
70 | - */ |
|
71 | - private function _insert_new_question_group_question($old_question_group_question) |
|
72 | - { |
|
73 | - global $wpdb; |
|
74 | - $new_question_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_question", $old_question_group_question['question_id'], $wpdb->prefix."esp_question"); |
|
75 | - $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", $old_question_group_question['group_id'], $wpdb->prefix."esp_question_group"); |
|
76 | - if (! $new_question_id) { |
|
77 | - $this->add_error(sprintf(__("Could not find 4.1 question id for 3.1 question #%d.", "event_espresso"), $old_question_group_question['question_id'])); |
|
78 | - return 0; |
|
79 | - } |
|
80 | - if (! $new_question_group_id) { |
|
81 | - $this->add_error(sprintf(__("Could not find 4.1 question group id for 3.1 question group #%d.", "event_espresso"), $old_question_group_question['group_id'])); |
|
82 | - return 0; |
|
83 | - } |
|
84 | - // if it's a system question, it needs to be in the right system group. otherwise no dice! |
|
85 | - if (($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id) ) |
|
86 | - || |
|
87 | - ! $this->_is_system_question_for_question_group($new_question_id) |
|
88 | - ) { |
|
89 | - $cols_n_values = array( |
|
90 | - 'QSG_ID'=>$new_question_group_id, |
|
91 | - 'QST_ID'=>$new_question_id |
|
92 | - ); |
|
93 | - $datatypes = array( |
|
94 | - '%d',// QSG_ID |
|
95 | - '%d',// QST_ID |
|
96 | - ); |
|
97 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
98 | - if (! $success) { |
|
99 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group_question, $this->_new_table, $cols_n_values, $datatypes)); |
|
100 | - return 0; |
|
101 | - } |
|
102 | - return $wpdb->insert_id; |
|
103 | - } else { |
|
104 | - return false; |
|
105 | - } |
|
106 | - } |
|
63 | + /** |
|
64 | + * Attempts to insert a new question group inthe new format given an old one |
|
65 | + * @global type $wpdb |
|
66 | + * @param array $old_question_group_question |
|
67 | + * @return int |
|
68 | + */ |
|
69 | + private function _insert_new_question_group_question($old_question_group_question) |
|
70 | + { |
|
71 | + global $wpdb; |
|
72 | + $new_question_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_question", $old_question_group_question['question_id'], $wpdb->prefix."esp_question"); |
|
73 | + $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", $old_question_group_question['group_id'], $wpdb->prefix."esp_question_group"); |
|
74 | + if (! $new_question_id) { |
|
75 | + $this->add_error(sprintf(__("Could not find 4.1 question id for 3.1 question #%d.", "event_espresso"), $old_question_group_question['question_id'])); |
|
76 | + return 0; |
|
77 | + } |
|
78 | + if (! $new_question_group_id) { |
|
79 | + $this->add_error(sprintf(__("Could not find 4.1 question group id for 3.1 question group #%d.", "event_espresso"), $old_question_group_question['group_id'])); |
|
80 | + return 0; |
|
81 | + } |
|
82 | + // if it's a system question, it needs to be in the right system group. otherwise no dice! |
|
83 | + if (($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id) ) |
|
84 | + || |
|
85 | + ! $this->_is_system_question_for_question_group($new_question_id) |
|
86 | + ) { |
|
87 | + $cols_n_values = array( |
|
88 | + 'QSG_ID'=>$new_question_group_id, |
|
89 | + 'QST_ID'=>$new_question_id |
|
90 | + ); |
|
91 | + $datatypes = array( |
|
92 | + '%d',// QSG_ID |
|
93 | + '%d',// QST_ID |
|
94 | + ); |
|
95 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
96 | + if (! $success) { |
|
97 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group_question, $this->_new_table, $cols_n_values, $datatypes)); |
|
98 | + return 0; |
|
99 | + } |
|
100 | + return $wpdb->insert_id; |
|
101 | + } else { |
|
102 | + return false; |
|
103 | + } |
|
104 | + } |
|
107 | 105 | |
108 | - /** |
|
109 | - * If this question is a system question, returns the QSG_system number that |
|
110 | - * indicates the question group its permitted in. |
|
111 | - * @global type $wpdb |
|
112 | - * @param type $new_question_id |
|
113 | - * @return int |
|
114 | - */ |
|
115 | - private function _is_system_question_for_question_group($new_question_id) |
|
116 | - { |
|
117 | - global $wpdb; |
|
118 | - $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM ".$wpdb->prefix."esp_question WHERE QST_ID=%d", $new_question_id)); |
|
119 | - if (in_array($system_id, array('fname','lname','email'))) { |
|
120 | - return 1; |
|
121 | - } elseif ($system_id!='' && $system_id) { |
|
122 | - return 2; |
|
123 | - } else { |
|
124 | - return 0; |
|
125 | - } |
|
126 | - } |
|
106 | + /** |
|
107 | + * If this question is a system question, returns the QSG_system number that |
|
108 | + * indicates the question group its permitted in. |
|
109 | + * @global type $wpdb |
|
110 | + * @param type $new_question_id |
|
111 | + * @return int |
|
112 | + */ |
|
113 | + private function _is_system_question_for_question_group($new_question_id) |
|
114 | + { |
|
115 | + global $wpdb; |
|
116 | + $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM ".$wpdb->prefix."esp_question WHERE QST_ID=%d", $new_question_id)); |
|
117 | + if (in_array($system_id, array('fname','lname','email'))) { |
|
118 | + return 1; |
|
119 | + } elseif ($system_id!='' && $system_id) { |
|
120 | + return 2; |
|
121 | + } else { |
|
122 | + return 0; |
|
123 | + } |
|
124 | + } |
|
127 | 125 | |
128 | - /** |
|
129 | - * Returns the questino group's QSG_system value (1 meaning personal info, 2 |
|
130 | - * being address info, and 0 being neither) |
|
131 | - * @global type $wpdb |
|
132 | - * @param type $new_question_group_id |
|
133 | - * @return boolean |
|
134 | - */ |
|
135 | - private function _is_system_question_group($new_question_group_id) |
|
136 | - { |
|
137 | - global $wpdb; |
|
138 | - $system_id = $wpdb->get_var($wpdb->prepare("SELECT QSG_system FROM ".$wpdb->prefix."esp_question_group WHERE QSG_ID=%d", $new_question_group_id)); |
|
139 | - return intval($system_id); |
|
140 | - } |
|
126 | + /** |
|
127 | + * Returns the questino group's QSG_system value (1 meaning personal info, 2 |
|
128 | + * being address info, and 0 being neither) |
|
129 | + * @global type $wpdb |
|
130 | + * @param type $new_question_group_id |
|
131 | + * @return boolean |
|
132 | + */ |
|
133 | + private function _is_system_question_group($new_question_group_id) |
|
134 | + { |
|
135 | + global $wpdb; |
|
136 | + $system_id = $wpdb->get_var($wpdb->prepare("SELECT QSG_system FROM ".$wpdb->prefix."esp_question_group WHERE QSG_ID=%d", $new_question_group_id)); |
|
137 | + return intval($system_id); |
|
138 | + } |
|
141 | 139 | } |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | global $wpdb; |
74 | 74 | $new_question_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_question", $old_question_group_question['question_id'], $wpdb->prefix."esp_question"); |
75 | 75 | $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", $old_question_group_question['group_id'], $wpdb->prefix."esp_question_group"); |
76 | - if (! $new_question_id) { |
|
76 | + if ( ! $new_question_id) { |
|
77 | 77 | $this->add_error(sprintf(__("Could not find 4.1 question id for 3.1 question #%d.", "event_espresso"), $old_question_group_question['question_id'])); |
78 | 78 | return 0; |
79 | 79 | } |
80 | - if (! $new_question_group_id) { |
|
80 | + if ( ! $new_question_group_id) { |
|
81 | 81 | $this->add_error(sprintf(__("Could not find 4.1 question group id for 3.1 question group #%d.", "event_espresso"), $old_question_group_question['group_id'])); |
82 | 82 | return 0; |
83 | 83 | } |
84 | 84 | // if it's a system question, it needs to be in the right system group. otherwise no dice! |
85 | - if (($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id) ) |
|
85 | + if (($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id)) |
|
86 | 86 | || |
87 | 87 | ! $this->_is_system_question_for_question_group($new_question_id) |
88 | 88 | ) { |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | 'QST_ID'=>$new_question_id |
92 | 92 | ); |
93 | 93 | $datatypes = array( |
94 | - '%d',// QSG_ID |
|
95 | - '%d',// QST_ID |
|
94 | + '%d', // QSG_ID |
|
95 | + '%d', // QST_ID |
|
96 | 96 | ); |
97 | 97 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
98 | - if (! $success) { |
|
98 | + if ( ! $success) { |
|
99 | 99 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group_question, $this->_new_table, $cols_n_values, $datatypes)); |
100 | 100 | return 0; |
101 | 101 | } |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | { |
117 | 117 | global $wpdb; |
118 | 118 | $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM ".$wpdb->prefix."esp_question WHERE QST_ID=%d", $new_question_id)); |
119 | - if (in_array($system_id, array('fname','lname','email'))) { |
|
119 | + if (in_array($system_id, array('fname', 'lname', 'email'))) { |
|
120 | 120 | return 1; |
121 | - } elseif ($system_id!='' && $system_id) { |
|
121 | + } elseif ($system_id != '' && $system_id) { |
|
122 | 122 | return 2; |
123 | 123 | } else { |
124 | 124 | return 0; |
@@ -11,77 +11,77 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_DMS_4_8_0_event_subtotals extends EE_Data_Migration_Script_Stage_Table |
13 | 13 | { |
14 | - public function __construct() |
|
15 | - { |
|
16 | - global $wpdb; |
|
17 | - $this->_old_table = $wpdb->prefix . 'esp_line_item'; |
|
18 | - $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"'; |
|
19 | - $this->_pretty_name = __('Event Sub-total line items', 'event_espresso'); |
|
20 | - parent::__construct(); |
|
21 | - } |
|
22 | - protected function _migrate_old_row($line_item_row) |
|
23 | - { |
|
24 | - global $wpdb; |
|
25 | - // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID |
|
26 | - $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
27 | - $new_line_item_data = array( |
|
28 | - 'LIN_code' => 'event-' . $event_id, |
|
29 | - 'TXN_ID' => $line_item_row['TXN_ID'], |
|
30 | - 'LIN_name' => __('Event', 'event_espresso'), |
|
31 | - 'LIN_desc' => $line_item_row['LIN_desc'], |
|
32 | - 'LIN_unit_price' => $line_item_row['LIN_unit_price'], |
|
33 | - 'LIN_percent' => $line_item_row['LIN_percent'], |
|
34 | - 'LIN_is_taxable' => $line_item_row['LIN_is_taxable'], |
|
35 | - 'LIN_order' => $line_item_row['LIN_order'], |
|
36 | - 'LIN_total' => $line_item_row['LIN_total'], |
|
37 | - 'LIN_quantity' => $line_item_row['LIN_quantity'], |
|
38 | - 'LIN_parent' => $line_item_row['LIN_ID'], |
|
39 | - 'LIN_type' => 'sub-total', |
|
40 | - 'OBJ_type' => 'Event', |
|
41 | - 'OBJ_ID' => $event_id, |
|
42 | - ); |
|
43 | - $new_line_item_datatypes = array( |
|
44 | - '%s',// LIN_code |
|
45 | - '%d',// TXN_ID |
|
46 | - '%s',// LIN_name |
|
47 | - '%s',// LIN_desc |
|
48 | - '%f',// LIN_unit_price |
|
49 | - '%f',// LIN_percent |
|
50 | - '%d',// LIN_is_taxable |
|
51 | - '%d',// LIN_order |
|
52 | - '%f',// LIN_total |
|
53 | - '%d',// LIN_quantity |
|
54 | - '%d',// LIN_parent |
|
55 | - '%s',// LIN_type |
|
56 | - '%s',// OBJ_type |
|
57 | - '%d',// OBJ_ID |
|
58 | - ); |
|
59 | - // insert the new event subtotal line item, pointing to this line item |
|
60 | - $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes); |
|
61 | - if (! $success) { |
|
62 | - $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes)); |
|
63 | - } |
|
64 | - $new_line_item_id = $wpdb->insert_id; |
|
65 | - $this->get_migration_script()->set_mapping($this->_old_table, $line_item_row['LIN_ID'], $this->_old_table, $new_line_item_id); |
|
66 | - $query = $wpdb->prepare( |
|
67 | - "UPDATE {$this->_old_table} SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100", |
|
68 | - $new_line_item_id, |
|
69 | - $line_item_row['LIN_ID'], |
|
70 | - $new_line_item_id |
|
71 | - ); |
|
72 | - $success = $wpdb->query($query); |
|
73 | - if ($success === false) { |
|
74 | - $this->add_error( |
|
75 | - sprintf( |
|
76 | - __('Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', 'event_espresso'), |
|
77 | - $new_line_item_id, |
|
78 | - $line_item_row['LIN_ID'], |
|
79 | - $wpdb->last_error, |
|
80 | - $query, |
|
81 | - $success |
|
82 | - ) |
|
83 | - ); |
|
84 | - } |
|
85 | - return 1; |
|
86 | - } |
|
14 | + public function __construct() |
|
15 | + { |
|
16 | + global $wpdb; |
|
17 | + $this->_old_table = $wpdb->prefix . 'esp_line_item'; |
|
18 | + $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"'; |
|
19 | + $this->_pretty_name = __('Event Sub-total line items', 'event_espresso'); |
|
20 | + parent::__construct(); |
|
21 | + } |
|
22 | + protected function _migrate_old_row($line_item_row) |
|
23 | + { |
|
24 | + global $wpdb; |
|
25 | + // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID |
|
26 | + $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
27 | + $new_line_item_data = array( |
|
28 | + 'LIN_code' => 'event-' . $event_id, |
|
29 | + 'TXN_ID' => $line_item_row['TXN_ID'], |
|
30 | + 'LIN_name' => __('Event', 'event_espresso'), |
|
31 | + 'LIN_desc' => $line_item_row['LIN_desc'], |
|
32 | + 'LIN_unit_price' => $line_item_row['LIN_unit_price'], |
|
33 | + 'LIN_percent' => $line_item_row['LIN_percent'], |
|
34 | + 'LIN_is_taxable' => $line_item_row['LIN_is_taxable'], |
|
35 | + 'LIN_order' => $line_item_row['LIN_order'], |
|
36 | + 'LIN_total' => $line_item_row['LIN_total'], |
|
37 | + 'LIN_quantity' => $line_item_row['LIN_quantity'], |
|
38 | + 'LIN_parent' => $line_item_row['LIN_ID'], |
|
39 | + 'LIN_type' => 'sub-total', |
|
40 | + 'OBJ_type' => 'Event', |
|
41 | + 'OBJ_ID' => $event_id, |
|
42 | + ); |
|
43 | + $new_line_item_datatypes = array( |
|
44 | + '%s',// LIN_code |
|
45 | + '%d',// TXN_ID |
|
46 | + '%s',// LIN_name |
|
47 | + '%s',// LIN_desc |
|
48 | + '%f',// LIN_unit_price |
|
49 | + '%f',// LIN_percent |
|
50 | + '%d',// LIN_is_taxable |
|
51 | + '%d',// LIN_order |
|
52 | + '%f',// LIN_total |
|
53 | + '%d',// LIN_quantity |
|
54 | + '%d',// LIN_parent |
|
55 | + '%s',// LIN_type |
|
56 | + '%s',// OBJ_type |
|
57 | + '%d',// OBJ_ID |
|
58 | + ); |
|
59 | + // insert the new event subtotal line item, pointing to this line item |
|
60 | + $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes); |
|
61 | + if (! $success) { |
|
62 | + $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes)); |
|
63 | + } |
|
64 | + $new_line_item_id = $wpdb->insert_id; |
|
65 | + $this->get_migration_script()->set_mapping($this->_old_table, $line_item_row['LIN_ID'], $this->_old_table, $new_line_item_id); |
|
66 | + $query = $wpdb->prepare( |
|
67 | + "UPDATE {$this->_old_table} SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100", |
|
68 | + $new_line_item_id, |
|
69 | + $line_item_row['LIN_ID'], |
|
70 | + $new_line_item_id |
|
71 | + ); |
|
72 | + $success = $wpdb->query($query); |
|
73 | + if ($success === false) { |
|
74 | + $this->add_error( |
|
75 | + sprintf( |
|
76 | + __('Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', 'event_espresso'), |
|
77 | + $new_line_item_id, |
|
78 | + $line_item_row['LIN_ID'], |
|
79 | + $wpdb->last_error, |
|
80 | + $query, |
|
81 | + $success |
|
82 | + ) |
|
83 | + ); |
|
84 | + } |
|
85 | + return 1; |
|
86 | + } |
|
87 | 87 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public function __construct() |
15 | 15 | { |
16 | 16 | global $wpdb; |
17 | - $this->_old_table = $wpdb->prefix . 'esp_line_item'; |
|
17 | + $this->_old_table = $wpdb->prefix.'esp_line_item'; |
|
18 | 18 | $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"'; |
19 | 19 | $this->_pretty_name = __('Event Sub-total line items', 'event_espresso'); |
20 | 20 | parent::__construct(); |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | { |
24 | 24 | global $wpdb; |
25 | 25 | // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID |
26 | - $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
26 | + $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM '.$wpdb->prefix.'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
27 | 27 | $new_line_item_data = array( |
28 | - 'LIN_code' => 'event-' . $event_id, |
|
28 | + 'LIN_code' => 'event-'.$event_id, |
|
29 | 29 | 'TXN_ID' => $line_item_row['TXN_ID'], |
30 | 30 | 'LIN_name' => __('Event', 'event_espresso'), |
31 | 31 | 'LIN_desc' => $line_item_row['LIN_desc'], |
@@ -41,24 +41,24 @@ discard block |
||
41 | 41 | 'OBJ_ID' => $event_id, |
42 | 42 | ); |
43 | 43 | $new_line_item_datatypes = array( |
44 | - '%s',// LIN_code |
|
45 | - '%d',// TXN_ID |
|
46 | - '%s',// LIN_name |
|
47 | - '%s',// LIN_desc |
|
48 | - '%f',// LIN_unit_price |
|
49 | - '%f',// LIN_percent |
|
50 | - '%d',// LIN_is_taxable |
|
51 | - '%d',// LIN_order |
|
52 | - '%f',// LIN_total |
|
53 | - '%d',// LIN_quantity |
|
54 | - '%d',// LIN_parent |
|
55 | - '%s',// LIN_type |
|
56 | - '%s',// OBJ_type |
|
57 | - '%d',// OBJ_ID |
|
44 | + '%s', // LIN_code |
|
45 | + '%d', // TXN_ID |
|
46 | + '%s', // LIN_name |
|
47 | + '%s', // LIN_desc |
|
48 | + '%f', // LIN_unit_price |
|
49 | + '%f', // LIN_percent |
|
50 | + '%d', // LIN_is_taxable |
|
51 | + '%d', // LIN_order |
|
52 | + '%f', // LIN_total |
|
53 | + '%d', // LIN_quantity |
|
54 | + '%d', // LIN_parent |
|
55 | + '%s', // LIN_type |
|
56 | + '%s', // OBJ_type |
|
57 | + '%d', // OBJ_ID |
|
58 | 58 | ); |
59 | 59 | // insert the new event subtotal line item, pointing to this line item |
60 | 60 | $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes); |
61 | - if (! $success) { |
|
61 | + if ( ! $success) { |
|
62 | 62 | $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes)); |
63 | 63 | } |
64 | 64 | $new_line_item_id = $wpdb->insert_id; |
@@ -13,53 +13,53 @@ |
||
13 | 13 | class EE_DMS_4_8_0_pretax_totals extends EE_Data_Migration_Script_Stage |
14 | 14 | { |
15 | 15 | |
16 | - protected $_line_item_table_name; |
|
16 | + protected $_line_item_table_name; |
|
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * Just initializes the status of the migration |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - global $wpdb; |
|
25 | - $this->_line_item_table_name = $wpdb->prefix."esp_line_item"; |
|
26 | - $this->_pretty_name = __('Pre-tax total line items', 'event_espresso'); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
19 | + /** |
|
20 | + * Just initializes the status of the migration |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + global $wpdb; |
|
25 | + $this->_line_item_table_name = $wpdb->prefix."esp_line_item"; |
|
26 | + $this->_pretty_name = __('Pre-tax total line items', 'event_espresso'); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Counts the records to migrate; the public version may cache it |
|
34 | - * @return int |
|
35 | - */ |
|
36 | - protected function _count_records_to_migrate() |
|
37 | - { |
|
38 | - return 1; |
|
39 | - } |
|
32 | + /** |
|
33 | + * Counts the records to migrate; the public version may cache it |
|
34 | + * @return int |
|
35 | + */ |
|
36 | + protected function _count_records_to_migrate() |
|
37 | + { |
|
38 | + return 1; |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
45 | - * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
46 | - * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
47 | - * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50, |
|
48 | - * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
49 | - * @param int $num_items_to_migrate |
|
50 | - * @return int number of items ACTUALLY migrated |
|
51 | - */ |
|
52 | - protected function _migration_step($num_items_to_migrate = 50) |
|
53 | - { |
|
54 | - global $wpdb; |
|
55 | - $rows_updated = $wpdb->update( |
|
56 | - $this->_line_item_table_name, |
|
57 | - array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
58 | - array( 'LIN_code' => 'tickets' ), |
|
59 | - array( '%s' ), |
|
60 | - array( '%s' ) |
|
61 | - ); |
|
62 | - $this->set_completed(); |
|
63 | - return 1; |
|
64 | - } |
|
43 | + /** |
|
44 | + * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
45 | + * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
46 | + * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
47 | + * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50, |
|
48 | + * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
49 | + * @param int $num_items_to_migrate |
|
50 | + * @return int number of items ACTUALLY migrated |
|
51 | + */ |
|
52 | + protected function _migration_step($num_items_to_migrate = 50) |
|
53 | + { |
|
54 | + global $wpdb; |
|
55 | + $rows_updated = $wpdb->update( |
|
56 | + $this->_line_item_table_name, |
|
57 | + array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
58 | + array( 'LIN_code' => 'tickets' ), |
|
59 | + array( '%s' ), |
|
60 | + array( '%s' ) |
|
61 | + ); |
|
62 | + $this->set_completed(); |
|
63 | + return 1; |
|
64 | + } |
|
65 | 65 | } |
@@ -54,10 +54,10 @@ |
||
54 | 54 | global $wpdb; |
55 | 55 | $rows_updated = $wpdb->update( |
56 | 56 | $this->_line_item_table_name, |
57 | - array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
58 | - array( 'LIN_code' => 'tickets' ), |
|
59 | - array( '%s' ), |
|
60 | - array( '%s' ) |
|
57 | + array('LIN_code' => 'pre-tax-subtotal'), |
|
58 | + array('LIN_code' => 'tickets'), |
|
59 | + array('%s'), |
|
60 | + array('%s') |
|
61 | 61 | ); |
62 | 62 | $this->set_completed(); |
63 | 63 | return 1; |
@@ -8,49 +8,49 @@ |
||
8 | 8 | |
9 | 9 | class EE_DMS_4_2_0_datetime_fields extends EE_Data_Migration_Script_Stage_Table |
10 | 10 | { |
11 | - public function __construct() |
|
12 | - { |
|
13 | - global $wpdb; |
|
14 | - $this->_pretty_name = __("Datetime Fields", "event_espresso"); |
|
15 | - $this->_old_table = $wpdb->prefix . "esp_datetime"; |
|
16 | - parent::__construct(); |
|
17 | - } |
|
11 | + public function __construct() |
|
12 | + { |
|
13 | + global $wpdb; |
|
14 | + $this->_pretty_name = __("Datetime Fields", "event_espresso"); |
|
15 | + $this->_old_table = $wpdb->prefix . "esp_datetime"; |
|
16 | + parent::__construct(); |
|
17 | + } |
|
18 | 18 | |
19 | - protected function _migrate_old_row($old_row) |
|
20 | - { |
|
21 | - // foreach question_group_question entry with this QST_ID, we want to set its |
|
22 | - // QSG_order equal to this question's QST_order |
|
23 | - global $wpdb; |
|
19 | + protected function _migrate_old_row($old_row) |
|
20 | + { |
|
21 | + // foreach question_group_question entry with this QST_ID, we want to set its |
|
22 | + // QSG_order equal to this question's QST_order |
|
23 | + global $wpdb; |
|
24 | 24 | |
25 | - $updated = $wpdb->update( |
|
26 | - $this->_old_table, |
|
27 | - array( |
|
28 | - 'DTT_name' => '', |
|
29 | - 'DTT_description' => '', |
|
30 | - ), |
|
31 | - array( |
|
32 | - 'DTT_ID' => $old_row['DTT_ID'], |
|
33 | - ), |
|
34 | - array( |
|
35 | - '%s',// DTT_name, |
|
36 | - '%s',// DTT_description |
|
37 | - ), |
|
38 | - array( |
|
39 | - '%d',// DTT_ID |
|
40 | - ) |
|
41 | - ); |
|
42 | - if (false === $updated) { |
|
43 | - $this->add_error( |
|
44 | - sprintf( |
|
45 | - __( |
|
46 | - "Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d", |
|
47 | - 'event_espresso' |
|
48 | - ), |
|
49 | - $this->_old_table, |
|
50 | - $old_row['QST_ID'] |
|
51 | - ) |
|
52 | - ); |
|
53 | - } |
|
54 | - // nothing to map really |
|
55 | - } |
|
25 | + $updated = $wpdb->update( |
|
26 | + $this->_old_table, |
|
27 | + array( |
|
28 | + 'DTT_name' => '', |
|
29 | + 'DTT_description' => '', |
|
30 | + ), |
|
31 | + array( |
|
32 | + 'DTT_ID' => $old_row['DTT_ID'], |
|
33 | + ), |
|
34 | + array( |
|
35 | + '%s',// DTT_name, |
|
36 | + '%s',// DTT_description |
|
37 | + ), |
|
38 | + array( |
|
39 | + '%d',// DTT_ID |
|
40 | + ) |
|
41 | + ); |
|
42 | + if (false === $updated) { |
|
43 | + $this->add_error( |
|
44 | + sprintf( |
|
45 | + __( |
|
46 | + "Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d", |
|
47 | + 'event_espresso' |
|
48 | + ), |
|
49 | + $this->_old_table, |
|
50 | + $old_row['QST_ID'] |
|
51 | + ) |
|
52 | + ); |
|
53 | + } |
|
54 | + // nothing to map really |
|
55 | + } |
|
56 | 56 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | { |
13 | 13 | global $wpdb; |
14 | 14 | $this->_pretty_name = __("Datetime Fields", "event_espresso"); |
15 | - $this->_old_table = $wpdb->prefix . "esp_datetime"; |
|
15 | + $this->_old_table = $wpdb->prefix."esp_datetime"; |
|
16 | 16 | parent::__construct(); |
17 | 17 | } |
18 | 18 | |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | 'DTT_ID' => $old_row['DTT_ID'], |
33 | 33 | ), |
34 | 34 | array( |
35 | - '%s',// DTT_name, |
|
36 | - '%s',// DTT_description |
|
35 | + '%s', // DTT_name, |
|
36 | + '%s', // DTT_description |
|
37 | 37 | ), |
38 | 38 | array( |
39 | - '%d',// DTT_ID |
|
39 | + '%d', // DTT_ID |
|
40 | 40 | ) |
41 | 41 | ); |
42 | 42 | if (false === $updated) { |
@@ -6,42 +6,42 @@ |
||
6 | 6 | |
7 | 7 | class EE_DMS_4_2_0_question_group_questions extends EE_Data_Migration_Script_Stage_Table |
8 | 8 | { |
9 | - private $_qgq_table; |
|
10 | - public function __construct() |
|
11 | - { |
|
12 | - global $wpdb; |
|
13 | - $this->_pretty_name = __("Question Group Questions", "event_espresso"); |
|
14 | - $this->_old_table = $wpdb->prefix."esp_question"; |
|
15 | - $this->_qgq_table = $wpdb->prefix."esp_question_group_question"; |
|
16 | - parent::__construct(); |
|
17 | - } |
|
18 | - protected function _migrate_old_row($old_row) |
|
19 | - { |
|
20 | - // foreach question_group_question entry with this QST_ID, we want to set its |
|
21 | - // QSG_order equal to this question's QST_order |
|
22 | - global $wpdb; |
|
23 | - $updated = $wpdb->update( |
|
24 | - $this->_qgq_table, |
|
25 | - array('QGQ_order'=>$old_row['QST_order']), |
|
26 | - array('QST_ID'=>$old_row['QST_ID']), |
|
27 | - array('%d',// QGQ_order |
|
28 | - ), |
|
29 | - array('%d',// QST_ID |
|
30 | - ) |
|
31 | - ); |
|
32 | - if (false === $updated) { |
|
33 | - $this->add_error( |
|
34 | - sprintf( |
|
35 | - __( |
|
36 | - "Error in updating table %s setting QGQ_order = %d where QST_ID = %d", |
|
37 | - 'event_espresso' |
|
38 | - ), |
|
39 | - $this->_qgq_table, |
|
40 | - $old_row['QST_order'], |
|
41 | - $old_row['QST_ID'] |
|
42 | - ) |
|
43 | - ); |
|
44 | - } |
|
45 | - // nothing to map really |
|
46 | - } |
|
9 | + private $_qgq_table; |
|
10 | + public function __construct() |
|
11 | + { |
|
12 | + global $wpdb; |
|
13 | + $this->_pretty_name = __("Question Group Questions", "event_espresso"); |
|
14 | + $this->_old_table = $wpdb->prefix."esp_question"; |
|
15 | + $this->_qgq_table = $wpdb->prefix."esp_question_group_question"; |
|
16 | + parent::__construct(); |
|
17 | + } |
|
18 | + protected function _migrate_old_row($old_row) |
|
19 | + { |
|
20 | + // foreach question_group_question entry with this QST_ID, we want to set its |
|
21 | + // QSG_order equal to this question's QST_order |
|
22 | + global $wpdb; |
|
23 | + $updated = $wpdb->update( |
|
24 | + $this->_qgq_table, |
|
25 | + array('QGQ_order'=>$old_row['QST_order']), |
|
26 | + array('QST_ID'=>$old_row['QST_ID']), |
|
27 | + array('%d',// QGQ_order |
|
28 | + ), |
|
29 | + array('%d',// QST_ID |
|
30 | + ) |
|
31 | + ); |
|
32 | + if (false === $updated) { |
|
33 | + $this->add_error( |
|
34 | + sprintf( |
|
35 | + __( |
|
36 | + "Error in updating table %s setting QGQ_order = %d where QST_ID = %d", |
|
37 | + 'event_espresso' |
|
38 | + ), |
|
39 | + $this->_qgq_table, |
|
40 | + $old_row['QST_order'], |
|
41 | + $old_row['QST_ID'] |
|
42 | + ) |
|
43 | + ); |
|
44 | + } |
|
45 | + // nothing to map really |
|
46 | + } |
|
47 | 47 | } |
@@ -24,9 +24,9 @@ |
||
24 | 24 | $this->_qgq_table, |
25 | 25 | array('QGQ_order'=>$old_row['QST_order']), |
26 | 26 | array('QST_ID'=>$old_row['QST_ID']), |
27 | - array('%d',// QGQ_order |
|
27 | + array('%d', // QGQ_order |
|
28 | 28 | ), |
29 | - array('%d',// QST_ID |
|
29 | + array('%d', // QST_ID |
|
30 | 30 | ) |
31 | 31 | ); |
32 | 32 | if (false === $updated) { |
@@ -37,103 +37,103 @@ |
||
37 | 37 | */ |
38 | 38 | abstract class EE_Data_Migration_Script_Stage extends EE_Data_Migration_Class_Base |
39 | 39 | { |
40 | - /** |
|
41 | - * The migration script this is a stage of |
|
42 | - * |
|
43 | - * @var EE_Data_Migration_Script_Base |
|
44 | - */ |
|
45 | - protected $_migration_script; |
|
40 | + /** |
|
41 | + * The migration script this is a stage of |
|
42 | + * |
|
43 | + * @var EE_Data_Migration_Script_Base |
|
44 | + */ |
|
45 | + protected $_migration_script; |
|
46 | 46 | |
47 | - /** |
|
48 | - * This should eb called to essentially 'finalize' construction of the stage. |
|
49 | - * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is |
|
50 | - * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to |
|
51 | - * |
|
52 | - * @param EE_Data_Migration_Script_Base $migration_script |
|
53 | - */ |
|
54 | - public function _construct_finalize($migration_script) |
|
55 | - { |
|
56 | - $this->_migration_script = $migration_script; |
|
57 | - } |
|
47 | + /** |
|
48 | + * This should eb called to essentially 'finalize' construction of the stage. |
|
49 | + * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is |
|
50 | + * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to |
|
51 | + * |
|
52 | + * @param EE_Data_Migration_Script_Base $migration_script |
|
53 | + */ |
|
54 | + public function _construct_finalize($migration_script) |
|
55 | + { |
|
56 | + $this->_migration_script = $migration_script; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here, |
|
61 | - * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children |
|
62 | - * needs to catch exceptions and decide what's a fatal error and what isn't. |
|
63 | - * |
|
64 | - * @param int $num_items_to_migrate |
|
65 | - * @return int |
|
66 | - */ |
|
67 | - public function migration_step($num_items_to_migrate = 50) |
|
68 | - { |
|
69 | - // before we run the migration step, we want ot take note of warnings that get outputted |
|
70 | - ob_start(); |
|
71 | - $items_migrated = $this->_migration_step($num_items_to_migrate); |
|
72 | - $output = ob_get_contents(); |
|
73 | - ob_end_clean(); |
|
74 | - if ($output) { |
|
75 | - $this->add_error($output); |
|
76 | - } |
|
77 | - $this->_records_migrated += $items_migrated; |
|
78 | - return $items_migrated; |
|
79 | - } |
|
59 | + /** |
|
60 | + * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here, |
|
61 | + * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children |
|
62 | + * needs to catch exceptions and decide what's a fatal error and what isn't. |
|
63 | + * |
|
64 | + * @param int $num_items_to_migrate |
|
65 | + * @return int |
|
66 | + */ |
|
67 | + public function migration_step($num_items_to_migrate = 50) |
|
68 | + { |
|
69 | + // before we run the migration step, we want ot take note of warnings that get outputted |
|
70 | + ob_start(); |
|
71 | + $items_migrated = $this->_migration_step($num_items_to_migrate); |
|
72 | + $output = ob_get_contents(); |
|
73 | + ob_end_clean(); |
|
74 | + if ($output) { |
|
75 | + $this->add_error($output); |
|
76 | + } |
|
77 | + $this->_records_migrated += $items_migrated; |
|
78 | + return $items_migrated; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property |
|
84 | - * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that |
|
85 | - * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the |
|
86 | - * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees |
|
87 | - * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at |
|
88 | - * very least we MUST report/return 50 items migrated) |
|
89 | - * |
|
90 | - * @param int $num_items_to_migrate |
|
91 | - * @return int number of items ACTUALLY migrated |
|
92 | - */ |
|
93 | - abstract protected function _migration_step($num_items_to_migrate = 50); |
|
82 | + /** |
|
83 | + * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property |
|
84 | + * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that |
|
85 | + * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the |
|
86 | + * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees |
|
87 | + * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at |
|
88 | + * very least we MUST report/return 50 items migrated) |
|
89 | + * |
|
90 | + * @param int $num_items_to_migrate |
|
91 | + * @return int number of items ACTUALLY migrated |
|
92 | + */ |
|
93 | + abstract protected function _migration_step($num_items_to_migrate = 50); |
|
94 | 94 | |
95 | - /** |
|
96 | - * Counts the records that have been migrated so far |
|
97 | - * |
|
98 | - * @return int |
|
99 | - */ |
|
100 | - public function count_records_migrated() |
|
101 | - { |
|
102 | - return $this->_records_migrated; |
|
103 | - } |
|
95 | + /** |
|
96 | + * Counts the records that have been migrated so far |
|
97 | + * |
|
98 | + * @return int |
|
99 | + */ |
|
100 | + public function count_records_migrated() |
|
101 | + { |
|
102 | + return $this->_records_migrated; |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * returns an array of strings describing errors |
|
107 | - * |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - public function get_errors() |
|
111 | - { |
|
112 | - return $this->_errors; |
|
113 | - } |
|
105 | + /** |
|
106 | + * returns an array of strings describing errors |
|
107 | + * |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + public function get_errors() |
|
111 | + { |
|
112 | + return $this->_errors; |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * Sets all of the properties of this script stage to match what's in the array, which is assumed |
|
118 | - * to have been made from the properties_as_array() function. |
|
119 | - * |
|
120 | - * @param array $array_of_properties like what's produced from properties_as_array() method |
|
121 | - */ |
|
122 | - public function instantiate_from_array_of_properties($array_of_properties) |
|
123 | - { |
|
124 | - unset($array_of_properties['class']); |
|
125 | - foreach ($array_of_properties as $property_name => $property_value) { |
|
126 | - $this->{$property_name} = $property_value; |
|
127 | - } |
|
128 | - } |
|
116 | + /** |
|
117 | + * Sets all of the properties of this script stage to match what's in the array, which is assumed |
|
118 | + * to have been made from the properties_as_array() function. |
|
119 | + * |
|
120 | + * @param array $array_of_properties like what's produced from properties_as_array() method |
|
121 | + */ |
|
122 | + public function instantiate_from_array_of_properties($array_of_properties) |
|
123 | + { |
|
124 | + unset($array_of_properties['class']); |
|
125 | + foreach ($array_of_properties as $property_name => $property_value) { |
|
126 | + $this->{$property_name} = $property_value; |
|
127 | + } |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Gets the script this is a stage of |
|
132 | - * |
|
133 | - * @return EE_Data_Migration_Script_Base |
|
134 | - */ |
|
135 | - protected function get_migration_script() |
|
136 | - { |
|
137 | - return $this->_migration_script; |
|
138 | - } |
|
130 | + /** |
|
131 | + * Gets the script this is a stage of |
|
132 | + * |
|
133 | + * @return EE_Data_Migration_Script_Base |
|
134 | + */ |
|
135 | + protected function get_migration_script() |
|
136 | + { |
|
137 | + return $this->_migration_script; |
|
138 | + } |
|
139 | 139 | } |
@@ -13,59 +13,59 @@ |
||
13 | 13 | class EE_DMS_4_3_0_event_message_templates extends EE_Data_Migration_Script_Stage_Table |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * This property will hold the table name for event_message_templates |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - private $_emt_table; |
|
16 | + /** |
|
17 | + * This property will hold the table name for event_message_templates |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + private $_emt_table; |
|
21 | 21 | |
22 | 22 | |
23 | - public function __construct() |
|
24 | - { |
|
25 | - global $wpdb; |
|
26 | - $this->_pretty_name = __('Event Message Templates', 'event_espresso'); |
|
27 | - $this->_old_table = $wpdb->prefix."esp_message_template_group"; |
|
28 | - $this->_emt_table = $wpdb->prefix."esp_event_message_template"; |
|
29 | - parent::__construct(); |
|
30 | - } |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + global $wpdb; |
|
26 | + $this->_pretty_name = __('Event Message Templates', 'event_espresso'); |
|
27 | + $this->_old_table = $wpdb->prefix."esp_message_template_group"; |
|
28 | + $this->_emt_table = $wpdb->prefix."esp_event_message_template"; |
|
29 | + parent::__construct(); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | - protected function _migrate_old_row($old_row) |
|
35 | - { |
|
36 | - // foreach row that has an evt_id ..let's create an equivalent entry in the new event_messages_template table to link the message template to the event (since EVT_ID is no longer referenced in esp_message_template_groups ) |
|
37 | - global $wpdb; |
|
38 | - if ($old_row['EVT_ID'] > 0) { |
|
39 | - // let's get the EVT for this id so we can update the custom name on the old row. |
|
40 | - $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID']))); |
|
34 | + protected function _migrate_old_row($old_row) |
|
35 | + { |
|
36 | + // foreach row that has an evt_id ..let's create an equivalent entry in the new event_messages_template table to link the message template to the event (since EVT_ID is no longer referenced in esp_message_template_groups ) |
|
37 | + global $wpdb; |
|
38 | + if ($old_row['EVT_ID'] > 0) { |
|
39 | + // let's get the EVT for this id so we can update the custom name on the old row. |
|
40 | + $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID']))); |
|
41 | 41 | |
42 | - // update name |
|
43 | - $updated = $wpdb->update( |
|
44 | - $this->_old_table, |
|
45 | - array( |
|
46 | - 'MTP_name' =>$event_name |
|
47 | - ), |
|
48 | - array( 'GRP_ID' => (int) $old_row['GRP_ID'] ), |
|
49 | - array( '%s' ), |
|
50 | - array( '%d' ) |
|
51 | - ); |
|
42 | + // update name |
|
43 | + $updated = $wpdb->update( |
|
44 | + $this->_old_table, |
|
45 | + array( |
|
46 | + 'MTP_name' =>$event_name |
|
47 | + ), |
|
48 | + array( 'GRP_ID' => (int) $old_row['GRP_ID'] ), |
|
49 | + array( '%s' ), |
|
50 | + array( '%d' ) |
|
51 | + ); |
|
52 | 52 | |
53 | - $inserted = $wpdb->insert( |
|
54 | - $this->_emt_table, |
|
55 | - array( |
|
56 | - 'EVT_ID' => (int) $old_row['EVT_ID'], |
|
57 | - 'GRP_ID' => (int) $old_row['GRP_ID'], |
|
58 | - ), |
|
59 | - array( '%d', '%d' ) |
|
60 | - ); |
|
53 | + $inserted = $wpdb->insert( |
|
54 | + $this->_emt_table, |
|
55 | + array( |
|
56 | + 'EVT_ID' => (int) $old_row['EVT_ID'], |
|
57 | + 'GRP_ID' => (int) $old_row['GRP_ID'], |
|
58 | + ), |
|
59 | + array( '%d', '%d' ) |
|
60 | + ); |
|
61 | 61 | |
62 | - if (false === $updated) { |
|
63 | - $this->add_error(sprintf(__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name)); |
|
64 | - } |
|
62 | + if (false === $updated) { |
|
63 | + $this->add_error(sprintf(__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name)); |
|
64 | + } |
|
65 | 65 | |
66 | - if (false === $inserted) { |
|
67 | - $this->add_error(sprintf(__("Error in inserting a row into setting EVT_ID = %d and GRP_ID = %d", "event_espresso"), $this->_emt_table, $old_row['EVT_ID'], $old_row['GRP_ID'])); |
|
68 | - } |
|
69 | - } |
|
70 | - } |
|
66 | + if (false === $inserted) { |
|
67 | + $this->add_error(sprintf(__("Error in inserting a row into setting EVT_ID = %d and GRP_ID = %d", "event_espresso"), $this->_emt_table, $old_row['EVT_ID'], $old_row['GRP_ID'])); |
|
68 | + } |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | global $wpdb; |
38 | 38 | if ($old_row['EVT_ID'] > 0) { |
39 | 39 | // let's get the EVT for this id so we can update the custom name on the old row. |
40 | - $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID']))); |
|
40 | + $event_name = 'Custom Template for '.$wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID']))); |
|
41 | 41 | |
42 | 42 | // update name |
43 | 43 | $updated = $wpdb->update( |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | array( |
46 | 46 | 'MTP_name' =>$event_name |
47 | 47 | ), |
48 | - array( 'GRP_ID' => (int) $old_row['GRP_ID'] ), |
|
49 | - array( '%s' ), |
|
50 | - array( '%d' ) |
|
48 | + array('GRP_ID' => (int) $old_row['GRP_ID']), |
|
49 | + array('%s'), |
|
50 | + array('%d') |
|
51 | 51 | ); |
52 | 52 | |
53 | 53 | $inserted = $wpdb->insert( |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | 'EVT_ID' => (int) $old_row['EVT_ID'], |
57 | 57 | 'GRP_ID' => (int) $old_row['GRP_ID'], |
58 | 58 | ), |
59 | - array( '%d', '%d' ) |
|
59 | + array('%d', '%d') |
|
60 | 60 | ); |
61 | 61 | |
62 | 62 | if (false === $updated) { |
@@ -7,39 +7,39 @@ |
||
7 | 7 | |
8 | 8 | class EE_DMS_4_3_0_question_option_order extends EE_Data_Migration_Script_Stage_Table |
9 | 9 | { |
10 | - public function __construct() |
|
11 | - { |
|
12 | - global $wpdb; |
|
13 | - $this->_pretty_name = __("Question Options", "event_espresso"); |
|
14 | - $this->_old_table = $wpdb->prefix."esp_question_option"; |
|
15 | - parent::__construct(); |
|
16 | - } |
|
17 | - protected function _migrate_old_row($old_row) |
|
18 | - { |
|
19 | - // foreach question_group_question entry with this QST_ID, we want to set its |
|
20 | - // QSG_order equal to this question's QST_order |
|
21 | - global $wpdb; |
|
22 | - $updated = $wpdb->update( |
|
23 | - $this->_old_table, |
|
24 | - array('QSO_order'=>$old_row['QSO_ID']), |
|
25 | - array('QSO_ID'=>$old_row['QSO_ID']), |
|
26 | - array('%d',// QSO_order |
|
27 | - ), |
|
28 | - array('%d',// QSO_ID |
|
29 | - ) |
|
30 | - ); |
|
31 | - if (false === $updated) { |
|
32 | - $this->add_error( |
|
33 | - sprintf( |
|
34 | - __( |
|
35 | - "Error in updating table %s setting QSO_order = %d where QSO_ID = %d", |
|
36 | - 'event_espresso' |
|
37 | - ), |
|
38 | - $this->_old_table, |
|
39 | - $old_row['QSO_ID'], |
|
40 | - $old_row['QSO_ID'] |
|
41 | - ) |
|
42 | - ); |
|
43 | - } |
|
44 | - } |
|
10 | + public function __construct() |
|
11 | + { |
|
12 | + global $wpdb; |
|
13 | + $this->_pretty_name = __("Question Options", "event_espresso"); |
|
14 | + $this->_old_table = $wpdb->prefix."esp_question_option"; |
|
15 | + parent::__construct(); |
|
16 | + } |
|
17 | + protected function _migrate_old_row($old_row) |
|
18 | + { |
|
19 | + // foreach question_group_question entry with this QST_ID, we want to set its |
|
20 | + // QSG_order equal to this question's QST_order |
|
21 | + global $wpdb; |
|
22 | + $updated = $wpdb->update( |
|
23 | + $this->_old_table, |
|
24 | + array('QSO_order'=>$old_row['QSO_ID']), |
|
25 | + array('QSO_ID'=>$old_row['QSO_ID']), |
|
26 | + array('%d',// QSO_order |
|
27 | + ), |
|
28 | + array('%d',// QSO_ID |
|
29 | + ) |
|
30 | + ); |
|
31 | + if (false === $updated) { |
|
32 | + $this->add_error( |
|
33 | + sprintf( |
|
34 | + __( |
|
35 | + "Error in updating table %s setting QSO_order = %d where QSO_ID = %d", |
|
36 | + 'event_espresso' |
|
37 | + ), |
|
38 | + $this->_old_table, |
|
39 | + $old_row['QSO_ID'], |
|
40 | + $old_row['QSO_ID'] |
|
41 | + ) |
|
42 | + ); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | } |
@@ -23,9 +23,9 @@ |
||
23 | 23 | $this->_old_table, |
24 | 24 | array('QSO_order'=>$old_row['QSO_ID']), |
25 | 25 | array('QSO_ID'=>$old_row['QSO_ID']), |
26 | - array('%d',// QSO_order |
|
26 | + array('%d', // QSO_order |
|
27 | 27 | ), |
28 | - array('%d',// QSO_ID |
|
28 | + array('%d', // QSO_ID |
|
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | if (false === $updated) { |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | print( |
345 | 345 | apply_filters( |
346 | 346 | 'FHEE__EE_Front_Controller__header_meta_tag', |
347 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
347 | + '<meta name="generator" content="Event Espresso Version '.EVENT_ESPRESSO_VERSION."\" />\n" |
|
348 | 348 | ) |
349 | 349 | ); |
350 | 350 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | print( |
361 | 361 | apply_filters( |
362 | 362 | 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
363 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
363 | + '<meta name="robots" content="noindex,follow" />'."\n" |
|
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | } |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | { |
414 | 414 | static $shown_already = false; |
415 | 415 | do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
416 | - if (! $shown_already |
|
416 | + if ( ! $shown_already |
|
417 | 417 | && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
418 | 418 | && is_main_query() |
419 | 419 | && ! is_feed() |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | ) { |
423 | 423 | echo EE_Error::get_notices(); |
424 | 424 | $shown_already = true; |
425 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
425 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
426 | 426 | } |
427 | 427 | do_action('AHEE__EE_Front_Controller__display_errors__end'); |
428 | 428 | } |
@@ -26,467 +26,467 @@ |
||
26 | 26 | final class EE_Front_Controller |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * @var string $_template_path |
|
31 | - */ |
|
32 | - private $_template_path; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string $_template |
|
36 | - */ |
|
37 | - private $_template; |
|
38 | - |
|
39 | - /** |
|
40 | - * @type EE_Registry $Registry |
|
41 | - */ |
|
42 | - protected $Registry; |
|
43 | - |
|
44 | - /** |
|
45 | - * @type EE_Request_Handler $Request_Handler |
|
46 | - */ |
|
47 | - protected $Request_Handler; |
|
48 | - |
|
49 | - /** |
|
50 | - * @type EE_Module_Request_Router $Module_Request_Router |
|
51 | - */ |
|
52 | - protected $Module_Request_Router; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * class constructor |
|
57 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
58 | - * |
|
59 | - * @access public |
|
60 | - * @param \EE_Registry $Registry |
|
61 | - * @param \EE_Request_Handler $Request_Handler |
|
62 | - * @param \EE_Module_Request_Router $Module_Request_Router |
|
63 | - */ |
|
64 | - public function __construct( |
|
65 | - EE_Registry $Registry, |
|
66 | - EE_Request_Handler $Request_Handler, |
|
67 | - EE_Module_Request_Router $Module_Request_Router |
|
68 | - ) { |
|
69 | - $this->Registry = $Registry; |
|
70 | - $this->Request_Handler = $Request_Handler; |
|
71 | - $this->Module_Request_Router = $Module_Request_Router; |
|
72 | - // load other resources and begin to actually run shortcodes and modules |
|
73 | - add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
74 | - // analyse the incoming WP request |
|
75 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
76 | - // process request with module factory |
|
77 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
78 | - // before headers sent |
|
79 | - add_action('wp', array($this, 'wp'), 5); |
|
80 | - // primarily used to process any content shortcodes |
|
81 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
82 | - // header |
|
83 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
84 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
85 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
86 | - // display errors |
|
87 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
88 | - // the content |
|
89 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
90 | - // exclude our private cpt comments |
|
91 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
92 | - // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
93 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
94 | - // action hook EE |
|
95 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @return EE_Request_Handler |
|
101 | - */ |
|
102 | - public function Request_Handler() |
|
103 | - { |
|
104 | - return $this->Request_Handler; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @return EE_Module_Request_Router |
|
110 | - */ |
|
111 | - public function Module_Request_Router() |
|
112 | - { |
|
113 | - return $this->Module_Request_Router; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @return LegacyShortcodesManager |
|
119 | - */ |
|
120 | - public function getLegacyShortcodesManager() |
|
121 | - { |
|
122 | - return EE_Config::getLegacyShortcodesManager(); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - |
|
129 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
130 | - /** |
|
131 | - * filter_wp_comments |
|
132 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
133 | - * widgets/queries done on frontend |
|
134 | - * |
|
135 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
136 | - * @return array array of comment clauses with modifications. |
|
137 | - * @throws InvalidArgumentException |
|
138 | - * @throws InvalidDataTypeException |
|
139 | - * @throws InvalidInterfaceException |
|
140 | - */ |
|
141 | - public function filter_wp_comments($clauses) |
|
142 | - { |
|
143 | - global $wpdb; |
|
144 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
145 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
146 | - $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
147 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
148 | - ); |
|
149 | - $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
150 | - foreach ($cpts as $cpt => $details) { |
|
151 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
152 | - } |
|
153 | - } |
|
154 | - return $clauses; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
160 | - * |
|
161 | - * @param string $url incoming url |
|
162 | - * @return string final assembled url |
|
163 | - */ |
|
164 | - public function maybe_force_admin_ajax_ssl($url) |
|
165 | - { |
|
166 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
167 | - $url = str_replace('http://', 'https://', $url); |
|
168 | - } |
|
169 | - return $url; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
182 | - * default priority init phases have run |
|
183 | - * |
|
184 | - * @access public |
|
185 | - * @return void |
|
186 | - */ |
|
187 | - public function wp_loaded() |
|
188 | - { |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
196 | - /** |
|
197 | - * _get_request |
|
198 | - * |
|
199 | - * @access public |
|
200 | - * @param WP $WP |
|
201 | - * @return void |
|
202 | - */ |
|
203 | - public function get_request(WP $WP) |
|
204 | - { |
|
205 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
206 | - $this->Request_Handler->parse_request($WP); |
|
207 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
213 | - * |
|
214 | - * @access public |
|
215 | - * @param WP_Query $WP_Query |
|
216 | - * @return void |
|
217 | - */ |
|
218 | - public function pre_get_posts($WP_Query) |
|
219 | - { |
|
220 | - // only load Module_Request_Router if this is the main query |
|
221 | - if ($this->Module_Request_Router instanceof EE_Module_Request_Router |
|
222 | - && $WP_Query->is_main_query() |
|
223 | - ) { |
|
224 | - // cycle thru module routes |
|
225 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
226 | - // determine module and method for route |
|
227 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
228 | - if ($module instanceof EED_Module) { |
|
229 | - // get registered view for route |
|
230 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
231 | - // grab module name |
|
232 | - $module_name = $module->module_name(); |
|
233 | - // map the module to the module objects |
|
234 | - $this->Registry->modules->{$module_name} = $module; |
|
235 | - } |
|
236 | - } |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - |
|
242 | - |
|
243 | - |
|
244 | - /*********************************************** WP HOOK ***********************************************/ |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * wp - basically last chance to do stuff before headers sent |
|
249 | - * |
|
250 | - * @access public |
|
251 | - * @return void |
|
252 | - */ |
|
253 | - public function wp() |
|
254 | - { |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - |
|
259 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * callback for the "template_redirect" hook point |
|
264 | - * checks sidebars for EE widgets |
|
265 | - * loads resources and assets accordingly |
|
266 | - * |
|
267 | - * @return void |
|
268 | - */ |
|
269 | - public function templateRedirect() |
|
270 | - { |
|
271 | - global $wp_query; |
|
272 | - if (empty($wp_query->posts)) { |
|
273 | - return; |
|
274 | - } |
|
275 | - // if we already know this is an espresso page, then load assets |
|
276 | - $load_assets = $this->Request_Handler->is_espresso_page(); |
|
277 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
278 | - $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
279 | - if ($load_assets) { |
|
280 | - add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
281 | - add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
282 | - } |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * builds list of active widgets then scans active sidebars looking for them |
|
288 | - * returns true is an EE widget is found in an active sidebar |
|
289 | - * Please Note: this does NOT mean that the sidebar or widget |
|
290 | - * is actually in use in a given template, as that is unfortunately not known |
|
291 | - * until a sidebar and it's widgets are actually loaded |
|
292 | - * |
|
293 | - * @return boolean |
|
294 | - */ |
|
295 | - private function espresso_widgets_in_active_sidebars() |
|
296 | - { |
|
297 | - $espresso_widgets = array(); |
|
298 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
299 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
300 | - if (is_active_widget(false, false, $id_base)) { |
|
301 | - $espresso_widgets[] = $id_base; |
|
302 | - } |
|
303 | - } |
|
304 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
305 | - foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
306 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
307 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
308 | - foreach ($espresso_widgets as $espresso_widget) { |
|
309 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
310 | - return true; |
|
311 | - } |
|
312 | - } |
|
313 | - } |
|
314 | - } |
|
315 | - } |
|
316 | - return false; |
|
317 | - } |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * header_meta_tag |
|
322 | - * |
|
323 | - * @access public |
|
324 | - * @return void |
|
325 | - */ |
|
326 | - public function header_meta_tag() |
|
327 | - { |
|
328 | - print( |
|
329 | - apply_filters( |
|
330 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
331 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
332 | - ) |
|
333 | - ); |
|
334 | - |
|
335 | - // let's exclude all event type taxonomy term archive pages from search engine indexing |
|
336 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
337 | - // also exclude all critical pages from indexing |
|
338 | - if (( |
|
339 | - is_tax('espresso_event_type') |
|
340 | - && get_option('blog_public') !== '0' |
|
341 | - ) |
|
342 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
343 | - ) { |
|
344 | - print( |
|
345 | - apply_filters( |
|
346 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
347 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
348 | - ) |
|
349 | - ); |
|
350 | - } |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * wp_print_scripts |
|
356 | - * |
|
357 | - * @return void |
|
358 | - */ |
|
359 | - public function wp_print_scripts() |
|
360 | - { |
|
361 | - global $post; |
|
362 | - if (isset($post->EE_Event) |
|
363 | - && $post->EE_Event instanceof EE_Event |
|
364 | - && get_post_type() === 'espresso_events' |
|
365 | - && is_singular() |
|
366 | - ) { |
|
367 | - \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - public function enqueueStyle() |
|
373 | - { |
|
374 | - wp_enqueue_style('espresso_default'); |
|
375 | - wp_enqueue_style('espresso_custom_css'); |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - |
|
380 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
381 | - |
|
382 | - |
|
383 | - public function enqueueScripts() |
|
384 | - { |
|
385 | - wp_enqueue_script('espresso_core'); |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * display_errors |
|
391 | - * |
|
392 | - * @access public |
|
393 | - * @return void |
|
394 | - * @throws DomainException |
|
395 | - */ |
|
396 | - public function display_errors() |
|
397 | - { |
|
398 | - static $shown_already = false; |
|
399 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
400 | - if (! $shown_already |
|
401 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
402 | - && is_main_query() |
|
403 | - && ! is_feed() |
|
404 | - && in_the_loop() |
|
405 | - && did_action('wp_head') |
|
406 | - && $this->Request_Handler->is_espresso_page() |
|
407 | - ) { |
|
408 | - echo EE_Error::get_notices(); |
|
409 | - $shown_already = true; |
|
410 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
411 | - } |
|
412 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - |
|
417 | - |
|
418 | - |
|
419 | - /*********************************************** UTILITIES ***********************************************/ |
|
420 | - /** |
|
421 | - * template_include |
|
422 | - * |
|
423 | - * @access public |
|
424 | - * @param string $template_include_path |
|
425 | - * @return string |
|
426 | - */ |
|
427 | - public function template_include($template_include_path = null) |
|
428 | - { |
|
429 | - if ($this->Request_Handler->is_espresso_page()) { |
|
430 | - $this->_template_path = ! empty($this->_template_path) |
|
431 | - ? basename($this->_template_path) |
|
432 | - : basename( |
|
433 | - $template_include_path |
|
434 | - ); |
|
435 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
436 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
437 | - $this->_template = basename($this->_template_path); |
|
438 | - return $this->_template_path; |
|
439 | - } |
|
440 | - return $template_include_path; |
|
441 | - } |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * get_selected_template |
|
446 | - * |
|
447 | - * @access public |
|
448 | - * @param bool $with_path |
|
449 | - * @return string |
|
450 | - */ |
|
451 | - public function get_selected_template($with_path = false) |
|
452 | - { |
|
453 | - return $with_path ? $this->_template_path : $this->_template; |
|
454 | - } |
|
455 | - |
|
456 | - |
|
457 | - /** |
|
458 | - * @deprecated 4.9.26 |
|
459 | - * @param string $shortcode_class |
|
460 | - * @param \WP $wp |
|
461 | - */ |
|
462 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
463 | - { |
|
464 | - \EE_Error::doing_it_wrong( |
|
465 | - __METHOD__, |
|
466 | - __( |
|
467 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
468 | - 'event_espresso' |
|
469 | - ), |
|
470 | - '4.9.26' |
|
471 | - ); |
|
472 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
473 | - } |
|
474 | - |
|
475 | - |
|
476 | - /** |
|
477 | - * @return void |
|
478 | - * @deprecated 4.9.57.p |
|
479 | - */ |
|
480 | - public function loadPersistentAdminNoticeManager() |
|
481 | - { |
|
482 | - } |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * @return void |
|
487 | - * @deprecated 4.9.64.p |
|
488 | - */ |
|
489 | - public function employ_CPT_Strategy() |
|
490 | - { |
|
491 | - } |
|
29 | + /** |
|
30 | + * @var string $_template_path |
|
31 | + */ |
|
32 | + private $_template_path; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string $_template |
|
36 | + */ |
|
37 | + private $_template; |
|
38 | + |
|
39 | + /** |
|
40 | + * @type EE_Registry $Registry |
|
41 | + */ |
|
42 | + protected $Registry; |
|
43 | + |
|
44 | + /** |
|
45 | + * @type EE_Request_Handler $Request_Handler |
|
46 | + */ |
|
47 | + protected $Request_Handler; |
|
48 | + |
|
49 | + /** |
|
50 | + * @type EE_Module_Request_Router $Module_Request_Router |
|
51 | + */ |
|
52 | + protected $Module_Request_Router; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * class constructor |
|
57 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
58 | + * |
|
59 | + * @access public |
|
60 | + * @param \EE_Registry $Registry |
|
61 | + * @param \EE_Request_Handler $Request_Handler |
|
62 | + * @param \EE_Module_Request_Router $Module_Request_Router |
|
63 | + */ |
|
64 | + public function __construct( |
|
65 | + EE_Registry $Registry, |
|
66 | + EE_Request_Handler $Request_Handler, |
|
67 | + EE_Module_Request_Router $Module_Request_Router |
|
68 | + ) { |
|
69 | + $this->Registry = $Registry; |
|
70 | + $this->Request_Handler = $Request_Handler; |
|
71 | + $this->Module_Request_Router = $Module_Request_Router; |
|
72 | + // load other resources and begin to actually run shortcodes and modules |
|
73 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
74 | + // analyse the incoming WP request |
|
75 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
76 | + // process request with module factory |
|
77 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
78 | + // before headers sent |
|
79 | + add_action('wp', array($this, 'wp'), 5); |
|
80 | + // primarily used to process any content shortcodes |
|
81 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
82 | + // header |
|
83 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
84 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
85 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
86 | + // display errors |
|
87 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
88 | + // the content |
|
89 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
90 | + // exclude our private cpt comments |
|
91 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
92 | + // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
93 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
94 | + // action hook EE |
|
95 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @return EE_Request_Handler |
|
101 | + */ |
|
102 | + public function Request_Handler() |
|
103 | + { |
|
104 | + return $this->Request_Handler; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @return EE_Module_Request_Router |
|
110 | + */ |
|
111 | + public function Module_Request_Router() |
|
112 | + { |
|
113 | + return $this->Module_Request_Router; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @return LegacyShortcodesManager |
|
119 | + */ |
|
120 | + public function getLegacyShortcodesManager() |
|
121 | + { |
|
122 | + return EE_Config::getLegacyShortcodesManager(); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + |
|
129 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
130 | + /** |
|
131 | + * filter_wp_comments |
|
132 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
133 | + * widgets/queries done on frontend |
|
134 | + * |
|
135 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
136 | + * @return array array of comment clauses with modifications. |
|
137 | + * @throws InvalidArgumentException |
|
138 | + * @throws InvalidDataTypeException |
|
139 | + * @throws InvalidInterfaceException |
|
140 | + */ |
|
141 | + public function filter_wp_comments($clauses) |
|
142 | + { |
|
143 | + global $wpdb; |
|
144 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
145 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
146 | + $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
147 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
148 | + ); |
|
149 | + $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
150 | + foreach ($cpts as $cpt => $details) { |
|
151 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
152 | + } |
|
153 | + } |
|
154 | + return $clauses; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
160 | + * |
|
161 | + * @param string $url incoming url |
|
162 | + * @return string final assembled url |
|
163 | + */ |
|
164 | + public function maybe_force_admin_ajax_ssl($url) |
|
165 | + { |
|
166 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
167 | + $url = str_replace('http://', 'https://', $url); |
|
168 | + } |
|
169 | + return $url; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
182 | + * default priority init phases have run |
|
183 | + * |
|
184 | + * @access public |
|
185 | + * @return void |
|
186 | + */ |
|
187 | + public function wp_loaded() |
|
188 | + { |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
196 | + /** |
|
197 | + * _get_request |
|
198 | + * |
|
199 | + * @access public |
|
200 | + * @param WP $WP |
|
201 | + * @return void |
|
202 | + */ |
|
203 | + public function get_request(WP $WP) |
|
204 | + { |
|
205 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
206 | + $this->Request_Handler->parse_request($WP); |
|
207 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
213 | + * |
|
214 | + * @access public |
|
215 | + * @param WP_Query $WP_Query |
|
216 | + * @return void |
|
217 | + */ |
|
218 | + public function pre_get_posts($WP_Query) |
|
219 | + { |
|
220 | + // only load Module_Request_Router if this is the main query |
|
221 | + if ($this->Module_Request_Router instanceof EE_Module_Request_Router |
|
222 | + && $WP_Query->is_main_query() |
|
223 | + ) { |
|
224 | + // cycle thru module routes |
|
225 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
226 | + // determine module and method for route |
|
227 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
228 | + if ($module instanceof EED_Module) { |
|
229 | + // get registered view for route |
|
230 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
231 | + // grab module name |
|
232 | + $module_name = $module->module_name(); |
|
233 | + // map the module to the module objects |
|
234 | + $this->Registry->modules->{$module_name} = $module; |
|
235 | + } |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + |
|
242 | + |
|
243 | + |
|
244 | + /*********************************************** WP HOOK ***********************************************/ |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * wp - basically last chance to do stuff before headers sent |
|
249 | + * |
|
250 | + * @access public |
|
251 | + * @return void |
|
252 | + */ |
|
253 | + public function wp() |
|
254 | + { |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + |
|
259 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * callback for the "template_redirect" hook point |
|
264 | + * checks sidebars for EE widgets |
|
265 | + * loads resources and assets accordingly |
|
266 | + * |
|
267 | + * @return void |
|
268 | + */ |
|
269 | + public function templateRedirect() |
|
270 | + { |
|
271 | + global $wp_query; |
|
272 | + if (empty($wp_query->posts)) { |
|
273 | + return; |
|
274 | + } |
|
275 | + // if we already know this is an espresso page, then load assets |
|
276 | + $load_assets = $this->Request_Handler->is_espresso_page(); |
|
277 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
278 | + $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
279 | + if ($load_assets) { |
|
280 | + add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
281 | + add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
282 | + } |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * builds list of active widgets then scans active sidebars looking for them |
|
288 | + * returns true is an EE widget is found in an active sidebar |
|
289 | + * Please Note: this does NOT mean that the sidebar or widget |
|
290 | + * is actually in use in a given template, as that is unfortunately not known |
|
291 | + * until a sidebar and it's widgets are actually loaded |
|
292 | + * |
|
293 | + * @return boolean |
|
294 | + */ |
|
295 | + private function espresso_widgets_in_active_sidebars() |
|
296 | + { |
|
297 | + $espresso_widgets = array(); |
|
298 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
299 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
300 | + if (is_active_widget(false, false, $id_base)) { |
|
301 | + $espresso_widgets[] = $id_base; |
|
302 | + } |
|
303 | + } |
|
304 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
305 | + foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
306 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
307 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
308 | + foreach ($espresso_widgets as $espresso_widget) { |
|
309 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
310 | + return true; |
|
311 | + } |
|
312 | + } |
|
313 | + } |
|
314 | + } |
|
315 | + } |
|
316 | + return false; |
|
317 | + } |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * header_meta_tag |
|
322 | + * |
|
323 | + * @access public |
|
324 | + * @return void |
|
325 | + */ |
|
326 | + public function header_meta_tag() |
|
327 | + { |
|
328 | + print( |
|
329 | + apply_filters( |
|
330 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
331 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
332 | + ) |
|
333 | + ); |
|
334 | + |
|
335 | + // let's exclude all event type taxonomy term archive pages from search engine indexing |
|
336 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
337 | + // also exclude all critical pages from indexing |
|
338 | + if (( |
|
339 | + is_tax('espresso_event_type') |
|
340 | + && get_option('blog_public') !== '0' |
|
341 | + ) |
|
342 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
343 | + ) { |
|
344 | + print( |
|
345 | + apply_filters( |
|
346 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
347 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
348 | + ) |
|
349 | + ); |
|
350 | + } |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * wp_print_scripts |
|
356 | + * |
|
357 | + * @return void |
|
358 | + */ |
|
359 | + public function wp_print_scripts() |
|
360 | + { |
|
361 | + global $post; |
|
362 | + if (isset($post->EE_Event) |
|
363 | + && $post->EE_Event instanceof EE_Event |
|
364 | + && get_post_type() === 'espresso_events' |
|
365 | + && is_singular() |
|
366 | + ) { |
|
367 | + \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + public function enqueueStyle() |
|
373 | + { |
|
374 | + wp_enqueue_style('espresso_default'); |
|
375 | + wp_enqueue_style('espresso_custom_css'); |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + |
|
380 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
381 | + |
|
382 | + |
|
383 | + public function enqueueScripts() |
|
384 | + { |
|
385 | + wp_enqueue_script('espresso_core'); |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * display_errors |
|
391 | + * |
|
392 | + * @access public |
|
393 | + * @return void |
|
394 | + * @throws DomainException |
|
395 | + */ |
|
396 | + public function display_errors() |
|
397 | + { |
|
398 | + static $shown_already = false; |
|
399 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
400 | + if (! $shown_already |
|
401 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
402 | + && is_main_query() |
|
403 | + && ! is_feed() |
|
404 | + && in_the_loop() |
|
405 | + && did_action('wp_head') |
|
406 | + && $this->Request_Handler->is_espresso_page() |
|
407 | + ) { |
|
408 | + echo EE_Error::get_notices(); |
|
409 | + $shown_already = true; |
|
410 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
411 | + } |
|
412 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + |
|
417 | + |
|
418 | + |
|
419 | + /*********************************************** UTILITIES ***********************************************/ |
|
420 | + /** |
|
421 | + * template_include |
|
422 | + * |
|
423 | + * @access public |
|
424 | + * @param string $template_include_path |
|
425 | + * @return string |
|
426 | + */ |
|
427 | + public function template_include($template_include_path = null) |
|
428 | + { |
|
429 | + if ($this->Request_Handler->is_espresso_page()) { |
|
430 | + $this->_template_path = ! empty($this->_template_path) |
|
431 | + ? basename($this->_template_path) |
|
432 | + : basename( |
|
433 | + $template_include_path |
|
434 | + ); |
|
435 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
436 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
437 | + $this->_template = basename($this->_template_path); |
|
438 | + return $this->_template_path; |
|
439 | + } |
|
440 | + return $template_include_path; |
|
441 | + } |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * get_selected_template |
|
446 | + * |
|
447 | + * @access public |
|
448 | + * @param bool $with_path |
|
449 | + * @return string |
|
450 | + */ |
|
451 | + public function get_selected_template($with_path = false) |
|
452 | + { |
|
453 | + return $with_path ? $this->_template_path : $this->_template; |
|
454 | + } |
|
455 | + |
|
456 | + |
|
457 | + /** |
|
458 | + * @deprecated 4.9.26 |
|
459 | + * @param string $shortcode_class |
|
460 | + * @param \WP $wp |
|
461 | + */ |
|
462 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
463 | + { |
|
464 | + \EE_Error::doing_it_wrong( |
|
465 | + __METHOD__, |
|
466 | + __( |
|
467 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
468 | + 'event_espresso' |
|
469 | + ), |
|
470 | + '4.9.26' |
|
471 | + ); |
|
472 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
473 | + } |
|
474 | + |
|
475 | + |
|
476 | + /** |
|
477 | + * @return void |
|
478 | + * @deprecated 4.9.57.p |
|
479 | + */ |
|
480 | + public function loadPersistentAdminNoticeManager() |
|
481 | + { |
|
482 | + } |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * @return void |
|
487 | + * @deprecated 4.9.64.p |
|
488 | + */ |
|
489 | + public function employ_CPT_Strategy() |
|
490 | + { |
|
491 | + } |
|
492 | 492 | } |