Completed
Branch BUG-9623-config-log (c144cd)
by
unknown
527:42 queued 509:06
created

EE_messages::activate_messenger()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
	exit( 'No direct script access allowed' );
4
}
5
/**
6
 * ************************************************************************
7
 *       _____  ______          _____      __  __ ______
8
 *      |  __ \|  ____|   /\   |  __ \    |  \/  |  ____|
9
 *      | |__) | |__     /  \  | |  | |   | \  / | |__
10
 *      |  _  /|  __|   / /\ \ | |  | |   | |\/| |  __|
11
 *      | | \ \| |____ / ____ \| |__| |   | |  | | |____
12
 *      |_|  \_\______/_/    \_\_____/    |_|  |_|______|
13
 *
14
 * ************************************************************************
15
 *
16
 * This file contains all deprecated actions, filters, functions, and classes in EE.
17
 * DO NOT ADD NEW CODE TO THE TOP OF THIS FILE !!!
18
 * PLEASE ADD ALL NEW CODE TO THE BOTTOM THIS FILE !!!
19
 * IF YOU ADD CODE TO THIS FILE, WHY NOT TRY ADDING IT TO THE BOTTOM ?
20
 * THE WHITE ZONE IS FOR LOADING AND UNLOADING ONLY,
21
 * IF YOU HAVE TO LOAD OR UNLOAD, GO TO THE WHITE ZONE !!!
22
 *
23
 * @package     Event Espresso
24
 * @subpackage  helpers
25
 * @since       4.5.0
26
 */
27
/**
28
 * ee_deprecated__registration_checkout__button_text
29
 *
30
 * @param string       $submit_button_text
31
 * @param \EE_Checkout $checkout
32
 * @return string
33
 */
34
function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) {
35
	// list of old filters
36
	$deprecated_filters = array(
37
		'update_registration_details' => true,
38
		'process_payment' => true,
39
		'finalize_registration' => true,
40
		'and_proceed_to_payment' => true,
41
		'proceed_to' => true,
42
	);
43
	// loop thru and call doing_it_wrong() or remove any that aren't being used
44
	foreach ( $deprecated_filters as $deprecated_filter => $on ) {
45
		// was this filter called ?
46
		if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) {
47
			// only display doing_it_wrong() notice to Event Admins during non-AJAX requests
48
			if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) {
49
				EE_Error::doing_it_wrong(
50
					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
51
					sprintf(
52
						__( 'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ),
53
						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
54
						'<br />',
55
						'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
56
						'/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
57
					),
58
					'4.6.10',
59
					E_USER_DEPRECATED
60
				);
61
			}
62
		} else {
63
			unset( $deprecated_filters[ $deprecated_filter ] );
64
		}
65
	}
66
	if ( ! empty( $deprecated_filters )) {
67
68
		if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) {
69
			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text );
70
		} else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) {
71
			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text );
72 View Code Duplication
		} else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) {
73
			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text );
74
		}
75
		if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) {
76
			if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) {
77
				$submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text );
78
			}
79 View Code Duplication
			if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) {
80
				$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name();
81
			}
82
		}
83
84
	}
85
	return $submit_button_text;
86
87
}
88
add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 );
89
90
91
92
93
/**
94
 * ee_deprecated_finalize_transaction
95
 *
96
 * @param \EE_Checkout $checkout
97
 * @param boolean $status_updates
98
 */
99
function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) {
100
	$action_ref = NULL;
101
	$action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
102
	$action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
103
	if ( $action_ref ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $action_ref of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
104
105
		EE_Error::doing_it_wrong(
106
			$action_ref,
107
			sprintf(
108
				__( 'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ),
109
				'<br />',
110
				'/core/business/EE_Transaction_Processor.class.php',
111
				'AHEE__EE_Transaction_Processor__finalize',
112
				'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
113
				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
114
				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing'
115
			),
116
			'4.6.0',
117
			E_USER_DEPRECATED
118
		);
119
		switch ( $action_ref ) {
120
			case 'AHEE__EE_Transaction__finalize__new_transaction' :
121
				do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request );
122
				break;
123
			case 'AHEE__EE_Transaction__finalize__all_transaction' :
124
				do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request );
125
				break;
126
		}
127
	}
128
}
129
add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 );
130
/**
131
 * ee_deprecated_finalize_registration
132
 *
133
 * @param EE_Registration $registration
134
 */
135
function ee_deprecated_finalize_registration( EE_Registration $registration ) {
136
	$action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL;
137 View Code Duplication
	if ( $action_ref ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $action_ref of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
138
		EE_Error::doing_it_wrong(
139
			$action_ref,
140
			sprintf(
141
				__( 'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ),
142
				'<br />',
143
				'/core/business/EE_Registration_Processor.class.php',
144
				'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook'
145
			),
146
			'4.6.0',
147
			E_USER_DEPRECATED
148
		);
149
		do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )));
150
	}
151
}
152
add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 );
153
154
155
156
157
/** Messages System deprecated things **/
158
159
160
/**
161
 * wrapper for deprecated FHEE__*___create_new_templates__templates filter.  Note depending on how this was used, it may or may not degrade gracefully for clients using the existing filter because the old Default classes are NOT present anymore.
162
 *
163
 * @deprecated 4.5.0
164
 * @deprecated Use FHEE__EE_Template_Pack___get_templates__templates filter instead.
165
 *
166
 * @param array                     $templates      array of generated templates
167
 * @param EE_messenger              $messenger
168
 * @param EE_message_type           $message_type
169
 * @param EE_Messages_Template_Pack $template_pack
170
 *
171
 * @return array
172
 */
