@@ -1,7 +1,7 @@ |
||
| 1 | -<?php defined('WPINC') || die; ?> |
|
| 1 | +<?php defined( 'WPINC' ) || die; ?> |
|
| 2 | 2 | |
| 3 | 3 | <p class="about-description"> |
| 4 | - Still need help with <?= glsr()->name; ?>? We offer excellent support, but don't forget to check our <a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">documentation</a> first. |
|
| 4 | + Still need help with <?= glsr()->name; ?>? We offer excellent support, but don't forget to check our <a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">documentation</a> first. |
|
| 5 | 5 | </p> |
| 6 | 6 | <div class="is-fullwidth"> |
| 7 | 7 | <div class="glsr-flex-row glsr-has-2-columns"> |
@@ -1,17 +1,17 @@ discard block |
||
| 1 | -<?php defined('WPINC') || die; ?> |
|
| 1 | +<?php defined( 'WPINC' ) || die; ?> |
|
| 2 | 2 | |
| 3 | 3 | <div class="is-fullwidth"> |
| 4 | 4 | <div class="glsr-flex-row glsr-has-2-columns"> |
| 5 | 5 | <div class="glsr-column"> |
| 6 | 6 | <h3>Editor Blocks</h3> |
| 7 | 7 | <p>The fastest way to getting started with Site Reviews is to use the three provided blocks in the WordPress Block Editor. Each block comes with multiple settings which let you configure the block exactly as needed. To add a block to your page, click the "Add Block" button and search for "Site Reviews".</p> |
| 8 | - <img class="screenshot" src="<?= glsr()->url('assets/images/blocks.png'); ?>" alt="Editor Blocks" /> |
|
| 8 | + <img class="screenshot" src="<?= glsr()->url( 'assets/images/blocks.png' ); ?>" alt="Editor Blocks" /> |
|
| 9 | 9 | </div> |
| 10 | 10 | <div class="glsr-column"> |
| 11 | 11 | <h3>Shortcodes and Widgets</h3> |
| 12 | 12 | <p>You can also use the shortcodes or widgets on your page. Keep in mind, however, that widgets are limited in options compared to the shortcodes (for example, the "Latest Reviews" widget does not allow pagination). If you are using the Classic Editor in WordPress, you can click on the Site Reviews shortcode button above the editor (next to the media button) to add a shortcode via a friendly popup.</p> |
| 13 | 13 | <p>To learn more about the shortcodes and the available shortcode options, please see the Shortcode Documentation page of the plugin.</p> |
| 14 | - <a class="button" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">View Shortcode Documentation</a> |
|
| 14 | + <a class="button" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">View Shortcode Documentation</a> |
|
| 15 | 15 | </div> |
| 16 | 16 | </div> |
| 17 | 17 | </div> |
@@ -20,31 +20,31 @@ discard block |
||
| 20 | 20 | <h2>Features</h2> |
| 21 | 21 | <ul class="glsr-flex-row glsr-has-3-columns"> |
| 22 | 22 | <li class="glsr-column"> |
| 23 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=addons'); ?>">Add-ons</a></h3> |
|
| 23 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=addons' ); ?>">Add-ons</a></h3> |
|
| 24 | 24 | <p>Extend Site Reviews with add-ons that provide additional features.</p> |
| 25 | 25 | </li> |
| 26 | 26 | <li class="glsr-column"> |
| 27 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-reviews'); ?>">Avatars</a></h3> |
|
| 27 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-reviews' ); ?>">Avatars</a></h3> |
|
| 28 | 28 | <p>Enable avatars to generate images using the WordPress Gravatar service.</p> |
| 29 | 29 | </li> |
| 30 | 30 | <li class="glsr-column"> |
| 31 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=tools#tab-general'); ?>">Backup/Restore</a></h3> |
|
| 31 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=tools#tab-general' ); ?>">Backup/Restore</a></h3> |
|
| 32 | 32 | <p>Backup and restore your plugin settings as needed.</p> |
| 33 | 33 | </li> |
| 34 | 34 | <li class="glsr-column"> |
| 35 | - <h3><a data-expand="#faq-14" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">Bayesian Ranking</a></h3> |
|
| 35 | + <h3><a data-expand="#faq-14" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq' ); ?>">Bayesian Ranking</a></h3> |
|
| 36 | 36 | <p>Easily rank pages with assigned reviews using the bayesian algorithm.</p> |
| 37 | 37 | </li> |
| 38 | 38 | <li class="glsr-column"> |
| 39 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions'); ?>">Blacklist</a></h3> |
|
| 39 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions' ); ?>">Blacklist</a></h3> |
|
| 40 | 40 | <p>Blacklist words, phrases, IP addresses, names, and emails.</p> |
| 41 | 41 | </li> |
| 42 | 42 | <li class="glsr-column"> |
| 43 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Blockchain Validation</a></h3> |
|
| 43 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Blockchain Validation</a></h3> |
|
| 44 | 44 | <p>Verify your reviews on the Blockchain with <a href="https://trustalyze.com?ref=105">Trustalyze</a>.</p> |
| 45 | 45 | </li> |
| 46 | 46 | <li class="glsr-column"> |
| 47 | - <h3><a href="<?= admin_url('edit-tags.php?taxonomy=site-review-category&post_type=site-review'); ?>">Categories</a></h3> |
|
| 47 | + <h3><a href="<?= admin_url( 'edit-tags.php?taxonomy=site-review-category&post_type=site-review' ); ?>">Categories</a></h3> |
|
| 48 | 48 | <p>Add your own categories and assign reviews to them.</p> |
| 49 | 49 | </li> |
| 50 | 50 | <li class="glsr-column"> |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | <p>Designed for WordPress developers with over 100 filter hooks and convenient functions.</p> |
| 53 | 53 | </li> |
| 54 | 54 | <li class="glsr-column"> |
| 55 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">Documentation</a></h3> |
|
| 55 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq' ); ?>">Documentation</a></h3> |
|
| 56 | 56 | <p>Provides FAQ and documenation for hooks and all shortcodes and functions.</p> |
| 57 | 57 | </li> |
| 58 | 58 | <li class="glsr-column"> |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | <p>Use configurable editor blocks in the new WordPress 5.0 editor.</p> |
| 61 | 61 | </li> |
| 62 | 62 | <li class="glsr-column"> |
| 63 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-schema'); ?>">JSON-LD Schema</a></h3> |
|
| 63 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-schema' ); ?>">JSON-LD Schema</a></h3> |
|
| 64 | 64 | <p>Enable JSON-LD schema to display your reviews and ratings in search results.</p> |
| 65 | 65 | </li> |
| 66 | 66 | <li class="glsr-column"> |
| 67 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Multilingual</a></h3> |
|
| 67 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Multilingual</a></h3> |
|
| 68 | 68 | <p>Integrates with Polylang and WPML and provides easy search/replace translation.</p> |
| 69 | 69 | </li> |
| 70 | 70 | <li class="glsr-column"> |
@@ -72,47 +72,47 @@ discard block |
||
| 72 | 72 | <p>Provides full support for the WordPress multisite feature.</p> |
| 73 | 73 | </li> |
| 74 | 74 | <li class="glsr-column"> |
| 75 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Notifications</a></h3> |
|
| 75 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Notifications</a></h3> |
|
| 76 | 76 | <p>Send notifications to one or more emails when a review is submitted.</p> |
| 77 | 77 | </li> |
| 78 | 78 | <li class="glsr-column"> |
| 79 | - <h3><a data-expand="#faq-03" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">Page Assignment</a></h3> |
|
| 79 | + <h3><a data-expand="#faq-03" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq' ); ?>">Page Assignment</a></h3> |
|
| 80 | 80 | <p>Assign reviews to Posts, Pages, and Custom Post Types.</p> |
| 81 | 81 | </li> |
| 82 | 82 | <li class="glsr-column"> |
| 83 | - <h3><a data-expand="#faq-02" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">Pagination</a></h3> |
|
| 83 | + <h3><a data-expand="#faq-02" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq' ); ?>">Pagination</a></h3> |
|
| 84 | 84 | <p>Enable AJAX pagination to display a custom number of reviews per-page.</p> |
| 85 | 85 | </li> |
| 86 | 86 | <li class="glsr-column"> |
| 87 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.''); ?>">Responses</a></h3> |
|
| 87 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'' ); ?>">Responses</a></h3> |
|
| 88 | 88 | <p>Write a response to reviews that require a response.</p> |
| 89 | 89 | </li> |
| 90 | 90 | <li class="glsr-column"> |
| 91 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Restrictions</a></h3> |
|
| 91 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Restrictions</a></h3> |
|
| 92 | 92 | <p>Require approval before publishing reviews and limit to registered users.</p> |
| 93 | 93 | </li> |
| 94 | 94 | <li class="glsr-column"> |
| 95 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions'); ?>">Review Limits</a></h3> |
|
| 95 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions' ); ?>">Review Limits</a></h3> |
|
| 96 | 96 | <p>Limit review submissions by email address, IP address, or username.</p> |
| 97 | 97 | </li> |
| 98 | 98 | <li class="glsr-column"> |
| 99 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Review Summaries</a></h3> |
|
| 99 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Review Summaries</a></h3> |
|
| 100 | 100 | <p>Display a summary of your review ratings from high to low.</p> |
| 101 | 101 | </li> |
| 102 | 102 | <li class="glsr-column"> |
| 103 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Shortcodes</a></h3> |
|
| 103 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Shortcodes</a></h3> |
|
| 104 | 104 | <p>Use the configurable shortcodes complete with documentation.</p> |
| 105 | 105 | </li> |
| 106 | 106 | <li class="glsr-column"> |
| 107 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Slack</a></h3> |
|
| 107 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Slack</a></h3> |
|
| 108 | 108 | <p>Receive notifications in Slack when a review is submitted.</p> |
| 109 | 109 | </li> |
| 110 | 110 | <li class="glsr-column"> |
| 111 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions'); ?>">SPAM Protection</a></h3> |
|
| 111 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions' ); ?>">SPAM Protection</a></h3> |
|
| 112 | 112 | <p>Uses a Honeypot and integrates with Invisible reCAPTCHA and Akismet.</p> |
| 113 | 113 | </li> |
| 114 | 114 | <li class="glsr-column"> |
| 115 | - <h3><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>">Styles</a></h3> |
|
| 115 | + <h3><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>">Styles</a></h3> |
|
| 116 | 116 | <p>Change the submission form style to match popular themes and form plugins.</p> |
| 117 | 117 | </li> |
| 118 | 118 | <li class="glsr-column"> |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | <p>Free premium-level support included on the WordPress support forum.</p> |
| 121 | 121 | </li> |
| 122 | 122 | <li class="glsr-column"> |
| 123 | - <h3><a data-expand="#faq-18" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq'); ?>">Templates</a></h3> |
|
| 123 | + <h3><a data-expand="#faq-18" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-faq' ); ?>">Templates</a></h3> |
|
| 124 | 124 | <p>Use the Site Reviews templates in your theme for full control over the HTML.</p> |
| 125 | 125 | </li> |
| 126 | 126 | <li class="glsr-column"> |
| 127 | - <h3><a href="<?= admin_url('widgets.php'); ?>">Widgets</a></h3> |
|
| 127 | + <h3><a href="<?= admin_url( 'widgets.php' ); ?>">Widgets</a></h3> |
|
| 128 | 128 | <p>Use the configurable widgets in your sidebars.</p> |
| 129 | 129 | </li> |
| 130 | 130 | </ul> |
@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public function migrateOptions() |
| 15 | 15 | { |
| 16 | - $isAccountVerified = glsr(OptionManager::class)->getWP('_glsr_rebusify', false); |
|
| 17 | - update_option('_glsr_trustalyze', $isAccountVerified); |
|
| 18 | - delete_option('_glsr_rebusify'); |
|
| 16 | + $isAccountVerified = glsr( OptionManager::class )->getWP( '_glsr_rebusify', false ); |
|
| 17 | + update_option( '_glsr_trustalyze', $isAccountVerified ); |
|
| 18 | + delete_option( '_glsr_rebusify' ); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -23,20 +23,20 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function migrateSettings() |
| 25 | 25 | { |
| 26 | - if ($settings = get_option(OptionManager::databaseKey(4))) { |
|
| 27 | - $settings = Arr::set($settings, 'settings.general.trustalyze', |
|
| 28 | - Arr::get($settings, 'settings.general.rebusify') |
|
| 26 | + if( $settings = get_option( OptionManager::databaseKey( 4 ) ) ) { |
|
| 27 | + $settings = Arr::set( $settings, 'settings.general.trustalyze', |
|
| 28 | + Arr::get( $settings, 'settings.general.rebusify' ) |
|
| 29 | 29 | ); |
| 30 | - $settings = Arr::set($settings, 'settings.general.trustalyze_email', |
|
| 31 | - Arr::get($settings, 'settings.general.rebusify_email') |
|
| 30 | + $settings = Arr::set( $settings, 'settings.general.trustalyze_email', |
|
| 31 | + Arr::get( $settings, 'settings.general.rebusify_email' ) |
|
| 32 | 32 | ); |
| 33 | - $settings = Arr::set($settings, 'settings.general.trustalyze_serial', |
|
| 34 | - Arr::get($settings, 'settings.general.rebusify_serial') |
|
| 33 | + $settings = Arr::set( $settings, 'settings.general.trustalyze_serial', |
|
| 34 | + Arr::get( $settings, 'settings.general.rebusify_serial' ) |
|
| 35 | 35 | ); |
| 36 | 36 | unset($settings['settings']['general']['rebusify']); |
| 37 | 37 | unset($settings['settings']['general']['rebusify_email']); |
| 38 | 38 | unset($settings['settings']['general']['rebusify_serial']); |
| 39 | - update_option(OptionManager::databaseKey(4), $settings); |
|
| 39 | + update_option( OptionManager::databaseKey( 4 ), $settings ); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
@@ -46,17 +46,17 @@ discard block |
||
| 46 | 46 | public function migrateUserMeta() |
| 47 | 47 | { |
| 48 | 48 | $metaKey = NoticeController::USER_META_KEY; |
| 49 | - $userIds = get_users([ |
|
| 49 | + $userIds = get_users( [ |
|
| 50 | 50 | 'fields' => 'ID', |
| 51 | 51 | 'meta_compare' => 'EXISTS', |
| 52 | 52 | 'meta_key' => $metaKey, |
| 53 | - ]); |
|
| 54 | - foreach ($userIds as $userId) { |
|
| 55 | - $meta = (array) get_user_meta($userId, $metaKey, true); |
|
| 56 | - if (array_key_exists('rebusify', $meta)) { |
|
| 53 | + ] ); |
|
| 54 | + foreach( $userIds as $userId ) { |
|
| 55 | + $meta = (array)get_user_meta( $userId, $metaKey, true ); |
|
| 56 | + if( array_key_exists( 'rebusify', $meta ) ) { |
|
| 57 | 57 | $meta['trustalyze'] = $meta['rebusify']; |
| 58 | 58 | unset($meta['rebusify']); |
| 59 | - update_user_meta($userId, $metaKey, $meta); |
|
| 59 | + update_user_meta( $userId, $metaKey, $meta ); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php defined('WPINC') || die; ?> |
|
| 1 | +<?php defined( 'WPINC' ) || die; ?> |
|
| 2 | 2 | |
| 3 | 3 | <div class="et_contact_bottom_container"> |
| 4 | 4 | <button type="submit" class="glsr-button et_pb_contact_submit et_pb_button"> |
@@ -20,31 +20,31 @@ discard block |
||
| 20 | 20 | * @param string $id |
| 21 | 21 | * @return string |
| 22 | 22 | */ |
| 23 | - public function buildFields($id) |
|
| 23 | + public function buildFields( $id ) |
|
| 24 | 24 | { |
| 25 | - $this->settings = glsr(DefaultsManager::class)->settings(); |
|
| 26 | - $method = Helper::buildMethodName($id, 'getTemplateDataFor'); |
|
| 27 | - $data = !method_exists($this, $method) |
|
| 28 | - ? $this->getTemplateData($id) |
|
| 29 | - : $this->$method($id); |
|
| 30 | - return glsr(Template::class)->build('pages/settings/'.$id, $data); |
|
| 25 | + $this->settings = glsr( DefaultsManager::class )->settings(); |
|
| 26 | + $method = Helper::buildMethodName( $id, 'getTemplateDataFor' ); |
|
| 27 | + $data = !method_exists( $this, $method ) |
|
| 28 | + ? $this->getTemplateData( $id ) |
|
| 29 | + : $this->$method( $id ); |
|
| 30 | + return glsr( Template::class )->build( 'pages/settings/'.$id, $data ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * @return string |
| 35 | 35 | */ |
| 36 | - protected function getFieldDefault(array $field) |
|
| 36 | + protected function getFieldDefault( array $field ) |
|
| 37 | 37 | { |
| 38 | - return Arr::get($field, 'default'); |
|
| 38 | + return Arr::get( $field, 'default' ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @return string |
| 43 | 43 | */ |
| 44 | - protected function getFieldNameForDependsOn($path) |
|
| 44 | + protected function getFieldNameForDependsOn( $path ) |
|
| 45 | 45 | { |
| 46 | - $fieldName = Str::convertPathToName($path, OptionManager::databaseKey()); |
|
| 47 | - return $this->isMultiDependency($path) |
|
| 46 | + $fieldName = Str::convertPathToName( $path, OptionManager::databaseKey() ); |
|
| 47 | + return $this->isMultiDependency( $path ) |
|
| 48 | 48 | ? $fieldName.'[]' |
| 49 | 49 | : $fieldName; |
| 50 | 50 | } |
@@ -52,25 +52,25 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @return array |
| 54 | 54 | */ |
| 55 | - protected function getSettingFields($path) |
|
| 55 | + protected function getSettingFields( $path ) |
|
| 56 | 56 | { |
| 57 | - return array_filter($this->settings, function ($key) use ($path) { |
|
| 58 | - return Str::startsWith($path, $key); |
|
| 59 | - }, ARRAY_FILTER_USE_KEY); |
|
| 57 | + return array_filter( $this->settings, function( $key ) use ($path) { |
|
| 58 | + return Str::startsWith( $path, $key ); |
|
| 59 | + }, ARRAY_FILTER_USE_KEY ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @return string |
| 64 | 64 | */ |
| 65 | - protected function getSettingRows(array $fields) |
|
| 65 | + protected function getSettingRows( array $fields ) |
|
| 66 | 66 | { |
| 67 | 67 | $rows = ''; |
| 68 | - foreach ($fields as $name => $field) { |
|
| 69 | - $field = wp_parse_args($field, [ |
|
| 68 | + foreach( $fields as $name => $field ) { |
|
| 69 | + $field = wp_parse_args( $field, [ |
|
| 70 | 70 | 'is_setting' => true, |
| 71 | 71 | 'name' => $name, |
| 72 | - ]); |
|
| 73 | - $rows.= new Field($this->normalize($field)); |
|
| 72 | + ] ); |
|
| 73 | + $rows .= new Field( $this->normalize( $field ) ); |
|
| 74 | 74 | } |
| 75 | 75 | return $rows; |
| 76 | 76 | } |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | * @param string $id |
| 80 | 80 | * @return array |
| 81 | 81 | */ |
| 82 | - protected function getTemplateData($id) |
|
| 82 | + protected function getTemplateData( $id ) |
|
| 83 | 83 | { |
| 84 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
| 84 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
| 85 | 85 | return [ |
| 86 | 86 | 'context' => [ |
| 87 | - 'rows' => $this->getSettingRows($fields), |
|
| 87 | + 'rows' => $this->getSettingRows( $fields ), |
|
| 88 | 88 | ], |
| 89 | 89 | ]; |
| 90 | 90 | } |
@@ -93,19 +93,19 @@ discard block |
||
| 93 | 93 | * @param string $id |
| 94 | 94 | * @return array |
| 95 | 95 | */ |
| 96 | - protected function getTemplateDataForAddons($id) |
|
| 96 | + protected function getTemplateDataForAddons( $id ) |
|
| 97 | 97 | { |
| 98 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
| 99 | - $settings = Arr::convertFromDotNotation($fields); |
|
| 100 | - $settingKeys = array_keys($settings['settings']['addons']); |
|
| 98 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
| 99 | + $settings = Arr::convertFromDotNotation( $fields ); |
|
| 100 | + $settingKeys = array_keys( $settings['settings']['addons'] ); |
|
| 101 | 101 | $results = []; |
| 102 | - foreach ($settingKeys as $key) { |
|
| 103 | - $addonFields = array_filter($fields, function ($path) use ($key) { |
|
| 104 | - return Str::startsWith('settings.addons.'.$key, $path); |
|
| 105 | - }, ARRAY_FILTER_USE_KEY); |
|
| 106 | - $results[$key] = $this->getSettingRows($addonFields); |
|
| 102 | + foreach( $settingKeys as $key ) { |
|
| 103 | + $addonFields = array_filter( $fields, function( $path ) use ($key) { |
|
| 104 | + return Str::startsWith( 'settings.addons.'.$key, $path ); |
|
| 105 | + }, ARRAY_FILTER_USE_KEY ); |
|
| 106 | + $results[$key] = $this->getSettingRows( $addonFields ); |
|
| 107 | 107 | } |
| 108 | - ksort($results); |
|
| 108 | + ksort( $results ); |
|
| 109 | 109 | return [ |
| 110 | 110 | 'settings' => $results, |
| 111 | 111 | ]; |
@@ -115,13 +115,13 @@ discard block |
||
| 115 | 115 | * @param string $id |
| 116 | 116 | * @return array |
| 117 | 117 | */ |
| 118 | - protected function getTemplateDataForLicenses($id) |
|
| 118 | + protected function getTemplateDataForLicenses( $id ) |
|
| 119 | 119 | { |
| 120 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
| 121 | - ksort($fields); |
|
| 120 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
| 121 | + ksort( $fields ); |
|
| 122 | 122 | return [ |
| 123 | 123 | 'context' => [ |
| 124 | - 'rows' => $this->getSettingRows($fields), |
|
| 124 | + 'rows' => $this->getSettingRows( $fields ), |
|
| 125 | 125 | ], |
| 126 | 126 | ]; |
| 127 | 127 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | protected function getTemplateDataForTranslations() |
| 133 | 133 | { |
| 134 | - $translations = glsr(Translation::class)->renderAll(); |
|
| 134 | + $translations = glsr( Translation::class )->renderAll(); |
|
| 135 | 135 | $class = empty($translations) |
| 136 | 136 | ? 'glsr-hidden' |
| 137 | 137 | : ''; |
@@ -149,16 +149,16 @@ discard block |
||
| 149 | 149 | * @param string|array $expectedValue |
| 150 | 150 | * @return bool |
| 151 | 151 | */ |
| 152 | - protected function isFieldHidden($path, $expectedValue) |
|
| 152 | + protected function isFieldHidden( $path, $expectedValue ) |
|
| 153 | 153 | { |
| 154 | - $optionValue = glsr(OptionManager::class)->get( |
|
| 154 | + $optionValue = glsr( OptionManager::class )->get( |
|
| 155 | 155 | $path, |
| 156 | - Arr::get(glsr()->defaults, $path) |
|
| 156 | + Arr::get( glsr()->defaults, $path ) |
|
| 157 | 157 | ); |
| 158 | - if (is_array($expectedValue)) { |
|
| 159 | - return is_array($optionValue) |
|
| 160 | - ? 0 === count(array_intersect($optionValue, $expectedValue)) |
|
| 161 | - : !in_array($optionValue, $expectedValue); |
|
| 158 | + if( is_array( $expectedValue ) ) { |
|
| 159 | + return is_array( $optionValue ) |
|
| 160 | + ? 0 === count( array_intersect( $optionValue, $expectedValue ) ) |
|
| 161 | + : !in_array( $optionValue, $expectedValue ); |
|
| 162 | 162 | } |
| 163 | 163 | return $optionValue != $expectedValue; |
| 164 | 164 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | /** |
| 167 | 167 | * @return bool |
| 168 | 168 | */ |
| 169 | - protected function isMultiDependency($path) |
|
| 169 | + protected function isMultiDependency( $path ) |
|
| 170 | 170 | { |
| 171 | - if (isset($this->settings[$path])) { |
|
| 171 | + if( isset($this->settings[$path]) ) { |
|
| 172 | 172 | $field = $this->settings[$path]; |
| 173 | 173 | return ('checkbox' == $field['type'] && !empty($field['options'])) |
| 174 | 174 | || !empty($field['multiple']); |
@@ -179,32 +179,32 @@ discard block |
||
| 179 | 179 | /** |
| 180 | 180 | * @return array |
| 181 | 181 | */ |
| 182 | - protected function normalize(array $field) |
|
| 182 | + protected function normalize( array $field ) |
|
| 183 | 183 | { |
| 184 | - $field = $this->normalizeDependsOn($field); |
|
| 185 | - $field = $this->normalizeLabelAndLegend($field); |
|
| 186 | - $field = $this->normalizeValue($field); |
|
| 184 | + $field = $this->normalizeDependsOn( $field ); |
|
| 185 | + $field = $this->normalizeLabelAndLegend( $field ); |
|
| 186 | + $field = $this->normalizeValue( $field ); |
|
| 187 | 187 | return $field; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | 191 | * @return array |
| 192 | 192 | */ |
| 193 | - protected function normalizeDependsOn(array $field) |
|
| 193 | + protected function normalizeDependsOn( array $field ) |
|
| 194 | 194 | { |
| 195 | - if (!empty($field['depends_on']) && is_array($field['depends_on'])) { |
|
| 195 | + if( !empty($field['depends_on']) && is_array( $field['depends_on'] ) ) { |
|
| 196 | 196 | $isFieldHidden = false; |
| 197 | 197 | $conditions = []; |
| 198 | - foreach ($field['depends_on'] as $path => $value) { |
|
| 198 | + foreach( $field['depends_on'] as $path => $value ) { |
|
| 199 | 199 | $conditions[] = [ |
| 200 | - 'name' => $this->getFieldNameForDependsOn($path), |
|
| 200 | + 'name' => $this->getFieldNameForDependsOn( $path ), |
|
| 201 | 201 | 'value' => $value, |
| 202 | 202 | ]; |
| 203 | - if ($this->isFieldHidden($path, $value)) { |
|
| 203 | + if( $this->isFieldHidden( $path, $value ) ) { |
|
| 204 | 204 | $isFieldHidden = true; |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | - $field['data-depends'] = json_encode($conditions, JSON_HEX_APOS | JSON_HEX_QUOT); |
|
| 207 | + $field['data-depends'] = json_encode( $conditions, JSON_HEX_APOS | JSON_HEX_QUOT ); |
|
| 208 | 208 | $field['is_hidden'] = $isFieldHidden; |
| 209 | 209 | } |
| 210 | 210 | return $field; |
@@ -213,14 +213,14 @@ discard block |
||
| 213 | 213 | /** |
| 214 | 214 | * @return array |
| 215 | 215 | */ |
| 216 | - protected function normalizeLabelAndLegend(array $field) |
|
| 216 | + protected function normalizeLabelAndLegend( array $field ) |
|
| 217 | 217 | { |
| 218 | - if (!empty($field['label'])) { |
|
| 218 | + if( !empty($field['label']) ) { |
|
| 219 | 219 | $field['legend'] = $field['label']; |
| 220 | 220 | unset($field['label']); |
| 221 | 221 | } else { |
| 222 | 222 | $field['is_valid'] = false; |
| 223 | - glsr_log()->warning('Setting field is missing a label')->debug($field); |
|
| 223 | + glsr_log()->warning( 'Setting field is missing a label' )->debug( $field ); |
|
| 224 | 224 | } |
| 225 | 225 | return $field; |
| 226 | 226 | } |
@@ -228,12 +228,12 @@ discard block |
||
| 228 | 228 | /** |
| 229 | 229 | * @return array |
| 230 | 230 | */ |
| 231 | - protected function normalizeValue(array $field) |
|
| 231 | + protected function normalizeValue( array $field ) |
|
| 232 | 232 | { |
| 233 | - if (!isset($field['value'])) { |
|
| 234 | - $field['value'] = glsr(OptionManager::class)->get( |
|
| 233 | + if( !isset($field['value']) ) { |
|
| 234 | + $field['value'] = glsr( OptionManager::class )->get( |
|
| 235 | 235 | $field['name'], |
| 236 | - $this->getFieldDefault($field) |
|
| 236 | + $this->getFieldDefault( $field ) |
|
| 237 | 237 | ); |
| 238 | 238 | } |
| 239 | 239 | return $field; |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | /** |
| 243 | 243 | * @return string |
| 244 | 244 | */ |
| 245 | - protected function normalizeSettingPath($path) |
|
| 245 | + protected function normalizeSettingPath( $path ) |
|
| 246 | 246 | { |
| 247 | - return Str::prefix('settings.', rtrim($path, '.')); |
|
| 247 | + return Str::prefix( 'settings.', rtrim( $path, '.' ) ); |
|
| 248 | 248 | } |
| 249 | 249 | } |
@@ -83,23 +83,23 @@ discard block |
||
| 83 | 83 | * @param array $args |
| 84 | 84 | * @return static |
| 85 | 85 | */ |
| 86 | - public function __call($method, $args) |
|
| 86 | + public function __call( $method, $args ) |
|
| 87 | 87 | { |
| 88 | - $constant = 'static::ATTRIBUTES_'.strtoupper($method); |
|
| 89 | - $allowedAttributeKeys = defined($constant) |
|
| 90 | - ? constant($constant) |
|
| 88 | + $constant = 'static::ATTRIBUTES_'.strtoupper( $method ); |
|
| 89 | + $allowedAttributeKeys = defined( $constant ) |
|
| 90 | + ? constant( $constant ) |
|
| 91 | 91 | : []; |
| 92 | - $this->normalize(Arr::consolidate(Arr::get($args, 0)), $allowedAttributeKeys); |
|
| 93 | - $this->normalizeInputType($method); |
|
| 92 | + $this->normalize( Arr::consolidate( Arr::get( $args, 0 ) ), $allowedAttributeKeys ); |
|
| 93 | + $this->normalizeInputType( $method ); |
|
| 94 | 94 | return $this; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * @return static |
| 99 | 99 | */ |
| 100 | - public function set(array $attributes) |
|
| 100 | + public function set( array $attributes ) |
|
| 101 | 101 | { |
| 102 | - $this->normalize($attributes); |
|
| 102 | + $this->normalize( $attributes ); |
|
| 103 | 103 | return $this; |
| 104 | 104 | } |
| 105 | 105 | |
@@ -117,21 +117,21 @@ discard block |
||
| 117 | 117 | public function toString() |
| 118 | 118 | { |
| 119 | 119 | $attributes = []; |
| 120 | - foreach ($this->attributes as $attribute => $value) { |
|
| 121 | - $quote = $this->getQuoteChar($attribute); |
|
| 122 | - $attributes[] = in_array($attribute, static::BOOLEAN_ATTRIBUTES) |
|
| 120 | + foreach( $this->attributes as $attribute => $value ) { |
|
| 121 | + $quote = $this->getQuoteChar( $attribute ); |
|
| 122 | + $attributes[] = in_array( $attribute, static::BOOLEAN_ATTRIBUTES ) |
|
| 123 | 123 | ? $attribute |
| 124 | - : $attribute.'='.$quote.implode(',', (array) $value).$quote; |
|
| 124 | + : $attribute.'='.$quote.implode( ',', (array)$value ).$quote; |
|
| 125 | 125 | } |
| 126 | - return implode(' ', $attributes); |
|
| 126 | + return implode( ' ', $attributes ); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | 130 | * @return array |
| 131 | 131 | */ |
| 132 | - protected function filterAttributes(array $allowedAttributeKeys) |
|
| 132 | + protected function filterAttributes( array $allowedAttributeKeys ) |
|
| 133 | 133 | { |
| 134 | - return array_intersect_key($this->attributes, array_flip($allowedAttributeKeys)); |
|
| 134 | + return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys ) ); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -139,15 +139,15 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | protected function filterGlobalAttributes() |
| 141 | 141 | { |
| 142 | - $globalAttributes = $this->filterAttributes(static::GLOBAL_ATTRIBUTES); |
|
| 142 | + $globalAttributes = $this->filterAttributes( static::GLOBAL_ATTRIBUTES ); |
|
| 143 | 143 | $wildcards = []; |
| 144 | - foreach (static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard) { |
|
| 145 | - $newWildcards = array_filter($this->attributes, function ($key) use ($wildcard) { |
|
| 146 | - return Str::startsWith($wildcard, $key); |
|
| 147 | - }, ARRAY_FILTER_USE_KEY); |
|
| 148 | - $wildcards = array_merge($wildcards, $newWildcards); |
|
| 144 | + foreach( static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard ) { |
|
| 145 | + $newWildcards = array_filter( $this->attributes, function( $key ) use ($wildcard) { |
|
| 146 | + return Str::startsWith( $wildcard, $key ); |
|
| 147 | + }, ARRAY_FILTER_USE_KEY ); |
|
| 148 | + $wildcards = array_merge( $wildcards, $newWildcards ); |
|
| 149 | 149 | } |
| 150 | - return array_merge($globalAttributes, $wildcards); |
|
| 150 | + return array_merge( $globalAttributes, $wildcards ); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | protected function getPermanentAttributes() |
| 157 | 157 | { |
| 158 | 158 | $permanentAttributes = []; |
| 159 | - if (array_key_exists('value', $this->attributes)) { |
|
| 159 | + if( array_key_exists( 'value', $this->attributes ) ) { |
|
| 160 | 160 | $permanentAttributes['value'] = $this->attributes['value']; |
| 161 | 161 | } |
| 162 | 162 | return $permanentAttributes; |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | * @param string $attribute |
| 167 | 167 | * @return string |
| 168 | 168 | */ |
| 169 | - protected function getQuoteChar($attribute) |
|
| 169 | + protected function getQuoteChar( $attribute ) |
|
| 170 | 170 | { |
| 171 | - return Str::startsWith('data-', $attribute) |
|
| 171 | + return Str::startsWith( 'data-', $attribute ) |
|
| 172 | 172 | ? '\'' |
| 173 | 173 | : '"'; |
| 174 | 174 | } |
@@ -178,19 +178,19 @@ discard block |
||
| 178 | 178 | * @param mixed $value |
| 179 | 179 | * @return bool |
| 180 | 180 | */ |
| 181 | - protected function isAttributeKeyNumeric($key, $value) |
|
| 181 | + protected function isAttributeKeyNumeric( $key, $value ) |
|
| 182 | 182 | { |
| 183 | - return is_string($value) |
|
| 184 | - && is_numeric($key) |
|
| 185 | - && !array_key_exists($value, $this->attributes); |
|
| 183 | + return is_string( $value ) |
|
| 184 | + && is_numeric( $key ) |
|
| 185 | + && !array_key_exists( $value, $this->attributes ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | 189 | * @return void |
| 190 | 190 | */ |
| 191 | - protected function normalize(array $args, array $allowedAttributeKeys = []) |
|
| 191 | + protected function normalize( array $args, array $allowedAttributeKeys = [] ) |
|
| 192 | 192 | { |
| 193 | - $this->attributes = array_change_key_case($args, CASE_LOWER); |
|
| 193 | + $this->attributes = array_change_key_case( $args, CASE_LOWER ); |
|
| 194 | 194 | $this->normalizeBooleanAttributes(); |
| 195 | 195 | $this->normalizeDataAttributes(); |
| 196 | 196 | $this->normalizeStringAttributes(); |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $this->removeIndexedAttributes(); |
| 199 | 199 | $this->attributes = array_merge( |
| 200 | 200 | $this->filterGlobalAttributes(), |
| 201 | - $this->filterAttributes($allowedAttributeKeys) |
|
| 201 | + $this->filterAttributes( $allowedAttributeKeys ) |
|
| 202 | 202 | ); |
| 203 | 203 | } |
| 204 | 204 | |
@@ -207,15 +207,15 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | protected function normalizeBooleanAttributes() |
| 209 | 209 | { |
| 210 | - foreach ($this->attributes as $key => $value) { |
|
| 211 | - if ($this->isAttributeKeyNumeric($key, $value)) { |
|
| 210 | + foreach( $this->attributes as $key => $value ) { |
|
| 211 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
| 212 | 212 | $key = $value; |
| 213 | 213 | $value = true; |
| 214 | 214 | } |
| 215 | - if (!in_array($key, static::BOOLEAN_ATTRIBUTES)) { |
|
| 215 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ) ) { |
|
| 216 | 216 | continue; |
| 217 | 217 | } |
| 218 | - $this->attributes[$key] = wp_validate_boolean($value); |
|
| 218 | + $this->attributes[$key] = wp_validate_boolean( $value ); |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
@@ -224,16 +224,16 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | protected function normalizeDataAttributes() |
| 226 | 226 | { |
| 227 | - foreach ($this->attributes as $key => $value) { |
|
| 228 | - if ($this->isAttributeKeyNumeric($key, $value)) { |
|
| 227 | + foreach( $this->attributes as $key => $value ) { |
|
| 228 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
| 229 | 229 | $key = $value; |
| 230 | 230 | $value = ''; |
| 231 | 231 | } |
| 232 | - if (!Str::startsWith('data-', $key)) { |
|
| 232 | + if( !Str::startsWith( 'data-', $key ) ) { |
|
| 233 | 233 | continue; |
| 234 | 234 | } |
| 235 | - if (is_array($value)) { |
|
| 236 | - $value = json_encode($value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
| 235 | + if( is_array( $value ) ) { |
|
| 236 | + $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); |
|
| 237 | 237 | } |
| 238 | 238 | $this->attributes[$key] = $value; |
| 239 | 239 | } |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | protected function normalizeStringAttributes() |
| 246 | 246 | { |
| 247 | - foreach ($this->attributes as $key => $value) { |
|
| 248 | - if (is_string($value)) { |
|
| 249 | - $this->attributes[$key] = trim($value); |
|
| 247 | + foreach( $this->attributes as $key => $value ) { |
|
| 248 | + if( is_string( $value ) ) { |
|
| 249 | + $this->attributes[$key] = trim( $value ); |
|
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -255,13 +255,13 @@ discard block |
||
| 255 | 255 | * @param string $method |
| 256 | 256 | * @return void |
| 257 | 257 | */ |
| 258 | - protected function normalizeInputType($method) |
|
| 258 | + protected function normalizeInputType( $method ) |
|
| 259 | 259 | { |
| 260 | - if ('input' != $method) { |
|
| 260 | + if( 'input' != $method ) { |
|
| 261 | 261 | return; |
| 262 | 262 | } |
| 263 | - $attributes = wp_parse_args($this->attributes, ['type' => '']); |
|
| 264 | - if (!in_array($attributes['type'], static::INPUT_TYPES)) { |
|
| 263 | + $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
|
| 264 | + if( !in_array( $attributes['type'], static::INPUT_TYPES ) ) { |
|
| 265 | 265 | $this->attributes['type'] = 'text'; |
| 266 | 266 | } |
| 267 | 267 | } |
@@ -273,16 +273,16 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | $attributes = $this->attributes; |
| 275 | 275 | $permanentAttributes = $this->getPermanentAttributes(); |
| 276 | - foreach ($this->attributes as $key => $value) { |
|
| 277 | - if (in_array($key, static::BOOLEAN_ATTRIBUTES) && !$value) { |
|
| 276 | + foreach( $this->attributes as $key => $value ) { |
|
| 277 | + if( in_array( $key, static::BOOLEAN_ATTRIBUTES ) && !$value ) { |
|
| 278 | 278 | unset($attributes[$key]); |
| 279 | 279 | } |
| 280 | - if (Str::startsWith('data-', $key)) { |
|
| 280 | + if( Str::startsWith( 'data-', $key ) ) { |
|
| 281 | 281 | $permanentAttributes[$key] = $value; |
| 282 | 282 | unset($attributes[$key]); |
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | - $this->attributes = array_merge(array_filter($attributes), $permanentAttributes); |
|
| 285 | + $this->attributes = array_merge( array_filter( $attributes ), $permanentAttributes ); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | { |
| 293 | 293 | $this->attributes = array_diff_key( |
| 294 | 294 | $this->attributes, |
| 295 | - array_filter($this->attributes, 'is_numeric', ARRAY_FILTER_USE_KEY) |
|
| 295 | + array_filter( $this->attributes, 'is_numeric', ARRAY_FILTER_USE_KEY ) |
|
| 296 | 296 | ); |
| 297 | 297 | } |
| 298 | 298 | } |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | $this->newSettings = $this->getNewSettings(); |
| 67 | 67 | $this->oldSettings = $this->getOldSettings(); |
| 68 | - if (empty($this->oldSettings) || empty($this->newSettings)) { |
|
| 68 | + if( empty($this->oldSettings) || empty($this->newSettings) ) { |
|
| 69 | 69 | return; |
| 70 | 70 | } |
| 71 | - foreach (static::MAPPED_SETTINGS as $old => $new) { |
|
| 72 | - if (empty($this->oldSettings[$old])) { |
|
| 71 | + foreach( static::MAPPED_SETTINGS as $old => $new ) { |
|
| 72 | + if( empty($this->oldSettings[$old]) ) { |
|
| 73 | 73 | continue; |
| 74 | 74 | } |
| 75 | 75 | $this->newSettings[$new] = $this->oldSettings[$old]; |
@@ -77,12 +77,12 @@ discard block |
||
| 77 | 77 | $this->migrateNotificationSettings(); |
| 78 | 78 | $this->migrateRecaptchaSettings(); |
| 79 | 79 | $this->migrateRequiredSettings(); |
| 80 | - $oldSettings = Arr::convertFromDotNotation($this->oldSettings); |
|
| 81 | - $newSettings = Arr::convertFromDotNotation($this->newSettings); |
|
| 82 | - if (isset($oldSettings['settings']['strings']) && is_array($oldSettings['settings']['strings'])) { |
|
| 80 | + $oldSettings = Arr::convertFromDotNotation( $this->oldSettings ); |
|
| 81 | + $newSettings = Arr::convertFromDotNotation( $this->newSettings ); |
|
| 82 | + if( isset($oldSettings['settings']['strings']) && is_array( $oldSettings['settings']['strings'] ) ) { |
|
| 83 | 83 | $newSettings['settings']['strings'] = $oldSettings['settings']['strings']; |
| 84 | 84 | } |
| 85 | - update_option(OptionManager::databaseKey(3), $newSettings); |
|
| 85 | + update_option( OptionManager::databaseKey( 3 ), $newSettings ); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | protected function getNewSettings() |
| 100 | 100 | { |
| 101 | - return Arr::flatten(Arr::consolidate(OptionManager::databaseKey(3))); |
|
| 101 | + return Arr::flatten( Arr::consolidate( OptionManager::databaseKey( 3 ) ) ); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | protected function getOldSettings() |
| 108 | 108 | { |
| 109 | - $defaults = array_fill_keys(array_keys(static::MAPPED_SETTINGS), ''); |
|
| 110 | - $settings = Arr::consolidate(get_option(OptionManager::databaseKey(2))); |
|
| 111 | - $settings = Arr::flatten($settings); |
|
| 109 | + $defaults = array_fill_keys( array_keys( static::MAPPED_SETTINGS ), '' ); |
|
| 110 | + $settings = Arr::consolidate( get_option( OptionManager::databaseKey( 2 ) ) ); |
|
| 111 | + $settings = Arr::flatten( $settings ); |
|
| 112 | 112 | return !empty($settings) |
| 113 | - ? wp_parse_args($settings, $defaults) |
|
| 113 | + ? wp_parse_args( $settings, $defaults ) |
|
| 114 | 114 | : []; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | 'webhook' => 'slack', |
| 126 | 126 | ]; |
| 127 | 127 | $this->newSettings['settings.general.notifications'] = []; |
| 128 | - foreach ($notifications as $old => $new) { |
|
| 129 | - if ($this->oldSettings['settings.general.notification'] != $old) { |
|
| 128 | + foreach( $notifications as $old => $new ) { |
|
| 129 | + if( $this->oldSettings['settings.general.notification'] != $old ) { |
|
| 130 | 130 | continue; |
| 131 | 131 | } |
| 132 | 132 | $this->newSettings['settings.general.notifications'][] = $new; |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | 'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'], |
| 144 | 144 | 'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'], |
| 145 | 145 | ]; |
| 146 | - if (in_array($this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'])) { |
|
| 146 | + if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] ) ) { |
|
| 147 | 147 | $this->newSettings['settings.submissions.recaptcha.integration'] = 'all'; |
| 148 | 148 | } |
| 149 | - if ('invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration']) { |
|
| 150 | - $recaptcha = wp_parse_args((array) get_site_option('ic-settings', [], false), $recaptcha); |
|
| 149 | + if( 'invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration'] ) { |
|
| 150 | + $recaptcha = wp_parse_args( (array)get_site_option( 'ic-settings', [], false ), $recaptcha ); |
|
| 151 | 151 | } |
| 152 | 152 | $this->newSettings['settings.submissions.recaptcha.key'] = $recaptcha['SiteKey']; |
| 153 | 153 | $this->newSettings['settings.submissions.recaptcha.secret'] = $recaptcha['SecretKey']; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | protected function migrateRequiredSettings() |
| 161 | 161 | { |
| 162 | - $this->newSettings['settings.submissions.required'] = array_filter((array) $this->oldSettings['settings.reviews-form.required']); |
|
| 162 | + $this->newSettings['settings.submissions.required'] = array_filter( (array)$this->oldSettings['settings.reviews-form.required'] ); |
|
| 163 | 163 | $this->newSettings['settings.submissions.required'][] = 'rating'; |
| 164 | 164 | $this->newSettings['settings.submissions.required'][] = 'terms'; |
| 165 | 165 | } |
@@ -17,25 +17,25 @@ discard block |
||
| 17 | 17 | * @param array $instance |
| 18 | 18 | * @return void |
| 19 | 19 | */ |
| 20 | - public function widget($args, $instance) |
|
| 20 | + public function widget( $args, $instance ) |
|
| 21 | 21 | { |
| 22 | - echo $this->shortcode()->build($instance, $args, 'widget'); |
|
| 22 | + echo $this->shortcode()->build( $instance, $args, 'widget' ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @param string $tag |
| 27 | 27 | * @return array |
| 28 | 28 | */ |
| 29 | - protected function normalizeFieldAttributes($tag, array $args) |
|
| 29 | + protected function normalizeFieldAttributes( $tag, array $args ) |
|
| 30 | 30 | { |
| 31 | - if (empty($args['value'])) { |
|
| 31 | + if( empty($args['value']) ) { |
|
| 32 | 32 | $args['value'] = $this->widgetArgs[$args['name']]; |
| 33 | 33 | } |
| 34 | - if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) { |
|
| 35 | - $args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]); |
|
| 34 | + if( empty($this->widgetArgs['options']) && in_array( $tag, ['checkbox', 'radio'] ) ) { |
|
| 35 | + $args['checked'] = in_array( $args['value'], (array)$this->widgetArgs[$args['name']] ); |
|
| 36 | 36 | } |
| 37 | - $args['id'] = $this->get_field_id($args['name']); |
|
| 38 | - $args['name'] = $this->get_field_name($args['name']); |
|
| 37 | + $args['id'] = $this->get_field_id( $args['name'] ); |
|
| 38 | + $args['name'] = $this->get_field_name( $args['name'] ); |
|
| 39 | 39 | $args['is_widget'] = true; |
| 40 | 40 | return $args; |
| 41 | 41 | } |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | * @param string $tag |
| 45 | 45 | * @return void |
| 46 | 46 | */ |
| 47 | - protected function renderField($tag, array $args = []) |
|
| 47 | + protected function renderField( $tag, array $args = [] ) |
|
| 48 | 48 | { |
| 49 | - $args = $this->normalizeFieldAttributes($tag, $args); |
|
| 50 | - $field = glsr(Builder::class)->$tag($args['name'], $args); |
|
| 51 | - echo glsr(Builder::class)->div($field, [ |
|
| 49 | + $args = $this->normalizeFieldAttributes( $tag, $args ); |
|
| 50 | + $field = glsr( Builder::class )->$tag( $args['name'], $args ); |
|
| 51 | + echo glsr( Builder::class )->div( $field, [ |
|
| 52 | 52 | 'class' => 'glsr-field', |
| 53 | - ]); |
|
| 53 | + ] ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | * @params string|array $atts |
| 9 | 9 | * @return string |
| 10 | 10 | */ |
| 11 | - public function buildBlock($atts = []); |
|
| 11 | + public function buildBlock( $atts = [] ); |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * @param string|array $atts |
| 15 | 15 | * @return string |
| 16 | 16 | */ |
| 17 | - public function buildShortcode($atts = []); |
|
| 17 | + public function buildShortcode( $atts = [] ); |
|
| 18 | 18 | } |