@@ -6,30 +6,30 @@ |
||
6 | 6 | |
7 | 7 | class Partial |
8 | 8 | { |
9 | - /** |
|
10 | - * @param string $partialPath |
|
11 | - * @return string |
|
12 | - */ |
|
13 | - public function build($partialPath, array $args = []) |
|
14 | - { |
|
15 | - $className = Helper::buildClassName($partialPath, 'Modules\Html\Partials'); |
|
16 | - if (!class_exists($className)) { |
|
17 | - glsr_log()->error('Partial missing: '.$className); |
|
18 | - return; |
|
19 | - } |
|
20 | - $args = apply_filters('site-reviews/partial/args/'.$partialPath, $args); |
|
21 | - $partial = glsr($className)->build($args); |
|
22 | - $partial = apply_filters('site-reviews/rendered/partial', $partial, $partialPath, $args); |
|
23 | - $partial = apply_filters('site-reviews/rendered/partial/'.$partialPath, $partial, $args); |
|
24 | - return $partial; |
|
25 | - } |
|
9 | + /** |
|
10 | + * @param string $partialPath |
|
11 | + * @return string |
|
12 | + */ |
|
13 | + public function build($partialPath, array $args = []) |
|
14 | + { |
|
15 | + $className = Helper::buildClassName($partialPath, 'Modules\Html\Partials'); |
|
16 | + if (!class_exists($className)) { |
|
17 | + glsr_log()->error('Partial missing: '.$className); |
|
18 | + return; |
|
19 | + } |
|
20 | + $args = apply_filters('site-reviews/partial/args/'.$partialPath, $args); |
|
21 | + $partial = glsr($className)->build($args); |
|
22 | + $partial = apply_filters('site-reviews/rendered/partial', $partial, $partialPath, $args); |
|
23 | + $partial = apply_filters('site-reviews/rendered/partial/'.$partialPath, $partial, $args); |
|
24 | + return $partial; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @param string $partialPath |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function render($partialPath, array $args = []) |
|
32 | - { |
|
33 | - echo $this->build($partialPath, $args); |
|
34 | - } |
|
27 | + /** |
|
28 | + * @param string $partialPath |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function render($partialPath, array $args = []) |
|
32 | + { |
|
33 | + echo $this->build($partialPath, $args); |
|
34 | + } |
|
35 | 35 | } |
@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | * @param string $partialPath |
11 | 11 | * @return string |
12 | 12 | */ |
13 | - public function build($partialPath, array $args = []) |
|
13 | + public function build( $partialPath, array $args = [] ) |
|
14 | 14 | { |
15 | - $className = Helper::buildClassName($partialPath, 'Modules\Html\Partials'); |
|
16 | - if (!class_exists($className)) { |
|
17 | - glsr_log()->error('Partial missing: '.$className); |
|
15 | + $className = Helper::buildClassName( $partialPath, 'Modules\Html\Partials' ); |
|
16 | + if( !class_exists( $className ) ) { |
|
17 | + glsr_log()->error( 'Partial missing: '.$className ); |
|
18 | 18 | return; |
19 | 19 | } |
20 | - $args = apply_filters('site-reviews/partial/args/'.$partialPath, $args); |
|
21 | - $partial = glsr($className)->build($args); |
|
22 | - $partial = apply_filters('site-reviews/rendered/partial', $partial, $partialPath, $args); |
|
23 | - $partial = apply_filters('site-reviews/rendered/partial/'.$partialPath, $partial, $args); |
|
20 | + $args = apply_filters( 'site-reviews/partial/args/'.$partialPath, $args ); |
|
21 | + $partial = glsr( $className )->build( $args ); |
|
22 | + $partial = apply_filters( 'site-reviews/rendered/partial', $partial, $partialPath, $args ); |
|
23 | + $partial = apply_filters( 'site-reviews/rendered/partial/'.$partialPath, $partial, $args ); |
|
24 | 24 | return $partial; |
25 | 25 | } |
26 | 26 | |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | * @param string $partialPath |
29 | 29 | * @return void |
30 | 30 | */ |
31 | - public function render($partialPath, array $args = []) |
|
31 | + public function render( $partialPath, array $args = [] ) |
|
32 | 32 | { |
33 | - echo $this->build($partialPath, $args); |
|
33 | + echo $this->build( $partialPath, $args ); |
|
34 | 34 | } |
35 | 35 | } |
@@ -9,67 +9,67 @@ |
||
9 | 9 | |
10 | 10 | class Upgrade_4_0_2 |
11 | 11 | { |
12 | - public function __construct() |
|
13 | - { |
|
14 | - $this->migrateSettings(); |
|
15 | - $this->protectMetaKeys(); |
|
16 | - $this->deleteSessions(); |
|
17 | - delete_transient(Application::ID.'_cloudflare_ips'); |
|
18 | - } |
|
12 | + public function __construct() |
|
13 | + { |
|
14 | + $this->migrateSettings(); |
|
15 | + $this->protectMetaKeys(); |
|
16 | + $this->deleteSessions(); |
|
17 | + delete_transient(Application::ID.'_cloudflare_ips'); |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function deleteSessions() |
|
24 | - { |
|
25 | - global $wpdb; |
|
26 | - $wpdb->query(" |
|
20 | + /** |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function deleteSessions() |
|
24 | + { |
|
25 | + global $wpdb; |
|
26 | + $wpdb->query(" |
|
27 | 27 | DELETE |
28 | 28 | FROM {$wpdb->options} |
29 | 29 | WHERE option_name LIKE '_glsr_session%' |
30 | 30 | "); |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function migrateSettings() |
|
37 | - { |
|
38 | - if ($settings = get_option(OptionManager::databaseKey(3))) { |
|
39 | - $multilingual = 'yes' == Arr::get($settings, 'settings.general.support.polylang') |
|
40 | - ? 'polylang' |
|
41 | - : ''; |
|
42 | - $settings = Arr::set($settings, 'settings.general.multilingual', $multilingual); |
|
43 | - $settings = Arr::set($settings, 'settings.general.rebusify', 'no'); |
|
44 | - $settings = Arr::set($settings, 'settings.general.rebusify_email', ''); |
|
45 | - $settings = Arr::set($settings, 'settings.general.rebusify_serial', ''); |
|
46 | - $settings = Arr::set($settings, 'settings.reviews.name.format', ''); |
|
47 | - $settings = Arr::set($settings, 'settings.reviews.name.initial', ''); |
|
48 | - $settings = Arr::set($settings, 'settings.submissions.blacklist.integration', ''); |
|
49 | - $settings = Arr::set($settings, 'settings.submissions.limit', ''); |
|
50 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.email', ''); |
|
51 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.ip_address', ''); |
|
52 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.username', ''); |
|
53 | - unset($settings['settings']['general']['support']); |
|
54 | - update_option(OptionManager::databaseKey(4), $settings); |
|
55 | - } |
|
56 | - } |
|
33 | + /** |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function migrateSettings() |
|
37 | + { |
|
38 | + if ($settings = get_option(OptionManager::databaseKey(3))) { |
|
39 | + $multilingual = 'yes' == Arr::get($settings, 'settings.general.support.polylang') |
|
40 | + ? 'polylang' |
|
41 | + : ''; |
|
42 | + $settings = Arr::set($settings, 'settings.general.multilingual', $multilingual); |
|
43 | + $settings = Arr::set($settings, 'settings.general.rebusify', 'no'); |
|
44 | + $settings = Arr::set($settings, 'settings.general.rebusify_email', ''); |
|
45 | + $settings = Arr::set($settings, 'settings.general.rebusify_serial', ''); |
|
46 | + $settings = Arr::set($settings, 'settings.reviews.name.format', ''); |
|
47 | + $settings = Arr::set($settings, 'settings.reviews.name.initial', ''); |
|
48 | + $settings = Arr::set($settings, 'settings.submissions.blacklist.integration', ''); |
|
49 | + $settings = Arr::set($settings, 'settings.submissions.limit', ''); |
|
50 | + $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.email', ''); |
|
51 | + $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.ip_address', ''); |
|
52 | + $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.username', ''); |
|
53 | + unset($settings['settings']['general']['support']); |
|
54 | + update_option(OptionManager::databaseKey(4), $settings); |
|
55 | + } |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - public function protectMetaKeys() |
|
62 | - { |
|
63 | - global $wpdb; |
|
64 | - $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults()); |
|
65 | - $keys = implode("','", $keys); |
|
66 | - $postType = Application::POST_TYPE; |
|
67 | - $wpdb->query(" |
|
58 | + /** |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + public function protectMetaKeys() |
|
62 | + { |
|
63 | + global $wpdb; |
|
64 | + $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults()); |
|
65 | + $keys = implode("','", $keys); |
|
66 | + $postType = Application::POST_TYPE; |
|
67 | + $wpdb->query(" |
|
68 | 68 | UPDATE {$wpdb->postmeta} pm |
69 | 69 | INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id |
70 | 70 | SET pm.meta_key = CONCAT('_', pm.meta_key) |
71 | 71 | WHERE pm.meta_key IN ('{$keys}') |
72 | 72 | AND p.post_type = '{$postType}' |
73 | 73 | "); |
74 | - } |
|
74 | + } |
|
75 | 75 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $this->migrateSettings(); |
15 | 15 | $this->protectMetaKeys(); |
16 | 16 | $this->deleteSessions(); |
17 | - delete_transient(Application::ID.'_cloudflare_ips'); |
|
17 | + delete_transient( Application::ID.'_cloudflare_ips' ); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | public function deleteSessions() |
24 | 24 | { |
25 | 25 | global $wpdb; |
26 | - $wpdb->query(" |
|
26 | + $wpdb->query( " |
|
27 | 27 | DELETE |
28 | 28 | FROM {$wpdb->options} |
29 | 29 | WHERE option_name LIKE '_glsr_session%' |
30 | - "); |
|
30 | + " ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -35,23 +35,23 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function migrateSettings() |
37 | 37 | { |
38 | - if ($settings = get_option(OptionManager::databaseKey(3))) { |
|
39 | - $multilingual = 'yes' == Arr::get($settings, 'settings.general.support.polylang') |
|
38 | + if( $settings = get_option( OptionManager::databaseKey( 3 ) ) ) { |
|
39 | + $multilingual = 'yes' == Arr::get( $settings, 'settings.general.support.polylang' ) |
|
40 | 40 | ? 'polylang' |
41 | 41 | : ''; |
42 | - $settings = Arr::set($settings, 'settings.general.multilingual', $multilingual); |
|
43 | - $settings = Arr::set($settings, 'settings.general.rebusify', 'no'); |
|
44 | - $settings = Arr::set($settings, 'settings.general.rebusify_email', ''); |
|
45 | - $settings = Arr::set($settings, 'settings.general.rebusify_serial', ''); |
|
46 | - $settings = Arr::set($settings, 'settings.reviews.name.format', ''); |
|
47 | - $settings = Arr::set($settings, 'settings.reviews.name.initial', ''); |
|
48 | - $settings = Arr::set($settings, 'settings.submissions.blacklist.integration', ''); |
|
49 | - $settings = Arr::set($settings, 'settings.submissions.limit', ''); |
|
50 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.email', ''); |
|
51 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.ip_address', ''); |
|
52 | - $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.username', ''); |
|
42 | + $settings = Arr::set( $settings, 'settings.general.multilingual', $multilingual ); |
|
43 | + $settings = Arr::set( $settings, 'settings.general.rebusify', 'no' ); |
|
44 | + $settings = Arr::set( $settings, 'settings.general.rebusify_email', '' ); |
|
45 | + $settings = Arr::set( $settings, 'settings.general.rebusify_serial', '' ); |
|
46 | + $settings = Arr::set( $settings, 'settings.reviews.name.format', '' ); |
|
47 | + $settings = Arr::set( $settings, 'settings.reviews.name.initial', '' ); |
|
48 | + $settings = Arr::set( $settings, 'settings.submissions.blacklist.integration', '' ); |
|
49 | + $settings = Arr::set( $settings, 'settings.submissions.limit', '' ); |
|
50 | + $settings = Arr::set( $settings, 'settings.submissions.limit_whitelist.email', '' ); |
|
51 | + $settings = Arr::set( $settings, 'settings.submissions.limit_whitelist.ip_address', '' ); |
|
52 | + $settings = Arr::set( $settings, 'settings.submissions.limit_whitelist.username', '' ); |
|
53 | 53 | unset($settings['settings']['general']['support']); |
54 | - update_option(OptionManager::databaseKey(4), $settings); |
|
54 | + update_option( OptionManager::databaseKey( 4 ), $settings ); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | public function protectMetaKeys() |
62 | 62 | { |
63 | 63 | global $wpdb; |
64 | - $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults()); |
|
65 | - $keys = implode("','", $keys); |
|
64 | + $keys = array_keys( glsr( CreateReviewDefaults::class )->defaults() ); |
|
65 | + $keys = implode( "','", $keys ); |
|
66 | 66 | $postType = Application::POST_TYPE; |
67 | - $wpdb->query(" |
|
67 | + $wpdb->query( " |
|
68 | 68 | UPDATE {$wpdb->postmeta} pm |
69 | 69 | INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id |
70 | 70 | SET pm.meta_key = CONCAT('_', pm.meta_key) |
71 | 71 | WHERE pm.meta_key IN ('{$keys}') |
72 | 72 | AND p.post_type = '{$postType}' |
73 | - "); |
|
73 | + " ); |
|
74 | 74 | } |
75 | 75 | } |
@@ -7,33 +7,33 @@ |
||
7 | 7 | |
8 | 8 | class Metaboxes |
9 | 9 | { |
10 | - /** |
|
11 | - * @param int $postId |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function saveAssignedToMetabox($postId) |
|
15 | - { |
|
16 | - if (!wp_verify_nonce(Helper::filterInput('_nonce-assigned-to'), 'assigned_to')) { |
|
17 | - return; |
|
18 | - } |
|
19 | - $assignedTo = strval(Helper::filterInput('assigned_to')); |
|
20 | - glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
21 | - } |
|
10 | + /** |
|
11 | + * @param int $postId |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function saveAssignedToMetabox($postId) |
|
15 | + { |
|
16 | + if (!wp_verify_nonce(Helper::filterInput('_nonce-assigned-to'), 'assigned_to')) { |
|
17 | + return; |
|
18 | + } |
|
19 | + $assignedTo = strval(Helper::filterInput('assigned_to')); |
|
20 | + glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @param int $postId |
|
25 | - * @return mixed |
|
26 | - */ |
|
27 | - public function saveResponseMetabox($postId) |
|
28 | - { |
|
29 | - if (!wp_verify_nonce(Helper::filterInput('_nonce-response'), 'response')) { |
|
30 | - return; |
|
31 | - } |
|
32 | - $response = strval(Helper::filterInput('response')); |
|
33 | - glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [ |
|
34 | - 'a' => ['href' => [], 'title' => []], |
|
35 | - 'em' => [], |
|
36 | - 'strong' => [], |
|
37 | - ]))); |
|
38 | - } |
|
23 | + /** |
|
24 | + * @param int $postId |
|
25 | + * @return mixed |
|
26 | + */ |
|
27 | + public function saveResponseMetabox($postId) |
|
28 | + { |
|
29 | + if (!wp_verify_nonce(Helper::filterInput('_nonce-response'), 'response')) { |
|
30 | + return; |
|
31 | + } |
|
32 | + $response = strval(Helper::filterInput('response')); |
|
33 | + glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [ |
|
34 | + 'a' => ['href' => [], 'title' => []], |
|
35 | + 'em' => [], |
|
36 | + 'strong' => [], |
|
37 | + ]))); |
|
38 | + } |
|
39 | 39 | } |
@@ -11,29 +11,29 @@ |
||
11 | 11 | * @param int $postId |
12 | 12 | * @return void |
13 | 13 | */ |
14 | - public function saveAssignedToMetabox($postId) |
|
14 | + public function saveAssignedToMetabox( $postId ) |
|
15 | 15 | { |
16 | - if (!wp_verify_nonce(Helper::filterInput('_nonce-assigned-to'), 'assigned_to')) { |
|
16 | + if( !wp_verify_nonce( Helper::filterInput( '_nonce-assigned-to' ), 'assigned_to' ) ) { |
|
17 | 17 | return; |
18 | 18 | } |
19 | - $assignedTo = strval(Helper::filterInput('assigned_to')); |
|
20 | - glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
19 | + $assignedTo = strval( Helper::filterInput( 'assigned_to' ) ); |
|
20 | + glsr( Database::class )->update( $postId, 'assigned_to', $assignedTo ); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @param int $postId |
25 | 25 | * @return mixed |
26 | 26 | */ |
27 | - public function saveResponseMetabox($postId) |
|
27 | + public function saveResponseMetabox( $postId ) |
|
28 | 28 | { |
29 | - if (!wp_verify_nonce(Helper::filterInput('_nonce-response'), 'response')) { |
|
29 | + if( !wp_verify_nonce( Helper::filterInput( '_nonce-response' ), 'response' ) ) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | - $response = strval(Helper::filterInput('response')); |
|
33 | - glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [ |
|
32 | + $response = strval( Helper::filterInput( 'response' ) ); |
|
33 | + glsr( Database::class )->update( $postId, 'response', trim( wp_kses( $response, [ |
|
34 | 34 | 'a' => ['href' => [], 'title' => []], |
35 | 35 | 'em' => [], |
36 | 36 | 'strong' => [], |
37 | - ]))); |
|
37 | + ] ) ) ); |
|
38 | 38 | } |
39 | 39 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | * @return array |
14 | 14 | * @filter block_categories |
15 | 15 | */ |
16 | - public function filterBlockCategories($categories) |
|
16 | + public function filterBlockCategories( $categories ) |
|
17 | 17 | { |
18 | - $categories = Arr::consolidateArray($categories); |
|
18 | + $categories = Arr::consolidateArray( $categories ); |
|
19 | 19 | $categories[] = [ |
20 | 20 | 'icon' => null, |
21 | 21 | 'slug' => Application::ID, |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @filter classic_editor_enabled_editors_for_post_type |
32 | 32 | * @plugin classic-editor/classic-editor.php |
33 | 33 | */ |
34 | - public function filterEnabledEditors($editors, $postType) |
|
34 | + public function filterEnabledEditors( $editors, $postType ) |
|
35 | 35 | { |
36 | 36 | return Application::POST_TYPE == $postType |
37 | 37 | ? ['block_editor' => false, 'classic_editor' => false] |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return bool |
45 | 45 | * @filter use_block_editor_for_post_type |
46 | 46 | */ |
47 | - public function filterUseBlockEditor($bool, $postType) |
|
47 | + public function filterUseBlockEditor( $bool, $postType ) |
|
48 | 48 | { |
49 | 49 | return Application::POST_TYPE == $postType |
50 | 50 | ? false |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | { |
59 | 59 | wp_register_style( |
60 | 60 | Application::ID.'/blocks', |
61 | - glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
61 | + glsr()->url( 'assets/styles/'.Application::ID.'-blocks.css' ), |
|
62 | 62 | ['wp-edit-blocks'], |
63 | 63 | glsr()->version |
64 | 64 | ); |
65 | 65 | wp_register_script( |
66 | 66 | Application::ID.'/blocks', |
67 | - glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
67 | + glsr()->url( 'assets/scripts/'.Application::ID.'-blocks.js' ), |
|
68 | 68 | ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID], |
69 | 69 | glsr()->version |
70 | 70 | ); |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | $blocks = [ |
80 | 80 | 'form', 'reviews', 'summary', |
81 | 81 | ]; |
82 | - foreach ($blocks as $block) { |
|
83 | - $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
84 | - $blockClass = Helper::buildClassName($id.'-block', 'Blocks'); |
|
85 | - if (!class_exists($blockClass)) { |
|
86 | - glsr_log()->error(sprintf('Class missing (%s)', $blockClass)); |
|
82 | + foreach( $blocks as $block ) { |
|
83 | + $id = str_replace( '_reviews', '', Application::ID.'_'.$block ); |
|
84 | + $blockClass = Helper::buildClassName( $id.'-block', 'Blocks' ); |
|
85 | + if( !class_exists( $blockClass ) ) { |
|
86 | + glsr_log()->error( sprintf( 'Class missing (%s)', $blockClass ) ); |
|
87 | 87 | continue; |
88 | 88 | } |
89 | - glsr($blockClass)->register($block); |
|
89 | + glsr( $blockClass )->register( $block ); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
@@ -8,86 +8,86 @@ |
||
8 | 8 | |
9 | 9 | class BlocksController extends Controller |
10 | 10 | { |
11 | - /** |
|
12 | - * @param array $categories |
|
13 | - * @return array |
|
14 | - * @filter block_categories |
|
15 | - */ |
|
16 | - public function filterBlockCategories($categories) |
|
17 | - { |
|
18 | - $categories = Arr::consolidateArray($categories); |
|
19 | - $categories[] = [ |
|
20 | - 'icon' => null, |
|
21 | - 'slug' => Application::ID, |
|
22 | - 'title' => glsr()->name, |
|
23 | - ]; |
|
24 | - return $categories; |
|
25 | - } |
|
11 | + /** |
|
12 | + * @param array $categories |
|
13 | + * @return array |
|
14 | + * @filter block_categories |
|
15 | + */ |
|
16 | + public function filterBlockCategories($categories) |
|
17 | + { |
|
18 | + $categories = Arr::consolidateArray($categories); |
|
19 | + $categories[] = [ |
|
20 | + 'icon' => null, |
|
21 | + 'slug' => Application::ID, |
|
22 | + 'title' => glsr()->name, |
|
23 | + ]; |
|
24 | + return $categories; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @param array $editors |
|
29 | - * @param string $postType |
|
30 | - * @return array |
|
31 | - * @filter classic_editor_enabled_editors_for_post_type |
|
32 | - * @plugin classic-editor/classic-editor.php |
|
33 | - */ |
|
34 | - public function filterEnabledEditors($editors, $postType) |
|
35 | - { |
|
36 | - return Application::POST_TYPE == $postType |
|
37 | - ? ['block_editor' => false, 'classic_editor' => false] |
|
38 | - : $editors; |
|
39 | - } |
|
27 | + /** |
|
28 | + * @param array $editors |
|
29 | + * @param string $postType |
|
30 | + * @return array |
|
31 | + * @filter classic_editor_enabled_editors_for_post_type |
|
32 | + * @plugin classic-editor/classic-editor.php |
|
33 | + */ |
|
34 | + public function filterEnabledEditors($editors, $postType) |
|
35 | + { |
|
36 | + return Application::POST_TYPE == $postType |
|
37 | + ? ['block_editor' => false, 'classic_editor' => false] |
|
38 | + : $editors; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param bool $bool |
|
43 | - * @param string $postType |
|
44 | - * @return bool |
|
45 | - * @filter use_block_editor_for_post_type |
|
46 | - */ |
|
47 | - public function filterUseBlockEditor($bool, $postType) |
|
48 | - { |
|
49 | - return Application::POST_TYPE == $postType |
|
50 | - ? false |
|
51 | - : $bool; |
|
52 | - } |
|
41 | + /** |
|
42 | + * @param bool $bool |
|
43 | + * @param string $postType |
|
44 | + * @return bool |
|
45 | + * @filter use_block_editor_for_post_type |
|
46 | + */ |
|
47 | + public function filterUseBlockEditor($bool, $postType) |
|
48 | + { |
|
49 | + return Application::POST_TYPE == $postType |
|
50 | + ? false |
|
51 | + : $bool; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return void |
|
56 | - * @action init |
|
57 | - */ |
|
58 | - public function registerAssets() |
|
59 | - { |
|
60 | - wp_register_style( |
|
61 | - Application::ID.'/blocks', |
|
62 | - glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
63 | - ['wp-edit-blocks'], |
|
64 | - glsr()->version |
|
65 | - ); |
|
66 | - wp_register_script( |
|
67 | - Application::ID.'/blocks', |
|
68 | - glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
69 | - ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID], |
|
70 | - glsr()->version |
|
71 | - ); |
|
72 | - } |
|
54 | + /** |
|
55 | + * @return void |
|
56 | + * @action init |
|
57 | + */ |
|
58 | + public function registerAssets() |
|
59 | + { |
|
60 | + wp_register_style( |
|
61 | + Application::ID.'/blocks', |
|
62 | + glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
63 | + ['wp-edit-blocks'], |
|
64 | + glsr()->version |
|
65 | + ); |
|
66 | + wp_register_script( |
|
67 | + Application::ID.'/blocks', |
|
68 | + glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
69 | + ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID], |
|
70 | + glsr()->version |
|
71 | + ); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return void |
|
76 | - * @action init |
|
77 | - */ |
|
78 | - public function registerBlocks() |
|
79 | - { |
|
80 | - $blocks = [ |
|
81 | - 'form', 'reviews', 'summary', |
|
82 | - ]; |
|
83 | - foreach ($blocks as $block) { |
|
84 | - $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
85 | - $blockClass = Helper::buildClassName($id.'-block', 'Blocks'); |
|
86 | - if (!class_exists($blockClass)) { |
|
87 | - glsr_log()->error(sprintf('Class missing (%s)', $blockClass)); |
|
88 | - continue; |
|
89 | - } |
|
90 | - glsr($blockClass)->register($block); |
|
91 | - } |
|
92 | - } |
|
74 | + /** |
|
75 | + * @return void |
|
76 | + * @action init |
|
77 | + */ |
|
78 | + public function registerBlocks() |
|
79 | + { |
|
80 | + $blocks = [ |
|
81 | + 'form', 'reviews', 'summary', |
|
82 | + ]; |
|
83 | + foreach ($blocks as $block) { |
|
84 | + $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
85 | + $blockClass = Helper::buildClassName($id.'-block', 'Blocks'); |
|
86 | + if (!class_exists($blockClass)) { |
|
87 | + glsr_log()->error(sprintf('Class missing (%s)', $blockClass)); |
|
88 | + continue; |
|
89 | + } |
|
90 | + glsr($blockClass)->register($block); |
|
91 | + } |
|
92 | + } |
|
93 | 93 | } |
@@ -7,18 +7,18 @@ |
||
7 | 7 | |
8 | 8 | class RegisterShortcodes |
9 | 9 | { |
10 | - /** |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function handle(Command $command) |
|
14 | - { |
|
15 | - foreach ($command->shortcodes as $shortcode) { |
|
16 | - $shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes'); |
|
17 | - if (!class_exists($shortcodeClass)) { |
|
18 | - glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass)); |
|
19 | - continue; |
|
20 | - } |
|
21 | - add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']); |
|
22 | - } |
|
23 | - } |
|
10 | + /** |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function handle(Command $command) |
|
14 | + { |
|
15 | + foreach ($command->shortcodes as $shortcode) { |
|
16 | + $shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes'); |
|
17 | + if (!class_exists($shortcodeClass)) { |
|
18 | + glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass)); |
|
19 | + continue; |
|
20 | + } |
|
21 | + add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']); |
|
22 | + } |
|
23 | + } |
|
24 | 24 | } |
@@ -10,15 +10,15 @@ |
||
10 | 10 | /** |
11 | 11 | * @return void |
12 | 12 | */ |
13 | - public function handle(Command $command) |
|
13 | + public function handle( Command $command ) |
|
14 | 14 | { |
15 | - foreach ($command->shortcodes as $shortcode) { |
|
16 | - $shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes'); |
|
17 | - if (!class_exists($shortcodeClass)) { |
|
18 | - glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass)); |
|
15 | + foreach( $command->shortcodes as $shortcode ) { |
|
16 | + $shortcodeClass = Helper::buildClassName( $shortcode.'-shortcode', 'Shortcodes' ); |
|
17 | + if( !class_exists( $shortcodeClass ) ) { |
|
18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass ) ); |
|
19 | 19 | continue; |
20 | 20 | } |
21 | - add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']); |
|
21 | + add_shortcode( $shortcode, [glsr( $shortcodeClass ), 'buildShortcode'] ); |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | } |
@@ -7,22 +7,22 @@ |
||
7 | 7 | |
8 | 8 | class RegisterTinymcePopups |
9 | 9 | { |
10 | - /** |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function handle(Command $command) |
|
14 | - { |
|
15 | - foreach ($command->popups as $slug => $label) { |
|
16 | - $buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes'); |
|
17 | - if (!class_exists($buttonClass)) { |
|
18 | - glsr_log()->error(sprintf('Class missing (%s)', $buttonClass)); |
|
19 | - continue; |
|
20 | - } |
|
21 | - $shortcode = glsr($buttonClass)->register($slug, [ |
|
22 | - 'label' => $label, |
|
23 | - 'title' => $label, |
|
24 | - ]); |
|
25 | - glsr()->mceShortcodes[$slug] = $shortcode->properties; |
|
26 | - } |
|
27 | - } |
|
10 | + /** |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function handle(Command $command) |
|
14 | + { |
|
15 | + foreach ($command->popups as $slug => $label) { |
|
16 | + $buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes'); |
|
17 | + if (!class_exists($buttonClass)) { |
|
18 | + glsr_log()->error(sprintf('Class missing (%s)', $buttonClass)); |
|
19 | + continue; |
|
20 | + } |
|
21 | + $shortcode = glsr($buttonClass)->register($slug, [ |
|
22 | + 'label' => $label, |
|
23 | + 'title' => $label, |
|
24 | + ]); |
|
25 | + glsr()->mceShortcodes[$slug] = $shortcode->properties; |
|
26 | + } |
|
27 | + } |
|
28 | 28 | } |
@@ -10,18 +10,18 @@ |
||
10 | 10 | /** |
11 | 11 | * @return void |
12 | 12 | */ |
13 | - public function handle(Command $command) |
|
13 | + public function handle( Command $command ) |
|
14 | 14 | { |
15 | - foreach ($command->popups as $slug => $label) { |
|
16 | - $buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes'); |
|
17 | - if (!class_exists($buttonClass)) { |
|
18 | - glsr_log()->error(sprintf('Class missing (%s)', $buttonClass)); |
|
15 | + foreach( $command->popups as $slug => $label ) { |
|
16 | + $buttonClass = Helper::buildClassName( $slug.'-popup', 'Shortcodes' ); |
|
17 | + if( !class_exists( $buttonClass ) ) { |
|
18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ) ); |
|
19 | 19 | continue; |
20 | 20 | } |
21 | - $shortcode = glsr($buttonClass)->register($slug, [ |
|
21 | + $shortcode = glsr( $buttonClass )->register( $slug, [ |
|
22 | 22 | 'label' => $label, |
23 | 23 | 'title' => $label, |
24 | - ]); |
|
24 | + ] ); |
|
25 | 25 | glsr()->mceShortcodes[$slug] = $shortcode->properties; |
26 | 26 | } |
27 | 27 | } |
@@ -8,21 +8,21 @@ |
||
8 | 8 | |
9 | 9 | class RegisterWidgets |
10 | 10 | { |
11 | - /** |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function handle(Command $command) |
|
15 | - { |
|
16 | - global $wp_widget_factory; |
|
17 | - foreach ($command->widgets as $key => $values) { |
|
18 | - $widgetClass = Helper::buildClassName($key.'-widget', 'Widgets'); |
|
19 | - if (!class_exists($widgetClass)) { |
|
20 | - glsr_log()->error(sprintf('Class missing (%s)', $widgetClass)); |
|
21 | - continue; |
|
22 | - } |
|
23 | - // Here we bypass register_widget() in order to pass our custom values to the widget |
|
24 | - $widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values); |
|
25 | - $wp_widget_factory->widgets[$widgetClass] = $widget; |
|
26 | - } |
|
27 | - } |
|
11 | + /** |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function handle(Command $command) |
|
15 | + { |
|
16 | + global $wp_widget_factory; |
|
17 | + foreach ($command->widgets as $key => $values) { |
|
18 | + $widgetClass = Helper::buildClassName($key.'-widget', 'Widgets'); |
|
19 | + if (!class_exists($widgetClass)) { |
|
20 | + glsr_log()->error(sprintf('Class missing (%s)', $widgetClass)); |
|
21 | + continue; |
|
22 | + } |
|
23 | + // Here we bypass register_widget() in order to pass our custom values to the widget |
|
24 | + $widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values); |
|
25 | + $wp_widget_factory->widgets[$widgetClass] = $widget; |
|
26 | + } |
|
27 | + } |
|
28 | 28 | } |
@@ -11,17 +11,17 @@ |
||
11 | 11 | /** |
12 | 12 | * @return void |
13 | 13 | */ |
14 | - public function handle(Command $command) |
|
14 | + public function handle( Command $command ) |
|
15 | 15 | { |
16 | 16 | global $wp_widget_factory; |
17 | - foreach ($command->widgets as $key => $values) { |
|
18 | - $widgetClass = Helper::buildClassName($key.'-widget', 'Widgets'); |
|
19 | - if (!class_exists($widgetClass)) { |
|
20 | - glsr_log()->error(sprintf('Class missing (%s)', $widgetClass)); |
|
17 | + foreach( $command->widgets as $key => $values ) { |
|
18 | + $widgetClass = Helper::buildClassName( $key.'-widget', 'Widgets' ); |
|
19 | + if( !class_exists( $widgetClass ) ) { |
|
20 | + glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass ) ); |
|
21 | 21 | continue; |
22 | 22 | } |
23 | 23 | // Here we bypass register_widget() in order to pass our custom values to the widget |
24 | - $widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values); |
|
24 | + $widget = new $widgetClass( Application::ID.'_'.$key, $values['title'], $values ); |
|
25 | 25 | $wp_widget_factory->widgets[$widgetClass] = $widget; |
26 | 26 | } |
27 | 27 | } |
@@ -6,60 +6,60 @@ |
||
6 | 6 | |
7 | 7 | class DefaultsManager |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function defaults() |
|
13 | - { |
|
14 | - $settings = $this->settings(); |
|
15 | - $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | - return wp_parse_args($defaults, [ |
|
17 | - 'version' => '', |
|
18 | - 'version_upgraded_from' => '', |
|
19 | - ]); |
|
20 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function defaults() |
|
13 | + { |
|
14 | + $settings = $this->settings(); |
|
15 | + $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | + return wp_parse_args($defaults, [ |
|
17 | + 'version' => '', |
|
18 | + 'version_upgraded_from' => '', |
|
19 | + ]); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @return array |
|
24 | - */ |
|
25 | - public function get() |
|
26 | - { |
|
27 | - return Arr::convertDotNotationArray($this->defaults()); |
|
28 | - } |
|
22 | + /** |
|
23 | + * @return array |
|
24 | + */ |
|
25 | + public function get() |
|
26 | + { |
|
27 | + return Arr::convertDotNotationArray($this->defaults()); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function set() |
|
34 | - { |
|
35 | - $settings = glsr(OptionManager::class)->all(); |
|
36 | - $currentSettings = Arr::removeEmptyArrayValues($settings); |
|
37 | - $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | - $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | - update_option(OptionManager::databaseKey(), $updatedSettings); |
|
40 | - return $defaultSettings; |
|
41 | - } |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function set() |
|
34 | + { |
|
35 | + $settings = glsr(OptionManager::class)->all(); |
|
36 | + $currentSettings = Arr::removeEmptyArrayValues($settings); |
|
37 | + $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | + $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | + update_option(OptionManager::databaseKey(), $updatedSettings); |
|
40 | + return $defaultSettings; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - public function settings() |
|
47 | - { |
|
48 | - $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | - return $this->normalize($settings); |
|
50 | - } |
|
43 | + /** |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + public function settings() |
|
47 | + { |
|
48 | + $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | + return $this->normalize($settings); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - protected function normalize(array $settings) |
|
56 | - { |
|
57 | - array_walk($settings, function (&$setting) { |
|
58 | - if (isset($setting['default'])) { |
|
59 | - return; |
|
60 | - } |
|
61 | - $setting['default'] = ''; |
|
62 | - }); |
|
63 | - return $settings; |
|
64 | - } |
|
52 | + /** |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + protected function normalize(array $settings) |
|
56 | + { |
|
57 | + array_walk($settings, function (&$setting) { |
|
58 | + if (isset($setting['default'])) { |
|
59 | + return; |
|
60 | + } |
|
61 | + $setting['default'] = ''; |
|
62 | + }); |
|
63 | + return $settings; |
|
64 | + } |
|
65 | 65 | } |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | public function defaults() |
13 | 13 | { |
14 | 14 | $settings = $this->settings(); |
15 | - $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | - return wp_parse_args($defaults, [ |
|
15 | + $defaults = (array)array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' ) ); |
|
16 | + return wp_parse_args( $defaults, [ |
|
17 | 17 | 'version' => '', |
18 | 18 | 'version_upgraded_from' => '', |
19 | - ]); |
|
19 | + ] ); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function get() |
26 | 26 | { |
27 | - return Arr::convertDotNotationArray($this->defaults()); |
|
27 | + return Arr::convertDotNotationArray( $this->defaults() ); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function set() |
34 | 34 | { |
35 | - $settings = glsr(OptionManager::class)->all(); |
|
36 | - $currentSettings = Arr::removeEmptyArrayValues($settings); |
|
37 | - $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | - $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | - update_option(OptionManager::databaseKey(), $updatedSettings); |
|
35 | + $settings = glsr( OptionManager::class )->all(); |
|
36 | + $currentSettings = Arr::removeEmptyArrayValues( $settings ); |
|
37 | + $defaultSettings = array_replace_recursive( $this->get(), $currentSettings ); |
|
38 | + $updatedSettings = array_replace_recursive( $settings, $defaultSettings ); |
|
39 | + update_option( OptionManager::databaseKey(), $updatedSettings ); |
|
40 | 40 | return $defaultSettings; |
41 | 41 | } |
42 | 42 | |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function settings() |
47 | 47 | { |
48 | - $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | - return $this->normalize($settings); |
|
48 | + $settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' ) ); |
|
49 | + return $this->normalize( $settings ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @return array |
54 | 54 | */ |
55 | - protected function normalize(array $settings) |
|
55 | + protected function normalize( array $settings ) |
|
56 | 56 | { |
57 | - array_walk($settings, function (&$setting) { |
|
58 | - if (isset($setting['default'])) { |
|
57 | + array_walk( $settings, function( &$setting ) { |
|
58 | + if( isset($setting['default']) ) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | $setting['default'] = ''; |
@@ -9,153 +9,153 @@ |
||
9 | 9 | |
10 | 10 | class OptionManager |
11 | 11 | { |
12 | - /** |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - protected $options; |
|
12 | + /** |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + protected $options; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - public static function databaseKey($version = null) |
|
21 | - { |
|
22 | - if (null === $version) { |
|
23 | - $version = explode('.', glsr()->version); |
|
24 | - $version = array_shift($version); |
|
25 | - } |
|
26 | - return Str::snakeCase( |
|
27 | - Application::ID.'-v'.intval($version) |
|
28 | - ); |
|
29 | - } |
|
17 | + /** |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + public static function databaseKey($version = null) |
|
21 | + { |
|
22 | + if (null === $version) { |
|
23 | + $version = explode('.', glsr()->version); |
|
24 | + $version = array_shift($version); |
|
25 | + } |
|
26 | + return Str::snakeCase( |
|
27 | + Application::ID.'-v'.intval($version) |
|
28 | + ); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @return array |
|
33 | - */ |
|
34 | - public function all() |
|
35 | - { |
|
36 | - if (empty($this->options)) { |
|
37 | - $this->reset(); |
|
38 | - } |
|
39 | - return $this->options; |
|
40 | - } |
|
31 | + /** |
|
32 | + * @return array |
|
33 | + */ |
|
34 | + public function all() |
|
35 | + { |
|
36 | + if (empty($this->options)) { |
|
37 | + $this->reset(); |
|
38 | + } |
|
39 | + return $this->options; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param string $path |
|
44 | - * @return bool |
|
45 | - */ |
|
46 | - public function delete($path) |
|
47 | - { |
|
48 | - $keys = explode('.', $path); |
|
49 | - $last = array_pop($keys); |
|
50 | - $options = $this->all(); |
|
51 | - $pointer = &$options; |
|
52 | - foreach ($keys as $key) { |
|
53 | - if (!isset($pointer[$key]) || !is_array($pointer[$key])) { |
|
54 | - continue; |
|
55 | - } |
|
56 | - $pointer = &$pointer[$key]; |
|
57 | - } |
|
58 | - unset($pointer[$last]); |
|
59 | - return $this->set($options); |
|
60 | - } |
|
42 | + /** |
|
43 | + * @param string $path |
|
44 | + * @return bool |
|
45 | + */ |
|
46 | + public function delete($path) |
|
47 | + { |
|
48 | + $keys = explode('.', $path); |
|
49 | + $last = array_pop($keys); |
|
50 | + $options = $this->all(); |
|
51 | + $pointer = &$options; |
|
52 | + foreach ($keys as $key) { |
|
53 | + if (!isset($pointer[$key]) || !is_array($pointer[$key])) { |
|
54 | + continue; |
|
55 | + } |
|
56 | + $pointer = &$pointer[$key]; |
|
57 | + } |
|
58 | + unset($pointer[$last]); |
|
59 | + return $this->set($options); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param string $path |
|
64 | - * @param mixed $fallback |
|
65 | - * @param string $cast |
|
66 | - * @return mixed |
|
67 | - */ |
|
68 | - public function get($path = '', $fallback = '', $cast = '') |
|
69 | - { |
|
70 | - $result = Arr::get($this->all(), $path, $fallback); |
|
71 | - return Helper::castTo($cast, $result); |
|
72 | - } |
|
62 | + /** |
|
63 | + * @param string $path |
|
64 | + * @param mixed $fallback |
|
65 | + * @param string $cast |
|
66 | + * @return mixed |
|
67 | + */ |
|
68 | + public function get($path = '', $fallback = '', $cast = '') |
|
69 | + { |
|
70 | + $result = Arr::get($this->all(), $path, $fallback); |
|
71 | + return Helper::castTo($cast, $result); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param string $path |
|
76 | - * @return bool |
|
77 | - */ |
|
78 | - public function getBool($path) |
|
79 | - { |
|
80 | - return Helper::castTo('bool', $this->get($path)); |
|
81 | - } |
|
74 | + /** |
|
75 | + * @param string $path |
|
76 | + * @return bool |
|
77 | + */ |
|
78 | + public function getBool($path) |
|
79 | + { |
|
80 | + return Helper::castTo('bool', $this->get($path)); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @param string $path |
|
85 | - * @param mixed $fallback |
|
86 | - * @param string $cast |
|
87 | - * @return mixed |
|
88 | - */ |
|
89 | - public function getWP($path, $fallback = '', $cast = '') |
|
90 | - { |
|
91 | - $option = get_option($path, $fallback); |
|
92 | - if (empty($option)) { |
|
93 | - $option = $fallback; |
|
94 | - } |
|
95 | - return Helper::castTo($cast, $option); |
|
96 | - } |
|
83 | + /** |
|
84 | + * @param string $path |
|
85 | + * @param mixed $fallback |
|
86 | + * @param string $cast |
|
87 | + * @return mixed |
|
88 | + */ |
|
89 | + public function getWP($path, $fallback = '', $cast = '') |
|
90 | + { |
|
91 | + $option = get_option($path, $fallback); |
|
92 | + if (empty($option)) { |
|
93 | + $option = $fallback; |
|
94 | + } |
|
95 | + return Helper::castTo($cast, $option); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public function json() |
|
102 | - { |
|
103 | - return json_encode($this->all()); |
|
104 | - } |
|
98 | + /** |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public function json() |
|
102 | + { |
|
103 | + return json_encode($this->all()); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * @return array |
|
108 | - */ |
|
109 | - public function normalize(array $options = []) |
|
110 | - { |
|
111 | - $options = wp_parse_args( |
|
112 | - Arr::flattenArray($options), |
|
113 | - glsr(DefaultsManager::class)->defaults() |
|
114 | - ); |
|
115 | - array_walk($options, function (&$value) { |
|
116 | - if (!is_string($value)) { |
|
117 | - return; |
|
118 | - } |
|
119 | - $value = wp_kses($value, wp_kses_allowed_html('post')); |
|
120 | - }); |
|
121 | - return Arr::convertDotNotationArray($options); |
|
122 | - } |
|
106 | + /** |
|
107 | + * @return array |
|
108 | + */ |
|
109 | + public function normalize(array $options = []) |
|
110 | + { |
|
111 | + $options = wp_parse_args( |
|
112 | + Arr::flattenArray($options), |
|
113 | + glsr(DefaultsManager::class)->defaults() |
|
114 | + ); |
|
115 | + array_walk($options, function (&$value) { |
|
116 | + if (!is_string($value)) { |
|
117 | + return; |
|
118 | + } |
|
119 | + $value = wp_kses($value, wp_kses_allowed_html('post')); |
|
120 | + }); |
|
121 | + return Arr::convertDotNotationArray($options); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * @return bool |
|
126 | - */ |
|
127 | - public function isRecaptchaEnabled() |
|
128 | - { |
|
129 | - $integration = $this->get('settings.submissions.recaptcha.integration'); |
|
130 | - return 'all' == $integration || ('guest' == $integration && !is_user_logged_in()); |
|
131 | - } |
|
124 | + /** |
|
125 | + * @return bool |
|
126 | + */ |
|
127 | + public function isRecaptchaEnabled() |
|
128 | + { |
|
129 | + $integration = $this->get('settings.submissions.recaptcha.integration'); |
|
130 | + return 'all' == $integration || ('guest' == $integration && !is_user_logged_in()); |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * @return array |
|
135 | - */ |
|
136 | - public function reset() |
|
137 | - { |
|
138 | - $options = $this->getWP(static::databaseKey(), []); |
|
139 | - if (!is_array($options) || empty($options)) { |
|
140 | - delete_option(static::databaseKey()); |
|
141 | - $options = glsr()->defaults ?: []; |
|
142 | - } |
|
143 | - $this->options = $options; |
|
144 | - } |
|
133 | + /** |
|
134 | + * @return array |
|
135 | + */ |
|
136 | + public function reset() |
|
137 | + { |
|
138 | + $options = $this->getWP(static::databaseKey(), []); |
|
139 | + if (!is_array($options) || empty($options)) { |
|
140 | + delete_option(static::databaseKey()); |
|
141 | + $options = glsr()->defaults ?: []; |
|
142 | + } |
|
143 | + $this->options = $options; |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * @param string|array $pathOrOptions |
|
148 | - * @param mixed $value |
|
149 | - * @return bool |
|
150 | - */ |
|
151 | - public function set($pathOrOptions, $value = '') |
|
152 | - { |
|
153 | - if (is_string($pathOrOptions)) { |
|
154 | - $pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value); |
|
155 | - } |
|
156 | - if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) { |
|
157 | - $this->reset(); |
|
158 | - } |
|
159 | - return $result; |
|
160 | - } |
|
146 | + /** |
|
147 | + * @param string|array $pathOrOptions |
|
148 | + * @param mixed $value |
|
149 | + * @return bool |
|
150 | + */ |
|
151 | + public function set($pathOrOptions, $value = '') |
|
152 | + { |
|
153 | + if (is_string($pathOrOptions)) { |
|
154 | + $pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value); |
|
155 | + } |
|
156 | + if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) { |
|
157 | + $this->reset(); |
|
158 | + } |
|
159 | + return $result; |
|
160 | + } |
|
161 | 161 | } |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @return string |
19 | 19 | */ |
20 | - public static function databaseKey($version = null) |
|
20 | + public static function databaseKey( $version = null ) |
|
21 | 21 | { |
22 | - if (null === $version) { |
|
23 | - $version = explode('.', glsr()->version); |
|
24 | - $version = array_shift($version); |
|
22 | + if( null === $version ) { |
|
23 | + $version = explode( '.', glsr()->version ); |
|
24 | + $version = array_shift( $version ); |
|
25 | 25 | } |
26 | 26 | return Str::snakeCase( |
27 | - Application::ID.'-v'.intval($version) |
|
27 | + Application::ID.'-v'.intval( $version ) |
|
28 | 28 | ); |
29 | 29 | } |
30 | 30 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function all() |
35 | 35 | { |
36 | - if (empty($this->options)) { |
|
36 | + if( empty($this->options) ) { |
|
37 | 37 | $this->reset(); |
38 | 38 | } |
39 | 39 | return $this->options; |
@@ -43,20 +43,20 @@ discard block |
||
43 | 43 | * @param string $path |
44 | 44 | * @return bool |
45 | 45 | */ |
46 | - public function delete($path) |
|
46 | + public function delete( $path ) |
|
47 | 47 | { |
48 | - $keys = explode('.', $path); |
|
49 | - $last = array_pop($keys); |
|
48 | + $keys = explode( '.', $path ); |
|
49 | + $last = array_pop( $keys ); |
|
50 | 50 | $options = $this->all(); |
51 | 51 | $pointer = &$options; |
52 | - foreach ($keys as $key) { |
|
53 | - if (!isset($pointer[$key]) || !is_array($pointer[$key])) { |
|
52 | + foreach( $keys as $key ) { |
|
53 | + if( !isset($pointer[$key]) || !is_array( $pointer[$key] ) ) { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | $pointer = &$pointer[$key]; |
57 | 57 | } |
58 | 58 | unset($pointer[$last]); |
59 | - return $this->set($options); |
|
59 | + return $this->set( $options ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | * @param string $cast |
66 | 66 | * @return mixed |
67 | 67 | */ |
68 | - public function get($path = '', $fallback = '', $cast = '') |
|
68 | + public function get( $path = '', $fallback = '', $cast = '' ) |
|
69 | 69 | { |
70 | - $result = Arr::get($this->all(), $path, $fallback); |
|
71 | - return Helper::castTo($cast, $result); |
|
70 | + $result = Arr::get( $this->all(), $path, $fallback ); |
|
71 | + return Helper::castTo( $cast, $result ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @param string $path |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | - public function getBool($path) |
|
78 | + public function getBool( $path ) |
|
79 | 79 | { |
80 | - return Helper::castTo('bool', $this->get($path)); |
|
80 | + return Helper::castTo( 'bool', $this->get( $path ) ); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | * @param string $cast |
87 | 87 | * @return mixed |
88 | 88 | */ |
89 | - public function getWP($path, $fallback = '', $cast = '') |
|
89 | + public function getWP( $path, $fallback = '', $cast = '' ) |
|
90 | 90 | { |
91 | - $option = get_option($path, $fallback); |
|
92 | - if (empty($option)) { |
|
91 | + $option = get_option( $path, $fallback ); |
|
92 | + if( empty($option) ) { |
|
93 | 93 | $option = $fallback; |
94 | 94 | } |
95 | - return Helper::castTo($cast, $option); |
|
95 | + return Helper::castTo( $cast, $option ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -100,25 +100,25 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function json() |
102 | 102 | { |
103 | - return json_encode($this->all()); |
|
103 | + return json_encode( $this->all() ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @return array |
108 | 108 | */ |
109 | - public function normalize(array $options = []) |
|
109 | + public function normalize( array $options = [] ) |
|
110 | 110 | { |
111 | 111 | $options = wp_parse_args( |
112 | - Arr::flattenArray($options), |
|
113 | - glsr(DefaultsManager::class)->defaults() |
|
112 | + Arr::flattenArray( $options ), |
|
113 | + glsr( DefaultsManager::class )->defaults() |
|
114 | 114 | ); |
115 | - array_walk($options, function (&$value) { |
|
116 | - if (!is_string($value)) { |
|
115 | + array_walk( $options, function( &$value ) { |
|
116 | + if( !is_string( $value ) ) { |
|
117 | 117 | return; |
118 | 118 | } |
119 | - $value = wp_kses($value, wp_kses_allowed_html('post')); |
|
119 | + $value = wp_kses( $value, wp_kses_allowed_html( 'post' ) ); |
|
120 | 120 | }); |
121 | - return Arr::convertDotNotationArray($options); |
|
121 | + return Arr::convertDotNotationArray( $options ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function isRecaptchaEnabled() |
128 | 128 | { |
129 | - $integration = $this->get('settings.submissions.recaptcha.integration'); |
|
129 | + $integration = $this->get( 'settings.submissions.recaptcha.integration' ); |
|
130 | 130 | return 'all' == $integration || ('guest' == $integration && !is_user_logged_in()); |
131 | 131 | } |
132 | 132 | |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function reset() |
137 | 137 | { |
138 | - $options = $this->getWP(static::databaseKey(), []); |
|
139 | - if (!is_array($options) || empty($options)) { |
|
140 | - delete_option(static::databaseKey()); |
|
138 | + $options = $this->getWP( static::databaseKey(), [] ); |
|
139 | + if( !is_array( $options ) || empty($options) ) { |
|
140 | + delete_option( static::databaseKey() ); |
|
141 | 141 | $options = glsr()->defaults ?: []; |
142 | 142 | } |
143 | 143 | $this->options = $options; |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | * @param mixed $value |
149 | 149 | * @return bool |
150 | 150 | */ |
151 | - public function set($pathOrOptions, $value = '') |
|
151 | + public function set( $pathOrOptions, $value = '' ) |
|
152 | 152 | { |
153 | - if (is_string($pathOrOptions)) { |
|
154 | - $pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value); |
|
153 | + if( is_string( $pathOrOptions ) ) { |
|
154 | + $pathOrOptions = Arr::set( $this->all(), $pathOrOptions, $value ); |
|
155 | 155 | } |
156 | - if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) { |
|
156 | + if( $result = update_option( static::databaseKey(), (array)$pathOrOptions ) ) { |
|
157 | 157 | $this->reset(); |
158 | 158 | } |
159 | 159 | return $result; |