173
function ee_deprecated_get_templates( $templates, EE_messenger $messenger, EE_message_type $message_type, EE_Messages_Template_Pack $template_pack ) {
0 ignored issues
show
Unused Code introduced by
The parameter $messenger is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $message_type is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $template_pack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
174
	$old_default_classnames = array(
175
		'EE_Messages_Email_Cancelled_Registration_Defaults',
176
		'EE_Messages_Email_Declined_Registration_Defaults',
177
		'EE_Messages_Email_Not_Approved_Registration_Defaults',
178
		'EE_Messages_Email_Payment_Declined_Defaults',
179
		'EE_Messages_Email_Payment_Defaults',
180
		'EE_Messages_Email_Payment_Reminder_Defaults',
181
		'EE_Messages_Email_Pending_Approval_Defaults',
182
		'EE_Messages_Email_Registration_Defaults',
183
		'EE_Messages_Email_Newsletter_Defaults',
184
		'EE_Message_Template_Defaults'
185
		);
186
187
	$old_class_instance = new stdClass();
188
189 View Code Duplication
	foreach ( $old_default_classnames as $classname ) {
190
		$filter_ref = 'FHEE__' . $classname . '___create_new_templates___templates';
191
		if ( has_filter( $filter_ref ) ) {
192
			EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the new filter provided which is "FHEE__EE_Template_Pack___get_templates__templates" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED );
193
		}
194
		$templates = apply_filters( $filter_ref, $templates, $old_class_instance );
195
	}
196
197
	return $templates;
198
}
199
add_filter( 'FHEE__EE_Template_Pack___get_templates__templates', 'ee_deprecated_get_templates', 10, 4 );
200
201
/**
202
 * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called.
203
 * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately.
204
 */
205
function ee_deprecated_hooks(){
206
	/**
207
	 * @var $hooks array where keys are hook names, and their values are array{
208
	 *			@type string $version  when deprecated
209
	 *			@type string $alternative  saying what to use instead
210
	 *			@type boolean $still_works  whether or not the hook still works
211
	 *		}
212
	 */
213
	$hooks = array(
214
		'AHEE__EE_System___do_setup_validations' => array(
215
			'version' => '4.6.0',
216
			'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ),
217
			'still_works' => FALSE
218
		)
219
	);
220
	foreach( $hooks as $name => $deprecation_info ){
221
		if( has_action( $name ) ){
222
			EE_Error::doing_it_wrong(
223
				$name,
224
				sprintf(
225
					__('This filter is deprecated. %1$s%2$s','event_espresso'),
226
					$deprecation_info[ 'still_works' ] ?  __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ),
227
					isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' )
228
				),
229
				isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ),
230
				E_USER_DEPRECATED
231
			);
232
		}
233
	}
234
}
235
add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' );
236
237
238
239
240
241
242
/**
243
 * wrapper for the now deprecated FHEE__*__get_default_field_content filter.  Note depending on how this was used, it may or may not degrade gracefully for clients using the  filter format that is "FHEE__EE_Messages_Base__get_default_field_content" as that format might have had either a EE_messenger or EE_message_type object as a param.  The backward_compat implementation assumed EE_message_type.
244
 *
245
 * @deprecated 4.5.0
246
 * @deprecated Use FHEE__EE_Messages_Template_Pack__get_specific_template__contents filter instead.
247
 *
248
 * @param string                    $contents        The template contents being used.
249
 * @param string                    $actual_path   The actual path for the template contents.
250
 * @param EE_messenger              $messenger
251
 * @param EE_message_type           $message_type
252
 * @param string                    $field         The field the contents are for.
253
 * @param string                    $context       The context the contents are for.
254
 * @param EE_Messages_Template_Pack $template_pack
255
 *
256
 * @return string                    The default contents for the messenger, message type, context and field.
257
 */
258
function ee_deprecated_get_default_field_content( $contents, $actual_path, EE_messenger $messenger, EE_message_type $message_type, $field, $context, EE_Messages_Template_Pack $template_pack ) {
0 ignored issues
show
Unused Code introduced by
The parameter $actual_path is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $field is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $template_pack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
259
260
	$classnames_to_try = array(
261
		get_class( $messenger ) => $messenger,
262
		get_class( $message_type ) => $message_type,
263
		'EE_Messages_Base' => $message_type
264
		);
265
266 View Code Duplication
	foreach ( $classnames_to_try as $classname => $obj ) {
267
		$filter_ref = 'FHEE__' . $classname . '__get_default_field_content';
268
		if ( has_filter( $filter_ref ) ) {
269
			EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_specific_template__contents" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED );
270
		}
271
		$contents = apply_filters( $filter_ref, $contents, $obj );
272
	}
273
274
	return $contents;
275
}
276
add_filter( 'FHEE__EE_Messages_Template_Pack__get_specific_template__contents', 'ee_deprecated_get_default_field_content', 10, 7 );
277
278
279
280
281
282
/**
283
 * wrapper for the now deprecated *__get_inline_css_template__css_url and path filters.
284
 * Filters deprecated are:
285
 * 	- FHEE__EE_Email_messenger__get_inline_css_template__css_url
286
 * 	- FHEE__EE_Email_messenger__get_inline_css_template__css_path
287
 * 	- FHEE__EE_Html_messenger__get_inline_css_template__css_url
288
 * 	- FHEE__EE_Html_messenger__get_inline_css_template__css_path
289
 *
290
 * @deprecated 4.5.0
291
 * @deprecated Use the new FHEE__EE_Messages_Template_Pack__get_variation filter instead.
292
 *
293
 * @param string                    $variation_path The current css path.
294
 * @param string                    $messenger      EE_messenger slug.
295
 * @param string                    $messenger      EE_message_type slug
296
 * @param string                    $type                The type of css file being returned (wpeditor, default etc.)
297
 * @param string                    $variation         Introduced by the new template pack system. The variation slug.
298
 * @param string                    $file_extension Defaults to css.  The file extension for the file being retrieved.
299
 * @param bool                      $url            Whether this is a directory path or url path.
300
 * @param EE_Messages_Template_Pack $template_pack
301
 *
302
 * @return string                    The path to the file being used.
303
 */
