@@ -1,4 +1,4 @@ |
||
| 1 | -<?php defined('WPINC') || die; ?> |
|
| 1 | +<?php defined( 'WPINC' ) || die; ?> |
|
| 2 | 2 | |
| 3 | 3 | <table class="form-table"> |
| 4 | 4 | <tbody> |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php defined('WPINC') || die; ?> |
|
| 1 | +<?php defined( 'WPINC' ) || die; ?> |
|
| 2 | 2 | |
| 3 | 3 | <table class="form-table"> |
| 4 | 4 | <tbody> |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -defined('WPINC') || die; |
|
| 3 | +defined( 'WPINC' ) || die; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Check for minimum system requirments on plugin activation. |
@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * @param string $file |
| 26 | 26 | */ |
| 27 | - public function __construct($file, array $versions = array()) |
|
| 27 | + public function __construct( $file, array $versions = array() ) |
|
| 28 | 28 | { |
| 29 | - $this->file = realpath($file); |
|
| 30 | - $this->versions = wp_parse_args($versions, array( |
|
| 29 | + $this->file = realpath( $file ); |
|
| 30 | + $this->versions = wp_parse_args( $versions, array( |
|
| 31 | 31 | 'php' => static::MIN_PHP_VERSION, |
| 32 | 32 | 'wordpress' => static::MIN_WORDPRESS_VERSION, |
| 33 | - )); |
|
| 33 | + ) ); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function canProceed() |
| 40 | 40 | { |
| 41 | - if ($this->isValid()) { |
|
| 41 | + if( $this->isValid() ) { |
|
| 42 | 42 | return true; |
| 43 | 43 | } |
| 44 | - add_action('activated_plugin', array($this, 'deactivate')); |
|
| 45 | - add_action('admin_notices', array($this, 'deactivate')); |
|
| 44 | + add_action( 'activated_plugin', array( $this, 'deactivate' ) ); |
|
| 45 | + add_action( 'admin_notices', array( $this, 'deactivate' ) ); |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function isPhpValid() |
| 53 | 53 | { |
| 54 | - return !version_compare(PHP_VERSION, $this->versions['php'], '<'); |
|
| 54 | + return !version_compare( PHP_VERSION, $this->versions['php'], '<' ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -68,25 +68,25 @@ discard block |
||
| 68 | 68 | public function isWpValid() |
| 69 | 69 | { |
| 70 | 70 | global $wp_version; |
| 71 | - return !version_compare($wp_version, $this->versions['wordpress'], '<'); |
|
| 71 | + return !version_compare( $wp_version, $this->versions['wordpress'], '<' ); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @param string $plugin |
| 76 | 76 | * @return void |
| 77 | 77 | */ |
| 78 | - public function deactivate($plugin) |
|
| 78 | + public function deactivate( $plugin ) |
|
| 79 | 79 | { |
| 80 | - if ($this->isValid()) { |
|
| 80 | + if( $this->isValid() ) { |
|
| 81 | 81 | return; |
| 82 | 82 | } |
| 83 | - $pluginSlug = plugin_basename($this->file); |
|
| 84 | - if ($plugin == $pluginSlug) { |
|
| 83 | + $pluginSlug = plugin_basename( $this->file ); |
|
| 84 | + if( $plugin == $pluginSlug ) { |
|
| 85 | 85 | $this->redirect(); //exit |
| 86 | 86 | } |
| 87 | - $pluginData = get_file_data($this->file, array('name' => 'Plugin Name'), 'plugin'); |
|
| 88 | - deactivate_plugins($pluginSlug); |
|
| 89 | - $this->printNotice($pluginData['name']); |
|
| 87 | + $pluginData = get_file_data( $this->file, array( 'name' => 'Plugin Name' ), 'plugin' ); |
|
| 88 | + deactivate_plugins( $pluginSlug ); |
|
| 89 | + $this->printNotice( $pluginData['name'] ); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -95,13 +95,13 @@ discard block |
||
| 95 | 95 | protected function getMessages() |
| 96 | 96 | { |
| 97 | 97 | return array( |
| 98 | - __('The %s plugin was deactivated.', 'site-reviews'), |
|
| 99 | - __('This plugin requires %s or greater in order to work properly.', 'site-reviews'), |
|
| 100 | - __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews'), |
|
| 101 | - __('PHP version', 'site-reviews'), |
|
| 102 | - __('WordPress version', 'site-reviews'), |
|
| 103 | - __('Update WordPress', 'site-reviews'), |
|
| 104 | - __('You can use the %s plugin to restore %s to the previous version.', 'site-reviews'), |
|
| 98 | + __( 'The %s plugin was deactivated.', 'site-reviews' ), |
|
| 99 | + __( 'This plugin requires %s or greater in order to work properly.', 'site-reviews' ), |
|
| 100 | + __( 'Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews' ), |
|
| 101 | + __( 'PHP version', 'site-reviews' ), |
|
| 102 | + __( 'WordPress version', 'site-reviews' ), |
|
| 103 | + __( 'Update WordPress', 'site-reviews' ), |
|
| 104 | + __( 'You can use the %s plugin to restore %s to the previous version.', 'site-reviews' ), |
|
| 105 | 105 | ); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -109,22 +109,22 @@ discard block |
||
| 109 | 109 | * @param string $pluginName |
| 110 | 110 | * @return void |
| 111 | 111 | */ |
| 112 | - protected function printNotice($pluginName) |
|
| 112 | + protected function printNotice( $pluginName ) |
|
| 113 | 113 | { |
| 114 | 114 | $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>'; |
| 115 | 115 | $messages = $this->getMessages(); |
| 116 | - $rollbackMessage = sprintf('<strong>'.$messages[6].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName); |
|
| 117 | - if (!$this->isPhpValid()) { |
|
| 118 | - printf($noticeTemplate, |
|
| 119 | - sprintf($messages[0], $pluginName), |
|
| 120 | - sprintf($messages[1], $messages[3].' '.$this->versions['php']), |
|
| 121 | - sprintf($messages[2], PHP_VERSION).'</p><p>'.$rollbackMessage |
|
| 116 | + $rollbackMessage = sprintf( '<strong>'.$messages[6].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName ); |
|
| 117 | + if( !$this->isPhpValid() ) { |
|
| 118 | + printf( $noticeTemplate, |
|
| 119 | + sprintf( $messages[0], $pluginName ), |
|
| 120 | + sprintf( $messages[1], $messages[3].' '.$this->versions['php'] ), |
|
| 121 | + sprintf( $messages[2], PHP_VERSION ).'</p><p>'.$rollbackMessage |
|
| 122 | 122 | ); |
| 123 | - } elseif (!$this->isWpValid()) { |
|
| 124 | - printf($noticeTemplate, |
|
| 125 | - sprintf($messages[0], $pluginName), |
|
| 126 | - sprintf($messages[1], $messages[4].' '.$this->versions['wordpress']), |
|
| 127 | - $rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages[5]) |
|
| 123 | + } elseif( !$this->isWpValid() ) { |
|
| 124 | + printf( $noticeTemplate, |
|
| 125 | + sprintf( $messages[0], $pluginName ), |
|
| 126 | + sprintf( $messages[1], $messages[4].' '.$this->versions['wordpress'] ), |
|
| 127 | + $rollbackMessage.'</p><p>'.sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[5] ) |
|
| 128 | 128 | ); |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | protected function redirect() |
| 136 | 136 | { |
| 137 | - wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
| 138 | - filter_input(INPUT_GET, 'plugin_status'), |
|
| 139 | - filter_input(INPUT_GET, 'paged'), |
|
| 140 | - filter_input(INPUT_GET, 's') |
|
| 141 | - ))); |
|
| 137 | + wp_safe_redirect( self_admin_url( sprintf( 'plugins.php?plugin_status=%s&paged=%s&s=%s', |
|
| 138 | + filter_input( INPUT_GET, 'plugin_status' ), |
|
| 139 | + filter_input( INPUT_GET, 'paged' ), |
|
| 140 | + filter_input( INPUT_GET, 's' ) |
|
| 141 | + ) ) ); |
|
| 142 | 142 | exit; |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php defined('WPINC') || die; ?> |
|
| 1 | +<?php defined( 'WPINC' ) || die; ?> |
|
| 2 | 2 | |
| 3 | 3 | <div class="glsr-form-wrap"> |
| 4 | 4 | <form class="{{ class }}" id="{{ id }}" method="post" enctype="multipart/form-data"> |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php defined('WPINC') || die; ?> |
|
| 1 | +<?php defined( 'WPINC' ) || die; ?> |
|
| 2 | 2 | |
| 3 | 3 | <div class="glsr-form-message {{ class }}"> |
| 4 | 4 | {{ message }} |
@@ -18,31 +18,31 @@ discard block |
||
| 18 | 18 | * @param string $id |
| 19 | 19 | * @return string |
| 20 | 20 | */ |
| 21 | - public function buildFields($id) |
|
| 21 | + public function buildFields( $id ) |
|
| 22 | 22 | { |
| 23 | - $this->settings = glsr(DefaultsManager::class)->settings(); |
|
| 24 | - $method = glsr(Helper::class)->buildMethodName($id, 'getTemplateDataFor'); |
|
| 25 | - $data = !method_exists($this, $method) |
|
| 26 | - ? $this->getTemplateData($id) |
|
| 27 | - : $this->$method($id); |
|
| 28 | - return glsr(Template::class)->build('pages/settings/'.$id, $data); |
|
| 23 | + $this->settings = glsr( DefaultsManager::class )->settings(); |
|
| 24 | + $method = glsr( Helper::class )->buildMethodName( $id, 'getTemplateDataFor' ); |
|
| 25 | + $data = !method_exists( $this, $method ) |
|
| 26 | + ? $this->getTemplateData( $id ) |
|
| 27 | + : $this->$method( $id ); |
|
| 28 | + return glsr( Template::class )->build( 'pages/settings/'.$id, $data ); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | - protected function getFieldDefault(array $field) |
|
| 34 | + protected function getFieldDefault( array $field ) |
|
| 35 | 35 | { |
| 36 | - return glsr_get($field, 'default'); |
|
| 36 | + return glsr_get( $field, 'default' ); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | - protected function getFieldNameForDependsOn($path) |
|
| 42 | + protected function getFieldNameForDependsOn( $path ) |
|
| 43 | 43 | { |
| 44 | - $fieldName = glsr(Helper::class)->convertPathToName($path, OptionManager::databaseKey()); |
|
| 45 | - return $this->isMultiDependency($path) |
|
| 44 | + $fieldName = glsr( Helper::class )->convertPathToName( $path, OptionManager::databaseKey() ); |
|
| 45 | + return $this->isMultiDependency( $path ) |
|
| 46 | 46 | ? $fieldName.'[]' |
| 47 | 47 | : $fieldName; |
| 48 | 48 | } |
@@ -50,25 +50,25 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * @return array |
| 52 | 52 | */ |
| 53 | - protected function getSettingFields($path) |
|
| 53 | + protected function getSettingFields( $path ) |
|
| 54 | 54 | { |
| 55 | - return array_filter($this->settings, function ($key) use ($path) { |
|
| 56 | - return glsr(Helper::class)->startsWith($path, $key); |
|
| 57 | - }, ARRAY_FILTER_USE_KEY); |
|
| 55 | + return array_filter( $this->settings, function( $key ) use ($path) { |
|
| 56 | + return glsr( Helper::class )->startsWith( $path, $key ); |
|
| 57 | + }, ARRAY_FILTER_USE_KEY ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - protected function getSettingRows(array $fields) |
|
| 63 | + protected function getSettingRows( array $fields ) |
|
| 64 | 64 | { |
| 65 | 65 | $rows = ''; |
| 66 | - foreach ($fields as $name => $field) { |
|
| 67 | - $field = wp_parse_args($field, [ |
|
| 66 | + foreach( $fields as $name => $field ) { |
|
| 67 | + $field = wp_parse_args( $field, [ |
|
| 68 | 68 | 'is_setting' => true, |
| 69 | 69 | 'name' => $name, |
| 70 | - ]); |
|
| 71 | - $rows.= new Field($this->normalize($field)); |
|
| 70 | + ] ); |
|
| 71 | + $rows .= new Field( $this->normalize( $field ) ); |
|
| 72 | 72 | } |
| 73 | 73 | return $rows; |
| 74 | 74 | } |
@@ -77,12 +77,12 @@ discard block |
||
| 77 | 77 | * @param string $id |
| 78 | 78 | * @return array |
| 79 | 79 | */ |
| 80 | - protected function getTemplateData($id) |
|
| 80 | + protected function getTemplateData( $id ) |
|
| 81 | 81 | { |
| 82 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
| 82 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
| 83 | 83 | return [ |
| 84 | 84 | 'context' => [ |
| 85 | - 'rows' => $this->getSettingRows($fields), |
|
| 85 | + 'rows' => $this->getSettingRows( $fields ), |
|
| 86 | 86 | ], |
| 87 | 87 | ]; |
| 88 | 88 | } |
@@ -91,19 +91,19 @@ discard block |
||
| 91 | 91 | * @param string $id |
| 92 | 92 | * @return array |
| 93 | 93 | */ |
| 94 | - protected function getTemplateDataForAddons($id) |
|
| 94 | + protected function getTemplateDataForAddons( $id ) |
|
| 95 | 95 | { |
| 96 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
| 97 | - $settings = glsr(Helper::class)->convertDotNotationArray($fields); |
|
| 98 | - $settingKeys = array_keys($settings['settings']['addons']); |
|
| 96 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
| 97 | + $settings = glsr( Helper::class )->convertDotNotationArray( $fields ); |
|
| 98 | + $settingKeys = array_keys( $settings['settings']['addons'] ); |
|
| 99 | 99 | $results = []; |
| 100 | - foreach ($settingKeys as $key) { |
|
| 101 | - $addonFields = array_filter($fields, function ($path) use ($key) { |
|
| 102 | - return glsr(Helper::class)->startsWith('settings.addons.'.$key, $path); |
|
| 103 | - }, ARRAY_FILTER_USE_KEY); |
|
| 104 | - $results[$key] = $this->getSettingRows($addonFields); |
|
| 100 | + foreach( $settingKeys as $key ) { |
|
| 101 | + $addonFields = array_filter( $fields, function( $path ) use ($key) { |
|
| 102 | + return glsr( Helper::class )->startsWith( 'settings.addons.'.$key, $path ); |
|
| 103 | + }, ARRAY_FILTER_USE_KEY ); |
|
| 104 | + $results[$key] = $this->getSettingRows( $addonFields ); |
|
| 105 | 105 | } |
| 106 | - ksort($results); |
|
| 106 | + ksort( $results ); |
|
| 107 | 107 | return [ |
| 108 | 108 | 'settings' => $results, |
| 109 | 109 | ]; |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | * @param string $id |
| 114 | 114 | * @return array |
| 115 | 115 | */ |
| 116 | - protected function getTemplateDataForLicenses($id) |
|
| 116 | + protected function getTemplateDataForLicenses( $id ) |
|
| 117 | 117 | { |
| 118 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
| 119 | - ksort($fields); |
|
| 118 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
| 119 | + ksort( $fields ); |
|
| 120 | 120 | return [ |
| 121 | 121 | 'context' => [ |
| 122 | - 'rows' => $this->getSettingRows($fields), |
|
| 122 | + 'rows' => $this->getSettingRows( $fields ), |
|
| 123 | 123 | ], |
| 124 | 124 | ]; |
| 125 | 125 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | protected function getTemplateDataForTranslations() |
| 131 | 131 | { |
| 132 | - $translations = glsr(Translation::class)->renderAll(); |
|
| 132 | + $translations = glsr( Translation::class )->renderAll(); |
|
| 133 | 133 | $class = empty($translations) |
| 134 | 134 | ? 'glsr-hidden' |
| 135 | 135 | : ''; |
@@ -147,16 +147,16 @@ discard block |
||
| 147 | 147 | * @param string|array $expectedValue |
| 148 | 148 | * @return bool |
| 149 | 149 | */ |
| 150 | - protected function isFieldHidden($path, $expectedValue) |
|
| 150 | + protected function isFieldHidden( $path, $expectedValue ) |
|
| 151 | 151 | { |
| 152 | - $optionValue = glsr(OptionManager::class)->get( |
|
| 152 | + $optionValue = glsr( OptionManager::class )->get( |
|
| 153 | 153 | $path, |
| 154 | - glsr(Helper::class)->dataGet(glsr()->defaults, $path) |
|
| 154 | + glsr( Helper::class )->dataGet( glsr()->defaults, $path ) |
|
| 155 | 155 | ); |
| 156 | - if (is_array($expectedValue)) { |
|
| 157 | - return is_array($optionValue) |
|
| 158 | - ? 0 === count(array_intersect($optionValue, $expectedValue)) |
|
| 159 | - : !in_array($optionValue, $expectedValue); |
|
| 156 | + if( is_array( $expectedValue ) ) { |
|
| 157 | + return is_array( $optionValue ) |
|
| 158 | + ? 0 === count( array_intersect( $optionValue, $expectedValue ) ) |
|
| 159 | + : !in_array( $optionValue, $expectedValue ); |
|
| 160 | 160 | } |
| 161 | 161 | return $optionValue != $expectedValue; |
| 162 | 162 | } |
@@ -164,9 +164,9 @@ discard block |
||
| 164 | 164 | /** |
| 165 | 165 | * @return bool |
| 166 | 166 | */ |
| 167 | - protected function isMultiDependency($path) |
|
| 167 | + protected function isMultiDependency( $path ) |
|
| 168 | 168 | { |
| 169 | - if (isset($this->settings[$path])) { |
|
| 169 | + if( isset($this->settings[$path]) ) { |
|
| 170 | 170 | $field = $this->settings[$path]; |
| 171 | 171 | return ('checkbox' == $field['type'] && !empty($field['options'])) |
| 172 | 172 | || !empty($field['multiple']); |
@@ -177,32 +177,32 @@ discard block |
||
| 177 | 177 | /** |
| 178 | 178 | * @return array |
| 179 | 179 | */ |
| 180 | - protected function normalize(array $field) |
|
| 180 | + protected function normalize( array $field ) |
|
| 181 | 181 | { |
| 182 | - $field = $this->normalizeDependsOn($field); |
|
| 183 | - $field = $this->normalizeLabelAndLegend($field); |
|
| 184 | - $field = $this->normalizeValue($field); |
|
| 182 | + $field = $this->normalizeDependsOn( $field ); |
|
| 183 | + $field = $this->normalizeLabelAndLegend( $field ); |
|
| 184 | + $field = $this->normalizeValue( $field ); |
|
| 185 | 185 | return $field; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | 189 | * @return array |
| 190 | 190 | */ |
| 191 | - protected function normalizeDependsOn(array $field) |
|
| 191 | + protected function normalizeDependsOn( array $field ) |
|
| 192 | 192 | { |
| 193 | - if (!empty($field['depends_on']) && is_array($field['depends_on'])) { |
|
| 193 | + if( !empty($field['depends_on']) && is_array( $field['depends_on'] ) ) { |
|
| 194 | 194 | $isFieldHidden = false; |
| 195 | 195 | $conditions = []; |
| 196 | - foreach ($field['depends_on'] as $path => $value) { |
|
| 196 | + foreach( $field['depends_on'] as $path => $value ) { |
|
| 197 | 197 | $conditions[] = [ |
| 198 | - 'name' => $this->getFieldNameForDependsOn($path), |
|
| 198 | + 'name' => $this->getFieldNameForDependsOn( $path ), |
|
| 199 | 199 | 'value' => $value, |
| 200 | 200 | ]; |
| 201 | - if ($this->isFieldHidden($path, $value)) { |
|
| 201 | + if( $this->isFieldHidden( $path, $value ) ) { |
|
| 202 | 202 | $isFieldHidden = true; |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | - $field['data-depends'] = json_encode($conditions, JSON_HEX_APOS | JSON_HEX_QUOT); |
|
| 205 | + $field['data-depends'] = json_encode( $conditions, JSON_HEX_APOS | JSON_HEX_QUOT ); |
|
| 206 | 206 | $field['is_hidden'] = $isFieldHidden; |
| 207 | 207 | } |
| 208 | 208 | return $field; |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | /** |
| 212 | 212 | * @return array |
| 213 | 213 | */ |
| 214 | - protected function normalizeLabelAndLegend(array $field) |
|
| 214 | + protected function normalizeLabelAndLegend( array $field ) |
|
| 215 | 215 | { |
| 216 | - if (!empty($field['label'])) { |
|
| 216 | + if( !empty($field['label']) ) { |
|
| 217 | 217 | $field['legend'] = $field['label']; |
| 218 | 218 | unset($field['label']); |
| 219 | 219 | } else { |
| 220 | 220 | $field['is_valid'] = false; |
| 221 | - glsr_log()->warning('Setting field is missing a label')->debug($field); |
|
| 221 | + glsr_log()->warning( 'Setting field is missing a label' )->debug( $field ); |
|
| 222 | 222 | } |
| 223 | 223 | return $field; |
| 224 | 224 | } |
@@ -226,12 +226,12 @@ discard block |
||
| 226 | 226 | /** |
| 227 | 227 | * @return array |
| 228 | 228 | */ |
| 229 | - protected function normalizeValue(array $field) |
|
| 229 | + protected function normalizeValue( array $field ) |
|
| 230 | 230 | { |
| 231 | - if (!isset($field['value'])) { |
|
| 232 | - $field['value'] = glsr(OptionManager::class)->get( |
|
| 231 | + if( !isset($field['value']) ) { |
|
| 232 | + $field['value'] = glsr( OptionManager::class )->get( |
|
| 233 | 233 | $field['name'], |
| 234 | - $this->getFieldDefault($field) |
|
| 234 | + $this->getFieldDefault( $field ) |
|
| 235 | 235 | ); |
| 236 | 236 | } |
| 237 | 237 | return $field; |
@@ -240,8 +240,8 @@ discard block |
||
| 240 | 240 | /** |
| 241 | 241 | * @return string |
| 242 | 242 | */ |
| 243 | - protected function normalizeSettingPath($path) |
|
| 243 | + protected function normalizeSettingPath( $path ) |
|
| 244 | 244 | { |
| 245 | - return glsr(Helper::class)->prefixString(rtrim($path, '.'), 'settings.'); |
|
| 245 | + return glsr( Helper::class )->prefixString( rtrim( $path, '.' ), 'settings.' ); |
|
| 246 | 246 | } |
| 247 | 247 | } |
@@ -61,18 +61,18 @@ discard block |
||
| 61 | 61 | * @param array $args |
| 62 | 62 | * @return string|void |
| 63 | 63 | */ |
| 64 | - public function __call($method, $args) |
|
| 64 | + public function __call( $method, $args ) |
|
| 65 | 65 | { |
| 66 | 66 | $instance = new static(); |
| 67 | - $instance->setTagFromMethod($method); |
|
| 68 | - call_user_func_array([$instance, 'normalize'], $args += ['', '']); |
|
| 69 | - $tags = array_merge(static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT); |
|
| 70 | - do_action_ref_array('site-reviews/builder', [$instance]); |
|
| 71 | - $generatedTag = in_array($instance->tag, $tags) |
|
| 67 | + $instance->setTagFromMethod( $method ); |
|
| 68 | + call_user_func_array( [$instance, 'normalize'], $args += ['', ''] ); |
|
| 69 | + $tags = array_merge( static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT ); |
|
| 70 | + do_action_ref_array( 'site-reviews/builder', [$instance] ); |
|
| 71 | + $generatedTag = in_array( $instance->tag, $tags ) |
|
| 72 | 72 | ? $instance->buildTag() |
| 73 | 73 | : $instance->buildCustomField(); |
| 74 | - $generatedTag = apply_filters('site-reviews/builder/result', $generatedTag, $instance); |
|
| 75 | - if (!$this->render) { |
|
| 74 | + $generatedTag = apply_filters( 'site-reviews/builder/result', $generatedTag, $instance ); |
|
| 75 | + if( !$this->render ) { |
|
| 76 | 76 | return $generatedTag; |
| 77 | 77 | } |
| 78 | 78 | echo $generatedTag; |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | * @param mixed $value |
| 84 | 84 | * @return void |
| 85 | 85 | */ |
| 86 | - public function __set($property, $value) |
|
| 86 | + public function __set( $property, $value ) |
|
| 87 | 87 | { |
| 88 | 88 | $properties = [ |
| 89 | 89 | 'args' => 'is_array', |
| 90 | 90 | 'render' => 'is_bool', |
| 91 | 91 | 'tag' => 'is_string', |
| 92 | 92 | ]; |
| 93 | - if (!isset($properties[$property]) |
|
| 94 | - || empty(array_filter([$value], $properties[$property])) |
|
| 93 | + if( !isset($properties[$property]) |
|
| 94 | + || empty(array_filter( [$value], $properties[$property] )) |
|
| 95 | 95 | ) { |
| 96 | 96 | return; |
| 97 | 97 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function getClosingTag() |
| 105 | 105 | { |
| 106 | - if (empty($this->tag)) { |
|
| 106 | + if( empty($this->tag) ) { |
|
| 107 | 107 | return; |
| 108 | 108 | } |
| 109 | 109 | return '</'.$this->tag.'>'; |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function getOpeningTag() |
| 116 | 116 | { |
| 117 | - if (empty($this->tag)) { |
|
| 117 | + if( empty($this->tag) ) { |
|
| 118 | 118 | return; |
| 119 | 119 | } |
| 120 | - $attributes = glsr(Attributes::class)->{$this->tag}($this->args)->toString(); |
|
| 121 | - return '<'.trim($this->tag.' '.$attributes).'>'; |
|
| 120 | + $attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString(); |
|
| 121 | + return '<'.trim( $this->tag.' '.$attributes ).'>'; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -126,19 +126,19 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function getTag() |
| 128 | 128 | { |
| 129 | - if (in_array($this->tag, static::TAGS_SINGLE)) { |
|
| 129 | + if( in_array( $this->tag, static::TAGS_SINGLE ) ) { |
|
| 130 | 130 | return $this->getOpeningTag(); |
| 131 | 131 | } |
| 132 | - if (!in_array($this->tag, static::TAGS_FORM)) { |
|
| 132 | + if( !in_array( $this->tag, static::TAGS_FORM ) ) { |
|
| 133 | 133 | return $this->buildDefaultTag(); |
| 134 | 134 | } |
| 135 | - return call_user_func([$this, 'buildForm'.ucfirst($this->tag)]).$this->buildFieldDescription(); |
|
| 135 | + return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription(); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * @return string |
| 140 | 140 | */ |
| 141 | - public function raw(array $field) |
|
| 141 | + public function raw( array $field ) |
|
| 142 | 142 | { |
| 143 | 143 | unset($field['label']); |
| 144 | 144 | return $this->{$field['type']}($field); |
@@ -150,18 +150,18 @@ discard block |
||
| 150 | 150 | protected function buildCustomField() |
| 151 | 151 | { |
| 152 | 152 | $className = $this->getCustomFieldClassName(); |
| 153 | - if (class_exists($className)) { |
|
| 154 | - return (new $className($this))->build(); |
|
| 153 | + if( class_exists( $className ) ) { |
|
| 154 | + return (new $className( $this ))->build(); |
|
| 155 | 155 | } |
| 156 | - glsr_log()->error('Field missing: '.$className); |
|
| 156 | + glsr_log()->error( 'Field missing: '.$className ); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
| 160 | 160 | * @return string|void |
| 161 | 161 | */ |
| 162 | - protected function buildDefaultTag($text = '') |
|
| 162 | + protected function buildDefaultTag( $text = '' ) |
|
| 163 | 163 | { |
| 164 | - if (empty($text)) { |
|
| 164 | + if( empty($text) ) { |
|
| 165 | 165 | $text = $this->args['text']; |
| 166 | 166 | } |
| 167 | 167 | return $this->getOpeningTag().$text.$this->getClosingTag(); |
@@ -172,13 +172,13 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | protected function buildFieldDescription() |
| 174 | 174 | { |
| 175 | - if (empty($this->args['description'])) { |
|
| 175 | + if( empty($this->args['description']) ) { |
|
| 176 | 176 | return; |
| 177 | 177 | } |
| 178 | - if ($this->args['is_widget']) { |
|
| 179 | - return $this->small($this->args['description']); |
|
| 178 | + if( $this->args['is_widget'] ) { |
|
| 179 | + return $this->small( $this->args['description'] ); |
|
| 180 | 180 | } |
| 181 | - return $this->p($this->args['description'], ['class' => 'description']); |
|
| 181 | + return $this->p( $this->args['description'], ['class' => 'description'] ); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | protected function buildFormInput() |
| 188 | 188 | { |
| 189 | - if (!in_array($this->args['type'], ['checkbox', 'radio'])) { |
|
| 190 | - if (isset($this->args['multiple'])) { |
|
| 191 | - $this->args['name'].= '[]'; |
|
| 189 | + if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) { |
|
| 190 | + if( isset($this->args['multiple']) ) { |
|
| 191 | + $this->args['name'] .= '[]'; |
|
| 192 | 192 | } |
| 193 | 193 | return $this->buildFormLabel().$this->getOpeningTag(); |
| 194 | 194 | } |
@@ -202,19 +202,19 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | protected function buildFormInputChoice() |
| 204 | 204 | { |
| 205 | - if (!empty($this->args['text'])) { |
|
| 205 | + if( !empty($this->args['text']) ) { |
|
| 206 | 206 | $this->args['label'] = $this->args['text']; |
| 207 | 207 | } |
| 208 | - if (!$this->args['is_public']) { |
|
| 209 | - return $this->buildFormLabel([ |
|
| 208 | + if( !$this->args['is_public'] ) { |
|
| 209 | + return $this->buildFormLabel( [ |
|
| 210 | 210 | 'class' => 'glsr-'.$this->args['type'].'-label', |
| 211 | 211 | 'text' => $this->getOpeningTag().' '.$this->args['label'].'<span></span>', |
| 212 | - ]); |
|
| 212 | + ] ); |
|
| 213 | 213 | } |
| 214 | - return $this->getOpeningTag().$this->buildFormLabel([ |
|
| 214 | + return $this->getOpeningTag().$this->buildFormLabel( [ |
|
| 215 | 215 | 'class' => 'glsr-'.$this->args['type'].'-label', |
| 216 | 216 | 'text' => $this->args['label'].'<span></span>', |
| 217 | - ]); |
|
| 217 | + ] ); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -222,39 +222,39 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | protected function buildFormInputMultiChoice() |
| 224 | 224 | { |
| 225 | - if ('checkbox' == $this->args['type']) { |
|
| 226 | - $this->args['name'].= '[]'; |
|
| 225 | + if( 'checkbox' == $this->args['type'] ) { |
|
| 226 | + $this->args['name'] .= '[]'; |
|
| 227 | 227 | } |
| 228 | 228 | $index = 0; |
| 229 | - $options = array_reduce(array_keys($this->args['options']), function ($carry, $key) use (&$index) { |
|
| 230 | - return $carry.$this->li($this->{$this->args['type']}([ |
|
| 231 | - 'checked' => in_array($key, (array) $this->args['value']), |
|
| 229 | + $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use (&$index) { |
|
| 230 | + return $carry.$this->li( $this->{$this->args['type']}([ |
|
| 231 | + 'checked' => in_array( $key, (array)$this->args['value'] ), |
|
| 232 | 232 | 'id' => $this->args['id'].'-'.$index++, |
| 233 | 233 | 'name' => $this->args['name'], |
| 234 | 234 | 'text' => $this->args['options'][$key], |
| 235 | 235 | 'value' => $key, |
| 236 | - ])); |
|
| 236 | + ]) ); |
|
| 237 | 237 | }); |
| 238 | - return $this->ul($options, [ |
|
| 238 | + return $this->ul( $options, [ |
|
| 239 | 239 | 'class' => $this->args['class'], |
| 240 | 240 | 'id' => $this->args['id'], |
| 241 | - ]); |
|
| 241 | + ] ); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | 245 | * @return void|string |
| 246 | 246 | */ |
| 247 | - protected function buildFormLabel(array $customArgs = []) |
|
| 247 | + protected function buildFormLabel( array $customArgs = [] ) |
|
| 248 | 248 | { |
| 249 | - if (empty($this->args['label']) || 'hidden' == $this->args['type']) { |
|
| 249 | + if( empty($this->args['label']) || 'hidden' == $this->args['type'] ) { |
|
| 250 | 250 | return; |
| 251 | 251 | } |
| 252 | - return $this->label(wp_parse_args($customArgs, [ |
|
| 252 | + return $this->label( wp_parse_args( $customArgs, [ |
|
| 253 | 253 | 'for' => $this->args['id'], |
| 254 | 254 | 'is_public' => $this->args['is_public'], |
| 255 | 255 | 'text' => $this->args['label'], |
| 256 | 256 | 'type' => $this->args['type'], |
| 257 | - ])); |
|
| 257 | + ] ) ); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | protected function buildFormSelect() |
| 264 | 264 | { |
| 265 | - return $this->buildFormLabel().$this->buildDefaultTag($this->buildFormSelectOptions()); |
|
| 265 | + return $this->buildFormLabel().$this->buildDefaultTag( $this->buildFormSelectOptions() ); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -270,12 +270,12 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | protected function buildFormSelectOptions() |
| 272 | 272 | { |
| 273 | - return array_reduce(array_keys($this->args['options']), function ($carry, $key) { |
|
| 274 | - return $carry.$this->option([ |
|
| 273 | + return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
|
| 274 | + return $carry.$this->option( [ |
|
| 275 | 275 | 'selected' => $this->args['value'] == $key, |
| 276 | 276 | 'text' => $this->args['options'][$key], |
| 277 | 277 | 'value' => $key, |
| 278 | - ]); |
|
| 278 | + ] ); |
|
| 279 | 279 | }); |
| 280 | 280 | } |
| 281 | 281 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | protected function buildFormTextarea() |
| 286 | 286 | { |
| 287 | - return $this->buildFormLabel().$this->buildDefaultTag($this->args['value']); |
|
| 287 | + return $this->buildFormLabel().$this->buildDefaultTag( $this->args['value'] ); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -301,8 +301,8 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | protected function getCustomFieldClassName() |
| 303 | 303 | { |
| 304 | - $classname = glsr(Helper::class)->buildClassName($this->tag, __NAMESPACE__.'\Fields'); |
|
| 305 | - return apply_filters('site-reviews/builder/field/'.$this->tag, $classname); |
|
| 304 | + $classname = glsr( Helper::class )->buildClassName( $this->tag, __NAMESPACE__.'\Fields' ); |
|
| 305 | + return apply_filters( 'site-reviews/builder/field/'.$this->tag, $classname ); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -311,27 +311,27 @@ discard block |
||
| 311 | 311 | protected function mergeArgsWithRequiredDefaults() |
| 312 | 312 | { |
| 313 | 313 | $className = $this->getCustomFieldClassName(); |
| 314 | - if (class_exists($className)) { |
|
| 315 | - $this->args = $className::merge($this->args); |
|
| 314 | + if( class_exists( $className ) ) { |
|
| 315 | + $this->args = $className::merge( $this->args ); |
|
| 316 | 316 | } |
| 317 | - $this->args = glsr(BuilderDefaults::class)->merge($this->args); |
|
| 317 | + $this->args = glsr( BuilderDefaults::class )->merge( $this->args ); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * @param string|array ...$params |
| 322 | 322 | * @return void |
| 323 | 323 | */ |
| 324 | - protected function normalize(...$params) |
|
| 324 | + protected function normalize( ...$params ) |
|
| 325 | 325 | { |
| 326 | - if (is_string($params[0]) || is_numeric($params[0])) { |
|
| 327 | - $this->setNameOrTextAttributeForTag($params[0]); |
|
| 326 | + if( is_string( $params[0] ) || is_numeric( $params[0] ) ) { |
|
| 327 | + $this->setNameOrTextAttributeForTag( $params[0] ); |
|
| 328 | 328 | } |
| 329 | - if (is_array($params[0])) { |
|
| 329 | + if( is_array( $params[0] ) ) { |
|
| 330 | 330 | $this->args += $params[0]; |
| 331 | - } elseif (is_array($params[1])) { |
|
| 331 | + } elseif( is_array( $params[1] ) ) { |
|
| 332 | 332 | $this->args += $params[1]; |
| 333 | 333 | } |
| 334 | - if (!isset($this->args['is_public'])) { |
|
| 334 | + if( !isset($this->args['is_public']) ) { |
|
| 335 | 335 | $this->args['is_public'] = false; |
| 336 | 336 | } |
| 337 | 337 | } |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | * @param string $value |
| 341 | 341 | * @return void |
| 342 | 342 | */ |
| 343 | - protected function setNameOrTextAttributeForTag($value) |
|
| 343 | + protected function setNameOrTextAttributeForTag( $value ) |
|
| 344 | 344 | { |
| 345 | - $attribute = in_array($this->tag, static::TAGS_FORM) |
|
| 345 | + $attribute = in_array( $this->tag, static::TAGS_FORM ) |
|
| 346 | 346 | ? 'name' |
| 347 | 347 | : 'text'; |
| 348 | 348 | $this->args[$attribute] = $value; |
@@ -352,10 +352,10 @@ discard block |
||
| 352 | 352 | * @param string $method |
| 353 | 353 | * @return void |
| 354 | 354 | */ |
| 355 | - protected function setTagFromMethod($method) |
|
| 355 | + protected function setTagFromMethod( $method ) |
|
| 356 | 356 | { |
| 357 | - $this->tag = strtolower($method); |
|
| 358 | - if (in_array($this->tag, static::INPUT_TYPES)) { |
|
| 357 | + $this->tag = strtolower( $method ); |
|
| 358 | + if( in_array( $this->tag, static::INPUT_TYPES ) ) { |
|
| 359 | 359 | $this->args['type'] = $this->tag; |
| 360 | 360 | $this->tag = 'input'; |
| 361 | 361 | } |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public $reviews; |
| 29 | 29 | |
| 30 | - public function __construct(array $reviews, $maxPageCount, array $args) |
|
| 30 | + public function __construct( array $reviews, $maxPageCount, array $args ) |
|
| 31 | 31 | { |
| 32 | 32 | $this->args = $args; |
| 33 | 33 | $this->max_num_pages = $maxPageCount; |
| 34 | 34 | $this->reviews = $reviews; |
| 35 | 35 | $this->pagination = $this->buildPagination(); |
| 36 | - parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
| 36 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function __toString() |
| 43 | 43 | { |
| 44 | - return glsr(Template::class)->build('templates/reviews', [ |
|
| 44 | + return glsr( Template::class )->build( 'templates/reviews', [ |
|
| 45 | 45 | 'args' => $this->args, |
| 46 | 46 | 'context' => [ |
| 47 | 47 | 'assigned_to' => $this->args['assigned_to'], |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | 'pagination' => $this->getPagination(), |
| 52 | 52 | 'reviews' => $this->getReviews(), |
| 53 | 53 | ], |
| 54 | - ]); |
|
| 54 | + ] ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function getPagination() |
| 61 | 61 | { |
| 62 | - return wp_validate_boolean($this->args['pagination']) |
|
| 62 | + return wp_validate_boolean( $this->args['pagination'] ) |
|
| 63 | 63 | ? $this->pagination |
| 64 | 64 | : ''; |
| 65 | 65 | } |
@@ -71,26 +71,26 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $html = empty($this->reviews) |
| 73 | 73 | ? $this->getReviewsFallback() |
| 74 | - : implode(PHP_EOL, $this->reviews); |
|
| 74 | + : implode( PHP_EOL, $this->reviews ); |
|
| 75 | 75 | $wrapper = '<div class="glsr-reviews">%s</div>'; |
| 76 | - $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper); |
|
| 77 | - return sprintf($wrapper, $html); |
|
| 76 | + $wrapper = apply_filters( 'site-reviews/reviews/reviews-wrapper', $wrapper ); |
|
| 77 | + return sprintf( $wrapper, $html ); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * @param mixed $key |
| 82 | 82 | * @return mixed |
| 83 | 83 | */ |
| 84 | - public function offsetGet($key) |
|
| 84 | + public function offsetGet( $key ) |
|
| 85 | 85 | { |
| 86 | - if ('navigation' == $key) { |
|
| 86 | + if( 'navigation' == $key ) { |
|
| 87 | 87 | glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.'; |
| 88 | 88 | return $this->pagination; |
| 89 | 89 | } |
| 90 | - if (property_exists($this, $key)) { |
|
| 90 | + if( property_exists( $this, $key ) ) { |
|
| 91 | 91 | return $this->{$key}; |
| 92 | 92 | } |
| 93 | - return array_key_exists($key, $this->reviews) |
|
| 93 | + return array_key_exists( $key, $this->reviews ) |
|
| 94 | 94 | ? $this->reviews[$key] |
| 95 | 95 | : null; |
| 96 | 96 | } |
@@ -100,15 +100,15 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected function buildPagination() |
| 102 | 102 | { |
| 103 | - $html = glsr(Partial::class)->build('pagination', [ |
|
| 104 | - 'baseUrl' => glsr_get($this->args, 'pagedUrl'), |
|
| 105 | - 'current' => glsr_get($this->args, 'paged'), |
|
| 103 | + $html = glsr( Partial::class )->build( 'pagination', [ |
|
| 104 | + 'baseUrl' => glsr_get( $this->args, 'pagedUrl' ), |
|
| 105 | + 'current' => glsr_get( $this->args, 'paged' ), |
|
| 106 | 106 | 'total' => $this->max_num_pages, |
| 107 | - ]); |
|
| 108 | - $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']); |
|
| 107 | + ] ); |
|
| 108 | + $html .= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] ); |
|
| 109 | 109 | $wrapper = '<div class="glsr-pagination">%s</div>'; |
| 110 | - $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper); |
|
| 111 | - return sprintf($wrapper, $html); |
|
| 110 | + $wrapper = apply_filters( 'site-reviews/reviews/pagination-wrapper', $wrapper ); |
|
| 111 | + return sprintf( $wrapper, $html ); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -119,12 +119,12 @@ discard block |
||
| 119 | 119 | $defaults = [ |
| 120 | 120 | 'glsr-default', |
| 121 | 121 | ]; |
| 122 | - if ('ajax' == $this->args['pagination']) { |
|
| 122 | + if( 'ajax' == $this->args['pagination'] ) { |
|
| 123 | 123 | $defaults[] = 'glsr-ajax-pagination'; |
| 124 | 124 | } |
| 125 | - $classes = explode(' ', $this->args['class']); |
|
| 126 | - $classes = array_unique(array_merge($defaults, array_filter($classes))); |
|
| 127 | - return implode(' ', $classes); |
|
| 125 | + $classes = explode( ' ', $this->args['class'] ); |
|
| 126 | + $classes = array_unique( array_merge( $defaults, array_filter( $classes ) ) ); |
|
| 127 | + return implode( ' ', $classes ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | protected function getReviewsFallback() |
| 134 | 134 | { |
| 135 | - if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) { |
|
| 136 | - $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews'); |
|
| 135 | + if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) { |
|
| 136 | + $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' ); |
|
| 137 | 137 | } |
| 138 | 138 | $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>'; |
| 139 | - return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args); |
|
| 139 | + return apply_filters( 'site-reviews/reviews/fallback', $fallback, $this->args ); |
|
| 140 | 140 | } |
| 141 | 141 | } |
@@ -13,41 +13,41 @@ discard block |
||
| 13 | 13 | * @param string|array|WP_Error $message |
| 14 | 14 | * @return void |
| 15 | 15 | */ |
| 16 | - public function add($type, $message, array $args = []) |
|
| 16 | + public function add( $type, $message, array $args = [] ) |
|
| 17 | 17 | { |
| 18 | - if (empty(array_filter([$message, $type]))) { |
|
| 18 | + if( empty(array_filter( [$message, $type] )) ) { |
|
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | 21 | $args['message'] = $message; |
| 22 | 22 | $args['type'] = $type; |
| 23 | - add_settings_error(Application::ID, '', json_encode($this->normalize($args))); |
|
| 23 | + add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ) ) ); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @param string|array|WP_Error $message |
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | - public function addError($message, array $args = []) |
|
| 30 | + public function addError( $message, array $args = [] ) |
|
| 31 | 31 | { |
| 32 | - $this->add('error', $message, $args); |
|
| 32 | + $this->add( 'error', $message, $args ); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * @param string|array|WP_Error $message |
| 37 | 37 | * @return void |
| 38 | 38 | */ |
| 39 | - public function addSuccess($message, array $args = []) |
|
| 39 | + public function addSuccess( $message, array $args = [] ) |
|
| 40 | 40 | { |
| 41 | - $this->add('success', $message, $args); |
|
| 41 | + $this->add( 'success', $message, $args ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * @param string|array|WP_Error $message |
| 46 | 46 | * @return void |
| 47 | 47 | */ |
| 48 | - public function addWarning($message, array $args = []) |
|
| 48 | + public function addWarning( $message, array $args = [] ) |
|
| 49 | 49 | { |
| 50 | - $this->add('warning', $message, $args); |
|
| 50 | + $this->add( 'warning', $message, $args ); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | global $wp_settings_errors; |
| 59 | 59 | $wp_settings_errors = []; |
| 60 | - delete_transient('settings_errors'); |
|
| 60 | + delete_transient( 'settings_errors' ); |
|
| 61 | 61 | return $this; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -66,41 +66,41 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function get() |
| 68 | 68 | { |
| 69 | - $notices = array_map('unserialize', |
|
| 70 | - array_unique(array_map('serialize', get_settings_errors(Application::ID))) |
|
| 69 | + $notices = array_map( 'unserialize', |
|
| 70 | + array_unique( array_map( 'serialize', get_settings_errors( Application::ID ) ) ) |
|
| 71 | 71 | ); |
| 72 | - if (empty($notices)) { |
|
| 72 | + if( empty($notices) ) { |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | - return array_reduce($notices, function ($carry, $notice) { |
|
| 76 | - return $carry.$this->buildNotice(json_decode($notice['message'], true)); |
|
| 75 | + return array_reduce( $notices, function( $carry, $notice ) { |
|
| 76 | + return $carry.$this->buildNotice( json_decode( $notice['message'], true ) ); |
|
| 77 | 77 | }); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * @return string |
| 82 | 82 | */ |
| 83 | - protected function buildNotice(array $args) |
|
| 83 | + protected function buildNotice( array $args ) |
|
| 84 | 84 | { |
| 85 | - $messages = array_reduce($args['messages'], function ($carry, $message) { |
|
| 86 | - return $carry.glsr(Builder::class)->p($message); |
|
| 85 | + $messages = array_reduce( $args['messages'], function( $carry, $message ) { |
|
| 86 | + return $carry.glsr( Builder::class )->p( $message ); |
|
| 87 | 87 | }); |
| 88 | 88 | $class = 'notice notice-'.$args['type']; |
| 89 | - if ($args['inline']) { |
|
| 90 | - $class.= ' inline'; |
|
| 89 | + if( $args['inline'] ) { |
|
| 90 | + $class .= ' inline'; |
|
| 91 | 91 | } |
| 92 | - if ($args['dismissible']) { |
|
| 93 | - $class.= ' is-dismissible'; |
|
| 92 | + if( $args['dismissible'] ) { |
|
| 93 | + $class .= ' is-dismissible'; |
|
| 94 | 94 | } |
| 95 | - return glsr(Builder::class)->div($messages, [ |
|
| 95 | + return glsr( Builder::class )->div( $messages, [ |
|
| 96 | 96 | 'class' => $class, |
| 97 | - ]); |
|
| 97 | + ] ); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * @return array |
| 102 | 102 | */ |
| 103 | - protected function normalize(array $args) |
|
| 103 | + protected function normalize( array $args ) |
|
| 104 | 104 | { |
| 105 | 105 | $defaults = [ |
| 106 | 106 | 'dismissible' => true, |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | 'message' => '', |
| 109 | 109 | 'type' => '', |
| 110 | 110 | ]; |
| 111 | - $args = shortcode_atts($defaults, $args); |
|
| 112 | - if (!in_array($args['type'], ['error', 'warning', 'success'])) { |
|
| 111 | + $args = shortcode_atts( $defaults, $args ); |
|
| 112 | + if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) { |
|
| 113 | 113 | $args['type'] = 'success'; |
| 114 | 114 | } |
| 115 | - $args['messages'] = is_wp_error($args['message']) |
|
| 116 | - ? (array) $args['message']->get_error_message() |
|
| 117 | - : (array) $args['message']; |
|
| 115 | + $args['messages'] = is_wp_error( $args['message'] ) |
|
| 116 | + ? (array)$args['message']->get_error_message() |
|
| 117 | + : (array)$args['message']; |
|
| 118 | 118 | unset($args['message']); |
| 119 | 119 | return $args; |
| 120 | 120 | } |