Completed
Branch FET/editor-dates-tickets-refac... (89c3e0)
by
unknown
40:17 queued 32:20
created
core/libraries/form_sections/inputs/EE_State_Select_Input.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -12,94 +12,94 @@
 block discarded – undo
12 12
  */
13 13
 class EE_State_Select_Input extends EE_Select_Input
14 14
 {
15
-    /**
16
-     * @var string the name of the EE_State field to use for option values in the HTML form input.
17
-     */
18
-    protected $valueFieldName;
15
+	/**
16
+	 * @var string the name of the EE_State field to use for option values in the HTML form input.
17
+	 */
18
+	protected $valueFieldName;
19 19
 
20
-    /**
21
-     * @param EE_State[]|array|null $state_options. If a flat array of string is provided,
22
-     * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for
23
-     * the keys (which will become the option values). If null or empty is passed, all active states will be used,
24
-     * and $input_settings['value_field_name'] will again be used.     *
25
-     * @param array $input_settings same as parent, but also {
26
-     *   @type string $value_field_name the name of the field to use
27
-     *   for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`.
28
-     * }
29
-     * @throws EE_Error
30
-     * @throws InvalidArgumentException
31
-     * @throws InvalidDataTypeException
32
-     * @throws InvalidInterfaceException
33
-     * @throws ReflectionException
34
-     */
35
-    public function __construct($state_options, $input_settings = array())
36
-    {
37
-        if (isset($input_settings['value_field_name'])) {
38
-            $this->valueFieldName = $input_settings['value_field_name'];
39
-            if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
40
-                throw new InvalidArgumentException(
41
-                    sprintf(
42
-                        esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'),
43
-                        $this->valueFieldName()
44
-                    )
45
-                );
46
-            }
47
-        } else {
48
-            $this->valueFieldName = 'STA_ID';
49
-        }
50
-        $state_options = apply_filters(
51
-            'FHEE__EE_State_Select_Input____construct__state_options',
52
-            $this->get_state_answer_options($state_options),
53
-            $this
54
-        );
55
-        $input_settings['html_class'] = isset($input_settings['html_class'])
56
-            ? $input_settings['html_class'] . ' ee-state-select-js'
57
-            : 'ee-state-select-js';
58
-        parent::__construct($state_options, $input_settings);
59
-    }
20
+	/**
21
+	 * @param EE_State[]|array|null $state_options. If a flat array of string is provided,
22
+	 * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for
23
+	 * the keys (which will become the option values). If null or empty is passed, all active states will be used,
24
+	 * and $input_settings['value_field_name'] will again be used.     *
25
+	 * @param array $input_settings same as parent, but also {
26
+	 *   @type string $value_field_name the name of the field to use
27
+	 *   for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`.
28
+	 * }
29
+	 * @throws EE_Error
30
+	 * @throws InvalidArgumentException
31
+	 * @throws InvalidDataTypeException
32
+	 * @throws InvalidInterfaceException
33
+	 * @throws ReflectionException
34
+	 */
35
+	public function __construct($state_options, $input_settings = array())
36
+	{
37
+		if (isset($input_settings['value_field_name'])) {
38
+			$this->valueFieldName = $input_settings['value_field_name'];
39
+			if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
40
+				throw new InvalidArgumentException(
41
+					sprintf(
42
+						esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'),
43
+						$this->valueFieldName()
44
+					)
45
+				);
46
+			}
47
+		} else {
48
+			$this->valueFieldName = 'STA_ID';
49
+		}
50
+		$state_options = apply_filters(
51
+			'FHEE__EE_State_Select_Input____construct__state_options',
52
+			$this->get_state_answer_options($state_options),
53
+			$this
54
+		);
55
+		$input_settings['html_class'] = isset($input_settings['html_class'])
56
+			? $input_settings['html_class'] . ' ee-state-select-js'
57
+			: 'ee-state-select-js';
58
+		parent::__construct($state_options, $input_settings);
59
+	}
60 60
 
61
-    /**
62
-     * Returns the name of the state field used for the HTML option values.
63
-     * @since 4.10.0.p
64
-     * @return string
65
-     */
66
-    public function valueFieldName()
67
-    {
68
-        return $this->valueFieldName;
69
-    }
61
+	/**
62
+	 * Returns the name of the state field used for the HTML option values.
63
+	 * @since 4.10.0.p
64
+	 * @return string
65
+	 */
66
+	public function valueFieldName()
67
+	{
68
+		return $this->valueFieldName;
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * get_state_answer_options
74
-     *
75
-     * @param array $state_options
76
-     * @return array
77
-     * @throws EE_Error
78
-     * @throws InvalidArgumentException
79
-     * @throws ReflectionException
80
-     * @throws InvalidDataTypeException
81
-     * @throws InvalidInterfaceException
82
-     */
83
-    public function get_state_answer_options($state_options = null)
84
-    {
85
-        // if passed something that is NOT an array
86
-        if (! is_array($state_options) || empty($state_options)) {
87
-            // get possibly cached list of states
88
-            $states = EEM_State::instance()->get_all_active_states();
89
-        }
90
-        if (is_array($state_options) && reset($state_options) instanceof EE_State) {
91
-            $states = $state_options;
92
-            $state_options = array();
93
-        }
94
-        if (! empty($states)) {
95
-            // set the default
96
-            $state_options[''][''] = '';
97
-            foreach ($states as $state) {
98
-                if ($state instanceof EE_State) {
99
-                    $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name();
100
-                }
101
-            }
102
-        }
103
-        return $state_options;
104
-    }
72
+	/**
73
+	 * get_state_answer_options
74
+	 *
75
+	 * @param array $state_options
76
+	 * @return array
77
+	 * @throws EE_Error
78
+	 * @throws InvalidArgumentException
79
+	 * @throws ReflectionException
80
+	 * @throws InvalidDataTypeException
81
+	 * @throws InvalidInterfaceException
82
+	 */
83
+	public function get_state_answer_options($state_options = null)
84
+	{
85
+		// if passed something that is NOT an array
86
+		if (! is_array($state_options) || empty($state_options)) {
87
+			// get possibly cached list of states
88
+			$states = EEM_State::instance()->get_all_active_states();
89
+		}
90
+		if (is_array($state_options) && reset($state_options) instanceof EE_State) {
91
+			$states = $state_options;
92
+			$state_options = array();
93
+		}
94
+		if (! empty($states)) {
95
+			// set the default
96
+			$state_options[''][''] = '';
97
+			foreach ($states as $state) {
98
+				if ($state instanceof EE_State) {
99
+					$state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name();
100
+				}
101
+			}
102
+		}
103
+		return $state_options;
104
+	}
105 105
 }
Please login to merge, or discard this patch.
form_sections/payment_methods/EE_Billing_Attendee_Info_Form.form.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -14,172 +14,172 @@
 block discarded – undo
14 14
 class EE_Billing_Attendee_Info_Form extends EE_Billing_Info_Form
