@@ -1,20 +1,20 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="wrap"> |
4 | - <h1 class="wp-heading-inline"><?= esc_html(get_admin_page_title()); ?></h1> |
|
4 | + <h1 class="wp-heading-inline"><?= esc_html( get_admin_page_title() ); ?></h1> |
|
5 | 5 | <?= $notices; ?> |
6 | - <p><?= __('Add-ons extend the functionality of Site Reviews.', 'site-reviews'); ?></p> |
|
6 | + <p><?= __( 'Add-ons extend the functionality of Site Reviews.', 'site-reviews' ); ?></p> |
|
7 | 7 | <div class="glsr-addons wp-clearfix"> |
8 | 8 | <?php |
9 | - $template->render('partials/addons/addon', [ |
|
9 | + $template->render( 'partials/addons/addon', [ |
|
10 | 10 | 'context' => [ |
11 | - 'description' => __('Allow your site visitors to submit images with their reviews.', 'site-reviews'), |
|
11 | + 'description' => __( 'Allow your site visitors to submit images with their reviews.', 'site-reviews' ), |
|
12 | 12 | 'link' => 'https://niftyplugins.com/plugins/images/', |
13 | 13 | 'slug' => 'images', |
14 | 14 | 'title' => 'Images', |
15 | 15 | ], |
16 | 16 | 'plugin' => 'site-reviews-images/site-reviews-images.php', |
17 | - ]); |
|
17 | + ] ); |
|
18 | 18 | ?> |
19 | 19 | </div> |
20 | 20 | </div> |
@@ -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#!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#!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,23 +1,23 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-welcome wrap about-wrap about-wrap-content"> |
4 | 4 | <h1>Welcome to <?= glsr()->name; ?></h1> |
5 | 5 | <div class="about-text">Site Reviews is a free WordPress review plugin with advanced features that makes it easy to manage reviews on your website. Follow the instructions below to get started!</div> |
6 | 6 | <div class="wp-badge">Version <?= glsr()->version; ?></div> |
7 | 7 | <p class="about-buttons"> |
8 | - <a class="button" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation'); ?>">Documentation</a> |
|
8 | + <a class="button" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation' ); ?>">Documentation</a> |
|
9 | 9 | <a class="button" href="https://wordpress.org/support/plugin/site-reviews/">Support</a> |
10 | 10 | <a target="_blank" class="button" href="https://www.facebook.com/sharer/sharer.php?u=https%3A//geminilabs.io/site-reviews"><span class="dashicons dashicons-facebook-alt"></span> Share</a> |
11 | 11 | <a target="_blank" class="button" href="https://twitter.com/intent/tweet?text=Site Reviews is a fantastic WordPress review plugin with advanced features that makes it easy to manage reviews on your website.&url=https://geminilabs.io/site-reviews&hashtags=WordPress,reviewplugins,"><span class="dashicons dashicons-twitter"></span> Tweet</a> |
12 | 12 | </p> |
13 | 13 | <nav class="glsr-nav-tab-wrapper nav-tab-wrapper"> |
14 | - <?php foreach ($tabs as $id => $title) : ?> |
|
14 | + <?php foreach( $tabs as $id => $title ) : ?> |
|
15 | 15 | <a class="glsr-nav-tab nav-tab" href="#<?= $id; ?>"><?= $title; ?></a> |
16 | 16 | <?php endforeach; ?> |
17 | 17 | </nav> |
18 | - <?php foreach ($tabs as $id => $title) : ?> |
|
18 | + <?php foreach( $tabs as $id => $title ) : ?> |
|
19 | 19 | <div class="glsr-nav-view ui-tabs-hide" id="<?= $id; ?>"> |
20 | - <?php $template->render('pages/welcome/'.$id, $data); ?> |
|
20 | + <?php $template->render( 'pages/welcome/'.$id, $data ); ?> |
|
21 | 21 | </div> |
22 | 22 | <?php endforeach; ?> |
23 | 23 | <input type="hidden" name="_active_tab"> |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <div class="notice is-dismissible glsr-notice" data-dismiss="rebusify"> |
2 | 2 | <div class="glsr-notice-icon"> |
3 | - <img width="96" height="96" src="<?= glsr()->url('assets/images/rebusify-badge.png'); ?>"> |
|
3 | + <img width="96" height="96" src="<?= glsr()->url( 'assets/images/rebusify-badge.png' ); ?>"> |
|
4 | 4 | </div> |
5 | 5 | <div class="glsr-notice-content"> |
6 | 6 | <h3>Validate Your Reviews on the Blockchain With the Rebusify Confidence System</h3> |
7 | - <p>Site Reviews now integrates with the Rebusify Confidence System which uses blockchain technology to verify to your visitors and customers that your reviews are authentic. Simply create a free Rebusify account and <a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#!general'); ?>">enter your credentials in the Settings</a>. Site Reviews will take care of the rest!</p> |
|
7 | + <p>Site Reviews now integrates with the Rebusify Confidence System which uses blockchain technology to verify to your visitors and customers that your reviews are authentic. Simply create a free Rebusify account and <a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#!general' ); ?>">enter your credentials in the Settings</a>. Site Reviews will take care of the rest!</p> |
|
8 | 8 | <a href="https://rebusify.com/plans?ref=105" class="button" target="_blank">Create Your Rebusify Account</a> |
9 | 9 | </div> |
10 | 10 | </div> |
@@ -1,5 +1,5 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | -<strong><a href="<?= esc_url(admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#!licenses')); ?>"> |
|
4 | - <?= __('Enter a valid license key for automatic updates.', 'site-reviews'); ?> |
|
3 | +<strong><a href="<?= esc_url( admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#!licenses' ) ); ?>"> |
|
4 | + <?= __( 'Enter a valid license key for automatic updates.', 'site-reviews' ); ?> |
|
5 | 5 | </a></strong> |
@@ -17,18 +17,18 @@ discard block |
||
17 | 17 | * @return array |
18 | 18 | * @callback register_setting |
19 | 19 | */ |
20 | - public function callbackRegisterSettings($input) |
|
20 | + public function callbackRegisterSettings( $input ) |
|
21 | 21 | { |
22 | - $settings = Arr::consolidateArray($input); |
|
23 | - if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
24 | - $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
25 | - $options = $this->sanitizeGeneral($input, $options); |
|
26 | - $options = $this->sanitizeLicenses($input, $options); |
|
27 | - $options = $this->sanitizeSubmissions($input, $options); |
|
28 | - $options = $this->sanitizeTranslations($input, $options); |
|
29 | - $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
30 | - if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
31 | - glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
22 | + $settings = Arr::consolidateArray( $input ); |
|
23 | + if( 1 === count( $settings ) && array_key_exists( 'settings', $settings ) ) { |
|
24 | + $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input ); |
|
25 | + $options = $this->sanitizeGeneral( $input, $options ); |
|
26 | + $options = $this->sanitizeLicenses( $input, $options ); |
|
27 | + $options = $this->sanitizeSubmissions( $input, $options ); |
|
28 | + $options = $this->sanitizeTranslations( $input, $options ); |
|
29 | + $options = apply_filters( 'site-reviews/settings/callback', $options, $settings ); |
|
30 | + if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) { |
|
31 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
32 | 32 | } |
33 | 33 | return $options; |
34 | 34 | } |
@@ -41,77 +41,77 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function registerSettings() |
43 | 43 | { |
44 | - register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
44 | + register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
45 | 45 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
46 | - ]); |
|
46 | + ] ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @return array |
51 | 51 | */ |
52 | - protected function sanitizeGeneral(array $input, array $options) |
|
52 | + protected function sanitizeGeneral( array $input, array $options ) |
|
53 | 53 | { |
54 | 54 | $key = 'settings.general'; |
55 | - $inputForm = Arr::get($input, $key); |
|
56 | - if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) { |
|
57 | - $options = Arr::set($options, $key.'.multilingual', ''); |
|
55 | + $inputForm = Arr::get( $input, $key ); |
|
56 | + if( !$this->hasMultilingualIntegration( Arr::get( $inputForm, 'multilingual' ) ) ) { |
|
57 | + $options = Arr::set( $options, $key.'.multilingual', '' ); |
|
58 | 58 | } |
59 | - if ('' == trim(Arr::get($inputForm, 'notification_message'))) { |
|
60 | - $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message'); |
|
61 | - $options = Arr::set($options, $key.'.notification_message', $defaultValue); |
|
59 | + if( '' == trim( Arr::get( $inputForm, 'notification_message' ) ) ) { |
|
60 | + $defaultValue = Arr::get( glsr()->defaults, $key.'.notification_message' ); |
|
61 | + $options = Arr::set( $options, $key.'.notification_message', $defaultValue ); |
|
62 | 62 | } |
63 | - $defaultValue = Arr::get($inputForm, 'notifications', []); |
|
64 | - $options = Arr::set($options, $key.'.notifications', $defaultValue); |
|
63 | + $defaultValue = Arr::get( $inputForm, 'notifications', [] ); |
|
64 | + $options = Arr::set( $options, $key.'.notifications', $defaultValue ); |
|
65 | 65 | return $options; |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @return array |
70 | 70 | */ |
71 | - protected function sanitizeLicenses(array $input, array $options) |
|
71 | + protected function sanitizeLicenses( array $input, array $options ) |
|
72 | 72 | { |
73 | 73 | $key = 'settings.licenses'; |
74 | - $licenses = Arr::consolidateArray(Arr::get($input, $key)); |
|
75 | - foreach ($licenses as $slug => &$license) { |
|
76 | - $license = $this->verifyLicense($license, $slug); |
|
74 | + $licenses = Arr::consolidateArray( Arr::get( $input, $key ) ); |
|
75 | + foreach( $licenses as $slug => &$license ) { |
|
76 | + $license = $this->verifyLicense( $license, $slug ); |
|
77 | 77 | } |
78 | - $options = Arr::set($options, $key, $licenses); |
|
78 | + $options = Arr::set( $options, $key, $licenses ); |
|
79 | 79 | return $options; |
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * @return array |
84 | 84 | */ |
85 | - protected function sanitizeSubmissions(array $input, array $options) |
|
85 | + protected function sanitizeSubmissions( array $input, array $options ) |
|
86 | 86 | { |
87 | 87 | $key = 'settings.submissions'; |
88 | - $inputForm = Arr::get($input, $key); |
|
88 | + $inputForm = Arr::get( $input, $key ); |
|
89 | 89 | $defaultValue = isset($inputForm['required']) |
90 | 90 | ? $inputForm['required'] |
91 | 91 | : []; |
92 | - $options = Arr::set($options, $key.'.required', $defaultValue); |
|
92 | + $options = Arr::set( $options, $key.'.required', $defaultValue ); |
|
93 | 93 | return $options; |
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
97 | 97 | * @return array |
98 | 98 | */ |
99 | - protected function sanitizeTranslations(array $input, array $options) |
|
99 | + protected function sanitizeTranslations( array $input, array $options ) |
|
100 | 100 | { |
101 | 101 | $key = 'settings.strings'; |
102 | - $inputForm = Arr::consolidateArray(Arr::get($input, $key)); |
|
103 | - if (!empty($inputForm)) { |
|
104 | - $options = Arr::set($options, $key, array_values(array_filter($inputForm))); |
|
102 | + $inputForm = Arr::consolidateArray( Arr::get( $input, $key ) ); |
|
103 | + if( !empty($inputForm) ) { |
|
104 | + $options = Arr::set( $options, $key, array_values( array_filter( $inputForm ) ) ); |
|
105 | 105 | $allowedTags = [ |
106 | 106 | 'a' => ['class' => [], 'href' => [], 'target' => []], |
107 | 107 | 'span' => ['class' => []], |
108 | 108 | ]; |
109 | - array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
110 | - if (isset($string['s2'])) { |
|
111 | - $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
109 | + array_walk( $options['settings']['strings'], function( &$string ) use ($allowedTags) { |
|
110 | + if( isset($string['s2']) ) { |
|
111 | + $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
|
112 | 112 | } |
113 | - if (isset($string['p2'])) { |
|
114 | - $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
113 | + if( isset($string['p2']) ) { |
|
114 | + $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
|
115 | 115 | } |
116 | 116 | }); |
117 | 117 | } |
@@ -122,24 +122,24 @@ discard block |
||
122 | 122 | * @param string $integrationSlug |
123 | 123 | * @return bool |
124 | 124 | */ |
125 | - protected function hasMultilingualIntegration($integrationSlug) |
|
125 | + protected function hasMultilingualIntegration( $integrationSlug ) |
|
126 | 126 | { |
127 | - $integration = glsr(Multilingual::class)->getIntegration($integrationSlug); |
|
128 | - if (!$integration) { |
|
127 | + $integration = glsr( Multilingual::class )->getIntegration( $integrationSlug ); |
|
128 | + if( !$integration ) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | - if (!$integration->isActive()) { |
|
132 | - glsr(Notice::class)->addError(sprintf( |
|
133 | - __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
131 | + if( !$integration->isActive() ) { |
|
132 | + glsr( Notice::class )->addError( sprintf( |
|
133 | + __( 'Please install/activate the %s plugin to enable integration.', 'site-reviews' ), |
|
134 | 134 | $integration->pluginName |
135 | - )); |
|
135 | + ) ); |
|
136 | 136 | return false; |
137 | - } elseif (!$integration->isSupported()) { |
|
138 | - glsr(Notice::class)->addError(sprintf( |
|
139 | - __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
137 | + } elseif( !$integration->isSupported() ) { |
|
138 | + glsr( Notice::class )->addError( sprintf( |
|
139 | + __( 'Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews' ), |
|
140 | 140 | $integration->pluginName, |
141 | 141 | $integration->supportedVersion |
142 | - )); |
|
142 | + ) ); |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | return true; |
@@ -150,21 +150,21 @@ discard block |
||
150 | 150 | * @param string $slug |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - protected function verifyLicense($license, $slug) |
|
153 | + protected function verifyLicense( $license, $slug ) |
|
154 | 154 | { |
155 | 155 | try { |
156 | - $addon = glsr($slug); |
|
157 | - $updater = new Updater($addon->update_url, $addon->file, [ |
|
156 | + $addon = glsr( $slug ); |
|
157 | + $updater = new Updater( $addon->update_url, $addon->file, [ |
|
158 | 158 | 'license' => $license, |
159 | 159 | 'testedTo' => $addon->testedTo, |
160 | - ]); |
|
161 | - if (!$updater->isLicenseValid()) { |
|
162 | - throw new Exception('Invalid license: '.$license.' ('.$addon->id.')'); |
|
160 | + ] ); |
|
161 | + if( !$updater->isLicenseValid() ) { |
|
162 | + throw new Exception( 'Invalid license: '.$license.' ('.$addon->id.')' ); |
|
163 | 163 | } |
164 | - } catch (Exception $e) { |
|
164 | + } catch( Exception $e ) { |
|
165 | 165 | $license = ''; |
166 | - glsr_log()->debug($e->getMessage()); |
|
167 | - glsr(Notice::class)->addError(__('A license you entered was invalid.', 'site-reviews')); |
|
166 | + glsr_log()->debug( $e->getMessage() ); |
|
167 | + glsr( Notice::class )->addError( __( 'A license you entered was invalid.', 'site-reviews' ) ); |
|
168 | 168 | } |
169 | 169 | return $license; |
170 | 170 | } |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public $reviews; |
26 | 26 | |
27 | - public function __construct(array $reviews, $maxPageCount, array $args) |
|
27 | + public function __construct( array $reviews, $maxPageCount, array $args ) |
|
28 | 28 | { |
29 | 29 | $this->args = $args; |
30 | 30 | $this->max_num_pages = $maxPageCount; |
31 | 31 | $this->reviews = $reviews; |
32 | - parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); |
|
32 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __toString() |
39 | 39 | { |
40 | - return (string) $this->build(); |
|
40 | + return (string)$this->build(); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function build() |
47 | 47 | { |
48 | - $args = glsr(SiteReviewsDefaults::class)->merge($this->args); |
|
49 | - return glsr(SiteReviewsPartial::class)->build($args, $this); |
|
48 | + $args = glsr( SiteReviewsDefaults::class )->merge( $this->args ); |
|
49 | + return glsr( SiteReviewsPartial::class )->build( $args, $this ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @param mixed $key |
54 | 54 | * @return mixed |
55 | 55 | */ |
56 | - public function offsetGet($key) |
|
56 | + public function offsetGet( $key ) |
|
57 | 57 | { |
58 | - if (array_key_exists($key, $this->reviews)) { |
|
58 | + if( array_key_exists( $key, $this->reviews ) ) { |
|
59 | 59 | return $this->reviews[$key]; |
60 | 60 | } |
61 | - return property_exists($this, $key) |
|
61 | + return property_exists( $this, $key ) |
|
62 | 62 | ? $this->$key |
63 | 63 | : null; |
64 | 64 | } |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | * @param string $templatePath |
12 | 12 | * @return void|string |
13 | 13 | */ |
14 | - public function build($templatePath, array $data = []) |
|
14 | + public function build( $templatePath, array $data = [] ) |
|
15 | 15 | { |
16 | - $data = $this->normalize($data); |
|
17 | - $path = Str::removePrefix('templates/', $templatePath); |
|
18 | - $template = glsr()->build($templatePath, $data); |
|
19 | - $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
20 | - $template = $this->interpolate($template, $data, $path); |
|
21 | - $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
22 | - $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
16 | + $data = $this->normalize( $data ); |
|
17 | + $path = Str::removePrefix( 'templates/', $templatePath ); |
|
18 | + $template = glsr()->build( $templatePath, $data ); |
|
19 | + $template = apply_filters( 'site-reviews/build/template/'.$path, $template, $data ); |
|
20 | + $template = $this->interpolate( $template, $data, $path ); |
|
21 | + $template = apply_filters( 'site-reviews/rendered/template', $template, $templatePath, $data ); |
|
22 | + $template = apply_filters( 'site-reviews/rendered/template/'.$path, $template, $data ); |
|
23 | 23 | return $template; |
24 | 24 | } |
25 | 25 | |
@@ -29,37 +29,37 @@ discard block |
||
29 | 29 | * @param string $templatePath |
30 | 30 | * @return string |
31 | 31 | */ |
32 | - public function interpolate($template, array $data = [], $templatePath) |
|
32 | + public function interpolate( $template, array $data = [], $templatePath ) |
|
33 | 33 | { |
34 | - $context = $this->normalizeContext(Arr::get($data, 'context', [])); |
|
35 | - $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
36 | - foreach ($context as $key => $value) { |
|
34 | + $context = $this->normalizeContext( Arr::get( $data, 'context', [] ) ); |
|
35 | + $context = apply_filters( 'site-reviews/interpolate/'.$templatePath, $context, $template, $data ); |
|
36 | + foreach( $context as $key => $value ) { |
|
37 | 37 | $template = strtr( |
38 | 38 | $template, |
39 | - array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
39 | + array_fill_keys( ['{'.$key.'}', '{{ '.$key.' }}'], $value ) |
|
40 | 40 | ); |
41 | 41 | } |
42 | - return trim($template); |
|
42 | + return trim( $template ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @param string $templatePath |
47 | 47 | * @return void|string |
48 | 48 | */ |
49 | - public function render($templatePath, array $data = []) |
|
49 | + public function render( $templatePath, array $data = [] ) |
|
50 | 50 | { |
51 | - echo $this->build($templatePath, $data); |
|
51 | + echo $this->build( $templatePath, $data ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @return array |
56 | 56 | */ |
57 | - protected function normalize(array $data) |
|
57 | + protected function normalize( array $data ) |
|
58 | 58 | { |
59 | 59 | $arrayKeys = ['context', 'globals']; |
60 | - $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
61 | - foreach ($arrayKeys as $key) { |
|
62 | - if (is_array($data[$key])) { |
|
60 | + $data = wp_parse_args( $data, array_fill_keys( $arrayKeys, [] ) ); |
|
61 | + foreach( $arrayKeys as $key ) { |
|
62 | + if( is_array( $data[$key] ) ) { |
|
63 | 63 | continue; |
64 | 64 | } |
65 | 65 | $data[$key] = []; |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @return array |
72 | 72 | */ |
73 | - protected function normalizeContext(array $context) |
|
73 | + protected function normalizeContext( array $context ) |
|
74 | 74 | { |
75 | - $context = array_filter($context, function ($value) { |
|
76 | - return !is_array($value) && !is_object($value); |
|
75 | + $context = array_filter( $context, function( $value ) { |
|
76 | + return !is_array( $value ) && !is_object( $value ); |
|
77 | 77 | }); |
78 | - return array_map(function ($value) { |
|
79 | - return (string) $value; |
|
80 | - }, $context); |
|
78 | + return array_map( function( $value ) { |
|
79 | + return (string)$value; |
|
80 | + }, $context ); |
|
81 | 81 | } |
82 | 82 | } |
@@ -18,19 +18,19 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public function build(array $args = []) |
|
21 | + public function build( array $args = [] ) |
|
22 | 22 | { |
23 | - $this->args = $this->normalize($args); |
|
24 | - if ($this->args['total'] < 2) { |
|
23 | + $this->args = $this->normalize( $args ); |
|
24 | + if( $this->args['total'] < 2 ) { |
|
25 | 25 | return ''; |
26 | 26 | } |
27 | - return glsr(Template::class)->build('templates/pagination', [ |
|
27 | + return glsr( Template::class )->build( 'templates/pagination', [ |
|
28 | 28 | 'context' => [ |
29 | - 'links' => apply_filters('site-reviews/paginate_links', $this->buildLinks(), $this->args), |
|
29 | + 'links' => apply_filters( 'site-reviews/paginate_links', $this->buildLinks(), $this->args ), |
|
30 | 30 | 'loader' => '<div class="glsr-loader"></div>', |
31 | - 'screen_reader_text' => __('Site Reviews navigation', 'site-reviews'), |
|
31 | + 'screen_reader_text' => __( 'Site Reviews navigation', 'site-reviews' ), |
|
32 | 32 | ], |
33 | - ]); |
|
33 | + ] ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,24 +38,24 @@ discard block |
||
38 | 38 | */ |
39 | 39 | protected function buildLinks() |
40 | 40 | { |
41 | - $args = glsr(Style::class)->paginationArgs($this->args); |
|
42 | - if ('array' == $args['type']) { |
|
41 | + $args = glsr( Style::class )->paginationArgs( $this->args ); |
|
42 | + if( 'array' == $args['type'] ) { |
|
43 | 43 | $args['type'] = 'plain'; |
44 | 44 | } |
45 | - return paginate_links($args); |
|
45 | + return paginate_links( $args ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @return array |
50 | 50 | */ |
51 | - protected function normalize(array $args) |
|
51 | + protected function normalize( array $args ) |
|
52 | 52 | { |
53 | - if ($baseUrl = Arr::get($args, 'baseUrl')) { |
|
53 | + if( $baseUrl = Arr::get( $args, 'baseUrl' ) ) { |
|
54 | 54 | $args['base'] = $baseUrl.'%_%'; |
55 | 55 | } |
56 | - return wp_parse_args(array_filter($args), [ |
|
57 | - 'current' => glsr(QueryBuilder::class)->getPaged(), |
|
56 | + return wp_parse_args( array_filter( $args ), [ |
|
57 | + 'current' => glsr( QueryBuilder::class )->getPaged(), |
|
58 | 58 | 'total' => 1, |
59 | - ]); |
|
59 | + ] ); |
|
60 | 60 | } |
61 | 61 | } |