@@ -16,41 +16,41 @@ |
||
| 16 | 16 | class BlockAssetManagerCollection extends Collection |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Collection constructor |
|
| 21 | - * |
|
| 22 | - * @throws InvalidInterfaceException |
|
| 23 | - */ |
|
| 24 | - public function __construct() |
|
| 25 | - { |
|
| 26 | - parent::__construct('EventEspresso\core\services\assets\BlockAssetManager'); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @return void |
|
| 32 | - */ |
|
| 33 | - public function addAssets() |
|
| 34 | - { |
|
| 35 | - $this->rewind(); |
|
| 36 | - while ($this->valid()) { |
|
| 37 | - $this->current()->addAssets(); |
|
| 38 | - $this->next(); |
|
| 39 | - } |
|
| 40 | - $this->rewind(); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @return void |
|
| 46 | - */ |
|
| 47 | - public function enqueueAssets() |
|
| 48 | - { |
|
| 49 | - $this->rewind(); |
|
| 50 | - while ($this->valid()) { |
|
| 51 | - $this->current()->enqueueAssets(); |
|
| 52 | - $this->next(); |
|
| 53 | - } |
|
| 54 | - $this->rewind(); |
|
| 55 | - } |
|
| 19 | + /** |
|
| 20 | + * Collection constructor |
|
| 21 | + * |
|
| 22 | + * @throws InvalidInterfaceException |
|
| 23 | + */ |
|
| 24 | + public function __construct() |
|
| 25 | + { |
|
| 26 | + parent::__construct('EventEspresso\core\services\assets\BlockAssetManager'); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @return void |
|
| 32 | + */ |
|
| 33 | + public function addAssets() |
|
| 34 | + { |
|
| 35 | + $this->rewind(); |
|
| 36 | + while ($this->valid()) { |
|
| 37 | + $this->current()->addAssets(); |
|
| 38 | + $this->next(); |
|
| 39 | + } |
|
| 40 | + $this->rewind(); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @return void |
|
| 46 | + */ |
|
| 47 | + public function enqueueAssets() |
|
| 48 | + { |
|
| 49 | + $this->rewind(); |
|
| 50 | + while ($this->valid()) { |
|
| 51 | + $this->current()->enqueueAssets(); |
|
| 52 | + $this->next(); |
|
| 53 | + } |
|
| 54 | + $this->rewind(); |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } catch (EE_Error $e) { |
| 90 | 90 | $billing_info = null; |
| 91 | 91 | } |
| 92 | - if (! $billing_info instanceof EE_Form_Section_Proper) { |
|
| 92 | + if ( ! $billing_info instanceof EE_Form_Section_Proper) { |
|
| 93 | 93 | continue; |
| 94 | 94 | } |
| 95 | 95 | $found_something = true; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $export_items[] = array( |
| 110 | 110 | 'group_id' => 'billing_data', |
| 111 | 111 | 'group_label' => esc_html__('Billing Data', 'event_espresso'), |
| 112 | - 'item_id' => $attendee->ID() . '-' . $payment_method->ID(), |
|
| 112 | + 'item_id' => $attendee->ID().'-'.$payment_method->ID(), |
|
| 113 | 113 | 'data' => $data, |
| 114 | 114 | ); |
| 115 | 115 | } |
@@ -18,117 +18,117 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class ExportAttendeeBillingData implements PersonalDataExporterInterface |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * @var EEM_Attendee |
|
| 23 | - */ |
|
| 24 | - protected $attendee_model; |
|
| 21 | + /** |
|
| 22 | + * @var EEM_Attendee |
|
| 23 | + */ |
|
| 24 | + protected $attendee_model; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var EEM_Payment_Method |
|
| 28 | - */ |
|
| 29 | - protected $payment_method_model; |
|
| 26 | + /** |
|
| 27 | + * @var EEM_Payment_Method |
|
| 28 | + */ |
|
| 29 | + protected $payment_method_model; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * ExportAttendeeBillingData constructor. |
|
| 33 | - * |
|
| 34 | - * @param EEM_Attendee $attendee_model |
|
| 35 | - */ |
|
| 36 | - public function __construct(EEM_Attendee $attendee_model, EEM_Payment_Method $payment_method_model) |
|
| 37 | - { |
|
| 38 | - $this->attendee_model = $attendee_model; |
|
| 39 | - $this->payment_method_model = $payment_method_model; |
|
| 40 | - } |
|
| 31 | + /** |
|
| 32 | + * ExportAttendeeBillingData constructor. |
|
| 33 | + * |
|
| 34 | + * @param EEM_Attendee $attendee_model |
|
| 35 | + */ |
|
| 36 | + public function __construct(EEM_Attendee $attendee_model, EEM_Payment_Method $payment_method_model) |
|
| 37 | + { |
|
| 38 | + $this->attendee_model = $attendee_model; |
|
| 39 | + $this->payment_method_model = $payment_method_model; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Returns data for export. |
|
| 44 | - * |
|
| 45 | - * @param string $email_address , |
|
| 46 | - * @param int $page starts at 1, not 0 |
|
| 47 | - * @return array { |
|
| 48 | - * @type array $data { |
|
| 49 | - * @type array { |
|
| 50 | - * @type string $group_id (not translated, same for all exports) |
|
| 51 | - * @type string $group_label (translated string) |
|
| 52 | - * @type string|int $item_id |
|
| 53 | - * @type array $data { |
|
| 54 | - * @type array { |
|
| 55 | - * @type string $name what's shown in the left-column of the export row |
|
| 56 | - * @type string $value what's showin the right-column of the export row |
|
| 57 | - * } |
|
| 58 | - * } |
|
| 59 | - * } |
|
| 60 | - * } |
|
| 61 | - * } |
|
| 62 | - */ |
|
| 63 | - public function export($email_address, $page = 1) |
|
| 64 | - { |
|
| 65 | - $page_size = 10; |
|
| 66 | - $attendees = $this->attendee_model->get_all( |
|
| 67 | - array( |
|
| 68 | - array( |
|
| 69 | - 'ATT_email' => $email_address, |
|
| 70 | - ), |
|
| 71 | - 'limit' => array( |
|
| 72 | - ($page - 1) * $page_size, |
|
| 73 | - $page_size, |
|
| 74 | - ), |
|
| 75 | - ) |
|
| 76 | - ); |
|
| 77 | - // get all payment methods, even inactive ones |
|
| 78 | - $payment_methods = $this->payment_method_model->get_all( |
|
| 79 | - array( |
|
| 80 | - 'group_by' => array('PMD_type'), |
|
| 81 | - ) |
|
| 82 | - ); |
|
| 83 | - $export_items = array(); |
|
| 84 | - $found_something = false; |
|
| 85 | - foreach ($attendees as $attendee) { |
|
| 86 | - foreach ($payment_methods as $payment_method) { |
|
| 87 | - try { |
|
| 88 | - $billing_info = $attendee->billing_info_for_payment_method($payment_method); |
|
| 89 | - } catch (EE_Error $e) { |
|
| 90 | - $billing_info = null; |
|
| 91 | - } |
|
| 92 | - if (! $billing_info instanceof EE_Form_Section_Proper) { |
|
| 93 | - continue; |
|
| 94 | - } |
|
| 95 | - $found_something = true; |
|
| 96 | - $data = array(); |
|
| 97 | - foreach ($billing_info->input_pretty_values(true, true) as $input_name => $display_value) { |
|
| 98 | - try { |
|
| 99 | - $input = $billing_info->get_input($input_name); |
|
| 100 | - $input_display_name = $input->html_label_text(); |
|
| 101 | - } catch (EE_Error $e) { |
|
| 102 | - $input_display_name = $input_name; |
|
| 103 | - } |
|
| 104 | - $data[] = array( |
|
| 105 | - 'name' => strip_tags((string) $input_display_name), |
|
| 106 | - 'value' => $display_value, |
|
| 107 | - ); |
|
| 108 | - } |
|
| 109 | - $export_items[] = array( |
|
| 110 | - 'group_id' => 'billing_data', |
|
| 111 | - 'group_label' => esc_html__('Billing Data', 'event_espresso'), |
|
| 112 | - 'item_id' => $attendee->ID() . '-' . $payment_method->ID(), |
|
| 113 | - 'data' => $data, |
|
| 114 | - ); |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - return array( |
|
| 118 | - 'data' => $export_items, |
|
| 119 | - 'done' => ! $found_something, |
|
| 120 | - ); |
|
| 121 | - } |
|
| 42 | + /** |
|
| 43 | + * Returns data for export. |
|
| 44 | + * |
|
| 45 | + * @param string $email_address , |
|
| 46 | + * @param int $page starts at 1, not 0 |
|
| 47 | + * @return array { |
|
| 48 | + * @type array $data { |
|
| 49 | + * @type array { |
|
| 50 | + * @type string $group_id (not translated, same for all exports) |
|
| 51 | + * @type string $group_label (translated string) |
|
| 52 | + * @type string|int $item_id |
|
| 53 | + * @type array $data { |
|
| 54 | + * @type array { |
|
| 55 | + * @type string $name what's shown in the left-column of the export row |
|
| 56 | + * @type string $value what's showin the right-column of the export row |
|
| 57 | + * } |
|
| 58 | + * } |
|
| 59 | + * } |
|
| 60 | + * } |
|
| 61 | + * } |
|
| 62 | + */ |
|
| 63 | + public function export($email_address, $page = 1) |
|
| 64 | + { |
|
| 65 | + $page_size = 10; |
|
| 66 | + $attendees = $this->attendee_model->get_all( |
|
| 67 | + array( |
|
| 68 | + array( |
|
| 69 | + 'ATT_email' => $email_address, |
|
| 70 | + ), |
|
| 71 | + 'limit' => array( |
|
| 72 | + ($page - 1) * $page_size, |
|
| 73 | + $page_size, |
|
| 74 | + ), |
|
| 75 | + ) |
|
| 76 | + ); |
|
| 77 | + // get all payment methods, even inactive ones |
|
| 78 | + $payment_methods = $this->payment_method_model->get_all( |
|
| 79 | + array( |
|
| 80 | + 'group_by' => array('PMD_type'), |
|
| 81 | + ) |
|
| 82 | + ); |
|
| 83 | + $export_items = array(); |
|
| 84 | + $found_something = false; |
|
| 85 | + foreach ($attendees as $attendee) { |
|
| 86 | + foreach ($payment_methods as $payment_method) { |
|
| 87 | + try { |
|
| 88 | + $billing_info = $attendee->billing_info_for_payment_method($payment_method); |
|
| 89 | + } catch (EE_Error $e) { |
|
| 90 | + $billing_info = null; |
|
| 91 | + } |
|
| 92 | + if (! $billing_info instanceof EE_Form_Section_Proper) { |
|
| 93 | + continue; |
|
| 94 | + } |
|
| 95 | + $found_something = true; |
|
| 96 | + $data = array(); |
|
| 97 | + foreach ($billing_info->input_pretty_values(true, true) as $input_name => $display_value) { |
|
| 98 | + try { |
|
| 99 | + $input = $billing_info->get_input($input_name); |
|
| 100 | + $input_display_name = $input->html_label_text(); |
|
| 101 | + } catch (EE_Error $e) { |
|
| 102 | + $input_display_name = $input_name; |
|
| 103 | + } |
|
| 104 | + $data[] = array( |
|
| 105 | + 'name' => strip_tags((string) $input_display_name), |
|
| 106 | + 'value' => $display_value, |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | + $export_items[] = array( |
|
| 110 | + 'group_id' => 'billing_data', |
|
| 111 | + 'group_label' => esc_html__('Billing Data', 'event_espresso'), |
|
| 112 | + 'item_id' => $attendee->ID() . '-' . $payment_method->ID(), |
|
| 113 | + 'data' => $data, |
|
| 114 | + ); |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + return array( |
|
| 118 | + 'data' => $export_items, |
|
| 119 | + 'done' => ! $found_something, |
|
| 120 | + ); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Gets the Translated name of this exporter |
|
| 125 | - * |
|
| 126 | - * @return string |
|
| 127 | - */ |
|
| 128 | - public function name() |
|
| 129 | - { |
|
| 130 | - return esc_html__('Event Espresso Attendee Billing Data Exporter', 'event_espresso'); |
|
| 131 | - } |
|
| 123 | + /** |
|
| 124 | + * Gets the Translated name of this exporter |
|
| 125 | + * |
|
| 126 | + * @return string |
|
| 127 | + */ |
|
| 128 | + public function name() |
|
| 129 | + { |
|
| 130 | + return esc_html__('Event Espresso Attendee Billing Data Exporter', 'event_espresso'); |
|
| 131 | + } |
|
| 132 | 132 | } |
| 133 | 133 | // End of file ExportAttendeeBillingData.php |
| 134 | 134 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportAttendeeBillingData.php |
@@ -16,88 +16,88 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class EraseAnswers implements PersonalDataEraserInterface |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @var EEM_Answer |
|
| 21 | - */ |
|
| 22 | - protected $answer_model; |
|
| 19 | + /** |
|
| 20 | + * @var EEM_Answer |
|
| 21 | + */ |
|
| 22 | + protected $answer_model; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var EEM_Question |
|
| 26 | - */ |
|
| 27 | - protected $question_model; |
|
| 24 | + /** |
|
| 25 | + * @var EEM_Question |
|
| 26 | + */ |
|
| 27 | + protected $question_model; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * EraseAnswers constructor. |
|
| 31 | - * |
|
| 32 | - * @param EEM_Answer $answer_model |
|
| 33 | - * @param EEM_Question $question_model |
|
| 34 | - */ |
|
| 35 | - public function __construct(EEM_Answer $answer_model, EEM_Question $question_model) |
|
| 36 | - { |
|
| 37 | - $this->answer_model = $answer_model; |
|
| 38 | - $this->question_model = $question_model; |
|
| 39 | - } |
|
| 29 | + /** |
|
| 30 | + * EraseAnswers constructor. |
|
| 31 | + * |
|
| 32 | + * @param EEM_Answer $answer_model |
|
| 33 | + * @param EEM_Question $question_model |
|
| 34 | + */ |
|
| 35 | + public function __construct(EEM_Answer $answer_model, EEM_Question $question_model) |
|
| 36 | + { |
|
| 37 | + $this->answer_model = $answer_model; |
|
| 38 | + $this->question_model = $question_model; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Gets a translated string name for the data eraser |
|
| 44 | - * |
|
| 45 | - * @return string |
|
| 46 | - */ |
|
| 47 | - public function name() |
|
| 48 | - { |
|
| 49 | - return esc_html__('Event Espresso Registration Answers', 'event_espresso'); |
|
| 50 | - } |
|
| 42 | + /** |
|
| 43 | + * Gets a translated string name for the data eraser |
|
| 44 | + * |
|
| 45 | + * @return string |
|
| 46 | + */ |
|
| 47 | + public function name() |
|
| 48 | + { |
|
| 49 | + return esc_html__('Event Espresso Registration Answers', 'event_espresso'); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Erases a "page" of personal user data |
|
| 54 | - * |
|
| 55 | - * @return array { |
|
| 56 | - * @type boolean $items_removed whether items were removed successfully or not |
|
| 57 | - * @type boolean $items_retained whether any items were skipped or not |
|
| 58 | - * @type array $messages values are messages to show |
|
| 59 | - * @type boolean $done whether this eraser is done or has more pages |
|
| 60 | - * } |
|
| 61 | - */ |
|
| 62 | - public function erase($email_address, $page = 1) |
|
| 63 | - { |
|
| 64 | - $multi_answer_enum_question_types = $this->question_model->question_types_in_category('multi-answer-enum'); |
|
| 65 | - $normal_questions_updated = $this->answer_model->update( |
|
| 66 | - array( |
|
| 67 | - 'ANS_value' => '', |
|
| 68 | - ), |
|
| 69 | - array( |
|
| 70 | - array( |
|
| 71 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
| 72 | - 'Question.QST_type' => array( |
|
| 73 | - 'NOT_IN', |
|
| 74 | - $multi_answer_enum_question_types, |
|
| 75 | - ), |
|
| 76 | - ), |
|
| 77 | - ) |
|
| 78 | - ); |
|
| 79 | - $multi_value_questions_updated = $this->answer_model->update( |
|
| 80 | - array( |
|
| 81 | - 'ANS_value' => array(), |
|
| 82 | - ), |
|
| 83 | - array( |
|
| 84 | - array( |
|
| 85 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
| 86 | - 'Question.QST_type' => array( |
|
| 87 | - 'IN', |
|
| 88 | - $multi_answer_enum_question_types, |
|
| 89 | - ), |
|
| 90 | - ), |
|
| 91 | - ) |
|
| 92 | - ); |
|
| 52 | + /** |
|
| 53 | + * Erases a "page" of personal user data |
|
| 54 | + * |
|
| 55 | + * @return array { |
|
| 56 | + * @type boolean $items_removed whether items were removed successfully or not |
|
| 57 | + * @type boolean $items_retained whether any items were skipped or not |
|
| 58 | + * @type array $messages values are messages to show |
|
| 59 | + * @type boolean $done whether this eraser is done or has more pages |
|
| 60 | + * } |
|
| 61 | + */ |
|
| 62 | + public function erase($email_address, $page = 1) |
|
| 63 | + { |
|
| 64 | + $multi_answer_enum_question_types = $this->question_model->question_types_in_category('multi-answer-enum'); |
|
| 65 | + $normal_questions_updated = $this->answer_model->update( |
|
| 66 | + array( |
|
| 67 | + 'ANS_value' => '', |
|
| 68 | + ), |
|
| 69 | + array( |
|
| 70 | + array( |
|
| 71 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
| 72 | + 'Question.QST_type' => array( |
|
| 73 | + 'NOT_IN', |
|
| 74 | + $multi_answer_enum_question_types, |
|
| 75 | + ), |
|
| 76 | + ), |
|
| 77 | + ) |
|
| 78 | + ); |
|
| 79 | + $multi_value_questions_updated = $this->answer_model->update( |
|
| 80 | + array( |
|
| 81 | + 'ANS_value' => array(), |
|
| 82 | + ), |
|
| 83 | + array( |
|
| 84 | + array( |
|
| 85 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
| 86 | + 'Question.QST_type' => array( |
|
| 87 | + 'IN', |
|
| 88 | + $multi_answer_enum_question_types, |
|
| 89 | + ), |
|
| 90 | + ), |
|
| 91 | + ) |
|
| 92 | + ); |
|
| 93 | 93 | |
| 94 | - return array( |
|
| 95 | - 'items_removed' => (bool) $normal_questions_updated || (bool) $multi_value_questions_updated, |
|
| 96 | - 'items_retained' => false, // always false in this example |
|
| 97 | - 'messages' => array(), // no messages in this example |
|
| 98 | - 'done' => true, |
|
| 99 | - ); |
|
| 100 | - } |
|
| 94 | + return array( |
|
| 95 | + 'items_removed' => (bool) $normal_questions_updated || (bool) $multi_value_questions_updated, |
|
| 96 | + 'items_retained' => false, // always false in this example |
|
| 97 | + 'messages' => array(), // no messages in this example |
|
| 98 | + 'done' => true, |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | 101 | } |
| 102 | 102 | // End of file EraseAnswers.php |
| 103 | 103 | // Location: EventEspresso\core\domain\services\privacy\erasure/EraseAnswers.php |
@@ -14,35 +14,35 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | interface PersonalDataExporterInterface |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Gets the Translated name of this exporter |
|
| 19 | - * |
|
| 20 | - * @return string |
|
| 21 | - */ |
|
| 22 | - public function name(); |
|
| 17 | + /** |
|
| 18 | + * Gets the Translated name of this exporter |
|
| 19 | + * |
|
| 20 | + * @return string |
|
| 21 | + */ |
|
| 22 | + public function name(); |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Returns data for export. |
|
| 26 | - * |
|
| 27 | - * @param string $email_address , |
|
| 28 | - * @param int $page starts at 1, not 0 |
|
| 29 | - * @return array { |
|
| 30 | - * @type array $data { |
|
| 31 | - * @type array { |
|
| 32 | - * @type string $group_id (not translated, same for all exports) |
|
| 33 | - * @type string $group_label (translated string) |
|
| 34 | - * @type string|int $item_id |
|
| 35 | - * @type array $data { |
|
| 36 | - * @type array { |
|
| 37 | - * @type string $name what's shown in the left-column of the export row |
|
| 38 | - * @type string $value what's showin the right-column of the export row |
|
| 39 | - * } |
|
| 40 | - * } |
|
| 41 | - * } |
|
| 42 | - * } |
|
| 43 | - * } |
|
| 44 | - */ |
|
| 45 | - public function export($email_address, $page = 1); |
|
| 24 | + /** |
|
| 25 | + * Returns data for export. |
|
| 26 | + * |
|
| 27 | + * @param string $email_address , |
|
| 28 | + * @param int $page starts at 1, not 0 |
|
| 29 | + * @return array { |
|
| 30 | + * @type array $data { |
|
| 31 | + * @type array { |
|
| 32 | + * @type string $group_id (not translated, same for all exports) |
|
| 33 | + * @type string $group_label (translated string) |
|
| 34 | + * @type string|int $item_id |
|
| 35 | + * @type array $data { |
|
| 36 | + * @type array { |
|
| 37 | + * @type string $name what's shown in the left-column of the export row |
|
| 38 | + * @type string $value what's showin the right-column of the export row |
|
| 39 | + * } |
|
| 40 | + * } |
|
| 41 | + * } |
|
| 42 | + * } |
|
| 43 | + * } |
|
| 44 | + */ |
|
| 45 | + public function export($email_address, $page = 1); |
|
| 46 | 46 | } |
| 47 | 47 | // End of file PersonalDataExporterInterface.php |
| 48 | 48 | // Location: EventEspresso\core\domain\services\admin/PersonalDataExporterInterface.php |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | // load all the privacy policy stuff |
| 44 | 44 | // add post policy text |
| 45 | 45 | foreach ($this->loadPrivateDataExporterCollection() as $exporter) { |
| 46 | - $exporters[ get_class($exporter) ] = array( |
|
| 46 | + $exporters[get_class($exporter)] = array( |
|
| 47 | 47 | 'exporter_friendly_name' => $exporter->name(), |
| 48 | 48 | 'callback' => array($exporter, 'export'), |
| 49 | 49 | ); |
@@ -22,68 +22,68 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class PersonalDataExporterManager |
| 24 | 24 | { |
| 25 | - public function __construct() |
|
| 26 | - { |
|
| 27 | - add_filter( |
|
| 28 | - 'wp_privacy_personal_data_exporters', |
|
| 29 | - array($this, 'hookInExporters') |
|
| 30 | - ); |
|
| 31 | - } |
|
| 25 | + public function __construct() |
|
| 26 | + { |
|
| 27 | + add_filter( |
|
| 28 | + 'wp_privacy_personal_data_exporters', |
|
| 29 | + array($this, 'hookInExporters') |
|
| 30 | + ); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Adds EE's exporters to the list of WP exporters |
|
| 36 | - * |
|
| 37 | - * @param array $exporters |
|
| 38 | - * @return array |
|
| 39 | - */ |
|
| 40 | - public function hookInExporters($exporters) |
|
| 41 | - { |
|
| 42 | - // load all the privacy policy stuff |
|
| 43 | - // add post policy text |
|
| 44 | - foreach ($this->loadPrivateDataExporterCollection() as $exporter) { |
|
| 45 | - $exporters[ get_class($exporter) ] = array( |
|
| 46 | - 'exporter_friendly_name' => $exporter->name(), |
|
| 47 | - 'callback' => array($exporter, 'export'), |
|
| 48 | - ); |
|
| 49 | - } |
|
| 50 | - return $exporters; |
|
| 51 | - } |
|
| 34 | + /** |
|
| 35 | + * Adds EE's exporters to the list of WP exporters |
|
| 36 | + * |
|
| 37 | + * @param array $exporters |
|
| 38 | + * @return array |
|
| 39 | + */ |
|
| 40 | + public function hookInExporters($exporters) |
|
| 41 | + { |
|
| 42 | + // load all the privacy policy stuff |
|
| 43 | + // add post policy text |
|
| 44 | + foreach ($this->loadPrivateDataExporterCollection() as $exporter) { |
|
| 45 | + $exporters[ get_class($exporter) ] = array( |
|
| 46 | + 'exporter_friendly_name' => $exporter->name(), |
|
| 47 | + 'callback' => array($exporter, 'export'), |
|
| 48 | + ); |
|
| 49 | + } |
|
| 50 | + return $exporters; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @return CollectionInterface|PersonalDataExporterInterface[] |
|
| 56 | - * @throws InvalidIdentifierException |
|
| 57 | - * @throws InvalidInterfaceException |
|
| 58 | - * @throws InvalidFilePathException |
|
| 59 | - * @throws InvalidEntityException |
|
| 60 | - * @throws InvalidDataTypeException |
|
| 61 | - * @throws InvalidClassException |
|
| 62 | - */ |
|
| 63 | - protected function loadPrivateDataExporterCollection() |
|
| 64 | - { |
|
| 65 | - $loader = new CollectionLoader( |
|
| 66 | - new CollectionDetails( |
|
| 67 | - // collection name |
|
| 68 | - 'personal_data_exporters', |
|
| 69 | - // collection interface |
|
| 70 | - 'EventEspresso\core\services\privacy\export\PersonalDataExporterInterface', |
|
| 71 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
| 72 | - apply_filters( |
|
| 73 | - 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
|
| 74 | - array('EventEspresso\core\domain\services\admin\privacy\export') |
|
| 75 | - ), |
|
| 76 | - // filepaths to classes to add |
|
| 77 | - array(), |
|
| 78 | - // file mask to use if parsing folder for files to add |
|
| 79 | - '', |
|
| 80 | - // what to use as identifier for collection entities |
|
| 81 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 82 | - CollectionDetails::ID_CLASS_NAME |
|
| 83 | - ) |
|
| 84 | - ); |
|
| 85 | - return $loader->getCollection(); |
|
| 86 | - } |
|
| 54 | + /** |
|
| 55 | + * @return CollectionInterface|PersonalDataExporterInterface[] |
|
| 56 | + * @throws InvalidIdentifierException |
|
| 57 | + * @throws InvalidInterfaceException |
|
| 58 | + * @throws InvalidFilePathException |
|
| 59 | + * @throws InvalidEntityException |
|
| 60 | + * @throws InvalidDataTypeException |
|
| 61 | + * @throws InvalidClassException |
|
| 62 | + */ |
|
| 63 | + protected function loadPrivateDataExporterCollection() |
|
| 64 | + { |
|
| 65 | + $loader = new CollectionLoader( |
|
| 66 | + new CollectionDetails( |
|
| 67 | + // collection name |
|
| 68 | + 'personal_data_exporters', |
|
| 69 | + // collection interface |
|
| 70 | + 'EventEspresso\core\services\privacy\export\PersonalDataExporterInterface', |
|
| 71 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
| 72 | + apply_filters( |
|
| 73 | + 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
|
| 74 | + array('EventEspresso\core\domain\services\admin\privacy\export') |
|
| 75 | + ), |
|
| 76 | + // filepaths to classes to add |
|
| 77 | + array(), |
|
| 78 | + // file mask to use if parsing folder for files to add |
|
| 79 | + '', |
|
| 80 | + // what to use as identifier for collection entities |
|
| 81 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 82 | + CollectionDetails::ID_CLASS_NAME |
|
| 83 | + ) |
|
| 84 | + ); |
|
| 85 | + return $loader->getCollection(); |
|
| 86 | + } |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // End of file PersonalDataExporterManager.php |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | // load all the privacy policy stuff |
| 41 | 41 | // add post policy text |
| 42 | 42 | foreach ($this->loadPrivateDataEraserCollection() as $eraser) { |
| 43 | - $erasers[ get_class($eraser) ] = array( |
|
| 43 | + $erasers[get_class($eraser)] = array( |
|
| 44 | 44 | 'eraser_friendly_name' => $eraser->name(), |
| 45 | 45 | 'callback' => array($eraser, 'erase'), |
| 46 | 46 | ); |
@@ -22,65 +22,65 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class PersonalDataEraserManager |
| 24 | 24 | { |
| 25 | - public function __construct() |
|
| 26 | - { |
|
| 27 | - add_filter( |
|
| 28 | - 'wp_privacy_personal_data_erasers', |
|
| 29 | - array($this, 'hookInErasers') |
|
| 30 | - ); |
|
| 31 | - } |
|
| 25 | + public function __construct() |
|
| 26 | + { |
|
| 27 | + add_filter( |
|
| 28 | + 'wp_privacy_personal_data_erasers', |
|
| 29 | + array($this, 'hookInErasers') |
|
| 30 | + ); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * For all the registered `PrivateDataEraserInterface`s, add them as erasers |
|
| 36 | - */ |
|
| 37 | - public function hookInErasers($erasers) |
|
| 38 | - { |
|
| 39 | - // load all the privacy policy stuff |
|
| 40 | - // add post policy text |
|
| 41 | - foreach ($this->loadPrivateDataEraserCollection() as $eraser) { |
|
| 42 | - $erasers[ get_class($eraser) ] = array( |
|
| 43 | - 'eraser_friendly_name' => $eraser->name(), |
|
| 44 | - 'callback' => array($eraser, 'erase'), |
|
| 45 | - ); |
|
| 46 | - } |
|
| 47 | - return $erasers; |
|
| 48 | - } |
|
| 34 | + /** |
|
| 35 | + * For all the registered `PrivateDataEraserInterface`s, add them as erasers |
|
| 36 | + */ |
|
| 37 | + public function hookInErasers($erasers) |
|
| 38 | + { |
|
| 39 | + // load all the privacy policy stuff |
|
| 40 | + // add post policy text |
|
| 41 | + foreach ($this->loadPrivateDataEraserCollection() as $eraser) { |
|
| 42 | + $erasers[ get_class($eraser) ] = array( |
|
| 43 | + 'eraser_friendly_name' => $eraser->name(), |
|
| 44 | + 'callback' => array($eraser, 'erase'), |
|
| 45 | + ); |
|
| 46 | + } |
|
| 47 | + return $erasers; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return CollectionInterface|PersonalDataEraserInterface[] |
|
| 53 | - * @throws InvalidIdentifierException |
|
| 54 | - * @throws InvalidInterfaceException |
|
| 55 | - * @throws InvalidFilePathException |
|
| 56 | - * @throws InvalidEntityException |
|
| 57 | - * @throws InvalidDataTypeException |
|
| 58 | - * @throws InvalidClassException |
|
| 59 | - */ |
|
| 60 | - protected function loadPrivateDataEraserCollection() |
|
| 61 | - { |
|
| 62 | - $loader = new CollectionLoader( |
|
| 63 | - new CollectionDetails( |
|
| 64 | - // collection name |
|
| 65 | - 'privacy_erasers', |
|
| 66 | - // collection interface |
|
| 67 | - 'EventEspresso\core\services\privacy\erasure\PersonalDataEraserInterface', |
|
| 68 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
| 69 | - apply_filters( |
|
| 70 | - 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
|
| 71 | - array('EventEspresso\core\domain\services\admin\privacy\erasure') |
|
| 72 | - ), |
|
| 73 | - // filepaths to classes to add |
|
| 74 | - array(), |
|
| 75 | - // file mask to use if parsing folder for files to add |
|
| 76 | - '', |
|
| 77 | - // what to use as identifier for collection entities |
|
| 78 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 79 | - CollectionDetails::ID_CLASS_NAME |
|
| 80 | - ) |
|
| 81 | - ); |
|
| 82 | - return $loader->getCollection(); |
|
| 83 | - } |
|
| 51 | + /** |
|
| 52 | + * @return CollectionInterface|PersonalDataEraserInterface[] |
|
| 53 | + * @throws InvalidIdentifierException |
|
| 54 | + * @throws InvalidInterfaceException |
|
| 55 | + * @throws InvalidFilePathException |
|
| 56 | + * @throws InvalidEntityException |
|
| 57 | + * @throws InvalidDataTypeException |
|
| 58 | + * @throws InvalidClassException |
|
| 59 | + */ |
|
| 60 | + protected function loadPrivateDataEraserCollection() |
|
| 61 | + { |
|
| 62 | + $loader = new CollectionLoader( |
|
| 63 | + new CollectionDetails( |
|
| 64 | + // collection name |
|
| 65 | + 'privacy_erasers', |
|
| 66 | + // collection interface |
|
| 67 | + 'EventEspresso\core\services\privacy\erasure\PersonalDataEraserInterface', |
|
| 68 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
| 69 | + apply_filters( |
|
| 70 | + 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
|
| 71 | + array('EventEspresso\core\domain\services\admin\privacy\erasure') |
|
| 72 | + ), |
|
| 73 | + // filepaths to classes to add |
|
| 74 | + array(), |
|
| 75 | + // file mask to use if parsing folder for files to add |
|
| 76 | + '', |
|
| 77 | + // what to use as identifier for collection entities |
|
| 78 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 79 | + CollectionDetails::ID_CLASS_NAME |
|
| 80 | + ) |
|
| 81 | + ); |
|
| 82 | + return $loader->getCollection(); |
|
| 83 | + } |
|
| 84 | 84 | } |
| 85 | 85 | // End of file PersonalDataEraserManager.php |
| 86 | 86 | // Location: EventEspresso\core\domain\services\admin/PersonalDataEraserManager.php |
@@ -32,18 +32,18 @@ discard block |
||
| 32 | 32 | $this->request = $request; |
| 33 | 33 | $this->response = $response; |
| 34 | 34 | // check required WP version |
| 35 | - if (! $this->minimumWordPressVersionRequired()) { |
|
| 35 | + if ( ! $this->minimumWordPressVersionRequired()) { |
|
| 36 | 36 | $this->request->unSetRequestParam('activate', true); |
| 37 | 37 | add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
| 38 | 38 | $this->response->terminateRequest(); |
| 39 | 39 | $this->response->deactivatePlugin(); |
| 40 | 40 | } |
| 41 | 41 | // check recommended PHP version |
| 42 | - if (! $this->minimumPhpVersionRecommended()) { |
|
| 42 | + if ( ! $this->minimumPhpVersionRecommended()) { |
|
| 43 | 43 | $this->displayMinimumRecommendedPhpVersionNotice(); |
| 44 | 44 | } |
| 45 | 45 | // upcoming required version |
| 46 | - if (! $this->upcomingRequiredPhpVersion()) { |
|
| 46 | + if ( ! $this->upcomingRequiredPhpVersion()) { |
|
| 47 | 47 | $this->displayUpcomingRequiredVersion(); |
| 48 | 48 | } |
| 49 | 49 | $this->response = $this->processRequestStack($this->request, $this->response); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | if ($this->request->isAdmin()) { |
| 144 | 144 | new PersistentAdminNotice( |
| 145 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
| 145 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
| 146 | 146 | sprintf( |
| 147 | 147 | esc_html__( |
| 148 | 148 | 'Event Espresso recommends PHP version %1$s or greater for optimal performance. 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.', |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
| 181 | 181 | && current_user_can('update_plugins') |
| 182 | 182 | ) { |
| 183 | - add_action('admin_notices', function () { |
|
| 183 | + add_action('admin_notices', function() { |
|
| 184 | 184 | echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
| 185 | 185 | . sprintf( |
| 186 | 186 | esc_html__( |
@@ -18,183 +18,183 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class RecommendedVersions extends Middleware |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * converts a Request to a Response |
|
| 23 | - * |
|
| 24 | - * @param RequestInterface $request |
|
| 25 | - * @param ResponseInterface $response |
|
| 26 | - * @return ResponseInterface |
|
| 27 | - * @throws InvalidDataTypeException |
|
| 28 | - */ |
|
| 29 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
| 30 | - { |
|
| 31 | - $this->request = $request; |
|
| 32 | - $this->response = $response; |
|
| 33 | - // check required WP version |
|
| 34 | - if (! $this->minimumWordPressVersionRequired()) { |
|
| 35 | - $this->request->unSetRequestParam('activate', true); |
|
| 36 | - add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
|
| 37 | - $this->response->terminateRequest(); |
|
| 38 | - $this->response->deactivatePlugin(); |
|
| 39 | - } |
|
| 40 | - // check recommended PHP version |
|
| 41 | - if (! $this->minimumPhpVersionRecommended()) { |
|
| 42 | - $this->displayMinimumRecommendedPhpVersionNotice(); |
|
| 43 | - } |
|
| 44 | - // upcoming required version |
|
| 45 | - if (! $this->upcomingRequiredPhpVersion()) { |
|
| 46 | - $this->displayUpcomingRequiredVersion(); |
|
| 47 | - } |
|
| 48 | - $this->response = $this->processRequestStack($this->request, $this->response); |
|
| 49 | - return $this->response; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Helper method to assess installed wp version against given values. |
|
| 55 | - * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
| 56 | - * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
| 57 | - * against) so consider that when sending in your values. |
|
| 58 | - * |
|
| 59 | - * @param string $version_to_check |
|
| 60 | - * @param string $operator |
|
| 61 | - * @return bool |
|
| 62 | - */ |
|
| 63 | - public static function compareWordPressVersion($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
| 64 | - { |
|
| 65 | - global $wp_version; |
|
| 66 | - return version_compare( |
|
| 67 | - // first account for wp_version being pre-release |
|
| 68 | - // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
| 69 | - strpos($wp_version, '-') > 0 |
|
| 70 | - ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
| 71 | - : $wp_version, |
|
| 72 | - $version_to_check, |
|
| 73 | - $operator |
|
| 74 | - ); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @return boolean |
|
| 80 | - */ |
|
| 81 | - private function minimumWordPressVersionRequired() |
|
| 82 | - { |
|
| 83 | - return RecommendedVersions::compareWordPressVersion(); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @param string $min_version |
|
| 89 | - * @return boolean |
|
| 90 | - */ |
|
| 91 | - private function checkPhpVersion($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
| 92 | - { |
|
| 93 | - return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @return boolean |
|
| 99 | - */ |
|
| 100 | - private function minimumPhpVersionRecommended() |
|
| 101 | - { |
|
| 102 | - return $this->checkPhpVersion(); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * @return void |
|
| 108 | - */ |
|
| 109 | - public function minimumWpVersionError() |
|
| 110 | - { |
|
| 111 | - global $wp_version; |
|
| 112 | - ?> |
|
| 21 | + /** |
|
| 22 | + * converts a Request to a Response |
|
| 23 | + * |
|
| 24 | + * @param RequestInterface $request |
|
| 25 | + * @param ResponseInterface $response |
|
| 26 | + * @return ResponseInterface |
|
| 27 | + * @throws InvalidDataTypeException |
|
| 28 | + */ |
|
| 29 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
| 30 | + { |
|
| 31 | + $this->request = $request; |
|
| 32 | + $this->response = $response; |
|
| 33 | + // check required WP version |
|
| 34 | + if (! $this->minimumWordPressVersionRequired()) { |
|
| 35 | + $this->request->unSetRequestParam('activate', true); |
|
| 36 | + add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
|
| 37 | + $this->response->terminateRequest(); |
|
| 38 | + $this->response->deactivatePlugin(); |
|
| 39 | + } |
|
| 40 | + // check recommended PHP version |
|
| 41 | + if (! $this->minimumPhpVersionRecommended()) { |
|
| 42 | + $this->displayMinimumRecommendedPhpVersionNotice(); |
|
| 43 | + } |
|
| 44 | + // upcoming required version |
|
| 45 | + if (! $this->upcomingRequiredPhpVersion()) { |
|
| 46 | + $this->displayUpcomingRequiredVersion(); |
|
| 47 | + } |
|
| 48 | + $this->response = $this->processRequestStack($this->request, $this->response); |
|
| 49 | + return $this->response; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Helper method to assess installed wp version against given values. |
|
| 55 | + * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
| 56 | + * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
| 57 | + * against) so consider that when sending in your values. |
|
| 58 | + * |
|
| 59 | + * @param string $version_to_check |
|
| 60 | + * @param string $operator |
|
| 61 | + * @return bool |
|
| 62 | + */ |
|
| 63 | + public static function compareWordPressVersion($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
| 64 | + { |
|
| 65 | + global $wp_version; |
|
| 66 | + return version_compare( |
|
| 67 | + // first account for wp_version being pre-release |
|
| 68 | + // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
| 69 | + strpos($wp_version, '-') > 0 |
|
| 70 | + ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
| 71 | + : $wp_version, |
|
| 72 | + $version_to_check, |
|
| 73 | + $operator |
|
| 74 | + ); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @return boolean |
|
| 80 | + */ |
|
| 81 | + private function minimumWordPressVersionRequired() |
|
| 82 | + { |
|
| 83 | + return RecommendedVersions::compareWordPressVersion(); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @param string $min_version |
|
| 89 | + * @return boolean |
|
| 90 | + */ |
|
| 91 | + private function checkPhpVersion($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
| 92 | + { |
|
| 93 | + return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @return boolean |
|
| 99 | + */ |
|
| 100 | + private function minimumPhpVersionRecommended() |
|
| 101 | + { |
|
| 102 | + return $this->checkPhpVersion(); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * @return void |
|
| 108 | + */ |
|
| 109 | + public function minimumWpVersionError() |
|
| 110 | + { |
|
| 111 | + global $wp_version; |
|
| 112 | + ?> |
|
| 113 | 113 | <div class="error"> |
| 114 | 114 | <p> |
| 115 | 115 | <?php |
| 116 | - printf( |
|
| 117 | - esc_html__( |
|
| 118 | - 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
| 119 | - 'event_espresso' |
|
| 120 | - ), |
|
| 121 | - EE_MIN_WP_VER_REQUIRED, |
|
| 122 | - $wp_version, |
|
| 123 | - '<br/>', |
|
| 124 | - '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
| 125 | - ); |
|
| 126 | - ?> |
|
| 116 | + printf( |
|
| 117 | + esc_html__( |
|
| 118 | + 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
| 119 | + 'event_espresso' |
|
| 120 | + ), |
|
| 121 | + EE_MIN_WP_VER_REQUIRED, |
|
| 122 | + $wp_version, |
|
| 123 | + '<br/>', |
|
| 124 | + '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
| 125 | + ); |
|
| 126 | + ?> |
|
| 127 | 127 | </p> |
| 128 | 128 | </div> |
| 129 | 129 | <?php |
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * _display_minimum_recommended_php_version_notice |
|
| 135 | - * |
|
| 136 | - * @access private |
|
| 137 | - * @return void |
|
| 138 | - * @throws InvalidDataTypeException |
|
| 139 | - */ |
|
| 140 | - private function displayMinimumRecommendedPhpVersionNotice() |
|
| 141 | - { |
|
| 142 | - if ($this->request->isAdmin()) { |
|
| 143 | - new PersistentAdminNotice( |
|
| 144 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
| 145 | - sprintf( |
|
| 146 | - esc_html__( |
|
| 147 | - 'Event Espresso recommends PHP version %1$s or greater for optimal performance. 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.', |
|
| 148 | - 'event_espresso' |
|
| 149 | - ), |
|
| 150 | - EE_MIN_PHP_VER_RECOMMENDED, |
|
| 151 | - PHP_VERSION, |
|
| 152 | - '<br/>', |
|
| 153 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 154 | - ) |
|
| 155 | - ); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Returns whether the provided php version number is less than the current version of php installed on the server. |
|
| 162 | - * |
|
| 163 | - * @param string $version_required |
|
| 164 | - * @return bool |
|
| 165 | - */ |
|
| 166 | - private function upcomingRequiredPhpVersion($version_required = '5.5') |
|
| 167 | - { |
|
| 168 | - return true; |
|
| 169 | - // return $this->checkPhpVersion($version_required); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
| 175 | - */ |
|
| 176 | - private function displayUpcomingRequiredVersion() |
|
| 177 | - { |
|
| 178 | - if ( |
|
| 179 | - $this->request->isAdmin() |
|
| 180 | - && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
|
| 181 | - && current_user_can('update_plugins') |
|
| 182 | - ) { |
|
| 183 | - add_action('admin_notices', function () { |
|
| 184 | - echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
| 185 | - . sprintf( |
|
| 186 | - esc_html__( |
|
| 187 | - 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
| 188 | - 'event_espresso' |
|
| 189 | - ), |
|
| 190 | - '<strong>', |
|
| 191 | - '</strong>', |
|
| 192 | - PHP_VERSION, |
|
| 193 | - '<a href="https://wordpress.org/support/upgrade-php/">', |
|
| 194 | - '</a>' |
|
| 195 | - ) |
|
| 196 | - . '</p></div>'; |
|
| 197 | - }); |
|
| 198 | - } |
|
| 199 | - } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * _display_minimum_recommended_php_version_notice |
|
| 135 | + * |
|
| 136 | + * @access private |
|
| 137 | + * @return void |
|
| 138 | + * @throws InvalidDataTypeException |
|
| 139 | + */ |
|
| 140 | + private function displayMinimumRecommendedPhpVersionNotice() |
|
| 141 | + { |
|
| 142 | + if ($this->request->isAdmin()) { |
|
| 143 | + new PersistentAdminNotice( |
|
| 144 | + 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
| 145 | + sprintf( |
|
| 146 | + esc_html__( |
|
| 147 | + 'Event Espresso recommends PHP version %1$s or greater for optimal performance. 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.', |
|
| 148 | + 'event_espresso' |
|
| 149 | + ), |
|
| 150 | + EE_MIN_PHP_VER_RECOMMENDED, |
|
| 151 | + PHP_VERSION, |
|
| 152 | + '<br/>', |
|
| 153 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 154 | + ) |
|
| 155 | + ); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Returns whether the provided php version number is less than the current version of php installed on the server. |
|
| 162 | + * |
|
| 163 | + * @param string $version_required |
|
| 164 | + * @return bool |
|
| 165 | + */ |
|
| 166 | + private function upcomingRequiredPhpVersion($version_required = '5.5') |
|
| 167 | + { |
|
| 168 | + return true; |
|
| 169 | + // return $this->checkPhpVersion($version_required); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
| 175 | + */ |
|
| 176 | + private function displayUpcomingRequiredVersion() |
|
| 177 | + { |
|
| 178 | + if ( |
|
| 179 | + $this->request->isAdmin() |
|
| 180 | + && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
|
| 181 | + && current_user_can('update_plugins') |
|
| 182 | + ) { |
|
| 183 | + add_action('admin_notices', function () { |
|
| 184 | + echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
| 185 | + . sprintf( |
|
| 186 | + esc_html__( |
|
| 187 | + 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
| 188 | + 'event_espresso' |
|
| 189 | + ), |
|
| 190 | + '<strong>', |
|
| 191 | + '</strong>', |
|
| 192 | + PHP_VERSION, |
|
| 193 | + '<a href="https://wordpress.org/support/upgrade-php/">', |
|
| 194 | + '</a>' |
|
| 195 | + ) |
|
| 196 | + . '</p></div>'; |
|
| 197 | + }); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | 200 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** @var Asset $asset */ |
| 76 | 76 | $asset = $this->current(); |
| 77 | 77 | if ($asset->type() === $type) { |
| 78 | - $files[ $asset->handle() ] = $asset; |
|
| 78 | + $files[$asset->handle()] = $asset; |
|
| 79 | 79 | } |
| 80 | 80 | $this->next(); |
| 81 | 81 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | /** @var JavascriptAsset $asset */ |
| 97 | 97 | $asset = $this->current(); |
| 98 | 98 | if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) { |
| 99 | - $files[ $asset->handle() ] = $asset; |
|
| 99 | + $files[$asset->handle()] = $asset; |
|
| 100 | 100 | } |
| 101 | 101 | $this->next(); |
| 102 | 102 | } |
@@ -21,192 +21,192 @@ |
||
| 21 | 21 | { |
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * AssetCollection constructor |
|
| 26 | - * |
|
| 27 | - * @throws InvalidInterfaceException |
|
| 28 | - */ |
|
| 29 | - public function __construct() |
|
| 30 | - { |
|
| 31 | - parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @return StylesheetAsset[] |
|
| 37 | - * @since 4.9.62.p |
|
| 38 | - */ |
|
| 39 | - public function getStylesheetAssets() |
|
| 40 | - { |
|
| 41 | - return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @return JavascriptAsset[] |
|
| 47 | - * @since 4.9.62.p |
|
| 48 | - */ |
|
| 49 | - public function getJavascriptAssets() |
|
| 50 | - { |
|
| 51 | - return $this->getAssetsOfType(Asset::TYPE_JS); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @return ManifestFile[] |
|
| 57 | - * @since 4.9.62.p |
|
| 58 | - */ |
|
| 59 | - public function getManifestFiles() |
|
| 60 | - { |
|
| 61 | - return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @param $type |
|
| 67 | - * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[] |
|
| 68 | - * @since 4.9.62.p |
|
| 69 | - */ |
|
| 70 | - protected function getAssetsOfType($type) |
|
| 71 | - { |
|
| 72 | - $files = array(); |
|
| 73 | - $this->rewind(); |
|
| 74 | - while ($this->valid()) { |
|
| 75 | - /** @var Asset $asset */ |
|
| 76 | - $asset = $this->current(); |
|
| 77 | - if ($asset->type() === $type) { |
|
| 78 | - $files[ $asset->handle() ] = $asset; |
|
| 79 | - } |
|
| 80 | - $this->next(); |
|
| 81 | - } |
|
| 82 | - $this->rewind(); |
|
| 83 | - return $files; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @return JavascriptAsset[] |
|
| 89 | - * @since 4.9.62.p |
|
| 90 | - */ |
|
| 91 | - public function getJavascriptAssetsWithData() |
|
| 92 | - { |
|
| 93 | - $files = array(); |
|
| 94 | - $this->rewind(); |
|
| 95 | - while ($this->valid()) { |
|
| 96 | - /** @var JavascriptAsset $asset */ |
|
| 97 | - $asset = $this->current(); |
|
| 98 | - if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) { |
|
| 99 | - $files[ $asset->handle() ] = $asset; |
|
| 100 | - } |
|
| 101 | - $this->next(); |
|
| 102 | - } |
|
| 103 | - $this->rewind(); |
|
| 104 | - return $files; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * returns TRUE or FALSE |
|
| 110 | - * depending on whether the object is within the Collection |
|
| 111 | - * based on the supplied $identifier and type |
|
| 112 | - * |
|
| 113 | - * @param mixed $identifier |
|
| 114 | - * @param string $type |
|
| 115 | - * @return bool |
|
| 116 | - * @since 4.9.63.p |
|
| 117 | - */ |
|
| 118 | - public function hasAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
| 119 | - { |
|
| 120 | - $this->rewind(); |
|
| 121 | - while ($this->valid()) { |
|
| 122 | - if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
| 123 | - $this->rewind(); |
|
| 124 | - return true; |
|
| 125 | - } |
|
| 126 | - $this->next(); |
|
| 127 | - } |
|
| 128 | - return false; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * returns TRUE or FALSE |
|
| 134 | - * depending on whether the Javascript Asset is within the Collection |
|
| 135 | - * based on the supplied $identifier |
|
| 136 | - * |
|
| 137 | - * @param mixed $identifier |
|
| 138 | - * @return bool |
|
| 139 | - * @since 4.9.63.p |
|
| 140 | - */ |
|
| 141 | - public function hasJavascriptAsset($identifier) |
|
| 142 | - { |
|
| 143 | - return $this->hasAssetOfType($identifier, Asset::TYPE_JS); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * returns TRUE or FALSE |
|
| 149 | - * depending on whether the Stylesheet Asset is within the Collection |
|
| 150 | - * based on the supplied $identifier |
|
| 151 | - * |
|
| 152 | - * @param mixed $identifier |
|
| 153 | - * @return bool |
|
| 154 | - * @since 4.9.63.p |
|
| 155 | - */ |
|
| 156 | - public function hasStylesheetAsset($identifier) |
|
| 157 | - { |
|
| 158 | - return $this->hasAssetOfType($identifier, Asset::TYPE_CSS); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * returns the object from the Collection |
|
| 163 | - * based on the supplied $identifier and type |
|
| 164 | - * |
|
| 165 | - * @param mixed $identifier |
|
| 166 | - * @param string $type |
|
| 167 | - * @return JavascriptAsset|StylesheetAsset |
|
| 168 | - * @since 4.9.63.p |
|
| 169 | - */ |
|
| 170 | - public function getAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
| 171 | - { |
|
| 172 | - $this->rewind(); |
|
| 173 | - while ($this->valid()) { |
|
| 174 | - if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
| 175 | - /** @var JavascriptAsset|StylesheetAsset $object */ |
|
| 176 | - $object = $this->current(); |
|
| 177 | - $this->rewind(); |
|
| 178 | - return $object; |
|
| 179 | - } |
|
| 180 | - $this->next(); |
|
| 181 | - } |
|
| 182 | - return null; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * returns the Stylesheet Asset from the Collection |
|
| 188 | - * based on the supplied $identifier |
|
| 189 | - * |
|
| 190 | - * @param mixed $identifier |
|
| 191 | - * @return StylesheetAsset |
|
| 192 | - * @since 4.9.63.p |
|
| 193 | - */ |
|
| 194 | - public function getStylesheetAsset($identifier) |
|
| 195 | - { |
|
| 196 | - return $this->getAssetOfType($identifier, Asset::TYPE_CSS); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * returns the Javascript Asset from the Collection |
|
| 202 | - * based on the supplied $identifier |
|
| 203 | - * |
|
| 204 | - * @param mixed $identifier |
|
| 205 | - * @return JavascriptAsset |
|
| 206 | - * @since 4.9.63.p |
|
| 207 | - */ |
|
| 208 | - public function getJavascriptAsset($identifier) |
|
| 209 | - { |
|
| 210 | - return $this->getAssetOfType($identifier, Asset::TYPE_JS); |
|
| 211 | - } |
|
| 24 | + /** |
|
| 25 | + * AssetCollection constructor |
|
| 26 | + * |
|
| 27 | + * @throws InvalidInterfaceException |
|
| 28 | + */ |
|
| 29 | + public function __construct() |
|
| 30 | + { |
|
| 31 | + parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @return StylesheetAsset[] |
|
| 37 | + * @since 4.9.62.p |
|
| 38 | + */ |
|
| 39 | + public function getStylesheetAssets() |
|
| 40 | + { |
|
| 41 | + return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @return JavascriptAsset[] |
|
| 47 | + * @since 4.9.62.p |
|
| 48 | + */ |
|
| 49 | + public function getJavascriptAssets() |
|
| 50 | + { |
|
| 51 | + return $this->getAssetsOfType(Asset::TYPE_JS); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @return ManifestFile[] |
|
| 57 | + * @since 4.9.62.p |
|
| 58 | + */ |
|
| 59 | + public function getManifestFiles() |
|
| 60 | + { |
|
| 61 | + return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @param $type |
|
| 67 | + * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[] |
|
| 68 | + * @since 4.9.62.p |
|
| 69 | + */ |
|
| 70 | + protected function getAssetsOfType($type) |
|
| 71 | + { |
|
| 72 | + $files = array(); |
|
| 73 | + $this->rewind(); |
|
| 74 | + while ($this->valid()) { |
|
| 75 | + /** @var Asset $asset */ |
|
| 76 | + $asset = $this->current(); |
|
| 77 | + if ($asset->type() === $type) { |
|
| 78 | + $files[ $asset->handle() ] = $asset; |
|
| 79 | + } |
|
| 80 | + $this->next(); |
|
| 81 | + } |
|
| 82 | + $this->rewind(); |
|
| 83 | + return $files; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @return JavascriptAsset[] |
|
| 89 | + * @since 4.9.62.p |
|
| 90 | + */ |
|
| 91 | + public function getJavascriptAssetsWithData() |
|
| 92 | + { |
|
| 93 | + $files = array(); |
|
| 94 | + $this->rewind(); |
|
| 95 | + while ($this->valid()) { |
|
| 96 | + /** @var JavascriptAsset $asset */ |
|
| 97 | + $asset = $this->current(); |
|
| 98 | + if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) { |
|
| 99 | + $files[ $asset->handle() ] = $asset; |
|
| 100 | + } |
|
| 101 | + $this->next(); |
|
| 102 | + } |
|
| 103 | + $this->rewind(); |
|
| 104 | + return $files; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * returns TRUE or FALSE |
|
| 110 | + * depending on whether the object is within the Collection |
|
| 111 | + * based on the supplied $identifier and type |
|
| 112 | + * |
|
| 113 | + * @param mixed $identifier |
|
| 114 | + * @param string $type |
|
| 115 | + * @return bool |
|
| 116 | + * @since 4.9.63.p |
|
| 117 | + */ |
|
| 118 | + public function hasAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
| 119 | + { |
|
| 120 | + $this->rewind(); |
|
| 121 | + while ($this->valid()) { |
|
| 122 | + if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
| 123 | + $this->rewind(); |
|
| 124 | + return true; |
|
| 125 | + } |
|
| 126 | + $this->next(); |
|
| 127 | + } |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * returns TRUE or FALSE |
|
| 134 | + * depending on whether the Javascript Asset is within the Collection |
|
| 135 | + * based on the supplied $identifier |
|
| 136 | + * |
|
| 137 | + * @param mixed $identifier |
|
| 138 | + * @return bool |
|
| 139 | + * @since 4.9.63.p |
|
| 140 | + */ |
|
| 141 | + public function hasJavascriptAsset($identifier) |
|
| 142 | + { |
|
| 143 | + return $this->hasAssetOfType($identifier, Asset::TYPE_JS); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * returns TRUE or FALSE |
|
| 149 | + * depending on whether the Stylesheet Asset is within the Collection |
|
| 150 | + * based on the supplied $identifier |
|
| 151 | + * |
|
| 152 | + * @param mixed $identifier |
|
| 153 | + * @return bool |
|
| 154 | + * @since 4.9.63.p |
|
| 155 | + */ |
|
| 156 | + public function hasStylesheetAsset($identifier) |
|
| 157 | + { |
|
| 158 | + return $this->hasAssetOfType($identifier, Asset::TYPE_CSS); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * returns the object from the Collection |
|
| 163 | + * based on the supplied $identifier and type |
|
| 164 | + * |
|
| 165 | + * @param mixed $identifier |
|
| 166 | + * @param string $type |
|
| 167 | + * @return JavascriptAsset|StylesheetAsset |
|
| 168 | + * @since 4.9.63.p |
|
| 169 | + */ |
|
| 170 | + public function getAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
| 171 | + { |
|
| 172 | + $this->rewind(); |
|
| 173 | + while ($this->valid()) { |
|
| 174 | + if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
| 175 | + /** @var JavascriptAsset|StylesheetAsset $object */ |
|
| 176 | + $object = $this->current(); |
|
| 177 | + $this->rewind(); |
|
| 178 | + return $object; |
|
| 179 | + } |
|
| 180 | + $this->next(); |
|
| 181 | + } |
|
| 182 | + return null; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * returns the Stylesheet Asset from the Collection |
|
| 188 | + * based on the supplied $identifier |
|
| 189 | + * |
|
| 190 | + * @param mixed $identifier |
|
| 191 | + * @return StylesheetAsset |
|
| 192 | + * @since 4.9.63.p |
|
| 193 | + */ |
|
| 194 | + public function getStylesheetAsset($identifier) |
|
| 195 | + { |
|
| 196 | + return $this->getAssetOfType($identifier, Asset::TYPE_CSS); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * returns the Javascript Asset from the Collection |
|
| 202 | + * based on the supplied $identifier |
|
| 203 | + * |
|
| 204 | + * @param mixed $identifier |
|
| 205 | + * @return JavascriptAsset |
|
| 206 | + * @since 4.9.63.p |
|
| 207 | + */ |
|
| 208 | + public function getJavascriptAsset($identifier) |
|
| 209 | + { |
|
| 210 | + return $this->getAssetOfType($identifier, Asset::TYPE_JS); |
|
| 211 | + } |
|
| 212 | 212 | } |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | */ |
| 82 | 82 | public function namespacedBlockType() |
| 83 | 83 | { |
| 84 | - return self::NAME_SPACE . '/' . $this->block_type; |
|
| 84 | + return self::NAME_SPACE.'/'.$this->block_type; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | |
@@ -20,211 +20,211 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | abstract class Block implements BlockInterface |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * BlockAssetManager that this editor block uses for asset registration |
|
| 25 | - * |
|
| 26 | - * @var BlockAssetManagerInterface $block_asset_manager |
|
| 27 | - */ |
|
| 28 | - protected $block_asset_manager; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var RequestInterface $request |
|
| 32 | - */ |
|
| 33 | - protected $request; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @var array $attributes |
|
| 37 | - */ |
|
| 38 | - private $attributes; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * If set to true, then the block will render its content client side |
|
| 42 | - * If false, then the block will render its content server side using the renderBlock() method |
|
| 43 | - * |
|
| 44 | - * @var bool $dynamic |
|
| 45 | - */ |
|
| 46 | - private $dynamic = false; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var string $block_type |
|
| 50 | - */ |
|
| 51 | - private $block_type; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var array $supported_routes |
|
| 55 | - */ |
|
| 56 | - private $supported_routes; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var WP_Block_Type $wp_block_type |
|
| 60 | - */ |
|
| 61 | - private $wp_block_type; |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * BlockLoader constructor. |
|
| 66 | - * |
|
| 67 | - * @param BlockAssetManagerInterface $block_asset_manager |
|
| 68 | - * @param RequestInterface $request |
|
| 69 | - */ |
|
| 70 | - public function __construct(BlockAssetManagerInterface $block_asset_manager, RequestInterface $request) |
|
| 71 | - { |
|
| 72 | - $this->block_asset_manager = $block_asset_manager; |
|
| 73 | - $this->request = $request; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * @return string |
|
| 79 | - */ |
|
| 80 | - public function blockType() |
|
| 81 | - { |
|
| 82 | - return $this->block_type; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @return string |
|
| 88 | - */ |
|
| 89 | - public function namespacedBlockType() |
|
| 90 | - { |
|
| 91 | - return self::NAME_SPACE . '/' . $this->block_type; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * @param string $block_type |
|
| 97 | - */ |
|
| 98 | - protected function setBlockType($block_type) |
|
| 99 | - { |
|
| 100 | - $this->block_type = $block_type; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * BlockAssetManager that this editor block uses for asset registration |
|
| 106 | - * |
|
| 107 | - * @return BlockAssetManagerInterface |
|
| 108 | - */ |
|
| 109 | - public function assetManager() |
|
| 110 | - { |
|
| 111 | - return $this->block_asset_manager; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @param WP_Block_Type $wp_block_type |
|
| 117 | - */ |
|
| 118 | - protected function setWpBlockType($wp_block_type) |
|
| 119 | - { |
|
| 120 | - $this->wp_block_type = $wp_block_type; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * returns an array of fully qualified class names |
|
| 125 | - * for RouteMatchSpecificationInterface objects |
|
| 126 | - * that specify routes that the block should be loaded for. |
|
| 127 | - * |
|
| 128 | - * @return array |
|
| 129 | - */ |
|
| 130 | - public function supportedRoutes() |
|
| 131 | - { |
|
| 132 | - return $this->supported_routes; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * @param array $supported_routes |
|
| 138 | - */ |
|
| 139 | - protected function setSupportedRoutes(array $supported_routes) |
|
| 140 | - { |
|
| 141 | - $this->supported_routes = $supported_routes; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * @return array |
|
| 147 | - */ |
|
| 148 | - public function attributes() |
|
| 149 | - { |
|
| 150 | - return $this->attributes; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @param array $attributes |
|
| 156 | - */ |
|
| 157 | - public function setAttributes(array $attributes) |
|
| 158 | - { |
|
| 159 | - $this->attributes = $attributes; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * @return bool |
|
| 165 | - */ |
|
| 166 | - public function isDynamic() |
|
| 167 | - { |
|
| 168 | - return $this->dynamic; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * @param bool $dynamic |
|
| 174 | - */ |
|
| 175 | - public function setDynamic($dynamic = true) |
|
| 176 | - { |
|
| 177 | - $this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * Registers the Editor Block with WP core; |
|
| 183 | - * Returns the registered block type on success, or false on failure. |
|
| 184 | - * |
|
| 185 | - * @return WP_Block_Type|false |
|
| 186 | - */ |
|
| 187 | - public function registerBlock() |
|
| 188 | - { |
|
| 189 | - $args = array( |
|
| 190 | - 'attributes' => $this->attributes(), |
|
| 191 | - 'editor_script' => $this->block_asset_manager->getEditorScriptHandle(), |
|
| 192 | - 'editor_style' => $this->block_asset_manager->getEditorStyleHandle(), |
|
| 193 | - 'script' => $this->block_asset_manager->getScriptHandle(), |
|
| 194 | - 'style' => $this->block_asset_manager->getStyleHandle(), |
|
| 195 | - ); |
|
| 196 | - if ($this->isDynamic()) { |
|
| 197 | - $args['render_callback'] = array($this, 'renderBlock'); |
|
| 198 | - } |
|
| 199 | - $wp_block_type = register_block_type( |
|
| 200 | - new WP_Block_Type( |
|
| 201 | - $this->namespacedBlockType(), |
|
| 202 | - $args |
|
| 203 | - ) |
|
| 204 | - ); |
|
| 205 | - $this->setWpBlockType($wp_block_type); |
|
| 206 | - return $wp_block_type; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * @return WP_Block_Type|false The registered block type on success, or false on failure. |
|
| 212 | - */ |
|
| 213 | - public function unRegisterBlock() |
|
| 214 | - { |
|
| 215 | - return unregister_block_type($this->namespacedBlockType()); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * @return array |
|
| 222 | - */ |
|
| 223 | - public function getEditorContainer() |
|
| 224 | - { |
|
| 225 | - return array( |
|
| 226 | - $this->namespacedBlockType(), |
|
| 227 | - array(), |
|
| 228 | - ); |
|
| 229 | - } |
|
| 23 | + /** |
|
| 24 | + * BlockAssetManager that this editor block uses for asset registration |
|
| 25 | + * |
|
| 26 | + * @var BlockAssetManagerInterface $block_asset_manager |
|
| 27 | + */ |
|
| 28 | + protected $block_asset_manager; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var RequestInterface $request |
|
| 32 | + */ |
|
| 33 | + protected $request; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @var array $attributes |
|
| 37 | + */ |
|
| 38 | + private $attributes; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * If set to true, then the block will render its content client side |
|
| 42 | + * If false, then the block will render its content server side using the renderBlock() method |
|
| 43 | + * |
|
| 44 | + * @var bool $dynamic |
|
| 45 | + */ |
|
| 46 | + private $dynamic = false; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var string $block_type |
|
| 50 | + */ |
|
| 51 | + private $block_type; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var array $supported_routes |
|
| 55 | + */ |
|
| 56 | + private $supported_routes; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var WP_Block_Type $wp_block_type |
|
| 60 | + */ |
|
| 61 | + private $wp_block_type; |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * BlockLoader constructor. |
|
| 66 | + * |
|
| 67 | + * @param BlockAssetManagerInterface $block_asset_manager |
|
| 68 | + * @param RequestInterface $request |
|
| 69 | + */ |
|
| 70 | + public function __construct(BlockAssetManagerInterface $block_asset_manager, RequestInterface $request) |
|
| 71 | + { |
|
| 72 | + $this->block_asset_manager = $block_asset_manager; |
|
| 73 | + $this->request = $request; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * @return string |
|
| 79 | + */ |
|
| 80 | + public function blockType() |
|
| 81 | + { |
|
| 82 | + return $this->block_type; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @return string |
|
| 88 | + */ |
|
| 89 | + public function namespacedBlockType() |
|
| 90 | + { |
|
| 91 | + return self::NAME_SPACE . '/' . $this->block_type; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * @param string $block_type |
|
| 97 | + */ |
|
| 98 | + protected function setBlockType($block_type) |
|
| 99 | + { |
|
| 100 | + $this->block_type = $block_type; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * BlockAssetManager that this editor block uses for asset registration |
|
| 106 | + * |
|
| 107 | + * @return BlockAssetManagerInterface |
|
| 108 | + */ |
|
| 109 | + public function assetManager() |
|
| 110 | + { |
|
| 111 | + return $this->block_asset_manager; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @param WP_Block_Type $wp_block_type |
|
| 117 | + */ |
|
| 118 | + protected function setWpBlockType($wp_block_type) |
|
| 119 | + { |
|
| 120 | + $this->wp_block_type = $wp_block_type; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * returns an array of fully qualified class names |
|
| 125 | + * for RouteMatchSpecificationInterface objects |
|
| 126 | + * that specify routes that the block should be loaded for. |
|
| 127 | + * |
|
| 128 | + * @return array |
|
| 129 | + */ |
|
| 130 | + public function supportedRoutes() |
|
| 131 | + { |
|
| 132 | + return $this->supported_routes; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * @param array $supported_routes |
|
| 138 | + */ |
|
| 139 | + protected function setSupportedRoutes(array $supported_routes) |
|
| 140 | + { |
|
| 141 | + $this->supported_routes = $supported_routes; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * @return array |
|
| 147 | + */ |
|
| 148 | + public function attributes() |
|
| 149 | + { |
|
| 150 | + return $this->attributes; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * @param array $attributes |
|
| 156 | + */ |
|
| 157 | + public function setAttributes(array $attributes) |
|
| 158 | + { |
|
| 159 | + $this->attributes = $attributes; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * @return bool |
|
| 165 | + */ |
|
| 166 | + public function isDynamic() |
|
| 167 | + { |
|
| 168 | + return $this->dynamic; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @param bool $dynamic |
|
| 174 | + */ |
|
| 175 | + public function setDynamic($dynamic = true) |
|
| 176 | + { |
|
| 177 | + $this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * Registers the Editor Block with WP core; |
|
| 183 | + * Returns the registered block type on success, or false on failure. |
|
| 184 | + * |
|
| 185 | + * @return WP_Block_Type|false |
|
| 186 | + */ |
|
| 187 | + public function registerBlock() |
|
| 188 | + { |
|
| 189 | + $args = array( |
|
| 190 | + 'attributes' => $this->attributes(), |
|
| 191 | + 'editor_script' => $this->block_asset_manager->getEditorScriptHandle(), |
|
| 192 | + 'editor_style' => $this->block_asset_manager->getEditorStyleHandle(), |
|
| 193 | + 'script' => $this->block_asset_manager->getScriptHandle(), |
|
| 194 | + 'style' => $this->block_asset_manager->getStyleHandle(), |
|
| 195 | + ); |
|
| 196 | + if ($this->isDynamic()) { |
|
| 197 | + $args['render_callback'] = array($this, 'renderBlock'); |
|
| 198 | + } |
|
| 199 | + $wp_block_type = register_block_type( |
|
| 200 | + new WP_Block_Type( |
|
| 201 | + $this->namespacedBlockType(), |
|
| 202 | + $args |
|
| 203 | + ) |
|
| 204 | + ); |
|
| 205 | + $this->setWpBlockType($wp_block_type); |
|
| 206 | + return $wp_block_type; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * @return WP_Block_Type|false The registered block type on success, or false on failure. |
|
| 212 | + */ |
|
| 213 | + public function unRegisterBlock() |
|
| 214 | + { |
|
| 215 | + return unregister_block_type($this->namespacedBlockType()); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * @return array |
|
| 222 | + */ |
|
| 223 | + public function getEditorContainer() |
|
| 224 | + { |
|
| 225 | + return array( |
|
| 226 | + $this->namespacedBlockType(), |
|
| 227 | + array(), |
|
| 228 | + ); |
|
| 229 | + } |
|
| 230 | 230 | } |