304
function ee_deprecated_get_inline_css_template_filters( $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url,  EE_Messages_Template_Pack $template_pack ) {
0 ignored issues
show
Unused Code introduced by
The parameter $message_type is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $variation is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $file_extension is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $template_pack is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
305
306
	if ( $messenger == 'email' ) {
307
		$filter_ref = $url ? 'FHEE__EE_Email_messenger__get_inline_css_template__css_url' : 'FHEE__EE_Email_messenger__get_inline_css_template__css_path';
308
	} elseif ( $messenger == 'html' ) {
309
		$filter_ref = $url ? 'FHEE__EE_Html_messenger__get_inline_css_template__css_url' : 'FHEE__EE_Html_messenger__get_inline_css_template__css_path';
310
	} else {
311
		return $variation_path;
312
	}
313
314
	if ( has_filter( $filter_ref ) ) {
315
		EE_Error::doing_it_wrong( $filter_ref, __('This filter is deprecated.  It is recommended to use the new filter provided which is "FHEE__EE_Messages_Template_Pack__get_variation" found in the EE_Messages_Template_Pack class.', 'event_espresso'), '4.5.0', E_USER_DEPRECATED );
316
	}
317
318
	return apply_filters( $filter_ref, $variation_path, $url, $type );
319
}
320
add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', 'ee_deprecated_get_inline_css_template_filters', 10, 8 );
321
322
323
324
325
/**
326
 * EE_Messages_Init
327
 * This was the old controller for the Messages system which has now been moved into a proper EED Module
328
 *
329
 * @deprecated 4.5.0
330
 * @deprecated Use the new EED_Messages module
331
 *
332
 */
333
class EE_Messages_Init extends EE_Base {
334
335
	public function __construct() {
336
		self::doing_it_wrong_call( __METHOD__ );
337
	}
338
339
	/**
340
	 * @param $method_name
341
	 */
342
	public static function doing_it_wrong_call( $method_name ) {
343
		EE_Error::doing_it_wrong( __CLASS__, sprintf( __('The %s in this class is deprecated as of EE4.5.0.  All functionality formerly in this class is now in the EED_Messages module.', 'event_espresso'), $method_name ), '4.5.0', E_USER_DEPRECATED );
344
	}
345
346
	/**
347
	 * @deprecated 4.5.0
348
	 */
349
	public static function set_autoloaders() {
350
		self::doing_it_wrong_call( __METHOD__ );
351
		EED_Messages::set_autoloaders();
352
	}
353
354
	/**
355
	 * @deprecated 4.5.0
356
	 */
357
	public function payment_reminder( $transaction ) {
358
		self::doing_it_wrong_call( __METHOD__ );
359
		EED_Messages::payment_reminder( $transaction );
360
	}
361
362
	/**
363
	 * @deprecated 4.5.0
364
	 */
365
	public function payment( $transaction, $payment ) {
366
		self::doing_it_wrong_call( __METHOD__ );
367
		EED_Messages::payment( $transaction, $payment );
368
	}
369
370
	/**
371
	 * @deprecated 4.5.0
372
	 */
373
	public function cancelled_registration( $transaction ) {
374
		self::doing_it_wrong_call( __METHOD__ );
375
		EED_Messages::cancelled_registration( $transaction );
376
	}
377
378
	/**
379
	 * @deprecated 4.5.0
380
	 */
381
	public function maybe_registration( $transaction, $reg_msg, $from_admin ) {
382
		self::doing_it_wrong_call( __METHOD__ );
383
		EED_Messages::maybe_registration( $transaction, $reg_msg, $from_admin );
0 ignored issues
show
Unused Code introduced by
The call to EED_Messages::maybe_registration() has too many arguments starting with $from_admin.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
384
	}
385
386
	/**
387
	 * @deprecated 4.5.0
388
	 */
389
	public function process_resend( $success, $req_data ) {
0 ignored issues
show
Unused Code introduced by
The parameter $success is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
390
		self::doing_it_wrong_call( __METHOD__ );
391
		EED_Messages::process_resend( $req_data );
392
	}
393
394
	/**
395
	 * @deprecated 4.5.0
396
	 */
397
	public function process_admin_payment( $success, $payment ) {
0 ignored issues
show
Unused Code introduced by
The parameter $success is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
398
		self::doing_it_wrong_call( __METHOD__ );
399
		EED_Messages::process_admin_payment( $payment );
400
	}
401
402
	/**
403
	 * @deprecated 4.5.0
404
	 */
405
	public function send_newsletter_message( $contacts, $grp_id ) {
406
		self::doing_it_wrong_call( __METHOD__ );
407
		EED_Messages::send_newsletter_message( $contacts, $grp_id );
408
	}
409
410
411
} //end deprecated EE_Messages_Init
412
413
414
/**
415
 * Deprecated EE_Register_CPTs filters
416
 */
417
418
/**
419
 * wrapper for deprecated 'FHEE__EE_Register_CPTs__construct__CPTs' filter.
420
 *
421
 * @deprecated 4.5.0
422
 * @deprecated Use FHEE__EE_Register_CPTs__get_CPTs__cpts filter instead
423
 *
424
 * @param array $cpts The cpts being filtered
425
 *
426
 * @return array additional cpts.
427
 */