15 15
 {
16 16
 
17
-    /**
18
-     *
19
-     * @param EE_Payment_Method $payment_method
20
-     * @param array $options_array @see EE_Form_Section_Proper::__construct()
21
-     */
22
-    public function __construct(EE_Payment_Method $payment_method, $options_array = array())
23
-    {
24
-        $options_array['subsections'] = array_merge(
25
-            array(
26
-                'first_name'    => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso') )),
27
-                'last_name'     => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso') )),
28
-                'email'             => new EE_Email_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email', 'event_espresso') )),
29
-                'address'           => new EE_Text_Input(array( 'html_label_text'=>  __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address' )),
30
-                'address2'      => new EE_Text_Input(array( 'html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2' )),
31
-                'city'                  => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso') )),
32
-                'state'                 => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso') ))),
33
-                'country'           => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso') ))),
34
-                'zip'                   => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso') )),
35
-                'phone'         => new EE_Text_Input(array( 'html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso') )),
36
-            ),
37
-            isset($options_array['subsections']) ? $options_array['subsections'] : array()
38
-        );
17
+	/**
18
+	 *
19
+	 * @param EE_Payment_Method $payment_method
20
+	 * @param array $options_array @see EE_Form_Section_Proper::__construct()
21
+	 */
22
+	public function __construct(EE_Payment_Method $payment_method, $options_array = array())
23
+	{
24
+		$options_array['subsections'] = array_merge(
25
+			array(
26
+				'first_name'    => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso') )),
27
+				'last_name'     => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso') )),
28
+				'email'             => new EE_Email_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email', 'event_espresso') )),
29
+				'address'           => new EE_Text_Input(array( 'html_label_text'=>  __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address' )),
30
+				'address2'      => new EE_Text_Input(array( 'html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2' )),
31
+				'city'                  => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso') )),
32
+				'state'                 => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso') ))),
33
+				'country'           => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso') ))),
34
+				'zip'                   => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso') )),
35
+				'phone'         => new EE_Text_Input(array( 'html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso') )),
36
+			),
37
+			isset($options_array['subsections']) ? $options_array['subsections'] : array()
38
+		);
39 39
 
40
-        parent::__construct($payment_method, $options_array);
41
-    }
40
+		parent::__construct($payment_method, $options_array);
41
+	}
42 42
 
43
-    /**
44
-     * Sets the defaults for the billing form according to the attendee's details
45
-     * @param EE_Attendee $attendee
46
-     */
47
-    public function populate_from_attendee($attendee)
48
-    {
49
-        $attendee = EEM_Attendee::instance()->ensure_is_obj($attendee);
43
+	/**
44
+	 * Sets the defaults for the billing form according to the attendee's details
45
+	 * @param EE_Attendee $attendee
46
+	 */
47
+	public function populate_from_attendee($attendee)
48
+	{
49
+		$attendee = EEM_Attendee::instance()->ensure_is_obj($attendee);
50 50
 
51
-        /** @var $attendee EE_Attendee */
52
-        $this->populate_defaults(
53
-            apply_filters(
54
-                'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee',
55
-                array(
56
-                    'first_name'=>$attendee->fname(),
57
-                    'last_name'=>$attendee->lname(),
58
-                    'email'=>$attendee->email(),
59
-                    'address'=>$attendee->address(),
60
-                    'address2'=>$attendee->address2(),
61
-                    'city'=>$attendee->city(),
62
-                    'state'=> $this->getAttendeeStateValueForForm($attendee),
63
-                    'country'=> $attendee->country_ID(),
64
-                    'zip'=>$attendee->zip(),
65
-                    'phone'=>$attendee->phone(),
66
-                ),
67
-                $attendee,
68
-                $this
69
-            )
70
-        );
71
-    }
51
+		/** @var $attendee EE_Attendee */
52
+		$this->populate_defaults(
53
+			apply_filters(
54
+				'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee',
55
+				array(
56
+					'first_name'=>$attendee->fname(),
57
+					'last_name'=>$attendee->lname(),
58
+					'email'=>$attendee->email(),
59
+					'address'=>$attendee->address(),
60
+					'address2'=>$attendee->address2(),
61
+					'city'=>$attendee->city(),
62
+					'state'=> $this->getAttendeeStateValueForForm($attendee),
63
+					'country'=> $attendee->country_ID(),
64
+					'zip'=>$attendee->zip(),
65
+					'phone'=>$attendee->phone(),
66
+				),
67
+				$attendee,
68
+				$this
69
+			)
70
+		);
71
+	}
72 72
 
73
-    /**
74
-     * Gets the default value to use for the billing form's state value.
75
-     * @since 4.10.0.p
76
-     * @param EE_Attendee $attendee
77
-     * @return string
78
-     * @throws EE_Error2
79
-     */
80
-    protected function getAttendeeStateValueForForm(EE_Attendee $attendee)
81
-    {
82
-        // If the state input was removed, just return a blank string.
83
-        if (! $this->has_subsection('state')) {
84
-            return '';
85
-        }
86
-        $state_input =  $this->get_input('state', false);
87
-        if ($state_input instanceof EE_State_Select_Input) {
88
-            $state_field_to_use =  $state_input->valueFieldName();
89
-        } else {
90
-            $state_field_to_use = 'STA_ID';
91
-        }
92
-        switch ($state_field_to_use) {
93
-            case 'STA_abbrev':
94
-                $state_value = $attendee->state_abbrev();
95
-                break;
96
-            case 'STA_name':
97
-                $state_value = $attendee->state_name();
98
-                break;
99
-            default:
100
-                $state_value = $attendee->state_ID();
101
-        }
102
-        return $state_value;
103
-    }
73
+	/**
74
+	 * Gets the default value to use for the billing form's state value.
75
+	 * @since 4.10.0.p
76
+	 * @param EE_Attendee $attendee
77
+	 * @return string
78
+	 * @throws EE_Error2
79
+	 */
80
+	protected function getAttendeeStateValueForForm(EE_Attendee $attendee)
81
+	{
82
+		// If the state input was removed, just return a blank string.
83
+		if (! $this->has_subsection('state')) {
84
+			return '';
85
+		}
86
+		$state_input =  $this->get_input('state', false);
87
+		if ($state_input instanceof EE_State_Select_Input) {
88
+			$state_field_to_use =  $state_input->valueFieldName();
89
+		} else {
90
+			$state_field_to_use = 'STA_ID';
91
+		}
92
+		switch ($state_field_to_use) {
93
+			case 'STA_abbrev':
94
+				$state_value = $attendee->state_abbrev();
95
+				break;
96
+			case 'STA_name':
97
+				$state_value = $attendee->state_name();
98
+				break;
99
+			default:
100
+				$state_value = $attendee->state_ID();
101
+		}
102
+		return $state_value;
103
+	}
104 104
 
105 105
 
106 106
 
107
-    /**
108
-     * copy_billing_form_data_to_attendee
109
-     * copies info from the billing form to the attendee's details
110
-     * @param \EE_Attendee $attendee - the attendee object to copy details to
111
-     * @return \EE_Attendee
112
-     */
113
-    public function copy_billing_form_data_to_attendee(EE_Attendee $attendee)
114
-    {
115
-        // grab billing form data
116
-        $data = $this->valid_data();
117
-        // copy first_name
118
-        if (! empty($data['first_name'])) {
119
-            $attendee->set_fname($data['first_name']);
120
-        }
121
-        // copy last_name
122
-        if (! empty($data['last_name'])) {
123
-            $attendee->set_lname($data['last_name']);
124
-        }
125
-        // copy email
126
-        if (! empty($data['email'])) {
127
-            $attendee->set_email($data['email']);
128
-        }
129
-        // copy address
130
-        if (! empty($data['address'])) {
131
-            $attendee->set_address($data['address']);
132
-        }
133
-        // copy address2
134
-        if (! empty($data['address2'])) {
135
-            $attendee->set_address2($data['address2']);
136
-        }
137
-        // copy city
138
-        if (! empty($data['city'])) {
139
-            $attendee->set_city($data['city']);
140
-        }
141
-        // copy state
142
-        if (! empty($data['state'])) {
143
-            $attendee->set_state($data['state']);
144
-        }
145
-        // copy country
146
-        if (! empty($data['country'])) {
147
-            $attendee->set_country($data['country']);
148
-        }
149
-        // copy zip
150
-        if (! empty($data['zip'])) {
151
-            $attendee->set_zip($data['zip']);
152
-        }
153
-        // copy phone
154
-        if (! empty($data['phone'])) {
155
-            $attendee->set_phone($data['phone']);
156
-        }
157
-        return $attendee;
158
-    }
107
+	/**
108
+	 * copy_billing_form_data_to_attendee
109
+	 * copies info from the billing form to the attendee's details
110
+	 * @param \EE_Attendee $attendee - the attendee object to copy details to
111
+	 * @return \EE_Attendee
112
+	 */
113
+	public function copy_billing_form_data_to_attendee(EE_Attendee $attendee)
114
+	{
115
+		// grab billing form data
116
+		$data = $this->valid_data();
117
+		// copy first_name
118
+		if (! empty($data['first_name'])) {
119
+			$attendee->set_fname($data['first_name']);
120
+		}
121
+		// copy last_name
122
+		if (! empty($data['last_name'])) {
123
+			$attendee->set_lname($data['last_name']);
124
+		}
125
+		// copy email
126
+		if (! empty($data['email'])) {
127
+			$attendee->set_email($data['email']);
128
+		}
129
+		// copy address
130
+		if (! empty($data['address'])) {
131
+			$attendee->set_address($data['address']);
132
+		}
133
+		// copy address2
134
+		if (! empty($data['address2'])) {
135
+			$attendee->set_address2($data['address2']);
136
+		}
137
+		// copy city
138
+		if (! empty($data['city'])) {
139
+			$attendee->set_city($data['city']);
140
+		}
141
+		// copy state
142
+		if (! empty($data['state'])) {
143
+			$attendee->set_state($data['state']);
144
+		}
145
+		// copy country
146
+		if (! empty($data['country'])) {
147
+			$attendee->set_country($data['country']);
148
+		}
149
+		// copy zip
150
+		if (! empty($data['zip'])) {
151
+			$attendee->set_zip($data['zip']);
152
+		}
153
+		// copy phone
154
+		if (! empty($data['phone'])) {
155
+			$attendee->set_phone($data['phone']);
156
+		}
157
+		return $attendee;
158
+	}
159 159
 
160 160
 
161
-    /**
162
-     * create_attendee_from_billing_form_data
163
-     * uses info from the billing form to create a new attendee
164
-     * @return \EE_Attendee
165
-     */
166
-    public function create_attendee_from_billing_form_data()
167
-    {
168
-        // grab billing form data
169
-        $data = $this->valid_data();
170
-        return EE_Attendee::new_instance(array(
171
-            'ATT_fname'         => ! empty($data['first_name']) ? $data['first_name'] : '',
172
-            'ATT_lname'         => ! empty($data['last_name']) ? $data['last_name'] : '',
173
-            'ATT_email'         => ! empty($data['email']) ? $data['email'] : '',
174
-            'ATT_address'       => ! empty($data['address']) ? $data['address'] : '',
175
-            'ATT_address2'  => ! empty($data['address2']) ? $data['address2'] : '',
176
-            'ATT_city'          => ! empty($data['city']) ? $data['city'] : '',
177
-            'STA_ID'                => ! empty($data['state']) ? $data['state'] : '',
178
-            'CNT_ISO'           => ! empty($data['country']) ? $data['country'] : '',
179
-            'ATT_zip'               => ! empty($data['zip']) ? $data['zip'] : '',
180
-            'ATT_phone'         => ! empty($data['phone']) ? $data['phone'] : '',
181
-        ));
182
-    }
161
+	/**
162
+	 * create_attendee_from_billing_form_data
163
+	 * uses info from the billing form to create a new attendee
164
+	 * @return \EE_Attendee
165
+	 */
166
+	public function create_attendee_from_billing_form_data()
167
+	{
168
+		// grab billing form data
169
+		$data = $this->valid_data();
170
+		return EE_Attendee::new_instance(array(
171
+			'ATT_fname'         => ! empty($data['first_name']) ? $data['first_name'] : '',
172
+			'ATT_lname'         => ! empty($data['last_name']) ? $data['last_name'] : '',
173
+			'ATT_email'         => ! empty($data['email']) ? $data['email'] : '',
174
+			'ATT_address'       => ! empty($data['address']) ? $data['address'] : '',
175
+			'ATT_address2'  => ! empty($data['address2']) ? $data['address2'] : '',
176
+			'ATT_city'          => ! empty($data['city']) ? $data['city'] : '',
177
+			'STA_ID'                => ! empty($data['state']) ? $data['state'] : '',
178
+			'CNT_ISO'           => ! empty($data['country']) ? $data['country'] : '',
179
+			'ATT_zip'               => ! empty($data['zip']) ? $data['zip'] : '',
180
+			'ATT_phone'         => ! empty($data['phone']) ? $data['phone'] : '',
181
+		));
182
+	}
183 183
 }
184 184
 
185 185
 // End of file EE_Billing_Attendee_Info_Form.form.php
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_PMT_Base.lib.php 2 patches
Indentation   +808 added lines, -808 removed lines patch added patch discarded remove patch
@@ -21,812 +21,812 @@
 block discarded – undo
21 21
 abstract class EE_PMT_Base
22 22
 {
23 23
 
24
-    const onsite = 'on-site';
25
-    const offsite = 'off-site';
26
-    const offline = 'off-line';
27
-
28
-    /**
29
-     * @var EE_Payment_Method
30
-     */
31
-    protected $_pm_instance = null;
32
-
33
-    /**
34
-     * @var boolean
35
-     */
36
-    protected $_requires_https = false;
37
-
38
-    /**
39
-     * @var boolean
40
-     */
41
-    protected $_has_billing_form;
42
-
43
-    /**
44
-     * @var EE_Gateway
45
-     */
46
-    protected $_gateway = null;
47
-
48
-    /**
49
-     * @var EE_Payment_Method_Form
50
-     */
51
-    protected $_settings_form = null;
52
-
53
-    /**
54
-     * @var EE_Form_Section_Proper
55
-     */
56
-    protected $_billing_form = null;
57
-
58
-    /**
59
-     * @var boolean
60
-     */
61
-    protected $_cache_billing_form = true;
62
-
63
-    /**
64
-     * String of the absolute path to the folder containing this file, with a trailing slash.
65
-     * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/'
66
-     *
67
-     * @var string
68
-     */
69
-    protected $_file_folder = null;
70
-
71
-    /**
72
-     * String to the absolute URL to this file (useful for getting its web-accessible resources
73
-     * like images, js, or css)
74
-     *
75
-     * @var string
76
-     */
77
-    protected $_file_url = null;
78
-
79
-    /**
80
-     * Pretty name for the payment method
81
-     *
82
-     * @var string
83
-     */
84
-    protected $_pretty_name = null;
85
-
86
-    /**
87
-     *
88
-     * @var string
89
-     */
90
-    protected $_default_button_url = null;
91
-
92
-    /**
93
-     *
94
-     * @var string
95
-     */
96
-    protected $_default_description = null;
97
-
98
-
99
-    /**
100
-     *
101
-     * @param EE_Payment_Method $pm_instance
102
-     * @throws EE_Error
103
-     * @return EE_PMT_Base
104
-     */
105
-    public function __construct($pm_instance = null)
106
-    {
107
-        if ($pm_instance instanceof EE_Payment_Method) {
108
-            $this->set_instance($pm_instance);
109
-        }
110
-        if ($this->_gateway) {
111
-            $this->_gateway->set_payment_model(EEM_Payment::instance());
112
-            $this->_gateway->set_payment_log(EEM_Change_Log::instance());
113
-            $this->_gateway->set_template_helper(new EEH_Template());
114
-            $this->_gateway->set_line_item_helper(new EEH_Line_Item());
115
-            $this->_gateway->set_money_helper(new EEH_Money());
116
-            $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter());
117
-            $this->_gateway->set_unsupported_character_remover(new AsciiOnly());
118
-            do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
119
-        }
120
-        if (! isset($this->_has_billing_form)) {
121
-            // by default, On Site gateways have a billing form
122
-            if ($this->payment_occurs() == EE_PMT_Base::onsite) {
123
-                $this->set_has_billing_form(true);
124
-            } else {
125
-                $this->set_has_billing_form(false);
126
-            }
127
-        }
128
-
129
-        if (! $this->_pretty_name) {
130
-            throw new EE_Error(
131
-                sprintf(
132
-                    __(
133
-                        "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized",
134
-                        "event_espresso"
135
-                    )
136
-                )
137
-            );
138
-        }
139
-        // if the child didn't specify a default button, use the credit card one
140
-        if ($this->_default_button_url === null) {
141
-            $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png';
142
-        }
143
-    }
144
-
145
-
146
-    /**
147
-     * @param boolean $has_billing_form
148
-     */
149
-    public function set_has_billing_form($has_billing_form)
150
-    {
151
-        $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN);
152
-    }
153
-
154
-
155
-    /**
156
-     * sets the file_folder property
157
-     */
158
-    protected function _set_file_folder()
159
-    {
160
-        $reflector = new ReflectionClass(get_class($this));
161
-        $fn = $reflector->getFileName();
162
-        $this->_file_folder = dirname($fn) . '/';
163
-    }
164
-
165
-
166
-    /**
167
-     * sets the file URL with a trailing slash for this PMT
168
-     */
169
-    protected function _set_file_url()
170
-    {
171
-        $plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR);
172
-        $file_folder_fixed = str_replace('\\', '/', $this->file_folder());
173
-        $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed);
174
-        $this->_file_url = set_url_scheme($file_path);
175
-    }
176
-
177
-    /**
178
-     * Gets the default description on all payment methods of this type
179
-     *
180
-     * @return string
181
-     */
182
-    public function default_description()
183
-    {
184
-        return $this->_default_description;
185
-    }
186
-
187
-
188
-    /**
189
-     * Returns the folder containing the PMT child class, with a trailing slash
190
-     *
191
-     * @return string
192
-     */
193
-    public function file_folder()
194
-    {
195
-        if (! $this->_file_folder) {
196
-            $this->_set_file_folder();
197
-        }
198
-        return $this->_file_folder;
199
-    }
200
-
201
-
202
-    /**
203
-     * @return string
204
-     */
205
-    public function file_url()
206
-    {
207
-        if (! $this->_file_url) {
208
-            $this->_set_file_url();
209
-        }
210
-        return $this->_file_url;
211
-    }
212
-
213
-
214
-    /**
215
-     * Sets the payment method instance this payment method type is for.
216
-     * Its important teh payment method instance is set before
217
-     *
218
-     * @param EE_Payment_Method $payment_method_instance
219
-     */
220
-    public function set_instance($payment_method_instance)
221
-    {
222
-        $this->_pm_instance = $payment_method_instance;
223
-        // if they have already requested the settings form, make sure its
224
-        // data matches this model object
225
-        if ($this->_settings_form) {
226
-            $this->settings_form()->populate_model_obj($payment_method_instance);
227
-        }
228
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
229
-            $this->_gateway->set_settings($payment_method_instance->settings_array());
230
-        }
231
-    }
232
-
233
-
234
-    /**
235
-     * Gets teh form for displaying to admins where they setup the payment method
236
-     *
237
-     * @return EE_Payment_Method_Form
238
-     */
239
-    public function settings_form()
240
-    {
241
-        if (! $this->_settings_form) {
242
-            $this->_settings_form = $this->generate_new_settings_form();
243
-            $this->_settings_form->set_payment_method_type($this);
244
-            // if we have already assigned a model object to this pmt, make
245
-            // sure its reflected in teh form we just generated
246
-            if ($this->_pm_instance) {
247
-                $this->_settings_form->populate_model_obj($this->_pm_instance);
248
-            }
249
-        }
250
-        return $this->_settings_form;
251
-    }
252
-
253
-
254
-    /**
255
-     * Gets the form for all the settings related to this payment method type
256
-     *
257
-     * @return EE_Payment_Method_Form
258
-     */
259
-    abstract public function generate_new_settings_form();
260
-
261
-
262
-    /**
263
-     * Sets the form for settings. This may be useful if we have already received
264
-     * a form submission and have form data it in, and want to use it anytime we're showing
265
-     * this payment method type's settings form later in the request
266
-     *
267
-     * @param EE_Payment_Method_Form $form
268
-     */
269
-    public function set_settings_form($form)
270
-    {
271
-        $this->_settings_form = $form;
272
-    }
273
-
274
-
275
-    /**
276
-     * @return boolean
277
-     */
278
-    public function has_billing_form()
279
-    {
280
-        return $this->_has_billing_form;
281
-    }
282
-
283
-
284
-    /**
285
-     * Gets the form for displaying to attendees where they can enter their billing info
286
-     * which will be sent to teh gateway (can be null)
287
-     *
288
-     * @param \EE_Transaction $transaction
289
-     * @param array           $extra_args
290
-     * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null
291
-     */
292
-    public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
293
-    {
294
-        // has billing form already been regenerated ? or overwrite cache?
295
-        if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
296
-            $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
297
-        }
298
-        // if we know who the attendee is, and this is a billing form
299
-        // that uses attendee info, populate it
300
-        if (apply_filters(
301
-            'FHEE__populate_billing_form_fields_from_attendee',
302
-            ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form
303
-                && $transaction instanceof EE_Transaction
304
-                && $transaction->primary_registration() instanceof EE_Registration
305
-                && $transaction->primary_registration()->attendee() instanceof EE_Attendee
306
-            ),
307
-            $this->_billing_form,
308
-            $transaction
309
-        )) {
310
-            $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee());
311
-        }
312
-        return $this->_billing_form;
313
-    }
314
-
315
-
316
-    /**
317
-     * Creates the billing form for this payment method type
318
-     *
319
-     * @param \EE_Transaction $transaction
320
-     * @return \EE_Billing_Info_Form
321
-     */
322
-    abstract public function generate_new_billing_form(EE_Transaction $transaction = null);
323
-
324
-
325
-    /**
326
-     * apply_billing_form_debug_settings
327
-     * applies debug data to the form
328
-     *
329
-     * @param \EE_Billing_Info_Form $billing_form
330
-     * @return \EE_Billing_Info_Form
331
-     */
332
-    public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
333
-    {
334
-        return $billing_form;
335
-    }
336
-
337
-
338
-    /**
339
-     * Sets the billing form for this payment method type. You may want to use this
340
-     * if you have form
341
-     *
342
-     * @param EE_Payment_Method $form
343
-     */
344
-    public function set_billing_form($form)
345
-    {
346
-        $this->_billing_form = $form;
347
-    }
348
-
349
-
350
-    /**
351
-     * Returns whether or not this payment method requires HTTPS to be used
352
-     *
353
-     * @return boolean
354
-     */
355
-    public function requires_https()
356
-    {
357
-        return $this->_requires_https;
358
-    }
359
-
360
-
361
-    /**
362
-     *
363
-     * @param EE_Transaction       $transaction
364
-     * @param float                $amount
365
-     * @param EE_Billing_Info_Form $billing_info
366
-     * @param string               $return_url
367
-     * @param string               $fail_url
368
-     * @param string               $method
369
-     * @param bool                 $by_admin
370
-     * @return EE_Payment
371
-     * @throws EE_Error
372
-     */
373
-    public function process_payment(
374
-        EE_Transaction $transaction,
375
-        $amount = null,
376
-        $billing_info = null,
377
-        $return_url = null,
378
-        $fail_url = '',
379
-        $method = 'CART',
380
-        $by_admin = false
381
-    ) {
382
-        // @todo: add surcharge for the payment method, if any
383
-        if ($this->_gateway) {
384
-            // there is a gateway, so we're going to make a payment object
385
-            // but wait! do they already have a payment in progress that we thought was failed?
386
-            $duplicate_properties = array(
387
-                'STS_ID'               => EEM_Payment::status_id_failed,
388
-                'TXN_ID'               => $transaction->ID(),
389
-                'PMD_ID'               => $this->_pm_instance->ID(),
390
-                'PAY_source'           => $method,
391
-                'PAY_amount'           => $amount !== null ? $amount : $transaction->remaining(),
392
-                'PAY_gateway_response' => null,
393
-            );
394
-            $payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
395
-            // if we didn't already have a payment in progress for the same thing,
396
-            // then we actually want to make a new payment
397
-            if (! $payment instanceof EE_Payment) {
398
-                $payment = EE_Payment::new_instance(
399
-                    array_merge(
400
-                        $duplicate_properties,
401
-                        array(
402
-                            'PAY_timestamp'       => time(),
403
-                            'PAY_txn_id_chq_nmbr' => null,
404
-                            'PAY_po_number'       => null,
405
-                            'PAY_extra_accntng'   => null,
406
-                            'PAY_details'         => null,
407
-                        )
408
-                    )
409
-                );
410
-            }
411
-            // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it
412
-            $payment->save();
413
-            $billing_values = $this->_get_billing_values_from_form($billing_info);
414
-
415
-            //  Offsite Gateway
416
-            if ($this->_gateway instanceof EE_Offsite_Gateway) {
417
-                $payment = $this->_gateway->set_redirection_info(
418
-                    $payment,
419
-                    $billing_values,
420
-                    $return_url,
421
-                    EE_Config::instance()->core->txn_page_url(
422
-                        array(
423
-                            'e_reg_url_link'    => $transaction->primary_registration()->reg_url_link(),
424
-                            'ee_payment_method' => $this->_pm_instance->slug(),
425
-                        )
426
-                    ),
427
-                    $fail_url
428
-                );
429
-                $payment->save();
430
-                //  Onsite Gateway
431
-            } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
432
-                $payment = $this->_gateway->do_direct_payment($payment, $billing_values);
433
-                $payment->save();
434
-            } else {
435
-                throw new EE_Error(
436
-                    sprintf(
437
-                        __(
438
-                            'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)',
439
-                            'event_espresso'
440
-                        ),
441
-                        get_class($this),
442
-                        gettype($this->_gateway)
443
-                    )
444
-                );
445
-            }
446
-        } else {
447
-            // no gateway provided
448
-            // there is no payment. Must be an offline gateway
449
-            // create a payment object anyways, but dont save it
450
-            $payment = EE_Payment::new_instance(
451
-                array(
452
-                    'STS_ID'        => EEM_Payment::status_id_pending,
453
-                    'TXN_ID'        => $transaction->ID(),
454
-                    'PMD_ID'        => $transaction->payment_method_ID(),
455
-                    'PAY_amount'    => 0.00,
456
-                    'PAY_timestamp' => time(),
457
-                )
458
-            );
459
-        }
460
-
461
-        // if there is billing info, clean it and save it now
462
-        if ($billing_info instanceof EE_Billing_Attendee_Info_Form) {
463
-            $this->_save_billing_info_to_attendee($billing_info, $transaction);
464
-        }
465
-
466
-        return $payment;
467
-    }
468
-
469
-    /**
470
-     * Gets the values we want to pass onto the gateway. Normally these
471
-     * are just the 'pretty' values, but there may be times the data may need
472
-     * a  little massaging. Proper subsections will become arrays of inputs
473
-     *
474
-     * @param EE_Billing_Info_Form $billing_form
475
-     * @return array
476
-     */
477
-    protected function _get_billing_values_from_form($billing_form)
478
-    {
479
-        if ($billing_form instanceof EE_Form_Section_Proper) {
480
-            return $billing_form->input_pretty_values(true);
481
-        } else {
482
-            return null;
483
-        }
484
-    }
485
-
486
-
487
-    /**
488
-     * Handles an instant payment notification when the transaction is known (by default).
489
-     *
490
-     * @param array          $req_data
491
-     * @param EE_Transaction $transaction
492
-     * @return EE_Payment
493
-     * @throws EE_Error
494
-     */
495
-    public function handle_ipn($req_data, $transaction)
496
-    {
497
-        $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
498
-        if (! $this->_gateway instanceof EE_Offsite_Gateway) {
499
-            throw new EE_Error(
500
-                sprintf(
501
-                    __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
502
-                    print_r($this->_gateway, true)
503
-                )
504
-            );
505
-        }
506
-        $payment = $this->_gateway->handle_payment_update($req_data, $transaction);
507
-        return $payment;
508
-    }
509
-
510
-
511
-    /**
512
-     * Saves the billing info onto the attendee of the primary registrant on this transaction, and
513
-     * cleans it first.
514
-     *
515
-     * @param EE_Billing_Attendee_Info_Form $billing_form
516
-     * @param EE_Transaction                $transaction
517
-     * @return boolean success
518
-     */
519
-    protected function _save_billing_info_to_attendee($billing_form, $transaction)
520
-    {
521
-        if (! $transaction || ! $transaction instanceof EE_Transaction) {
522
-            EE_Error::add_error(
523
-                __("Cannot save billing info because no transaction was specified", "event_espresso"),
524
-                __FILE__,
525
-                __FUNCTION__,
526
-                __LINE__
527
-            );
528
-            return false;
529
-        }
530
-        $primary_reg = $transaction->primary_registration();
531
-        if (! $primary_reg) {
532
-            EE_Error::add_error(
533
-                __("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
534
-                __FILE__,
535
-                __FUNCTION__,
536
-                __LINE__
537
-            );
538
-            return false;
539
-        }
540
-        $attendee = $primary_reg->attendee();
541
-        if (! $attendee) {
542
-            EE_Error::add_error(
543
-                __(
544
-                    "Cannot save billing info because the transaction's primary registration has no attendee!",
545
-                    "event_espresso"
546
-                ),
547
-                __FILE__,
548
-                __FUNCTION__,
549
-                __LINE__
550
-            );
551
-            return false;
552
-        }
553
-        return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method());
554
-    }
555
-
556
-
557
-    /**
558
-     * Gets the payment this IPN is for. Children may often want to
559
-     * override this to inspect the request
560
-     *
561
-     * @param EE_Transaction $transaction
562
-     * @param array          $req_data
563
-     * @return EE_Payment
564
-     */
565
-    protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array())
566
-    {
567
-        return $transaction->last_payment();
568
-    }
569
-
570
-
571
-    /**
572
-     * In case generic code cannot provide the payment processor with a specific payment method
573
-     * and transaction, it will try calling this method on each activate payment method.
574
-     * If the payment method is able to identify the request as being for it, it should fetch
575
-     * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot
576
-     * handle the IPN
577
-     *
578
-     * @param array $req_data
579
-     * @return EE_Payment only if this payment method can find the info its needs from $req_data
580
-     * and identifies the IPN as being for this payment method (not just fo ra payment method of this type)
581
-     * @throws EE_Error
582
-     */
583
-    public function handle_unclaimed_ipn($req_data = array())
584
-    {
585
-        throw new EE_Error(
586
-            sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))
587
-        );
588
-    }
589
-
590
-
591
-    /**
592
-     * Logic to be accomplished when the payment attempt is complete.
593
-     * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
594
-     * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
595
-     * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
596
-     * of the payment). Fed a transaction because it's always assumed to be the last payment that
597
-     * we're dealing with. Returns that last payment (if there is one)
598
-     *
599
-     * @param EE_Transaction $transaction
600
-     * @return EE_Payment
601
-     */
602
-    public function finalize_payment_for($transaction)
603
-    {
604
-        return $transaction->last_payment();
605
-    }
606
-
607
-
608
-    /**
609
-     * Whether or not this payment method's gateway supports sending refund requests
610
-     *
611
-     * @return boolean
612
-     */
613
-    public function supports_sending_refunds()
614
-    {
615
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
616
-            return $this->_gateway->supports_sending_refunds();
617
-        } else {
618
-            return false;
619
-        }
620
-    }
621
-
622
-
623
-    /**
624
-     *
625
-     * @param EE_Payment $payment
626
-     * @param array      $refund_info
627
-     * @throws EE_Error
628
-     * @return EE_Payment
629
-     */
630
-    public function process_refund(EE_Payment $payment, $refund_info = array())
631
-    {
632
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
633
-            return $this->_gateway->do_direct_refund($payment, $refund_info);
634
-        } else {
635
-            throw new EE_Error(
636
-                sprintf(
637
-                    __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'),
638
-                    get_class($this)
639
-                )
640
-            );
641
-        }
642
-    }
643
-
644
-
645
-    /**
646
-     * Returns one the class's constants onsite,offsite, or offline, depending on this
647
-     * payment method's gateway.
648
-     *
649
-     * @return string
650
-     * @throws EE_Error
651
-     */
652
-    public function payment_occurs()
653
-    {
654
-        if (! $this->_gateway) {
655
-            return EE_PMT_Base::offline;
656
-        } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
657
-            return EE_PMT_Base::onsite;
658
-        } elseif ($this->_gateway instanceof EE_Offsite_Gateway) {
659
-            return EE_PMT_Base::offsite;
660
-        } else {
661
-            throw new EE_Error(
662
-                sprintf(
663
-                    __(
664
-                        "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those",
665
-                        "event_espresso"
666
-                    ),
667
-                    get_class($this)
668
-                )
669
-            );
670
-        }
671
-    }
672
-
673
-
674
-    /**
675
-     * For adding any html output ab ove the payment overview.
676
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
677
-     * Other gateways may want to override this, such as offline gateways.
678
-     *
679
-     * @param EE_Payment $payment
680
-     * @return string
681
-     */
682
-    public function payment_overview_content(EE_Payment $payment)
683
-    {
684
-        return EEH_Template::display_template(
685
-            EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php',
686
-            array('payment_method' => $this->_pm_instance, 'payment' => $payment),
687
-            true
688
-        );
689
-    }
690
-
691
-
692
-    /**
693
-     * @return array where keys are the help tab name,
694
-     * values are: array {
695
-     * @type string $title         i18n name for the help tab
696
-     * @type string $filename      name of the file located in ./help_tabs/ (ie, in a folder next to this file)
697
-     * @type array  $template_args any arguments you want passed to the template file while rendering.
698
-     *                Keys will be variable names and values with be their values.
699
-     */
700
-    public function help_tabs_config()
701
-    {
702
-        return array();
703
-    }
704
-
705
-
706
-    /**
707
-     * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into
708
-     * the payment method's table's PMT_type column)
709
-     *
710
-     * @return string
711
-     */
712
-    public function system_name()
713
-    {
714
-        $classname = get_class($this);
715
-        return str_replace("EE_PMT_", '', $classname);
716
-    }
717
-
718
-
719
-    /**
720
-     * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding
721
-     * this method.
722
-     * @return string
723
-     */
724
-    public function defaultFrontendName()
725
-    {
726
-        return $this->pretty_name();
727
-    }
728
-
729
-
730
-    /**
731
-     * A pretty i18n version of the PMT name
732
-     *
733
-     * @return string
734
-     */
735
-    public function pretty_name()
736
-    {
737
-        return $this->_pretty_name;
738
-    }
739
-
740
-
741
-    /**
742
-     * Gets the default absolute URL to the payment method type's button
743
-     *
744
-     * @return string
745
-     */
746
-    public function default_button_url()
747
-    {
748
-        return $this->_default_button_url;
749
-    }
750
-
751
-
752
-    /**
753
-     * Gets the gateway used by this payment method (if any)
754
-     *
755
-     * @return EE_Gateway
756
-     */
757
-    public function get_gateway()
758
-    {
759
-        return $this->_gateway;
760
-    }
761
-
762
-
763
-    /**
764
-     * @return string html for the link to a help tab
765
-     */
766
-    public function get_help_tab_link()
767
-    {
768
-        return EEH_Template::get_help_tab_link(
769
-            $this->get_help_tab_name(),
770
-            'espresso_payment_settings',
771
-            'default'
772
-        );
773
-    }
774
-
775
-
776
-    /**
777
-     * Returns the name of the help tab for this PMT
778
-     *
779
-     * @return string
780
-     */
781
-    public function get_help_tab_name()
782
-    {
783
-        return 'ee_' . strtolower($this->system_name()) . '_help_tab';
784
-    }
785
-
786
-    /**
787
-     * The name of the wp capability that should be associated with the usage of
788
-     * this PMT by an admin
789
-     *
790
-     * @return string
791
-     */
792
-    public function cap_name()
793
-    {
794
-        return 'ee_payment_method_' . strtolower($this->system_name());
795
-    }
796
-
797
-    /**
798
-     * Called by client code to tell the gateway that if it wants to change
799
-     * the transaction or line items or registrations related to teh payment it already
800
-     * processed (we think, but possibly not) that now's the time to do it.
801
-     * It is expected that gateways will store any info they need for this on the PAY_details,
802
-     * or maybe an extra meta value
803
-     *
804
-     * @param EE_Payment $payment
805
-     * @return void
806
-     */
807
-    public function update_txn_based_on_payment($payment)
808
-    {
809
-        if ($this->_gateway instanceof EE_Gateway) {
810
-            $this->_gateway->update_txn_based_on_payment($payment);
811
-        }
812
-    }
813
-
814
-    /**
815
-     * Returns a string of HTML describing this payment method type for an admin,
816
-     * primarily intended for them to read before activating it.
817
-     * The easiest way to set this is to create a folder 'templates' alongside
818
-     * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php".
819
-     * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php",
820
-     * then you'd create a file named "templates" in the same folder as it, and name the file
821
-     * "foo_bar_intro.template.php", and its content will be returned by this method
822
-     *
823
-     * @return string
824
-     */
825
-    public function introductory_html()
826
-    {
827
-        return EEH_Template::locate_template(
828
-            $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php',
829
-            array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
830
-        );
831
-    }
24
+	const onsite = 'on-site';
25
+	const offsite = 'off-site';
26
+	const offline = 'off-line';
27
+
28
+	/**
29
+	 * @var EE_Payment_Method
30
+	 */
31
+	protected $_pm_instance = null;
32
+
33
+	/**
34
+	 * @var boolean
35
+	 */
36
+	protected $_requires_https = false;
37
+
38
+	/**
39
+	 * @var boolean
40
+	 */
41
+	protected $_has_billing_form;
42
+
43
+	/**
44
+	 * @var EE_Gateway
45
+	 */
46
+	protected $_gateway = null;
47
+
48
+	/**
49
+	 * @var EE_Payment_Method_Form
50
+	 */
51
+	protected $_settings_form = null;
52
+
53
+	/**
54
+	 * @var EE_Form_Section_Proper
55
+	 */
56
+	protected $_billing_form = null;
57
+
58
+	/**
59
+	 * @var boolean
60
+	 */
61
+	protected $_cache_billing_form = true;
62
+
63
+	/**
64
+	 * String of the absolute path to the folder containing this file, with a trailing slash.
65
+	 * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/'
66
+	 *
67
+	 * @var string
68
+	 */
69
+	protected $_file_folder = null;
70
+
71
+	/**
72
+	 * String to the absolute URL to this file (useful for getting its web-accessible resources
73
+	 * like images, js, or css)
74
+	 *
75
+	 * @var string
76
+	 */
77
+	protected $_file_url = null;
78
+
79
+	/**
80
+	 * Pretty name for the payment method
81
+	 *
82
+	 * @var string
83
+	 */
84
+	protected $_pretty_name = null;
85
+
86
+	/**
87
+	 *
88
+	 * @var string
89
+	 */
90
+	protected $_default_button_url = null;
91
+
92
+	/**
93
+	 *
94
+	 * @var string
95
+	 */
96
+	protected $_default_description = null;
97
+
98
+
99
+	/**
100
+	 *
101
+	 * @param EE_Payment_Method $pm_instance
102
+	 * @throws EE_Error
103
+	 * @return EE_PMT_Base
104
+	 */
105
+	public function __construct($pm_instance = null)
106
+	{
107
+		if ($pm_instance instanceof EE_Payment_Method) {
108
+			$this->set_instance($pm_instance);
109
+		}
110
+		if ($this->_gateway) {
111
+			$this->_gateway->set_payment_model(EEM_Payment::instance());
112
+			$this->_gateway->set_payment_log(EEM_Change_Log::instance());
113
+			$this->_gateway->set_template_helper(new EEH_Template());
114
+			$this->_gateway->set_line_item_helper(new EEH_Line_Item());
115
+			$this->_gateway->set_money_helper(new EEH_Money());
116
+			$this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter());
117
+			$this->_gateway->set_unsupported_character_remover(new AsciiOnly());
118
+			do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
119
+		}
120
+		if (! isset($this->_has_billing_form)) {
121
+			// by default, On Site gateways have a billing form
122
+			if ($this->payment_occurs() == EE_PMT_Base::onsite) {
123
+				$this->set_has_billing_form(true);
124
+			} else {
125
+				$this->set_has_billing_form(false);
126
+			}
127
+		}
128
+
129
+		if (! $this->_pretty_name) {
130
+			throw new EE_Error(
131
+				sprintf(
132
+					__(
133
+						"You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized",
134
+						"event_espresso"
135
+					)
136
+				)
137
+			);
138
+		}
139
+		// if the child didn't specify a default button, use the credit card one
140
+		if ($this->_default_button_url === null) {
141
+			$this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png';
142
+		}
143
+	}
144
+
145
+
146
+	/**
147
+	 * @param boolean $has_billing_form
148
+	 */
149
+	public function set_has_billing_form($has_billing_form)
150
+	{
151
+		$this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN);
152
+	}
153
+
154
+
155
+	/**
156
+	 * sets the file_folder property
157
+	 */
158
+	protected function _set_file_folder()
159
+	{
160
+		$reflector = new ReflectionClass(get_class($this));
161
+		$fn = $reflector->getFileName();
162
+		$this->_file_folder = dirname($fn) . '/';
163
+	}
164
+
165
+
166
+	/**
167
+	 * sets the file URL with a trailing slash for this PMT
168
+	 */
169
+	protected function _set_file_url()
170
+	{
171
+		$plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR);
172
+		$file_folder_fixed = str_replace('\\', '/', $this->file_folder());
173
+		$file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed);
174
+		$this->_file_url = set_url_scheme($file_path);
175
+	}
176
+
177
+	/**
178
+	 * Gets the default description on all payment methods of this type
179
+	 *
180
+	 * @return string
181
+	 */
182
+	public function default_description()
183
+	{
184
+		return $this->_default_description;
185
+	}
186
+
187
+
188
+	/**
189
+	 * Returns the folder containing the PMT child class, with a trailing slash
190
+	 *
191
+	 * @return string
192
+	 */
193
+	public function file_folder()
194
+	{
195
+		if (! $this->_file_folder) {
196
+			$this->_set_file_folder();
197
+		}
198
+		return $this->_file_folder;
199
+	}
200
+
201
+
202
+	/**
203
+	 * @return string
204
+	 */
205
+	public function file_url()
206
+	{
207
+		if (! $this->_file_url) {
208
+			$this->_set_file_url();
209
+		}
210
+		return $this->_file_url;
211
+	}
212
+
213
+
214
+	/**
215
+	 * Sets the payment method instance this payment method type is for.
216
+	 * Its important teh payment method instance is set before
217
+	 *
218
+	 * @param EE_Payment_Method $payment_method_instance
219
+	 */
220
+	public function set_instance($payment_method_instance)
221
+	{
222
+		$this->_pm_instance = $payment_method_instance;
223
+		// if they have already requested the settings form, make sure its
224
+		// data matches this model object
225
+		if ($this->_settings_form) {
226
+			$this->settings_form()->populate_model_obj($payment_method_instance);
227
+		}
228
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
229
+			$this->_gateway->set_settings($payment_method_instance->settings_array());
230
+		}
231
+	}
232
+
233
+
234
+	/**
235
+	 * Gets teh form for displaying to admins where they setup the payment method
236
+	 *
237
+	 * @return EE_Payment_Method_Form
238
+	 */
239
+	public function settings_form()
240
+	{
241
+		if (! $this->_settings_form) {
242
+			$this->_settings_form = $this->generate_new_settings_form();
243
+			$this->_settings_form->set_payment_method_type($this);
244
+			// if we have already assigned a model object to this pmt, make
245
+			// sure its reflected in teh form we just generated
246
+			if ($this->_pm_instance) {
247
+				$this->_settings_form->populate_model_obj($this->_pm_instance);
248
+			}
249
+		}
250
+		return $this->_settings_form;
251
+	}
252
+
253
+
254
+	/**
255
+	 * Gets the form for all the settings related to this payment method type
256
+	 *
257
+	 * @return EE_Payment_Method_Form
258
+	 */
259
+	abstract public function generate_new_settings_form();
260
+
261
+
262
+	/**
263
+	 * Sets the form for settings. This may be useful if we have already received
264
+	 * a form submission and have form data it in, and want to use it anytime we're showing
265
+	 * this payment method type's settings form later in the request
266
+	 *
267
+	 * @param EE_Payment_Method_Form $form
268
+	 */
269
+	public function set_settings_form($form)
270
+	{
271
+		$this->_settings_form = $form;
272
+	}
273
+
274
+
275
+	/**
276
+	 * @return boolean
277
+	 */
278
+	public function has_billing_form()
279
+	{
280
+		return $this->_has_billing_form;
281
+	}
282
+
283
+
284
+	/**
285
+	 * Gets the form for displaying to attendees where they can enter their billing info
286
+	 * which will be sent to teh gateway (can be null)
287
+	 *
288
+	 * @param \EE_Transaction $transaction
289
+	 * @param array           $extra_args
290
+	 * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null
291
+	 */
292
+	public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
293
+	{
294
+		// has billing form already been regenerated ? or overwrite cache?
295
+		if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
296
+			$this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
297
+		}
298
+		// if we know who the attendee is, and this is a billing form
299
+		// that uses attendee info, populate it
300
+		if (apply_filters(
301
+			'FHEE__populate_billing_form_fields_from_attendee',
302
+			($this->_billing_form instanceof EE_Billing_Attendee_Info_Form
303
+				&& $transaction instanceof EE_Transaction
304
+				&& $transaction->primary_registration() instanceof EE_Registration
305
+				&& $transaction->primary_registration()->attendee() instanceof EE_Attendee
306
+			),
307
+			$this->_billing_form,
308
+			$transaction
309
+		)) {
310
+			$this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee());
311
+		}
312
+		return $this->_billing_form;
313
+	}
314
+
315
+
316
+	/**
317
+	 * Creates the billing form for this payment method type
318
+	 *
319
+	 * @param \EE_Transaction $transaction
320
+	 * @return \EE_Billing_Info_Form
321
+	 */
322
+	abstract public function generate_new_billing_form(EE_Transaction $transaction = null);
323
+
324
+
325
+	/**
326
+	 * apply_billing_form_debug_settings
327
+	 * applies debug data to the form
328
+	 *
329
+	 * @param \EE_Billing_Info_Form $billing_form
330
+	 * @return \EE_Billing_Info_Form
331
+	 */
332
+	public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
333
+	{
334
+		return $billing_form;
335
+	}
336
+
337
+
338
+	/**
339
+	 * Sets the billing form for this payment method type. You may want to use this
340
+	 * if you have form
341
+	 *
342
+	 * @param EE_Payment_Method $form
343
+	 */
344
+	public function set_billing_form($form)
345
+	{
346
+		$this->_billing_form = $form;
347
+	}
348
+
349
+
350
+	/**
351
+	 * Returns whether or not this payment method requires HTTPS to be used
352
+	 *
353
+	 * @return boolean
354
+	 */
355
+	public function requires_https()
356
+	{
357
+		return $this->_requires_https;
358
+	}
359
+
360
+
361
+	/**
362
+	 *
363
+	 * @param EE_Transaction       $transaction
364
+	 * @param float                $amount
365
+	 * @param EE_Billing_Info_Form $billing_info
366
+	 * @param string               $return_url
367
+	 * @param string               $fail_url
368
+	 * @param string               $method
369
+	 * @param bool                 $by_admin
370
+	 * @return EE_Payment
371
+	 * @throws EE_Error
372
+	 */
373
+	public function process_payment(
374
+		EE_Transaction $transaction,
375
+		$amount = null,
376
+		$billing_info = null,
377
+		$return_url = null,
378
+		$fail_url = '',
379
+		$method = 'CART',
380
+		$by_admin = false
381
+	) {
382
+		// @todo: add surcharge for the payment method, if any
383
+		if ($this->_gateway) {
384
+			// there is a gateway, so we're going to make a payment object
385
+			// but wait! do they already have a payment in progress that we thought was failed?
386
+			$duplicate_properties = array(
387
+				'STS_ID'               => EEM_Payment::status_id_failed,
388
+				'TXN_ID'               => $transaction->ID(),
389
+				'PMD_ID'               => $this->_pm_instance->ID(),
390
+				'PAY_source'           => $method,
391
+				'PAY_amount'           => $amount !== null ? $amount : $transaction->remaining(),
392
+				'PAY_gateway_response' => null,
393
+			);
394
+			$payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
395
+			// if we didn't already have a payment in progress for the same thing,
396
+			// then we actually want to make a new payment
397
+			if (! $payment instanceof EE_Payment) {
398
+				$payment = EE_Payment::new_instance(
399
+					array_merge(
400
+						$duplicate_properties,
401
+						array(
402
+							'PAY_timestamp'       => time(),
403
+							'PAY_txn_id_chq_nmbr' => null,
404
+							'PAY_po_number'       => null,
405
+							'PAY_extra_accntng'   => null,
406
+							'PAY_details'         => null,
407
+						)
408
+					)
409
+				);
410
+			}
411
+			// make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it
412
+			$payment->save();
413
+			$billing_values = $this->_get_billing_values_from_form($billing_info);
414
+
415
+			//  Offsite Gateway
416
+			if ($this->_gateway instanceof EE_Offsite_Gateway) {
417
+				$payment = $this->_gateway->set_redirection_info(
418
+					$payment,
419
+					$billing_values,
420
+					$return_url,
421
+					EE_Config::instance()->core->txn_page_url(
422
+						array(
423
+							'e_reg_url_link'    => $transaction->primary_registration()->reg_url_link(),
424
+							'ee_payment_method' => $this->_pm_instance->slug(),
425
+						)
426
+					),
427
+					$fail_url
428
+				);
429
+				$payment->save();
430
+				//  Onsite Gateway
431
+			} elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
432
+				$payment = $this->_gateway->do_direct_payment($payment, $billing_values);
433
+				$payment->save();
434
+			} else {
435
+				throw new EE_Error(
436
+					sprintf(
437
+						__(
438
+							'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)',
439
+							'event_espresso'
440
+						),
441
+						get_class($this),
442
+						gettype($this->_gateway)
443
+					)
444
+				);
445
+			}
446
+		} else {
447
+			// no gateway provided
448
+			// there is no payment. Must be an offline gateway
449
+			// create a payment object anyways, but dont save it
450
+			$payment = EE_Payment::new_instance(
451
+				array(
452
+					'STS_ID'        => EEM_Payment::status_id_pending,
453
+					'TXN_ID'        => $transaction->ID(),
454
+					'PMD_ID'        => $transaction->payment_method_ID(),
455
+					'PAY_amount'    => 0.00,
456
+					'PAY_timestamp' => time(),
457
+				)
458
+			);
459
+		}
460
+
461
+		// if there is billing info, clean it and save it now
462
+		if ($billing_info instanceof EE_Billing_Attendee_Info_Form) {
463
+			$this->_save_billing_info_to_attendee($billing_info, $transaction);
464
+		}
465
+
466
+		return $payment;
467
+	}
468
+
469
+	/**
470
+	 * Gets the values we want to pass onto the gateway. Normally these
471
+	 * are just the 'pretty' values, but there may be times the data may need
472
+	 * a  little massaging. Proper subsections will become arrays of inputs
473
+	 *
474
+	 * @param EE_Billing_Info_Form $billing_form
475
+	 * @return array
476
+	 */
477
+	protected function _get_billing_values_from_form($billing_form)
478
+	{
479
+		if ($billing_form instanceof EE_Form_Section_Proper) {
480
+			return $billing_form->input_pretty_values(true);
481
+		} else {
482
+			return null;
483
+		}
484
+	}
485
+
486
+
487
+	/**
488
+	 * Handles an instant payment notification when the transaction is known (by default).
489
+	 *
490
+	 * @param array          $req_data
491
+	 * @param EE_Transaction $transaction
492
+	 * @return EE_Payment
493
+	 * @throws EE_Error
494
+	 */
495
+	public function handle_ipn($req_data, $transaction)
496
+	{
497
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
498
+		if (! $this->_gateway instanceof EE_Offsite_Gateway) {
499
+			throw new EE_Error(
500
+				sprintf(
501
+					__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
502
+					print_r($this->_gateway, true)
503
+				)
504
+			);
505
+		}
506
+		$payment = $this->_gateway->handle_payment_update($req_data, $transaction);
507
+		return $payment;
508
+	}
509
+
510
+
511
+	/**
512
+	 * Saves the billing info onto the attendee of the primary registrant on this transaction, and
513
+	 * cleans it first.
514
+	 *
515
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
516
+	 * @param EE_Transaction                $transaction
517
+	 * @return boolean success
518
+	 */
519
+	protected function _save_billing_info_to_attendee($billing_form, $transaction)
520
+	{
521
+		if (! $transaction || ! $transaction instanceof EE_Transaction) {
522
+			EE_Error::add_error(
523
+				__("Cannot save billing info because no transaction was specified", "event_espresso"),
524
+				__FILE__,
525
+				__FUNCTION__,
526
+				__LINE__
527
+			);
528
+			return false;
529
+		}
530
+		$primary_reg = $transaction->primary_registration();
531
+		if (! $primary_reg) {
532
+			EE_Error::add_error(
533
+				__("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
534
+				__FILE__,
535
+				__FUNCTION__,
536
+				__LINE__
537
+			);
538
+			return false;
539
+		}
540
+		$attendee = $primary_reg->attendee();
541
+		if (! $attendee) {
542
+			EE_Error::add_error(
543
+				__(
544
+					"Cannot save billing info because the transaction's primary registration has no attendee!",
545
+					"event_espresso"
546
+				),
547
+				__FILE__,
548
+				__FUNCTION__,
549
+				__LINE__
550
+			);
551
+			return false;
552
+		}
553
+		return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method());
554
+	}
555
+
556
+
557
+	/**
558
+	 * Gets the payment this IPN is for. Children may often want to
559
+	 * override this to inspect the request
560
+	 *
561
+	 * @param EE_Transaction $transaction
562
+	 * @param array          $req_data
563
+	 * @return EE_Payment
564
+	 */
565
+	protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array())
566
+	{
567
+		return $transaction->last_payment();
568
+	}
569
+
570
+
571
+	/**
572
+	 * In case generic code cannot provide the payment processor with a specific payment method
573
+	 * and transaction, it will try calling this method on each activate payment method.
574
+	 * If the payment method is able to identify the request as being for it, it should fetch
575
+	 * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot
576
+	 * handle the IPN
577
+	 *
578
+	 * @param array $req_data
579
+	 * @return EE_Payment only if this payment method can find the info its needs from $req_data
580
+	 * and identifies the IPN as being for this payment method (not just fo ra payment method of this type)
581
+	 * @throws EE_Error
582
+	 */
583
+	public function handle_unclaimed_ipn($req_data = array())
584
+	{
585
+		throw new EE_Error(
586
+			sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))
587
+		);
588
+	}
589
+
590
+
591
+	/**
592
+	 * Logic to be accomplished when the payment attempt is complete.
593
+	 * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
594
+	 * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
595
+	 * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
596
+	 * of the payment). Fed a transaction because it's always assumed to be the last payment that
597
+	 * we're dealing with. Returns that last payment (if there is one)
598
+	 *
599
+	 * @param EE_Transaction $transaction
600
+	 * @return EE_Payment
601
+	 */
602
+	public function finalize_payment_for($transaction)
603
+	{
604
+		return $transaction->last_payment();
605
+	}
606
+
607
+
608
+	/**
609
+	 * Whether or not this payment method's gateway supports sending refund requests
610
+	 *
611
+	 * @return boolean
612
+	 */
613
+	public function supports_sending_refunds()
614
+	{
615
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
616
+			return $this->_gateway->supports_sending_refunds();
617
+		} else {
618
+			return false;
619
+		}
620
+	}
621
+
622
+
623
+	/**
624
+	 *
625
+	 * @param EE_Payment $payment
626
+	 * @param array      $refund_info
627
+	 * @throws EE_Error
628
+	 * @return EE_Payment
629
+	 */
630
+	public function process_refund(EE_Payment $payment, $refund_info = array())
631
+	{
632
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
633
+			return $this->_gateway->do_direct_refund($payment, $refund_info);
634
+		} else {
635
+			throw new EE_Error(
636
+				sprintf(
637
+					__('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'),
638
+					get_class($this)
639
+				)
640
+			);
641
+		}
642
+	}
643
+
644
+
645
+	/**
646
+	 * Returns one the class's constants onsite,offsite, or offline, depending on this
647
+	 * payment method's gateway.
648
+	 *
649
+	 * @return string
650
+	 * @throws EE_Error
651
+	 */
652
+	public function payment_occurs()
653
+	{
654
+		if (! $this->_gateway) {
655
+			return EE_PMT_Base::offline;
656
+		} elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
657
+			return EE_PMT_Base::onsite;
658
+		} elseif ($this->_gateway instanceof EE_Offsite_Gateway) {
659
+			return EE_PMT_Base::offsite;
660
+		} else {
661
+			throw new EE_Error(
662
+				sprintf(
663
+					__(
664
+						"Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those",
665
+						"event_espresso"
666
+					),
667
+					get_class($this)
668
+				)
669
+			);
670
+		}
671
+	}
672
+
673
+
674
+	/**
675
+	 * For adding any html output ab ove the payment overview.
676
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
677
+	 * Other gateways may want to override this, such as offline gateways.
678
+	 *
679
+	 * @param EE_Payment $payment
680
+	 * @return string
681
+	 */
682
+	public function payment_overview_content(EE_Payment $payment)
683
+	{
684
+		return EEH_Template::display_template(
685
+			EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php',
686
+			array('payment_method' => $this->_pm_instance, 'payment' => $payment),
687
+			true
688
+		);
689
+	}
690
+
691
+
692
+	/**
693
+	 * @return array where keys are the help tab name,
694
+	 * values are: array {
695
+	 * @type string $title         i18n name for the help tab
696
+	 * @type string $filename      name of the file located in ./help_tabs/ (ie, in a folder next to this file)
697
+	 * @type array  $template_args any arguments you want passed to the template file while rendering.
698
+	 *                Keys will be variable names and values with be their values.
699
+	 */
700
+	public function help_tabs_config()
701
+	{
702
+		return array();
703
+	}
704
+
705
+
706
+	/**
707
+	 * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into
708
+	 * the payment method's table's PMT_type column)
709
+	 *
710
+	 * @return string
711
+	 */
712
+	public function system_name()
713
+	{
714
+		$classname = get_class($this);
715
+		return str_replace("EE_PMT_", '', $classname);
716
+	}
717
+
718
+
719
+	/**
720
+	 * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding
721
+	 * this method.
722
+	 * @return string
723
+	 */
724
+	public function defaultFrontendName()
725
+	{
726
+		return $this->pretty_name();
727
+	}
728
+
729
+
730
+	/**
731
+	 * A pretty i18n version of the PMT name
732
+	 *
733
+	 * @return string
734
+	 */
735
+	public function pretty_name()
736
+	{
737
+		return $this->_pretty_name;
738
+	}
739
+
740
+
741
+	/**
742
+	 * Gets the default absolute URL to the payment method type's button
743
+	 *
744
+	 * @return string
745
+	 */
746
+	public function default_button_url()
747
+	{
748
+		return $this->_default_button_url;
749
+	}
750
+
751
+
752
+	/**
753
+	 * Gets the gateway used by this payment method (if any)
754
+	 *
755
+	 * @return EE_Gateway
756
+	 */
757
+	public function get_gateway()
758
+	{
759
+		return $this->_gateway;
760
+	}
761
+
762
+
763
+	/**
764
+	 * @return string html for the link to a help tab
765
+	 */
766
+	public function get_help_tab_link()
767
+	{
768
+		return EEH_Template::get_help_tab_link(
769
+			$this->get_help_tab_name(),
770
+			'espresso_payment_settings',
771
+			'default'
772
+		);
773
+	}
774
+
775
+
776
+	/**
777
+	 * Returns the name of the help tab for this PMT
778
+	 *
779
+	 * @return string
780
+	 */
781
+	public function get_help_tab_name()
782
+	{
783
+		return 'ee_' . strtolower($this->system_name()) . '_help_tab';
784
+	}
785
+
786
+	/**
787
+	 * The name of the wp capability that should be associated with the usage of
788
+	 * this PMT by an admin
789
+	 *
790
+	 * @return string
791
+	 */
792
+	public function cap_name()
793
+	{
794
+		return 'ee_payment_method_' . strtolower($this->system_name());
795
+	}
796
+
797
+	/**
798
+	 * Called by client code to tell the gateway that if it wants to change
799
+	 * the transaction or line items or registrations related to teh payment it already
800
+	 * processed (we think, but possibly not) that now's the time to do it.
801
+	 * It is expected that gateways will store any info they need for this on the PAY_details,
802
+	 * or maybe an extra meta value
803
+	 *
804
+	 * @param EE_Payment $payment
805
+	 * @return void
806
+	 */
807
+	public function update_txn_based_on_payment($payment)
808
+	{
809
+		if ($this->_gateway instanceof EE_Gateway) {
810
+			$this->_gateway->update_txn_based_on_payment($payment);
811
+		}
812
+	}
813
+
814
+	/**
815
+	 * Returns a string of HTML describing this payment method type for an admin,
816
+	 * primarily intended for them to read before activating it.
817
+	 * The easiest way to set this is to create a folder 'templates' alongside
818
+	 * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php".
819
+	 * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php",
820
+	 * then you'd create a file named "templates" in the same folder as it, and name the file
821
+	 * "foo_bar_intro.template.php", and its content will be returned by this method
822
+	 *
823
+	 * @return string
824
+	 */
825
+	public function introductory_html()
826
+	{
827
+		return EEH_Template::locate_template(
828
+			$this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php',
829
+			array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
830
+		);
831
+	}
832 832
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             $this->_gateway->set_unsupported_character_remover(new AsciiOnly());
118 118
             do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
