@@ -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 | } |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function registerScriptI18n($handle, $domain = 'event_espresso') |
77 | 77 | { |
78 | - if(! isset($this->registered_i18n[$handle])) { |
|
79 | - $this->registered_i18n[ $handle ] = 1; |
|
80 | - $this->queued_scripts[ $handle ] = $domain; |
|
78 | + if ( ! isset($this->registered_i18n[$handle])) { |
|
79 | + $this->registered_i18n[$handle] = 1; |
|
80 | + $this->queued_scripts[$handle] = $domain; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -121,8 +121,7 @@ discard block |
||
121 | 121 | protected function registerInlineScript($handle, array $translations, $domain) |
122 | 122 | { |
123 | 123 | $script = $domain ? |
124 | - 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' : |
|
125 | - 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );'; |
|
124 | + 'eejs.i18n.setLocaleData( '.wp_json_encode($translations).', "'.$domain.'" );' : 'eejs.i18n.setLocaleData( '.wp_json_encode($translations).' );'; |
|
126 | 125 | wp_add_inline_script($handle, $script, 'before'); |
127 | 126 | } |
128 | 127 | |
@@ -158,9 +157,9 @@ discard block |
||
158 | 157 | private function setI18nMap(array $i18n_map) |
159 | 158 | { |
160 | 159 | if (empty($i18n_map)) { |
161 | - $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json') |
|
160 | + $i18n_map = file_exists($this->domain->pluginPath().'translation-map.json') |
|
162 | 161 | ? json_decode( |
163 | - file_get_contents($this->domain->pluginPath() . 'translation-map.json'), |
|
162 | + file_get_contents($this->domain->pluginPath().'translation-map.json'), |
|
164 | 163 | true |
165 | 164 | ) |
166 | 165 | : array(); |
@@ -238,7 +237,7 @@ discard block |
||
238 | 237 | ), |
239 | 238 | ); |
240 | 239 | |
241 | - if (! empty($translations->headers['Plural-Forms'])) { |
|
240 | + if ( ! empty($translations->headers['Plural-Forms'])) { |
|
242 | 241 | $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
243 | 242 | } |
244 | 243 |
@@ -15,239 +15,239 @@ |
||
15 | 15 | */ |
16 | 16 | class I18nRegistry |
17 | 17 | { |
18 | - /** |
|
19 | - * @var DomainInterface |
|
20 | - */ |
|
21 | - private $domain; |
|
22 | - |
|
23 | - /** |
|
24 | - * Will hold all registered i18n scripts. Prevents script handles from being registered more than once. |
|
25 | - * |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - private $registered_i18n = array(); |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * Used to hold queued translations for the chunks loading in a view. |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - private $queued_handle_translations = array(); |
|
37 | - |
|
38 | - /** |
|
39 | - * Used to track script handles queued for adding translation strings as inline data in the dom. |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - private $queued_scripts = array(); |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to |
|
48 | - * translation strings. |
|
49 | - * |
|
50 | - * @var array |
|
51 | - */ |
|
52 | - private $i18n_map; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * I18nRegistry constructor. |
|
57 | - * |
|
58 | - * @param array() $i18n_map An array of script handle names and the strings translated for those handles. If not |
|
59 | - * provided, the class will look for map in root of plugin with filename of |
|
60 | - * 'translation-map.json'. |
|
61 | - * @param DomainInterface $domain |
|
62 | - */ |
|
63 | - public function __construct(array $i18n_map = array(), DomainInterface $domain) |
|
64 | - { |
|
65 | - $this->domain = $domain; |
|
66 | - $this->setI18nMap($i18n_map); |
|
67 | - add_filter('print_scripts_array', array($this, 'queueI18n')); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * Used to register a script that has i18n strings for its $handle |
|
73 | - * |
|
74 | - * @param string $handle The script handle reference. |
|
75 | - * @param string $domain The i18n domain for the strings. |
|
76 | - */ |
|
77 | - public function registerScriptI18n($handle, $domain = 'event_espresso') |
|
78 | - { |
|
79 | - if(! isset($this->registered_i18n[$handle])) { |
|
80 | - $this->registered_i18n[ $handle ] = 1; |
|
81 | - $this->queued_scripts[ $handle ] = $domain; |
|
82 | - } |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data. |
|
89 | - * |
|
90 | - * @param array $handles Array of registered script handles. |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - public function queueI18n(array $handles) |
|
94 | - { |
|
95 | - if (empty($this->queued_scripts)) { |
|
96 | - return $handles; |
|
97 | - } |
|
98 | - foreach ($handles as $handle) { |
|
99 | - $this->queueI18nTranslationsForHandle($handle); |
|
100 | - } |
|
101 | - if ($this->queued_handle_translations) { |
|
102 | - foreach ($this->queued_handle_translations as $handle => $translations_for_domain) { |
|
103 | - $this->registerInlineScript( |
|
104 | - $handle, |
|
105 | - $translations_for_domain['translations'], |
|
106 | - $translations_for_domain['domain'] |
|
107 | - ); |
|
108 | - unset($this->queued_handle_translations[$handle]); |
|
109 | - } |
|
110 | - } |
|
111 | - return $handles; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Registers inline script with translations for given handle and domain. |
|
117 | - * |
|
118 | - * @param string $handle Handle used to register javascript file containing translations. |
|
119 | - * @param array $translations Array of string translations. |
|
120 | - * @param string $domain Domain for translations. If left empty then strings are registered with the default |
|
121 | - * domain for the javascript. |
|
122 | - */ |
|
123 | - protected function registerInlineScript($handle, array $translations, $domain) |
|
124 | - { |
|
125 | - $script = $domain ? |
|
126 | - 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' : |
|
127 | - 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );'; |
|
128 | - wp_add_inline_script($handle, $script, 'before'); |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * Queues up the translation strings for the given handle. |
|
134 | - * |
|
135 | - * @param string $handle The script handle being queued up. |
|
136 | - */ |
|
137 | - private function queueI18nTranslationsForHandle($handle) |
|
138 | - { |
|
139 | - if (isset($this->queued_scripts[$handle])) { |
|
140 | - $domain = $this->queued_scripts[$handle]; |
|
141 | - $translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain); |
|
142 | - if (count($translations) > 0) { |
|
143 | - $this->queued_handle_translations[$handle] = array( |
|
144 | - 'domain' => $domain, |
|
145 | - 'translations' => $translations, |
|
146 | - ); |
|
147 | - } |
|
148 | - unset($this->queued_scripts[$handle]); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * Sets the internal i18n_map property. |
|
155 | - * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map. |
|
156 | - * |
|
157 | - * @param array $i18n_map If provided, an array of translation strings indexed by script handle names they |
|
158 | - * correspond to. |
|
159 | - */ |
|
160 | - private function setI18nMap(array $i18n_map) |
|
161 | - { |
|
162 | - if (empty($i18n_map)) { |
|
163 | - $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json') |
|
164 | - ? json_decode( |
|
165 | - file_get_contents($this->domain->pluginPath() . 'translation-map.json'), |
|
166 | - true |
|
167 | - ) |
|
168 | - : array(); |
|
169 | - } |
|
170 | - $this->i18n_map = $i18n_map; |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * Get the jed locale data for a given $handle and domain |
|
176 | - * |
|
177 | - * @param string $handle The name for the script handle we want strings returned for. |
|
178 | - * @param string $domain The i18n domain. |
|
179 | - * @return array |
|
180 | - */ |
|
181 | - protected function getJedLocaleDataForDomainAndChunk($handle, $domain) |
|
182 | - { |
|
183 | - $translations = $this->getJedLocaleData($domain); |
|
184 | - // get index for adding back after extracting strings for this $chunk. |
|
185 | - $index = $translations['']; |
|
186 | - $translations = $this->getLocaleDataMatchingMap( |
|
187 | - $this->getOriginalStringsForHandleFromMap($handle), |
|
188 | - $translations |
|
189 | - ); |
|
190 | - $translations[''] = $index; |
|
191 | - return $translations; |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * Get locale data for given strings from given translations |
|
197 | - * |
|
198 | - * @param array $string_set This is the subset of strings (msgIds) we want to extract from the translations array. |
|
199 | - * @param array $translations Translation data to extra strings from. |
|
200 | - * @return array |
|
201 | - */ |
|
202 | - protected function getLocaleDataMatchingMap(array $string_set, array $translations) |
|
203 | - { |
|
204 | - if (empty($string_set)) { |
|
205 | - return array(); |
|
206 | - } |
|
207 | - // some strings with quotes in them will break on the array_flip, so making sure quotes in the string are |
|
208 | - // slashed also filter falsey values. |
|
209 | - $string_set = array_unique(array_filter(wp_slash($string_set))); |
|
210 | - return array_intersect_key($translations, array_flip($string_set)); |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * Get original strings to translate for the given chunk from the map |
|
216 | - * |
|
217 | - * @param string $handle The script handle name to get strings from the map for. |
|
218 | - * @return array |
|
219 | - */ |
|
220 | - protected function getOriginalStringsForHandleFromMap($handle) |
|
221 | - { |
|
222 | - return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array(); |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * Returns Jed-formatted localization data. |
|
228 | - * |
|
229 | - * @param string $domain Translation domain. |
|
230 | - * @return array |
|
231 | - */ |
|
232 | - private function getJedLocaleData($domain) |
|
233 | - { |
|
234 | - $translations = get_translations_for_domain($domain); |
|
235 | - |
|
236 | - $locale = array( |
|
237 | - '' => array( |
|
238 | - 'domain' => $domain, |
|
239 | - 'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale() |
|
240 | - ), |
|
241 | - ); |
|
242 | - |
|
243 | - if (! empty($translations->headers['Plural-Forms'])) { |
|
244 | - $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
245 | - } |
|
246 | - |
|
247 | - foreach ($translations->entries as $msgid => $entry) { |
|
248 | - $locale[$msgid] = $entry->translations; |
|
249 | - } |
|
250 | - |
|
251 | - return $locale; |
|
252 | - } |
|
18 | + /** |
|
19 | + * @var DomainInterface |
|
20 | + */ |
|
21 | + private $domain; |
|
22 | + |
|
23 | + /** |
|
24 | + * Will hold all registered i18n scripts. Prevents script handles from being registered more than once. |
|
25 | + * |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + private $registered_i18n = array(); |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * Used to hold queued translations for the chunks loading in a view. |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + private $queued_handle_translations = array(); |
|
37 | + |
|
38 | + /** |
|
39 | + * Used to track script handles queued for adding translation strings as inline data in the dom. |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + private $queued_scripts = array(); |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to |
|
48 | + * translation strings. |
|
49 | + * |
|
50 | + * @var array |
|
51 | + */ |
|
52 | + private $i18n_map; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * I18nRegistry constructor. |
|
57 | + * |
|
58 | + * @param array() $i18n_map An array of script handle names and the strings translated for those handles. If not |
|
59 | + * provided, the class will look for map in root of plugin with filename of |
|
60 | + * 'translation-map.json'. |
|
61 | + * @param DomainInterface $domain |
|
62 | + */ |
|
63 | + public function __construct(array $i18n_map = array(), DomainInterface $domain) |
|
64 | + { |
|
65 | + $this->domain = $domain; |
|
66 | + $this->setI18nMap($i18n_map); |
|
67 | + add_filter('print_scripts_array', array($this, 'queueI18n')); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * Used to register a script that has i18n strings for its $handle |
|
73 | + * |
|
74 | + * @param string $handle The script handle reference. |
|
75 | + * @param string $domain The i18n domain for the strings. |
|
76 | + */ |
|
77 | + public function registerScriptI18n($handle, $domain = 'event_espresso') |
|
78 | + { |
|
79 | + if(! isset($this->registered_i18n[$handle])) { |
|
80 | + $this->registered_i18n[ $handle ] = 1; |
|
81 | + $this->queued_scripts[ $handle ] = $domain; |
|
82 | + } |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data. |
|
89 | + * |
|
90 | + * @param array $handles Array of registered script handles. |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + public function queueI18n(array $handles) |
|
94 | + { |
|
95 | + if (empty($this->queued_scripts)) { |
|
96 | + return $handles; |
|
97 | + } |
|
98 | + foreach ($handles as $handle) { |
|
99 | + $this->queueI18nTranslationsForHandle($handle); |
|
100 | + } |
|
101 | + if ($this->queued_handle_translations) { |
|
102 | + foreach ($this->queued_handle_translations as $handle => $translations_for_domain) { |
|
103 | + $this->registerInlineScript( |
|
104 | + $handle, |
|
105 | + $translations_for_domain['translations'], |
|
106 | + $translations_for_domain['domain'] |
|
107 | + ); |
|
108 | + unset($this->queued_handle_translations[$handle]); |
|
109 | + } |
|
110 | + } |
|
111 | + return $handles; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Registers inline script with translations for given handle and domain. |
|
117 | + * |
|
118 | + * @param string $handle Handle used to register javascript file containing translations. |
|
119 | + * @param array $translations Array of string translations. |
|
120 | + * @param string $domain Domain for translations. If left empty then strings are registered with the default |
|
121 | + * domain for the javascript. |
|
122 | + */ |
|
123 | + protected function registerInlineScript($handle, array $translations, $domain) |
|
124 | + { |
|
125 | + $script = $domain ? |
|
126 | + 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' : |
|
127 | + 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );'; |
|
128 | + wp_add_inline_script($handle, $script, 'before'); |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * Queues up the translation strings for the given handle. |
|
134 | + * |
|
135 | + * @param string $handle The script handle being queued up. |
|
136 | + */ |
|
137 | + private function queueI18nTranslationsForHandle($handle) |
|
138 | + { |
|
139 | + if (isset($this->queued_scripts[$handle])) { |
|
140 | + $domain = $this->queued_scripts[$handle]; |
|
141 | + $translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain); |
|
142 | + if (count($translations) > 0) { |
|
143 | + $this->queued_handle_translations[$handle] = array( |
|
144 | + 'domain' => $domain, |
|
145 | + 'translations' => $translations, |
|
146 | + ); |
|
147 | + } |
|
148 | + unset($this->queued_scripts[$handle]); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * Sets the internal i18n_map property. |
|
155 | + * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map. |
|
156 | + * |
|
157 | + * @param array $i18n_map If provided, an array of translation strings indexed by script handle names they |
|
158 | + * correspond to. |
|
159 | + */ |
|
160 | + private function setI18nMap(array $i18n_map) |
|
161 | + { |
|
162 | + if (empty($i18n_map)) { |
|
163 | + $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json') |
|
164 | + ? json_decode( |
|
165 | + file_get_contents($this->domain->pluginPath() . 'translation-map.json'), |
|
166 | + true |
|
167 | + ) |
|
168 | + : array(); |
|
169 | + } |
|
170 | + $this->i18n_map = $i18n_map; |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * Get the jed locale data for a given $handle and domain |
|
176 | + * |
|
177 | + * @param string $handle The name for the script handle we want strings returned for. |
|
178 | + * @param string $domain The i18n domain. |
|
179 | + * @return array |
|
180 | + */ |
|
181 | + protected function getJedLocaleDataForDomainAndChunk($handle, $domain) |
|
182 | + { |
|
183 | + $translations = $this->getJedLocaleData($domain); |
|
184 | + // get index for adding back after extracting strings for this $chunk. |
|
185 | + $index = $translations['']; |
|
186 | + $translations = $this->getLocaleDataMatchingMap( |
|
187 | + $this->getOriginalStringsForHandleFromMap($handle), |
|
188 | + $translations |
|
189 | + ); |
|
190 | + $translations[''] = $index; |
|
191 | + return $translations; |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * Get locale data for given strings from given translations |
|
197 | + * |
|
198 | + * @param array $string_set This is the subset of strings (msgIds) we want to extract from the translations array. |
|
199 | + * @param array $translations Translation data to extra strings from. |
|
200 | + * @return array |
|
201 | + */ |
|
202 | + protected function getLocaleDataMatchingMap(array $string_set, array $translations) |
|
203 | + { |
|
204 | + if (empty($string_set)) { |
|
205 | + return array(); |
|
206 | + } |
|
207 | + // some strings with quotes in them will break on the array_flip, so making sure quotes in the string are |
|
208 | + // slashed also filter falsey values. |
|
209 | + $string_set = array_unique(array_filter(wp_slash($string_set))); |
|
210 | + return array_intersect_key($translations, array_flip($string_set)); |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * Get original strings to translate for the given chunk from the map |
|
216 | + * |
|
217 | + * @param string $handle The script handle name to get strings from the map for. |
|
218 | + * @return array |
|
219 | + */ |
|
220 | + protected function getOriginalStringsForHandleFromMap($handle) |
|
221 | + { |
|
222 | + return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array(); |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * Returns Jed-formatted localization data. |
|
228 | + * |
|
229 | + * @param string $domain Translation domain. |
|
230 | + * @return array |
|
231 | + */ |
|
232 | + private function getJedLocaleData($domain) |
|
233 | + { |
|
234 | + $translations = get_translations_for_domain($domain); |
|
235 | + |
|
236 | + $locale = array( |
|
237 | + '' => array( |
|
238 | + 'domain' => $domain, |
|
239 | + 'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale() |
|
240 | + ), |
|
241 | + ); |
|
242 | + |
|
243 | + if (! empty($translations->headers['Plural-Forms'])) { |
|
244 | + $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
245 | + } |
|
246 | + |
|
247 | + foreach ($translations->entries as $msgid => $entry) { |
|
248 | + $locale[$msgid] = $entry->translations; |
|
249 | + } |
|
250 | + |
|
251 | + return $locale; |
|
252 | + } |
|
253 | 253 | } |
254 | 254 | \ No newline at end of file |
@@ -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 | - esc_html__( |
|
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 | + esc_html__( |
|
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 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | /** @var Asset $asset */ |
76 | 76 | $asset = $this->current(); |
77 | 77 | if ($asset->type() === $type) { |
78 | - $files[ $asset->handle() ] = $asset; |
|
78 | + $files[$asset->handle()] = $asset; |
|
79 | 79 | } |
80 | 80 | $this->next(); |
81 | 81 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | /** @var JavascriptAsset $asset */ |
97 | 97 | $asset = $this->current(); |
98 | 98 | if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) { |
99 | - $files[ $asset->handle() ] = $asset; |
|
99 | + $files[$asset->handle()] = $asset; |
|
100 | 100 | } |
101 | 101 | $this->next(); |
102 | 102 | } |
@@ -21,192 +21,192 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * AssetCollection constructor |
|
26 | - * |
|
27 | - * @throws InvalidInterfaceException |
|
28 | - */ |
|
29 | - public function __construct() |
|
30 | - { |
|
31 | - parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * @return StylesheetAsset[] |
|
37 | - * @since 4.9.62.p |
|
38 | - */ |
|
39 | - public function getStylesheetAssets() |
|
40 | - { |
|
41 | - return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * @return JavascriptAsset[] |
|
47 | - * @since 4.9.62.p |
|
48 | - */ |
|
49 | - public function getJavascriptAssets() |
|
50 | - { |
|
51 | - return $this->getAssetsOfType(Asset::TYPE_JS); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @return ManifestFile[] |
|
57 | - * @since 4.9.62.p |
|
58 | - */ |
|
59 | - public function getManifestFiles() |
|
60 | - { |
|
61 | - return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @param $type |
|
67 | - * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[] |
|
68 | - * @since 4.9.62.p |
|
69 | - */ |
|
70 | - protected function getAssetsOfType($type) |
|
71 | - { |
|
72 | - $files = array(); |
|
73 | - $this->rewind(); |
|
74 | - while ($this->valid()) { |
|
75 | - /** @var Asset $asset */ |
|
76 | - $asset = $this->current(); |
|
77 | - if ($asset->type() === $type) { |
|
78 | - $files[ $asset->handle() ] = $asset; |
|
79 | - } |
|
80 | - $this->next(); |
|
81 | - } |
|
82 | - $this->rewind(); |
|
83 | - return $files; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @return JavascriptAsset[] |
|
89 | - * @since 4.9.62.p |
|
90 | - */ |
|
91 | - public function getJavascriptAssetsWithData() |
|
92 | - { |
|
93 | - $files = array(); |
|
94 | - $this->rewind(); |
|
95 | - while ($this->valid()) { |
|
96 | - /** @var JavascriptAsset $asset */ |
|
97 | - $asset = $this->current(); |
|
98 | - if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) { |
|
99 | - $files[ $asset->handle() ] = $asset; |
|
100 | - } |
|
101 | - $this->next(); |
|
102 | - } |
|
103 | - $this->rewind(); |
|
104 | - return $files; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * returns TRUE or FALSE |
|
110 | - * depending on whether the object is within the Collection |
|
111 | - * based on the supplied $identifier and type |
|
112 | - * |
|
113 | - * @param mixed $identifier |
|
114 | - * @param string $type |
|
115 | - * @return bool |
|
116 | - * @since 4.9.63.p |
|
117 | - */ |
|
118 | - public function hasAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
119 | - { |
|
120 | - $this->rewind(); |
|
121 | - while ($this->valid()) { |
|
122 | - if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
123 | - $this->rewind(); |
|
124 | - return true; |
|
125 | - } |
|
126 | - $this->next(); |
|
127 | - } |
|
128 | - return false; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * returns TRUE or FALSE |
|
134 | - * depending on whether the Javascript Asset is within the Collection |
|
135 | - * based on the supplied $identifier |
|
136 | - * |
|
137 | - * @param mixed $identifier |
|
138 | - * @return bool |
|
139 | - * @since 4.9.63.p |
|
140 | - */ |
|
141 | - public function hasJavascriptAsset($identifier) |
|
142 | - { |
|
143 | - return $this->hasAssetOfType($identifier, Asset::TYPE_JS); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * returns TRUE or FALSE |
|
149 | - * depending on whether the Stylesheet Asset is within the Collection |
|
150 | - * based on the supplied $identifier |
|
151 | - * |
|
152 | - * @param mixed $identifier |
|
153 | - * @return bool |
|
154 | - * @since 4.9.63.p |
|
155 | - */ |
|
156 | - public function hasStylesheetAsset($identifier) |
|
157 | - { |
|
158 | - return $this->hasAssetOfType($identifier, Asset::TYPE_CSS); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * returns the object from the Collection |
|
163 | - * based on the supplied $identifier and type |
|
164 | - * |
|
165 | - * @param mixed $identifier |
|
166 | - * @param string $type |
|
167 | - * @return JavascriptAsset|StylesheetAsset |
|
168 | - * @since 4.9.63.p |
|
169 | - */ |
|
170 | - public function getAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
171 | - { |
|
172 | - $this->rewind(); |
|
173 | - while ($this->valid()) { |
|
174 | - if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
175 | - /** @var JavascriptAsset|StylesheetAsset $object */ |
|
176 | - $object = $this->current(); |
|
177 | - $this->rewind(); |
|
178 | - return $object; |
|
179 | - } |
|
180 | - $this->next(); |
|
181 | - } |
|
182 | - return null; |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * returns the Stylesheet Asset from the Collection |
|
188 | - * based on the supplied $identifier |
|
189 | - * |
|
190 | - * @param mixed $identifier |
|
191 | - * @return StylesheetAsset |
|
192 | - * @since 4.9.63.p |
|
193 | - */ |
|
194 | - public function getStylesheetAsset($identifier) |
|
195 | - { |
|
196 | - return $this->getAssetOfType($identifier, Asset::TYPE_CSS); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * returns the Javascript Asset from the Collection |
|
202 | - * based on the supplied $identifier |
|
203 | - * |
|
204 | - * @param mixed $identifier |
|
205 | - * @return JavascriptAsset |
|
206 | - * @since 4.9.63.p |
|
207 | - */ |
|
208 | - public function getJavascriptAsset($identifier) |
|
209 | - { |
|
210 | - return $this->getAssetOfType($identifier, Asset::TYPE_JS); |
|
211 | - } |
|
24 | + /** |
|
25 | + * AssetCollection constructor |
|
26 | + * |
|
27 | + * @throws InvalidInterfaceException |
|
28 | + */ |
|
29 | + public function __construct() |
|
30 | + { |
|
31 | + parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * @return StylesheetAsset[] |
|
37 | + * @since 4.9.62.p |
|
38 | + */ |
|
39 | + public function getStylesheetAssets() |
|
40 | + { |
|
41 | + return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * @return JavascriptAsset[] |
|
47 | + * @since 4.9.62.p |
|
48 | + */ |
|
49 | + public function getJavascriptAssets() |
|
50 | + { |
|
51 | + return $this->getAssetsOfType(Asset::TYPE_JS); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @return ManifestFile[] |
|
57 | + * @since 4.9.62.p |
|
58 | + */ |
|
59 | + public function getManifestFiles() |
|
60 | + { |
|
61 | + return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @param $type |
|
67 | + * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[] |
|
68 | + * @since 4.9.62.p |
|
69 | + */ |
|
70 | + protected function getAssetsOfType($type) |
|
71 | + { |
|
72 | + $files = array(); |
|
73 | + $this->rewind(); |
|
74 | + while ($this->valid()) { |
|
75 | + /** @var Asset $asset */ |
|
76 | + $asset = $this->current(); |
|
77 | + if ($asset->type() === $type) { |
|
78 | + $files[ $asset->handle() ] = $asset; |
|
79 | + } |
|
80 | + $this->next(); |
|
81 | + } |
|
82 | + $this->rewind(); |
|
83 | + return $files; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @return JavascriptAsset[] |
|
89 | + * @since 4.9.62.p |
|
90 | + */ |
|
91 | + public function getJavascriptAssetsWithData() |
|
92 | + { |
|
93 | + $files = array(); |
|
94 | + $this->rewind(); |
|
95 | + while ($this->valid()) { |
|
96 | + /** @var JavascriptAsset $asset */ |
|
97 | + $asset = $this->current(); |
|
98 | + if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) { |
|
99 | + $files[ $asset->handle() ] = $asset; |
|
100 | + } |
|
101 | + $this->next(); |
|
102 | + } |
|
103 | + $this->rewind(); |
|
104 | + return $files; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * returns TRUE or FALSE |
|
110 | + * depending on whether the object is within the Collection |
|
111 | + * based on the supplied $identifier and type |
|
112 | + * |
|
113 | + * @param mixed $identifier |
|
114 | + * @param string $type |
|
115 | + * @return bool |
|
116 | + * @since 4.9.63.p |
|
117 | + */ |
|
118 | + public function hasAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
119 | + { |
|
120 | + $this->rewind(); |
|
121 | + while ($this->valid()) { |
|
122 | + if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
123 | + $this->rewind(); |
|
124 | + return true; |
|
125 | + } |
|
126 | + $this->next(); |
|
127 | + } |
|
128 | + return false; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * returns TRUE or FALSE |
|
134 | + * depending on whether the Javascript Asset is within the Collection |
|
135 | + * based on the supplied $identifier |
|
136 | + * |
|
137 | + * @param mixed $identifier |
|
138 | + * @return bool |
|
139 | + * @since 4.9.63.p |
|
140 | + */ |
|
141 | + public function hasJavascriptAsset($identifier) |
|
142 | + { |
|
143 | + return $this->hasAssetOfType($identifier, Asset::TYPE_JS); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * returns TRUE or FALSE |
|
149 | + * depending on whether the Stylesheet Asset is within the Collection |
|
150 | + * based on the supplied $identifier |
|
151 | + * |
|
152 | + * @param mixed $identifier |
|
153 | + * @return bool |
|
154 | + * @since 4.9.63.p |
|
155 | + */ |
|
156 | + public function hasStylesheetAsset($identifier) |
|
157 | + { |
|
158 | + return $this->hasAssetOfType($identifier, Asset::TYPE_CSS); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * returns the object from the Collection |
|
163 | + * based on the supplied $identifier and type |
|
164 | + * |
|
165 | + * @param mixed $identifier |
|
166 | + * @param string $type |
|
167 | + * @return JavascriptAsset|StylesheetAsset |
|
168 | + * @since 4.9.63.p |
|
169 | + */ |
|
170 | + public function getAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
171 | + { |
|
172 | + $this->rewind(); |
|
173 | + while ($this->valid()) { |
|
174 | + if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
175 | + /** @var JavascriptAsset|StylesheetAsset $object */ |
|
176 | + $object = $this->current(); |
|
177 | + $this->rewind(); |
|
178 | + return $object; |
|
179 | + } |
|
180 | + $this->next(); |
|
181 | + } |
|
182 | + return null; |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * returns the Stylesheet Asset from the Collection |
|
188 | + * based on the supplied $identifier |
|
189 | + * |
|
190 | + * @param mixed $identifier |
|
191 | + * @return StylesheetAsset |
|
192 | + * @since 4.9.63.p |
|
193 | + */ |
|
194 | + public function getStylesheetAsset($identifier) |
|
195 | + { |
|
196 | + return $this->getAssetOfType($identifier, Asset::TYPE_CSS); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * returns the Javascript Asset from the Collection |
|
202 | + * based on the supplied $identifier |
|
203 | + * |
|
204 | + * @param mixed $identifier |
|
205 | + * @return JavascriptAsset |
|
206 | + * @since 4.9.63.p |
|
207 | + */ |
|
208 | + public function getJavascriptAsset($identifier) |
|
209 | + { |
|
210 | + return $this->getAssetOfType($identifier, Asset::TYPE_JS); |
|
211 | + } |
|
212 | 212 | } |
@@ -81,7 +81,7 @@ |
||
81 | 81 | */ |
82 | 82 | public function namespacedBlockType() |
83 | 83 | { |
84 | - return self::NAME_SPACE . '/' . $this->block_type; |
|
84 | + return self::NAME_SPACE.'/'.$this->block_type; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 |
@@ -21,211 +21,211 @@ |
||
21 | 21 | abstract class Block implements BlockInterface |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * BlockAssetManager that this editor block uses for asset registration |
|
26 | - * |
|
27 | - * @var BlockAssetManagerInterface $block_asset_manager |
|
28 | - */ |
|
29 | - protected $block_asset_manager; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var RequestInterface $request |
|
33 | - */ |
|
34 | - protected $request; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var array $attributes |
|
38 | - */ |
|
39 | - private $attributes; |
|
40 | - |
|
41 | - /** |
|
42 | - * If set to true, then the block will render its content client side |
|
43 | - * If false, then the block will render its content server side using the renderBlock() method |
|
44 | - * |
|
45 | - * @var bool $dynamic |
|
46 | - */ |
|
47 | - private $dynamic = false; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var string $block_type |
|
51 | - */ |
|
52 | - private $block_type; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var array $supported_routes |
|
56 | - */ |
|
57 | - private $supported_routes; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var WP_Block_Type $wp_block_type |
|
61 | - */ |
|
62 | - private $wp_block_type; |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * BlockLoader constructor. |
|
67 | - * |
|
68 | - * @param BlockAssetManagerInterface $block_asset_manager |
|
69 | - * @param RequestInterface $request |
|
70 | - */ |
|
71 | - public function __construct(BlockAssetManagerInterface $block_asset_manager, RequestInterface $request) |
|
72 | - { |
|
73 | - $this->block_asset_manager = $block_asset_manager; |
|
74 | - $this->request = $request; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function blockType() |
|
82 | - { |
|
83 | - return $this->block_type; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function namespacedBlockType() |
|
91 | - { |
|
92 | - return self::NAME_SPACE . '/' . $this->block_type; |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @param string $block_type |
|
98 | - */ |
|
99 | - protected function setBlockType($block_type) |
|
100 | - { |
|
101 | - $this->block_type = $block_type; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * BlockAssetManager that this editor block uses for asset registration |
|
107 | - * |
|
108 | - * @return BlockAssetManagerInterface |
|
109 | - */ |
|
110 | - public function assetManager() |
|
111 | - { |
|
112 | - return $this->block_asset_manager; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @param WP_Block_Type $wp_block_type |
|
118 | - */ |
|
119 | - protected function setWpBlockType($wp_block_type) |
|
120 | - { |
|
121 | - $this->wp_block_type = $wp_block_type; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * returns an array of fully qualified class names |
|
126 | - * for RouteMatchSpecificationInterface objects |
|
127 | - * that specify routes that the block should be loaded for. |
|
128 | - * |
|
129 | - * @return array |
|
130 | - */ |
|
131 | - public function supportedRoutes() |
|
132 | - { |
|
133 | - return $this->supported_routes; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @param array $supported_routes |
|
139 | - */ |
|
140 | - protected function setSupportedRoutes(array $supported_routes) |
|
141 | - { |
|
142 | - $this->supported_routes = $supported_routes; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @return array |
|
148 | - */ |
|
149 | - public function attributes() |
|
150 | - { |
|
151 | - return $this->attributes; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * @param array $attributes |
|
157 | - */ |
|
158 | - public function setAttributes(array $attributes) |
|
159 | - { |
|
160 | - $this->attributes = $attributes; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @return bool |
|
166 | - */ |
|
167 | - public function isDynamic() |
|
168 | - { |
|
169 | - return $this->dynamic; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * @param bool $dynamic |
|
175 | - */ |
|
176 | - public function setDynamic($dynamic = true) |
|
177 | - { |
|
178 | - $this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * Registers the Editor Block with WP core; |
|
184 | - * Returns the registered block type on success, or false on failure. |
|
185 | - * |
|
186 | - * @return WP_Block_Type|false |
|
187 | - */ |
|
188 | - public function registerBlock() |
|
189 | - { |
|
190 | - $args = array( |
|
191 | - 'attributes' => $this->attributes(), |
|
192 | - 'editor_script' => $this->block_asset_manager->getEditorScriptHandle(), |
|
193 | - 'editor_style' => $this->block_asset_manager->getEditorStyleHandle(), |
|
194 | - 'script' => $this->block_asset_manager->getScriptHandle(), |
|
195 | - 'style' => $this->block_asset_manager->getStyleHandle(), |
|
196 | - ); |
|
197 | - if ($this->isDynamic()) { |
|
198 | - $args['render_callback'] = array($this, 'renderBlock'); |
|
199 | - } |
|
200 | - $wp_block_type = register_block_type( |
|
201 | - new WP_Block_Type( |
|
202 | - $this->namespacedBlockType(), |
|
203 | - $args |
|
204 | - ) |
|
205 | - ); |
|
206 | - $this->setWpBlockType($wp_block_type); |
|
207 | - return $wp_block_type; |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * @return WP_Block_Type|false The registered block type on success, or false on failure. |
|
213 | - */ |
|
214 | - public function unRegisterBlock() |
|
215 | - { |
|
216 | - return unregister_block_type($this->namespacedBlockType()); |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * @return array |
|
223 | - */ |
|
224 | - public function getEditorContainer() |
|
225 | - { |
|
226 | - return array( |
|
227 | - $this->namespacedBlockType(), |
|
228 | - array(), |
|
229 | - ); |
|
230 | - } |
|
24 | + /** |
|
25 | + * BlockAssetManager that this editor block uses for asset registration |
|
26 | + * |
|
27 | + * @var BlockAssetManagerInterface $block_asset_manager |
|
28 | + */ |
|
29 | + protected $block_asset_manager; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var RequestInterface $request |
|
33 | + */ |
|
34 | + protected $request; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var array $attributes |
|
38 | + */ |
|
39 | + private $attributes; |
|
40 | + |
|
41 | + /** |
|
42 | + * If set to true, then the block will render its content client side |
|
43 | + * If false, then the block will render its content server side using the renderBlock() method |
|
44 | + * |
|
45 | + * @var bool $dynamic |
|
46 | + */ |
|
47 | + private $dynamic = false; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var string $block_type |
|
51 | + */ |
|
52 | + private $block_type; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var array $supported_routes |
|
56 | + */ |
|
57 | + private $supported_routes; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var WP_Block_Type $wp_block_type |
|
61 | + */ |
|
62 | + private $wp_block_type; |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * BlockLoader constructor. |
|
67 | + * |
|
68 | + * @param BlockAssetManagerInterface $block_asset_manager |
|
69 | + * @param RequestInterface $request |
|
70 | + */ |
|
71 | + public function __construct(BlockAssetManagerInterface $block_asset_manager, RequestInterface $request) |
|
72 | + { |
|
73 | + $this->block_asset_manager = $block_asset_manager; |
|
74 | + $this->request = $request; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function blockType() |
|
82 | + { |
|
83 | + return $this->block_type; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function namespacedBlockType() |
|
91 | + { |
|
92 | + return self::NAME_SPACE . '/' . $this->block_type; |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @param string $block_type |
|
98 | + */ |
|
99 | + protected function setBlockType($block_type) |
|
100 | + { |
|
101 | + $this->block_type = $block_type; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * BlockAssetManager that this editor block uses for asset registration |
|
107 | + * |
|
108 | + * @return BlockAssetManagerInterface |
|
109 | + */ |
|
110 | + public function assetManager() |
|
111 | + { |
|
112 | + return $this->block_asset_manager; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @param WP_Block_Type $wp_block_type |
|
118 | + */ |
|
119 | + protected function setWpBlockType($wp_block_type) |
|
120 | + { |
|
121 | + $this->wp_block_type = $wp_block_type; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * returns an array of fully qualified class names |
|
126 | + * for RouteMatchSpecificationInterface objects |
|
127 | + * that specify routes that the block should be loaded for. |
|
128 | + * |
|
129 | + * @return array |
|
130 | + */ |
|
131 | + public function supportedRoutes() |
|
132 | + { |
|
133 | + return $this->supported_routes; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @param array $supported_routes |
|
139 | + */ |
|
140 | + protected function setSupportedRoutes(array $supported_routes) |
|
141 | + { |
|
142 | + $this->supported_routes = $supported_routes; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @return array |
|
148 | + */ |
|
149 | + public function attributes() |
|
150 | + { |
|
151 | + return $this->attributes; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * @param array $attributes |
|
157 | + */ |
|
158 | + public function setAttributes(array $attributes) |
|
159 | + { |
|
160 | + $this->attributes = $attributes; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @return bool |
|
166 | + */ |
|
167 | + public function isDynamic() |
|
168 | + { |
|
169 | + return $this->dynamic; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * @param bool $dynamic |
|
175 | + */ |
|
176 | + public function setDynamic($dynamic = true) |
|
177 | + { |
|
178 | + $this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * Registers the Editor Block with WP core; |
|
184 | + * Returns the registered block type on success, or false on failure. |
|
185 | + * |
|
186 | + * @return WP_Block_Type|false |
|
187 | + */ |
|
188 | + public function registerBlock() |
|
189 | + { |
|
190 | + $args = array( |
|
191 | + 'attributes' => $this->attributes(), |
|
192 | + 'editor_script' => $this->block_asset_manager->getEditorScriptHandle(), |
|
193 | + 'editor_style' => $this->block_asset_manager->getEditorStyleHandle(), |
|
194 | + 'script' => $this->block_asset_manager->getScriptHandle(), |
|
195 | + 'style' => $this->block_asset_manager->getStyleHandle(), |
|
196 | + ); |
|
197 | + if ($this->isDynamic()) { |
|
198 | + $args['render_callback'] = array($this, 'renderBlock'); |
|
199 | + } |
|
200 | + $wp_block_type = register_block_type( |
|
201 | + new WP_Block_Type( |
|
202 | + $this->namespacedBlockType(), |
|
203 | + $args |
|
204 | + ) |
|
205 | + ); |
|
206 | + $this->setWpBlockType($wp_block_type); |
|
207 | + return $wp_block_type; |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * @return WP_Block_Type|false The registered block type on success, or false on failure. |
|
213 | + */ |
|
214 | + public function unRegisterBlock() |
|
215 | + { |
|
216 | + return unregister_block_type($this->namespacedBlockType()); |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * @return array |
|
223 | + */ |
|
224 | + public function getEditorContainer() |
|
225 | + { |
|
226 | + return array( |
|
227 | + $this->namespacedBlockType(), |
|
228 | + array(), |
|
229 | + ); |
|
230 | + } |
|
231 | 231 | } |
@@ -28,112 +28,112 @@ |
||
28 | 28 | class PrivacySettingsFormHandler extends FormHandler |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @var EE_Config |
|
33 | - */ |
|
34 | - protected $config; |
|
31 | + /** |
|
32 | + * @var EE_Config |
|
33 | + */ |
|
34 | + protected $config; |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * PrivacySettingsFormHandler constructor. |
|
39 | - * |
|
40 | - * @param EE_Registry $registry |
|
41 | - * @param EE_Config $config |
|
42 | - */ |
|
43 | - public function __construct(EE_Registry $registry, EE_Config $config) |
|
44 | - { |
|
45 | - $this->config = $config; |
|
46 | - parent::__construct( |
|
47 | - esc_html__('Privacy Settings', 'event_espresso'), |
|
48 | - esc_html__('Privacy Settings', 'event_espresso'), |
|
49 | - 'privacy-settings', |
|
50 | - '', |
|
51 | - FormHandler::DO_NOT_SETUP_FORM, |
|
52 | - $registry |
|
53 | - ); |
|
54 | - } |
|
37 | + /** |
|
38 | + * PrivacySettingsFormHandler constructor. |
|
39 | + * |
|
40 | + * @param EE_Registry $registry |
|
41 | + * @param EE_Config $config |
|
42 | + */ |
|
43 | + public function __construct(EE_Registry $registry, EE_Config $config) |
|
44 | + { |
|
45 | + $this->config = $config; |
|
46 | + parent::__construct( |
|
47 | + esc_html__('Privacy Settings', 'event_espresso'), |
|
48 | + esc_html__('Privacy Settings', 'event_espresso'), |
|
49 | + 'privacy-settings', |
|
50 | + '', |
|
51 | + FormHandler::DO_NOT_SETUP_FORM, |
|
52 | + $registry |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * creates and returns the actual form |
|
59 | - * |
|
60 | - * @return EE_Form_Section_Proper |
|
61 | - */ |
|
62 | - public function generate() |
|
63 | - { |
|
64 | - // this form makes use of the session for passing around invalid form submission data, so make sure its enabled |
|
65 | - add_filter('FHEE__EE_Session___save_session_to_db__abort_session_save', '__return_false'); |
|
66 | - /** |
|
67 | - * @var $reg_config EE_Registration_Config |
|
68 | - */ |
|
69 | - $reg_config = $this->config->registration; |
|
70 | - return new EE_Form_Section_Proper( |
|
71 | - array( |
|
72 | - 'name' => 'privacy_consent_settings', |
|
73 | - 'subsections' => array( |
|
74 | - 'privacy_consent_form_hdr' => new EE_Form_Section_HTML( |
|
75 | - EEH_HTML::h2(esc_html__('Privacy Policy Consent Settings', 'event_espresso')) |
|
76 | - ), |
|
77 | - 'enable' => new EE_Select_Reveal_Input( |
|
78 | - array( |
|
79 | - 'enable-privacy-consent' => esc_html__('Enabled', 'event_espresso'), |
|
80 | - 'disable' => esc_html__('Disabled', 'event_espresso'), |
|
81 | - ), |
|
82 | - array( |
|
83 | - 'default' => $reg_config->isConsentCheckboxEnabled() |
|
84 | - ? 'enable-privacy-consent' |
|
85 | - : 'disable', |
|
86 | - 'html_label_text' => esc_html__('Privacy Consent Checkbox', 'event_espresso'), |
|
87 | - 'html_help_text' => esc_html__( |
|
88 | - 'When enabled, a checkbox appears in the registration form requiring users to consent to your site\'s privacy policy.', |
|
89 | - 'event_espresso' |
|
90 | - ), |
|
91 | - ) |
|
92 | - ), |
|
93 | - 'enable-privacy-consent' => new EE_Form_Section_Proper( |
|
94 | - array( |
|
95 | - 'subsections' => array( |
|
96 | - 'consent_assertion' => new EE_Text_Area_Input( |
|
97 | - array( |
|
98 | - 'default' => $reg_config->getConsentCheckboxLabelText(), |
|
99 | - 'html_label_text' => esc_html__('Consent Text', 'event_espresso'), |
|
100 | - 'html_help_text' => esc_html__( |
|
101 | - 'Text describing what the registrant is consenting to by submitting their personal data in the registration form. To reset to default value, remove all this text and save.', |
|
102 | - 'event_espresso' |
|
103 | - ), |
|
104 | - 'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()), |
|
105 | - ) |
|
106 | - ), |
|
107 | - ), |
|
108 | - ) |
|
109 | - ), |
|
110 | - ), |
|
111 | - ) |
|
112 | - ); |
|
113 | - } |
|
57 | + /** |
|
58 | + * creates and returns the actual form |
|
59 | + * |
|
60 | + * @return EE_Form_Section_Proper |
|
61 | + */ |
|
62 | + public function generate() |
|
63 | + { |
|
64 | + // this form makes use of the session for passing around invalid form submission data, so make sure its enabled |
|
65 | + add_filter('FHEE__EE_Session___save_session_to_db__abort_session_save', '__return_false'); |
|
66 | + /** |
|
67 | + * @var $reg_config EE_Registration_Config |
|
68 | + */ |
|
69 | + $reg_config = $this->config->registration; |
|
70 | + return new EE_Form_Section_Proper( |
|
71 | + array( |
|
72 | + 'name' => 'privacy_consent_settings', |
|
73 | + 'subsections' => array( |
|
74 | + 'privacy_consent_form_hdr' => new EE_Form_Section_HTML( |
|
75 | + EEH_HTML::h2(esc_html__('Privacy Policy Consent Settings', 'event_espresso')) |
|
76 | + ), |
|
77 | + 'enable' => new EE_Select_Reveal_Input( |
|
78 | + array( |
|
79 | + 'enable-privacy-consent' => esc_html__('Enabled', 'event_espresso'), |
|
80 | + 'disable' => esc_html__('Disabled', 'event_espresso'), |
|
81 | + ), |
|
82 | + array( |
|
83 | + 'default' => $reg_config->isConsentCheckboxEnabled() |
|
84 | + ? 'enable-privacy-consent' |
|
85 | + : 'disable', |
|
86 | + 'html_label_text' => esc_html__('Privacy Consent Checkbox', 'event_espresso'), |
|
87 | + 'html_help_text' => esc_html__( |
|
88 | + 'When enabled, a checkbox appears in the registration form requiring users to consent to your site\'s privacy policy.', |
|
89 | + 'event_espresso' |
|
90 | + ), |
|
91 | + ) |
|
92 | + ), |
|
93 | + 'enable-privacy-consent' => new EE_Form_Section_Proper( |
|
94 | + array( |
|
95 | + 'subsections' => array( |
|
96 | + 'consent_assertion' => new EE_Text_Area_Input( |
|
97 | + array( |
|
98 | + 'default' => $reg_config->getConsentCheckboxLabelText(), |
|
99 | + 'html_label_text' => esc_html__('Consent Text', 'event_espresso'), |
|
100 | + 'html_help_text' => esc_html__( |
|
101 | + 'Text describing what the registrant is consenting to by submitting their personal data in the registration form. To reset to default value, remove all this text and save.', |
|
102 | + 'event_espresso' |
|
103 | + ), |
|
104 | + 'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()), |
|
105 | + ) |
|
106 | + ), |
|
107 | + ), |
|
108 | + ) |
|
109 | + ), |
|
110 | + ), |
|
111 | + ) |
|
112 | + ); |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * After validating the form data, update the registration config |
|
118 | - * |
|
119 | - * @param array $submitted_form_data |
|
120 | - * @return bool |
|
121 | - */ |
|
122 | - public function process($submitted_form_data = array()) |
|
123 | - { |
|
124 | - try { |
|
125 | - $valid_data = parent::process($submitted_form_data); |
|
126 | - $reg_config = $this->config->registration; |
|
127 | - $reg_config->setConsentCheckboxEnabled($valid_data['enable'] === 'enable-privacy-consent'); |
|
128 | - $reg_config->setConsentCheckboxLabelText( |
|
129 | - $valid_data['enable-privacy-consent']['consent_assertion'] |
|
130 | - ); |
|
131 | - return $this->config->update_espresso_config(false, false); |
|
132 | - } catch (InvalidFormSubmissionException $e) { |
|
133 | - // the form was invalid, it should be re-displayed with errors |
|
134 | - return false; |
|
135 | - } |
|
136 | - } |
|
116 | + /** |
|
117 | + * After validating the form data, update the registration config |
|
118 | + * |
|
119 | + * @param array $submitted_form_data |
|
120 | + * @return bool |
|
121 | + */ |
|
122 | + public function process($submitted_form_data = array()) |
|
123 | + { |
|
124 | + try { |
|
125 | + $valid_data = parent::process($submitted_form_data); |
|
126 | + $reg_config = $this->config->registration; |
|
127 | + $reg_config->setConsentCheckboxEnabled($valid_data['enable'] === 'enable-privacy-consent'); |
|
128 | + $reg_config->setConsentCheckboxLabelText( |
|
129 | + $valid_data['enable-privacy-consent']['consent_assertion'] |
|
130 | + ); |
|
131 | + return $this->config->update_espresso_config(false, false); |
|
132 | + } catch (InvalidFormSubmissionException $e) { |
|
133 | + // the form was invalid, it should be re-displayed with errors |
|
134 | + return false; |
|
135 | + } |
|
136 | + } |
|
137 | 137 | } |
138 | 138 | // End of file PrivacySettingsFormHandler.php |
139 | 139 | // Location: EventEspresso\core\domain\services\admin\privacy\forms/PrivacySettingsFormHandler.php |