428
function ee_deprecated_get_cpts( $cpts ) {
429
	if ( has_filter( 'FHEE__EE_Register_CPTs__construct__CPTs' ) ) {
430
		EE_Error::doing_it_wrong( 'FHEE__EE_Register_CPTs__construct__CPTs', __('This filter is deprecated. It will still work for the time being.  However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_CPTs__cpts" found in EE_Register_CPTs::get_CPTs()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED );
431
	}
432
	return apply_filters( 'FHEE__EE_Register_CPTs__construct__CPTs', $cpts );
433
}
434
add_filter( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', 'ee_deprecated_get_cpts', 10 );
435
436
437
438
/**
439
 * wrapper for deprecated 'FHEE__EE_Register_CPTs__construct__taxonomies' filter.
440
 *
441
 * @deprecated 4.5.0
442
 * @deprecated Use FHEE__EE_Register_CPTs__get_taxonomies__taxonomies filter instead
443
 *
444
 * @param array $cts The custom taxonomies being filtered
445
 *
446
 * @return array additional custom taxonomies.
447
 */
448
function ee_deprecated_get_taxonomies( $cts ) {
449
	if ( has_filter( 'FHEE__EE_Register_CPTs__construct__taxonomies' ) ) {
450
		EE_Error::doing_it_wrong( 'FHEE__EE_Register_CPTs__construct__taxonomies', __('This filter is deprecated. It will still work for the time being.  However, it is recommended to use the new filter provided which is "FHEE__EE_Register_CPTs__get_taxonomies__taxonomies" found in EE_Register_CPTs::get_taxonomies()', 'event_espresso'), '4.5.0', E_USER_DEPRECATED );
451
	}
452
	return apply_filters( 'FHEE__EE_Register_CPTs__construct__taxonomies', $cts );
453
}
454
add_filter( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', 'ee_deprecated_get_taxonomies', 10 );
455
456
457
458
459
/**
460
 * Checks if the filters which were removed as part of https://events.codebasehq.com/projects/event-espresso/tickets/9165
461
 * are in use. If so, issues a doing_it_wrong AND an error (because the doing_it_wrong
462
 * messages were somehow hidden in the UI)
463
 * @return boolean
464
 */
465
function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() {
466
	$in_use =  has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' )
467
			|| has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' );
468
	if( $in_use ) {
469
		$msg = __(
470
			'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
471
			. 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
472
			. 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end '
473
			. 'to add other actions after a form submission has been received.',
474
			'event_espresso' )
475
		;
476
		EE_Error::doing_it_wrong(
477
			__CLASS__ . '::' . __FUNCTION__,
478
			$msg,
479
			'4.8.32.rc.000'
480
		);
481
		//it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
482
		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
483
			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
484
		}
485
	}
486
	return $in_use;
487
}
488
add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' );
489
490
/**
491
 * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165
492
 * it is preferred to instead use _update_attendee_registration_form_new() which
493
 * also better handles form validation. Exits
494
 * @param EE_Admin_Page $admin_page
495
 * @return void
496
 */
497
function ee_deprecated_update_attendee_registration_form_old( $admin_page ) {
498
	//check if the old hooks are in use. If not, do the default
499
	if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
500
		|| ! $admin_page instanceof EE_Admin_Page ) {
501
		return;
502
	}
503
	$req_data = $admin_page->get_request_data();
504
	$qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE;
505
	$REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE;
506
	$qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns );
507
	if ( ! $REG_ID || ! $qstns ) {
508
		EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
509
	}
510
	$success = TRUE;
511
512
	// allow others to get in on this awesome fun   :D
513
	do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns );
514
	// loop thru questions... FINALLY!!!
515
516
	foreach ( $qstns as $QST_ID => $qstn ) {
517
		//if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
518
		if ( !is_array($qstn) ) {
519
			$success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn);
0 ignored issues
show
Bug introduced by
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
520
			continue;
521
		}
522
523
524
		foreach ( $qstn as $ANS_ID => $ANS_value ) {
525
			//get answer
526
			$query_params = array(
527
				0 => array(
528
					'ANS_ID' => $ANS_ID,
529
					'REG_ID' => $REG_ID,
530
					'QST_ID' => $QST_ID
531
					)
532
				);
533
			$answer = EEM_Answer::instance()->get_one($query_params);
534
			//this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
535
			if ( ! $answer instanceof EE_Answer ) {
536
				$set_values = array(
537
					'QST_ID' => $QST_ID,
538
					'REG_ID' => $REG_ID,
539
					'ANS_value' => $qstn
540
					);
541
				$success = EEM_Answer::instance()->insert($set_values);
542
				continue 2;
543
			}
544
545
			$answer->set('ANS_value', $ANS_value);
546
			$success = $answer->save();
547
		}
548
	}
549
	$what = __('Registration Form', 'event_espresso');
550
	$route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' );
551
	$admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route );
552
	exit;
553
}
554
add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 );
555
/**
556
 * Render the registration admin page's custom questions area in the old fashion
557
 * and firing the old hooks. When this method is removed, we can probably also
558
 * remove the deprecated methods form_before_question_group, form_after_question_group,
559
 * form_form_field_label_wrap and form_form_field_input__wrap in Registrations_Admin_Page
560
 *
561
 * @param boolean         $do_default_action
562
 * @param EE_Admin_Page   $admin_page
563
 * @param EE_Registration $registration
564
 * @return bool
565
 * @throws \EE_Error
566
 */
567
function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) {
568
	//check if the old hooks are in use. If not, do the default
569
	if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
570
		|| ! $admin_page instanceof EE_Admin_Page ) {
571
		return $do_default_action;
572
	}
573
	add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 );
574
	add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 );
575
	add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 );
576
	add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 );
577
578
	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') );
0 ignored issues
show
Deprecated Code introduced by
The method EEM_Event::assemble_arra...questions_and_options() has been deprecated with message: as of 4.8.32.rc.001. Instead consider using
EE_Registration_Custom_Questions_Form located in admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
579
580
	EE_Registry::instance()->load_helper( 'Form_Fields' );