119 119
         }
120
-        if (! isset($this->_has_billing_form)) {
120
+        if ( ! isset($this->_has_billing_form)) {
121 121
             // by default, On Site gateways have a billing form
122 122
             if ($this->payment_occurs() == EE_PMT_Base::onsite) {
123 123
                 $this->set_has_billing_form(true);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             }
127 127
         }
128 128
 
129
-        if (! $this->_pretty_name) {
129
+        if ( ! $this->_pretty_name) {
130 130
             throw new EE_Error(
131 131
                 sprintf(
132 132
                     __(
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         }
139 139
         // if the child didn't specify a default button, use the credit card one
140 140
         if ($this->_default_button_url === null) {
141
-            $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png';
141
+            $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods/pay-by-credit-card.png';
142 142
         }
143 143
     }
144 144
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     {
160 160
         $reflector = new ReflectionClass(get_class($this));
161 161
         $fn = $reflector->getFileName();
162
-        $this->_file_folder = dirname($fn) . '/';
162
+        $this->_file_folder = dirname($fn).'/';
163 163
     }
164 164
 
165 165
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     public function file_folder()
194 194
     {
195
-        if (! $this->_file_folder) {
195
+        if ( ! $this->_file_folder) {
196 196
             $this->_set_file_folder();
197 197
         }
198 198
         return $this->_file_folder;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     public function file_url()
206 206
     {
207
-        if (! $this->_file_url) {
207
+        if ( ! $this->_file_url) {
208 208
             $this->_set_file_url();
209 209
         }
210 210
         return $this->_file_url;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      */
239 239
     public function settings_form()
240 240
     {
241
-        if (! $this->_settings_form) {
241
+        if ( ! $this->_settings_form) {
242 242
             $this->_settings_form = $this->generate_new_settings_form();
243 243
             $this->_settings_form->set_payment_method_type($this);
244 244
             // if we have already assigned a model object to this pmt, make
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
     public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
293 293
     {
294 294
         // has billing form already been regenerated ? or overwrite cache?
295
-        if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
295
+        if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
296 296
             $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
297 297
         }
298 298
         // if we know who the attendee is, and this is a billing form
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
             $payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
395 395
             // if we didn't already have a payment in progress for the same thing,
396 396
             // then we actually want to make a new payment
397
-            if (! $payment instanceof EE_Payment) {
397
+            if ( ! $payment instanceof EE_Payment) {
398 398
                 $payment = EE_Payment::new_instance(
399 399
                     array_merge(
400 400
                         $duplicate_properties,
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
     public function handle_ipn($req_data, $transaction)
496 496
     {
497 497
         $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
498
-        if (! $this->_gateway instanceof EE_Offsite_Gateway) {
498
+        if ( ! $this->_gateway instanceof EE_Offsite_Gateway) {
499 499
             throw new EE_Error(
500 500
                 sprintf(
501 501
                     __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
      */
519 519
     protected function _save_billing_info_to_attendee($billing_form, $transaction)
520 520
     {
521
-        if (! $transaction || ! $transaction instanceof EE_Transaction) {
521
+        if ( ! $transaction || ! $transaction instanceof EE_Transaction) {
522 522
             EE_Error::add_error(
523 523
                 __("Cannot save billing info because no transaction was specified", "event_espresso"),
524 524
                 __FILE__,
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
             return false;
529 529
         }
530 530
         $primary_reg = $transaction->primary_registration();
531
-        if (! $primary_reg) {
531
+        if ( ! $primary_reg) {
532 532
             EE_Error::add_error(
533 533
                 __("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
534 534
                 __FILE__,
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
             return false;
539 539
         }
540 540
         $attendee = $primary_reg->attendee();
541
-        if (! $attendee) {
541
+        if ( ! $attendee) {
542 542
             EE_Error::add_error(
543 543
                 __(
544 544
                     "Cannot save billing info because the transaction's primary registration has no attendee!",
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
      */
652 652
     public function payment_occurs()
653 653
     {
654
-        if (! $this->_gateway) {
654
+        if ( ! $this->_gateway) {
655 655
             return EE_PMT_Base::offline;
656 656
         } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
657 657
             return EE_PMT_Base::onsite;
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
     public function payment_overview_content(EE_Payment $payment)
683 683
     {
684 684
         return EEH_Template::display_template(
685
-            EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php',
685
+            EE_LIBRARIES.'payment_methods/templates/payment_details_content.template.php',
686 686
             array('payment_method' => $this->_pm_instance, 'payment' => $payment),
687 687
             true
688 688
         );
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
      */
781 781
     public function get_help_tab_name()
782 782
     {
783
-        return 'ee_' . strtolower($this->system_name()) . '_help_tab';
783
+        return 'ee_'.strtolower($this->system_name()).'_help_tab';
784 784
     }
785 785
 
786 786
     /**
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
      */
792 792
     public function cap_name()
793 793
     {
794
-        return 'ee_payment_method_' . strtolower($this->system_name());
794
+        return 'ee_payment_method_'.strtolower($this->system_name());
795 795
     }
796 796
 
797 797
     /**
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
     public function introductory_html()
826 826
     {
827 827
         return EEH_Template::locate_template(
828
-            $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php',
828
+            $this->file_folder().'templates/'.strtolower($this->system_name()).'_intro.template.php',
829 829
             array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
830 830
         );
831 831
     }
Please login to merge, or discard this patch.
registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php 1 patch
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -18,184 +18,184 @@
 block discarded – undo
18 18
  */
19 19
 class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper
20 20
 {
21
-    /**
22
-     *
23
-     * @var EE_Registration
24
-     */
25
-    protected $_registration = null;
21
+	/**
22
+	 *
23
+	 * @var EE_Registration
24
+	 */
25
+	protected $_registration = null;
26 26
 
27
-    /**
28
-     *
29
-     * @param EE_Registration $reg
30
-     * @param array $options
31
-     */
32
-    public function __construct(EE_Registration $reg, $options = array())
33
-    {
34
-        $this->_registration = $reg;
35
-        if (! isset($options['layout_strategy'])) {
36
-            $options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
37
-        }
38
-        if (! isset($options['html_id'])) {
39
-            $options['html_id'] = 'reg-admin-attendee-questions-frm';
40
-        }
41
-        $this->build_form_from_registration();
42
-        parent::__construct($options);
43
-    }
27
+	/**
28
+	 *
29
+	 * @param EE_Registration $reg
30
+	 * @param array $options
31
+	 */
32
+	public function __construct(EE_Registration $reg, $options = array())
33
+	{
34
+		$this->_registration = $reg;
35
+		if (! isset($options['layout_strategy'])) {
36
+			$options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
37
+		}
38
+		if (! isset($options['html_id'])) {
39
+			$options['html_id'] = 'reg-admin-attendee-questions-frm';
40
+		}
41
+		$this->build_form_from_registration();
42
+		parent::__construct($options);
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * Gets the registration object this form is about
48
-     * @return EE_Registration
49
-     */
50
-    public function get_registration()
51
-    {
52
-        return $this->_registration;
53
-    }
46
+	/**
47
+	 * Gets the registration object this form is about
48
+	 * @return EE_Registration
49
+	 */
50
+	public function get_registration()
51
+	{
52
+		return $this->_registration;
53
+	}
54 54
 
55
-    /**
56
-     * @since 4.10.0.p
57
-     * @throws EE_Error
58
-     * @throws InvalidArgumentException
59
-     * @throws ReflectionException
60
-     * @throws InvalidDataTypeException
61
-     * @throws InvalidInterfaceException
62
-     */
63
-    public function build_form_from_registration()
64
-    {
65
-        $reg = $this->get_registration();
66
-        if (! $reg instanceof EE_Registration) {
67
-            throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
68
-        }
69
-        // we want to get all their question groups
70
-        $question_groups = EEM_Question_Group::instance()->get_all(
71
-            [
72
-                [
73
-                    'Event_Question_Group.EVT_ID' => $reg->event_ID(),
74
-                    'OR' => [
75
-                        'Question.QST_system*blank' =>  '',
76
-                        'Question.QST_system*null' => ['IS_NULL']
77
-                    ],
78
-                    'Event_Question_Group.'
79
-                    . EEM_Event_Question_Group::instance()->fieldNameForContext(
80
-                        $reg->is_primary_registrant()
81
-                    ) => true
82
-                ],
83
-                'order_by' => ['QSG_order' => 'ASC']
84
-            ]
85
-        );
86
-        // get each question groups questions
87
-        foreach ($question_groups as $question_group) {
88
-            if ($question_group instanceof EE_Question_Group) {
89
-                $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
90
-                    $question_group,
91
-                    $reg
92
-                );
93
-            }
94
-        }
95
-    }
55
+	/**
56
+	 * @since 4.10.0.p
57
+	 * @throws EE_Error
58
+	 * @throws InvalidArgumentException
59
+	 * @throws ReflectionException
60
+	 * @throws InvalidDataTypeException
61
+	 * @throws InvalidInterfaceException
62
+	 */
63
+	public function build_form_from_registration()
64
+	{
65
+		$reg = $this->get_registration();
66
+		if (! $reg instanceof EE_Registration) {
67
+			throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
68
+		}
69
+		// we want to get all their question groups
70
+		$question_groups = EEM_Question_Group::instance()->get_all(
71
+			[
72
+				[
73
+					'Event_Question_Group.EVT_ID' => $reg->event_ID(),
74
+					'OR' => [
75
+						'Question.QST_system*blank' =>  '',
76
+						'Question.QST_system*null' => ['IS_NULL']
77
+					],
78
+					'Event_Question_Group.'
79
+					. EEM_Event_Question_Group::instance()->fieldNameForContext(
80
+						$reg->is_primary_registrant()
81
+					) => true
82
+				],
83
+				'order_by' => ['QSG_order' => 'ASC']
84
+			]
85
+		);
86
+		// get each question groups questions
87
+		foreach ($question_groups as $question_group) {
88
+			if ($question_group instanceof EE_Question_Group) {
89
+				$this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
90
+					$question_group,
91
+					$reg
92
+				);
93
+			}
94
+		}
95
+	}
96 96
 
97 97
 
98 98
 
99
-    /**
100
-     *
101
-     * @param EE_Question_Group $question_group
102
-     * @param EE_Registration   $registration
103
-     * @return \EE_Form_Section_Proper
104
-     * @throws \EE_Error
105
-     */
106
-    public function build_subform_from_question_group($question_group, $registration)
107
-    {
108
-        if (! $question_group instanceof EE_Question_Group ||
109
-            ! $registration instanceof EE_Registration) {
110
-            throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
111
-        }
112
-        $parts_of_subsection = array(
113
-            'title' => new EE_Form_Section_HTML(
114
-                EEH_HTML::h5(
115
-                    $question_group->name(),
116
-                    $question_group->identifier(),
117
-                    'espresso-question-group-title-h5 section-title'
118
-                )
119
-            )
120
-        );
121
-        $questions = $question_group->questions(
122
-            array(
123
-                array(
124
-                    'OR' => array(
125
-                        'QST_system*blank' => '',
126
-                        'QST_system*null' => array( 'IS_NULL' )
127
-                    )
128
-                )
129
-            )
130
-        );
131
-        foreach ($questions as $question) {
132
-            $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
133
-        }
134
-        if (EE_Registry::instance()->CAP->current_user_can(
135
-            'ee_edit_registration',
136
-            'edit-reg-questions-mbox',
137
-            $this->_registration->ID()
138
-        )) {
139
-            $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
140
-                EEH_HTML::table(
141
-                    EEH_HTML::tr(
142
-                        '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '">
99
+	/**
100
+	 *
101
+	 * @param EE_Question_Group $question_group
102
+	 * @param EE_Registration   $registration
103
+	 * @return \EE_Form_Section_Proper
104
+	 * @throws \EE_Error
105
+	 */
106
+	public function build_subform_from_question_group($question_group, $registration)
107
+	{
108
+		if (! $question_group instanceof EE_Question_Group ||
109
+			! $registration instanceof EE_Registration) {
110
+			throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
111
+		}
112
+		$parts_of_subsection = array(
113
+			'title' => new EE_Form_Section_HTML(
114
+				EEH_HTML::h5(
115
+					$question_group->name(),
116
+					$question_group->identifier(),
117
+					'espresso-question-group-title-h5 section-title'
118
+				)
119
+			)
120
+		);
121
+		$questions = $question_group->questions(
122
+			array(
123
+				array(
124
+					'OR' => array(
125
+						'QST_system*blank' => '',
126
+						'QST_system*null' => array( 'IS_NULL' )
127
+					)
128
+				)
129
+			)
130
+		);
131
+		foreach ($questions as $question) {
132
+			$parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
133
+		}
134
+		if (EE_Registry::instance()->CAP->current_user_can(
135
+			'ee_edit_registration',
136
+			'edit-reg-questions-mbox',
137
+			$this->_registration->ID()
138
+		)) {
139
+			$parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
140
+				EEH_HTML::table(
141
+					EEH_HTML::tr(
142
+						'<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '">
143 143
 		  			<span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso') . '</span>
144 144
 		  			<div class="dashicons dashicons-edit"></div>
145 145
 		  		</a></td>'
146
-                    ) .
147
-                    EEH_HTML::no_row('', 2)
148
-                )
149
-            );
150
-        }
151
-        return new EE_Form_Section_Proper(
152
-            array(
153
-                'subsections' => $parts_of_subsection,
154
-                'html_class' => 'question-group-questions',
155
-            )
156
-        );
157
-    }
146
+					) .
147
+					EEH_HTML::no_row('', 2)
148
+				)
149
+			);
150
+		}
151
+		return new EE_Form_Section_Proper(
152
+			array(
153
+				'subsections' => $parts_of_subsection,
154
+				'html_class' => 'question-group-questions',
155
+			)
156
+		);
157
+	}
158 158
 
159
-    /**
160
-     * Overrides parent so if inputs were disabled, we leave those with their defaults
161
-     * from the answers in the DB
162
-     * @param array $req_data like $_POST
163
-     * @return void
164
-     */
165
-    protected function _normalize($req_data)
166
-    {
167
-        $this->_received_submission = true;
168
-        $this->_validation_errors = array();
169
-        foreach ($this->get_validatable_subsections() as $subsection) {
170
-            if ($subsection->form_data_present_in($req_data)) {
171
-                try {
172
-                    $subsection->_normalize($req_data);
173
-                } catch (EE_Validation_Error $e) {
174
-                    $subsection->add_validation_error($e);
175
-                }
176
-            }
177
-        }
178
-    }
159
+	/**
160
+	 * Overrides parent so if inputs were disabled, we leave those with their defaults
161
+	 * from the answers in the DB
162
+	 * @param array $req_data like $_POST
163
+	 * @return void
164
+	 */
165
+	protected function _normalize($req_data)
166
+	{
167
+		$this->_received_submission = true;
168
+		$this->_validation_errors = array();
169
+		foreach ($this->get_validatable_subsections() as $subsection) {
170
+			if ($subsection->form_data_present_in($req_data)) {
171
+				try {
172
+					$subsection->_normalize($req_data);
173
+				} catch (EE_Validation_Error $e) {
174
+					$subsection->add_validation_error($e);
175
+				}
176
+			}
177
+		}
178
+	}
179 179
 
180 180
 
181 181
 
182
-    /**
183
-     * Performs validation on this form section and its subsections. For each subsection,
184
-     * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection.
185
-     * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method,
186
-     * calling parent::_validate() first.
187
-     */
188
-    protected function _validate()
189
-    {
190
-        foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
191
-            if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) {
192
-                if (method_exists($this, '_validate_'.$subsection_name)) {
193
-                    call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
194
-                }
195
-                $subsection->_validate();
196
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
197
-                $subsection->_received_submission = true;
198
-            }
199
-        }
200
-    }
182
+	/**
183
+	 * Performs validation on this form section and its subsections. For each subsection,
184
+	 * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection.
185
+	 * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method,
186
+	 * calling parent::_validate() first.
187
+	 */
188
+	protected function _validate()
189
+	{
190
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
191
+			if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) {
192
+				if (method_exists($this, '_validate_'.$subsection_name)) {
193
+					call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
194
+				}
195
+				$subsection->_validate();
196
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
197
+				$subsection->_received_submission = true;
198
+			}
199
+		}
200
+	}
201 201
 }
Please login to merge, or discard this patch.
admin_pages/about/templates/credits.template.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <p class="about-description">
2 2
     <?php esc_html_e(
3
-        'Event Espresso is created by an international team of passionate individuals with a drive to empower your events!',
4
-        'event_espresso'
5
-    ); ?></p>
3
+		'Event Espresso is created by an international team of passionate individuals with a drive to empower your events!',
4
+		'event_espresso'
5
+	); ?></p>
6 6
 <h3 class="wp-people-group"><?php esc_html_e('Founders', 'event_espresso'); ?></h3>
7 7
 <ul class="wp-people-group" id="ee-people-group-owners">
8 8
     <li class="wp-person" id="ee-person-sshoultes">
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 <h3 class="wp-people-group"><?php esc_html_e('Contributor Recognition', 'event_espresso'); ?></h3>
86 86
 <p class="description">
87 87
     <?php printf(
88
-        esc_html__(
89
-            'For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.',
90
-            'event_espresso'
91
-        ),
92
-        '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">',
93
-        '</a>'
94
-    ); ?>
88
+		esc_html__(
89
+			'For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.',
90
+			'event_espresso'
91
+		),
92
+		'<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">',
93
+		'</a>'
94
+	); ?>
95 95
 </p>
96 96
 <p class="wp-credits-list">
97 97
 <ul>
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 <h3 class="wp-people-group"><?php esc_html_e('External Libraries', 'event_espresso'); ?></h3>
107 107
 <p class="description">
108 108
     <?php printf(
109
-        esc_html__(
110
-            'Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:',
111
-            'event_espresso'
112
-        ),
113
-        '<a href="credits.php">',
114
-        '</a>'
115
-    ); ?>
109
+		esc_html__(
110
+			'Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:',
111
+			'event_espresso'
112
+		),
113
+		'<a href="credits.php">',
114
+		'</a>'
115
+	); ?>
116 116
 </p>
117 117
 <p class="wp-credits-list">
118 118
     <a href="https://openexchangerates.github.io/accounting.js/">accounting.js</a>,
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 <?php
130 130
 function esp_gravatar_profile($email)
131 131
 {
132
-    echo 'https://www.gravatar.com/' . md5($email);
132
+	echo 'https://www.gravatar.com/' . md5($email);
133 133
 }
134 134
 
135 135
 function esp_gravatar_image($email, $name)
136 136
 {
137
-    echo '<img src="https://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>';
137
+	echo '<img src="https://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>';
138 138
 }
139 139
 
140 140
 ?>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,12 +129,12 @@
 block discarded – undo
129 129
 <?php
130 130
 function esp_gravatar_profile($email)
131 131
 {
132
-    echo 'https://www.gravatar.com/' . md5($email);
132
+    echo 'https://www.gravatar.com/'.md5($email);
133 133
 }
134 134
 
135 135
 function esp_gravatar_image($email, $name)
136 136
 {
137
-    echo '<img src="https://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>';
137
+    echo '<img src="https://0.gravatar.com/avatar/'.md5($email).'?s=60" class="gravatar" alt="'.$name.'"/>';
138 138
 }
139 139
 
140 140
 ?>
Please login to merge, or discard this patch.
line_item_display/EE_Default_Line_Item_Display_Strategy.strategy.php 2 patches
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -1,225 +1,225 @@
 block discarded – undo
1 1
 <?php
2 2
  /**
3
- *
4
- * Class EE_Default_Line_Item_Display_Strategy
5
- *
6
- * Description
7
- *
8
- * @package         Event Espresso
9
- * @subpackage    core
10
- * @author              Brent Christensen
11
- *
12
- *
13
- */
3
+  *
4
+  * Class EE_Default_Line_Item_Display_Strategy
5
+  *
6
+  * Description
7
+  *
8
+  * @package         Event Espresso
9
+  * @subpackage    core
10
+  * @author              Brent Christensen
11
+  *
12
+  *
13
+  */
14 14
 
15 15
 class EE_Default_Line_Item_Display_Strategy implements EEI_Line_Item_Display
16 16
 {
17 17
 
18
-    /**
19
-     * total amount of tax to apply
20
-     * @type float $_tax_rate
21
-     */
22
-    private $_tax_rate = 0;
23
-
24
-    /**
25
-     * total amount including tax we can bill for at this time
26
-     * @type float $_grand_total
27
-     */
28
-    private $_grand_total = 0.00;
29
-
30
-    /**
31
-     * total number of items being billed for
32
-     * @type int $_total_items
33
-     */
34
-    private $_total_items = 0;
35
-
36
-
37
-
38
-    /**
39
-     * @return float
40
-     */
41
-    public function grand_total()
42
-    {
43
-        return $this->_grand_total;
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * @return int
50
-     */
51
-    public function total_items()
52
-    {
53
-        return $this->_total_items;
54
-    }
55
-
56
-
57
-
58
-    /**
59
-     * @param EE_Line_Item $line_item
60
-     * @param array        $options
61
-     * @return mixed
62
-     */
63
-    public function display_line_item(EE_Line_Item $line_item, $options = array())
64
-    {
65
-
66
-        $html = '';
67
-        // set some default options and merge with incoming
68
-        $default_options = array(
69
-            'show_desc' => true,  //    TRUE        FALSE
70
-            'odd' => false
71
-        );
72
-        $options = array_merge($default_options, (array) $options);
73
-
74
-        switch ($line_item->type()) {
75
-            case EEM_Line_Item::type_line_item:
76
-                // item row
77
-                $html .= $this->_item_row($line_item, $options);
78
-                // got any kids?
79
-                foreach ($line_item->children() as $child_line_item) {
80
-                    $this->display_line_item($child_line_item, $options);
81
-                }
82
-                break;
83
-
84
-            case EEM_Line_Item::type_sub_line_item:
85
-                $html .= $this->_sub_item_row($line_item, $options);
86
-                break;
87
-
88
-            case EEM_Line_Item::type_sub_total:
89
-                break;
90
-
91
-            case EEM_Line_Item::type_tax:
92
-                $this->_tax_rate += $line_item->percent();
93
-                break;
94
-
95
-            case EEM_Line_Item::type_tax_sub_total:
96
-                foreach ($line_item->children() as $child_line_item) {
97
-                    if ($child_line_item->type() == EEM_Line_Item::type_tax) {
98
-                        // recursively feed children back into this method
99
-                        $this->display_line_item($child_line_item, $options);
100
-                    }
101
-                }
102
-                break;
103
-
104
-            case EEM_Line_Item::type_total:
105
-                // get all child line items
106
-                $children = $line_item->children();
107
-                if ($options['set_tax_rate'] === true) {
108
-                    // loop thru tax child line items just to determine tax rate
109
-                    foreach ($children as $child_line_item) {
110
-                        if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) {
111
-                            // recursively feed children back into this method
112
-                            $this->display_line_item($child_line_item, $options);
113
-                        }
114
-                    }
115
-                } else {
116
-                    // now loop thru all non-tax child line items
117
-                    foreach ($children as $child_line_item) {
118
-                        if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) {
119
-                            // recursively feed children back into this method
120
-                            $html .= $this->display_line_item($child_line_item, $options);
121
-                        }
122
-                    }
123
-                }
124
-                break;
125
-        }
126
-
127
-        return $html;
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     *  _total_row
134
-     *
135
-     * @param EE_Line_Item $line_item
136
-     * @param array        $options
137
-     * @return mixed
138
-     */
139
-    private function _item_row(EE_Line_Item $line_item, $options = array())
140
-    {
141
-        // start of row
142
-        $row_class = $options['odd'] ? 'item odd' : 'item';
143
-        $html = EEH_HTML::tr('', '', $row_class);
144
-        // name && desc
145
-        $name_and_desc = apply_filters(
146
-            'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__name',
147
-            $line_item->name(),
148
-            $line_item
149
-        );
150
-        $name_and_desc .= apply_filters(
151
-            'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc',
152
-            ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ),
153
-            $line_item,
154
-            $options
155
-        );
156
-        if ($line_item->is_taxable()) {
157
-            $ticket_price_includes_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes
158
-                ? esc_html__('* price includes taxes', 'event_espresso')
159
-                : esc_html__('* price does not include taxes', 'event_espresso');
160
-            $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
161
-                  . $ticket_price_includes_taxes
162
-                  . '</span>';
163
-        }
164
-
165
-        // name td
166
-        $html .= EEH_HTML::td($name_and_desc, '', 'item_l');
167
-        // quantity td
168
-        $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
169
-        $tax_rate = $line_item->is_taxable()
170
-                    && EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes
171
-            ? 1 + ( $this->_tax_rate / 100 )
172
-            : 1;
173
-        // price td
174
-        $unit_price = apply_filters(
175
-            'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__unit_price',
176
-            EEH_Template::format_currency($line_item->unit_price() * $tax_rate, false, false),
177
-            $line_item,
178
-            $tax_rate
179
-        );
180
-        $html .= EEH_HTML::td($unit_price, '', 'item_c jst-rght');
181
-        // total td
182
-        $total = apply_filters(
183
-            'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__total',
184
-            EEH_Template::format_currency($line_item->unit_price() * $line_item->quantity() * $tax_rate, false, false),
185
-            $line_item,
186
-            $tax_rate
187
-        );
188
-        $html .= EEH_HTML::td($total, '', 'item_r jst-rght');
189
-        // end of row
190
-        $html .= EEH_HTML::trx();
191
-
192
-        return $html;
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     *  _sub_item_row
199
-     *
200
-     * @param EE_Line_Item $line_item
201
-     * @param array        $options
202
-     * @return mixed
203
-     */
204
-    private function _sub_item_row(EE_Line_Item $line_item, $options = array())
205
-    {
206
-        // start of row
207
-        $html = EEH_HTML::tr('', 'item sub-item-row');
208
-        // name && desc
209
-        $name_and_desc = $line_item->name();
210
-        $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '';
211
-        // name td
212
-        $html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item');
213
-        // discount/surcharge td
214
-        if ($line_item->is_percent()) {
215
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c');
216
-        } else {
217
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
218
-        }
219
-        // total td
220
-        $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght');
221
-        // end of row
222
-        $html .= EEH_HTML::trx();
223
-        return $html;
224
-    }
18
+	/**
19
+	 * total amount of tax to apply
20
+	 * @type float $_tax_rate
21
+	 */
22
+	private $_tax_rate = 0;
23
+
24
+	/**
25
+	 * total amount including tax we can bill for at this time
26
+	 * @type float $_grand_total
27
+	 */
28
+	private $_grand_total = 0.00;
29
+
30
+	/**
31
+	 * total number of items being billed for
32
+	 * @type int $_total_items
33
+	 */
34
+	private $_total_items = 0;
35
+
36
+
37
+
38
+	/**
39
+	 * @return float
40
+	 */
41
+	public function grand_total()
42
+	{
43
+		return $this->_grand_total;
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * @return int
50
+	 */
51
+	public function total_items()
52
+	{
53
+		return $this->_total_items;
54
+	}
55
+
56
+
57
+
58
+	/**
59
+	 * @param EE_Line_Item $line_item
60
+	 * @param array        $options
61
+	 * @return mixed
62
+	 */
63
+	public function display_line_item(EE_Line_Item $line_item, $options = array())
64
+	{
65
+
66
+		$html = '';
67
+		// set some default options and merge with incoming
68
+		$default_options = array(
69
+			'show_desc' => true,  //    TRUE        FALSE
70
+			'odd' => false
71
+		);
72
+		$options = array_merge($default_options, (array) $options);
73
+
74
+		switch ($line_item->type()) {
75
+			case EEM_Line_Item::type_line_item:
76
+				// item row
77
+				$html .= $this->_item_row($line_item, $options);
78
+				// got any kids?
79
+				foreach ($line_item->children() as $child_line_item) {
80
+					$this->display_line_item($child_line_item, $options);
81
+				}
82
+				break;
83
+
84
+			case EEM_Line_Item::type_sub_line_item:
85
+				$html .= $this->_sub_item_row($line_item, $options);
86
+				break;
87
+
88
+			case EEM_Line_Item::type_sub_total:
89
+				break;
90
+
91
+			case EEM_Line_Item::type_tax:
92
+				$this->_tax_rate += $line_item->percent();
93
+				break;
94
+
95
+			case EEM_Line_Item::type_tax_sub_total:
96
+				foreach ($line_item->children() as $child_line_item) {
97
+					if ($child_line_item->type() == EEM_Line_Item::type_tax) {
98
+						// recursively feed children back into this method
99
+						$this->display_line_item($child_line_item, $options);
100
+					}
101
+				}
102
+				break;
103
+
104
+			case EEM_Line_Item::type_total:
105
+				// get all child line items
106
+				$children = $line_item->children();
107
+				if ($options['set_tax_rate'] === true) {
108
+					// loop thru tax child line items just to determine tax rate
109
+					foreach ($children as $child_line_item) {
110
+						if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) {
111
+							// recursively feed children back into this method
112
+							$this->display_line_item($child_line_item, $options);
113
+						}
114
+					}
115
+				} else {
116
+					// now loop thru all non-tax child line items
117
+					foreach ($children as $child_line_item) {
118
+						if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) {
119
+							// recursively feed children back into this method
120
+							$html .= $this->display_line_item($child_line_item, $options);
121
+						}
122
+					}
123
+				}
124
+				break;
125
+		}
126
+
127
+		return $html;
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 *  _total_row
134
+	 *
135
+	 * @param EE_Line_Item $line_item
136
+	 * @param array        $options
137
+	 * @return mixed
138
+	 */
139
+	private function _item_row(EE_Line_Item $line_item, $options = array())
140
+	{
141
+		// start of row
142
+		$row_class = $options['odd'] ? 'item odd' : 'item';
143
+		$html = EEH_HTML::tr('', '', $row_class);
144
+		// name && desc
145
+		$name_and_desc = apply_filters(
146
+			'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__name',
147
+			$line_item->name(),
148
+			$line_item
149
+		);
150
+		$name_and_desc .= apply_filters(
151
+			'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc',
152
+			( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ),
153
+			$line_item,
154
+			$options
155
+		);
156
+		if ($line_item->is_taxable()) {
157
+			$ticket_price_includes_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes
158
+				? esc_html__('* price includes taxes', 'event_espresso')
159
+				: esc_html__('* price does not include taxes', 'event_espresso');
160
+			$name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
161
+				  . $ticket_price_includes_taxes
162
+				  . '</span>';
163
+		}
164
+
165
+		// name td
166
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l');
167
+		// quantity td
168
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
169
+		$tax_rate = $line_item->is_taxable()
170
+					&& EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes
171
+			? 1 + ( $this->_tax_rate / 100 )
172
+			: 1;
173
+		// price td
174
+		$unit_price = apply_filters(
175
+			'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__unit_price',
176
+			EEH_Template::format_currency($line_item->unit_price() * $tax_rate, false, false),
177
+			$line_item,
178
+			$tax_rate
179
+		);
180
+		$html .= EEH_HTML::td($unit_price, '', 'item_c jst-rght');
181
+		// total td
182
+		$total = apply_filters(
183
+			'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__total',
184
+			EEH_Template::format_currency($line_item->unit_price() * $line_item->quantity() * $tax_rate, false, false),
185
+			$line_item,
186
+			$tax_rate
187
+		);
188
+		$html .= EEH_HTML::td($total, '', 'item_r jst-rght');
189
+		// end of row
190
+		$html .= EEH_HTML::trx();
191
+
192
+		return $html;
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 *  _sub_item_row
199
+	 *
200
+	 * @param EE_Line_Item $line_item
201
+	 * @param array        $options
202
+	 * @return mixed
203
+	 */
204
+	private function _sub_item_row(EE_Line_Item $line_item, $options = array())
205
+	{
206
+		// start of row
207
+		$html = EEH_HTML::tr('', 'item sub-item-row');
208
+		// name && desc
209
+		$name_and_desc = $line_item->name();
210
+		$name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '';
211
+		// name td
212
+		$html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item');
213
+		// discount/surcharge td
214
+		if ($line_item->is_percent()) {
215
+			$html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c');
216
+		} else {
217
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
218
+		}
219
+		// total td
220
+		$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght');
221
+		// end of row
222
+		$html .= EEH_HTML::trx();
223
+		return $html;
224
+	}
225 225
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $html = '';
67 67
         // set some default options and merge with incoming
68 68
         $default_options = array(
69
-            'show_desc' => true,  //    TRUE        FALSE
69
+            'show_desc' => true, //    TRUE        FALSE
70 70
             'odd' => false
71 71
         );
72 72
         $options = array_merge($default_options, (array) $options);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         );
150 150
         $name_and_desc .= apply_filters(
151 151
             'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc',
152
-            ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ),
152
+            ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''),
153 153
             $line_item,
154 154
             $options
155 155
         );
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
169 169
         $tax_rate = $line_item->is_taxable()
170 170
                     && EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes
171
-            ? 1 + ( $this->_tax_rate / 100 )
171
+            ? 1 + ($this->_tax_rate / 100)
172 172
             : 1;
173 173
         // price td
174 174
         $unit_price = apply_filters(
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
         $html = EEH_HTML::tr('', 'item sub-item-row');
208 208
         // name && desc
209 209
         $name_and_desc = $line_item->name();
210
-        $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '';
210
+        $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : '';
211 211
         // name td
212 212
         $html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item');
213 213
         // discount/surcharge td
214 214
         if ($line_item->is_percent()) {
215
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c');
215
+            $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c');
216 216
         } else {
217 217
             $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
218 218
         }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_CPT.core.php 2 patches
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
             $this->_cpt_routes
170 170
         );
171 171
         // let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
172
-        $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[ $this->_req_data['action'] ])
173
-            ? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
172
+        $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']])
173
+            ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']])
174 174
             : get_post_type_object($page);
175 175
         // tweak pagenow for page loading.
176
-        if (! $this->_pagenow_map) {
176
+        if ( ! $this->_pagenow_map) {
177 177
             $this->_pagenow_map = array(
178 178
                 'create_new' => 'post-new.php',
179 179
                 'edit'       => 'post.php',
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
     {
208 208
         global $pagenow, $hook_suffix;
209 209
         // possibly reset pagenow.
210
-        if (! empty($this->_req_data['page'])
210
+        if ( ! empty($this->_req_data['page'])
211 211
             && $this->_req_data['page'] == $this->page_slug
212 212
             && ! empty($this->_req_data['action'])
213
-            && isset($this->_pagenow_map[ $this->_req_data['action'] ])
213
+            && isset($this->_pagenow_map[$this->_req_data['action']])
214 214
         ) {
215
-            $pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
215
+            $pagenow = $this->_pagenow_map[$this->_req_data['action']];
216 216
             $hook_suffix = $pagenow;
217 217
         }
218 218
     }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         if (empty($wp_meta_boxes)) {
245 245
             return;
246 246
         }
247
-        $current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
247
+        $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array();
248 248
         foreach ($current_metaboxes as $box_context) {
249 249
             foreach ($box_context as $box_details) {
250 250
                 foreach ($box_details as $box) {
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
             $this
278 278
         );
279 279
         $containers = apply_filters(
280
-            'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
280
+            'FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers',
281 281
             $containers,
282 282
             $this
283 283
         );
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     protected function _load_page_dependencies()
322 322
     {
323 323
         // we only add stuff if this is a cpt_route!
324
-        if (! $this->_cpt_route) {
324
+        if ( ! $this->_cpt_route) {
325 325
             parent::_load_page_dependencies();
326 326
             return;
327 327
         }
@@ -345,16 +345,16 @@  discard block
 block discarded – undo
345 345
         add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
346 346
         // This basically allows us to change the title of the "publish" metabox area
347 347
         // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
348
-        if (! empty($this->_labels['publishbox'])) {
348
+        if ( ! empty($this->_labels['publishbox'])) {
349 349
             $box_label = is_array($this->_labels['publishbox'])
350
-                         && isset($this->_labels['publishbox'][ $this->_req_action ])
351
-                ? $this->_labels['publishbox'][ $this->_req_action ]
350
+                         && isset($this->_labels['publishbox'][$this->_req_action])
351
+                ? $this->_labels['publishbox'][$this->_req_action]
352 352
                 : $this->_labels['publishbox'];
353 353
             add_meta_box(
354 354
                 'submitdiv',
355 355
                 $box_label,
356 356
                 'post_submit_meta_box',
357
-                $this->_cpt_routes[ $this->_req_action ],
357
+                $this->_cpt_routes[$this->_req_action],
358 358
                 'side',
359 359
                 'core'
360 360
             );
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                 'page_templates',
366 366
                 __('Page Template', 'event_espresso'),
367 367
                 array($this, 'page_template_meta_box'),
368
-                $this->_cpt_routes[ $this->_req_action ],
368
+                $this->_cpt_routes[$this->_req_action],
369 369
                 'side',
370 370
                 'default'
371 371
             );
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
         // This is for any plugins that are doing things properly
398 398
         // and hooking into the load page hook for core wp cpt routes.
399 399
         global $pagenow;
400
-        add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
401
-        do_action('load-' . $pagenow);
400
+        add_action('load-'.$pagenow, array($this, 'modify_current_screen'), 20);
401
+        do_action('load-'.$pagenow);
402 402
         add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
403 403
         // we route REALLY early.
404 404
         try {
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
                 'admin.php?page=espresso_registrations&action=contact_list',
428 428
             ),
429 429
             1 => array(
430
-                'edit.php?post_type=' . $this->_cpt_object->name,
431
-                'admin.php?page=' . $this->_cpt_object->name,
430
+                'edit.php?post_type='.$this->_cpt_object->name,
431
+                'admin.php?page='.$this->_cpt_object->name,
432 432
             ),
433 433
         );
434 434
         foreach ($routes_to_match as $route_matches) {
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
458 458
         );
459 459
         $cpt_args = $custom_post_types->getDefinitions();
460
-        $cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
460
+        $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array();
461 461
         $cpt_has_support = ! empty($cpt_args['page_templates']);
462 462
 
463 463
         // if the installed version of WP is > 4.7 we do some additional checks.
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             // if there are $post_templates for this cpt, then we return false for this method because
467 467
             // that means we aren't going to load our page template manager and leave that up to the native
468 468
             // cpt template manager.
469
-            $cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
469
+            $cpt_has_support = ! isset($post_templates[$cpt_name]) ? $cpt_has_support : false;
470 470
         }
471 471
 
472 472
         return $cpt_has_support;
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 
541 541
         $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
542 542
         $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
543
-            ? $statuses[ $this->_cpt_model_obj->status() ]
543
+            ? $statuses[$this->_cpt_model_obj->status()]
544 544
             : '';
545 545
         $template_args = array(
546 546
             'cur_status'            => $this->_cpt_model_obj->status(),
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
             $template_args['statuses'] = $statuses;
556 556
         }
557 557
 
558
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
558
+        $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php';
559 559
         EEH_Template::display_template($template, $template_args);
560 560
     }
561 561
 
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
             : null;
597 597
         $this->_verify_nonce($nonce, 'autosave');
598 598
         // make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
599
-        if (! defined('DOING_AUTOSAVE')) {
599
+        if ( ! defined('DOING_AUTOSAVE')) {
600 600
             define('DOING_AUTOSAVE', true);
601 601
         }
602 602
         // if we made it here then the nonce checked out.  Let's run our methods and actions
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
             $this->_template_args['success'] = true;
608 608
         }
609 609
         do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
610
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
610
+        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this);
611 611
         // now let's return json
612 612
         $this->_return_json();
613 613
     }
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
             return;
630 630
         }
631 631
         // set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
632
-        if (! empty($this->_cpt_object)) {
632
+        if ( ! empty($this->_cpt_object)) {
633 633
             $this->_page_routes = array_merge(
634 634
                 array(
635 635
                     'create_new' => '_create_new_cpt_item',
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
             );
661 661
         }
662 662
         // load the next section only if this is a matching cpt route as set in the cpt routes array.
663
-        if (! isset($this->_cpt_routes[ $this->_req_action ])) {
663
+        if ( ! isset($this->_cpt_routes[$this->_req_action])) {
664 664
             return;
665 665
         }
666
-        $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
666
+        $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? true : false;
667 667
         // add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
668 668
         if (empty($this->_cpt_object)) {
669 669
             $msg = sprintf(
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
         if (empty($this->_cpt_model_names)
704 704
             || (
705 705
                 ! $ignore_route_check
706
-                && ! isset($this->_cpt_routes[ $this->_req_action ])
706
+                && ! isset($this->_cpt_routes[$this->_req_action])
707 707
             ) || (
708 708
                 $this->_cpt_model_obj instanceof EE_CPT_Base
709 709
                 && $this->_cpt_model_obj->ID() === $id
@@ -720,11 +720,11 @@  discard block
 block discarded – undo
720 720
                 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
721 721
             );
722 722
             $model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
723
-            if (isset($model_names[ $post_type ])) {
724
-                $model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
723
+            if (isset($model_names[$post_type])) {
724
+                $model = EE_Registry::instance()->load_model($model_names[$post_type]);
725 725
             }
726 726
         } else {
727
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
727
+            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]);
728 728
         }
729 729
         if ($model instanceof EEM_Base) {
730 730
             $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
@@ -754,8 +754,8 @@  discard block
 block discarded – undo
754 754
         $current_route = isset($this->_req_data['current_route'])
755 755
             ? $this->_req_data['current_route']
756 756
             : 'shouldneverwork';
757
-        $route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
758
-            ? $this->_cpt_routes[ $current_route ]
757
+        $route_to_check = $post_type && isset($this->_cpt_routes[$current_route])
758
+            ? $this->_cpt_routes[$current_route]
759 759
             : '';
760 760
         add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
761 761
         add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
@@ -764,10 +764,10 @@  discard block
 block discarded – undo
764 764
         }
765 765
         // now let's filter redirect if we're on a revision page and the revision is for an event CPT.
766 766
         $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
767
-        if (! empty($revision)) {
767
+        if ( ! empty($revision)) {
768 768
             $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
769 769
             // doing a restore?
770
-            if (! empty($action) && $action === 'restore') {
770
+            if ( ! empty($action) && $action === 'restore') {
771 771
                 // get post for revision
772 772
                 $rev_post = get_post($revision);
773 773
                 $rev_parent = get_post($rev_post->post_parent);
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
     {
804 804
         $this->_set_model_object($post_id, true, 'trash');
805 805
         // if our cpt object isn't existent then get out immediately.
806
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
806
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
807 807
             return;
808 808
         }
809 809
         $this->trash_cpt_item($post_id);
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
     {
822 822
         $this->_set_model_object($post_id, true, 'restore');
823 823
         // if our cpt object isn't existent then get out immediately.
824
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
824
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
825 825
             return;
826 826
         }
827 827
         $this->restore_cpt_item($post_id);
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
     {
840 840
         $this->_set_model_object($post_id, true, 'delete');
841 841
         // if our cpt object isn't existent then get out immediately.
842
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
842
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
843 843
             return;
844 844
         }
845 845
         $this->delete_cpt_item($post_id);
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
     {
859 859
         $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
860 860
         // verify event object
861
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
861
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
862 862
             throw new EE_Error(
863 863
                 sprintf(
864 864
                     __(
@@ -914,13 +914,13 @@  discard block
 block discarded – undo
914 914
         if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
915 915
             // setup custom post status object for localize script but only if we've got a cpt object
916 916
             $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
917
-            if (! empty($statuses)) {
917
+            if ( ! empty($statuses)) {
918 918
                 // get ALL statuses!
919 919
                 $statuses = $this->_cpt_model_obj->get_all_post_statuses();
920 920
                 // setup object
921 921
                 $ee_cpt_statuses = array();
922 922
                 foreach ($statuses as $status => $label) {
923
-                    $ee_cpt_statuses[ $status ] = array(
923
+                    $ee_cpt_statuses[$status] = array(
924 924
                         'label'      => $label,
925 925
                         'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
926 926
                     );
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
                 $post->page_template = $this->_req_data['page_template'];
983 983
                 $page_templates = wp_get_theme()->get_page_templates($post);
984 984
             }
985
-            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
985
+            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) {
986 986
                 EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
987 987
             } else {
988 988
                 update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
     {
1008 1008
         // only do this if we're actually processing one of our CPTs
1009 1009
         // if our cpt object isn't existent then get out immediately.
1010
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1010
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1011 1011
             return;
1012 1012
         }
1013 1013
         delete_post_meta($post_id, '_wp_trash_meta_status');
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
         // global action
1033 1033
         do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1034 1034
         // class specific action so you can limit hooking into a specific page.
1035
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1035
+        do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id);
1036 1036
     }
1037 1037
 
1038 1038
 
@@ -1059,11 +1059,11 @@  discard block
 block discarded – undo
1059 1059
     public function modify_current_screen()
1060 1060
     {
1061 1061
         // ONLY do this if the current page_route IS a cpt route
1062
-        if (! $this->_cpt_route) {
1062
+        if ( ! $this->_cpt_route) {
1063 1063
             return;
1064 1064
         }
1065 1065
         // routing things REALLY early b/c this is a cpt admin page
1066
-        set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1066
+        set_current_screen($this->_cpt_routes[$this->_req_action]);
1067 1067
         $this->_current_screen = get_current_screen();
1068 1068
         $this->_current_screen->base = 'event-espresso';
1069 1069
         $this->_add_help_tabs(); // we make sure we add any help tabs back in!
@@ -1086,8 +1086,8 @@  discard block
 block discarded – undo
1086 1086
      */
1087 1087
     public function add_custom_editor_default_title($title)
1088 1088
     {
1089
-        return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1090
-            ? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1089
+        return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]])
1090
+            ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]
1091 1091
             : $title;
1092 1092
     }
1093 1093
 
@@ -1103,10 +1103,10 @@  discard block
 block discarded – undo
1103 1103
      */
1104 1104
     public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1105 1105
     {
1106
-        if (! empty($id) && get_option('permalink_structure') !== '') {
1106
+        if ( ! empty($id) && get_option('permalink_structure') !== '') {
1107 1107
             $post = get_post($id);
1108 1108
             if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1109
-                $shortlink = home_url('?p=' . $post->ID);
1109
+                $shortlink = home_url('?p='.$post->ID);
1110 1110
             }
1111 1111
         }
1112 1112
         return $shortlink;
@@ -1139,11 +1139,11 @@  discard block
 block discarded – undo
1139 1139
      */
1140 1140
     public function cpt_post_form_hidden_input()
1141 1141
     {
1142
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1142
+        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />';
1143 1143
         // we're also going to add the route value and the current page so we can direct autosave parsing correctly
1144 1144
         echo '<div id="ee-cpt-hidden-inputs">';
1145
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1146
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1145
+        echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />';
1146
+        echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />';
1147 1147
         echo '</div>';
1148 1148
     }
1149 1149
 
@@ -1188,15 +1188,15 @@  discard block
 block discarded – undo
1188 1188
     public function modify_edit_post_link($link, $id, $context)
1189 1189
     {
1190 1190
         $post = get_post($id);
1191
-        if (! isset($this->_req_data['action'])
1192
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1193
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1191
+        if ( ! isset($this->_req_data['action'])
1192
+            || ! isset($this->_cpt_routes[$this->_req_data['action']])
1193
+            || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1194 1194
         ) {
1195 1195
             return $link;
1196 1196
         }
1197 1197
         $query_args = array(
1198
-            'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1199
-                ? $this->_cpt_edit_routes[ $post->post_type ]
1198
+            'action' => isset($this->_cpt_edit_routes[$post->post_type])
1199
+                ? $this->_cpt_edit_routes[$post->post_type]
1200 1200
                 : 'edit',
1201 1201
             'post'   => $id,
1202 1202
         );
@@ -1219,16 +1219,16 @@  discard block
 block discarded – undo
1219 1219
         $post = get_post($post_id);
1220 1220
 
1221 1221
         if (empty($this->_req_data['action'])
1222
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1222
+            || ! isset($this->_cpt_routes[$this->_req_data['action']])
1223 1223
             || ! $post instanceof WP_Post
1224
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1224
+            || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1225 1225
         ) {
1226 1226
             return $delete_link;
1227 1227
         }
1228 1228
         $this->_set_model_object($post->ID, true);
1229 1229
 
1230 1230
         // returns something like `trash_event` or `trash_attendee` or `trash_venue`
1231
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1231
+        $action = 'trash_'.str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1232 1232
 
1233 1233
         return EE_Admin_Page::add_query_args_and_nonce(
1234 1234
             array(
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
         // we DO have a match so let's setup the url
1257 1257
         // we have to get the post to determine our route
1258 1258
         $post = get_post($post_id);
1259
-        $edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1259
+        $edit_route = $this->_cpt_edit_routes[$post->post_type];
1260 1260
         // shared query_args
1261 1261
         $query_args = array('action' => $edit_route, 'post' => $post_id);
1262 1262
         $admin_url = $this->_admin_base_url;
@@ -1328,12 +1328,12 @@  discard block
 block discarded – undo
1328 1328
         /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1329 1329
 
1330 1330
         $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : '';/**/
1331
-        $messages[ $post->post_type ] = array(
1331
+        $messages[$post->post_type] = array(
1332 1332
             0  => '', // Unused. Messages start at index 1.
1333 1333
             1  => sprintf(
1334 1334
                 __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1335 1335
                 $this->_cpt_object->labels->singular_name,
1336
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1336
+                '<a href="'.esc_url(get_permalink($id)).'">',
1337 1337
                 '</a>'
1338 1338
             ),
1339 1339
             2  => __('Custom field updated', 'event_espresso'),
@@ -1348,27 +1348,27 @@  discard block
 block discarded – undo
1348 1348
             6  => sprintf(
1349 1349
                 __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1350 1350
                 $this->_cpt_object->labels->singular_name,
1351
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1351
+                '<a href="'.esc_url(get_permalink($id)).'">',
1352 1352
                 '</a>'
1353 1353
             ),
1354 1354
             7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1355 1355
             8  => sprintf(
1356 1356
                 __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1357 1357
                 $this->_cpt_object->labels->singular_name,
1358
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1358
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">',
1359 1359
                 '</a>'
1360 1360
             ),
1361 1361
             9  => sprintf(
1362 1362
                 __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1363 1363
                 $this->_cpt_object->labels->singular_name,
1364
-                '<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1365
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1364
+                '<strong>'.date_i18n('M j, Y @ G:i', strtotime($post->post_date)).'</strong>',
1365
+                '<a target="_blank" href="'.esc_url(get_permalink($id)),
1366 1366
                 '</a>'
1367 1367
             ),
1368 1368
             10 => sprintf(
1369 1369
                 __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1370 1370
                 $this->_cpt_object->labels->singular_name,
1371
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1371
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1372 1372
                 '</a>'
1373 1373
             ),
1374 1374
         );
@@ -1387,10 +1387,10 @@  discard block
 block discarded – undo
1387 1387
     {
1388 1388
         // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1389 1389
         global $post, $title, $is_IE, $post_type, $post_type_object;
1390
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1390
+        $post_type = $this->_cpt_routes[$this->_req_action];
1391 1391
         $post_type_object = $this->_cpt_object;
1392 1392
         $title = $post_type_object->labels->add_new_item;
1393
-        $post = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1393
+        $post = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true);
1394 1394
         add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1395 1395
         // modify the default editor title field with default title.
1396 1396
         add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
@@ -1415,8 +1415,8 @@  discard block
 block discarded – undo
1415 1415
             if ($creating) {
1416 1416
                 wp_enqueue_script('autosave');
1417 1417
             } else {
1418
-                if (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1419
-                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1418
+                if (isset($this->_cpt_routes[$this->_req_data['action']])
1419
+                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])
1420 1420
                 ) {
1421 1421
                     $create_new_action = apply_filters(
1422 1422
                         'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
@@ -1432,7 +1432,7 @@  discard block
 block discarded – undo
1432 1432
                     );
1433 1433
                 }
1434 1434
             }
1435
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1435
+            include_once WP_ADMIN_PATH.'edit-form-advanced.php';
1436 1436
         }
1437 1437
     }
1438 1438
 
@@ -1463,21 +1463,21 @@  discard block
 block discarded – undo
1463 1463
         if (empty($post)) {
1464 1464
             wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1465 1465
         }
1466
-        if (! empty($_GET['get-post-lock'])) {
1466
+        if ( ! empty($_GET['get-post-lock'])) {
1467 1467
             wp_set_post_lock($post_id);
1468 1468
             wp_redirect(get_edit_post_link($post_id, 'url'));
1469 1469
             exit();
1470 1470
         }
1471 1471
 
1472 1472
         // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1473
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1473
+        $post_type = $this->_cpt_routes[$this->_req_action];
1474 1474
         $post_type_object = $this->_cpt_object;
1475 1475
 
1476
-        if (! wp_check_post_lock($post->ID)) {
1476
+        if ( ! wp_check_post_lock($post->ID)) {
1477 1477
             wp_set_post_lock($post->ID);
1478 1478
         }
1479 1479
         add_action('admin_footer', '_admin_notice_post_locked');
1480
-        if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1480
+        if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) {
1481 1481
             wp_enqueue_script('admin-comments');
1482 1482
             enqueue_comment_hotkeys_js();
1483 1483
         }
Please login to merge, or discard this patch.
Indentation   +1485 added lines, -1485 removed lines patch added patch discarded remove patch
@@ -28,474 +28,474 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    /**
32
-     * This gets set in _setup_cpt
33
-     * It will contain the object for the custom post type.
34
-     *
35
-     * @var EE_CPT_Base
36
-     */
37
-    protected $_cpt_object;
38
-
39
-
40
-    /**
41
-     * a boolean flag to set whether the current route is a cpt route or not.
42
-     *
43
-     * @var bool
44
-     */
45
-    protected $_cpt_route = false;
46
-
47
-
48
-    /**
49
-     * This property allows cpt classes to define multiple routes as cpt routes.
50
-     * //in this array we define what the custom post type for this route is.
51
-     * array(
52
-     * 'route_name' => 'custom_post_type_slug'
53
-     * )
54
-     *
55
-     * @var array
56
-     */
57
-    protected $_cpt_routes = array();
58
-
59
-
60
-    /**
61
-     * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
62
-     * in this format:
63
-     * array(
64
-     * 'post_type_slug' => 'edit_route'
65
-     * )
66
-     *
67
-     * @var array
68
-     */
69
-    protected $_cpt_edit_routes = array();
70
-
71
-
72
-    /**
73
-     * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
74
-     * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
75
-     * _cpt_model_names property should be in the following format: array(
76
-     * 'route_defined_by_action_param' => 'Model_Name')
77
-     *
78
-     * @var array $_cpt_model_names
79
-     */
80
-    protected $_cpt_model_names = array();
81
-
82
-
83
-    /**
84
-     * @var EE_CPT_Base
85
-     */
86
-    protected $_cpt_model_obj = false;
87
-
88
-
89
-    /**
90
-     * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
91
-     * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
92
-     * the _register_autosave_containers() method so that we don't override any other containers already registered.
93
-     * Registration of containers should be done before load_page_dependencies() is run.
94
-     *
95
-     * @var array()
96
-     */
97
-    protected $_autosave_containers = array();
98
-    protected $_autosave_fields = array();
99
-
100
-    /**
101
-     * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
102
-     * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
103
-     *
104
-     * @var array
105
-     */
106
-    protected $_pagenow_map;
107
-
108
-
109
-    /**
110
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
111
-     * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
112
-     * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
113
-     * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
114
-     * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
115
-     *
116
-     * @access protected
117
-     * @abstract
118
-     * @param  string      $post_id The ID of the cpt that was saved (so you can link relationally)
119
-     * @param  EE_CPT_Base $post    The post object of the cpt that was saved.
120
-     * @return void
121
-     */
122
-    abstract protected function _insert_update_cpt_item($post_id, $post);
123
-
124
-
125
-    /**
126
-     * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
127
-     *
128
-     * @abstract
129
-     * @access public
130
-     * @param  string $post_id The ID of the cpt that was trashed
131
-     * @return void
132
-     */
133
-    abstract public function trash_cpt_item($post_id);
134
-
135
-
136
-    /**
137
-     * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
138
-     *
139
-     * @param  string $post_id theID of the cpt that was untrashed
140
-     * @return void
141
-     */
142
-    abstract public function restore_cpt_item($post_id);
143
-
144
-
145
-    /**
146
-     * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
147
-     * from the db
148
-     *
149
-     * @param  string $post_id the ID of the cpt that was deleted
150
-     * @return void
151
-     */
152
-    abstract public function delete_cpt_item($post_id);
153
-
154
-
155
-    /**
156
-     * Just utilizing the method EE_Admin exposes for doing things before page setup.
157
-     *
158
-     * @access protected
159
-     * @return void
160
-     */
161
-    protected function _before_page_setup()
162
-    {
163
-        $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
164
-        $this->_cpt_routes = array_merge(
165
-            array(
166
-                'create_new' => $this->page_slug,
167
-                'edit'       => $this->page_slug,
168
-                'trash'      => $this->page_slug,
169
-            ),
170
-            $this->_cpt_routes
171
-        );
172
-        // let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
173
-        $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[ $this->_req_data['action'] ])
174
-            ? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
175
-            : get_post_type_object($page);
176
-        // tweak pagenow for page loading.
177
-        if (! $this->_pagenow_map) {
178
-            $this->_pagenow_map = array(
179
-                'create_new' => 'post-new.php',
180
-                'edit'       => 'post.php',
181
-                'trash'      => 'post.php',
182
-            );
183
-        }
184
-        add_action('current_screen', array($this, 'modify_pagenow'));
185
-        // TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
186
-        // get current page from autosave
187
-        $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
188
-            ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
189
-            : null;
190
-        $this->_current_page = isset($this->_req_data['current_page'])
191
-            ? $this->_req_data['current_page']
192
-            : $current_page;
193
-        // autosave... make sure its only for the correct page
194
-        // if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
195
-        // setup autosave ajax hook
196
-        // add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
197
-        // }
198
-    }
199
-
200
-
201
-    /**
202
-     * Simply ensure that we simulate the correct post route for cpt screens
203
-     *
204
-     * @param WP_Screen $current_screen
205
-     * @return void
206
-     */
207
-    public function modify_pagenow($current_screen)
208
-    {
209
-        global $pagenow, $hook_suffix;
210
-        // possibly reset pagenow.
211
-        if (! empty($this->_req_data['page'])
212
-            && $this->_req_data['page'] == $this->page_slug
213
-            && ! empty($this->_req_data['action'])
214
-            && isset($this->_pagenow_map[ $this->_req_data['action'] ])
215
-        ) {
216
-            $pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
217
-            $hook_suffix = $pagenow;
218
-        }
219
-    }
220
-
221
-
222
-    /**
223
-     * This method is used to register additional autosave containers to the _autosave_containers property.
224
-     *
225
-     * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
226
-     *       automatically register the id for the post metabox as a container.
227
-     * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
228
-     *                    you would send along the id of a metabox container.
229
-     * @return void
230
-     */
231
-    protected function _register_autosave_containers($ids)
232
-    {
233
-        $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
234
-    }
235
-
236
-
237
-    /**
238
-     * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
239
-     * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
240
-     */
241
-    protected function _set_autosave_containers()
242
-    {
243
-        global $wp_meta_boxes;
244
-        $containers = array();
245
-        if (empty($wp_meta_boxes)) {
246
-            return;
247
-        }
248
-        $current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
249
-        foreach ($current_metaboxes as $box_context) {
250
-            foreach ($box_context as $box_details) {
251
-                foreach ($box_details as $box) {
252
-                    if (is_array($box['callback'])
253
-                        && (
254
-                            $box['callback'][0] instanceof EE_Admin_Page
255
-                            || $box['callback'][0] instanceof EE_Admin_Hooks
256
-                        )
257
-                    ) {
258
-                        $containers[] = $box['id'];
259
-                    }
260
-                }
261
-            }
262
-        }
263
-        $this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
264
-        // add hidden inputs container
265
-        $this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
266
-    }
267
-
268
-
269
-    protected function _load_autosave_scripts_styles()
270
-    {
271
-        /*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
31
+	/**
32
+	 * This gets set in _setup_cpt
33
+	 * It will contain the object for the custom post type.
34
+	 *
35
+	 * @var EE_CPT_Base
36
+	 */
37
+	protected $_cpt_object;
38
+
39
+
40
+	/**
41
+	 * a boolean flag to set whether the current route is a cpt route or not.
42
+	 *
43
+	 * @var bool
44
+	 */
45
+	protected $_cpt_route = false;
46
+
47
+
48
+	/**
49
+	 * This property allows cpt classes to define multiple routes as cpt routes.
50
+	 * //in this array we define what the custom post type for this route is.
51
+	 * array(
52
+	 * 'route_name' => 'custom_post_type_slug'
53
+	 * )
54
+	 *
55
+	 * @var array
56
+	 */
57
+	protected $_cpt_routes = array();
58
+
59
+
60
+	/**
61
+	 * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
62
+	 * in this format:
63
+	 * array(
64
+	 * 'post_type_slug' => 'edit_route'
65
+	 * )
66
+	 *
67
+	 * @var array
68
+	 */
69
+	protected $_cpt_edit_routes = array();
70
+
71
+
72
+	/**
73
+	 * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
74
+	 * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
75
+	 * _cpt_model_names property should be in the following format: array(
76
+	 * 'route_defined_by_action_param' => 'Model_Name')
77
+	 *
78
+	 * @var array $_cpt_model_names
79
+	 */
80
+	protected $_cpt_model_names = array();
81
+
82
+
83
+	/**
84
+	 * @var EE_CPT_Base
85
+	 */
86
+	protected $_cpt_model_obj = false;
87
+
88
+
89
+	/**
90
+	 * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
91
+	 * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
92
+	 * the _register_autosave_containers() method so that we don't override any other containers already registered.
93
+	 * Registration of containers should be done before load_page_dependencies() is run.
94
+	 *
95
+	 * @var array()
96
+	 */
97
+	protected $_autosave_containers = array();
98
+	protected $_autosave_fields = array();
99
+
100
+	/**
101
+	 * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
102
+	 * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
103
+	 *
104
+	 * @var array
105
+	 */
106
+	protected $_pagenow_map;
107
+
108
+
109
+	/**
110
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
111
+	 * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
112
+	 * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
113
+	 * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
114
+	 * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
115
+	 *
116
+	 * @access protected
117
+	 * @abstract
118
+	 * @param  string      $post_id The ID of the cpt that was saved (so you can link relationally)
119
+	 * @param  EE_CPT_Base $post    The post object of the cpt that was saved.
120
+	 * @return void
121
+	 */
122
+	abstract protected function _insert_update_cpt_item($post_id, $post);
123
+
124
+
125
+	/**
126
+	 * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
127
+	 *
128
+	 * @abstract
129
+	 * @access public
130
+	 * @param  string $post_id The ID of the cpt that was trashed
131
+	 * @return void
132
+	 */
133
+	abstract public function trash_cpt_item($post_id);
134
+
135
+
136
+	/**
137
+	 * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
138
+	 *
139
+	 * @param  string $post_id theID of the cpt that was untrashed
140
+	 * @return void
141
+	 */
142
+	abstract public function restore_cpt_item($post_id);
143
+
144
+
145
+	/**
146
+	 * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
147
+	 * from the db
148
+	 *
149
+	 * @param  string $post_id the ID of the cpt that was deleted
150
+	 * @return void
151
+	 */
152
+	abstract public function delete_cpt_item($post_id);
153
+
154
+
155
+	/**
156
+	 * Just utilizing the method EE_Admin exposes for doing things before page setup.
157
+	 *
158
+	 * @access protected
159
+	 * @return void
160
+	 */
161
+	protected function _before_page_setup()
162
+	{
163
+		$page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
164
+		$this->_cpt_routes = array_merge(
165
+			array(
166
+				'create_new' => $this->page_slug,
167
+				'edit'       => $this->page_slug,
168
+				'trash'      => $this->page_slug,
169
+			),
170
+			$this->_cpt_routes
171
+		);
172
+		// let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
173
+		$this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[ $this->_req_data['action'] ])
174
+			? get_post_type_object($this->_cpt_routes[ $this->_req_data['action'] ])
175
+			: get_post_type_object($page);
176
+		// tweak pagenow for page loading.
177
+		if (! $this->_pagenow_map) {
178
+			$this->_pagenow_map = array(
179
+				'create_new' => 'post-new.php',
180
+				'edit'       => 'post.php',
181
+				'trash'      => 'post.php',
182
+			);
183
+		}
184
+		add_action('current_screen', array($this, 'modify_pagenow'));
185
+		// TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
186
+		// get current page from autosave
187
+		$current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
188
+			? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
189
+			: null;
190
+		$this->_current_page = isset($this->_req_data['current_page'])
191
+			? $this->_req_data['current_page']
192
+			: $current_page;
193
+		// autosave... make sure its only for the correct page
194
+		// if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
195
+		// setup autosave ajax hook
196
+		// add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
197
+		// }
198
+	}
199
+
200
+
201
+	/**
202
+	 * Simply ensure that we simulate the correct post route for cpt screens
203
+	 *
204
+	 * @param WP_Screen $current_screen
205
+	 * @return void
206
+	 */
207
+	public function modify_pagenow($current_screen)
208
+	{
209
+		global $pagenow, $hook_suffix;
210
+		// possibly reset pagenow.
211
+		if (! empty($this->_req_data['page'])
212
+			&& $this->_req_data['page'] == $this->page_slug
213
+			&& ! empty($this->_req_data['action'])
214
+			&& isset($this->_pagenow_map[ $this->_req_data['action'] ])
215
+		) {
216
+			$pagenow = $this->_pagenow_map[ $this->_req_data['action'] ];
217
+			$hook_suffix = $pagenow;
218
+		}
219
+	}
220
+
221
+
222
+	/**
223
+	 * This method is used to register additional autosave containers to the _autosave_containers property.
224
+	 *
225
+	 * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
226
+	 *       automatically register the id for the post metabox as a container.
227
+	 * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
228
+	 *                    you would send along the id of a metabox container.
229
+	 * @return void
230
+	 */
231
+	protected function _register_autosave_containers($ids)
232
+	{
233
+		$this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
234
+	}
235
+
236
+
237
+	/**
238
+	 * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
239
+	 * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
240
+	 */
241
+	protected function _set_autosave_containers()
242
+	{
243
+		global $wp_meta_boxes;
244
+		$containers = array();
245
+		if (empty($wp_meta_boxes)) {
246
+			return;
247
+		}
248
+		$current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : array();
249
+		foreach ($current_metaboxes as $box_context) {
250
+			foreach ($box_context as $box_details) {
251
+				foreach ($box_details as $box) {
252
+					if (is_array($box['callback'])
253
+						&& (
254
+							$box['callback'][0] instanceof EE_Admin_Page
255
+							|| $box['callback'][0] instanceof EE_Admin_Hooks
256
+						)
257
+					) {
258
+						$containers[] = $box['id'];
259
+					}
260
+				}
261
+			}
262
+		}
263
+		$this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
264
+		// add hidden inputs container
265
+		$this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
266
+	}
267
+
268
+
269
+	protected function _load_autosave_scripts_styles()
270
+	{
271
+		/*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
272 272
         wp_enqueue_script('cpt-autosave');/**/ // todo re-enable when we start doing autosave again in 4.2
273 273
 
274
-        // filter _autosave_containers
275
-        $containers = apply_filters(
276
-            'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
277
-            $this->_autosave_containers,
278
-            $this
279
-        );
280
-        $containers = apply_filters(
281
-            'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
282
-            $containers,
283
-            $this
284
-        );
285
-
286
-        wp_localize_script(
287
-            'event_editor_js',
288
-            'EE_AUTOSAVE_IDS',
289
-            $containers
290
-        ); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
291
-
292
-        $unsaved_data_msg = array(
293
-            'eventmsg'     => sprintf(
294
-                __(
295
-                    "The changes you made to this %s will be lost if you navigate away from this page.",
296
-                    'event_espresso'
297
-                ),
298
-                $this->_cpt_object->labels->singular_name
299
-            ),
300
-            'inputChanged' => 0,
301
-        );
302
-        wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
303
-    }
304
-
305
-
306
-    public function load_page_dependencies()
307
-    {
308
-        try {
309
-            $this->_load_page_dependencies();
310
-        } catch (EE_Error $e) {
311
-            $e->get_error();
312
-        }
313
-    }
314
-
315
-
316
-    /**
317
-     * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
318
-     *
319
-     * @access protected
320
-     * @return void
321
-     */
322
-    protected function _load_page_dependencies()
323
-    {
324
-        // we only add stuff if this is a cpt_route!
325
-        if (! $this->_cpt_route) {
326
-            parent::_load_page_dependencies();
327
-            return;
328
-        }
329
-        // now let's do some automatic filters into the wp_system
330
-        // and we'll check to make sure the CHILD class
331
-        // automatically has the required methods in place.
332
-        // the following filters are for setting all the redirects
333
-        // on DEFAULT WP custom post type actions
334
-        // let's add a hidden input to the post-edit form
335
-        // so we know when we have to trigger our custom redirects!
336
-        // Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
337
-        add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
338
-        // inject our Admin page nav tabs...
339
-        // let's make sure the nav tabs are set if they aren't already
340
-        // if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
341
-        add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
342
-        // modify the post_updated messages array
343
-        add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
344
-        // add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
345
-        // cpts use the same format for shortlinks as posts!
346
-        add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
347
-        // This basically allows us to change the title of the "publish" metabox area
348
-        // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
349
-        if (! empty($this->_labels['publishbox'])) {
350
-            $box_label = is_array($this->_labels['publishbox'])
351
-                         && isset($this->_labels['publishbox'][ $this->_req_action ])
352
-                ? $this->_labels['publishbox'][ $this->_req_action ]
353
-                : $this->_labels['publishbox'];
354
-            add_meta_box(
355
-                'submitdiv',
356
-                $box_label,
357
-                'post_submit_meta_box',
358
-                $this->_cpt_routes[ $this->_req_action ],
359
-                'side',
360
-                'core'
361
-            );
362
-        }
363
-        // let's add page_templates metabox if this cpt added support for it.
364
-        if ($this->_supports_page_templates($this->_cpt_object->name)) {
365
-            add_meta_box(
366
-                'page_templates',
367
-                __('Page Template', 'event_espresso'),
368
-                array($this, 'page_template_meta_box'),
369
-                $this->_cpt_routes[ $this->_req_action ],
370
-                'side',
371
-                'default'
372
-            );
373
-        }
374
-        // this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
375
-        if (method_exists($this, 'extra_permalink_field_buttons')) {
376
-            add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
377
-        }
378
-        // add preview button
379
-        add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
380
-        // insert our own post_stati dropdown
381
-        add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
382
-        // This allows adding additional information to the publish post submitbox on the wp post edit form
383
-        if (method_exists($this, 'extra_misc_actions_publish_box')) {
384
-            add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
385
-        }
386
-        // This allows for adding additional stuff after the title field on the wp post edit form.
387
-        // This is also before the wp_editor for post description field.
388
-        if (method_exists($this, 'edit_form_after_title')) {
389
-            add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
390
-        }
391
-        /**
392
-         * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
393
-         */
394
-        add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
395
-        parent::_load_page_dependencies();
396
-        // notice we are ALSO going to load the pagenow hook set for this route
397
-        // (see _before_page_setup for the reset of the pagenow global ).
398
-        // This is for any plugins that are doing things properly
399
-        // and hooking into the load page hook for core wp cpt routes.
400
-        global $pagenow;
401
-        add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
402
-        do_action('load-' . $pagenow);
403
-        add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
404
-        // we route REALLY early.
405
-        try {
406
-            $this->_route_admin_request();
407
-        } catch (EE_Error $e) {
408
-            $e->get_error();
409
-        }
410
-    }
411
-
412
-
413
-    /**
414
-     * Since we don't want users going to default core wp routes, this will check any wp urls run through the
415
-     * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
416
-     * route instead.
417
-     *
418
-     * @param string $good_protocol_url The escaped url.
419
-     * @param string $original_url      The original url.
420
-     * @param string $_context          The context sent to the esc_url method.
421
-     * @return string possibly a new url for our route.
422
-     */
423
-    public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
424
-    {
425
-        $routes_to_match = array(
426
-            0 => array(
427
-                'edit.php?post_type=espresso_attendees',
428
-                'admin.php?page=espresso_registrations&action=contact_list',
429
-            ),
430
-            1 => array(
431
-                'edit.php?post_type=' . $this->_cpt_object->name,
432
-                'admin.php?page=' . $this->_cpt_object->name,
433
-            ),
434
-        );
435
-        foreach ($routes_to_match as $route_matches) {
436
-            if (strpos($good_protocol_url, $route_matches[0]) !== false) {
437
-                return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
438
-            }
439
-        }
440
-        return $good_protocol_url;
441
-    }
442
-
443
-
444
-    /**
445
-     * Determine whether the current cpt supports page templates or not.
446
-     *
447
-     * @since %VER%
448
-     * @param string $cpt_name The cpt slug we're checking on.
449
-     * @return bool True supported, false not.
450
-     * @throws InvalidArgumentException
451
-     * @throws InvalidDataTypeException
452
-     * @throws InvalidInterfaceException
453
-     */
454
-    private function _supports_page_templates($cpt_name)
455
-    {
456
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
457
-        $custom_post_types = LoaderFactory::getLoader()->getShared(
458
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
459
-        );
460
-        $cpt_args = $custom_post_types->getDefinitions();
461
-        $cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
462
-        $cpt_has_support = ! empty($cpt_args['page_templates']);
463
-
464
-        // if the installed version of WP is > 4.7 we do some additional checks.
465
-        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
466
-            $post_templates = wp_get_theme()->get_post_templates();
467
-            // if there are $post_templates for this cpt, then we return false for this method because
468
-            // that means we aren't going to load our page template manager and leave that up to the native
469
-            // cpt template manager.
470
-            $cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
471
-        }
472
-
473
-        return $cpt_has_support;
474
-    }
475
-
476
-
477
-    /**
478
-     * Callback for the page_templates metabox selector.
479
-     *
480
-     * @since %VER%
481
-     * @return void
482
-     */
483
-    public function page_template_meta_box()
484
-    {
485
-        global $post;
486
-        $template = '';
487
-
488
-        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
489
-            $page_template_count = count(get_page_templates());
490
-        } else {
491
-            $page_template_count = count(get_page_templates($post));
492
-        };
493
-
494
-        if ($page_template_count) {
495
-            $page_template = get_post_meta($post->ID, '_wp_page_template', true);
496
-            $template = ! empty($page_template) ? $page_template : '';
497
-        }
498
-        ?>
274
+		// filter _autosave_containers
275
+		$containers = apply_filters(
276
+			'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
277
+			$this->_autosave_containers,
278
+			$this
279
+		);
280
+		$containers = apply_filters(
281
+			'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
282
+			$containers,
283
+			$this
284
+		);
285
+
286
+		wp_localize_script(
287
+			'event_editor_js',
288
+			'EE_AUTOSAVE_IDS',
289
+			$containers
290
+		); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
291
+
292
+		$unsaved_data_msg = array(
293
+			'eventmsg'     => sprintf(
294
+				__(
295
+					"The changes you made to this %s will be lost if you navigate away from this page.",
296
+					'event_espresso'
297
+				),
298
+				$this->_cpt_object->labels->singular_name
299
+			),
300
+			'inputChanged' => 0,
301
+		);
302
+		wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
303
+	}
304
+
305
+
306
+	public function load_page_dependencies()
307
+	{
308
+		try {
309
+			$this->_load_page_dependencies();
310
+		} catch (EE_Error $e) {
311
+			$e->get_error();
312
+		}
313
+	}
314
+
315
+
316
+	/**
317
+	 * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
318
+	 *
319
+	 * @access protected
320
+	 * @return void
321
+	 */
322
+	protected function _load_page_dependencies()
323
+	{
324
+		// we only add stuff if this is a cpt_route!
325
+		if (! $this->_cpt_route) {
326
+			parent::_load_page_dependencies();
327
+			return;
328
+		}
329
+		// now let's do some automatic filters into the wp_system
330
+		// and we'll check to make sure the CHILD class
331
+		// automatically has the required methods in place.
332
+		// the following filters are for setting all the redirects
333
+		// on DEFAULT WP custom post type actions
334
+		// let's add a hidden input to the post-edit form
335
+		// so we know when we have to trigger our custom redirects!
336
+		// Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
337
+		add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
338
+		// inject our Admin page nav tabs...
339
+		// let's make sure the nav tabs are set if they aren't already
340
+		// if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
341
+		add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
342
+		// modify the post_updated messages array
343
+		add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
344
+		// add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
345
+		// cpts use the same format for shortlinks as posts!
346
+		add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
347
+		// This basically allows us to change the title of the "publish" metabox area
348
+		// on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
349
+		if (! empty($this->_labels['publishbox'])) {
350
+			$box_label = is_array($this->_labels['publishbox'])
351
+						 && isset($this->_labels['publishbox'][ $this->_req_action ])
352
+				? $this->_labels['publishbox'][ $this->_req_action ]
353
+				: $this->_labels['publishbox'];
354
+			add_meta_box(
355
+				'submitdiv',
356
+				$box_label,
357
+				'post_submit_meta_box',
358
+				$this->_cpt_routes[ $this->_req_action ],
359
+				'side',
360
+				'core'
361
+			);
362
+		}
363
+		// let's add page_templates metabox if this cpt added support for it.
364
+		if ($this->_supports_page_templates($this->_cpt_object->name)) {
365
+			add_meta_box(
366
+				'page_templates',
367
+				__('Page Template', 'event_espresso'),
368
+				array($this, 'page_template_meta_box'),
369
+				$this->_cpt_routes[ $this->_req_action ],
370
+				'side',
371
+				'default'
372
+			);
373
+		}
374
+		// this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
375
+		if (method_exists($this, 'extra_permalink_field_buttons')) {
376
+			add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
377
+		}
378
+		// add preview button
379
+		add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
380
+		// insert our own post_stati dropdown
381
+		add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
382
+		// This allows adding additional information to the publish post submitbox on the wp post edit form
383
+		if (method_exists($this, 'extra_misc_actions_publish_box')) {
384
+			add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
385
+		}
386
+		// This allows for adding additional stuff after the title field on the wp post edit form.
387
+		// This is also before the wp_editor for post description field.
388
+		if (method_exists($this, 'edit_form_after_title')) {
389
+			add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
390
+		}
391
+		/**
392
+		 * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
393
+		 */
394
+		add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
395
+		parent::_load_page_dependencies();
396
+		// notice we are ALSO going to load the pagenow hook set for this route
397
+		// (see _before_page_setup for the reset of the pagenow global ).
398
+		// This is for any plugins that are doing things properly
399
+		// and hooking into the load page hook for core wp cpt routes.
400
+		global $pagenow;
401
+		add_action('load-' . $pagenow, array($this, 'modify_current_screen'), 20);
402
+		do_action('load-' . $pagenow);
403
+		add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
404
+		// we route REALLY early.
405
+		try {
406
+			$this->_route_admin_request();
407
+		} catch (EE_Error $e) {
408
+			$e->get_error();
409
+		}
410
+	}
411
+
412
+
413
+	/**
414
+	 * Since we don't want users going to default core wp routes, this will check any wp urls run through the
415
+	 * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
416
+	 * route instead.
417
+	 *
418
+	 * @param string $good_protocol_url The escaped url.
419
+	 * @param string $original_url      The original url.
420
+	 * @param string $_context          The context sent to the esc_url method.
421
+	 * @return string possibly a new url for our route.
422
+	 */
423
+	public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
424
+	{
425
+		$routes_to_match = array(
426
+			0 => array(
427
+				'edit.php?post_type=espresso_attendees',
428
+				'admin.php?page=espresso_registrations&action=contact_list',
429
+			),
430
+			1 => array(
431
+				'edit.php?post_type=' . $this->_cpt_object->name,
432
+				'admin.php?page=' . $this->_cpt_object->name,
433
+			),
434
+		);
435
+		foreach ($routes_to_match as $route_matches) {
436
+			if (strpos($good_protocol_url, $route_matches[0]) !== false) {
437
+				return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
438
+			}
439
+		}
440
+		return $good_protocol_url;
441
+	}
442
+
443
+
444
+	/**
445
+	 * Determine whether the current cpt supports page templates or not.
446
+	 *
447
+	 * @since %VER%
448
+	 * @param string $cpt_name The cpt slug we're checking on.
449
+	 * @return bool True supported, false not.
450
+	 * @throws InvalidArgumentException
451
+	 * @throws InvalidDataTypeException
452
+	 * @throws InvalidInterfaceException
453
+	 */
454
+	private function _supports_page_templates($cpt_name)
455
+	{
456
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
457
+		$custom_post_types = LoaderFactory::getLoader()->getShared(
458
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
459
+		);
460
+		$cpt_args = $custom_post_types->getDefinitions();
461
+		$cpt_args = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : array();
462
+		$cpt_has_support = ! empty($cpt_args['page_templates']);
463
+
464
+		// if the installed version of WP is > 4.7 we do some additional checks.
465
+		if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
466
+			$post_templates = wp_get_theme()->get_post_templates();
467
+			// if there are $post_templates for this cpt, then we return false for this method because
468
+			// that means we aren't going to load our page template manager and leave that up to the native
469
+			// cpt template manager.
470
+			$cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
471
+		}
472
+
473
+		return $cpt_has_support;
474
+	}
475
+
476
+
477
+	/**
478
+	 * Callback for the page_templates metabox selector.
479
+	 *
480
+	 * @since %VER%
481
+	 * @return void
482
+	 */
483
+	public function page_template_meta_box()
484
+	{
485
+		global $post;
486
+		$template = '';
487
+
488
+		if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
489
+			$page_template_count = count(get_page_templates());
490
+		} else {
491
+			$page_template_count = count(get_page_templates($post));
492
+		};
493
+
494
+		if ($page_template_count) {
495
+			$page_template = get_post_meta($post->ID, '_wp_page_template', true);
496
+			$template = ! empty($page_template) ? $page_template : '';
497
+		}
498
+		?>
499 499
         <p><strong><?php _e('Template', 'event_espresso') ?></strong></p>
500 500
         <label class="screen-reader-text" for="page_template"><?php _e('Page Template', 'event_espresso') ?></label><select
501 501
         name="page_template" id="page_template">
@@ -503,507 +503,507 @@  discard block
 block discarded – undo
503 503
         <?php page_template_dropdown($template); ?>
504 504
     </select>
505 505
         <?php
506
-    }
507
-
508
-
509
-    /**
510
-     * if this post is a draft or scheduled post then we provide a preview button for user to click
511
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
512
-     *
513
-     * @param  string $return    the current html
514
-     * @param  int    $id        the post id for the page
515
-     * @param  string $new_title What the title is
516
-     * @param  string $new_slug  what the slug is
517
-     * @return string            The new html string for the permalink area
518
-     */
519
-    public function preview_button_html($return, $id, $new_title, $new_slug)
520
-    {
521
-        $post = get_post($id);
522
-        if ('publish' !== get_post_status($post)) {
523
-            $return .= '<span_id="view-post-btn"><a target="_blank" href="'
524
-                       . get_preview_post_link($id)
525
-                       . '" class="button button-small">'
526
-                       . __('Preview', 'event_espresso')
527
-                       . '</a></span>'
528
-                       . "\n";
529
-        }
530
-        return $return;
531
-    }
532
-
533
-
534
-    /**
535
-     * add our custom post stati dropdown on the wp post page for this cpt
536
-     *
537
-     * @return void
538
-     */
539
-    public function custom_post_stati_dropdown()
540
-    {
541
-
542
-        $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
543
-        $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
544
-            ? $statuses[ $this->_cpt_model_obj->status() ]
545
-            : '';
546
-        $template_args = array(
547
-            'cur_status'            => $this->_cpt_model_obj->status(),
548
-            'statuses'              => $statuses,
549
-            'cur_status_label'      => $cur_status_label,
550
-            'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
551
-        );
552
-        // we'll add a trash post status (WP doesn't add one for some reason)
553
-        if ($this->_cpt_model_obj->status() === 'trash') {
554
-            $template_args['cur_status_label'] = __('Trashed', 'event_espresso');
555
-            $statuses['trash'] = __('Trashed', 'event_espresso');
556
-            $template_args['statuses'] = $statuses;
557
-        }
558
-
559
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
560
-        EEH_Template::display_template($template, $template_args);
561
-    }
562
-
563
-
564
-    public function setup_autosave_hooks()
565
-    {
566
-        $this->_set_autosave_containers();
567
-        $this->_load_autosave_scripts_styles();
568
-    }
569
-
570
-
571
-    /**
572
-     * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
573
-     * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
574
-     * for the nonce in here, but then this method looks for two things:
575
-     * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
576
-     * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
577
-     * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
578
-     * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
579
-     * template args.
580
-     *    1. $template_args['error'] = IF there is an error you can add the message in here.
581
-     *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
582
-     *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
583
-     *    $this->_template_args['data']['items'] = array(
584
-     *        'event-datetime-ids' => '1,2,3';
585
-     *    );
586
-     *    Keep in mind the following things:
587
-     *    - "where" index is for the input with the id as that string.
588
-     *    - "what" index is what will be used for the value of that input.
589
-     *
590
-     * @return void
591
-     */
592
-    public function do_extra_autosave_stuff()
593
-    {
594
-        // next let's check for the autosave nonce (we'll use _verify_nonce )
595
-        $nonce = isset($this->_req_data['autosavenonce'])
596
-            ? $this->_req_data['autosavenonce']
597
-            : null;
598
-        $this->_verify_nonce($nonce, 'autosave');
599
-        // make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
600
-        if (! defined('DOING_AUTOSAVE')) {
601
-            define('DOING_AUTOSAVE', true);
602
-        }
603
-        // if we made it here then the nonce checked out.  Let's run our methods and actions
604
-        $autosave = "_ee_autosave_{$this->_current_view}";
605
-        if (method_exists($this, $autosave)) {
606
-            $this->$autosave();
607
-        } else {
608
-            $this->_template_args['success'] = true;
609
-        }
610
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
611
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
612
-        // now let's return json
613
-        $this->_return_json();
614
-    }
615
-
616
-
617
-    /**
618
-     * This takes care of setting up default routes and pages that utilize the core WP admin pages.
619
-     * Child classes can override the defaults (in cases for adding metaboxes etc.)
620
-     * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
621
-     *
622
-     * @access protected
623
-     * @throws EE_Error
624
-     * @return void
625
-     */
626
-    protected function _extend_page_config_for_cpt()
627
-    {
628
-        // before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
629
-        if (isset($this->_req_data['page']) && $this->_req_data['page'] !== $this->page_slug) {
630
-            return;
631
-        }
632
-        // set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
633
-        if (! empty($this->_cpt_object)) {
634
-            $this->_page_routes = array_merge(
635
-                array(
636
-                    'create_new' => '_create_new_cpt_item',
637
-                    'edit'       => '_edit_cpt_item',
638
-                ),
639
-                $this->_page_routes
640
-            );
641
-            $this->_page_config = array_merge(
642
-                array(
643
-                    'create_new' => array(
644
-                        'nav'           => array(
645
-                            'label' => $this->_cpt_object->labels->add_new_item,
646
-                            'order' => 5,
647
-                        ),
648
-                        'require_nonce' => false,
649
-                    ),
650
-                    'edit'       => array(
651
-                        'nav'           => array(
652
-                            'label'      => $this->_cpt_object->labels->edit_item,
653
-                            'order'      => 5,
654
-                            'persistent' => false,
655
-                            'url'        => '',
656
-                        ),
657
-                        'require_nonce' => false,
658
-                    ),
659
-                ),
660
-                $this->_page_config
661
-            );
662
-        }
663
-        // load the next section only if this is a matching cpt route as set in the cpt routes array.
664
-        if (! isset($this->_cpt_routes[ $this->_req_action ])) {
665
-            return;
666
-        }
667
-        $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
668
-        // add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
669
-        if (empty($this->_cpt_object)) {
670
-            $msg = sprintf(
671
-                __(
672
-                    'This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).',
673
-                    'event_espresso'
674
-                ),
675
-                $this->page_slug,
676
-                $this->_req_action,
677
-                get_class($this)
678
-            );
679
-            throw new EE_Error($msg);
680
-        }
681
-        if ($this->_cpt_route) {
682
-            $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
683
-            $this->_set_model_object($id);
684
-        }
685
-    }
686
-
687
-
688
-    /**
689
-     * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
690
-     *
691
-     * @access protected
692
-     * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
693
-     * @param bool   $ignore_route_check
694
-     * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
695
-     * @throws EE_Error
696
-     * @throws InvalidArgumentException
697
-     * @throws InvalidDataTypeException
698
-     * @throws InvalidInterfaceException
699
-     * @throws ReflectionException
700
-     */
701
-    protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
702
-    {
703
-        $model = null;
704
-        if (empty($this->_cpt_model_names)
705
-            || (
706
-                ! $ignore_route_check
707
-                && ! isset($this->_cpt_routes[ $this->_req_action ])
708
-            ) || (
709
-                $this->_cpt_model_obj instanceof EE_CPT_Base
710
-                && $this->_cpt_model_obj->ID() === $id
711
-            )
712
-        ) {
713
-            // get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
714
-            return;
715
-        }
716
-        // if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
717
-        if ($ignore_route_check) {
718
-            $post_type = get_post_type($id);
719
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
720
-            $custom_post_types = LoaderFactory::getLoader()->getShared(
721
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
722
-            );
723
-            $model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
724
-            if (isset($model_names[ $post_type ])) {
725
-                $model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
726
-            }
727
-        } else {
728
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
729
-        }
730
-        if ($model instanceof EEM_Base) {
731
-            $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
732
-        }
733
-        do_action(
734
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
735
-            $this->_cpt_model_obj,
736
-            $req_type
737
-        );
738
-    }
739
-
740
-
741
-    /**
742
-     * admin_init_global
743
-     * This runs all the code that we want executed within the WP admin_init hook.
744
-     * This method executes for ALL EE Admin pages.
745
-     *
746
-     * @access public
747
-     * @return void
748
-     */
749
-    public function admin_init_global()
750
-    {
751
-        $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
752
-        // its possible this is a new save so let's catch that instead
753
-        $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
754
-        $post_type = $post ? $post->post_type : false;
755
-        $current_route = isset($this->_req_data['current_route'])
756
-            ? $this->_req_data['current_route']
757
-            : 'shouldneverwork';
758
-        $route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
759
-            ? $this->_cpt_routes[ $current_route ]
760
-            : '';
761
-        add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
762
-        add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
763
-        if ($post_type === $route_to_check) {
764
-            add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
765
-        }
766
-        // now let's filter redirect if we're on a revision page and the revision is for an event CPT.
767
-        $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
768
-        if (! empty($revision)) {
769
-            $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
770
-            // doing a restore?
771
-            if (! empty($action) && $action === 'restore') {
772
-                // get post for revision
773
-                $rev_post = get_post($revision);
774
-                $rev_parent = get_post($rev_post->post_parent);
775
-                // only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
776
-                if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
777
-                    add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
778
-                    // restores of revisions
779
-                    add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
780
-                }
781
-            }
782
-        }
783
-        // NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
784
-        if ($post_type && $post_type === $route_to_check) {
785
-            // $post_id, $post
786
-            add_action('save_post', array($this, 'insert_update'), 10, 3);
787
-            // $post_id
788
-            add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
789
-            add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
790
-            add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
791
-            add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
792
-        }
793
-    }
794
-
795
-
796
-    /**
797
-     * Callback for the WordPress trashed_post hook.
798
-     * Execute some basic checks before calling the trash_cpt_item declared in the child class.
799
-     *
800
-     * @param int $post_id
801
-     * @throws \EE_Error
802
-     */
803
-    public function before_trash_cpt_item($post_id)
804
-    {
805
-        $this->_set_model_object($post_id, true, 'trash');
806
-        // if our cpt object isn't existent then get out immediately.
807
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
808
-            return;
809
-        }
810
-        $this->trash_cpt_item($post_id);
811
-    }
812
-
813
-
814
-    /**
815
-     * Callback for the WordPress untrashed_post hook.
816
-     * Execute some basic checks before calling the restore_cpt_method in the child class.
817
-     *
818
-     * @param $post_id
819
-     * @throws \EE_Error
820
-     */
821
-    public function before_restore_cpt_item($post_id)
822
-    {
823
-        $this->_set_model_object($post_id, true, 'restore');
824
-        // if our cpt object isn't existent then get out immediately.
825
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
826
-            return;
827
-        }
828
-        $this->restore_cpt_item($post_id);
829
-    }
830
-
831
-
832
-    /**
833
-     * Callback for the WordPress after_delete_post hook.
834
-     * Execute some basic checks before calling the delete_cpt_item method in the child class.
835
-     *
836
-     * @param $post_id
837
-     * @throws \EE_Error
838
-     */
839
-    public function before_delete_cpt_item($post_id)
840
-    {
841
-        $this->_set_model_object($post_id, true, 'delete');
842
-        // if our cpt object isn't existent then get out immediately.
843
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
844
-            return;
845
-        }
846
-        $this->delete_cpt_item($post_id);
847
-    }
848
-
849
-
850
-    /**
851
-     * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
852
-     * accordingly.
853
-     *
854
-     * @return void
855
-     * @throws EE_Error
856
-     * @throws InvalidArgumentException
857
-     * @throws InvalidDataTypeException
858
-     * @throws InvalidInterfaceException
859
-     * @throws ReflectionException
860
-     */
861
-    public function verify_cpt_object()
862
-    {
863
-        $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
864
-        // verify event object
865
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
866
-            throw new EE_Error(
867
-                sprintf(
868
-                    __(
869
-                        'Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
870
-                        'event_espresso'
871
-                    ),
872
-                    $label
873
-                )
874
-            );
875
-        }
876
-        // if auto-draft then throw an error
877
-        if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
878
-            EE_Error::overwrite_errors();
879
-            EE_Error::add_error(
880
-                sprintf(
881
-                    __(
882
-                        'This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.',
883
-                        'event_espresso'
884
-                    ),
885
-                    $label
886
-                ),
887
-                __FILE__,
888
-                __FUNCTION__,
889
-                __LINE__
890
-            );
891
-        }
892
-        $this->loadEspressoEditorAssetManager();
893
-    }
894
-
895
-
896
-    /**
897
-     * admin_footer_scripts_global
898
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
899
-     * will apply on ALL EE_Admin pages.
900
-     *
901
-     * @access public
902
-     * @return void
903
-     */
904
-    public function admin_footer_scripts_global()
905
-    {
906
-        $this->_add_admin_page_ajax_loading_img();
907
-        $this->_add_admin_page_overlay();
908
-    }
909
-
910
-
911
-    /**
912
-     * add in any global scripts for cpt routes
913
-     *
914
-     * @return void
915
-     */
916
-    public function load_global_scripts_styles()
917
-    {
918
-        parent::load_global_scripts_styles();
919
-        if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
920
-            // setup custom post status object for localize script but only if we've got a cpt object
921
-            $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
922
-            if (! empty($statuses)) {
923
-                // get ALL statuses!
924
-                $statuses = $this->_cpt_model_obj->get_all_post_statuses();
925
-                // setup object
926
-                $ee_cpt_statuses = array();
927
-                foreach ($statuses as $status => $label) {
928
-                    $ee_cpt_statuses[ $status ] = array(
929
-                        'label'      => $label,
930
-                        'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
931
-                    );
932
-                }
933
-                wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
934
-            }
935
-        }
936
-    }
937
-
938
-
939
-    /**
940
-     * @throws InvalidArgumentException
941
-     * @throws InvalidDataTypeException
942
-     * @throws InvalidInterfaceException
943
-     */
944
-    private function loadEspressoEditorAssetManager()
945
-    {
946
-        EE_Dependency_Map::register_dependencies(
947
-            'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager',
948
-            array(
949
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
950
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
951
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
952
-            )
953
-        );
954
-        LoaderFactory::getLoader()->getShared(
955
-            'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager'
956
-        );
957
-        add_action('admin_enqueue_scripts', array($this, 'enqueueEspressoEditorAssets'), 100);
958
-    }
959
-
960
-
961
-    /**
962
-     * enqueue_scripts - Load the scripts and css
963
-     *
964
-     * @return void
965
-     * @throws DomainException
966
-     */
967
-    public function enqueueEspressoEditorAssets()
968
-    {
969
-        wp_enqueue_style(EspressoEditorAssetManager::CSS_HANDLE_EDITOR);
970
-        wp_enqueue_script(EspressoEditorAssetManager::JS_HANDLE_EDITOR);
971
-    }
972
-
973
-
974
-    /**
975
-     * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
976
-     * insert/updates
977
-     *
978
-     * @param  int     $post_id ID of post being updated
979
-     * @param  WP_Post $post    Post object from WP
980
-     * @param  bool    $update  Whether this is an update or a new save.
981
-     * @return void
982
-     * @throws \EE_Error
983
-     */
984
-    public function insert_update($post_id, $post, $update)
985
-    {
986
-        // make sure that if this is a revision OR trash action that we don't do any updates!
987
-        if (isset($this->_req_data['action'])
988
-            && (
989
-                $this->_req_data['action'] === 'restore'
990
-                || $this->_req_data['action'] === 'trash'
991
-            )
992
-        ) {
993
-            return;
994
-        }
995
-        $this->_set_model_object($post_id, true, 'insert_update');
996
-        // if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
997
-        if ($update
998
-            && (
999
-                ! $this->_cpt_model_obj instanceof EE_CPT_Base
1000
-                || $this->_cpt_model_obj->ID() !== $post_id
1001
-            )
1002
-        ) {
1003
-            return;
1004
-        }
1005
-        // check for autosave and update our req_data property accordingly.
1006
-        /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
506
+	}
507
+
508
+
509
+	/**
510
+	 * if this post is a draft or scheduled post then we provide a preview button for user to click
511
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
512
+	 *
513
+	 * @param  string $return    the current html
514
+	 * @param  int    $id        the post id for the page
515
+	 * @param  string $new_title What the title is
516
+	 * @param  string $new_slug  what the slug is
517
+	 * @return string            The new html string for the permalink area
518
+	 */
519
+	public function preview_button_html($return, $id, $new_title, $new_slug)
520
+	{
521
+		$post = get_post($id);
522
+		if ('publish' !== get_post_status($post)) {
523
+			$return .= '<span_id="view-post-btn"><a target="_blank" href="'
524
+					   . get_preview_post_link($id)
525
+					   . '" class="button button-small">'
526
+					   . __('Preview', 'event_espresso')
527
+					   . '</a></span>'
528
+					   . "\n";
529
+		}
530
+		return $return;
531
+	}
532
+
533
+
534
+	/**
535
+	 * add our custom post stati dropdown on the wp post page for this cpt
536
+	 *
537
+	 * @return void
538
+	 */
539
+	public function custom_post_stati_dropdown()
540
+	{
541
+
542
+		$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
543
+		$cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
544
+			? $statuses[ $this->_cpt_model_obj->status() ]
545
+			: '';
546
+		$template_args = array(
547
+			'cur_status'            => $this->_cpt_model_obj->status(),
548
+			'statuses'              => $statuses,
549
+			'cur_status_label'      => $cur_status_label,
550
+			'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
551
+		);
552
+		// we'll add a trash post status (WP doesn't add one for some reason)
553
+		if ($this->_cpt_model_obj->status() === 'trash') {
554
+			$template_args['cur_status_label'] = __('Trashed', 'event_espresso');
555
+			$statuses['trash'] = __('Trashed', 'event_espresso');
556
+			$template_args['statuses'] = $statuses;
557
+		}
558
+
559
+		$template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
560
+		EEH_Template::display_template($template, $template_args);
561
+	}
562
+
563
+
564
+	public function setup_autosave_hooks()
565
+	{
566
+		$this->_set_autosave_containers();
567
+		$this->_load_autosave_scripts_styles();
568
+	}
569
+
570
+
571
+	/**
572
+	 * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
573
+	 * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
574
+	 * for the nonce in here, but then this method looks for two things:
575
+	 * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
576
+	 * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
577
+	 * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
578
+	 * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
579
+	 * template args.
580
+	 *    1. $template_args['error'] = IF there is an error you can add the message in here.
581
+	 *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
582
+	 *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
583
+	 *    $this->_template_args['data']['items'] = array(
584
+	 *        'event-datetime-ids' => '1,2,3';
585
+	 *    );
586
+	 *    Keep in mind the following things:
587
+	 *    - "where" index is for the input with the id as that string.
588
+	 *    - "what" index is what will be used for the value of that input.
589
+	 *
590
+	 * @return void
591
+	 */
592
+	public function do_extra_autosave_stuff()
593
+	{
594
+		// next let's check for the autosave nonce (we'll use _verify_nonce )
595
+		$nonce = isset($this->_req_data['autosavenonce'])
596
+			? $this->_req_data['autosavenonce']
597
+			: null;
598
+		$this->_verify_nonce($nonce, 'autosave');
599
+		// make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
600
+		if (! defined('DOING_AUTOSAVE')) {
601
+			define('DOING_AUTOSAVE', true);
602
+		}
603
+		// if we made it here then the nonce checked out.  Let's run our methods and actions
604
+		$autosave = "_ee_autosave_{$this->_current_view}";
605
+		if (method_exists($this, $autosave)) {
606
+			$this->$autosave();
607
+		} else {
608
+			$this->_template_args['success'] = true;
609
+		}
610
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
611
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
612
+		// now let's return json
613
+		$this->_return_json();
614
+	}
615
+
616
+
617
+	/**
618
+	 * This takes care of setting up default routes and pages that utilize the core WP admin pages.
619
+	 * Child classes can override the defaults (in cases for adding metaboxes etc.)
620
+	 * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
621
+	 *
622
+	 * @access protected
623
+	 * @throws EE_Error
624
+	 * @return void
625
+	 */
626
+	protected function _extend_page_config_for_cpt()
627
+	{
628
+		// before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
629
+		if (isset($this->_req_data['page']) && $this->_req_data['page'] !== $this->page_slug) {
630
+			return;
631
+		}
632
+		// set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
633
+		if (! empty($this->_cpt_object)) {
634
+			$this->_page_routes = array_merge(
635
+				array(
636
+					'create_new' => '_create_new_cpt_item',
637
+					'edit'       => '_edit_cpt_item',
638
+				),
639
+				$this->_page_routes
640
+			);
641
+			$this->_page_config = array_merge(
642
+				array(
643
+					'create_new' => array(
644
+						'nav'           => array(
645
+							'label' => $this->_cpt_object->labels->add_new_item,
646
+							'order' => 5,
647
+						),
648
+						'require_nonce' => false,
649
+					),
650
+					'edit'       => array(
651
+						'nav'           => array(
652
+							'label'      => $this->_cpt_object->labels->edit_item,
653
+							'order'      => 5,
654
+							'persistent' => false,
655
+							'url'        => '',
656
+						),
657
+						'require_nonce' => false,
658
+					),
659
+				),
660
+				$this->_page_config
661
+			);
662
+		}
663
+		// load the next section only if this is a matching cpt route as set in the cpt routes array.
664
+		if (! isset($this->_cpt_routes[ $this->_req_action ])) {
665
+			return;
666
+		}
667
+		$this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]) ? true : false;
668
+		// add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
669
+		if (empty($this->_cpt_object)) {
670
+			$msg = sprintf(
671
+				__(
672
+					'This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).',
673
+					'event_espresso'
674
+				),
675
+				$this->page_slug,
676
+				$this->_req_action,
677
+				get_class($this)
678
+			);
679
+			throw new EE_Error($msg);
680
+		}
681
+		if ($this->_cpt_route) {
682
+			$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
683
+			$this->_set_model_object($id);
684
+		}
685
+	}
686
+
687
+
688
+	/**
689
+	 * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
690
+	 *
691
+	 * @access protected
692
+	 * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
693
+	 * @param bool   $ignore_route_check
694
+	 * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
695
+	 * @throws EE_Error
696
+	 * @throws InvalidArgumentException
697
+	 * @throws InvalidDataTypeException
698
+	 * @throws InvalidInterfaceException
699
+	 * @throws ReflectionException
700
+	 */
701
+	protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
702
+	{
703
+		$model = null;
704
+		if (empty($this->_cpt_model_names)
705
+			|| (
706
+				! $ignore_route_check
707
+				&& ! isset($this->_cpt_routes[ $this->_req_action ])
708
+			) || (
709
+				$this->_cpt_model_obj instanceof EE_CPT_Base
710
+				&& $this->_cpt_model_obj->ID() === $id
711
+			)
712
+		) {
713
+			// get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
714
+			return;
715
+		}
716
+		// if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
717
+		if ($ignore_route_check) {
718
+			$post_type = get_post_type($id);
719
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
720
+			$custom_post_types = LoaderFactory::getLoader()->getShared(
721
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
722
+			);
723
+			$model_names = $custom_post_types->getCustomPostTypeModelNames($post_type);
724
+			if (isset($model_names[ $post_type ])) {
725
+				$model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
726
+			}
727
+		} else {
728
+			$model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
729
+		}
730
+		if ($model instanceof EEM_Base) {
731
+			$this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
732
+		}
733
+		do_action(
734
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
735
+			$this->_cpt_model_obj,
736
+			$req_type
737
+		);
738
+	}
739
+
740
+
741
+	/**
742
+	 * admin_init_global
743
+	 * This runs all the code that we want executed within the WP admin_init hook.
744
+	 * This method executes for ALL EE Admin pages.
745
+	 *
746
+	 * @access public
747
+	 * @return void
748
+	 */
749
+	public function admin_init_global()
750
+	{
751
+		$post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
752
+		// its possible this is a new save so let's catch that instead
753
+		$post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
754
+		$post_type = $post ? $post->post_type : false;
755
+		$current_route = isset($this->_req_data['current_route'])
756
+			? $this->_req_data['current_route']
757
+			: 'shouldneverwork';
758
+		$route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
759
+			? $this->_cpt_routes[ $current_route ]
760
+			: '';
761
+		add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
762
+		add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
763
+		if ($post_type === $route_to_check) {
764
+			add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
765
+		}
766
+		// now let's filter redirect if we're on a revision page and the revision is for an event CPT.
767
+		$revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
768
+		if (! empty($revision)) {
769
+			$action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
770
+			// doing a restore?
771
+			if (! empty($action) && $action === 'restore') {
772
+				// get post for revision
773
+				$rev_post = get_post($revision);
774
+				$rev_parent = get_post($rev_post->post_parent);
775
+				// only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
776
+				if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
777
+					add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
778
+					// restores of revisions
779
+					add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
780
+				}
781
+			}
782
+		}
783
+		// NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
784
+		if ($post_type && $post_type === $route_to_check) {
785
+			// $post_id, $post
786
+			add_action('save_post', array($this, 'insert_update'), 10, 3);
787
+			// $post_id
788
+			add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
789
+			add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
790
+			add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
791
+			add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
792
+		}
793
+	}
794
+
795
+
796
+	/**
797
+	 * Callback for the WordPress trashed_post hook.
798
+	 * Execute some basic checks before calling the trash_cpt_item declared in the child class.
799
+	 *
800
+	 * @param int $post_id
801
+	 * @throws \EE_Error
802
+	 */
803
+	public function before_trash_cpt_item($post_id)
804
+	{
805
+		$this->_set_model_object($post_id, true, 'trash');
806
+		// if our cpt object isn't existent then get out immediately.
807
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
808
+			return;
809
+		}
810
+		$this->trash_cpt_item($post_id);
811
+	}
812
+
813
+
814
+	/**
815
+	 * Callback for the WordPress untrashed_post hook.
816
+	 * Execute some basic checks before calling the restore_cpt_method in the child class.
817
+	 *
818
+	 * @param $post_id
819
+	 * @throws \EE_Error
820
+	 */
821
+	public function before_restore_cpt_item($post_id)
822
+	{
823
+		$this->_set_model_object($post_id, true, 'restore');
824
+		// if our cpt object isn't existent then get out immediately.
825
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
826
+			return;
827
+		}
828
+		$this->restore_cpt_item($post_id);
829
+	}
830
+
831
+
832
+	/**
833
+	 * Callback for the WordPress after_delete_post hook.
834
+	 * Execute some basic checks before calling the delete_cpt_item method in the child class.
835
+	 *
836
+	 * @param $post_id
837
+	 * @throws \EE_Error
838
+	 */
839
+	public function before_delete_cpt_item($post_id)
840
+	{
841
+		$this->_set_model_object($post_id, true, 'delete');
842
+		// if our cpt object isn't existent then get out immediately.
843
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
844
+			return;
845
+		}
846
+		$this->delete_cpt_item($post_id);
847
+	}
848
+
849
+
850
+	/**
851
+	 * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
852
+	 * accordingly.
853
+	 *
854
+	 * @return void
855
+	 * @throws EE_Error
856
+	 * @throws InvalidArgumentException
857
+	 * @throws InvalidDataTypeException
858
+	 * @throws InvalidInterfaceException
859
+	 * @throws ReflectionException
860
+	 */
861
+	public function verify_cpt_object()
862
+	{
863
+		$label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
864
+		// verify event object
865
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
866
+			throw new EE_Error(
867
+				sprintf(
868
+					__(
869
+						'Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
870
+						'event_espresso'
871
+					),
872
+					$label
873
+				)
874
+			);
875
+		}
876
+		// if auto-draft then throw an error
877
+		if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
878
+			EE_Error::overwrite_errors();
879
+			EE_Error::add_error(
880
+				sprintf(
881
+					__(
882
+						'This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.',
883
+						'event_espresso'
884
+					),
885
+					$label
886
+				),
887
+				__FILE__,
888
+				__FUNCTION__,
889
+				__LINE__
890
+			);
891
+		}
892
+		$this->loadEspressoEditorAssetManager();
893
+	}
894
+
895
+
896
+	/**
897
+	 * admin_footer_scripts_global
898
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
899
+	 * will apply on ALL EE_Admin pages.
900
+	 *
901
+	 * @access public
902
+	 * @return void
903
+	 */
904
+	public function admin_footer_scripts_global()
905
+	{
906
+		$this->_add_admin_page_ajax_loading_img();
907
+		$this->_add_admin_page_overlay();
908
+	}
909
+
910
+
911
+	/**
912
+	 * add in any global scripts for cpt routes
913
+	 *
914
+	 * @return void
915
+	 */
916
+	public function load_global_scripts_styles()
917
+	{
918
+		parent::load_global_scripts_styles();
919
+		if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
920
+			// setup custom post status object for localize script but only if we've got a cpt object
921
+			$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
922
+			if (! empty($statuses)) {
923
+				// get ALL statuses!
924
+				$statuses = $this->_cpt_model_obj->get_all_post_statuses();
925
+				// setup object
926
+				$ee_cpt_statuses = array();
927
+				foreach ($statuses as $status => $label) {
928
+					$ee_cpt_statuses[ $status ] = array(
929
+						'label'      => $label,
930
+						'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
931
+					);
932
+				}
933
+				wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
934
+			}
935
+		}
936
+	}
937
+
938
+
939
+	/**
940
+	 * @throws InvalidArgumentException
941
+	 * @throws InvalidDataTypeException
942
+	 * @throws InvalidInterfaceException
943
+	 */
944
+	private function loadEspressoEditorAssetManager()
945
+	{
946
+		EE_Dependency_Map::register_dependencies(
947
+			'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager',
948
+			array(
949
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
950
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
951
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
952
+			)
953
+		);
954
+		LoaderFactory::getLoader()->getShared(
955
+			'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager'
956
+		);
957
+		add_action('admin_enqueue_scripts', array($this, 'enqueueEspressoEditorAssets'), 100);
958
+	}
959
+
960
+
961
+	/**
962
+	 * enqueue_scripts - Load the scripts and css
963
+	 *
964
+	 * @return void
965
+	 * @throws DomainException
966
+	 */
967
+	public function enqueueEspressoEditorAssets()
968
+	{
969
+		wp_enqueue_style(EspressoEditorAssetManager::CSS_HANDLE_EDITOR);
970
+		wp_enqueue_script(EspressoEditorAssetManager::JS_HANDLE_EDITOR);
971
+	}
972
+
973
+
974
+	/**
975
+	 * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
976
+	 * insert/updates
977
+	 *
978
+	 * @param  int     $post_id ID of post being updated
979
+	 * @param  WP_Post $post    Post object from WP
980
+	 * @param  bool    $update  Whether this is an update or a new save.
981
+	 * @return void
982
+	 * @throws \EE_Error
983
+	 */
984
+	public function insert_update($post_id, $post, $update)
985
+	{
986
+		// make sure that if this is a revision OR trash action that we don't do any updates!
987
+		if (isset($this->_req_data['action'])
988
+			&& (
989
+				$this->_req_data['action'] === 'restore'
990
+				|| $this->_req_data['action'] === 'trash'
991
+			)
992
+		) {
993
+			return;
994
+		}
995
+		$this->_set_model_object($post_id, true, 'insert_update');
996
+		// if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
997
+		if ($update
998
+			&& (
999
+				! $this->_cpt_model_obj instanceof EE_CPT_Base
1000
+				|| $this->_cpt_model_obj->ID() !== $post_id
1001
+			)
1002
+		) {
1003
+			return;
1004
+		}
1005
+		// check for autosave and update our req_data property accordingly.
1006
+		/*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
1007 1007
             foreach( (array) $this->_req_data['ee_autosave_data'] as $id => $values ) {
1008 1008
 
1009 1009
                 foreach ( (array) $values as $key => $value ) {
@@ -1013,532 +1013,532 @@  discard block
 block discarded – undo
1013 1013
 
1014 1014
         }/**/ // TODO reactivate after autosave is implemented in 4.2
1015 1015
 
1016
-        // take care of updating any selected page_template IF this cpt supports it.
1017
-        if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
1018
-            // wp version aware.
1019
-            if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
1020
-                $page_templates = wp_get_theme()->get_page_templates();
1021
-            } else {
1022
-                $post->page_template = $this->_req_data['page_template'];
1023
-                $page_templates = wp_get_theme()->get_page_templates($post);
1024
-            }
1025
-            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
1026
-                EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1027
-            } else {
1028
-                update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
1029
-            }
1030
-        }
1031
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1032
-            return;
1033
-        } //TODO we'll remove this after reimplementing autosave in 4.2
1034
-        $this->_insert_update_cpt_item($post_id, $post);
1035
-    }
1036
-
1037
-
1038
-    /**
1039
-     * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
1040
-     * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
1041
-     * so we don't have to check for our CPT.
1042
-     *
1043
-     * @param  int $post_id ID of the post
1044
-     * @return void
1045
-     */
1046
-    public function dont_permanently_delete_ee_cpts($post_id)
1047
-    {
1048
-        // only do this if we're actually processing one of our CPTs
1049
-        // if our cpt object isn't existent then get out immediately.
1050
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1051
-            return;
1052
-        }
1053
-        delete_post_meta($post_id, '_wp_trash_meta_status');
1054
-        delete_post_meta($post_id, '_wp_trash_meta_time');
1055
-        // our cpts may have comments so let's take care of that too
1056
-        delete_post_meta($post_id, '_wp_trash_meta_comments_status');
1057
-    }
1058
-
1059
-
1060
-    /**
1061
-     * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1062
-     * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1063
-     * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1064
-     *
1065
-     * @param  int $post_id     ID of cpt item
1066
-     * @param  int $revision_id ID of revision being restored
1067
-     * @return void
1068
-     */
1069
-    public function restore_revision($post_id, $revision_id)
1070
-    {
1071
-        $this->_restore_cpt_item($post_id, $revision_id);
1072
-        // global action
1073
-        do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1074
-        // class specific action so you can limit hooking into a specific page.
1075
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1076
-    }
1077
-
1078
-
1079
-    /**
1080
-     * @see restore_revision() for details
1081
-     * @param  int $post_id     ID of cpt item
1082
-     * @param  int $revision_id ID of revision for item
1083
-     * @return void
1084
-     */
1085
-    abstract protected function _restore_cpt_item($post_id, $revision_id);
1086
-
1087
-
1088
-    /**
1089
-     * Execution of this method is added to the end of the load_page_dependencies method in the parent
1090
-     * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1091
-     * To fix we have to reset the current_screen using the page_slug
1092
-     * (which is identical - or should be - to our registered_post_type id.)
1093
-     * Also, since the core WP file loads the admin_header.php for WP
1094
-     * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1095
-     * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1096
-     *
1097
-     * @return void
1098
-     */
1099
-    public function modify_current_screen()
1100
-    {
1101
-        // ONLY do this if the current page_route IS a cpt route
1102
-        if (! $this->_cpt_route) {
1103
-            return;
1104
-        }
1105
-        // routing things REALLY early b/c this is a cpt admin page
1106
-        set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1107
-        $this->_current_screen = get_current_screen();
1108
-        $this->_current_screen->base = 'event-espresso';
1109
-        $this->_add_help_tabs(); // we make sure we add any help tabs back in!
1110
-        /*try {
1016
+		// take care of updating any selected page_template IF this cpt supports it.
1017
+		if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
1018
+			// wp version aware.
1019
+			if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
1020
+				$page_templates = wp_get_theme()->get_page_templates();
1021
+			} else {
1022
+				$post->page_template = $this->_req_data['page_template'];
1023
+				$page_templates = wp_get_theme()->get_page_templates($post);
1024
+			}
1025
+			if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[ $this->_req_data['page_template'] ])) {
1026
+				EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1027
+			} else {
1028
+				update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
1029
+			}
1030
+		}
1031
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1032
+			return;
1033
+		} //TODO we'll remove this after reimplementing autosave in 4.2
1034
+		$this->_insert_update_cpt_item($post_id, $post);
1035
+	}
1036
+
1037
+
1038
+	/**
1039
+	 * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
1040
+	 * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
1041
+	 * so we don't have to check for our CPT.
1042
+	 *
1043
+	 * @param  int $post_id ID of the post
1044
+	 * @return void
1045
+	 */
1046
+	public function dont_permanently_delete_ee_cpts($post_id)
1047
+	{
1048
+		// only do this if we're actually processing one of our CPTs
1049
+		// if our cpt object isn't existent then get out immediately.
1050
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1051
+			return;
1052
+		}
1053
+		delete_post_meta($post_id, '_wp_trash_meta_status');
1054
+		delete_post_meta($post_id, '_wp_trash_meta_time');
1055
+		// our cpts may have comments so let's take care of that too
1056
+		delete_post_meta($post_id, '_wp_trash_meta_comments_status');
1057
+	}
1058
+
1059
+
1060
+	/**
1061
+	 * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1062
+	 * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1063
+	 * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1064
+	 *
1065
+	 * @param  int $post_id     ID of cpt item
1066
+	 * @param  int $revision_id ID of revision being restored
1067
+	 * @return void
1068
+	 */
1069
+	public function restore_revision($post_id, $revision_id)
1070
+	{
1071
+		$this->_restore_cpt_item($post_id, $revision_id);
1072
+		// global action
1073
+		do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1074
+		// class specific action so you can limit hooking into a specific page.
1075
+		do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1076
+	}
1077
+
1078
+
1079
+	/**
1080
+	 * @see restore_revision() for details
1081
+	 * @param  int $post_id     ID of cpt item
1082
+	 * @param  int $revision_id ID of revision for item
1083
+	 * @return void
1084
+	 */
1085
+	abstract protected function _restore_cpt_item($post_id, $revision_id);
1086
+
1087
+
1088
+	/**
1089
+	 * Execution of this method is added to the end of the load_page_dependencies method in the parent
1090
+	 * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1091
+	 * To fix we have to reset the current_screen using the page_slug
1092
+	 * (which is identical - or should be - to our registered_post_type id.)
1093
+	 * Also, since the core WP file loads the admin_header.php for WP
1094
+	 * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1095
+	 * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1096
+	 *
1097
+	 * @return void
1098
+	 */
1099
+	public function modify_current_screen()
1100
+	{
1101
+		// ONLY do this if the current page_route IS a cpt route
1102
+		if (! $this->_cpt_route) {
1103
+			return;
1104
+		}
1105
+		// routing things REALLY early b/c this is a cpt admin page
1106
+		set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1107
+		$this->_current_screen = get_current_screen();
1108
+		$this->_current_screen->base = 'event-espresso';
1109
+		$this->_add_help_tabs(); // we make sure we add any help tabs back in!
1110
+		/*try {
1111 1111
             $this->_route_admin_request();
1112 1112
         } catch ( EE_Error $e ) {
1113 1113
             $e->get_error();
1114 1114
         }/**/
1115
-    }
1116
-
1117
-
1118
-    /**
1119
-     * This allows child classes to modify the default editor title that appears when people add a new or edit an
1120
-     * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1121
-     * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1122
-     * default to be.
1123
-     *
1124
-     * @param string $title The new title (or existing if there is no editor_title defined)
1125
-     * @return string
1126
-     */
1127
-    public function add_custom_editor_default_title($title)
1128
-    {
1129
-        return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1130
-            ? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1131
-            : $title;
1132
-    }
1133
-
1134
-
1135
-    /**
1136
-     * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1137
-     *
1138
-     * @param string $shortlink   The already generated shortlink
1139
-     * @param int    $id          Post ID for this item
1140
-     * @param string $context     The context for the link
1141
-     * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1142
-     * @return string
1143
-     */
1144
-    public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1145
-    {
1146
-        if (! empty($id) && get_option('permalink_structure') !== '') {
1147
-            $post = get_post($id);
1148
-            if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1149
-                $shortlink = home_url('?p=' . $post->ID);
1150
-            }
1151
-        }
1152
-        return $shortlink;
1153
-    }
1154
-
1155
-
1156
-    /**
1157
-     * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1158
-     * already run in modify_current_screen())
1159
-     *
1160
-     * @return void
1161
-     */
1162
-    public function route_admin_request()
1163
-    {
1164
-        if ($this->_cpt_route) {
1165
-            return;
1166
-        }
1167
-        try {
1168
-            $this->_route_admin_request();
1169
-        } catch (EE_Error $e) {
1170
-            $e->get_error();
1171
-        }
1172
-    }
1173
-
1174
-
1175
-    /**
1176
-     * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1177
-     *
1178
-     * @return void
1179
-     */
1180
-    public function cpt_post_form_hidden_input()
1181
-    {
1182
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1183
-        // we're also going to add the route value and the current page so we can direct autosave parsing correctly
1184
-        echo '<div id="ee-cpt-hidden-inputs">';
1185
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1186
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1187
-        echo '</div>';
1188
-    }
1189
-
1190
-
1191
-    /**
1192
-     * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1193
-     *
1194
-     * @param  string $location Original location url
1195
-     * @param  int    $status   Status for http header
1196
-     * @return string           new (or original) url to redirect to.
1197
-     */
1198
-    public function revision_redirect($location, $status)
1199
-    {
1200
-        // get revision
1201
-        $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1202
-        // can't do anything without revision so let's get out if not present
1203
-        if (empty($rev_id)) {
1204
-            return $location;
1205
-        }
1206
-        // get rev_post_data
1207
-        $rev = get_post($rev_id);
1208
-        $admin_url = $this->_admin_base_url;
1209
-        $query_args = array(
1210
-            'action'   => 'edit',
1211
-            'post'     => $rev->post_parent,
1212
-            'revision' => $rev_id,
1213
-            'message'  => 5,
1214
-        );
1215
-        $this->_process_notices($query_args, true);
1216
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1217
-    }
1218
-
1219
-
1220
-    /**
1221
-     * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1222
-     *
1223
-     * @param  string $link    the original generated link
1224
-     * @param  int    $id      post id
1225
-     * @param  string $context optional, defaults to display.  How to write the '&'
1226
-     * @return string          the link
1227
-     */
1228
-    public function modify_edit_post_link($link, $id, $context)
1229
-    {
1230
-        $post = get_post($id);
1231
-        if (! isset($this->_req_data['action'])
1232
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1233
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1234
-        ) {
1235
-            return $link;
1236
-        }
1237
-        $query_args = array(
1238
-            'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1239
-                ? $this->_cpt_edit_routes[ $post->post_type ]
1240
-                : 'edit',
1241
-            'post'   => $id,
1242
-        );
1243
-        return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1244
-    }
1245
-
1246
-
1247
-    /**
1248
-     * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1249
-     * our routes.
1250
-     *
1251
-     * @param  string $delete_link  original delete link
1252
-     * @param  int    $post_id      id of cpt object
1253
-     * @param  bool   $force_delete whether this is forcing a hard delete instead of trash
1254
-     * @return string new delete link
1255
-     * @throws EE_Error
1256
-     */
1257
-    public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1258
-    {
1259
-        $post = get_post($post_id);
1260
-
1261
-        if (empty($this->_req_data['action'])
1262
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1263
-            || ! $post instanceof WP_Post
1264
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1265
-        ) {
1266
-            return $delete_link;
1267
-        }
1268
-        $this->_set_model_object($post->ID, true);
1269
-
1270
-        // returns something like `trash_event` or `trash_attendee` or `trash_venue`
1271
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1272
-
1273
-        return EE_Admin_Page::add_query_args_and_nonce(
1274
-            array(
1275
-                'page'   => $this->_req_data['page'],
1276
-                'action' => $action,
1277
-                $this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1278
-                         => $post->ID,
1279
-            ),
1280
-            admin_url()
1281
-        );
1282
-    }
1283
-
1284
-
1285
-    /**
1286
-     * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1287
-     * so that we can hijack the default redirect locations for wp custom post types
1288
-     * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1289
-     *
1290
-     * @param  string $location This is the incoming currently set redirect location
1291
-     * @param  string $post_id  This is the 'ID' value of the wp_posts table
1292
-     * @return string           the new location to redirect to
1293
-     */
1294
-    public function cpt_post_location_redirect($location, $post_id)
1295
-    {
1296
-        // we DO have a match so let's setup the url
1297
-        // we have to get the post to determine our route
1298
-        $post = get_post($post_id);
1299
-        $edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1300
-        // shared query_args
1301
-        $query_args = array('action' => $edit_route, 'post' => $post_id);
1302
-        $admin_url = $this->_admin_base_url;
1303
-        if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1304
-            $status = get_post_status($post_id);
1305
-            if (isset($this->_req_data['publish'])) {
1306
-                switch ($status) {
1307
-                    case 'pending':
1308
-                        $message = 8;
1309
-                        break;
1310
-                    case 'future':
1311
-                        $message = 9;
1312
-                        break;
1313
-                    default:
1314
-                        $message = 6;
1315
-                }
1316
-            } else {
1317
-                $message = 'draft' === $status ? 10 : 1;
1318
-            }
1319
-        } elseif (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1320
-            $message = 2;
1321
-        } elseif (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1322
-            $message = 3;
1323
-        } elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1324
-            $message = 7;
1325
-        } else {
1326
-            $message = 4;
1327
-        }
1328
-        // change the message if the post type is not viewable on the frontend
1329
-        $this->_cpt_object = get_post_type_object($post->post_type);
1330
-        $message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1331
-        $query_args = array_merge(array('message' => $message), $query_args);
1332
-        $this->_process_notices($query_args, true);
1333
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1334
-    }
1335
-
1336
-
1337
-    /**
1338
-     * This method is called to inject nav tabs on core WP cpt pages
1339
-     *
1340
-     * @access public
1341
-     * @return void
1342
-     */
1343
-    public function inject_nav_tabs()
1344
-    {
1345
-        // can we hijack and insert the nav_tabs?
1346
-        $nav_tabs = $this->_get_main_nav_tabs();
1347
-        // first close off existing form tag
1348
-        $html = '>';
1349
-        $html .= $nav_tabs;
1350
-        // now let's handle the remaining tag ( missing ">" is CORRECT )
1351
-        $html .= '<span></span';
1352
-        echo $html;
1353
-    }
1354
-
1355
-
1356
-    /**
1357
-     * This just sets up the post update messages when an update form is loaded
1358
-     *
1359
-     * @access public
1360
-     * @param  array $messages the original messages array
1361
-     * @return array           the new messages array
1362
-     */
1363
-    public function post_update_messages($messages)
1364
-    {
1365
-        global $post;
1366
-        $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1367
-        $id = empty($id) && is_object($post) ? $post->ID : null;
1368
-        /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1115
+	}
1116
+
1117
+
1118
+	/**
1119
+	 * This allows child classes to modify the default editor title that appears when people add a new or edit an
1120
+	 * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1121
+	 * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1122
+	 * default to be.
1123
+	 *
1124
+	 * @param string $title The new title (or existing if there is no editor_title defined)
1125
+	 * @return string
1126
+	 */
1127
+	public function add_custom_editor_default_title($title)
1128
+	{
1129
+		return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1130
+			? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1131
+			: $title;
1132
+	}
1133
+
1134
+
1135
+	/**
1136
+	 * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1137
+	 *
1138
+	 * @param string $shortlink   The already generated shortlink
1139
+	 * @param int    $id          Post ID for this item
1140
+	 * @param string $context     The context for the link
1141
+	 * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1142
+	 * @return string
1143
+	 */
1144
+	public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1145
+	{
1146
+		if (! empty($id) && get_option('permalink_structure') !== '') {
1147
+			$post = get_post($id);
1148
+			if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1149
+				$shortlink = home_url('?p=' . $post->ID);
1150
+			}
1151
+		}
1152
+		return $shortlink;
1153
+	}
1154
+
1155
+
1156
+	/**
1157
+	 * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1158
+	 * already run in modify_current_screen())
1159
+	 *
1160
+	 * @return void
1161
+	 */
1162
+	public function route_admin_request()
1163
+	{
1164
+		if ($this->_cpt_route) {
1165
+			return;
1166
+		}
1167
+		try {
1168
+			$this->_route_admin_request();
1169
+		} catch (EE_Error $e) {
1170
+			$e->get_error();
1171
+		}
1172
+	}
1173
+
1174
+
1175
+	/**
1176
+	 * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1177
+	 *
1178
+	 * @return void
1179
+	 */
1180
+	public function cpt_post_form_hidden_input()
1181
+	{
1182
+		echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1183
+		// we're also going to add the route value and the current page so we can direct autosave parsing correctly
1184
+		echo '<div id="ee-cpt-hidden-inputs">';
1185
+		echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1186
+		echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1187
+		echo '</div>';
1188
+	}
1189
+
1190
+
1191
+	/**
1192
+	 * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1193
+	 *
1194
+	 * @param  string $location Original location url
1195
+	 * @param  int    $status   Status for http header
1196
+	 * @return string           new (or original) url to redirect to.
1197
+	 */
1198
+	public function revision_redirect($location, $status)
1199
+	{
1200
+		// get revision
1201
+		$rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1202
+		// can't do anything without revision so let's get out if not present
1203
+		if (empty($rev_id)) {
1204
+			return $location;
1205
+		}
1206
+		// get rev_post_data
1207
+		$rev = get_post($rev_id);
1208
+		$admin_url = $this->_admin_base_url;
1209
+		$query_args = array(
1210
+			'action'   => 'edit',
1211
+			'post'     => $rev->post_parent,
1212
+			'revision' => $rev_id,
1213
+			'message'  => 5,
1214
+		);
1215
+		$this->_process_notices($query_args, true);
1216
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1217
+	}
1218
+
1219
+
1220
+	/**
1221
+	 * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1222
+	 *
1223
+	 * @param  string $link    the original generated link
1224
+	 * @param  int    $id      post id
1225
+	 * @param  string $context optional, defaults to display.  How to write the '&'
1226
+	 * @return string          the link
1227
+	 */
1228
+	public function modify_edit_post_link($link, $id, $context)
1229
+	{
1230
+		$post = get_post($id);
1231
+		if (! isset($this->_req_data['action'])
1232
+			|| ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1233
+			|| $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1234
+		) {
1235
+			return $link;
1236
+		}
1237
+		$query_args = array(
1238
+			'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1239
+				? $this->_cpt_edit_routes[ $post->post_type ]
1240
+				: 'edit',
1241
+			'post'   => $id,
1242
+		);
1243
+		return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1244
+	}
1245
+
1246
+
1247
+	/**
1248
+	 * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1249
+	 * our routes.
1250
+	 *
1251
+	 * @param  string $delete_link  original delete link
1252
+	 * @param  int    $post_id      id of cpt object
1253
+	 * @param  bool   $force_delete whether this is forcing a hard delete instead of trash
1254
+	 * @return string new delete link
1255
+	 * @throws EE_Error
1256
+	 */
1257
+	public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1258
+	{
1259
+		$post = get_post($post_id);
1260
+
1261
+		if (empty($this->_req_data['action'])
1262
+			|| ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1263
+			|| ! $post instanceof WP_Post
1264
+			|| $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1265
+		) {
1266
+			return $delete_link;
1267
+		}
1268
+		$this->_set_model_object($post->ID, true);
1269
+
1270
+		// returns something like `trash_event` or `trash_attendee` or `trash_venue`
1271
+		$action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1272
+
1273
+		return EE_Admin_Page::add_query_args_and_nonce(
1274
+			array(
1275
+				'page'   => $this->_req_data['page'],
1276
+				'action' => $action,
1277
+				$this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1278
+						 => $post->ID,
1279
+			),
1280
+			admin_url()
1281
+		);
1282
+	}
1283
+
1284
+
1285
+	/**
1286
+	 * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1287
+	 * so that we can hijack the default redirect locations for wp custom post types
1288
+	 * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1289
+	 *
1290
+	 * @param  string $location This is the incoming currently set redirect location
1291
+	 * @param  string $post_id  This is the 'ID' value of the wp_posts table
1292
+	 * @return string           the new location to redirect to
1293
+	 */
1294
+	public function cpt_post_location_redirect($location, $post_id)
1295
+	{
1296
+		// we DO have a match so let's setup the url
1297
+		// we have to get the post to determine our route
1298
+		$post = get_post($post_id);
1299
+		$edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1300
+		// shared query_args
1301
+		$query_args = array('action' => $edit_route, 'post' => $post_id);
1302
+		$admin_url = $this->_admin_base_url;
1303
+		if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1304
+			$status = get_post_status($post_id);
1305
+			if (isset($this->_req_data['publish'])) {
1306
+				switch ($status) {
1307
+					case 'pending':
1308
+						$message = 8;
1309
+						break;
1310
+					case 'future':
1311
+						$message = 9;
1312
+						break;
1313
+					default:
1314
+						$message = 6;
1315
+				}
1316
+			} else {
1317
+				$message = 'draft' === $status ? 10 : 1;
1318
+			}
1319
+		} elseif (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1320
+			$message = 2;
1321
+		} elseif (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1322
+			$message = 3;
1323
+		} elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1324
+			$message = 7;
1325
+		} else {
1326
+			$message = 4;
1327
+		}
1328
+		// change the message if the post type is not viewable on the frontend
1329
+		$this->_cpt_object = get_post_type_object($post->post_type);
1330
+		$message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1331
+		$query_args = array_merge(array('message' => $message), $query_args);
1332
+		$this->_process_notices($query_args, true);
1333
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1334
+	}
1335
+
1336
+
1337
+	/**
1338
+	 * This method is called to inject nav tabs on core WP cpt pages
1339
+	 *
1340
+	 * @access public
1341
+	 * @return void
1342
+	 */
1343
+	public function inject_nav_tabs()
1344
+	{
1345
+		// can we hijack and insert the nav_tabs?
1346
+		$nav_tabs = $this->_get_main_nav_tabs();
1347
+		// first close off existing form tag
1348
+		$html = '>';
1349
+		$html .= $nav_tabs;
1350
+		// now let's handle the remaining tag ( missing ">" is CORRECT )
1351
+		$html .= '<span></span';
1352
+		echo $html;
1353
+	}
1354
+
1355
+
1356
+	/**
1357
+	 * This just sets up the post update messages when an update form is loaded
1358
+	 *
1359
+	 * @access public
1360
+	 * @param  array $messages the original messages array
1361
+	 * @return array           the new messages array
1362
+	 */
1363
+	public function post_update_messages($messages)
1364
+	{
1365
+		global $post;
1366
+		$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1367
+		$id = empty($id) && is_object($post) ? $post->ID : null;
1368
+		/*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1369 1369
 
1370 1370
         $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : '';/**/
1371
-        $messages[ $post->post_type ] = array(
1372
-            0  => '', // Unused. Messages start at index 1.
1373
-            1  => sprintf(
1374
-                __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1375
-                $this->_cpt_object->labels->singular_name,
1376
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1377
-                '</a>'
1378
-            ),
1379
-            2  => __('Custom field updated', 'event_espresso'),
1380
-            3  => __('Custom field deleted.', 'event_espresso'),
1381
-            4  => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1382
-            5  => isset($_GET['revision']) ? sprintf(
1383
-                __('%s restored to revision from %s', 'event_espresso'),
1384
-                $this->_cpt_object->labels->singular_name,
1385
-                wp_post_revision_title((int) $_GET['revision'], false)
1386
-            )
1387
-                : false,
1388
-            6  => sprintf(
1389
-                __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1390
-                $this->_cpt_object->labels->singular_name,
1391
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1392
-                '</a>'
1393
-            ),
1394
-            7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1395
-            8  => sprintf(
1396
-                __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1397
-                $this->_cpt_object->labels->singular_name,
1398
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1399
-                '</a>'
1400
-            ),
1401
-            9  => sprintf(
1402
-                __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1403
-                $this->_cpt_object->labels->singular_name,
1404
-                '<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1405
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1406
-                '</a>'
1407
-            ),
1408
-            10 => sprintf(
1409
-                __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1410
-                $this->_cpt_object->labels->singular_name,
1411
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1412
-                '</a>'
1413
-            ),
1414
-        );
1415
-        return $messages;
1416
-    }
1417
-
1418
-
1419
-    /**
1420
-     * default method for the 'create_new' route for cpt admin pages.
1421
-     * For reference what to include in here, see wp-admin/post-new.php
1422
-     *
1423
-     * @access  protected
1424
-     * @return void
1425
-     */
1426
-    protected function _create_new_cpt_item()
1427
-    {
1428
-        // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1429
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1430
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1431
-        $post_type_object = $this->_cpt_object;
1432
-        $title = $post_type_object->labels->add_new_item;
1433
-        $post = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1434
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1435
-        // modify the default editor title field with default title.
1436
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1437
-        $this->loadEditorTemplate(true);
1438
-    }
1439
-
1440
-
1441
-    /**
1442
-     * Enqueues auto-save and loads the editor template
1443
-     *
1444
-     * @param bool $creating
1445
-     */
1446
-    private function loadEditorTemplate($creating = true)
1447
-    {
1448
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1449
-        // these vars are used by the template
1450
-        $editing = true;
1451
-        $post_ID = $post->ID;
1452
-        if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1453
-            // only enqueue autosave when creating event (necessary to get permalink/url generated)
1454
-            // otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1455
-            if ($creating) {
1456
-                wp_enqueue_script('autosave');
1457
-            } else {
1458
-                if (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1459
-                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1460
-                ) {
1461
-                    $create_new_action = apply_filters(
1462
-                        'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1463
-                        'create_new',
1464
-                        $this
1465
-                    );
1466
-                    $post_new_file = EE_Admin_Page::add_query_args_and_nonce(
1467
-                        array(
1468
-                            'action' => $create_new_action,
1469
-                            'page'   => $this->page_slug,
1470
-                        ),
1471
-                        'admin.php'
1472
-                    );
1473
-                }
1474
-            }
1475
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1476
-        }
1477
-    }
1478
-
1479
-
1480
-    public function add_new_admin_page_global()
1481
-    {
1482
-        $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1483
-        ?>
1371
+		$messages[ $post->post_type ] = array(
1372
+			0  => '', // Unused. Messages start at index 1.
1373
+			1  => sprintf(
1374
+				__('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1375
+				$this->_cpt_object->labels->singular_name,
1376
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1377
+				'</a>'
1378
+			),
1379
+			2  => __('Custom field updated', 'event_espresso'),
1380
+			3  => __('Custom field deleted.', 'event_espresso'),
1381
+			4  => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1382
+			5  => isset($_GET['revision']) ? sprintf(
1383
+				__('%s restored to revision from %s', 'event_espresso'),
1384
+				$this->_cpt_object->labels->singular_name,
1385
+				wp_post_revision_title((int) $_GET['revision'], false)
1386
+			)
1387
+				: false,
1388
+			6  => sprintf(
1389
+				__('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1390
+				$this->_cpt_object->labels->singular_name,
1391
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1392
+				'</a>'
1393
+			),
1394
+			7  => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1395
+			8  => sprintf(
1396
+				__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1397
+				$this->_cpt_object->labels->singular_name,
1398
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1399
+				'</a>'
1400
+			),
1401
+			9  => sprintf(
1402
+				__('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1403
+				$this->_cpt_object->labels->singular_name,
1404
+				'<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1405
+				'<a target="_blank" href="' . esc_url(get_permalink($id)),
1406
+				'</a>'
1407
+			),
1408
+			10 => sprintf(
1409
+				__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1410
+				$this->_cpt_object->labels->singular_name,
1411
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1412
+				'</a>'
1413
+			),
1414
+		);
1415
+		return $messages;
1416
+	}
1417
+
1418
+
1419
+	/**
1420
+	 * default method for the 'create_new' route for cpt admin pages.
1421
+	 * For reference what to include in here, see wp-admin/post-new.php
1422
+	 *
1423
+	 * @access  protected
1424
+	 * @return void
1425
+	 */
1426
+	protected function _create_new_cpt_item()
1427
+	{
1428
+		// gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1429
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1430
+		$post_type = $this->_cpt_routes[ $this->_req_action ];
1431
+		$post_type_object = $this->_cpt_object;
1432
+		$title = $post_type_object->labels->add_new_item;
1433
+		$post = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1434
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1435
+		// modify the default editor title field with default title.
1436
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1437
+		$this->loadEditorTemplate(true);
1438
+	}
1439
+
1440
+
1441
+	/**
1442
+	 * Enqueues auto-save and loads the editor template
1443
+	 *
1444
+	 * @param bool $creating
1445
+	 */
1446
+	private function loadEditorTemplate($creating = true)
1447
+	{
1448
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1449
+		// these vars are used by the template
1450
+		$editing = true;
1451
+		$post_ID = $post->ID;
1452
+		if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1453
+			// only enqueue autosave when creating event (necessary to get permalink/url generated)
1454
+			// otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1455
+			if ($creating) {
1456
+				wp_enqueue_script('autosave');
1457
+			} else {
1458
+				if (isset($this->_cpt_routes[ $this->_req_data['action'] ])
1459
+					&& ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1460
+				) {
1461
+					$create_new_action = apply_filters(
1462
+						'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1463
+						'create_new',
1464
+						$this
1465
+					);
1466
+					$post_new_file = EE_Admin_Page::add_query_args_and_nonce(
1467
+						array(
1468
+							'action' => $create_new_action,
1469
+							'page'   => $this->page_slug,
1470
+						),
1471
+						'admin.php'
1472
+					);
1473
+				}
1474
+			}
1475
+			include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1476
+		}
1477
+	}
1478
+
1479
+
1480
+	public function add_new_admin_page_global()
1481
+	{
1482
+		$admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1483
+		?>
1484 1484
         <script type="text/javascript">
1485 1485
             adminpage = '<?php echo $admin_page; ?>';
1486 1486
         </script>
1487 1487
         <?php
1488
-    }
1489
-
1490
-
1491
-    /**
1492
-     * default method for the 'edit' route for cpt admin pages
1493
-     * For reference on what to put in here, refer to wp-admin/post.php
1494
-     *
1495
-     * @access protected
1496
-     * @return string   template for edit cpt form
1497
-     */
1498
-    protected function _edit_cpt_item()
1499
-    {
1500
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1501
-        $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1502
-        $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1503
-        if (empty($post)) {
1504
-            wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1505
-        }
1506
-        if (! empty($_GET['get-post-lock'])) {
1507
-            wp_set_post_lock($post_id);
1508
-            wp_redirect(get_edit_post_link($post_id, 'url'));
1509
-            exit();
1510
-        }
1511
-
1512
-        // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1513
-        $post_type = $this->_cpt_routes[ $this->_req_action ];
1514
-        $post_type_object = $this->_cpt_object;
1515
-
1516
-        if (! wp_check_post_lock($post->ID)) {
1517
-            wp_set_post_lock($post->ID);
1518
-        }
1519
-        add_action('admin_footer', '_admin_notice_post_locked');
1520
-        if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1521
-            wp_enqueue_script('admin-comments');
1522
-            enqueue_comment_hotkeys_js();
1523
-        }
1524
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1525
-        // modify the default editor title field with default title.
1526
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1527
-        $this->loadEditorTemplate(false);
1528
-    }
1529
-
1530
-
1531
-
1532
-    /**
1533
-     * some getters
1534
-     */
1535
-    /**
1536
-     * This returns the protected _cpt_model_obj property
1537
-     *
1538
-     * @return EE_CPT_Base
1539
-     */
1540
-    public function get_cpt_model_obj()
1541
-    {
1542
-        return $this->_cpt_model_obj;
1543
-    }
1488
+	}
1489
+
1490
+
1491
+	/**
1492
+	 * default method for the 'edit' route for cpt admin pages
1493
+	 * For reference on what to put in here, refer to wp-admin/post.php
1494
+	 *
1495
+	 * @access protected
1496
+	 * @return string   template for edit cpt form
1497
+	 */
1498
+	protected function _edit_cpt_item()
1499
+	{
1500
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1501
+		$post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1502
+		$post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1503
+		if (empty($post)) {
1504
+			wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?', 'event_espresso'));
1505
+		}
1506
+		if (! empty($_GET['get-post-lock'])) {
1507
+			wp_set_post_lock($post_id);
1508
+			wp_redirect(get_edit_post_link($post_id, 'url'));
1509
+			exit();
1510
+		}
1511
+
1512
+		// template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1513
+		$post_type = $this->_cpt_routes[ $this->_req_action ];
1514
+		$post_type_object = $this->_cpt_object;
1515
+
1516
+		if (! wp_check_post_lock($post->ID)) {
1517
+			wp_set_post_lock($post->ID);
1518
+		}
1519
+		add_action('admin_footer', '_admin_notice_post_locked');
1520
+		if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1521
+			wp_enqueue_script('admin-comments');
1522
+			enqueue_comment_hotkeys_js();
1523
+		}
1524
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1525
+		// modify the default editor title field with default title.
1526
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1527
+		$this->loadEditorTemplate(false);
1528
+	}
1529
+
1530
+
1531
+
1532
+	/**
1533
+	 * some getters
1534
+	 */
1535
+	/**
1536
+	 * This returns the protected _cpt_model_obj property
1537
+	 *
1538
+	 * @return EE_CPT_Base
1539
+	 */
1540
+	public function get_cpt_model_obj()
1541
+	{
1542
+		return $this->_cpt_model_obj;
1543
+	}
1544 1544
 }
Please login to merge, or discard this patch.
libraries/line_item_display/EE_SPCO_Line_Item_Display_Strategy.strategy.php 2 patches
Indentation   +641 added lines, -641 removed lines patch added patch discarded remove patch
@@ -12,645 +12,645 @@
 block discarded – undo
12 12
 class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display
13 13
 {
14 14
 
15
-    /**
16
-     * array of events
17
-     *
18
-     * @type EE_Line_Item[] $_events
19
-     */
20
-    private $_events = array();
21
-
22
-    /**
23
-     * whether to display the taxes row or not
24
-     *
25
-     * @type bool $_show_taxes
26
-     */
27
-    private $_show_taxes = false;
28
-
29
-    /**
30
-     * html for any tax rows
31
-     *
32
-     * @type string $_show_taxes
33
-     */
34
-    private $_taxes_html = '';
35
-
36
-    /**
37
-     * total amount including tax we can bill for at this time
38
-     *
39
-     * @type float $_grand_total
40
-     */
41
-    private $_grand_total = 0.00;
42
-
43
-    /**
44
-     * total number of items being billed for
45
-     *
46
-     * @type int $_total_items
47
-     */
48
-    private $_total_items = 0;
49
-
50
-
51
-
52
-    /**
53
-     * @return float
54
-     */
55
-    public function grand_total()
56
-    {
57
-        return $this->_grand_total;
58
-    }
59
-
60
-
61
-
62
-    /**
63
-     * @return int
64
-     */
65
-    public function total_items()
66
-    {
67
-        return $this->_total_items;
68
-    }
69
-
70
-
71
-
72
-    /**
73
-     * @param EE_Line_Item $line_item
74
-     * @param array        $options
75
-     * @param EE_Line_Item $parent_line_item
76
-     * @return mixed
77
-     * @throws EE_Error
78
-     */
79
-    public function display_line_item(
80
-        EE_Line_Item $line_item,
81
-        $options = array(),
82
-        EE_Line_Item $parent_line_item = null
83
-    ) {
84
-        $html = '';
85
-        // set some default options and merge with incoming
86
-        $default_options = array(
87
-            'show_desc' => true,  //    true        false
88
-            'odd'       => false,
89
-        );
90
-        $options = array_merge($default_options, (array) $options);
91
-        switch ($line_item->type()) {
92
-            case EEM_Line_Item::type_line_item:
93
-                $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
94
-                if ($line_item->OBJ_type() === 'Ticket') {
95
-                    // item row
96
-                    $html .= $this->_ticket_row($line_item, $options);
97
-                } else {
98
-                    // item row
99
-                    $html .= $this->_item_row($line_item, $options);
100
-                }
101
-                if (apply_filters(
102
-                    'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items',
103
-                    true
104
-                )
105
-                ) {
106
-                    // got any kids?
107
-                    foreach ($line_item->children() as $child_line_item) {
108
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
109
-                    }
110
-                }
111
-                break;
112
-            case EEM_Line_Item::type_sub_line_item:
113
-                $html .= $this->_sub_item_row($line_item, $options, $parent_line_item);
114
-                break;
115
-            case EEM_Line_Item::type_sub_total:
116
-                static $sub_total = 0;
117
-                $event_sub_total = 0;
118
-                $text = esc_html__('Sub-Total', 'event_espresso');
119
-                if ($line_item->OBJ_type() === 'Event') {
120
-                    $options['event_id'] = $event_id = $line_item->OBJ_ID();
121
-                    if (! isset($this->_events[ $options['event_id'] ])) {
122
-                        $event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
123
-                        // if event has default reg status of Not Approved, then don't display info on it
124
-                        if ($event instanceof EE_Event
125
-                            && $event->default_registration_status() === EEM_Registration::status_id_not_approved
126
-                        ) {
127
-                            $display_event = false;
128
-                            // unless there are registrations for it that are returning to pay
129
-                            if (isset($options['registrations']) && is_array($options['registrations'])) {
130
-                                foreach ($options['registrations'] as $registration) {
131
-                                    if (! $registration instanceof EE_Registration) {
132
-                                        continue;
133
-                                    }
134
-                                    $display_event = $registration->event_ID() === $options['event_id']
135
-                                                     && $registration->status_ID() !== EEM_Registration::status_id_not_approved
136
-                                        ? true
137
-                                        : $display_event;
138
-                                }
139
-                            }
140
-                            if (! $display_event) {
141
-                                return '';
142
-                            }
143
-                        }
144
-                        $this->_events[ $options['event_id'] ] = 0;
145
-                        $html .= $this->_event_row($line_item);
146
-                        $text = esc_html__('Event Sub-Total', 'event_espresso');
147
-                    }
148
-                }
149
-                $child_line_items = $line_item->children();
150
-                // loop thru children
151
-                foreach ($child_line_items as $child_line_item) {
152
-                    // recursively feed children back into this method
153
-                    $html .= $this->display_line_item($child_line_item, $options, $line_item);
154
-                }
155
-                $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0;
156
-                $sub_total += $event_sub_total;
157
-                if ((
158
-                        // event subtotals
159
-                        $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1
160
-                    )
161
-                    || (
162
-                        // pre-tax subtotals
163
-                        $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1
164
-                    )
165
-                ) {
166
-                    $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total;
167
-                    $html .= $this->_sub_total_row($line_item, $text, $options);
168
-                }
169
-                break;
170
-            case EEM_Line_Item::type_tax:
171
-                if ($this->_show_taxes) {
172
-                    $this->_taxes_html .= $this->_tax_row($line_item, $options);
173
-                }
174
-                break;
175
-            case EEM_Line_Item::type_tax_sub_total:
176
-                if ($this->_show_taxes) {
177
-                    $child_line_items = $line_item->children();
178
-                    // loop thru children
179
-                    foreach ($child_line_items as $child_line_item) {
180
-                        // recursively feed children back into this method
181
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
182
-                    }
183
-                    if (count($child_line_items) > 1) {
184
-                        $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso'));
185
-                    }
186
-                }
187
-                break;
188
-            case EEM_Line_Item::type_total:
189
-                // get all child line items
190
-                $children = $line_item->children();
191
-                // loop thru all non-tax child line items
192
-                foreach ($children as $child_line_item) {
193
-                    if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) {
194
-                        // recursively feed children back into this method
195
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
196
-                    }
197
-                }
198
-                // now loop thru  tax child line items
199
-                foreach ($children as $child_line_item) {
200
-                    if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) {
201
-                        // recursively feed children back into this method
202
-                        $html .= $this->display_line_item($child_line_item, $options, $line_item);
203
-                    }
204
-                }
205
-                $html .= $this->_taxes_html;
206
-                $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso'));
207
-                $html .= $this->_payments_and_amount_owing_rows($line_item, $options);
208
-                break;
209
-        }
210
-        return $html;
211
-    }
212
-
213
-
214
-
215
-    /**
216
-     * _event_row - basically a Heading row displayed once above each event's ticket rows
217
-     *
218
-     * @param EE_Line_Item $line_item
219
-     * @return mixed
220
-     */
221
-    private function _event_row(EE_Line_Item $line_item)
222
-    {
223
-        // start of row
224
-        $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd');
225
-        // event name td
226
-        $html .= EEH_HTML::td(
227
-            EEH_HTML::strong($line_item->name()),
228
-            '',
229
-            'event-header',
230
-            '',
231
-            ' colspan="4"'
232
-        );
233
-        // end of row
234
-        $html .= EEH_HTML::trx();
235
-        return $html;
236
-    }
237
-
238
-
239
-
240
-    /**
241
-     * _ticket_row
242
-     *
243
-     * @param EE_Line_Item $line_item
244
-     * @param array        $options
245
-     * @return mixed
246
-     * @throws EE_Error
247
-     */
248
-    private function _ticket_row(EE_Line_Item $line_item, $options = array())
249
-    {
250
-        // start of row
251
-        $row_class = $options['odd'] ? 'item odd' : 'item';
252
-        $html = EEH_HTML::tr('', '', $row_class);
253
-        // name && desc
254
-        $name_and_desc = apply_filters(
255
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
256
-            $line_item->name(),
257
-            $line_item
258
-        );
259
-        $name_and_desc .= apply_filters(
260
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
261
-            (
262
-                $options['show_desc']
263
-                    ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
264
-                    : ''
265
-            ),
266
-            $line_item,
267
-            $options
268
-        );
269
-        $name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
270
-        // name td
271
-        $html .= EEH_HTML::td( /*__FUNCTION__ .*/
272
-            $name_and_desc,
273
-            '',
274
-            'item_l'
275
-        );
276
-        // price td
277
-        $price = apply_filters(
278
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__price',
279
-            $line_item->unit_price_no_code(),
280
-            $line_item
281
-        );
282
-        $html .= EEH_HTML::td($price, '', 'item_c jst-rght');
283
-        // quantity td
284
-        $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
285
-        $this->_total_items += $line_item->quantity();
286
-        // determine total for line item
287
-        $total = apply_filters(
288
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__total',
289
-            $line_item->total(),
290
-            $line_item
291
-        );
292
-        $this->_events[ $options['event_id'] ] += $total;
293
-        // total td
294
-        $html .= EEH_HTML::td(
295
-            EEH_Template::format_currency($total, false, false),
296
-            '',
297
-            'item_r jst-rght'
298
-        );
299
-        // end of row
300
-        $html .= EEH_HTML::trx();
301
-        return $html;
302
-    }
303
-
304
-
305
-
306
-    /**
307
-     * _item_row
308
-     *
309
-     * @param EE_Line_Item $line_item
310
-     * @param array        $options
311
-     * @return mixed
312
-     * @throws EE_Error
313
-     */
314
-    private function _item_row(EE_Line_Item $line_item, $options = array())
315
-    {
316
-        // start of row
317
-        $row_class = $options['odd'] ? 'item odd' : 'item';
318
-        $html = EEH_HTML::tr('', '', $row_class);
319
-        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
320
-        // name && desc
321
-        $name_and_desc = apply_filters(
322
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
323
-            $obj_name . $line_item->name(),
324
-            $line_item
325
-        );
326
-        $name_and_desc .= apply_filters(
327
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
328
-            (
329
-                $options['show_desc']
330
-                ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
331
-                : ''
332
-            ),
333
-            $line_item,
334
-            $options
335
-        );
336
-        $name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
337
-        // name td
338
-        $html .= EEH_HTML::td($name_and_desc, '', 'item_l');
339
-        // price td
340
-        if ($line_item->is_percent()) {
341
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
342
-        } else {
343
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
344
-        }
345
-        // quantity td
346
-        $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
347
-        // $total = $line_item->total() * $line_item->quantity();
348
-        $total = $line_item->total();
349
-        if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) {
350
-            $this->_events[ $options['event_id'] ] += $total;
351
-        }
352
-        // total td
353
-        $html .= EEH_HTML::td(
354
-            EEH_Template::format_currency($total, false, false),
355
-            '',
356
-            'item_r jst-rght'
357
-        );
358
-        // end of row
359
-        $html .= EEH_HTML::trx();
360
-        return $html;
361
-    }
362
-
363
-
364
-
365
-    /**
366
-     * _sub_item_row
367
-     *
368
-     * @param EE_Line_Item $line_item
369
-     * @param array        $options
370
-     * @param EE_Line_Item $parent_line_item
371
-     * @return mixed
372
-     * @throws EE_Error
373
-     */
374
-    private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null)
375
-    {
376
-        if ($parent_line_item instanceof  EE_Line_Item
377
-            && $line_item->children() === array()
378
-            && $line_item->name() === $parent_line_item->name()
379
-            && apply_filters(
380
-                'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item',
381
-                true
382
-            )
383
-        ) {
384
-            return '';
385
-        }
386
-        // start of row
387
-        $html = EEH_HTML::tr('', '', 'item sub-item-row');
388
-        // name && desc
389
-        $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right')
390
-                         . $line_item->name();
391
-        $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '
392
-                                                  . $line_item->desc()
393
-                                                  . '</span>' : '';
394
-        // name td
395
-        $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item');
396
-        $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1;
397
-        // discount/surcharge td
398
-        if ($line_item->is_percent()) {
399
-            $html .= EEH_HTML::td(
400
-                EEH_Template::format_currency(
401
-                    $line_item->total() / $qty,
402
-                    false,
403
-                    false
404
-                ),
405
-                '',
406
-                'item_c jst-rght'
407
-            );
408
-        } else {
409
-            $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
410
-        }
411
-        // no quantity td
412
-        $html .= EEH_HTML::td();
413
-        // no total td
414
-        $html .= EEH_HTML::td();
415
-        // end of row
416
-        $html .= EEH_HTML::trx();
417
-        $html = apply_filters(
418
-            'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html',
419
-            $html,
420
-            $line_item,
421
-            $options,
422
-            $parent_line_item
423
-        );
424
-        return $html;
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     * _tax_row
431
-     *
432
-     * @param EE_Line_Item $line_item
433
-     * @param array        $options
434
-     * @return mixed
435
-     * @throws EE_Error
436
-     */
437
-    private function _tax_row(EE_Line_Item $line_item, $options = array())
438
-    {
439
-        // start of row
440
-        $html = EEH_HTML::tr('', 'item sub-item tax-total');
441
-        // name && desc
442
-        $name_and_desc = $line_item->name();
443
-        $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
444
-                          . esc_html__(' * taxable items', 'event_espresso') . '</span>';
445
-        $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
446
-        // name td
447
-        $html .= EEH_HTML::td( /*__FUNCTION__ .*/
448
-            $name_and_desc,
449
-            '',
450
-            'item_l sub-item'
451
-        );
452
-        // percent td
453
-        $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
454
-        // empty td (price)
455
-        $html .= EEH_HTML::td(EEH_HTML::nbsp());
456
-        // total td
457
-        $html .= EEH_HTML::td(
458
-            EEH_Template::format_currency(
459
-                $line_item->total(),
460
-                false,
461
-                false
462
-            ),
463
-            '',
464
-            'item_r jst-rght'
465
-        );
466
-        // end of row
467
-        $html .= EEH_HTML::trx();
468
-        return $html;
469
-    }
470
-
471
-
472
-
473
-    /**
474
-     * _total_row
475
-     *
476
-     * @param EE_Line_Item $line_item
477
-     * @param string       $text
478
-     * @return mixed
479
-     * @throws EE_Error
480
-     */
481
-    private function _total_tax_row(EE_Line_Item $line_item, $text = '')
482
-    {
483
-        $html = '';
484
-        if ($line_item->total()) {
485
-            // start of row
486
-            $html = EEH_HTML::tr('', '', 'total_tr odd');
487
-            // total td
488
-            $html .= EEH_HTML::td(
489
-                $text,
490
-                '',
491
-                'total_currency total jst-rght',
492
-                '',
493
-                ' colspan="2"'
494
-            );
495
-            // empty td (price)
496
-            $html .= EEH_HTML::td(EEH_HTML::nbsp());
497
-            // total td
498
-            $html .= EEH_HTML::td(
499
-                EEH_Template::format_currency($line_item->total(), false, false),
500
-                '',
501
-                'total jst-rght'
502
-            );
503
-            // end of row
504
-            $html .= EEH_HTML::trx();
505
-        }
506
-        return $html;
507
-    }
508
-
509
-
510
-
511
-    /**
512
-     * _total_row
513
-     *
514
-     * @param EE_Line_Item $line_item
515
-     * @param string       $text
516
-     * @param array        $options
517
-     * @return mixed
518
-     * @throws EE_Error
519
-     */
520
-    private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array())
521
-    {
522
-        $html = '';
523
-        if ($line_item->total()) {
524
-            // start of row
525
-            $html = EEH_HTML::tr('', '', 'total_tr odd');
526
-            // total td
527
-            $html .= EEH_HTML::td(
528
-                $text,
529
-                '',
530
-                'total_currency total jst-rght',
531
-                '',
532
-                ' colspan="3"'
533
-            );
534
-            // total td
535
-            $html .= EEH_HTML::td(
536
-                EEH_Template::format_currency($options['sub_total'], false, false),
537
-                '',
538
-                'total jst-rght'
539
-            );
540
-            // end of row
541
-            $html .= EEH_HTML::trx();
542
-        }
543
-        return $html;
544
-    }
545
-
546
-
547
-
548
-    /**
549
-     * _total_row
550
-     *
551
-     * @param EE_Line_Item $line_item
552
-     * @param string       $text
553
-     * @return mixed
554
-     * @throws EE_Error
555
-     */
556
-    private function _total_row(EE_Line_Item $line_item, $text = '')
557
-    {
558
-        // start of row
559
-        $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd');
560
-        // total td
561
-        $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
562
-        // total td
563
-        $html .= EEH_HTML::td(
564
-            EEH_Template::format_currency($line_item->total(), false, false),
565
-            '',
566
-            'total jst-rght'
567
-        );
568
-        // end of row
569
-        $html .= EEH_HTML::trx();
570
-        return $html;
571
-    }
572
-
573
-
574
-
575
-    /**
576
-     * _payments_and_amount_owing_rows
577
-     *
578
-     * @param EE_Line_Item $line_item
579
-     * @param array        $options
580
-     * @return mixed
581
-     * @throws EE_Error
582
-     */
583
-    private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array())
584
-    {
585
-        $html = '';
586
-        $owing = $line_item->total();
587
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
588
-        if ($transaction instanceof EE_Transaction) {
589
-            $registration_payments = array();
590
-            $registrations = ! empty($options['registrations'])
591
-                ? $options['registrations']
592
-                : $transaction->registrations();
593
-            foreach ($registrations as $registration) {
594
-                if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
595
-                    $registration_payments += $registration->registration_payments();
596
-                }
597
-            }
598
-            if (! empty($registration_payments)) {
599
-                foreach ($registration_payments as $registration_payment) {
600
-                    if ($registration_payment instanceof EE_Registration_Payment) {
601
-                        $owing -= $registration_payment->amount();
602
-                        $payment = $registration_payment->payment();
603
-                        $payment_desc = '';
604
-                        if ($payment instanceof EE_Payment) {
605
-                            $payment_desc = sprintf(
606
-                                esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
607
-                                $payment->txn_id_chq_nmbr() !== ''
608
-                                    ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
609
-                                    : '',
610
-                                $payment->timestamp()
611
-                            );
612
-                        }
613
-                        // start of row
614
-                        $html .= EEH_HTML::tr('', '', 'total_tr odd');
615
-                        // payment desc
616
-                        $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
617
-                        // total td
618
-                        $html .= EEH_HTML::td(
619
-                            EEH_Template::format_currency(
620
-                                $registration_payment->amount(),
621
-                                false,
622
-                                false
623
-                            ),
624
-                            '',
625
-                            'total jst-rght'
626
-                        );
627
-                        // end of row
628
-                        $html .= EEH_HTML::trx();
629
-                    }
630
-                }
631
-                if ($line_item->total()) {
632
-                    // start of row
633
-                    $html .= EEH_HTML::tr('', '', 'total_tr odd');
634
-                    // total td
635
-                    $html .= EEH_HTML::td(
636
-                        esc_html__('Amount Owing', 'event_espresso'),
637
-                        '',
638
-                        'total_currency total jst-rght',
639
-                        '',
640
-                        ' colspan="3"'
641
-                    );
642
-                    // total td
643
-                    $html .= EEH_HTML::td(
644
-                        EEH_Template::format_currency($owing, false, false),
645
-                        '',
646
-                        'total jst-rght'
647
-                    );
648
-                    // end of row
649
-                    $html .= EEH_HTML::trx();
650
-                }
651
-            }
652
-        }
653
-        $this->_grand_total = $owing;
654
-        return $html;
655
-    }
15
+	/**
16
+	 * array of events
17
+	 *
18
+	 * @type EE_Line_Item[] $_events
19
+	 */
20
+	private $_events = array();
21
+
22
+	/**
23
+	 * whether to display the taxes row or not
24
+	 *
25
+	 * @type bool $_show_taxes
26
+	 */
27
+	private $_show_taxes = false;
28
+
29
+	/**
30
+	 * html for any tax rows
31
+	 *
32
+	 * @type string $_show_taxes
33
+	 */
34
+	private $_taxes_html = '';
35
+
36
+	/**
37
+	 * total amount including tax we can bill for at this time
38
+	 *
39
+	 * @type float $_grand_total
40
+	 */
41
+	private $_grand_total = 0.00;
42
+
43
+	/**
44
+	 * total number of items being billed for
45
+	 *
46
+	 * @type int $_total_items
47
+	 */
48
+	private $_total_items = 0;
49
+
50
+
51
+
52
+	/**
53
+	 * @return float
54
+	 */
55
+	public function grand_total()
56
+	{
57
+		return $this->_grand_total;
58
+	}
59
+
60
+
61
+
62
+	/**
63
+	 * @return int
64
+	 */
65
+	public function total_items()
66
+	{
67
+		return $this->_total_items;
68
+	}
69
+
70
+
71
+
72
+	/**
73
+	 * @param EE_Line_Item $line_item
74
+	 * @param array        $options
75
+	 * @param EE_Line_Item $parent_line_item
76
+	 * @return mixed
77
+	 * @throws EE_Error
78
+	 */
79
+	public function display_line_item(
80
+		EE_Line_Item $line_item,
81
+		$options = array(),
82
+		EE_Line_Item $parent_line_item = null
83
+	) {
84
+		$html = '';
85
+		// set some default options and merge with incoming
86
+		$default_options = array(
87
+			'show_desc' => true,  //    true        false
88
+			'odd'       => false,
89
+		);
90
+		$options = array_merge($default_options, (array) $options);
91
+		switch ($line_item->type()) {
92
+			case EEM_Line_Item::type_line_item:
93
+				$this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
94
+				if ($line_item->OBJ_type() === 'Ticket') {
95
+					// item row
96
+					$html .= $this->_ticket_row($line_item, $options);
97
+				} else {
98
+					// item row
99
+					$html .= $this->_item_row($line_item, $options);
100
+				}
101
+				if (apply_filters(
102
+					'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items',
103
+					true
104
+				)
105
+				) {
106
+					// got any kids?
107
+					foreach ($line_item->children() as $child_line_item) {
108
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
109
+					}
110
+				}
111
+				break;
112
+			case EEM_Line_Item::type_sub_line_item:
113
+				$html .= $this->_sub_item_row($line_item, $options, $parent_line_item);
114
+				break;
115
+			case EEM_Line_Item::type_sub_total:
116
+				static $sub_total = 0;
117
+				$event_sub_total = 0;
118
+				$text = esc_html__('Sub-Total', 'event_espresso');
119
+				if ($line_item->OBJ_type() === 'Event') {
120
+					$options['event_id'] = $event_id = $line_item->OBJ_ID();
121
+					if (! isset($this->_events[ $options['event_id'] ])) {
122
+						$event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
123
+						// if event has default reg status of Not Approved, then don't display info on it
124
+						if ($event instanceof EE_Event
125
+							&& $event->default_registration_status() === EEM_Registration::status_id_not_approved
126
+						) {
127
+							$display_event = false;
128
+							// unless there are registrations for it that are returning to pay
129
+							if (isset($options['registrations']) && is_array($options['registrations'])) {
130
+								foreach ($options['registrations'] as $registration) {
131
+									if (! $registration instanceof EE_Registration) {
132
+										continue;
133
+									}
134
+									$display_event = $registration->event_ID() === $options['event_id']
135
+													 && $registration->status_ID() !== EEM_Registration::status_id_not_approved
136
+										? true
137
+										: $display_event;
138
+								}
139
+							}
140
+							if (! $display_event) {
141
+								return '';
142
+							}
143
+						}
144
+						$this->_events[ $options['event_id'] ] = 0;
145
+						$html .= $this->_event_row($line_item);
146
+						$text = esc_html__('Event Sub-Total', 'event_espresso');
147
+					}
148
+				}
149
+				$child_line_items = $line_item->children();
150
+				// loop thru children
151
+				foreach ($child_line_items as $child_line_item) {
152
+					// recursively feed children back into this method
153
+					$html .= $this->display_line_item($child_line_item, $options, $line_item);
154
+				}
155
+				$event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0;
156
+				$sub_total += $event_sub_total;
157
+				if ((
158
+						// event subtotals
159
+						$line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1
160
+					)
161
+					|| (
162
+						// pre-tax subtotals
163
+						$line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1
164
+					)
165
+				) {
166
+					$options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total;
167
+					$html .= $this->_sub_total_row($line_item, $text, $options);
168
+				}
169
+				break;
170
+			case EEM_Line_Item::type_tax:
171
+				if ($this->_show_taxes) {
172
+					$this->_taxes_html .= $this->_tax_row($line_item, $options);
173
+				}
174
+				break;
175
+			case EEM_Line_Item::type_tax_sub_total:
176
+				if ($this->_show_taxes) {
177
+					$child_line_items = $line_item->children();
178
+					// loop thru children
179
+					foreach ($child_line_items as $child_line_item) {
180
+						// recursively feed children back into this method
181
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
182
+					}
183
+					if (count($child_line_items) > 1) {
184
+						$this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso'));
185
+					}
186
+				}
187
+				break;
188
+			case EEM_Line_Item::type_total:
189
+				// get all child line items
190
+				$children = $line_item->children();
191
+				// loop thru all non-tax child line items
192
+				foreach ($children as $child_line_item) {
193
+					if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) {
194
+						// recursively feed children back into this method
195
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
196
+					}
197
+				}
198
+				// now loop thru  tax child line items
199
+				foreach ($children as $child_line_item) {
200
+					if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) {
201
+						// recursively feed children back into this method
202
+						$html .= $this->display_line_item($child_line_item, $options, $line_item);
203
+					}
204
+				}
205
+				$html .= $this->_taxes_html;
206
+				$html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso'));
207
+				$html .= $this->_payments_and_amount_owing_rows($line_item, $options);
208
+				break;
209
+		}
210
+		return $html;
211
+	}
212
+
213
+
214
+
215
+	/**
216
+	 * _event_row - basically a Heading row displayed once above each event's ticket rows
217
+	 *
218
+	 * @param EE_Line_Item $line_item
219
+	 * @return mixed
220
+	 */
221
+	private function _event_row(EE_Line_Item $line_item)
222
+	{
223
+		// start of row
224
+		$html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd');
225
+		// event name td
226
+		$html .= EEH_HTML::td(
227
+			EEH_HTML::strong($line_item->name()),
228
+			'',
229
+			'event-header',
230
+			'',
231
+			' colspan="4"'
232
+		);
233
+		// end of row
234
+		$html .= EEH_HTML::trx();
235
+		return $html;
236
+	}
237
+
238
+
239
+
240
+	/**
241
+	 * _ticket_row
242
+	 *
243
+	 * @param EE_Line_Item $line_item
244
+	 * @param array        $options
245
+	 * @return mixed
246
+	 * @throws EE_Error
247
+	 */
248
+	private function _ticket_row(EE_Line_Item $line_item, $options = array())
249
+	{
250
+		// start of row
251
+		$row_class = $options['odd'] ? 'item odd' : 'item';
252
+		$html = EEH_HTML::tr('', '', $row_class);
253
+		// name && desc
254
+		$name_and_desc = apply_filters(
255
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
256
+			$line_item->name(),
257
+			$line_item
258
+		);
259
+		$name_and_desc .= apply_filters(
260
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
261
+			(
262
+				$options['show_desc']
263
+					? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
264
+					: ''
265
+			),
266
+			$line_item,
267
+			$options
268
+		);
269
+		$name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
270
+		// name td
271
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/
272
+			$name_and_desc,
273
+			'',
274
+			'item_l'
275
+		);
276
+		// price td
277
+		$price = apply_filters(
278
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__price',
279
+			$line_item->unit_price_no_code(),
280
+			$line_item
281
+		);
282
+		$html .= EEH_HTML::td($price, '', 'item_c jst-rght');
283
+		// quantity td
284
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
285
+		$this->_total_items += $line_item->quantity();
286
+		// determine total for line item
287
+		$total = apply_filters(
288
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__total',
289
+			$line_item->total(),
290
+			$line_item
291
+		);
292
+		$this->_events[ $options['event_id'] ] += $total;
293
+		// total td
294
+		$html .= EEH_HTML::td(
295
+			EEH_Template::format_currency($total, false, false),
296
+			'',
297
+			'item_r jst-rght'
298
+		);
299
+		// end of row
300
+		$html .= EEH_HTML::trx();
301
+		return $html;
302
+	}
303
+
304
+
305
+
306
+	/**
307
+	 * _item_row
308
+	 *
309
+	 * @param EE_Line_Item $line_item
310
+	 * @param array        $options
311
+	 * @return mixed
312
+	 * @throws EE_Error
313
+	 */
314
+	private function _item_row(EE_Line_Item $line_item, $options = array())
315
+	{
316
+		// start of row
317
+		$row_class = $options['odd'] ? 'item odd' : 'item';
318
+		$html = EEH_HTML::tr('', '', $row_class);
319
+		$obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
320
+		// name && desc
321
+		$name_and_desc = apply_filters(
322
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
323
+			$obj_name . $line_item->name(),
324
+			$line_item
325
+		);
326
+		$name_and_desc .= apply_filters(
327
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
328
+			(
329
+				$options['show_desc']
330
+				? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
331
+				: ''
332
+			),
333
+			$line_item,
334
+			$options
335
+		);
336
+		$name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
337
+		// name td
338
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l');
339
+		// price td
340
+		if ($line_item->is_percent()) {
341
+			$html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
342
+		} else {
343
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
344
+		}
345
+		// quantity td
346
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
347
+		// $total = $line_item->total() * $line_item->quantity();
348
+		$total = $line_item->total();
349
+		if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) {
350
+			$this->_events[ $options['event_id'] ] += $total;
351
+		}
352
+		// total td
353
+		$html .= EEH_HTML::td(
354
+			EEH_Template::format_currency($total, false, false),
355
+			'',
356
+			'item_r jst-rght'
357
+		);
358
+		// end of row
359
+		$html .= EEH_HTML::trx();
360
+		return $html;
361
+	}
362
+
363
+
364
+
365
+	/**
366
+	 * _sub_item_row
367
+	 *
368
+	 * @param EE_Line_Item $line_item
369
+	 * @param array        $options
370
+	 * @param EE_Line_Item $parent_line_item
371
+	 * @return mixed
372
+	 * @throws EE_Error
373
+	 */
374
+	private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null)
375
+	{
376
+		if ($parent_line_item instanceof  EE_Line_Item
377
+			&& $line_item->children() === array()
378
+			&& $line_item->name() === $parent_line_item->name()
379
+			&& apply_filters(
380
+				'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item',
381
+				true
382
+			)
383
+		) {
384
+			return '';
385
+		}
386
+		// start of row
387
+		$html = EEH_HTML::tr('', '', 'item sub-item-row');
388
+		// name && desc
389
+		$name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right')
390
+						 . $line_item->name();
391
+		$name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '
392
+												  . $line_item->desc()
393
+												  . '</span>' : '';
394
+		// name td
395
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item');
396
+		$qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1;
397
+		// discount/surcharge td
398
+		if ($line_item->is_percent()) {
399
+			$html .= EEH_HTML::td(
400
+				EEH_Template::format_currency(
401
+					$line_item->total() / $qty,
402
+					false,
403
+					false
404
+				),
405
+				'',
406
+				'item_c jst-rght'
407
+			);
408
+		} else {
409
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
410
+		}
411
+		// no quantity td
412
+		$html .= EEH_HTML::td();
413
+		// no total td
414
+		$html .= EEH_HTML::td();
415
+		// end of row
416
+		$html .= EEH_HTML::trx();
417
+		$html = apply_filters(
418
+			'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html',
419
+			$html,
420
+			$line_item,
421
+			$options,
422
+			$parent_line_item
423
+		);
424
+		return $html;
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 * _tax_row
431
+	 *
432
+	 * @param EE_Line_Item $line_item
433
+	 * @param array        $options
434
+	 * @return mixed
435
+	 * @throws EE_Error
436
+	 */
437
+	private function _tax_row(EE_Line_Item $line_item, $options = array())
438
+	{
439
+		// start of row
440
+		$html = EEH_HTML::tr('', 'item sub-item tax-total');
441
+		// name && desc
442
+		$name_and_desc = $line_item->name();
443
+		$name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
444
+						  . esc_html__(' * taxable items', 'event_espresso') . '</span>';
445
+		$name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
446
+		// name td
447
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/
448
+			$name_and_desc,
449
+			'',
450
+			'item_l sub-item'
451
+		);
452
+		// percent td
453
+		$html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
454
+		// empty td (price)
455
+		$html .= EEH_HTML::td(EEH_HTML::nbsp());
456
+		// total td
457
+		$html .= EEH_HTML::td(
458
+			EEH_Template::format_currency(
459
+				$line_item->total(),
460
+				false,
461
+				false
462
+			),
463
+			'',
464
+			'item_r jst-rght'
465
+		);
466
+		// end of row
467
+		$html .= EEH_HTML::trx();
468
+		return $html;
469
+	}
470
+
471
+
472
+
473
+	/**
474
+	 * _total_row
475
+	 *
476
+	 * @param EE_Line_Item $line_item
477
+	 * @param string       $text
478
+	 * @return mixed
479
+	 * @throws EE_Error
480
+	 */
481
+	private function _total_tax_row(EE_Line_Item $line_item, $text = '')
482
+	{
483
+		$html = '';
484
+		if ($line_item->total()) {
485
+			// start of row
486
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
487
+			// total td
488
+			$html .= EEH_HTML::td(
489
+				$text,
490
+				'',
491
+				'total_currency total jst-rght',
492
+				'',
493
+				' colspan="2"'
494
+			);
495
+			// empty td (price)
496
+			$html .= EEH_HTML::td(EEH_HTML::nbsp());
497
+			// total td
498
+			$html .= EEH_HTML::td(
499
+				EEH_Template::format_currency($line_item->total(), false, false),
500
+				'',
501
+				'total jst-rght'
502
+			);
503
+			// end of row
504
+			$html .= EEH_HTML::trx();
505
+		}
506
+		return $html;
507
+	}
508
+
509
+
510
+
511
+	/**
512
+	 * _total_row
513
+	 *
514
+	 * @param EE_Line_Item $line_item
515
+	 * @param string       $text
516
+	 * @param array        $options
517
+	 * @return mixed
518
+	 * @throws EE_Error
519
+	 */
520
+	private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array())
521
+	{
522
+		$html = '';
523
+		if ($line_item->total()) {
524
+			// start of row
525
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
526
+			// total td
527
+			$html .= EEH_HTML::td(
528
+				$text,
529
+				'',
530
+				'total_currency total jst-rght',
531
+				'',
532
+				' colspan="3"'
533
+			);
534
+			// total td
535
+			$html .= EEH_HTML::td(
536
+				EEH_Template::format_currency($options['sub_total'], false, false),
537
+				'',
538
+				'total jst-rght'
539
+			);
540
+			// end of row
541
+			$html .= EEH_HTML::trx();
542
+		}
543
+		return $html;
544
+	}
545
+
546
+
547
+
548
+	/**
549
+	 * _total_row
550
+	 *
551
+	 * @param EE_Line_Item $line_item
552
+	 * @param string       $text
553
+	 * @return mixed
554
+	 * @throws EE_Error
555
+	 */
556
+	private function _total_row(EE_Line_Item $line_item, $text = '')
557
+	{
558
+		// start of row
559
+		$html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd');
560
+		// total td
561
+		$html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
562
+		// total td
563
+		$html .= EEH_HTML::td(
564
+			EEH_Template::format_currency($line_item->total(), false, false),
565
+			'',
566
+			'total jst-rght'
567
+		);
568
+		// end of row
569
+		$html .= EEH_HTML::trx();
570
+		return $html;
571
+	}
572
+
573
+
574
+
575
+	/**
576
+	 * _payments_and_amount_owing_rows
577
+	 *
578
+	 * @param EE_Line_Item $line_item
579
+	 * @param array        $options
580
+	 * @return mixed
581
+	 * @throws EE_Error
582
+	 */
583
+	private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array())
584
+	{
585
+		$html = '';
586
+		$owing = $line_item->total();
587
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
588
+		if ($transaction instanceof EE_Transaction) {
589
+			$registration_payments = array();
590
+			$registrations = ! empty($options['registrations'])
591
+				? $options['registrations']
592
+				: $transaction->registrations();
593
+			foreach ($registrations as $registration) {
594
+				if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
595
+					$registration_payments += $registration->registration_payments();
596
+				}
597
+			}
598
+			if (! empty($registration_payments)) {
599
+				foreach ($registration_payments as $registration_payment) {
600
+					if ($registration_payment instanceof EE_Registration_Payment) {
601
+						$owing -= $registration_payment->amount();
602
+						$payment = $registration_payment->payment();
603
+						$payment_desc = '';
604
+						if ($payment instanceof EE_Payment) {
605
+							$payment_desc = sprintf(
606
+								esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
607
+								$payment->txn_id_chq_nmbr() !== ''
608
+									? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
609
+									: '',
610
+								$payment->timestamp()
611
+							);
612
+						}
613
+						// start of row
614
+						$html .= EEH_HTML::tr('', '', 'total_tr odd');
615
+						// payment desc
616
+						$html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
617
+						// total td
618
+						$html .= EEH_HTML::td(
619
+							EEH_Template::format_currency(
620
+								$registration_payment->amount(),
621
+								false,
622
+								false
623
+							),
624
+							'',
625
+							'total jst-rght'
626
+						);
627
+						// end of row
628
+						$html .= EEH_HTML::trx();
629
+					}
630
+				}
631
+				if ($line_item->total()) {
632
+					// start of row
633
+					$html .= EEH_HTML::tr('', '', 'total_tr odd');
634
+					// total td
635
+					$html .= EEH_HTML::td(
636
+						esc_html__('Amount Owing', 'event_espresso'),
637
+						'',
638
+						'total_currency total jst-rght',
639
+						'',
640
+						' colspan="3"'
641
+					);
642
+					// total td
643
+					$html .= EEH_HTML::td(
644
+						EEH_Template::format_currency($owing, false, false),
645
+						'',
646
+						'total jst-rght'
647
+					);
648
+					// end of row
649
+					$html .= EEH_HTML::trx();
650
+				}
651
+			}
652
+		}
653
+		$this->_grand_total = $owing;
654
+		return $html;
655
+	}
656 656
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         $html = '';
85 85
         // set some default options and merge with incoming
