@@ -15,25 +15,25 @@ |
||
15 | 15 | interface PersonalDataEraserInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Gets a translated string name for the data eraser |
|
20 | - * |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public function name(); |
|
18 | + /** |
|
19 | + * Gets a translated string name for the data eraser |
|
20 | + * |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public function name(); |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Erases a "page" of personal user data |
|
28 | - * |
|
29 | - * @return array { |
|
30 | - * @type boolean $items_removed whether items were removed successfully or not |
|
31 | - * @type boolean $items_retained whether any items were skipped or not |
|
32 | - * @type array $messages values are messages to show |
|
33 | - * @type boolean $done whether this eraser is done or has more pages |
|
34 | - * } |
|
35 | - */ |
|
36 | - public function erase($email_address, $page = 1); |
|
26 | + /** |
|
27 | + * Erases a "page" of personal user data |
|
28 | + * |
|
29 | + * @return array { |
|
30 | + * @type boolean $items_removed whether items were removed successfully or not |
|
31 | + * @type boolean $items_retained whether any items were skipped or not |
|
32 | + * @type array $messages values are messages to show |
|
33 | + * @type boolean $done whether this eraser is done or has more pages |
|
34 | + * } |
|
35 | + */ |
|
36 | + public function erase($email_address, $page = 1); |
|
37 | 37 | } |
38 | 38 | // End of file PersonalDataEraserInterface.php |
39 | 39 | // Location: EventEspresso\core\domain\services\admin/PersonalDataEraserInterface.php |
@@ -23,68 +23,68 @@ |
||
23 | 23 | class PersonalDataExporterManager |
24 | 24 | { |
25 | 25 | |
26 | - public function __construct() |
|
27 | - { |
|
28 | - add_filter( |
|
29 | - 'wp_privacy_personal_data_exporters', |
|
30 | - array($this, 'hookInExporters') |
|
31 | - ); |
|
32 | - } |
|
26 | + public function __construct() |
|
27 | + { |
|
28 | + add_filter( |
|
29 | + 'wp_privacy_personal_data_exporters', |
|
30 | + array($this, 'hookInExporters') |
|
31 | + ); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Adds EE's exporters to the list of WP exporters |
|
37 | - * |
|
38 | - * @param array $exporters |
|
39 | - * @return array |
|
40 | - */ |
|
41 | - public function hookInExporters($exporters) |
|
42 | - { |
|
43 | - // load all the privacy policy stuff |
|
44 | - // add post policy text |
|
45 | - foreach ($this->loadPrivateDataExporterCollection() as $exporter) { |
|
46 | - $exporters[ get_class($exporter) ] = array( |
|
47 | - 'exporter_friendly_name' => $exporter->name(), |
|
48 | - 'callback' => array($exporter, 'export'), |
|
49 | - ); |
|
50 | - } |
|
51 | - return $exporters; |
|
52 | - } |
|
35 | + /** |
|
36 | + * Adds EE's exporters to the list of WP exporters |
|
37 | + * |
|
38 | + * @param array $exporters |
|
39 | + * @return array |
|
40 | + */ |
|
41 | + public function hookInExporters($exporters) |
|
42 | + { |
|
43 | + // load all the privacy policy stuff |
|
44 | + // add post policy text |
|
45 | + foreach ($this->loadPrivateDataExporterCollection() as $exporter) { |
|
46 | + $exporters[ get_class($exporter) ] = array( |
|
47 | + 'exporter_friendly_name' => $exporter->name(), |
|
48 | + 'callback' => array($exporter, 'export'), |
|
49 | + ); |
|
50 | + } |
|
51 | + return $exporters; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * @return CollectionInterface|PersonalDataExporterInterface[] |
|
57 | - * @throws InvalidIdentifierException |
|
58 | - * @throws InvalidInterfaceException |
|
59 | - * @throws InvalidFilePathException |
|
60 | - * @throws InvalidEntityException |
|
61 | - * @throws InvalidDataTypeException |
|
62 | - * @throws InvalidClassException |
|
63 | - */ |
|
64 | - protected function loadPrivateDataExporterCollection() |
|
65 | - { |
|
66 | - $loader = new CollectionLoader( |
|
67 | - new CollectionDetails( |
|
68 | - // collection name |
|
69 | - 'personal_data_exporters', |
|
70 | - // collection interface |
|
71 | - 'EventEspresso\core\services\privacy\export\PersonalDataExporterInterface', |
|
72 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
73 | - apply_filters( |
|
74 | - 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
|
75 | - array('EventEspresso\core\domain\services\admin\privacy\export') |
|
76 | - ), |
|
77 | - // filepaths to classes to add |
|
78 | - array(), |
|
79 | - // file mask to use if parsing folder for files to add |
|
80 | - '', |
|
81 | - // what to use as identifier for collection entities |
|
82 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
83 | - CollectionDetails::ID_CLASS_NAME |
|
84 | - ) |
|
85 | - ); |
|
86 | - return $loader->getCollection(); |
|
87 | - } |
|
55 | + /** |
|
56 | + * @return CollectionInterface|PersonalDataExporterInterface[] |
|
57 | + * @throws InvalidIdentifierException |
|
58 | + * @throws InvalidInterfaceException |
|
59 | + * @throws InvalidFilePathException |
|
60 | + * @throws InvalidEntityException |
|
61 | + * @throws InvalidDataTypeException |
|
62 | + * @throws InvalidClassException |
|
63 | + */ |
|
64 | + protected function loadPrivateDataExporterCollection() |
|
65 | + { |
|
66 | + $loader = new CollectionLoader( |
|
67 | + new CollectionDetails( |
|
68 | + // collection name |
|
69 | + 'personal_data_exporters', |
|
70 | + // collection interface |
|
71 | + 'EventEspresso\core\services\privacy\export\PersonalDataExporterInterface', |
|
72 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
73 | + apply_filters( |
|
74 | + 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
|
75 | + array('EventEspresso\core\domain\services\admin\privacy\export') |
|
76 | + ), |
|
77 | + // filepaths to classes to add |
|
78 | + array(), |
|
79 | + // file mask to use if parsing folder for files to add |
|
80 | + '', |
|
81 | + // what to use as identifier for collection entities |
|
82 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
83 | + CollectionDetails::ID_CLASS_NAME |
|
84 | + ) |
|
85 | + ); |
|
86 | + return $loader->getCollection(); |
|
87 | + } |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | // End of file PersonalDataExporterManager.php |
@@ -43,7 +43,7 @@ |
||
43 | 43 | // load all the privacy policy stuff |
44 | 44 | // add post policy text |
45 | 45 | foreach ($this->loadPrivateDataExporterCollection() as $exporter) { |
46 | - $exporters[ get_class($exporter) ] = array( |
|
46 | + $exporters[get_class($exporter)] = array( |
|
47 | 47 | 'exporter_friendly_name' => $exporter->name(), |
48 | 48 | 'callback' => array($exporter, 'export'), |
49 | 49 | ); |
@@ -40,7 +40,7 @@ |
||
40 | 40 | // load all the privacy policy stuff |
41 | 41 | // add post policy text |
42 | 42 | foreach ($this->loadPrivateDataEraserCollection() as $eraser) { |
43 | - $erasers[ get_class($eraser) ] = array( |
|
43 | + $erasers[get_class($eraser)] = array( |
|
44 | 44 | 'eraser_friendly_name' => $eraser->name(), |
45 | 45 | 'callback' => array($eraser, 'erase'), |
46 | 46 | ); |
@@ -23,65 +23,65 @@ |
||
23 | 23 | class PersonalDataEraserManager |
24 | 24 | { |
25 | 25 | |
26 | - public function __construct() |
|
27 | - { |
|
28 | - add_filter( |
|
29 | - 'wp_privacy_personal_data_erasers', |
|
30 | - array($this, 'hookInErasers') |
|
31 | - ); |
|
32 | - } |
|
26 | + public function __construct() |
|
27 | + { |
|
28 | + add_filter( |
|
29 | + 'wp_privacy_personal_data_erasers', |
|
30 | + array($this, 'hookInErasers') |
|
31 | + ); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * For all the registered `PrivateDataEraserInterface`s, add them as erasers |
|
37 | - */ |
|
38 | - public function hookInErasers($erasers) |
|
39 | - { |
|
40 | - // load all the privacy policy stuff |
|
41 | - // add post policy text |
|
42 | - foreach ($this->loadPrivateDataEraserCollection() as $eraser) { |
|
43 | - $erasers[ get_class($eraser) ] = array( |
|
44 | - 'eraser_friendly_name' => $eraser->name(), |
|
45 | - 'callback' => array($eraser, 'erase'), |
|
46 | - ); |
|
47 | - } |
|
48 | - return $erasers; |
|
49 | - } |
|
35 | + /** |
|
36 | + * For all the registered `PrivateDataEraserInterface`s, add them as erasers |
|
37 | + */ |
|
38 | + public function hookInErasers($erasers) |
|
39 | + { |
|
40 | + // load all the privacy policy stuff |
|
41 | + // add post policy text |
|
42 | + foreach ($this->loadPrivateDataEraserCollection() as $eraser) { |
|
43 | + $erasers[ get_class($eraser) ] = array( |
|
44 | + 'eraser_friendly_name' => $eraser->name(), |
|
45 | + 'callback' => array($eraser, 'erase'), |
|
46 | + ); |
|
47 | + } |
|
48 | + return $erasers; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @return CollectionInterface|PersonalDataEraserInterface[] |
|
54 | - * @throws InvalidIdentifierException |
|
55 | - * @throws InvalidInterfaceException |
|
56 | - * @throws InvalidFilePathException |
|
57 | - * @throws InvalidEntityException |
|
58 | - * @throws InvalidDataTypeException |
|
59 | - * @throws InvalidClassException |
|
60 | - */ |
|
61 | - protected function loadPrivateDataEraserCollection() |
|
62 | - { |
|
63 | - $loader = new CollectionLoader( |
|
64 | - new CollectionDetails( |
|
65 | - // collection name |
|
66 | - 'privacy_erasers', |
|
67 | - // collection interface |
|
68 | - 'EventEspresso\core\services\privacy\erasure\PersonalDataEraserInterface', |
|
69 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
70 | - apply_filters( |
|
71 | - 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
|
72 | - array('EventEspresso\core\domain\services\admin\privacy\erasure') |
|
73 | - ), |
|
74 | - // filepaths to classes to add |
|
75 | - array(), |
|
76 | - // file mask to use if parsing folder for files to add |
|
77 | - '', |
|
78 | - // what to use as identifier for collection entities |
|
79 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
80 | - CollectionDetails::ID_CLASS_NAME |
|
81 | - ) |
|
82 | - ); |
|
83 | - return $loader->getCollection(); |
|
84 | - } |
|
52 | + /** |
|
53 | + * @return CollectionInterface|PersonalDataEraserInterface[] |
|
54 | + * @throws InvalidIdentifierException |
|
55 | + * @throws InvalidInterfaceException |
|
56 | + * @throws InvalidFilePathException |
|
57 | + * @throws InvalidEntityException |
|
58 | + * @throws InvalidDataTypeException |
|
59 | + * @throws InvalidClassException |
|
60 | + */ |
|
61 | + protected function loadPrivateDataEraserCollection() |
|
62 | + { |
|
63 | + $loader = new CollectionLoader( |
|
64 | + new CollectionDetails( |
|
65 | + // collection name |
|
66 | + 'privacy_erasers', |
|
67 | + // collection interface |
|
68 | + 'EventEspresso\core\services\privacy\erasure\PersonalDataEraserInterface', |
|
69 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
70 | + apply_filters( |
|
71 | + 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
|
72 | + array('EventEspresso\core\domain\services\admin\privacy\erasure') |
|
73 | + ), |
|
74 | + // filepaths to classes to add |
|
75 | + array(), |
|
76 | + // file mask to use if parsing folder for files to add |
|
77 | + '', |
|
78 | + // what to use as identifier for collection entities |
|
79 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
80 | + CollectionDetails::ID_CLASS_NAME |
|
81 | + ) |
|
82 | + ); |
|
83 | + return $loader->getCollection(); |
|
84 | + } |
|
85 | 85 | } |
86 | 86 | // End of file PersonalDataEraserManager.php |
87 | 87 | // Location: EventEspresso\core\domain\services\admin/PersonalDataEraserManager.php |
@@ -17,97 +17,97 @@ |
||
17 | 17 | class RegisterCustomTaxonomies |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var CustomTaxonomyDefinitions $custom_taxonomies |
|
22 | - */ |
|
23 | - public $custom_taxonomies; |
|
20 | + /** |
|
21 | + * @var CustomTaxonomyDefinitions $custom_taxonomies |
|
22 | + */ |
|
23 | + public $custom_taxonomies; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * RegisterCustomTaxonomies constructor. |
|
28 | - * |
|
29 | - * @param CustomTaxonomyDefinitions $custom_taxonomies |
|
30 | - */ |
|
31 | - public function __construct(CustomTaxonomyDefinitions $custom_taxonomies) |
|
32 | - { |
|
33 | - $this->custom_taxonomies = $custom_taxonomies; |
|
34 | - } |
|
26 | + /** |
|
27 | + * RegisterCustomTaxonomies constructor. |
|
28 | + * |
|
29 | + * @param CustomTaxonomyDefinitions $custom_taxonomies |
|
30 | + */ |
|
31 | + public function __construct(CustomTaxonomyDefinitions $custom_taxonomies) |
|
32 | + { |
|
33 | + $this->custom_taxonomies = $custom_taxonomies; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * @return void |
|
39 | - * @throws DomainException |
|
40 | - */ |
|
41 | - public function registerCustomTaxonomies() |
|
42 | - { |
|
43 | - $custom_taxonomies = $this->custom_taxonomies->getCustomTaxonomyDefinitions(); |
|
44 | - foreach ($custom_taxonomies as $taxonomy => $tax) { |
|
45 | - $this->registerCustomTaxonomy( |
|
46 | - $taxonomy, |
|
47 | - $tax['singular_name'], |
|
48 | - $tax['plural_name'], |
|
49 | - $tax['args'] |
|
50 | - ); |
|
51 | - } |
|
52 | - } |
|
37 | + /** |
|
38 | + * @return void |
|
39 | + * @throws DomainException |
|
40 | + */ |
|
41 | + public function registerCustomTaxonomies() |
|
42 | + { |
|
43 | + $custom_taxonomies = $this->custom_taxonomies->getCustomTaxonomyDefinitions(); |
|
44 | + foreach ($custom_taxonomies as $taxonomy => $tax) { |
|
45 | + $this->registerCustomTaxonomy( |
|
46 | + $taxonomy, |
|
47 | + $tax['singular_name'], |
|
48 | + $tax['plural_name'], |
|
49 | + $tax['args'] |
|
50 | + ); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Registers a custom taxonomy. Should be called before registering custom post types, |
|
57 | - * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'. |
|
58 | - * |
|
59 | - * @param string $taxonomy_name , eg 'books' |
|
60 | - * @param string $singular_name internationalized singular name |
|
61 | - * @param string $plural_name internationalized plural name |
|
62 | - * @param array $override_arguments like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy |
|
63 | - * @throws DomainException |
|
64 | - */ |
|
65 | - public function registerCustomTaxonomy($taxonomy_name, $singular_name, $plural_name, array $override_arguments) |
|
66 | - { |
|
67 | - $result = register_taxonomy( |
|
68 | - $taxonomy_name, |
|
69 | - null, |
|
70 | - $this->prepareArguments( |
|
71 | - $singular_name, |
|
72 | - $plural_name, |
|
73 | - $override_arguments |
|
74 | - ) |
|
75 | - ); |
|
76 | - if ($result instanceof WP_Error) { |
|
77 | - throw new DomainException($result->get_error_message()); |
|
78 | - } |
|
79 | - } |
|
55 | + /** |
|
56 | + * Registers a custom taxonomy. Should be called before registering custom post types, |
|
57 | + * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'. |
|
58 | + * |
|
59 | + * @param string $taxonomy_name , eg 'books' |
|
60 | + * @param string $singular_name internationalized singular name |
|
61 | + * @param string $plural_name internationalized plural name |
|
62 | + * @param array $override_arguments like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy |
|
63 | + * @throws DomainException |
|
64 | + */ |
|
65 | + public function registerCustomTaxonomy($taxonomy_name, $singular_name, $plural_name, array $override_arguments) |
|
66 | + { |
|
67 | + $result = register_taxonomy( |
|
68 | + $taxonomy_name, |
|
69 | + null, |
|
70 | + $this->prepareArguments( |
|
71 | + $singular_name, |
|
72 | + $plural_name, |
|
73 | + $override_arguments |
|
74 | + ) |
|
75 | + ); |
|
76 | + if ($result instanceof WP_Error) { |
|
77 | + throw new DomainException($result->get_error_message()); |
|
78 | + } |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * @param string $singular_name |
|
84 | - * @param string $plural_name |
|
85 | - * @param array $override_arguments |
|
86 | - * @since 4.9.62.p |
|
87 | - * @return array |
|
88 | - */ |
|
89 | - protected function prepareArguments($singular_name, $plural_name, array $override_arguments) |
|
90 | - { |
|
91 | - $arguments = array( |
|
92 | - 'hierarchical' => true, |
|
93 | - 'labels' => array( |
|
94 | - 'name' => $plural_name, |
|
95 | - 'singular_name' => $singular_name, |
|
96 | - ), |
|
97 | - 'show_ui' => true, |
|
98 | - 'show_ee_ui' => true, |
|
99 | - 'show_admin_column' => true, |
|
100 | - 'query_var' => true, |
|
101 | - 'show_in_nav_menus' => false, |
|
102 | - 'map_meta_cap' => true, |
|
103 | - ); |
|
104 | - if ($override_arguments) { |
|
105 | - if (isset($override_args['labels'])) { |
|
106 | - $labels = array_merge($arguments['labels'], $override_arguments['labels']); |
|
107 | - $arguments['labels'] = $labels; |
|
108 | - } |
|
109 | - $arguments = array_merge($arguments, $override_arguments); |
|
110 | - } |
|
111 | - return $arguments; |
|
112 | - } |
|
82 | + /** |
|
83 | + * @param string $singular_name |
|
84 | + * @param string $plural_name |
|
85 | + * @param array $override_arguments |
|
86 | + * @since 4.9.62.p |
|
87 | + * @return array |
|
88 | + */ |
|
89 | + protected function prepareArguments($singular_name, $plural_name, array $override_arguments) |
|
90 | + { |
|
91 | + $arguments = array( |
|
92 | + 'hierarchical' => true, |
|
93 | + 'labels' => array( |
|
94 | + 'name' => $plural_name, |
|
95 | + 'singular_name' => $singular_name, |
|
96 | + ), |
|
97 | + 'show_ui' => true, |
|
98 | + 'show_ee_ui' => true, |
|
99 | + 'show_admin_column' => true, |
|
100 | + 'query_var' => true, |
|
101 | + 'show_in_nav_menus' => false, |
|
102 | + 'map_meta_cap' => true, |
|
103 | + ); |
|
104 | + if ($override_arguments) { |
|
105 | + if (isset($override_args['labels'])) { |
|
106 | + $labels = array_merge($arguments['labels'], $override_arguments['labels']); |
|
107 | + $arguments['labels'] = $labels; |
|
108 | + } |
|
109 | + $arguments = array_merge($arguments, $override_arguments); |
|
110 | + } |
|
111 | + return $arguments; |
|
112 | + } |
|
113 | 113 | } |
@@ -19,303 +19,303 @@ discard block |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * instantiated at init priority 5 |
|
24 | - * |
|
25 | - * @deprecated 4.9.62.p |
|
26 | - */ |
|
27 | - public function __construct() |
|
28 | - { |
|
29 | - do_action('AHEE__EE_Register_CPTs__construct_end', $this); |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
35 | - * |
|
36 | - * @deprecated 4.9.62.p |
|
37 | - * @return void |
|
38 | - * @throws InvalidInterfaceException |
|
39 | - * @throws InvalidDataTypeException |
|
40 | - * @throws InvalidArgumentException |
|
41 | - */ |
|
42 | - public static function maybe_flush_rewrite_rules() |
|
43 | - { |
|
44 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
45 | - $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
46 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
47 | - ); |
|
48 | - $rewrite_rules->flushRewriteRules(); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * @return CustomTaxonomyDefinitions |
|
54 | - * @throws InvalidArgumentException |
|
55 | - * @throws InvalidDataTypeException |
|
56 | - * @throws InvalidInterfaceException |
|
57 | - */ |
|
58 | - public static function getTaxonomyDefinitions() |
|
59 | - { |
|
60 | - return LoaderFactory::getLoader()->getShared( |
|
61 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' |
|
62 | - ); |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @deprecated 4.9.62.p |
|
68 | - * @param string $description The description content. |
|
69 | - * @param string $taxonomy The taxonomy name for the taxonomy being filtered. |
|
70 | - * @return string |
|
71 | - * @throws InvalidArgumentException |
|
72 | - * @throws InvalidDataTypeException |
|
73 | - * @throws InvalidInterfaceException |
|
74 | - */ |
|
75 | - public function ee_filter_ee_term_description_not_wp($description, $taxonomy) |
|
76 | - { |
|
77 | - $taxonomies = EE_Register_CPTs::getTaxonomyDefinitions(); |
|
78 | - return $taxonomies->filterCustomTermDescription($description, $taxonomy); |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @deprecated 4.9.62.p |
|
84 | - * @return array |
|
85 | - * @throws InvalidArgumentException |
|
86 | - * @throws InvalidDataTypeException |
|
87 | - * @throws InvalidInterfaceException |
|
88 | - */ |
|
89 | - public static function get_taxonomies() |
|
90 | - { |
|
91 | - $taxonomies = EE_Register_CPTs::getTaxonomyDefinitions(); |
|
92 | - return $taxonomies->getCustomTaxonomyDefinitions(); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @return CustomPostTypeDefinitions |
|
98 | - * @throws InvalidArgumentException |
|
99 | - * @throws InvalidDataTypeException |
|
100 | - * @throws InvalidInterfaceException |
|
101 | - */ |
|
102 | - public static function getCustomPostTypeDefinitions() |
|
103 | - { |
|
104 | - return LoaderFactory::getLoader()->getShared( |
|
105 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
106 | - ); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @deprecated 4.9.62.p |
|
112 | - * @return array |
|
113 | - * @throws InvalidArgumentException |
|
114 | - * @throws InvalidDataTypeException |
|
115 | - * @throws InvalidInterfaceException |
|
116 | - */ |
|
117 | - public static function get_CPTs() |
|
118 | - { |
|
119 | - $custom_post_types = EE_Register_CPTs::getCustomPostTypeDefinitions(); |
|
120 | - return $custom_post_types->getDefinitions(); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @deprecated 4.9.62.p |
|
126 | - * @return array |
|
127 | - * @throws InvalidArgumentException |
|
128 | - * @throws InvalidDataTypeException |
|
129 | - * @throws InvalidInterfaceException |
|
130 | - */ |
|
131 | - public static function get_private_CPTs() |
|
132 | - { |
|
133 | - $custom_post_types = EE_Register_CPTs::getCustomPostTypeDefinitions(); |
|
134 | - return $custom_post_types->getPrivateCustomPostTypes(); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * @deprecated 4.9.62.p |
|
140 | - * @param string $post_type_slug If a slug is included, then attempt to retrieve the model name for |
|
141 | - * the given cpt slug. Otherwise if empty, then we'll return all cpt |
|
142 | - * model names for cpts registered in EE. |
|
143 | - * @return array Empty array if no matching model names for the given slug or an array of model |
|
144 | - * names indexed by post type slug. |
|
145 | - * @throws InvalidArgumentException |
|
146 | - * @throws InvalidDataTypeException |
|
147 | - * @throws InvalidInterfaceException |
|
148 | - */ |
|
149 | - public static function get_cpt_model_names($post_type_slug = '') |
|
150 | - { |
|
151 | - $custom_post_types = EE_Register_CPTs::getCustomPostTypeDefinitions(); |
|
152 | - return $custom_post_types->getCustomPostTypeModelNames($post_type_slug); |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * @deprecated 4.9.62.p |
|
158 | - * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
159 | - * the cpt matching the given slug. Otherwise all cpt models will be |
|
160 | - * instantiated (if possible). |
|
161 | - * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
162 | - * EEM models indexed by post slug. |
|
163 | - * @throws InvalidArgumentException |
|
164 | - * @throws InvalidDataTypeException |
|
165 | - * @throws InvalidInterfaceException |
|
166 | - */ |
|
167 | - public static function instantiate_cpt_models($post_type_slug = '') |
|
168 | - { |
|
169 | - $custom_post_types = EE_Register_CPTs::getCustomPostTypeDefinitions(); |
|
170 | - return $custom_post_types->getCustomPostTypeModels($post_type_slug); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * @deprecated 4.9.62.p |
|
176 | - * @param string $taxonomy_name , eg 'books' |
|
177 | - * @param string $singular_name internationalized singular name |
|
178 | - * @param string $plural_name internationalized plural name |
|
179 | - * @param array $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy |
|
180 | - * @throws InvalidArgumentException |
|
181 | - * @throws InvalidDataTypeException |
|
182 | - * @throws InvalidInterfaceException |
|
183 | - * @throws DomainException |
|
184 | - */ |
|
185 | - public function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array()) |
|
186 | - { |
|
187 | - /** @var \EventEspresso\core\domain\services\custom_post_types\registerCustomTaxonomies $taxonomies */ |
|
188 | - $taxonomies = LoaderFactory::getLoader()->getShared( |
|
189 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' |
|
190 | - ); |
|
191 | - $taxonomies->registerCustomTaxonomy( |
|
192 | - $taxonomy_name, |
|
193 | - $singular_name, |
|
194 | - $plural_name, |
|
195 | - $override_args |
|
196 | - ); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * @deprecated 4.9.62.p |
|
202 | - * @param string $post_type the actual post type name |
|
203 | - * (VERY IMPORTANT: this much match what the slug is for admin pages related to this |
|
204 | - * cpt Also any models must use this slug as well) |
|
205 | - * @param string $singular_name a pre-internationalized string for the singular name of the objects |
|
206 | - * @param string $plural_name a pre-internalized string for the plural name of the objects |
|
207 | - * @param array $override_args exactly like $args as described in |
|
208 | - * http://codex.wordpress.org/Function_Reference/register_post_type The default values |
|
209 | - * set in this function will be overridden by whatever you set in $override_args |
|
210 | - * @param string $singular_slug |
|
211 | - * @param string $plural_slug |
|
212 | - * @return void , but registers the custom post type |
|
213 | - * @throws InvalidArgumentException |
|
214 | - * @throws InvalidDataTypeException |
|
215 | - * @throws InvalidInterfaceException |
|
216 | - * @throws DomainException |
|
217 | - */ |
|
218 | - public function register_CPT( |
|
219 | - $post_type, |
|
220 | - $singular_name, |
|
221 | - $plural_name, |
|
222 | - $override_args = array(), |
|
223 | - $singular_slug = '', |
|
224 | - $plural_slug = '' |
|
225 | - ) { |
|
226 | - /** @var \EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */ |
|
227 | - $register_custom_post_types = LoaderFactory::getLoader()->getShared( |
|
228 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' |
|
229 | - ); |
|
230 | - $register_custom_post_types->registerCustomPostType( |
|
231 | - $post_type, |
|
232 | - $singular_name, |
|
233 | - $plural_name, |
|
234 | - $singular_slug, |
|
235 | - $plural_slug, |
|
236 | - $override_args |
|
237 | - ); |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * @return RegisterCustomTaxonomyTerms |
|
243 | - * @throws InvalidArgumentException |
|
244 | - * @throws InvalidDataTypeException |
|
245 | - * @throws InvalidInterfaceException |
|
246 | - */ |
|
247 | - public static function getRegisterCustomTaxonomyTerms() |
|
248 | - { |
|
249 | - return LoaderFactory::getLoader()->getShared( |
|
250 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms' |
|
251 | - ); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * @deprecated 4.9.62.p |
|
257 | - * @throws InvalidArgumentException |
|
258 | - * @throws InvalidDataTypeException |
|
259 | - * @throws InvalidInterfaceException |
|
260 | - */ |
|
261 | - public function set_must_use_event_types() |
|
262 | - { |
|
263 | - $register_custom_taxonomy_terms = EE_Register_CPTs::getRegisterCustomTaxonomyTerms(); |
|
264 | - $register_custom_taxonomy_terms->setMustUseEventTypes(); |
|
265 | - } |
|
266 | - |
|
267 | - |
|
268 | - /** |
|
269 | - * @deprecated 4.9.62.p |
|
270 | - * @param string $taxonomy The name of the taxonomy |
|
271 | - * @param array $term_details An array of term details indexed by slug and containing Name of term, and |
|
272 | - * description as the elements in the array |
|
273 | - * @return void |
|
274 | - * @throws InvalidArgumentException |
|
275 | - * @throws InvalidDataTypeException |
|
276 | - * @throws InvalidInterfaceException |
|
277 | - */ |
|
278 | - public function set_must_use_terms($taxonomy, $term_details) |
|
279 | - { |
|
280 | - $register_custom_taxonomy_terms = EE_Register_CPTs::getRegisterCustomTaxonomyTerms(); |
|
281 | - $register_custom_taxonomy_terms->setMustUseTerms($taxonomy, $term_details); |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - /** |
|
286 | - * @deprecated 4.9.62.p |
|
287 | - * @param string $taxonomy The taxonomy we're using for the default term |
|
288 | - * @param string $term_slug The slug of the term that will be the default. |
|
289 | - * @param array $cpt_slugs An array of custom post types we want the default assigned to |
|
290 | - * @throws InvalidArgumentException |
|
291 | - * @throws InvalidDataTypeException |
|
292 | - * @throws InvalidInterfaceException |
|
293 | - */ |
|
294 | - public function set_default_term($taxonomy, $term_slug, $cpt_slugs = array()) |
|
295 | - { |
|
296 | - $register_custom_taxonomy_terms = EE_Register_CPTs::getRegisterCustomTaxonomyTerms(); |
|
297 | - $register_custom_taxonomy_terms->registerCustomTaxonomyTerm( |
|
298 | - $taxonomy, |
|
299 | - $term_slug, |
|
300 | - $cpt_slugs |
|
301 | - ); |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * @deprecated 4.9.62.p |
|
307 | - * @param int $post_id ID of CPT being saved |
|
308 | - * @param WP_Post $post Post object |
|
309 | - * @return void |
|
310 | - * @throws InvalidArgumentException |
|
311 | - * @throws InvalidDataTypeException |
|
312 | - * @throws InvalidInterfaceException |
|
313 | - */ |
|
314 | - public function save_default_term($post_id, $post) |
|
315 | - { |
|
316 | - $register_custom_taxonomy_terms = EE_Register_CPTs::getRegisterCustomTaxonomyTerms(); |
|
317 | - $register_custom_taxonomy_terms->saveDefaultTerm($post_id, $post); |
|
318 | - } |
|
22 | + /** |
|
23 | + * instantiated at init priority 5 |
|
24 | + * |
|
25 | + * @deprecated 4.9.62.p |
|
26 | + */ |
|
27 | + public function __construct() |
|
28 | + { |
|
29 | + do_action('AHEE__EE_Register_CPTs__construct_end', $this); |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
35 | + * |
|
36 | + * @deprecated 4.9.62.p |
|
37 | + * @return void |
|
38 | + * @throws InvalidInterfaceException |
|
39 | + * @throws InvalidDataTypeException |
|
40 | + * @throws InvalidArgumentException |
|
41 | + */ |
|
42 | + public static function maybe_flush_rewrite_rules() |
|
43 | + { |
|
44 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
45 | + $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
46 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
47 | + ); |
|
48 | + $rewrite_rules->flushRewriteRules(); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * @return CustomTaxonomyDefinitions |
|
54 | + * @throws InvalidArgumentException |
|
55 | + * @throws InvalidDataTypeException |
|
56 | + * @throws InvalidInterfaceException |
|
57 | + */ |
|
58 | + public static function getTaxonomyDefinitions() |
|
59 | + { |
|
60 | + return LoaderFactory::getLoader()->getShared( |
|
61 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' |
|
62 | + ); |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @deprecated 4.9.62.p |
|
68 | + * @param string $description The description content. |
|
69 | + * @param string $taxonomy The taxonomy name for the taxonomy being filtered. |
|
70 | + * @return string |
|
71 | + * @throws InvalidArgumentException |
|
72 | + * @throws InvalidDataTypeException |
|
73 | + * @throws InvalidInterfaceException |
|
74 | + */ |
|
75 | + public function ee_filter_ee_term_description_not_wp($description, $taxonomy) |
|
76 | + { |
|
77 | + $taxonomies = EE_Register_CPTs::getTaxonomyDefinitions(); |
|
78 | + return $taxonomies->filterCustomTermDescription($description, $taxonomy); |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @deprecated 4.9.62.p |
|
84 | + * @return array |
|
85 | + * @throws InvalidArgumentException |
|
86 | + * @throws InvalidDataTypeException |
|
87 | + * @throws InvalidInterfaceException |
|
88 | + */ |
|
89 | + public static function get_taxonomies() |
|
90 | + { |
|
91 | + $taxonomies = EE_Register_CPTs::getTaxonomyDefinitions(); |
|
92 | + return $taxonomies->getCustomTaxonomyDefinitions(); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @return CustomPostTypeDefinitions |
|
98 | + * @throws InvalidArgumentException |
|
99 | + * @throws InvalidDataTypeException |
|
100 | + * @throws InvalidInterfaceException |
|
101 | + */ |
|
102 | + public static function getCustomPostTypeDefinitions() |
|
103 | + { |
|
104 | + return LoaderFactory::getLoader()->getShared( |
|
105 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
106 | + ); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @deprecated 4.9.62.p |
|
112 | + * @return array |
|
113 | + * @throws InvalidArgumentException |
|
114 | + * @throws InvalidDataTypeException |
|
115 | + * @throws InvalidInterfaceException |
|
116 | + */ |
|
117 | + public static function get_CPTs() |
|
118 | + { |
|
119 | + $custom_post_types = EE_Register_CPTs::getCustomPostTypeDefinitions(); |
|
120 | + return $custom_post_types->getDefinitions(); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @deprecated 4.9.62.p |
|
126 | + * @return array |
|
127 | + * @throws InvalidArgumentException |
|
128 | + * @throws InvalidDataTypeException |
|
129 | + * @throws InvalidInterfaceException |
|
130 | + */ |
|
131 | + public static function get_private_CPTs() |
|
132 | + { |
|
133 | + $custom_post_types = EE_Register_CPTs::getCustomPostTypeDefinitions(); |
|
134 | + return $custom_post_types->getPrivateCustomPostTypes(); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * @deprecated 4.9.62.p |
|
140 | + * @param string $post_type_slug If a slug is included, then attempt to retrieve the model name for |
|
141 | + * the given cpt slug. Otherwise if empty, then we'll return all cpt |
|
142 | + * model names for cpts registered in EE. |
|
143 | + * @return array Empty array if no matching model names for the given slug or an array of model |
|
144 | + * names indexed by post type slug. |
|
145 | + * @throws InvalidArgumentException |
|
146 | + * @throws InvalidDataTypeException |
|
147 | + * @throws InvalidInterfaceException |
|
148 | + */ |
|
149 | + public static function get_cpt_model_names($post_type_slug = '') |
|
150 | + { |
|
151 | + $custom_post_types = EE_Register_CPTs::getCustomPostTypeDefinitions(); |
|
152 | + return $custom_post_types->getCustomPostTypeModelNames($post_type_slug); |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * @deprecated 4.9.62.p |
|
158 | + * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
159 | + * the cpt matching the given slug. Otherwise all cpt models will be |
|
160 | + * instantiated (if possible). |
|
161 | + * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
162 | + * EEM models indexed by post slug. |
|
163 | + * @throws InvalidArgumentException |
|
164 | + * @throws InvalidDataTypeException |
|
165 | + * @throws InvalidInterfaceException |
|
166 | + */ |
|
167 | + public static function instantiate_cpt_models($post_type_slug = '') |
|
168 | + { |
|
169 | + $custom_post_types = EE_Register_CPTs::getCustomPostTypeDefinitions(); |
|
170 | + return $custom_post_types->getCustomPostTypeModels($post_type_slug); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * @deprecated 4.9.62.p |
|
176 | + * @param string $taxonomy_name , eg 'books' |
|
177 | + * @param string $singular_name internationalized singular name |
|
178 | + * @param string $plural_name internationalized plural name |
|
179 | + * @param array $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy |
|
180 | + * @throws InvalidArgumentException |
|
181 | + * @throws InvalidDataTypeException |
|
182 | + * @throws InvalidInterfaceException |
|
183 | + * @throws DomainException |
|
184 | + */ |
|
185 | + public function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array()) |
|
186 | + { |
|
187 | + /** @var \EventEspresso\core\domain\services\custom_post_types\registerCustomTaxonomies $taxonomies */ |
|
188 | + $taxonomies = LoaderFactory::getLoader()->getShared( |
|
189 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' |
|
190 | + ); |
|
191 | + $taxonomies->registerCustomTaxonomy( |
|
192 | + $taxonomy_name, |
|
193 | + $singular_name, |
|
194 | + $plural_name, |
|
195 | + $override_args |
|
196 | + ); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * @deprecated 4.9.62.p |
|
202 | + * @param string $post_type the actual post type name |
|
203 | + * (VERY IMPORTANT: this much match what the slug is for admin pages related to this |
|
204 | + * cpt Also any models must use this slug as well) |
|
205 | + * @param string $singular_name a pre-internationalized string for the singular name of the objects |
|
206 | + * @param string $plural_name a pre-internalized string for the plural name of the objects |
|
207 | + * @param array $override_args exactly like $args as described in |
|
208 | + * http://codex.wordpress.org/Function_Reference/register_post_type The default values |
|
209 | + * set in this function will be overridden by whatever you set in $override_args |
|
210 | + * @param string $singular_slug |
|
211 | + * @param string $plural_slug |
|
212 | + * @return void , but registers the custom post type |
|
213 | + * @throws InvalidArgumentException |
|
214 | + * @throws InvalidDataTypeException |
|
215 | + * @throws InvalidInterfaceException |
|
216 | + * @throws DomainException |
|
217 | + */ |
|
218 | + public function register_CPT( |
|
219 | + $post_type, |
|
220 | + $singular_name, |
|
221 | + $plural_name, |
|
222 | + $override_args = array(), |
|
223 | + $singular_slug = '', |
|
224 | + $plural_slug = '' |
|
225 | + ) { |
|
226 | + /** @var \EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */ |
|
227 | + $register_custom_post_types = LoaderFactory::getLoader()->getShared( |
|
228 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' |
|
229 | + ); |
|
230 | + $register_custom_post_types->registerCustomPostType( |
|
231 | + $post_type, |
|
232 | + $singular_name, |
|
233 | + $plural_name, |
|
234 | + $singular_slug, |
|
235 | + $plural_slug, |
|
236 | + $override_args |
|
237 | + ); |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * @return RegisterCustomTaxonomyTerms |
|
243 | + * @throws InvalidArgumentException |
|
244 | + * @throws InvalidDataTypeException |
|
245 | + * @throws InvalidInterfaceException |
|
246 | + */ |
|
247 | + public static function getRegisterCustomTaxonomyTerms() |
|
248 | + { |
|
249 | + return LoaderFactory::getLoader()->getShared( |
|
250 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms' |
|
251 | + ); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * @deprecated 4.9.62.p |
|
257 | + * @throws InvalidArgumentException |
|
258 | + * @throws InvalidDataTypeException |
|
259 | + * @throws InvalidInterfaceException |
|
260 | + */ |
|
261 | + public function set_must_use_event_types() |
|
262 | + { |
|
263 | + $register_custom_taxonomy_terms = EE_Register_CPTs::getRegisterCustomTaxonomyTerms(); |
|
264 | + $register_custom_taxonomy_terms->setMustUseEventTypes(); |
|
265 | + } |
|
266 | + |
|
267 | + |
|
268 | + /** |
|
269 | + * @deprecated 4.9.62.p |
|
270 | + * @param string $taxonomy The name of the taxonomy |
|
271 | + * @param array $term_details An array of term details indexed by slug and containing Name of term, and |
|
272 | + * description as the elements in the array |
|
273 | + * @return void |
|
274 | + * @throws InvalidArgumentException |
|
275 | + * @throws InvalidDataTypeException |
|
276 | + * @throws InvalidInterfaceException |
|
277 | + */ |
|
278 | + public function set_must_use_terms($taxonomy, $term_details) |
|
279 | + { |
|
280 | + $register_custom_taxonomy_terms = EE_Register_CPTs::getRegisterCustomTaxonomyTerms(); |
|
281 | + $register_custom_taxonomy_terms->setMustUseTerms($taxonomy, $term_details); |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + /** |
|
286 | + * @deprecated 4.9.62.p |
|
287 | + * @param string $taxonomy The taxonomy we're using for the default term |
|
288 | + * @param string $term_slug The slug of the term that will be the default. |
|
289 | + * @param array $cpt_slugs An array of custom post types we want the default assigned to |
|
290 | + * @throws InvalidArgumentException |
|
291 | + * @throws InvalidDataTypeException |
|
292 | + * @throws InvalidInterfaceException |
|
293 | + */ |
|
294 | + public function set_default_term($taxonomy, $term_slug, $cpt_slugs = array()) |
|
295 | + { |
|
296 | + $register_custom_taxonomy_terms = EE_Register_CPTs::getRegisterCustomTaxonomyTerms(); |
|
297 | + $register_custom_taxonomy_terms->registerCustomTaxonomyTerm( |
|
298 | + $taxonomy, |
|
299 | + $term_slug, |
|
300 | + $cpt_slugs |
|
301 | + ); |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * @deprecated 4.9.62.p |
|
307 | + * @param int $post_id ID of CPT being saved |
|
308 | + * @param WP_Post $post Post object |
|
309 | + * @return void |
|
310 | + * @throws InvalidArgumentException |
|
311 | + * @throws InvalidDataTypeException |
|
312 | + * @throws InvalidInterfaceException |
|
313 | + */ |
|
314 | + public function save_default_term($post_id, $post) |
|
315 | + { |
|
316 | + $register_custom_taxonomy_terms = EE_Register_CPTs::getRegisterCustomTaxonomyTerms(); |
|
317 | + $register_custom_taxonomy_terms->saveDefaultTerm($post_id, $post); |
|
318 | + } |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -327,24 +327,24 @@ discard block |
||
327 | 327 | class EE_Default_Term |
328 | 328 | { |
329 | 329 | |
330 | - // props holding the items |
|
331 | - public $taxonomy = ''; |
|
330 | + // props holding the items |
|
331 | + public $taxonomy = ''; |
|
332 | 332 | |
333 | - public $cpt_slugs = array(); |
|
333 | + public $cpt_slugs = array(); |
|
334 | 334 | |
335 | - public $term_slug = ''; |
|
335 | + public $term_slug = ''; |
|
336 | 336 | |
337 | 337 | |
338 | - /** |
|
339 | - * @deprecated 4.9.62.p |
|
340 | - * @param string $taxonomy The taxonomy the default term belongs to |
|
341 | - * @param string $term_slug The slug of the term that will be the default. |
|
342 | - * @param array $cpt_slugs The custom post type the default term gets saved with |
|
343 | - */ |
|
344 | - public function __construct($taxonomy, $term_slug, $cpt_slugs = array()) |
|
345 | - { |
|
346 | - $this->taxonomy = $taxonomy; |
|
347 | - $this->cpt_slugs = (array) $cpt_slugs; |
|
348 | - $this->term_slug = $term_slug; |
|
349 | - } |
|
338 | + /** |
|
339 | + * @deprecated 4.9.62.p |
|
340 | + * @param string $taxonomy The taxonomy the default term belongs to |
|
341 | + * @param string $term_slug The slug of the term that will be the default. |
|
342 | + * @param array $cpt_slugs The custom post type the default term gets saved with |
|
343 | + */ |
|
344 | + public function __construct($taxonomy, $term_slug, $cpt_slugs = array()) |
|
345 | + { |
|
346 | + $this->taxonomy = $taxonomy; |
|
347 | + $this->cpt_slugs = (array) $cpt_slugs; |
|
348 | + $this->term_slug = $term_slug; |
|
349 | + } |
|
350 | 350 | } |
@@ -32,18 +32,18 @@ discard block |
||
32 | 32 | $this->request = $request; |
33 | 33 | $this->response = $response; |
34 | 34 | // check required WP version |
35 | - if (! $this->minimumWordPressVersionRequired()) { |
|
35 | + if ( ! $this->minimumWordPressVersionRequired()) { |
|
36 | 36 | $this->request->unSetRequestParam('activate', true); |
37 | 37 | add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
38 | 38 | $this->response->terminateRequest(); |
39 | 39 | $this->response->deactivatePlugin(); |
40 | 40 | } |
41 | 41 | // check recommended PHP version |
42 | - if (! $this->minimumPhpVersionRecommended()) { |
|
42 | + if ( ! $this->minimumPhpVersionRecommended()) { |
|
43 | 43 | $this->displayMinimumRecommendedPhpVersionNotice(); |
44 | 44 | } |
45 | 45 | // upcoming required version |
46 | - if (! $this->upcomingRequiredPhpVersion()) { |
|
46 | + if ( ! $this->upcomingRequiredPhpVersion()) { |
|
47 | 47 | $this->displayUpcomingRequiredVersion(); |
48 | 48 | } |
49 | 49 | $this->response = $this->processRequestStack($this->request, $this->response); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | if ($this->request->isAdmin()) { |
144 | 144 | new PersistentAdminNotice( |
145 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
145 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
146 | 146 | sprintf( |
147 | 147 | esc_html__( |
148 | 148 | 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
181 | 181 | && current_user_can('update_plugins') |
182 | 182 | ) { |
183 | - add_action('admin_notices', function () { |
|
183 | + add_action('admin_notices', function() { |
|
184 | 184 | echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
185 | 185 | . sprintf( |
186 | 186 | esc_html__( |
@@ -19,183 +19,183 @@ |
||
19 | 19 | class RecommendedVersions extends Middleware |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * converts a Request to a Response |
|
24 | - * |
|
25 | - * @param RequestInterface $request |
|
26 | - * @param ResponseInterface $response |
|
27 | - * @return ResponseInterface |
|
28 | - * @throws InvalidDataTypeException |
|
29 | - */ |
|
30 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
31 | - { |
|
32 | - $this->request = $request; |
|
33 | - $this->response = $response; |
|
34 | - // check required WP version |
|
35 | - if (! $this->minimumWordPressVersionRequired()) { |
|
36 | - $this->request->unSetRequestParam('activate', true); |
|
37 | - add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
|
38 | - $this->response->terminateRequest(); |
|
39 | - $this->response->deactivatePlugin(); |
|
40 | - } |
|
41 | - // check recommended PHP version |
|
42 | - if (! $this->minimumPhpVersionRecommended()) { |
|
43 | - $this->displayMinimumRecommendedPhpVersionNotice(); |
|
44 | - } |
|
45 | - // upcoming required version |
|
46 | - if (! $this->upcomingRequiredPhpVersion()) { |
|
47 | - $this->displayUpcomingRequiredVersion(); |
|
48 | - } |
|
49 | - $this->response = $this->processRequestStack($this->request, $this->response); |
|
50 | - return $this->response; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Helper method to assess installed wp version against given values. |
|
56 | - * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
57 | - * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
58 | - * against) so consider that when sending in your values. |
|
59 | - * |
|
60 | - * @param string $version_to_check |
|
61 | - * @param string $operator |
|
62 | - * @return bool |
|
63 | - */ |
|
64 | - public static function compareWordPressVersion($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
65 | - { |
|
66 | - global $wp_version; |
|
67 | - return version_compare( |
|
68 | - // first account for wp_version being pre-release |
|
69 | - // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
70 | - strpos($wp_version, '-') > 0 |
|
71 | - ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
72 | - : $wp_version, |
|
73 | - $version_to_check, |
|
74 | - $operator |
|
75 | - ); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @return boolean |
|
81 | - */ |
|
82 | - private function minimumWordPressVersionRequired() |
|
83 | - { |
|
84 | - return RecommendedVersions::compareWordPressVersion(); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @param string $min_version |
|
90 | - * @return boolean |
|
91 | - */ |
|
92 | - private function checkPhpVersion($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
93 | - { |
|
94 | - return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @return boolean |
|
100 | - */ |
|
101 | - private function minimumPhpVersionRecommended() |
|
102 | - { |
|
103 | - return $this->checkPhpVersion(); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @return void |
|
109 | - */ |
|
110 | - public function minimumWpVersionError() |
|
111 | - { |
|
112 | - global $wp_version; |
|
113 | - ?> |
|
22 | + /** |
|
23 | + * converts a Request to a Response |
|
24 | + * |
|
25 | + * @param RequestInterface $request |
|
26 | + * @param ResponseInterface $response |
|
27 | + * @return ResponseInterface |
|
28 | + * @throws InvalidDataTypeException |
|
29 | + */ |
|
30 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
31 | + { |
|
32 | + $this->request = $request; |
|
33 | + $this->response = $response; |
|
34 | + // check required WP version |
|
35 | + if (! $this->minimumWordPressVersionRequired()) { |
|
36 | + $this->request->unSetRequestParam('activate', true); |
|
37 | + add_action('admin_notices', array($this, 'minimumWpVersionError'), 1); |
|
38 | + $this->response->terminateRequest(); |
|
39 | + $this->response->deactivatePlugin(); |
|
40 | + } |
|
41 | + // check recommended PHP version |
|
42 | + if (! $this->minimumPhpVersionRecommended()) { |
|
43 | + $this->displayMinimumRecommendedPhpVersionNotice(); |
|
44 | + } |
|
45 | + // upcoming required version |
|
46 | + if (! $this->upcomingRequiredPhpVersion()) { |
|
47 | + $this->displayUpcomingRequiredVersion(); |
|
48 | + } |
|
49 | + $this->response = $this->processRequestStack($this->request, $this->response); |
|
50 | + return $this->response; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Helper method to assess installed wp version against given values. |
|
56 | + * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
57 | + * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
58 | + * against) so consider that when sending in your values. |
|
59 | + * |
|
60 | + * @param string $version_to_check |
|
61 | + * @param string $operator |
|
62 | + * @return bool |
|
63 | + */ |
|
64 | + public static function compareWordPressVersion($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
65 | + { |
|
66 | + global $wp_version; |
|
67 | + return version_compare( |
|
68 | + // first account for wp_version being pre-release |
|
69 | + // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
70 | + strpos($wp_version, '-') > 0 |
|
71 | + ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
72 | + : $wp_version, |
|
73 | + $version_to_check, |
|
74 | + $operator |
|
75 | + ); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @return boolean |
|
81 | + */ |
|
82 | + private function minimumWordPressVersionRequired() |
|
83 | + { |
|
84 | + return RecommendedVersions::compareWordPressVersion(); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @param string $min_version |
|
90 | + * @return boolean |
|
91 | + */ |
|
92 | + private function checkPhpVersion($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
93 | + { |
|
94 | + return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @return boolean |
|
100 | + */ |
|
101 | + private function minimumPhpVersionRecommended() |
|
102 | + { |
|
103 | + return $this->checkPhpVersion(); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @return void |
|
109 | + */ |
|
110 | + public function minimumWpVersionError() |
|
111 | + { |
|
112 | + global $wp_version; |
|
113 | + ?> |
|
114 | 114 | <div class="error"> |
115 | 115 | <p> |
116 | 116 | <?php |
117 | - printf( |
|
118 | - __( |
|
119 | - 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
120 | - 'event_espresso' |
|
121 | - ), |
|
122 | - EE_MIN_WP_VER_REQUIRED, |
|
123 | - $wp_version, |
|
124 | - '<br/>', |
|
125 | - '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
126 | - ); |
|
127 | - ?> |
|
117 | + printf( |
|
118 | + __( |
|
119 | + 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
120 | + 'event_espresso' |
|
121 | + ), |
|
122 | + EE_MIN_WP_VER_REQUIRED, |
|
123 | + $wp_version, |
|
124 | + '<br/>', |
|
125 | + '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
126 | + ); |
|
127 | + ?> |
|
128 | 128 | </p> |
129 | 129 | </div> |
130 | 130 | <?php |
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * _display_minimum_recommended_php_version_notice |
|
136 | - * |
|
137 | - * @access private |
|
138 | - * @return void |
|
139 | - * @throws InvalidDataTypeException |
|
140 | - */ |
|
141 | - private function displayMinimumRecommendedPhpVersionNotice() |
|
142 | - { |
|
143 | - if ($this->request->isAdmin()) { |
|
144 | - new PersistentAdminNotice( |
|
145 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
146 | - sprintf( |
|
147 | - esc_html__( |
|
148 | - 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
149 | - 'event_espresso' |
|
150 | - ), |
|
151 | - EE_MIN_PHP_VER_RECOMMENDED, |
|
152 | - PHP_VERSION, |
|
153 | - '<br/>', |
|
154 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
155 | - ) |
|
156 | - ); |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Returns whether the provided php version number is less than the current version of php installed on the server. |
|
163 | - * |
|
164 | - * @param string $version_required |
|
165 | - * @return bool |
|
166 | - */ |
|
167 | - private function upcomingRequiredPhpVersion($version_required = '5.5') |
|
168 | - { |
|
169 | - return true; |
|
170 | - // return $this->checkPhpVersion($version_required); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
176 | - */ |
|
177 | - private function displayUpcomingRequiredVersion() |
|
178 | - { |
|
179 | - if ( |
|
180 | - $this->request->isAdmin() |
|
181 | - && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
|
182 | - && current_user_can('update_plugins') |
|
183 | - ) { |
|
184 | - add_action('admin_notices', function () { |
|
185 | - echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
186 | - . sprintf( |
|
187 | - esc_html__( |
|
188 | - 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
189 | - 'event_espresso' |
|
190 | - ), |
|
191 | - '<strong>', |
|
192 | - '</strong>', |
|
193 | - PHP_VERSION, |
|
194 | - '<a href="https://wordpress.org/support/upgrade-php/">', |
|
195 | - '</a>' |
|
196 | - ) |
|
197 | - . '</p></div>'; |
|
198 | - }); |
|
199 | - } |
|
200 | - } |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * _display_minimum_recommended_php_version_notice |
|
136 | + * |
|
137 | + * @access private |
|
138 | + * @return void |
|
139 | + * @throws InvalidDataTypeException |
|
140 | + */ |
|
141 | + private function displayMinimumRecommendedPhpVersionNotice() |
|
142 | + { |
|
143 | + if ($this->request->isAdmin()) { |
|
144 | + new PersistentAdminNotice( |
|
145 | + 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
146 | + sprintf( |
|
147 | + esc_html__( |
|
148 | + 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
149 | + 'event_espresso' |
|
150 | + ), |
|
151 | + EE_MIN_PHP_VER_RECOMMENDED, |
|
152 | + PHP_VERSION, |
|
153 | + '<br/>', |
|
154 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
155 | + ) |
|
156 | + ); |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Returns whether the provided php version number is less than the current version of php installed on the server. |
|
163 | + * |
|
164 | + * @param string $version_required |
|
165 | + * @return bool |
|
166 | + */ |
|
167 | + private function upcomingRequiredPhpVersion($version_required = '5.5') |
|
168 | + { |
|
169 | + return true; |
|
170 | + // return $this->checkPhpVersion($version_required); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
176 | + */ |
|
177 | + private function displayUpcomingRequiredVersion() |
|
178 | + { |
|
179 | + if ( |
|
180 | + $this->request->isAdmin() |
|
181 | + && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->request) |
|
182 | + && current_user_can('update_plugins') |
|
183 | + ) { |
|
184 | + add_action('admin_notices', function () { |
|
185 | + echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
186 | + . sprintf( |
|
187 | + esc_html__( |
|
188 | + 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
189 | + 'event_espresso' |
|
190 | + ), |
|
191 | + '<strong>', |
|
192 | + '</strong>', |
|
193 | + PHP_VERSION, |
|
194 | + '<a href="https://wordpress.org/support/upgrade-php/">', |
|
195 | + '</a>' |
|
196 | + ) |
|
197 | + . '</p></div>'; |
|
198 | + }); |
|
199 | + } |
|
200 | + } |
|
201 | 201 | } |
@@ -3,4 +3,4 @@ |
||
3 | 3 | * @var EE_Checkbox_Multi_Input $input |
4 | 4 | */ |
5 | 5 | ?> |
6 | -<div class="ee-privacy-consent-assertion"><?php echo $input->get_html_for_input();?></div> |
|
6 | +<div class="ee-privacy-consent-assertion"><?php echo $input->get_html_for_input(); ?></div> |
@@ -14,62 +14,62 @@ |
||
14 | 14 | class EE_Full_HTML_Validation_Strategy extends EE_Validation_Strategy_Base |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @param null $validation_error_message |
|
19 | - */ |
|
20 | - public function __construct($validation_error_message = null) |
|
21 | - { |
|
22 | - if (! $validation_error_message) { |
|
23 | - $validation_error_message = sprintf( |
|
24 | - __('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"), |
|
25 | - '<br />', |
|
26 | - $this->get_list_of_allowed_tags() |
|
27 | - ); |
|
28 | - } |
|
29 | - parent::__construct($validation_error_message); |
|
30 | - } |
|
17 | + /** |
|
18 | + * @param null $validation_error_message |
|
19 | + */ |
|
20 | + public function __construct($validation_error_message = null) |
|
21 | + { |
|
22 | + if (! $validation_error_message) { |
|
23 | + $validation_error_message = sprintf( |
|
24 | + __('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"), |
|
25 | + '<br />', |
|
26 | + $this->get_list_of_allowed_tags() |
|
27 | + ); |
|
28 | + } |
|
29 | + parent::__construct($validation_error_message); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * get_list_of_allowed_tags |
|
35 | - * |
|
36 | - * generates and returns a string that lists the top-level HTML tags that are allowable for this input |
|
37 | - * |
|
38 | - * @return string |
|
39 | - */ |
|
40 | - public function get_list_of_allowed_tags() |
|
41 | - { |
|
42 | - $tags_we_allow = $this->getAllowedTags(); |
|
43 | - ksort($tags_we_allow); |
|
44 | - return implode(', ', array_keys($tags_we_allow)); |
|
45 | - } |
|
33 | + /** |
|
34 | + * get_list_of_allowed_tags |
|
35 | + * |
|
36 | + * generates and returns a string that lists the top-level HTML tags that are allowable for this input |
|
37 | + * |
|
38 | + * @return string |
|
39 | + */ |
|
40 | + public function get_list_of_allowed_tags() |
|
41 | + { |
|
42 | + $tags_we_allow = $this->getAllowedTags(); |
|
43 | + ksort($tags_we_allow); |
|
44 | + return implode(', ', array_keys($tags_we_allow)); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Returns an array whose keys are allowed tags and values are an array of allowed attributes |
|
50 | - * |
|
51 | - * @return array |
|
52 | - */ |
|
53 | - protected function getAllowedTags() |
|
54 | - { |
|
55 | - global $allowedposttags; |
|
56 | - return array_merge_recursive( |
|
57 | - $allowedposttags, |
|
58 | - EEH_HTML::get_simple_tags() |
|
59 | - ); |
|
60 | - } |
|
48 | + /** |
|
49 | + * Returns an array whose keys are allowed tags and values are an array of allowed attributes |
|
50 | + * |
|
51 | + * @return array |
|
52 | + */ |
|
53 | + protected function getAllowedTags() |
|
54 | + { |
|
55 | + global $allowedposttags; |
|
56 | + return array_merge_recursive( |
|
57 | + $allowedposttags, |
|
58 | + EEH_HTML::get_simple_tags() |
|
59 | + ); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @param $normalized_value |
|
65 | - * @throws \EE_Validation_Error |
|
66 | - */ |
|
67 | - public function validate($normalized_value) |
|
68 | - { |
|
69 | - parent::validate($normalized_value); |
|
70 | - $normalized_value_sans_tags = wp_kses("$normalized_value", $this->getAllowedTags()); |
|
71 | - if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) { |
|
72 | - throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
73 | - } |
|
74 | - } |
|
63 | + /** |
|
64 | + * @param $normalized_value |
|
65 | + * @throws \EE_Validation_Error |
|
66 | + */ |
|
67 | + public function validate($normalized_value) |
|
68 | + { |
|
69 | + parent::validate($normalized_value); |
|
70 | + $normalized_value_sans_tags = wp_kses("$normalized_value", $this->getAllowedTags()); |
|
71 | + if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) { |
|
72 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | */ |
20 | 20 | public function __construct($validation_error_message = null) |
21 | 21 | { |
22 | - if (! $validation_error_message) { |
|
22 | + if ( ! $validation_error_message) { |
|
23 | 23 | $validation_error_message = sprintf( |
24 | 24 | __('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"), |
25 | 25 | '<br />', |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function instance() |
40 | 40 | { |
41 | - if (! self::$_instance instanceof EE_Cron_Tasks) { |
|
41 | + if ( ! self::$_instance instanceof EE_Cron_Tasks) { |
|
42 | 42 | self::$_instance = new self(); |
43 | 43 | } |
44 | 44 | return self::$_instance; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | add_action( |
73 | 73 | 'AHEE__EE_System__load_core_configuration__complete', |
74 | - function () { |
|
74 | + function() { |
|
75 | 75 | EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true; |
76 | 76 | EE_Registry::instance()->NET_CFG->update_config(true, false); |
77 | 77 | add_option('ee_disabled_wp_cron_check', 1, '', false); |
@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
124 | 124 | ); |
125 | 125 | $crons = (array) get_option('cron'); |
126 | - if (! is_array($crons)) { |
|
126 | + if ( ! is_array($crons)) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | foreach ($crons as $timestamp => $cron) { |
130 | 130 | /** @var array[] $cron */ |
131 | 131 | foreach ($ee_crons as $ee_cron) { |
132 | - if (isset($cron[ $ee_cron ]) && is_array($cron[ $ee_cron ])) { |
|
132 | + if (isset($cron[$ee_cron]) && is_array($cron[$ee_cron])) { |
|
133 | 133 | do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
134 | - foreach ($cron[ $ee_cron ] as $ee_cron_details) { |
|
135 | - if (! empty($ee_cron_details['args'])) { |
|
134 | + foreach ($cron[$ee_cron] as $ee_cron_details) { |
|
135 | + if ( ! empty($ee_cron_details['args'])) { |
|
136 | 136 | do_action( |
137 | 137 | 'AHEE_log', |
138 | 138 | __CLASS__, |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public static function reschedule_cron_for_transactions_if_maintenance_mode($cron_task, array $TXN_IDs) |
161 | 161 | { |
162 | - if (! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
162 | + if ( ! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
163 | 163 | throw new DomainException( |
164 | 164 | sprintf( |
165 | 165 | __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'), |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | ); |
169 | 169 | } |
170 | 170 | // reschedule the cron if we can't hit the db right now |
171 | - if (! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
171 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
172 | 172 | foreach ($TXN_IDs as $TXN_ID => $additional_vars) { |
173 | 173 | // ensure $additional_vars is an array |
174 | 174 | $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars); |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | { |
250 | 250 | do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
251 | 251 | if (absint($TXN_ID)) { |
252 | - self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID; |
|
252 | + self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID; |
|
253 | 253 | add_action( |
254 | 254 | 'shutdown', |
255 | 255 | array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | EE_Registry::instance()->load_model('Transaction'); |
296 | 296 | foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
297 | 297 | // reschedule the cron if we can't hit the db right now |
298 | - if (! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
298 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
299 | 299 | // reset cron job for updating the TXN |
300 | 300 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
301 | 301 | time() + EE_Cron_Tasks::reschedule_timeout, |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | // now try to update the TXN with any payments |
312 | 312 | $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
313 | 313 | } |
314 | - unset(self::$_update_transactions_with_payment[ $TXN_ID ]); |
|
314 | + unset(self::$_update_transactions_with_payment[$TXN_ID]); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | public static function expired_transaction_check($TXN_ID = 0) |
373 | 373 | { |
374 | 374 | if (absint($TXN_ID)) { |
375 | - self::$_expired_transactions[ $TXN_ID ] = $TXN_ID; |
|
375 | + self::$_expired_transactions[$TXN_ID] = $TXN_ID; |
|
376 | 376 | add_action( |
377 | 377 | 'shutdown', |
378 | 378 | array('EE_Cron_Tasks', 'process_expired_transactions'), |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | break; |
487 | 487 | } |
488 | 488 | } |
489 | - unset(self::$_expired_transactions[ $TXN_ID ]); |
|
489 | + unset(self::$_expired_transactions[$TXN_ID]); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $reg_config = LoaderFactory::getLoader()->load('EE_Registration_Config'); |
534 | 534 | $time_diff_for_comparison = apply_filters( |
535 | 535 | 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison', |
536 | - '-' . $reg_config->gateway_log_lifespan |
|
536 | + '-'.$reg_config->gateway_log_lifespan |
|
537 | 537 | ); |
538 | 538 | EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison)); |
539 | 539 | } |
@@ -15,607 +15,607 @@ |
||
15 | 15 | class EE_Cron_Tasks extends EE_Base |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * WordPress doesn't allow duplicate crons within 10 minutes of the original, |
|
20 | - * so we'll set our retry time for just over 10 minutes to avoid that |
|
21 | - */ |
|
22 | - const reschedule_timeout = 605; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * @var EE_Cron_Tasks |
|
27 | - */ |
|
28 | - private static $_instance; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @return EE_Cron_Tasks |
|
33 | - * @throws ReflectionException |
|
34 | - * @throws EE_Error |
|
35 | - * @throws InvalidArgumentException |
|
36 | - * @throws InvalidInterfaceException |
|
37 | - * @throws InvalidDataTypeException |
|
38 | - */ |
|
39 | - public static function instance() |
|
40 | - { |
|
41 | - if (! self::$_instance instanceof EE_Cron_Tasks) { |
|
42 | - self::$_instance = new self(); |
|
43 | - } |
|
44 | - return self::$_instance; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @access private |
|
50 | - * @throws InvalidDataTypeException |
|
51 | - * @throws InvalidInterfaceException |
|
52 | - * @throws InvalidArgumentException |
|
53 | - * @throws EE_Error |
|
54 | - * @throws ReflectionException |
|
55 | - */ |
|
56 | - private function __construct() |
|
57 | - { |
|
58 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
59 | - // verify that WP Cron is enabled |
|
60 | - if ( |
|
61 | - defined('DISABLE_WP_CRON') |
|
62 | - && DISABLE_WP_CRON |
|
63 | - && is_admin() |
|
64 | - && ! get_option('ee_disabled_wp_cron_check') |
|
65 | - ) { |
|
66 | - /** |
|
67 | - * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before |
|
68 | - * config is loaded. |
|
69 | - * This is intentionally using a anonymous function so that its not easily de-registered. Client code |
|
70 | - * wanting to not have this functionality can just register its own action at a priority after this one to |
|
71 | - * reverse any changes. |
|
72 | - */ |
|
73 | - add_action( |
|
74 | - 'AHEE__EE_System__load_core_configuration__complete', |
|
75 | - function () { |
|
76 | - EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true; |
|
77 | - EE_Registry::instance()->NET_CFG->update_config(true, false); |
|
78 | - add_option('ee_disabled_wp_cron_check', 1, '', false); |
|
79 | - } |
|
80 | - ); |
|
81 | - } |
|
82 | - // UPDATE TRANSACTION WITH PAYMENT |
|
83 | - add_action( |
|
84 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
85 | - array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'), |
|
86 | - 10, |
|
87 | - 2 |
|
88 | - ); |
|
89 | - // ABANDONED / EXPIRED TRANSACTION CHECK |
|
90 | - add_action( |
|
91 | - 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
|
92 | - array('EE_Cron_Tasks', 'expired_transaction_check'), |
|
93 | - 10, |
|
94 | - 1 |
|
95 | - ); |
|
96 | - // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
|
97 | - add_action( |
|
98 | - 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
99 | - array('EE_Cron_Tasks', 'clean_out_junk_transactions') |
|
100 | - ); |
|
101 | - // logging |
|
102 | - add_action( |
|
103 | - 'AHEE__EE_System__load_core_configuration__complete', |
|
104 | - array('EE_Cron_Tasks', 'log_scheduled_ee_crons') |
|
105 | - ); |
|
106 | - EE_Registry::instance()->load_lib('Messages_Scheduler'); |
|
107 | - // clean out old gateway logs |
|
108 | - add_action( |
|
109 | - 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs', |
|
110 | - array('EE_Cron_Tasks', 'clean_out_old_gateway_logs') |
|
111 | - ); |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @access protected |
|
117 | - * @return void |
|
118 | - */ |
|
119 | - public static function log_scheduled_ee_crons() |
|
120 | - { |
|
121 | - $ee_crons = array( |
|
122 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment', |
|
123 | - 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
124 | - 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
125 | - ); |
|
126 | - $crons = (array) get_option('cron'); |
|
127 | - if (! is_array($crons)) { |
|
128 | - return; |
|
129 | - } |
|
130 | - foreach ($crons as $timestamp => $cron) { |
|
131 | - /** @var array[] $cron */ |
|
132 | - foreach ($ee_crons as $ee_cron) { |
|
133 | - if (isset($cron[ $ee_cron ]) && is_array($cron[ $ee_cron ])) { |
|
134 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
|
135 | - foreach ($cron[ $ee_cron ] as $ee_cron_details) { |
|
136 | - if (! empty($ee_cron_details['args'])) { |
|
137 | - do_action( |
|
138 | - 'AHEE_log', |
|
139 | - __CLASS__, |
|
140 | - __FUNCTION__, |
|
141 | - print_r($ee_cron_details['args'], true), |
|
142 | - "{$ee_cron} args" |
|
143 | - ); |
|
144 | - } |
|
145 | - } |
|
146 | - } |
|
147 | - } |
|
148 | - } |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * reschedule_cron_for_transactions_if_maintenance_mode |
|
154 | - * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes |
|
155 | - * |
|
156 | - * @param string $cron_task |
|
157 | - * @param array $TXN_IDs |
|
158 | - * @return bool |
|
159 | - * @throws DomainException |
|
160 | - */ |
|
161 | - public static function reschedule_cron_for_transactions_if_maintenance_mode($cron_task, array $TXN_IDs) |
|
162 | - { |
|
163 | - if (! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
164 | - throw new DomainException( |
|
165 | - sprintf( |
|
166 | - __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'), |
|
167 | - $cron_task |
|
168 | - ) |
|
169 | - ); |
|
170 | - } |
|
171 | - // reschedule the cron if we can't hit the db right now |
|
172 | - if (! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
173 | - foreach ($TXN_IDs as $TXN_ID => $additional_vars) { |
|
174 | - // ensure $additional_vars is an array |
|
175 | - $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars); |
|
176 | - // reset cron job for the TXN |
|
177 | - call_user_func_array( |
|
178 | - array('EE_Cron_Tasks', $cron_task), |
|
179 | - array_merge( |
|
180 | - array( |
|
181 | - time() + (10 * MINUTE_IN_SECONDS), |
|
182 | - $TXN_ID, |
|
183 | - ), |
|
184 | - $additional_vars |
|
185 | - ) |
|
186 | - ); |
|
187 | - } |
|
188 | - return true; |
|
189 | - } |
|
190 | - return false; |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - |
|
196 | - /**************** UPDATE TRANSACTION WITH PAYMENT ****************/ |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * array of TXN IDs and the payment |
|
201 | - * |
|
202 | - * @var array |
|
203 | - */ |
|
204 | - protected static $_update_transactions_with_payment = array(); |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * schedule_update_transaction_with_payment |
|
209 | - * sets a wp_schedule_single_event() for updating any TXNs that may |
|
210 | - * require updating due to recently received payments |
|
211 | - * |
|
212 | - * @param int $timestamp |
|
213 | - * @param int $TXN_ID |
|
214 | - * @param int $PAY_ID |
|
215 | - */ |
|
216 | - public static function schedule_update_transaction_with_payment( |
|
217 | - $timestamp, |
|
218 | - $TXN_ID, |
|
219 | - $PAY_ID |
|
220 | - ) { |
|
221 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
222 | - // validate $TXN_ID and $timestamp |
|
223 | - $TXN_ID = absint($TXN_ID); |
|
224 | - $timestamp = absint($timestamp); |
|
225 | - if ($TXN_ID && $timestamp) { |
|
226 | - wp_schedule_single_event( |
|
227 | - $timestamp, |
|
228 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
229 | - array($TXN_ID, $PAY_ID) |
|
230 | - ); |
|
231 | - } |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * setup_update_for_transaction_with_payment |
|
237 | - * this is the callback for the action hook: |
|
238 | - * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' |
|
239 | - * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment(). |
|
240 | - * The passed TXN_ID and associated payment gets added to an array, and then |
|
241 | - * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into |
|
242 | - * 'shutdown' which will actually handle the processing of any |
|
243 | - * transactions requiring updating, because doing so now would be too early |
|
244 | - * and the required resources may not be available |
|
245 | - * |
|
246 | - * @param int $TXN_ID |
|
247 | - * @param int $PAY_ID |
|
248 | - */ |
|
249 | - public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) |
|
250 | - { |
|
251 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
252 | - if (absint($TXN_ID)) { |
|
253 | - self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID; |
|
254 | - add_action( |
|
255 | - 'shutdown', |
|
256 | - array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
|
257 | - 5 |
|
258 | - ); |
|
259 | - } |
|
260 | - } |
|
261 | - |
|
262 | - |
|
263 | - /** |
|
264 | - * update_transaction_with_payment |
|
265 | - * loops through the self::$_abandoned_transactions array |
|
266 | - * and attempts to finalize any TXNs that have not been completed |
|
267 | - * but have had their sessions expired, most likely due to a user not |
|
268 | - * returning from an off-site payment gateway |
|
269 | - * |
|
270 | - * @throws EE_Error |
|
271 | - * @throws DomainException |
|
272 | - * @throws InvalidDataTypeException |
|
273 | - * @throws InvalidInterfaceException |
|
274 | - * @throws InvalidArgumentException |
|
275 | - * @throws ReflectionException |
|
276 | - * @throws RuntimeException |
|
277 | - */ |
|
278 | - public static function update_transaction_with_payment() |
|
279 | - { |
|
280 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
281 | - if ( |
|
18 | + /** |
|
19 | + * WordPress doesn't allow duplicate crons within 10 minutes of the original, |
|
20 | + * so we'll set our retry time for just over 10 minutes to avoid that |
|
21 | + */ |
|
22 | + const reschedule_timeout = 605; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * @var EE_Cron_Tasks |
|
27 | + */ |
|
28 | + private static $_instance; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @return EE_Cron_Tasks |
|
33 | + * @throws ReflectionException |
|
34 | + * @throws EE_Error |
|
35 | + * @throws InvalidArgumentException |
|
36 | + * @throws InvalidInterfaceException |
|
37 | + * @throws InvalidDataTypeException |
|
38 | + */ |
|
39 | + public static function instance() |
|
40 | + { |
|
41 | + if (! self::$_instance instanceof EE_Cron_Tasks) { |
|
42 | + self::$_instance = new self(); |
|
43 | + } |
|
44 | + return self::$_instance; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @access private |
|
50 | + * @throws InvalidDataTypeException |
|
51 | + * @throws InvalidInterfaceException |
|
52 | + * @throws InvalidArgumentException |
|
53 | + * @throws EE_Error |
|
54 | + * @throws ReflectionException |
|
55 | + */ |
|
56 | + private function __construct() |
|
57 | + { |
|
58 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
59 | + // verify that WP Cron is enabled |
|
60 | + if ( |
|
61 | + defined('DISABLE_WP_CRON') |
|
62 | + && DISABLE_WP_CRON |
|
63 | + && is_admin() |
|
64 | + && ! get_option('ee_disabled_wp_cron_check') |
|
65 | + ) { |
|
66 | + /** |
|
67 | + * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before |
|
68 | + * config is loaded. |
|
69 | + * This is intentionally using a anonymous function so that its not easily de-registered. Client code |
|
70 | + * wanting to not have this functionality can just register its own action at a priority after this one to |
|
71 | + * reverse any changes. |
|
72 | + */ |
|
73 | + add_action( |
|
74 | + 'AHEE__EE_System__load_core_configuration__complete', |
|
75 | + function () { |
|
76 | + EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true; |
|
77 | + EE_Registry::instance()->NET_CFG->update_config(true, false); |
|
78 | + add_option('ee_disabled_wp_cron_check', 1, '', false); |
|
79 | + } |
|
80 | + ); |
|
81 | + } |
|
82 | + // UPDATE TRANSACTION WITH PAYMENT |
|
83 | + add_action( |
|
84 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
85 | + array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'), |
|
86 | + 10, |
|
87 | + 2 |
|
88 | + ); |
|
89 | + // ABANDONED / EXPIRED TRANSACTION CHECK |
|
90 | + add_action( |
|
91 | + 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
|
92 | + array('EE_Cron_Tasks', 'expired_transaction_check'), |
|
93 | + 10, |
|
94 | + 1 |
|
95 | + ); |
|
96 | + // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
|
97 | + add_action( |
|
98 | + 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
99 | + array('EE_Cron_Tasks', 'clean_out_junk_transactions') |
|
100 | + ); |
|
101 | + // logging |
|
102 | + add_action( |
|
103 | + 'AHEE__EE_System__load_core_configuration__complete', |
|
104 | + array('EE_Cron_Tasks', 'log_scheduled_ee_crons') |
|
105 | + ); |
|
106 | + EE_Registry::instance()->load_lib('Messages_Scheduler'); |
|
107 | + // clean out old gateway logs |
|
108 | + add_action( |
|
109 | + 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs', |
|
110 | + array('EE_Cron_Tasks', 'clean_out_old_gateway_logs') |
|
111 | + ); |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @access protected |
|
117 | + * @return void |
|
118 | + */ |
|
119 | + public static function log_scheduled_ee_crons() |
|
120 | + { |
|
121 | + $ee_crons = array( |
|
122 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment', |
|
123 | + 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
124 | + 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
125 | + ); |
|
126 | + $crons = (array) get_option('cron'); |
|
127 | + if (! is_array($crons)) { |
|
128 | + return; |
|
129 | + } |
|
130 | + foreach ($crons as $timestamp => $cron) { |
|
131 | + /** @var array[] $cron */ |
|
132 | + foreach ($ee_crons as $ee_cron) { |
|
133 | + if (isset($cron[ $ee_cron ]) && is_array($cron[ $ee_cron ])) { |
|
134 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
|
135 | + foreach ($cron[ $ee_cron ] as $ee_cron_details) { |
|
136 | + if (! empty($ee_cron_details['args'])) { |
|
137 | + do_action( |
|
138 | + 'AHEE_log', |
|
139 | + __CLASS__, |
|
140 | + __FUNCTION__, |
|
141 | + print_r($ee_cron_details['args'], true), |
|
142 | + "{$ee_cron} args" |
|
143 | + ); |
|
144 | + } |
|
145 | + } |
|
146 | + } |
|
147 | + } |
|
148 | + } |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * reschedule_cron_for_transactions_if_maintenance_mode |
|
154 | + * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes |
|
155 | + * |
|
156 | + * @param string $cron_task |
|
157 | + * @param array $TXN_IDs |
|
158 | + * @return bool |
|
159 | + * @throws DomainException |
|
160 | + */ |
|
161 | + public static function reschedule_cron_for_transactions_if_maintenance_mode($cron_task, array $TXN_IDs) |
|
162 | + { |
|
163 | + if (! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
164 | + throw new DomainException( |
|
165 | + sprintf( |
|
166 | + __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'), |
|
167 | + $cron_task |
|
168 | + ) |
|
169 | + ); |
|
170 | + } |
|
171 | + // reschedule the cron if we can't hit the db right now |
|
172 | + if (! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
173 | + foreach ($TXN_IDs as $TXN_ID => $additional_vars) { |
|
174 | + // ensure $additional_vars is an array |
|
175 | + $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars); |
|
176 | + // reset cron job for the TXN |
|
177 | + call_user_func_array( |
|
178 | + array('EE_Cron_Tasks', $cron_task), |
|
179 | + array_merge( |
|
180 | + array( |
|
181 | + time() + (10 * MINUTE_IN_SECONDS), |
|
182 | + $TXN_ID, |
|
183 | + ), |
|
184 | + $additional_vars |
|
185 | + ) |
|
186 | + ); |
|
187 | + } |
|
188 | + return true; |
|
189 | + } |
|
190 | + return false; |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + |
|
196 | + /**************** UPDATE TRANSACTION WITH PAYMENT ****************/ |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * array of TXN IDs and the payment |
|
201 | + * |
|
202 | + * @var array |
|
203 | + */ |
|
204 | + protected static $_update_transactions_with_payment = array(); |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * schedule_update_transaction_with_payment |
|
209 | + * sets a wp_schedule_single_event() for updating any TXNs that may |
|
210 | + * require updating due to recently received payments |
|
211 | + * |
|
212 | + * @param int $timestamp |
|
213 | + * @param int $TXN_ID |
|
214 | + * @param int $PAY_ID |
|
215 | + */ |
|
216 | + public static function schedule_update_transaction_with_payment( |
|
217 | + $timestamp, |
|
218 | + $TXN_ID, |
|
219 | + $PAY_ID |
|
220 | + ) { |
|
221 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
222 | + // validate $TXN_ID and $timestamp |
|
223 | + $TXN_ID = absint($TXN_ID); |
|
224 | + $timestamp = absint($timestamp); |
|
225 | + if ($TXN_ID && $timestamp) { |
|
226 | + wp_schedule_single_event( |
|
227 | + $timestamp, |
|
228 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
229 | + array($TXN_ID, $PAY_ID) |
|
230 | + ); |
|
231 | + } |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * setup_update_for_transaction_with_payment |
|
237 | + * this is the callback for the action hook: |
|
238 | + * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' |
|
239 | + * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment(). |
|
240 | + * The passed TXN_ID and associated payment gets added to an array, and then |
|
241 | + * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into |
|
242 | + * 'shutdown' which will actually handle the processing of any |
|
243 | + * transactions requiring updating, because doing so now would be too early |
|
244 | + * and the required resources may not be available |
|
245 | + * |
|
246 | + * @param int $TXN_ID |
|
247 | + * @param int $PAY_ID |
|
248 | + */ |
|
249 | + public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) |
|
250 | + { |
|
251 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
252 | + if (absint($TXN_ID)) { |
|
253 | + self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID; |
|
254 | + add_action( |
|
255 | + 'shutdown', |
|
256 | + array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
|
257 | + 5 |
|
258 | + ); |
|
259 | + } |
|
260 | + } |
|
261 | + |
|
262 | + |
|
263 | + /** |
|
264 | + * update_transaction_with_payment |
|
265 | + * loops through the self::$_abandoned_transactions array |
|
266 | + * and attempts to finalize any TXNs that have not been completed |
|
267 | + * but have had their sessions expired, most likely due to a user not |
|
268 | + * returning from an off-site payment gateway |
|
269 | + * |
|
270 | + * @throws EE_Error |
|
271 | + * @throws DomainException |
|
272 | + * @throws InvalidDataTypeException |
|
273 | + * @throws InvalidInterfaceException |
|
274 | + * @throws InvalidArgumentException |
|
275 | + * @throws ReflectionException |
|
276 | + * @throws RuntimeException |
|
277 | + */ |
|
278 | + public static function update_transaction_with_payment() |
|
279 | + { |
|
280 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
281 | + if ( |
|
282 | 282 | // are there any TXNs that need cleaning up ? |
283 | - empty(self::$_update_transactions_with_payment) |
|
284 | - // reschedule the cron if we can't hit the db right now |
|
285 | - || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
|
286 | - 'schedule_update_transaction_with_payment', |
|
287 | - self::$_update_transactions_with_payment |
|
288 | - ) |
|
289 | - ) { |
|
290 | - return; |
|
291 | - } |
|
292 | - /** @type EE_Payment_Processor $payment_processor */ |
|
293 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
294 | - // set revisit flag for payment processor |
|
295 | - $payment_processor->set_revisit(); |
|
296 | - // load EEM_Transaction |
|
297 | - EE_Registry::instance()->load_model('Transaction'); |
|
298 | - foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
|
299 | - // reschedule the cron if we can't hit the db right now |
|
300 | - if (! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
301 | - // reset cron job for updating the TXN |
|
302 | - EE_Cron_Tasks::schedule_update_transaction_with_payment( |
|
303 | - time() + EE_Cron_Tasks::reschedule_timeout, |
|
304 | - $TXN_ID, |
|
305 | - $PAY_ID |
|
306 | - ); |
|
307 | - continue; |
|
308 | - } |
|
309 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
310 | - $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
311 | - // verify transaction |
|
312 | - if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) { |
|
313 | - // now try to update the TXN with any payments |
|
314 | - $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
|
315 | - } |
|
316 | - unset(self::$_update_transactions_with_payment[ $TXN_ID ]); |
|
317 | - } |
|
318 | - } |
|
319 | - |
|
320 | - |
|
321 | - |
|
322 | - /************ END OF UPDATE TRANSACTION WITH PAYMENT ************/ |
|
323 | - |
|
324 | - |
|
325 | - /***************** EXPIRED TRANSACTION CHECK *****************/ |
|
326 | - |
|
327 | - |
|
328 | - /** |
|
329 | - * array of TXN IDs |
|
330 | - * |
|
331 | - * @var array |
|
332 | - */ |
|
333 | - protected static $_expired_transactions = array(); |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * schedule_expired_transaction_check |
|
338 | - * sets a wp_schedule_single_event() for following up on TXNs after their session has expired |
|
339 | - * |
|
340 | - * @param int $timestamp |
|
341 | - * @param int $TXN_ID |
|
342 | - */ |
|
343 | - public static function schedule_expired_transaction_check( |
|
344 | - $timestamp, |
|
345 | - $TXN_ID |
|
346 | - ) { |
|
347 | - // validate $TXN_ID and $timestamp |
|
348 | - $TXN_ID = absint($TXN_ID); |
|
349 | - $timestamp = absint($timestamp); |
|
350 | - if ($TXN_ID && $timestamp) { |
|
351 | - wp_schedule_single_event( |
|
352 | - $timestamp, |
|
353 | - 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
|
354 | - array($TXN_ID) |
|
355 | - ); |
|
356 | - } |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * expired_transaction_check |
|
362 | - * this is the callback for the action hook: |
|
363 | - * 'AHEE__EE_Cron_Tasks__transaction_session_expiration_check' |
|
364 | - * which is utilized by wp_schedule_single_event() |
|
365 | - * in \EED_Single_Page_Checkout::_initialize_transaction(). |
|
366 | - * The passed TXN_ID gets added to an array, and then the |
|
367 | - * process_expired_transactions() function is hooked into |
|
368 | - * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the |
|
369 | - * processing of any failed transactions, because doing so now would be |
|
370 | - * too early and the required resources may not be available |
|
371 | - * |
|
372 | - * @param int $TXN_ID |
|
373 | - */ |
|
374 | - public static function expired_transaction_check($TXN_ID = 0) |
|
375 | - { |
|
376 | - if (absint($TXN_ID)) { |
|
377 | - self::$_expired_transactions[ $TXN_ID ] = $TXN_ID; |
|
378 | - add_action( |
|
379 | - 'shutdown', |
|
380 | - array('EE_Cron_Tasks', 'process_expired_transactions'), |
|
381 | - 5 |
|
382 | - ); |
|
383 | - } |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * process_expired_transactions |
|
389 | - * loops through the self::$_expired_transactions array and processes any failed TXNs |
|
390 | - * |
|
391 | - * @throws EE_Error |
|
392 | - * @throws InvalidDataTypeException |
|
393 | - * @throws InvalidInterfaceException |
|
394 | - * @throws InvalidArgumentException |
|
395 | - * @throws ReflectionException |
|
396 | - * @throws DomainException |
|
397 | - * @throws RuntimeException |
|
398 | - */ |
|
399 | - public static function process_expired_transactions() |
|
400 | - { |
|
401 | - if ( |
|
283 | + empty(self::$_update_transactions_with_payment) |
|
284 | + // reschedule the cron if we can't hit the db right now |
|
285 | + || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
|
286 | + 'schedule_update_transaction_with_payment', |
|
287 | + self::$_update_transactions_with_payment |
|
288 | + ) |
|
289 | + ) { |
|
290 | + return; |
|
291 | + } |
|
292 | + /** @type EE_Payment_Processor $payment_processor */ |
|
293 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
294 | + // set revisit flag for payment processor |
|
295 | + $payment_processor->set_revisit(); |
|
296 | + // load EEM_Transaction |
|
297 | + EE_Registry::instance()->load_model('Transaction'); |
|
298 | + foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
|
299 | + // reschedule the cron if we can't hit the db right now |
|
300 | + if (! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
301 | + // reset cron job for updating the TXN |
|
302 | + EE_Cron_Tasks::schedule_update_transaction_with_payment( |
|
303 | + time() + EE_Cron_Tasks::reschedule_timeout, |
|
304 | + $TXN_ID, |
|
305 | + $PAY_ID |
|
306 | + ); |
|
307 | + continue; |
|
308 | + } |
|
309 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
310 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
311 | + // verify transaction |
|
312 | + if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) { |
|
313 | + // now try to update the TXN with any payments |
|
314 | + $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
|
315 | + } |
|
316 | + unset(self::$_update_transactions_with_payment[ $TXN_ID ]); |
|
317 | + } |
|
318 | + } |
|
319 | + |
|
320 | + |
|
321 | + |
|
322 | + /************ END OF UPDATE TRANSACTION WITH PAYMENT ************/ |
|
323 | + |
|
324 | + |
|
325 | + /***************** EXPIRED TRANSACTION CHECK *****************/ |
|
326 | + |
|
327 | + |
|
328 | + /** |
|
329 | + * array of TXN IDs |
|
330 | + * |
|
331 | + * @var array |
|
332 | + */ |
|
333 | + protected static $_expired_transactions = array(); |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * schedule_expired_transaction_check |
|
338 | + * sets a wp_schedule_single_event() for following up on TXNs after their session has expired |
|
339 | + * |
|
340 | + * @param int $timestamp |
|
341 | + * @param int $TXN_ID |
|
342 | + */ |
|
343 | + public static function schedule_expired_transaction_check( |
|
344 | + $timestamp, |
|
345 | + $TXN_ID |
|
346 | + ) { |
|
347 | + // validate $TXN_ID and $timestamp |
|
348 | + $TXN_ID = absint($TXN_ID); |
|
349 | + $timestamp = absint($timestamp); |
|
350 | + if ($TXN_ID && $timestamp) { |
|
351 | + wp_schedule_single_event( |
|
352 | + $timestamp, |
|
353 | + 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
|
354 | + array($TXN_ID) |
|
355 | + ); |
|
356 | + } |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * expired_transaction_check |
|
362 | + * this is the callback for the action hook: |
|
363 | + * 'AHEE__EE_Cron_Tasks__transaction_session_expiration_check' |
|
364 | + * which is utilized by wp_schedule_single_event() |
|
365 | + * in \EED_Single_Page_Checkout::_initialize_transaction(). |
|
366 | + * The passed TXN_ID gets added to an array, and then the |
|
367 | + * process_expired_transactions() function is hooked into |
|
368 | + * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the |
|
369 | + * processing of any failed transactions, because doing so now would be |
|
370 | + * too early and the required resources may not be available |
|
371 | + * |
|
372 | + * @param int $TXN_ID |
|
373 | + */ |
|
374 | + public static function expired_transaction_check($TXN_ID = 0) |
|
375 | + { |
|
376 | + if (absint($TXN_ID)) { |
|
377 | + self::$_expired_transactions[ $TXN_ID ] = $TXN_ID; |
|
378 | + add_action( |
|
379 | + 'shutdown', |
|
380 | + array('EE_Cron_Tasks', 'process_expired_transactions'), |
|
381 | + 5 |
|
382 | + ); |
|
383 | + } |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * process_expired_transactions |
|
389 | + * loops through the self::$_expired_transactions array and processes any failed TXNs |
|
390 | + * |
|
391 | + * @throws EE_Error |
|
392 | + * @throws InvalidDataTypeException |
|
393 | + * @throws InvalidInterfaceException |
|
394 | + * @throws InvalidArgumentException |
|
395 | + * @throws ReflectionException |
|
396 | + * @throws DomainException |
|
397 | + * @throws RuntimeException |
|
398 | + */ |
|
399 | + public static function process_expired_transactions() |
|
400 | + { |
|
401 | + if ( |
|
402 | 402 | // are there any TXNs that need cleaning up ? |
403 | - empty(self::$_expired_transactions) |
|
404 | - // reschedule the cron if we can't hit the db right now |
|
405 | - || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
|
406 | - 'schedule_expired_transaction_check', |
|
407 | - self::$_expired_transactions |
|
408 | - ) |
|
409 | - ) { |
|
410 | - return; |
|
411 | - } |
|
412 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
413 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
414 | - // set revisit flag for txn processor |
|
415 | - $transaction_processor->set_revisit(); |
|
416 | - // load EEM_Transaction |
|
417 | - EE_Registry::instance()->load_model('Transaction'); |
|
418 | - foreach (self::$_expired_transactions as $TXN_ID) { |
|
419 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
420 | - // verify transaction and whether it is failed or not |
|
421 | - if ($transaction instanceof EE_Transaction) { |
|
422 | - switch ($transaction->status_ID()) { |
|
423 | - // Completed TXNs |
|
424 | - case EEM_Transaction::complete_status_code: |
|
425 | - // Don't update the transaction/registrations if the Primary Registration is Not Approved. |
|
426 | - $primary_registration = $transaction->primary_registration(); |
|
427 | - if ( |
|
428 | - $primary_registration instanceof EE_Registration |
|
429 | - && $primary_registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
430 | - ) { |
|
431 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
432 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
433 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
434 | - $transaction, |
|
435 | - $transaction->last_payment() |
|
436 | - ); |
|
437 | - do_action( |
|
438 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', |
|
439 | - $transaction |
|
440 | - ); |
|
441 | - } |
|
442 | - break; |
|
443 | - // Overpaid TXNs |
|
444 | - case EEM_Transaction::overpaid_status_code: |
|
445 | - do_action( |
|
446 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', |
|
447 | - $transaction |
|
448 | - ); |
|
449 | - break; |
|
450 | - // Incomplete TXNs |
|
451 | - case EEM_Transaction::incomplete_status_code: |
|
452 | - do_action( |
|
453 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', |
|
454 | - $transaction |
|
455 | - ); |
|
456 | - // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
|
457 | - break; |
|
458 | - // Abandoned TXNs |
|
459 | - case EEM_Transaction::abandoned_status_code: |
|
460 | - // run hook before updating transaction, primarily so |
|
461 | - // EED_Ticket_Sales_Monitor::process_abandoned_transactions() can release reserved tickets |
|
462 | - do_action( |
|
463 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction', |
|
464 | - $transaction |
|
465 | - ); |
|
466 | - // don't finalize the TXN if it has already been completed |
|
467 | - if ($transaction->all_reg_steps_completed() !== true) { |
|
468 | - /** @type EE_Payment_Processor $payment_processor */ |
|
469 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
470 | - // let's simulate an IPN here which will trigger any notifications that need to go out |
|
471 | - $payment_processor->update_txn_based_on_payment( |
|
472 | - $transaction, |
|
473 | - $transaction->last_payment(), |
|
474 | - true, |
|
475 | - true |
|
476 | - ); |
|
477 | - } |
|
478 | - break; |
|
479 | - // Failed TXNs |
|
480 | - case EEM_Transaction::failed_status_code: |
|
481 | - do_action( |
|
482 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', |
|
483 | - $transaction |
|
484 | - ); |
|
485 | - // todo : |
|
486 | - // perform garbage collection here and remove clean_out_junk_transactions() |
|
487 | - // $registrations = $transaction->registrations(); |
|
488 | - // if (! empty($registrations)) { |
|
489 | - // foreach ($registrations as $registration) { |
|
490 | - // if ($registration instanceof EE_Registration) { |
|
491 | - // $delete_registration = true; |
|
492 | - // if ($registration->attendee() instanceof EE_Attendee) { |
|
493 | - // $delete_registration = false; |
|
494 | - // } |
|
495 | - // if ($delete_registration) { |
|
496 | - // $registration->delete_permanently(); |
|
497 | - // $registration->delete_related_permanently(); |
|
498 | - // } |
|
499 | - // } |
|
500 | - // } |
|
501 | - // } |
|
502 | - break; |
|
503 | - } |
|
504 | - } |
|
505 | - unset(self::$_expired_transactions[ $TXN_ID ]); |
|
506 | - } |
|
507 | - } |
|
508 | - |
|
509 | - |
|
510 | - |
|
511 | - /************* END OF EXPIRED TRANSACTION CHECK *************/ |
|
512 | - |
|
513 | - |
|
514 | - /************* START CLEAN UP BOT TRANSACTIONS **********************/ |
|
515 | - |
|
516 | - |
|
517 | - /** |
|
518 | - * callback for 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions' |
|
519 | - * which is setup during activation to run on an hourly cron |
|
520 | - * |
|
521 | - * @throws EE_Error |
|
522 | - * @throws InvalidArgumentException |
|
523 | - * @throws InvalidDataTypeException |
|
524 | - * @throws InvalidInterfaceException |
|
525 | - * @throws DomainException |
|
526 | - */ |
|
527 | - public static function clean_out_junk_transactions() |
|
528 | - { |
|
529 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
530 | - EED_Ticket_Sales_Monitor::reset_reservation_counts(); |
|
531 | - EEM_Transaction::instance('')->delete_junk_transactions(); |
|
532 | - EEM_Registration::instance('')->delete_registrations_with_no_transaction(); |
|
533 | - EEM_Line_Item::instance('')->delete_line_items_with_no_transaction(); |
|
534 | - } |
|
535 | - } |
|
536 | - |
|
537 | - |
|
538 | - /** |
|
539 | - * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that. |
|
540 | - * |
|
541 | - * @throws EE_Error |
|
542 | - * @throws InvalidDataTypeException |
|
543 | - * @throws InvalidInterfaceException |
|
544 | - * @throws InvalidArgumentException |
|
545 | - */ |
|
546 | - public static function clean_out_old_gateway_logs() |
|
547 | - { |
|
548 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
549 | - $reg_config = LoaderFactory::getLoader()->load('EE_Registration_Config'); |
|
550 | - $time_diff_for_comparison = apply_filters( |
|
551 | - 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison', |
|
552 | - '-' . $reg_config->gateway_log_lifespan |
|
553 | - ); |
|
554 | - EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison)); |
|
555 | - } |
|
556 | - } |
|
557 | - |
|
558 | - |
|
559 | - /***************** FINALIZE ABANDONED TRANSACTIONS *****************/ |
|
560 | - |
|
561 | - |
|
562 | - /** |
|
563 | - * @var array |
|
564 | - */ |
|
565 | - protected static $_abandoned_transactions = array(); |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * @deprecated |
|
570 | - * @param int $timestamp |
|
571 | - * @param int $TXN_ID |
|
572 | - */ |
|
573 | - public static function schedule_finalize_abandoned_transactions_check($timestamp, $TXN_ID) |
|
574 | - { |
|
575 | - EE_Cron_Tasks::schedule_expired_transaction_check($timestamp, $TXN_ID); |
|
576 | - } |
|
577 | - |
|
578 | - |
|
579 | - /** |
|
580 | - * @deprecated |
|
581 | - * @param int $TXN_ID |
|
582 | - */ |
|
583 | - public static function check_for_abandoned_transactions($TXN_ID = 0) |
|
584 | - { |
|
585 | - EE_Cron_Tasks::expired_transaction_check($TXN_ID); |
|
586 | - } |
|
587 | - |
|
588 | - |
|
589 | - /** |
|
590 | - * @deprecated |
|
591 | - * @throws EE_Error |
|
592 | - * @throws DomainException |
|
593 | - * @throws InvalidDataTypeException |
|
594 | - * @throws InvalidInterfaceException |
|
595 | - * @throws InvalidArgumentException |
|
596 | - * @throws ReflectionException |
|
597 | - * @throws RuntimeException |
|
598 | - */ |
|
599 | - public static function finalize_abandoned_transactions() |
|
600 | - { |
|
601 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
602 | - if ( |
|
403 | + empty(self::$_expired_transactions) |
|
404 | + // reschedule the cron if we can't hit the db right now |
|
405 | + || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
|
406 | + 'schedule_expired_transaction_check', |
|
407 | + self::$_expired_transactions |
|
408 | + ) |
|
409 | + ) { |
|
410 | + return; |
|
411 | + } |
|
412 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
413 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
414 | + // set revisit flag for txn processor |
|
415 | + $transaction_processor->set_revisit(); |
|
416 | + // load EEM_Transaction |
|
417 | + EE_Registry::instance()->load_model('Transaction'); |
|
418 | + foreach (self::$_expired_transactions as $TXN_ID) { |
|
419 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
420 | + // verify transaction and whether it is failed or not |
|
421 | + if ($transaction instanceof EE_Transaction) { |
|
422 | + switch ($transaction->status_ID()) { |
|
423 | + // Completed TXNs |
|
424 | + case EEM_Transaction::complete_status_code: |
|
425 | + // Don't update the transaction/registrations if the Primary Registration is Not Approved. |
|
426 | + $primary_registration = $transaction->primary_registration(); |
|
427 | + if ( |
|
428 | + $primary_registration instanceof EE_Registration |
|
429 | + && $primary_registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
430 | + ) { |
|
431 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
432 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
433 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
434 | + $transaction, |
|
435 | + $transaction->last_payment() |
|
436 | + ); |
|
437 | + do_action( |
|
438 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', |
|
439 | + $transaction |
|
440 | + ); |
|
441 | + } |
|
442 | + break; |
|
443 | + // Overpaid TXNs |
|
444 | + case EEM_Transaction::overpaid_status_code: |
|
445 | + do_action( |
|
446 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', |
|
447 | + $transaction |
|
448 | + ); |
|
449 | + break; |
|
450 | + // Incomplete TXNs |
|
451 | + case EEM_Transaction::incomplete_status_code: |
|
452 | + do_action( |
|
453 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', |
|
454 | + $transaction |
|
455 | + ); |
|
456 | + // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
|
457 | + break; |
|
458 | + // Abandoned TXNs |
|
459 | + case EEM_Transaction::abandoned_status_code: |
|
460 | + // run hook before updating transaction, primarily so |
|
461 | + // EED_Ticket_Sales_Monitor::process_abandoned_transactions() can release reserved tickets |
|
462 | + do_action( |
|
463 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction', |
|
464 | + $transaction |
|
465 | + ); |
|
466 | + // don't finalize the TXN if it has already been completed |
|
467 | + if ($transaction->all_reg_steps_completed() !== true) { |
|
468 | + /** @type EE_Payment_Processor $payment_processor */ |
|
469 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
470 | + // let's simulate an IPN here which will trigger any notifications that need to go out |
|
471 | + $payment_processor->update_txn_based_on_payment( |
|
472 | + $transaction, |
|
473 | + $transaction->last_payment(), |
|
474 | + true, |
|
475 | + true |
|
476 | + ); |
|
477 | + } |
|
478 | + break; |
|
479 | + // Failed TXNs |
|
480 | + case EEM_Transaction::failed_status_code: |
|
481 | + do_action( |
|
482 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', |
|
483 | + $transaction |
|
484 | + ); |
|
485 | + // todo : |
|
486 | + // perform garbage collection here and remove clean_out_junk_transactions() |
|
487 | + // $registrations = $transaction->registrations(); |
|
488 | + // if (! empty($registrations)) { |
|
489 | + // foreach ($registrations as $registration) { |
|
490 | + // if ($registration instanceof EE_Registration) { |
|
491 | + // $delete_registration = true; |
|
492 | + // if ($registration->attendee() instanceof EE_Attendee) { |
|
493 | + // $delete_registration = false; |
|
494 | + // } |
|
495 | + // if ($delete_registration) { |
|
496 | + // $registration->delete_permanently(); |
|
497 | + // $registration->delete_related_permanently(); |
|
498 | + // } |
|
499 | + // } |
|
500 | + // } |
|
501 | + // } |
|
502 | + break; |
|
503 | + } |
|
504 | + } |
|
505 | + unset(self::$_expired_transactions[ $TXN_ID ]); |
|
506 | + } |
|
507 | + } |
|
508 | + |
|
509 | + |
|
510 | + |
|
511 | + /************* END OF EXPIRED TRANSACTION CHECK *************/ |
|
512 | + |
|
513 | + |
|
514 | + /************* START CLEAN UP BOT TRANSACTIONS **********************/ |
|
515 | + |
|
516 | + |
|
517 | + /** |
|
518 | + * callback for 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions' |
|
519 | + * which is setup during activation to run on an hourly cron |
|
520 | + * |
|
521 | + * @throws EE_Error |
|
522 | + * @throws InvalidArgumentException |
|
523 | + * @throws InvalidDataTypeException |
|
524 | + * @throws InvalidInterfaceException |
|
525 | + * @throws DomainException |
|
526 | + */ |
|
527 | + public static function clean_out_junk_transactions() |
|
528 | + { |
|
529 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
530 | + EED_Ticket_Sales_Monitor::reset_reservation_counts(); |
|
531 | + EEM_Transaction::instance('')->delete_junk_transactions(); |
|
532 | + EEM_Registration::instance('')->delete_registrations_with_no_transaction(); |
|
533 | + EEM_Line_Item::instance('')->delete_line_items_with_no_transaction(); |
|
534 | + } |
|
535 | + } |
|
536 | + |
|
537 | + |
|
538 | + /** |
|
539 | + * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that. |
|
540 | + * |
|
541 | + * @throws EE_Error |
|
542 | + * @throws InvalidDataTypeException |
|
543 | + * @throws InvalidInterfaceException |
|
544 | + * @throws InvalidArgumentException |
|
545 | + */ |
|
546 | + public static function clean_out_old_gateway_logs() |
|
547 | + { |
|
548 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
549 | + $reg_config = LoaderFactory::getLoader()->load('EE_Registration_Config'); |
|
550 | + $time_diff_for_comparison = apply_filters( |
|
551 | + 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison', |
|
552 | + '-' . $reg_config->gateway_log_lifespan |
|
553 | + ); |
|
554 | + EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison)); |
|
555 | + } |
|
556 | + } |
|
557 | + |
|
558 | + |
|
559 | + /***************** FINALIZE ABANDONED TRANSACTIONS *****************/ |
|
560 | + |
|
561 | + |
|
562 | + /** |
|
563 | + * @var array |
|
564 | + */ |
|
565 | + protected static $_abandoned_transactions = array(); |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * @deprecated |
|
570 | + * @param int $timestamp |
|
571 | + * @param int $TXN_ID |
|
572 | + */ |
|
573 | + public static function schedule_finalize_abandoned_transactions_check($timestamp, $TXN_ID) |
|
574 | + { |
|
575 | + EE_Cron_Tasks::schedule_expired_transaction_check($timestamp, $TXN_ID); |
|
576 | + } |
|
577 | + |
|
578 | + |
|
579 | + /** |
|
580 | + * @deprecated |
|
581 | + * @param int $TXN_ID |
|
582 | + */ |
|
583 | + public static function check_for_abandoned_transactions($TXN_ID = 0) |
|
584 | + { |
|
585 | + EE_Cron_Tasks::expired_transaction_check($TXN_ID); |
|
586 | + } |
|
587 | + |
|
588 | + |
|
589 | + /** |
|
590 | + * @deprecated |
|
591 | + * @throws EE_Error |
|
592 | + * @throws DomainException |
|
593 | + * @throws InvalidDataTypeException |
|
594 | + * @throws InvalidInterfaceException |
|
595 | + * @throws InvalidArgumentException |
|
596 | + * @throws ReflectionException |
|
597 | + * @throws RuntimeException |
|
598 | + */ |
|
599 | + public static function finalize_abandoned_transactions() |
|
600 | + { |
|
601 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
602 | + if ( |
|
603 | 603 | // are there any TXNs that need cleaning up ? |
604 | - empty(self::$_abandoned_transactions) |
|
605 | - // reschedule the cron if we can't hit the db right now |
|
606 | - || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
|
607 | - 'schedule_expired_transaction_check', |
|
608 | - self::$_abandoned_transactions |
|
609 | - ) |
|
610 | - ) { |
|
611 | - return; |
|
612 | - } |
|
613 | - // combine our arrays of transaction IDs |
|
614 | - self::$_expired_transactions = self::$_abandoned_transactions + self::$_expired_transactions; |
|
615 | - // and deal with abandoned transactions here now... |
|
616 | - EE_Cron_Tasks::process_expired_transactions(); |
|
617 | - } |
|
618 | - |
|
619 | - |
|
620 | - /************* END OF FINALIZE ABANDONED TRANSACTIONS *************/ |
|
604 | + empty(self::$_abandoned_transactions) |
|
605 | + // reschedule the cron if we can't hit the db right now |
|
606 | + || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
|
607 | + 'schedule_expired_transaction_check', |
|
608 | + self::$_abandoned_transactions |
|
609 | + ) |
|
610 | + ) { |
|
611 | + return; |
|
612 | + } |
|
613 | + // combine our arrays of transaction IDs |
|
614 | + self::$_expired_transactions = self::$_abandoned_transactions + self::$_expired_transactions; |
|
615 | + // and deal with abandoned transactions here now... |
|
616 | + EE_Cron_Tasks::process_expired_transactions(); |
|
617 | + } |
|
618 | + |
|
619 | + |
|
620 | + /************* END OF FINALIZE ABANDONED TRANSACTIONS *************/ |
|
621 | 621 | } |