581
	$template_args = array(
582
		'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ),
583
		'reg_questions_form_action' => 'edit_registration',
584
		'REG_ID' => $registration->ID()
585
	);
586
	$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
587
	echo EEH_Template::display_template( $template_path, $template_args, TRUE );
588
	//indicate that we should not do the default admin page code
589
	return false;
590
}
591
add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 );
592
593
594
595
596
/**
597
 * Deprecated class for instantiating default templates.  This was deprecated because of a substantial change in the constructor
598
 * signature.
599
 *
600
 * @package    Event Espresso
601
 * @subpackage messages
602
 * @author     Darren Ethier
603
 * @since      4.1
604
 * @deprecated 4.9.0  Replaced by EE_Messages_Template_Defaults (note the plural s on Messages)
605
 */
606
class EE_Message_Template_Defaults extends EE_Base {
607
608
	/**
609
	 * EE_Message_Template_Defaults constructor.
610
	 *
611
	 * @param EE_messages $messages
612
	 * @param             $messenger_name
613
	 * @param             $message_type_name
614
	 * @param int         $GRP_ID
615
	 * @return EE_Messages_Template_Defaults
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
616
	 */
617
	public function __construct(
618
		EE_messages $messages,
0 ignored issues
show
Unused Code introduced by
The parameter $messages is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
619
		$messenger_name,
620
		$message_type_name,
621
		$GRP_ID = 0
622
	) {
623
		EE_Error::doing_it_wrong(
624
			__FUNCTION__,
625
			__(
626
				'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.',
627
				'event_espresso'
628
			),
629
			'4.9.0'
630
		);
631
		/** @var EE_Message_Resource_Manager $message_resource_manager */
632
		$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
633
		$messenger = $message_resource_manager->get_messenger( $messenger_name );
634
		$message_type = $message_resource_manager->get_message_type( $message_type_name );
635
		return EE_Registry::instance()->load_lib(
0 ignored issues
show
Bug Compatibility introduced by
The expression \EE_Registry::instance()...enger, $message_type)); of type null|object|boolean adds the type boolean to the return on line 635 which is incompatible with the return type documented by EE_Message_Template_Defaults::__construct of type EE_Messages_Template_Defaults|null.
Loading history...
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
636
			'Messages_Template_Defaults',
637
			array(
638
				$GRP_ID,
639
				$messenger,
640
				$message_type,
641
			)
642
		);
643
	}
644
}
645
646
647
648
//end EE_Message_Template_Defaults class
649
650
651
652
653
/**
654
 * @deprecated     4.9.0
655
 * @package        Event Espresso
656
 * @subpackage     includes/core/messages
657
 * @author         Darren Ethier, Brent Christensen
658
 *
659
 * ------------------------------------------------------------------------
660
 */
661
class EE_messages {
662
663
	/** @type EE_messenger[] */
664
	protected $_active_messengers = array();
665
666
	/** @type array */
667
	protected $_active_message_types = array();
668
669
	/** @type EE_message_type[] */
670
	protected $_installed_message_types = array();
671
672
	/** @type EE_messenger */
673
	protected $_messenger;
674
675
	/** @type EE_message_type */
676
	protected $_message_type;
677
678
	/** @type array */
679
	protected $_contexts = array();
680
681
	/** @type EE_Message_Resource_Manager $_message_resource_manager */
682
	protected $_message_resource_manager;
683
684
685
686
	/**
687
	 * EE_messages constructor.
688
	 *
689
	 * @deprecated 4.9.0
690
	 */
691
	function __construct() {
692
	}
693
694
695
696
	/**
697
	 * @param string $method
698
	 */
699
	public function _class_is_deprecated( $method ) {
700
		// EE_messages has been deprecated
701
		EE_Error::doing_it_wrong(
702
			'EE_messages::' . $method,
703
			__( 'EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.' ),
704
			'4.9.0'
705
		);
706
		// Please use EE_Message_Resource_Manager instead
707
		$this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
0 ignored issues
show
Documentation Bug introduced by
It seems like \EE_Registry::instance()...sage_Resource_Manager') can also be of type boolean. However, the property $_message_resource_manager is declared as type object<EE_Message_Resource_Manager>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
708
	}
709
710
711
712
	/**
713
	 * @deprecated 4.9.0
714
	 * @param string $messenger_name
715
	 * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
716
	 */
717
	public function ensure_messenger_is_active( $messenger_name ) {
718
		// EE_messages has been deprecated
719
		$this->_class_is_deprecated( __FUNCTION__ );
720
		return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name );
721
	}
722
723
724
725
	/**
726
	 * @deprecated 4.9.0
727
	 * @param string $message_type message type name
728
	 * @param        $messenger
729
	 * @return bool true if it got activated (or was active) and false if not.
730
	 * @throws \EE_Error
731
	 */
732
	public function ensure_message_type_is_active( $message_type, $messenger ) {
733
		// EE_messages has been deprecated
734
		$this->_class_is_deprecated( __FUNCTION__ );
735
		return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger );
736
	}
737
738
739
740
	/**
741
	 * @deprecated 4.9.0
742
	 * @param string $messenger_name
743
	 * @param array  $mts_to_activate             (optional) An array of message types to activate with this messenger.  If
744
	 *                                            included we do NOT setup the default message types (assuming
745
	 *                                            they are already setup.)
746
	 * @return boolean an array of generated templates or false if nothing generated/activated.
747
	 */
748
	public function activate_messenger( $messenger_name, $mts_to_activate = array() ) {
749
		// EE_messages has been deprecated
750
		$this->_class_is_deprecated( __FUNCTION__ );
751
		return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate );
752
	}
753
754
755
756
	/**
757
	 * @deprecated 4.9.0
758
	 * @param EE_messenger    $messenger    messenger used in trigger
759
	 * @param EE_message_type $message_type message type used in trigger
760
	 *
761
	 * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
762
	 */
