diff --git a/public_html/wp-content/plugins/camptix/addons/privacy.php b/public_html/wp-content/plugins/camptix/addons/privacy.php
index 5654af039..d4aa9cc29 100644
--- a/public_html/wp-content/plugins/camptix/addons/privacy.php
+++ b/public_html/wp-content/plugins/camptix/addons/privacy.php
@@ -40,9 +40,6 @@ public function register_personal_data_exporters( $exporters ) {
* @return array
*/
public function attendee_personal_data_exporter( $email_address, $page ) {
- /* @var CampTix_Plugin $camptix */
- global $camptix;
-
$page = (int) $page;
$data_to_export = array();
@@ -127,7 +124,7 @@ public function attendee_personal_data_exporter( $email_address, $page ) {
}
break;
case 'questions':
- $questions = $camptix->get_sorted_questions( $post->tix_ticket_id );
+ $questions = CampTix_Utility::get_sorted_questions( $post->tix_ticket_id );
$answers = $post->tix_questions;
foreach ( $questions as $question ) {
@@ -327,7 +324,7 @@ public function attendee_personal_data_eraser( $email_address, $page ) {
update_post_meta( $post->ID, $key, $anonymized_value );
break;
case 'questions':
- $questions = $camptix->get_sorted_questions( $post->tix_ticket_id );
+ $questions = CampTix_Utility::get_sorted_questions( $post->tix_ticket_id );
$answers = $post->tix_questions;
$anonymized_answers = array();
diff --git a/public_html/wp-content/plugins/camptix/addons/require-login.php b/public_html/wp-content/plugins/camptix/addons/require-login.php
index 8f7926ce2..00b28b310 100644
--- a/public_html/wp-content/plugins/camptix/addons/require-login.php
+++ b/public_html/wp-content/plugins/camptix/addons/require-login.php
@@ -274,15 +274,13 @@ protected function registering_multiple_attendees( $tickets_selected ) {
* @return bool
*/
protected function tickets_have_questions( $tickets_selected ) {
- /** @var $camptix CampTix_Plugin */
- global $camptix;
$has_questions = false;
foreach ( $tickets_selected as $ticket_id => $number_attendees_current_ticket ) {
$number_attendees_current_ticket = absint( $number_attendees_current_ticket );
if ( $number_attendees_current_ticket > 0 ) {
- $questions = $camptix->get_sorted_questions( $ticket_id );
+ $questions = CampTix_Utility::get_sorted_questions( $ticket_id );
if ( count( $questions ) >= 1 ) {
$has_questions = true;
diff --git a/public_html/wp-content/plugins/camptix/camptix.php b/public_html/wp-content/plugins/camptix/camptix.php
index 20e63f8e1..9b2605c6f 100644
--- a/public_html/wp-content/plugins/camptix/camptix.php
+++ b/public_html/wp-content/plugins/camptix/camptix.php
@@ -936,46 +936,6 @@ function get_all_questions() {
return $questions;
}
- /**
- * Takes a ticket id and returns a sorted array of questions.
- *
- * @param int $ticket_id
- *
- * @return array
- */
- function get_sorted_questions( $ticket_id ) {
- $question_ids = (array) get_post_meta( $ticket_id, 'tix_question_id' );
- $order = (array) get_post_meta( $ticket_id, 'tix_questions_order', true );
-
- // Make sure we have at least some questions
- if ( empty( $question_ids ) )
- return array();
-
- $questions = get_posts( array(
- 'post_type' => 'tix_question',
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'post__in' => $question_ids,
- ) );
-
- $questions_with_keys = array();
-
- foreach ( $questions as $question )
- $questions_with_keys[ $question->ID ] = $question;
-
- $questions = $questions_with_keys;
- unset( $questions_with_keys );
-
- $questions_sorted = array();
- foreach ( $order as $question_id )
- if ( isset( $questions[ $question_id ] ) )
- $questions_sorted[] = $questions[ $question_id ];
-
- unset( $questions );
-
- return $questions_sorted;
- }
-
/**
* Fired during init, registers our new post types. $supports depends
* on $this->debug, which if true, renders things like custom fields.
@@ -4400,7 +4360,7 @@ function metabox_ticket_questions() {
get_sorted_questions( get_the_ID() );
+ $questions = CampTix_Utility::get_sorted_questions( get_the_ID() );
$i = 0;
?>
@@ -4715,7 +4675,7 @@ function metabox_attendee_info() {
// Questions
$rows[] = array( __( 'Questions', 'wordcamporg' ), '' );
- $questions = $this->get_sorted_questions( $ticket_id );
+ $questions = CampTix_Utility::get_sorted_questions( $ticket_id );
$answers = get_post_meta( $post->ID, 'tix_questions', true );
foreach ( $questions as $question ) {
@@ -5862,7 +5822,7 @@ function form_attendee_info() {
tickets[$ticket_id];
- $questions = $this->get_sorted_questions( $ticket->ID );
+ $questions = CampTix_Utility::get_sorted_questions( $ticket->ID );
$this->form_data['tix_attendee_info'][ $i ]['ticket_id'] = intval( $ticket->ID );
?>
@@ -6231,7 +6191,7 @@ function form_edit_attendee() {
$this->notice( __( 'Please note that the payment for this ticket is still pending.', 'wordcamporg' ) );
$ticket = get_post( $ticket_id );
- $questions = $this->get_sorted_questions( $ticket->ID );
+ $questions = CampTix_Utility::get_sorted_questions( $ticket->ID );
$answers = (array) get_post_meta( $attendee->ID, 'tix_questions', true );
$ticket_info = array(
@@ -7162,7 +7122,7 @@ function form_checkout() {
$answers = array();
if ( isset( $_POST['tix_attendee_questions'][ $i ] ) ) {
- $questions = $this->get_sorted_questions( $ticket->ID );
+ $questions = CampTix_Utility::get_sorted_questions( $ticket->ID );
foreach ( $questions as $question ) {
if ( isset( $_POST['tix_attendee_questions'][ $i ][ $question->ID ] ) ) {
diff --git a/public_html/wp-content/plugins/camptix/utility.php b/public_html/wp-content/plugins/camptix/utility.php
index 1d5477cff..707916427 100644
--- a/public_html/wp-content/plugins/camptix/utility.php
+++ b/public_html/wp-content/plugins/camptix/utility.php
@@ -49,4 +49,44 @@ public static function append_currency( $amount, $options, $nbsp = true, $curren
return $formatted_amount;
}
+
+ /**
+ * Takes a ticket id and returns a sorted array of questions.
+ *
+ * @param int $ticket_id
+ *
+ * @return array
+ */
+ public static function get_sorted_questions( $ticket_id ) {
+ $question_ids = (array) get_post_meta( $ticket_id, 'tix_question_id' );
+ $order = (array) get_post_meta( $ticket_id, 'tix_questions_order', true );
+
+ // Make sure we have at least some questions
+ if ( empty( $question_ids ) )
+ return array();
+
+ $questions = get_posts( array(
+ 'post_type' => 'tix_question',
+ 'post_status' => 'publish',
+ 'posts_per_page' => -1,
+ 'post__in' => $question_ids,
+ ) );
+
+ $questions_with_keys = array();
+
+ foreach ( $questions as $question )
+ $questions_with_keys[ $question->ID ] = $question;
+
+ $questions = $questions_with_keys;
+ unset( $questions_with_keys );
+
+ $questions_sorted = array();
+ foreach ( $order as $question_id )
+ if ( isset( $questions[ $question_id ] ) )
+ $questions_sorted[] = $questions[ $question_id ];
+
+ unset( $questions );
+
+ return $questions_sorted;
+ }
}
\ No newline at end of file