86 86
         $default_options = array(
87
-            'show_desc' => true,  //    true        false
87
+            'show_desc' => true, //    true        false
88 88
             'odd'       => false,
89 89
         );
90 90
         $options = array_merge($default_options, (array) $options);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                 $text = esc_html__('Sub-Total', 'event_espresso');
119 119
                 if ($line_item->OBJ_type() === 'Event') {
120 120
                     $options['event_id'] = $event_id = $line_item->OBJ_ID();
121
-                    if (! isset($this->_events[ $options['event_id'] ])) {
121
+                    if ( ! isset($this->_events[$options['event_id']])) {
122 122
                         $event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
123 123
                         // if event has default reg status of Not Approved, then don't display info on it
124 124
                         if ($event instanceof EE_Event
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                             // unless there are registrations for it that are returning to pay
129 129
                             if (isset($options['registrations']) && is_array($options['registrations'])) {
130 130
                                 foreach ($options['registrations'] as $registration) {
131
-                                    if (! $registration instanceof EE_Registration) {
131
+                                    if ( ! $registration instanceof EE_Registration) {
132 132
                                         continue;
133 133
                                     }
134 134
                                     $display_event = $registration->event_ID() === $options['event_id']
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
                                         : $display_event;
138 138
                                 }
139 139
                             }
140
-                            if (! $display_event) {
140
+                            if ( ! $display_event) {
141 141
                                 return '';
142 142
                             }
143 143
                         }
144
-                        $this->_events[ $options['event_id'] ] = 0;
144
+                        $this->_events[$options['event_id']] = 0;
145 145
                         $html .= $this->_event_row($line_item);
146 146
                         $text = esc_html__('Event Sub-Total', 'event_espresso');
147 147
                     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
                     // recursively feed children back into this method
153 153
                     $html .= $this->display_line_item($child_line_item, $options, $line_item);
154 154
                 }
155
-                $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0;
155
+                $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0;
156 156
                 $sub_total += $event_sub_total;
157 157
                 if ((
158 158
                         // event subtotals
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
261 261
             (
262 262
                 $options['show_desc']
263
-                    ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
263
+                    ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>'
264 264
                     : ''
265 265
             ),
266 266
             $line_item,
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
             $line_item->total(),
290 290
             $line_item
291 291
         );
292
-        $this->_events[ $options['event_id'] ] += $total;
292
+        $this->_events[$options['event_id']] += $total;
293 293
         // total td
294 294
         $html .= EEH_HTML::td(
295 295
             EEH_Template::format_currency($total, false, false),
@@ -316,18 +316,18 @@  discard block
 block discarded – undo
316 316
         // start of row
317 317
         $row_class = $options['odd'] ? 'item odd' : 'item';
318 318
         $html = EEH_HTML::tr('', '', $row_class);
319
-        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : '';
319
+        $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : '';
320 320
         // name && desc
321 321
         $name_and_desc = apply_filters(
322 322
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
323
-            $obj_name . $line_item->name(),
323
+            $obj_name.$line_item->name(),
324 324
             $line_item
325 325
         );
326 326
         $name_and_desc .= apply_filters(
327 327
             'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
328 328
             (
329 329
                 $options['show_desc']
330
-                ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>'
330
+                ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>'
331 331
                 : ''
332 332
             ),
333 333
             $line_item,
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
         $html .= EEH_HTML::td($name_and_desc, '', 'item_l');
339 339
         // price td
340 340
         if ($line_item->is_percent()) {
341
-            $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght');
341
+            $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght');
342 342
         } else {
343 343
             $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
344 344
         }
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
         $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
347 347
         // $total = $line_item->total() * $line_item->quantity();
348 348
         $total = $line_item->total();
349
-        if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) {
350
-            $this->_events[ $options['event_id'] ] += $total;
349
+        if (isset($options['event_id'], $this->_events[$options['event_id']])) {
350
+            $this->_events[$options['event_id']] += $total;
351 351
         }
352 352
         // total td
353 353
         $html .= EEH_HTML::td(
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
         // name && desc
442 442
         $name_and_desc = $line_item->name();
443 443
         $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'
444
-                          . esc_html__(' * taxable items', 'event_espresso') . '</span>';
445
-        $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : '';
444
+                          . esc_html__(' * taxable items', 'event_espresso').'</span>';
445
+        $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : '';
446 446
         // name td
447 447
         $html .= EEH_HTML::td( /*__FUNCTION__ .*/
448 448
             $name_and_desc,
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
             'item_l sub-item'
451 451
         );
452 452
         // percent td
453
-        $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', '');
453
+        $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', '');
454 454
         // empty td (price)
455 455
         $html .= EEH_HTML::td(EEH_HTML::nbsp());
456 456
         // total td
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
                     $registration_payments += $registration->registration_payments();
596 596
                 }
597 597
             }
598
-            if (! empty($registration_payments)) {
598
+            if ( ! empty($registration_payments)) {
599 599
                 foreach ($registration_payments as $registration_payment) {
600 600
                     if ($registration_payment instanceof EE_Registration_Payment) {
601 601
                         $owing -= $registration_payment->amount();
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
                             $payment_desc = sprintf(
606 606
                                 esc_html__('Payment%1$s Received: %2$s', 'event_espresso'),
607 607
                                 $payment->txn_id_chq_nmbr() !== ''
608
-                                    ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
608
+                                    ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> '
609 609
                                     : '',
610 610
                                 $payment->timestamp()
611 611
                             );
Please login to merge, or discard this patch.
templates/txn_admin_details_side_meta_box_registrant.template.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,19 +10,19 @@  discard block
 block discarded – undo
10 10
 ?>
11 11
 <div id="admin-side-mbox-primary-registrant-dv" class="admin-side-mbox-dv">
12 12
     <?php
13
-    if (! empty($no_attendee_message)) : ?>
13
+	if (! empty($no_attendee_message)) : ?>
14 14
     <p class="clearfix">
15 15
         <?php echo $no_attendee_message; ?>
16 16
     </p>
17 17
 </div> <!-- end #admin-side-mbox-primary-registrant-dv -->
18 18
 <?php
19
-    else : ?>
19
+	else : ?>
20 20
     <p class="clearfix">
21 21
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left">
22 22
             <?php esc_html_e(
23
-                'Name',
24
-                'event_espresso'
25
-            ); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>
23
+				'Name',
24
+				'event_espresso'
25
+			); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>
26 26
     </p>
27 27
     <p class="clearfix">
28 28
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php esc_html_e('Email', 'event_espresso'); ?></span><a
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
     <p class="clearfix">
32 32
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left">
33 33
             <?php esc_html_e(
34
-                'Phone #',
35
-                'event_espresso'
36
-            ); ?>
34
+				'Phone #',
35
+				'event_espresso'
36
+			); ?>
37 37
     </span>
38 38
     <?php if (! empty($prime_reg_phone)) : ?>
39 39
         <a href="tel:<?php echo $prime_reg_phone; ?>">
@@ -50,22 +50,22 @@  discard block
 block discarded – undo
50 50
     </div> <!-- end #admin-side-mbox-primary-registrant-dv -->
51 51
 
52 52
     <?php
53
-    /** only show if logged in user has access */
54
-    if (EE_Registry::instance()->CAP->current_user_can(
55
-        'ee_edit_contact',
56
-        'view_or_edit_contact_button',
57
-        $ATT_ID
58
-    )
59
-    ) : ?>
53
+	/** only show if logged in user has access */
54
+	if (EE_Registry::instance()->CAP->current_user_can(
55
+		'ee_edit_contact',
56
+		'view_or_edit_contact_button',
57
+		$ATT_ID
58
+	)
59
+	) : ?>
60 60
         <p style="text-align:right;">
61 61
             <a class="button button-small" href="<?php echo $edit_attendee_url; ?>"
62 62
                title="<?php esc_attr_e('View details for this contact.', 'event_espresso'); ?>">
63 63
                 <span class="ee-icon ee-icon-user-edit"></span>
64 64
                 <?php _e(
65
-                    'View / Edit this Contact',
66
-                    'event_espresso'
67
-                ); ?>
65
+					'View / Edit this Contact',
66
+					'event_espresso'
67
+				); ?>
68 68
             </a>
69 69
         </p>
70 70
     <?php endif;
71
-    endif;
71
+	endif;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 ?>
11 11
 <div id="admin-side-mbox-primary-registrant-dv" class="admin-side-mbox-dv">
12 12
     <?php
13
-    if (! empty($no_attendee_message)) : ?>
13
+    if ( ! empty($no_attendee_message)) : ?>
14 14
     <p class="clearfix">
15 15
         <?php echo $no_attendee_message; ?>
16 16
     </p>
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
             <?php esc_html_e(
23 23
                 'Name',
24 24
                 'event_espresso'
25
-            ); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>
25
+            ); ?></span><?php echo $prime_reg_fname.' '.$prime_reg_lname; ?>
26 26
     </p>
27 27
     <p class="clearfix">
28 28
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php esc_html_e('Email', 'event_espresso'); ?></span><a
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                 'event_espresso'
36 36
             ); ?>
37 37
     </span>
38
-    <?php if (! empty($prime_reg_phone)) : ?>
38
+    <?php if ( ! empty($prime_reg_phone)) : ?>
39 39
         <a href="tel:<?php echo $prime_reg_phone; ?>">
40 40
             <?php echo $prime_reg_phone; ?>
41 41
         </a>
Please login to merge, or discard this patch.