763
	public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) {
764
		// EE_messages has been deprecated
765
		$this->_class_is_deprecated( __FUNCTION__ );
766
		return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type );
767
	}
768
769
770
771
	/**
772
	 * @deprecated 4.9.0
773
	 * @param string $messenger
774
	 * @return EE_messenger | null
775
	 */
776
	public function get_messenger_if_active( $messenger ) {
777
		// EE_messages has been deprecated
778
		$this->_class_is_deprecated( __FUNCTION__ );
779
		return $this->_message_resource_manager->get_active_messenger( $messenger );
780
	}
781
782
783
784
	/**
785
	 * @deprecated 4.9.0
786
	 * @param EE_Message $message
787
	 * @return array  An array with 'messenger' and 'message_type' as the index and the corresponding valid object if
788
	 *                  available.
789
	 *                  Eg. Valid Messenger and Message Type:
790
	 *                  array(
791
	 *                  'messenger' => new EE_Email_messenger(),
792
	 *                  'message_type' => new EE_Registration_Approved_message_type()
793
	 *                  )
794
	 *                  Valid Messenger and Invalid Message Type:
795
	 *                  array(
796
	 *                  'messenger' => new EE_Email_messenger(),
797
	 *                  'message_type' => null
798
	 *                  )
799
	 */
800
	public function validate_for_use( EE_Message $message ) {
801
		// EE_messages has been deprecated
802
		$this->_class_is_deprecated( __FUNCTION__ );
803
		return array(
804
			'messenger'    => $message->messenger_object(),
805
			'message_type' => $message->message_type_object(),
806
		);
807
	}
808
809
810
811
	/**
812
	 * @deprecated 4.9.0
813
	 * @param  string $type                 What type of message are we sending (corresponds to message types)
814
	 * @param  mixed  $vars                 Data being sent for parsing in the message
815
	 * @param  string $sending_messenger    if included then we ONLY use the specified messenger for delivery.  Otherwise we cycle through all active messengers.
816
	 * @param string  $generating_messenger if included then this messenger is used for generating the message templates (but not for sending).
817
	 * @param string  $context              If included then only a message type for a specific context will be generated.
818
	 * @param bool    $send                 Default TRUE.  If false, then this will just return the generated EE_messages objects which might be used by the trigger to setup a batch message (typically html messenger uses it).
819
	 * @return bool
820
	 */
821
	public function send_message(
822
		$type,
823
		$vars,
824
		$sending_messenger = '',
825
		$generating_messenger = '',
826
		$context = '',
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
827
		$send = true
828
	) {
829
		// EE_messages has been deprecated
830
		$this->_class_is_deprecated( __FUNCTION__ );
831
		/** @type EE_Messages_Processor $processor */
832
		$processor = EE_Registry::instance()->load_lib( 'Messages_Processor' );
833
		$error = false;
834
		//try to intelligently determine what method we'll call based on the incoming data.
835
		//if generating and sending are different then generate and send immediately.
836
		if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) {
837
			//in the legacy system, when generating and sending were different, that means all the
838
			//vars are already in the request object.  So let's just use that.
839
			try {
840
				/** @type EE_Message_To_Generate_From_Request $mtg */
841
				$mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' );
842
				$processor->generate_and_send_now( $mtg );
843
			} catch ( EE_Error $e ) {
844
				$error_msg = __(
845
					'Please note that a system message failed to send due to a technical issue.',
846
					'event_espresso'
847
				);
848
				// add specific message for developers if WP_DEBUG in on
849
				$error_msg .= '||' . $e->getMessage();
850
				EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
851
				$error = true;
852
			}
853
		} else {
854
			$processor->generate_for_all_active_messengers( $type, $vars, $send );
855
			//let's find out if there were any errors and how many successfully were queued.
856
			$count_errors = $processor->get_queue()->count_STS_in_queue(
857
				array( EEM_Message::status_failed, EEM_Message::status_debug_only )
858
			);
859
			$count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete );
860
			$count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry );
861
			$count_errors = $count_errors + $count_retry;
862
			if ( $count_errors > 0 ) {
863
				$error = true;
864
				if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) {
865
					$message = sprintf(
866
						__(
867
							'There were %d errors and %d messages successfully queued for generation and sending',
868
							'event_espresso'
869
						),
870
						$count_errors,
871
						$count_queued
872
					);
873
				} elseif ( $count_errors > 1 && $count_queued === 1 ) {
874
					$message = sprintf(
875
						__(
876
							'There were %d errors and %d message successfully queued for generation.',
877
							'event_espresso'
878
						),
879
						$count_errors,
880
						$count_queued
881
					);
882
				} elseif ( $count_errors === 1 && $count_queued > 1 ) {
883
					$message = sprintf(
884
						__(
885
							'There was %d error and %d messages successfully queued for generation.',
886
							'event_espresso'
887
						),
888
						$count_errors,
889
						$count_queued
890
					);
891
				} else {
892
					$message = sprintf(
893
						__(
894
							'There was %d message that failed to be queued for generation.',
895
							'event_espresso'
896
						),
897
						$count_errors
898
					);
899
				}
900
				EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ );
901
			} else {
902
				if ( $count_queued === 1 ) {
903
					$message = sprintf(
904
						__(
905
							'%d message successfully queued for generation.',
906
							'event_espresso'
907
						),
908
						$count_queued
909
					);
910
				} else {
911
					$message = sprintf(
912
						__(
913
							'%d messages were successfully queued for generation.',
914
							'event_espresso'
915
						),
916
						$count_queued
917
					);
918
				}
919
				EE_Error::add_success( $message );
920
			}
921
		}
922
		//if no error then return the generated message(s).
923
		if ( ! $error && ! $send ) {
924
			$generated_queue = $processor->generate_queue( false );
925
			//get message and return.
926
			$generated_queue->get_message_repository()->rewind();
927
			$messages = array();
928
			while ( $generated_queue->get_message_repository()->valid() ) {
929
				$message = $generated_queue->get_message_repository()->current();
930
				if ( $message instanceof EE_Message ) {
931
					//set properties that might be expected by add-ons (backward compat)
932
					$message->content = $message->content();
0 ignored issues
show
Deprecated Code introduced by
The property EE_Message::$content has been deprecated with message: 4.9.0 Added for backward compat with add-on's

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
933
					$message->template_pack = $message->get_template_pack();
0 ignored issues
show
Documentation Bug introduced by
It seems like $message->get_template_pack() can also be of type object<EE_Messages_Template_Pack>. However, the property $template_pack is declared as type null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
Deprecated Code introduced by
The property EE_Message::$template_pack has been deprecated with message: 4.9.0 Added for backward compat with add-on's

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
934
					$message->template_variation = $message->get_template_pack_variation();
0 ignored issues
show
Documentation Bug introduced by
It seems like $message->get_template_pack_variation() of type string is incompatible with the declared type null of property $template_variation.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
Deprecated Code introduced by
The property EE_Message::$template_variation has been deprecated with message: 4.9.0 Added for backward compat with add-on's

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
935
					$messages[] = $message;
936
				}
937
				$generated_queue->get_message_repository()->next();
938
			}
939
			return $messages;
940
		}
941
		return $error ? false
942
			: true; //yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
943
	}
944
945
946
947
	/**
948
	 * @deprecated 4.9.0
949
	 * @param  string $type      This should correspond with a valid message type
950
	 * @param  string $context   This should correspond with a valid context for the message type
951
	 * @param  string $messenger This should correspond with a valid messenger.
952
	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular preview
953
	 * @return string          The body of the message.
954
	 */
955
	public function preview_message( $type, $context, $messenger, $send = false ) {
956
		// EE_messages has been deprecated
957
		$this->_class_is_deprecated( __FUNCTION__ );
958
		return EED_Messages::preview_message( $type, $context, $messenger, $send );
959
	}
960
961
962
963
	/**
964
	 * @since      4.5.0
965
	 * @deprecated 4.9.0   Moved to EED_Messages Module
966
	 * @param string   $messenger    a string matching a valid active messenger in the system
967
	 * @param string   $message_type Although it seems contrary to the name of the method, a message type name is still required to send along the message type to the messenger because this is used for determining what specific variations might be loaded for the generated message.
968
	 * @param stdClass $message      a stdClass object in the format expected by the messenger.
969
	 *
970
	 * @return bool          success or fail.
971
	 */
972
	public function send_message_with_messenger_only( $messenger, $message_type, $message ) {
973
		// EE_messages has been deprecated
974
		$this->_class_is_deprecated( __FUNCTION__ );
975
		//setup for sending to new method.
976
		/** @type EE_Messages_Queue $queue */
977
		$queue = EE_Registry::instance()->load_lib( 'Messages_Queue' );
978
		//make sure we have a proper message object
979
		if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) {
980
			$msg = EE_Message_Factory::create(
981
				array(
982
					'MSG_messenger'    => $messenger,
983
					'MSG_message_type' => $message_type,
984
					'MSG_content'      => $message->content,
985
					'MSG_subject'      => $message->subject
986
				)
987
			);
988
		} else {
989
			$msg = $message;
990
		}
991
		if ( ! $msg instanceof EE_Message ) {
992
			return false;
993
		}
994
		//make sure any content in a content property (if not empty) is set on the MSG_content.
995
		if ( ! empty( $msg->content ) ) {
0 ignored issues
show
Deprecated Code introduced by
The property EE_Message::$content has been deprecated with message: 4.9.0 Added for backward compat with add-on's

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
996
			$msg->set( 'MSG_content', $msg->content );
0 ignored issues
show
Deprecated Code introduced by
The property EE_Message::$content has been deprecated with message: 4.9.0 Added for backward compat with add-on's

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
997
		}
998
		$queue->add( $msg );
999
		return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue );
1000
	}
1001
1002
1003
1004
	/**
1005
	 * @deprecated 4.9.0
1006
	 * @param         $messenger
1007
	 * @param  string $message_type message type that the templates are being created for
1008
	 * @param int     $GRP_ID
1009
	 * @param bool    $is_global
1010
	 * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned.
1011
	 * @throws \EE_Error
1012
	 */
1013
	public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) {
1014
		// EE_messages has been deprecated
1015
		$this->_class_is_deprecated( __FUNCTION__ );
1016
		EE_Registry::instance()->load_helper( 'MSG_Template' );
1017
		return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global );
1018
	}
1019
1020
1021
1022
	/**
1023
	 * @deprecated 4.9.0
1024
	 * @param  string $messenger_name    name of EE_messenger
1025
	 * @param  string $message_type_name name of EE_message_type
1026
	 * @return array
1027
	 */
1028
	public function get_fields( $messenger_name, $message_type_name ) {
1029
		// EE_messages has been deprecated
1030
		$this->_class_is_deprecated( __FUNCTION__ );
1031
		EE_Registry::instance()->load_helper( 'MSG_Template' );
1032
		return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name );
1033
	}
1034
1035
1036
1037
	/**
1038
	 * @deprecated 4.9.0
1039
	 * @access     public
1040
	 * @param string $type                we can indicate just returning installed message types
1041
	 *                                    or messengers (or both) via this parameter.
1042
	 * @param bool   $skip_cache          if true then we skip the cache and retrieve via files.
1043
	 * @return array                    multidimensional array of messenger and message_type objects
1044
	 *                                    (messengers index, and message_type index);
1045
	 */
1046
	public function get_installed( $type = 'all', $skip_cache = false ) {
1047
		// EE_messages has been deprecated
1048
		$this->_class_is_deprecated( __FUNCTION__ );
1049
		if ( $skip_cache ) {
1050
			$this->_message_resource_manager->reset_active_messengers_and_message_types();
1051
		}
1052
		switch ( $type ) {
1053
			case 'messengers' :
1054
				return array(
1055
					'messenger' => $this->_message_resource_manager->installed_messengers(),
1056
				);
1057
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
1058
			case 'message_types' :
1059
				return array(
1060
					'message_type' => $this->_message_resource_manager->installed_message_types(),
1061
				);
1062
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
1063
			case 'all' :
1064
			default :
1065
				return array(
1066
					'messenger'    => $this->_message_resource_manager->installed_messengers(),
1067
					'message_type' => $this->_message_resource_manager->installed_message_types(),
1068
				);
1069
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
1070
		}
1071
	}
1072
1073
1074
1075
	/**
1076
	 * @deprecated 4.9.0
1077
	 * @return \EE_messenger[]
1078
	 */
1079
	public function get_active_messengers() {
1080
		// EE_messages has been deprecated
1081
		$this->_class_is_deprecated( __FUNCTION__ );
1082
		return $this->_message_resource_manager->active_messengers();
1083
	}
1084
1085
1086
1087
	/**
1088
	 * @deprecated 4.9.0
1089
	 * @return array array of message_type references (string)
1090
	 */
1091
	public function get_active_message_types() {
1092
		// EE_messages has been deprecated
1093
		$this->_class_is_deprecated( __FUNCTION__ );
1094
		return $this->_message_resource_manager->list_of_active_message_types();
1095
	}
1096
1097
1098
1099
	/**
1100
	 * @deprecated 4.9.0
1101
	 * @return EE_message_type[]
1102
	 */
1103
	public function get_active_message_type_objects() {
1104
		// EE_messages has been deprecated
1105
		$this->_class_is_deprecated( __FUNCTION__ );
1106
		return $this->_message_resource_manager->get_active_message_type_objects();
1107
	}
1108
1109
1110
1111
	/**
1112
	 * @deprecated 4.9.0
1113
	 * @since      4.5.0
1114
	 * @param string $messenger The messenger being checked
1115
	 * @return EE_message_type[]    (or empty array if none present)
1116
	 */
1117
	public function get_active_message_types_per_messenger( $messenger ) {
1118
		// EE_messages has been deprecated
1119
		$this->_class_is_deprecated( __FUNCTION__ );
1120
		return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger );
1121
	}
1122
1123
1124
1125
	/**
1126
	 * @deprecated 4.9.0
1127
	 * @param string $messenger    The string should correspond to the messenger (message types are
1128
	 * @param string $message_type The string should correspond to a message type.
1129
	 * @return EE_message_type|null
1130
	 */
1131
	public function get_active_message_type( $messenger, $message_type ) {
1132
		// EE_messages has been deprecated
1133
		$this->_class_is_deprecated( __FUNCTION__ );
1134
		return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type );
1135
	}
1136
1137
1138
1139
	/**
1140
	 * @deprecated 4.9.0
1141
	 * @return array|\EE_message_type[]
1142
	 */
1143
	public function get_installed_message_types() {
1144
		// EE_messages has been deprecated
1145
		$this->_class_is_deprecated( __FUNCTION__ );
1146
		return $this->_message_resource_manager->installed_message_types();
1147
	}
1148
1149
1150
1151
	/**
1152
	 * @deprecated 4.9.0
1153
	 * @return array
1154
	 */
1155
	public function get_installed_messengers() {
1156
		// EE_messages has been deprecated
1157
		$this->_class_is_deprecated( __FUNCTION__ );
1158
		return $this->_message_resource_manager->installed_messengers();
1159
	}
1160
1161
1162
1163
	/**
1164
	 * @deprecated 4.9.0
1165
	 * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type.
1166
	 * @return array
1167
	 */
1168
	public function get_all_contexts( $slugs_only = true ) {
1169
		// EE_messages has been deprecated
1170
		$this->_class_is_deprecated( __FUNCTION__ );
1171
		return $this->_message_resource_manager->get_all_contexts( $slugs_only );
1172
	}
1173
1174
1175
1176
}
1177
//end EE_messages class
1178
1179
1180
1181
/**
1182
 * Class EE_Address_Formatter
1183
 *
1184
 * @deprecated 4.9.0
1185
 */
1186
class EE_Address_Formatter extends \EventEspresso\core\services\address\formatters\AddressFormatter {}
1187
1188
1189
1190
/**
1191
 * Class EE_MultiLine_Address_Formatter
1192
 *
1193
 * @deprecated 4.9.0
1194
 */
1195
class EE_MultiLine_Address_Formatter extends \EventEspresso\core\services\address\formatters\NullAddressFormatter {}
1196
1197
1198
1199
/**
1200
 * Class EE_Inline_Address_Formatter
1201
 *
1202
 * @deprecated 4.9.0
1203
 */
1204
class EE_Inline_Address_Formatter extends \EventEspresso\core\services\address\formatters\InlineAddressFormatter {}
1205
1206
1207
1208
/**
1209
 * Class EE_Null_Address_Formatter
1210
 *
1211
 * @deprecated 4.9.0
1212
 */
1213
class EE_Null_Address_Formatter extends \EventEspresso\core\services\address\formatters\NullAddressFormatter {}
1214
1215
1216
1217
/**
1218
 * Class EE_Generic_Address
1219
 *
1220
 * @deprecated 4.9.0
1221
 */
1222
class EE_Generic_Address extends \EventEspresso\core\entities\GenericAddress {}
1223
1224
1225